From nobody Fri Dec 27 03:25:14 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 1503491049896885.518880347409; Wed, 23 Aug 2017 05:24:09 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 155A221E47D44; 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 17F6121D2E634 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=a1xsqvS31ryoYBnlQepiFNy7YR3E9rrDKKCWw1l0SNo=; b=rxR3p0FGRiyJdzz5nbqF7uguYHjojB3NHJ87ehLifViKcrn+osmXuFDEqIGLMlkzR4e+f6PkuQlnmcvwqMKbWEARQaRD6rhFdn4UR8S2RI1Fx5sljHRHyhgst9Z5svwhFsY4+nbQq5VLjxG7pYaFc9Q0DtXHQJjwaJsOs8hfywg= 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:41 -0400 Message-Id: <1503490967-5559-18-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: 8cb5c258-df26-42e4-4e6c-08d4ea21b516 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:hDruoq8fetSIcD9q68/jxHu+oxwFUt5kSRfRNPApMY/mNGvOAoyHdf+VI62cT+jSaQji6TFAsB7zxPtsv1/03bfbOWZFbj+s3G/PDP83XfICD4dvAuEfOdNisSk/eLkcTfLdj/9TNULN9TMjfwJjXWHIV9ZGLFQbMrNLPCP8fTTXjZOx+22S4pV3krA/RiS7yFR1AKAEA9q2MXHhf3+8o0CpuoCNirytIir7lHMQ4sRWh/4OpwqQlFiUsqG6XDCM; 25:omq6UkeWfLLM18GLV6xPSna80i/MKuShPmi7dx7d0h5+q++x+v/vARY/CUgo5fGr31QjbLFLnPIw2iti7Mpi7DPCIDUC2wZng0VRfLDRi+ATaQ07SiqSgzXSfnT+MqtISeaJgp5myNbjXYwdjwRAxmFfBybaLyFSeCxpecOnlr5B53CGYcGWI08PnSR6l8yjgX4z+P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fc6jpoYF0nIOadySP1SiyQ72WBmSlVvIMKTbWvKWwU0ovLrawDe6yBBV1bzaSpFN5A339yC8hAGzumSAWSV/um8vu05GshQr4l9+Lwjtzt+gEj/QmVc/DDGm75M7b5gQGFzVILwbY4NBwQ2vE/cdVh+nTZHBSpEJfZWQJPkSlx8QWKcwOFMe7SUBPd//aqrgqW/SJOC7KnMkf0rBs8pPHKwgAqTkDKpUATcmlg== 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)(575784001)(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:mOubQM2k/YYU23Vs1HHXpjY6UNzQqGsH5XgKniAUZ?= =?us-ascii?Q?ydN4y166ZoZLcZQKED10bFBEnako/tt1mr4XiNbygYw9e7vgwmmhnQDMxy2b?= =?us-ascii?Q?vRto6hZGBb4cz0MTh2jlq17MD8jxUxHOV+rJ3FGhLfLnGPIqemKLqNN7NqRl?= =?us-ascii?Q?2NbJETyUgiAm+i4rbTvW5ePDMXxA5dGKj7IbYCruhDOdOsDMhYHWNP0835jn?= =?us-ascii?Q?vSnYWqvs3x4jMlUTc1TWnEpTl+KV4JBIz6gE6o3wcLBf8LvxWj04y3J2Maf6?= =?us-ascii?Q?MZPbT3PBKxluk3W63AjSZBE6Z9Te7vbGE2X7WhMLGK/tActjttAQ4t1aAwih?= =?us-ascii?Q?WvbDyQpaZgi8rYTzuTA5xSb0+aFhqhd6hvjv2fzIwfxCJ1/Foo9SPHondmvZ?= =?us-ascii?Q?x218ezzVkRv1Xw9XHw5ggSVK7K5OKQSd3WAYcGWWOClJHB29hU+ZlvUUgn/+?= =?us-ascii?Q?cGfW7/waG+zSmd+jE/o4d0LUTLcNdg/Fee5uTU5ULtJ+2SANifXH9AfECACi?= =?us-ascii?Q?LkK8yUWyTpgi6qjAJR9muUbE9HQuT96Kj2A/wGn8kxe5Ig2ftndzOCF/08IC?= =?us-ascii?Q?9raRPKxDRMCNRpuZXLKxoB66/AsQbdYy9q691tdiZPZVDGCkP8tM9aazCUXf?= =?us-ascii?Q?xLnLkJIeEWKKNbDKKkd9x6vC89G7ahSqLpCSaVkvLXNK85FZf4tLKPvRynUs?= =?us-ascii?Q?tC6TsaKsQZJ0l7OGJ3fCC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6e7p/OcbP0z+WlT7WPeE6N+2rGiAYon/1pAtrORQsFzfSw==; 24:EMO5we3i1rMsnGC+X2knVnOwrJ3JbPdsLAqxbqr5SenQ9Ls0yLJuLSKAn0hoHPjejjXM8YLYRuNqdgfHguh6oQQGTpLwNEm9iX+zAZquK4E=; 7:vwfuAfbao6S0XZyrnt+EYqjJyV/GaDPomLK3Sbg6wteIUA2MidQU+L+B40IPvrXaDbwhykh1DNA35QddQwBjhWI0nqXiZAxj9gPNlypwsqwgKvakU+o0YB0b+djAjFgdypmjwXdWFepq/tSOTcPRL+G0p51lGioJjUCa0vp1CLrWoT1vmfzkMPD9fVHz9/gxTfsFIeRBnryEAHHCkEy4mrrViJWmKjvPmgMmBxN9crU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:cVGfHQPQDA5GWKTeB2ZSrH52QptSEdwfZsybR59coAYTlFkiPXoeBuEnScr/dizyJMVGyVO0Y9S6WpB1y8fKo6ARylCaTEU5KCmgvpRrwGFrVhGrKLbs04yDuOPNhN6VeUcYMR8czr7D5Dm+iCYMwgCbpAtvLZxqm9ndK/0P+zxpBFkk22xkMEq6pLQtaBwG8fyyWvFHcsUzgCZxXoENk13jNMq+Bv0MKS5s0KJGuTXolUEM5iUTXNLH1zj9oWYE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:05.7323 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 17/23] OvmfPkg/VirtioNetDxe: dynamically alloc transmit header 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" A network packets are transmitted by placing them into a transmit queue, each packet is preceded by a VIRTIO_1_0_NET_REQ header. VirtioNetInitTx(), builds the header once and fills the vring descriptors with the system physical address of the VIRTIO_1_0_NET_REQ header. The patch uses VirtIo->AllocateSharedPages() to allocate the header buffer and map it with BusMasterCommonBuffer so that it can be equally accessed by both processor and device. We could map it with BusMasterRead but since the header pointer is used after it was added into vring hence I choose to dynamically allocate it and map it with BusMasterCommonBuffer to avoid the code complexity. 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 | 65 +++++++++++++++++--- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 7 +++ 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index 7df51bd044f5..3efe95a735d8 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -94,7 +94,8 @@ typedef struct { UINT16 TxMaxPending; // VirtioNetInitTx UINT16 TxCurPending; // VirtioNetInitTx UINT16 *TxFreeStack; // VirtioNetInitTx - VIRTIO_1_0_NET_REQ TxSharedReq; // VirtioNetInitTx + VIRTIO_1_0_NET_REQ *TxSharedReq; // VirtioNetInitTx + VOID *TxSharedReqMap; // VirtioMapSharedBuffer UINT16 TxLastUsed; // VirtioNetInitTx } VNET_DEV; =20 diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 0586a82cdf09..9366aa00a1b3 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -101,4 +101,10 @@ VirtioNetExitBoot ( // device is reset. // Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + + // + // Unmap shared Tx request mapping so that hypervisor will not be able t= o get + // readable data after device is reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxSharedReqMap); } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index bdc3fd7ac6a2..3d4eb70aa630 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -18,6 +18,7 @@ **/ =20 #include +#include #include #include =20 @@ -151,8 +152,12 @@ VirtioNetInitTx ( IN OUT VNET_DEV *Dev ) { - UINTN TxSharedReqSize; - UINTN PktIdx; + UINTN TxSharedReqSize; + UINTN PktIdx; + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS DeviceAddress; + UINT64 BufBaseShift; + VOID *TxSharedReqBuffer; =20 Dev->TxMaxPending =3D (UINT16) MIN (Dev->TxRing.QueueSize / 2, VNET_MAX_PENDING); @@ -164,24 +169,60 @@ VirtioNetInitTx ( } =20 // + // Allocate TxSharedReq header and map with BusMasterCommonBuffer so tha= t it + // can be accessed equally by both processor and device. + // + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)), + &TxSharedReqBuffer + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + TxSharedReqBuffer, + sizeof *(Dev->TxSharedReq), + &DeviceAddress, + &Dev->TxSharedReqMap + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_OUT_OF_RESOURCES; + goto FreeBuffer; + } + + Dev->TxSharedReq =3D TxSharedReqBuffer; + + BufBaseShift =3D (UINT64) (UINTN)Dev->TxSharedReq - (UINT64) DeviceAddre= ss; + + ZeroMem ((VOID *) Dev->TxSharedReq, sizeof *(Dev->TxSharedReq)); + + // // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depend= s on // VIRTIO_NET_F_MRG_RXBUF, which we never negotiate. // TxSharedReqSize =3D (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0,= 0)) ? - sizeof Dev->TxSharedReq.V0_9_5 : - sizeof Dev->TxSharedReq; + sizeof ((Dev->TxSharedReq)->V0_9_5) : + sizeof *(Dev->TxSharedReq); =20 for (PktIdx =3D 0; PktIdx < Dev->TxMaxPending; ++PktIdx) { UINT16 DescIdx; + UINT64 Address; =20 DescIdx =3D (UINT16) (2 * PktIdx); Dev->TxFreeStack[PktIdx] =3D DescIdx; =20 + Address =3D (UINTN) Dev->TxSharedReq; + Address +=3D BufBaseShift; + // // For each possibly pending packet, lay out the descriptor for the co= mmon // (unmodified by the host) virtio-net request header. // - Dev->TxRing.Desc[DescIdx].Addr =3D (UINTN) &Dev->TxSharedReq; + Dev->TxRing.Desc[DescIdx].Addr =3D Address; Dev->TxRing.Desc[DescIdx].Len =3D (UINT32) TxSharedReqSize; Dev->TxRing.Desc[DescIdx].Flags =3D VRING_DESC_F_NEXT; Dev->TxRing.Desc[DescIdx].Next =3D (UINT16) (DescIdx + 1); @@ -196,13 +237,13 @@ VirtioNetInitTx ( // // virtio-0.9.5, Appendix C, Packet Transmission // - Dev->TxSharedReq.V0_9_5.Flags =3D 0; - Dev->TxSharedReq.V0_9_5.GsoType =3D VIRTIO_NET_HDR_GSO_NONE; + Dev->TxSharedReq->V0_9_5.Flags =3D 0; + Dev->TxSharedReq->V0_9_5.GsoType =3D VIRTIO_NET_HDR_GSO_NONE; =20 // // For VirtIo 1.0 only -- the field exists, but it is unused // - Dev->TxSharedReq.NumBuffers =3D 0; + Dev->TxSharedReq->NumBuffers =3D 0; =20 // // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device @@ -217,6 +258,14 @@ VirtioNetInitTx ( *Dev->TxRing.Avail.Flags =3D (UINT16) VRING_AVAIL_F_NO_INTERRUPT; =20 return EFI_SUCCESS; + +FreeBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)), + (VOID *) Dev->TxSharedReq + ); + return Status; } =20 =20 diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe= /SnpSharedHelpers.c index 4c9d9ece0790..aeb9e6605f0d 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -54,5 +54,12 @@ VirtioNetShutdownTx ( IN OUT VNET_DEV *Dev ) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxSharedReqMap); + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)), + (VOID *) Dev->TxSharedReq + ); + FreePool (Dev->TxFreeStack); } --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel