From nobody Sat May 4 12:11:01 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1570891080; cv=none; d=zoho.com; s=zohoarc; b=hzIK5lxlveY7NRHyeITpceUPhd8jATqkjFW1p/DMye/XZghh+Nci6i9e0/qzhqnANft/+NJfUC3ZnwRZr0B70JIWrlEX4rDkXz6G0CtSuemtqJsJobZxyJcughbvXYmBlP3T69pmk07aglQ5nO0a5+24NwI9I2bitSpK+TyF0h4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570891080; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IkwqqZW2YCIBfksPtbQ4Q14HdcXFqkm3KW5cvgaT1IQ=; b=fo0FgVHlMcZzNz6d/xGVqXr7Kb164/lI9VNz0aqr3Bu6g/ouAPUQZo8mmbp+BfNxPo6qppnaBJfSad3u77kwozOgttlhw3017akH7Dd2md+ET6p07+M4EjBxXUoRAYm9DkXfo9cwPSf+Fbe8U1ljGTP5oCUlV/qzCJg5SGMFhro= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1570891080099845.3237472910715; Sat, 12 Oct 2019 07:38:00 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iJIVW-0000YB-Co; Sat, 12 Oct 2019 14:36:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iJIVV-0000Xz-0G for xen-devel@lists.xenproject.org; Sat, 12 Oct 2019 14:36:33 +0000 Received: from wout4-smtp.messagingengine.com (unknown [64.147.123.20]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ad6ffd1e-ecfd-11e9-9350-12813bfff9fa; Sat, 12 Oct 2019 14:36:29 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 8969857C; Sat, 12 Oct 2019 10:36:28 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 12 Oct 2019 10:36:28 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id 5132DD6005A; Sat, 12 Oct 2019 10:36:27 -0400 (EDT) X-Inumbo-ID: ad6ffd1e-ecfd-11e9-9350-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=8Ruyq0Rj+dxTgFQqWjzHFuXOl5sCUsMV8H9KlttxG g0=; b=Th/drH4OsjtqQ0ERqlV42tn+RsZAbj3d6x2f4h8QkhFu63vSQ5RnPGNWS Yzi+LAUV4fbXjFkhmirhm5XQDkZurK+yvxZRcwgwdK/sF8GqKPMOljk6bWzBIFSO RL1BSe8ObRw7CgeC7GTvuom2eWTXTkc40wv0MezGIFivAegxH5yFzpVM5kwdjAKm eCuipmVo/NsVs++rYsDUKSBzFAh53yQxpmBvqL5bMDaMitqDxErUqQ8gv4GblCh5 lOgP20lxIyZNaKgZLVxRlyBqNi+hLwNXuWQxvyjWKLUX6kIm660eoEep1bUITBje 4j2DFm6ynsDSTrsBM1ZYYZTHR/PBw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrieejgdejlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Sat, 12 Oct 2019 16:36:08 +0200 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 1/2] efi: remove old SetVirtualAddressMap() arrangement X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Remove unused (#ifdef-ed out) code. Reviving it in its current shape won't fly because: - SetVirtualAddressMap() needs to be mapped with 1:1 mapping, which isn't the case at this time - it uses directmap, which is going away soon - it uses directmap, which is mapped with NX, breaking EfiRuntimeServicesC= ode No functional change. Signed-off-by: Marek Marczykowski-G=C3=B3recki Acked-by: Andrew Cooper --- xen/common/efi/boot.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 7919378..cddf3de 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -29,9 +29,6 @@ #undef __ASSEMBLY__ #endif =20 -/* Using SetVirtualAddressMap() is incompatible with kexec: */ -#undef USE_SET_VIRTUAL_ADDRESS_MAP - #define EFI_REVISION(major, minor) (((major) << 16) | (minor)) =20 #define SMBIOS3_TABLE_GUID \ @@ -1099,9 +1096,6 @@ static void __init efi_exit_boot(EFI_HANDLE ImageHand= le, EFI_SYSTEM_TABLE *Syste =20 /* Adjust pointers into EFI. */ efi_ct =3D (void *)efi_ct + DIRECTMAP_VIRT_START; -#ifdef USE_SET_VIRTUAL_ADDRESS_MAP - efi_rs =3D (void *)efi_rs + DIRECTMAP_VIRT_START; -#endif efi_memmap =3D (void *)efi_memmap + DIRECTMAP_VIRT_START; efi_fw_vendor =3D (void *)efi_fw_vendor + DIRECTMAP_VIRT_START; } @@ -1422,7 +1416,6 @@ static int __init parse_efi_param(const char *s) } custom_param("efi", parse_efi_param); =20 -#ifndef USE_SET_VIRTUAL_ADDRESS_MAP static __init void copy_mapping(unsigned long mfn, unsigned long end, bool (*is_valid)(unsigned long smfn, unsigned long emfn)) @@ -1466,7 +1459,6 @@ static bool __init rt_range_valid(unsigned long smfn,= unsigned long emfn) { return true; } -#endif =20 #define INVALID_VIRTUAL_ADDRESS (0xBAAADUL << \ (EFI_PAGE_SHIFT + BITS_PER_LONG - 32)) @@ -1474,13 +1466,11 @@ static bool __init rt_range_valid(unsigned long smf= n, unsigned long emfn) void __init efi_init_memory(void) { unsigned int i; -#ifndef USE_SET_VIRTUAL_ADDRESS_MAP struct rt_extra { struct rt_extra *next; unsigned long smfn, emfn; unsigned int prot; } *extra, *extra_head =3D NULL; -#endif =20 free_ebmalloc_unused_mem(); =20 @@ -1563,7 +1553,6 @@ void __init efi_init_memory(void) printk(XENLOG_ERR "Could not map MFNs %#lx-%#lx\n", smfn, emfn - 1); } -#ifndef USE_SET_VIRTUAL_ADDRESS_MAP else if ( !((desc->PhysicalStart + len - 1) >> (VADDR_BITS - 1)) && (extra =3D xmalloc(struct rt_extra)) !=3D NULL ) { @@ -1574,12 +1563,8 @@ void __init efi_init_memory(void) extra_head =3D extra; desc->VirtualStart =3D desc->PhysicalStart; } -#endif else { -#ifdef USE_SET_VIRTUAL_ADDRESS_MAP - /* XXX allocate e.g. down from FIXADDR_START */ -#endif printk(XENLOG_ERR "No mapping for MFNs %#lx-%#lx\n", smfn, emfn - 1); } @@ -1591,10 +1576,6 @@ void __init efi_init_memory(void) return; } =20 -#ifdef USE_SET_VIRTUAL_ADDRESS_MAP - efi_rs->SetVirtualAddressMap(efi_memmap_size, efi_mdesc_size, - mdesc_ver, efi_memmap); -#else /* Set up 1:1 page tables to do runtime calls in "physical" mode. */ efi_l4_pgtable =3D alloc_xen_pagetable(); BUG_ON(!efi_l4_pgtable); @@ -1680,6 +1661,5 @@ void __init efi_init_memory(void) for ( i =3D l4_table_offset(HYPERVISOR_VIRT_START); i < l4_table_offset(DIRECTMAP_VIRT_END); ++i ) efi_l4_pgtable[i] =3D idle_pg_table[i]; -#endif } #endif --=20 git-series 0.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 12:11:01 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1570891062; cv=none; d=zoho.com; s=zohoarc; b=W4DWxGC4xSWd/DnMwzqsYz17LKb5duHwWFl/xntloww57bqLKOlLR/OOrbvmfWRrMGGIZ9sGFNfKADxfS/FLGf6nfZbfAq/CY+QKftojGUXQU+UxOJYL6h1d0LoilGqI8LVprNA5018qcXpK/J1LOXfAJDVSbOXhJlMeJLspCX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570891062; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QDawWqJTXuNpQVUKL9u3am7uav2h9GxWCwbQrm6J4Nk=; b=BUNTU6N55eA05oeke/vz4E6fMoEDvrTw6+01wULi+2iTU+Gk+9nYD3AgIcdKw6/8LmlwXGb2tWrGQumLUf42bl0Bz3zAAoQ8liyumAsUVEpni2qdOkvhMTFc3hOhvN/zxd2LVYSVl9JO8LnxamVWf94VZwRNV1DeEAhuiHp5g9s= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1570891062336598.1503960467269; Sat, 12 Oct 2019 07:37:42 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iJIVX-0000YQ-LR; Sat, 12 Oct 2019 14:36:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iJIVW-0000Y8-Bv for xen-devel@lists.xenproject.org; Sat, 12 Oct 2019 14:36:34 +0000 Received: from new1-smtp.messagingengine.com (unknown [66.111.4.221]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id adbfc236-ecfd-11e9-bbab-bc764e2007e4; Sat, 12 Oct 2019 14:36:29 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id 93BB25916; Sat, 12 Oct 2019 10:36:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 12 Oct 2019 10:36:29 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id 0F367D6005D; Sat, 12 Oct 2019 10:36:27 -0400 (EDT) X-Inumbo-ID: adbfc236-ecfd-11e9-bbab-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=2tq+EVixw2b0GMKGNXgcN3F/3xwOoxlJnB+6cPiUc fY=; b=L0PZjdmOEq9VoeoAAD5bKWKzcQqI/EdCaEh7iXKU6TcsULet/uZbpFGbN GHJW3IM6FOXEURI0FOjEE4gSHISUZAPUL75qhelqzayod+cEHlH6ViTk/R50bCWj 9i4mYoIiMbtFWgwf96p5Whht4NZIOnSXhQmcCDQvv8aGBvdQ4H0EqXKfdJC4pRBr PBMoB1++tVXEBN7yBr9gpUO11Ft8CwXJZ1Kt8nimW/Fj/MaZjwGMytALxrJsw3T9 XR8kbDVLMZrspZLFOLulnf+uhcJZv0aBBibkZM47EssnGglfaTgG5kgTWCHKT0fQ HyPpNLygqiQuLg9G59+SsBn3blvCw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrieejgdejlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Sat, 12 Oct 2019 16:36:09 +0200 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 2/2] xen/efi: optionally call SetVirtualAddressMap() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Tim Deegan , Julien Grall , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Some UEFI implementations are not happy about running in 1:1 addressing, but really virtual address space. Specifically, some access EfiBootServices{Code,Data}, or even totally unmapped areas. Example crash of GetVariable() call on Thinkpad W540: Xen call trace: [<0000000000000080>] 0000000000000080 [<8c2b0398e0000daa>] 8c2b0398e0000daa Pagetable walk from ffffffff858483a1: L4[0x1ff] =3D 0000000000000000 ffffffffffffffff **************************************** Panic on CPU 0: FATAL PAGE FAULT [error_code=3D0002] Faulting linear address: ffffffff858483a1 **************************************** Fix this by calling SetVirtualAddressMap() runtime service, giving it 1:1 map for areas marked as needed during runtime. The address space in which EFI runtime services are called is unchanged, but UEFI view of it may be. SetVirtualAddressMap() can be called only once, hence it's incompatible with kexec. For this reason, make it an optional feature, depending on !KEXEC. And to not inflate number of supported configurations, hide it behind EXPERT. Signed-off-by: Marek Marczykowski-G=C3=B3recki --- Changes in v2: - call SetVirtualAddressMap() before adjusting efi pointers; especially efi_memmap at this point still needs to use physical address, not a directmap one --- xen/common/Kconfig | 13 +++++++++++++ xen/common/efi/boot.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 16829f6..fe98f8a 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -88,6 +88,19 @@ config KEXEC =20 If unsure, say Y. =20 +config SET_VIRTUAL_ADDRESS_MAP + bool "EFI: call SetVirtualAddressMap()" if EXPERT =3D "y" + default n + depends on !KEXEC + ---help--- + Call EFI SetVirtualAddressMap() runtime service to setup memory map = for + further runtime services. According to UEFI spec, it isn't strictly + necessary, but many UEFI implementations misbehave when this call is + missing. On the other hand, this call can be made only once, which m= akes + it incompatible with kexec (kexec-ing this Xen from other Xen or Lin= ux). + + If unsuser, say N. + config XENOPROF def_bool y prompt "Xen Oprofile Support" if EXPERT =3D "y" diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index cddf3de..6eaabd4 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1056,11 +1056,17 @@ static void __init efi_set_gop_mode(EFI_GRAPHICS_OU= TPUT_PROTOCOL *gop, UINTN gop efi_arch_video_init(gop, info_size, mode_info); } =20 +#define INVALID_VIRTUAL_ADDRESS (0xBAAADUL << \ + (EFI_PAGE_SHIFT + BITS_PER_LONG - 32)) + static void __init efi_exit_boot(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE = *SystemTable) { EFI_STATUS status; UINTN info_size =3D 0, map_key; bool retry; +#ifdef CONFIG_SET_VIRTUAL_ADDRESS_MAP + unsigned int i; +#endif =20 efi_bs->GetMemoryMap(&info_size, NULL, &map_key, &efi_mdesc_size, &mdesc_ver); @@ -1094,6 +1100,26 @@ static void __init efi_exit_boot(EFI_HANDLE ImageHan= dle, EFI_SYSTEM_TABLE *Syste if ( EFI_ERROR(status) ) PrintErrMesg(L"Cannot exit boot services", status); =20 +#ifdef CONFIG_SET_VIRTUAL_ADDRESS_MAP + for ( i =3D 0; i < efi_memmap_size; i +=3D efi_mdesc_size ) + { + EFI_MEMORY_DESCRIPTOR *desc =3D efi_memmap + i; + + if ( desc->Attribute & EFI_MEMORY_RUNTIME ) + desc->VirtualStart =3D desc->PhysicalStart; + else + desc->VirtualStart =3D INVALID_VIRTUAL_ADDRESS; + } + status =3D efi_rs->SetVirtualAddressMap(efi_memmap_size, efi_mdesc_siz= e, + mdesc_ver, efi_memmap); + if ( status !=3D EFI_SUCCESS ) + { + printk(XENLOG_ERR "EFI: SetVirtualAddressMap() failed (%#lx), disa= bling runtime services\n", + status); + __clear_bit(EFI_RS, &efi_flags); + } +#endif + /* Adjust pointers into EFI. */ efi_ct =3D (void *)efi_ct + DIRECTMAP_VIRT_START; efi_memmap =3D (void *)efi_memmap + DIRECTMAP_VIRT_START; @@ -1460,8 +1486,6 @@ static bool __init rt_range_valid(unsigned long smfn,= unsigned long emfn) return true; } =20 -#define INVALID_VIRTUAL_ADDRESS (0xBAAADUL << \ - (EFI_PAGE_SHIFT + BITS_PER_LONG - 32)) =20 void __init efi_init_memory(void) { --=20 git-series 0.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel