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 74400D811AC for ; Fri, 12 Apr 2024 14:33:50 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=8hcBqv/l7GegYeFbjPkou0xKA237AiCNe//4nIeseYs=; 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=1712932429; v=1; b=FiFptZF86pzWGmEdAWeESlqFLd5p4r3+CBxNukaBJcST91d4Rk6noa87glTeizrzkVvIV/XV cvL5BpgOhT8d0l5Dr81ibJAxaH/Vh4esrMeYyc9OW+Uk0iaGCvG5ne2FK17UWhnZB3vP9DpGxJd ffaMvqnZzCkuDfEDxy9mavDvKdkXN3DiLx/IyreCPiVCzs3YAznJ2MA2MioTLCk8e/9ThBmCYop bLvKOjAJjdomzdjpRLRlBmT5XV981hpNy0cA/TZgT3i02NiMBaoTHRXSEjDmWMrW0yvcJXhnIKK oIRKvO1gPKdHuohlBbIVytlQ6vx4XJVS3QfOWkGBH4LBQ== X-Received: by 127.0.0.2 with SMTP id aADUYY7687511xmGxt17P3Fl; Fri, 12 Apr 2024 07:33:49 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.89]) by mx.groups.io with SMTP id smtpd.web11.47953.1712932428152338607 for ; Fri, 12 Apr 2024 07:33:48 -0700 X-Received: from DUZPR01CA0229.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b4::26) by PA4PR08MB5949.eurprd08.prod.outlook.com (2603:10a6:102:eb::22) 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 14:33:44 +0000 X-Received: from DU2PEPF00028D10.eurprd03.prod.outlook.com (2603:10a6:10:4b4:cafe::a) by DUZPR01CA0229.outlook.office365.com (2603:10a6:10:4b4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.19 via Frontend Transport; Fri, 12 Apr 2024 14:33:44 +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 DU2PEPF00028D10.mail.protection.outlook.com (10.167.242.24) 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 14:33:44 +0000 X-Received: ("Tessian outbound 8c03561b2da6:v313"); Fri, 12 Apr 2024 14:33:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b180eb7d9ae084f2 X-CR-MTA-TID: 64aa7808 X-Received: from d2c8bfa44ece.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 936195FD-ADD5-4CB9-BD16-97F006D87C13.1; Fri, 12 Apr 2024 14:33:37 +0000 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d2c8bfa44ece.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Apr 2024 14:33:37 +0000 X-Received: from DB8P191CA0019.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::29) by AS8PR08MB7742.eurprd08.prod.outlook.com (2603:10a6:20b:50a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 14:33:33 +0000 X-Received: from DU6PEPF00009529.eurprd02.prod.outlook.com (2603:10a6:10:130:cafe::c6) by DB8P191CA0019.outlook.office365.com (2603:10a6:10:130::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.39 via Frontend Transport; Fri, 12 Apr 2024 14:33: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; pr=C X-Received: from nebula.arm.com (40.67.248.234) by DU6PEPF00009529.mail.protection.outlook.com (10.167.8.10) 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 14:33:33 +0000 X-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.2507.35; Fri, 12 Apr 2024 14:33:31 +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 14:33:31 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [edk2-devel] [PATCH v2 13/45] ArmVirtPkg: Add Null instance of ArmCcaLib Date: Fri, 12 Apr 2024 15:32:50 +0100 Message-ID: <20240412143322.5244-14-sami.mujawar@arm.com> In-Reply-To: <20240412143322.5244-1-sami.mujawar@arm.com> References: <20240412143322.5244-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DU6PEPF00009529:EE_|AS8PR08MB7742:EE_|DU2PEPF00028D10:EE_|PA4PR08MB5949:EE_ X-MS-Office365-Filtering-Correlation-Id: 28e7f5f2-3ba6-43e1-a0a8-08dc5afd8e6f 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: 8WtfeQnkNy1H4jJFaVcEwifsTnpKpc0Bmt/nC1RIR6Bz7vQuX3zgxBajHxamgRrZsoMqF/ZZaKLGdouKFIljCYoJkl5EwWNPFI1b2OiNh2Jcgyg4fslCLLBKsJLk8J0gB1A3ogJSUJM2rgmlxMFhbqnoQQ6GrKBoDAtd8Zapk7mJ+ZIvAYJ682tzl6hMXdKoQiyrc4LFr284/ip+6QCzGcSFdWWvHG8iq7WNpKI1gG/lVhyqT1EzJOiZa8kIFjiKBrGe8BDUDegmzc5JHqRlUHjRsNAFFbeM9wHmhtb95xbJd4+jBiZKlbntjDes2BtagzfDyKJwIj6Al6UHhHg3B3bEoYpjhRbeiGJNv3oIXymHbp+5k11TgpnV59dcESRbeg2sj2XHwh4BK0Kq/FuMJgnx8K3XyhYNzuZIxY3dpVq7KGX3KX+ng02SpRn9CJW+hZarWTJAAitrm8btfz54Ac+hwNkh5S5rAC958CDE3pjzRcXbiR+TLr9NRFwQNL0YPIKub0JnILllLlmQcEr6WY4l+mK9041l5fxDDfwtFbTYvVNUicBT7/NFI0U+iefJYgEi+7FcJMyRcrMSdNYzf5OlD1GTbK38+bFyDsgKXPtZyFwSBUrD7ouzMAlUqGjTgDb3EZdu5LVjypfBw7nmgpvvKtIRHQtEjxMkbp1X3XFxUnOldufrJC6dE7fsLLC9nBzYACwf8umVf/g/C4YFeYsjxPlpfZ4veG9AAwRB1GoC0u1a1s6HYB0/VPwGs1JN 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)(82310400014)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7742 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF00028D10.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8b39a0de-b62f-4ccf-b00d-08dc5afd87f2 X-Microsoft-Antispam-Message-Info: ghIa/zvYvvHSrEtYk+2xcSBvFZ2joYfVpwQcyldcklBdTpZ6iVDMBqLPJgJbujiLOkx8y+KrrNYTFKY70Unszrv0qfAyeRmdJ3hreJS0HJGa1FE6DwS//zSNq6HEHFOW44D6/c+bRYIRdnfJaxqego5y9+te9PahoAN6IZ/FFD5TirG1q/fzNdzxkNb5JBbn1vFwVwND1shqRhOr8YIb/tfmV+nEiHvYAZ1QgbU36g1aNzl9hQBNZqCiZeL/5IoMJZ1ZdZ+vyuxpO7jAiAGt/1haeVF6xlES5MAUWn7/WFON72kkn2X7346pwpBX+1FJ336VDusm8SIa0izsMU1Fd/Os0TZRdt6DEZAon/tOZuDKieZQBMsHK9RNztmHwA0W70fi9lsuakpYn44w8RWZmAdemhJvHKxqFfz3un/iY0tZfuFVZca+rWa6ErXMAxkd98c6uH2tw7Wyl05fnDCNkdQLoCe+DceDSYWvyeD6++DBwMr4fpiGPLsE85gU4f/SU0J+zG7zKnJMQZ8AqMgUFAeVGn5Sif1vaQLMqQvb+BbHImPVt2EH9u2nA4buVxHpMbx8AebhNu1SvCohvlRTNIPH1SzExzf43SUZEbZWH1oE4Rc/QShlDGsS1hsjPc5hVLWsewLmpR8sNU5Xbu1s5c3dFKwWAElvLud15cgmbD0FOJF2aGnXrg/jB2yCYtry0jw9Kdae5Eg6vHo+7ixJcecgIDsONnU62lHNKLnGu4LcI9fcZQ34QvQdkLXcqdRl X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 14:33:44.2517 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28e7f5f2-3ba6-43e1-a0a8-08dc5afd8e6f 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: DU2PEPF00028D10.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB5949 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 07:33:48 -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: 3CxQECZTjKLTrwTPQ4vCmHrwx7686176AA= 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=FiFptZF8; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.227.220 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) Add a Null instance of ArmCcaLib so that guest firmware that does not support Arm CCA can link to this Null version of the library. Also include it in ArmVirt.dsc.inc so that it is linked for the non-Arm CCA firmware builds. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Gerd Hoffmann Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirt.dsc.inc | 4 +- ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.c | 117 ++++++++++++++++++++ ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.inf | 28 +++++ 3 files changed, 148 insertions(+), 1 deletion(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 8c1063fb73f81e69e866549a2ba9b12945c83d9c..c8a29dd8ebc88107c4caab4f826001d9b0c2e7f7 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -1,5 +1,5 @@ # -# Copyright (c) 2011 - 2022, ARM Limited. All rights reserved. +# Copyright (c) 2011 - 2023, ARM Limited. All rights reserved. # Copyright (c) 2014, Linaro Limited. All rights reserved. # Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. @@ -180,6 +180,8 @@ [LibraryClasses.common] ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf + ArmCcaLib|ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.inf + [LibraryClasses.common.SEC] PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf diff --git a/ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.c b/ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.c new file mode 100644 index 0000000000000000000000000000000000000000..e5e645e148d485fc324e060ec27fbc3607fe8aae --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.c @@ -0,0 +1,117 @@ +/** @file + Null implemmentation of the ArmCcaLib library. + + Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Rsi or RSI - Realm Service Interface + - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state +**/ +#include + +/** + Check if running in a Realm. + + @retval TRUE The execution is within the context of a Realm. + @retval FALSE The execution is not within the context of a Realm. +**/ +BOOLEAN +EFIAPI +IsRealm ( + VOID + ) +{ + return FALSE; +} + +/** + Configure the protection attribute for the page tables + describing the memory region. + + The IPA space of a Realm is divided into two halves: + - Protected IPA space and + - Unprotected IPA space. + + Software in a Realm should treat the most significant bit of an + IPA as a protection attribute. + + A Protected IPA is an address in the lower half of a Realms IPA + space. The most significant bit of a Protected IPA is 0. + + An Unprotected IPA is an address in the upper half of a Realms + IPA space. The most significant bit of an Unprotected IPA is 1. + + Note: + - Configuring the memory region as Unprotected IPA enables the + Realm to share the memory region with the Host. + - This function updates the page table entries to reflect the + protection attribute. + - A separate call to transition the memory range using the Realm + Service Interface (RSI) RSI_IPA_STATE_SET command is additionally + required and is expected to be done outside this function. + + @param [in] BaseAddress Base address of the memory region. + @param [in] Length Length of the memory region. + @param [in] IpaWidth IPA width of the Realm. + @param [in] Share If TRUE, set the most significant + bit of the IPA to configure the memory + region as Unprotected IPA. + If FALSE, clear the most significant + bit of the IPA to configure the memory + region as Protected IPA. + + @retval RETURN_SUCCESS IPA protection attribute updated. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The request is not initiated in a + Realm. +**/ +RETURN_STATUS +EFIAPI +ArmCcaSetMemoryProtectAttribute ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 IpaWidth, + IN BOOLEAN Share + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Return the IPA width of the Realm. + + The IPA width of the Realm is used to configure the protection attribute + for memory regions, see ArmCcaSetMemoryProtectAttribute(). + + The IPA width of the Realm is present in the Realm config which is read + when the ArmCcaInitPeiLib library hook function ArmCcaInitialize () is + called in the PrePi phase. ArmCcaInitialize () stores the IPA width of + the Realm in a GUID HOB gArmCcaIpaWidthGuid. + + This function searches the GUID HOB gArmCcaIpaWidthGuid and returns the + IPA width value stored therein. + + Note: + - This function must only be called after ArmCcaInitialize () has setup + the GUID HOB gArmCcaIpaWidthGuid. + + @param [out] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_NOT_FOUND The GUID HOB gArmCcaIpaWidthGuid is not + found and could mean that this function + was called before ArmCcaInitialize () + has created and initialised the GUID + HOB gArmCcaIpaWidthGuid. +**/ +RETURN_STATUS +EFIAPI +GetIpaWidth ( + OUT UINT64 *IpaWidth + ) +{ + return RETURN_UNSUPPORTED; +} diff --git a/ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.inf b/ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.inf new file mode 100644 index 0000000000000000000000000000000000000000..8f6c251afb14da48db45ba78d96d1d497e3fe8eb --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaLibNull/ArmCcaLibNull.inf @@ -0,0 +1,28 @@ +## @file +# Null implemmentation of the ArmCcaLib library. +# +# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = ArmCcaLib + FILE_GUID = 9E3F7AAA-10A6-4513-A960-B87F4D7DCFC5 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = ArmCcaLib + +[Sources] + ArmCcaLibNull.c + + +[Packages] + ArmVirtPkg/ArmVirtPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117673): https://edk2.groups.io/g/devel/message/117673 Mute This Topic: https://groups.io/mt/105483411/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-