From nobody Thu Dec 26 13:13:12 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 1503697435166434.463146090136; Fri, 25 Aug 2017 14:43:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A4E5A2095B9D4; Fri, 25 Aug 2017 14:41:14 -0700 (PDT) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0074.outbound.protection.outlook.com [104.47.36.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 332AA2095AE72 for ; Fri, 25 Aug 2017 14:41:13 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0156.namprd12.prod.outlook.com (2a01:111:e400:50ce::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Fri, 25 Aug 2017 21:43:46 +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=F/NsL1gY72+TKo8SxA73hUgWolyO8q3fqY40oIZ/AQw=; b=oNFtBVa2D30hKN5FJqmjVGu2hqD/fwgO5cbEHL3NO10QX9Mw9/gfsSYNdmeN7p8idovEFYc32moVCvYxdBb+kUQAuJT7tFkyJyUa1IlKXyI91qN9EpflupAtCVOkm8Ipwmq7G+QINq2JnMz59/HZOcJKJvu94NZPoD0DFzhH/MI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Fri, 25 Aug 2017 17:43:32 -0400 Message-Id: <1503697414-6830-2-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503697414-6830-1-git-send-email-brijesh.singh@amd.com> References: <1503697414-6830-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR2201CA0041.namprd22.prod.outlook.com (2603:10b6:301:16::15) To DM2PR12MB0156.namprd12.prod.outlook.com (2a01:111:e400:50ce::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7153634e-f6ad-45ec-c664-08d4ec025dd4 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0156; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 3:2rZd0bWQev1BmfH1pj1+VArIFnSrGwHVMZYzZHlhnojBEV4+U3yxV8+pB6UW5/FufTlbgPoxTgODnCqc52uzkjVDGBewbCi+oavTWbsnD2BOy4pc2s9JPgwDzrSTTTFhWO9e5kREHpNFrV6/X+eMQblb7XS8RBnks7B1c4QOfb6OmS/KNyGKvQBfFDTTVFxdqaPpx0SxFujkf7+wJxn8EExcINVjZZOaMnNBRA1UbgdrTSHWZPu26xcXiIyJWb04; 25:7CnM/CLs2hi9YKfYIOnSbmAATDS5+VyO9rZmXlU9YI02XYpsWglwKVG5QxJJwTTqQPQaqZEkp3y1o8E1/WmtlskhUFzBzh/Wttl0QWI9ec9bSxN+t/WVR4m+Hl7CVDV1s6G2nprqFlyUHQpgrbMg/Mq/Xd/F8dqyMBF+8kSzi6CfGET4ZrEO1ZCOgN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NW4g5754Ep2ssvHmhV1Cr4OwsejvQyBqbbZAb3AxjJReRrGGU1Fx0R2jIjmbOCKapb8r6M5IxCHnd66gHj8ahHNPaUPuMPDTZg5+5Rk+ihxl2w0vmMpi3T71XLpSU998aoqUN4UPT12iBRbn1kQn94WPMEAE4dCITpPq0l3UuGc1D2Zil67kWl+IR9KkNTK4ac5rjK3seNnUYrUVMRouPXLbuWf1DEBJE02tdGh339NjPW3sJwEmBZRFgYTvkSrh0eAGeIQ== 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)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0156; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0156; X-Forefront-PRVS: 041032FF37 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(51234002)(199003)(189002)(97736004)(54906002)(86362001)(47776003)(5660300001)(110136004)(48376002)(4326008)(7736002)(305945005)(575784001)(53936002)(68736007)(105586002)(50466002)(5003940100001)(6486002)(7350300001)(2950100002)(8676002)(76176999)(101416001)(6666003)(6116002)(50986999)(478600001)(106356001)(66066001)(2906002)(25786009)(81156014)(53416004)(189998001)(33646002)(50226002)(81166006)(3846002)(36756003)(42186005)(2361001)(2351001)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0156; 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; DM2PR12MB0156; 23:uKqSAy/R3osPae9Tr9zET7yjDJICq6uewUqGmWosU?= =?us-ascii?Q?rNWPOl5oqlwW7Xq0TM69yKPGUXPYbPuN0+TzpxlgR4B2HxEk94BEdrjm/NOU?= =?us-ascii?Q?8oTwDKDgQL7nc5k5NAhGSXF7HifQrDAPJjAMKMCEBuVFGV/5iJBzrx7T6wGq?= =?us-ascii?Q?ymJHy+217pcECBrP5mhwls62ZQKddW63L+uJtSJa7CDQ2pSv9HTzQdYU41cX?= =?us-ascii?Q?jKaHjdvEMMsYLltqR0WKFZw/UzswzqAUomStG+ADBia/A9kLvx2/YSyyzrOH?= =?us-ascii?Q?XZF/5QS0QWvRn9KIeMZBTIfkELbiaMD4tHxi9HkYslnG2fd59HQwI8Wd2Vi0?= =?us-ascii?Q?z2gHLU3S0qmeP1fudUr34BmldtwVf5Gkk6JTl/HLWt4U82G4i3YUKizUlpVd?= =?us-ascii?Q?XmHzeWmSk0ZXjMBamSkWANdXQFj3Nnc7KMXmkmOIta8gDGhwiaondYwLcrjJ?= =?us-ascii?Q?8OjEEE9XQXRXndtJdp9LqTY8q0+FK36gZ14GzyxlFHdsalDRBlO+VGk7EulN?= =?us-ascii?Q?xiZ7AEVdYY0ROdID6vRje6udxKszkjBgMsZcB6m6dUnkRJHr5crN/StE55Uy?= =?us-ascii?Q?2RDWAY2uxwCzMMGimw+I+nJDx1XwN5n7efZmWWQRX2GeRBEm3kt79MP1hgcr?= =?us-ascii?Q?f+mtBNtVHxI4/y0aack6mBjPxg4UyiV4DXM/19soVo0E5kOWv4GqbOc7+mp4?= =?us-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Dwjtk0fy/YdNUfK3B7ZL/hHrmofSVt1qdSM+jLUsmdknPq/o9DIqPWN6z+Eiu93aGmVUuSxiDYvyCz3u0NduyyPz2h1sowSK3aGsRzjTBU6Cw==; 24:WNGykg6YsWzSnFcFQPEObfvBjqBRT/BU1ijZPWrMvaA7181S41vAtQmE4qtozrW9ACGqXQ5PNaNQNTol952jqH5yBfMnpew54+DhKwkTVao=; 7:8Opyur4cODlTV0CntMo+zFifB7mcmNXRvjdopRazvxtRr3XD+YqnPbE9/lb1PnKecu+yza5edVx38yyAwqofyQmSRdUua6k4zB9TPduylIeyG+fXdN1WSCTkJOx6XwGLPzAEt9qG38rge1BKDPXMeQcsYietKhVcPSL/+yIuanQ7OcqZmc/gWfKK9iYx996Eif3W0XU3paYXxeHKKAdkxTo84AhVQOPZ890NpiEEN2M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 20:p3eLXAisMiF2K+skQWA1av49vEquiXOnxMGBQ+pJ87Ld1EEPNFPCFyUOqZFowc0q5w7PxiJz80KEBUzTfBNGSHP590hCiVv99Q4z5IEBljtwA60wTPy07O2EpTxcncqNFTEORXqjeCT4nOURSYZbGA5RNYB2A38/golctUosQ7wYzFsazmxqfvuhcVPIYPYIdNlqWA7oBL4xPMIjrSwduI9fr/QTBXiJ0IVSHt9Bjce1JWSoR1RSDPnEPhNjpP9s X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 21:43:46.7210 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0156 Subject: [edk2] [PATCH 1/3] OvmfPkg/VirtioBlkDxe: map VRING using VirtioRingMap() 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 then driver need to pass the device address when programing the bus master. The patch uses VirtioRingMap() to map the VRING system physical address to device address. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/VirtioBlkDxe/VirtioBlk.h | 1 + OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 45 ++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.h index 6c402ca88ea4..9ec0b956b818 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.h @@ -41,6 +41,7 @@ typedef struct { VRING Ring; // VirtioRingInit 2 EFI_BLOCK_IO_PROTOCOL BlockIo; // VirtioBlkInit 1 EFI_BLOCK_IO_MEDIA BlockIoMedia; // VirtioBlkInit 1 + VOID *RingMap; // VirtioRingMap 2 } VBLK_DEV; =20 #define VIRTIO_BLK_FROM_BLOCK_IO(BlockIoPointer) \ diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.c index bff15fe3add1..663ba281ab73 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -580,7 +580,8 @@ VirtioBlkDriverBindingSupported ( virtio-blk attributes the host provides. =20 @return Error codes from VirtioRingInit() or - VIRTIO_CFG_READ() / VIRTIO_CFG_WRITE(). + VIRTIO_CFG_READ() / VIRTIO_CFG_WRITE or + VirtioRingMap(). =20 **/ =20 @@ -601,6 +602,7 @@ VirtioBlkInit ( UINT8 AlignmentOffset; UINT32 OptIoSize; UINT16 QueueSize; + UINT64 RingBaseShift; =20 PhysicalBlockExp =3D 0; AlignmentOffset =3D 0; @@ -729,25 +731,42 @@ VirtioBlkInit ( } =20 // + // If anything fails from here on, we must release the ring resources + // + Status =3D VirtioRingMap ( + Dev->VirtIo, + &Dev->Ring, + &RingBaseShift, + &Dev->RingMap + ); + if (EFI_ERROR (Status)) { + goto ReleaseQueue; + } + + // // Additional steps for MMIO: align the queue appropriately, and set the - // size. If anything fails from here on, we must release the ring resour= ces. + // size. If anything fails from here on, we must unmap the ring resource= s. // Status =3D Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 Status =3D Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // // step 4c -- Report GPFN (guest-physical frame number) of queue. // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0); + Status =3D Dev->VirtIo->SetQueueAddress ( + Dev->VirtIo, + &Dev->Ring, + RingBaseShift + ); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 =20 @@ -758,7 +777,7 @@ VirtioBlkInit ( Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } } =20 @@ -768,7 +787,7 @@ VirtioBlkInit ( NextDevStat |=3D VSTAT_DRIVER_OK; Status =3D Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -811,6 +830,9 @@ VirtioBlkInit ( } return EFI_SUCCESS; =20 +UnmapQueue: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); + ReleaseQueue: VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 @@ -849,6 +871,7 @@ VirtioBlkUninit ( // Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); =20 + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00); @@ -885,6 +908,12 @@ VirtioBlkExitBoot ( // Dev =3D Context; Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + // + // Unmap the ring buffer so that hypervisor will not be able to get + // readable data after device is reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); } =20 /** --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:13:12 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 1503697437694201.15352881384342; Fri, 25 Aug 2017 14:43:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E830B2095DC99; Fri, 25 Aug 2017 14:41:14 -0700 (PDT) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0074.outbound.protection.outlook.com [104.47.36.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7E0DF2095B9C1 for ; Fri, 25 Aug 2017 14:41:13 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0156.namprd12.prod.outlook.com (2a01:111:e400:50ce::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Fri, 25 Aug 2017 21:43:47 +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=Rd6zM54aL5sXFOKdXOzdreScP0dvo2cpqFEf1U/809U=; b=dh+dLvhS5NB5rO+Bcq4KyMgjING+60wOHRHhoqLo8CDyYge+Bf2Nw/pWrDTXekH0EFieABtwJXhQvoFNFnk3WBNUAYGY5YXTTtiXwnjPHVVAMyarcnbKqJeQ3fLBrie9sqxwCgH8F7b/znnxkDCrcolwzhUaAVkOjvoSgXWDQcY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Fri, 25 Aug 2017 17:43:33 -0400 Message-Id: <1503697414-6830-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503697414-6830-1-git-send-email-brijesh.singh@amd.com> References: <1503697414-6830-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR2201CA0041.namprd22.prod.outlook.com (2603:10b6:301:16::15) To DM2PR12MB0156.namprd12.prod.outlook.com (2a01:111:e400:50ce::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7945dbbc-8003-4b6b-2225-08d4ec025e72 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0156; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 3:P2wVw8Ap7beMFnudmZRuiNeszuQEETM/1n0mH3sCOg0smC/l+Gpl97u9zzux2ZerFuvLl5Qn8vZnXZ9CqQmJUH+JZRAzZcnV9Un0G6ngBjvuuqgnuHllJtTkvlHINNMZYjrk+N+Pe5P2D2tgzdCBULmA4BhjMCWoxmvYjG7M9yRZ4G7I8kcmjAujCqeIAXQqIg5zazICisHFdha9B5o6TTvybq6UYUg2I5AfSd7/0Aglf//g0jj5gEmjYI1w0Lar; 25:DLtSVmDvuihNDjKWSjBZ2DZoCZw5j0VKJtkQi8V+gN9W9C3RCDJ0RjFUYwFPv0F1Zq4kd/6vST6FLh4scOfsU4ePG+fEuFaZsC/OjKH1HigKKUphRRWS/M3cNJMmocZmGb+akEt9YPHhAHNbHLRFipMgK2vRxJBUTGuD9tnQRALkVYHvLwfxBlY28y56Y3J1RMpauHOussG6FEupJT/dUTXy03ihic1dZAJAdLHEhkB3cLb+tUxtKYGE/kCT01VjZSa63KvkppzXjLyIVEslgENbSD0LC/YrGRxDwgcdhVqsRuLUeDUWG4xXPLNUcldNrwF6T+cvtiAJWOw8Dh5VEw==; 31:Ezj0VL+2OI3drri+R0oM1hFntsm/QL99ysqHtWNBLv9eEIfLwtBj8qRT/jOJ8Yy6c/V06OQo2cXoW+48s0035uJ5pBVXvgJwdqesuRphDTaRT7M1D/Vk8a0MORViOWdOF7kaOUG6EMFWHPUwUUah8/SDM7/aD/h4c9fdi0kOIlmjhv1a6hShKtMdfoFagaq68i1+35lo1b1O1pH8SAPejMNRNo3hQ5map5xOoog23Pc= X-MS-TrafficTypeDiagnostic: DM2PR12MB0156: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 20:UUgRlf6ITEtcjXMInKp2G/2F1TxBgkSwT9lKPp9KiTMnK0h6uVKQlzYMposoxYCIEeUxj04Bmj9UtQcaxEVhaIMzNNv64mdlAb5cYRs9jU9MDyNRvOLjHwKd0HcupBH3o31Si3IWQFXPiT1yaKe3Xxtq73F4fHBZ31ZVC3gqhQpteOebgOjN5e2tH54Z5kfr9MGXzQizA3uf8JMCOYAdZxKTjyrmzmeS93X4/iseaYN1KryBRSO7XY6+Ob6gJy5oBVV0/FMIQMoG7uUmR6Fc3d2uccMUonpBDl10SnRgs5fl256nmyDuOMzTFVz7rkqQAXaVngbWSGyFVzmOreU1kfgUuZQWgmPz55/r1MWL5SJjpJmwVfQRfKvfUY/6mzZyX8mQgLbt8BYCOwnLDSgeOv9ewAkIi49Vz9R7R7h9X7BkuGHANRiz74yujhRP1p6J0ovnry9p3DLkLzsgZYl6v/LfiAhVR/6nGCG4G8ztcAMMHDo+pD3v43+TmnF12JuM; 4:Qg8u8qRZa81gE1X0/OaoyUQ1G6bq7RCOw1dU4MHC1ynw5Yf/xvXQMLWtCHYGi3Y0kfsSRo0nUIZvrbHBmIOVG3B8WH1aqXNavmryiGpxcgmKHUKlESfgFAKb1f7n0YwNA5d7g08fAzUOive2AoLjoNBV2r/al23X68PsN6YdbIPlDfU8+1CHWtFCVNrjNA+MXkWQFP9H4SCqUYv2DFlTGPB2S+V0kMTfbNW4W2JeyDI4ya3Umwtyox20FIpchcNpExm7uLRmHopwjKNaDt0ubBCX/TuG4xT/4WJMElzDSAVaqN3QQs7+8I05ig0wKOkTWPmhieKIhPDMg5BEhFnwwQ== 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)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0156; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0156; X-Forefront-PRVS: 041032FF37 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(199003)(189002)(97736004)(54906002)(86362001)(47776003)(5660300001)(110136004)(48376002)(4326008)(7736002)(305945005)(53936002)(68736007)(105586002)(50466002)(5003940100001)(6486002)(7350300001)(2950100002)(8676002)(76176999)(101416001)(6666003)(6116002)(50986999)(478600001)(106356001)(66066001)(2906002)(25786009)(81156014)(53416004)(189998001)(33646002)(50226002)(81166006)(3846002)(36756003)(42186005)(2361001)(2351001)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0156; 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; DM2PR12MB0156; 23:VIFEaYaUJRtt472zH/SY/ksYuGVpekSq/4TuUPD/O?= =?us-ascii?Q?eLq4b+fy0C2nzr1dx00g8Qd8qMjl3wnk3xonPlgmvtFO+ZvDERnEgRUxRl6P?= =?us-ascii?Q?1vnk+mS6ugs/m/sKgmQFWZm9VokEW6/zvtCV6Xs6yFy1jOoWWxD1eSIQXuEo?= =?us-ascii?Q?gg+oazdGqq6nXNx+cEO5UIfvtjAP8jmUQmUxe/L3nZfo4pXuyL7o8kGx8rVC?= =?us-ascii?Q?2CWTnDHwPqDG+ap0boNxE6Gq7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eVHFoIA?= =?us-ascii?Q?o5WAQPUJswZaj4BpIzoOcQHdJ+4ckWE?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 6:eSCdhPY3qysx8i5wd0tGABpZVHuBUiXSXLZfwYZ+c9PgdS3YyD5Hr5z60it6Tf2h9WqTlqqIkdKfs9Natl/0euo6heQZAef5jMkzxtLlIVWsbt1w9fFDag5T4QrlPc94cajK5fINVW2pCDCAA9MLorA88vJNMBwV49RBFzP+gZ7wOK2Pw980EEbgYNGnDPdetL/r2BLRGF3P6UEX+kjH7sAtW30KhfVnE6E+PONSuf+/q9q36b7psRmOmVd5a/F9JN17NOtnMyBztcl5oKHztGiKW3DxeopdUD9Yo3l0xVctwz8GP3+qzfA0qXI19FNLeiOxE0y/07gFh9q50LzyHg==; 5:0JhlLX8dNzrxmJ7isJRBftL5tU2+BHDfh4TDvBN9ewI1MHLiM0tl0tucQTMyJro6OXS4ZTHT4h4NANGR4TrVVVe7+Y5qNhnkEdnfhKWJ6iUZRHiVnq/Upcr/x+6wt9Zh6PYz/pUYsaIuI5CX/tyOuQ==; 24:7KmVwd+P+JAOkmu7NFxNmytFsRucflEvF3mfbxw/Z4YAczTUk36v1QCYpwt6tLwki7qihG2/Uf0DtWciD3OqQOFTu/X9rC9SKaw+hWHYCNc=; 7:sx9+C9L0tr3Gq+qWZDX64nyunjSv+olTvrwIpOR5SBqVphY0oOAoeFKhx0fUp/jAODDsPVDgs4OVnVmhWt9uN586haDStrddXt3Pnab6Eb2Xl+rJT6G6Cu2MiDWaDtvNYQ4VytA+U3AWHHQxP67u+ZxYb9gjDlcvFbhRGBjjlW+YD08nxfOJGZskweId8ObeUy5ASav2UZ3cRxXL+cRS5v8aoAkYed9ovKlU83SNdGg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 20:HGdhRLjxGkxO/NxaDrv7kBCbktekJ5RCE/OHtz2q2DIAT9dcKhuXhrvJv8hni6Awt/wNQw57aQJqD7bNVAADxQX0zpLPlNW5iHJpmfsI9JthLA5zUPZ2T6tpvEL/eDnGom/4xNxj6VB/nuCBF0nTNYyS6qI5ChDyVncHwnTIp8qxINYr8XZAMMC5xv4sG8ys7OiCx3852NoJMtlK9rxN/D6gnLohEVHoTyOF2JjsjUyyVuqULoWYiTmcnT8QBNur X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 21:43:47.7522 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0156 Subject: [edk2] [PATCH 2/3] Ovmfpkg/VirtioBlkDxe: map virtio-blk request and response buffers 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, driver is require to pass the device address of virtio request, response and any memory referenced by those request/response to the bus master. The patch uses IOMMU-like member functions from VIRTIO_DEVICE_PROTOCOL to map request and response buffers system physical address to the device address. - If the buffer need to be accessed by both the processor and a bus master then map with BusMasterCommonBuffer. - If the buffer need to be accessed for a write operation by a bus master then map with BusMasterWrite. - If the buffer need to be accessed for a read operation by a bus master then map with BusMasterRead. 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/VirtioBlkDxe/VirtioBlk.c | 157 ++++++++++++++++++-- 1 file changed, 143 insertions(+), 14 deletions(-) diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.c index 663ba281ab73..ab69cb08a625 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -232,7 +232,8 @@ VerifyReadWriteRequest ( =20 @retval EFI_DEVICE_ERROR Failed to notify host side via VirtIo write= , or unable to parse host response, or host resp= onse - is not VIRTIO_BLK_S_OK. + is not VIRTIO_BLK_S_OK or failed to map Buf= fer + for a bus master operation. =20 **/ =20 @@ -249,8 +250,16 @@ SynchronousRequest ( { UINT32 BlockSize; volatile VIRTIO_BLK_REQ Request; - volatile UINT8 HostStatus; + volatile UINT8 *HostStatus; + VOID *HostStatusBuffer; DESC_INDICES Indices; + VOID *RequestMapping; + VOID *StatusMapping; + VOID *BufferMapping; + EFI_PHYSICAL_ADDRESS BufferDeviceAddress; + EFI_PHYSICAL_ADDRESS HostStatusDeviceAddress; + EFI_PHYSICAL_ADDRESS RequestDeviceAddress; + EFI_STATUS Status, Ret; =20 BlockSize =3D Dev->BlockIoMedia.BlockSize; =20 @@ -278,9 +287,89 @@ SynchronousRequest ( VirtioPrepare (&Dev->Ring, &Indices); =20 // + // Host status is bi-directional (we preset with a value and expect the + // device to update it). Allocate a host status buffer which can be mapp= ed + // to access equally by both processor and the device. + // + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *HostStatus), + &HostStatusBuffer + ); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + + // + // Map virtio-blk request header (must be done after request header is + // populated) + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + (VOID *) &Request, + sizeof Request, + &RequestDeviceAddress, + &RequestMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto FreeHostStatusBuffer; + } + + // + // Map data buffer + // + if (BufferSize > 0) { + if (RequestIsWrite) { + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + (VOID *) Buffer, + BufferSize, + &BufferDeviceAddress, + &BufferMapping + ); + } else { + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterWrite, + (VOID *) Buffer, + BufferSize, + &BufferDeviceAddress, + &BufferMapping + ); + } + + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapRequestBuffer; + } + } + + // + // Map the Status Buffer with VirtioOperationBusMasterCommonBuffer so th= at + // both processor and device can access it. + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + HostStatusBuffer, + sizeof *HostStatus, + &HostStatusDeviceAddress, + &StatusMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapDataBuffer; + } + + HostStatus =3D HostStatusBuffer; + + // // preset a host status for ourselves that we do not accept as success // - HostStatus =3D VIRTIO_BLK_S_IOERR; + *HostStatus =3D VIRTIO_BLK_S_IOERR; =20 // // ensured by VirtioBlkInit() -- this predicate, in combination with the @@ -291,8 +380,13 @@ SynchronousRequest ( // // virtio-blk header in first desc // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Request, sizeof Request, - VRING_DESC_F_NEXT, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + RequestDeviceAddress, + sizeof Request, + VRING_DESC_F_NEXT, + &Indices + ); =20 // // data buffer for read/write in second desc @@ -311,27 +405,62 @@ SynchronousRequest ( // // VRING_DESC_F_WRITE is interpreted from the host's point of view. // - VirtioAppendDesc (&Dev->Ring, (UINTN) Buffer, (UINT32) BufferSize, + VirtioAppendDesc ( + &Dev->Ring, + BufferDeviceAddress, + (UINT32) BufferSize, VRING_DESC_F_NEXT | (RequestIsWrite ? 0 : VRING_DESC_F_WRITE), - &Indices); + &Indices + ); } =20 // // host status in last (second or third) desc // - VirtioAppendDesc (&Dev->Ring, (UINTN) &HostStatus, sizeof HostStatus, - VRING_DESC_F_WRITE, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + HostStatusDeviceAddress, + sizeof *HostStatus, + VRING_DESC_F_WRITE, + &Indices + ); =20 // // virtio-blk's only virtqueue is #0, called "requestq" (see Appendix D). // - if (VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, - NULL) =3D=3D EFI_SUCCESS && - HostStatus =3D=3D VIRTIO_BLK_S_OK) { - return EFI_SUCCESS; + Status =3D VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, NULL); + + // + // Unmap the HostStatus buffer before accessing it + // + Ret =3D Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, StatusMapping); + if (EFI_ERROR (Ret)) { + Status =3D EFI_DEVICE_ERROR; + } + + if (!EFI_ERROR (Status) && + *HostStatus =3D=3D VIRTIO_BLK_S_OK) { + Status =3D EFI_SUCCESS; + } else { + Status =3D EFI_DEVICE_ERROR; } =20 - return EFI_DEVICE_ERROR; +UnmapDataBuffer: + if (BufferSize > 0) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping); + } + +UnmapRequestBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, RequestMapping); + +FreeHostStatusBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *HostStatus), + HostStatusBuffer + ); + + return Status; } =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:13:12 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 1503697441047284.25414345625745; Fri, 25 Aug 2017 14:44:01 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2EA0F2095E01F; Fri, 25 Aug 2017 14:41:15 -0700 (PDT) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0074.outbound.protection.outlook.com [104.47.36.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BAEB02095AE71 for ; Fri, 25 Aug 2017 14:41:13 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0156.namprd12.prod.outlook.com (2a01:111:e400:50ce::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Fri, 25 Aug 2017 21:43:48 +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=NaaglaFg/ZwCF3X4hy+HOFIkJ8k1tM3sX9eCY0vl3ow=; b=V0wLUY1kw2p0XhROT6s7b78MQTO7Kt7Y557IzY2QQkSyA5qfBRSqaVle7RvBbLGrFOrdUt1ji12zP1lc/xH3RM5ccPAzL9UneVR7Z6sUjUd0/gDJWkacUcc6ccvs291hyG6Z1ZrhbUGNceOuN36uDmXbIKZggOK4QydTYyLC5Ag= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Fri, 25 Aug 2017 17:43:34 -0400 Message-Id: <1503697414-6830-4-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503697414-6830-1-git-send-email-brijesh.singh@amd.com> References: <1503697414-6830-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR2201CA0041.namprd22.prod.outlook.com (2603:10b6:301:16::15) To DM2PR12MB0156.namprd12.prod.outlook.com (2a01:111:e400:50ce::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4de933c3-8335-4acc-69b0-08d4ec025f1b X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0156; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 3:Ew5TZo1yhUqMSUL2i4drsD1yUcEFOfY+YsS9zAg+moO6F4YGiSaHJwEmwQNtKl8okGH8dWuWt1N6JKKs2K/IRoC4RAJekTMJ9jClLkZFGQAz2NPtaf1AMt5/oHq5bNQkcjX3jOO9GQ2WUEbaZHCZaX4A+yYUPc4DinU+JkobF+PcGr8z7X5ccidC2umUgNotF8XGqDAWcQcqKNksmBJ9TCXXfvOCGGynn6B7TQmR9U1qTe0pg5CCFH51TLgrMvgr; 25:zB/+dYwWcIaFFjWa+32eR5kwjIIdNrnLQ5dLSb9JNV48cJ9/JMBqWhtS4l+FWCAPJVdMOwP7ABiqqVVwsx+d1N7gHqIl2FauLrMRKuPrp8pJL1/sajWCVuDkX7UHPm26Fy35nxWLAMB4uQl8sQTBjU6kLtYBHpQtgBQs+kD7b3JIeX4i7WSeRmkW2n/AiQvc6MvLrtZzVF5xj6TcszYbI08EeGO8pP+VypywjkuIqNck9+21s4GKhKi3neVsxUubSn3rS0vcusLlBoUqF8GhcshAha20X768h0MhFzB+knCorkldTNTGrux5jXr/VlGYjAVPI5IAE4U9hOCIDMb2xw==; 31:ELZYqomVPqXwVG5fPKyis28kvX9YhKXeCafqSKRsx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C7zAdSzoK60huxIz2zSK6mcRm/7iWA3DONzA8M/djGrPVAeA== 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)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0156; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0156; X-Forefront-PRVS: 041032FF37 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(199003)(189002)(97736004)(54906002)(86362001)(47776003)(5660300001)(110136004)(48376002)(4326008)(7736002)(305945005)(53936002)(68736007)(105586002)(50466002)(5003940100001)(6486002)(7350300001)(2950100002)(8676002)(76176999)(101416001)(6666003)(6116002)(50986999)(478600001)(106356001)(66066001)(2906002)(25786009)(81156014)(53416004)(189998001)(33646002)(50226002)(81166006)(3846002)(36756003)(42186005)(2361001)(2351001)(6916009)(344415003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0156; 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; DM2PR12MB0156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DoPMmz6tesP4tIs0kIJIezk0hNhvVaIEAn1ciq7Qq7PCrjiAE/IbiLWMzzRXFDWEGVk1FauQQavIUQtVJDaSsqY4GAZafGsGUW+JdPn7iLgiuYn70jNGHQ/MVqWnOSCyueIcRKuLMA2+FN2CFL+QPqFJNRkeIWp/aQHHSz7TuIv5i0hJHsQWf1OdsohuQ/joQkMQgCN1utkmMm8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 20:uLWWfRZCV5Dkr+KdYQcYu5q9Df0t/PO8oM1Ltd5h9JQUyCm1/1ENRT3MmEjBgLDxczYMY1Q+yg1UcNeM8rXl5lh5S2ehTtd8tKqqX8YouSmcRQdaIb04xdTzs0cT2LpfJGJObGfuIG2B1yxByPocafbEmSAS1Es/X8S1QDzq4mQUjcJlo9y3rx8fVFJCOaFouQdA707Vs1NgC3067Ohu/eNAzYLl9C5aEeYg//8WaR8j/qSJcu9Uvpo5GYoSyy1K X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 21:43:48.8616 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0156 Subject: [edk2] [PATCH 3/3] OvmfPkg/VirtioBlkDxe: negotiate VIRTIO_F_IOMMU_PLATFORM 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" VirtioBlkDxe driver has been updated to use IOMMU-like member functions from VIRTIO_DEVICE_PROTOCOL to translate the system physical address to device address. We do not need to do anything special when VIRTIO_F_IOMMU_PLATFORM bit is present hence treat it in parallel with VIRTIO_F_VERSION_1. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.c index ab69cb08a625..3c4d9dfd4d54 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -825,7 +825,8 @@ VirtioBlkInit ( } =20 Features &=3D VIRTIO_BLK_F_BLK_SIZE | VIRTIO_BLK_F_TOPOLOGY | VIRTIO_BLK= _F_RO | - VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1; + VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1 | + VIRTIO_F_IOMMU_PLATFORM; =20 // // In virtio-1.0, feature negotiation is expected to complete before que= ue @@ -903,7 +904,7 @@ VirtioBlkInit ( // step 5 -- Report understood features. // if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; + Features &=3D ~(UINT64)(VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM); Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { goto UnmapQueue; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel