From patchwork Mon Apr 8 14:24:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 10889641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ADA317E1 for ; Mon, 8 Apr 2019 14:29:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73BF62793B for ; Mon, 8 Apr 2019 14:29:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6845128382; Mon, 8 Apr 2019 14:29:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D98BF27F90 for ; Mon, 8 Apr 2019 14:29:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hDVFa-00028C-Ds; Mon, 08 Apr 2019 14:27:54 +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 1hDVFY-000271-NY for xen-devel@lists.xenproject.org; Mon, 08 Apr 2019 14:27:52 +0000 X-Inumbo-ID: 7c8f4532-5a0a-11e9-8f6b-8b9dd737b7bc Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7c8f4532-5a0a-11e9-8f6b-8b9dd737b7bc; Mon, 08 Apr 2019 14:27:49 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,325,1549929600"; d="scan'208";a="83010297" From: Anthony PERARD To: Date: Mon, 8 Apr 2019 15:24:06 +0100 Message-ID: <20190408142408.30419-30-anthony.perard@citrix.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408142408.30419-1-anthony.perard@citrix.com> References: <20190408142408.30419-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 29/31] OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables 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: Ard Biesheuvel , Jordan Justen , Julien Grall , Anthony PERARD , xen-devel@lists.xenproject.org, Laszlo Ersek Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This "device" 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 probably 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. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Anthony PERARD --- Notes: 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/XenOvmf.dsc | 2 ++ OvmfPkg/XenOvmf.fdf | 1 + OvmfPkg/{XenIoPciDxe/XenIoPciDxe.inf => XenIoPvhDxe/XenIoPvhDxe.inf} | 26 +++++--------- OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c | 38 ++++++++++++++++++++ 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/OvmfPkg/XenOvmf.dsc b/OvmfPkg/XenOvmf.dsc index a26f611058..72d6ea8b29 100644 --- a/OvmfPkg/XenOvmf.dsc +++ b/OvmfPkg/XenOvmf.dsc @@ -199,6 +199,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 Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf @@ -596,6 +597,7 @@ [Components] NULL|IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf !endif } + OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf OvmfPkg/XenBusDxe/XenBusDxe.inf OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf diff --git a/OvmfPkg/XenOvmf.fdf b/OvmfPkg/XenOvmf.fdf index e078c7b405..9aa998f15f 100644 --- a/OvmfPkg/XenOvmf.fdf +++ b/OvmfPkg/XenOvmf.fdf @@ -295,6 +295,7 @@ [FV.DXEFV] INF MdeModulePkg/Universal/Metronome/Metronome.inf INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf +INF OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf INF OvmfPkg/XenBusDxe/XenBusDxe.inf INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf diff --git a/OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf b/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf similarity index 56% copy from OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf copy to OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf index b32075a381..985b6d54b7 100644 --- a/OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf +++ b/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf @@ -1,7 +1,7 @@ ## @file -# Driver for the virtual Xen PCI device +# Driver for the XenIo protocol # -# Copyright (C) 2015, Linaro Ltd. +# Copyright (c) 2019, Citrix Systems, Inc. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -15,31 +15,21 @@ [Defines] INF_VERSION = 0x00010005 - BASE_NAME = XenIoPciDxe - FILE_GUID = cf569f50-de44-4f54-b4d7-f4ae25cda599 + BASE_NAME = XenIoPvhDxe + FILE_GUID = 7a567cc4-0e75-4d7a-a305-c3db109b53ad MODULE_TYPE = UEFI_DRIVER VERSION_STRING = 1.0 - ENTRY_POINT = XenIoPciDeviceEntryPoint + ENTRY_POINT = InitializeXenIoPvhDxe [Packages] MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec [Sources] - XenIoPciDxe.c + XenIoPvhDxe.c [LibraryClasses] UefiDriverEntryPoint - UefiBootServicesTableLib MemoryAllocationLib - BaseMemoryLib - BaseLib - UefiLib - DebugLib - -[Protocols] - gEfiDriverBindingProtocolGuid - gEfiPciIoProtocolGuid - gEfiComponentName2ProtocolGuid - gEfiComponentNameProtocolGuid - gXenIoProtocolGuid + XenIoMmioLib + XenPlatformLib diff --git a/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c b/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c new file mode 100644 index 0000000000..f2113b768c --- /dev/null +++ b/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c @@ -0,0 +1,38 @@ +/** @file + + Driver for the XenIo protocol + + This driver simply allocate space for the grant tables. + + Copyright (c) 2019, Citrix Systems, Inc. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include + +EFI_STATUS +EFIAPI +InitializeXenIoPvhDxe ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + if (XenPvhDetected ()) { + EFI_HANDLE Handle; + + Handle = NULL; + return XenIoMmioInstall (&Handle, (UINTN) AllocateReservedPages (4)); + } + + return EFI_SUCCESS; +}