From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Ly6hmnc/; spf=pass (domain: arm.com, ip: 40.107.8.44, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c7Rhv7lwNUd6hNtjUstF0C0s3ratn+qvdfaOTTaVr1Y=; b=Ly6hmnc/OOvqrkz8Okn70QQlzGmsrEqe/5YIdZOdmxQezhMyNlNKfQ8UbEwxCmbVcUGnE7nMqVEclUTd5g8dfuBHfjaYGtDb9E1yr0itmqWD6yHDvDLfXhkaGEC5atTsvUroc5T3f0NRL9/UOC+A/0mvGztRlg+eTCeCvvZFzUU= 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 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 (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 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 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 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 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c7Rhv7lwNUd6hNtjUstF0C0s3ratn+qvdfaOTTaVr1Y=; b=Ly6hmnc/OOvqrkz8Okn70QQlzGmsrEqe/5YIdZOdmxQezhMyNlNKfQ8UbEwxCmbVcUGnE7nMqVEclUTd5g8dfuBHfjaYGtDb9E1yr0itmqWD6yHDvDLfXhkaGEC5atTsvUroc5T3f0NRL9/UOC+A/0mvGztRlg+eTCeCvvZFzUU= 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 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 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 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 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: [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> X-Mailer: git-send-email 2.16.2.windows.1 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 Return-Path: Sami.Mujawar@arm.com 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: BCL:0; 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-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(54906003)(36756003)(40460700003)(34070700002)(478600001)(82740400003)(316002)(40480700001)(6916009)(70586007)(70206006)(4326008)(41300700001)(44832011)(81166007)(8676002)(2906002)(8936002)(5660300002)(36860700001)(186003)(426003)(86362001)(336012)(26005)(1076003)(2616005)(7696005)(6666004)(47076005)(83380400001)(82310400005);DIR:OUT;SFP:1101; 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 Content-Type: text/plain 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..5468b2506522bbc9a1467045df0eed6fc70f24de 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 fd29fc61caf880bcaf96d982f3a4d973e7ebb70f..5b04c8af890fead113b827030f86af5f07698354 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)'