From: Sai Praneeth <[email protected]>

During early boot phase EFI_BOOT_SERVICES_<CODE/DATA> regions are marked
as reserved by kernel (see efi_reserve_boot_services()) and hence are
not used by kernel for boot purposes. When EFI_WARN_ON_ILLEGAL_ACCESSES
is enabled, page faults triggered by firmware due to illegal accesses to
EFI_BOOT_SERVICES_<CODE/DATA> regions are dynamically fixed by kernel by
mapping these regions on demand. This resolution assumes that
EFI_BOOT_SERVICES_<CODE/DATA> regions are intact i.e. no one has ever
used these regions except firmware. Hence, to make this assumption true,
don't call efi_free_boot_services() if EFI_WARN_ON_ILLEGAL_ACCESSES is
enabled.

Signed-off-by: Sai Praneeth Prakhya <[email protected]>
Suggested-by: Matt Fleming <[email protected]>
Based-on-code-from: Ricardo Neri <[email protected]>
Cc: Al Stone <[email protected]>
Cc: Lee Chun-Yi <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Bhupesh Sharma <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
---
 init/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/init/main.c b/init/main.c
index 3b4ada11ed52..dce0520861a1 100644
--- a/init/main.c
+++ b/init/main.c
@@ -730,7 +730,8 @@ asmlinkage __visible void __init start_kernel(void)
        arch_post_acpi_subsys_init();
        sfi_init_late();
 
-       if (efi_enabled(EFI_RUNTIME_SERVICES)) {
+       if (efi_enabled(EFI_RUNTIME_SERVICES) &&
+           !IS_ENABLED(CONFIG_EFI_WARN_ON_ILLEGAL_ACCESSES)) {
                efi_free_boot_services();
        }
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to