From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail03.groups.io (mail03.groups.io [45.79.227.220]) by spool.mail.gandi.net (Postfix) with ESMTPS id E301CAC1237 for ; Fri, 12 Apr 2024 15:14:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=VAqnfTNLSob9/zPzfSY3oc47lbZi7hZsL0uFc8PumW4=; c=relaxed/simple; d=groups.io; h=Received-SPF:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:NoDisclaimer:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1712934845; v=1; b=Bdg6K2A4Ob9BzdILwxX+gh1k4HJZXa0hrFhZhbJyzm42yjHvFJmGjFppot0c8h4NnzuaQDd/ Sf/hYh0VUds0y0OCbAUfkcy8zBufDizjfNalv7IyAsjeXRVgBWBAi66Qbp6h4L9SjDTZmxYeoId S1lk6w0Ei6FDn6Fii2YUChhwbTQPPmzUuiFGNKmkeEfUdr1h6po4FW7V46vhTvjaViaFxCegPj4 ToAKEzhTXtw7MPV5N4Ar4/v+BgdwESILH9W+I3NYjNaC3En82fwIW7PMYbUhzZtwJIgIeEe74J/ F31ClXXTjn88cjXJDLl6GX7jPFN3ja2P2mWUMfW/mVXww== X-Received: by 127.0.0.2 with SMTP id JvG3YY7687511xxUNgQylHLz; Fri, 12 Apr 2024 08:14:05 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.68]) by mx.groups.io with SMTP id smtpd.web10.49604.1712934844781487873 for ; Fri, 12 Apr 2024 08:14:05 -0700 X-Received: from AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) by PAVPR08MB9580.eurprd08.prod.outlook.com (2603:10a6:102:31b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Fri, 12 Apr 2024 15:14:01 +0000 X-Received: from AMS0EPF000001B5.eurprd05.prod.outlook.com (2603:10a6:208:aa:cafe::4b) by AM0PR01CA0164.outlook.office365.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 15:14:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS0EPF000001B5.mail.protection.outlook.com (10.167.16.169) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 15:14:01 +0000 X-Received: ("Tessian outbound 9fd7e4b543e6:v313"); Fri, 12 Apr 2024 15:14:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2adb0afdfd39ae9a X-CR-MTA-TID: 64aa7808 X-Received: from 0d5cff8c8578.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 83BA13F1-1128-46EE-ADCE-06BA3FF0D920.1; Fri, 12 Apr 2024 15:13:53 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0d5cff8c8578.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Apr 2024 15:13:53 +0000 X-Received: from DUZP191CA0051.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4fa::28) by AS8PR08MB9363.eurprd08.prod.outlook.com (2603:10a6:20b:5aa::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.54; Fri, 12 Apr 2024 15:13:50 +0000 X-Received: from DU2PEPF00028D08.eurprd03.prod.outlook.com (2603:10a6:10:4fa:cafe::10) by DUZP191CA0051.outlook.office365.com (2603:10a6:10:4fa::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 15:13:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C X-Received: from nebula.arm.com (40.67.248.234) by DU2PEPF00028D08.mail.protection.outlook.com (10.167.242.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 15:13:50 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 15:13:45 +0000 X-Received: from E114225.Arm.com (10.1.196.56) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 12 Apr 2024 15:13:44 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [edk2-devel] [PATCH v2 45/45] ArmVirtPkg: ArmCcaIoMmu: Provide an implementation for SetAttribute Date: Fri, 12 Apr 2024 16:13:41 +0100 Message-ID: <20240412151341.16488-6-sami.mujawar@arm.com> In-Reply-To: <20240412151341.16488-1-sami.mujawar@arm.com> References: <20240412151341.16488-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DU2PEPF00028D08:EE_|AS8PR08MB9363:EE_|AMS0EPF000001B5:EE_|PAVPR08MB9580:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f18587a-78ab-454c-5cf9-08dc5b032ef6 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: nTBw/+wgjRlHvKzDX7ZxLP5dunIB8MOhUX2bylunWybm/HzOC9wlKpNlOEiMMlvjBRVkiO9ZASlHPYr2Wiree84RHIhXFZi06/Ij/05rswluxFi+lNowGQsKbKrdFvkaTyZZFVRJt4LFExwY5sKa0LbKoLd1CJLTMiU/ZRp/pG/uxjYb+wTbXwyfT6nQQA5PCnQmq+beeWEW5pXEBTfFiFWPq7BJQPVbkconNkj+cyu1ehwjSXZPXj+uenYGYdesAQTtkqZ/MIkXCx+Zm6MpgllI3GBPoeZZgxFhnHPg39lJPvGcWzS8bho/kGTwXhwAS91mRnTwNN97gWQdS9c9tvayQ7vhm0fjEdz4tYRIlZiJHzb6kSQUC9Bxdg/p1u8DGZKllQcIQBV7UT/rpy5lTneK5iiY//Va7gd0OsICsWeMd55Ge9NZ9sOJilPsJXEqlrU8Psr4utFk/4ifRseKz9sgolvGtzV+bUNGIh2kBwnXpUpPGr96c0ScE6cBl8EVNeePj9/qaf2nJZ1V3ZfCUoKwpdhLw4yH1oH89PAWIJ7DG4wje9A5w3GMHG/1xTkGgy3/jhL5pqiWcbYa2zEOY2L6W2grAGAURWexJmv5oi64xwdov9EadBzkTz2B5vg6yWMSbTUb8hyU+XkFJZZjkQc82FQ1At8iC30iqiWZIUksDfPbQJnqmD2gD0yQilQhLUOIB7XgYICSRPxB0Hr28fhS6ELBoW07FtCpgUcvYtDd1HN0AVNH3kWUN02nxnSN X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(82310400014)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9363 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF000001B5.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cb760f6c-903d-47c5-2054-08dc5b0328b5 X-Microsoft-Antispam-Message-Info: l+1S6sjltNJfP61nqcjkR2zrNvoiT3cLL32k8KVkRherRM/W3BnxO0Odafm6QW2XpJiaQQDeJIhTFrY+eLbOIy5d9NkxqjjcXigWsl2OewhWeawQDV23dv3WeNfsGY+EkCJYEWOBxRufykS6A3a2Tao9egFrv14qi1apz199b+LqPUtsrWEQ1sMCQvX2H5upLnzEhZTibmzloTGR6QIJk6Lu6ORgTX8Vmal3dt8oh6X/XWjhOkDku1tXwQ7jSmEaJyKkBoxieGh/5VONgalmQ1TVP7OUKCoaEYZAOI6UMDM/7xRBaMAb73HosCrDD9Ee0ZFOoXOIPvae2S+kiLQtvY/POfZBLICe5cve3vrRiX1VEiskrBFZFeaFlmHwBS1zhfbZFCx8kCirD/k9ZoZdjS1X+bWihhhKpPHetaNCmX9j0pVpOJdbVvrgIIGM0UWHydXuNUBRco0uyhPza1v/PXlqjQ8x5pZ8Iyw4erIUNviGDaqZZjXAHpgI03D2m+QRIRBd958dHPRTXkerBT3VwUpP5XlLKln7xg76Z8d0qFl7LmigjDb3QDbA1Gf6KDN487U/fGfUXQz6QxoYJu8sqrstOJ0gmgE11vL33FucFvwbPkF5/8xNUYgWLTmwreLyKDn5EODBT1t1hSCv0BWTPSDSDcx2XH/jFFvN0mB4u0BLZNuE8iYi4JI60Hspi2RPwlOcuI44wAtH2QsweyqO2RfoX/ZHoZ2/ia/jJEgQrxPhPbrsuWzFqvWnjj6sGtsl X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 15:14:01.0069 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f18587a-78ab-454c-5cf9-08dc5b032ef6 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001B5.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9580 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 Resent-Date: Fri, 12 Apr 2024 08:14:05 -0700 Resent-From: sami.mujawar@arm.com Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: jFK5JjhhnIIp8TzlUvRaorUCx7686176AA= Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=Bdg6K2A4; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.227.220 as permitted sender) smtp.mailfrom=bounce@groups.io The patch at "049695a0b1e2 MdeModulePkg/PciBusDxe: Add feedback status for PciIoMap" adds support to propagate the error code following the invocation of the IoMmu protocol SetAttribute() operation. Since the ArmCcaIoMmuDxe implementation of the SetAttribute() function returned EFI_UNSUPPORTED, it resulted in the virtio disk not being mounted. Although there is nothing to be done in SetAttribute(), follow the approach as done by the patch at "97c3f5b8d272 Provide an implementation for SetAttribute" to validate the IoMmu access method being requested against the IoMmu mapping operation and return a suitable return code. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Gerd Hoffmann Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c | 63 +++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c b/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c index cf52b82218bb9ece7bfedcb6e3a2ced00eff5e92..91f9dae91843b6739ddb818e9ec81706ccfa73b3 100644 --- a/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c +++ b/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c @@ -629,7 +629,9 @@ IoMmuFreeBuffer ( @param[in] Mapping The mapping value returned from Map(). @param[in] IoMmuAccess The IOMMU access. - @retval EFI_UNSUPPORTED Operation not supported by IOMMU. + @retval EFI_INVALID_PARAMETER A parameter was invalid. + @retval EFI_UNSUPPORTED The requested operation is not supported. + @retval EFI_SUCCESS Success. **/ EFI_STATUS @@ -641,7 +643,64 @@ IoMmuSetAttribute ( IN UINT64 IoMmuAccess ) { - return EFI_UNSUPPORTED; + EFI_STATUS Status; + MAP_INFO *MapInfo; + + DEBUG (( + DEBUG_VERBOSE, + "%a: Mapping=0x%p Access=%lu\n", + __func__, + Mapping, + IoMmuAccess + )); + + if (Mapping == NULL) { + return EFI_INVALID_PARAMETER; + } + + Status = EFI_SUCCESS; + + // An IoMmuAccess value of 0 is always accepted, + // validate any non-zero value. + if (IoMmuAccess != 0) { + MapInfo = (MAP_INFO *)Mapping; + + // The mapping operation already implied the access mode. + // Validate that the supplied access mode matches operation + // access mode. + switch (MapInfo->Operation) { + case EdkiiIoMmuOperationBusMasterRead: + case EdkiiIoMmuOperationBusMasterRead64: + if (IoMmuAccess != EDKII_IOMMU_ACCESS_READ) { + Status = EFI_INVALID_PARAMETER; + } + + break; + + case EdkiiIoMmuOperationBusMasterWrite: + case EdkiiIoMmuOperationBusMasterWrite64: + if (IoMmuAccess != EDKII_IOMMU_ACCESS_WRITE) { + Status = EFI_INVALID_PARAMETER; + } + + break; + + case EdkiiIoMmuOperationBusMasterCommonBuffer: + case EdkiiIoMmuOperationBusMasterCommonBuffer64: + if (IoMmuAccess != + (EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE)) + { + Status = EFI_INVALID_PARAMETER; + } + + break; + + default: + Status = EFI_UNSUPPORTED; + } // switch + } + + return Status; } /** Arm CCA IoMMU protocol -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117713): https://edk2.groups.io/g/devel/message/117713 Mute This Topic: https://groups.io/mt/105484264/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-