From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103551+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438690824155.888233617516; Tue, 25 Apr 2023 09:04:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DyssYY1788612xcUM9bLdPgo; Tue, 25 Apr 2023 09:04:50 -0700 X-Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.73]) by mx.groups.io with SMTP id smtpd.web10.83956.1682438688830226331 for ; Tue, 25 Apr 2023 09:04:49 -0700 X-Received: from AS9PR01CA0047.eurprd01.prod.exchangelabs.com (2603:10a6:20b:542::28) by PA4PR08MB6288.eurprd08.prod.outlook.com (2603:10a6:102:f3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: from AM7EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:542:cafe::49) by AS9PR01CA0047.outlook.office365.com (2603:10a6:20b:542::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103551+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT059.mail.protection.outlook.com (100.127.140.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: ("Tessian outbound 3570909035da:v136"); Tue, 25 Apr 2023 16:04:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 837b05f3741222ac X-CR-MTA-TID: 64aa7808 X-Received: from 832eb5b6e3ad.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C8433F6B-7576-43F5-A93B-8880B81CB2C4.1; Tue, 25 Apr 2023 16:04:38 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 832eb5b6e3ad.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KwhdfDaf8SamSez1laHTpDqcxoVXAGDY5jemOn8hHMWf1a9UQRk+R4S20/cxAJaj+rkqEX95Pkih7s0TTe+EDM6u8YfiYXh+mXiy8MaZRhUdH1mjZgKFpwsPPwxSWJrR4UGDh4jQbWdoD4NEXMErbHkhAOEJQp/21bHmdCHe5g+WEtEJPm9dsdbeH5X/k0V/X3+7IlV8TBFHkeW1hwv3o48g3udzMNUO37iiHS+j0cqX0CafZR3B72aBktjb3tyTMv7wDVHIauXsUKH4G1/OPGcfTi+oMNo58KpXgIdyaTeatkGhrgbUVzsn2ujdHWu8Is7jLJIp0Ad7ey5jNTziTg== 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=+w4gO6Uj8Jkt++7ACJ0wCttUc8O/m4k4hbxpzVPFznc=; b=fmJpB8TEf9C/fV6MlcF0Fk9MSjuijHrl2/2DtpVDrUsRUhRIQ8pRzrhl3pFZyojTqtgMfiRijms6U4RNQnVl4t8n47T7lslhbNT7LBTh79zu4/oQ7l5y6H7YECYUsIsDbiGrCDmHES/w31fQ8IZU+1jM1pggP8xL5WSrFVEKZEGaTfjsm8ApP8w8lbZu188D7bkffnjnFjduWvt+GmGC6E4tm3EZP7Ln02Cehnl0gwAhu/6E8TE4itJ7QsyLIBvNoWi5bGy/s//cJVZ8h8d2RYQt+PtpqTaO6voWTFU98gXTWa8uhfuoOUx7HD2oZVav2Tidr7FSBVLhJ4h15Qcqaw== 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 X-Received: from DB6PR0601CA0033.eurprd06.prod.outlook.com (2603:10a6:4:17::19) by VI1PR08MB5469.eurprd08.prod.outlook.com (2603:10a6:803:132::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:33 +0000 X-Received: from DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:17:cafe::b5) by DB6PR0601CA0033.outlook.office365.com (2603:10a6:4:17::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04: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 DBAEUR03FT052.mail.protection.outlook.com (100.127.142.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:32 +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.23; Tue, 25 Apr 2023 16:04:31 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:30 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 01/30] ArmVirtPkg: kvmtool: Add Emulated Runtime variable support Date: Tue, 25 Apr 2023 17:03:59 +0100 Message-ID: <20230425160428.27980-2-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT052:EE_|VI1PR08MB5469:EE_|AM7EUR03FT059:EE_|PA4PR08MB6288:EE_ X-MS-Office365-Filtering-Correlation-Id: 31ff02fe-4e8d-4ea8-48bf-08db45a6c98b 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: KlHAAuJUhmpQQqqc3/dA0/fUHZUdL8ucqBrsJQ/rMS5GWCpVfNj/psIr8MnVdI3+m68FbPjFP/c/XFeUhvWGwjTfM1HGzkK7TquJUpAkJUqNiTpKgt2xoFdDdnFJ0pJsayxQWYNrBI4AvE7JYDO4+nztQZiOtyjmVPwHVo1Veo/KlbrPcmZhnWUWjsViAV1egi0pbc/xYPpno7Oy2NsYI5SD75SqYY8svc7dcSuXGCdk+0aUQyVkC42L+zYyY4pnJgOvY14HDlUjSup36A8AgxDH0PnWJm3sVsug7JJpJnaIJS/vkGvKExmyE9iFtQ+FCDLrc9Wxz5evvpuF4TG2ago2u16RNM+yKvJ/pb/OXUoylcz69mRI1Frc3heFMpfIVZgQv2+HciT8SYSOYH8wgAa66TWWf1SqROheZZJmPjpK/THibRA5WBQNUUe0qrywj4edwjQ06dyJZ3l04laz8A8jcMuLTQj99sdXssGNAsowG4MDvN115sMD8cik94MismDz/8U9hF7C6d+vijRNDEkrYjxnkIUGlfiCcobmqWyXabDe6h8fkfFVZanfrGbQmHSYVBYQqltfCXNA1C5Iw3oTVmlCZIDnwbkiVkhvlwxLm1ETCtKlZxQybBCce+pIPaCJSWtesZyH5Qrd37ConRl29Cxy5LkZX1k5ZMEpOhqKsRlAfvjl1ITNI8fegUiz4KKFxAOmBvD+x/lPfor2cr16Gicg+UHPSC8JUMx9JVg= 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:(13230028)(4636009)(396003)(39850400004)(346002)(136003)(376002)(451199021)(46966006)(36840700001)(7696005)(2906002)(2616005)(6666004)(186003)(40480700001)(1076003)(70206006)(70586007)(8936002)(8676002)(41300700001)(6916009)(4326008)(316002)(26005)(478600001)(44832011)(5660300002)(54906003)(82740400003)(356005)(81166007)(82310400005)(36756003)(86362001)(36860700001)(47076005)(336012)(426003)(83380400001)(34070700002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5469 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 088ed2c7-f53f-4ff3-ec43-08db45a6c22b X-Microsoft-Antispam-Message-Info: RQ3rUS258ctdUz8x3WxGotno6h3pVQTUXim6mImerL0sF/wp2HdLlhOsvHqXccfShJNICi/PqNHvx1cdgiFTYox4lbtfVBwXiaLzts5+cT6hRHguMHPkhalcdcUz/9gKRIL02RyEHZobyLbsA8zvtBo5rhqlKBAskGEpzvZLBHGYV/iew/FEGvp3nF9StCjjI5k9SfJv9fDSPue0w4a/kZtCEA8QCYK57ICbUzrX/RwcTRMxgI+/++iiJ/TbfpHcy0uzvzB9TuTI9OeEbuesncwS4dlgxpomphX7Vhus5GagptfCtlQm0p1nkTptGPwppw/m8hWq5PejqFE715a+CuLHwBBFJMqVEihRQnLvbQ1bFDMKE5j6tBzIEfq/BaDyXL3F+vfsuoAHOSC/UoGrbv2Q9ZXYq4p+RnuNnmVenqBpnDy4m70h9QAVyi90cMfHTEUZ4sPWKeScXKbLfpadIF2ydXHGc1M6wYtsHO15/vyyHGc56OsYhdOlsVKJnP4MwSAB2PSmgWkhbrxcWHgQzmGYRsziszDJfmw5viIf6/1q3+zmIwkyyGrIkc7wMdLRmwwmUOZsIf2WjMQFHeD9qHtIMhid3OUblrOxVnowViVgLnMUvwHTJgvxFimgxdLt1E/v9RteYu4Pi81SItqBGZLYrpZQOwB52hmAHByKNMp1KzxoZLrpjARyAer0l4qTsJsEFVQ4vkbo5bsUIWzUSAIlFkP8YGS1I35n+l0xLnw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:45.0824 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31ff02fe-4e8d-4ea8-48bf-08db45a6c98b 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: AM7EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6288 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: NT149GMTViSjoP12Wd2BUBBkx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438690; bh=LyQlf9xDLTE33jVje1KNv9yIsnLnLDqEuu5LLnMIaZo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=svUEuOXFiKUIdNZfM6YFP1TtDlvUOM+HIUP9XTyeH5rZ9/SM9sXxbB7fHUepkniKj6F HQZXafb6cgeOp+BPMVC0g/4Uj3OqvKylJXr40+EJHxZ8Qih3gpcM9XGiRsodpM4sbsez3 SQIIr1mIEG4BltpREdBmuvq2W1R3Rb9h3ak= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438692721100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Although Kvmtool supports a CFI flash interface, it is currently implemented using file backed support on the Host. This scenario requires the VMM to be within the trust boundary. In Confidential Compute Architecture the VMM is outside the trust boundary. For such architectures Emulated Runtime variable storage is desirable. Therefore, make Emulated Runtime variable storage as the default option and add a build flag ENABLE_CFI_FLASH to configure the firmware build to use the CFI Flash as the Variable storage. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtKvmTool.dsc | 22 +++++++++++++++++++- ArmVirtPkg/ArmVirtKvmTool.fdf | 4 +++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index d0afe1b49e250c554313c2077b89650d6f6d67cb..d2228a95726b24fe5c2edfbc84b= 1f5c23a85feba 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -1,7 +1,7 @@ # @file # Workspace file for KVMTool virtual platform. # -# Copyright (c) 2018 - 2022, ARM Limited. All rights reserved. +# Copyright (c) 2018 - 2023, ARM Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -50,7 +50,9 @@ [LibraryClasses.common] ArmVirtMemInfoLib|ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMe= mInfoLib.inf =20 TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf +!ifdef ENABLE_CFI_FLASH VirtNorFlashPlatformLib|ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKv= mtoolLib.inf +!endif =20 CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf =20 @@ -156,6 +158,13 @@ [PcdsFixedAtBuild.common] # gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16 =20 +!ifndef ENABLE_CFI_FLASH + # Emulate Runtime Variable storage + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 +!endif + [PcdsPatchableInModule.common] # # This will be overridden in the code @@ -211,6 +220,7 @@ [PcdsDynamicDefault.common] gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640 gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480 =20 +!ifdef ENABLE_CFI_FLASH # Setup Flash storage variables gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x40000 @@ -218,6 +228,10 @@ [PcdsDynamicDefault.common] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x40000 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x40000 +!else + # Emulate Runtime Variable storage + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 +!endif =20 ## RTC Register address in MMIO space. gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister64|0x0 @@ -263,7 +277,9 @@ [Components.common] MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf +!ifdef ENABLE_CFI_FLASH NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedL= ib.inf +!endif BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf } =20 @@ -271,7 +287,9 @@ [Components.common] MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf { +!ifdef ENABLE_CFI_FLASH NULL|ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf +!endif } =20 MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf @@ -296,11 +314,13 @@ [Components.common] NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClie= ntLib.inf } =20 +!ifdef ENABLE_CFI_FLASH OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf { # don't use unaligned CopyMem () on the UEFI varstore NOR flash regi= on BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf } +!endif =20 MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf =20 diff --git a/ArmVirtPkg/ArmVirtKvmTool.fdf b/ArmVirtPkg/ArmVirtKvmTool.fdf index 82aff47673cb3085c91c1dd7431683c8353c16e6..8ccbccd71e134e0ea97d4938029= 3687aca43e8b9 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.fdf +++ b/ArmVirtPkg/ArmVirtKvmTool.fdf @@ -1,5 +1,5 @@ # -# Copyright (c) 2018 - 2022, ARM Limited. All rights reserved. +# Copyright (c) 2018 - 2023, ARM Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -154,7 +154,9 @@ [FV.FvMain] INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf +!ifdef ENABLE_CFI_FLASH INF OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf +!endif =20 # # FAT filesystem + GPT/MBR partitioning + UDF filesystem --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103551): https://edk2.groups.io/g/devel/message/103551 Mute This Topic: https://groups.io/mt/98495953/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103578+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438810310941.4602547976842; Tue, 25 Apr 2023 09:06:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OiNkYY1788612xeoEhDYE8ZW; Tue, 25 Apr 2023 09:06:49 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.60]) by mx.groups.io with SMTP id smtpd.web11.83522.1682438808995796268 for ; Tue, 25 Apr 2023 09:06:49 -0700 X-Received: from AS8PR07CA0012.eurprd07.prod.outlook.com (2603:10a6:20b:451::12) by GV2PR08MB10384.eurprd08.prod.outlook.com (2603:10a6:150:b2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Tue, 25 Apr 2023 16:06:42 +0000 X-Received: from AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:451:cafe::f0) by AS8PR07CA0012.outlook.office365.com (2603:10a6:20b:451::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:06:42 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103578+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT058.mail.protection.outlook.com (100.127.140.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Tue, 25 Apr 2023 16:06:42 +0000 X-Received: ("Tessian outbound e13c2446394c:v136"); Tue, 25 Apr 2023 16:06:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1093fe20b0a86a97 X-CR-MTA-TID: 64aa7808 X-Received: from 95cc29501919.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5FCC725C-A080-4E2E-8B67-3C86A7A29F63.1; Tue, 25 Apr 2023 16:04:37 +0000 X-Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 95cc29501919.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MqJc5j3QXxZVST6X4DdIUbPPNcMXDGEQ6kxDJrTvPoxdLgMYnfvLkHizxw6AAQBfiYhNQy2RZQStkCdFlfbsG/2BQo0PfOr8ISu3HpNEpSbYOpvd202+tfTOWeK9KtHW2k6CAILzzVsdOv+n3vOnc3odatOtfFRhHCG0ZYmc6aZv+n9faN0gQ4K/fSUKfT6et8/KP0APdZfkhEIQ2bCodolsAgGEXjnHElwz+5j6/l3ozb9VMmD3CIj+LTMx+FXmXMJeEeW9OdBwi2ORlZ/GsvPXt6mbB5bCeYm2d6vOwH5msjR9y6lOZ2ndEyikhzf9kR96RWkfqdCkmz/iAhxc/A== 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=cA9ZGbgHr2nqbmhR6QxfnNixcBufCHRmpV7d8GJ+anE=; b=LaVGMxwaxzX6CTm2KrRNf+u+2S8FXpWEuwDw7ptlX5A8n2EfcRBstDoaE8fqz40REO181hizzpx05TpwJ+YVNInW88dJygf14hfdBI0V8PuOuzrWQ9JEKbq5ZUdihHWlEBtu0M3Qx5RGrYnNmiaAvWc88aP7gKIah6Gv4cRfGiqtjezyovc+KMpD5yAgSt1F+yUHKJyuDxbk54h5JSg2HvQsKbcq81/TCsBqb5TO3hoyVVUIS8rB/u+z16Bm4tDEdkI7duc0pUYBtvf55wNjY1C8ZZEaEfxsiIgDujbgpoZuhnJ09wxLb72ew6iCU4G+Gvb7ZIvwzIEnyvKyE0uFUw== 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 X-Received: from DB6PR0601CA0033.eurprd06.prod.outlook.com (2603:10a6:4:17::19) by PA4PR08MB6208.eurprd08.prod.outlook.com (2603:10a6:102:e5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.32; Tue, 25 Apr 2023 16:04:33 +0000 X-Received: from DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:17:cafe::83) by DB6PR0601CA0033.outlook.office365.com (2603:10a6:4:17::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04: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 DBAEUR03FT052.mail.protection.outlook.com (100.127.142.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:33 +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.23; Tue, 25 Apr 2023 16:04:32 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:31 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 02/30] ArmPkg: Add helper function to detect RME Date: Tue, 25 Apr 2023 17:04:00 +0100 Message-ID: <20230425160428.27980-3-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT052:EE_|PA4PR08MB6208:EE_|AM7EUR03FT058:EE_|GV2PR08MB10384:EE_ X-MS-Office365-Filtering-Correlation-Id: f2d7ddd5-5f8b-4b0e-b04b-08db45a70f95 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: JWRfR/WrWmdNhpop52W9EmrYByRMgErp89tsNGzxDRX+Mmz/MFBr4gDBqAc1ho8/TAaG6i0oag29OlSsKUSNfLHEC4aJngYR7xlQunN7fA2KZC87nJ8liLqahTnWJ6b5n/NIKzJvKBkx43a9fgjedB/3qV+WKu+58lBJBNl8INkQ9Bh6frY63FX5+4t5pLL4ku/nQyqIkdfRSQE2g5eZaZMSpFRK3jatW1DZ7qG4R2d2eJq5jJM0spcV9tD/1R3XSHSPti1AXhcRtoXKfscSzujUcDGaPGYPVSIVR8lxUFFkyOdKMN4f94iV//CUYl4n5a/HGusr9kJ4OdsJI24KlIqfYFbMhRiMogI1qVxARHS2AlwcvzdZ7T/NcZFZ8ttOERzLnTNCDOrPORypnnWr2YzykPMtMx9XInshQ9dW1l8TPwJnnsDXylO42G4RJz1HbOXtUjX33TWMZ6FtYikYXv7Lj0Cq+BerXTlPkUx+iQnmKd2AyOcM6z6xS7mfp73BdSGZRkPyRAvbNKGlINDKoCvJxbZTwhA5+MRHGFjW4gU6lGU8imqHDQ93xzAfY8tPxNcnHKg8c84w02gt/cupGAW7ygxnShOhy/dRah6PzbMxQNvKu/PC7rZPvdkcib4Z6w3d2BlUtjO7LQzozJAN78Sf6KjRvSPI5/nm7UPrFxcu+5jfSIfnsagzbZOcJIbCC3dAx40RmevLVLE/riHl7enJSft7QC0FQuvYEgwB3wk= 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:(13230028)(4636009)(136003)(396003)(39860400002)(346002)(376002)(451199021)(36840700001)(46966006)(2906002)(70206006)(70586007)(6916009)(4326008)(316002)(44832011)(5660300002)(8936002)(8676002)(41300700001)(82310400005)(36756003)(86362001)(40480700001)(356005)(186003)(26005)(1076003)(81166007)(19627235002)(478600001)(36860700001)(6666004)(7696005)(34070700002)(83380400001)(2616005)(47076005)(336012)(426003)(54906003)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6208 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 121cd97a-787e-4735-4877-08db45a6c28b X-Microsoft-Antispam-Message-Info: 1m/scB6F8AXy+qbzM0lCHDpdW8sVgbg7w5SdZ2zJWsjoAjX8qaSMA6rkKZjjBoFGkThpTgvX1LVYYoUdzVqSWu9I2Qi2RRC3OEaZ05o2LCXcQ0mwIzv8X3HG2mAbSDW7rpO60qO9qnQPA0qZdDazVS8MTBqWhJn40flvSoIR6WO48exZJj/kuce89lHywieXPNgz5M+0ybd8TLADyrPFhjaYRZV44KdnQ49prBHfUUxg6MIihCMa3Saw7CjieJMnZE8MqE4BCq3StZNSiW4C94iKRIploLilup1rGMDDuG3oOVmJiAim8jSyttzTP354q90wBN9CAVqhlGUrE2CtbYyF+eNb0+Y/1Rz4Kwtj3LjxSDxC39Y/m4vECA0zOkDUdoXAiDbLjjJKi+tVXzNyreC9Q2hUJcXrLDXLsdYeGoa3FJY2BkStP+clWQQ6QKr9wJtKZBzRdh06IBtGM04xWmeyJXakisrbOzvv7YPgjS+izjiCXlfC9kz8MfdyaEPuq9NNUDwRuNzFxDvrrmttu1UQdolR9YcZp0fNAwgPtehIao8ePcH9d4cP0g7z9ueHEXHX2HCS5/x6JpCn/wgLaz7cqbbUrhQ/bpoWqLGX8Hc2ljFh51IC7kszOg2rj3BQVznSm2Mi1gqeIkw4DgcJnoD2rDqDZl70jluw6ydROv8bABbadmr36nSK1pluv9l9BbMr5yZ1xoWf136Muxr91DSvV313FAHFWXvXd4h9E44= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:06:42.5755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2d7ddd5-5f8b-4b0e-b04b-08db45a70f95 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: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB10384 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: Rn81yPzDe64cj98BOE3SJLLPx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438809; bh=tctoAJq8V1kGIFq4z2wvXIEobWJQXvU7NISZZ7DeLY4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=AWzqrNiinEi5IJLr8v4nDqwJVyBo7/QcXJ8i4+UUIDMYMUMp0jw3+yqH/R9bNn1nqGG 35cSdCLnkhkSlZujAE5xGIPDrWzAepr/0+pL4vnMHhQ94tLs/e8efEZWwCzwUbTyD/TGb 1PgHyQwcW/D16IeqAIcShdFWkI/0SLRRU4s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438811436100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add helper function to check if the Realm Management Extension (RME) is implemented by the hardware. Signed-off-by: Sami Mujawar --- ArmPkg/Include/Chipset/AArch64.h | 3 ++- ArmPkg/Include/Library/ArmLib.h | 15 ++++++++++++++- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c | 16 +++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ArmPkg/Include/Chipset/AArch64.h b/ArmPkg/Include/Chipset/AArc= h64.h index bfd2859f51310993a42057a4c68604d492d8d7a8..47ef4d85656f1da32e3b924b18c= f21ee83be8206 100644 --- a/ArmPkg/Include/Chipset/AArch64.h +++ b/ArmPkg/Include/Chipset/AArch64.h @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
+ Copyright (c) 2011 - 2023, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -27,6 +27,7 @@ // ID_AA64PFR0 - AArch64 Processor Feature Register 0 definitions #define AARCH64_PFR0_FP (0xF << 16) #define AARCH64_PFR0_GIC (0xF << 24) +#define AARCH64_PFR0_RME (0xFULL << 52) =20 // SCR - Secure Configuration Register definitions #define SCR_NS (1 << 0) diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLi= b.h index fb1ae57b35221b2e96bc6c671398c526a6813fa7..27a6070feaa68ad03f256bcd7c2= be751fdaea6b0 100644 --- a/ArmPkg/Include/Library/ArmLib.h +++ b/ArmPkg/Include/Library/ArmLib.h @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2023, Arm Limited. All rights reserved.
Copyright (c) 2020 - 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -783,6 +783,19 @@ ArmHasSecurityExtensions ( VOID ); =20 +#else + +/** Checks if RME is implemented. + + @retval TRUE RME is implemented. + @retval FALSE RME is not implemented. +**/ +BOOLEAN +EFIAPI +ArmHasRme ( + VOID + ); + #endif // MDE_CPU_ARM =20 #endif // ARM_LIB_H_ diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c b/ArmPkg/Library/Ar= mLib/AArch64/AArch64Lib.c index 7ab28e3e05fe77333b8f315f3754164c4cd30a39..0f36b090effeb9f3eec21177105= 704a001102fc6 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Portions copyright (c) 2011 - 2023, Arm Limited. All rights reserved.
Copyright (c) 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -104,3 +104,17 @@ ArmHasCcidx ( Mmfr2 =3D ArmReadIdAA64Mmfr2 (); return (((Mmfr2 >> 20) & 0xF) =3D=3D 1) ? TRUE : FALSE; } + +/** Checks if RME is implemented. + + @retval TRUE RME is implemented. + @retval FALSE RME is not implemented. +**/ +BOOLEAN +EFIAPI +ArmHasRme ( + VOID + ) +{ + return ((ArmReadIdAA64Pfr0 () & AARCH64_PFR0_RME) !=3D 0); +} --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103578): https://edk2.groups.io/g/devel/message/103578 Mute This Topic: https://groups.io/mt/98496019/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103579+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438845418649.213763324384; Tue, 25 Apr 2023 09:07:25 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OHTGYY1788612xrHZJ2vnrlq; Tue, 25 Apr 2023 09:07:25 -0700 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.58]) by mx.groups.io with SMTP id smtpd.web10.84039.1682438844238277239 for ; Tue, 25 Apr 2023 09:07:24 -0700 X-Received: from DB9PR06CA0029.eurprd06.prod.outlook.com (2603:10a6:10:1db::34) by PAVPR08MB8797.eurprd08.prod.outlook.com (2603:10a6:102:32e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:07:20 +0000 X-Received: from DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1db:cafe::5f) by DB9PR06CA0029.outlook.office365.com (2603:10a6:10:1db::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:07:20 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103579+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT041.mail.protection.outlook.com (100.127.142.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:07:20 +0000 X-Received: ("Tessian outbound 3570909035da:v136"); Tue, 25 Apr 2023 16:07:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b45b49e43d2f4a26 X-CR-MTA-TID: 64aa7808 X-Received: from 508e8378810d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BBC5FBBB-5E70-45A0-A86A-B74B27D2F5B6.1; Tue, 25 Apr 2023 16:04:35 +0000 X-Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 508e8378810d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JMzvD5GUW0zEf+PZiObpkCw1hwkDVQH3WIXRgLdZBvCdxLXXwrPOmvR2ewICkH7ODc65XThyzg6oc/3YcONVhdXJNU1o2eMfMVoAXJrNXk7gxsmaX+XiOVyitJAj0S1v5A8qQ9PB1AWgIyG1mPXqCtwKG1QChECDoUEh7lXmodst2bPDt9iZBjrtbZQfBQvbS6959LHc0LzJ55DBNVYW/w9ifLB+CYTciY/wqhqfu5W2S8GJ/2OA4exYDBk7Av3ntURcvaY0gbhPgyMfqtYrQfVP39Vb7xJcq+iDtt7izaECaojnKl8Sg4eyeQZOHfGAYsz0+Y50g3G3XRyOBsf0Nw== 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=xMJBssLvPEw0pNBQIlUf4y3Z3aX/noymdxuuTd/c0R4=; b=ONjTCQxiLh5lQ+GX3dTTFCEZc7zw1xJFTHKW7ElG0Ra2x5O/m0tRvk14bXPKnIRDlgu2us/GGnlT0PldmpUeTXMZmrHQmhER7CCWF8QDUCL++7j/+yF0UE426ED1PdzzhsuQGfo/6AbxXVRDgB+AqkerlyA85k5elmTgJk72/G8rl8AF4W/lkZ12Cdxvd3KeD6P4vfB/1fPSv5qAzO9M5OuuSlrmhanjfbrKZnkn+9eJFBzVGVDjFvGPCF9Km+/bSFor6DwP3APZzgtfojK2F4N20t0nTIPBn8nZTCGIcTLt10CkfLSEqIo1sFbBbkusdkLO6BV55XQGyUSw6wgNXA== 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 X-Received: from DB6PR0601CA0042.eurprd06.prod.outlook.com (2603:10a6:4:17::28) by PAXPR08MB6480.eurprd08.prod.outlook.com (2603:10a6:102:155::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:33 +0000 X-Received: from DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:17:cafe::16) by DB6PR0601CA0042.outlook.office365.com (2603:10a6:4:17::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04: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 DBAEUR03FT052.mail.protection.outlook.com (100.127.142.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:33 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:33 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:32 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:32 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 03/30] ArmPkg: Export SetMemoryRegionAttribute in ArmMmuLib Date: Tue, 25 Apr 2023 17:04:01 +0100 Message-ID: <20230425160428.27980-4-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT052:EE_|PAXPR08MB6480:EE_|DBAEUR03FT041:EE_|PAVPR08MB8797:EE_ X-MS-Office365-Filtering-Correlation-Id: cfc2ab42-c9d3-40fc-c2fc-08db45a725ee 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: rUEXsd6VDVAonnL5QVXXj+R9JPSaLh+ePuFiGeQqARd+D4xr34/NmkuZnuPmRm3mKNkTowzLRW6sENET/WKQSy6CWcpxsqzc2SFvUXShCEI/gT5nMaaoTa6CVMnHCSH35TOPiFZyuPNxIB6JZelJpfnaP/R1XgCgpKHLLY3dVSAd+3jXJrZhPDqoqNJDKaqULdYtaYT7zVNXinSy6KZaSyUEMWnyYlI3u4cHsKyXoWQ1KuQen0VltDGzcQV1uVoeOnu82Xsrqiroav+08LItYI4BTluvRia7VzkkAjcGD8QujthPNJiJEiiVX6pf/HP473YiuWIfmDX4gwozJSmPYJ3yUCpd97q2WGT9CMm7mpQhupaaB9MRzZRtxsnSVPljJZ5Nmmlf14brdf9ODfrxSW7LDsO92QI4zp6INuNuhUhzv2IlNx5mq9iTCEx0/K9hyoS2S67BrEvJbkHtNcNZej3bpAi9QrL+dK9G8MukjG6bfopb96PtSGuOALSI+zc/jIHbqLg3ybOsTLPZLZ8TrUtRKR5wtB5K1PA91ZYtyhe/ytNdoMrlgBNbDEHnnm64cW8CUU/PmelsBUlOD+WMjdqGTchvSZr62Akkk0fw1cgjQQp8CMSrxfHJ9m3EQtyEcvVKKCkp1ykK55C6dlIMTiuhTX8gwjjIkf0dn+faKyzTEfW9HBm9H9DbIzxUn/h580rya+o9v1YmwxcskjOv5+Lem/jeUkuyqYrPyej5lm8= 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:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(36840700001)(46966006)(1076003)(26005)(40480700001)(426003)(336012)(2616005)(36756003)(34070700002)(83380400001)(36860700001)(47076005)(186003)(82740400003)(356005)(81166007)(70206006)(86362001)(70586007)(478600001)(6916009)(8676002)(8936002)(54906003)(44832011)(19627235002)(5660300002)(7696005)(41300700001)(2906002)(82310400005)(4326008)(6666004)(316002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6480 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1ce76983-2b44-4b1c-7fc9-08db45a6c2c4 X-Microsoft-Antispam-Message-Info: FrTPcRtCmXAgmZGtKEGNWtv94skIWWxF5R1jRAIc4G9ScgbHe9fBe9V+UkuxJKDwbdG6khapYeVuqqht+4roKFzHCVtPLkc0sMg4F3T5DYUMnw8ZwatzwZRLupiCVuQBy+s+Go01QMINGDmsSF3PrwxO4zdPsa2oC3mqJ8iRXx6X1bdJuQani/J9qMFptTv4wqZdW7EmhQ8GFEWv7CTB48yMEclDSNjFV3Nyyaqd+z1+E6r0rcN1dPkrYYZCCvPl+r+NXVFoXwEK8xqWhVeKzxGWCYugs7XxKBVcgRICEkytdcj1JqbLwJIM8xONTaUvRHtzK73nZsUmEQH5Xynjw26rA7o/yt8Lp4vX6JIVmx52FzoZ3XkFX2W70JPFzYnvdgFd6/LDVT9tsBhZrcSfInqxE5m7NkCLAvokgTPtX0oKHG9GP2dXA/aYfdnMRCzc239a9QrqvIJhrbHeaXlginF3U17zFafTleRFwFR+BO+WUeige5y0GCvwiGYkrWTvXVv9+uP5T6n1Yvo50pin9q7UroUtYvMzl3dG/wqNi6u7atqSVSW7HDi99dbwkA5fIGmu468uSbNLOrVRGBTepT22d7pNwvEPNgB8ODisDLu3pH7Y54EbBfwGYtLUzJAxb/5vh0L3mDlo0rdO2p5RaNlJsKTZwhsQTeW5iaOfiUHMZSlLlXdSwwCKptfShAd1kgzI8u8ZjsKWLnb6YmGtomaakLl2Fb6Qixi4C2MN1GA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:07:20.1160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfc2ab42-c9d3-40fc-c2fc-08db45a725ee 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: DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB8797 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: j5LvxlQhH9IkNQMghF5oCT3wx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438845; bh=irvGAiC2+E2Cuo5pXZJbYRb4Xrv6bEdQUJH7v7nWWbk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=MtjBl1oE88Clv+GM4FNzDeuI5YhVAlHj2H4EsegXoFifHg8i6zQqt/Yb3eEQbwkqD3X ixwKLiUlCVE/ToQDCmMpSNFQjKbzIVlJ+IwSLv7xb0BCemFCu57zX89XcKYGaW+QCgfyQ ynEaJ6WQiFOQyH9tm/AAqwXP8SzfpZjGES0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438846444100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Arm CCA requires the software in a Realm to treat the most significant bit of an IPA as a protection attribute. To enable/disable sharing of memory regions with the host, the protection attribute needs to be set/cleared accordingly. Instead of implementing the functionality to Set/Clear the protection attribute in ArmMmuLib, defer this to an Arm CCA specific library so that additional dependencies for ArmMmuLib can be avoided. Therefore, export the SetMemoryRegionAttribute () in ArmMmuLib so that the Realm software can configure the protection attribute. Signed-off-by: Sami Mujawar --- ArmPkg/Include/Library/ArmMmuLib.h | 22 ++++++++++++++++++++ ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 16 ++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ArmPkg/Include/Library/ArmMmuLib.h b/ArmPkg/Include/Library/Ar= mMmuLib.h index 4cf59a1e376b123c036f80b0f545245334f87dcd..97e44b49f45728693d2cf147c41= 6b96643596df0 100644 --- a/ArmPkg/Include/Library/ArmMmuLib.h +++ b/ArmPkg/Include/Library/ArmMmuLib.h @@ -1,6 +1,7 @@ /** @file =20 Copyright (c) 2015 - 2016, Linaro Ltd. All rights reserved.
+ Copyright (c) 2023, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -99,4 +100,25 @@ ArmSetMemoryAttributes ( IN UINT64 Attributes ); =20 +/** + Set the attributes for the memory region. + + @param[in] BaseAddress Start address of the memory region. + @param[in] Length Length memory region. + @param[in] Attributes Attributes to set for the memory region. + @param[in] BlockEntryMask Mask to be used for the block entry. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +SetMemoryRegionAttribute ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + IN UINT64 BlockEntryMask + ); + #endif // ARM_MMU_LIB_H_ diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index 7ed758fbbc699732a720149ffce6078d312f27c3..defe266a6c5afe6cbeaf89b11c7= 304665b98f011 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -1,7 +1,7 @@ /** @file * File managing the MMU for ARMv8 architecture * -* Copyright (c) 2011-2020, ARM Limited. All rights reserved. +* Copyright (c) 2011-2023, ARM Limited. All rights reserved. * Copyright (c) 2016, Linaro Limited. All rights reserved. * Copyright (c) 2017, Intel Corporation. All rights reserved.
* @@ -502,8 +502,20 @@ ArmSetMemoryAttributes ( ); } =20 -STATIC +/** + Set the attributes for the memory region. + + @param[in] BaseAddress Start address of the memory region. + @param[in] Length Length memory region. + @param[in] Attributes Attributes to set for the memory region. + @param[in] BlockEntryMask Mask to be used for the block entry. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ EFI_STATUS +EFIAPI SetMemoryRegionAttribute ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103579): https://edk2.groups.io/g/devel/message/103579 Mute This Topic: https://groups.io/mt/98496026/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103580+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168243884858171.31363680771005; Tue, 25 Apr 2023 09:07:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id AwoxYY1788612xwcFt4HXnAt; Tue, 25 Apr 2023 09:07:28 -0700 X-Received: from EUR02-VI1-obe.outbound.protection.outlook.com (EUR02-VI1-obe.outbound.protection.outlook.com [40.107.241.58]) by mx.groups.io with SMTP id smtpd.web10.84041.1682438847138840752 for ; Tue, 25 Apr 2023 09:07:27 -0700 X-Received: from DU2PR04CA0283.eurprd04.prod.outlook.com (2603:10a6:10:28c::18) by AS2PR08MB9414.eurprd08.prod.outlook.com (2603:10a6:20b:596::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:07:23 +0000 X-Received: from DBAEUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28c:cafe::d2) by DU2PR04CA0283.outlook.office365.com (2603:10a6:10:28c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:07:23 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103580+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT023.mail.protection.outlook.com (100.127.142.253) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:07:23 +0000 X-Received: ("Tessian outbound 5bb4c51d5a1f:v136"); Tue, 25 Apr 2023 16:07:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8a5f767d4ef2e1c1 X-CR-MTA-TID: 64aa7808 X-Received: from b6bf8159bdcf.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 309F7BA3-513D-40F2-BA79-59B7016A22C1.1; Tue, 25 Apr 2023 16:04:36 +0000 X-Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b6bf8159bdcf.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HKsz7RcCEFX2ixqB8NKQY9+GEHfqs1wxPhIr5ZeXmWGHwHW/GmFefW/1HCuWI4LT/VaaztTWUyTNwZhhGyTDQjgGZHh9jaaUArubnX++fitirww3ujYeZnQAQ5vIxmBQggxo0IY49QxT4zgvv54jqNcwi5IXrfaaHSouymye+Qu+7sPx6N+Vs8DBce1RAS3zUs8gSNlj8qBj5B0fkjYTRpE96bLj+UMwrwemkW04nkAiUuCpFdGKEcf8PDP19A70fHbXn1GB14pnxM7M9NtLCNV2Bzqgnen8NrYT6Ac7x07jWmW8X4peoCkoQgKSSivSjFoG9ZRkoaVOmeoAnJfnVg== 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=NXrFj/Yv3fEkP1bQA0j8la1bTIvRD8SMCpvxza7gv3w=; b=K57A59JgVZr+6w2e4zeOkckFPi72qwbh4MNjltfYn085Tj1dxWZfwhBmuby+Hlw6g+OFf+0C8BNDonXiQWMz69yKC8U3pyEI1HpCLPBtR2jJWBPAz6HCnLGYX3nN0vownWg4GfxZ+pGsvuy/yQRgaQDZKJWFuxisFHvK9yH+ZiE9AOQxHombV0ErwHQ7VC9NuGkRiWfPBJN/WhfnHimH6n4DwuTg/w2wR4qSPSoGnUX5ciMZhd4CLGdd/Li8x++lFIaSKmsGUj97QjVgsRW/pdit3tmpMnMTrxMJGbzxPvo0KFBtnP/68TYf3/aHF27ydA8EMRedkmKd4aJAtr01aw== 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 X-Received: from DU2PR04CA0240.eurprd04.prod.outlook.com (2603:10a6:10:2b1::35) by AS8PR08MB9672.eurprd08.prod.outlook.com (2603:10a6:20b:614::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:34 +0000 X-Received: from DBAEUR03FT003.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b1:cafe::3d) by DU2PR04CA0240.outlook.office365.com (2603:10a6:10:2b1::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:34 +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 DBAEUR03FT003.mail.protection.outlook.com (100.127.142.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:34 +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.23; Tue, 25 Apr 2023 16:04:33 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:33 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 04/30] ArmPkg: Extend number of parameter registers in SMC call Date: Tue, 25 Apr 2023 17:04:02 +0100 Message-ID: <20230425160428.27980-5-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT003:EE_|AS8PR08MB9672:EE_|DBAEUR03FT023:EE_|AS2PR08MB9414:EE_ X-MS-Office365-Filtering-Correlation-Id: 7744e3d2-bb1b-4e9d-50e0-08db45a727f2 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: CY/HKWqu/cKrzrbiNUjNtDXAbRZedKhzsFDk14AMiIjs4S1yQ6M5XKpVet0kIUsoHgp0I+a32z5K5Eq7Ecu8zkfg2cXbyqu0an1BW+X2cjBWafs+VDQPYEbhxe6l5CzzzqYxj6x6CN/GiRHzVHowDt4yx1gGhpDsPCSSGGEJuvtTKRbfzx6dxEiB4+JJm68F9DW1S4J7c/bpcXOoeYZjQBbKToveiSABbIBpXqaYPXuzMko3bClaXoKK+guyz319l62LrwqJ6nmq/B/IReH7FbdkTTQdgtBVrm2c+nZkYMq956Kvo+CWOUOGzvWqRX2SaM8rU7G8xzOYqNAn5djkKWr/SO0k7qWwDtJORny37ZNLS7Z2tjPhTNw0gWsvYouQtpoPUkNkd8F8hft7vTpjLUABR42gzkNfZNQzENN1oD+wye8GxbDlq9K94EHl9dhM87aC8DKuWUhr26qXBEE3HVzorSOFentidNO0bhARiqOjncFSgW12hSgdCji7a2CUZ25IhzaQZlat8rJJYIKDv7oPeUAldJLscKrC+QAsF4wV32Dd+LjdksE1zQNnwRLpqjEFGWfpqBy+PGvM4j/ymL+wKNrtNW7nLqDb9Wu6jZatv9DYdwxfCVE3DK6Z1UFpGhz3jz7Vk5o1yrKhw3rVaoNsAZPHRq+cDOCd20LldUfQtRGj5AB+81075Ckb22LICBdK6/XQkhecPWhVMCshR36DS9G9EkVrNkqJdogETjw= 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:(13230028)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199021)(36840700001)(46966006)(36756003)(54906003)(19627235002)(34070700002)(478600001)(82740400003)(4326008)(70206006)(70586007)(40480700001)(316002)(6916009)(356005)(44832011)(81166007)(41300700001)(2906002)(8936002)(8676002)(5660300002)(2616005)(426003)(336012)(1076003)(26005)(86362001)(186003)(6666004)(83380400001)(47076005)(7696005)(82310400005)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9672 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c72e061a-c894-4982-3970-08db45a6c35e X-Microsoft-Antispam-Message-Info: dVyvPf9lHv8U18Ddb2mvIx+cfyEb4phAmnChAqrBoA4Omrfnpr5Sm9KYMbppHtz1TPZNsUdp5eFdtPmKVKeB9cGMm6aDyWcTgd9x70HZiWTX9UG5iJ786IlAJRV1UKSPqa07yHeZYIr7oi4t0Z4sr823fv+yKInss771L6f4UsAd4lpbRQCpipVcuEpIz/w6RaeJEwQ9pvMLVcpysIK9Duj0XlX6xxJv1GpCWrKs1KoSTU1bKlfMcrLp3xTiNrT2ccwi2uDA7hhHRGGtyr0cRNmrZKvYtbmRGF1oRwaHvTfkUJ9FL4uvIFfVzya2H/SP2r17yddpdPdqYyY5+ldcfcdWz1Zkw4FGRm+bShE8FtwSS5MHRL5ZkwOsNbb5yq8bUlewIaDxEHXbQyD4kauT+b0wSUihLD6sxuzQzpk/nQVbZAKVWPHyGg4Q9AX/FI4LMsqTv/OHcQ7YjCLsM7zLYAuGEqEoN/yug7VfMG1qf+CE+YLapX7rLICaXNGp1AvkMalpDGx+zDR05plIZhPo9CDvYZeNQ2zlY0A5vzpkue0Um+e7SC3KIglJ7XPGBWaPVMmMRPiNMrsxlJsvCaBVbRW9KO11e0G+MiXMRpgQd8nEgAGrSffx6W7oY3dsKl3nhbU9CiIQBIYqDJmmx+dyhes5cTQV6oqasphZQVpvb6L85K5j7dRPw96Co+o6b/UED4rflbeqykjwU5dvGicCChF6fhGzTROQy+/Sokys3YA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:07:23.5103 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7744e3d2-bb1b-4e9d-50e0-08db45a727f2 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: DBAEUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9414 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: rqpOUXkE6e1sfooS4PZxPvprx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438848; bh=gPXr+BTe845Voh+lC0ReKNddgXu2pHpEEhHpBQFtPSE=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=jrt0R3IVFohqF0Xc5IrkCelo1oqYK4wSqY+HRFkCq5MgPOeWO3dvGmLenOARgeZdDBN wXLtlHVpC6DuyZm6K5iycie4H7KPzfNTvA+iQQvL9hkpOBcDdcQN58zDIcAFl0cLRbH0B 1zGD3GQ6w1t98MFRu4IUAyZxe518S8v0VcY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438850470100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Realm Service Interface (RSI) commands use registers between X1-X10 as parameters and between X0-X8 as return values for SMC calls. According to the SMCCC Section 2.6 SMC32/HVC32 argument passing When an SMC32/HVC32 call is made from AArch32: - Arguments are passed in registers R1-R7. - Results are returned in R0-R7. When an SMC32/HVC32 call is made from AArch64: - Arguments are passed in registers W1-W7. - Results are returned in W0-W7. According to SMCCC Section 2.7 SMC64/HVC64 argument passing When an SMC64/HVC64 call is made from AArch64: - Arguments are passed in registers X1-X17. - Results are returned in X0-X17. This means SMC calls can take up to 7/17 arguments and return up to 7/17 return values. However, for the current use-case(s): - SMC32/HVC32 calls made from AArch32/AArch64 require up to 7 arguments and 4 return values. - SMC64/HVC64 calls made from AArch64 require up to 10 arguments and 9 return values. Therefore, for SMC32/HVC32 calls made from AArch32/AArch64 there is no update required. However, for AMC64/HVC64 calls made from AArch64, extend the ArmCallSmc () to use registers X1-X11 as parameters and return values for SMC call. Signed-off-by: Sami Mujawar --- ArmPkg/Include/Library/ArmSmcLib.h | 50 ++++++++++++++++++-- ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S | 22 ++++++--- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/Ar= mSmcLib.h index beef0175c35ce86aac9e465f9062bf8052b08dfb..e80b74671a6424723323bab9591= 7fb3909771759 100644 --- a/ArmPkg/Include/Library/ArmSmcLib.h +++ b/ArmPkg/Include/Library/ArmSmcLib.h @@ -1,10 +1,13 @@ /** @file * * Copyright (c) 2021, NUVIA Inc. All rights reserved.
-* Copyright (c) 2012-2014, ARM Limited. All rights reserved. +* Copyright (c) 2012-2023, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * +* @par Reference(s): +* - SMC Calling Convention (SMCCC), ARM DEN 0028E, EAC0, 1.4 +* (https://developer.arm.com/documentation/den0028/e/) **/ =20 #ifndef ARM_SMC_LIB_H_ @@ -13,6 +16,18 @@ /** * The size of the SMC arguments are different between AArch64 and AArch32. * The native size is used for the arguments. + * According to the SMCCC Section 2.6 SMC32/HVC32 argument passing + * When an SMC32/HVC32 call is made from AArch32: + * - Arguments are passed in registers R1-R7. + * - Results are returned in R0-R7. + * When an SMC32/HVC32 call is made from AArch64: + * - Arguments are passed in registers W1-W7. + * - Results are returned in W0-W7. + * + * According to SMCCC Section 2.7 SMC64/HVC64 argument passing + * When an SMC64/HVC64 call is made from AArch64: + * - Arguments are passed in registers X1-X17. + * - Results are returned in X0-X17. */ typedef struct { UINTN Arg0; @@ -23,13 +38,42 @@ typedef struct { UINTN Arg5; UINTN Arg6; UINTN Arg7; + #ifdef MDE_CPU_AARCH64 + UINTN Arg8; + UINTN Arg9; + UINTN Arg10; + UINTN Arg11; + #endif } ARM_SMC_ARGS; =20 /** Trigger an SMC call =20 - SMC calls can take up to 7 arguments and return up to 4 return values. - Therefore, the 4 first fields in the ARM_SMC_ARGS structure are used + According to the SMCCC Section 2.6 SMC32/HVC32 argument passing + When an SMC32/HVC32 call is made from AArch32: + - Arguments are passed in registers R1-R7. + - Results are returned in R0-R7. + When an SMC32/HVC32 call is made from AArch64: + - Arguments are passed in registers W1-W7. + - Results are returned in W0-W7. + + According to SMCCC Section 2.7 SMC64/HVC64 argument passing + When an SMC64/HVC64 call is made from AArch64: + - Arguments are passed in registers X1-X17. + - Results are returned in X0-X17. + + This means SMC calls can take up to 7/17 arguments and return up + to 7/17 return values. + + However, the current use-case: + - For SMC32/HVC32 calls made from AArch32/AArch64 up to 7 arguments + and 4 return values are required. Therefore, limit the maximum + arguments to 7 and return values to 4. + - For AMC64/HVC64 calls made from AArch64 up to 11 arguments and + return values are required. Therefore, limit the maximum arguments + and return values to 11. + + The fields in the ARM_SMC_ARGS structure are used for both input and output values. =20 **/ diff --git a/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S b/ArmPkg/Library/Arm= SmcLib/AArch64/ArmSmc.S index 4a8c2a8f59eab3e5b66dda2515d5bbced131af13..299d612dc5e1ebfeaf69a356b40= 0c511905d72fe 100644 --- a/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S +++ b/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S @@ -1,8 +1,11 @@ // -// Copyright (c) 2012-2014, ARM Limited. All rights reserved. +// Copyright (c) 2012-2023, Arm Limited. All rights reserved. // // SPDX-License-Identifier: BSD-2-Clause-Patent // +// @par Reference(s): +// - SMC Calling Convention (SMCCC), ARM DEN 0028E, EAC0, 1.4 +// (https://developer.arm.com/documentation/den0028/e/) // =20 #include @@ -12,6 +15,8 @@ ASM_FUNC(ArmCallSmc) str x0, [sp, #-16]! =20 // Load the SMC arguments values into the appropriate registers + ldp x10, x11, [x0, #80] + ldp x8, x9, [x0, #64] ldp x6, x7, [x0, #48] ldp x4, x5, [x0, #32] ldp x2, x3, [x0, #16] @@ -19,14 +24,17 @@ ASM_FUNC(ArmCallSmc) =20 smc #0 =20 - // Pop the ARM_SMC_ARGS structure address from the stack into x9 - ldr x9, [sp], #16 + // Pop the ARM_SMC_ARGS structure address from the stack into x13 + ldr x13, [sp], #16 =20 // Store the SMC returned values into the ARM_SMC_ARGS structure. - // A SMC call can return up to 4 values - we do not need to store back x= 4-x7. - stp x2, x3, [x9, #16] - stp x0, x1, [x9, #0] + stp x10, x11, [x13, #80] + stp x8, x9, [x13, #64] + stp x6, x7, [x13, #48] + stp x4, x5, [x13, #32] + stp x2, x3, [x13, #16] + stp x0, x1, [x13, #0] =20 - mov x0, x9 + mov x0, x13 =20 ret --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103580): https://edk2.groups.io/g/devel/message/103580 Mute This Topic: https://groups.io/mt/98496033/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103552+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168243869247563.987642008544185; Tue, 25 Apr 2023 09:04:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7DnhYY1788612xFjBgMEA5AT; Tue, 25 Apr 2023 09:04:51 -0700 X-Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.55]) by mx.groups.io with SMTP id smtpd.web10.83958.1682438689577562037 for ; Tue, 25 Apr 2023 09:04:50 -0700 X-Received: from DB6PR0801CA0047.eurprd08.prod.outlook.com (2603:10a6:4:2b::15) by DU0PR08MB9369.eurprd08.prod.outlook.com (2603:10a6:10:41d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: from DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:2b:cafe::4e) by DB6PR0801CA0047.outlook.office365.com (2603:10a6:4:2b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103552+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT044.mail.protection.outlook.com (100.127.142.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: ("Tessian outbound 3a01b65b5aad:v136"); Tue, 25 Apr 2023 16:04:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a698bcb3c33f5846 X-CR-MTA-TID: 64aa7808 X-Received: from 0c64014b5260.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F505CDA4-E2DB-462C-8527-F1F05DFCB0F4.1; Tue, 25 Apr 2023 16:04:38 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0c64014b5260.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GNwpK1iwVScxEbZuUxspS711AQQ1C6O30S+Zx78jKLIPd8ZwOUgN57bV6mzS1fRGKHpFH4YlQQlzhqyvirwtL5OcVFd11QeJxTrMhW4TZzHrm4MAoVqZO9s6p314PA7Ig8E6/d2owiBBFjfSQlR+2zXlfyrjnDteZe98NMY3osOv87hx83+w2u7zB9pPdQWRIq+JNc/TLtOlRIMAjMafK5jYHOhK7H4aCmnDpiqIjOhzRzm2Tlp+pfYQ+ImHMet1fF4ZmMl+Ynvx62nAAvdV4VGRxFWuuLR/Umj1eYNz/TRuF3nWXWohyZYYepLhVViw4c+zXPv05E4A8GuGxmN4Aw== 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=zYs+t6xNGTfl4IN1bhlZkSAtCbYaPyx8uPvN62D4sSY=; b=RWWJNg/T4GxwFPBSRjUftA0Ij9v353bB669pofdRT6PSdxk/+x0N6RHkRsuRcLrcgv5lvUkhbXXNbCQVJhDvXp5sLzGxp4VayRdOQs5qYYTyy2DvkMAlhLeoEm8wTgnQb9RPDqZbK0/ldNE4CWr4A4kHr3tZJ/FbMtx/uA101uGThN2Q9lJiFX2c8eDUrk4+TrYd0jBOhWtChyDKki0UjhNJxjjFtE/EG1dSJuY8a4wnMCT30IlSKLHhBvYCd1ObPGXyfC+DFejgG44z6yD64hiIRmOZbqIsdXafMJaHVI8bN/2YBSCScV/4I5UUwECnOdj41R7Nynlf8MP5s+Hm9Q== 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 X-Received: from DU2P251CA0012.EURP251.PROD.OUTLOOK.COM (2603:10a6:10:230::8) by PAWPR08MB8934.eurprd08.prod.outlook.com (2603:10a6:102:33e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:35 +0000 X-Received: from DBAEUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:230:cafe::3) by DU2P251CA0012.outlook.office365.com (2603:10a6:10:230::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:35 +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 DBAEUR03FT019.mail.protection.outlook.com (100.127.142.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:35 +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.23; Tue, 25 Apr 2023 16:04:34 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:34 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 05/30] ArmPkg & ArmVirtPkg: Make PcdMonitorConduitHvc a dynamic PCD Date: Tue, 25 Apr 2023 17:04:03 +0100 Message-ID: <20230425160428.27980-6-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT019:EE_|PAWPR08MB8934:EE_|DBAEUR03FT044:EE_|DU0PR08MB9369:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fcedaa8-ce4d-49b5-c418-08db45a6c9a3 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: JyaPa8WJxmeycIil7fPQZ2BBXS4kCrMiWu9iJaHg0r2HRC2GcZEdxWz+g2eSNPOGUkghOkVCNeUy0O/EcULI2EHn3UYO20ERqti1a+usZzFLsw85HsBgZ8Kz7OW6C8dTKGRUg2Vx3awR0+DRasHybPp9HjpDcjNFbvqY2P5fvZRC3IRpSPT9Lr6KSbibbHCdgZsMxonT3RiXTdtuiP001X83PsLPe+hNA7LdzziSayHCymi1XvD3g8/7euPJZtL/xvHYrDSxXfqKfAX3SmY3HhTqfP3RoRxVB4ngyzDQIA1Kfn3foekyXO5KgSaizSVqlOpJEMQvoFs401AhicTlhOmsDlG6UN//zAy1PhuklEJxc2kjvY1PAVsm1OL0IdcL65oGXuZaBGuHrUK5617Y5XxlqUuXQZwjAFO+YZx+Mh5HQUxUgFAnEW/yq8yo5EaiyzNOfAv4QietOgMXfGzcwKfCV750Axl+T9c1YeofZYxE8SH2ltHAOHEZef9AZieGDJe45D6vlXkK0vMMBhPkWcfBKfLAfJ9k+W+MPsR12J5vD/Z8QhkqJLUF78koYgjoUbxYCrX65F0osCMxuwRYbjjBu0YpAU45qb648JHfRfe/uVx8pdADIgJQz0/suL4fH+qqDNXfz0eATSl4uIwc1M0tLkLab+//HwzDVJTSoayEu5NaTVgdMT4KJaE0G1J7MwxmX4EH5y47TMlY+4jDLyNN6ZIryz9+fL0Zucn5d+I= 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:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(36840700001)(46966006)(316002)(82740400003)(44832011)(6916009)(4326008)(81166007)(41300700001)(5660300002)(356005)(8936002)(8676002)(82310400005)(36756003)(86362001)(2906002)(40480700001)(7696005)(6666004)(1076003)(26005)(478600001)(34070700002)(2616005)(36860700001)(83380400001)(47076005)(336012)(426003)(186003)(54906003)(70206006)(70586007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB8934 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 285e5e05-96a9-43ac-c730-08db45a6c3d8 X-Microsoft-Antispam-Message-Info: BrtsfN/aj44AlnAnJbZblkbpELSdBQoLFTX23ZoyUN3Oh4kY/ivf3Ej3XDaV4n5sZTceMnkobdYacG0mlTIQe/wWem4JIU0CdkQQCH3sqjgYV9nIQg9jG2DQLMuCZicdRX++/G39i7poQj9o+HqwO1D4Tu2QVpvcg/nZ8NIb3qqVfrOCCJ8XqDnjwgs+LEp94tp6RJ9rrexZvFmye90o516bBkUruFiELiYHMb5pYtMXoPPPXH07GkKB4pnFz3WcBcOug8OpVeClalAEke0Xd/CMktVTCKG3bsmc+ZjW1RNdlh+XSdPCI3o5lGI9zkRxpPLgXKV0etbdW6K+8qKxMW5Dcu23/G1DZ/dofgVBRGSP6dFivKUHtoFM8inJbVkUSb6EgFqb3ii18S5JrV1v9tbpLipqPYuldzmy4DWTg5PI0xgpDZ4P6ZyVcKUNfPRgXshLjEAu2ZgtZck3T3NsNcRdAE4OkbSDYRA1c0wC/0mhv3HuHq/GrlmfRW4p8xHyHzyBtg5aO9Awgszp2ZkhykaNRT5uqEiiGHObNlwceCBeE+us7katu9cujCJ8g0sxu5M7iOPbxXePNmow9nF2F7/3xfK5cq3i2h40l1klIIVG3sS0LTYOdeimCFCUGvmI0nySryze24e6zaPJ8i5JCIiuFTZenh5ZTKzv4QmFRkBO5n3s1zqjYYmP1sDY6wG1OP2v8+M5alYYQ0FVYZSg/KE29vrKt6Y0G4Ri0MDNOWI= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:45.2585 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fcedaa8-ce4d-49b5-c418-08db45a6c9a3 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: DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9369 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: ZqDORq0odraB51yYvBFCbb1Qx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438691; bh=MBTco5t7C228FeYnA2a68mcKkrMK9ILKqKIoX2eEadk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=LKIxloSvRnmGuD1BJ4Xz6A5WAnXL9PTsOCn7IA1Qc1msCDW313JG60H9dwSVOCY7W3w u5FJ8hYQIOXkJm6DKkRfPXghUG97RRGB+q33WYRVAgOZ/UHag7lUiwxRrQ/diJ3+ilgPV SXs6255sBjNwbnY/iBTxz2odrkAvKXvAE44= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438693472100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The monitor call conduit is fixed for a platform firmware in most scenarios. For a normal virtual machine guest firmware, the default conduit is HVC. However, for Arm CCA the Realm code must use SMC as the conduit. To have a common code base for Guest/Virtual firmware to be used by both normal VMs and Realm VMs, make PcdMonitorConduitHvc as a dynamic PCD. This allows the firmware to detect if it is running in a Realm and it can configure the PcdMonitorConduitHvc as FALSE (i.e. to use SMC as the conduit when running in a Realm). Also update the ArmVirtPkg/ArmVirtKvmTool.dsc workspace to move the PcdMonitorConduitHvc in the PcdsDynamic section to prevent the build from breaking. Signed-off-by: Sami Mujawar --- ArmPkg/ArmPkg.dec | 10 +++++----- ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c | 4 ++-- ArmVirtPkg/ArmVirtKvmTool.dsc | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index f17ba913e6de1326d49b93d6a15378ff2f522d24..0730533e512d60fcba19c4cfa84= 944061d16f02e 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -139,11 +139,6 @@ [PcdsFeatureFlag.common] # Define if the GICv3 controller should use the GICv2 legacy gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042 =20 - ## Define the conduit to use for monitor calls. - # Default PcdMonitorConduitHvc =3D FALSE, conduit =3D SMC - # If PcdMonitorConduitHvc =3D TRUE, conduit =3D HVC - gArmTokenSpaceGuid.PcdMonitorConduitHvc|FALSE|BOOLEAN|0x00000047 - [PcdsFeatureFlag.ARM] # Whether to map normal memory as non-shareable. FALSE is the safe choic= e, but # TRUE may be appropriate to fix performance problems if you don't care = about @@ -393,6 +388,11 @@ [PcdsFixedAtBuild.common, PcdsDynamic.common] gArmTokenSpaceGuid.PcdPciBusMin|0x0|UINT32|0x00000059 gArmTokenSpaceGuid.PcdPciBusMax|0x0|UINT32|0x0000005A =20 + ## Define the conduit to use for monitor calls. + # Default PcdMonitorConduitHvc =3D FALSE, conduit =3D SMC + # If PcdMonitorConduitHvc =3D TRUE, conduit =3D HVC + gArmTokenSpaceGuid.PcdMonitorConduitHvc|FALSE|BOOLEAN|0x00000047 + [PcdsDynamicEx] # # This dynamic PCD hold the GUID of a firmware FFS which contains diff --git a/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c b/ArmPkg/Library/= ArmMonitorLib/ArmMonitorLib.c index 741f5c615744dc5cc5381ff3848078f93858dd2b..221724125ce3a8f351a55a81f44= 1409a99bcb5cf 100644 --- a/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c +++ b/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c @@ -1,7 +1,7 @@ /** @file Arm Monitor Library. =20 - Copyright (c) 2022, Arm Limited. All rights reserved.
+ Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -26,7 +26,7 @@ ArmMonitorCall ( IN OUT ARM_MONITOR_ARGS *Args ) { - if (FeaturePcdGet (PcdMonitorConduitHvc)) { + if (PcdGetBool (PcdMonitorConduitHvc)) { ArmCallHvc ((ARM_HVC_ARGS *)Args); } else { ArmCallSmc ((ARM_SMC_ARGS *)Args); diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index d2228a95726b24fe5c2edfbc84b1f5c23a85feba..467e5c166e1bbad3acbae78f53c= 225f5bac525a9 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -117,8 +117,6 @@ [PcdsFeatureFlag.common] # Use MMIO for accessing RTC controller registers. gPcAtChipsetPkgTokenSpaceGuid.PcdRtcUseMmio|TRUE =20 - gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE - [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000000F =20 @@ -237,6 +235,8 @@ [PcdsDynamicDefault.common] gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister64|0x0 gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister64|0x0 =20 + gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE + ##########################################################################= ###### # # Components Section - list of all EDK II Modules needed by this Platform --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103552): https://edk2.groups.io/g/devel/message/103552 Mute This Topic: https://groups.io/mt/98495955/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103553+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438693473458.61896051963254; Tue, 25 Apr 2023 09:04:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vrUCYY1788612xA7kr86zU1P; Tue, 25 Apr 2023 09:04:53 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.71]) by mx.groups.io with SMTP id smtpd.web11.83445.1682438690987342709 for ; Tue, 25 Apr 2023 09:04:51 -0700 X-Received: from AS9PR06CA0142.eurprd06.prod.outlook.com (2603:10a6:20b:467::35) by AS1PR08MB7612.eurprd08.prod.outlook.com (2603:10a6:20b:477::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: from AM7EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:467:cafe::b8) by AS9PR06CA0142.outlook.office365.com (2603:10a6:20b:467::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103553+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT050.mail.protection.outlook.com (100.127.141.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Tue, 25 Apr 2023 16:04:46 +0000 X-Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 25 Apr 2023 16:04:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 65822af2f738dae3 X-CR-MTA-TID: 64aa7808 X-Received: from db44ddda7f40.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1CCF64AE-8030-48EC-9703-34168ED6B4E8.1; Tue, 25 Apr 2023 16:04:39 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id db44ddda7f40.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4wdy68Ir3+Wfd/KEvmpLvoATGwNbZ7+YdEkFqcrAE7+IHJylhuQNQ1u0Lw/LC5w0Te/H5hnxZMug8NsokjTy3++px4vTeeuHoaLXmkLrMQm5yGWuhvOG7oSjPHwsPicZKj9rC6tU/8FA/JYNVtQ+Ng0X2SXFMh3BqXHS0KMRVLlHyxBJTPSd24FH8HxHCXJ8BMpaEk8cDK1SM+nMK3lze71Z5F5QSTx9YYO+3FUFfnQ7UsO4BxvPYj7NCsquxwyqZDdYc9Pu/rKc2GTNuZ4W8MQsKhdTjM/YNpYxp/VY0qFCimVIcA/h3/x8nKCd/vWicq0ctJ2vwTuoUTn1mM3pQ== 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=JpiKmZanIgN70LV/20XCSdKvWVFmSmmo1DWTDgU+6Rs=; b=LovDbjd5wZQuRjil5icxSgCGO5gmBtS2b4hgXAfpW1zvHdYB1UKcCPv8za4d45qyBoji0Z31N/GPWdn9jQ24HxwvPUvLxMjwYbJgIcEV1dQqUSZJz6vLpcERA25mQh+gkdGBek1uC1VThwrmlf06SLAYcj/jbsrntEZW3gQFD2Eea/eKup58925Jpy6fswrC2ZrlGjq/E8yExx5OkSvWPRycfBfkVz60VLRVzUIaCOn1hqOku5SijxhujrQSrGmeFTLriDWFCdU4uelkHmkKTvZENo8SHaeOBM+pRgjijyE3g4wsQ/yMeIUQjeB1D1+IMZpZkQXGPPKPJESVbiPF+A== 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 X-Received: from DB3PR08CA0030.eurprd08.prod.outlook.com (2603:10a6:8::43) by DBAPR08MB5606.eurprd08.prod.outlook.com (2603:10a6:10:1a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:37 +0000 X-Received: from DBAEUR03FT017.eop-EUR03.prod.protection.outlook.com (2603:10a6:8:0:cafe::9d) by DB3PR08CA0030.outlook.office365.com (2603:10a6:8::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:37 +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 DBAEUR03FT017.mail.protection.outlook.com (100.127.142.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:37 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:36 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:35 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:35 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 06/30] ArmVirtPkg: Add Arm CCA Realm Service Interface Library Date: Tue, 25 Apr 2023 17:04:04 +0100 Message-ID: <20230425160428.27980-7-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT017:EE_|DBAPR08MB5606:EE_|AM7EUR03FT050:EE_|AS1PR08MB7612:EE_ X-MS-Office365-Filtering-Correlation-Id: f1416ec7-711d-4c48-7682-08db45a6ca9b 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: YyWmgLY3yvBS53RZ9Jh5WThF1Uheg3pNOjhkntTemCv82hI5o74t+gyzHw6yWcGks5HkY55A++bgc4FIlRi1YGEEcJfkzWBeYD9JAhVQa4mxckvcw5bX5SOo010z2UsTKkw9iRB0Hq7ft4rWjJH7ND97y9wdOW5hAAsWw58hc+HCJsfUFLdXAXqu+v4F5uzOSo6YLFPq1FpC9V3BGPrFWN0HLLVrZSRsjyCvkv/LEKCIX1v52tRXSdqWwhytbvYveupzQDZCrzYIcNtLrm2yGP69LfkbRP1ykYOMyo0TMVkiU24I5d3PF0KdKN7/yepnZrvlYb2QTroe37XKIedQNPjtc5stfOpNOLmx1/CpzM5LR3lyBkqCGttri0Xq/ZvxNiKKAC0GeK/Y+xPvQtOS1RNadf8EL6Zisl3IXLe1/TOd+nfTRV6U5NENSSdt5kXpwEV8wtAfnMuPV38e0QudTxbkL46Rqc6F6xkrKmSok8WRR9rFYa0t+KATSJeixeL6Z/3V1V9LxPcV/i4rTPYZHJYUz9bYpgjhidZS7D2iHU1hXpTsugeVBuQzthe3b0EgJdKnEKN7DYTBW4voLN+Qti9jSpZqJsDRaOBuP2zviTD4cW6KutsjJJmNjRjF8CtD+ns8hhpyzAjUgy1bH6LtBVQaXKtVRaHbD/kaJy/mboHO0WRfAaVbBc9WmZS8+ilzsv6OzdcsxHFmRw6tbDCd9I3NC6nkC1//ddKiHMJczlM= 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:(13230028)(4636009)(39850400004)(136003)(396003)(376002)(346002)(451199021)(46966006)(36840700001)(36756003)(54906003)(34070700002)(82310400005)(86362001)(478600001)(41300700001)(81166007)(8936002)(8676002)(44832011)(2906002)(6916009)(40480700001)(4326008)(316002)(356005)(82740400003)(70586007)(70206006)(5660300002)(186003)(1076003)(26005)(336012)(426003)(83380400001)(47076005)(2616005)(36860700001)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5606 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: fea7935d-3c56-4c29-a5ee-08db45a6c4fa X-Microsoft-Antispam-Message-Info: nBcpH5ZtGF9WHbGne4xyINm/tr3x/2TBlewdGP7Kmp//WCTRFAZ8pz9O0UJohcL4x6rP3anMaYbu0EHthqlpi3Ik9Qd1Ygii7MdGMSpsvG7Ny8qGyun91LIDAryEz42diPY4wHpS8dPFoZdgZJQraCch1FMejOmV2D/GZ7w4chShjzfNTUVL1SMFiESW+YEE8X2nTMV3j2ohU8zIVbumLbICX0QeXthz4cKfyY6GVcFJPsCN60i4I6se0cKUtJjx65zDEddv9U7tdLR52wZ/mBQOqLiUASxJukB52qNRERTfWGpbh14BqwjAm8xM4WyyYL/v+Vauit9hHrGq9hFXFC6A7FAmLeko6vcFURAA7ZPmEC0+3E6txOvAzPZWWouoykSgzYYuPx7g6Z3zFNCtE6nN1fxqH5sxhoVei+fGHb4lV8jy2n7W5+VQDU+UKf1zeCJrjJsU3QHKfPSDRj2NAf+VH3/oG4Ka39jZg/tveEXZwd2SS2glFLjAP0cRYJXKtW+c/3VSGFixMciopLWDPZuboYfBaGCTWlUUosJcfR2wsI58b46yb/LY0YLNZE4eegcGwCF+zMHVqx3VMTtoscKbIZmw6b9P0uXsbOBSYZhWDVS3fuHd7i7MudO31UJsAMtJzArhvi5ok789k6R03RcEY+XlqSK0YCIHcB4+om9t5C1Ej/QtoaWZJCvWcF2U1YzhC4XUyeRjX7jVHlwVm5LjoDf06kwwOPuX5ttgVcY= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:46.8349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1416ec7-711d-4c48-7682-08db45a6ca9b 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: AM7EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR08MB7612 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: yDIBt2VCKpHTEjh5dfCQKHkmx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438693; bh=U1jUPH7BrooXiQxNJBVkMR3BevFeJ5/vdTiK7v1xu10=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=LrKCxC6a/cKwD1jLNnnkhp123Z9i1tZD00IJqXOKZYYVN45nEzYDc+UApQ+JqgYoCDg emp1D2N2AWVkZkB6lAvrwOHt+2qkz0QWxuoNkyDYcSybUQHOqLj3uYiBa0nq9pVtuldF0 xJq2p/Mn2q+BwvKBNfx7qd+T0D0updfuFhU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438695381100009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Realm Management Monitor (RMM) is a software component which forms part of a system which implements the Arm Confidential Compute Architecture (CCA) and is responsible for management of Realms. The RMM specification defines a Realm Service Interface (RSI) that the Guest can use to request services from the RMM. Therefore, add a library that implements the RSI interfaces to: - query the RSI version - get the Realm configuration. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtPkg.dec | 1 + ArmVirtPkg/Include/Library/ArmCcaRsiLib.h | 72 ++++++++++ ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 40 ++++++ ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c | 145 ++++++++++++++++++++ ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.inf | 29 ++++ 5 files changed, 287 insertions(+) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index 4645c91a83756603141717baadd9f3e9b482cdb2..0bc7d697428636d42ffb27e8e92= fca947665a79e 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -26,6 +26,7 @@ [Includes.common] Include # Root include for the package =20 [LibraryClasses] + ArmCcaRsiLib|Include/Library/ArmCcaRsiLib.h ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h =20 [Guids.common] diff --git a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h b/ArmVirtPkg/Include= /Library/ArmCcaRsiLib.h new file mode 100644 index 0000000000000000000000000000000000000000..ab70240b3ab2979996f20190ddf= 669b53183556b --- /dev/null +++ b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h @@ -0,0 +1,72 @@ +/** @file + Library that implements the Arm CCA Realm Service Interface calls. + + Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + - Rsi or RSI - Realm Service Interface + - IPA - Intermediate Physical Address + + @par Reference(s): + - Realm Management Monitor (RMM) Specification, version A-bet0 + (https://developer.arm.com/documentation/den0137/) +**/ + +#ifndef ARM_CCA_RSI_LIB_ +#define ARM_CCA_RSI_LIB_ + +#include + +/** + A macro defining the size of a Realm Granule. + See Section A2.2, RMM Specification, version A-bet0 + DNBXXX A Granule is a unit of physical memory whose size is 4KB. +*/ +#define REALM_GRANULE_SIZE SIZE_4KB + +/** A structure describing the Realm Configuration. + See Section B4.4.4 RsiRealmConfig type, RMM Specification, version A-bet0 + The width of the RsiRealmConfig structure is 4096 (0x1000) bytes. +*/ +typedef struct RealmConfig { + // Width of IPA in bits. + UINT64 IpaWidth; + // Unused bits of the RsiRealmConfig structure should be zero. + UINT8 Reserved[SIZE_4KB - sizeof (UINT64)]; +} REALM_CONFIG; + +/** + Read the Realm Configuration. + + @param [out] Config Pointer to the address of the buffer to retrieve + the Realm configuration. + + Note: The buffer to retrieve the Realm configuration must be aligned to = the + Realm granule size. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiGetRealmConfig ( + IN REALM_CONFIG *Config + ); + +/** + Get the version of the RSI implementation. + + @param [out] Major The major version of the RSI implementation. + @param [out] Minor The minor version of the RSI implementation. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + */ +RETURN_STATUS +EFIAPI +RsiGetVersion ( + OUT UINT16 *CONST Major, + OUT UINT16 *CONST Minor + ); + +#endif // ARM_CCA_RSI_LIB_ diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Libra= ry/ArmCcaRsiLib/ArmCcaRsi.h new file mode 100644 index 0000000000000000000000000000000000000000..90e9dbb609679c82cd8e8ee8081= 428fd97021f97 --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h @@ -0,0 +1,40 @@ +/** @file + Definitions for Arm CCA Realm Service Interface. + + Copyright (c) 2022 - 2023, ARM Ltd. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Rsi or RSI - Realm Service Interface + - IPA - Intermediate Physical Address + + @par Reference(s): + - Realm Management Monitor (RMM) Specification, version A-bet0 + (https://developer.arm.com/documentation/den0137/) +**/ + +#ifndef ARM_CCA_RSI_H_ +#define ARM_CCA_RSI_H_ + +// FIDs for Realm Service Interface calls. +#define FID_RSI_REALM_CONFIG 0xC4000196 +#define FID_RSI_VERSION 0xC4000190 + +/** RSI Command Return codes + See Section B4.4.1, RMM Specification, version A-bet0. + The width of the RsiCommandReturnCode enumeration is 64 bits. +*/ +#define RSI_SUCCESS 0ULL +#define RSI_ERROR_INPUT 1ULL +#define RSI_ERROR_STATE 2ULL +#define RSI_INCOMPLETE 3ULL + +/** RSI interface Version + See Section B4.4.3, RMM Specification, version A-bet0. + The width of the RsiInterfaceVersion fieldset is 64 bits. +*/ +#define RSI_VER_MINOR_MASK 0x00FFULL +#define RSI_VER_MAJOR_MASK 0x7F00ULL +#define RSI_VER_MAJOR_SHIFT 16 + +#endif // ARM_CCA_RSI_H_ diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c b/ArmVirtPkg/Li= brary/ArmCcaRsiLib/ArmCcaRsiLib.c new file mode 100644 index 0000000000000000000000000000000000000000..42b99fb7a71c8b38512a2f7472f= 9bc8a034fe1e9 --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c @@ -0,0 +1,145 @@ +/** @file + Library that implements the Arm CCA Realm Service Interface calls. + + 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 + + @par Reference(s): + - Realm Management Monitor (RMM) Specification, version A-bet0 + (https://developer.arm.com/documentation/den0137/) + +**/ +#include + +#include +#include +#include +#include +#include +#include "ArmCcaRsi.h" + +/** + Convert the RSI status code to EFI Status code. + + @param [in] RsiCommandReturnCode RSI status code. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_ABORTED The operation was aborted as the state + of the Realm or REC does not match the + state expected by the command. + @retval RETURN_NOT_READY The operation requested by the command + is not complete. + **/ +STATIC +RETURN_STATUS +RsiCmdStatusToEfiStatus ( + IN UINT64 RsiCommandReturnCode + ) +{ + switch (RsiCommandReturnCode) { + case RSI_SUCCESS: + return RETURN_SUCCESS; + case RSI_ERROR_INPUT: + return RETURN_INVALID_PARAMETER; + case RSI_ERROR_STATE: + return RETURN_ABORTED; + case RSI_INCOMPLETE: + return RETURN_NOT_READY; + default: + // Unknown error code. + ASSERT (0); + break; + } // switch + + return RETURN_ABORTED; +} + +/** + Check if the address is aligned to the size of the Realm granule. + + @param [in] Address Address to check granule alignment. + + @retval TRUE Address is aligned to the Realm granule size. + @retval FALSE Address is not aligned to the Realm granule size. +**/ +STATIC +BOOLEAN +EFIAPI +AddrIsGranuleAligned ( + IN UINT64 *Address + ) +{ + if (((UINT64)Address & (REALM_GRANULE_SIZE - 1)) !=3D 0) { + return FALSE; + } + + return TRUE; +} + +/** + Read the Realm Configuration. + + @param [out] Config Pointer to the address of the buffer to retrieve + the Realm configuration. + + Note: The buffer to retrieve the Realm configuration must be aligned to = the + Realm granule size. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiGetRealmConfig ( + OUT REALM_CONFIG *Config + ) +{ + ARM_SMC_ARGS SmcCmd; + + if ((Config =3D=3D NULL) || (!AddrIsGranuleAligned ((UINT64 *)Config))) { + return RETURN_INVALID_PARAMETER; + } + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_REALM_CONFIG; + SmcCmd.Arg1 =3D (UINTN)Config; + + ArmCallSmc (&SmcCmd); + return RsiCmdStatusToEfiStatus (SmcCmd.Arg0); +} + +/** + Get the version of the RSI implementation. + + @param [out] Major The major version of the RSI implementation. + @param [out] Minor The minor version of the RSI implementation. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + */ +RETURN_STATUS +EFIAPI +RsiGetVersion ( + OUT UINT16 *CONST Major, + OUT UINT16 *CONST Minor + ) +{ + ARM_SMC_ARGS SmcCmd; + + if ((Major =3D=3D NULL) || (Minor =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_VERSION; + + ArmCallSmc (&SmcCmd); + *Minor =3D SmcCmd.Arg0 & RSI_VER_MINOR_MASK; + *Major =3D (SmcCmd.Arg0 & RSI_VER_MAJOR_MASK) >> RSI_VER_MAJOR_SHIFT; + return RETURN_SUCCESS; +} diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.inf b/ArmVirtPkg/= Library/ArmCcaRsiLib/ArmCcaRsiLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..1e2b72f312587f822dfca1b26b1= 910f75d4ec7b6 --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.inf @@ -0,0 +1,29 @@ +## @file +# Library that implements the Arm CCA Realm Service Interface calls. +# +# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D ArmCcaRsiLib + FILE_GUID =3D 5EF34A0A-28B5-4E57-A999-CC1528FC629A + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmCcaRsiLib + +[Sources] + ArmCcaRsiLib.c + ArmCcaRsi.h + +[Packages] + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmLib + ArmSmcLib --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103553): https://edk2.groups.io/g/devel/message/103553 Mute This Topic: https://groups.io/mt/98495956/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103555+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438696100725.9831052123666; Tue, 25 Apr 2023 09:04:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 18TuYY1788612xsa9hjuq0pl; Tue, 25 Apr 2023 09:04:55 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.80]) by mx.groups.io with SMTP id smtpd.web10.83962.1682438694691617593 for ; Tue, 25 Apr 2023 09:04:55 -0700 X-Received: from AS9PR0301CA0022.eurprd03.prod.outlook.com (2603:10a6:20b:468::18) by AM9PR08MB6676.eurprd08.prod.outlook.com (2603:10a6:20b:2ff::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: from AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:468:cafe::28) by AS9PR0301CA0022.outlook.office365.com (2603:10a6:20b:468::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.54 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103555+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT014.mail.protection.outlook.com (100.127.140.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: ("Tessian outbound 3a01b65b5aad:v136"); Tue, 25 Apr 2023 16:04:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1ae188d6bdfd72db X-CR-MTA-TID: 64aa7808 X-Received: from cb4b7a39bab1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CB9FC1E5-C047-4DC3-9AA9-C1D508A253A8.1; Tue, 25 Apr 2023 16:04:40 +0000 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cb4b7a39bab1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jj2/I5dIfVc2N59Fr7weJ9EnYpl3dSfnrmHi3zfRHCQZQDEP8XfJ1jidkfj7RfisJgeRuGUtl6mSWLzkntBNYFTBbXjE56gdkwq44GZGesgfMV6Ay6YNA4ZEgMIJBNHOZE4UwEwF/mj+We/r6n03WHxyOCjzwlYH90Ce73aGMiRaJy+fE3bHTyobOm7FAqQo1IoBPt7z++OE5zfHfpU0xx0ob5pVd6MAY3ToGjhSq1gagZdllxAtfnnzFheAQxwX2MweYhtDXZDy4PP8NRVTW4nT5bDiLtQNRW2OhWu59eElrAuRkjVJYdaNhvF4fuXBmDltfNVlah1oO+ZM9Pftfw== 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=sdgl81LEDTHHrd63wk5/yLnJtSJVvnfqgcSdkEnEkPw=; b=IML1HYXmcK6Tv6r0vgGWhkGIOm2oagPXCCv0MicxGffW1WDpG/YO5a0/fhs33aFbFRNq9fus+bOsI6ZA6mcEKrbM7raENOexQrLRPu3hZFoHj/cz82JJotTUjDd+ETS0nE8+tkJ0365OW2vUYCV0rvhUJnrOWVEJTR1NADY/FLCPaynXjAoNgxgsvsKgJoelwr9ZcbHdKUEx1N1dhnZ6Mvcihq08n5dNNF/VWbe2Yz8bHXQ8409yPl4OyB+inZjkTZwWnEuWQTKRMeB5J4NINl7I8ZrBa4ANgiWJyCx0iPJRkY9ldXzQ8GbgtgiMcAl/MIUmnuSKRrHuKxSXmZPwGg== 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 X-Received: from DU2PR04CA0269.eurprd04.prod.outlook.com (2603:10a6:10:28e::34) by AS8PR08MB10170.eurprd08.prod.outlook.com (2603:10a6:20b:63f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:38 +0000 X-Received: from DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::e0) by DU2PR04CA0269.outlook.office365.com (2603:10a6:10:28e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:38 +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 DBAEUR03FT055.mail.protection.outlook.com (100.127.142.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:38 +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.23; Tue, 25 Apr 2023 16:04:37 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:36 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 07/30] ArmVirtPkg: ArmCcaRsiLib: Add interfaces to manage the Realm IPA state Date: Tue, 25 Apr 2023 17:04:05 +0100 Message-ID: <20230425160428.27980-8-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT055:EE_|AS8PR08MB10170:EE_|AM7EUR03FT014:EE_|AM9PR08MB6676:EE_ X-MS-Office365-Filtering-Correlation-Id: b2e972f1-2f26-4e37-e60f-08db45a6cb05 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: mMwH5MgCcQ+kvW71y9QASI6AK+xi7bhpxepx/+qV4s+FITqJcp+TgUEORns+We75IqkZnazXq1ZHhFBwhGRA6YRw2UVi2Xm+MYWKB/diezb1mDt49jnyFI96VwlHW4qFu30QcUzmhdBbf+nsEm+c0IPHIbhHhWSMUhIgn5pVl6PKKwh6RoGJFED9qGwN20rB1Fz8pV3Ye3RheimskRYYESTr9IqbnuibHNK0jd32OxBmlg5+Qv2dT6NG8sTPPXvz8DPE6BAGE+UwaUCuQUi/MlyN6QXMKiuVhHPR6GtK6rlrpzLfI/7WZYMJNORX5kuz6mvHiw59/IgH4uTg1btVSBeJa7lysgTCBWJfZQsXdtFTFvtfVFPaos7h59VaszRuh2DpFc/gPwdnV6eWPUpVrupimI3sNYWUZEQ6nj+BMlbS+sl9VMUbmiUMa9RQhgAfVn4g5JZcZKwfieggKECi/AiEtDF2BGqVtfriLHDKpFcHfjAEx5j1Sj96PjzpdTXngTEKfukqyknZNV4z9wU7syPGnW7Tvn2cP7JMKj2idLaNYL0QWNSaR39e9um5rHwjiXn1/UNNqs2A52GG31vj0REDH8Rq5fp41k7b2ZSHAKZ5R4Avbgg2OIINFRXoiHLZ4SsBplQe3wBjZZERgarOFCP12mu2305+fjgY9xc4gir5Yoh+nX/MKj1jIZ52FlzORi7AYhKAZi5j+lavxPJvD7sQRKm7L7uwN8Dz66FGTNk= 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:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(36840700001)(46966006)(1076003)(26005)(40480700001)(426003)(336012)(2616005)(36756003)(34070700002)(83380400001)(36860700001)(47076005)(186003)(82740400003)(356005)(81166007)(70206006)(86362001)(70586007)(478600001)(6916009)(8676002)(8936002)(54906003)(44832011)(5660300002)(7696005)(41300700001)(2906002)(82310400005)(4326008)(6666004)(316002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10170 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1ff1f0a5-9772-46b8-c4a3-08db45a6c584 X-Microsoft-Antispam-Message-Info: pohMm1rXWVGpANXa4zAmxkNkZiwn9+5hP/+Xm7AkL++myFVfg9R5myzM1m7SgmotKic0gDO7xSWIUFjrOCfLwRoIgPOlP4G2TxM6OZSq+ZMd5+evPt6/6y3umPL9clmE+iU1JjKNE9bJor90Bw5LFnwBmbadhNot5etMBvqsKBgilXYpf1nmD7ThWazDoBh1ny537L29URrJD3UQi4rN2T/ALlMWeJIHoNmD1y9vrUEKauQ6Ui0/bcspshng9udOQbyihXfuAwb7UJHK8C3bFANSldO/WbPEyA9DhtETZCGBJw2bhpUzkNWCEnAQGTfO3EXRlmQZBjSxWkfA8DTx4jQF5hIXgPSetTAs2U6PN7mRUTqPsyXv+oF3gbFtnlPdb0cWV3mwAfyOtfzEVqxipcD1I4E1cp0rP4YzatanC8pjrezbP4Wmva7f/k66HTE7DD4wTw3/mrwzmcPtlk0c10lhc8MC92gSr3N3zsy8VYH70pMvhsB/lX4aiG/8BEq6ezQvhbMHcIS7jFwp1KfZlol1z66OBH/q8y6S42yAC+YfpAmiEx9VKfGmKb57LIWfEDmwCQEJuUCvzmXbvEIZ4/7YxaP6Sm7k+O2nkMP6rTSOxNmgq8lfCFvxFCWblDyryGN9LPLMLgwbYUb1GUGrz9Ty/WjD3hpHzFmZdz8HVfY82M/X999W2jA2w0Lwg+m+82Q24UjUdEixsSBZX2DCjIy1HupJArfNCRK8VHJg8hQ= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:47.5325 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2e972f1-2f26-4e37-e60f-08db45a6cb05 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: AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6676 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: EjwcBNMp0Zstmf9Pi6MZJ7S9x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438695; bh=gf0vF+aGkbmR+UKyO8XwQA2ZI6KkVU4c36CVf7e9kZQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=tqY+Oz7hMUEvmL/05UoserRp62yy48Z6S1e1n0BjRZM0ifWhNDJ68rnq7TSHHXX2MzP CCayVKooE0QoPUGrySkkbgE7dsx4ut4xe8JxSuG1G25fk6DTbHOAWCnPAxlq9ZVyz+Aj+ XRSfAyg6LxA1PNtISTRBVN3JuX2GmKMyrJo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438696705100017 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Realm's IPA space. An Unprotected IPA is an address in the upper half of a Realm's IPA space. A Protected IPA has an associated Realm IPA state (RIPAS). The RIPAS values are: * EMPTY - Unused address * RAM - Private code or data owned by the Realm. Software in the Realm needs to share memory with the host to communicate with the outside world, e.g. network, disk image, etc. To share memory, the software in the Realm first transitions the RIPAS of memory region it wants to share with the host from RAM to EMPTY. The Realm software can then access the shared memory region using the Unprotected IPA address. The RMM specification defines the following Realm Service Interfaces for managing the IPA state: * RSI_IPA_STATE_GET * RSI_IPA_STATE_SET Therefore, update the ArmCcaRsiLib to add interfaces to get and set the IPA state of Realm memory pages. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Include/Library/ArmCcaRsiLib.h | 50 +++++++++++ ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 7 +- ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c | 92 ++++++++++++++++++++ 3 files changed, 147 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h b/ArmVirtPkg/Include= /Library/ArmCcaRsiLib.h index ab70240b3ab2979996f20190ddf669b53183556b..ae798a2feb9c3c417f06b7c2dfd= b49479731df52 100644 --- a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h +++ b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h @@ -6,6 +6,7 @@ =20 - Rsi or RSI - Realm Service Interface - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state =20 @par Reference(s): - Realm Management Monitor (RMM) Specification, version A-bet0 @@ -24,6 +25,21 @@ */ #define REALM_GRANULE_SIZE SIZE_4KB =20 +/** + A macro defining the mask for the RSI RIPAS type. + See Section B4.4.5 RsiRipas type, RMM Specification, version A-bet0. +*/ +#define RIPAS_TYPE_MASK 0xFF + +/** An enum describing the RSI RIPAS. + See Section A5.2.2 Realm IPA state, RMM Specification, version A-bet0 +*/ +typedef enum Ripas { + RIPAS_EMPTY, ///< Unused IPA location. + RIPAS_RAM, ///< Private code or data owned by the Realm. + RIPAS_MAX ///< A valid RIPAS type value is less than RIPAS_MAX. +} RIPAS; + /** A structure describing the Realm Configuration. See Section B4.4.4 RsiRealmConfig type, RMM Specification, version A-bet0 The width of the RsiRealmConfig structure is 4096 (0x1000) bytes. @@ -35,6 +51,40 @@ typedef struct RealmConfig { UINT8 Reserved[SIZE_4KB - sizeof (UINT64)]; } REALM_CONFIG; =20 +/** + Returns the IPA state for the page pointed by the address. + + @param [in] Address Address to retrive IPA state. + @param [out] State The RIPAS state for the address specified. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiGetIpaState ( + IN UINT64 *Address, + OUT RIPAS *State + ); + +/** + Sets the IPA state for the pages pointed by the memory range. + + @param [in] Address Address to the start of the memory range. + @param [in] Size Length of the memory range. + @param [in] State The RIPAS state to be configured. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiSetIpaState ( + IN UINT64 *Address, + IN UINT64 Size, + IN RIPAS State + ); + /** Read the Realm Configuration. =20 diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Libra= ry/ArmCcaRsiLib/ArmCcaRsi.h index 90e9dbb609679c82cd8e8ee8081428fd97021f97..9cc12bc5a70b457367077d0b260= 11c3b91fa63c9 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h @@ -7,6 +7,7 @@ @par Glossary: - Rsi or RSI - Realm Service Interface - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state =20 @par Reference(s): - Realm Management Monitor (RMM) Specification, version A-bet0 @@ -17,8 +18,10 @@ #define ARM_CCA_RSI_H_ =20 // FIDs for Realm Service Interface calls. -#define FID_RSI_REALM_CONFIG 0xC4000196 -#define FID_RSI_VERSION 0xC4000190 +#define FID_RSI_IPA_STATE_GET 0xC4000198 +#define FID_RSI_IPA_STATE_SET 0xC4000197 +#define FID_RSI_REALM_CONFIG 0xC4000196 +#define FID_RSI_VERSION 0xC4000190 =20 /** RSI Command Return codes See Section B4.4.1, RMM Specification, version A-bet0. diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c b/ArmVirtPkg/Li= brary/ArmCcaRsiLib/ArmCcaRsiLib.c index 42b99fb7a71c8b38512a2f7472f9bc8a034fe1e9..546df9a94cb86533b37fef7e42f= daf7b8563052d 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c @@ -7,6 +7,7 @@ @par Glossary: - Rsi or RSI - Realm Service Interface - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state =20 @par Reference(s): - Realm Management Monitor (RMM) Specification, version A-bet0 @@ -81,6 +82,97 @@ AddrIsGranuleAligned ( return TRUE; } =20 +/** + Returns the IPA state for the page pointed by the address. + + @param [in] Address Address to retrive IPA state. + @param [out] State The RIPAS state for the address specified. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiGetIpaState ( + IN UINT64 *Address, + OUT RIPAS *State + ) +{ + RETURN_STATUS Status; + ARM_SMC_ARGS SmcCmd; + + if ((State =3D=3D NULL) || (!AddrIsGranuleAligned (Address))) { + return RETURN_INVALID_PARAMETER; + } + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_IPA_STATE_GET; + SmcCmd.Arg1 =3D (UINTN)Address; + + ArmCallSmc (&SmcCmd); + Status =3D RsiCmdStatusToEfiStatus (SmcCmd.Arg0); + if (!RETURN_ERROR (Status)) { + *State =3D (RIPAS)(SmcCmd.Arg1 & RIPAS_TYPE_MASK); + } + + return Status; +} + +/** + Sets the IPA state for the pages pointed by the memory range. + + @param [in] Address Address to the start of the memory range. + @param [in] Size Length of the memory range. + @param [in] State The RIPAS state to be configured. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiSetIpaState ( + IN UINT64 *Address, + IN UINT64 Size, + IN RIPAS State + ) +{ + RETURN_STATUS Status; + UINT64 *BaseAddress; + UINT64 *EndAddress; + ARM_SMC_ARGS SmcCmd; + + if ((Size =3D=3D 0) || + ((Size & (REALM_GRANULE_SIZE - 1)) !=3D 0) || + (!AddrIsGranuleAligned (Address))) + { + return RETURN_INVALID_PARAMETER; + } + + BaseAddress =3D Address; + // Divide Size by 8 for the pointer arithmetic + // to work, as we are adding to UINT64*. + EndAddress =3D Address + (Size >> 3); + + while (Size > 0) { + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_IPA_STATE_SET; + SmcCmd.Arg1 =3D (UINTN)BaseAddress; + SmcCmd.Arg2 =3D (UINTN)Size; + SmcCmd.Arg3 =3D (UINTN)State; + + ArmCallSmc (&SmcCmd); + Status =3D RsiCmdStatusToEfiStatus (SmcCmd.Arg0); + if (RETURN_ERROR (Status)) { + break; + } + + BaseAddress =3D (UINT64 *)SmcCmd.Arg1; + Size =3D EndAddress - BaseAddress; + } // while + + return Status; +} + /** Read the Realm Configuration. =20 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103555): https://edk2.groups.io/g/devel/message/103555 Mute This Topic: https://groups.io/mt/98495959/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103554+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438694597138.90455552580795; Tue, 25 Apr 2023 09:04:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id oN5OYY1788612x2TUJuAqVDK; Tue, 25 Apr 2023 09:04:54 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.76]) by mx.groups.io with SMTP id smtpd.web10.83960.1682438693338643272 for ; Tue, 25 Apr 2023 09:04:53 -0700 X-Received: from AM5PR04CA0015.eurprd04.prod.outlook.com (2603:10a6:206:1::28) by DB9PR08MB6380.eurprd08.prod.outlook.com (2603:10a6:10:256::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::8b) by AM5PR04CA0015.outlook.office365.com (2603:10a6:206:1::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:49 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103554+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT004.mail.protection.outlook.com (100.127.140.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: ("Tessian outbound 99a3040377ca:v136"); Tue, 25 Apr 2023 16:04:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1dde94fb138da702 X-CR-MTA-TID: 64aa7808 X-Received: from 17111e49aab3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D1DDA034-8141-42F5-A24E-376C22C57143.1; Tue, 25 Apr 2023 16:04:42 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 17111e49aab3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PqNwVimRa0hYK1uo+boXReAn95h3y379t/ij5awBpiMXgbCxcwiBwyhZXwR0jmFTjkohz2M8rP1NuoMMpq4bZ/paKBdneLWZL/JjqPtlYr3mkvF4ZCW1SdIDyx8tCX8GQW4rEF/5zHd/DszzZjNXynLZ1ktTOrB0wd9FnotODybmZmYNuy7MNPkj4pBAMeZ6plHoBvCAJ1HHSeKyKK2mihKKfkDU6YK/10ssI/W4K3DB9S52zv2QndJAieKFyrhmsNLAlMmdC6RoalhXQ1n+euMHDtLU3estVFVfx/ApRrkxzJs6AganV5wCbiUG1p9fFAHPMHFHVWXWo/Rx85UEtQ== 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=7GHEUhW6gb7cnx+w2N/0uwF1y8zwWcc/7Te/XQAO4o8=; b=odkMGKCnoqK5JwxM6/BKIv8iyBUz0VeqMfKdgNnAep28sM50lvAFaoPTw91+Ewoc3q8jABlikAT4fekX42PDiuHG7Q1CicWCU7bLfuHr2+tx/rmzQi+o74VRA/BVPen4QCxrf1aUod2dU6Y29DV/IT70luS/9+WRhblxjx2aJ1j2KpAVPtzri/jlA5HTGPSXrxUbYoBbqRMqhBUgESLY6U8/AfjjBVTTJNWcLh+M1A1uY+eTzWHudWRCMVM6BNCxKdvkF/Yary+Hj8TtS6L12bhioFROl6ECq+x5sVcAttweNNQ/SNp5DNa44Sk0SrvF/aAnVAJbxVjpB5xYjV18xQ== 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 X-Received: from DUZPR01CA0060.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::18) by AS8PR08MB6264.eurprd08.prod.outlook.com (2603:10a6:20b:29a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:39 +0000 X-Received: from DBAEUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:469:cafe::6a) by DUZPR01CA0060.outlook.office365.com (2603:10a6:10:469::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:39 +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 DBAEUR03FT043.mail.protection.outlook.com (100.127.143.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:39 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:39 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:38 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:37 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 08/30] ArmVirtPkg: ArmCcaRsiLib: Add an interface to get an attestation token Date: Tue, 25 Apr 2023 17:04:06 +0100 Message-ID: <20230425160428.27980-9-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT043:EE_|AS8PR08MB6264:EE_|AM7EUR03FT004:EE_|DB9PR08MB6380:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f6212b5-24f2-430d-68e3-08db45a6cc01 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: XAS+BewockkpvwySglZIiIFbVhm83cf/F90HjXAwJQbUHnYMNGx1q/07VbfnqRykgDChkx9MxjVZghey/GNiKXq+2D2xdBVntuye8WRw40E9wgyQLkqH5bIW/fihRvw70xduKerh42km34hzSApyiJzuocuLatyXNRHsT2Ny4GOBXQxsLGlXiK1p+qczwcvufS8GeZENL5LgX0O/MNukRnfYoNTs+Bm+csw5iUJbzEBqWka1R1YMo3Int5iDhU62MTx0Ms0carOng912MtDieNfSMHwaumLxKfFpFwRm1xgPKg+gIGXyhC5RKgfX+cEOjEplsMxuJf3bluSEyP/n+ZA++obAqWXlF0CmJTVstXE1CUDR5dIFxMVOqojeeYNNPBBIn+Jsasd+wGRnQXXWTInow0GHPj35iu7Ad15E16L6AmCQ5qRHWuNbzar6ukcATeMcfkCgvlX2+EjjzGbMSoKWPGtWb5RVg2WaMTc2RYEnmq5mXj6gnUyE7BX+RT+SoGz52X1yQ0q8r3nGDcJ+4dlfoZpNETsepmM2+olYrkEBNqqCaJ37igMdsP8mp1/p/amhCyrOhuaJcyFgreYjSPLa8JWjqgaiWuGbXlpjj8oivSzpZ8yLgqbuwjXVwXcMY4FbaI+piZgH/uVoEU65eBg9xGhPvppKvkioxUY9xM3MFHccb86SMBN+cbdSqAXvryz8ebvMNQ913zmtQ0c5TgCmS+rgNoE2nN8EMlpgIAM= 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:(13230028)(4636009)(136003)(346002)(396003)(39860400002)(376002)(451199021)(46966006)(36840700001)(186003)(40480700001)(34070700002)(54906003)(478600001)(86362001)(36756003)(7696005)(6666004)(82310400005)(2906002)(5660300002)(44832011)(8676002)(8936002)(70586007)(70206006)(4326008)(6916009)(81166007)(82740400003)(41300700001)(356005)(316002)(26005)(1076003)(336012)(426003)(2616005)(36860700001)(47076005)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6264 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b1e488ed-adff-4d1e-0714-08db45a6c630 X-Microsoft-Antispam-Message-Info: p3e/YAHKPGAv32GbQQ1tnhrm14fTp9LUCtSS6NXTg6yEsLcdSoE84SB+Nu4l/ykdA/xd8fD1yRzMxu0ynJm/jbuWsas+PrgHw+UvvCgb/UBwAA3h3KQg2GY0xBCQXXD9Bm+3PSGkPJ3vhzLxRpIVhcKAqqCnT/DwZmbrtu2qCUbu9pasZ7wNL+jDd58/NFqntimvfPePX6rUXL1PoESbUa2lvM/Meg2Tc4rX4W1vmEybRzrlcOC29TQrDIFHKo6hiS3zunjnHxqdXZM2LptsgUHMW7PJOxF46xdZUl0F9+Bii1em0ida/yeHp2yN39tauDYEXWWrKLMFDLgrYefNzo96bUL4UEsPRNFBIr9wqevBSS5njaJoC7GO9guxklO09+qpgDDfI8zRjSbgnii7d9IpxDWBUXKM9vSeG+NPy4OG6QJm6X4tGMJDXOhAz1kXyrgapnVC4oEtkwTwsLfzjufesbJSVbS4ebsBV52rZBBVJqcFPJO2jXmA0nn5nFtcX8A3n2skhlU4kdQSYpdzAPKpyIrjIBHQvhn3uO44Y9sp+txc5j2KP9WqWYaEtRddYCDDzU1vY71e3F5M74Kytc6UNgyxy0rsgbS69U5boKcv59XPzPT88MoiRz/sDJ+UxbBCGjDHjSiepORJ5hmiGQ7HcB64Kun328IQpRKNBvgOJyLbEP0D10zMCXzKHujwzreMKRHlNbPHNHsMv6ydELMZ0s2Vozg2PuPD6dSMmUo= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:49.1026 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f6212b5-24f2-430d-68e3-08db45a6cc01 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: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6380 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: UkjtdNe1TZ43We9omDlWr2z8x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438694; bh=tjBswjy91YEgMWvrv9EzPinqXxIwWKs4iT0ysphJVOI=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=jTUBu+TG5UWMiwbI6CJBPdPSO1eA8lhPB1pu6kf2rfiP9sin582PNc+R+RS+Rr7yDgG KLiWlz/38Q+Ho6Q2zZYHcF46MS8ySYVIuNXGZWCAkGsOR5VsTcYLXdcaqohQ2VBIQ6I8C k0IZ2wEd6MUbHnXxHETpjLkfESYPJ6rN/zU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438695787100013 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A CCA attestation token is a collection of claims about the state of a Realm and of the CCA platform on which the Realm is running. A CCA attestation token consists of two parts: * Realm token - Contains attributes of the Realm, including: # Realm Initial Measurement # Realm Extensible Measurements * CCA platform token - Contains attributes of the CCA platform on which the Realm is running, including: # CCA platform identity # CCA platform life cycle state # CCA platform software component measurements The CCA attestation token is used by a verification service to validate these claims. The Realm Service Interface defines the following interfaces to retrieve an attestation token from the Realm Management Monitor (RMM). - RSI_ATTESTATION_TOKEN_INIT - RSI_ATTESTATION_TOKEN_CONTINUE Therefore, update the ArmCcaRsiLib to add an interface to get an attestation token from the RMM. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Include/Library/ArmCcaRsiLib.h | 42 +++++ ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 10 +- ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c | 193 ++++++++++++++++++++ 3 files changed, 241 insertions(+), 4 deletions(-) diff --git a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h b/ArmVirtPkg/Include= /Library/ArmCcaRsiLib.h index ae798a2feb9c3c417f06b7c2dfdb49479731df52..fe176d83c4b11d3f7bb35c97ec8= ef00a4f47f981 100644 --- a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h +++ b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h @@ -31,6 +31,19 @@ */ #define RIPAS_TYPE_MASK 0xFF =20 +/* Maximum attestation token size + RBXKKY The size of an attestation token is no larger than 4KB. +*/ +#define MAX_ATTESTATION_TOKEN_SIZE SIZE_4KB + +/* Maximum challenge data size in bits. +*/ +#define MAX_CHALLENGE_DATA_SIZE_BITS 512 + +/* Minimum recommended challenge data size in bits. +*/ +#define MIN_CHALLENGE_DATA_SIZE_BITS 256 + /** An enum describing the RSI RIPAS. See Section A5.2.2 Realm IPA state, RMM Specification, version A-bet0 */ @@ -51,6 +64,35 @@ typedef struct RealmConfig { UINT8 Reserved[SIZE_4KB - sizeof (UINT64)]; } REALM_CONFIG; =20 +/** + Retrieve an attestation token from the RMM. + + @param [in] ChallengeData Pointer to the challenge data to= be + included in the attestation toke= n. + @param [in] ChallengeDataSizeBits Size of the challenge data in bi= ts. + @param [out] TokenBuffer Pointer to a buffer to store the + retrieved attestation token. + @param [in, out] TokenBufferSize Size of the token buffer on inpu= t and + number of bytes stored in token = buffer + on return. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_ABORTED The operation was aborted as the state + of the Realm or REC does not match the + state expected by the command. + @retval RETURN_NOT_READY The operation requested by the command + is not complete. +**/ +RETURN_STATUS +EFIAPI +RsiGetAttestationToken ( + IN CONST UINT8 *CONST ChallengeData, + IN UINT64 ChallengeDataSizeBits, + OUT UINT8 *CONST TokenBuffer, + IN OUT UINT64 *CONST TokenBufferSize + ); + /** Returns the IPA state for the page pointed by the address. =20 diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Libra= ry/ArmCcaRsiLib/ArmCcaRsi.h index 9cc12bc5a70b457367077d0b26011c3b91fa63c9..325234d06695befc840dcf37e95= 1130dfe0550c3 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h @@ -18,10 +18,12 @@ #define ARM_CCA_RSI_H_ =20 // FIDs for Realm Service Interface calls. -#define FID_RSI_IPA_STATE_GET 0xC4000198 -#define FID_RSI_IPA_STATE_SET 0xC4000197 -#define FID_RSI_REALM_CONFIG 0xC4000196 -#define FID_RSI_VERSION 0xC4000190 +#define FID_RSI_ATTESTATION_TOKEN_CONTINUE 0xC4000195 +#define FID_RSI_ATTESTATION_TOKEN_INIT 0xC4000194 +#define FID_RSI_IPA_STATE_GET 0xC4000198 +#define FID_RSI_IPA_STATE_SET 0xC4000197 +#define FID_RSI_REALM_CONFIG 0xC4000196 +#define FID_RSI_VERSION 0xC4000190 =20 /** RSI Command Return codes See Section B4.4.1, RMM Specification, version A-bet0. diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c b/ArmVirtPkg/Li= brary/ArmCcaRsiLib/ArmCcaRsiLib.c index 546df9a94cb86533b37fef7e42fdaf7b8563052d..01ecee3a6798c0e5cefd9fb4f48= 788d3063c94cd 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c @@ -82,6 +82,199 @@ AddrIsGranuleAligned ( return TRUE; } =20 +/** + Continue the operation to retrieve an attestation token. + + @param [out] TokenBuffer Pointer to a buffer to store the + retrieved attestation token. + @param [in,out] TokenSize On input size of the token buffer, + and on output size of the token + returned if operation is successful, + otherwise 0. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_ABORTED The operation was aborted as the state + of the Realm or REC does not match the + state expected by the command. + @retval RETURN_NOT_READY The operation requested by the command + is not complete. + **/ +STATIC +RETURN_STATUS +EFIAPI +RsiAttestationTokenContinue ( + OUT UINT8 *CONST TokenBuffer, + OUT UINT64 *CONST TokenSize + ) +{ + RETURN_STATUS Status; + ARM_SMC_ARGS SmcCmd; + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_ATTESTATION_TOKEN_CONTINUE; + // Set the IPA of the Granule to which the token will be written. + SmcCmd.Arg1 =3D (UINTN)TokenBuffer; + + ArmCallSmc (&SmcCmd); + Status =3D RsiCmdStatusToEfiStatus (SmcCmd.Arg0); + if (!RETURN_ERROR (Status)) { + // Update the token size + *TokenSize =3D SmcCmd.Arg1; + } else { + // Clear the TokenBuffer on error. + ZeroMem (TokenBuffer, *TokenSize); + *TokenSize =3D 0; + } + + return Status; +} + +/** + Initialize the operation to retrieve an attestation token. + + @param [in] ChallengeData Pointer to the challenge data to= be + included in the attestation toke= n. + @param [in] ChallengeDataSizeBits Size of the challenge data in bi= ts. + @param [in] TokenBuffer Pointer to a buffer to store the + retrieved attestation token. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + **/ +STATIC +RETURN_STATUS +EFIAPI +RsiAttestationTokenInit ( + IN CONST UINT8 *CONST ChallengeData, + IN UINT64 ChallengeDataSizeBits, + IN UINT8 *CONST TokenBuffer + ) +{ + ARM_SMC_ARGS SmcCmd; + UINT8 *Buffer8; + CONST UINT8 *Data8; + UINT64 Count; + UINT8 TailBits; + + /* See A7.2.2 Attestation token generation, RMM Specification, version A= -bet0 + IWTKDD - If the size of the challenge provided by the relying party i= s less + than 64 bytes, it should be zero-padded prior to calling + RSI_ATTESTATION_TOKEN_INIT. + + Therefore, zero out the SmcCmd memory before coping the ChallengeData + bits. + */ + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_ATTESTATION_TOKEN_INIT; + // Set the IPA of the Granule to which the token will be written. + SmcCmd.Arg1 =3D (UINTN)TokenBuffer; + + // Copy challenge data. + Buffer8 =3D (UINT8 *)&SmcCmd.Arg2; + Data8 =3D ChallengeData; + + // First copy whole bytes + Count =3D ChallengeDataSizeBits >> 3; + CopyMem (Buffer8, Data8, Count); + + // Now copy any remaining tail bits. + TailBits =3D ChallengeDataSizeBits & (8 - 1); + if (TailBits > 0) { + // Advance buffer pointers. + Buffer8 +=3D Count; + Data8 +=3D Count; + + // Copy tail byte. + *Buffer8 =3D *Data8; + + // Clear unused tail bits. + *Buffer8 &=3D ~(0xFF << TailBits); + } + + ArmCallSmc (&SmcCmd); + return RsiCmdStatusToEfiStatus (SmcCmd.Arg0); +} + +/** + Retrieve an attestation token from the RMM. + + @param [in] ChallengeData Pointer to the challenge data to= be + included in the attestation toke= n. + @param [in] ChallengeDataSizeBits Size of the challenge data in bi= ts. + @param [out] TokenBuffer Pointer to a buffer to store the + retrieved attestation token. + @param [in, out] TokenBufferSize Size of the token buffer on inpu= t and + number of bytes stored in token = buffer + on return. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_ABORTED The operation was aborted as the state + of the Realm or REC does not match the + state expected by the command. + @retval RETURN_NOT_READY The operation requested by the command + is not complete. +**/ +RETURN_STATUS +EFIAPI +RsiGetAttestationToken ( + IN CONST UINT8 *CONST ChallengeData, + IN UINT64 ChallengeDataSizeBits, + OUT UINT8 *CONST TokenBuffer, + IN OUT UINT64 *CONST TokenBufferSize + ) +{ + RETURN_STATUS Status; + + if ((TokenBuffer =3D=3D NULL) || + (TokenBufferSize =3D=3D NULL) || + (ChallengeData =3D=3D NULL)) + { + return RETURN_INVALID_PARAMETER; + } + + if (*TokenBufferSize < MAX_ATTESTATION_TOKEN_SIZE) { + *TokenBufferSize =3D MAX_ATTESTATION_TOKEN_SIZE; + return RETURN_BAD_BUFFER_SIZE; + } + + if (!AddrIsGranuleAligned ((UINT64 *)TokenBuffer)) { + DEBUG ((DEBUG_ERROR, "ERROR : Token buffer not granule aligned\n")); + return RETURN_INVALID_PARAMETER; + } + + if (ChallengeDataSizeBits > MAX_CHALLENGE_DATA_SIZE_BITS) { + return RETURN_INVALID_PARAMETER; + } + + /* See A7.2.2 Attestation token generation, RMM Specification, version A= -bet0 + IWTKDD - Arm recommends that the challenge should contain at least 32= bytes + of unique data. + */ + if (ChallengeDataSizeBits < MIN_CHALLENGE_DATA_SIZE_BITS) { + DEBUG ((DEBUG_WARN, "Minimum Challenge data size should be 32 bytes\n"= )); + } + + Status =3D RsiAttestationTokenInit ( + ChallengeData, + ChallengeDataSizeBits, + TokenBuffer + ); + if (RETURN_ERROR (Status)) { + ASSERT (0); + return Status; + } + + /* Loop until the token is ready or there is an error. + */ + do { + Status =3D RsiAttestationTokenContinue (TokenBuffer, TokenBufferSize); + } while (Status =3D=3D RETURN_NOT_READY); + + return Status; +} + /** Returns the IPA state for the page pointed by the address. =20 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103554): https://edk2.groups.io/g/devel/message/103554 Mute This Topic: https://groups.io/mt/98495957/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103557+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168243869950947.61771487949238; Tue, 25 Apr 2023 09:04:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id AZSOYY1788612x08odlKrKsV; Tue, 25 Apr 2023 09:04:57 -0700 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.80]) by mx.groups.io with SMTP id smtpd.web11.83448.1682438696776121751 for ; Tue, 25 Apr 2023 09:04:57 -0700 X-Received: from DB6PR0402CA0014.eurprd04.prod.outlook.com (2603:10a6:4:91::24) by PAVPR08MB9794.eurprd08.prod.outlook.com (2603:10a6:102:31e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:51 +0000 X-Received: from DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:91:cafe::71) by DB6PR0402CA0014.outlook.office365.com (2603:10a6:4:91::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:51 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103557+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT040.mail.protection.outlook.com (100.127.142.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:51 +0000 X-Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 25 Apr 2023 16:04:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a040f625eff439e2 X-CR-MTA-TID: 64aa7808 X-Received: from f8c9dccc31ad.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4A9AA680-DA2B-4C77-82E5-EEE2895E4F8A.1; Tue, 25 Apr 2023 16:04:44 +0000 X-Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f8c9dccc31ad.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UhyPZzJa2pN7CYJdqHdabKOfvunNoSx3JLa/aTSh+qlJgWydbcNZDr5Yz19M7vVeyWmzPsHxeTBQzUoIlyIVnMcBq6EVFP26JjEfenzOkW/Eyo/M6WCvtutWUOjjRnioJJvgHrvoBpPXHS3hwrszCbvM6MWJNHzI/OrGzFqGGJHDkILkx9qvtDQntWa5rBcLH/cz+LB05RwJxI28a3cniRX2/ZUQWY/cok6ppV7HPceahmhb9QnBSbKEuz2ZPf2zwqItgjT/EK5e42ybBjQpJ5M9bIgDMfJ+Qo8Gv/a/xZ96j6C/7wKzProukEgayvCGwZGn1vO++zVCoiKQaph8Pg== 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=B009P1u/LlyCTYTNiOhGXTYedXP9PGH4DpFgK9FG1hQ=; b=imz5Cj1wC/+ICJOKcZVjrb6zG/PrytDue8aB8sLBJ/wJaFMt+/Kb2OaPASuaJ8bwsKGL64f1kHUqvtvIBbDgX2Z9zsfHfjALqAOu2Thze86nVn6C7FGlq1h8ocbtP+SLUqfrmLMz6AsAKBF3bjMtBXTPMrE3LLDwNA3VPIxXbVtNQcZjH8Ozd4oCSU0aX22Ik5FuJp+Wdp/5KY5MiZKqKv3JFIXhQQ9gjZCRexijjzH2TYAPQtC9Smhpel4AUmYNp7OjZLEfHC7bfJcCDt/40gxd9+tj6mZ5KkNgAC/clZmLVd6tDlEfVwNzazURjf4ziI0JsF0uaeu0FIjfQ3QX2w== 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 X-Received: from DB7PR05CA0043.eurprd05.prod.outlook.com (2603:10a6:10:2e::20) by PR3PR08MB5577.eurprd08.prod.outlook.com (2603:10a6:102:81::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:41 +0000 X-Received: from DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::52) by DB7PR05CA0043.outlook.office365.com (2603:10a6:10:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:41 +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 DBAEUR03FT010.mail.protection.outlook.com (100.127.142.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:41 +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.23; Tue, 25 Apr 2023 16:04:39 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:39 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 09/30] ArmVirtPkg: ArmCcaRsiLib: Add interfaces to get/extend REMs Date: Tue, 25 Apr 2023 17:04:07 +0100 Message-ID: <20230425160428.27980-10-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT010:EE_|PR3PR08MB5577:EE_|DBAEUR03FT040:EE_|PAVPR08MB9794:EE_ X-MS-Office365-Filtering-Correlation-Id: 563767d1-b425-4a90-6b80-08db45a6cd98 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: s2Qs9PsjaZnxUTgQF/Bv5tWb0YeubEhoamYaUpp+wrxKQPWdvN08DavqXW4L+OilHFVzzwHnIlzDONa6diApksarxDjjmRr0/NpOIKw0nZcRwGDTe5Vx9e5SKF8ncnWFhafNSePq78hArd8NoRB7GfHKkaTDCjJgzXJfJDBgKO8NxJP6fEglAqhNxFFS7rZ4xH9lZzU1phffMVl2FUpcwDFCyTe7R4wBs1d3drre+Bh7TU86UYXZ5xWtabRYo84cA3neGjyt9BfCV7RA4J53Jtb5HVk7c7YzW74VXQ/Xq4/gStmWA/kSPVVu1+pXKwTvhlCVzhoA8xjsOWpy+vhTmovyz+2YrNzANo8MsWNLd4J0qVNOfrPGakZhDgI2fiul23u3hOgD0u8sqI5RoUbAYu0pFmCRnq17XCfvnc6gFydG67cz7PbEnNTRW98Q9wO/trT/Sv46pIN4/OSJQ2/p6Xxns2EhrNU+cV2n6TUjt7fPpqkyGv368WnATNuv70Ja1sDCxSOoOH2JCpRpTmcoVMV7GvqhNYyIGtvgML8qHYV3oUvJP/Mvf0raz54npUqu87+6q/Nb/SU2ls7kmayF9i+q80GBN+oVwTJvn9OhGWqxSlzlsx8uYt10IH2TEUrwpvCs0K9KpLFKab778REWkBgy8NWpzuVQkKnngYVsvLRSRdjH4bVueteDlnsUyaPi4xcs8qVk7OASA9iJz7XMPXjiRpppG899z1ObTSR/37Q= 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:(13230028)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199021)(46966006)(36840700001)(478600001)(54906003)(86362001)(36756003)(34070700002)(186003)(26005)(82310400005)(1076003)(40480700001)(4326008)(6916009)(316002)(6666004)(82740400003)(44832011)(83380400001)(70206006)(70586007)(36860700001)(2906002)(8676002)(336012)(426003)(356005)(81166007)(41300700001)(7696005)(5660300002)(8936002)(47076005)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5577 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ab1be8eb-2f7d-403d-c723-08db45a6c737 X-Microsoft-Antispam-Message-Info: 75rUFzl15WWjI0W8oVbx1OaYbY5hT0pYkmGi2sHQr2drHCph1qtW+dN4NlpUEVnGf5gJkS483cuGCsZk65r+lNqxXn9rFp4mi03BUPJpQL5pZK9FrVGiCTxoyAK2qgVn8MLKptGOAzNBtzatcthbW7bVORkudcrkVvpTDjB/YXvJZCis9HVc2sYAIwn8YNIWkCikeWteLFHcyW8qC42fUlzu5MPNq/dMU4xrZcjdFtBB0oiYW9UVwS1BMJfQsEEHAGH8xLstpPcsY3Y4aJWFtIa4ZQR7FWxbW1lnpwuVuJzh6Fvc2pl2MOpIRnrh5wtV3DD2AOeTo4ono0lxYS8ce9uv+zSxiDoHpWb/f1+COQHMORe7sMZqLu9K8Ee2WAs5HPpX+nDamtFB+3mhn19HGWrcB5HG3ooq/vcq2VdxvyNfurCES/X2m62D8oLHezaTiqydLnNbkrvfpxDkxtewERfrqC1j9uJwJWM497WHxkspOf4dK2uG9/7wWQ4A2v4CZR4vNUzvo9oCW21cNbXCKZkkQLElOdVmST3y82SMBxUlJYLG9+mgE7yekEKP6WDe4dwYEzfneaL4zNFq3hjgVClDRodhc1tTQDmxVdN/uq8bNyr9VrcFneCZS/y4gUTFq5lV32mUR17duG+M1kfdXu1A2P5/TqiF53v48ZlRto/glvd0WVxTw6KysOZvDy89M9b9BWR2ovlrsP02/I7nEEzp2eWVSOxITLsKa66cyi4= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:51.9106 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 563767d1-b425-4a90-6b80-08db45a6cd98 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: DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9794 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: pwZZlajm5x5RTXv5psdofYHax1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438697; bh=JRhuj3K1alSWEq00qN7MV06w1Wl9WQ0ZnfuJr3oR8Bo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=nzO0niVvgXu/HDYcg/J5ws9TH3XRzGu8jAAYNc5K6oF/fKO+wQx4hq8QwVg7j1u7cJv Dq3mk/ljugf3uoJ8QfaTlSFrKrh/uX+m6h2uUUl7PfcgMbtzh4a5hE6QnnPUys1IflERW iF2tZjFRv0sGHpj/kmjW0EVQ6mLS2Etjg5I= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438700803100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Section A2.1.3 Realm attributes, RMM Specification, version A-bet0 introduces the concept of REMs as described below: DGRFCS - A Realm Extensible Measurement (REM) is a measurement value which can be extended during the lifetime of a Realm. IFMPYL - Attributes of a Realm include an array of measurement values. The first entry in this array is a RIM. The remaining entries in this array are REMs. The Realm Service Interface commands defined in section B4.3.7 RSI_MEASUREMENT_READ and B4.3.6 RSI_MEASUREMENT_EXTEND specify the interfaces to read and extend measurements to REMs. Therefore, update ArmCcaRsiLib to add interfaces to get and extend REMs. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Include/Library/ArmCcaRsiLib.h | 53 ++++++++++++ ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 2 + ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c | 91 ++++++++++++++++++++ 3 files changed, 146 insertions(+) diff --git a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h b/ArmVirtPkg/Include= /Library/ArmCcaRsiLib.h index fe176d83c4b11d3f7bb35c97ec8ef00a4f47f981..51527071ab87aa82efa9ddc3064= bb88803d5ba13 100644 --- a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h +++ b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h @@ -7,6 +7,8 @@ - Rsi or RSI - Realm Service Interface - IPA - Intermediate Physical Address - RIPAS - Realm IPA state + - RIM - Realm Initial Measurement + - REM - Realm Extensible Measurement =20 @par Reference(s): - Realm Management Monitor (RMM) Specification, version A-bet0 @@ -44,6 +46,21 @@ */ #define MIN_CHALLENGE_DATA_SIZE_BITS 256 =20 +/* Maximum measurement data size in bytes. + See Section C1.11 RmmRealmMeasurement type, RMM Specification, version A= -bet0 + The width of the RmmRealmMeasurement type is 512 bits. +*/ +#define MAX_MEASUREMENT_DATA_SIZE_BYTES 64 + +/* Minimum and Maximum indices for REMs + See Section A2.1.3 Realm attributes, RMM Specification, version A-bet0 + IFMPYL - Attributes of a Realm include an array of measurement values. T= he + first entry in this array is a RIM. The remaining entries in this array = are + REMs. +*/ +#define MIN_REM_INDEX 1 +#define MAX_REM_INDEX 4 + /** An enum describing the RSI RIPAS. See Section A5.2.2 Realm IPA state, RMM Specification, version A-bet0 */ @@ -127,6 +144,42 @@ RsiSetIpaState ( IN RIPAS State ); =20 +/** + Extends a measurement to a REM. + + @param [in] MeasurementIndex Index of the REM. + @param [in] Measurement Pointer to the measurement buffer. + @param [in] MeasurementSize Size of the measurement data. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiExtendMeasurement ( + IN UINTN MeasurementIndex, + IN CONST UINT8 *CONST Measurement, + IN UINTN MeasurementSize + ); + +/** + Read the measurement value from a REM. + + @param [in] MeasurementIndex Index of the REM. + @param [out] MeasurementBuffer Pointer to store the measurement dat= a. + @param [in] MeasurementBufferSize Size of the measurement buffer. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiReadMeasurement ( + IN UINTN MeasurementIndex, + OUT UINT8 *CONST MeasurementBuffer, + IN UINTN MeasurementBufferSize + ); + /** Read the Realm Configuration. =20 diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Libra= ry/ArmCcaRsiLib/ArmCcaRsi.h index 325234d06695befc840dcf37e951130dfe0550c3..6f0ee3061ade5a4a99b717a52d5= a241e0e446270 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h @@ -22,6 +22,8 @@ #define FID_RSI_ATTESTATION_TOKEN_INIT 0xC4000194 #define FID_RSI_IPA_STATE_GET 0xC4000198 #define FID_RSI_IPA_STATE_SET 0xC4000197 +#define FID_RSI_MEASUREMENT_EXTEND 0xC4000193 +#define FID_RSI_MEASUREMENT_READ 0xC4000192 #define FID_RSI_REALM_CONFIG 0xC4000196 #define FID_RSI_VERSION 0xC4000190 =20 diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c b/ArmVirtPkg/Li= brary/ArmCcaRsiLib/ArmCcaRsiLib.c index 01ecee3a6798c0e5cefd9fb4f48788d3063c94cd..fd29fc61caf880bcaf96d982f3a= 4d973e7ebb70f 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c @@ -8,6 +8,7 @@ - Rsi or RSI - Realm Service Interface - IPA - Intermediate Physical Address - RIPAS - Realm IPA state + - REM - Realm Extensible Measurement =20 @par Reference(s): - Realm Management Monitor (RMM) Specification, version A-bet0 @@ -366,6 +367,96 @@ RsiSetIpaState ( return Status; } =20 +/** + Extends a measurement to a REM. + + @param [in] MeasurementIndex Index of the REM. + @param [in] Measurement Pointer to the measurement buffer. + @param [in] MeasurementSize Size of the measurement data. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiExtendMeasurement ( + IN UINTN MeasurementIndex, + IN CONST UINT8 *CONST Measurement, + IN UINTN MeasurementSize + ) +{ + ARM_SMC_ARGS SmcCmd; + UINT64 *Data64; + + if ((MeasurementIndex < MIN_REM_INDEX) || + (MeasurementIndex > MAX_REM_INDEX) || + (Measurement =3D=3D NULL) || + (MeasurementSize =3D=3D 0) || + (MeasurementSize > MAX_MEASUREMENT_DATA_SIZE_BYTES)) + { + return RETURN_INVALID_PARAMETER; + } + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + + SmcCmd.Arg0 =3D FID_RSI_MEASUREMENT_EXTEND; + SmcCmd.Arg1 =3D MeasurementIndex; + SmcCmd.Arg2 =3D MeasurementSize; + + Data64 =3D &SmcCmd.Arg3; + CopyMem (Data64, Measurement, MeasurementSize); + + ArmCallSmc (&SmcCmd); + return RsiCmdStatusToEfiStatus (SmcCmd.Arg0); +} + +/** + Read the measurement value from a REM. + + @param [in] MeasurementIndex Index of the REM. + @param [out] MeasurementBuffer Pointer to store the measurement dat= a. + @param [in] MeasurementBufferSize Size of the measurement buffer. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiReadMeasurement ( + IN UINTN MeasurementIndex, + OUT UINT8 *CONST MeasurementBuffer, + IN UINTN MeasurementBufferSize + ) +{ + RETURN_STATUS Status; + ARM_SMC_ARGS SmcCmd; + UINT64 *Data64; + + if ((MeasurementIndex < MIN_REM_INDEX) || + (MeasurementIndex > MAX_REM_INDEX) || + (MeasurementBuffer =3D=3D NULL)) + { + return RETURN_INVALID_PARAMETER; + } + + if (MeasurementBufferSize < MAX_MEASUREMENT_DATA_SIZE_BYTES) { + return RETURN_BUFFER_TOO_SMALL; + } + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_MEASUREMENT_READ; + SmcCmd.Arg1 =3D MeasurementIndex; + + ArmCallSmc (&SmcCmd); + Status =3D RsiCmdStatusToEfiStatus (SmcCmd.Arg0); + if (!RETURN_ERROR (Status)) { + Data64 =3D &SmcCmd.Arg1; + CopyMem (MeasurementBuffer, Data64, MAX_MEASUREMENT_DATA_SIZE_BYTES); + } + + return Status; +} + /** Read the Realm Configuration. =20 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103557): https://edk2.groups.io/g/devel/message/103557 Mute This Topic: https://groups.io/mt/98495961/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103558+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438702201739.3564145576742; Tue, 25 Apr 2023 09:05:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id GobwYY1788612xIWFYflFnUK; Tue, 25 Apr 2023 09:05:01 -0700 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.44]) by mx.groups.io with SMTP id smtpd.web10.83969.1682438700639428004 for ; Tue, 25 Apr 2023 09:05:01 -0700 X-Received: from AS9PR06CA0394.eurprd06.prod.outlook.com (2603:10a6:20b:461::27) by AS8PR08MB9430.eurprd08.prod.outlook.com (2603:10a6:20b:5ee::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.32; Tue, 25 Apr 2023 16:04:51 +0000 X-Received: from AM7EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:461:cafe::69) by AS9PR06CA0394.outlook.office365.com (2603:10a6:20b:461::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:51 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103558+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT021.mail.protection.outlook.com (100.127.140.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Tue, 25 Apr 2023 16:04:50 +0000 X-Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 25 Apr 2023 16:04:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4da5a03cf06fa5b9 X-CR-MTA-TID: 64aa7808 X-Received: from d3fac3b3b99b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2BB016E9-5B92-4173-8F46-4235733C16A1.1; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d3fac3b3b99b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XQATPZ+iaNhgA6DpDEVaQIvPH32VqohJrJP8cNYmFBTdoH95hP2pT2Zmv4TLvoYluoyZYd2SsF79yqMyYl0fmy8dKT6wsT9lmWuxKBDeof6RHNtWMdLkpz4YWOJAs9pDHnbiH+aNhQ2SqLwUjJ325j36K1pptW8iuD002j9nf2sr76GQ6Y5axXUpfwXz/jLTpmljsQIN42BKRjWipukishm7kjrEP0WzLQfodYnFNDxLoMIcrKCmRDkevm8rsXprTXPJuifRIqKY44jkYxfOYIr1PJ+oTtp8e+eYGdkONZ4o88wgUqatNnSSC9LuUoOQrAhFMBQQ1/DZJS+oC1yrmg== 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=c7Rhv7lwNUd6hNtjUstF0C0s3ratn+qvdfaOTTaVr1Y=; b=CicDT72hf2vHs4b0W9VqEUdFannVZWaz3Y8qtxhAY0TtkV38Ni7Z9MldWn/HKyKTZWtI4+DaHF/f4k3Q1uUX0mqNLLeDqime5ZNX44SksNHSFnWefRT2LbxvpE00mEry2Nttl7PBWCQ2+BV0KeIIgUum7sQd7ETxiNAkauuWF2Z37QGiN4cCMGx3EctzbvO1BBdV+H/EHw754RA99tVt8lqIY8uulkEW1SYPK4Vut1y02kNQYsck4T2HpGVohlwWebH7+95sD9qeU8kELIb3BZ2XzX9VjnDz3uN7GfHVBrIaCh6DM6nXVxriOM1HEea9e6aCulbUqUbCKdlkWCNolA== 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 X-Received: from DB7PR05CA0041.eurprd05.prod.outlook.com (2603:10a6:10:2e::18) by PAWPR08MB9470.eurprd08.prod.outlook.com (2603:10a6:102:2e9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:43 +0000 X-Received: from DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::46) by DB7PR05CA0041.outlook.office365.com (2603:10a6:10:2e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:42 +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 DBAEUR03FT010.mail.protection.outlook.com (100.127.142.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:42 +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.23; Tue, 25 Apr 2023 16:04:40 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:40 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 10/30] ArmVirtPkg: ArmCcaRsiLib: Add an interface to make a RSI Host Call Date: Tue, 25 Apr 2023 17:04:08 +0100 Message-ID: <20230425160428.27980-11-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT010:EE_|PAWPR08MB9470:EE_|AM7EUR03FT021:EE_|AS8PR08MB9430:EE_ X-MS-Office365-Filtering-Correlation-Id: f5ea6e9b-2e81-4507-bed0-08db45a6ccf8 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: WPZP3/4ckLAXw+WBi73JKl+3htPw+QiknY4xhexDWJKXIJ+RNlFPtc5ntnUsEz119GW0LU9oHJhEYbHACr7/Ki8gx3qfak30wYMGVUrc2heVqqAyAuntPz/UKqtktPKvSGSi/UHt6emZGiAR9pfmjkHqD9qnOKNBJoN+0/iQC5tHIFdPY1TAcKfk2vryy8psV8y5gvmBZfV7lfWEzgH/2CGEnTJRckmGYXN2OFK9sSNsOOYxj2letfZiidPPDbOk0gWU/pUvTtkYHMbOBi9TAswPo0PTHoz7+is3ZIN+8JT7aLH/N2MNQ4WJdomYfapEj/RTCLf7l8eddDt4gE0mTGvPll18A3zlgJmvYTF++J516qMQBnOthGPqrWJGg9e7rDdI1JksKSi8H1xJd94y8lpGbulSXeuMRKb1ZsTFTIi6Gii2WHrXhtXPUJENpLjt58hg+GXQKmim+6s3nbC/JqkTSZBRw/GO252rvbKw68v4STXOzIpssDsF10ssRqsUMwxArE+Yif6OzaUN61ZtxWfJ3TZi/GRgNhUb+ac/4h5tjFxIRxLW12jfIeaYVYk7uAxwTLGDPxITNdcOd9vIbFvfBDsA39f5/tGeUAex5Aj4wXVOPNjkbnFWQjyruCJiD6a8lbGxSflaf1JLR9AvrhnVRL0hcK917gGKOA/ZHgN7mMSw5qvfydK4xeStBG7xt2/e5B6znAuVgfK9js32I93egstvNB+svEk7YjOy7mI= 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:(13230028)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199021)(46966006)(36840700001)(478600001)(54906003)(86362001)(36756003)(34070700002)(186003)(26005)(82310400005)(1076003)(40480700001)(4326008)(6916009)(316002)(6666004)(82740400003)(44832011)(83380400001)(70206006)(70586007)(36860700001)(2906002)(8676002)(336012)(426003)(356005)(81166007)(41300700001)(7696005)(5660300002)(8936002)(47076005)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9470 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1f424d31-9db8-448b-1817-08db45a6c832 X-Microsoft-Antispam-Message-Info: h/Sl+dwdejqgJYN2NGtblAcv0YRrjhIZKWJs/4QIEDs5JcN5N2S3DIDCsmCC9EM8COfN9li9JyaSxh+ItCZqJEBLRgdbv8VUjwz8w5lSrDtCy3AXwTDQ+ZOLOJbNySXpVJJLVzz6VUJJHrojjMkDLgZG26r3gpYA5wVebSgilS//kYZTqh3yvfZX0iwdktum05ns9wynTqYEVefk9Ib4oQ7Qo+XnuwLOahdBSuxwoL3qlzam9+Ywp/fQcsap85OdCD1EmTxezyVg5A7oCr4T8y7dasC/fBMSOP615oeeD+DXB3OLaYZM6fGccVvmWMWnolu2k0L3l09hxmVWZBFrzwilVGtawEC6em/j74fPGg1fc5A3E7EEKW8OFmj/Df0Li8z2A65Zz95+hJIProglIn7Ll5ej54Gl7b6xGnr4FSzA/zH/ZTVn6/is6tccu/n7cdhm8wdOAVre0MKVjZwBW1/TWWLJORrARrqMIwFbf8pN81jI3fnZ0Ir3EArQxEOjaZ7/1Ofz8IS5P1V+1pknjW1NCwD6ITTrLwLWwwhLcVPrd14FmytYmWqrYMF6cJDUk1MwI0sLd5d6JHsXJHagyeCcV70R+g+oZZvB9af757n6D+Xgcpf0i9vRNfQ21/tM8msjOXSLUo8ESJY9IJnqU3AlQJCvmrk3dnBNlpk6JVwhBREqN5b9IGLbIO2T29AiTnuohQ7h+mADp6JvD+zximkdnvWQs2XToEwOQU1F80Q= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:50.8173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5ea6e9b-2e81-4507-bed0-08db45a6ccf8 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: AM7EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9430 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: nUjoBoQkUfMN5W4hvRDNCF9Vx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438701; bh=hUezNES3J/z3osxkI90g8ey8HUG/zQBcMdkjLH5UExg=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=UhXg8PCZnQpqGEGrx1hBE8zSgLWZHQ7YGzHyhei3ofVWDM34ii1rjwyhjg38rmkjTUc dOxrDX88+IEFs+/qu8Hap5B93Esw6Kd1qYDrN/z2F4fFFEq3VAWp2etTgPyFqtOIy083x jpVRTVIV+WK+hPKfWOzedCTmYPU2X2EoJFA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438703421100010 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Section A4.5 Host call, RMM Specification, version A-bet0 describes the programming model for Realm communication with the Host and specifies the following: DYDJWT - A Host call is a call made by the Realm to the Host, by execution of the RSI_HOST_CALL command. IXNFKZ - A Host call can be used by a Realm to make a hypercall. DYDJWT - A Host call is a call made by the Realm to the Host, by execution of the RSI_HOST_CALL command. Therefore, introduce definition of HOST_CALL_ARGS structure that represents the arguments to the RSI_HOST_CALL command as defined in Section B4.3.3 RSI_HOST_CALL command. Also update the ArmCcaRsiLib library to add a new interface RsiHostCall () to make a Host call. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Include/Library/ArmCcaRsiLib.h | 36 ++++++++++++++++++ ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 1 + ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c | 40 ++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h b/ArmVirtPkg/Include= /Library/ArmCcaRsiLib.h index 51527071ab87aa82efa9ddc3064bb88803d5ba13..5468b2506522bbc9a1467045df0= eed6fc70f24de 100644 --- a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h +++ b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h @@ -81,6 +81,21 @@ typedef struct RealmConfig { UINT8 Reserved[SIZE_4KB - sizeof (UINT64)]; } REALM_CONFIG; =20 +/** A structure describing the Host Call arguments + See Section 4.4.2 RsiHostCall type, RMM Specification, version A-bet0 +*/ +typedef struct HostCallArgs { + UINT64 Imm; + UINT64 Gprs0; + UINT64 Gprs1; + UINT64 Gprs2; + UINT64 Gprs3; + UINT64 Gprs4; + UINT64 Gprs5; + UINT64 Gprs6; + UINT8 Reserved[0x1000 - (sizeof (UINT64) * 8)]; +} HOST_CALL_ARGS; + /** Retrieve an attestation token from the RMM. =20 @@ -198,6 +213,27 @@ RsiGetRealmConfig ( IN REALM_CONFIG *Config ); =20 +/** + Make a Host Call. + + A Host call can be used by a Realm to make a hypercall. + On Realm execution of HVC, an Unknown exception is taken to the Realm. + + @param [in] Args Pointer to the IPA of the Host call data + structure. + + Note: The IPA of the Host call arguments data structure must be aligned + to the Realm granule size. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiHostCall ( + IN HOST_CALL_ARGS *Args + ); + /** Get the version of the RSI implementation. =20 diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Libra= ry/ArmCcaRsiLib/ArmCcaRsi.h index 6f0ee3061ade5a4a99b717a52d5a241e0e446270..70e84a20711f04c32a5850230cc= 907a6d231f50b 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h @@ -20,6 +20,7 @@ // FIDs for Realm Service Interface calls. #define FID_RSI_ATTESTATION_TOKEN_CONTINUE 0xC4000195 #define FID_RSI_ATTESTATION_TOKEN_INIT 0xC4000194 +#define FID_RSI_HOST_CALL 0xC4000199 #define FID_RSI_IPA_STATE_GET 0xC4000198 #define FID_RSI_IPA_STATE_SET 0xC4000197 #define FID_RSI_MEASUREMENT_EXTEND 0xC4000193 diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c b/ArmVirtPkg/Li= brary/ArmCcaRsiLib/ArmCcaRsiLib.c index fd29fc61caf880bcaf96d982f3a4d973e7ebb70f..5b04c8af890fead113b827030f8= 6af5f07698354 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c @@ -489,6 +489,46 @@ RsiGetRealmConfig ( return RsiCmdStatusToEfiStatus (SmcCmd.Arg0); } =20 +/** + Make a Host Call. + + A Host call can be used by a Realm to make a hypercall. + On Realm execution of HVC, an Unknown exception is taken to the Realm. + + @param [in] Args Pointer to the IPA of the Host call data + structure. + + Note: The IPA of the Host call arguments data structure must be aligned + to the Realm granule size. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiHostCall ( + IN HOST_CALL_ARGS *Args + ) +{ + ARM_SMC_ARGS SmcCmd; + + if ((Args =3D=3D NULL) || (!AddrIsGranuleAligned ((UINT64 *)Args))) { + return RETURN_INVALID_PARAMETER; + } + + STATIC_ASSERT (sizeof (HOST_CALL_ARGS) =3D=3D SIZE_4KB); + + // Clear the reserved fields + ZeroMem (&Args->Reserved, sizeof (Args->Reserved)); + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_HOST_CALL; + SmcCmd.Arg1 =3D (UINTN)Args; + + ArmCallSmc (&SmcCmd); + return RsiCmdStatusToEfiStatus (SmcCmd.Arg0); +} + /** Get the version of the RSI implementation. =20 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103558): https://edk2.groups.io/g/devel/message/103558 Mute This Topic: https://groups.io/mt/98495963/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103556+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16824386970781023.4223545384458; Tue, 25 Apr 2023 09:04:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id knmaYY1788612x8vgvMxpRnz; Tue, 25 Apr 2023 09:04:56 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.61]) by mx.groups.io with SMTP id smtpd.web10.83965.1682438695646068350 for ; Tue, 25 Apr 2023 09:04:55 -0700 X-Received: from DUZPR01CA0168.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::24) by DB4PR08MB8199.eurprd08.prod.outlook.com (2603:10a6:10:381::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:52 +0000 X-Received: from DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::f8) by DUZPR01CA0168.outlook.office365.com (2603:10a6:10:4b3::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:52 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103556+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT024.mail.protection.outlook.com (100.127.142.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:52 +0000 X-Received: ("Tessian outbound 5bb4c51d5a1f:v136"); Tue, 25 Apr 2023 16:04:52 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 95019b9899476f45 X-CR-MTA-TID: 64aa7808 X-Received: from e3b9f09b5afc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 908B82C9-03C6-40B5-8E51-1258FE7A7CE9.1; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e3b9f09b5afc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P9mit4HF7zhi/1Ole9HCY1FE4VzMflK4suSXHf/WCLTDy2yW/0ynmXF7MtGS21OBM9XhfjPXRrwiTHuzy1qmpbe/tac2kV1RyhpY5GrAkYt4rvRTD5XC4M6W6D1V86DkW0sNWMvJcXt3WXErzVw7okl3po5yCiZSz4hvXVN14qHd1lENXIY9m54K2pPnNzebgJO0brliVZOGCfP+3daFeqWSDqXWL/mYpVkw3R/4jVvucm2uMQWDUb0fuSiyptxAGSfdVPP/YHXf5q5+ZI90W8fVdpSdRMniejeqn/kKv3yzecb6VaNGvAcqY4dKv5TN98OrUxw+FiuHd1qvlUOFjQ== 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=CP5ET3GunY9sBoDg35TqdGCtbnaL0ovT6mZoMuvwgF4=; b=kRRjwd+3eWk4YAMa7Vg21bXGF/JnwLENFTyUZMwcDYNqeEgOhaq/sbJa6vqHSwW7nZbMv3wzdCaYjb7v4pY3+UrknhHrbLPvIJEeXeeroMJGrv0+LDlDwvRlfrAftrGaf6EQgnlj50JJs8rUmcfS8mqLL5DTqbrxZpxbyEA+7CD+dG9QjJ0MmJIHSEZl02Ykvsv/TM1fDYj5G1iVOCwNXh+QGQ3mytrjTGkhvI2eRBdQeE2sQoban0i/7vDEM3ngaoOlrh+VbAaKFf1gi8FKomfNaFjVRfAXAK6vR56IxWKk0UfOyxu3qbMuEpPvNguvIzKWObajsyrjRJC06QwAnw== 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 X-Received: from DB7PR05CA0070.eurprd05.prod.outlook.com (2603:10a6:10:2e::47) by AS4PR08MB8217.eurprd08.prod.outlook.com (2603:10a6:20b:51c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.32; Tue, 25 Apr 2023 16:04:43 +0000 X-Received: from DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::4a) by DB7PR05CA0070.outlook.office365.com (2603:10a6:10:2e::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:43 +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 DBAEUR03FT010.mail.protection.outlook.com (100.127.142.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:43 +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.23; Tue, 25 Apr 2023 16:04:41 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:41 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 11/30] ArmVirtPkg: Define a GUID HOB for IPA width of a Realm Date: Tue, 25 Apr 2023 17:04:09 +0100 Message-ID: <20230425160428.27980-12-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT010:EE_|AS4PR08MB8217:EE_|DBAEUR03FT024:EE_|DB4PR08MB8199:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c7aef10-ed3c-4f74-fc1c-08db45a6cdc3 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: lPcSy04pidBVh5UNYyhWJAq0AdWtncz0zeWkpJMHITQ5PoHExkZVSyZzAFpnDMZ3nI58cd9BS9NmDNEqQIHMeliBDCx6Lgwsfalwj64Sbu8Ps9x6yhG8xAl3oDmbuPRQFURWXXktZt7UolbiYErxwO8dYVC3+Ud/nz+jvnj3QFomhtlJ9cIeXDR7LK/g5kib9aCZoBvc/qKBUjtK5p57TKX7qlogXg1iHfkE2SEP8TYGis1sCrzLl1ONHvcIdvh3wNDq+bOLxNtVlgB0qw3q7RfwHW4xvK6om0Z6FV9PZ1L0GdpALtSPWKyeL2wCHzew5SfaO6Wx0IQtPO3FXxciCY3GNnz/7R96rCLtG7WX1FFemSlv/vwgNmZ9pSMhF5LXo3G7fjLC4vjQ53gwFV4WmknQ4emEXkudB+M0tsbhzA+Y4bNaxz+UC0tiyZvHe/CSe5cDsvc5zDEB6/M21RZdyqtPVFZfH5sWso78nDWFOW4fM80bTjAQEn+pqdP4/0b8RmCdYFmCiPB1NyIae7fjAP6xSIqbjJmuJcitNL0P2YHSgweYvoYy8c2jeVJapPxgjhvj7MwBCu5iPznqWG9Ey4P2BE50l8o8hBp8QBvq5j/mac55/mAsyyekCQDZm4WjjxEJJlntCCEzTAFekZqf5yYMclzFTg5VOuxfGYNKKDJTb0S8o3WUlMM7yrPiVWGaHko5W5K9Jnps0YViZ6BMGxWDUPZ/9lK+C5pPJlzudeM= 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:(13230028)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199021)(36840700001)(46966006)(478600001)(6666004)(7696005)(19627235002)(34070700002)(81166007)(36860700001)(40480700001)(26005)(186003)(356005)(1076003)(82740400003)(54906003)(47076005)(2616005)(336012)(426003)(5660300002)(8936002)(8676002)(41300700001)(70206006)(70586007)(2906002)(316002)(44832011)(4326008)(6916009)(86362001)(36756003)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8217 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 00151e17-9ec2-4567-fd12-08db45a6c89a X-Microsoft-Antispam-Message-Info: yVdSmT8IrXubwkAr0sg8WErLxYHI5gPBOgPreCpvVC+Bna49gzsj/BbbkVcrppxf/jO8H6Tmo5xy862Sn0ExdvYykm8YoK3ZTnFPiHQExo7lly1uEZjjcU9HuiNiTCaMIq+sV3y2s7A6R8elZwvxcpPKfgogl1O/a/Nhaxgla9+Mo3I98jRW6pVa6KCbsB6sUSZ7vAZTpX0zTl3tGLVyMocHdasIL2IvbTm8QyA15EkSvLBOQ0CA+y6D+MsLNoV4GaVoIw877nH2YtBwXBPFRelMXVh4OoSv5YxQFTvbjNYoqAcazo3BJpe+ciLXFyq1VCZpX7QX8FFn7Yt5pDsoFg3tk1naoiBaw4FWCg2oMEFucQ6MSqcvYopjmheDM4TN71HdNA0DYIbSG9m6ydXo1BVr9TfbO6Nt6WyDRIbfa0+ard8EAF9kaBaMIMHXjvm1XMYeBOpbC7xzBkum5SN2ak8USeA2YbaixPGKyGZmX39wc3P0BM7Kzar0OBaWWrqTDOTkqeeADJvomb95TRZ9S7krX8CZazJjxi9ddk3xYeJB2xzmr9R9O+qTsB75953CsmbUMb5+ssRp2GHPMdc4Cb7oT1yPLeRqP+y4jqE5nUVJQ7UxoJ32UQ4FDC+5gcFBlrTSml8cppE70GVn1cA+iaOrcPy/ZEv4E6M5lXqaWRLTfctDaGCGoAJzLafYYkQjt/FwsU4UjzJlqdEbYgCklAw/maOUnAEmCku5rV7C0Hg= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:52.1961 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c7aef10-ed3c-4f74-fc1c-08db45a6cdc3 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: DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB8199 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: tP6tgTX9VLQr1KGBZYV0Qkcgx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438696; bh=D3WRXJOq48WAhFt9UB0lviN7hm7eA20UBeKxoWLV0MY=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=HjkYM/U4b9Med9dxwK94qnst7yi/kXfEXAUiMo/gCjQLP0eIOKtVO+yU2+x5MFlDHUv /hYM15pl4cyZpat1jgIToWbeBHq7n7Z/iZ+r3IQd8vu874QOQJpjDXV8EQQl5nAitvt2l OOcqdsya5t27faCj0D2NdO1uP4nOOPXWDEM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438697425100019 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The IPA width of a Realm is read from the Realm Config by invoking the RSI call RSI_REALM_CONFIG to read the Realm Config. The IPA width is then stored in a GUID HOB gArmCcaIpaWidthGuid for subsequent use. This GUID HOB is also useful to pass the IPA width of the Realm to the DXE phase. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtPkg.dec | 1 + 1 file changed, 1 insertion(+) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index 0bc7d697428636d42ffb27e8e92fca947665a79e..ebdb9629fa2754e6f8b59f23750= ea50cf702d8fd 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -34,6 +34,7 @@ [Guids.common] gEarlyPL011BaseAddressGuid =3D { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x8= 0, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } } gEarly16550UartBaseAddressGuid =3D { 0xea67ca3e, 0x1f54, 0x436b, { 0x9= 7, 0x88, 0xd4, 0xeb, 0x29, 0xc3, 0x42, 0x67 } } gArmVirtSystemMemorySizeGuid =3D { 0x504eccb9, 0x1bf0, 0x4420, { 0x8= 6, 0x5d, 0xdc, 0x66, 0x06, 0xd4, 0x13, 0xbf } } + gArmCcaIpaWidthGuid =3D { 0xbdb66787, 0xfc8a, 0x412e, { 0xa= 0, 0x9b, 0x84, 0x96, 0x61, 0x81, 0x72, 0xc0 } } =20 [PcdsFeatureFlag] # --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103556): https://edk2.groups.io/g/devel/message/103556 Mute This Topic: https://groups.io/mt/98495960/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103569+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438711567630.4039108351591; Tue, 25 Apr 2023 09:05:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EMLfYY1788612xIU5FXe971r; Tue, 25 Apr 2023 09:05:11 -0700 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com (EUR03-AM7-obe.outbound.protection.outlook.com [40.107.105.80]) by mx.groups.io with SMTP id smtpd.web11.83464.1682438709486030019 for ; Tue, 25 Apr 2023 09:05:09 -0700 X-Received: from AM6P193CA0086.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::27) by AS2PR08MB10111.eurprd08.prod.outlook.com (2603:10a6:20b:62d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:57 +0000 X-Received: from AM7EUR03FT065.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::45) by AM6P193CA0086.outlook.office365.com (2603:10a6:209:88::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:57 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103569+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT065.mail.protection.outlook.com (100.127.140.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.19 via Frontend Transport; Tue, 25 Apr 2023 16:04:57 +0000 X-Received: ("Tessian outbound 3a01b65b5aad:v136"); Tue, 25 Apr 2023 16:04:57 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 301b1281c6bc2f0a X-CR-MTA-TID: 64aa7808 X-Received: from f4ffd1d3368c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 19225EF1-8FF5-430E-A92C-3AF40F202DB6.1; Tue, 25 Apr 2023 16:04:50 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f4ffd1d3368c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cejnMI0teJKj8qKhLD95mqim+aZ8gQtL4Ypxz9HDKDERBdkLEdaYbluVMlX83+y0WGkL2T/uZen+/GzZ8lpWURKfHW6foJXZIu2LXGzzKv+/p+VfXQptSv67pXf8aMcklHUR6B7TSNN64iLBVEMXfD1Qoeqi9Y656eFcRzoc/t6A2GhIdRQOPRNuuy+Yd9lQyAFfc4MwTsflJ7RnOqD0A1F99fRl2QmwxGRfoaWsSqHKPb6TrOUeh8v3JTkwd54gUlQ0IDZCX/adEtWeklrz9d18YEwX1QqOyorxrxis4IUwISKg4RzglVmvlRc0i3wPQySQ4lVKOdtjPYxPzdGJQQ== 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=R7mcpJ5ZAFLJeQwI5mWmp4oT+pR7WhNK0ZU7bUlvpRE=; b=YRL0wSXR2ZGWQuT+gosB9bh+kBsZxqAGj97gV2RRuvfowjPG1tPKULalXwhyX9a2XLYGyPBCQsuHbXKSbGMmw2BzxSkeRDzOSYvLm4s73vTbmHjbzy/zDfICKXYP3xhEIszRx7cnHW8JlvsJeCPPANosDnaiJaRiDUgvWW8q3FXbB6op291gZ/Ujn/GYtmq1LnBjX9OcthDxuHX1KTf9OYkGA6Yi4KsJ4Uei5nw3lOiE7qlXhpZYbJeVrjxgsv+19f2AX5/T7U+1CpdUmuotfxVqce6JGqR81GV7xtkFQliYlPeKmQ+6+UtxSs3/ojctH49jjoX3pg7dj4DiHofhKA== 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 X-Received: from DB7PR05CA0072.eurprd05.prod.outlook.com (2603:10a6:10:2e::49) by GV1PR08MB8260.eurprd08.prod.outlook.com (2603:10a6:150:a1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:44 +0000 X-Received: from DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::ae) by DB7PR05CA0072.outlook.office365.com (2603:10a6:10:2e::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:43 +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 DBAEUR03FT010.mail.protection.outlook.com (100.127.142.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:43 +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.23; Tue, 25 Apr 2023 16:04:42 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:41 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 12/30] ArmVirtPkg: Add library for Arm CCA initialisation in PEI Date: Tue, 25 Apr 2023 17:04:10 +0100 Message-ID: <20230425160428.27980-13-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT010:EE_|GV1PR08MB8260:EE_|AM7EUR03FT065:EE_|AS2PR08MB10111:EE_ X-MS-Office365-Filtering-Correlation-Id: 725797ba-5cd2-4b15-c04e-08db45a6d11f 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: mIuWEvkneEfc0pVXcMPZB5J9msRaMSpCiL2eN/yq6UeBS9rSVvQwg91+q9TP6XufRdaxkN65Q/S8GkJpa6X9JcChFRy1wujqnAOOaFd39VJt4Y2RyRm9Ej9v/7r2MMHIzQU1FiQaLeEoy0fYOS969ZqlIVd3V97FFFSiLVbQ6J+dCZDVIUYVcftLHu+Joa47GBtn/uJcuVwVQzLcDIcrI1pEtc3FLtFTIgYFGQaTVRV2mQkb4LpU6qJ7mbChJ/Og7bnDUABSpTcJBUF7bsdx8bkmGrB6YxEpClPK4doQJgMwFXWikZsUHzyblVzxL6vdW1hKu9LOwfkaSB1FV4g+02Vb1urnn/NcWOaJrkRDCRuFSs5pqY76+c9dprIKXKXU0LYbv4fEasCyMendQiZkno8NowrGjHt1NQG1sOt/m7c+sDsNN+I78Q8G/Wy7IDuNQiCcH3AcLudqrIX2CXqrx7+YNbQcqLKcuGFEPvET9cn6SYsS1q6fM1xFqKPLM8gOX4+npXbH5FELmQo9gwyOQAdOTIbeTcNDQYSMSgDIRi94kEFOJ6XLE6N/bIVRuSZIy5BJUZTTtnPe5xn2usfsywU/qGHpE54c7ABVk0LBdJxY5lQf407e4R7xBO/CyYZucVFu5cEKvkolQKQL8n74QQKkJj6GXyWGW1tlQ7qfaij6R0bfFOsxYFY1GmmraeurYbwjwzJN9Y6rcnpoD639WIsY15Xj6uyT1pwucEbCwBA= 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:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(36756003)(8676002)(8936002)(54906003)(34070700002)(478600001)(70586007)(6916009)(4326008)(70206006)(40480700001)(356005)(81166007)(44832011)(316002)(41300700001)(82740400003)(2906002)(5660300002)(2616005)(86362001)(36860700001)(186003)(336012)(426003)(26005)(1076003)(7696005)(6666004)(83380400001)(47076005)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8260 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: bb4906ba-168f-4aa5-f8bb-08db45a6c8d8 X-Microsoft-Antispam-Message-Info: tZYxdkLo1glAFi7FPypskTFDVYoriQhHDMa7IKwlOwc9h+/p6CXSYdJHXfrHg+uB9B6kzdiiQF4rpGkS7yNjeGFd5oi3EyiQM5Y6X/5MgW0PDORlVT/jaUaTdtem/5Mg1KdvPOgwiTIkLvjbUSvnoJWTQF9RH1ekZoQLxTgLYuiYwgMqdbOgQrDxgS/z9P5VaEvGlEKHOAWKdDug5AYdVS2oj0sJhX3y+8VtqvS2qHjEnr3pUePlUuehKOLeVhihwg1itXgUMI0EU8MGX8ro2h+0x3RH6HQfYciSY9124jfMt+ofUuwRK/qx1IJVxA/fxY479FURFmMknXHaSNhGUm3J0pUkfpNVdMwn6a56KGbQb53MScSVGwo7a12AT48g/XBURCiqxz+sGlChC1yI4cIMrFnG/42sCCleAVukSHP/3698TjPdKQb34+YDTu1Zb0o59iy63TSQsPuQS3860lY+Ekj1oOKmtaGrdiRHRNnpqBtebhFN1OIk6TBNuQqXvKtehkifs5Z/oc9vdnYgMxWI0mCcmegMOj/x7r41q7v/RP8kwpKYgtoFOzENQ0Tb34y//kGRc0/9sUSBiVTI7mvArsbMINWIQkvUi0wO/aPWt2NWrWWlZPOWx+RxIh4gFe2eVscliOz3Ew2SEQaIwld4xJEaCggsIdJBmkIP7RkJtsghFgty5uIxLk9ZOedaOpJ30d9oA10VzZFlYYG30bQkiov9MPrvN3S/nO5uUMM= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:57.7682 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 725797ba-5cd2-4b15-c04e-08db45a6d11f 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: AM7EUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10111 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: P33a5NmsVGvSeRI7gbKEn5hix1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438711; bh=vsoAthWwu9T8pGfquborK9E7rqqnXgNMVYo9yr3dpc4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=qw8NZ9o98ICAqvMX7yU7JnFJed1r1xrHJjsdjol+TsvLydUsV8N8LvdLsVUzCT2yi5m 3XpHhR7IPou5kgAy9g2uiNJqimdtYLaN6tWzmPUhIWKL5udyW13+e7ot4YtuMDjc/qAhY tJi9ViX5HLJp7dJj1ylo3utqGC4hd9nOmvQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438712335100053 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add ArmCcaInitPeiLib library that performs the Arm CCA specific initialisation in the PEI phase like: - Configuring the system memory as Protected RAM. - Reading the Realm Config and storing the IPA width in a GUID HOB i.e., gArmCcaIpaWidthGuid for subsequent use. - Calling ArmCcaConfigureMmio () to configure the MMIO regions by setting the Unprotected IPA attribute in the page tables. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtPkg.dec | 1 + ArmVirtPkg/Include/Library/ArmCcaInitPeiLib.h | 49 +++++++++ ArmVirtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.c | 116 +++++++++++= +++++++++ ArmVirtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.inf | 39 +++++++ 4 files changed, 205 insertions(+) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index ebdb9629fa2754e6f8b59f23750ea50cf702d8fd..c270d4a1ee268fb57a5338fd714= 87ed54699f496 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -26,6 +26,7 @@ [Includes.common] Include # Root include for the package =20 [LibraryClasses] + ArmCcaInitPeiLib|Include/Library/ArmCcaInitPeiLib.h ArmCcaRsiLib|Include/Library/ArmCcaRsiLib.h ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h =20 diff --git a/ArmVirtPkg/Include/Library/ArmCcaInitPeiLib.h b/ArmVirtPkg/Inc= lude/Library/ArmCcaInitPeiLib.h new file mode 100644 index 0000000000000000000000000000000000000000..439a70a54a218badd4cd4d6c419= df58f57271cc2 --- /dev/null +++ b/ArmVirtPkg/Include/Library/ArmCcaInitPeiLib.h @@ -0,0 +1,49 @@ +/** @file + Library that implements the Arm CCA helper functions. + + Copyright (c) 2022 2023, Arm Ltd. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + - Rsi or RSI - Realm Service Interface + - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state +**/ + +#ifndef ARM_CCA_INIT_PEI_LIB_ +#define ARM_CCA_INIT_PEI_LIB_ + +#include + +/** + Configure the System Memory region as Protected RAM. + + When a VMM creates a Realm, a small amount of DRAM (which contains the + firmware image) and the initial content is configured as Protected RAM. + The remaining System Memory is in the Protected Empty state. The firmware + must then initialise the remaining System Memory as Protected RAM before + it can be accessed. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Real= m. +**/ +RETURN_STATUS +EFIAPI +ArmCcaConfigureSystemMemory ( + VOID + ); + +/** + Perform Arm CCA specific initialisations. + + @retval RETURN_SUCCESS Success or execution context is not= a Realm. + @retval RETURN_OUT_OF_RESOURCES Out of resources. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +ArmCcaInitialize ( + VOID + ); + +#endif // ARM_CCA_LIB_ diff --git a/ArmVirtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.c b/ArmVi= rtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.c new file mode 100644 index 0000000000000000000000000000000000000000..2b1ed4c3eaa18a5519edce2d3d4= f143d08adb53e --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.c @@ -0,0 +1,116 @@ +/** @file + Library that implements the Arm CCA initialisation in PEI phase. + + 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + Configure the System Memory region as Protected RAM. + + When a VMM creates a Realm, a small amount of DRAM (which contains the + firmware image) and the initial content is configured as Protected RAM. + The remaining System Memory is in the Protected Empty state. The firmware + must then initialise the remaining System Memory as Protected RAM before + it can be accessed. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Real= m. +**/ +RETURN_STATUS +EFIAPI +ArmCcaConfigureSystemMemory ( + VOID + ) +{ + RETURN_STATUS Status; + + if (!IsRealm ()) { + return RETURN_UNSUPPORTED; + } + + Status =3D RsiSetIpaState ( + (UINT64 *)PcdGet64 (PcdSystemMemoryBase), + PcdGet64 (PcdSystemMemorySize), + RIPAS_RAM + ); + if (RETURN_ERROR (Status)) { + // Panic + CpuDeadLoop (); + } + + return Status; +} + +/** + Perform Arm CCA specific initialisations. + + @retval RETURN_SUCCESS Success or execution context is not= a Realm. + @retval RETURN_OUT_OF_RESOURCES Out of resources. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +ArmCcaInitialize ( + VOID + ) +{ + EFI_STATUS Status; + REALM_CONFIG *Config; + UINT64 *IpaWidthHobData; + + if (!IsRealm ()) { + // Noting to do as the execution context is not a Realm. + return RETURN_SUCCESS; + } + + // Read the Realm Config and store the IPA width in a GUID HOB. + Config =3D AllocatePages (EFI_SIZE_TO_PAGES (sizeof (REALM_CONFIG))); + if (Config =3D=3D NULL) { + ASSERT (0); + return RETURN_OUT_OF_RESOURCES; + } + + ZeroMem (Config, sizeof (REALM_CONFIG)); + + Status =3D RsiGetRealmConfig (Config); + if (RETURN_ERROR (Status)) { + ASSERT (0); + return Status; + } + + IpaWidthHobData =3D BuildGuidHob ( + &gArmCcaIpaWidthGuid, + sizeof (*IpaWidthHobData) + ); + if (IpaWidthHobData =3D=3D NULL) { + ASSERT (0); + FreePages (Config, EFI_SIZE_TO_PAGES (sizeof (REALM_CONFIG))); + return RETURN_OUT_OF_RESOURCES; + } + + *IpaWidthHobData =3D Config->IpaWidth; + + FreePages (Config, EFI_SIZE_TO_PAGES (sizeof (REALM_CONFIG))); + + // Configure the MMIO memory regions. + return ArmCcaConfigureMmio (*IpaWidthHobData); +} diff --git a/ArmVirtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.inf b/Arm= VirtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..f2a321d9cdfcf1bd87d6584e3c6= 834686a298bf0 --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.inf @@ -0,0 +1,39 @@ +## @file +# Library that implements the Arm CCA initialisation in PEI phase. +# +# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D ArmCcaInitPeiLib + FILE_GUID =3D 9A8C3768-79ED-487E-8155-BBF4DD638296 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmCcaInitPeiLib + +[Sources] + ArmCcaInitPeiLib.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmCcaLib + ArmCcaRsiLib + ArmLib + ArmMmuLib + ArmVirtMemInfoLib + BaseLib + +[Pcd] + gArmTokenSpaceGuid.PcdSystemMemoryBase + gArmTokenSpaceGuid.PcdSystemMemorySize + +[Guids] + gArmCcaIpaWidthGuid --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103569): https://edk2.groups.io/g/devel/message/103569 Mute This Topic: https://groups.io/mt/98495978/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103564+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438705790147.5548661976046; Tue, 25 Apr 2023 09:05:05 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 755XYY1788612xYSqdIkt40T; Tue, 25 Apr 2023 09:05:05 -0700 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.83]) by mx.groups.io with SMTP id smtpd.web11.83459.1682438703836636679 for ; Tue, 25 Apr 2023 09:05:04 -0700 X-Received: from DUZPR01CA0306.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b7::16) by AS8PR08MB7815.eurprd08.prod.outlook.com (2603:10a6:20b:529::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:55 +0000 X-Received: from DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b7:cafe::4e) by DUZPR01CA0306.outlook.office365.com (2603:10a6:10:4b7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:55 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103564+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT016.mail.protection.outlook.com (100.127.142.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:55 +0000 X-Received: ("Tessian outbound 3570909035da:v136"); Tue, 25 Apr 2023 16:04:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4333d20a7cb2c8c1 X-CR-MTA-TID: 64aa7808 X-Received: from b6c820fde953.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 581B0BF3-C3FC-4118-9EC4-B5ED49DC3A5E.1; Tue, 25 Apr 2023 16:04:48 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b6c820fde953.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jtD+ot+8W9LoWJc4hA63+9L+l/FWZWMiHvHpdWiUjNAbeL8eKk0SBAgeKU5A2/BL4LBMd7xXUp8oY4/fOBrwIu4gtn+YPDvoa1E+VewLjOf589rQBnOSwQhMaIOOqxNqHRGdhkRpaEh9oI0FOlrHk6lkbzk6rrQm81LsMB6rxUVFN4zZRjOCIe6Wj6W6+fGdpdWkMP7KdiWjx6A9nVE9AIXaFwgNqC0jp7a/ReqM8GGXkkvgRRg2kVYm0o6jCzIYhRl/ouJSlDpP6fNS1PnXkjZ6jl/uy2U9muBZYPj4x5GhPtQXH9sXPLJUxRM5iQn2t/n1CIZr/57CAe27Gt//Xg== 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=2R+Lu8sFq1r82tuKRe1bNV1i3jws/WkEKnuXk8wsZ/Y=; b=U9zF2TKUX0OyAyheg68N1TXMtGIkaqpDFfdtgOCCRdhveIDsZl63CsIFUd9G0/J9bYZ0isRXKoGI/UMfRmUhA1fbBVpi2DaUywRSj6JygJ92M5xf+bHVmswUfGk9IyQJIxAH6XXQxtWsDgYPw0rT4Lx6r+5wuuGtfrVNzA6kDdMrBka+P0L8vSb5bl4RglVRR4r9N2N95uwgZAjjJS17NP06ir3aJ08ciabkesbKrmTVogsGcO2COCcL1sbwRIELaKz59C7H9WUThxgYLSWRwWST0ttbqDTEJUbijxEkdyy+sX+cXTsQoYX695JP/MPywPtbFpyMneDDagL54WtVgg== 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 X-Received: from DB7PR05CA0053.eurprd05.prod.outlook.com (2603:10a6:10:2e::30) by AS8PR08MB9314.eurprd08.prod.outlook.com (2603:10a6:20b:5a5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: from DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::a4) by DB7PR05CA0053.outlook.office365.com (2603:10a6:10:2e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +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 DBAEUR03FT010.mail.protection.outlook.com (100.127.142.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +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.23; Tue, 25 Apr 2023 16:04:43 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:43 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 13/30] ArmVirtPkg: Add NULL instance of ArmCcaInitPeiLib Date: Tue, 25 Apr 2023 17:04:11 +0100 Message-ID: <20230425160428.27980-14-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT010:EE_|AS8PR08MB9314:EE_|DBAEUR03FT016:EE_|AS8PR08MB7815:EE_ X-MS-Office365-Filtering-Correlation-Id: bc93916a-aa86-46dd-bb26-08db45a6cfa5 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: xjDMtpqDoGYWZ5BQBksdKkw+dos7F5QQXJkFUIk/FHBDzmAw6H7FgpxF4+0dCPSO8wEo1MeQgkFdw1wvJihKrEKfx9BL+UsSh1nanMpbjhLBG8RyMZA+pfzU2mEekh24KW945xvMxFc1vrocI1T3HTrYCwz24PhWd/fPjz0LloXjnWNUie+nBKOUUwA5I40IxxOF8OYjbeBaYHAKI81NADG4Kbm2mvHXd73p6IKWhbg89vR9yRF3obIStCvFnxBcQvobYa51Q5xocYkVi84CWDohGuRX+3N6QxwBTeaR2/IZ0i2Gz90+aoueswDkgssmnjm+405xzBXkKlf0GJ8Of95kJqNpp2q8aHCipefFc+Gf+0TnK8npUIx84q59jVskoUbERc+h/NvMPPhRMBmW65jfP7NFzJWNfcA7zThte3MHHJOkXaa+if6+2Iql6gt3f6dDPipILqSgEciuQCepuwp/8r+++51fmPsEt7V3AnExp/MrrJe6KpvX8aX2v39LKUl5hHYPQe565iD0P6Wm14JMKgemI7HJCysTT+FQYmuTXxVsNZVkekOeQsf40Xg+kmNmhS7+rYE1EBzMus0XcmpqIO2pNaSNoCJvPpLoBKNYLWlfwOLabRCt3fzwaECgmCBtJxXQ1cbRyFvxz8Nc58lF+AZLBNary1VMRlcxUe5bNhKpQmSYjyHnGkd9i1ksZ/AqxKfzk3nQL+dCYaXdbNRmxd9Asil3ZKXU5TRh8LKulsgidxds8vm7oTXb2EQyx0nkVrxXiQTQra16aSYxYw== 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:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(36840700001)(46966006)(1076003)(26005)(40480700001)(426003)(336012)(2616005)(36756003)(34070700002)(83380400001)(36860700001)(47076005)(186003)(82740400003)(356005)(81166007)(70206006)(86362001)(70586007)(478600001)(6916009)(8676002)(8936002)(54906003)(44832011)(5660300002)(7696005)(41300700001)(2906002)(82310400005)(4326008)(6666004)(316002)(213903007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9314 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2cd568c9-22bd-4206-8975-08db45a6c990 X-Microsoft-Antispam-Message-Info: a9yxuAt77b9Kp3oU7masSX+bRJ1d/Ej6qSPprZZ7gVAUXB2du/w5UVDI+GAVRRNnAzORsZsUXQ9pWfJEPAOhvF26WMJMFalUtJ3rTWhxqy4JNN+bd+cggfWsqjIC+U7DbrHgaonxZsh/koVnbqD21eteFKuOBVuiNJT8bE3Crm4cRbDXsn1X29BvzWd/rmYxRg9iJ+bBIqhaIhhjCXrULBHIwdR4EDrnak/+aGcBuwK3vHn7Y2TYafolATLnvM3KeBJVjXh/sSV5B7PEFKdK91PWWgi6bUoEJF6KgVIPOB2+Herp6hqJO8AaCukk4NZpnpQA9yFHDAMMB9XZnWN7lYYsqHYiqvXC6bM++haYbaPV/RqbWmJnZeYDQgyabEwK+O99gF1w47VFHsG1eOuV9cpoRtT21WEfr5BKbY6bY6y9AxZFCp2USBycIcvznP7biecSglQ5j8n9bicaH+LdmP+qDww+cxnO2gurSP/YQjerRTPfQ1Nycbax7WQedLDA3PClhj6RZTHS17veiIFCTdu1KQjtaGl9NDnTdY9UqUt5vWxq5rndnR/uzpmkv2e7iZ8gkqQPVGSbJy1xMyyAA8jiCoe/tJ3kaItSB4AGEv+L5pELk1+lVgPpY/9vsmQh2h7oGcQUpy22nzaeVl86Uh4ZlnbUvwSoFBHZD4szFqo5nJrd7mqy+Hh3nsVQ+YfCBO2997z7w8zQ6mJz61uu/tby8NVsmPNr5ypnmSHG+mCHh6MOfsXdGAUJu+OW0AsSAEUOaiU86TOcG2o4xyiqbA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:55.3533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc93916a-aa86-46dd-bb26-08db45a6cfa5 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: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7815 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: 0gaWTEuV5ZjFKorIrqXRtnqXx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438705; bh=4Lj4GBV/VoEaFLHMpClaysXa/uYe6Q7xbIYcahYxGh0=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=fu0aG60kj8xgO8JcZEV2b22GZFiQgZfUPemQ58KqHLjypmEdHtOQc9AnoIlEnuMR+41 STZgm7d9rZm+8wClnOBUiSjpej1g2Fk21GmkTWphPBbNvmIUT218XgSKPPN34zomPcOzW 2R1Cd0xKhEsIM+q84ZBZcUkhFjBjcaButHg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438707642100027 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a NULL instance of ArmCcaInitPeiLib library that guest firmware for VMMs that do not implement Arm CCA Realms can use. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirt.dsc.inc | 2 + ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLibNull.c | 59 ++++= ++++++++++++++++ ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLibNull.inf | 27 ++++= +++++ 3 files changed, 88 insertions(+) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 5b18184be2631ce6d158b471c055af9e6e07f4a0..409749297263a13696885d17c6d= 5554d07c195e4 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -189,6 +189,8 @@ [LibraryClasses.common.SEC] PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/Pei= ServicesTablePointerLib.inf MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAlloc= ationLib.inf =20 + ArmCcaInitPeiLib|ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLi= bNull.inf + [LibraryClasses.common.PEI_CORE] PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf diff --git a/ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLibNull.c= b/ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLibNull.c new file mode 100644 index 0000000000000000000000000000000000000000..5b606208dbcf4f0494cde79dd89= 23ef80fa0137b --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLibNull.c @@ -0,0 +1,59 @@ +/** @file + Library that implements a NULL implementation of the ArmCcaInitPeiLib. + + 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 +#include +#include +#include +#include +#include +#include +#include + +/** + Configure the System Memory region as Protected RAM. + + When a VMM creates a Realm, a small amount of DRAM (which contains the + firmware image) and the initial content is configured as Protected RAM. + The remaining System Memory is in the Protected Empty state. The firmware + must then initialise the remaining System Memory as Protected RAM before + it can be accessed. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Real= m. +**/ +RETURN_STATUS +EFIAPI +ArmCcaConfigureSystemMemory ( + VOID + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Perform Arm CCA specific initialisations. + + @retval EFI_SUCCESS Success or execution context is not a = Realm. + @retval EFI_OUT_OF_RESOURCES Out of resources. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +EFI_STATUS +EFIAPI +ArmCcaInitialize ( + VOID + ) +{ + // Noting to do as the execution context is not a Realm. + return EFI_SUCCESS; +} diff --git a/ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLibNull.i= nf b/ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLibNull.inf new file mode 100644 index 0000000000000000000000000000000000000000..f039c7abdb6d5391f792179546f= f9947086fe541 --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaInitPeiLibNull/ArmCcaInitPeiLibNull.inf @@ -0,0 +1,27 @@ +## @file +# Library that implements a NULL implementation of the ArmCcaInitPeiLib. +# +# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D ArmCcaInitPeiLib + FILE_GUID =3D 60686C60-8433-49EE-9F2C-DDC424A95652 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmCcaInitPeiLib + +[Sources] + ArmCcaInitPeiLibNull.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103564): https://edk2.groups.io/g/devel/message/103564 Mute This Topic: https://groups.io/mt/98495971/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103566+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438709119281.1638290248454; Tue, 25 Apr 2023 09:05:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id wPLKYY1788612x63rnMTOrny; Tue, 25 Apr 2023 09:05:08 -0700 X-Received: from EUR03-DBA-obe.outbound.protection.outlook.com (EUR03-DBA-obe.outbound.protection.outlook.com [40.107.104.89]) by mx.groups.io with SMTP id smtpd.web11.83461.1682438706139470385 for ; Tue, 25 Apr 2023 09:05:06 -0700 X-Received: from DB6PR0501CA0002.eurprd05.prod.outlook.com (2603:10a6:4:8f::12) by GV2PR08MB8727.eurprd08.prod.outlook.com (2603:10a6:150:b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: from DBAEUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:8f:cafe::7f) by DB6PR0501CA0002.outlook.office365.com (2603:10a6:4:8f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103566+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT014.mail.protection.outlook.com (100.127.143.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: ("Tessian outbound 99a3040377ca:v136"); Tue, 25 Apr 2023 16:04:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 24c5d39d245a50bd X-CR-MTA-TID: 64aa7808 X-Received: from e05294ede9ca.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F2C99CBD-3332-41B0-9630-314B1B8602A8.1; Tue, 25 Apr 2023 16:04:52 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e05294ede9ca.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cBfZRZC23enVgHsWlbQ47nRzGoxJLLvPpNu9nAbQMm89ebLGfYmVmjKRwVkKYWb/tZqGA7J3a4UJaOUcWfB+hmtAib/oCxLFbhomskloIeksxlMkPNahk6JVkpy/Chux0PMyBz8oraL5YZNH9H3Z0pvsSNMWzFjy9fAB1Bwy7XJ4d241gh9p8uUktt5wc64zaYL075HbtlJ5ucKuDTsPHRnLq4n12Qw3IgrDIiak0sVSeD1PjkXUTCHeLcrelV2f5GmgKVFkCIIlSnQhTYKfGt+jfp9T84+W7EIvxfpk3lkwi74RVqbFsE9GgjGOHq8WJaFvOu0YuVgAQLKwtL6Ujg== 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=LKn0thTE6oU75BE7SJHPd/6Jqw3NgakTracWKqwwDIc=; b=IM+cvcdSUD55wfLPzazufkBqFnpTDv9UBKSY1ecaOxapfVrE9I0e+MUvXQgSGn1oKZmqmzosAnPuju4g1H3ZBp0Jt9XkJiINLndjikvMMuQUjoosj26Y98BLRZjQ8bRmoyhcxD/xoI4czy8wchExqRE+EPKiGm4NIuXJKS8J1zdAS3tFWRwjvIFZ2ScdJ+/Xwe3UxMOqOfOorznDcRxLSVnL2Pa7XOGfnfbBJ+7Z5J+fvy1aiDpIskMb/ZQqm0vTqoLs4tzz/3EL3MzmdQGocl4RWzOH7tAfrgYDoJeGtGPpo99AtZ9FSGhEQapLIF8Sey12LayxIhMh6x7hYVgwRw== 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 X-Received: from DB6PR0601CA0036.eurprd06.prod.outlook.com (2603:10a6:4:17::22) by GV2PR08MB9399.eurprd08.prod.outlook.com (2603:10a6:150:df::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: from DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:17:cafe::ae) by DB6PR0601CA0036.outlook.office365.com (2603:10a6:4:17::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +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 DBAEUR03FT052.mail.protection.outlook.com (100.127.142.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +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.23; Tue, 25 Apr 2023 16:04:44 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:43 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 14/30] ArmVirtPkg: Add library for Arm CCA helper functions Date: Tue, 25 Apr 2023 17:04:12 +0100 Message-ID: <20230425160428.27980-15-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT052:EE_|GV2PR08MB9399:EE_|DBAEUR03FT014:EE_|GV2PR08MB8727:EE_ X-MS-Office365-Filtering-Correlation-Id: bc382d02-c2ec-4806-6129-08db45a6d204 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: RdEH3FezpWjup1WgTNfM0F0ZnKIYCjKCYpctP2WRMlQXDCu/7jQGM+EgLi75juBTUTXKE74Ly8DJ7LuLbFkkdJ/xT+iG+yrbnbk1SJHXeevYl/HPn25XrROQetHqsEgwD1nuZRiVAK30ARDwANMuFgaYR7jnXF3nz/2pHPu2XWlnm0974xupMNj0rNVq66/FSgIKbRbHef7cbWWqxwjty0bqb9Ebq9HzYIigO3wIrs23nzx105/byX0ixaeGbwvq5nCIS7oV6ZLV4hSJEWYXNRD+JAsVhRaAmrjC00vUhJU0OzHN55pZdDUM5EYRazhJGzNfkj8Tk+G/ntWGmM+xrXPSh/ynwQD8VAig2YjHYF/RFE/v3n3GYey+Sr/3WP9O/2k9RveelP6ivFz1uMiXGTLspuALDm2zHJUUBAAf/EDaKMqADZwGySez1aQCudOZl+7uHWvHayKMR92EwRTwOMuOCAX5HWPBVvQ2PW/MEx9mDa0ZKgU2E6p45MsudzNiR0I7AttF6Uneukzj57pLgQUtLGNpmN3QMxvDdkxen4D+cKtT7XeEqUHfmU23fzmQmPZ3vKFXdQeo9mcOfbRsOmWZsB6IjXO+eCCHpvUjeAemW+RD6rv42d59Rq04H2dXVBm3tf4VyIDnMb7DVPOCWUuKnYn7TQj1B/Ud0d9cYYu8zgjZzKS2kSBZiqyynL26sflmGYLznjUxEOKm/JdYwpDyQdRyZr7YkxXakkMud4Q= 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:(13230028)(4636009)(346002)(396003)(136003)(39860400002)(376002)(451199021)(46966006)(36840700001)(54906003)(86362001)(478600001)(36756003)(186003)(34070700002)(7696005)(26005)(8936002)(40480700001)(82310400005)(1076003)(6666004)(82740400003)(316002)(356005)(336012)(426003)(81166007)(41300700001)(36860700001)(6916009)(4326008)(70206006)(70586007)(83380400001)(44832011)(8676002)(5660300002)(47076005)(30864003)(2906002)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB9399 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 3c4b74bf-d5ae-4c6a-f34a-08db45a6c9f4 X-Microsoft-Antispam-Message-Info: ejQezY1keAHkwNvgITEZBnjh5E/jQPRT1TC/P9g5h5iv4NXe4TQqunZeQBGw7aM+kybroVxqJsFlEY7X5GDmb/AOeyU1cJ2wDvjI+QJPDcyyhtN4fFpQ67vOiWnXKSZLOUby+CSuf3OQgdJE9WqEptKgX9mSX/zGIF4UxxKhq+sZIa+UCFQHumXLGkP/JRAWZT9aQf5cyvJgXnBDDsFhIPm1ALxf/C2QShkJ+Z97n4azmopHuMjYpo0DG0iQISRze0sOW3czaJH3F8Vw4qT9BGZle7Ljkdtyxi4a37gP4TT3WQsM2NKusdoJyKHBZ05sVtNVg+YpRJpKlACto7crL8A2WjoEgIbp0qiGx9es1ZZdS4zhFcQQf8/uYAqnRAD/a7CSmFyfFrbxnONuInR1AgymwWv8c8GldRrYUh+2MNIb19/vZ7XPs0IKjxhr40+p5u0k0yYsvZFy13/llbIpT0UulH2DlcTN+b516DEFhwBwN/PHLT/wGEqC2MAtGFIAFACTmrUjf5YEkyQw+UfmqWIq4LNC7Sbx3ddxtr8W0nX+Yif4BW49Yj93SQGKuc1uL0fqDUwJdDjzB3zaF+8VNBdJSTOP3IRQ72gzv//w7hK1q3S8dn2xYmR1KaBHWE0fPlrOiypjZU4G5W5f0L3rJhVt/6OL3DkJebtGcslvjRTD2/aXfl1TlpG+666WcIqzAH1TFkSavj8s5224lezFXvmRBVkYI3MZnDGVFCgo6RE= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:59.3290 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc382d02-c2ec-4806-6129-08db45a6d204 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: DBAEUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8727 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: p0NSstuRHtK2e6iVdVilHgxUx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438708; bh=vaBRuiil42bMZwZzOv4DgSQ7Pp+hmQCzSlEtfYJwwAo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=YDqOCyRmHp1IJW/cxK0ailLVAzKRZl4q6qGkWfTkizGlSqqYTnOou4gYX0IRaIVGiST of6YnnZZYOAfsMJy4Xf8zTarl5dzjL1HeJ9+tES+v0tTQ12SEQnf4nW1DroRoKju7oP+Z O/dfIosbwjpooMakq1eMcAclg2Z8uv6t8mE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438709766100032 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce ArmCcaLib library that implements helper functions to: - probe if the code is executing in a Realm context - configure the protection attribute in page tables for the memory regions shared with the host - get the IPA width of the Realm which was stored in the GUID HOB gArmCcaIpaWidthGuid. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtPkg.dec | 1 + ArmVirtPkg/Include/Library/ArmCcaLib.h | 114 ++++++++++++ ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c | 190 ++++++++++++++++++++ ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf | 34 ++++ 4 files changed, 339 insertions(+) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index c270d4a1ee268fb57a5338fd71487ed54699f496..c61ed9c492e97aa00ba9dbab1a5= 544354b6e7de7 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -27,6 +27,7 @@ [Includes.common] =20 [LibraryClasses] ArmCcaInitPeiLib|Include/Library/ArmCcaInitPeiLib.h + ArmCcaLib|Include/Library/ArmCcaLib.h ArmCcaRsiLib|Include/Library/ArmCcaRsiLib.h ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h =20 diff --git a/ArmVirtPkg/Include/Library/ArmCcaLib.h b/ArmVirtPkg/Include/Li= brary/ArmCcaLib.h new file mode 100644 index 0000000000000000000000000000000000000000..a47e14b507f1bfd1feece636063= eb2ba83357a5b --- /dev/null +++ b/ArmVirtPkg/Include/Library/ArmCcaLib.h @@ -0,0 +1,114 @@ +/** @file + Library that implements the Arm CCA helper functions. + + Copyright (c) 2022 - 2023, Arm Ltd. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + - Rsi or RSI - Realm Service Interface + - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state +**/ + +#ifndef ARM_CCA_LIB_ +#define ARM_CCA_LIB_ + +#include +#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 + ); + +/** + 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 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 funct= ion + was called before ArmCcaInitialize () + has created and initialised the GUID + HOB gArmCcaIpaWidthGuid. +**/ +RETURN_STATUS +EFIAPI +GetIpaWidth ( + OUT UINT64 *IpaWidth + ); + +#endif // ARM_CCA_LIB_ diff --git a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c b/ArmVirtPkg/Library/= ArmCcaLib/ArmCcaLib.c new file mode 100644 index 0000000000000000000000000000000000000000..32cfcbcadea261d0fa616b0e0b7= 5ede47bd0f747 --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c @@ -0,0 +1,190 @@ +/** @file + Library that implements the Arm CCA helper functions. + + 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 + +#include +#include +#include +#include +#include + +#include +#include +#include +#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_STATUS Status; + UINT16 Major; + UINT16 Minor; + + if (ArmHasRme ()) { + Status =3D RsiGetVersion (&Major, &Minor); + if (!RETURN_ERROR (Status)) { + return TRUE; + } + } + + 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 + ) +{ + UINT64 Val; + UINT64 Mask; + UINT64 ProtectionAttributeMask; + + if (!IsRealm ()) { + return RETURN_UNSUPPORTED; + } + + if (IpaWidth =3D=3D 0) { + return RETURN_INVALID_PARAMETER; + } + + /* Software in a Realm should treat the most significant bit of an + IPA as a protection attribute. + */ + ProtectionAttributeMask =3D 1ULL << (IpaWidth - 1); + + if (Share) { + Val =3D ProtectionAttributeMask; + Mask =3D ~TT_ADDRESS_MASK_BLOCK_ENTRY; + } else { + Val =3D 0; + Mask =3D ~(TT_ADDRESS_MASK_BLOCK_ENTRY | ProtectionAttributeMask); + } + + return SetMemoryRegionAttribute ( + BaseAddress, + Length, + Val, + Mask + ); +} + +/** + 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 funct= ion + was called before ArmCcaInitialize () + has created and initialised the GUID + HOB gArmCcaIpaWidthGuid. +**/ +RETURN_STATUS +EFIAPI +GetIpaWidth ( + OUT UINT64 *IpaWidth + ) +{ + VOID *Hob; + UINT64 *CcaIpaWidth; + + if (IpaWidth =3D=3D NULL) { + return RETURN_INVALID_PARAMETER; + } + + Hob =3D GetFirstGuidHob (&gArmCcaIpaWidthGuid); + if ((Hob =3D=3D NULL) || + (GET_GUID_HOB_DATA_SIZE (Hob) !=3D sizeof (UINT64))) + { + return RETURN_NOT_FOUND; + } + + CcaIpaWidth =3D GET_GUID_HOB_DATA (Hob); + if ((UINT64)*CcaIpaWidth =3D=3D 0) { + return RETURN_NOT_FOUND; + } + + *IpaWidth =3D *CcaIpaWidth; + + return RETURN_SUCCESS; +} diff --git a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf b/ArmVirtPkg/Librar= y/ArmCcaLib/ArmCcaLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..7d90b4535d69c12672af5de3d7c= ab63a3cd528a6 --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf @@ -0,0 +1,34 @@ +## @file +# Library that implements the Arm CCA helper functions. +# +# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D ArmCcaLib + FILE_GUID =3D 11C18743-52F9-405E-B35B-D7BE91A26F9F + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmCcaLib + +[Sources] + ArmCcaLib.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmCcaRsiLib + ArmLib + ArmMmuLib + BaseLib + HobLib + +[Guids] + gArmCcaIpaWidthGuid --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103566): https://edk2.groups.io/g/devel/message/103566 Mute This Topic: https://groups.io/mt/98495975/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103563+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438707277994.3024498837358; Tue, 25 Apr 2023 09:05:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RhsuYY1788612xRLXevcsn4y; Tue, 25 Apr 2023 09:05:06 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.74]) by mx.groups.io with SMTP id smtpd.web11.83458.1682438703700974597 for ; Tue, 25 Apr 2023 09:05:04 -0700 X-Received: from AS9PR07CA0002.eurprd07.prod.outlook.com (2603:10a6:20b:46c::20) by DBBPR08MB6204.eurprd08.prod.outlook.com (2603:10a6:10:1f5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: from AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::37) by AS9PR07CA0002.outlook.office365.com (2603:10a6:20b:46c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103563+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT049.mail.protection.outlook.com (100.127.140.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 25 Apr 2023 16:04:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0aab8001de07577a X-CR-MTA-TID: 64aa7808 X-Received: from a748b70d80e7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7C71EF1F-6EAD-4633-9440-9926C055D3FB.1; Tue, 25 Apr 2023 16:04:53 +0000 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a748b70d80e7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R1OtOXdBVd4YIjam/qv18KYeDoaOJ85QrOQNTKfVFvBs+8RT2IHe/U/gC1b9iWRrdC7Md7OKI6MXTu4OAOpfUf0SKTc5F15R1gDWhCcTbkPtBlV0Y2SKkhtbF6XRJ1kC1QbrmzDx081/QHEbMkhtKxPi4ZOoaWx4DggpJC2YAqhKN6o0oDiThzyEfPxlKttSvyN8RTTzVJH/NWyqvy7fuls+dYC2LEzop8CqEuO/Pa74vWIASm38uCr0kIKm/2bvvkGkyf+Pm5B+joYOnuT2/YW1EvcAU8SK+1hL/oo8HZ0xvlgXgqm7BBXDsjPnXq3A2jevPNt8lqthqRwuDY30Bw== 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=oTaRcYhnnuqSr3u1y9YeVNEw403lPfy3Q3ACiN+tsOY=; b=Fpc51WGUhFxunZreORh70efh0GrP3mDC5hKe5zDirIGpWiJSmUDeP7gz0e1ogwy51JqsvH/d33K3GBSvbmNhr5YbZmJeOmlL1amoM+LLcz3m7bjlHwJYUaT/eZgLnxkSAfKi2nNRocmCfTmQj9rJwA4eoXjgsxcpuOzZD4DcMKVR7OCEsFvIEj+rtYgyy3T7YbM1cks2mQ1nOefhZYnSKAh55VeD2+fxluFVYeZC+TBkI75Z0sCobUicJTFPToLe+vXMdgJv+8luq3KQkSHIyiaWtT/0U5MuYEPc0UIyiN3GOevbtQ0UFdrCJjyfN3fTvXJ+qOuGcVHC34hQIES6PQ== 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 X-Received: from DUZPR01CA0050.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::20) by AS8PR08MB9816.eurprd08.prod.outlook.com (2603:10a6:20b:613::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: from DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:469:cafe::c1) by DUZPR01CA0050.outlook.office365.com (2603:10a6:10:469::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +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 DBAEUR03FT011.mail.protection.outlook.com (100.127.142.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +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.23; Tue, 25 Apr 2023 16:04:45 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:45 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 15/30] ArmVirtPkg: Add Null instance of ArmCcaLib Date: Tue, 25 Apr 2023 17:04:13 +0100 Message-ID: <20230425160428.27980-16-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT011:EE_|AS8PR08MB9816:EE_|AM7EUR03FT049:EE_|DBBPR08MB6204:EE_ X-MS-Office365-Filtering-Correlation-Id: 275d1a5e-6109-4196-8360-08db45a6d209 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: 22AEdU7r+KYfmrpDfSx//VOXAJeGGqjaO0rbE3K6/ocoAV8Nn8JwH5KRlKURJwmjgH4KDjalF3aBJEreZ3w0VY48o1RtJjiYa2EuvE8igDVu/q2fdBEgne0vLTQloyDpxB8PS3elcnkfhAh9LcPNsR9VMq7GgNXXstsyFKXZpySs5TZzqfT+2TE6o3zPD3dgAoT16JdRUCzUL2snxXenc6k1sq6m9ub2sLN4vYaXIrWWGYbOnqLaQF8D7YQCaTJQoN0PTPny9DgXuwdvA9qiOZMdipDFr1+ZlkFOoQIgivJ1DwAKbqw7qs5X1JMaEH09gf6Rilm/7jHF6LRPDVCO+BuJLo+wPrS8Xscg2lC8+8TscCol6JRNhpkeIH4yoZbGhHDGB1eSU5wmOUoNJZmyGKeQLSkUWuO9ewCRY9Q3Xi9sn2Ek9oRRQ5IuKYrXOZMvNo7FteuEDaOVweQas3iDwjaipSoJMNOfejl8Fa3UEI6xHVvUMgGTbSIMcWOZLZOf78XVZp0bBgU3c0fhDmTeEAPlqoJ/OzERLNPL4scm+fprAbxE3WSNpCvVNDR1GoeIp5jKVYqQyjckDjvOQcakgX4PTCCmm3yXzQrkJg6aG9U+1wmk5WbzwD1KVxLIFTf8b0GK2u0KgOP1OcFkh4DMLXGKm5RX+aN2Uz/DKQfVCu+GhOA2EGonER3CcC/90yqWT2YkTQYV9JM/1r1iEabt7CvIPX/EPsQQmkOS1WR3AOc= 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:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(36840700001)(46966006)(1076003)(26005)(40480700001)(426003)(336012)(2616005)(36756003)(34070700002)(83380400001)(36860700001)(47076005)(186003)(82740400003)(356005)(81166007)(70206006)(45080400002)(86362001)(70586007)(478600001)(6916009)(8676002)(8936002)(54906003)(44832011)(5660300002)(7696005)(41300700001)(2906002)(82310400005)(4326008)(6666004)(316002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9816 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1a3ca798-f206-4ee8-f093-08db45a6caae X-Microsoft-Antispam-Message-Info: SKESkmvWDmYMmF+fNmw+0gInE0FQj+TwbNaZKi8iw2dxaNaru1RRdFHAN59kA1Q1qMcB1ZhZCpi73IEOVzO3H+++fd9BfhXzIT8cc1kttNW6nwpkR0wgBZ5b5tjHJEFqQx+Xt/1SC0ZPfzgv/KbNuH7/nXOQesFwK7sXdEQo3Cbs/BavKeNSNgpwAL/I6JfmYBh/ztCxIrJYgSSuA0ihXddTK8QZWd6Uyr6Ua3gUymmxWHZxw7mRi46oCy0wmqvKFc1eLVXxFS8FuCFzvSJA0Uww6jupnlbfuQseY65G9XWnjFhphDJULWB/UGQkMkrQa5e0QZUY0aJGIAvi+sB6DncVpBgvvE4UnIa+jKOrezAyWEAWR/sS0Wg/5FaF6GvWJvVnghJ9Hm7Vmk4WePlQRDmnrzbsUHjC2SGe5sLyrmepag4lR4epC0TLMWpof7LeG+N30MMx9Rf60YbFb2tRWMKwHx9h6vzes9iONF/7rIXWT9dFKqvTSWn6Ausqv9DDM0YuTOuUh0IkrG7gCYVPGfKlz6NAZ+NLcFil97+XV085TUaiZazmoGwm0rRXZBd4XJT6dfYbqrsy9j4VyBgWBb54DnVGQm3HLTL+lN9/O/cS9blrJOSEZnJ+SgPh/Y4lSc1zvXVObgD6TFCUsdCT/r/XRYNkS9w+hKIK51P+7Qc0pPYimIiJkOcjmVb8/Gk1ib+Elv/zsFlMBJwSYLQ3n8d3UNJmM7xQypsCOgu1qO4= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:59.3002 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 275d1a5e-6109-4196-8360-08db45a6d209 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: AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6204 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: N1APfxsgimaTz0TiNEnn2XFnx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438706; bh=01J01gTABXnolNn3guFyDqbTkrNb/o+qJqHeDr2Mr0Q=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=opR67APjr3lf5pK0LbRaT6RC68ZB8oG5AVothsNm0xaazDY8YWAbghMH3d8QV/2sBFx 9hvdvG8+oj4/EdWLG4DOcctLWs+yrZoOi8kTiz1OwAtQDkiewUfuW/l7qOLATCpLJR5WI aQkOBYEcZWiHP0PrAuNHM5Pxo33B9KLZ/NM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438709906100037 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. 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 409749297263a13696885d17c6d5554d07c195e4..88dd74e7bb0e1352a8867727a33= ae80498a9ea98 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. @@ -178,6 +178,8 @@ [LibraryClasses.common] =20 ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRepor= tStatusCodeLibNull.inf =20 + 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..e5e645e148d485fc324e060ec27= fbc3607fe8aae --- /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 funct= ion + 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/ArmVirtPk= g/Library/ArmCcaLibNull/ArmCcaLibNull.inf new file mode 100644 index 0000000000000000000000000000000000000000..8f6c251afb14da48db45ba78d96= d1d497e3fe8eb --- /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 =3D 0x0001001B + BASE_NAME =3D ArmCcaLib + FILE_GUID =3D 9E3F7AAA-10A6-4513-A960-B87F4D7DCFC5 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmCcaLib + +[Sources] + ArmCcaLibNull.c + + +[Packages] + ArmVirtPkg/ArmVirtPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103563): https://edk2.groups.io/g/devel/message/103563 Mute This Topic: https://groups.io/mt/98495970/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103559+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438702654260.272090426404; Tue, 25 Apr 2023 09:05:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NO7BYY1788612xEIuh3NGAXE; Tue, 25 Apr 2023 09:05:02 -0700 X-Received: from EUR02-AM0-obe.outbound.protection.outlook.com (EUR02-AM0-obe.outbound.protection.outlook.com [40.107.247.84]) by mx.groups.io with SMTP id smtpd.web11.83449.1682438700894121368 for ; Tue, 25 Apr 2023 09:05:01 -0700 X-Received: from DUZPR01CA0047.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::16) by AS2PR08MB9786.eurprd08.prod.outlook.com (2603:10a6:20b:605::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: from DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:469:cafe::d3) by DUZPR01CA0047.outlook.office365.com (2603:10a6:10:469::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:57 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103559+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT015.mail.protection.outlook.com (100.127.142.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:56 +0000 X-Received: ("Tessian outbound 945aec65ec65:v136"); Tue, 25 Apr 2023 16:04:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 44425aacb0ec7c2c X-CR-MTA-TID: 64aa7808 X-Received: from 36b0111cc216.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 864306D3-B6F6-4A69-BC78-F5F52690390F.1; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 36b0111cc216.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L4mWHZNm3w1GwX3slX3AD1sm5Iht+ejMFF7QFk95lgvffEB1rUXKlP7o7neTvJmwopRxf2jP35rR3RnDAs/xlYPmMMD3b6m4rUYIsHuf9zwPMKkp3LsEG2iNoVXCEfBh4+yWHI+4qQDcJn+9Q/Wfl4g96bb6xd/3VMPPlFNX9anFt8QQbqGpb9+rZJGtbYfW6I/IMQeAKeM4Yw+kwfE1i0k03G4m9bdfLTm42CBPblYiOYap/IkwWbk+kTGG/xTUsW8yURqtTr74XQE3CGhDKTEG6yGRlDrUlbtc3qjrgzAzbdhAlRt60acGp9k0PEoBouPk/ftYujFuiAkkBbV+eA== 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=Ysef8IRGjfpBtVoFx50q53CHwtU7t4us0mKbXDxlNP8=; b=L3AHm6LRLWbGw+j3dp1f/vwJg8IYmaNmzFn+RUCPQfWYk5dTb6VqNCFah/zhCgIoZ7HmMThkHfwKOojHVkvNxufUOK2vvE8/LANHMyFYU/x/W1Jko7WkvbtAxkz9hjpzgJ46rSo5BLYf5kTSXKTdshaFD9qhaFZ4Mi4DniVi/BlT3Jw/DSx5v4zRoJTl1QkOoi8XFqJH034nHL2q3Gfg3SVhGklouy9KJsyKqLDNK9m3FJUG8HdFiWGmUwibgwBc6TpMBHLJKeg9i6tj8gpOWanKEZ4w5m3Eh0hU80aY1ZlDYee3uaxfh861EIfn/8iRx5WCdMfR0SqNQ5b7v66iTQ== 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 X-Received: from DUZPR01CA0110.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bb::7) by PAXPR08MB7383.eurprd08.prod.outlook.com (2603:10a6:102:22e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: from DBAEUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4bb:cafe::a4) by DUZPR01CA0110.outlook.office365.com (2603:10a6:10:4bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +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 DBAEUR03FT054.mail.protection.outlook.com (100.127.142.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:46 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:46 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 16/30] ArmVirtPkg: Define an interface to configure MMIO regions for Arm CCA Date: Tue, 25 Apr 2023 17:04:14 +0100 Message-ID: <20230425160428.27980-17-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT054:EE_|PAXPR08MB7383:EE_|DBAEUR03FT015:EE_|AS2PR08MB9786:EE_ X-MS-Office365-Filtering-Correlation-Id: 8fdb9734-bfb7-43bb-503c-08db45a6d088 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: qFLOs8vYrxm84zi3gm8U5R2FKvNxieZH6/0SCzY8RDz9/daoKO3hr8Pdmh2ydj9GPZd1CNO1eWh5PIDl7qnqWzxlY8AMsbNhC/J69WUxSYprYh4iuTsbSN1whHUrVgXojxSEpWTC1JwdwtEMem1fPdPjSuC37LtHUP6NmRfMGySPT7n60S1jzHDBISx1qQQu9CttY1clba3H4dKJl6nHHtOGan+AdKmIB6AvjB2m96H2RM8Bd9w8jnoWP9u6nupblBicni5ScfBs6thJd4d5XqesySypwqRbf61Mhh/zOMqTBFvQ0CO72cduDVQjBH8Y/kRR0TVUvlc8N2OspBZ3/biSn+M2hFhH84TljzoBg6lItfP+bU3MZ0gPKbGOL36Dtwdu3tkF+aLAP626CsZxtfDcUmj1pELsce7vXIQmad3T2ZkenZrlbxAfXF9oQhGPI30zFNf7wLjgiZMXjqhR9yL2xTCAs+i1mS0IptDeP4PKL6iOZuWYdHqL9LoZ2lLr6yBMBFU5xrrg949aBkYmBsq1dCn5WttOs3oxT1O6fRg1aOdhX2NIT/z7b8DAUx15dYf3Q07sTBVF0dT5MdD8InLglfzt7VmTrBp4DwLNkTPdWp9Sr7HnWKYfRjoC5Dcbk88yuVBnKLqCAuOVdefOOgCJDQXtkfo3FIYfgS4Q2d00+uNk9nhp2c+VImVYCRYFZYUVORnOtcbwsrS16vvZT+N7A0NVWpcGPYY5z8CwX0Q= 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:(13230028)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199021)(46966006)(36840700001)(478600001)(54906003)(86362001)(36756003)(34070700002)(186003)(26005)(82310400005)(1076003)(40480700001)(4326008)(6916009)(316002)(6666004)(82740400003)(44832011)(83380400001)(70206006)(70586007)(36860700001)(2906002)(8676002)(336012)(426003)(356005)(81166007)(41300700001)(7696005)(5660300002)(8936002)(47076005)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7383 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 318f41f6-0eb0-430b-54ae-08db45a6cb20 X-Microsoft-Antispam-Message-Info: ZMdZu6jjklwIEU1qQGfeBcEvDQoSoFsDKRJqP/oedOiPL32mqhgwjKWQs+R41ZP8Abo1GbGuMq4ymfnq6HzEbsOC97JXMfigiE0+ReO9+JcTgmc+jon80OcvxMk9HvwK2ECLh8nyMGj3JApvp3ElOZbH0BCvg+sQS/HwlxpmwYfljLPhUXmdauFzS5F9ozKoEdt+3IeGtQaJ3yxrjs3KszRPrqY056WU1UrQQTZOrwdB31YkzQErjlj3DnZRyAOE3hIc46D0WCqxexy5MqT3D0/6uSxFt2iUDgtRFMU0DLcsgKhIRwjZOd37q3/cJgyMcw9eeAFwuH8KkUuYYMt0JDiMmbtHXq563tcXel2cwa5IWWZyf0tfoWcSbwwap/o4GaidujFbWIgY8X8Avg+TAeVGGXpalK7DOM1sr1nwsPvFaBSx1uwx/KfZFMsDEi7wJSTzcq93+xRyXZxNTjyE1huW+LYWzCU1TJGV+TPFahdE/u40v8speHakWmQEhxoqMPbcgWXR507aO7fc7gII0UhKu6M1+RXOkMwHu6JbOZBid8bWmWwmG11d72FWdVkByBfkVRa1LCQekTNH3/sedNtAreZA0MSaF0g3qyaqhyVOfRCYENqAWP7S8yn9FV/VbrpzEKWllViaPYURnxiEAFXm6GBMVKDOgzbK3RdGWi+oqyCYlMwDSd6ezrfKeC90Od/6/KcdDeTMhboAXhQCIvWO0ypPFh6JEV3vnZdztuE= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:56.8382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8fdb9734-bfb7-43bb-503c-08db45a6d088 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: DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9786 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: uKhKlG0oZ9VngDsJhLadQhBPx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438702; bh=zTJTsurSC+IZGje0iMGK0ag77OfiRZYVrk33iDwbzJ8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=VO8nH1i2F9vUF3/lRf36avyZfIFOq8G9sQDrXAdKVSH6s4xYQQj9Z88bK8tHixR2Snc YDcaXonPv+neRi2cwZpQfjcIsXqT0KXIJAnH0MkR6PQ+hsH4beJH86KQkmR3DAlSwSJjW Q/OWa9aawxU8fSPYbCEbQAfCkUyrXRz1PLo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438703403100009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. The Unprotected IPA space is used for sharing memory and for performing MMIO accesses with the Host. An Unprotected IPA is an address in the upper half of a Realm's IPA space. The most significant bit of an Unprotected IPA is 1. Therefore, the page tables for the MMIO regions must be updated to set the most significant bit of the IPA space. To facilitate this define ArmCcaConfigureMmio () that can be called during the early firmware startup. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h b/ArmVirtPkg/In= clude/Library/ArmVirtMemInfoLib.h index 7812c2e28657ca9525880dcc0d16d7bca90cc334..b70a96ed923e8c2654e51c97140= 74744a4d5f0c2 100644 --- a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h +++ b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2011-2013, ARM Limited. All rights reserved. + Copyright (c) 2011-2023, Arm Limited. All rights reserved. Copyright (c) 2017, Linaro, Ltd. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -32,4 +32,21 @@ ArmVirtGetMemoryMap ( OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap ); =20 +/** + Configure the MMIO regions as shared with the VMM. + + Set the protection attribute for the MMIO regions as Unprotected IPA. + + @param[in] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Real= m. +**/ +EFI_STATUS +EFIAPI +ArmCcaConfigureMmio ( + IN UINT64 IpaWidth + ); + #endif --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103559): https://edk2.groups.io/g/devel/message/103559 Mute This Topic: https://groups.io/mt/98495964/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103560+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438703317368.5004352757662; Tue, 25 Apr 2023 09:05:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DNHFYY1788612xG17Utzlj3T; Tue, 25 Apr 2023 09:05:03 -0700 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com (EUR03-AM7-obe.outbound.protection.outlook.com [40.107.105.65]) by mx.groups.io with SMTP id smtpd.web11.83452.1682438701803303254 for ; Tue, 25 Apr 2023 09:05:02 -0700 X-Received: from DUZPR01CA0109.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bb::28) by AS8PR08MB10170.eurprd08.prod.outlook.com (2603:10a6:20b:63f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: from DBAEUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4bb:cafe::b6) by DUZPR01CA0109.outlook.office365.com (2603:10a6:10:4bb::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:58 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103560+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT054.mail.protection.outlook.com (100.127.142.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: ("Tessian outbound 5154e9d36775:v136"); Tue, 25 Apr 2023 16:04:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 42a3261a6f0c95fd X-CR-MTA-TID: 64aa7808 X-Received: from 5d84adee9990.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A7B430C4-D6AB-4523-9436-C38AEB22FE01.1; Tue, 25 Apr 2023 16:04:51 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5d84adee9990.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VIYVahnaAvOeL8BTiWOmlAQZo/ia+/fQu9knj+fZlnFhtrLC2/i2cyizf8vNE7N2wOHzTPxRgDh57pZmHt6dtQJFM3fX+kgwOQTBbuyUQoOdyT9Gmf3jHWLhHozi1nqhira8X51zw5+x+QpD2CTvrD5Es3SHHksYbU5DgWi10mliFxcybX1ISGqq+ZyvonKKbMrsQBobHl810M5mNC5SeB81mZhZqDo2FDdcSIowH8wiwIDw740HNP+/bXLBZHIcHJeNgKLxky6jwLJbL3p9h6cqaJYn9ukYi9qqiEzPyDoN2znOZN5LPkIPzAuCsaMPbNOikWDz8xbOq3G6rVJC2w== 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=T9ouZGy9tJQSBvQqEyj9Xbi58Z8s6Z33UB7fp+EPUH0=; b=IBHniDarDIuHsbeEzkU/cyBguW/7vvy3Eo37qVR/JM+VIKrys5aH+lUvMw+5+HomM68PsVdZgFwBE49ZSXyVAiTGogpfWdGcb+tl7TN0mMjisH+malUBj4hbP7KRPpbxqEcJ/L6e4qbXdTkwO4TYZDLI2FScZRrD0D9bY+s2I5dKYaQY5xIEBks92BXaPbxvxCtSl8c8o+spn50L6Y4XX+kRpOxI4jjP8uXX/TJKKCY3jSFJIUqv9YlDEr3atIqzG9+oSoIijxOGAgdRE+NgrWE7thNRVgBGvHNjndQV3jKlkZGRya8Q8+4ey0mr+aMawfGkVwNztoAR8+L+jQg0/w== 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 X-Received: from DU2P251CA0009.EURP251.PROD.OUTLOOK.COM (2603:10a6:10:230::22) by PAXPR08MB7335.eurprd08.prod.outlook.com (2603:10a6:102:220::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:48 +0000 X-Received: from DBAEUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:230:cafe::25) by DU2P251CA0009.outlook.office365.com (2603:10a6:10:230::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:48 +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 DBAEUR03FT019.mail.protection.outlook.com (100.127.142.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:48 +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.23; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 17/30] ArmVirtPkg: CloudHv: Add a NULL implementation of ArmCcaConfigureMmio Date: Tue, 25 Apr 2023 17:04:15 +0100 Message-ID: <20230425160428.27980-18-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT019:EE_|PAXPR08MB7335:EE_|DBAEUR03FT054:EE_|AS8PR08MB10170:EE_ X-MS-Office365-Filtering-Correlation-Id: fb30aa70-b2a9-4eae-b3b7-08db45a6d151 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: RC212oRP9+OlD9WEsG+ERJRDbYmxaAAC4nL5Ux2NK/N7PJT/uYW58AcLmqzbHXmrzLN6jHRjqgths6W0A2RGao/BfNADSdkrYylV5piA/mG+OS89DKiwuBG0kpw2cJA69wcEEDDrD1MtDL/FW06lKWf5x3crNUMbkVcVO1i6efgvVF7CzlN2AKjySjViX/SypaQ4LB3DEH39UNazZJ9phyM7CwX2FImo4Lsrjax0vVEvuH2CL4cmN7ohZ+9NiHBOiXrueHiDw5vsjarP9uPpBwwnmYd+ONh0FJ/qiYeKhwJ1yYK8ds1pjy/CDYwjuvfdli2YIkqA3bnlOG53jPAUPWbQyFBCtch+mdqP7qpWWLAxMjOfhJBGIR46vIGLGSuFtnYE+kTtoWPEGuaz7dWRvrFnqwwiW9Iq5q2vzXb8iFYT5nguMhoABewFt2Wtt2gB3sSefzazMqrJlH2j3xH6mTmJPzCxTnK4ar6/id7Xl/RoqaOTI5Am64XHZXnNsGOgtuS3RJiUHcxUH36vqThl8xMYbzKnIzHwd+OISnPMC6ngemWApVSv8sjiug8dMgauyqXmOenYPDoz5MewGaiwGzLP8ZFkxoHny7L0SfhcCqttucikZsDQkS5w/atn8NnxsaolnChHr2Go3fED0kvMMRdhMvYXndi57LiHByPi80vQEu2f0d3g725NSrF/BeQPlHbQB6oGF0vbO1eUFy8gGrtF3qGFKg4zX1QzQef367E= 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:(13230028)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199021)(36840700001)(46966006)(36860700001)(47076005)(86362001)(83380400001)(26005)(186003)(1076003)(336012)(426003)(40480700001)(2616005)(82740400003)(356005)(81166007)(34070700002)(44832011)(4326008)(6916009)(5660300002)(316002)(8936002)(41300700001)(8676002)(6666004)(7696005)(36756003)(70206006)(70586007)(478600001)(54906003)(82310400005)(2906002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7335 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 353e4e72-01d0-4eed-a5ca-08db45a6cb7b X-Microsoft-Antispam-Message-Info: 0ytS0NLIN+jgtIg6QRvHRsh0yzOPvE3pfsSgk3RdMEHcx2f4Ke8yaNbEk5TLxftKhpTuaUoiYp7/n/aXrrhdul1qm9c84yazWPXQYu38R+kn0qzD0B5tQWH4WT0EkDyF7WiNVSnG1qP7JXqfBVGsHe4RcrX9nYx8bbtXCzcGboVPpTbxIQmLq9sq87zU96HaZnaB+HM5gAXKlUy8Iv7htFGSd2thtwZSpdpnCBlY66MS+tl+OjO4kOYew3kIq1p+nKZAb/I1WAB0/0ruR11gyOQNfWQHr9vQjUHuZkfGKPzUpiu4NVA/0vBi1sHtoYUpVfNVqcLRymezQy5Zz1tJW8HHjetLp4OdyYg6TuxVGIBmlJaSi81LM2dlAeboJrtxKE7+SCPVy5ANE1Tv9mDPfyJZBLJZaiVTdyM2YSRclDOM8sv8jEaJQnU6aFb6rIugMRMy7100uvvgQx+jtdajKOZEb31+ojrCqCRDfzlTqwlvXT2TNDY2h75FKShCcK7nMH6dEwb/gJHbqMfWQgzAEkvWogd5oL/Xh2sQLOa5UHTHVEAAIqPmacxnSUmMi/QuCxjjwQCvWB9fU/sUWi1Id+jO8LA502mBTO/ejHmhSPyt4ULNvuKE7MS8LUnmxOxinCLaPKrrlGJGW0yFvYd0hh7Xobfdr1gGFlNkKnI62gwMkD5QTKCJP0qIeqCXJwTMDKszC+/xWS5HkhxZ8CzY8xs7EiFYkEUON+EhHoh9ET0= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:58.1581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fb30aa70-b2a9-4eae-b3b7-08db45a6d151 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: DBAEUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10170 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: A9ccPox320Hg8DGz7IxbLzvzx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438703; bh=xt/pZ3NEsvBhzC5kZnGIC65LsrQuvu5jDpYxmXtx4FM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=aEoH2gBk/sWP7f0Pit8nrQA8miJca1rWrBwq80Rw46Zrx/TO9CuABl4dgHtz/Rfk58N 4rKOOcAcQZdg7VN6Hi6hjP0488/5FCKid7oK9Kf4zavgxC1TIIWc4ejORQEQBzvAcFvKv 7y+9V1ob1WJfvlJrQvgZq01aArrjfFrUfMc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438705518100021 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To support Arm CCA, a hook function ArmCcaConfigureMmio () has been added to the ArmVirtMemInfoLib library. Since, Arm CCA has not been enabled for the Cloud Hypervisor guest firmware, update the CloudHvVirtMemInfoLib library to add a NULL implementation for ArmCcaConfigureMmio () that returns RETURN_UNSUPPORTED. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib.c | 22 ++++= +++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib= .c b/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib.c index 98cc13870599c10bfab5029de9f7730a67099b72..c47ddc4a16caf9b375561762771= 8789098aa2f26 100644 --- a/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib.c +++ b/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2022, Arm Limited. All rights reserved. + Copyright (c) 2022 - 2023, Arm Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -241,3 +241,23 @@ ArmVirtGetMemoryMap ( =20 *VirtualMemoryMap =3D VirtualMemoryTable; } + +/** + Configure the MMIO regions as shared with the VMM. + + Set the protection attribute for the MMIO regions as Unprotected IPA. + + @param[in] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Real= m. +**/ +EFI_STATUS +EFIAPI +ArmCcaConfigureMmio ( + IN UINT64 IpaWidth + ) +{ + return RETURN_UNSUPPORTED; +} --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103560): https://edk2.groups.io/g/devel/message/103560 Mute This Topic: https://groups.io/mt/98495966/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103562+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438708150450.7857575915465; Tue, 25 Apr 2023 09:05:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0PBnYY1788612xPc9ypjzN5j; Tue, 25 Apr 2023 09:05:06 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.51]) by mx.groups.io with SMTP id smtpd.web11.83457.1682438703669237701 for ; Tue, 25 Apr 2023 09:05:04 -0700 X-Received: from DUZP191CA0014.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4f9::18) by AM9PR08MB6644.eurprd08.prod.outlook.com (2603:10a6:20b:30e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: from DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4f9:cafe::64) by DUZP191CA0014.outlook.office365.com (2603:10a6:10:4f9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.54 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103562+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT032.mail.protection.outlook.com (100.127.142.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 25 Apr 2023 16:04:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 76417d1426b32e40 X-CR-MTA-TID: 64aa7808 X-Received: from fb23f9e00199.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FBA2B046-C57F-4D1C-B40E-85BB82FAAD8F.1; Tue, 25 Apr 2023 16:04:51 +0000 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fb23f9e00199.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fnkyW64vyIIzw4L3VReK7G2E+MPNIV31VmGnXdH+3G6N0eEyCvKDNqECjZ+572kHmafs6EuVrh1efUxjN8Vk7eoZp7cDwoEASJEdHcRdJyjXzZrBgFhOTBI8BYcC9T5rrD+ekhXHFQ1IZ4B41MCGp0kzcLTpG2c7ru6so0+Y8+3UlI7SfEt6h4f+dRFxEl84nZSkaaE6IRDF1O38Lt6QL4No2RS/hwwmDQBcEoYov9FI+jDrgzEVxatsPBIHhE9CndxDhM0Z/5+YnmKiqBPRO0zVYEO0fG5O3jz8gsRgWvARFt6bPwldRMZ7ZkIrX6AXT2gl94Ieguyk7fFrqTT0HA== 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=igrnDonPscTyZEBYVUM18Jmq0DkCMtKvJ3Snzfpy1Js=; b=glQt4KaP1svIx5j4+Lg0/FtlH4PzPfel1ndRnn5obCTHGmVuiLLJ6FEyEQhUy+w4aB/bGxng2OA+/Ol2gKsRpBJMsuGoidZAWA6B79WKXzIyTmexPGmRHt5O63EfpfgNa8QKIIZW+iNIbjLJ8L+QctAQPXXXSBbbSIHfLK74maKT1tvItJFX3j1fKfsrL4WMzC556llC4wSh8C7K7Tj6Dw/0/cBh5IGcfQzLI8OkO9Hvvzunyw3hBgk3AWmFT2JHtUWurxc0VJAXZ0XzN7F3JXaoB57GYEz+/c6q8lfXNJsxvTTBV4u1ucfAxpx16fkJrMQw12TeDT2I3KWMcv9vyA== 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 X-Received: from DUZPR01CA0079.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::16) by PAVPR08MB8847.eurprd08.prod.outlook.com (2603:10a6:102:2fd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: from DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46a:cafe::fc) by DUZPR01CA0079.outlook.office365.com (2603:10a6:10:46a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:49 +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 DBAEUR03FT022.mail.protection.outlook.com (100.127.142.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:48 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:48 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 18/30] ArmVirtPkg: Qemu: Add a NULL implementation of ArmCcaConfigureMmio Date: Tue, 25 Apr 2023 17:04:16 +0100 Message-ID: <20230425160428.27980-19-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT022:EE_|PAVPR08MB8847:EE_|DBAEUR03FT032:EE_|AM9PR08MB6644:EE_ X-MS-Office365-Filtering-Correlation-Id: a128df0c-f3a2-4712-1a80-08db45a6d1e6 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: lETCth9NHvNbEyJOiDVaxTH+AmRG+UOevYScxt/xDQ0ZxVKueQpR92hHCdm/iRz+VTH6xXJd1x/kcL6Ge9q7uzxDeRtw3Wqm5lx5joaTu4c57ZzyOQ8hSNA5u4pOY/r0HclExr/+APdpXkIAZzQ2fyY7j+Sh8upJyWKxekeryK0vaBR8Si4EcIPtYdxvBKBKx/9t5EIueSUX/FrAAVP+m1zJWCD/NrLtoF0qu3B3QXfH/6meWCCR2ckr36kvkic0B8KwU5OdDppLG1lKFIkpoPWOWvWXk8BaOX1+9L/HckNvOmWIMx7v0kGZD9G452eaKOqOvUFU5t+e1DZjcMdRyKePv4kKi/YBpbbJ8ETtMVSuy+5DLFRK9SmQWbmJSqNAQ0WJR4uLsje+XHAhAEX2U7SObMKC57YzeuBXOvHlKA1O98nH9vkYPe6WUtvdzMi1/xaaVGgk8JinYRbbB4U4LRCX5McMrZMmbI24a6EVnuk6RzVWLsOoc7dRG7PXK/hxfzGJtyKd83dJaoglj1n6TdUzmFSPixjLcUR6pPxyW5JEMkAPT6pNQJja/EWSiQhoEthaVAOjaD9+91KREU6x/nIHZvEMANnQGVy/+jz4/cxnvD+1lxsc8WBnfqbAacSt8SCPyemyZTNgQv3varE9eLzJjSL4Zir+roj97gt8xFetCeMILuy2p+AA3ESYoo/Duw1rx97+uKwugJmv70/Z/jI9+5dB298BjQrdlg0V2KM= 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:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(36840700001)(46966006)(316002)(82740400003)(44832011)(6916009)(4326008)(81166007)(41300700001)(5660300002)(356005)(8936002)(8676002)(82310400005)(36756003)(86362001)(2906002)(40480700001)(7696005)(6666004)(1076003)(26005)(478600001)(34070700002)(2616005)(36860700001)(83380400001)(47076005)(336012)(426003)(186003)(54906003)(70206006)(70586007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB8847 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1dd87fcd-99d6-4de1-b9dd-08db45a6cbfd X-Microsoft-Antispam-Message-Info: 6xxOTSOVaU5De7qxBI6D0+CcYI1xHzs/Zu7blnJB1V27FJejjf+3VoWJfo1iUGoHJs1EsxPbW4GY37mAbGzdpPlx+um30qepDGjIAajcTp67aXaCWhUc3ELG7aehjqBbOZ/+Zf1i9z1I/xRc5mADD0zJiF/7LUPfFYW72Gw9POmp3JkxUbt7jJNg9vhnZugt6+KvPNPCTMpShT4QlUtl7m0KEmvh0lOZgbMqfhI4yE6AljldyYSNrUjXr03pKJHxQY14cPNLy31caQm9lT0bSjibSfgITCEZ1GHJE1r9idJxSkK42uGXSJ8bXUHJmg8CTFNfxhRNxe1qEvlTVVu7w/taXbjSscYudXLdRKZMC+4iLWil5aN0Rhy61RmexXByfrE5vS17m58Z5yR/U1/ppqeiOafJFKUMyDZKuplL/yFYykTYB0ZzZ+Sfc0Vx76hBKUtSUFDnw/L/7B6Eufh8+GFBqD851iucYSWOclZN8lvfzzwGvFQNtlvdc21FZm968/w4X+nflhgqZrlH8xNK6vOpkl/YobYKVuXRRG8pK5uPxYsm7vEfuZwYYpT7tACS0GwAKt1d3ReYdUz8z+id3Z3PpB1DacYn0gjOr+nAgKQeJ2mKfIKH7wqRBpOGH5eSSHn1KCq5UMtjIeeR9MZfLgcpMsPdrl3xHSNM8Dyo3Y07ERL8jUTuKZyhUM1c2PbRUfSX/2l4FYA9Tf34QUUZrMh6n+4teDXeGRn9zosAETc= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:59.0994 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a128df0c-f3a2-4712-1a80-08db45a6d1e6 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: DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6644 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: zAjWa8wObJO4nn4DWWRrxadxx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438706; bh=z8R8aCLOcnYVSGopyjKsc2ZyjQ9R6m1FtfUSvv2CI7U=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=QrjvFsiVcwiIqxjL7F3QSsn9ky2PS+hlek41q83+QdKvO7wkNPWcFPOVZkjmMzuZ4o8 g9fNIz9suGxp4whXaiqRsFHg49WybKlBTu7m+U+XOXsQlZ8BbxIL2Dhrs7PNlp1rY/8c1 +3a0nWCnCi9HsKLMeO432WJUiNW3VEtpi/o= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438708879100029 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To support Arm CCA, a hook function ArmCcaConfigureMmio () has been added to the ArmVirtMemInfoLib library. Since, Arm CCA has not been enabled for the Qemu guest firmware, update the QemuVirtMemInfoLib library to add a NULL implementation for ArmCcaConfigureMmio () that returns RETURN_UNSUPPORTED. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 21 ++++++++++= ++++++++++ 1 file changed, 21 insertions(+) diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/A= rmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c index 23bd0fe68ef79d98c0b934b73b61c098bc04397b..4db41f5fde3d35182692269bd36= 45b0e0bf6dc9e 100644 --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c @@ -1,6 +1,7 @@ /** @file =20 Copyright (c) 2014-2017, Linaro Limited. All rights reserved. + Copyright (c) 2023, Arm Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -122,3 +123,23 @@ ArmVirtGetMemoryMap ( =20 *VirtualMemoryMap =3D VirtualMemoryTable; } + +/** + Configure the MMIO regions as shared with the VMM. + + Set the protection attribute for the MMIO regions as Unprotected IPA. + + @param[in] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Real= m. +**/ +EFI_STATUS +EFIAPI +ArmCcaConfigureMmio ( + IN UINT64 IpaWidth + ) +{ + return RETURN_UNSUPPORTED; +} --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103562): https://edk2.groups.io/g/devel/message/103562 Mute This Topic: https://groups.io/mt/98495969/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103561+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438704758154.29518642437745; Tue, 25 Apr 2023 09:05:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id yJm8YY1788612xwzUPbQmxSE; Tue, 25 Apr 2023 09:05:04 -0700 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com (EUR03-AM7-obe.outbound.protection.outlook.com [40.107.105.49]) by mx.groups.io with SMTP id smtpd.web11.83455.1682438703439645671 for ; Tue, 25 Apr 2023 09:05:03 -0700 X-Received: from DU2PR04CA0026.eurprd04.prod.outlook.com (2603:10a6:10:3b::31) by PAXPR08MB6431.eurprd08.prod.outlook.com (2603:10a6:102:157::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: from DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3b:cafe::a4) by DU2PR04CA0026.outlook.office365.com (2603:10a6:10:3b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:58 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103561+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT036.mail.protection.outlook.com (100.127.142.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: ("Tessian outbound 5bb4c51d5a1f:v136"); Tue, 25 Apr 2023 16:04:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 53631f6a375f9944 X-CR-MTA-TID: 64aa7808 X-Received: from 83be432f7823.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 88FC8230-DB6E-4668-88EC-C8E23039C3E3.1; Tue, 25 Apr 2023 16:04:51 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 83be432f7823.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwRF8FASqGQEZxYjnSBTO74Up1ZcJYuhvvicqMLHpjlX03FPc8ONLwETNDyGEkNvhcAFGoGslM4FpmetSMMsPIaNuH1S5c67XCRez0N/1YnsiVWfr+7EHYFY/cdWJTdBAiI3kbFtNcLpvdnbMy2B87XpvOLnMyLL8gro6cibRhtiNB413NcqJ1omHjpKjZdAEsZiYyX2Cp1Ja/XeedZjSe4KZJtJLsndC8L1Sn+cmASiWC1+NwDglRp67Bhvnq9U/e8vRLi0q7u44f2e1C6VO/z/cLWrYu9mYGaWA+D+e+/OEOTg/JxlqMEkKyeMiZzdI9hOOrrz8t9agNBOpcqRcw== 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=qR+gwe9fZ0OgPOsrk+R+qFXljCdmF7F4EyoKq1gxYxs=; b=PbznfrZBlgPZFudRZy+sBwj7fKPr0CbYqzzfer3j/6d5d3VICUQ348i6vGu+Nj6wiZ0p976W/wus1fzPJWkIeUjs54xw/jZztbPJ+eKeOAkQUcbsMPSoRy++zIiUERoT2lsm3mejUGg+Tgc8s31y8RSCLFGGfiQ5bBF1xEb8rr3ETW8hSnVHN5IkiBV5rVZ5gEoEZqZs7L3I+ePLcj8JejNVy8BjUVXl3D4+dgK6deTswKtjxUDo6A6MQ9mjht9ZQ319o/R41IOqZYExfdDPYSomw6zH4M/l7tpcJaYzTCWD+TIdf3qRNKJLqM9OPE4fgcYRMd140GpMuecDVIddTg== 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 X-Received: from DUZPR01CA0086.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::13) by DU0PR08MB8397.eurprd08.prod.outlook.com (2603:10a6:10:407::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: from DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46a:cafe::93) by DUZPR01CA0086.outlook.office365.com (2603:10a6:10:46a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:49 +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 DBAEUR03FT022.mail.protection.outlook.com (100.127.142.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:49 +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.23; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:48 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 19/30] ArmVirtPkg: Xen: Add a NULL implementation of ArmCcaConfigureMmio Date: Tue, 25 Apr 2023 17:04:17 +0100 Message-ID: <20230425160428.27980-20-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT022:EE_|DU0PR08MB8397:EE_|DBAEUR03FT036:EE_|PAXPR08MB6431:EE_ X-MS-Office365-Filtering-Correlation-Id: 7905b9f5-63db-4a75-7510-08db45a6d183 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: 37VvTAkMExljxrg2zl8zsS94siubS50ZCEkPLPK7MCTZGMtV1rBuDoYPYTONfCXLkI7c2jt2wusfEgIJ7Xz47k9em+6/AsvvvjWPKJa+ChdpbpPFLfLdHVhIVh1dlXCSimYhQGoy9uh5r/p0Ph/hhROaVTwWLjdclS7aRLpHb5UhYVQOpfDxYdSRF1AH+SfZIZnktbEGdN6AGU2fWfnsxrch33a+rfWI6LXPeWEUNP3x0fHGDnBzbG8cBZL9yTd6LuUsy+m+FqOrMKD1Zuph75E1B1D1SxkEGnMOQHzdS353XBsJIeDVQdMAJ5T5rdmzJ4/TcAmgOLyILpUrxFV0G/KUGvze5kPMIJDID6/BMHHFVy4UXQN5IZ5o0CMmdMrzi8IjJJUnpSL9DqWdGuYkhKvnLaFl8rjp/ChzjZ2LByE1qyOiH96UYV4CMMijj3y48VleyftIcB2CE74wlv6tmA9xD39Rhco1UDQDBsXcqI5qRbkoT48B4RjElEz9cOPsdxgZIUnazmNcTi8LhXAMLho+0WU+pVD7GumYY+WPMo/IuNScQZa6lSj/kyQdxc+3ujFvWe2Vpe74zNPZLPcpmaD4K3IUZgMAZXInCoZSrjIJ6o6upLHQE9xYx7vig9R9bpbZ/+VeQh46vDU4OQ4xSoUksvQEOX9G68ipyzd6BOW+oC2Ubn1/03FqnlKF6VBTkshaM+newxksF1Sy92j91eF6b/FvJ3Yu/DZZPyceQCs= 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:(13230028)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(26005)(1076003)(186003)(40480700001)(34070700002)(6666004)(426003)(336012)(54906003)(86362001)(478600001)(8936002)(47076005)(8676002)(83380400001)(5660300002)(82740400003)(316002)(44832011)(70586007)(70206006)(4326008)(6916009)(81166007)(356005)(41300700001)(2906002)(2616005)(7696005)(82310400005)(36756003)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8397 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a5e0b9f9-a3d3-450e-7870-08db45a6cc5f X-Microsoft-Antispam-Message-Info: J6cV/HJ0kLdPLMhEIl/1bZxbcI+zMbcVNHmxAzPT9jkT/xVnksyN3kaUYEODKHlwDxJUPEHw/sPTF8E4t3LXh4buVUaWBTg0jz9eSH4FojHQCXQ5xeWaFG8XQvnhO3KIVHf2IvgK2LaYXS0fXnIOgW9HnKUzqPDvRVR6otf3BXVcaaePToWq1nI9DUasIN9Fsy4idvPewJHm11peNDTbZ1cdr99Ov3rtKo/NexLvH4TaB4rFAOZuJR2sfVl94bhpFjArGRtfYIxTMoToRCMZyZ7kinZSK88vFa3E7Ydq7z2n/SOm0xO62PdUnHJBRgWX7CNn3+O6+RD2ER6kCprBovzJS7CvibSjYtQFo3xwc3QkOErcQDsBIViQoTNEaEwVIGYCBZKOPyc7SST3Q36YVP/JzCLODiIDVCMPu0QCnvHyiffNNn/ynw8DWDkQpy+bpg29nwft0GLYfhQxtBDODPxy2So8iuq6lDxyZRp2zUx9UR4EQ/v3NoJ+dQOlKBYWC5eY7hNTOqY2g5df2iNoAmAA3jVgc3O4hOJVRvFTVIKDmgcMF3Sd8h/n1bvI6LeOv9I44+VErlLNmDif3T7A7C6IcJoSpL5gTB7epd0BMMH0Z4zsRTE4Tl5rTCCAd9NvzO2aatktr/Re2mc405Om2Vo7xtI5+GmbOQ5TlvRrWJM8TQ8Qju9Ae1I72CWjiRBAlKHscDJyb7fXX/3vtssIR8ZATIl9kAztj7UfXJvrYuI= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:58.4373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7905b9f5-63db-4a75-7510-08db45a6d183 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: DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6431 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: AH7hFxvjSvqVBRRzgDCWuqPSx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438704; bh=blmkI3K/w1LbEM/1xndJZneWW45TtdVXtao1ecLyZMw=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=lZ0m+5qVvkM+V3rM+z8qA6iVcaNJ+7u1J4djNOmBhidVFOr16VHtQKeSORny9BhJvtM R3kaAMeQTlRKSm3QOnVXrojMUEk+/vH9/cLQcy0H71JS0a5C1Q4kuL9xo4yid/AQ8QyQ0 aN7GfmGs0aBixoZIUNyCayBGMRNkEGqudVA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438705404100017 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To support Arm CCA, a hook function ArmCcaConfigureMmio () has been added to the ArmVirtMemInfoLib library. Since, Arm CCA has not been enabled for the Xen guest firmware, update the XenVirtMemInfoLib library to add a NULL implementation for ArmCcaConfigureMmio () that returns RETURN_UNSUPPORTED. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c | 21 ++++++++++++= ++++++++ 1 file changed, 21 insertions(+) diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c b/Arm= VirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c index ac0c75aecfe54090788836f2eea097f4abb112a3..8a9f6e1e1eee91ec2fc1418b342= c0966548e8a6c 100644 --- a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c +++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c @@ -1,6 +1,7 @@ /** @file =20 Copyright (c) 2014-2017, Linaro Limited. All rights reserved. + Copyright (c) 2023, Arm Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -55,3 +56,23 @@ ArmVirtGetMemoryMap ( =20 *VirtualMemoryMap =3D mVirtualMemoryTable; } + +/** + Configure the MMIO regions as shared with the VMM. + + Set the protection attribute for the MMIO regions as Unprotected IPA. + + @param[in] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Real= m. +**/ +EFI_STATUS +EFIAPI +ArmCcaConfigureMmio ( + IN UINT64 IpaWidth + ) +{ + return RETURN_UNSUPPORTED; +} --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103561): https://edk2.groups.io/g/devel/message/103561 Mute This Topic: https://groups.io/mt/98495968/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103565+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438708945326.47386298123877; Tue, 25 Apr 2023 09:05:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id bZPlYY1788612xMO09eLaCcB; Tue, 25 Apr 2023 09:05:08 -0700 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.47]) by mx.groups.io with SMTP id smtpd.web10.83974.1682438705713915086 for ; Tue, 25 Apr 2023 09:05:06 -0700 X-Received: from DUZPR01CA0077.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::15) by PAXPR08MB6510.eurprd08.prod.outlook.com (2603:10a6:102:158::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:00 +0000 X-Received: from DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46a:cafe::85) by DUZPR01CA0077.outlook.office365.com (2603:10a6:10:46a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:00 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103565+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT021.mail.protection.outlook.com (100.127.142.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:00 +0000 X-Received: ("Tessian outbound 99a3040377ca:v136"); Tue, 25 Apr 2023 16:05:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b79711b0cb348684 X-CR-MTA-TID: 64aa7808 X-Received: from 9d3f32eee6a9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 847B3A3D-8329-4129-8596-835046A9D8BB.1; Tue, 25 Apr 2023 16:04:53 +0000 X-Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9d3f32eee6a9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oSeISpWhjIiwm/k+dl96Q6WMXyfukeqIs6SsuGkbfv+ngyT8KKtngQnqxgc43fOoxZlWBmewOsgDqu27QwAMTepeVpST2dRJX9tPQ9LfcbCpOqTjv63RKx5EZrstjuEAKtMzkwjeRV343aTi6dC5bTQPuMVAJeD9IbAfArwcLcT8+8CZmyaS9jaqzBcZx8ywGhRrxiaoh1U+GQSl3dkqPjeVzH/oDXeICV/j6KT33MF5QGlarhcUyomU01Trwoh43+QgLEqOFcJoSRhfhuwo6IelwmJ1QL4zxCL9AUiZCiW7bGSQGRbXCAn4TLViPbPdV/qgiGTO//oEQ0Y/bXb5sA== 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=r3BCtOA42w0PMS4IwSH5LR5x5xwQVxUSbhXfyPiE0w0=; b=U/aYjwiyj5zQljrzaiXjqrJo/WBQ0kzEg8T378aBWhiZkK7A3/GmS/j0FA/1K26snKn8xdHY0mHr3MoodvXqqRshlYCxeuyWgknFjozBaCsmE7SxxGuLyWT4SqLybQ7s5IGMOQFxA7yah+xKMu6AfL8bKYyEodtOJuRDIZpNlMo+654DbUz4eoxxoDuKK4Q6H8o75T1tjC+dpxCLZPYU3dMS3V6FSNQnN0H2dQB/e1eeeJ4KZuXG6gzKWR+1bHxiog4prRgKZmOs627GwdnJYLg4k9AQIsyJeqY1Dg31jRxsu5Kx2RKrpXY99CbqaVCiKrbgJwT+TpnWQ8MBHq+xJA== 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 X-Received: from DU2PR04CA0016.eurprd04.prod.outlook.com (2603:10a6:10:3b::21) by AS4PR08MB8243.eurprd08.prod.outlook.com (2603:10a6:20b:51f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:51 +0000 X-Received: from DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3b:cafe::b7) by DU2PR04CA0016.outlook.office365.com (2603:10a6:10:3b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:51 +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 DBAEUR03FT036.mail.protection.outlook.com (100.127.142.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:51 +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.23; Tue, 25 Apr 2023 16:04:49 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:49 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 20/30] ArmVirtPkg: Configure the MMIO regions for Arm CCA Date: Tue, 25 Apr 2023 17:04:18 +0100 Message-ID: <20230425160428.27980-21-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT036:EE_|AS4PR08MB8243:EE_|DBAEUR03FT021:EE_|PAXPR08MB6510:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b322df2-012e-4541-b30d-08db45a6d2a8 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: aN9ezWbol+l19rTPUAPywtvogH0JTATmUmHDOqJvD/4yWPJjmO57Z1miuGhiV02gRclvW3zIGnTzZZ4OiEGtse8YV2irTs86lvm2INJs8PCmqIbZVULpX0SXOg4G0mq+5f/TVpy2Wktnj4f63ueUsmFBM1674EEBobO8VBzXe3Iwc0MirPDsGJpNst8k24HvuFBNoykhpcbhuDTcQZ5+19oa2AXG+C/SkShyVGAnIlm+57auWmok2godoXeeu8wjreHTO09iqVVKe4jkRjEYwxc6nI4Pz1gbTzGluJjI54osO5QMTdRyWsHzyT4MIluEcUt7jyK77Rw2po9nqtngu6EfpxdwToVSl9Dawooc8ZvVMiPhJQ2daxjaf8tsrfH7gOR8Hb2fWXE776Ccm3aG7EDrqer54aaARhtxJkEupo5hnbE/e3NOezAAOtxi3XcYhSUct6ZFodiWPbC2X9icVntiK1UwVZyWPGp3O/yoSlauFVdGW9udg7Fos4z7qN95f+SqZZA2f6T2UAYAIJpK9qv4GxdWz61vTB/M+h1T4fU1y9hWgzS2NK+e9opnKDQtapbhtulxA10W/fAQq7C9b5VEXAWm5vqIX1+CJ8l8+r7ggBJLEsB+SAVkxfCo2oEvpQLcqGuDhkHn3mjxn0tHXfJMyxdPTusVIiRufORDQKWW+IFM/KK8X1QI0L+IwPUyCTKtoMgp8TIlXK+QTaAfLNAduCKeQsdRDGxVW7CRJhk= 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:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(36756003)(8676002)(8936002)(54906003)(34070700002)(478600001)(70586007)(6916009)(4326008)(70206006)(40480700001)(356005)(81166007)(44832011)(316002)(41300700001)(82740400003)(2906002)(5660300002)(2616005)(86362001)(36860700001)(186003)(336012)(426003)(26005)(1076003)(7696005)(6666004)(83380400001)(47076005)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8243 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8d8e8da3-e0d5-4fb6-58b8-08db45a6cd63 X-Microsoft-Antispam-Message-Info: bO6U2VECo+Is/ylnxrM7taHZf8NkXtRY7tVmEyIHL4rLOkhbbAswBj3lZH+Sb2xuFwapZmqzROdH+u0WDCHp4TVdKS78GfxwZ2zObtlwec1DpZaZYP6vkknLL7RDcdp5ZAnvzym0IKD0xcZ8ppRU9ZGQMFqx7prZZgNpNXYUOaZ2YWx8S25g3OZPIlaYN7g6LKx4zAM9QDsa4n0MI+At82bRKQxmJ8jDHE0zCLrWLOJ8uc0gk8LFQNTeH0vLODhCDDmNAa51G5fDtfG1x3r/LmGs96jXKFlrT3fSmx2P/QBF8V4gMqkACEDVwkJZW5fn304BZIaEd8QHOG0pjkI/QOI9ivMWYZVv5vK0lJ5dRWuc+w6m7nySHvCUauGix83y5nn+eUA1v1aqO2t7kqeQaYrjfZzhSmlqWqOE9WQac76FXT8HifnujGdpVQDejybRBJ2dvN7PQLZ5DnfkAkl1kQ+cX2Oa3SUk273jh6dINXbqX/vmQY55e/QREnN+8EJ58rzxFU7TCO9FVL5RQaofSsrSFeekstpFjhYvrMYKhnTpP6sQdvCZhnK0gPuWTOEmgd60vE3xWpZcACbiwIZa7cKN6bgFIC9xutwlq1GY7tlFlp6yOPvsRMjv0msLq3d7SJtT2iGuyH+5dDxAPamYG8a9/HoMd67GZqngAXppQIcwkuGXU6BpNPtUvi4LP9lFFEeZsAc7+Y+oJ+IAtcyetNcoK0C5Pd/rS/JJEJWrw/o= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:00.3747 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b322df2-012e-4541-b30d-08db45a6d2a8 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: DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6510 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: NCuQAglrtB4QZYrCRYCaN4jzx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438708; bh=YBiqUcFeVAZOPHtYF46o0OxDTwCrZ5n62Tqml7qdwB0=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=U0PCnHohu9eP9aSW7joy5nfUW1TqOZJecq8igxIE4M2wrECoBW0R8Pq+07OmdLBEIxP GRiwJ9SeR+wMkKlUSzvA0GFA39fgr5WsS8lDJh+hnciSK1VZMcWQj5T/hx40TuqL6Yvvs CsnNkNaPLcfIKjhyt/1NAiSutiRAe/HNceQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438709740100031 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. The Unprotected IPA space is used for sharing memory and for performing MMIO accesses with the Host. An Unprotected IPA is an address in the upper half of a Realm's IPA space. The most significant bit of an Unprotected IPA is 1. The page tables for the MMIO regions must be updated to set the most significant bit of the IPA space. Therefore, implement ArmCcaConfigureMmio () which configures the MMIO regions as Unprotected IPA by setting the protection attribute in the page tables for the MMIO regions. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c | 39 ++= +++++++++++++++++- ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf | 3 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib= .c b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c index 79412897f2251712fafa4a9633b44235f2d7bb9b..a4fee904a43ccb8844ceaea9926= 98a99df2a8b3c 100644 --- a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c +++ b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c @@ -1,14 +1,16 @@ /** @file Kvmtool virtual memory map library. =20 - Copyright (c) 2018 - 2020, ARM Limited. All rights reserved. + Copyright (c) 2018 - 2023, Arm Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include +#include #include +#include #include #include #include @@ -96,3 +98,38 @@ ArmVirtGetMemoryMap ( =20 *VirtualMemoryMap =3D VirtualMemoryTable; } + +/** + Configure the MMIO regions as shared with the VMM. + + Set the protection attribute for the MMIO regions as Unprotected IPA. + + @param[in] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Real= m. +**/ +EFI_STATUS +EFIAPI +ArmCcaConfigureMmio ( + IN UINT64 IpaWidth + ) +{ + EFI_STATUS Status; + + if (!IsRealm ()) { + return RETURN_UNSUPPORTED; + } + + // Set the protection attribute for the Peripheral memory. + // Peripheral space before DRAM + Status =3D ArmCcaSetMemoryProtectAttribute ( + 0, + PcdGet64 (PcdSystemMemoryBase), + IpaWidth, + TRUE + ); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib= .inf b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf index a354e734ab1b7308a3e52b4e2b4885ef29592681..8e157a44dc9d11b9258d3f6182d= 5b169ec97ae9c 100644 --- a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf +++ b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf @@ -1,7 +1,7 @@ ## @file # Kvmtool virtual memory map library. # -# Copyright (c) 2018, ARM Limited. All rights reserved. +# Copyright (c) 2018 - 2023, Arm Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -26,6 +26,7 @@ [Packages] MdePkg/MdePkg.dec =20 [LibraryClasses] + ArmCcaLib ArmLib BaseLib BaseMemoryLib --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103565): https://edk2.groups.io/g/devel/message/103565 Mute This Topic: https://groups.io/mt/98495974/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103567+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438709571995.5017160911374; Tue, 25 Apr 2023 09:05:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZivPYY1788612xaXmjzKTFQF; Tue, 25 Apr 2023 09:05:09 -0700 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.57]) by mx.groups.io with SMTP id smtpd.web11.83462.1682438707570303956 for ; Tue, 25 Apr 2023 09:05:08 -0700 X-Received: from DUZPR01CA0047.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::16) by AS8PR08MB8466.eurprd08.prod.outlook.com (2603:10a6:20b:568::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.32; Tue, 25 Apr 2023 16:05:04 +0000 X-Received: from DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:469:cafe::ff) by DUZPR01CA0047.outlook.office365.com (2603:10a6:10:469::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:05:04 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103567+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT011.mail.protection.outlook.com (100.127.142.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:04 +0000 X-Received: ("Tessian outbound e13c2446394c:v136"); Tue, 25 Apr 2023 16:05:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2b64ea9de604fab9 X-CR-MTA-TID: 64aa7808 X-Received: from 901d203d8aa1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 01779222-D317-467B-A41D-D47D9F9C1845.1; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 901d203d8aa1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oeRGFpucd8KBU3yI+8fhqjcLlqch+IZ+tuzhbbGa0xagmN4bDEq6Tl87tJ/mCEl6dwLF6811tUGVQdVkX8qMlvn8vW0tni+qshcx/p18wWYt//FQo5aMZB/5KHO5KRyKtlZk/hTVr94XGBr8RYTtivi+lwGzcdgbThN1726c5MO/nPW1vhck34CPPUwl645V11/nnnhdyvjLOwmZA5kDvcHB+v2RHJ1DKMDaAs/AiRo6xX86B9RetLZqRZ1d4OE2t6X/ImCgIvde96s1HKWBd9FFpKc8L0Mg5vfcjh5Ao7aTtsTNpGo4Mm0yQ8aZRiPYY9NySSNpGq29X7Jt+pDa4Q== 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=5KcKyZ1YyztqmqAKQYTcQ++Q2no7vf0XzDSlfXOfqaY=; b=OULrr9URUCi3j5wq2uT3SsHbeM7CcBc2mi+pMG5m55hbn2VGFFGbhbKqvRYc2GQ06RNxaZh5TR4C53/BWotN/+Kgc/ij0s5y40Au4ZcMW8//6fZzvAC/sszINhiDHqCE2yKRM4Iiv1Up2qoVuBy+aEtLLqfASqqf9karQq6woHtzVGgF1bIt4C+U3DmhE7nCpRMjR/XvxuBKWdyrtxEzHQLvL63wkS9d+vnZiB8olIr87cF2y+TYoyGRHXQCESXkq+uoZqAKiKCpIg2j+lOMDQc2oCxT/QeITcuzYTdkmMM4Qex4MrVP2MDVaKOvJjz9L7HXRrA9ZaCfCcJ1L0qxEg== 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 X-Received: from DU2PR04CA0005.eurprd04.prod.outlook.com (2603:10a6:10:3b::10) by GV1PR08MB8451.eurprd08.prod.outlook.com (2603:10a6:150:83::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.32; Tue, 25 Apr 2023 16:04:52 +0000 X-Received: from DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3b:cafe::82) by DU2PR04CA0005.outlook.office365.com (2603:10a6:10:3b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:52 +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 DBAEUR03FT036.mail.protection.outlook.com (100.127.142.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:52 +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.23; Tue, 25 Apr 2023 16:04:50 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:50 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 21/30] ArmVirtPkg: Kvmtool: Use Null version of DebugLib in PrePi Date: Tue, 25 Apr 2023 17:04:19 +0100 Message-ID: <20230425160428.27980-22-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT036:EE_|GV1PR08MB8451:EE_|DBAEUR03FT011:EE_|AS8PR08MB8466:EE_ X-MS-Office365-Filtering-Correlation-Id: c55dab9e-24eb-4525-f69f-08db45a6d4ea 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: Ckv6ZqXnfEuOVppj/k9UI4YyFbgAX+m8H8ptQPHM1tokW4bauuPCntJr8kXtYbm4QNSgvknNYF29Kag6reydoRarlwd4smNRrKwVoMGHkGYQulPSyl+eTsPo0frN4gqjvZlK+PAQT80owfvhTbcA+mhoHVk4hx8T0dYLaBOhIbXVQ4QCKelh5G/3BGQV1gpB07ctt7gflra//0bofKJufe1h3BIrNlDhJhBjvMPhny8P/6DY5hSUUTyzoxyIPVoGQS6wRhRFWP1NeHWJylDp7hvb+Fkc9NqFRXCMGMakKgeKdPO0wq2PZTJUBPtQHzwYrMK0vGfTTOXIWjQjpZzcGWTj6IvcfXmuCGx+7US5/Jxvi7+/EpF7pMugAXgSzoCsN+ddb/oPJS7KsKkW2z9jyq/QlAtC3u6tD/y+J5/ELZDFy2kw17NjvHeJzrRtY+R2E1c6myNPtAuBjtr0WghDmBoABUaCLwXVeVRuS3hp1/blTgKT+a5FlvqLmTSCOz6E7DQ+GMaypA/Z+YgmVssdxjX62L1HtD0/qpjeHCSFc3jTNsIYQq6NIDaZCTj7psnHZmslZ7pOnqYx7Z645sUKaNwgD7vjaUdTCQCm1Fh5IsIXWbkBcedF9rI2MluobQh+OxALLbHczqN4Was9eY+AnMA0GfBJDmLH1yU9lGgZXfK/stTlJYV7+OIZOVUgFy7HINRBy+1PcVzrpNX672Y34rapnZhlH0j7JWJ7ffVaWl0= 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:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(36756003)(8676002)(54906003)(8936002)(34070700002)(478600001)(6916009)(70206006)(4326008)(70586007)(40480700001)(356005)(81166007)(44832011)(316002)(82740400003)(41300700001)(2906002)(5660300002)(2616005)(86362001)(36860700001)(186003)(336012)(426003)(26005)(1076003)(7696005)(6666004)(83380400001)(47076005)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8451 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 48a5c1de-4c7d-47c1-c96d-08db45a6cdb6 X-Microsoft-Antispam-Message-Info: phsHsIzk+EesfHjPREDhNhTpo0XBgKpXdRWqUQebC88b6Rb8TJjB2pknlpuhh9t9IGO6wg6iL0mRg5jbEWRijiH3gDMrptGQLNtC2WoADwL0znM3OUpbkoh9/rJz7/h/jCPkM3vu5bQr74S93w/UPLGyYf0HtDaoG4gPc1iZdQRbm/SLiMLOcqkaTuaSQTcCaShngqNWqoGVnyuW/WaYtURVV+QbEeXNN0P0j2bad8PTexr2guZIvoc4nrbIsEKhmjQuboIDq/ViebVkUMh8tdWOEOj8OO0iHi0Nge1G4p/AuSrFKry1Mf+kINt985L90BBISKBFvm9xxvOOpaSLfXSFc8KwF8GWyjGocBGZTCE5VX+WOdKhH+YezdkgS3LWxf1MSZKPDyx1iVWmU+q8qW6Ugap7LEgvXRhEOebjL3K+2772tdF9wxUiVi6YKtoNEoRVG3ud70Ctak1GceKfIWg2bSH6+NasnaR0JwVSF9CQ63pnCcs2AN7AqC9R1yPevrz1HaKF8UBv9mvBDCUHXzPA3ztEVBjmhgH5XdhACi3TqD+6QJ7ZMXnRT3URKFGgZOLpNSwOpoyplB1zMd3Ao83KL+MFMomjb6eAIFIGkahkmBWv+YjGztl6EWmXrwyHQ/29DJgvVA6J1P9gFnZKpzxw9I7Td8nGVQ+fnfc6we/hMgYZJphQbLBuQm+PONeAVDVIJ5mGR9RKD5g9JqTgmniTw+BdIcRcrdpgviOyQBc= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:04.1800 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c55dab9e-24eb-4525-f69f-08db45a6d4ea 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: DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8466 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: RKo1p4alKigYicg7SpOyN1kOx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438709; bh=2Sh6ww5xFIUoJ84nnBceZHyTrqBDRQ6348XkW1xfZG0=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=JhX3C/7xqvcMuds2RLd4nF//xkKCkSV5Ug3qy31RfptLbyshSAZn9N6fJdrxB0L8il5 ojluclg/YpfztdrX8EO9+tPQTPH+P724HLuZc3+8ZQy6dDj4xHqVZASXmm8ImktFeUX9c HnAi22GnM3cRZG3QnItLPyK0FRlypJ9yXo8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438711583100044 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The patch at "6c8a08bd8a680 ArmVirtPkg/PrePi: Ensure timely execution of library constructors" moved the processing of library constructors before the MMU is initialised. This resulted in the BaseDebugLibSerialPort library constructor BaseDebugLibSerialPortConstructor () which initialises the serial port, being invoked before the MMU is enabled. However, the Realm Code requires the protection attribute of the MMIO regions to be configured as unprotected (shared with the host), which requires the MMU to be enabled. Otherwise, accesses to the MMIO region result in a synchronous external abort being reflected to the Realm by the RMM. Therefore, link the Null version of DebugLib in PrePi stage. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtKvmTool.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index 467e5c166e1bbad3acbae78f53c225f5bac525a9..1cfd9e7ed8a6d2b0b054e130a84= c66c2fec54e57 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -248,6 +248,7 @@ [Components.common] # ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf { + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectio= nLib/PrePiExtractGuidedSectionLib.inf LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaC= ustomDecompressLib.inf PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103567): https://edk2.groups.io/g/devel/message/103567 Mute This Topic: https://groups.io/mt/98495976/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103571+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438714403938.2953869090171; Tue, 25 Apr 2023 09:05:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id thCrYY1788612xnY8pgyA23k; Tue, 25 Apr 2023 09:05:13 -0700 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.55]) by mx.groups.io with SMTP id smtpd.web10.83979.1682438712203936005 for ; Tue, 25 Apr 2023 09:05:12 -0700 X-Received: from AS9PR04CA0165.eurprd04.prod.outlook.com (2603:10a6:20b:530::25) by AM8PR08MB6564.eurprd08.prod.outlook.com (2603:10a6:20b:314::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:04 +0000 X-Received: from AM7EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:530:cafe::a9) by AS9PR04CA0165.outlook.office365.com (2603:10a6:20b:530::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:04 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103571+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT046.mail.protection.outlook.com (100.127.140.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Tue, 25 Apr 2023 16:05:04 +0000 X-Received: ("Tessian outbound 3570909035da:v136"); Tue, 25 Apr 2023 16:05:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 68bfa3d4164144dc X-CR-MTA-TID: 64aa7808 X-Received: from 5b13d284e0ce.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9C270824-12A0-452C-B541-60DBE3F4601A.1; Tue, 25 Apr 2023 16:04:57 +0000 X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5b13d284e0ce.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hqn8bnj1nle2IVl8pJN2KMIYGEALgAi0543FluF48P3SHP+q5WCSiE0dhBGPetf/w3DaIslpoJ3Uz8NveqTWkuv7CKKA242F95A7SS4jKglZrM4bzqpi+5lzMfyl4wtmEu6Q84pbHQe9qQU2a8iNUi3IMzfdayPoqXQMM4LV5J6wxVxdQD6VHZWraZNoJbzVIPCv9LxPv1GKBIfwp0qdHkUcFo+ombYHxpEfVblI/PLy3HGI6HvARlj+4U3lB5VdpQVFEg3vIzTuvz1uK2Ho0LMLBl3fs96KE5TfeVYgp7WKlCZmQHO9paYECmzT7OIDoEYRv8eDA5s7OOvi0qnYIg== 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=MR5EFXo7WKI4P4GsXqtz4DKwZ1KO3uW4C2cMo5bP+RQ=; b=d9Ii67Z4bCGBa/G091uw/gy6HYEAwB5sWdB1K8nzob3RSWLXFNicxP31kvFfPMEI1GBbtUDT0fdQBYBIC/4XUy3jXHonvcR6I3ET8A5BzmJ33bqDTB4Nw4H7i83wdmWtRGF6kCGv46nEhYSJfRMLn1joZuWYEQr2gsECOG71E7rJ4BZSrMwLc2oM54wn7ZJaftjV6NFqvfRvsu9xrMFYFKD+o7BHjSEaZ2HOxRPOPy4y6HJc4R0ohNScbbre2TUaPG113PDk/Z4Fe2efR5nbBm0bIP+RoQlbfuy0V4hxXsxFtx1FNjAoXfGGle3zK2S7zNdzn03hxIrPPj4OY41BeA== 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 X-Received: from DU2PR04CA0264.eurprd04.prod.outlook.com (2603:10a6:10:28e::29) by AS8PR08MB8946.eurprd08.prod.outlook.com (2603:10a6:20b:5b4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:52 +0000 X-Received: from DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::9f) by DU2PR04CA0264.outlook.office365.com (2603:10a6:10:28e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:52 +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 DBAEUR03FT055.mail.protection.outlook.com (100.127.142.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:52 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:52 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:51 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:51 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 22/30] ArmVirtPkg: Add Arm CCA libraries for Kvmtool guest firmware Date: Tue, 25 Apr 2023 17:04:20 +0100 Message-ID: <20230425160428.27980-23-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT055:EE_|AS8PR08MB8946:EE_|AM7EUR03FT046:EE_|AM8PR08MB6564:EE_ X-MS-Office365-Filtering-Correlation-Id: d96c9d36-3b04-42ec-8f5d-08db45a6d540 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: L0yXWb798HLhQx/HLK2Vmx59uWT1wgNOzCtq/oeYIFQUGNdsCnVS3hmhg6G6YDo0uxzMfAggfpKZraU3w3fGFw5UEkm/4TNB71yDmplhpWh/0X0A8kgPsrQy8JLRqCBwJL4k2Fpgc62EWIrI3xi5p3cnbToeaL8VpSgaHqK8k+QBcko8Nt/ylBKMx0GYjCM7Rwr7Jh9a6jZrlx1I33/DFAeMxWXaTOyU64UIrHBUifkroDqY6X6iY7qLIFb8cQ8saoMdngnAXoRZqEM/0zzEodnG3OrLqrhb/wI0MiNt39OortK35zqnVHHOilV09hIrFn8sXPgGCMIKy+hTdEFVWlyWtuah6ImJZLzVjnX1Xq7KfSpDhyy1I3Efxm8G61wlWH9gOmV8m5Bshzn8QfPNWtVcPnG+6kWuXiEg9hgaVIwOy2iCk/Y/n8928sV3MXbEJ4VOpWOcRyfgzFMxabCbPYXbdIq9sfMaXZLPBQHe6iRdfSIWgMoAtXeOkarqpixWUvDX0VSZ1MvfjInytclVGWNufRzokbcB6+KFWnYx1LFrB3B4ToR0UAtw5ibfDT009Gl5vtkPnvcUfwHutYSSB64I48bUekouGcQ81mewXN86mwtbrAwXp+VYE0Sz4kEdFTVwF+LPEc2R8MGr2mbP+iuimGTQLUTBRJvhuSmJfeYKMbAQKyuoO+DuY7Q7aMk9lYvhEJh/+uA4THTZITu5czdcvwcoeJnmZjOfTyoBVIc= 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:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(36756003)(8676002)(8936002)(54906003)(34070700002)(478600001)(70586007)(6916009)(4326008)(70206006)(40480700001)(356005)(81166007)(44832011)(316002)(41300700001)(82740400003)(2906002)(5660300002)(2616005)(86362001)(36860700001)(186003)(336012)(426003)(26005)(1076003)(7696005)(6666004)(47076005)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8946 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c68f76fa-44db-402f-c265-08db45a6cde8 X-Microsoft-Antispam-Message-Info: t4yIl+oPVckMsifQQ8NGMUYPR5Zf0lDf7Ppq/eg3NoPcNJDM3AQQKv1PfLiB2OSsxrtA7h4Qs5e6aO9Gy9qSDj6l0zrpm2498BgnXl7zwh3UlYY0ho6UTZEeDfOROhavUN1BBCX5gd3BS33UNA9XosTSnzCFnOreBClPv7oqt9Z0vzx0qADwu0bATS/HzpSLYb6VJ0jZZT6c/b+BG0MDt13yFZ6ugOSqXhMCKzj9bcgt5DqqRVNwOLNymelR72Ca5No4YvPAMLA2fuarrvuyegOEXdRN7zIa75BBWdfFtCAR3K/s3MSLIX92qG+vebCzHpgyVyI9AErusyXFOFPJg++Qg0BijJPa5k1X0iTCAQ/zS7kjrSqrl7sMYvVCcK4xxJMxvawe4EpKz+fkFaXrqnvRiMJPI+YMpW/OeyInQo8HRjURAficoPADODKXNirAPDIwYgTqL0HD4+PESvKHFhTZwvXaptp0trFReb+3ojg9MhfTxI8Ayg2mWDOypOjoTyf3MHIEh8E9mjo8RKulpzIvGWIj4XSpxNgg1UAwBNgGh8n4gYPGyrG+NYW5EB66jqPIgusSZuNpc3gddcV4XarZwngABJUMiV3nIkpMBXP2VOEd/sM0z4n4qG0ruGtW3VBupkhq0vUjupWG8/V6Moo+ZhA/nqrdchd1N/DtiFe81WkZixUHhcHKh6IfDS0Hk6mP0Hx+5n7hEkYzPVLk1S6gnMhrjvJEqQS1NoReTPs= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:04.7254 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d96c9d36-3b04-42ec-8f5d-08db45a6d540 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: AM7EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6564 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: WDZVElwKCJOvewAct2bDOYKpx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438713; bh=FNvwH5yYkoTYYMpjJwqLoQT+9DONROm+OseN6PM9bgc=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=P2KiK/wQnldND4KaMrirmhzF2cAf57YhiM90O8e6o8PPY7K8V9aPD7KYqgfTk5o5li1 /oXbNJ2WQ6aA8UAc9edwHldYbtT1qiJcSdD1XGyQFeSE+iWNYCACH2qnBr7oBMt4qrpzy VwgQZwInuNAB3fcBCjBGzhu4OJgSSQneHiw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438714985100063 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The following libraries have been introduced for Arm CCA: * ArmCcaInitPeiLib - provides functions for ARM CCA initialisations in early PEI phase. * ArmCcaLib - provides the necessary helper functions for Arm CCA * ArmCcaRsiLib - implements functions to call the Realm Service Interface. Therefore, add these libraries in the Kvmtool guest firmware workspace as part of enabling support for Arm CCA. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtKvmTool.dsc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index 1cfd9e7ed8a6d2b0b054e130a84c66c2fec54e57..9bc857ea88d00431bf4223f588f= 908eab7561a19 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -86,11 +86,18 @@ [LibraryClasses.common] ArmMonitorLib|ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf ArmTrngLib|ArmPkg/Library/ArmTrngLib/ArmTrngLib.inf =20 +[LibraryClasses.AARCH64] + ArmCcaLib|ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf + ArmCcaRsiLib|ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.inf + [LibraryClasses.common.SEC, LibraryClasses.common.PEI_CORE, LibraryClasses= .common.PEIM] PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt165= 50SerialPortHookLib.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort= Lib16550.inf =20 +[LibraryClasses.AARCH64.SEC, LibraryClasses.AARCH64.PEI_CORE, LibraryClass= es.AARCH64.PEIM] + ArmCcaInitPeiLib|ArmVirtPkg/Library/ArmCcaInitPeiLib/ArmCcaInitPeiLib.inf + [LibraryClasses.common.UEFI_DRIVER] UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf =20 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103571): https://edk2.groups.io/g/devel/message/103571 Mute This Topic: https://groups.io/mt/98495980/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103568+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438710511795.1634221504096; Tue, 25 Apr 2023 09:05:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dJU9YY1788612xpSCSGK8EAd; Tue, 25 Apr 2023 09:05:10 -0700 X-Received: from EUR02-VI1-obe.outbound.protection.outlook.com (EUR02-VI1-obe.outbound.protection.outlook.com [40.107.241.50]) by mx.groups.io with SMTP id smtpd.web10.83976.1682438708221494041 for ; Tue, 25 Apr 2023 09:05:08 -0700 X-Received: from AS9PR04CA0146.eurprd04.prod.outlook.com (2603:10a6:20b:48a::19) by AS4PR08MB7506.eurprd08.prod.outlook.com (2603:10a6:20b:4f8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Tue, 25 Apr 2023 16:05:04 +0000 X-Received: from AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:48a:cafe::3c) by AS9PR04CA0146.outlook.office365.com (2603:10a6:20b:48a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:04 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103568+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT027.mail.protection.outlook.com (100.127.140.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:04 +0000 X-Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 25 Apr 2023 16:05:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: db91e0ec1c159140 X-CR-MTA-TID: 64aa7808 X-Received: from aa84faba890b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 717225D3-31BE-4675-ADDE-EDE941592710.1; Tue, 25 Apr 2023 16:04:56 +0000 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id aa84faba890b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KN07JZ1ql1Wv1m1L5saMw+Lvcy1DlGFAvcvGkgXkXDMSXNf3z/QodHkPucNb0xpJ/sKN8HEEDkzwUYZG9zfUuokKMPIcmPHPeH4KsezVft6u9jE/gRqtHn+whWi52k9X0tmqJqEHKRATyCVnvGi2j9X/FIF4JpgkKFI88ZISF9SG7T7TFohHT7agUsoHueneRMsJ9w5BdCtdM5dvrOGGbpIvhU2GEBAf/Gd/KREGPSYPN/ooCB7nQZUyp43SLzx2YKEpoHCTIn6CQT4ro1FAOrN0M0PbU8KWlYfXEwKtO/Q1WwyAmzcpVjEykU++S0A55DStpjwpEbwmorS1z/NQkg== 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=RAgHeiq8reVHDfEAsnplGWXOuoZvCSpkXxoz5JpBG0Q=; b=ShLAMZGOjx8fCjP+6Hu0eQXKrb0lRFCDwZ6yfGyZlWhmshiaaxGGp+sng0dXvHRmin3im+Xx9IF1t4wfek+8L5qgxFVhi+5HUSuhxGE9iQe6j1gZzzGIuUzk2ekSnGk2BE6URfwpjAQUg0/DICouCWJS+cRB/wGZrnOAx9E1ZegQcKsl6gtL7/qgNj+E1ZPdlG8D6qb9GhSYrqumaBcx7w9x3Mdo1VhEkF6N2eVR20B/103ozqMfoD6Au7XtnNRr3/r4YMPlXVvRwUkEN2WR27a99c69Ez55LCv85K8M3uXsd5qBSEkD4ZC2ZwsIdudZmCMlw15q0Uko+LP8GBE6BA== 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 X-Received: from DU2PR04CA0247.eurprd04.prod.outlook.com (2603:10a6:10:28e::12) by GV1PR08MB8213.eurprd08.prod.outlook.com (2603:10a6:150:5c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Tue, 25 Apr 2023 16:04:53 +0000 X-Received: from DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::35) by DU2PR04CA0247.outlook.office365.com (2603:10a6:10:28e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:53 +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 DBAEUR03FT055.mail.protection.outlook.com (100.127.142.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:53 +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.23; Tue, 25 Apr 2023 16:04:52 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:52 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 23/30] ArmVirtPkg: Arm CCA configure system memory in early Pei Date: Tue, 25 Apr 2023 17:04:21 +0100 Message-ID: <20230425160428.27980-24-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT055:EE_|GV1PR08MB8213:EE_|AM7EUR03FT027:EE_|AS4PR08MB7506:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c840f65-4720-4471-9d43-08db45a6d4ed 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: 5nvfM8PyTlP49MJ22dsuBwNC5NkmeQOv3F8/L7PdJ3MR8d9bQmYYq1VrHWb5hQlFZgZIGo3U/1QiNx4De2/cLF84eWLNTvH9xCUgr+MvMjaJkw8PThJXfPnfFkBO2vVQy6NUVCbvBGm/V3UoMKKpTSOQ+cUFuuTNLO00zv2XbGwytKaF4Ji1PtgmfPwTdQgeHC9ZkIkOY+hNED0uAvI6WWNzMVuKq5hNeHRxUFBEOaW34SjzlfO6Y0to+Yeoy91iiHEd5hAyxi/nvrfLLiEW/Ge2NjYJXyQWSHZOMRFrZVAoMIGJKDzirsZafsqgJ/+ZQ3LtqaLgHHJtuzyMeT+ZFJ0OEt6NtuSf02T/WIQzELU9Kw3rjeFaQrx2yMtjVcnIuglUch49U8H0KhTdZaK6MxZjHUnbczQtAai9zM1PZJPc8EMiIU8oFdv7OzpA/+WUJvrkL0ekLuRAhyFZhUnFg7KcOERxnQuaa6NbfuVvkR/VlukJu1Mxp4XILzIUlScEgHfUspMAz626BP92aySCkdIOoK5YbpyDMEJkyAXoYRBLT/+JfnvZKTF7czJpVED0QTH9Xod1iIim3fRzHGSoNo9hiSj7n87wlAj1MQJ8N0WlcoNMkHVEI6tFLqgPs/KW2q3/r9HOgSP4yfciabx+a4Ardah1qjW4o6VO9BSI0Yyq29VosOD/JUJ5uQyCy/8/THq84ToyFd4PAKD8Btg2WfDyVn7B/5DHJa5AhVXBGzM= 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:(13230028)(4636009)(136003)(39860400002)(346002)(376002)(396003)(451199021)(46966006)(36840700001)(82310400005)(1076003)(26005)(40480700001)(186003)(82740400003)(7696005)(6916009)(70206006)(6666004)(70586007)(36756003)(86362001)(41300700001)(54906003)(19627235002)(478600001)(83380400001)(4326008)(316002)(81166007)(356005)(36860700001)(426003)(44832011)(8936002)(2906002)(2616005)(5660300002)(8676002)(34070700002)(47076005)(336012)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8213 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 3366e24e-1786-40e0-cabc-08db45a6ce96 X-Microsoft-Antispam-Message-Info: KFa1ura+m/ooflMEbR7pHQeRsbqYEl9BYzNl0Mfkdp+49vQWm9UEJ3NndpGupKnqFerNp40opME8kA8v+4M/TD5Ri6fEm2hpHeDDnkEOQ57oq3/HK3RzPO5vvP/EzLbS1g28s0N56AkEfBvJL3T8dez0rF8Kz/rgKSsBl+5WI+QyAuvSi/75SDpxDy1GKiiTIWMdQUeT8ENX1GXMR/nQhU6vLBOJ7EjDE0MqFkRZsq0Y1Q/n8tJe9vrCPzplJL4LJMWoXJdEV2/OfNhJ+W27ZVXxwS6Wk98rJXNeQelFad2UeGkYPYdurMu7T3a7P4WoxkC0i1KSCCO+NzE/6gKcYOyn+QLBob4EcAgCRehQaaSRhby2QyFN/6XvqTnFLRcDrv8LWD2breSQ68BtnqZuHylrINytoOLrlswHehOzWY/NfMXFDd/UWAkdTU2/XBSFldyQ81VHrJBJMXhGJW3y/5+V9sL0O6Q/gh/I2Vnz4bT5CpZ/XIeOpnaMGMtSYw6/RgYHtxPahKR3N7KJ/k7SQrlCPjkNddr4q9XwTj1jG3zpsGmrnJOfsbRWcm4iiZgnWBPFArPoNAGhvCaX6ZU1Be2cszf+0SoNnIavF3SXTKs2/LQI2Dv6Fon++W1dacTd6X6mAPu4gzfiQgLhFzC5WnfBrHbCLXE64NCvcIgf5LuLzUILfaO7G7YoLL0/MNUU0+gdWZML4nkWunyB7Em0LKkjlFSu2MQecDiZPrxrN44= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:04.1818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c840f65-4720-4471-9d43-08db45a6d4ed 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: AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7506 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: dICz6sZOW0bQBv7NUuQraorgx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438710; bh=9DMX123XC/hnj+FT6TJfTnNddNUFnSZLZpPx3htchUc=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=tsoMRxRNDsZgiuLMIRLXNItY1DkgeKbtoK+AkIm1HF1WlKssoLN42BzGRmRP16yH8AZ W1iHxBJPCyY528SRMOK2NDEiNeyZQARkN/ZMaBCk6JsMAjDq2X7cwzZDQGzIbTwnlDrYF 4vlIQYWVHmbRdvLAT1Pf2oR8D3VYJLC+C4k= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438711863100051 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a VMM creates a Realm, a small amount of DRAM (which contains the firmware image) and the initial content is configured as Protected RAM. The remaining System Memory is in the Protected Empty state. The firmware must then initialise the remaining System Memory as Protected RAM before it can be accessed. Therefore, call the ArmCcaConfigureSystemMemory () in the early Pei phase so that the System Memory is configured as Protected RAM. Note: ArmCcaConfigureSystemMemory () is implemented in ArmCcaInitPeiLib for which a Null implementation is provided. Therefore, this change should not have an impact for non-Arm CCA enabled systems. Signed-off-by: Sami Mujawar --- ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 6 +++++- ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi= /AArch64/ModuleEntryPoint.S index 01623b6b3591242778a5c76df5d401b1ce71834f..03bef60dd408e787cbeb9eeee12= d95639821714f 100644 --- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S +++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S @@ -1,5 +1,5 @@ // -// Copyright (c) 2011-2013, ARM Limited. All rights reserved. +// Copyright (c) 2011-2023, Arm Limited. All rights reserved. // Copyright (c) 2015-2016, Linaro Limited. All rights reserved. // // SPDX-License-Identifier: BSD-2-Clause-Patent @@ -11,6 +11,10 @@ ASM_FUNC(_ModuleEntryPoint) bl ASM_PFX(DiscoverDramFromDt) =20 + // Check if we are in a Realm and configure + // the System Memory as Protected RAM. + bl ASM_PFX(ArmCcaConfigureSystemMemory) + // Get ID of this CPU in Multicore system bl ASM_PFX(ArmReadMpidr) // Keep a copy of the MpId register value diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtP= kg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf index 7edf5018089d0710564159a06e3f50b8890d2795..afa9b686eed60d894af6933e3b2= fd5a82ebae951 100755 --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf @@ -1,6 +1,6 @@ #/** @file # -# Copyright (c) 2011-2015, ARM Ltd. All rights reserved.
+# Copyright (c) 2011-2023, Arm Limited. All rights reserved.
# Copyright (c) 2015, Linaro Ltd. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -37,6 +37,7 @@ [Packages] ArmVirtPkg/ArmVirtPkg.dec =20 [LibraryClasses] + ArmCcaInitPeiLib BaseLib DebugLib FdtLib --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103568): https://edk2.groups.io/g/devel/message/103568 Mute This Topic: https://groups.io/mt/98495977/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103570+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438711934709.401773083376; Tue, 25 Apr 2023 09:05:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RyulYY1788612xzMc0329lo8; Tue, 25 Apr 2023 09:05:11 -0700 X-Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.89]) by mx.groups.io with SMTP id smtpd.web10.83977.1682438709487087082 for ; Tue, 25 Apr 2023 09:05:10 -0700 X-Received: from AM6PR01CA0042.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::19) by AS4PR08MB7479.eurprd08.prod.outlook.com (2603:10a6:20b:4e6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:06 +0000 X-Received: from AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::24) by AM6PR01CA0042.outlook.office365.com (2603:10a6:20b:e0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:06 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103570+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT061.mail.protection.outlook.com (100.127.140.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.19 via Frontend Transport; Tue, 25 Apr 2023 16:05:06 +0000 X-Received: ("Tessian outbound 3a01b65b5aad:v136"); Tue, 25 Apr 2023 16:05:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6ed8a76c541ad89f X-CR-MTA-TID: 64aa7808 X-Received: from 2d7936ed63e7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2CBD3FB4-CBA5-42C8-95EB-3A047A230F9D.1; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2d7936ed63e7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dOUi376AHLadHMJ2b/LnKHZ+tX6jcLGzUUUiJ18CwhrJQy0200CIdxv0nHJ1VsrHhh+8c6/4cqjP+LuNaAllYTRUHww098TAsPJPwIjMP1pFNG6dLoXKgq/u3+sbPZEQDNC1d55z09rFSvkhCB9UFMO4uxpa8IHDZ8RTvK01ejZDif4HGZAIIT54l+OFWpgG+UmsfMYPv2VcOUQFWuFkV35X2OzuEOLeWUfKpIeXx/ILYMaQmqX8Kq85aWwqYaKVPGqrOcO+569Sujc7wOLPJ+9rbLK+Y0Ra+vac4rC2AocLajUpAKdhiw1ZDHZBseiO/YlzabFYMMZrXUJStq4k0w== 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=1oVwmpGAf3voqL9vWH7WpkvNo3ymIXFICsg04W94SDs=; b=Mc1wJMrWd+mTjsC+jHegrAhZpxvxswL5Snd909P8o1T4au6zeWUnQmDIvrmD9/KZtLozQHTD0uf/4mtMhXBqItS/ztGx1jDjLkH7xsc3aMnO3BpWmfwsGB+2AbUn+fsmFSfHo8dlvDoC89Be0eeSXK1kwIH87KsrabEP3FeGHkv2ANfRmpK7DLWZs6D3Py8pnBWRznFu3McxHVtYJtb8c7sEnybXpKuNyoSJbpSO/sHTBEvIwDA11/xNSGayIQOT5zuR18jWd0VzdR6J6K7c7WHiWFnL3RKarAL851+fHlgUcq0OKUNGy7huNkshKVHwPa9re9UE39gxdMn3oiX+Qg== 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 X-Received: from DU2PR04CA0264.eurprd04.prod.outlook.com (2603:10a6:10:28e::29) by PAXPR08MB6656.eurprd08.prod.outlook.com (2603:10a6:102:135::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:54 +0000 X-Received: from DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::9f) by DU2PR04CA0264.outlook.office365.com (2603:10a6:10:28e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:54 +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 DBAEUR03FT055.mail.protection.outlook.com (100.127.142.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:54 +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.23; Tue, 25 Apr 2023 16:04:53 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:52 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 24/30] ArmVirtPkg: Perform Arm CCA initialisation in the Pei phase Date: Tue, 25 Apr 2023 17:04:22 +0100 Message-ID: <20230425160428.27980-25-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT055:EE_|PAXPR08MB6656:EE_|AM7EUR03FT061:EE_|AS4PR08MB7479:EE_ X-MS-Office365-Filtering-Correlation-Id: 955817fe-3c16-4970-64a4-08db45a6d612 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: QUc/ttYBCmQbECnyh3UgeHBznS9KWdu5ybJl5FPh9s6YpVkqpbXrljsDvmZQcpXi9Tdc5mkden1vhqdu2eGrB9vp4Ga0vt0s6uphg4Tr2ZPh2XSOYrj0+94/pcEWNllRD1zWfpEr+QI/ZiuZEICGyqmXQ54aEbSG3mNQLpMnx74LnQALy8Thd8QurO7LEuHa3lnfGBwaH8JbLLW7yzEbx/z/xD00VdGmmS8+w+bwXbdV8nJQ6O8uvvyO2azBe6uYzkzASPI0UjgDRHJ5swqcXqWv5gCFUcYoqjjaawBoFu/dgc5QRFUmQwyi+XT/Vnm2ArJjAxuGA7FaprrtAVnphE0GKTSXocNzzBLp5H6QrZxtnHWMkeqimgixW/wD+OXBAecHkuixlrkVLZ70hZ0MZ8CfGwdBTtTw+AtctDOv3iKJwQDDz8Z/vRdw9RqXhGn53tIm22DladCviWarEFHMpWqlZodO/zZeAHtSEqaXX4sVoZE6utBHn1Zzy7KgkAQmVBGmx6d/aD3oDPujQ+Rhdj7eJ/S61Iqe2r2HA9UG0pfGOSLz5UiSqt7KB+rFwYzKcX0PiISlHo2bQh5VtenKQJBaftXUzMa0+T0jyf5XfUU6ZHNaAluCxCsYkL5dlQHQwBB2pjvL/IYoGcgNGAuNulgiEW+j7xf7bMJp5kKZ5pvgY+Ild7Lt8lzsxE8G085qr/4ci9eR5bE6/ALjXJUUvOah+b474SWeVGpd31xVo+g= 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:(13230028)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199021)(46966006)(36840700001)(36756003)(54906003)(34070700002)(82310400005)(86362001)(478600001)(41300700001)(81166007)(8936002)(8676002)(44832011)(2906002)(6916009)(40480700001)(4326008)(316002)(356005)(82740400003)(70586007)(70206006)(5660300002)(186003)(1076003)(26005)(336012)(426003)(83380400001)(47076005)(2616005)(36860700001)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6656 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 34e4fcd1-49f0-40c8-b046-08db45a6ceff X-Microsoft-Antispam-Message-Info: cLFdAEp6mQv+XM63rk0y9QDiPRnn+SvIDB45PKKjScY1zV/82J1AK9anxyCG4N/qWmqevLpA9IiZnTLg3Vqfn6xc0dChAD0CoD+ryrczuwlbZd1r0mPC9eSUjxqlfYHKus3AdwPZdSN8s1TwAIOlJT8CuR664Tjh5WbREjO/u4UEGwWuHvQhLhTbjfOusRBywzMMCdcgQrmYf0VXVAhcNHvY1rCvvFOXPXXUmzs2mM8m9yXCRVXe22/TrKnfbWpRwPa4GIgxb1uQsQzyl18S4GWoXfKpUzTsOjs5y+6mrMA9f184pQKXSuA1QqzXiNHyShImS0s7vLlXd20K9lFxhIWRi5YvksaYXhC1iVodVPkDQw5ZKS3w35Y4ig5v+qZCD00VGp6bsNrG5FJAYN2kGz2S9OzKkx5vKfAQVLuaFpW4KlXUsdCP5l32WfQcTM5HTon1u+t/+TpeICFnEOJtlz4jpC3Qpig45ECFWoH1QuIKU/DC5473XcCcgYDPkvGuMIljhytskJvuzvG4rj/9cCvSmLPrN4HG388eBXvtSQZVRR+Sa0gaRKR2/u1TSWxtFBxz1Gdymc3QTFSw/DQa4Im1CX4L3n0yvZzwBFrBz64flyCjkS+yZjrJ+/dXpP88SLzIaE89pr9m/u8IVLC+wcNNxd5wJUvEKL0VoOXD891LteDKTehT/+U8sliRCO9Kc927jHUfla3adU5QspXNxhkQ5FqM5vwC/RrdAGve3Iw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:06.1005 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 955817fe-3c16-4970-64a4-08db45a6d612 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: AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7479 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: OxDuFA6dUISPvNApaxt14e0kx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438711; bh=7QCndRFJy4q69uod5+oq83+sisE2Pe2geG/y7DBaR3Y=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Oz6lq60OyNWHMQSF4slBbCCl3T5SvGpjpF1QJIujiSZh4IbzYcXkIaNAMnr3Avzlg41 3Gp1gFQYCQZFrp3JfPiSv1L5YQjisDbSCiPBiJOLt5s4++D6l7Bc+wFZ1lbmyIZ7nxYKq C+50WaL2IBE9musTSZR0DNtQbXMoRH9jSCg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438713635100059 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add ArmCcaInitialize () to perform Arm CCA specific initialisation like: - Reading the Realm Config by calling the RSI interface. - Storing the IPA width of the Realm in PcdArmCcaEarlyIpaWidth. - Configuring the MMIO regions to update the page tables to set the protection attribute as Unprotected IPA. Note: ArmCcaInitialize () is implemented in ArmCcaInitPeiLib for which a Null implementation is provided. Therefore, this change should not break existing platforms that do not implement the Arm CCA. Signed-off-by: Sami Mujawar --- ArmVirtPkg/PrePi/PrePi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c index 3d943b2138d3fe8a03322262111d5f7df3e39d39..7ece1e07152ebc395c1f21dfabd= 78df2020cf052 100755 --- a/ArmVirtPkg/PrePi/PrePi.c +++ b/ArmVirtPkg/PrePi/PrePi.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2011-2014, ARM Limited. All rights reserved. +* Copyright (c) 2011-2023, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -9,6 +9,7 @@ #include #include =20 +#include #include #include #include @@ -40,6 +41,7 @@ PrePiMain ( CHAR8 Buffer[100]; UINTN CharCount; UINTN StacksSize; + RETURN_STATUS RetStatus; =20 // Initialize the architecture specific bits ArchInitialize (); @@ -67,6 +69,12 @@ PrePiMain ( Status =3D MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUef= iRegionSize)); ASSERT_EFI_ERROR (Status); =20 + // Perform the Arm CCA specific initialisations. + RetStatus =3D ArmCcaInitialize (); + if (RETURN_ERROR (RetStatus)) { + CpuDeadLoop (); + } + // Initialize the Serial Port SerialPortInitialize (); CharCount =3D AsciiSPrint ( --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103570): https://edk2.groups.io/g/devel/message/103570 Mute This Topic: https://groups.io/mt/98495979/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103576+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438720306520.180293066167; Tue, 25 Apr 2023 09:05:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Kq7WYY1788612xOk3dmbxrlP; Tue, 25 Apr 2023 09:05:19 -0700 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.40]) by mx.groups.io with SMTP id smtpd.web11.83470.1682438718776735899 for ; Tue, 25 Apr 2023 09:05:19 -0700 X-Received: from AS9P194CA0017.EURP194.PROD.OUTLOOK.COM (2603:10a6:20b:46d::33) by DB9PR08MB8291.eurprd08.prod.outlook.com (2603:10a6:10:3dd::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:08 +0000 X-Received: from AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46d:cafe::e1) by AS9P194CA0017.outlook.office365.com (2603:10a6:20b:46d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:07 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103576+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT023.mail.protection.outlook.com (100.127.140.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:07 +0000 X-Received: ("Tessian outbound 5bb4c51d5a1f:v136"); Tue, 25 Apr 2023 16:05:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c97d7815684d423a X-CR-MTA-TID: 64aa7808 X-Received: from edeb0aa806b4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D77C649D-BDC3-4B3F-96BF-E73735CD5403.1; Tue, 25 Apr 2023 16:05:01 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id edeb0aa806b4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:05:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jeY/s+1xkhmGEhgUeGCMAY5TJBOrMUmTsFmPlJRkH6X7IyNszz24S8KC5hh1eSppl8Xz03M8kyxN92xCFr7MCoTXs9hdIm5RTzVbbuFRQjB2pqxosH3NHTNiic9n/Ejf5Zzml9KmtU41baUZDQ+tLpp4sIrH4J3W7ESGfBHKyftYIEVYc7B2Rwq3IIlNBM2voO8Ch5bRcVExhH8gE6cwJSzlghfYSRj0WKrlp4kjf/N6Ll+w3Q40LFE7S1xTXm3BskpKqGyyRdvaws9QxYpcAz3tpXROX52x+7C2vBf6SLcfj8otdZ6lkcp40sWBZ4eOrjD8ZnBchhxhcooLrioSqw== 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=N31DQKS46PybftiF/nXwWL3GaOdiz7EmAtFRZibjByY=; b=e7pFkR8M54Znat4i7vS/QMH5//FsMvk52c8oMKmbSOe60eer0YH0SrVp7V44Xlh+XL+V5lbPxbbix80KZ2TJK3mkYNH2sz4elei8V4jrQJDp/psM3gB8kS7z5Cygq4GpLM/MjfT46zQcnMr8ggwp3SO6eA2/+JH7mxo+D0IKGaefpkn6EO1+5pF24Q9JBGnmRDAxfNpCLFBmDwWwi/MleVP85+uUZvJyoWcP//OKXdwJQI9SRh+vruHl3WKrQ5npfVSoLyONqqbQd2SObdkdWC+OvK1dwKpQRXEU8rT26D6rwD+UoDh1BtwfZC7SXC4KbB5VuzgTjNDCV80G9RYQiA== 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 X-Received: from DU2PR04CA0249.eurprd04.prod.outlook.com (2603:10a6:10:28e::14) by GV1PR08MB8237.eurprd08.prod.outlook.com (2603:10a6:150:5d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: from DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::bc) by DU2PR04CA0249.outlook.office365.com (2603:10a6:10:28e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:58 +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 DBAEUR03FT055.mail.protection.outlook.com (100.127.142.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:58 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:54 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:54 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:53 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 25/30] ArmVirtPkg: Add ArmCcaDxe for early DXE phase initialisation Date: Tue, 25 Apr 2023 17:04:23 +0100 Message-ID: <20230425160428.27980-26-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT055:EE_|GV1PR08MB8237:EE_|AM7EUR03FT023:EE_|DB9PR08MB8291:EE_ X-MS-Office365-Filtering-Correlation-Id: 0443fc22-94b3-407e-25ce-08db45a6d713 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: IWQIqYXb/GuuUL/PfGtlt3H92ELjddWBS5sWuEyzJYp1ol2rpkJWELCL33MF9fKZhpEbSFEjnzxissNeQc5t+nsmhVSYiVpxo6uyEr6K5BHVgoNu5Tltc9h1XeRfWrBG8E8aT0ifHyyEFW6FRxgukt8X+NjJCHC9LNkx6BgF+slkdOMRJIKLYYm8YZwUVgRGhT39UmEPc1Hd6tapot20KdlrFGNcs5KXcCrlanRvGxsYeRV9tk1Sn9DVrb2Wklv5bTFWx3eGm/cJ4hjQ6qfKSeS+3My2goClcjtgKPu56kFC2Et3WmtP3riRay3AivrJBeCNARJvTmICvrkt46QJwm29FeYXQFnCLogWlWVAiUR6yTnD2/MmmySsMm4OXQJz2SoPhIyJbShDRC6aBwEflK07LsmYOjmof7gVxLDPzQm01zGPFqCUTu74nZUoXTFnMV6zc2ziZ85CvSJBIr3rA7v0bHK1hx5nmXX2+J/KB/4tet6rG59OZor32pTHu1mpt6z2QL+aiE3SODgoCpljdECdb6dl5d6jX7IkJjkYVugmGiXWZ3xvhx2pwl7qJ2AjntkaFGp+7NUbHnaHQMen/d57fpWBfSRgAnIkJEjdeI/+SCkFsTfzMZjzC7iyWXe/FRGeJLuvWBcMoREKrBOg4KM2PB6FKoxjESxOXa2/jDRudxQgY+g1cnhHjSg+KuojLGOrlyiB2dCs7oKkNZ63y3Vr/PjDRktm62ca47EI7sU= 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:(13230028)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199021)(36840700001)(46966006)(36860700001)(336012)(426003)(47076005)(83380400001)(34070700002)(478600001)(7696005)(6666004)(2616005)(1076003)(54906003)(26005)(186003)(5660300002)(44832011)(36756003)(81166007)(356005)(70586007)(70206006)(82740400003)(4326008)(6916009)(82310400005)(41300700001)(86362001)(2906002)(8936002)(40480700001)(316002)(8676002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8237 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0d6185df-b06c-4a55-89ce-08db45a6d14c X-Microsoft-Antispam-Message-Info: SinidEToBErE9mdn10UQ7qXHcHYzCypSdNoic/gRsO5P50YLu4fYKV2RGoWTD7Mmdzg4Oc/qhaC7WNSMzeD4zX4yWheq7f3kvHyHSdSDws74FhmeNoH/1hXq1g2RPjgiDM8mV1SnWUzQstdxchrSmL6/Ac1ea/0Du5wXGVkJJ5S5FtO3lPEldLuLTT54k36fSh7dN4TA6fcxvO5cRxRV7I7VvkZkzMy3i0njkKpTagdWQKg5UZ6I6k7SLwpTMPuwiqnSEX6uey1bz1TnAINl1Ey22gh7SKjE9auP7N4bDPUwGAQS1xiLdsrFh3R2Kr3LHRgIBuVLWm86BlyZaAhlVmIpYnwMm2hYtHG5nRQtLhegQW1cmvMhPjeSvmvdk9G8qrvy5Q9SMLKGnXIYgxvF1C2FrWUjS9Il+JYr0wUZOWOcEiuYW/SDfssKVuLtOgJkRZ72dYgP37umqJ2vQoSwdgiIr3PdhAf3Cz8NP8Nk3jOQsaisHD+sf7PNn1ekAFxmjgRFedP7FsoU985VFKUpzbLb6G+Ii0WxrDUUhm1EXx6j6WU+XkLgF6Pbxm23wzG2WwgNZ7DudluwRu0gzTbhluS6jD/6lB9EZrLz0VCROPoC7REJyP8U0Rb+CdlNI4QCXDwehJvt8lSfeRTogKZbt3+0RRhzSai+G9H6eTiQ0oN8Qc+Rwr8Ib8pc9koHs8dW556E4EbiN63VC7aeY9fRkzQLuRBWFCAuGjR+Fk2JJfA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:07.7676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0443fc22-94b3-407e-25ce-08db45a6d713 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: AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB8291 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: KKWcxdPzMPys9e8VOIPxAX3px1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438719; bh=By3XzssD5GPwihPY62ZoiVEMMd4Vjz5xqi21D0Ql4fQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=vN1C5T3paCmmeqFc6G0sIM+1jgtremtWQLELEuw86GYe/3SRgokG8OXHjEI+z9lKynb HBeiiWM346bpa41Hm/WHsrRnWLvdEvuFf4EYKoHyAie87tvFIHKaSC6aQ1LjZkSP8voHA JegLi4yExJ1c6ARXxmXrtnQLRFk6CQa0kzQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438720903100081 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add ArmCcaDxe for early DXE phase initialisation like setting up the monitor call conduit for Realm code The Realm code should use SMC as the conduit for monitor calls. Therefore, set the PcdMonitorConduitHvc to FALSE if the code is running in a Realm. Note: ArmCcaDxe is configured as an APRIORI DXE so that the DXE dispatcher can schedule this to be loaded at the very beginning of the Dxe phase. The DevicePathDxe.inf and Pcd.inf modules have also been included to satisfy the required dependencies. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.c | 50 ++++++++++++++++++++ ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.inf | 39 +++++++++++++++ ArmVirtPkg/ArmVirtKvmTool.dsc | 5 +- ArmVirtPkg/ArmVirtKvmTool.fdf | 10 ++++ 4 files changed, 102 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.c b/ArmVirtPkg/ArmCcaDxe/ArmCca= Dxe.c new file mode 100644 index 0000000000000000000000000000000000000000..36a74f2521d2d92d404c42e86d5= d37dd31a1972d --- /dev/null +++ b/ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.c @@ -0,0 +1,50 @@ +/** @file + ArmCcaDxe + + Copyright (c) 2022 - 2023, ARM Ltd. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** Entrypoint of Arm CCA Dxe. + + @param [in] ImageHandle Image handle of this driver. + @param [in] SystemTable Pointer to the EFI System Table. + + @retval RETURN_SUCCESS Success. + @retval EFI_NOT_FOUND Required HOB not found. +**/ +EFI_STATUS +EFIAPI +ArmCcaDxe ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (!IsRealm ()) { + // Nothing to do here, return SUCCESS. + return EFI_SUCCESS; + } + + // Setup the conduit to be used by Realm code to SMC. + Status =3D PcdSetBoolS (PcdMonitorConduitHvc, FALSE); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "ERROR - Failed to set PcdMonitorConduitHvc\n")); + ASSERT (0); + return Status; + } + + return Status; +} diff --git a/ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.inf b/ArmVirtPkg/ArmCcaDxe/ArmC= caDxe.inf new file mode 100644 index 0000000000000000000000000000000000000000..df110ae54ce54f792fe9cf94203= 34dd1e6a3fc2c --- /dev/null +++ b/ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.inf @@ -0,0 +1,39 @@ +## @file +# ArmCcaDxe +# +# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D ArmCcaDxe + FILE_GUID =3D 6E474F73-7D50-46A8-9AEB-996B71599FE9 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D ArmCcaDxe + +[Sources] + ArmCcaDxe.c + +[LibraryClasses] + ArmCcaLib + BaseLib + DebugLib + HobLib + PcdLib + UefiDriverEntryPoint + +[Packages] + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[Pcd] + gArmTokenSpaceGuid.PcdMonitorConduitHvc + +[Depex] + TRUE diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index 9bc857ea88d00431bf4223f588f908eab7561a19..acf4ede48da2d33d50b5593a857= f3815f427707c 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -404,9 +404,10 @@ [Components.common] # SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf =20 -!if $(ARCH) =3D=3D AARCH64 +[Components.AARCH64] # # ACPI Support # ArmVirtPkg/KvmtoolCfgMgrDxe/ConfigurationManagerDxe.inf -!endif + + ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.inf diff --git a/ArmVirtPkg/ArmVirtKvmTool.fdf b/ArmVirtPkg/ArmVirtKvmTool.fdf index 8ccbccd71e134e0ea97d49380293687aca43e8b9..68bd0e9d82dc83a337d8127a598= 018381888d894 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.fdf +++ b/ArmVirtPkg/ArmVirtKvmTool.fdf @@ -117,6 +117,16 @@ [FV.FvMain] READ_LOCK_CAP =3D TRUE READ_LOCK_STATUS =3D TRUE =20 +!if $(ARCH) =3D=3D AARCH64 + APRIORI DXE { + INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf + INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.inf + } + + INF ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.inf +!endif + INF MdeModulePkg/Core/Dxe/DxeMain.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf INF OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103576): https://edk2.groups.io/g/devel/message/103576 Mute This Topic: https://groups.io/mt/98495990/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103573+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438716699206.00245457753476; Tue, 25 Apr 2023 09:05:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DSxHYY1788612xbYKZksP72h; Tue, 25 Apr 2023 09:05:16 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.55]) by mx.groups.io with SMTP id smtpd.web10.83981.1682438715427432005 for ; Tue, 25 Apr 2023 09:05:15 -0700 X-Received: from AS9P194CA0010.EURP194.PROD.OUTLOOK.COM (2603:10a6:20b:46d::10) by VE1PR08MB5599.eurprd08.prod.outlook.com (2603:10a6:800:1a1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:10 +0000 X-Received: from AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46d:cafe::4b) by AS9P194CA0010.outlook.office365.com (2603:10a6:20b:46d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:10 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103573+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT023.mail.protection.outlook.com (100.127.140.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:09 +0000 X-Received: ("Tessian outbound 5bb4c51d5a1f:v136"); Tue, 25 Apr 2023 16:05:09 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 206fe9afc39f0bae X-CR-MTA-TID: 64aa7808 X-Received: from 14d279b19fbc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3584204F-8AA4-420A-BB0F-A43DC9C6F228.1; Tue, 25 Apr 2023 16:05:03 +0000 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 14d279b19fbc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:05:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WRQ29gjyC/trZN05MnqUaOrhG6w+PHXAOnujWeKb2XRtjRNoLPOm78/BDU9tAMGOQ/kz888FaY4R/VlkfxUHAnwvxqH0rSn0p7Vc4C3ZT0FBRshAGKfNvwxP8qXim9x3786EjrhjrKqNTUSH8ZAhYhCZPmXLQbEvHjxzOTyqbTnfDN/QRTSSIT/z80jQ47cGp0oxqNpcWX9anFr2idqDydsBmQjDawByXEDyhgIXb0YWSiw6HXSS63QqDN5rqPglA3AkzmG4zzxYsj7iFbLmI9jFl0FbD1y/ooP95L2Q8q4XIgKUPjdwJU4SUR5b0ox3H5vilxuNXJmi39OMRgZNFA== 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=XGKhiPM28kQmNQZ53DXXjOTV+7RMJgsllUU9E4pgz0Q=; b=iJi2zhrMdztmfcyvQGMvVIJ2srN3LEkasZFKE1ebFKUdOhH3WFPn81jGygVxwzPPuARpWabPA9pdwBTWcPDn5S1GpnsXT4KYNG5QNjnYAnMTYjidAvjftrAD8NpOGiLGtaitNc72FDiuC0Lp19dFDIKpx4x9xK2BuBE/u9lbl0e90fUFCwQ7oR7qD9j0chs/BSP7J9d4wv8dwSVxngdKxJOvlE5qGY+vsn4gtsMrHY16DPtylqxZIFaVgrFYk2G+4g6w/ULyJO0THUXyS0Wm0a0TiycviEU1hFt8rz68Zt9hZdwgJDF0CdFs2FK0arbpz0wgqE2lcwyD+M5tadF+yA== 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 X-Received: from DUZPR01CA0177.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::26) by DB9PR08MB7673.eurprd08.prod.outlook.com (2603:10a6:10:37c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: from DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::24) by DUZPR01CA0177.outlook.office365.com (2603:10a6:10:4b3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +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 DBAEUR03FT024.mail.protection.outlook.com (100.127.142.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:57 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:55 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:54 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 26/30] ArmVirtPkg: Introduce Realm Aperture Management Protocol Date: Tue, 25 Apr 2023 17:04:24 +0100 Message-ID: <20230425160428.27980-27-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT024:EE_|DB9PR08MB7673:EE_|AM7EUR03FT023:EE_|VE1PR08MB5599:EE_ X-MS-Office365-Filtering-Correlation-Id: 89a95bb9-d3a6-415d-24f4-08db45a6d85c 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: ZaYG3JHxJvXgdqTEuqJ/Kboa9zPTtYUaCbLn8Trb211XD1FWR49/4A+48yKc+gwgk990Y72aFJ4cptR7go3WJoFLTQnuUVVAElT2XepIqmcLl2PLb3dZut75r0cP0h89Doo0mUFMlGhyj1UnF2iVHrj1uyINDE4sNi9UZIhoICbeseY+zbny8awHA1TKgYXYETh/BL5wzUxS52kjxdwEcgR7UwwIgtwj6ebPEg8wcl+B1PU1ydAL+T+ytAcke2UqE85vz4FjM5sYz20rKXXYgeubY7zPTmlqZpmBYd0YiUBiiVj8SOrhHcNY5Y9mGX986k4ur7HO0kV3S2i9nPRg/gEZAokbaklT4tzmteFGlpIyCXCQOBXBsfkkfyZmvJwqdM7pdcmJck9lCaSPcFYFE4eIgE5arbGOTrqHj9CcWaHG0Uk3qH/BkKuQnbmkNThOMPROfBV+G8rnuUdHj2M+x66v6ctrvANiJvWuVgSD77t0c3EBYc698+HnTLIFP37KivTJl0hXt/YzM9UG7HJV1hGyZx9i/L8ldpTV3WkcikZnU+hmqg4OsNp42jahFZObBZ8c2tIevri8XB0BES1GsNNt5qHnNWy04Xp9PcTNIPOhJmuPrHYHuuXmgKEqBj+yVvhDTgrnHyyk2PfnS5aoUA+IUiY/hO+OgqabFfpbVIowcDdYUkXKpmmjxnpIToVcT4MIaZG2U+19SYHC0ug6+J2DQoAFuZP8AYih2NWbUWalLK2Za0IwruCJW+sAssxDFRXSDRg9BZO+hxLWgub0hw== 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:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(46966006)(36840700001)(82740400003)(34070700002)(44832011)(7696005)(70586007)(6916009)(70206006)(2906002)(6666004)(30864003)(1076003)(8936002)(40480700001)(336012)(426003)(186003)(83380400001)(8676002)(2616005)(41300700001)(36860700001)(26005)(5660300002)(316002)(47076005)(86362001)(54906003)(36756003)(4326008)(81166007)(356005)(82310400005)(478600001)(36900700001)(44824005);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7673 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e24916ca-9e8b-47a0-0252-08db45a6d20f X-Microsoft-Antispam-Message-Info: ZyrsBpTS0jbEpCc9Vxgl4fRub1EPgmlC53oi1/I5AIQOoAbD7zUvm5DHRGDRrSB3mw0ZSa8ZRXK5kZfWiVLccFh1tBQxyFa5+Y+vA5Faq6YD7FeLPzvYQrRjWC7E0YasWJTpZbRVwDi7sk+00/xfH9p4JXRg4C9BhzUg51VtyhrdQATvyfhimK/EN6gMARL10lfTzhif6ipeS6Wc21WXg6IOSg7wsZNkHny2ssiik8x37AoIKDGj5+ybnIDGi3HF4ZrpE7Dj0OfZrUttmN6vxJJWwLItd8wdZepoMfYPrKeIpClTfW+LhQRpuqdyRcns2Ma3SlO+0WslS5YIhzpIL/uMU3x/QHrKaqvYusdyKzTN5uXcVNtzfgXVl5SuFRh8jF4ckUOh9Ln6f56OOH4oxVjEPKlbSucKv2+sIiEhPHe+JND18xO7kAOWUhXlGPTWPob2uxUG4HXYg1SeoAcShhxCHyIfMuILFKGnpjeOw4l0NEXZ7HubtgaLckrI49AV1Wqibn5CcEKvIuGL3mYBLj5PpBDC+NZ4JmcS2sd8eqKO2pr3CO4hkfhAEE50bNkDQwpyVS6/zKSY3h15tZ0QUSg87Ifngqu15j8pRrgEcyMpA6Y6YNm4u67f/hym3gzY9Xy7f+NC6cozeWzafLufUDlkzzjaoIqJ4vURrzWQ7YttrCNIkRqzxzep0hzFfiN765mtmzXrcsS+73Yq4f+/UA0lA8bebj2rd1HbDJKIPX21nVUpaUaj/U+8ytqrWzarA8gqTQUc9q8AlreovTSrTQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:09.9081 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89a95bb9-d3a6-415d-24f4-08db45a6d85c 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: AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5599 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: OkQ0RHGjLQsMOwgqIZElGJmOx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438716; bh=amTc13YHil2bmkeLnzCl6lfuc8jqjgJGlBgZVnOrBgk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Pi5T7S/3WBByMwkSYnWSWuD6Y/Otob9PAwOJ63dQVteCpFqbZ7NRgKZvmXEBfjXIc3T +RlYrvCA4tGxVY7Pwx4LIf16ls0E6cP27nR+s++9NUL/vTNAJahWwe8Clkh229r9Rbns3 KvYwuV5jZ7NoMe10gI9VfW2M9yPkugwXzWI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438719057100075 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Realm Aperture Management Protocol (RAMP) is used to manage the sharing of buffers between the Guest and Host. It configures the memory regions as Protected EMPTY or Protected RAM by calling RSI_IPA_STATE_SET command. The RAMP provides interfaces that device drivers can use to open/close apertures for sharing buffers. The RAMP also keeps track of the apertures that have been opened and closes them on ExitBootServices. It also registers for reset notification and closes all open apertures before the platform resets the system. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtPkg.dec = | 3 + ArmVirtPkg/Include/Protocol/RealmApertureManagementProtocol.h = | 103 +++ ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmApertureManagementProto= colDxe.c | 656 ++++++++++++++++++++ ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmApertureManagementProto= colDxe.inf | 48 ++ 4 files changed, 810 insertions(+) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index c61ed9c492e97aa00ba9dbab1a5544354b6e7de7..5f5fb0f0d911f871ffdf0d8e7d1= d181d31093679 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -44,6 +44,9 @@ [PcdsFeatureFlag] # gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|FALSE|BOOLEAN|0x00000004 =20 +[Protocols] + gEfiRealmApertureManagementProtocolGuid =3D { 0x585c00be, 0xcf7c, 0x4db8= , { 0x8a, 0xa2, 0x49, 0xd, 0x67, 0xf5, 0xf6, 0xe6 } } + [PcdsFixedAtBuild, PcdsPatchableInModule] # # This is the physical address where the device tree is expected to be s= tored diff --git a/ArmVirtPkg/Include/Protocol/RealmApertureManagementProtocol.h = b/ArmVirtPkg/Include/Protocol/RealmApertureManagementProtocol.h new file mode 100644 index 0000000000000000000000000000000000000000..0f45fd296fd54ec536ed3d4bd77= 25350ab487295 --- /dev/null +++ b/ArmVirtPkg/Include/Protocol/RealmApertureManagementProtocol.h @@ -0,0 +1,103 @@ +/** @file + Realm Aperture Management Protocol (RAMP) + On Arm CCA Systems the Realm protects access and visibility of Guest mem= ory + and code execution from software outside the realm. + + However, software executing in a Realm needs to interact with the extern= al + world. This may be done using virtualised disk, network interfaces, etc. + The drivers for these virtualised devices need to share buffers with the= host + OS to exchange information/data. + + Since the Guest memory is protected by the Realm, the host cannot access= these + buffers unless the IPA state of the buffers is changed to Protected EMPT= Y by + the software executing in the Realm. + + By enabling the sharing of the buffers, we are essentially opening an + aperture so that the host OS can access the range of pages that are shar= ed. + + The virtual firmware (Guest firmware) needs a mechanism to manage the sh= aring + of buffers. The Realm Aperture Management Protocol provides an interface= that + UEFI drivers/modules can use to enable/disable the sharing of buffers wi= th the + Host. The protocol also tracks open apertures and ensures they are shut = on + ExitBootServices. + + Copyright (c) 2022 - 2023, ARM Ltd. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - RAMP - Realm Aperture Management Protocol +**/ + +#ifndef REALM_APERTURE_MANAGEMENT_PROTOCOL_H_ +#define REALM_APERTURE_MANAGEMENT_PROTOCOL_H_ + +/** This macro defines the Realm Aperture Management Protocol GUID. + + GUID: {585C00BE-CF7C-4DB8-8AA2-490D67F5F6E6} +*/ +#define EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL_GUID \ + { 0x585c00be, 0xcf7c, 0x4db8, \ + { 0x8a, 0xa2, 0x49, 0xd, 0x67, 0xf5, 0xf6, 0xe6 } \ + }; + +/** This macro defines the Realm Aperture Management Protocol Revision. +*/ +#define EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL_REVISION 0x00010000 + +#pragma pack(1) + +/** Enables sharing of the memory buffers with the host. + + @param [in] Memory Pointer to the page start address. + @param [in] Pages Number of pages to share. + @param [out] ApertureReference Reference to the opened aperture. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + @retval EFI_ACCESS_DENIED Aperture already open over memory region. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL_OPEN_APERTURE)( + IN CONST EFI_PHYSICAL_ADDRESS Memory, + IN CONST UINTN Pages, + OUT EFI_HANDLE *CONST ApertureReference + ); + +/** Disables the sharing of the buffers. + + @param [in] ApertureReference Reference to the aperture for closing. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required buffer information is not f= ound. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL_CLOSE_APERTURE)( + IN CONST EFI_HANDLE ApertureReference + ); + +/** A structure describing the interface provided by the Realm Aperture + Management Protocol. +*/ +typedef struct RealmApertureManagementProtocol { + /// The Realm Aperture Management Protocol revision. + UINT64 Revision; + + /// Shares Realm Pages(s) with the Host. + EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL_OPEN_APERTURE OpenAperture; + + /// Makes the Realm Pages(s) private to the Realm. + EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL_CLOSE_APERTURE CloseAperture; +} EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL; + +/** The Realm Aperture Management Protocol GUID. +*/ +extern EFI_GUID gEfiRealmApertureManagementProtocolGuid; + +#pragma pack() + +#endif // REALM_APERTURE_MANAGEMENT_PROTOCOL_H_ diff --git a/ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmApertureMan= agementProtocolDxe.c b/ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmA= pertureManagementProtocolDxe.c new file mode 100644 index 0000000000000000000000000000000000000000..f6c31125209468cfe24c4ea4b0e= b74e08fe3e2f2 --- /dev/null +++ b/ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmApertureManagement= ProtocolDxe.c @@ -0,0 +1,656 @@ +/** @file + Realm Aperture Management Protocol Dxe + + Copyright (c) 2022 - 2023, Arm Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - IPA - Intermediate Physical Address + - RAMP - Realm Aperture Management Protocol + - RIPAS - Realm IPA state + - RSI - Realm Service Interface +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + A macro defining the signature for the aperture information structure. +*/ +#define APERTURE_INFO_SIG SIGNATURE_64 ('A', 'P', 'E', 'R', 'T', 'U', 'R'= , 'E') + +/** + A structure describing the aperture. +*/ +typedef struct { + /// Signature for identifying this structure. + UINT64 Signature; + + /// The linked list entry. + LIST_ENTRY Link; + + /// The base address for the start of the aperture. + EFI_PHYSICAL_ADDRESS BaseAddress; + + /// The number of pages covered by the aperture. + UINTN Pages; + + /// The bit mask of attributes for the memory region. The + /// bit mask of available attributes is defined in GetMemoryMap(). + UINT64 MemoryAttributes; + + /// The RIPAS for the aperture. + RIPAS Ripas; +} APERTURE_INFO; + +/** + List of the APERTURE_INFO structures that have been set up by OpenApertu= re() + and not yet torn down by CloseAperture(). The list represents the full s= et + of open apertures currently in effect. +*/ +STATIC +LIST_ENTRY mApertureInfos =3D INITIALIZE_LIST_HEAD_VARIABLE (mApertureInf= os); + +/** + A local variable to store the IPA width of the Realm. The IPA width + of the Realm is required to configure the protection attribute of + memory regions. +*/ +STATIC UINT64 mIpaWidth; + +/** Checks if an open aperture is overlapping the memory region. + + @param [in] Memory Pointer to the page start address. + @param [in] Pages Number of pages to share. + + @retval TRUE If memory region overlaps an open aperture. + @retval FALSE Memory region does not overlap any open apertures. +**/ +STATIC +BOOLEAN +EFIAPI +IsApertureOverlapping ( + IN CONST EFI_PHYSICAL_ADDRESS MemStart, + IN CONST UINTN Pages + ) +{ + LIST_ENTRY *Node; + LIST_ENTRY *NextNode; + APERTURE_INFO *ApertureInfo; + EFI_PHYSICAL_ADDRESS MemEnd; + EFI_PHYSICAL_ADDRESS ApertureStart; + EFI_PHYSICAL_ADDRESS ApertureEnd; + + MemEnd =3D MemStart + (EFI_PAGE_SIZE * Pages) - 1; + + // All drivers that had opened the apertures have halted their respective + // controllers by now; close all the apertures. + for ( + Node =3D GetFirstNode (&mApertureInfos); + Node !=3D &mApertureInfos; + Node =3D NextNode + ) + { + NextNode =3D GetNextNode (&mApertureInfos, Node); + ApertureInfo =3D CR (Node, APERTURE_INFO, Link, APERTURE_INFO_SIG); + ApertureStart =3D ApertureInfo->BaseAddress; + ApertureEnd =3D ApertureStart + (EFI_PAGE_SIZE * ApertureInfo->Pages= ) - 1; + + if (((ApertureStart >=3D MemStart) && (ApertureStart <=3D MemEnd)) || + ((ApertureEnd >=3D MemStart) && (ApertureEnd <=3D MemEnd)) || + ((MemStart >=3D ApertureStart) && (MemStart <=3D ApertureEnd)) || + ((MemEnd >=3D ApertureStart) && (MemEnd <=3D ApertureEnd))) + { + return TRUE; + } + } + + return FALSE; +} + +/** Enables sharing of the memory buffers with the host. + + @param [in] Memory Pointer to the page start address. + @param [in] Pages Number of pages to share. + @param [out] ApertureReference Reference to the opened aperture. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + @retval EFI_ACCESS_DENIED Aperture already open over memory region. +**/ +STATIC +EFI_STATUS +EFIAPI +RampOpenAperture ( + IN CONST EFI_PHYSICAL_ADDRESS Memory, + IN CONST UINTN Pages, + OUT EFI_HANDLE *CONST ApertureReference + ) +{ + EFI_STATUS Status; + EFI_STATUS Status1; + APERTURE_INFO *ApertInfo; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; + EFI_PHYSICAL_ADDRESS MemRangeAddr; + UINTN Index; + + if ((Memory =3D=3D 0) || + (Pages =3D=3D 0) || + (ApertureReference =3D=3D NULL) || + ((Memory & (EFI_PAGE_SIZE - 1)) !=3D 0)) + { + return EFI_INVALID_PARAMETER; + } + + // The pages size must be aligned to the Realm Granule size. + STATIC_ASSERT ((EFI_PAGE_SIZE & (REALM_GRANULE_SIZE - 1)) =3D=3D 0); + + // Checks if we already have an open aperture that overlaps the + // memory region. If so return the request as invalid. + if (IsApertureOverlapping (Memory, Pages)) { + return EFI_INVALID_PARAMETER; + } + + MemRangeAddr =3D Memory; + for (Index =3D 0; Index < Pages; Index++) { + Status =3D gDS->GetMemorySpaceDescriptor (MemRangeAddr, &GcdDescriptor= ); + if (EFI_ERROR (Status)) { + return Status; + } + + DEBUG (( + DEBUG_INFO, + "%a: Memory =3D 0x%lx, MemType =3D %a\n", + __func__, + MemRangeAddr, + ((GcdDescriptor.Attributes & EFI_MEMORY_RUNTIME) =3D=3D EFI_MEMORY_R= UNTIME) ? + "Runtime Services Memory" : "Boot Services Memory" + )); + + // We currently do not have a usecase where we would want to open aper= tures + // for runtime services memory + if ((GcdDescriptor.Attributes & EFI_MEMORY_RUNTIME) =3D=3D EFI_MEMORY_= RUNTIME) { + return EFI_UNSUPPORTED; + } + + MemRangeAddr +=3D EFI_PAGE_SIZE; + } // for + + Status =3D ArmCcaSetMemoryProtectAttribute ( + Memory, + EFI_PAGES_TO_SIZE (Pages), + mIpaWidth, + TRUE + ); + if (RETURN_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to update page tables for Protected EMPTY page mappin= g, " + "Address =3D %p, Pages =3D 0x%lx, Status =3D %r\n", + Memory, + Pages, + Status + )); + return Status; + } + + // Allocate a APERTURE_INFO structure to remember the apertures opened. + ApertInfo =3D AllocateZeroPool (sizeof (APERTURE_INFO)); + if (ApertInfo =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto error_handler1; + } + + InitializeListHead (&ApertInfo->Link); + ApertInfo->Signature =3D APERTURE_INFO_SIG; + ApertInfo->BaseAddress =3D Memory; + ApertInfo->Pages =3D Pages; + ApertInfo->MemoryAttributes =3D GcdDescriptor.Attributes; + ApertInfo->Ripas =3D RIPAS_EMPTY; + + DEBUG (( + DEBUG_INFO, + "%a: ApertRef =3D 0x%p, Memory =3D 0x%lx, Pages =3D 0x%x, " + "MemoryAttributes =3D 0x%x, Ripas =3D 0x%x\n", + __func__, + ApertInfo, + ApertInfo->BaseAddress, + ApertInfo->Pages, + ApertInfo->MemoryAttributes, + ApertInfo->Ripas + )); + + // Set the Realm IPA state to Empty to open the Aperture + Status =3D RsiSetIpaState ( + (UINT64 *)Memory, + (Pages * EFI_PAGE_SIZE), + RIPAS_EMPTY + ); + if (RETURN_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: RSI Set IPA State failed, Address =3D %p, Pages =3D 0x%lx, " + "Status =3D %r\n", + Memory, + Pages, + Status + )); + goto error_handler; + } + + DEBUG (( + DEBUG_INFO, + "SUCCESS: RSI Set IPA State complete, Address =3D %p, Pages =3D 0x%lx,= " + "Status =3D %r\n", + Memory, + Pages, + Status + )); + + InsertHeadList (&mApertureInfos, &ApertInfo->Link); + *ApertureReference =3D (EFI_HANDLE *)&ApertInfo->Link; + + return Status; + +error_handler: + + FreePool (ApertInfo); + +error_handler1: + Status1 =3D ArmCcaSetMemoryProtectAttribute ( + Memory, + EFI_PAGES_TO_SIZE (Pages), + mIpaWidth, + TRUE + ); + if (RETURN_ERROR (Status1)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to update page tables to Protected page mapping, " + "Address =3D %p, Pages =3D 0x%lx, Status =3D %r\n", + Memory, + Pages, + Status1 + )); + } + + *ApertureReference =3D NULL; + // return the first error code + return Status; +} + +/** Disables the sharing of the buffers. + + @param [in] ApertureReference Reference to the aperture for closing. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required buffer information is not f= ound. +**/ +STATIC +EFI_STATUS +EFIAPI +RampCloseAperture ( + IN CONST EFI_HANDLE ApertureReference + ) +{ + EFI_STATUS Status; + APERTURE_INFO *ApertInfo =3D NULL; + + if (ApertureReference =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + ApertInfo =3D CR (ApertureReference, APERTURE_INFO, Link, APERTURE_INFO_= SIG); + if (ApertInfo =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + DEBUG (( + DEBUG_INFO, + "%a: ApertRef =3D 0x%p, Memory =3D 0x%lx, Pages =3D 0x%x, " + "MemoryAttributes =3D 0x%x, Ripas =3D 0x%x\n", + __func__, + ApertInfo, + ApertInfo->BaseAddress, + ApertInfo->Pages, + ApertInfo->MemoryAttributes, + ApertInfo->Ripas + )); + + // Set the Realm IPA state to RAM to close the Aperture + Status =3D RsiSetIpaState ( + (UINT64 *)ApertInfo->BaseAddress, + (ApertInfo->Pages * EFI_PAGE_SIZE), + RIPAS_RAM + ); + if (RETURN_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: RSI Set IPA State failed, Address =3D %p, Pages =3D 0x%lx, " + "Status =3D %r\n", + ApertInfo->BaseAddress, + ApertInfo->Pages, + Status + )); + return Status; + } + + Status =3D ArmCcaSetMemoryProtectAttribute ( + ApertInfo->BaseAddress, + EFI_PAGES_TO_SIZE (ApertInfo->Pages), + mIpaWidth, + FALSE + ); + if (RETURN_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to update page tables for Protected RAM page mapping," + "Address =3D %p, Pages =3D 0x%lx, Status =3D %r\n", + ApertInfo->BaseAddress, + ApertInfo->Pages, + Status + )); + } + + RemoveEntryList (&ApertInfo->Link); + FreePool (ApertInfo); + + return Status; +} + +/** Closes all open apertures. + +**/ +STATIC +VOID +EFIAPI +RampCloseAllApertures ( + VOID + ) +{ + LIST_ENTRY *Node; + LIST_ENTRY *NextNode; + APERTURE_INFO *ApertureInfo; + + // All drivers that had opened the apertures have halted their respective + // controllers by now; close all the apertures. + for ( + Node =3D GetFirstNode (&mApertureInfos); + Node !=3D &mApertureInfos; + Node =3D NextNode + ) + { + NextNode =3D GetNextNode (&mApertureInfos, Node); + ApertureInfo =3D CR (Node, APERTURE_INFO, Link, APERTURE_INFO_SIG); + RampCloseAperture (&ApertureInfo->Link); + } +} + +/** + Notification function that is queued after the notification functions of= all + events in the EFI_EVENT_GROUP_EXIT_BOOT_SERVICES event group. + + This function invokes the closing of all open apertures. + + @param[in] Event Event whose notification function is being invoked. = Event + is permitted to request the queueing of this function + only at TPL_CALLBACK task priority level. + + @param[in] Context Ignored. +**/ +STATIC +VOID +EFIAPI +OnRampExitBootServicesEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + RampCloseAllApertures (); +} + +/** + Notification function that is queued when gBS->ExitBootServices() signal= s the + EFI_EVENT_GROUP_EXIT_BOOT_SERVICES event group. This function signals an= other + event, received as Context, and returns. + + Signaling an event in this context is safe. The UEFI spec allows + gBS->SignalEvent() to return EFI_SUCCESS only; EFI_OUT_OF_RESOURCES is n= ot + listed, hence memory is not allocated. + + @param[in] Event Event whose notification function is being inv= oked. + Event is permitted to request the queueing of = this + function at TPL_CALLBACK or TPL_NOTIFY task + priority level. + + @param[in] EventToSignal Identifies the EFI_EVENT to signal. EventToSig= nal + is permitted to request the queueing of its + notification function only at TPL_CALLBACK lev= el. +**/ +STATIC +VOID +EFIAPI +RampExitBootServices ( + IN EFI_EVENT Event, + IN VOID *EventToSignal + ) +{ + // (1) The NotifyFunctions of all the events in + // EFI_EVENT_GROUP_EXIT_BOOT_SERVICES will have been queued before + // RampExitBootServices() is entered. + // + // (2) RampExitBootServices() is executing minimally at TPL_CALLBACK. + // + // (3) RampExitBootServices() has been queued in unspecified order relat= ive + // to the NotifyFunctions of all the other events in + // EFI_EVENT_GROUP_EXIT_BOOT_SERVICES whose NotifyTpl is the same as + // Event's. + // + // Consequences: + // + // - If Event's NotifyTpl is TPL_CALLBACK, then some other NotifyFunctio= ns + // queued at TPL_CALLBACK may be invoked after RampExitBootServices() + // returns. + // + // - If Event's NotifyTpl is TPL_NOTIFY, then some other NotifyFunctions + // queued at TPL_NOTIFY may be invoked after RampExitBootServices() + // returns; plus *all* NotifyFunctions queued at TPL_CALLBACK will be + // invoked strictly after all NotifyFunctions queued at TPL_NOTIFY, + // including RampExitBootServices(), have been invoked. + // + // - By signaling EventToSignal here, whose NotifyTpl is TPL_CALLBACK, we + // queue EventToSignal's NotifyFunction after the NotifyFunctions of *= all* + // events in EFI_EVENT_GROUP_EXIT_BOOT_SERVICES. + gBS->SignalEvent (EventToSignal); +} + +/** A structure describing the Realm Aperture Management protocol. +*/ +STATIC +CONST +EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL Ramp =3D { + EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL_REVISION, + RampOpenAperture, + RampCloseAperture +}; + +/** + This routine is called to close all apertures before system reset. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatus The status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, = or + EfiResetShutdown the data buffer starts with a = Null- + terminated string, optionally followed by addit= ional + binary data. The string is a description that t= he + caller may use to further indicate the reason f= or + the system reset. ResetData is only valid if + ResetStatus is something other than EFI_SUCCESS + unless the ResetType is EfiResetPlatformSpecific + where a minimum amount of ResetData is always + required. + For a ResetType of EfiResetPlatformSpecific the= data + buffer also starts with a Null-terminated string + that is followed by an EFI_GUID that describes = the + specific type of reset to perform. +**/ +VOID +EFIAPI +OnResetEvent ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ) +{ + RampCloseAllApertures (); +} + +/** + Hook the system reset to close all apertures. + + @param[in] Event Event whose notification function is being invoked + @param[in] Context Pointer to the notification function's context +**/ +VOID +EFIAPI +OnResetNotificationInstall ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotify; + + Status =3D gBS->LocateProtocol ( + &gEfiResetNotificationProtocolGuid, + NULL, + (VOID **)&ResetNotify + ); + if (!EFI_ERROR (Status)) { + Status =3D ResetNotify->RegisterResetNotify (ResetNotify, OnResetEvent= ); + ASSERT_EFI_ERROR (Status); + DEBUG ((DEBUG_INFO, "RAMP: Hook system reset to close all apertures.\n= ")); + gBS->CloseEvent (Event); + } +} + +/** Entry point for Realm Aperture Management Protocol Dxe + + @param [in] ImageHandle Handle for this image. + @param [in] SystemTable Pointer to the EFI system table. + + @retval EFI_SUCCESS When executing in a Realm the RAMP was + installed successfully. + When execution context is not a Realm, t= his + function returns success indicating noth= ing + needs to be done and allow other modules= to + run. + @retval EFI_OUT_OF_RESOURCES There was not enough memory to install t= he + protocols. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + +**/ +EFI_STATUS +EFIAPI +RealmApertureManagementProtocolDxeInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle =3D NULL; + EFI_EVENT CloseAllAperturesEvent; + EFI_EVENT ExitBootEvent; + VOID *Registration; + + // When the execution context is a Realm, install the Realm Aperture + // Management protocol otherwise return success so that other modules + // can run. + if (!IsRealm ()) { + return EFI_SUCCESS; + } + + // Retrieve the IPA Width of the Realm for subsequent use to configure + // the protection attribute of memory regions. + Status =3D GetIpaWidth (&mIpaWidth); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to get Ipa Width, Status =3D %r\n", + Status + )); + ASSERT (0); + return Status; + } + + /* + Create the "late" event whose notification function will close all + apertures. + */ + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, // Type + TPL_CALLBACK, // NotifyTpl + OnRampExitBootServicesEvent, // NotifyFunction + NULL, // NotifyContext + &CloseAllAperturesEvent // Event + ); + if (EFI_ERROR (Status)) { + return Status; + } + + /* + Create the event whose notification function will be queued by + gBS->ExitBootServices() and will signal the event created above. + */ + Status =3D gBS->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, // Type + TPL_CALLBACK, // NotifyTpl + RampExitBootServices, // NotifyFunction + CloseAllAperturesEvent, // NotifyContext + &ExitBootEvent // Event + ); + if (EFI_ERROR (Status)) { + goto error_handler1; + } + + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gEfiRealmApertureManagementProtocolGuid, + &Ramp, + NULL + ); + if (!EFI_ERROR (Status)) { + // RAMP Protocol installed successfully + // Hook the system reset to close all apertures. + EfiCreateProtocolNotifyEvent ( + &gEfiResetNotificationProtocolGuid, + TPL_CALLBACK, + OnResetNotificationInstall, + NULL, + &Registration + ); + return Status; + } + + // cleanup on error + gBS->CloseEvent (ExitBootEvent); + +error_handler1: + gBS->CloseEvent (CloseAllAperturesEvent); + return Status; +} diff --git a/ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmApertureMan= agementProtocolDxe.inf b/ArmVirtPkg/RealmApertureManagementProtocolDxe/Real= mApertureManagementProtocolDxe.inf new file mode 100644 index 0000000000000000000000000000000000000000..2e3021b82bd75b7f41dc9427117= a8394dfde2e68 --- /dev/null +++ b/ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmApertureManagement= ProtocolDxe.inf @@ -0,0 +1,48 @@ +## @file +# Module to manage the sharing of buffers in a Realm with the Host. +# +# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D RealmApertureManagementProtocolDxe + FILE_GUID =3D CEC2F7D5-2564-46D4-A23F-501623F7F56A + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D RealmApertureManagementProtocolDxeIni= tialize + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D AARCH64 +# + +[Sources] + RealmApertureManagementProtocolDxe.c + +[Packages] + ArmVirtPkg/ArmVirtPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmCcaLib + ArmCcaRsiLib + BaseLib + DxeServicesTableLib + MemoryAllocationLib + PrintLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + gEfiRealmApertureManagementProtocolGuid ## SOMETIME_PRODUCES + gEfiResetNotificationProtocolGuid ## CONSUMES + +[Depex] + TRUE --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103573): https://edk2.groups.io/g/devel/message/103573 Mute This Topic: https://groups.io/mt/98495984/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103577+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438720738968.8453735442146; Tue, 25 Apr 2023 09:05:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id GVUaYY1788612x0ZrELGUye6; Tue, 25 Apr 2023 09:05:20 -0700 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com (EUR03-AM7-obe.outbound.protection.outlook.com [40.107.105.84]) by mx.groups.io with SMTP id smtpd.web11.83471.1682438719148595243 for ; Tue, 25 Apr 2023 09:05:19 -0700 X-Received: from DB6PR0301CA0072.eurprd03.prod.outlook.com (2603:10a6:6:30::19) by DB9PR08MB8626.eurprd08.prod.outlook.com (2603:10a6:10:3d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:15 +0000 X-Received: from DBAEUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::a0) by DB6PR0301CA0072.outlook.office365.com (2603:10a6:6:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:15 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103577+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT053.mail.protection.outlook.com (100.127.142.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:15 +0000 X-Received: ("Tessian outbound 5bb4c51d5a1f:v136"); Tue, 25 Apr 2023 16:05:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 11b99f782ac843df X-CR-MTA-TID: 64aa7808 X-Received: from 3cda25c21982.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D74C2708-3F5A-4DCC-946C-7B9BADE3C51B.1; Tue, 25 Apr 2023 16:05:08 +0000 X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3cda25c21982.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:05:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HQMu2tHv2zmQ35sSWto3Ee8WqJOLP/RjdLu3qIhQ++DFj0EKSJH1viw0E3QHyCL6oN8zRUjiViUJn2cqYKTfP4LfooLfNBwyRbpN42EKVd9L/bTw4dFngcGrknzHdyeybl9bAtfcO4qfS0+K4oURimS+G1BMQQal/a+YA6gAiHk+hJH6Adr+mclTYHA+Hak1ed66Dt50VpYi3SeqOGP1N08twr4wvOGtL0+apRd+Fm3f30xBIfBLVuI3q90+rg+Y+eFvSrTgoiiB0s1WYZ7rPOqBdPZpFIra4jzyxtVCztxeRfWd1Cx83pOvTt2MWREKKfp32sO7RczK0nhUWGEBZg== 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=1l4sgj85KsehAy5cVHQsnXLpF5wHRCsCuadblcgBppA=; b=aXb0NXBDGnqqjCQ4DG+6KPdKtPejjFjwFmC3jggnpybxJgRFuLTSoPOr3KWe+h6zXrxtVV4/1LExyDF61k0SeEVhBeKzYvGMQrX9CRMsYLk8OrxP6EPg2hhSETL35rFg3H/s7Swxd7k3OWs0afEOUqApTwzu6+ZjztcPXX3rsW8nQP6+tCtmjfSUY0OhDnOiER8QB65KUeq8tV9BXOtpyQHQs8F2bjBNuk6Fw5wZsfBjcyMs2Ygq/7fza8BwlBaCXpGzlEO/mbXt152YmGDsgOcaD/qjRNZrQZQBJtuIXYFOT//Qt0Qa0+twq8HS/WAdhv/ouQHw6TIAcvWfH08bww== 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 X-Received: from DUZPR01CA0010.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::12) by PAVPR08MB9140.eurprd08.prod.outlook.com (2603:10a6:102:30b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Tue, 25 Apr 2023 16:05:01 +0000 X-Received: from DBAEUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c3:cafe::3a) by DUZPR01CA0010.outlook.office365.com (2603:10a6:10:3c3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:01 +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 DBAEUR03FT004.mail.protection.outlook.com (100.127.142.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:01 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:57 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:57 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 27/30] ArmVirtPkg: IoMMU driver to DMA from Realms Date: Tue, 25 Apr 2023 17:04:25 +0100 Message-ID: <20230425160428.27980-28-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT004:EE_|PAVPR08MB9140:EE_|DBAEUR03FT053:EE_|DB9PR08MB8626:EE_ X-MS-Office365-Filtering-Correlation-Id: 702689ac-1afd-4879-aa9a-08db45a6db6c 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: Al1nMliV4jQmJCZMWa8XIMelzke69fVDU2Urw0S2IVC4iIShpKZ8l93KlHcxStIS8f6DsbcPF4tXLdZ/PzpznhRvKwjWSejls51pDECxf/BV3b/ZRz1LLfellqgmU6nDnV48jrm4/v7V80ERLnazW1bL+ZUdW4xERxZ3a7CoKmEiV3WyLfBQ7uci27Rrd+saGWnDtQRbfY1PUy3Yc1kTBkh4AXcsxPaXE6Js4QXMcBZU7ISB0TgDH2h8//RXzjGkW8scrIEJzuC6He05ofQbHmixI2UPJgzU72nIQke2b0ZiIskUmmXevm8dcBc1jGa3ekWZ4E3eZQOv2aEaV03UTy/ShjTE7S4s9trpBp6dI7wDdOYovKfa329fEZCq897mXBnk02YAmYWbNRatt6zWZtFvmiUqO+YOaWOQQjOkj500iglGxGtkJQvdlNwMaRi8gWwvt/sw1Lae/0duXt9bAb0o0zB7F4EreD1RVP/VqliFPgAbJp5B+qfAn+ROPKc6SnhVCJzmUyBsk/LRsZtBZSnyhXgsZ2xQrgRNpf7d9PMBhzPgOXs0C+peQ2eMC91qnqD8iopl5193tP42NsLqLLu4q/63nn8HBib+gQwMqSxBoIf20FVcPxemWNZ/gyDfXBsUStTsnDdtv1khOoG7EIKFf79a3r/dDW3Ts+ZbYy+G+gKQazs+qt1L9jmKEAVZZLJq69fDOdoSBvjvrUAw4O49h22jVtlxjoZb+Upc4ayDib2LtVEoXja8W6bArlMvQMRXSZHAH068Y1xkJRbKIQ== 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:(13230028)(4636009)(136003)(39860400002)(346002)(376002)(396003)(451199021)(46966006)(36840700001)(82310400005)(1076003)(26005)(40480700001)(186003)(82740400003)(7696005)(6916009)(70206006)(6666004)(70586007)(36756003)(86362001)(41300700001)(54906003)(19627235002)(478600001)(83380400001)(4326008)(316002)(81166007)(356005)(36860700001)(426003)(44832011)(8936002)(2906002)(30864003)(2616005)(5660300002)(8676002)(34070700002)(47076005)(336012)(36900700001)(44824005);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9140 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 17e164e3-9f0e-485d-a5b4-08db45a6d369 X-Microsoft-Antispam-Message-Info: gomo+QLxUZYE8GYfqXDbwMYXmrgTp9+4G22eutytqqgpWStsJBEDyQON9jzkg8/fS6++VsXKjVr2PMoRKZdkkl7jDaDrsF4mw9phM4JRehcrvk6fsHrFS4ftIIyhXDduqHW1CmpY672TjSqN5Zk8nr4zLAz17oRC/t/pbyauUb94VW7Ybf92h303mGqdGrk4Wn1borMwOMUeTMVSjTogmssu4uDY7hU38rCZ1K81o6cRfoT+G206cXnl5zskGrkSbQqWTn4HGeC12cFd7F91aNaFroF3T2ic26JXEYmuNiAyYW1csYSYNxY4sgNdr3hfRw5ahPQNU0S5TAD7FpqH5gaCVV76+or9Y7uXewJCjC66uLkEduoXuB5MkFMGCsi8A1M5Izg1JMqEK8Nmi8wEHPy6zj9OPTt+9MNJ5m8FW5i7GfF9FFmpNFC983/j3f/iD6q33n5X96jw7wWxazpS/v0vYKVdxlCTP56rtmVZJ0OByAgM6TdGFo+EbaxSGFlySnsvH1R/8pzZbtS4z5fnGtrqGLmBIVICO5vw4s8gqLb2p9lM7oGghhK5cm+ybilg+6hfHiIe2Hhep2yin4JJnYr5PXhNcQi+QumIxsPd4EWj6Y7E6dOwTUD9EAqGl3XaWTaggEJlg1CxKbtFReRowghjlV9EcrQTkUQ3On+Ano3de6mcpwCAIdEi2P5QCbBn6LcTFnENxawnEI1iwfYXsZCIY9zwDl5Kiqm0jedRQBrGY97uEdEspj0VCGjwiZS4Iy9YybbQSvjTDF/XYPmOvA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:15.1120 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 702689ac-1afd-4879-aa9a-08db45a6db6c 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: DBAEUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB8626 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: t3oYE6XZQqHYkmxYDeC7EnvQx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438720; bh=jmP4MLq8EO/eIJeT4pA2xcMTOop+22b8hdtA/jJ47gY=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=ghN4psMMHgDoS0henr8zyAza70Ipbi7UIP8PMIYWCpIBe8wJCW/UeQ8DfMQDuUERSu8 iMFVDXy5FrkZExdUcGUyV5nNwfQ8gvDysat7B6RXxC+KdjX9d/5eFu12pDDW/Inih4jCm NkczyvnZsW39yuexU2fLymm4y5oWoV5W90w= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438721671100085 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Arm CCA systems the access to pages inside the Realm is protected. However, software executing in a Realm needs to interact with the external world. This may be done using para virtualisation of the disk, network interfaces, etc. For this to work the buffers in the Realm need to be shared with the Host. The sharing and management of the Realm buffers is done by the Realm Aperture Management Protocol, which invokes the necessary Realm Service Interfaces to transition the buffers from Protected IPA to Unprotected IPA. The ArmCcaIoMmu driver provides the necessary hooks so that DMA operations can be performed by bouncing buffers using pages shared with the Host. It uses the Realm Aperture Management protocol to share the buffers with the Host. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c | 813 ++++++++++++++++++++ ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.h | 66 ++ ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmuDxe.c | 59 ++ ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmuDxe.inf | 45 ++ 4 files changed, 983 insertions(+) diff --git a/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c b/ArmVirtPkg/ArmCcaIoM= muDxe/ArmCcaIoMmu.c new file mode 100644 index 0000000000000000000000000000000000000000..cf52b82218bb9ece7bfedcb6e3a= 2ced00eff5e92 --- /dev/null +++ b/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c @@ -0,0 +1,813 @@ +/** @file + The protocol provides support to allocate, free, map and umap a DMA buff= er + for bus master (e.g PciHostBridge). When the execution context is a Real= m, + the DMA operations must be performed on buffers that are shared with the= Host. + Hence the RAMP protocol is used to manage the sharing of the DMA buffers= or + in some cases to bounce the buffers. + + Copyright (c) 2017, AMD Inc. All rights reserved.
+ Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "ArmCcaIoMmu.h" + +/** List of the MAP_INFO structures that have been set up by IoMmuMap() an= d not + yet torn down by IoMmuUnmap(). The list represents the full set of map= pings + currently in effect. +*/ +STATIC LIST_ENTRY mMapInfos =3D INITIALIZE_LIST_HEAD_VARIABLE (mMapInfos); + +#if !defined (MDEPKG_NDEBUG) + +/** ASCII names for EDKII_IOMMU_OPERATION constants, for debug logging. +*/ +STATIC CONST CHAR8 *CONST +mBusMasterOperationName[EdkiiIoMmuOperationMaximum] =3D { + "Read", + "Write", + "CommonBuffer", + "Read64", + "Write64", + "CommonBuffer64" +}; +#endif + +/** Pointer to the Realm Aperture Management Protocol +*/ +extern EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL *mRamp; + +/** + Given the host address find a mapping node in the linked list. + + @param [in] HostAddress Host address. + + @return Pointer to the MapInfo node if found, otherwise NULL. +**/ +STATIC +MAP_INFO * +EFIAPI +FindMappingByHostAddress ( + IN VOID *HostAddress + ) +{ + LIST_ENTRY *Node; + LIST_ENTRY *NextNode; + MAP_INFO *MapInfo; + + for (Node =3D GetFirstNode (&mMapInfos); Node !=3D &mMapInfos; Node =3D = NextNode) { + NextNode =3D GetNextNode (&mMapInfos, Node); + MapInfo =3D CR (Node, MAP_INFO, Link, MAP_INFO_SIG); + if (MapInfo->HostAddress =3D=3D HostAddress) { + return MapInfo; + } + } + + return NULL; +} + +/** + Map a shared buffer + + @param [in] Operation IoMMU operation to perform. + @param [in] HostAddress Pointer to the Host buffer. + @param [in] NumberOfBytes Number of bytes to map. + @param [in] BbAddress Bounce buffer address. + @param [in] BbPages Number of pages covering the bounce buffer. + @param [out] Mapping Pointer to the MapInfo node. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +MapSharedBuffer ( + IN EDKII_IOMMU_OPERATION Operation, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + IN EFI_PHYSICAL_ADDRESS BbAddress, + IN UINTN BbPages, + OUT MAP_INFO **Mapping + ) +{ + EFI_STATUS Status; + MAP_INFO *MapInfo; + + if (BbPages !=3D EFI_SIZE_TO_PAGES (NumberOfBytes)) { + return EFI_INVALID_PARAMETER; + } + + // Allocate a MAP_INFO structure to remember the mapping when Unmap() is + // called later. + MapInfo =3D AllocateZeroPool (sizeof (MAP_INFO)); + if (MapInfo =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + InitializeListHead (&MapInfo->Link); + + // Initialize the MAP_INFO structure, except the NonParAddress field + MapInfo->Signature =3D MAP_INFO_SIG; + MapInfo->Operation =3D Operation; + MapInfo->NumberOfBytes =3D NumberOfBytes; + MapInfo->NumberOfPages =3D BbPages; + MapInfo->HostAddress =3D HostAddress; + MapInfo->BbAddress =3D BbAddress; + + // Open aperture here + Status =3D mRamp->OpenAperture ( + BbAddress, + BbPages, + &MapInfo->ApertureRef + ); + if (EFI_ERROR (Status)) { + goto FreeMapInfo; + } + + // Track all MAP_INFO structures. + InsertHeadList (&mMapInfos, &MapInfo->Link); + *Mapping =3D MapInfo; + return Status; + +FreeMapInfo: + FreePool (MapInfo); + return Status; +} + +/** + Unmap a shared buffer. + + @param [in] MapInfo Pointer to the MapInfo node. + @param [in] MemoryMapLocked The function is executing on the stack of + gBS->ExitBootServices(); changes to the UE= FI + memory map are forbidden. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +STATIC +EFI_STATUS +EFIAPI +UnMapSharedBuffer ( + IN MAP_INFO *MapInfo, + IN BOOLEAN MemoryMapLocked + ) +{ + EFI_STATUS Status; + + if (MapInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + DEBUG (( + DEBUG_VERBOSE, + "%a: HostAddress =3D 0x%p, BbAddress =3D 0x%p\n", + __func__, + MapInfo->HostAddress, + MapInfo->BbAddress + )); + Status =3D mRamp->CloseAperture (MapInfo->ApertureRef); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "Failed to close aperture. Status =3D %r\n", + Status + )); + } + + RemoveEntryList (&MapInfo->Link); + + if (!MemoryMapLocked) { + FreePool (MapInfo); + } + + return Status; +} + +/** + Provides the controller-specific addresses required to access system mem= ory + from a DMA bus master. On guest Realms, the DMA operations must be perfo= rmed + on shared buffer hence we allocate a bounce buffer to map the HostAddres= s to + a DeviceAddress. The Realm Aperture Management protocol is then involved= to + open the aperture for sharing the buffer pages with the Host OS. + + @param This The protocol instance pointer. + @param Operation Indicates if the bus master is going to re= ad or + write to system memory. + @param HostAddress The system memory address to map to the PCI + controller. + @param NumberOfBytes On input the number of bytes to map. On ou= tput + the number of bytes that were mapped. + @param DeviceAddress The resulting map address for the bus mast= er + PCI controller to use to access the hosts + HostAddress. + @param Mapping A resulting value to pass to Unmap(). + + @retval EFI_SUCCESS The range was mapped for the returned + NumberOfBytes. + @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a comm= on + buffer. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources. + @retval EFI_DEVICE_ERROR The system hardware could not map the requ= ested + address. + +**/ +EFI_STATUS +EFIAPI +IoMmuMap ( + IN EDKII_IOMMU_PROTOCOL *This, + IN EDKII_IOMMU_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +{ + EFI_STATUS Status; + MAP_INFO *MapInfo; + EFI_PHYSICAL_ADDRESS BbAddress; + UINTN Pages; + EFI_ALLOCATE_TYPE AllocateType; + + DEBUG (( + DEBUG_VERBOSE, + "%a: Operation=3D%a Host=3D0x%p Bytes=3D0x%lx\n", + __func__, + ((Operation >=3D 0 && + Operation < ARRAY_SIZE (mBusMasterOperationName)) ? + mBusMasterOperationName[Operation] : + "Invalid"), + HostAddress, + (UINT64)((NumberOfBytes =3D=3D NULL) ? 0 : *NumberOfBytes) + )); + + if ((HostAddress =3D=3D NULL) || + (NumberOfBytes =3D=3D NULL) || + (DeviceAddress =3D=3D NULL) || + (Mapping =3D=3D NULL) || + (Operation >=3D EdkiiIoMmuOperationMaximum) || + (Operation < EdkiiIoMmuOperationBusMasterRead)) + { + return EFI_INVALID_PARAMETER; + } + + BbAddress =3D MAX_ADDRESS; + Pages =3D EFI_SIZE_TO_PAGES (*NumberOfBytes); + AllocateType =3D AllocateAnyPages; + switch (Operation) { + // For BusMasterRead[64] and BusMasterWrite[64] operations, a bounce b= uffer + // is necessary as the original buffer may not meet the page start/end= and + // page size alignment requirements. Also we need to consider the case= where + // the original buffer crosses the 4GB limit. + case EdkiiIoMmuOperationBusMasterRead: + case EdkiiIoMmuOperationBusMasterWrite: + BbAddress =3D BASE_4GB - 1; + AllocateType =3D AllocateMaxAddress; + // fall through + case EdkiiIoMmuOperationBusMasterRead64: + case EdkiiIoMmuOperationBusMasterWrite64: + // Allocate a bounce buffer. + Status =3D gBS->AllocatePages ( + AllocateType, + EfiBootServicesData, + Pages, + &BbAddress + ); + if (EFI_ERROR (Status)) { + goto Failed; + } + + // Open aperture here + Status =3D MapSharedBuffer ( + Operation, + HostAddress, + *NumberOfBytes, + BbAddress, + Pages, + &MapInfo + ); + if (EFI_ERROR (Status)) { + goto FreeBounceBuffer; + } + + break; + + // For BusMasterCommonBuffer[64] operations, the buffer is already all= ocated + // and mapped in a call to AllocateBuffer(). So, we only need to retur= n the + // device address and the mapping info + case EdkiiIoMmuOperationBusMasterCommonBuffer: + // fall through + case EdkiiIoMmuOperationBusMasterCommonBuffer64: + MapInfo =3D FindMappingByHostAddress (HostAddress); + if (MapInfo =3D=3D NULL) { + ASSERT (MapInfo =3D=3D NULL); + goto Failed; + } + + BbAddress =3D MapInfo->BbAddress; + break; + + default: + // Operation is invalid + Status =3D EFI_INVALID_PARAMETER; + goto Failed; + } // switch + + // If this is a read operation from the Bus Master's point of view, + // then copy the contents of the real buffer into the mapped buffer + // so the Bus Master can read the contents of the real buffer. + // No special action is needed for BusMasterCommonBuffer[64] operations. + if ((Operation =3D=3D EdkiiIoMmuOperationBusMasterRead) || + (Operation =3D=3D EdkiiIoMmuOperationBusMasterRead64)) + { + CopyMem ( + (VOID *)(UINTN)BbAddress, + (VOID *)(UINTN)HostAddress, + MapInfo->NumberOfBytes + ); + } + + // Populate output parameters. + *DeviceAddress =3D BbAddress; + *Mapping =3D MapInfo; + + DEBUG (( + DEBUG_VERBOSE, + "%a: Mapping=3D0x%p HostAddress =3D 0x%p BBAddress =3D 0x%Lx Pages=3D0= x%Lx\n", + __func__, + MapInfo, + HostAddress, + MapInfo->BbAddress, + MapInfo->NumberOfPages + )); + + return EFI_SUCCESS; + +FreeBounceBuffer: + gBS->FreePages (BbAddress, Pages); + +Failed: + *NumberOfBytes =3D 0; + return Status; +} + +/** + Completes the Map() operation and releases any corresponding resources. + + This is an internal worker function that only extends the Map() API with + the MemoryMapLocked parameter. + + @param This The protocol instance pointer. + @param MapInfo The mapping value returned from Map(). + @param MemoryMapLocked The function is executing on the stack of + gBS->ExitBootServices(); changes to the UE= FI + memory map are forbidden. + + @retval EFI_SUCCESS The range was unmapped. + @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by + Map(). + @retval EFI_DEVICE_ERROR The data was not committed to the target s= ystem + memory. +**/ +STATIC +EFI_STATUS +EFIAPI +IoMmuUnmapWorker ( + IN EDKII_IOMMU_PROTOCOL *This, + IN MAP_INFO *MapInfo, + IN BOOLEAN MemoryMapLocked + ) +{ + EFI_STATUS Status; + PHYSICAL_ADDRESS BbAddress; + UINTN Pages; + + DEBUG (( + DEBUG_VERBOSE, + "%a: MapInfo=3D0x%p MemoryMapLocked=3D%d\n", + __func__, + MapInfo, + MemoryMapLocked + )); + + if (MapInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + BbAddress =3D MapInfo->BbAddress; + Pages =3D MapInfo->NumberOfPages; + + // For BusMasterWrite[64] operations and BusMasterCommonBuffer[64] opera= tions + // we have to copy the results, ultimately to the original place (i.e., + // "MapInfo->HostAddress"). + // No special operaton is needed for BusMasterCommonBuffer[64] operation= s. + switch (MapInfo->Operation) { + case EdkiiIoMmuOperationBusMasterCommonBuffer: + case EdkiiIoMmuOperationBusMasterCommonBuffer64: + ASSERT (BbAddress =3D=3D (PHYSICAL_ADDRESS)MapInfo->HostAddress); + break; + case EdkiiIoMmuOperationBusMasterWrite: + case EdkiiIoMmuOperationBusMasterWrite64: + CopyMem ( + (VOID *)(UINTN)MapInfo->HostAddress, + (VOID *)(UINTN)BbAddress, + MapInfo->NumberOfBytes + ); + break; + + default: + // nothing to do for BusMasterRead[64] operations + break; + } + + // For all other operations, fill the late bounce buffer with zeros, and + // then release it (unless the UEFI memory map is locked). + if ((MapInfo->Operation !=3D EdkiiIoMmuOperationBusMasterCommonBuffer) && + (MapInfo->Operation !=3D EdkiiIoMmuOperationBusMasterCommonBuffer64)) + { + ZeroMem ( + (VOID *)(UINTN)BbAddress, + EFI_PAGES_TO_SIZE (Pages) + ); + + // UnMapSharedPages + Status =3D UnMapSharedBuffer (MapInfo, MemoryMapLocked); + ASSERT_EFI_ERROR (Status); + + if (!MemoryMapLocked) { + gBS->FreePages (BbAddress, Pages); + } + } + + return Status; +} + +/** + Completes the Map() operation and releases any corresponding resources. + + @param This The protocol instance pointer. + @param Mapping The mapping value returned from Map(). + + @retval EFI_SUCCESS The range was unmapped. + @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by + Map(). + @retval EFI_DEVICE_ERROR The data was not committed to the target s= ystem + memory. +**/ +EFI_STATUS +EFIAPI +IoMmuUnmap ( + IN EDKII_IOMMU_PROTOCOL *This, + IN VOID *Mapping + ) +{ + return IoMmuUnmapWorker ( + This, + (MAP_INFO *)Mapping, + FALSE // MemoryMapLocked + ); +} + +/** + Allocates pages that are suitable for an OperationBusMasterCommonBuffer = or + OperationBusMasterCommonBuffer64 mapping. + + @param This The protocol instance pointer. + @param Type This parameter is not used and must be ign= ored. + @param MemoryType The type of memory to allocate, + EfiBootServicesData or EfiRuntimeServicesD= ata. + @param Pages The number of pages to allocate. + @param HostAddress A pointer to store the base system memory + address of the allocated range. + @param Attributes The requested bit mask of attributes for t= he + allocated range. + + @retval EFI_SUCCESS The requested memory pages were allocated. + @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal + attribute bits are MEMORY_WRITE_COMBINE and + MEMORY_CACHED. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. + +**/ +EFI_STATUS +EFIAPI +IoMmuAllocateBuffer ( + IN EDKII_IOMMU_PROTOCOL *This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT VOID **HostAddress, + IN UINT64 Attributes + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS BbAddress; + MAP_INFO *MapInfo; + + // Validate Attributes + if ((Attributes & EDKII_IOMMU_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER) != =3D 0) { + return EFI_UNSUPPORTED; + } + + // Check for invalid inputs + if (HostAddress =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // The only valid memory types are EfiBootServicesData + if (MemoryType !=3D EfiBootServicesData) { + return EFI_INVALID_PARAMETER; + } + + if (Pages >=3D MAX_UINTN) { + return EFI_INVALID_PARAMETER; + } + + BbAddress =3D (UINTN)-1; + if ((Attributes & EDKII_IOMMU_ATTRIBUTE_DUAL_ADDRESS_CYCLE) =3D=3D 0) { + // Limit allocations to memory below 4GB + BbAddress =3D SIZE_4GB - 1; + } + + Status =3D gBS->AllocatePages ( + AllocateMaxAddress, + MemoryType, + Pages, + &BbAddress + ); + if (EFI_ERROR (Status)) { + // Set the host address to NULL in case of error + *HostAddress =3D NULL; + } else { + *HostAddress =3D (VOID *)(UINTN)BbAddress; + Status =3D MapSharedBuffer ( + EdkiiIoMmuOperationBusMasterCommonBuffer, + *HostAddress, + EFI_PAGES_TO_SIZE (Pages), + BbAddress, + Pages, + &MapInfo + ); + ASSERT_EFI_ERROR (Status); + } + + return Status; +} + +/** + Frees memory that was allocated with AllocateBuffer(). + + @param This The protocol instance pointer. + @param Pages The number of pages to free. + @param HostAddress The base system memory address of the allo= cated + range. + + @retval EFI_SUCCESS The requested memory pages were freed. + @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress = and + Pages was not allocated with AllocateBuffe= r(). + +**/ +EFI_STATUS +EFIAPI +IoMmuFreeBuffer ( + IN EDKII_IOMMU_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress + ) +{ + EFI_STATUS Status; + MAP_INFO *MapInfo; + + // Release the common buffer itself. Unmap() has re-encrypted it in-plac= e, so + // no need to zero it. + MapInfo =3D FindMappingByHostAddress (HostAddress); + if (MapInfo =3D=3D NULL) { + ASSERT (0); + return EFI_NOT_FOUND; + } else { + // UnMapSharedPages + Status =3D UnMapSharedBuffer (MapInfo, FALSE); + ASSERT_EFI_ERROR (Status); + } + + return gBS->FreePages ((UINTN)HostAddress, Pages); +} + +/** + Set IOMMU attribute for a system memory. + + If the IOMMU protocol exists, the system memory cannot be used + for DMA by default. + + When a device requests a DMA access to system memory, + the device driver need use SetAttribute() to update the IOMMU + attribute to request DMA access (read and/or write). + + The DeviceHandle is used to identify which device submits the request. + The IOMMU implementation need to translate the device path to an IOMMU d= evice + ID, and set the IOMMU hardware register accordingly. + 1) DeviceHandle can be a standard PCI device. + The memory for BusMasterRead needs EDKII_IOMMU_ACCESS_READ set. + The memory for BusMasterWrite needs EDKII_IOMMU_ACCESS_WRITE set. + The memory for BusMasterCommonBuffer needs + EDKII_IOMMU_ACCESS_READ|EDKII_IOMMU_ACCESS_WRITE set. + After the memory is used, the memory need set 0 to keep it being + protected. + 2) DeviceHandle can be an ACPI device (ISA, I2C, SPI, etc). + The memory for DMA access need set EDKII_IOMMU_ACCESS_READ and/or + EDKII_IOMMU_ACCESS_WRITE. + + @param[in] This The protocol instance pointer. + @param[in] DeviceHandle The device initiating the DMA access + request. + @param[in] Mapping The mapping value returned from Map(). + @param[in] IoMmuAccess The IOMMU access. + + @retval EFI_UNSUPPORTED Operation not supported by IOMMU. + +**/ +EFI_STATUS +EFIAPI +IoMmuSetAttribute ( + IN EDKII_IOMMU_PROTOCOL *This, + IN EFI_HANDLE DeviceHandle, + IN VOID *Mapping, + IN UINT64 IoMmuAccess + ) +{ + return EFI_UNSUPPORTED; +} + +/** Arm CCA IoMMU protocol +*/ +EDKII_IOMMU_PROTOCOL mArmCcaIoMmu =3D { + EDKII_IOMMU_PROTOCOL_REVISION, + IoMmuSetAttribute, + IoMmuMap, + IoMmuUnmap, + IoMmuAllocateBuffer, + IoMmuFreeBuffer, +}; + +/** + Notification function that is queued when gBS->ExitBootServices() signal= s the + EFI_EVENT_GROUP_EXIT_BOOT_SERVICES event group. This function signals an= other + event, received as Context, and returns. + + Signaling an event in this context is safe. The UEFI spec allows + gBS->SignalEvent() to return EFI_SUCCESS only; EFI_OUT_OF_RESOURCES is n= ot + listed, hence memory is not allocated. The edk2 implementation also does= not + release memory (and we only have to care about the edk2 implementation + because EDKII_IOMMU_PROTOCOL is edk2-specific anyway). + + @param[in] Event Event whose notification function is being inv= oked. + Event is permitted to request the queueing of = this + function at TPL_CALLBACK or TPL_NOTIFY task + priority level. + + @param[in] EventToSignal Identifies the EFI_EVENT to signal. EventToSig= nal + is permitted to request the queueing of its + notification function only at TPL_CALLBACK lev= el. +**/ +STATIC +VOID +EFIAPI +ArmCcaIoMmuExitBoot ( + IN EFI_EVENT Event, + IN VOID *EventToSignal + ) +{ + // (1) The NotifyFunctions of all the events in + // EFI_EVENT_GROUP_EXIT_BOOT_SERVICES will have been queued before + // ArmCcaIoMmuExitBoot() is entered. + // + // (2) ArmCcaIoMmuExitBoot() is executing minimally at TPL_CALLBACK. + // + // (3) ArmCcaIoMmuExitBoot() has been queued in unspecified order relati= ve + // to the NotifyFunctions of all the other events in + // EFI_EVENT_GROUP_EXIT_BOOT_SERVICES whose NotifyTpl is the same as + // Event's. + // + // Consequences: + // + // - If Event's NotifyTpl is TPL_CALLBACK, then some other NotifyFunctio= ns + // queued at TPL_CALLBACK may be invoked after ArmCcaIoMmuExitBoot() + // returns. + // + // - If Event's NotifyTpl is TPL_NOTIFY, then some other NotifyFunctions + // queued at TPL_NOTIFY may be invoked after ArmCcaIoMmuExitBoot() ret= urns; + // plus *all* NotifyFunctions queued at TPL_CALLBACK will be invoked + // strictly after all NotifyFunctions queued at TPL_NOTIFY, including + // ArmCcaIoMmuExitBoot(), have been invoked. + // + // - By signaling EventToSignal here, whose NotifyTpl is TPL_CALLBACK, we + // queue EventToSignal's NotifyFunction after the NotifyFunctions of *= all* + // events in EFI_EVENT_GROUP_EXIT_BOOT_SERVICES. + gBS->SignalEvent (EventToSignal); +} + +/** + Notification function that is queued after the notification functions of= all + events in the EFI_EVENT_GROUP_EXIT_BOOT_SERVICES event group. The same m= emory + map restrictions apply. + + This function unmaps all currently existing IOMMU mappings. + + @param[in] Event Event whose notification function is being invoked. = Event + is permitted to request the queueing of this function + only at TPL_CALLBACK task priority level. + + @param[in] Context Ignored. +**/ +STATIC +VOID +EFIAPI +ArmCcaIoMmuUnmapAllMappings ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + LIST_ENTRY *Node; + LIST_ENTRY *NextNode; + MAP_INFO *MapInfo; + + // All drivers that had set up IOMMU mappings have halted their respecti= ve + // controllers by now; tear down the mappings. + for (Node =3D GetFirstNode (&mMapInfos); Node !=3D &mMapInfos; Node =3D = NextNode) { + NextNode =3D GetNextNode (&mMapInfos, Node); + MapInfo =3D CR (Node, MAP_INFO, Link, MAP_INFO_SIG); + IoMmuUnmapWorker ( + &mArmCcaIoMmu, // This + MapInfo, // Mapping + TRUE // MemoryMapLocked + ); + } +} + +/** + Initialize and install the ArmCca IoMmu Protocol. + + @return RETURN_SUCCESS if successful, otherwise any other error. +**/ +EFI_STATUS +EFIAPI +ArmCcaInstallIoMmuProtocol ( + VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT UnmapAllMappingsEvent; + EFI_EVENT ExitBootEvent; + EFI_HANDLE Handle; + + // Create the "late" event whose notification function will tear down all + // left-over IOMMU mappings. + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, // Type + TPL_CALLBACK, // NotifyTpl + ArmCcaIoMmuUnmapAllMappings, // NotifyFunction + NULL, // NotifyContext + &UnmapAllMappingsEvent // Event + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // Create the event whose notification function will be queued by + // gBS->ExitBootServices() and will signal the event created above. + Status =3D gBS->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, // Type + TPL_CALLBACK, // NotifyTpl + ArmCcaIoMmuExitBoot, // NotifyFunction + UnmapAllMappingsEvent, // NotifyContext + &ExitBootEvent // Event + ); + if (EFI_ERROR (Status)) { + goto CloseUnmapAllMappingsEvent; + } + + Handle =3D NULL; + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gEdkiiIoMmuProtocolGuid, + &mArmCcaIoMmu, + NULL + ); + if (!EFI_ERROR (Status)) { + return Status; + } + + // cleanup on error + gBS->CloseEvent (ExitBootEvent); + +CloseUnmapAllMappingsEvent: + gBS->CloseEvent (UnmapAllMappingsEvent); + + return Status; +} diff --git a/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.h b/ArmVirtPkg/ArmCcaIoM= muDxe/ArmCcaIoMmu.h new file mode 100644 index 0000000000000000000000000000000000000000..070f7bebf5bff84fc3e530e434d= 62c1205bfb70a --- /dev/null +++ b/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.h @@ -0,0 +1,66 @@ +/** @file + The protocol provides support to allocate, free, map and umap a DMA buff= er + for bus master (e.g PciHostBridge). When the execution context is a Real= m, + the DMA operations must be performed on buffers that are shared with the= HOST, + hence the RAMP protocol is used to manage the sharing of the DMA buffers= or in + some cases bounce the buffers. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc. All rights reserved.
+ (C) Copyright 2017 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef ARM_CCA_IOMMU_H_ +#define ARM_CCA_IOMMU_H_ + +#include + +#include +#include +#include +#include +#include +#include + +/** + A macro defning the signature for the MAP_INFO structure. +*/ +#define MAP_INFO_SIG SIGNATURE_64 ('M', 'A', 'P', '_', 'I', 'N', 'F', 'O') + +/** A structure describing the mapping for the buffers shared with the hos= t. +*/ +typedef struct { + /// Signature. + UINT64 Signature; + /// Linked List node entry. + LIST_ENTRY Link; + /// IoMMU operation. + EDKII_IOMMU_OPERATION Operation; + /// Number of bytes. + UINTN NumberOfBytes; + /// Number of pages. + UINTN NumberOfPages; + /// Address of the Host buffer. + VOID *HostAddress; + + /// Address for the Bounce Buffer. + EFI_PHYSICAL_ADDRESS BbAddress; + /// Handle to the Aperture. + EFI_HANDLE ApertureRef; +} MAP_INFO; + +/** + Install IOMMU protocol to provide the DMA support for PciHostBridge and + RAMP. + +**/ +EFI_STATUS +EFIAPI +ArmCcaInstallIoMmuProtocol ( + VOID + ); + +#endif diff --git a/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmuDxe.c b/ArmVirtPkg/ArmCca= IoMmuDxe/ArmCcaIoMmuDxe.c new file mode 100644 index 0000000000000000000000000000000000000000..deba9dd5e72041f318336141ca8= 095b4a43d8b9b --- /dev/null +++ b/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmuDxe.c @@ -0,0 +1,59 @@ +/** @file + + IoMmuArmBowDxe driver installs EDKII_IOMMU_PROTOCOL to support + DMA operations when the execution context is a Realm. + + Copyright (c) 2017, AMD Inc. All rights reserved.
+ Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "ArmCcaIoMmu.h" + +/** Pointer to the Realm Aperture Management Protocol +*/ +EDKII_REALM_APERTURE_MANAGEMENT_PROTOCOL *mRamp =3D NULL; + +/** Entrypoint of Arm CCA IoMMU Dxe. + + @param [in] ImageHandle Image handle of this driver. + @param [in] SystemTable Pointer to the EFI System Table. + + @return RETURN_SUCCESS if successful, otherwise any other error. +**/ +EFI_STATUS +EFIAPI +ArmCcaIoMmuDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + // When the execution context is a Realm, install ArmCcaIoMmu protocol + // otherwise install the placeholder protocol so that other dependent + // module can run. + Status =3D gBS->LocateProtocol ( + &gEfiRealmApertureManagementProtocolGuid, + NULL, + (VOID **)&mRamp + ); + if (!EFI_ERROR (Status)) { + // If the Realm Aperture Management Protocol is present + // then the execution context is a Realm. + Status =3D ArmCcaInstallIoMmuProtocol (); + } else { + DEBUG ((DEBUG_INFO, "Execution context is not a Realm.\n")); + Handle =3D NULL; + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gIoMmuAbsentProtocolGuid, + NULL, + NULL + ); + } + + return Status; +} diff --git a/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmuDxe.inf b/ArmVirtPkg/ArmC= caIoMmuDxe/ArmCcaIoMmuDxe.inf new file mode 100644 index 0000000000000000000000000000000000000000..b8e125296f4da417a7a07ccbaeb= ce33c29d411e5 --- /dev/null +++ b/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmuDxe.inf @@ -0,0 +1,45 @@ +## @file +# Driver provides the IOMMU protcol support for PciHostBridgeIo and others +# drivers. +# +# Copyright (c) 2017, AMD Inc. All rights reserved.
+# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D IoMmuDxe + FILE_GUID =3D AA6C1A48-A341-439C-950E-CC394FDFE144 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D ArmCcaIoMmuDxeEntryPoint + +[Sources] + ArmCcaIoMmu.c + ArmCcaIoMmu.h + ArmCcaIoMmuDxe.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + OvmfPkg/OvmfPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEdkiiIoMmuProtocolGuid ## SOMETIME_PRODUCES + gIoMmuAbsentProtocolGuid ## SOMETIME_PRODUCES + gEfiRealmApertureManagementProtocolGuid + +[Depex] + gEfiRealmApertureManagementProtocolGuid --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103577): https://edk2.groups.io/g/devel/message/103577 Mute This Topic: https://groups.io/mt/98495992/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103572+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438715378158.22974871288045; Tue, 25 Apr 2023 09:05:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vKX0YY1788612xKNopnIuDYw; Tue, 25 Apr 2023 09:05:15 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.68]) by mx.groups.io with SMTP id smtpd.web11.83466.1682438713987237677 for ; Tue, 25 Apr 2023 09:05:14 -0700 X-Received: from DUZPR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::11) by AM0PR08MB5473.eurprd08.prod.outlook.com (2603:10a6:208:180::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:11 +0000 X-Received: from DBAEUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c3:cafe::e4) by DUZPR01CA0007.outlook.office365.com (2603:10a6:10:3c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:05:11 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103572+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT034.mail.protection.outlook.com (100.127.142.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:11 +0000 X-Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 25 Apr 2023 16:05:11 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a11fbcaf0c82dd4c X-CR-MTA-TID: 64aa7808 X-Received: from 0d786e6741ce.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 918F4E9B-4880-4682-9FE6-4024B27A2D22.1; Tue, 25 Apr 2023 16:05:04 +0000 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0d786e6741ce.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:05:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hzBdZ2Oq/gzdouS8NlPzVtOSqy8EQlkMZIHB44u5WPx0RJStKSyT1ttZTnULJMohgOb177l+qGlExBqLH0iKJ0R5zur67gyIOwC+th8tc+etCVua2jHfLsK+J9TeTEBkAx9oADTt61jlfKKEJFrHaC+Kljv/utuNAZVCnhifzbs4MZXWCRkrnq3fYjW/s7brmI72cVvc9B7jSQf5vHankguwFIsY7Q3q8BkrYCtiIIHQ8jsEzYfpIwifb5v8+fW/CEy94D/ltxzNmHCiyoslVOzg2tFQxEJ5hVbvDAKWLMi6v/7IdwlMKaG6i9kivYjCGIa+0oei8qJGIRqbwaRkSQ== 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=zypZF577QhpXMYB855rhgmuQpX7Wujv/5sCWlDwmj3E=; b=TQPONQm4C/t0DqK3ZvIDJVmW+0SZnUFhjT2xgXCJEoPUi2NgzJ7IhyjZx8PL71tvu04N9pvha+yRQLrh16Uj1SBhhF8Yv3NbjzUA14a5V94oo4AfTcCe7lIZdAix0dZS6lRbLq/IoKH4oiaM4U85Lq86kADEEMhfehe4FOXakiXNxDry9wnKSp4DsnnsVG8WXhdkGxnghFwGCeChbXQtceC7yMK2VPVpIAmiQNqUcowEwmlSO0RzAUBDzs7qL9l8jyuzomPlk0xiP4Xub/Ju7ognoBvNnSBcVYhmqtKL4JWMI0hoaJfKSwetqz/3WtbItU5oOYV7XvISOOoKXjTVMA== 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 X-Received: from DUZPR01CA0009.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::16) by DB9PR08MB8436.eurprd08.prod.outlook.com (2603:10a6:10:3d4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:02 +0000 X-Received: from DBAEUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c3:cafe::80) by DUZPR01CA0009.outlook.office365.com (2603:10a6:10:3c3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:05:02 +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 DBAEUR03FT004.mail.protection.outlook.com (100.127.142.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:02 +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.23; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 28/30] ArmVirtPkg: Enable Virtio communication for Arm CCA Date: Tue, 25 Apr 2023 17:04:26 +0100 Message-ID: <20230425160428.27980-29-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT004:EE_|DB9PR08MB8436:EE_|DBAEUR03FT034:EE_|AM0PR08MB5473:EE_ X-MS-Office365-Filtering-Correlation-Id: 31c066c8-10f9-44dc-cad6-08db45a6d928 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: Jzk7xXuDAUKeflwPM6opsisEqqkuAf59P/+3vEiVaj9CA7Oopy7J/6ytcPHit3kjKWPlyzpv6agxKIW1DfyrCGb9MAKZnLd1j/kHGEZxu/P/QPe+i0TXUTaiXqL17yJj7CPsQaQ2KorxIuUE/59PXs5qw/y5PYT0psuSfmY0lWtZZZ/9i4vDnjvXx9VySKstvFMUGIArekkOC0g1PgLTBQS0w+pKaO5LIv13mVF9K797USx6yd994E7i7RUM9e3cetVAZqazzZF9VKcafVxQyta07KRV5Uxx9o3TL5k7nFwmfhwRaZoElR/LTqHwUrbEYN8ENZJGnXy5+wx/KJAOMTyZlBi2tLuFluo6rue2E/4WDLfudnCvWUya+eft4q+YAjqBQO7w7y8aTCyqHyJrX/GsFkCzIw/cT0NhfU8P7cn5P8Hk3rXJfVkGofi/CG0fqJ9yyYA1CnVDzjQHVtwhHXUsnPwNyCvDtBwOlWCF8w/hnECWljqx8uZvLV0rtBREqC6iLZlVhu1v13ULQPS922oWUKct6BAp/MMxWf7pa2R/SYuw47FK6YK1M85wpghqjGR2XMvzeHwXQzPZk120sT6ifGcTuOAlsdSm6mbLK79MKHJBptOxLTFQY/LCGdso3kIeaSRQZehr2H5Mg7cbzlJ2lAHGBbh5r5CajWOh6KmRzfhIiP8lmLoi+TMlyQc4A0AsudcETxSJZ/fT0Bt4ABVFwvp+SNW+5qWyxtlfzto= 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:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(46966006)(36840700001)(54906003)(36756003)(34070700002)(478600001)(82740400003)(316002)(40480700001)(6916009)(70586007)(70206006)(4326008)(356005)(41300700001)(44832011)(81166007)(8676002)(2906002)(8936002)(5660300002)(36860700001)(186003)(426003)(86362001)(336012)(26005)(1076003)(2616005)(7696005)(6666004)(47076005)(83380400001)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB8436 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0f0e4d09-0e77-46e3-dad7-08db45a6d3c1 X-Microsoft-Antispam-Message-Info: oPTmG5S6h57VrEl5A4JMlJtyCbJCjuZyRwiIhqYeLT2dtF+UvqqtWeaaSTKySA0lKYqO3weGYnVz7BgoexQvUYeQPb8oOxpkncjJQHYtsugMFuyCM/SXyUEs5mVgPT4Y8DTCSD/h/I43DBkRsgrXnaOEJiJ8Bz7/JnJ5HfB8nb+fDDoKuSbSEls11W3LWGb1mfS7LL3QF9u8cllMUFKnwAwnXJHZaSJMkVIpIQ77B1pidhlKf1OZMlxptcpAFzBxtDv5ddEgIr9tUl/uSTyYy+pbjzyt1huhqQ5ybzVMeIiB6V1xSL1DyFXFMUSh2GJa9GJxp01KnltcKsLw1XoPzsxHfszUx3ptMYhbU16HupplxZrnQdpm1lrTvWHHP3FjFAWO+4ouPn430ppLoWcSrZOshMf0w75OmnUGp9X20eCVlIhnoymKi0u8UCRz4WCltJwv+rMCqrjERHdCUJRRZ4MABeLRQWPQUvDFVP/JWSVWarYOUcSsJJl+dgG8E5RznJlCkhT04Oe0DpU9HVeg/ykKdZ3+PgWA8jZiTUsGEyLQ2g8QrhXIjwYF6oamvFg2hdbp6DkrzgLwDleoUPN3ZO0rmJF7QncYP9g6je3MHsCLYkCtOrENVzfHwkIvY1lNxZprljbgDeBJPSLD+kudCbsr9HfQByPorWtCL3qjRuWTA0O+Twq5eNMTtqPfE551XlLOP8XuX/lhuVXcdsZ2z3jh3dU5oORoPNPcjWy1t9k= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:11.3274 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31c066c8-10f9-44dc-cad6-08db45a6d928 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: DBAEUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5473 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: udjyEyZlUkR9VMdEiuWoh0knx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438715; bh=jVciHqgYhnCbb89Lazzc4kc9HZ3Vvb43ly7TKWV4i4o=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=c2zVfYn5afCKDJuMvTIA/L1mNqe/rU/qFznihkQTePLb37H5e6x0vYXNcHcjpHi4R68 pTp8zQK9hKgDBuy9li4FGlR7z3NZMVHKk9uvlAIIkUsd9/tRtBd1OrdCV4CREWxc5Nszk cYKO/1QNpKWfFscZ+xKMEUoHd2Ng2Akf1Hs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438716997100067 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Arm CCA Realms protect the access to memory from outside the Realm. For Virtio to work the Realm Guest and the Host should be able to share buffers. Realm Aperture Management protocol (RAMP) manages the sharing of buffers between the Realm Guest and the Host, while the ArmCcaIoMmuDxe implements the EDKII_IOMMU_PROTOCOL which provides the necessary hooks so that DMA accesses can be performed by bouncing buffers using pages shared with the host. Therefore, enable the support for Realm Aperture Management Protocol and ArmCcaIoMmuDxe for Kvmtool Guest firmware. Note: The ArmCcaIoMmuDxe and RAMP check if the code is executing in a Realm before installing the respective protocols. If the code is not executing in a Realm the gIoMmuAbsentProtocolGuid is installed, thereby allowing the same firmware to be used both for normal and Realm Guest firmware. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtKvmTool.dsc | 10 ++++++++++ ArmVirtPkg/ArmVirtKvmTool.fdf | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index acf4ede48da2d33d50b5593a857f3815f427707c..d9dd7a67307ffed5da16837301f= 18e7715187450 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -411,3 +411,13 @@ [Components.AARCH64] ArmVirtPkg/KvmtoolCfgMgrDxe/ConfigurationManagerDxe.inf =20 ArmVirtPkg/ArmCcaDxe/ArmCcaDxe.inf + + # + # Realm Aperture Management + # + ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmApertureManagementPro= tocolDxe.inf + + # + # IoMMU support for Arm CCA + # + ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmuDxe.inf diff --git a/ArmVirtPkg/ArmVirtKvmTool.fdf b/ArmVirtPkg/ArmVirtKvmTool.fdf index 68bd0e9d82dc83a337d8127a598018381888d894..c04a1f1f381410d2eccb781b2de= 99898d5da9578 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.fdf +++ b/ArmVirtPkg/ArmVirtKvmTool.fdf @@ -224,6 +224,16 @@ [FV.FvMain] !include DynamicTablesPkg/DynamicTables.fdf.inc =20 INF ArmVirtPkg/KvmtoolCfgMgrDxe/ConfigurationManagerDxe.inf + + # + # Realm Aperture Management + # + INF ArmVirtPkg/RealmApertureManagementProtocolDxe/RealmApertureManagemen= tProtocolDxe.inf + + # + # IoMMU support for Arm CCA + # + INF ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmuDxe.inf !endif =20 # --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103572): https://edk2.groups.io/g/devel/message/103572 Mute This Topic: https://groups.io/mt/98495983/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103574+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438717790122.78896015319788; Tue, 25 Apr 2023 09:05:17 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id pQq2YY1788612x1qYCBbZpM4; Tue, 25 Apr 2023 09:05:17 -0700 X-Received: from EUR03-DBA-obe.outbound.protection.outlook.com (EUR03-DBA-obe.outbound.protection.outlook.com [40.107.104.50]) by mx.groups.io with SMTP id smtpd.web10.83982.1682438716454100436 for ; Tue, 25 Apr 2023 09:05:16 -0700 X-Received: from DU2PR04CA0013.eurprd04.prod.outlook.com (2603:10a6:10:3b::18) by PAWPR08MB9544.eurprd08.prod.outlook.com (2603:10a6:102:2f2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:05:12 +0000 X-Received: from DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3b:cafe::30) by DU2PR04CA0013.outlook.office365.com (2603:10a6:10:3b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:12 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103574+1787277+3901457@groups.io; helo=mail02.groups.io; 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 DBAEUR03FT048.mail.protection.outlook.com (100.127.142.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:12 +0000 X-Received: ("Tessian outbound 99a3040377ca:v136"); Tue, 25 Apr 2023 16:05:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b545023850a3a37d X-CR-MTA-TID: 64aa7808 X-Received: from 88eff68a30f6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A2FFCE1C-6C63-4644-ABB2-7F78D4267360.1; Tue, 25 Apr 2023 16:05:06 +0000 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 88eff68a30f6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:05:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XptZUFWk+lacE0064cIfBtY+jsYOaHG0hQcA34j3/jugrYSgUfy4G5XbqWuVIC9KAZGDD7SSXGZ8QiyhSK/o/ATxZvgrsAVgqqZR6kg3Yi60Rd1w6aNaX8RG6y3t0xHJCxoKuKNyYMVcelOeHTdIw0rDoswDeYJcsoy427+a9RpqMepJpSnKB41/vG2LyUwnkJhZRTz7WsXaI0tfaM1lHWnI5AuF9W15XsqY2pRqlwFHPN7SN4ThUcel/U3De1yjKVa3dsK2TnJ3okTMJ1i9+VEOdVPY2MRl/sCyFB7gzSR312fDqZZoMf3z+frk37aR4obdnrXoDFAwLjDkEZ8frg== 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=iXkL80mLvvfVNU7tzwYg1I9T3hTIuFc8osZioFtNjHk=; b=ldi5pXIBbbSl7UwOrGiwk2GfFm8wac5bQ23Bp0KnNSjY2fMqoyvDZiOaDUM7ReT7jRstDyVtWaPjq9RqOWQdV6OzmrQrSKW4GPri4A/k3Q3rn7S1/lVIcb60Yr7ZSPsP0UTog+qoNeNKau9WZtMc5vKECqjPG8HBYr9jZZdYr/W6iyPuxVSAPJXCff6O2PZsNDQhC47iozlpCFVgBrgaU1oQsSK/AYTLwiY5O6jJSnuJPxdt4cGE16Am8vkRt+8FBiD/PFij6uXMSooXoQqgC54QyP4vOgCxDsSwXWFLj2KDP3Qsc5N+ZzfWktDMzTWm3FzMzu5CvPxTdb9JFV96mg== 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 X-Received: from DB6PR0402CA0016.eurprd04.prod.outlook.com (2603:10a6:4:91::26) by GV1PR08MB8690.eurprd08.prod.outlook.com (2603:10a6:150:83::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:05:02 +0000 X-Received: from DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:91:cafe::42) by DB6PR0402CA0016.outlook.office365.com (2603:10a6:4:91::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:05:02 +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 DBAEUR03FT007.mail.protection.outlook.com (100.127.142.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:02 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.23; Tue, 25 Apr 2023 16:05:00 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:59 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:59 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 29/30] MdePkg: Warn if AArch64 RNDR instruction is not supported Date: Tue, 25 Apr 2023 17:04:27 +0100 Message-ID: <20230425160428.27980-30-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT007:EE_|GV1PR08MB8690:EE_|DBAEUR03FT048:EE_|PAWPR08MB9544:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fe27b84-846b-4f59-6910-08db45a6da01 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: uc27lfKnTq2iEN83UVm+C/aKxCDsytATXNssQguAafBzreMAmvfyV59kxqoAz4l9kKyywXlMn9zKMUeqpRembd5RG3XmWb/3nATJubBZmD2isjVeNxB2fSrmvvCUKud2581zR9yQZVEAjF6eXQ0l/UE0m/iEJJHsRmZ4v5m7oXNoU5AM8y57P2KtJ3S1rstmTkLUoh/MwXHu43iqsj6fTBD0fm1owuv2jo55+6kBjyuvO6uvYUrJGNrdMUf5e12qIRh8tpFsAuuA/e+NXoSXF7k8G8vMT9kzHDJN6dqRqdisU0qi5AECxN6VMRy3bvoBHeo0f09stLynh8KlrC8KmZU+or6d8Altn5KbvcT9hRLIsPktXfhNovjGxIKJgFvLpgDipsTS+vkKglL/6Nugh3TGgSA0LuXpdXmfqAJIyFDJa6ufyvhqxiVMd2mqNwYTvuH5fErbsQndkIwGWn78Vgbr6NaRBlMfsmwrzRsZDn2Dap8sDBA7QSb532icNRNkeMklcvofE1a1qmtRTiCflxtF0jScVvRDkZXOJdHyDGeFru3DnxotvhIB7Nh2jNFHW4xfgsb5AyqslwfeLWeKVXev1yEMUtoHDr61lHBll8plLix7GTPeHG0hlvD6a4kg7op3VPt9suvX4hshaJQxW1rBCJ+PuZVgzRMKaoOH8DuQQyYh6E/7u6oB2fTTKrjguEl4vhtCWu6VKJfvi1fPqW/rVpAEHuukdbASO270TjM= 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:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(36840700001)(46966006)(316002)(82740400003)(44832011)(6916009)(4326008)(81166007)(41300700001)(5660300002)(356005)(8936002)(8676002)(82310400005)(36756003)(86362001)(2906002)(40480700001)(7696005)(6666004)(1076003)(26005)(478600001)(34070700002)(2616005)(36860700001)(83380400001)(47076005)(336012)(426003)(186003)(19627235002)(54906003)(70206006)(70586007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8690 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e6dc4010-3c0e-4cdf-651b-08db45a6d3ef X-Microsoft-Antispam-Message-Info: D5+MHji0nF/yW2MqfRdS5qrQNHQIcz93a1OnaNcnrF66W54mHsKqgNQMEA8gmJK/+t5ZveKWVqUR4tJgfJSDBUqp1FqMzlgS8tsce8G9ApSeZIXLsnTjLW1bXYPtJH/gol06UBoi6th3NUoDi4Q9NROr0Ly3QETL9EiUp02zTiYntNa+GmAELcmRJHZOw1n7u07VI76PwWGlR005rEgvloDO4TaFEHAzHFXXIKdmbAR3CI6Uwl0OxTZJYneO5F4CP51QMu4emuIKLv5MA8Z6U3JeFMx5/wV0/CpLITneBWHF7dM556fXjcjHCbMrRlcHSGA9s5Bm/TG6eyqwkHyBWkMIUXk4+WGldjdVLjVqdL1mzuE++SHaGSOXjsDG9H27/XzAuhHAwhbLPuD3Mcl7MdsUx42nZVZfYMBQdmsC9MaWiJN7lAG2polSWdUa9e8Jycp6flVejMp48ibJD+MLsWscZRpY8nbsIBqFLyr7PVIJ/dZmFXYk7rRu+FcYrHPuqY66wAXDIKCNkNGgTAiu9eYbh1iekhheNT2AVFZwLb9Ru/UEM2Ge2cYJYRX7XZLaGWp6Ym2w2wqXp1eA+TofAezkgloGJFiiJXMXs19PrRmjB4F1geLcFvfO+kMt24MlE5uGmHj39MpRfgTk7HIX323CVFftAdeyC74Su6arnhunZ1ms5+hD+vWzzfgs0RFpoAanp2BM2VLrfNcRwzCSzYjs1A22/1DANMNzYxhFE2s= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:12.7314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fe27b84-846b-4f59-6910-08db45a6da01 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: DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9544 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: 5wU3jPsFe87v3IvNDszH6iBcx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438717; bh=KOt24moTeOYAncKX16DJZEsKlZftigno9mwiFGEEUAs=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=lEwShyN3VqfzquJtW2mww0+oRmSv9YIIcOe8b4FPheyudkHXP/xdAT0Wh4PL0uOxpQq +5fpiG/HipigGNXYis+8Cwuue0Uv+aMTH9mw8wDiTGpWF6qjQeQnm82IYInol5UnNxkWq +ss6sKUYWFXn93SH2PTplTYMLXiDn7pYh18= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438718987100072 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The BaseRngLib library constructor for AArch64 asserts if the RNDR instruction is not supported by the CPU. This approach to warn about the unsupported instruction may be suitable for the host platform firmware. However, for a guest firmware the only mechanism to discover the supported RNG interface is by probing the processor feature registers. The guest firmware may therefore assume that RNDR instruction is supported and if the probe fails, fall back to an alternate RNG source, e.g. Virtio RNG. Therefore, replace the assert with a warning message to allow the guest firmware to progress. Note: - If RNDR instruction is not supported, the GetRandomNumberXXX functions will return FALSE to indicate that the random number generation has failed. It is expected that the calling function checks the status and handles this error appropriately. - This change should not have any side effect as the behaviour will be similar to that of release builds where the asserts would be removed. Signed-off-by: Sami Mujawar --- MdePkg/Library/BaseRngLib/AArch64/Rndr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c b/MdePkg/Library/Base= RngLib/AArch64/Rndr.c index 20811bf3ebf3e82d4037a617e0ff3c0336495a51..991adbf896bbb7b2b7d2cea03c7= 5ecee0f284973 100644 --- a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c +++ b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c @@ -48,9 +48,13 @@ BaseRngLibConstructor ( // MSR. A non-zero value indicates that the processor supports the RNDR = instruction. // Isar0 =3D ArmReadIdIsar0 (); - ASSERT ((Isar0 & RNDR_MASK) !=3D 0); - mRndrSupported =3D ((Isar0 & RNDR_MASK) !=3D 0); + if (!mRndrSupported) { + DEBUG (( + DEBUG_WARN, + "WARNING: BaseRngLib: RNDR instruction not supported by the processo= r.\n" + )); + } =20 return EFI_SUCCESS; } --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103574): https://edk2.groups.io/g/devel/message/103574 Mute This Topic: https://groups.io/mt/98495987/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 08:47:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103575+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438718742563.3876482456574; Tue, 25 Apr 2023 09:05:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id d0ZRYY1788612x7MCCSqlIyS; Tue, 25 Apr 2023 09:05:18 -0700 X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.89]) by mx.groups.io with SMTP id smtpd.web11.83467.1682438717349846200 for ; Tue, 25 Apr 2023 09:05:17 -0700 X-Received: from AS8PR04CA0159.eurprd04.prod.outlook.com (2603:10a6:20b:331::14) by AS8PR08MB10099.eurprd08.prod.outlook.com (2603:10a6:20b:628::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:14 +0000 X-Received: from AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:331:cafe::8f) by AS8PR04CA0159.outlook.office365.com (2603:10a6:20b:331::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:14 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103575+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT057.mail.protection.outlook.com (100.127.140.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Tue, 25 Apr 2023 16:05:13 +0000 X-Received: ("Tessian outbound 945aec65ec65:v136"); Tue, 25 Apr 2023 16:05:13 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2c961156b0ee9ee4 X-CR-MTA-TID: 64aa7808 X-Received: from 0fd47ba6f48c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C5AA35FA-ED8C-49EC-9709-59BB20063A52.1; Tue, 25 Apr 2023 16:05:06 +0000 X-Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0fd47ba6f48c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:05:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qgvt6jCOqoEAKUkuPOS3tS3s+24OxRJx2F9mVTA4LNbVYHcJvJ6sgKR9wJt++/FY8aCONY0ZY2G9sqqizNxdorT8ILpEE+75MPOkh9F+jDFFz2XNWBf5l+D+4U09iNZ8D6fkBrDQ3P779lHa3KZuSAvTxM67LsUbPU25XpnTyUtWKYqKuege5wQeS/oNcvjRgSxNxjT2fIgLjxSGGpgpWBVxBHWBZEBCdcwOcyYd7+uY1MFmSTvDG+JEqpsRQzA1fXsJsdQv8nVhtoJ7ihzDdsgCSWXHRDhc8tvV2LRa4wgpvkdTuN8prZwULtkmTDifL2wiLfeq1j9ZlDaF02uQ/w== 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=B6BW4DLITQBE+qf/EJbQmQZamV0fpzUlCNUKDINAM3Q=; b=lLdfVn2rNlsmsFhWqI5NIwSBwUjr3dRqBqt827Y091b+lcMdT2sXC/b/7039Ygv/vW7c93AD9hgaWnsi+vCtDZyTvdEsjsZrVkEP4HkCvtQu5OChrZhUy0v+2VEXYuQK8ZY4WbQvV9k8g0QqvbzgX0PsREkC/iT/rGlgFuyAyzIdT8GFo4NfyiYDPiliuFv65ilfIwASVphI7BLelD46XqWizr/e/o6/GSYivo7dA2Ap5RavpWTnwXefxh3DjzJ/xkIyAJM4DuMlsH5IgTTtTbR0SOrAiUzkXljAbpFLWyIhGFIlR3g91L5yUvucAgrGvEpfS4Tt6v3YEQZ5gwrbAA== 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 X-Received: from DUZPR01CA0011.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::19) by GV2PR08MB8582.eurprd08.prod.outlook.com (2603:10a6:150:b5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:05:03 +0000 X-Received: from DBAEUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c3:cafe::38) by DUZPR01CA0011.outlook.office365.com (2603:10a6:10:3c3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:03 +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 DBAEUR03FT004.mail.protection.outlook.com (100.127.142.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:03 +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.23; Tue, 25 Apr 2023 16:05:00 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:05:00 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 30/30] ArmVirtPkg: Kvmtool: Switch to use BaseRng for AArch64 Date: Tue, 25 Apr 2023 17:04:28 +0100 Message-ID: <20230425160428.27980-31-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT004:EE_|GV2PR08MB8582:EE_|AM7EUR03FT057:EE_|AS8PR08MB10099:EE_ X-MS-Office365-Filtering-Correlation-Id: c9ca6ea9-e94e-4418-7133-08db45a6dac2 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: DEjrrNby/NYijJopYBHwgM6/lGSrqt8mTy/DMMhxZ5L+gK4To5isdWu+R8UwoOlPUs/7ydpQps5ahBHEb8ja2D8NTFQLkjErxD5yos2U0UdRbJLHQGaYdMztfnKnmOeGWZKiP8V5Ps235189G+jWiUnzj2S2Ry38PyTfQK+lqeR+Tgo7xDNvgyhHV9pTqsvCDsFfS3QsAtscO/TwsdG29VAgB+uN6pBaFSPClBq7hA4GuLWisM9BLxN2ggor630DY4PQ+jfJd5p6N047RTpZwcqiEbm/VijDXIox8fpkjJFa8S9JEHGspWwngja9I3DyZOiaGn9CtVUGLgmYuF/6Sdap+ToHRxJNCeYzi2VSTtYPVGoJS3Aj28A6kjzuFzO6i6x5y8WcK2Uic5BvwbbhyX9BGFvACtWdIOlW0myDvQqgP6um3F7K212Ve+7F7J8w/gMDcuZXqz7kinXOLcWOZxZwKRq80mkyfX83n6NBYQzP3KwnZrbmXgqgz602rALIYAUnuOKTp0JvDhlL6qcgvCkHdQ+RwoZ+ZIU9jTm/loq2kAgg3BdMgTP95ZIhtCfVf/Ilq9Gvxia7u7EaFpJxBeAWoF1emBr0JvKhaQ2olTGacOWAhW39d3cnjWvV9JRz28Gdt+K3JTGq8RJvsSwChVrHAfOPeVz0E8J4XlXqst/UzibZ5gVbe3pALWhLkByipFuK5gqjKdkMVbpYg6oaKCmCUSmAjicIKkumvRY9YZs= 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:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199021)(36840700001)(46966006)(34070700002)(54906003)(478600001)(5660300002)(8936002)(8676002)(36756003)(2906002)(86362001)(82310400005)(44832011)(40480700001)(6916009)(4326008)(82740400003)(316002)(70206006)(70586007)(356005)(41300700001)(81166007)(426003)(336012)(186003)(2616005)(1076003)(26005)(36860700001)(83380400001)(7696005)(47076005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8582 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: be2ccbc8-2170-4862-0de5-08db45a6d439 X-Microsoft-Antispam-Message-Info: a8YJHbAsK6VY0iH8Oy3xWisdN4bi6+nDs0z6Ud2niuZ8jgZPYVusN0skmGNfau3egtC/pgou+/BFqPmES7yU6597FWdrE0I8pPZ8t4JoL/j50TRAfs0yX/Z+tjStaWtTfohx/yVNStyDEpVl8VDbdNkZTakh1wKKGjWGXtmLdJ5ChXdtPEbtglrizCDe3A/KT9uDs8bAeadV9Cu+2SPWiCChbAb1DMMfSLk7BRyNHNYmuzrMpV11fdbmhI6XtcFmz8djE0Q47ZmWIroKtGaPGWiR6TcKfo6j8A8hBPLaaZK3zfpXskEyPNhtJ1gxWhOzJbx6IPK+nJwFkEFYSJO8ipFTif0popsRffzkzIaqLNkELjWmGxq9l2SVR9UAJ/uTQ4m3iM5ywee25F0InLcPPZrWS+ZFI7kHQ2Uh4Ea8COno3h2MwgeGgx9hJkw/LH1L4b2OAIp23N3FXUwMjrSUETj9EJ6E7jykmc53a0AsYuvzBwXwuDftJwiTKm9EWonylMmAgumaSlTIY2M+cy+sWWCTTWOzZDdPFUhoIzlBlc6+hU54bBWshbryYlMaa+LNEgH1DiDWnqlW+MwnhXtZrJYWqw7z1Bhwf5BjmTQKZg+k9C3tdOrRyhSR/S7qOqITrOU40J3BGnK6A/Qw9ypB9czY/9QHwvcf0IDKKmmHUWpZHV+U959Y1nQcmZZoZuXzVCva+TuGG9UPkB25q6S0D+b+vx6ltaU8EUa576bDK+4= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:13.9652 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9ca6ea9-e94e-4418-7133-08db45a6dac2 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: AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10099 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: WKa029E9RuI2gJ8vixnZfmSgx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438718; bh=6BBGVqrYAlF8gKQn6H2LgRQyZGVTbznB+14dOC17jy8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=og8x+OUQGGTyXNPXG572Nl1S7sbWk+gGLTwHeCbXjYRewIenjdj+qLP5tLuQ0BjdQIU jsiuvv4q3vecEOgg6ig8hzTRfCUK2msce2I87fBuPUs57Uy9YSALFT5cWBsGk6VmGDk3Z YoJSEIwLOg2tExDoNpMYgSWxbhmVsWqVvdM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438718984100071 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The kvmtool guest firmware is using the default RNG library defined in ArmVirtPkg.dsc.inc which is BaseRngLibTimerLib. BaseRngLibTimerLib is only present to use for test purposes on platforms that do not have a suitable RNG source and must not be used for production purposes. Armv8.5 introduces random number instructions (e.g., RNDR) which return a 64-bit random number. Although, this feature is optional, it can be assumed that most modern platforms will implement this support. This feature i.e. FEAT_RNG can be discovered by examining the processor feature registers. It is therefore desirable to use the RNDR instructions instead of using the default BaseRngLibTimerLib which is unsafe. The BaseRngLib in MdePkg already implements the RNG support using RNDR. However, it is worth noting that FEAT_RNG is supported in AArch64 state only. Therefore, switch to using the BaseRngLib instance for AArch64 firmware builds. The AArch32 firmware builds will continue to use BaseRngLibTimerLib. Note: The guest firmware already supports Virtio RNG. So, should the processor not implement FEAT_RNG, the guest firmware can fall back to use Virtio RNG. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtKvmTool.dsc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index d9dd7a67307ffed5da16837301f18e7715187450..829a378a8dcfdbb5045db361010= 4a0f5c43431dc 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -89,6 +89,7 @@ [LibraryClasses.common] [LibraryClasses.AARCH64] ArmCcaLib|ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf ArmCcaRsiLib|ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.inf + RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf =20 [LibraryClasses.common.SEC, LibraryClasses.common.PEI_CORE, LibraryClasses= .common.PEIM] PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf @@ -170,6 +171,10 @@ [PcdsFixedAtBuild.common] gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 !endif =20 + # Define a UUID that represents the CPU based RNG algorithm implemented = by RNDR + # {BABE3B70-6474-4C0C-AFD8-3B8A32482C40} + gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{ 0xba, 0xbe, = 0x3b, 0x70, 0x64, 0x74, 0x4c, 0x0c, 0xaf, 0xd8, 0x3b, 0x8a, 0x32, 0x48, 0x2= c, 0x40} + [PcdsPatchableInModule.common] # # This will be overridden in the code --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103575): https://edk2.groups.io/g/devel/message/103575 Mute This Topic: https://groups.io/mt/98495988/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-