From nobody Fri Dec 27 18:23:37 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 1502107200387684.3930758747869; Mon, 7 Aug 2017 05:00:00 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9BDD621DF9699; Mon, 7 Aug 2017 04:57:15 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0049.outbound.protection.outlook.com [104.47.33.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1E8B621DF37A1 for ; Mon, 7 Aug 2017 04:57:14 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59: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=CjS4f3zzSWFd+uyFLlubNRrMRJQSjPkECnaJTA6On80=; b=2HTIgU2V207vYNVNbaBClUv5b6O+L2DCjHeq5OKIE3x0Qm9CnWbbEMfk5+7UNZm7lowwKSLP3Kq/iUJTkI3P4Ahwyl/7WF2L17Qz+MdPMLKYFsPORgyTd3u1zKriBROeLGDEHUzM6m5EuSw/sdDvPiHf7YiI2G8XhgyJXMOCCq8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:55 -0400 Message-Id: <1502107139-412-11-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e7127d0-6ffd-40b8-9542-08d4dd8bc1cb 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:NHUxOPtWOyjjnKWfnR6Hp+5c9NnjrBRCMB16IkZjeP+uLMy6CXnB/QxBKohAnK832smuBEOT1BUo5xwabYcw6GYbel/Vz/BRt4SmJmCudbC++8BXKrUZsDAInh46dYcTsJ/mq7SYxrhn10DPeHUgszoSKzD6NdV00ynjdiJqKXk+S2e1h1u/q5rXa5ZvWOSYXuxcGn5O+m/Z5aniDF4VVWd442L7UdxPHC7ihKA+aQqOu+Jmmbx554jJLwQCsU2n; 25:MkX7mVyRCk/IR/FpZgcdyiyd4/itR2shlUoQk/tNpxT8mRv3dAtvS0aq+rdx1gICILK0hKFMcaJL2EGrWdcW3uDy8N0ObBfZKw3eMNcF0xY16XvjQcHESZVuqFm0/+hueUAt9kHnqE3zYPDu62TnvWr++bldb1DFfFm3lNhNOUoqHMtxRL6Rvn2s4aenc8BB8ce+HrigS6EJXp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EKYkrsDQCMix84c3zorfoXhFkeG3AnXRsGyGRMkFQuALYRfhCUx11gIWpaDR0TMdiqsYvyCM7Rht9uVtpcP5RTQK6JTUYjXKIsQfPWcI/xL7cqosTRCHU3pm2+CVRfqCODRq9ohj9SXs4HBijbcbgMA94e7UhdL2reMmaNx9f8sH8n197PkhQDwiD2t8xTAw0bjFZAboG1OtjSazLAKr20t/Y2brqjVYni7cpDmSDg== 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)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; 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; SN1PR12MB0159; 23:QmgKzY3yXQB53IIQPevNzCuGhRssnDdt18vwjB1F3?= =?us-ascii?Q?KFKOwlEhZN8eJudPP9G0Ihd7cZeDKID9ahCXSEr1k5MZzTI2c1ldyOHKxLUK?= =?us-ascii?Q?E6vAuaeXp/w2d4OOYSUygZ4VnKFTHu+eTjpaQlEvX6a7Tv1cetMgWHQKyHWq?= =?us-ascii?Q?J6Fk0tgu7NX+16cLNiGzbPLr4ZE3CNY4p2MjQhhQ3QKjS8ROwS7XV4sCUeHN?= =?us-ascii?Q?FZeFjAbUWupiZjwhBxvWE5VTE1Ha+SyASyvanZ+fN5iGddFPcJWfDWbK6NIV?= =?us-ascii?Q?u9o0t4H64ciy5uKl4RKVOWIxmg2E5b53FxJB0kPyRDk0GZ76MZs0b2A7Byni?= =?us-ascii?Q?FAd6Ek94gO5Q/yDTM+E5bbi4G6yy9iYJYr6aYi6v3MgQAF75BZ2nskNLw5xJ?= =?us-ascii?Q?1W1PixJvSqyBs3WtITnuc/v3DNvT6n6Xb45nPUE0+rcgxX2Sw80TJcGGFnE1?= =?us-ascii?Q?ZAPqMlA32g9jdj7LRLGsidXLgfnrrozJtVEwGUHqg4rn17zla2RaygzJnyx8?= =?us-ascii?Q?tmvHG/kCTyZ3Ymcg3WumYhGKA1h5F2xLdC3kTaDsxR+0K17MDewWMqu4q93f?= =?us-ascii?Q?Ns9G+9jx4ktpp7IoN8L6If8jmsoiXF0tbRxqvG5R+nopf9OtFdyEdpAwzZql?= =?us-ascii?Q?YZCUxvOPTfhwk/xiOM9QhDOgIOyIjJGVhJy6jS5EnzX976xkfT6e12bPFuT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0WkV5/iv4HTilf6+qq6b9lbkvJlf7zq0Cos7MfZjC24+BmvH2f12tAXI7RvgUd2VXcYtv1MnVoX6D3vf/rZtrGSzMsxyw==; 5:jLX6rRZ1Y2F/sFXmhG3fv3eT2QSWEhdBaRv0IdrcDieDnsbA5YBM17SUyOCtlQsU3zQoGj9vdD6H9hwO2uipWdEu5mDPI9zlO1UZtgzmBDVshQqi8JA7cUhZ7Jq6ZQeQYK2+17x5lP4ZoyDXjb4sDQ==; 24:jHvJVpJPBqD7d90JRpsbXC8wyg02Dg1NA3ZQwEtYhCHBgmw44sWbjwFkddy6y/GAb3ey3VPobRAWZ/OoKTSlChBpUGMXc9O2NPt1EegJEKU=; 7:wwySkivYJIJ0qsWnrgMLshcSE6FM93yLXUuu37cWLguoTjk0t8GN+QfC+LN6vuW4JQd31XomUR7wr8LrjMJhif6Uas5VSy9Ga/4Pwx5CIxkKrrMPqCYA5y9tFBwnajyoSPlwrM0oKljnkkPz4NZwD8pBG/2BJB2N8YxnpGlS/EM1Ozh4xrrqqusn7IsxQL+c2M3ThU7Cb+E9BJ49V3H3I6qgM4hjS6ya5EYKDBI03YE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:fRSyTGxUFlw6PpafRaM5EI6Gq+QiHkNrjaVE80mLqgJcHzfkTzjo+KjgMu+qNhq9QqPTLZSngGxetTdCz5v29ZQS+RgBakJrmdPiaQ9o5ehyHMdM8BZcTxAxJHqb/vDFqIeZk84q22eAuvhtlKXAnYFGRnFqfFcTDnykcJWp5TzQuU+dSWOJ+qz0m//kym2BERGKqXJG3Qcj3SSmf+J+uEwpgk/2S0lMrI6M64tb2KPKOtvm/T49QTDFk1rcAvde X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:28.3402 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 10/14] OvmfPkg/VirtioNetDxe: Allocate Tx and Rx ring using AllocateSharedPage() 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" The Tx and Rx rings are accessed by both guest and hypervisor, allocate the rings using newly added VirtIo->AllocateSharedPages() and map it with BusMasterCommonBuffer 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 | 2 ++ OvmfPkg/VirtioNetDxe/Events.c | 14 ++++++++++++++ OvmfPkg/VirtioNetDxe/SnpInitialize.c | 19 +++++++++++++++++++ OvmfPkg/VirtioNetDxe/SnpShutdown.c | 11 +++++++++++ 4 files changed, 46 insertions(+) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index 710859bc6115..2964c946e26e 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -82,10 +82,12 @@ typedef struct { EFI_HANDLE MacHandle; // VirtioNetDriverBinding= Start =20 VRING RxRing; // VirtioNetInitRing + VOID *RxRingMap; // VirtioNetInitRing UINT8 *RxBuf; // VirtioNetInitRx UINT16 RxLastUsed; // VirtioNetInitRx =20 VRING TxRing; // VirtioNetInitRing + VOID *TxRingMap; // VirtioNetInitRing UINT16 TxMaxPending; // VirtioNetInitTx UINT16 TxCurPending; // VirtioNetInitTx UINT16 *TxFreeStack; // VirtioNetInitTx diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 5be1af6ffbee..9eb129ca2006 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -88,4 +88,18 @@ VirtioNetExitBoot ( if (Dev->Snm.State =3D=3D EfiSimpleNetworkInitialized) { Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); } + + // + // If Rx and Tx Ring exist then unmap it so that hypervisor is not able = to + // get readable data after device is reset. + // + if (Dev->TxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->TxRing, Dev->TxRingMap); + Dev->TxRingMap =3D NULL; + } + + if (Dev->RxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->RxRing, Dev->RxRingMap); + Dev->RxRingMap =3D NULL; + } } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 6d9b81a9f939..cbc9c51cb643 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -461,11 +461,21 @@ VirtioNetInitialize ( goto DeviceFailed; } =20 + Status =3D VirtioRingMap (Dev->VirtIo, &Dev->RxRing, &Dev->RxRingMap); + if (EFI_ERROR (Status)) { + goto ReleaseRxRing; + } + Status =3D VirtioNetInitRing (Dev, VIRTIO_NET_Q_TX, &Dev->TxRing); if (EFI_ERROR (Status)) { goto ReleaseRxRing; } =20 + Status =3D VirtioRingMap (Dev->VirtIo, &Dev->TxRing, &Dev->TxRingMap); + if (EFI_ERROR (Status)) { + goto ReleaseTxRing; + } + // // step 5 -- keep only the features we want // @@ -510,9 +520,18 @@ AbortDevice: Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); =20 ReleaseTxRing: + if (Dev->TxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->TxRing, Dev->TxRingMap); + Dev->TxRingMap =3D NULL; + } + VirtioRingUninit (Dev->VirtIo, &Dev->TxRing); =20 ReleaseRxRing: + if (Dev->RxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->TxRing, Dev->RxRingMap); + Dev->TxRingMap =3D NULL; + } VirtioRingUninit (Dev->VirtIo, &Dev->RxRing); =20 DeviceFailed: diff --git a/OvmfPkg/VirtioNetDxe/SnpShutdown.c b/OvmfPkg/VirtioNetDxe/SnpS= hutdown.c index 5e84191fbbdd..08524ab94006 100644 --- a/OvmfPkg/VirtioNetDxe/SnpShutdown.c +++ b/OvmfPkg/VirtioNetDxe/SnpShutdown.c @@ -65,6 +65,17 @@ VirtioNetShutdown ( } =20 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + if (Dev->RxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->RxRing, Dev->RxRingMap); + Dev->RxRingMap =3D NULL; + } + + if (Dev->TxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->TxRing, Dev->TxRingMap); + Dev->TxRingMap =3D NULL; + } + VirtioNetShutdownRx (Dev); VirtioNetShutdownTx (Dev); VirtioRingUninit (Dev->VirtIo, &Dev->TxRing); --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel