From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (EUR03-VE1-obe.outbound.protection.outlook.com [40.107.5.69]) by mx.groups.io with SMTP id smtpd.web11.10425.1636541811130289305 for ; Wed, 10 Nov 2021 02:56:51 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=6OKvZWh0; spf=pass (domain: arm.com, ip: 40.107.5.69, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mLUH+7+JVdhRGBNrP7FstTXNO2wLU2UoQk1IKrc+ic4=; b=6OKvZWh0M/mhqtIqLgUS+hzoX/GtFXVUbyC+AKnVSJGTvYFBdcyRxp8CR/2Xs/ZyxUKd5rIRJVHpMfEAlyvuJHbuwRnEqcx7h1GGJiKO/dltYiuzZfaPVh31ueBk5HUip0DKhJPi6j0v+Kpjij9FP5b2OFrNWvYKeLGDujP5yVI= Received: from AS8P251CA0010.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::8) by HE1PR0802MB2523.eurprd08.prod.outlook.com (2603:10a6:3:e1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Wed, 10 Nov 2021 10:56:44 +0000 Received: from AM5EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::56) by AS8P251CA0010.outlook.office365.com (2603:10a6:20b:2f2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 10:56:44 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT039.mail.protection.outlook.com (10.152.17.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Wed, 10 Nov 2021 10:56:42 +0000 Received: ("Tessian outbound e7ce0d853b63:v108"); Wed, 10 Nov 2021 10:56:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 792f62d5199df015 X-CR-MTA-TID: 64aa7808 Received: from b48aafaeb067.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 27DAEB33-EC31-4B2A-B471-372EC870E0BE.1; Wed, 10 Nov 2021 10:56:35 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b48aafaeb067.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 10 Nov 2021 10:56:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aooZ4kKU3Nevh1E5H5Ou/W3S8BdLcf7+AjXyZ2tgAcGLzHvs/DO1Y0HI0IM6yU4oE4t3EYA43C2u3wtPV4rmMIulhnyQRtL4KXvFN0oMneSEGojkHO8tmc1/98+Qk/qqzxTxc6YPJM1P7l6ruyWIZUI1qR2nfnDLnZOcDEh1IVsATL/n1mRfdSiNzTVMO/d1NpOCiOloF+UW118fDw1dv10nkVoXfohZyEre7xensCFjnptaqY64lVI9Lrx0q5dUF8TUtxRyqU3u6ppinPuQEZEnXiOqPagPhMzB2g3Uk50WeQ4tBeYM39TdLl6xuXG5ElGf+1K5OYPlUsKag5M7NA== 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=mLUH+7+JVdhRGBNrP7FstTXNO2wLU2UoQk1IKrc+ic4=; b=PdW7IrJLGyr06elvbOiK6Gzml0cf2Fnf7O0diQwMTDnksioQEnznBhVub9lbjf5rzCrR27WX4O+LklMBHDMnpxJq+kBVWA4ZEXOHzRHJARTWJzNHGcMHnNN8gsnpaqy8Kc2ixyZ7dAV7xOPHs55hcHmfmBcnesDVdk7ITzhaudkZk2Qyy/RuupUnS+BDoMOu/aatAaqBMfPN0be2rWgElTd/RDS8cEl8+bnUShFZKLFX5xbU35sUUrwg9p8UZOK/PMpQIdOZM2Jc2bC5nIsf1d1mXd4/Z1d4kiHnefNwP2oTaCFZTnk+Y/pNF9m2IcExGLWonDUEonj0v9sQYzLXwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mLUH+7+JVdhRGBNrP7FstTXNO2wLU2UoQk1IKrc+ic4=; b=6OKvZWh0M/mhqtIqLgUS+hzoX/GtFXVUbyC+AKnVSJGTvYFBdcyRxp8CR/2Xs/ZyxUKd5rIRJVHpMfEAlyvuJHbuwRnEqcx7h1GGJiKO/dltYiuzZfaPVh31ueBk5HUip0DKhJPi6j0v+Kpjij9FP5b2OFrNWvYKeLGDujP5yVI= Received: from DB7PR05CA0048.eurprd05.prod.outlook.com (2603:10a6:10:2e::25) by PAXPR08MB7368.eurprd08.prod.outlook.com (2603:10a6:102:22a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Wed, 10 Nov 2021 10:56:33 +0000 Received: from DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::82) by DB7PR05CA0048.outlook.office365.com (2603:10a6:10:2e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 10:56:33 +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; Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT038.mail.protection.outlook.com (10.152.21.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4649.14 via Frontend Transport; Wed, 10 Nov 2021 10:56:33 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.2308.14; Wed, 10 Nov 2021 10:55:30 +0000 Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.14 via Frontend Transport; Wed, 10 Nov 2021 10:55:30 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , Subject: [PATCH v3 6/8] DynamicTablesPkg: IORT set reference to interrupt array if present Date: Wed, 10 Nov 2021 10:55:30 +0000 Message-ID: <20211110105532.38696-7-sami.mujawar@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20211110105532.38696-1-sami.mujawar@arm.com> References: <20211110105532.38696-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df89d40b-851c-45bd-1a28-08d9a438c7cb X-MS-TrafficTypeDiagnostic: PAXPR08MB7368:|HE1PR0802MB2523: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4941;OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: rqrSrbGkMIUhTPSGYBXscGUC49KqS4kDflbkJJEFkuvuFlRCh6s3KZekA8KQfNCeBxImokWbclKSQNTyTJklyxAylRiGvsLdSXzVGzzoVMQPmoh6eBDzq8QkbD1SbD4QJilzka/F5qnwaWFgSdft/iD4+ns8flSwk6wo82qYKZ1A4gUv3cnsgB8e/HZ+imaRprBnI5VoypXITNc5TDTilkRjVC9LJlVcO3QUYulrittULdU5FxmR1Ag3Qwi3RadH7vRxrZwDDj4BXXfMpA0LFuk+J9orwFg7jG5aqh0NNX/g3aRykpLRRXuGgWN0Tj2JKRZZZ4vl1qPr3tNknEKP76GXHganqTH8z48igsMF6NdfeWFx86C0NjdseRV3F+KasDNKp6PPpvjEz6a8NYfh3I7JlY1sqIjwkM3/ZfqCvvMIyLwecr+e9MuI6b3uaqgne6JCTocGdGkFUOIrjI1Bi8tXmkKHYVEXnuS01I4mQkpoI3xpLfp2XZHBTOVojx9u5K6MXye9OQOzEIg3edvD1F8jnx4iBcgrQkER/Rqobrh40WDE5Ta2eugdVB02RRC+yQff3dyJCXUAqeaXB2PmHuk+diSHL80guuiJIM4LpN1gZzftAAaD5SPi56l8FEQdUuhuL3A76FADKZpnFpBlzA6Byc+tk4Kfe5jJAi9/GOY6Z0X+JMC3+0Im4HbU0vN5JHsP+Nmo9aZPCvP0OqzOIA9vPuI5znQwLii1K2lIvfdY6MCcbQ37vt3AZ3WKgfpEXdnOOnPrxZMTvxAl6D1fNBDhahvbLOno10xMXYAxfgspanlg7qwb4jblp/+HaKgf 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:(4636009)(36840700001)(46966006)(316002)(966005)(508600001)(2616005)(426003)(1076003)(356005)(81166007)(44832011)(5660300002)(2906002)(8936002)(4326008)(6916009)(82310400003)(36860700001)(47076005)(7696005)(86362001)(70206006)(36756003)(186003)(54906003)(70586007)(336012)(83380400001)(26005)(8676002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7368 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 3c0ce140-3dbd-488b-8582-08d9a438c258 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OGbGMQOUOjH3CHSBGqi6TSMoyiT8VmeRLu+dcZAshcdiCplAV447XucKK89i2yw83uVeyh6AwUGoTa6pNgySrJk9zdUiQVr6FcbW3HPQJ3oqb//sqEGvHCxJWpagJqhNzXVoSlnWt9YNDDcTAYIv75y0UoUlA3rCrhYSffrtih467z5H+XUX24ityDCy9CqdhVpTZW+vxftR83TJhP5OAklWO8BEkQuU93tdNMvmufAzi4i/kKHsePmr2VGTDEMd7B9Y9Of+Ho8wW6WlT6La1OIB2KIALhO8rNkSDZhRNW5lItLSle2dC8eQcT6Hggopjdxq5fE/vltswT1YU9pmWtTgdf5a5MCFTBu9P4UUvANHlvRrnzYQnGqPEVqI/lM+StFzy/xje4ydBHgBICweuyjo8ay+RcD5LRasxh+cFtfBMQE2wRNzy5jjbRipEyFJYjaQ8E2lwcDKZMYwfkosXs2ZTOfDP6xOddtSoL+MlG3RNIN+G4wDA4v54zpaVW5J87nTST7QTN0+ztZ9OGpL3vxi/Zq78yICoKPLiAEskJRdFxQFvkf++iW76kMv28wnPcEbTOqu1GKpAODVma5F6OmalVwhc3TT1ZNzVfLy6Bn+QT/ZMk0rAJJxXKKSRy4IBW/qANO43OxAxLVO4HT2Q4CrlEYna6Lk64oeZDJlKiVQoLUowT4kuq7tHTgCd5xan6ByV9/iv339kkzn6K55O6jDJGLHdcfk1WVa59mHXC5DhCYI+AM5USgykWGXYWpec46gmkgq31it2V9RpXxULnp71Le80/qmvuuanqK+NqU= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(63350400001)(2616005)(63370400001)(26005)(4326008)(47076005)(426003)(82310400003)(86362001)(2906002)(5660300002)(54906003)(7696005)(1076003)(316002)(186003)(36860700001)(336012)(83380400001)(44832011)(36756003)(70586007)(966005)(8676002)(70206006)(8936002)(508600001)(81166007)(6916009);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:56:42.6066 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df89d40b-851c-45bd-1a28-08d9a438c7cb 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: AM5EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2523 Content-Type: text/plain The IORT generator is populating the reference field for Context and PMU interrupts even if their count is zero. Update the IORT generator to set the references only if the interrupt count is not 0. Also add checks to ensure a valid reference token has been provided. Signed-off-by: Sami Mujawar Reviewed-by: Pierre Gondois --- Notes: v2: - No code change since v1. Re-sending with v2 series. [SAMI] v3: - Move error handling for IdMappingToken. [PIERRE] - Moved error handling for IdMappingToken in a separate [SAMI] patch in v3 series. Ref: https://edk2.groups.io/g/devel/topic/83600728#76662 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 82 +++++++++++++------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c index 46ff1e6d03852daa2058b8bd13f4b18f775aba6e..4c7e99f8c05fdf0a490abb9677e54862efa1ddf2 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c @@ -1158,6 +1158,7 @@ AddSmmuV1V2Nodes ( EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * ContextInterruptArray; EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * PmuInterruptArray; UINT64 NodeLength; + UINT32 Offset; ASSERT (Iort != NULL); @@ -1200,47 +1201,74 @@ AddSmmuV1V2Nodes ( SmmuNode->GlobalInterruptArrayRef = OFFSET_OF (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE, SMMU_NSgIrpt); + Offset = sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE); // Context Interrupt SmmuNode->NumContextInterrupts = NodeList->ContextInterruptCount; - SmmuNode->ContextInterruptArrayRef = - sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE); - ContextInterruptArray = - (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode + - sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE)); + if (NodeList->ContextInterruptCount != 0) { + SmmuNode->ContextInterruptArrayRef = Offset; + ContextInterruptArray = + (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode + Offset); + Offset += (NodeList->ContextInterruptCount * + sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)); + } // PMU Interrupt SmmuNode->NumPmuInterrupts = NodeList->PmuInterruptCount; - SmmuNode->PmuInterruptArrayRef = SmmuNode->ContextInterruptArrayRef + - (NodeList->ContextInterruptCount * - sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)); - PmuInterruptArray = - (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode + - SmmuNode->PmuInterruptArrayRef); + if (NodeList->PmuInterruptCount != 0) { + SmmuNode->PmuInterruptArrayRef = Offset; + PmuInterruptArray = + (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode + Offset); + } SmmuNode->SMMU_NSgIrpt = NodeList->SMMU_NSgIrpt; SmmuNode->SMMU_NSgIrptFlags = NodeList->SMMU_NSgIrptFlags; SmmuNode->SMMU_NSgCfgIrpt = NodeList->SMMU_NSgCfgIrpt; SmmuNode->SMMU_NSgCfgIrptFlags = NodeList->SMMU_NSgCfgIrptFlags; - // Add Context Interrupt Array - Status = AddSmmuInterruptArray ( - CfgMgrProtocol, - ContextInterruptArray, - SmmuNode->NumContextInterrupts, - NodeList->ContextInterruptToken - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to Context Interrupt Array. Status = %r\n", - Status - )); - return Status; + if (NodeList->ContextInterruptCount != 0) { + if (NodeList->ContextInterruptToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Context Interrupt token," + " Token = 0x%x, Status =%r\n", + NodeList->ContextInterruptToken, + Status + )); + return Status; + } + + // Add Context Interrupt Array + Status = AddSmmuInterruptArray ( + CfgMgrProtocol, + ContextInterruptArray, + SmmuNode->NumContextInterrupts, + NodeList->ContextInterruptToken + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Failed to Context Interrupt Array. Status = %r\n", + Status + )); + return Status; + } } // Add PMU Interrupt Array - if ((SmmuNode->NumPmuInterrupts > 0) && - (NodeList->PmuInterruptToken != CM_NULL_TOKEN)) { + if (SmmuNode->NumPmuInterrupts != 0) { + if (NodeList->PmuInterruptToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid PMU Interrupt token," + " Token = 0x%x, Status =%r\n", + NodeList->PmuInterruptToken, + Status + )); + return Status; + } + Status = AddSmmuInterruptArray ( CfgMgrProtocol, PmuInterruptArray, -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'