From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.88]) by mx.groups.io with SMTP id smtpd.web10.688.1614195500077061227 for ; Wed, 24 Feb 2021 11:38:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=qn8QL4w9; spf=pass (domain: arm.com, ip: 40.107.21.88, 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=hLcf70/VtcVLzGEx1hvDE9jKOAD1wywbH4otjewLacI=; b=qn8QL4w99SiPwkXn9MQxkmovqJ2xoRi5XR3NFZb1q4HAsbZMqCNTYB0CsFpVG9FuCOCuNjRtWipVrsRcurMDyXaoJLjR74LgCZksThbqHcH2nb/4c2PspGbb/7gwhbrOJQ4A/sJv3uDVW3RANW4pouqeyoRPmMROy1fjv4uDiIw= Received: from AM6P193CA0127.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::32) by AM6PR08MB4440.eurprd08.prod.outlook.com (2603:10a6:20b:bc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Wed, 24 Feb 2021 19:38:09 +0000 Received: from AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::25) by AM6P193CA0127.outlook.office365.com (2603:10a6:209:85::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19 via Frontend Transport; Wed, 24 Feb 2021 19:38:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT023.mail.protection.outlook.com (10.152.16.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19 via Frontend Transport; Wed, 24 Feb 2021 19:38:08 +0000 Received: ("Tessian outbound a87bfa165cc0:v71"); Wed, 24 Feb 2021 19:38:08 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7e863aef2cc28808 X-CR-MTA-TID: 64aa7808 Received: from d617bdd966de.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C7E88600-958E-41EB-8209-B79A6C232533.1; Wed, 24 Feb 2021 19:38:02 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d617bdd966de.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 24 Feb 2021 19:38:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XMWMezoeeAiRXuno0ogakwBIOKc/zRaiRVGIF++KVJfuXwsFPhYpgMlCRFCM6PNwzxtMpIquE9c7ApZBsOlkdyN/lP7uGOUEFEET/BQI9APFpaTQgVPKl6FWXG1Pi2t1B4CQrS+74q9HLSnXFMGy9PhzcZBmbGM9hse+QDEoC+eow3HnjI5yhzMPYQGK6vFUZxui8vOstbwfrOmZZbEu7t0JBH4YWJ7Ia4DuJ8/lWE6m2RNtXsldYOpT1tSAAfc3mjUbGcYK2RjPXj9+AQwIpOcm+8P6Bd2rAIhxAkvJE8DinbopYcHKYZ/7ZqF/1xt1Gbb2MsNX7GFmP274Jpf7IQ== 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-SenderADCheck; bh=hLcf70/VtcVLzGEx1hvDE9jKOAD1wywbH4otjewLacI=; b=Zz1YlyvrR56BmriLwzH9VAIbzpjNxsQ0p9Is5/h3d2dOFg2XJWahuL95gLKo1cWehEvq8FW2aYUy3fWoKOe9iL1OyhW+QjTX0a3AwFfygzmVqnl2DIf8/dGytE676/8VaZ5QykGLpkyqNMi/AoAJNNSTFNc0Fd0RcExuxprFFSxySdSKx06lLQuEn5uNT4lVSeatwrcs8P7ZJgZVtiUl8Pe5JTkwQmWFW0szHRsSeqrLNeK6OVEAwKlG1tgm1CEspvXkyWyipjmtNtZrioNNvPttMXeCrt4GrpXOexDJ2X983VlInJ2LHtdW/X3qYogMyZ+YwefuBjcSIH3CKkEadg== 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=hLcf70/VtcVLzGEx1hvDE9jKOAD1wywbH4otjewLacI=; b=qn8QL4w99SiPwkXn9MQxkmovqJ2xoRi5XR3NFZb1q4HAsbZMqCNTYB0CsFpVG9FuCOCuNjRtWipVrsRcurMDyXaoJLjR74LgCZksThbqHcH2nb/4c2PspGbb/7gwhbrOJQ4A/sJv3uDVW3RANW4pouqeyoRPmMROy1fjv4uDiIw= Received: from AM7PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:20b:110::20) by AM8PR08MB5682.eurprd08.prod.outlook.com (2603:10a6:20b:1c5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Wed, 24 Feb 2021 19:38:01 +0000 Received: from VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:110:cafe::f4) by AM7PR04CA0010.outlook.office365.com (2603:10a6:20b:110::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Wed, 24 Feb 2021 19:38:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 VE1EUR03FT038.mail.protection.outlook.com (10.152.19.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3890.19 via Frontend Transport; Wed, 24 Feb 2021 19:38:00 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Wed, 24 Feb 2021 19:37:59 +0000 Received: from E107187.Arm.com (10.57.16.52) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Wed, 24 Feb 2021 19:37:58 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , Subject: [PATCH v1 1/1] ArmPkg: Fix uninitialised variable in ArmMmuStandaloneMmLib Date: Wed, 24 Feb 2021 19:37:56 +0000 Message-ID: <20210224193756.24132-1-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd47bb83-26ce-44d7-b40b-08d8d8fbb6bb X-MS-TrafficTypeDiagnostic: AM8PR08MB5682:|AM6PR08MB4440: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5236;OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: IvYjQWxiN1RmbzGc9MvT1SLbA0qqwIJlQrp/M13h02FHRjNaBKUh1AagDcOWoUN3LMqVyVtoChEpE8FzitwfIpP13Rhxb3jzSvDTBSRD4c26FeTEvsX7rdsCXymNqZdo9MX8+s0CiVMRAl3mnMVTksZmE6/hqc0YFEUKmYb3DcPolh5URWBJ0J1TZhmJc7zQrFOBSKUvVvDNVf4kwscMbavRAOuV7avY+pxfAnuxmIoDbue6gTxL3XmS/l3QAC9siAmhKAdZWQ+B5nn7PXj+y/fCXzZAsYY6PRy7j3hMX5zMinJI/4KhswM7qWx26AT6obZAq670FlKNfgCyIK/nZaQVYVkgi/OKERjPw8UPomoxKWPD8sWWnVa0zXssBs0Z2o4fdIC6XdDb+cWjM8tUFCaYVmAv7a2ce2s2+g8X9kcp1o8cz+2ckfjRlqXl/VcU1+4tUalOoGbiD4bG0T/hqCbtGtgD5qKpOd/Z57C9Oo/kB9VzosC8fzQiim5hIm2t3O1PCTr3jrIQQ2S+TOhbcAGCknZrbqfZ+wSPRybkP8Cc00LBel7WcmAgeiwSnbh9uXTBbrk+k2n4ZW+40jUsU3WmC3v+BsJnLAy7SU4S2o81ok93RYsKDuIsapWiagQ5gyUx2ID/cBcr0UnX25ls/pCGJJbVSL4AImkkfP2vXMP7VJa0CYhI0HSDzmiY3t2yzC3T4WwZFPfIKPSlI/2gkU4x/WXxs7WwyGouqBBzbp+d8M2OdH9Ly2hjq+OMWTJXwFc27heJ9XElc1EUPpmcaA== 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:(6029001)(4636009)(346002)(396003)(39860400002)(136003)(376002)(46966006)(36840700001)(7696005)(336012)(1076003)(86362001)(54906003)(81166007)(356005)(6916009)(5660300002)(4326008)(2616005)(36860700001)(8676002)(478600001)(966005)(316002)(83380400001)(2906002)(47076005)(70586007)(82310400003)(70206006)(426003)(8936002)(36756003)(82740400003)(26005)(186003)(44832011)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5682 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a23bddc1-4341-43dd-84c4-08d8d8fbb21b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C8qzf8/8XYApMtxaqTYBICeiZod+wzxpMSXIBcUkBCzGG42iFz4pTqeU6fByThTHinlmI+iDGsjc8sAo+rElyA5Hj2iwjH4mqxUi4XwCo7bmgKL6JkQ6IU5uUxTg59VYlA2Obg8AMvSKxgnMhYaHPez19T5Z3HxaYnohaV81hkm5gj/Jbwiy0zgJZIABfgI7WiK6vXCl1PKAa46ARuBufazPWMNqmcdW5NoWhqJK6VkwUDHalC1rDrZDqf1J8Zcj8m5GBwyUfNAxpW9C15+ykr88rhchtGSDwXcwu4PaztGxE3ck7/3BBsw8FAW11Z3VUOjNZA2jp7W6zQxm4oFXAVC4NKmROJ7U59bOihHUPvmCXPSIPwYWUX1kXQrSSzwuhw48Ot9WCuxCbCNX2t3wnb4ASBmqR0qg0Ku8Zhm6vozhs1YQOzYNITOhb8/CRsxP1oYrwuXU2saOqdXaUnxgxuj5850qdZrUleKsDip0J3RpcbVCdj56TMZOIu1+Hbf0MNjub86s4ESGFiBliwtdhsaLo9+5Gu0wtC/vxHe/4eoNBUUl0xpPpLqOSdGovhl4Q8brDuNvmJUx3pq9AH5nSJ2+T0AM7X4ySctjYMqu6pLuaV3UV/gxDIsE1MLXw7ZgyiavVqMjMFuVq5ziEsiyaih3oRoRZh/YauwwqgLvkeDIEs7TdfFTkDK563g+4cyAMpiSnzsqpPs7TUGGLnipc63tSDQInZCY56yVCwzhyic= 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:(6029001)(4636009)(346002)(376002)(39860400002)(136003)(396003)(36840700001)(46966006)(81166007)(36860700001)(4326008)(8676002)(70206006)(316002)(86362001)(1076003)(54906003)(478600001)(70586007)(7696005)(966005)(5660300002)(47076005)(82310400003)(36756003)(336012)(2906002)(186003)(44832011)(426003)(2616005)(26005)(83380400001)(82740400003)(8936002)(6916009);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2021 19:38:08.6490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd47bb83-26ce-44d7-b40b-08d8d8fbb6bb 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: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4440 Content-Type: text/plain The following patches added support for StandaloneMM using FF-A: 9da5ee116a28 ArmPkg: Allow FF-A calls to set memory region's attributes 0e43e02b9bd8 ArmPkg: Allow FF-A calls to get memory region's attributes However, the error handling logic for the Get/Set Memory attributes introduced an issue wherein a status variable could be used without initialisation. This issue is reported by CLANG compiler and is not seen with GCC. The Get/Set Memory attributes operation is atomic and therefore an FFA_INTERRUPT or FFA_SUCCESS response is not expected in response to FFA_MSG_SEND_DIRECT_REQ. So the remaining cases that could occur are: - the target sends FFA_MSG_SEND_DIRECT_RESP with a success or failure code. or - FFA_MSG_SEND_DIRECT_REQ transmission failure. Therefore, reorder the error handling conditions such that the uninitialised variable issue is fixed. Signed-off-by: Sami Mujawar --- The changes can be seen at: https://github.com/samimujawar/edk2/tree/1657_stmm_ffa_fix_unused_var_v1 ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c | 92 ++++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c index a30369af9c91fb8045dfec7a68e2bd072706d101..73b63ca396e5395bdf2112709b0aa2ab871a2a07 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c +++ b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c @@ -57,36 +57,35 @@ GetMemoryPermissions ( // for other Direct Request calls which are not atomic // We therefore check only for Direct Response by the // callee. - if (GetMemoryPermissionsSvcArgs.Arg0 != + if (GetMemoryPermissionsSvcArgs.Arg0 == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64) { - // If Arg0 is not a Direct Response, that means we - // have an FF-A error. We need to check Arg2 for the - // FF-A error code. - Ret = GetMemoryPermissionsSvcArgs.Arg2; - switch (Ret) { - case ARM_FFA_SPM_RET_INVALID_PARAMETERS: - - return EFI_INVALID_PARAMETER; - - case ARM_FFA_SPM_RET_DENIED: - return EFI_NOT_READY; - - case ARM_FFA_SPM_RET_NOT_SUPPORTED: - return EFI_UNSUPPORTED; - - case ARM_FFA_SPM_RET_BUSY: - return EFI_NOT_READY; - - case ARM_FFA_SPM_RET_ABORTED: - return EFI_ABORTED; - } - } else if (GetMemoryPermissionsSvcArgs.Arg0 == - ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64) { // A Direct Response means FF-A success // Now check the payload for errors // The callee sends back the return value // in Arg3 Ret = GetMemoryPermissionsSvcArgs.Arg3; + } else { + // If Arg0 is not a Direct Response, that means we + // have an FF-A error. We need to check Arg2 for the + // FF-A error code. + Ret = GetMemoryPermissionsSvcArgs.Arg2; + switch (Ret) { + case ARM_FFA_SPM_RET_INVALID_PARAMETERS: + + return EFI_INVALID_PARAMETER; + + case ARM_FFA_SPM_RET_DENIED: + return EFI_NOT_READY; + + case ARM_FFA_SPM_RET_NOT_SUPPORTED: + return EFI_UNSUPPORTED; + + case ARM_FFA_SPM_RET_BUSY: + return EFI_NOT_READY; + + case ARM_FFA_SPM_RET_ABORTED: + return EFI_ABORTED; + } } } else { Ret = GetMemoryPermissionsSvcArgs.Arg0; @@ -150,35 +149,34 @@ RequestMemoryPermissionChange ( // for other Direct Request calls which are not atomic // We therefore check only for Direct Response by the // callee. - if (ChangeMemoryPermissionsSvcArgs.Arg0 != + if (ChangeMemoryPermissionsSvcArgs.Arg0 == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64) { - // If Arg0 is not a Direct Response, that means we - // have an FF-A error. We need to check Arg2 for the - // FF-A error code. - Ret = ChangeMemoryPermissionsSvcArgs.Arg2; - switch (Ret) { - case ARM_FFA_SPM_RET_INVALID_PARAMETERS: - return EFI_INVALID_PARAMETER; - - case ARM_FFA_SPM_RET_DENIED: - return EFI_NOT_READY; - - case ARM_FFA_SPM_RET_NOT_SUPPORTED: - return EFI_UNSUPPORTED; - - case ARM_FFA_SPM_RET_BUSY: - return EFI_NOT_READY; - - case ARM_FFA_SPM_RET_ABORTED: - return EFI_ABORTED; - } - } else if (ChangeMemoryPermissionsSvcArgs.Arg0 == - ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64) { // A Direct Response means FF-A success // Now check the payload for errors // The callee sends back the return value // in Arg3 Ret = ChangeMemoryPermissionsSvcArgs.Arg3; + } else { + // If Arg0 is not a Direct Response, that means we + // have an FF-A error. We need to check Arg2 for the + // FF-A error code. + Ret = ChangeMemoryPermissionsSvcArgs.Arg2; + switch (Ret) { + case ARM_FFA_SPM_RET_INVALID_PARAMETERS: + return EFI_INVALID_PARAMETER; + + case ARM_FFA_SPM_RET_DENIED: + return EFI_NOT_READY; + + case ARM_FFA_SPM_RET_NOT_SUPPORTED: + return EFI_UNSUPPORTED; + + case ARM_FFA_SPM_RET_BUSY: + return EFI_NOT_READY; + + case ARM_FFA_SPM_RET_ABORTED: + return EFI_ABORTED; + } } } else { Ret = ChangeMemoryPermissionsSvcArgs.Arg0; -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'