From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail03.groups.io (mail03.groups.io [45.79.227.220]) by spool.mail.gandi.net (Postfix) with ESMTPS id 46C04D811D3 for ; Fri, 12 Apr 2024 14:34:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=E4giJJcz897Z7NkCvh9FWteixFCtghxnYbHtKrIyyfQ=; c=relaxed/simple; d=groups.io; h=Received-SPF:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:NoDisclaimer:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1712932441; v=1; b=pALy+odi829e5dwsrucDwEsNFlTlrIdOOdb/0ak0Yg89FEJysQGQrGIh483hMKa9SKWkK+EG 6wk8tTMUXl3r0hOhJnxusfqQmYCPCbimD5Co/ga5hgKh3SkPowXbYgSR8hqzNvDCuIvfP8xmiI+ 2JXZySpM19opZNiIZ+ftQLSathjN3OI/LViTRZEc3d+vDtHaMmYJ4LtJc2KQLUe8PiGlC4SpvUz olLL7RUnR/RH/JjkUIcahgt2773HcUWTb8CRLRuIPE6dlnxw01T4Q/QaqHRptYx7F/81TTGWdQc RxRJP4++syhefdnnv8ewiY6yh+k6g9oLudvz8kgvXI+Kg== X-Received: by 127.0.0.2 with SMTP id NLyKYY7687511xQnWVzpWHUZ; Fri, 12 Apr 2024 07:34:01 -0700 X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.71]) by mx.groups.io with SMTP id smtpd.web10.48540.1712932434115055989 for ; Fri, 12 Apr 2024 07:33:54 -0700 X-Received: from DB8PR09CA0008.eurprd09.prod.outlook.com (2603:10a6:10:a0::21) by DBBPR08MB10603.eurprd08.prod.outlook.com (2603:10a6:10:52b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Fri, 12 Apr 2024 14:33:48 +0000 X-Received: from DB5PEPF00014B8E.eurprd02.prod.outlook.com (2603:10a6:10:a0:cafe::8a) by DB8PR09CA0008.outlook.office365.com (2603:10a6:10:a0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.22 via Frontend Transport; Fri, 12 Apr 2024 14:33:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5PEPF00014B8E.mail.protection.outlook.com (10.167.8.202) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 14:33:48 +0000 X-Received: ("Tessian outbound 8c03561b2da6:v313"); Fri, 12 Apr 2024 14:33:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 695431eaa0efd84d X-CR-MTA-TID: 64aa7808 X-Received: from b1ea8f3b84b0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EF50757A-8E7C-406D-A8FC-476142CF71DD.1; Fri, 12 Apr 2024 14:33:35 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b1ea8f3b84b0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Apr 2024 14:33:35 +0000 X-Received: from DB7PR03CA0096.eurprd03.prod.outlook.com (2603:10a6:10:72::37) by PA4PR08MB6270.eurprd08.prod.outlook.com (2603:10a6:102:f3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Fri, 12 Apr 2024 14:33:32 +0000 X-Received: from DU2PEPF00028D02.eurprd03.prod.outlook.com (2603:10a6:10:72:cafe::9b) by DB7PR03CA0096.outlook.office365.com (2603:10a6:10:72::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 14:33:32 +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 DU2PEPF00028D02.mail.protection.outlook.com (10.167.242.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 14:33: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.35; Fri, 12 Apr 2024 14:33:29 +0000 X-Received: from E114225.Arm.com (10.1.196.56) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 12 Apr 2024 14:33:28 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [edk2-devel] [PATCH v2 08/45] ArmVirtPkg: ArmCcaRsiLib: Add an interface to make a RSI Host Call Date: Fri, 12 Apr 2024 15:32:45 +0100 Message-ID: <20240412143322.5244-9-sami.mujawar@arm.com> In-Reply-To: <20240412143322.5244-1-sami.mujawar@arm.com> References: <20240412143322.5244-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DU2PEPF00028D02:EE_|PA4PR08MB6270:EE_|DB5PEPF00014B8E:EE_|DBBPR08MB10603:EE_ X-MS-Office365-Filtering-Correlation-Id: ca9d2fbb-76a4-429a-09ca-08dc5afd9101 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: PQJNF9IBLnn/RJ/pjHmcIDVQpUhPGxF5a3tDCPaxstRY+sEHlIaFQ5kmQHlC9IhsJvK/CcW+2i+Ig/Iov659vmR+0m+lcnalsRejc54s4Xw9jy8pDB9Z0+CS6zqaGtfbDm4Umaw5ZxVduWIwRDe+S0N9irxYmLpkldyI27nMzoEVU6e9oE5eO7tFdfJbVawG5o7x4JQlJqj6FGYdR258us2m7Jxa7N1WCYF1GqbVI/UTqL2Nzbc/GnXrb1XSaWj95g3q3ked8bEzeGY1o0vSgbMotQZYV1yTvX10ZO9yxwoErc6UigCsKNINodeWgH2je2q9FZ9oqsIlsGbRuT5zQ53Dx1NehPbbdhJ36On8lgtnECU71xsgFZeiU0FcHKYNt+rcCIqCXy2Lb+YsiHRBA+z6heQtWC0liTgyNHpiXcWU+Q2EdF8tkKYKtoBul441Rl+x62ubtsyl3T9GNu/wWTtil4CM42HhQWvHi391H/23pP+93llMb69jmoMQf5UTJ0Jpt8Y60bksULb8yUS8RZBcGfeazmalwbc8SxMq16t5HFvOsNp7Bxawe8ltws6R6CK9NxD9ENj0r1pntfwdY0b03mooi944Thz33+uroQ8wQGID5bVJtHt6kwoW02eyjBI0HpxcyDVB74vZfTAdXyvhluXRv0GqAu7f8BgM3n9NPylr/ooN6UkHI5i1OiPMzDPIAJ5kEGFVq8V0T8D4HS7sCcx7sPfRGWN6aGVn07ALET656iB9M9uCx9YK35vN X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6270 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5PEPF00014B8E.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: fade9bc9-b9a5-432e-edf1-08dc5afd8786 X-Microsoft-Antispam-Message-Info: KVsUY5r2m1MKjDwYTXjQEj6dhYhFDXDMjB9wTdakgDGjL5X91KfvaLX0+3o9JCvVSLZDBKZY2a1n1iGWEvJIPRGkcfR7NHsSEpoj+2uSsLYzU8bDuCH/851VdGAOGuNXqDsO37emrsAXUrDbjviHU5aNnOI6iB4Lqt9FajB72Dh0L8hnZNXMEemSMXD47mG58DjYyoZJ51w06UKWGcgIcKUT+3GrLfl+Q2KzFSzwoNym6SK8ix3m+JMDvlhvM828HKNV4pkbrTGyGrGput1K5/evjhGl+k539QElTOCyMZgYO0BViR8dN92w8+Vrx0skagl7MLM5R37te6D0+zGLQAw0+v6A/LEqjiTx3Bc1jF4Mzl8T+uL+rTJiDUTLY6Ap+NkR54LX5xOPW/43JE8PSL7+cxzdwQy2ZAkjW238uW17FM3eXNpxVpz4hDg4ttGOIlQNEQrIMQjVddK8FDv7hpabAglweM9/pQeHPm3Kh16Fei/fDIo4+dbwevccuC6dCBkHHA2kF+4940Rg1f71OSs+bcQ4tOJfQGFFN7D4hiS5hAw9Fht6cguvQxHZ4xKjfzJWzejJdfp0wOagTGV+gINtASxYqqPCO+AKIvriY6VOQRMNzN1T0DUPCC64CBSLkQPYX6MfX9W5UJIO1H/Pyi+q5pnyqElHoWFTU55EEAOWIGhG28ndr0CMH2Hvpus0h8LpTtmFsEkqEC510+QIeVEbGi6pBnXYWUAqmLlAvCHs4mptZ57Z22gF3CMS0XTX X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 14:33:48.5757 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca9d2fbb-76a4-429a-09ca-08dc5afd9101 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: DB5PEPF00014B8E.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB10603 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 12 Apr 2024 07:33:54 -0700 Resent-From: sami.mujawar@arm.com Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Hf7jIFE0eknnEG7QGISqAXaix7686176AA= Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=pALy+odi; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.227.220 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) 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. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Gerd Hoffmann 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 99a8175262331f4b0ddc098c3c62a20954b2b516..db1ae5b4c1a6475a275ce6be3383ea933ec9af20 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; +/** 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. @@ -198,6 +213,27 @@ RsiGetRealmConfig ( IN REALM_CONFIG *Config ); +/** + 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. diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h index 6f0ee3061ade5a4a99b717a52d5a241e0e446270..70e84a20711f04c32a5850230cc907a6d231f50b 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/Library/ArmCcaRsiLib/ArmCcaRsiLib.c index eb9896668a267f2cdf30f36bd14697d56d2612ed..79a65300f05af665b3afebe2a8f8b1f6faf76f23 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c @@ -489,6 +489,46 @@ RsiGetRealmConfig ( return RsiCmdStatusToEfiStatus (SmcCmd.Arg0); } +/** + 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 == NULL) || (!AddrIsGranuleAligned ((UINT64 *)Args))) { + return RETURN_INVALID_PARAMETER; + } + + STATIC_ASSERT (sizeof (HOST_CALL_ARGS) == SIZE_4KB); + + // Clear the reserved fields + ZeroMem (&Args->Reserved, sizeof (Args->Reserved)); + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 = FID_RSI_HOST_CALL; + SmcCmd.Arg1 = (UINTN)Args; + + ArmCallSmc (&SmcCmd); + return RsiCmdStatusToEfiStatus (SmcCmd.Arg0); +} + /** Get the version of the RSI implementation. -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117686): https://edk2.groups.io/g/devel/message/117686 Mute This Topic: https://groups.io/mt/105483425/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-