x86/efi: Implement arch_ima_efi_boot_mode() in source file
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 12 Jan 2024 09:44:38 +0000 (10:44 +0100)
committerBorislav Petkov (AMD) <bp@alien8.de>
Tue, 30 Jan 2024 14:17:17 +0000 (15:17 +0100)
The x86 implementation of arch_ima_efi_boot_mode() uses the global
boot_param state. Move it into a source file to clean up the header.
Avoid potential rebuilds of unrelated source files if boot_params
changes.

Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20240112095000.8952-4-tzimmermann@suse.de
arch/x86/include/asm/efi.h
arch/x86/platform/efi/efi.c

index a5d7a83e4c2a81f4a57b870973598ceb608c340b..1dc600fa3ba536e904027df726d4d33360f0fe77 100644 (file)
@@ -409,8 +409,9 @@ extern int __init efi_memmap_split_count(efi_memory_desc_t *md,
 extern void __init efi_memmap_insert(struct efi_memory_map *old_memmap,
                                     void *buf, struct efi_mem_range *mem);
 
-#define arch_ima_efi_boot_mode \
-       ({ extern struct boot_params boot_params; boot_params.secure_boot; })
+extern enum efi_secureboot_mode __x86_ima_efi_boot_mode(void);
+
+#define arch_ima_efi_boot_mode __x86_ima_efi_boot_mode()
 
 #ifdef CONFIG_EFI_RUNTIME_MAP
 int efi_get_runtime_map_size(void);
index e9f99c56f3ce625d0b568124091ff3281dd03b87..f090ec972d7b60c18e975a00a1aba8340290f0d4 100644 (file)
@@ -950,3 +950,8 @@ umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
        }
        return attr->mode;
 }
+
+enum efi_secureboot_mode __x86_ima_efi_boot_mode(void)
+{
+       return boot_params.secure_boot;
+}