From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1E9C4740047 for ; Tue, 30 Jan 2024 17:15:53 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=bS5IDWJb8Tbi8/8DZ4CGzL5B5WnP37XgIq+k2GZ1rc8=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1706634952; v=1; b=Tc7Md05dnAK63hLrK+vXArZb0DRv6oB/4bavtiAtYtlA6NXTZqoZjMTsD3j6cEWR86nzg8YF lSqHKlvtzaYKnP57giMulgaMazwhU9wn3X0pVFXxn+06DzJL2/ChMzugf7K/tNWUqhb7ghwbBOF 13zy+7n9zv/fCg5YWYtGXzvg= X-Received: by 127.0.0.2 with SMTP id zCKdYY7687511xhHsaqa5lFK; Tue, 30 Jan 2024 09:15:52 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web10.1806.1706634951771100671 for ; Tue, 30 Jan 2024 09:15:52 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kMBjrVb/ODjjGEWqRxR7Xpe9ZEAJuE6cdpeoj2Se1Q/6XuxvIt4jjR7rEnwZmf/214Vf35S6l6znQYZReVQF5vIWnKPkFuyBKVhwiqvJEd3f+eGnjYmHhBNVu4TeUk9/7QkaGbsvpsU1bUaFHk2Nt65NNK1TsXERcpzmTWVGRmQ522AREJDNIdwWB6ib0hNH0Sl9WAgVZSZhSNACvn2LLwQkxWLB8aIabQQB+dYDHBqPhXOgh18+OmR1ZmRp5ojFhWiOgiDnlIvKsfsjkmOYmmmTHPQz/OJecFBfIPiXxK2tRTZY2tAsNIdpD3v8zBMrmD86Z5I/f/VnkbDAVrz0Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mUJLSr6cMUolXyInDyNOVg97ONPWlsm4kEzSTluSBC0=; b=PxIK3LgutblrDQGANX2epSSu+rIILlN2SSvP4yPdsQBfs8DgvAvGjULJ6BRFqtIH/fWVftK/PY+Dnc9FF41G8buo1ibH1ybXCvFGJlTc9Ba3FplkIT5mIzGbrvd/X1fYewwVkKtV03D+t3phvg81TZxVvvNNThNC5Ha559FYv/XzF0XtjgOuXvl1IhfpLbVqVuuSlst1YCXGXKR0G56mIVb/Z+Bw3dE5fqJFlr61/rRkE748YyOx5jkNz/fFTaBuYqknMu/joKnLwQXS6fh2ryxz9Gr41gVen0q/Gy2zyCrpImxkWz9n3JaXxQgLlH7PhK741yf4duY/rrK5EmfrrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from BN9PR03CA0425.namprd03.prod.outlook.com (2603:10b6:408:113::10) by IA1PR12MB6460.namprd12.prod.outlook.com (2603:10b6:208:3a8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Tue, 30 Jan 2024 17:15:48 +0000 X-Received: from BN1PEPF00004685.namprd03.prod.outlook.com (2603:10b6:408:113:cafe::d) by BN9PR03CA0425.outlook.office365.com (2603:10b6:408:113::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34 via Frontend Transport; Tue, 30 Jan 2024 17:15:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00004685.mail.protection.outlook.com (10.167.243.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Tue, 30 Jan 2024 17:15:47 +0000 X-Received: from tlendack-t1.amdoffice.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 30 Jan 2024 11:15:47 -0600 From: "Lendacky, Thomas via groups.io" To: CC: Ard Biesheuvel , Erdem Aktas , Gerd Hoffmann , Jiewen Yao , Laszlo Ersek , Min Xu , Michael Roth Subject: [edk2-devel] [PATCH] OvmfPkg/IoMmuDxe: Provide an implementation for SetAttribute Date: Tue, 30 Jan 2024 11:15:33 -0600 Message-ID: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004685:EE_|IA1PR12MB6460:EE_ X-MS-Office365-Filtering-Correlation-Id: 61f8d402-3c51-4531-3587-08dc21b71a0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: DdSZ3nH/P6bJFFdYmMNRg7Y9QJekliym6NIW9CoFlhiq4KTatIvwIWSLDt0i8UJNGVVryG9brpdLv4+YcjhUOrpLUPgx9zZXFu+xT3wtPWDuB4xThDwpLkC5rFUTz3HsGUBazjxs4vM+rk+GlSmpHmYHlHGmieJms8nMKIRIbI6Sy/91GhpaK4PxmkQqscQTvxjbCQ1CXw/GFxhot6e3jSYVQKh0fSbpo+yN5vCTFnpR39kDjpHCvXH+f7eVtq7m9w1vHnEA04LCej26HnzWIYtSjPHm8OKery9x2WaiBosIL2gV8Ekm87ccvw7VPqqWjoIDtQZ+aFKb6K4aR5uFau+mktgrXnpq9Q1Rv2ieydGTac60wsCtHyZryLraw/hkZ+e1AiMXKl3EUYAKfKmIorI3+4ZDdjB7mOl5eYz9B5vTrTG2MtWqbvweGJJw9+t3f2l9LNr1bAx66AwQn+jfQFGviOoRRdjn0ZWjpXApHFEtRZpeCrRfGN9yifMuhf7D0ko41CGuPQ0jyG4Ro5xv2QPa1h9XiqgHZZcB5zDLlvmdJY3cFtHvJyVwXbTi0/4Nd23F7tcpGL0ygj0bkOCJwMB2qUjpHTYk53kGKkHqS1GcDN9La8IADTq1+DiS/bCSaPgwOrEzh57I3P0JMbJzstM5ciUUBkp87B99O4wV4+1bMOfETUr6pcN2NAEfpQKUHsUHn2LcRpjusWnLwxf5Un8omjCqok02M1zBitRaxGtlJUmpcBqeB38FDEy8zFIHzln/0lDRbXxnxCCUSpZfyg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2024 17:15:47.9235 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61f8d402-3c51-4531-3587-08dc21b71a0f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004685.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6460 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: zqL6SXj33VitzVNR6qLDbQrpx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Tc7Md05d; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") A recent change to the PciIoMap() function now propagates the return code from the IoMmu protocol SetAttribute() operation. The implementation of this operation in OvmfPkg/IoMmuDxe/CcIoMmu.c returns EFI_UNSUPPORTED, resulting in a failure to boot the guest. Provide an implementation for SetAttribute() that validates the IoMmu access method being requested against the IoMmu mapping operation. Suggested-by: Laszlo Ersek Reviewed-by: Laszlo Ersek Signed-off-by: Tom Lendacky --- OvmfPkg/IoMmuDxe/CcIoMmu.c | 55 +++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/IoMmuDxe/CcIoMmu.c b/OvmfPkg/IoMmuDxe/CcIoMmu.c index b83a9690062b..795b945dacb0 100644 --- a/OvmfPkg/IoMmuDxe/CcIoMmu.c +++ b/OvmfPkg/IoMmuDxe/CcIoMmu.c @@ -5,7 +5,7 @@ operations must be performed on unencrypted buffer hence we use a bounce buffer to map the guest buffer into an unencrypted DMA buffer. =20 - Copyright (c) 2017, AMD Inc. All rights reserved.
+ Copyright (c) 2017 - 2024, AMD Inc. All rights reserved.
Copyright (c) 2017, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -751,7 +751,58 @@ IoMmuSetAttribute ( IN UINT64 IoMmuAccess ) { - return EFI_UNSUPPORTED; + MAP_INFO *MapInfo; + EFI_STATUS Status; + + DEBUG ((DEBUG_VERBOSE, "%a: Mapping=3D0x%p Access=3D%lu\n", __func__, Ma= pping, IoMmuAccess)); + + if (Mapping =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_SUCCESS; + + // + // An IoMmuAccess value of 0 is always accepted, validate any non-zero v= alue. + // + if (IoMmuAccess !=3D 0) { + MapInfo =3D (MAP_INFO *)Mapping; + + // + // The mapping operation already implied the access mode. Validate tha= t + // the supplied access mode matches operation access mode. + // + switch (MapInfo->Operation) { + case EdkiiIoMmuOperationBusMasterRead: + case EdkiiIoMmuOperationBusMasterRead64: + if (IoMmuAccess !=3D EDKII_IOMMU_ACCESS_READ) { + Status =3D EFI_INVALID_PARAMETER; + } + + break; + + case EdkiiIoMmuOperationBusMasterWrite: + case EdkiiIoMmuOperationBusMasterWrite64: + if (IoMmuAccess !=3D EDKII_IOMMU_ACCESS_WRITE) { + Status =3D EFI_INVALID_PARAMETER; + } + + break; + + case EdkiiIoMmuOperationBusMasterCommonBuffer: + case EdkiiIoMmuOperationBusMasterCommonBuffer64: + if (IoMmuAccess !=3D (EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS= _WRITE)) { + Status =3D EFI_INVALID_PARAMETER; + } + + break; + + default: + Status =3D EFI_UNSUPPORTED; + } + } + + return Status; } =20 EDKII_IOMMU_PROTOCOL mIoMmu =3D { --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114806): https://edk2.groups.io/g/devel/message/114806 Mute This Topic: https://groups.io/mt/104058148/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-