From nobody Fri Dec 27 02:41:19 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 150426507965812.61003496679848; Fri, 1 Sep 2017 04:24:39 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5016C21E74908; Fri, 1 Sep 2017 04:21:47 -0700 (PDT) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0075.outbound.protection.outlook.com [104.47.34.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BB28421E7491D for ; Fri, 1 Sep 2017 04:21:45 -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:28 +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=BRUHN2+GDOktaHMqYoyJxmO4rI+iJUOgD6Xq6DvWUvY=; b=2n3st5tabPQrhbazLzttqxD9KIFo0LG9K7dEhW+zKMsDGqAvQPh/+/jjeyqs2OhZSg0swCcEPf+zLQwbUuw3dl4r4Iw+5+2kJIwT58lRhHeTO5hZQ6rJ8DTARfEDUvLILg7miTVZdvLhbCO/m7SefJ6//ueppkOg5YJRJdVQ4bU= 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:03 -0400 Message-Id: <1504265045-19008-4-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: 15e6ebdf-3a8d-451e-e992-08d4f12c02b3 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:1V0ug/3EZY9jhSCBItp4sCFkej3jicGfSE0LShtEjJi2iE0YAqYJZ+ojdg8gMmWLlqL09cq+0vBTOCotkc+DPtztGzLOiDPiNj3dgC1v1CssogWo119ymSuGlZSds2oa1xsdSZsfxzYSlkw6KBYSxTPnHfug+w+04rOcrwADo70y7x3rrzad/j+uW7H964am0/gGZ2poB7Ixxlq2irbNxDSHivlVfveFy7rrtfkoSePj7Qh0ImTXhRK7u+QAgFZA; 25:UJL5I3LaULVnDzSoHCx7ydc1BzEOWi0J+S+er5JZJ08PyOWPFIUDjBlTU8aq4BlzqqmYujqj/dWEP9ErPxLUujH3kkRllVx0mZuDc3LMph3tadUx/fb+B+41Qby9u59GIz7YuIHUjgoRFg+UpEQfRkmwdfMamn0U4LNe8eTiLO/SItdw/CwyiUdHVICs7Qz0HYSMvqOdqBn+8C9D6nlTb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8SvUbOnYViA/sFa1rRmK4812UBV/Jt2LbYPKwYFWG2ks4jv7OKQYpdogVge85ah+YtMic+oyRT5DKm7p1k6QfkBrdoSx1uaHSPi8rA0+To24TdFPN4KNyDq2fL4NMCZrMK+jOD3LdcBJTSsj9HM93jNGdMOkwf7F6STjACqTKUy5pzlYK17qix7sCkjzg2avIE00IV6f7FbDNFLSNFGEfC6+iSgkN8ViA== 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)(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)(575784001)(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:luSgLZSuFPEdJdwVNJaKRV6h1jdORhVtp4F56SDtl?= =?us-ascii?Q?wHtH2p4QkvKQj9LEU+z8hdjQUXEv4MgVQqBkveZGr1Dl/r6G1sUQCIOiU5WA?= =?us-ascii?Q?i4M/H/Q6y9OS5baG73e+3N9w/O7UgRUhTNuZC5iwnHcS7V6KRm2i5VAQlD/b?= =?us-ascii?Q?oBYfd3tU+HgIyKMjR7SMUExUdUaUJX19OlyCnEI+zMOnyDXjHUzVehbXecUf?= =?us-ascii?Q?pOl1b/nlBkc8PtBbE7l60ow9QRxlNuTNXeBikQrYgY1zjUzreB9a+gnbEK94?= =?us-ascii?Q?yTbdp/zR4QoEXWWM7LcmJ3ItEfBNfS06Qf+i+x9QHRrqTmzYpTPEKAbaYZ+k?= =?us-ascii?Q?nLPuAFVIm4k/R/F+N8xz25zQNGZSYNSYIyExihwh612Ho/5AV8Wu8v9/SiLg?= =?us-ascii?Q?NgvAFSSWF7j2aLHbfNHMenQgzKC8SPz7cQTQtnTfQSLGre953tsQMcgPBxro?= =?us-ascii?Q?E9dYqk/01XowrUK9JhmMhPMoEbrGhcmrRS4cYmcyB98IQjtTVlFQY/tD1gF7?= =?us-ascii?Q?yNFKoJ2YycHCSaHaiUIVgDxGGGYGbxMiwSTDcxneFJUjvgbu9bZKkcLVEmfQ?= =?us-ascii?Q?vSh+OyyZDsNbW1zW0UYyj/b8Ro2RsKdQey9lIKd3OGjER4f2AD5Nhtu2qzQc?= =?us-ascii?Q?OK29jJAu1imYCF8zq5+YfVffq9Bjjjdi4PLnM8SUQKttePzBD5auefplYlAD?= =?us-ascii?Q?9G0xZlQq3icgQ9EDDBUEUv+tLyUxaIZPE/j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s3ScEkopQ4RoOwq+W71CQzU4fl3hKWHOItoU2ca6MK362B1GOjVDCW+m93DDE8VIozPICKCWczvmRVA=; 7:rOT/Cqbc0jXd8773QpYeFlT35ThGoqyKCsfodgRwSqLutM+f4KZzAmLLIipNUxxDdApuqdQS3rfHU3bJ8SOyVAczLGjl7EfHpO8yXgfDU36hQjlJKyrSV26EgYlbfeD9iwoqQimIAG3N1jBx2TmSE5hlpednO9fizhW6Yvy33iR3fMt5xA98f5ljY3C7mEDSDnHe1v611rP+OYsPjxApc1nBM951RW5eqSkWcPKj21k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0146; 20:hB03j9bma1xWzUIIhnlQmaSLm5aDbYgtX+3a/m59SMQ4uiN4y+8j5QWtheaEdAOSGWFtx6taKhDmU57KVOOPp0kXFlRx7qsXXA7BUAt6ygTTWssM/IbaB61o6kwREA8Kb0tlRYplxJePCKDqQy1ZMeaV7PFQeBLbSQY/1m09sqAi/UIJQ5IyWK+Q48TFf9FFcyaiiH+Sk85ucaEqi42QL0Ux9Xv6hEuke/EiDrisUHGAad7OoepN01twTAO1zsDW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2017 11:24:28.2907 (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 3/5] 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. When device is behind the IOMMU, VirtioNet driver is required to provide the device address of VIRTIO_1_0_NET_REQ header. In this patch we dynamically allocate the header using AllocateSharedPages() and map with BusMasterCommonBuffer so that header can be accessed by both processor and the 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 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 6052d40fc6cb..551820e30f36 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