From nobody Fri Dec 27 03:31:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491055652600.8280064528967; Wed, 23 Aug 2017 05:24:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4F98421E47D47; Wed, 23 Aug 2017 05:20:43 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3A65021D2E628 for ; Wed, 23 Aug 2017 05:20:36 -0700 (PDT) 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:23:05 +0000 X-Original-To: edk2-devel@lists.01.org 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=g5L0FMZqbCBq7Cx68uGBRcOvBovwZv0Sd/dPSXZ4Aw4=; b=RcNNVmekd8WOE3L7rGtlZCrnJCFIpgWxiL6zsWaPosDo1cwqW4bI+DGv2W/F8dMPSKw2eZZnHfjgCYb6c8/wtCykPyAoU4jbOdaCpciapwssmwjtVB8KTGppr1sRtdYBnq+QQoScNwWTf7fsTmJEzWVsmzLGpUNdV4mscP8rgzA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:40 -0400 Message-Id: <1503490967-5559-17-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: 7060c7ba-1ad8-438d-c804-08d4ea21b4ce 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:RmtHVF+LTmI0ZJOdytR/WxH+hyHdPU5zVP66oh4Qwl9hnXNx3lz3+clPdiN7tJ0dV7mbHq62ZAoK4r8kTIfqVB9f1Ljx2rG6JcpIDguKwc/H++TXX5RLprz9tjkvTpP7GnHuAN1h4Y5I41oWyRr/HB1joNy19CmaMYHvnV4epASzil4Y3BBxxqcOrcHL+PKg3aCTj+4Aj8mr1KyEw1B2BKpwavZiIEiLupGfRBVmu8a6/uspbK6UfYI1zYcsMXRY; 25:C03hI6cNItnhUU2YqqSkSa7v1sfK+DtNKXSQxsOMI7ljJnXnvFYdFEl2ccpyzNsprFuukQBsi/viyP+0TzxnUiJP/5gUPPPYilxGgBlzP8r2oANNkNmv4z2XjupiokP0VSK82gvZd0KRdZf5bagmZ1yMz5UrcTVoadAS7zwxYKTJIAVqkBnzvm386sp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VJNmxXZW3ssSkfHjqFuBSTxwrZ66MtzWAh2LY1HJ2xv9huhvlJKPbzd5X9hT4ypw3mnWs3KkFEndpgTtuH3BE+HSjZNzmr0rIyhketXhF8DuFgPP9CMQ5tS+5z28WXqzg0jP2RV4DGVbS3+4rHfU1xDK7orNtfTcn0XdZkJUz+KcVaw8wMLxo2b+0RA+jotp3Q1yikl8+HSPw/0XYpaUc32EQkvAf3EmG2ZTwIu4Ak+cVpLwHRheLQ== 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)(6029001)(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 (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:0gtgqDqqMTCZsPAzIks1aQ//+ikKdHC0Y7vVLyPel?= =?us-ascii?Q?Z+nGklJl9FJswAJTW1mHdYC4BDvqK+A7YtWSmQC4mGarhlqMxUZI6dqp4YCR?= =?us-ascii?Q?w2h/CwHdr1GGtOetR8XYgE/OThXYwLpgrZem1eJmgzjCQJ2USSbB/MPiDxOB?= =?us-ascii?Q?lbq7nkaFiFKCDmOH7n/ziYvJLpBSwGQA5+vw+57ALX4j06euNnNPYwKbOR7n?= =?us-ascii?Q?dY0krq3HHeW7MWgETQSLlTbS5JXlm6D7auPdf98DNjsKc2jUCqLMv1SKhwvj?= =?us-ascii?Q?sQwyR31Yf4m/Oql5UnFuYkYUwusQbe5RCnzSqLr7S/63UxlnXkngxKXUoLXk?= =?us-ascii?Q?CyjapGllMJZgIv54ghwYsLOIiAYVCXY9iCtuxASCEHwFY4WSAMU6z36/yXQs?= =?us-ascii?Q?h5W04O2Qe2ZD8L6zdWPpHwMVw8j8d8GCCPR9JZSmqMBDazHAOeAwgN/1P26w?= =?us-ascii?Q?gwMcHK4biKlu5e4YIe/3547PVOpyQ0nprnPhHt2UiMLf0do8qpbk4Ax7IQKC?= =?us-ascii?Q?vOXYVz45xUbnRd6uQFCdglCvfWxpnIURPkEJP5nwyxIFMOoIu3auK/XyOJYx?= =?us-ascii?Q?vGaeZgyQQjh50Q3FAcpHSTxQU8ZKPAThmrti4FVtzm7ZTDcil0Y5OOUAufL6?= =?us-ascii?Q?jpXessc3tVwilizRRwcotFPyb3KuF91wMgeYERDNVWuhynC+aK1w6XWC6nXC?= =?us-ascii?Q?QbQv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1Z35xwupymKRX9Gd37wyvju8iw==; 24:Oo/tebA/0hx7K7QWq378/hiJrS8Ah5NlHlGBvyT6avwpvxr0R+eJJUPb+D5CZsHznW/gdyiqdLW5vWTdzFGn3hwuLnOIx+MNNHfL8wBzuLg=; 7:3T40GdPuW+mNZlhV7AFfgoU+Oq1RXKuIt8G3Cl+NR6xU6oGoKFeee4Dpaz+JERgoUHsOyby3tA8godWBoaprRVSFzcFAllNwYFk2kRgozg99MgN7cgXzZHufdL5O//oNBevgHnyua6txBj3P/HOltvRSGHb5POhmABxSgav7/UMmS9QTRIHdcE+Q5DrPyA2nByPBuD4K45kpC105qfN9b7iec6H8d3JT2ZjpY0xKKVU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:ECZljH0IDBoCZSTdO7TsjIL7sbgal23fPF1RGJQKYEdbZXdPRoY4ZvOSWozeZsyH/Zq69M7LTt0f6cYGphCed29Sp6HMWl+QFQjn1H2aPEaJmIbhcVHHZiA3EcSgpTMJUFrKNIy4B1maOsU3raUqmLTJkil5RXgZGL4NQ+wTkzwssz6105RNKWWSpRBNSZAzPQXEzx4f+lq6xR0lafTrjr2j3WwX9otJ7XgrLpa8z1tc1kdmUneEOiVIOzXCdNyj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:05.2634 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 16/23] OvmfPkg/VirtioNetDxe: alloc RxBuf using AllocateSharedPages() 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: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" RxBuf is shared between guest and hypervisor, use VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages() to allocate this memory region and map it with BusMasterCommonBuffer operation so that it can be accessed by both guest and hypervisor. 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/VirtioNetDxe/VirtioNet.h | 3 + OvmfPkg/VirtioNetDxe/Events.c | 6 ++ OvmfPkg/VirtioNetDxe/SnpInitialize.c | 76 ++++++++++++++++---- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 7 +- 4 files changed, 78 insertions(+), 14 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index d80d441b50a4..7df51bd044f5 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -4,6 +4,7 @@ Protocol instances for virtio-net devices. =20 Copyright (C) 2013, Red Hat, Inc. + Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -85,6 +86,8 @@ typedef struct { VOID *RxRingMap; // VirtioRingMap UINT8 *RxBuf; // VirtioNetInitRx UINT16 RxLastUsed; // VirtioNetInitRx + UINTN RxBufNoPages; // VirtioNetInitRx + VOID *RxBufMap; // VirtioMapSharedBuffer =20 VRING TxRing; // VirtioNetInitRing VOID *TxRingMap; // VirtioRingMap diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 6950c4d56df1..0586a82cdf09 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -95,4 +95,10 @@ VirtioNetExitBoot ( // Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxRingMap); Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxRingMap); + + // + // Unmap Rx buffer so that hypervisor will not be able get readable data= after + // device is reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 803a38bd4239..bdc3fd7ac6a2 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -249,13 +249,17 @@ VirtioNetInitRx ( IN OUT VNET_DEV *Dev ) { - EFI_STATUS Status; - UINTN VirtioNetReqSize; - UINTN RxBufSize; - UINT16 RxAlwaysPending; - UINTN PktIdx; - UINT16 DescIdx; - UINT8 *RxPtr; + EFI_STATUS Status; + UINTN VirtioNetReqSize; + UINTN RxBufSize; + UINT16 RxAlwaysPending; + UINTN PktIdx; + UINT16 DescIdx; + UINT8 *RxPtr; + UINTN NumBytes; + EFI_PHYSICAL_ADDRESS RxBufDeviceAddress; + UINT64 BufBaseShift; + VOID *RxBuffer; =20 // // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depend= s on @@ -280,11 +284,41 @@ VirtioNetInitRx ( // RxAlwaysPending =3D (UINT16) MIN (Dev->RxRing.QueueSize / 2, VNET_MAX_PE= NDING); =20 - Dev->RxBuf =3D AllocatePool (RxAlwaysPending * RxBufSize); - if (Dev->RxBuf =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + // + // The RxBuf is shared between guest and hypervisor, use SharedPages() to + // allocate this memory region and map it with BusMasterCommonBuffer + // operation so that it can be accessed equally by both guest and + // hypervisor. + // + NumBytes =3D RxAlwaysPending * RxBufSize; + Dev->RxBufNoPages =3D EFI_SIZE_TO_PAGES (NumBytes); + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + Dev->RxBufNoPages, + &RxBuffer + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_OUT_OF_RESOURCES; + return Status; } =20 + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + RxBuffer, + NumBytes, + &RxBufDeviceAddress, + &Dev->RxBufMap + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_OUT_OF_RESOURCES; + goto FreeSharedBuffer; + } + + Dev->RxBuf =3D RxBuffer; + + BufBaseShift =3D (UINT64) (UINTN)Dev->RxBuf - (UINT64) RxBufDeviceAddres= s; + // // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device // @@ -306,6 +340,11 @@ VirtioNetInitRx ( DescIdx =3D 0; RxPtr =3D Dev->RxBuf; for (PktIdx =3D 0; PktIdx < RxAlwaysPending; ++PktIdx) { + UINT64 Address; + + Address =3D (UINTN) RxPtr; + Address +=3D BufBaseShift; + // // virtio-0.9.5, 2.4.1.2 Updating the Available Ring // invisible to the host until we update the Index Field @@ -315,13 +354,13 @@ VirtioNetInitRx ( // // virtio-0.9.5, 2.4.1.1 Placing Buffers into the Descriptor Table // - Dev->RxRing.Desc[DescIdx].Addr =3D (UINTN) RxPtr; + Dev->RxRing.Desc[DescIdx].Addr =3D Address; Dev->RxRing.Desc[DescIdx].Len =3D (UINT32) VirtioNetReqSize; Dev->RxRing.Desc[DescIdx].Flags =3D VRING_DESC_F_WRITE | VRING_DESC_F_= NEXT; Dev->RxRing.Desc[DescIdx].Next =3D (UINT16) (DescIdx + 1); RxPtr +=3D Dev->RxRing.Desc[DescIdx++].Len; =20 - Dev->RxRing.Desc[DescIdx].Addr =3D (UINTN) RxPtr; + Dev->RxRing.Desc[DescIdx].Addr =3D Address; Dev->RxRing.Desc[DescIdx].Len =3D (UINT32) (RxBufSize - VirtioNetReq= Size); Dev->RxRing.Desc[DescIdx].Flags =3D VRING_DESC_F_WRITE; RxPtr +=3D Dev->RxRing.Desc[DescIdx++].Len; @@ -345,10 +384,21 @@ VirtioNetInitRx ( Status =3D Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_RX); if (EFI_ERROR (Status)) { Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - FreePool (Dev->RxBuf); + goto UnmapSharedBuffer; } =20 return Status; + +UnmapSharedBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + +FreeSharedBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + Dev->RxBufNoPages, + (VOID *) Dev->RxBuf + ); + return Status; } =20 =20 diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe= /SnpSharedHelpers.c index 9fedb72fdbd4..4c9d9ece0790 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -39,7 +39,12 @@ VirtioNetShutdownRx ( IN OUT VNET_DEV *Dev ) { - FreePool (Dev->RxBuf); + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + Dev->RxBufNoPages, + (VOID *) Dev->RxBuf + ); } =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel