From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: citrix.com, ip: 216.71.155.175, mailfrom: anthony.perard@citrix.com) Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by groups.io with SMTP; Thu, 04 Jul 2019 07:58:15 -0700 Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 8mx8ozuIJMQI/wlv4Ud0vpLKaFr9r267d1IJ43XJoxoGC84KkG8gKcPMOOgcvWK9aVXnGe7X4a 48In/9K61OnMFuROEKlR8vWxDM4UY9iShvfx31V8nBA2dT82d34M4LfNdyRz0VkoS01768wie/ Z/KNrvAizqeZScFfXJc2gAHiL41Y56v8vYZbySyBJ4nKgP0B2sXtR8hYIjWiFXFLW867QVX9Um OLTdRiuS7EdioUK0DSL+0cDwSz1sv5SkB3Ihx7kShoNiFT0q5XTgS2yZousLwlpQ/dRNn7I9HU WYE= X-SBRS: 2.7 X-MesageID: 2626064 X-Ironport-Server: esa6.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="2626064" From: "Anthony PERARD" To: CC: , Ard Biesheuvel , Jordan Justen , Laszlo Ersek , Julien Grall , Anthony PERARD Subject: [PATCH v3 16/35] OvmfPkg/XenHypercallLib: Enable it in PEIM Date: Thu, 4 Jul 2019 15:42:14 +0100 Message-ID: <20190704144233.27968-17-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190704144233.27968-1-anthony.perard@citrix.com> References: <20190704144233.27968-1-anthony.perard@citrix.com> MIME-Version: 1.0 Return-Path: anthony.perard@citrix.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Allow to use Xen hypercalls earlier, during the PEIM stage, but XenHypercallLibInit() must be called once the XenInfo HOB is created with the HyperPage setup. Change the return value of XenHypercallLibInit so failure can be detected when the call shouldn't fail, but still have the constructor always succeed. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1689 Signed-off-by: Anthony PERARD --- Notes: v3: - only modify XenHypercallLib, and to the modification of XenPlatformPei in a separated patch. - Allow XenHypercallLibInit to be called outside the library instead of creating a new function, but also return failure on failure, and have a new constructor that never fail. .../Library/XenHypercallLib/XenHypercallLib.inf | 4 ++-- OvmfPkg/Include/Library/XenHypercallLib.h | 12 ++++++++++++ .../Library/XenHypercallLib/X86XenHypercall.c | 8 +------- OvmfPkg/Library/XenHypercallLib/XenHypercall.c | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf b/OvmfPkg/= Library/XenHypercallLib/XenHypercallLib.inf index 1208f0057a..21ce5b4434 100644 --- a/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf +++ b/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf @@ -12,10 +12,10 @@ [Defines] FILE_GUID =3D B5EE9A32-CA5A-49A8-82E3-ADA4CCB77C7C= =0D MODULE_TYPE =3D BASE=0D VERSION_STRING =3D 1.0=0D - CONSTRUCTOR =3D XenHypercallLibInit=0D + CONSTRUCTOR =3D XenHypercallLibConstruct=0D =0D [Defines.IA32, Defines.X64]=0D - LIBRARY_CLASS =3D XenHypercallLib|DXE_DRIVER UEFI_DRIVE= R=0D + LIBRARY_CLASS =3D XenHypercallLib|PEIM DXE_DRIVER UEFI_= DRIVER=0D =0D [Defines.ARM, Defines.AARCH64]=0D LIBRARY_CLASS =3D XenHypercallLib=0D diff --git a/OvmfPkg/Include/Library/XenHypercallLib.h b/OvmfPkg/Include/Li= brary/XenHypercallLib.h index c43822782b..c1491dd652 100644 --- a/OvmfPkg/Include/Library/XenHypercallLib.h +++ b/OvmfPkg/Include/Library/XenHypercallLib.h @@ -10,6 +10,18 @@ #ifndef __XEN_HYPERCALL_LIB_H__=0D #define __XEN_HYPERCALL_LIB_H__=0D =0D +/**=0D + To call when the gEfiXenInfoGuid HOB became available after the library = init=0D + function has already been executed.=0D +=0D + This allow to make hypercall in the PEIM stage.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +XenHypercallLibInit (=0D + VOID=0D + );=0D +=0D /**=0D Check if the Xen Hypercall library is able to make calls to the Xen=0D hypervisor.=0D diff --git a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c b/OvmfPkg/Li= brary/XenHypercallLib/X86XenHypercall.c index 27083f924f..f779e46470 100644 --- a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c +++ b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c @@ -59,13 +59,7 @@ XenHypercallLibInit ( =0D GuidHob =3D GetFirstGuidHob (&gEfiXenInfoGuid);=0D if (GuidHob =3D=3D NULL) {=0D - //=0D - // We don't fail library construction, since that has catastrophic=0D - // consequences for client modules (whereas those modules may easily b= e=0D - // running on a non-Xen platform). Instead, XenHypercallIsAvailable() = above=0D - // will return FALSE.=0D - //=0D - return RETURN_SUCCESS;=0D + return RETURN_NOT_FOUND;=0D }=0D XenInfo =3D (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);=0D HyperPage =3D XenInfo->HyperPages;=0D diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c b/OvmfPkg/Libra= ry/XenHypercallLib/XenHypercall.c index a2c41a2a69..d4fa802743 100644 --- a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c +++ b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c @@ -15,6 +15,22 @@ #include =0D #include =0D =0D +RETURN_STATUS=0D +EFIAPI=0D +XenHypercallLibConstruct (=0D + VOID=0D + )=0D +{=0D + XenHypercallLibInit ();=0D + //=0D + // We don't fail library construction, since that has catastrophic=0D + // consequences for client modules (whereas those modules may easily be= =0D + // running on a non-Xen platform). Instead, XenHypercallIsAvailable()=0D + // will return FALSE.=0D + //=0D + return RETURN_SUCCESS;=0D +}=0D +=0D UINT64=0D EFIAPI=0D XenHypercallHvmGetParam (=0D --=20 Anthony PERARD