From nobody Fri Dec 27 02:21:00 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 1504265076640626.6581150401798; Fri, 1 Sep 2017 04:24:36 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 11A2921E7491F; Fri, 1 Sep 2017 04:21:46 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0042.outbound.protection.outlook.com [104.47.40.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 96A9A21E7490F for ; Fri, 1 Sep 2017 04:21:44 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by BY2PR12MB0146.namprd12.prod.outlook.com (10.162.82.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Fri, 1 Sep 2017 11:24:26 +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=MSFLSsxVZQvsBM0cTJi7jarW1mUfjMmBCh4kQKHnYYA=; b=hhRgEjsioRTYT9coCPKO2BeVVrT/GIpgfUQRFZ3rbut+gwVInLTcJSy4X0AKkd6ZgM4DcZ528yxv13jsf8qBvGsI+forgUbxY9tI5/QBnBOOzGTiM50WakV6J+rOwU0S35f0WB/UxqeNQwI6z0DW0WlZ0oD/wN7xiFxwTckFXjg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Fri, 1 Sep 2017 07:24:02 -0400 Message-Id: <1504265045-19008-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504265045-19008-1-git-send-email-brijesh.singh@amd.com> References: <1504265045-19008-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR03CA0012.namprd03.prod.outlook.com (10.168.230.150) To BY2PR12MB0146.namprd12.prod.outlook.com (10.162.82.19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d9a5051-36dc-4034-a3d4-08d4f12c01eb 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)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BY2PR12MB0146; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0146; 3:LflHfRHWEsVGFuZlaoxxX1iitxJJXwqvc7asOHCh/4eah7ZJTCtM0ADHwyBTGB7x8jKX7OLrJtbW0EUYrmBOqAMEP/crwMZp45jEp9Qa/vvFCDYEBb1Lm4/RHmaan4flxjimYDTfxMkLDArKNSatuIvNxTIwaa6S3ggWaJxpP+Z9X30kdCWJFIomej5fBvehmvQmN6xn93UbfDv9sNg4lVdNXqu5KA6HegmiXS0FbIkU60/lkyEnjJyIQF1sjmDx; 25:EhMfwECDRsaOPdsrwkPeXOEqAWRNpMLAPAqUKHU61BYgjkb5a/h9h+f0EshNgMG/70+wec5b0MeRCJ4r16WK4bzRqWmD9G0giq7bKdMK5BDk2G2cD5T5Enzv//80+mbr6CKVnQPqA47DQjx/ku0nr5rJF+q6uRWQgA7i2HM3nLlPPcLmEcS2CDgL8zHV1ZyeN4T/l5Ri0T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biICQLXuvIgvYpxEQEBHBMjGEc+blN081qANesMngoqqxviOKDhd7rl0DVTKXuha22BzMXWfIOa7zgffFhdp/i93TJzocd/TLU/YQDF71GfH3QxrPxw8AUPdd7KdTxWnB1qCEAFZX7ug2d9PCRqJ4bkxX6Xs1UPBjVP1XbK5Z273N6lmkf8Qd3wjXCjvePIXKxNxC+UxYGa8gZsTNwjxEjfRWVXFUzmDbAJMg== 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)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BY2PR12MB0146; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BY2PR12MB0146; X-Forefront-PRVS: 0417A3FFD2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6029001)(6009001)(39860400002)(199003)(189002)(50466002)(54906002)(6666003)(8936002)(66066001)(4326008)(50226002)(48376002)(47776003)(53936002)(478600001)(25786009)(110136004)(189998001)(76176999)(42186005)(53416004)(5003940100001)(2351001)(68736007)(106356001)(105586002)(3846002)(6116002)(2950100002)(6916009)(2361001)(305945005)(36756003)(50986999)(5660300001)(33646002)(2906002)(101416001)(7736002)(97736004)(81166006)(6486002)(8676002)(81156014)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0146; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BY2PR12MB0146; 23:Bgjkvcyj8jcpUcW96iZYp/9zLFa2jX2v8Rjk3C7jo?= =?us-ascii?Q?fYkaxTm0Jn7WQ0fa1kiE92Bplf+vWHOPVkkjuZO1fxVruI0ydywJfMqzznMz?= =?us-ascii?Q?4e/bt5aG9w2Q1j0XqAdLjVVyQG7AtzwLX4eMyThgclPscdTUclCVasXPX25b?= =?us-ascii?Q?TnpaW8u/yqbbXNgmBQc0StorUW/DvTBM/IwLT7LoR5eLNXdyMg4C1Sbq7cqF?= =?us-ascii?Q?mVseb7daRVlfAAasv6Rlhi9tSzXJtEPqF1uBifkjUaDduckOyMxkx6izj49z?= =?us-ascii?Q?ZQ8VkUHhRXv30XXKGr1zQbjngd3ibP8TaSuqGAX1WC1M7t3xZ5ZDuT5ZbGo/?= =?us-ascii?Q?VuVsQlM4XWHJO4NQaImwxY8+OXRp2a3G1L4t4nX9iJhLTvHX1vldSZq2qzwR?= =?us-ascii?Q?o8VGN3PzqtX9nnfsWFFhf2szohFRlZDyVB+sCO63CxDRTX185JxHZbPPqyL6?= =?us-ascii?Q?c+kCSjbUGKmY4LDZUpNfOTktOXti/eFfkhW/Wy4FTB7UFDRjZqfAiOt8oSuc?= =?us-ascii?Q?r3oVgh3RY1b8Palr1a40XD56T/I8uyLys48h5742J2Jijjs3qO2yMc7bxDzj?= =?us-ascii?Q?Me9Ybfzn8t5VNqyagOAaSOYm474Y+bEMkq+d1bJBVWIFcjzUujyD8ZNO+iN9?= =?us-ascii?Q?+eiEaR+zjONLql1CsTTYZ7JWWaV0qm/5zLypuD6ZeOd4ViBKlJefjGE1cTPH?= =?us-ascii?Q?W0rMO1mh2Xy+8x5AreDMa+NTorA1s/q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1XbW03A60zoIR9BwkcV/80qgss/Ja4sgkAsycQGXu0Bxn9txvCcmM=; 7:ohhByAQauOt6O5n6AFO/2yBAI/uQ5HpC774dNDrpsbcnwo/RwVRtifY3QukyqqZS+6b7lsizBgXo0+vhlDXDQwprhx0XRD+GJm047W88GU/lSz469oN6UiWcv5wuJ3Qs6YgUocS1mfbMUmXPCKLZ4SBmcoOYHtu8325IThIM+tsa8tTMODJDo0i5UPFh/06g2v+qX7WaHGsby7Cw8YQ93u+D+/VfEcQRDgMNENuNYKs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0146; 20:24SONDsBfaj6rG1IBq8nRa/QKSL5SL1du4cxqzLMIalQ4C1n9MffiKvWh3f//s5A8oFzV/DmSRHupmTK7wfmkLxMm4V+0WLfHtTu2WHpfg2nWETIX4O2HBles/zbneA/Zsa+D+blxYq3iKxc6aLMD4hyqWyJSc85V+Ogm6ldxYDsc+QN5/yabk5aIu3SrBBYyDBXQ5xp7Xf3VB+I1HUbQM9WXK7vf6RG2yXjQ3mQWXJUkyvTrijyF+LMzsJ2ctgN X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2017 11:24:26.9782 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0146 Subject: [edk2] [PATCH 2/5] 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" When device is behind the IOMMU, VirtioNetDxe is required to use the device address in bus master operations. RxBuf is allocated using AllocatePool() which returns the system physical address. The patch uses VIRTIO_DEVICE_PROTOCOL.AllocateSharedPage() to allocate the RxBuf and map with BusMasterCommonBuffer so that we can obtain the device address for RxBuf. 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 | 75 ++++++++++++++++---- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 7 +- 4 files changed, 77 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..6052d40fc6cb 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -236,7 +236,7 @@ VirtioNetInitTx ( @param[in,out] Dev The VNET_DEV driver instance about to enter the EfiSimpleNetworkInitialized state. =20 - @retval EFI_OUT_OF_RESOURCES Failed to allocate RX destination area. + @retval EFI_OUT_OF_RESOURCES Failed to allocate or map RX destination a= rea. @return Status codes from VIRTIO_CFG_WRITE(). @retval EFI_SUCCESS RX setup successful. The device is live an= d may already be writing to the receive area. @@ -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,40 @@ 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) { + // + // The RxBuf is shared between guest and hypervisor, use + // AllocateSharedPages() to allocate this memory region and map it with + // BusMasterCommonBuffer so that it can be accessed 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)) { return EFI_OUT_OF_RESOURCES; } =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 +339,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 +353,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 +383,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