From nobody Thu Nov 14 17:23:34 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+45557+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1565697509; cv=none; d=zoho.com; s=zohoarc; b=YS35IsEUyu2DwJRqgVTEf3O1u76ylj9TmYBbjJvyw9ZJJBhKyAwsdqupniwm4A2x2bHKcqB+RNBjUFiVAtnsUQTQQKMp+8gbD10HecgyYHchBESoGpI85c7IHRbQJpbSaL0vGA3Xd5d1PqP9OL7cWTIBDLTke9+hbLpQKFStTmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565697509; 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=E8TfwLUc44R3JV103tgvQVbJ12pUdZxvrKl3IOjUd1k=; b=SBfgH2WOqIyinbgQ5jafQevasZcV6ja0M8VgnTdVotYfS3sRUYYNZO+KXNxjEXZfIFOytRDEY2A3ksTQbBeOqxIAxdOP3qynBumniQQQGeX8WVN5kqv6BzCgPxwj/pdFLCRNX2vc6oCIXryXvgjeY9qjHAE2FoVx5SzcF3iX0mM= 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+45557+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156569750947767.74611027289757; Tue, 13 Aug 2019 04:58:29 -0700 (PDT) Return-Path: X-Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by groups.io with SMTP; Tue, 13 Aug 2019 04:58:28 -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+45557+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: 3igOo/eflFaplot55F9aQI48jVDVeTmTVYlgUwgcDiLk7mjrwKSPqt/v0clOQN9DBZxdd16yFf QSPfgUx0hRsYbCPmkXeGBtY5yuAUX05uQ3DWgabN1wqlvHQrTYkXwmBsFAG67sc3suRWfAF3u4 eP+Ew2GoIZVvMvId8U+ZxO5dtMrlMEmT8cywRYRBbLcOH1tOslHZTCrfLgpzWUoMxLbsnk/z8J e8WnRMZ9wC4Bju9FovQG26809wwA5yALzDEr7fL7bqNu8DPgyEt5JGKYHelL87e3LtQGIRtGtA IHU= X-SBRS: 2.7 X-MesageID: 4347506 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.64,381,1559534400"; d="scan'208";a="4347506" From: "Anthony PERARD" To: CC: Laszlo Ersek , Jordan Justen , Julien Grall , , Ard Biesheuvel , Anthony PERARD Subject: [edk2-devel] [PATCH v5 33/35] OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables Date: Tue, 13 Aug 2019 12:31:17 +0100 Message-ID: <20190813113119.14804-34-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=1565697509; bh=E8TfwLUc44R3JV103tgvQVbJ12pUdZxvrKl3IOjUd1k=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=V95xYFOtcLd325InFluDnz7Fi5a49GgH29Lzrp9yMC/X3Pv4m6bCk+Irb8lKR+/lAml ZSjtKGQdS5vxlBpLhTmQREXTIFz03Js8QRPzBfASI8hfdJma7XpBnYhSQKMHa2BTYCFZJ 26S1/elVppGsEQV20LVb9qQ1jcwpGZm5WMw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" XenIoPvhDxe use XenIoMmioLib to reserve some space to be use by the Grant Tables. The call is only done if it is necessary, we simply detect if the guest is PVH, as in this case there is currently no PCI bus, and no PCI Xen platform device which would start the XenIoPciDxe and allocate the space for the Grant Tables. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1689 Signed-off-by: Anthony PERARD Reviewed-by: Laszlo Ersek --- Notes: v5: - add missing PcdLib as #include and in [LibraryClasses] =20 v4: - Removed XenIoPvhDxeNotifyExitBoot() which was doing action that should not be done in an ExitBootServices notification. (InitializeXenIoPvhDxe() has been cleaned up following this.) - Use new PcdXenGrantFrames. - Some coding style fix - Update Maintainers.txt =20 v3: - downgrade type to DXE_DRIVER - use SPDX - rework InitializeXenIoPvhDxe, and handle errors properly. - Free the reserved allocation in ExitBootServices even if the XenIo protocol could successfully been uninstalled. =20 v2: - do allocation in EntryPoint like the other user of XenIoMmioLib. - allocate memory instead of hardcoded addr. - cleanup, add copyright - detect if we are running in PVH mode OvmfPkg/OvmfXen.dsc | 2 ++ OvmfPkg/OvmfXen.fdf | 1 + OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf | 36 +++++++++++++++++++ OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c | 54 +++++++++++++++++++++++++++++ Maintainers.txt | 1 + 5 files changed, 94 insertions(+) create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index e719a168f8..5e07b37279 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -195,6 +195,7 @@ [LibraryClasses] OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib= /BaseOrderedCollectionRedBlackTreeLib.inf XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf + XenIoMmioLib|OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf =20 Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeT= cg2PhysicalPresenceLib.inf TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurem= entLibNull.inf @@ -583,6 +584,7 @@ [Components] NULL|OvmfPkg/Csm/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf !endif } + OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf OvmfPkg/XenBusDxe/XenBusDxe.inf OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf diff --git a/OvmfPkg/OvmfXen.fdf b/OvmfPkg/OvmfXen.fdf index 5c1a925d6a..517a492f14 100644 --- a/OvmfPkg/OvmfXen.fdf +++ b/OvmfPkg/OvmfXen.fdf @@ -309,6 +309,7 @@ [FV.DXEFV] INF MdeModulePkg/Universal/Metronome/Metronome.inf INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDx= e.inf =20 +INF OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf INF OvmfPkg/XenBusDxe/XenBusDxe.inf INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf diff --git a/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf b/OvmfPkg/XenIoPvhDxe/XenI= oPvhDxe.inf new file mode 100644 index 0000000000..1c27f8aae0 --- /dev/null +++ b/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf @@ -0,0 +1,36 @@ +## @file +# Driver for the XenIo protocol +# +# Copyright (c) 2019, Citrix Systems, Inc. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D XenIoPvhDxe + FILE_GUID =3D 7a567cc4-0e75-4d7a-a305-c3db109b53ad + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeXenIoPvhDxe + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[Sources] + XenIoPvhDxe.c + +[LibraryClasses] + MemoryAllocationLib + PcdLib + UefiDriverEntryPoint + XenIoMmioLib + XenPlatformLib + +[FixedPcd] + gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames + +[Depex] + TRUE diff --git a/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c b/OvmfPkg/XenIoPvhDxe/XenIoP= vhDxe.c new file mode 100644 index 0000000000..9264a85df1 --- /dev/null +++ b/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c @@ -0,0 +1,54 @@ +/** @file + + Driver for the XenIo protocol + + This driver simply allocate space for the grant tables. + + Copyright (c) 2019, Citrix Systems, Inc. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +InitializeXenIoPvhDxe ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + VOID *Allocation; + EFI_STATUS Status; + EFI_HANDLE XenIoHandle; + + Allocation =3D NULL; + XenIoHandle =3D NULL; + + if (!XenPvhDetected ()) { + return EFI_UNSUPPORTED; + } + + Allocation =3D AllocateReservedPages (FixedPcdGet32 (PcdXenGrantFrames)); + if (Allocation =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Error; + } + + Status =3D XenIoMmioInstall (&XenIoHandle, (UINTN) Allocation); + if (EFI_ERROR (Status)) { + goto Error; + } + + return EFI_SUCCESS; + +Error: + if (Allocation !=3D NULL) { + FreePages (Allocation, FixedPcdGet32 (PcdXenGrantFrames)); + } + return Status; +} diff --git a/Maintainers.txt b/Maintainers.txt index 78e9f889ab..79defd13bf 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -382,6 +382,7 @@ F: OvmfPkg/PlatformPei/Xen.* F: OvmfPkg/SmbiosPlatformDxe/*Xen.c F: OvmfPkg/XenBusDxe/ F: OvmfPkg/XenIoPciDxe/ +F: OvmfPkg/XenIoPvhDxe/ F: OvmfPkg/XenPlatformPei/ F: OvmfPkg/XenPvBlkDxe/ F: OvmfPkg/XenResetVector/ --=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 (#45557): https://edk2.groups.io/g/devel/message/45557 Mute This Topic: https://groups.io/mt/32851705/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-