From nobody Thu Nov 14 16:48:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45547+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1565697486; cv=none; d=zoho.com; s=zohoarc; b=DejaRWRqQsxNwVWacDydqyeoCR/vwpVgAMaxThDdqAMGSN/FMFaV/0DwAsh3DlCLb1DIQzzEWEh1TLmMdMuLN5sQ7QfwLrYTEJU9xN3IxmywL3nBLrfqoGhtpEI/wF7JHtsbx43zF/n3mFB+hkZlMhu4D9vGO2geHiY8wRiq56U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565697486; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=cpNEIGiEmWK9bel16f+q26Hxxg0KmNgxTKcDmVAnQIE=; b=VevyQqEKb0C5TG4hQ3wRuupfTGuoRpCmpESJLlJtZMnaBQ7m7QkHpXxVLJgVZO12HBk1kKQ71k7WRtYW2n7r2FYNosG4U4tCYgpePwtDz3csFXwoTEb0475i5LElxmCL+YPQathyzMR2WviS8XliLg1Ak0H9ANhg2LxugRg518w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45547+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565697486428854.5798584973878; Tue, 13 Aug 2019 04:58:06 -0700 (PDT) Return-Path: X-Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by groups.io with SMTP; Tue, 13 Aug 2019 04:58:05 -0700 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45547+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: v/mVwBaGG/mQEs/xWzpqEWzCH58rjRfN8J84LjSayZ/RX3cxIug+Px/k+PvhRczyDrtLFhTmEA T/FQNz2cF39384NGV0y0hVlvqRQ7EVlCUkvhtsVLII8O6OiISZvKJwWbX9tCM3Sqx44eIR9JyJ vCFs7TuWFa/YIiXMO6XIAJOXKzgvz7R8MLm5AN3DNDvM2vB5mOGKucYLo7ZUkuH5q76DHW9eyi nBs5wxEV2a5aszVkDUZm24QySdGL+YsvUFBTaPH8wQJfJDDx8pinbKR/y0LRPyjxge+XTUlwvW B/c= X-SBRS: 2.7 X-MesageID: 4198441 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,381,1559534400"; d="scan'208";a="4198441" From: "Anthony PERARD" To: CC: Laszlo Ersek , Jordan Justen , Julien Grall , , Ard Biesheuvel , Anthony PERARD Subject: [edk2-devel] [PATCH v5 22/35] OvmfPkg/XenPlatformPei: no hvmloader: get the E820 table via hypercall Date: Tue, 13 Aug 2019 12:31:06 +0100 Message-ID: <20190813113119.14804-23-anthony.perard@citrix.com> In-Reply-To: <20190813113119.14804-1-anthony.perard@citrix.com> References: <20190813113119.14804-1-anthony.perard@citrix.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,anthony.perard@citrix.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565697486; bh=cpNEIGiEmWK9bel16f+q26Hxxg0KmNgxTKcDmVAnQIE=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=bHjxmJI+eEaOzgCGZWb0BmlyfogcWjeFdB4Z3A9XWWNJR8hn2EfXBUkYxcuGOAi4OQW JOdssb0q+bZFzqkby9dWGSpfmHExtOBsZZGLd+OAPYqz76TjIndWVG8kzMYDKTWe96cDz 2PKYAtULGEE+HX7LCYxebKoNQHFGekqwo1c= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" When the Xen PVH entry point has been used, hvmloader hasn't run and hasn't prepared an E820 table. The only way left to get an E820 table is to ask Xen via an hypercall. We keep the result cached to avoid making a second hypercall which would give the same result. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1689 Signed-off-by: Anthony PERARD Acked-by: Laszlo Ersek --- Notes: v5: - fix commit message, the hypercall *can* be made several time, but we still cache the result. =20 v3: - fix commit message - add 'm' prefix to the global variables and make them static OvmfPkg/XenPlatformPei/Xen.c | 46 +++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/XenPlatformPei/Xen.c b/OvmfPkg/XenPlatformPei/Xen.c index f26f0e56dd..72f6f37b46 100644 --- a/OvmfPkg/XenPlatformPei/Xen.c +++ b/OvmfPkg/XenPlatformPei/Xen.c @@ -27,6 +27,7 @@ #include #include #include +#include =20 #include "Platform.h" #include "Xen.h" @@ -40,6 +41,8 @@ EFI_XEN_INFO mXenInfo; // Only the E820 table is used by OVMF. // EFI_XEN_OVMF_INFO *mXenHvmloaderInfo; +STATIC EFI_E820_ENTRY64 mE820Entries[128]; +STATIC UINT32 mE820EntriesCount; =20 /** Returns E820 map provided by Xen @@ -55,6 +58,12 @@ XenGetE820Map ( UINT32 *Count ) { + INTN ReturnCode; + xen_memory_map_t Parameters; + UINTN LoopIndex; + UINTN Index; + EFI_E820_ENTRY64 TmpEntry; + // // Get E820 produced by hvmloader // @@ -66,7 +75,42 @@ XenGetE820Map ( return EFI_SUCCESS; } =20 - return EFI_NOT_FOUND; + // + // Otherwise, get the E820 table from the Xen hypervisor + // + + if (mE820EntriesCount > 0) { + *Entries =3D mE820Entries; + *Count =3D mE820EntriesCount; + return EFI_SUCCESS; + } + + Parameters.nr_entries =3D 128; + set_xen_guest_handle (Parameters.buffer, mE820Entries); + + // Returns a errno + ReturnCode =3D XenHypercallMemoryOp (XENMEM_memory_map, &Parameters); + ASSERT (ReturnCode =3D=3D 0); + + mE820EntriesCount =3D Parameters.nr_entries; + + // + // Sort E820 entries + // + for (LoopIndex =3D 1; LoopIndex < mE820EntriesCount; LoopIndex++) { + for (Index =3D LoopIndex; Index < mE820EntriesCount; Index++) { + if (mE820Entries[Index - 1].BaseAddr > mE820Entries[Index].BaseAddr)= { + TmpEntry =3D mE820Entries[Index]; + mE820Entries[Index] =3D mE820Entries[Index - 1]; + mE820Entries[Index - 1] =3D TmpEntry; + } + } + } + + *Count =3D mE820EntriesCount; + *Entries =3D mE820Entries; + + return EFI_SUCCESS; } =20 /** --=20 Anthony PERARD -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45547): https://edk2.groups.io/g/devel/message/45547 Mute This Topic: https://groups.io/mt/32851694/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-