efi: Introduce EFI_NX_PE_DATA bit and set it from properties table
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 23 Sep 2015 14:29:34 +0000 (07:29 -0700)
committerMatt Fleming <matt.fleming@intel.com>
Mon, 12 Oct 2015 13:20:07 +0000 (14:20 +0100)
UEFI v2.5 introduces a runtime memory protection feature that splits
PE/COFF runtime images into separate code and data regions. Since this
may require special handling by the OS, allocate a EFI_xxx bit to
keep track of whether this feature is currently active or not.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
drivers/firmware/efi/efi.c
include/linux/efi.h

index c297d78f50fd4eaf18b5b298b6ea31e81b385f65..31fc864eb037ca9626a332988a7e8a46ab56a310 100644 (file)
@@ -426,6 +426,24 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz,
        }
        pr_cont("\n");
        set_bit(EFI_CONFIG_TABLES, &efi.flags);
+
+       /* Parse the EFI Properties table if it exists */
+       if (efi.properties_table != EFI_INVALID_TABLE_ADDR) {
+               efi_properties_table_t *tbl;
+
+               tbl = early_memremap(efi.properties_table, sizeof(*tbl));
+               if (tbl == NULL) {
+                       pr_err("Could not map Properties table!\n");
+                       return -ENOMEM;
+               }
+
+               if (tbl->memory_protection_attribute &
+                   EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA)
+                       set_bit(EFI_NX_PE_DATA, &efi.flags);
+
+               early_memunmap(tbl, sizeof(*tbl));
+       }
+
        return 0;
 }
 
index d6a9bee755f247b6cc9225766355e2d1a510b191..fa5106c2f9f5f5c1f152ed148205f11a322ba579 100644 (file)
@@ -973,6 +973,7 @@ extern int __init efi_setup_pcdp_console(char *);
 #define EFI_PARAVIRT           6       /* Access is via a paravirt interface */
 #define EFI_ARCH_1             7       /* First arch-specific bit */
 #define EFI_DBG                        8       /* Print additional debug info at runtime */
+#define EFI_NX_PE_DATA         9       /* Can runtime data regions be mapped non-executable? */
 
 #ifdef CONFIG_EFI
 /*