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.83]) by mx.groups.io with SMTP id smtpd.web09.35303.1606138014333782260 for ; Mon, 23 Nov 2020 05:26:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=r2apCBio; spf=pass (domain: arm.com, ip: 40.107.21.83, 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=EUXhWT8p0YSJvzQO6PvpphpmAnmbX4YtauGlNWoGs4A=; b=r2apCBioeXaubH/uNg4lglOMzmn/IPvlXcHbYpoC42pKbtIyJLi6Ri33UC13MjshOj3rpXUQittARecsmKw3bIgt+1hGaG3eiVd1boGn5nPjfhaiiCHgKxx+wmG3JU3d2hC+AcmcLMd8V27dlbd8Ugba6X7FB7rEwpR3iyUq9hU= Received: from AM6P195CA0053.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::30) by AS8PR08MB6261.eurprd08.prod.outlook.com (2603:10a6:20b:295::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.21; Mon, 23 Nov 2020 13:26:51 +0000 Received: from AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:87:cafe::80) by AM6P195CA0053.outlook.office365.com (2603:10a6:209:87::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 13:26:51 +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 AM5EUR03FT063.mail.protection.outlook.com (10.152.16.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 13:26:51 +0000 Received: ("Tessian outbound e0cdfd2b0406:v71"); Mon, 23 Nov 2020 13:26:51 +0000 X-CR-MTA-TID: 64aa7808 Received: from 4ed5b6de2342.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FF295927-FDAC-4740-A822-C4CE20BE6C19.1; Mon, 23 Nov 2020 13:26:46 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4ed5b6de2342.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 23 Nov 2020 13:26:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FhbFCdHdWhhpKXQKFXqbncHHc5unT7KmRj1ujIxYBTFjyuLsO38zeuzGxifSer5M5PuoY0qN7VIPVS9B+RcqNh2OUMENcWndPpZy87eg+dnkgKtMTlFm++JnoJL9v1aYgxK8fO5roKnIyBMBWnSk7iqlEBAMifpncHWZuCA3PJnkHLL6KXD5lWVXyyq9K7QcCMQ7xmhWM9aw6XIB6G1OXpa7+zt4x4RBkmStipwVOVOK8yNqvn1Nf9zdxc5Tnr6I4kkt4TD0JasEceuqyqwmBt3qLEU2ezeNp0E4oe92zyt1NtAPzFGdFTZrLhdFgjl+4iZxuhByQc/OluOJ9cZQTQ== 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=EUXhWT8p0YSJvzQO6PvpphpmAnmbX4YtauGlNWoGs4A=; b=WkUUVi4iFeb5m7fl0ncdUHednnzoLMtRlrkzUlH9lIrqIeMa1dztF9VkyOlBUoaA7ox1fysITaC0Z5DxVm6zuZFhHG7OC76AAhIezVzHdw9FdyUgNRQ8bNRTJZ029u6SNirDMnLsya2zDsJCR/djzBwUFbn7v0Ig10v38aC+6jjiuGb+78mGDcIXCPhkfdpXlNDEAIF/ySnqZsKrBTm2BjVWZRLd5Vyy9Rn8CWHX1SPCLPdc5IsUzR4kHfB8QOJNIDTeEJwfM7R0korP2umAzUvsqsgflFgJxe7QunyzSbffJmqQLJdTsiRxic2YQixKHQd613S2EZ6yVdNVk4lULw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; 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=EUXhWT8p0YSJvzQO6PvpphpmAnmbX4YtauGlNWoGs4A=; b=r2apCBioeXaubH/uNg4lglOMzmn/IPvlXcHbYpoC42pKbtIyJLi6Ri33UC13MjshOj3rpXUQittARecsmKw3bIgt+1hGaG3eiVd1boGn5nPjfhaiiCHgKxx+wmG3JU3d2hC+AcmcLMd8V27dlbd8Ugba6X7FB7rEwpR3iyUq9hU= Received: from DB7PR08MB3097.eurprd08.prod.outlook.com (2603:10a6:5:1d::27) by DB7PR08MB3674.eurprd08.prod.outlook.com (2603:10a6:10:4a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.25; Mon, 23 Nov 2020 13:26:45 +0000 Received: from DB7PR08MB3097.eurprd08.prod.outlook.com ([fe80::315c:f6c3:2600:bd39]) by DB7PR08MB3097.eurprd08.prod.outlook.com ([fe80::315c:f6c3:2600:bd39%6]) with mapi id 15.20.3589.030; Mon, 23 Nov 2020 13:26:44 +0000 From: "Sami Mujawar" To: Sughosh Ganu , "devel@edk2.groups.io" CC: Ard Biesheuvel , Jiewen Yao , Achin Gupta , nd Subject: Re: [PATCH v1 09/12] ArmPkg/StandaloneMmMmuLib: Add option to use FF-A calls to get memory region's permissions Thread-Topic: [PATCH v1 09/12] ArmPkg/StandaloneMmMmuLib: Add option to use FF-A calls to get memory region's permissions Thread-Index: AQHWp54ccjrTthDI2USCm7HCLh5x76nV5RWA Date: Mon, 23 Nov 2020 13:26:44 +0000 Message-ID: References: <20201021113233.25548-1-sughosh.ganu@linaro.org> <20201021113233.25548-10-sughosh.ganu@linaro.org> In-Reply-To: <20201021113233.25548-10-sughosh.ganu@linaro.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: AB4F5140249E3C4A88FEB435E0A90C38.0 x-checkrecipientchecked: true Authentication-Results-Original: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=arm.com; x-originating-ip: [2a00:23c6:548a:4800:e1e2:5e02:5cb9:6f61] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cbeade3e-f488-4880-ba57-08d88fb36ff9 x-ms-traffictypediagnostic: DB7PR08MB3674:|AS8PR08MB6261: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:6790;OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: HT87Io+HlMIfq9Yr7tTj6ceGNtgPFB+XUSL9xOtxrviUoDGu592e3GlDa0CVV3DOrnpnUKdeR9G0UJbmMKkyGF08/RP7+no3jqPM/CAEkDqRc2tw87cgTXmNZFGo+ngbGhGRsg6R3hVA4faUM7jcTl5c8P56ugaXEf0Esr0cFT5C/arKBzhuUo/zQ3e/ugMPePOUVxxkZEDxemodJP/DU51lrWp/5gmy7D6aZtnFKAYf619JHyTu5SAOecMSzEstDjvOudp6vm5K9nbAFrdwl8M3Anh5mAdM4XREnDoEYZxqchdEDjbJWMvpTZrv0ElFzsoxOVqtSO0TxB6t66etM7oirThIYvb3VcNieXRWyRA= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR08MB3097.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(396003)(346002)(366004)(39860400002)(136003)(376002)(86362001)(8936002)(9686003)(83380400001)(4326008)(53546011)(8676002)(2906002)(5660300002)(316002)(55016002)(966005)(110136005)(478600001)(76116006)(7696005)(71200400001)(64756008)(33656002)(186003)(52536014)(66556008)(66946007)(19627235002)(6506007)(54906003)(66446008)(66476007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?V3Vqugqd8u5KHXy3auf2PwyXzSsN6EqORJu+D17dPa74KT6eVO5XfEkRzZsC?= =?us-ascii?Q?JhHoBRGXVp36TxLCbaNtP82w++kW0xo4QZObioxf1tFF6DUWQz95GZvZ5ueq?= =?us-ascii?Q?cJgN+GMitGjX9BDeOvy89vQX5/AVvJlj+y13qkyPGOb7x9YAbGEvqkCYyW5y?= =?us-ascii?Q?LOaRjpSu9jAFYhUHg7+CLHobi0HKmJzf8v7EnHXfNLSND/CnWNV9od+udK4q?= =?us-ascii?Q?f0xXqFeEyyqtL4YpG23ZRipmfFba5U1B2wO+qHuWSjy+zDL4c3uhwE5pxLz2?= =?us-ascii?Q?0VefF23Ixy8IkXVfQBFQ//MbKanJN8pt/FK5/gyYMHiy3en+I/KDN0pA8ZKi?= =?us-ascii?Q?vJ/iyQr7/MRiL9/A/DywT1eQsIMRet02LLSHTZAJOw2bF/8uau+rSQ6f+7tq?= =?us-ascii?Q?eeU/ofKyO2GFm/9PUHjmY9WLfnp3uYwe/isiLe/lCVzOsvjEY0buJeroRcEq?= =?us-ascii?Q?6m1qonM/01FT20+ah7ZwuM2V+mhvD2OdL7rP7grrJS4yfdkrsHAccrywxV+S?= =?us-ascii?Q?O9ZSoWlyoXcmYCrRdapundTJONHHH51uM89GXkvmMwU+o6al/vElG+DnrVub?= =?us-ascii?Q?bT4O/K/96ucGvlPcpvOm3vNKtIh78fq64IetxJWfHxwld6lsKm/7BJSY6hPX?= =?us-ascii?Q?CvqtmxUIFO588o1kfO23RUV0gHVBD7OmH0cF05qea8+3BnQqsGPDyNQwrOGx?= =?us-ascii?Q?VVV9vc2kMZ0UlBxlK3xAhskWI6qU+3sCZvBI+RMfoEl5XvcifEpSuSIgGATx?= =?us-ascii?Q?OzJpGaJfehMzA8preavJR8/lOAhbdhiHu8fnodQ6S2Z4MFRiYSY6uonuqsPF?= =?us-ascii?Q?DRj42bH04YR3tFRrrmtQU4zAe1gd4Iqx6gX4v4etIiq2IPpEKmc+zWpr/7si?= =?us-ascii?Q?N6ZEqUx78rYlIprvdjTXLMU1crfQlzAJLvlDDbQU+SkcSxFG5mMFrb9KOzAJ?= =?us-ascii?Q?Y6rvSkB3nPUxB+zep7m9Og=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3674 Original-Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 96e81b94-ef76-49ae-57f0-08d88fb36c2a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tjJtTSPyFYgL/3qnTzxf4e0fvt94Ljr+TS1FUmhru0dCG+0VG4i4oVUP5k2KXXnrWQVD9dc5jFLpY06L9G9wJjR/KKXJj2Mw8EmdzdZhSP4jXlrJT6XeObp4Od+cs3mJS18dT3NjjGu8G1NEfmlkGgmM5ivSkWn3WogZRVSVHSNOFkBMI37OhoOfPPIKTxFVCY9LGqcB0aH+61+uTKMYHR6Qo+MPQTH+guxmPuDNZpeJeCekpWTWXbNW+Fv4Cw2H5tmXx733OCnlhtk+vcQNeMeLKjEGKn9ZLu+0EAyaUGMbd4Rd6HZbA+A45U4dxGY0nO5bOE8h6WG5wRCeD1an3fIThgFQSe5p2LZZ5Fd9jBdcEPFPD9j1qWzYa+WOuEZNFZ8ypC75XWzPK9mekLRbuOR0LC5tj3ISk1Sc2K4YWdEC9WQIwcWXN/w/JYAh6Gtu 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)(39860400002)(396003)(136003)(376002)(346002)(46966005)(33656002)(81166007)(54906003)(2906002)(186003)(19627235002)(55016002)(9686003)(4326008)(966005)(336012)(478600001)(82740400003)(8676002)(47076004)(8936002)(70206006)(52536014)(82310400003)(86362001)(83380400001)(316002)(6506007)(53546011)(36906005)(110136005)(70586007)(7696005)(356005)(26005)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2020 13:26:51.2950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbeade3e-f488-4880-ba57-08d88fb36ff9 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: AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6261 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Sughosh, Please find my response inline marked [SAMI]. Regards, Sami Mujawar -----Original Message----- From: Sughosh Ganu =20 Sent: 21 October 2020 12:33 PM To: devel@edk2.groups.io Cc: Ard Biesheuvel ; Sami Mujawar ; Jiewen Yao ; Achin Gupta Subject: [PATCH v1 09/12] ArmPkg/StandaloneMmMmuLib: Add option to use FF-A= calls to get memory region's permissions [SAMI] Please abbreviate the subject line if possible. [/SAMI] From: Achin Gupta Allow getting memory region's permissions using either of the Firmware Framework(FF-A) ABI transport or through the earlier used SVC calls. Signed-off-by: Achin Gupta Co-developed-by: Sughosh Ganu --- ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 3 +++ ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c | 28 +++= ++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf b/= ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf index 85973687f5..a29dd800b5 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf @@ -23,6 +23,9 @@ ArmPkg/ArmPkg.dec MdePkg/MdePkg.dec =20 +[Pcd] + gArmTokenSpaceGuid.PcdFfaEnable + [LibraryClasses] ArmLib CacheMaintenanceLib diff --git a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLi= b.c b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c index 362b1a0f8a..ab13602556 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c +++ b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 STATIC EFI_STATUS @@ -25,19 +26,32 @@ GetMemoryPermissions ( ) { ARM_SVC_ARGS GetMemoryPermissionsSvcArgs =3D {0}; - - GetMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AA= RCH64; - GetMemoryPermissionsSvcArgs.Arg1 =3D BaseAddress; - GetMemoryPermissionsSvcArgs.Arg2 =3D 0; - GetMemoryPermissionsSvcArgs.Arg3 =3D 0; + BOOLEAN FfaEnabled; + + FfaEnabled =3D FeaturePcdGet (PcdFfaEnable); + if (FfaEnabled) { + GetMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RE= Q_AARCH64; + GetMemoryPermissionsSvcArgs.Arg1 =3D 0x3; + GetMemoryPermissionsSvcArgs.Arg2 =3D 0; + GetMemoryPermissionsSvcArgs.Arg3 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_= AARCH64; + GetMemoryPermissionsSvcArgs.Arg4 =3D BaseAddress; + } else { + GetMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_= AARCH64; + GetMemoryPermissionsSvcArgs.Arg1 =3D BaseAddress; + GetMemoryPermissionsSvcArgs.Arg2 =3D 0; + GetMemoryPermissionsSvcArgs.Arg3 =3D 0; + } =20 ArmCallSvc (&GetMemoryPermissionsSvcArgs); - if (GetMemoryPermissionsSvcArgs.Arg0 =3D=3D ARM_SVC_SPM_RET_INVALID_PARA= MS) { + if (GetMemoryPermissionsSvcArgs.Arg0 =3D=3D ARM_SVC_SPM_RET_INVALID_PARA= MS || + GetMemoryPermissionsSvcArgs.Arg3 =3D=3D ARM_SVC_SPM_RET_INVALID_PARA= MS) { [SAMI] Other error codes can also be returned and must be checked.=20 See FFA Spec, section 10.2 and also https://trustedfirmware-a.readthedocs.i= o/en/latest/components/secure-partition-manager-mm.html#mm-sp-memory-attrib= utes-get-aarch64 For FFA the error codes would be returned in Arg0 & Arg3. For SPM based on = the MM interface the error code would be in Arg0. It might be better to check if FfaEnabled is enabled here and handle the er= rors appropriately. Also, it could be combined with the following code that= returns the Memory attributes. [/SAMI] *MemoryAttributes =3D 0; return EFI_INVALID_PARAMETER; } =20 - *MemoryAttributes =3D GetMemoryPermissionsSvcArgs.Arg0; + *MemoryAttributes =3D FfaEnabled ? + GetMemoryPermissionsSvcArgs.Arg3 : GetMemoryPermissionsSvcArgs.Arg0; + return EFI_SUCCESS; } =20 --=20 2.17.1