From patchwork Mon May 8 16:17:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 9716443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F13760387 for ; Mon, 8 May 2017 16:20:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E66E203B9 for ; Mon, 8 May 2017 16:20:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 330FE205A8; Mon, 8 May 2017 16:20:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96BC2203B9 for ; Mon, 8 May 2017 16:20:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7lM3-0004VR-PF; Mon, 08 May 2017 16:17:47 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7lM1-0004VL-TZ for xen-devel@lists.xen.org; Mon, 08 May 2017 16:17:46 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 3A/5C-01709-92A90195; Mon, 08 May 2017 16:17:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXitHRDpK7aLIF Ig/uT5C2WfFzM4sDocXT3b6YAxijWzLyk/IoE1owPjavZCv7LVTxcOZmpgfGoZBcjJ4eEgL/E vAnTWUBsNgEDiVuXvjOD2CICshKru+awg9jMAtUSBxb2MYLYwgJmEo2H5oLZLAIqEpsv/GICs XkFPCXetp1hhpgpJ3HzXCeYLSSgJvF2+RkWiBpBiZMzn7BAzJSQOPjiBfMERu5ZSFKzkKQWMD KtYtQoTi0qSy3SNTLWSyrKTM8oyU3MzNE1NDDVy00tLk5MT81JTCrWS87P3cQIDIZ6BgbGHYw 72v0OMUpyMCmJ8voUC0QK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuCdNBMoJ1iUmp5akZaZAwxL mLQEB4+SCK8qSJq3uCAxtzgzHSJ1ilGXo6/j43smIZa8/LxUKXFeHpAiAZCijNI8uBGwGLnEK CslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZjXCWQKT2ZeCdymV0BHMAEdEcgAdkRJIkJKqoHR5w mHUJvFtuRUxkdr2vTSS3hOLDH/PPPR/9qd2362i39yZsgxvbZbJE3ry49NNktSVi41s06f8fn PidNCDs26Zvvknvtfusn+kLutce5Lw8rO3Ttjr0V0O2yty0h66bS53DzQbqnn3Ac1jvvmP/KQ imvcaJR2JbhxsusZ/QVurudrK7qPHZBRYinOSDTUYi4qTgQAPlUiq4wCAAA= X-Env-Sender: prvs=29411ba52=ross.lagerwall@citrix.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1494260260!81075529!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16460 invoked from network); 8 May 2017 16:17:42 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-16.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 8 May 2017 16:17:42 -0000 X-IronPort-AV: E=Sophos;i="5.38,309,1491264000"; d="scan'208";a="422704890" From: Ross Lagerwall To: Date: Mon, 8 May 2017 17:17:18 +0100 Message-ID: <1494260238-30713-1-git-send-email-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Cc: Ross Lagerwall , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH] x86/efi: Reserve EFI properties table X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some EFI firmware implementations may place the EFI properties table in RAM marked as BootServicesData, which Xen does not consider as reserved. When dom0 tries to access the EFI properties table (which Linux >= 4.4 does), it crashes with a page fault. Fix this by unconditionally marking the EFI properties table as reserved in the E820, much like is done with the dmi regions. Signed-off-by: Ross Lagerwall Reviewed-by: Andrew Cooper Reviewed-by: Konrad Rzeszutek Wilk --- xen/arch/x86/efi/efi-boot.h | 8 ++++++++ xen/common/efi/boot.c | 20 ++++++++++++++++++++ xen/common/efi/efi.h | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 34537d4..36ae464 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -209,6 +209,14 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable, } } + if ( efi_properties_tbl_addr && efi_properties_tbl_size ) + { + ++e; + e->addr = efi_properties_tbl_addr; + e->size = efi_properties_tbl_size; + e->type = E820_RESERVED; + ++e820_raw.nr_map; + } } static void *__init efi_arch_allocate_mmap_buffer(UINTN map_size) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index daf0c80..1fb396b 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -40,6 +40,8 @@ { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } #define APPLE_PROPERTIES_PROTOCOL_GUID \ { 0x91bd12fe, 0xf6c3, 0x44fb, { 0xa5, 0xb7, 0x51, 0x22, 0xab, 0x30, 0x3a, 0xe0} } +#define EFI_PROPERTIES_TABLE_GUID \ + { 0x880aaca3, 0x4adc, 0x4a04, { 0x90, 0x79, 0xb7, 0x47, 0x34, 0x08, 0x25, 0xe5} } typedef EFI_STATUS (/* _not_ EFIAPI */ *EFI_SHIM_LOCK_VERIFY) ( @@ -171,6 +173,15 @@ static char __section(".bss.page_aligned") __aligned(PAGE_SIZE) ebmalloc_mem[EBMALLOC_SIZE]; static unsigned long __initdata ebmalloc_allocated; +struct efi_properties_table { + u32 version; + u32 length; + u64 memory_protection_attribute; +}; + +u64 __initdata efi_properties_tbl_addr; +u32 __initdata efi_properties_tbl_size; + /* EFI boot allocator. */ static void __init __maybe_unused *ebmalloc(size_t size) { @@ -809,6 +820,7 @@ static void __init efi_tables(void) static EFI_GUID __initdata mps_guid = MPS_TABLE_GUID; static EFI_GUID __initdata smbios_guid = SMBIOS_TABLE_GUID; static EFI_GUID __initdata smbios3_guid = SMBIOS3_TABLE_GUID; + static EFI_GUID __initdata properties_guid = EFI_PROPERTIES_TABLE_GUID; if ( match_guid(&acpi2_guid, &efi_ct[i].VendorGuid) ) efi.acpi20 = (long)efi_ct[i].VendorTable; @@ -820,6 +832,14 @@ static void __init efi_tables(void) efi.smbios = (long)efi_ct[i].VendorTable; if ( match_guid(&smbios3_guid, &efi_ct[i].VendorGuid) ) efi.smbios3 = (long)efi_ct[i].VendorTable; + if ( match_guid(&properties_guid, &efi_ct[i].VendorGuid) ) + { + struct efi_properties_table *properties; + + efi_properties_tbl_addr = (long)efi_ct[i].VendorTable; + properties = (struct efi_properties_table *)efi_properties_tbl_addr; + efi_properties_tbl_size = properties->length; + } } #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */ diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h index 6b9c56e..e509111 100644 --- a/xen/common/efi/efi.h +++ b/xen/common/efi/efi.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -39,3 +40,6 @@ extern UINT64 efi_boot_max_var_store_size, efi_boot_remain_var_store_size, extern UINT64 efi_apple_properties_addr; extern UINTN efi_apple_properties_len; + +extern u64 __initdata efi_properties_tbl_addr; +extern u32 __initdata efi_properties_tbl_size;