Эх сурвалжийг харах

x86/efi: Fix 32-bit fallout

We do not enable the new efi memmap on 32-bit and thus we need to run
runtime_code_page_mkexec() unconditionally there. Fix that.

Reported-and-tested-by: Lejun Zhu <lejun.zhu@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Borislav Petkov 11 жил өмнө
parent
commit
c55d016f7a

+ 2 - 0
arch/x86/include/asm/efi.h

@@ -132,6 +132,8 @@ extern void __init efi_map_region_fixed(efi_memory_desc_t *md);
 extern void efi_sync_low_kernel_mappings(void);
 extern void efi_sync_low_kernel_mappings(void);
 extern void efi_setup_page_tables(void);
 extern void efi_setup_page_tables(void);
 extern void __init old_map_region(efi_memory_desc_t *md);
 extern void __init old_map_region(efi_memory_desc_t *md);
+extern void __init runtime_code_page_mkexec(void);
+extern void __init efi_runtime_mkexec(void);
 
 
 struct efi_setup_data {
 struct efi_setup_data {
 	u64 fw_vendor;
 	u64 fw_vendor;

+ 2 - 3
arch/x86/platform/efi/efi.c

@@ -792,7 +792,7 @@ void __init efi_set_executable(efi_memory_desc_t *md, bool executable)
 		set_memory_nx(addr, npages);
 		set_memory_nx(addr, npages);
 }
 }
 
 
-static void __init runtime_code_page_mkexec(void)
+void __init runtime_code_page_mkexec(void)
 {
 {
 	efi_memory_desc_t *md;
 	efi_memory_desc_t *md;
 	void *p;
 	void *p;
@@ -1069,8 +1069,7 @@ void __init efi_enter_virtual_mode(void)
 	efi.update_capsule = virt_efi_update_capsule;
 	efi.update_capsule = virt_efi_update_capsule;
 	efi.query_capsule_caps = virt_efi_query_capsule_caps;
 	efi.query_capsule_caps = virt_efi_query_capsule_caps;
 
 
-	if (efi_enabled(EFI_OLD_MEMMAP) && (__supported_pte_mask & _PAGE_NX))
-		runtime_code_page_mkexec();
+	efi_runtime_mkexec();
 
 
 	kfree(new_memmap);
 	kfree(new_memmap);
 
 

+ 6 - 0
arch/x86/platform/efi/efi_32.c

@@ -77,3 +77,9 @@ void efi_call_phys_epilog(void)
 
 
 	local_irq_restore(efi_rt_eflags);
 	local_irq_restore(efi_rt_eflags);
 }
 }
+
+void __init efi_runtime_mkexec(void)
+{
+	if (__supported_pte_mask & _PAGE_NX)
+		runtime_code_page_mkexec();
+}

+ 9 - 0
arch/x86/platform/efi/efi_64.c

@@ -233,3 +233,12 @@ void __init parse_efi_setup(u64 phys_addr, u32 data_len)
 {
 {
 	efi_setup = phys_addr + sizeof(struct setup_data);
 	efi_setup = phys_addr + sizeof(struct setup_data);
 }
 }
+
+void __init efi_runtime_mkexec(void)
+{
+	if (!efi_enabled(EFI_OLD_MEMMAP))
+		return;
+
+	if (__supported_pte_mask & _PAGE_NX)
+		runtime_code_page_mkexec();
+}