From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0072.outbound.protection.outlook.com [104.47.40.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C683D2095B9F4 for ; Wed, 23 Aug 2017 05:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jYsfQGp2XaMBi3D71uCWntoP87Md6Po6hVCn3UCViJw=; b=h1Hy+8dM4MqpXjfcJW5KuoZxzWFIfl5GSK0c3sFwZgsYO/CN1b2Kj0+9G4qB2vEj6GYRADoiPE1TEkxSD16C/x81InqCI5Ew2GD+eZBa8yD0QF+TgoC+vQ+OsMERXc85MvuYa0EXMt9IbvhoiFclvEjXD6AByg5sIhnxQqjW2EE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:22:59 +0000 From: Brijesh Singh To: edk2-devel@lists.01.org Cc: Brijesh Singh , Ard Biesheuvel , Jordan Justen , Tom Lendacky , Laszlo Ersek Date: Wed, 23 Aug 2017 08:22:28 -0400 Message-Id: <1503490967-5559-5-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 954d4f7e-9af2-4580-908c-08d4ea21b149 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:isKUImTWk4a7lzx3nX41IDq3Ig7DkZgyhz7lfqffZlwk5nnS+0xJYSeVbTK665IlncY8OkESHBVLnPOCYM/GWjfZX7E3mQxym59XRQQxH+XwTD4q6rGRXGE2XqwqkDX2TjwdvYO47oJqWFi9gJZNSBDS6jNLd1RL1SbWYTZv+hVlh8buTXyB6UGI/AGe779FeZgnfAyqM5u3V46mRMm9KHJrHMzOa07+M1xzvi0G+IH/1SF5+gZfOJc3IJm/oGYb; 25:PcMpelKNyQQ/4chYKNhEWu+T/eoz8LuoHNTAH9jvhLTUv9UstN7VrDiXt2Tk73WARGFE+lu7mZTmlY64hUes/LBavXJTHZfV81W86uD8aK4xyEnNz/HgWKsxKjGJ4CFPJwoPz5alem+0Xb1VTeww67jRr3zSP3OW+swFrds3A3pzkML0gUQpeiaBvoehk3dn8urMxM9QSueNyprc/srrC40rMhhl7+X+AdQs6OZrf8kFWEzv2gZVWnafmPAvSBLsvqmNrhyx7VRpXehfH0WPR4W8lwfON1AG8pYwm0+P3Cfk8bQDidUgGNQj2vsWiMXFQeSjbmw9bKSa8fkX+wT9Uw==; 31:ZpjkGmeSAbCXVMtHfNO+lFqzhsd04cDvYBt2sEYv8OzTSnvf2s301NcSXUVZtlNpLTkeMJZ0cMxVA1Z70HLWIu63Aq95jKZ4FrjDg4x7QcZR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/BCk7A== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:pNykiIGhUvKR1BrzH4PWudmEijHcCqIHeqzS5yMmm?= =?us-ascii?Q?J++NSwOquXmwbQZE4Tne6XM9I57+XQs4ncZ7U0W7TEnh6lBYxxj45QXhm6Zt?= =?us-ascii?Q?CjhdnElO61nJc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CcPtL5aWRBUx+P5MRzw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:U7rb3j5bCOL7Nn9f0jYjgHLfGDvO/377SYS8mI+Xn5QaT0v5Q0ExrT6y/Bgn8jL2eYtJ/QNF5FYiHzTL2acNNuXRAxqk1SE2MDtqk4tQd4PPtBYGQn65Xa2oawVJeh47L62x0SwzuwN7dHiikdbPrDkZxjVFJAct9l/p6Mvg61CkEo+3zFEOX3Aetg8Yuqs7gHA7MW54U9qDgQh0VDEOcdQhuOIw+yVWqZLE4NGCKkazKWurAKe1ORbvse/1RAv9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:22:59.3416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [PATCH v3 04/23] OvmfPkg/VirtioMmioDeviceLib: implement IOMMU-like member functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 12:20:27 -0000 Content-Type: text/plain The patch implements the newly added IOMMU-like member functions by respectively delegating the job to: - VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages () -> MemoryAllocationLib.AllocatePages() - VIRTIO_DEVICE_PROTOCOL.FreeSharedPages () -> MemoryAllocationLib.FreePages () - VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer () -> no-op - VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer () -> no-op Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h | 36 +++++++++++++ OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c | 8 ++- OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c | 57 ++++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h index bedd635e1a86..e5881d537f09 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h @@ -3,6 +3,7 @@ Internal definitions for the VirtIo MMIO Device driver Copyright (C) 2013, ARM Ltd + Copyright (C) 2017, AMD Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this @@ -25,6 +26,7 @@ #include #include #include +#include #define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O') @@ -137,4 +139,38 @@ VirtioMmioSetGuestFeatures ( IN UINT64 Features ); +EFI_STATUS +EFIAPI +VirtioMmioAllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + OUT VOID **HostAddress + ); + +VOID +EFIAPI +VirtioMmioFreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + IN VOID *HostAddress + ); + +EFI_STATUS +EFIAPI +VirtioMmioMapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); + +EFI_STATUS +EFIAPI +VirtioMmioUnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VOID *Mapping + ); + #endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_ diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c index b1d443ea7007..fce934e1e953 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c @@ -3,6 +3,7 @@ This driver produces Virtio Device Protocol instances for Virtio Mmio devices. Copyright (C) 2013, ARM Ltd. + Copyright (C) 2017, AMD Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this @@ -15,7 +16,6 @@ **/ #include -#include #include #include "VirtioMmioDevice.h" @@ -35,7 +35,11 @@ static VIRTIO_DEVICE_PROTOCOL mMmioDeviceProtocolTemplate = { VirtioMmioGetDeviceStatus, // GetDeviceStatus VirtioMmioSetDeviceStatus, // SetDeviceStatus VirtioMmioDeviceWrite, // WriteDevice - VirtioMmioDeviceRead // ReadDevice + VirtioMmioDeviceRead, // ReadDevice + VirtioMmioAllocateSharedPages, // AllocateSharedPages + VirtioMmioFreeSharedPages, // FreeSharedPages + VirtioMmioMapSharedBuffer, // MapSharedBuffer + VirtioMmioUnmapSharedBuffer // UnmapSharedBuffer }; /** diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c index 9142d4a162c0..644ec65e1788 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c @@ -293,3 +293,60 @@ VirtioMmioDeviceRead ( return EFI_SUCCESS; } + +EFI_STATUS +EFIAPI +VirtioMmioAllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + OUT VOID **HostAddress + ) +{ + VOID *Buffer; + + Buffer = AllocatePages (NumPages); + if (Buffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *HostAddress = Buffer; + return EFI_SUCCESS; +} + +VOID +EFIAPI +VirtioMmioFreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + IN VOID *HostAddress + ) +{ + FreePages (HostAddress, NumPages); +} + +EFI_STATUS +EFIAPI +VirtioMmioMapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +{ + *DeviceAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress; + *Mapping = NULL; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +VirtioMmioUnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VOID *Mapping + ) +{ + return EFI_SUCCESS; +} -- 2.7.4