From nobody Thu Nov 14 05:53:15 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+43312+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1562252326; cv=none; d=zoho.com; s=zohoarc; b=lbi7QsQtFQp6zrowKqLjjvjsDVZ0tYbebtpjGMTsvdnJ29Ue9GLN7T0xWhgMRbGi3T3smDK8s7i7xXM0Eiuz5IRhmCr11iX6qqa5nASHac5Fa2Ww6RQLgPEYuaFjMacAj2mKVWxZQNHiSLlwUgf0mpTQm61uNo6tpiJz7xt0YPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562252326; 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=hT4qDXEhBeQrD2t5bKIl6NuorKHNElG/LOPslSYOJF4=; b=BNEU8hG2XXhYeAJ9EAsfqSrDnZlSmI8JzrtuFK+PqXKm1dTWMYL/bhzeS3mvIfQyGgk31nsrMc3QQKLaFDh/QnBvccyo0NTtdxtaGDxtTfiD0QAtDC5GlIG4NBJwjot+DiJM4BfG9bRcrVW9iTzcHhKWlEVcHPzm+IebvjMZQY0= 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+43312+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1562252326476875.4598692866647; Thu, 4 Jul 2019 07:58:46 -0700 (PDT) Return-Path: X-Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com []) by groups.io with SMTP; Thu, 04 Jul 2019 07:58:45 -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+43312+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: None (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: G/tltgAy+zTctT9Gyaz7C/Upd5a9xKVJbugBhAUQ1ou0Jut389RqXAo5AZwj3HciKzwdP1UQ8U oGfJ/VorkmLT/NUgfTaaWaX+yk3BRpXVtzb3wTzYwipFBSP2BIx6/PpLGjD4xMVRiqNjt6hOlk cYg6O3dLcPIOrj+ZFhPZhZlK55b/CeXqpJRQ2y+EOFGW8hIPzZO1fc9L3lVLDRKIIrMWXN0P38 /bXrp4VrJoBq3W2dCfN2JQEFEAC4kSBCNTgi2SDddnRsBKbUQ5pa/5RjocEyA8ZDPq+866I5pL 4pw= X-SBRS: 2.7 X-MesageID: 2623863 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,451,1557201600"; d="scan'208";a="2623863" From: "Anthony PERARD" To: CC: , Ard Biesheuvel , Jordan Justen , Laszlo Ersek , Julien Grall , Anthony PERARD Subject: [edk2-devel] [PATCH v3 23/35] OvmfPkg/XenPlatformPei: no hvmloader: get the E820 table via hypercall Date: Thu, 4 Jul 2019 15:42:21 +0100 Message-ID: <20190704144233.27968-24-anthony.perard@citrix.com> In-Reply-To: <20190704144233.27968-1-anthony.perard@citrix.com> References: <20190704144233.27968-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=1562252326; bh=XrHr4rn6aR5DfmogRFfMSVO3Pm3Yeg4BTss73iZJoGQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=ZF7SLzvRGzFnecahCTm/fZyiH0CfLYSP+fUj+TvRBwENSDCcf9Z5N75wPcAuAp6asTG MtOxOaUmCu0kZrsVurFx4QNKw1ViItL+tS64e3HJwyiBVhq6K7t4Jroxjph/MutVJncYG NJTaAARZVT+mAhJxKsINCTz6zhl1RwOct0Y= 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, the call can only be made once so keep the result cached for later. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1689 Signed-off-by: Anthony PERARD Acked-by: Laszlo Ersek --- Notes: 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 188e831c5c..cbfd8058fc 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 (#43312): https://edk2.groups.io/g/devel/message/43312 Mute This Topic: https://groups.io/mt/32308736/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-