From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2059.outbound.protection.outlook.com [40.107.249.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1391E28E8; Fri, 27 Jan 2023 11:41:49 +0000 (UTC) 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=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=zUAwlXkO3HsOouGuiII0TbNTcNLGTfiYODHQnOU8XcnquggamJJ/R1xEIOurpHPhsSkHe2Mn+VN5j6xBYXA7jKkFC0lEB2qjo0Wgv0bRSTydaWesh+YrnMIMmzpbZTJgLsXtz/PXZd5GsxB273oLNs/Kw/TtaqaBmmCrmVsnkfY= Received: from AM6PR04CA0002.eurprd04.prod.outlook.com (2603:10a6:20b:92::15) by DU0PR08MB9846.eurprd08.prod.outlook.com (2603:10a6:10:445::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21; Fri, 27 Jan 2023 11:41:45 +0000 Received: from AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:92:cafe::17) by AM6PR04CA0002.outlook.office365.com (2603:10a6:20b:92::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:41: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 (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 AM7EUR03FT062.mail.protection.outlook.com (100.127.140.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:41:45 +0000 Received: ("Tessian outbound baf1b7a96f25:v132"); Fri, 27 Jan 2023 11:41:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f541c80697b1d018 X-CR-MTA-TID: 64aa7808 Received: from ef6d3d9679ba.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1235D9C1-D4EB-40A7-AF4E-4BCBA772B947.1; Fri, 27 Jan 2023 11:41:38 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ef6d3d9679ba.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDS80Fatr69LDCB09zJP2pGgOkcxwRdgpS502m9mfHT6YINpkO8CCn4/damB6td1IspHUsVbrW24rzWeQzaP6MVMOXaLe1PybZNV66ac7jzlx9rMXzWIUMTbLFcsknLu+fPLmuL4qL7G8B6TgrGjFKX7/5EWeWv4i5Tdd7JBDLZ3OTcoo5nDlGYohtluqUAoY0eXMN6Kej8eMzLrK2cIbGS1/ljOATou4m5dzPbhFNYrtuebLtsHD+jr+Gc9loYrYWq/gnsAMGiIMLaSpp1tmaXta0uanEXGvU9RsCIBPpEgPf2IT2pgDJ2C+7+JbFHkJJ4PlinZK7spSIKKSwdYtw== 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=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=JOdnRuvCOzXu1OJNIDEk52DZrbXcXK3AWlpgtCeSzcDn8oLdZX6q8mfqqXB4By1JnwQmWFecDAtY9EhaJDFE4m5ss5beKAY4QHrbwN6p0t1l8R4KqSky4DwHarxIjZJiVeeR/wS1VwZNy7uj8pclXbSnfBQqERhdIs/l9n1WIoBExJhw3wQ5N/L6mcKZi9HFvo1/B8YxS4gWgQtSUq9Tvrikz6nPBYlBfE3wRnqvdkpC5JqbVFZwzuZ9cfenEgjp380539LZ8ssZChCg3XfLMD/B+RierTA2otOxG0pqVryd1AT+G3aTr76o3yOprWXlu5A7wVzyfqhnursxJe4L4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev 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=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=zUAwlXkO3HsOouGuiII0TbNTcNLGTfiYODHQnOU8XcnquggamJJ/R1xEIOurpHPhsSkHe2Mn+VN5j6xBYXA7jKkFC0lEB2qjo0Wgv0bRSTydaWesh+YrnMIMmzpbZTJgLsXtz/PXZd5GsxB273oLNs/Kw/TtaqaBmmCrmVsnkfY= Received: from DUZPR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::18) by AS8PR08MB8706.eurprd08.prod.outlook.com (2603:10a6:20b:564::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:41:35 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::cb) by DUZPR01CA0164.outlook.office365.com (2603:10a6:10:4b3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.35 via Frontend Transport; Fri, 27 Jan 2023 11:41: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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:34 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:41:27 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:21 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 02/27] arm: Expand SMCCC arguments and return values Date: Fri, 27 Jan 2023 11:40:43 +0000 Message-ID: <20230127114108.10025-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|AS8PR08MB8706:EE_|AM7EUR03FT062:EE_|DU0PR08MB9846:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f3900d1-9c9e-4301-2f84-08db005b779e 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: oQJjb/Wo+WCK/3gYJfPP3Z6forKMnlJbI/FRPW/46kP030cHpBi22Kahjb4HzTWB0uQtsVm+X8imP/rkMU4db8+CsTHFd/ehkxorog2cpAWglvv/0Ic24SzIzB1O1DyCZkh1G6CXb4/7W2vQWK8FqJ8iM0SEYRP6YqIpdcLAsDk0bMnMLJ7nvWL1PeEzJTy37rE+GMsLmxyY+nvv803SJVyc46KyvLv0A7rQWnl+Bld/RySh9FJ/UFA4A85qcubj/eTdSc2ROvf6urPdmx4XtPUyQeDfa7+yNKkpQpvxJ/W5YpxU4Y5Y6HD8oujG0mneDfJUZsoFh9ECabmjCB+JaOPTNQFb5a7baiJWj3XYL0GOHnDoR3Uv2vimdRqXqbWZHRK5sg/M2Yz9XQx/nIWLNz+TxHd+Tiqk6rwzmXpuDbLve/jFJEAKLW/GW9umaMJ14loGlRKdAU293bqKqcyh3QOV29LhcEJGSMoiszmmjnLrv9G4GyrEvtm85K60Tbm+vVMiYqhwhR8+QfbnH7zcDd63Mf6fUzPAxYyU7hidxhceuNa7IIJJOPJZ3HnRW1SNfFJ6Capss9981jU33EK/I0LDgk48iFOcj+TWL1masK77ttOtQ8L1iOSmS9jKuzpgZ1ebgcVje8UnlvAzdGYdktiIEHMVSLEhekRfC91UC19JEpLLcWL4epU70SZ6A67rf6FikfIAHuPqkdgcvtjMXBqwC45r4Pbx74Gu6ZcXUk0rse1zHWEYSbR6yqEHYYif 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:(13230025)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199018)(40470700004)(36840700001)(46966006)(7696005)(336012)(478600001)(6666004)(2906002)(4326008)(26005)(186003)(44832011)(1076003)(8676002)(70206006)(70586007)(426003)(47076005)(110136005)(2616005)(54906003)(83380400001)(356005)(36860700001)(82740400003)(316002)(36756003)(5660300002)(41300700001)(40460700003)(7416002)(40480700001)(81166007)(8936002)(82310400005)(86362001)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8706 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d055afe7-ace8-46c6-33e7-08db005b7115 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R9KgFkkfoyrWYjQAZxzdYTTjWyGTnVXNe2do4uWh9wAEe8IqLzJ6BaaWKNS+YXC3ap2J2djnwuUnSKz2rZoNT8eyD5UBncxRYlm4aWTaeWe8fbx93mvRDeBvEytIzM355dhDgSwZbNkXV1iNVCQ1RFs2pZ8vRq+ims1mtEwGxPY0RnEAkgXMDkD1GjQ46seoJh6Jb5lmsxnp44IFkNCdCqg5s+pWxTx6AwHRZ1j/M2MRhnxlibruLxpOAevSdD5U0i46fZAy1wC1E4kCbolAWXRf+zhCX2ksxy6Q+eW3i/A3Gs3MAk4M6JyXF53BBUqOlLvBZri3p4PKWphW8504ELCQrL0B4JNjbtfcnynNg5TC/tEhWsCgwrLdjmUw03y9gbcuOijkXgSbY61dLRdqQzW9W3yfHHVAelB3e2OVp0mH4VzoXSMfrI/y28FPsPtOxOv/xXYB7mES2wier+ytmixc+LRobX6J/84Jii4jRHz1wDwGWiIl2vcxgLUNwTNu/v1M0oaZbnfWGPqBUnKKmH3Lx1qbt7oechWxGl+xcrIQs9WRgDDrssGmxFStoLQp2ZleOLKXfChDiLsoMUMULMFoNoYHxw/3YicOAVdTAqqVOO5Si33EuHXyTLLA+sgtUyY1rsyU02mjhUUB7XqVy/iNZJcj9rxSsQHfLDSVXx/mY8izMggUR4xYmGRfoameEhz5xa0PzteOmIqmeoz5+hcjFGX6Mp10P7aBaD/J/Vw= 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:(13230025)(4636009)(39860400002)(136003)(396003)(346002)(376002)(451199018)(40470700004)(46966006)(36840700001)(36756003)(40480700001)(83380400001)(81166007)(2616005)(8676002)(44832011)(5660300002)(8936002)(2906002)(26005)(40460700003)(86362001)(7696005)(186003)(1076003)(4326008)(107886003)(6666004)(478600001)(70206006)(70586007)(82740400003)(47076005)(426003)(36860700001)(336012)(110136005)(316002)(54906003)(450100002)(41300700001)(82310400005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:41:45.0999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f3900d1-9c9e-4301-2f84-08db005b779e 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: AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9846 From: Alexandru Elisei PSCI uses the SMC Calling Convention (SMCCC) to communicate with the higher level software. PSCI uses at most 4 arguments and expend only one return value. However, SMCCC has provisions for more arguments (upto 17 depending on the SMCCC version) and upto 10 distinct return values. We are going to be adding tests that make use of it, so add support for the extended number of arguments and return values. Also rename the SMCCC functions to generic, non-PSCI names, so they can be used for Realm services. Signed-off-by: Alexandru Elisei [ Expand the number of args to 11 /results 10] Signed-off-by: Joey Gouly --- arm/cstart.S | 49 ++++++++++++++++++++++++++++------ arm/cstart64.S | 55 +++++++++++++++++++++++++++++++++------ arm/selftest.c | 2 +- lib/arm/asm/arm-smccc.h | 44 +++++++++++++++++++++++++++++++ lib/arm/asm/psci.h | 13 +++++---- lib/arm/psci.c | 19 +++++++++++--- lib/arm64/asm/arm-smccc.h | 6 +++++ 7 files changed, 160 insertions(+), 28 deletions(-) create mode 100644 lib/arm/asm/arm-smccc.h create mode 100644 lib/arm64/asm/arm-smccc.h diff --git a/arm/cstart.S b/arm/cstart.S index 7036e67f..db377668 100644 --- a/arm/cstart.S +++ b/arm/cstart.S @@ -96,26 +96,59 @@ start: .text /* - * psci_invoke_hvc / psci_invoke_smc + * arm_smccc_hvc / arm_smccc_smc * * Inputs: * r0 -- function_id * r1 -- arg0 * r2 -- arg1 * r3 -- arg2 + * [sp] - arg3 + * [sp + #4] - arg4 + * [sp + #8] - arg5 + * [sp + #12] - arg6 + * [sp + #16] - arg7 + * [sp + #20] - arg8 + * [sp + #24] - arg9 + * [sp + #28] - arg10 + * [sp + #32] - result (as a pointer to a struct smccc_result) * * Outputs: * r0 -- return code + * + * If result pointer is not NULL: + * result.r0 -- return code + * result.r1 -- r1 + * result.r2 -- r2 + * result.r3 -- r3 + * result.r4 -- r4 + * result.r5 -- r5 + * result.r6 -- r6 + * result.r7 -- r7 + * result.r8 -- r8 + * result.r9 -- r9 */ -.globl psci_invoke_hvc -psci_invoke_hvc: - hvc #0 +.macro do_smccc_call instr + mov r12, sp + push {r4-r11} + ldm r12, {r4-r11} + \instr #0 + ldr r10, [sp, #64] + cmp r10, #0 + beq 1f + stm r10, {r0-r9} +1: + pop {r4-r11} mov pc, lr +.endm -.globl psci_invoke_smc -psci_invoke_smc: - smc #0 - mov pc, lr +.globl arm_smccc_hvc +arm_smccc_hvc: + do_smccc_call hvc + +.globl arm_smccc_smc +arm_smccc_smc: + do_smccc_call smc enable_vfp: /* Enable full access to CP10 and CP11: */ diff --git a/arm/cstart64.S b/arm/cstart64.S index e4ab7d06..b689b132 100644 --- a/arm/cstart64.S +++ b/arm/cstart64.S @@ -110,26 +110,65 @@ start: .text /* - * psci_invoke_hvc / psci_invoke_smc + * arm_smccc_hvc / arm_smccc_smc * * Inputs: * w0 -- function_id * x1 -- arg0 * x2 -- arg1 * x3 -- arg2 + * x4 -- arg3 + * x5 -- arg4 + * x6 -- arg5 + * x7 -- arg6 + * sp -- { arg7, arg8, arg9, arg10, result } * * Outputs: * x0 -- return code + * + * If result pointer is not NULL: + * result.r0 -- return code + * result.r1 -- x1 + * result.r2 -- x2 + * result.r3 -- x3 + * result.r4 -- x4 + * result.r5 -- x5 + * result.r6 -- x6 + * result.r7 -- x7 + * result.r8 -- x8 + * result.r9 -- x9 */ -.globl psci_invoke_hvc -psci_invoke_hvc: - hvc #0 +.macro do_smccc_call instr + /* Save x8-x11 on stack */ + stp x9, x8, [sp, #-16]! + stp x11, x10, [sp, #-16]! + /* Load arg7 - arg10 from the stack */ + ldp x8, x9, [sp, #32] + ldp x10, x11, [sp, #48] + \instr #0 + /* Get the result address */ + ldr x10, [sp, #64] + cmp x10, xzr + b.eq 1f + stp x0, x1, [x10, #0] + stp x2, x3, [x10, #16] + stp x4, x5, [x10, #32] + stp x6, x7, [x10, #48] + stp x8, x9, [x10, #64] +1: + /* Restore x8-x11 from stack */ + ldp x11, x10, [sp], #16 + ldp x9, x8, [sp], #16 ret +.endm -.globl psci_invoke_smc -psci_invoke_smc: - smc #0 - ret +.globl arm_smccc_hvc +arm_smccc_hvc: + do_smccc_call hvc + +.globl arm_smccc_smc +arm_smccc_smc: + do_smccc_call smc get_mmu_off: adrp x0, auxinfo diff --git a/arm/selftest.c b/arm/selftest.c index 9f459ed3..6f825add 100644 --- a/arm/selftest.c +++ b/arm/selftest.c @@ -405,7 +405,7 @@ static void psci_print(void) int ver = psci_invoke(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); report_info("PSCI version: %d.%d", PSCI_VERSION_MAJOR(ver), PSCI_VERSION_MINOR(ver)); - report_info("PSCI method: %s", psci_invoke == psci_invoke_hvc ? + report_info("PSCI method: %s", psci_invoke_fn == arm_smccc_hvc ? "hvc" : "smc"); } diff --git a/lib/arm/asm/arm-smccc.h b/lib/arm/asm/arm-smccc.h new file mode 100644 index 00000000..5d85b01a --- /dev/null +++ b/lib/arm/asm/arm-smccc.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#ifndef _ASMARM_ARM_SMCCC_H_ +#define _ASMARM_ARM_SMCCC_H_ + +struct smccc_result { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r9; +}; + +typedef int (*smccc_invoke_fn)(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); +extern int arm_smccc_hvc(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); +extern int arm_smccc_smc(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); + +#endif /* _ASMARM_ARM_SMCCC_H_ */ diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h index cf03449b..6a399621 100644 --- a/lib/arm/asm/psci.h +++ b/lib/arm/asm/psci.h @@ -3,13 +3,12 @@ #include #include -typedef int (*psci_invoke_fn)(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); -extern psci_invoke_fn psci_invoke; -extern int psci_invoke_hvc(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); -extern int psci_invoke_smc(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); +#include + +extern smccc_invoke_fn psci_invoke_fn; + +extern int psci_invoke(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2); extern void psci_set_conduit(void); extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point); extern void psci_system_reset(void); diff --git a/lib/arm/psci.c b/lib/arm/psci.c index 9c031a12..0a1d0e82 100644 --- a/lib/arm/psci.c +++ b/lib/arm/psci.c @@ -13,13 +13,24 @@ #include static int psci_invoke_none(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2) + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result) { printf("No PSCI method configured! Can't invoke...\n"); return PSCI_RET_NOT_PRESENT; } -psci_invoke_fn psci_invoke = psci_invoke_none; +smccc_invoke_fn psci_invoke_fn = psci_invoke_none; + +int psci_invoke(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2) +{ + return psci_invoke_fn(function_id, arg0, arg1, arg2, 0, 0, 0, 0, 0, 0, 0, 0, NULL); +} int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) { @@ -69,9 +80,9 @@ void psci_set_conduit(void) assert(method != NULL && len == 4); if (strcmp(method->data, "hvc") == 0) - psci_invoke = psci_invoke_hvc; + psci_invoke_fn = arm_smccc_hvc; else if (strcmp(method->data, "smc") == 0) - psci_invoke = psci_invoke_smc; + psci_invoke_fn = arm_smccc_smc; else assert_msg(false, "Unknown PSCI conduit: %s", method->data); } diff --git a/lib/arm64/asm/arm-smccc.h b/lib/arm64/asm/arm-smccc.h new file mode 100644 index 00000000..ab649489 --- /dev/null +++ b/lib/arm64/asm/arm-smccc.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#include "../../arm/asm/arm-smccc.h" -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CA5FC54EAA for ; Fri, 27 Jan 2023 12:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N5PrZJp1CfpFuOw3wWtSzySSG4UD2+NtPK4Qi+sxhdA=; b=Cmi2rhcGQKrnz3 v8h85S1bnculKXbqgd3tMbeCnpZOYJ5rxd6AEO2C542FY6f6QfvuleUcQjcYqgQIYZh2qivFGtj5h L3j9eCpY9N1VNTkmDnmQk4mgKMqzkYRYTeZVlb05WvnLKFU9RfNtg9oFZ9/uOK1LdfcQzdVh+dUZ0 NOSz6XvlGhACkiD3c26yT8F5HwBRGdVpE29zupA0juWBnjgIjUbQFS/8MirJnWr1MIHSL02Lal2WU hIUM2T5joCoprTEQexsYF7QQ9ET2kda6hEg8y03KdL5IPKK5FGMZ3Hv4dhDFMs/nnjN1FfwOtOmjL ki59KBKRwCGIbsppckMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNhm-00EV6k-Ob; Fri, 27 Jan 2023 12:19:44 +0000 Received: from mail-he1eur04on2089.outbound.protection.outlook.com ([40.107.7.89] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN7C-00EDhd-0t for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:56 +0000 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=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=zUAwlXkO3HsOouGuiII0TbNTcNLGTfiYODHQnOU8XcnquggamJJ/R1xEIOurpHPhsSkHe2Mn+VN5j6xBYXA7jKkFC0lEB2qjo0Wgv0bRSTydaWesh+YrnMIMmzpbZTJgLsXtz/PXZd5GsxB273oLNs/Kw/TtaqaBmmCrmVsnkfY= Received: from AS9PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:20b:46a::35) by GV2PR08MB8100.eurprd08.prod.outlook.com (2603:10a6:150:7a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:41:45 +0000 Received: from AM7EUR03FT017.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46a:cafe::c8) by AS9PR04CA0050.outlook.office365.com (2603:10a6:20b:46a::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41: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 (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 AM7EUR03FT017.mail.protection.outlook.com (100.127.140.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:41:45 +0000 Received: ("Tessian outbound baf1b7a96f25:v132"); Fri, 27 Jan 2023 11:41:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f541c80697b1d018 X-CR-MTA-TID: 64aa7808 Received: from ef6d3d9679ba.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1235D9C1-D4EB-40A7-AF4E-4BCBA772B947.1; Fri, 27 Jan 2023 11:41:38 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ef6d3d9679ba.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDS80Fatr69LDCB09zJP2pGgOkcxwRdgpS502m9mfHT6YINpkO8CCn4/damB6td1IspHUsVbrW24rzWeQzaP6MVMOXaLe1PybZNV66ac7jzlx9rMXzWIUMTbLFcsknLu+fPLmuL4qL7G8B6TgrGjFKX7/5EWeWv4i5Tdd7JBDLZ3OTcoo5nDlGYohtluqUAoY0eXMN6Kej8eMzLrK2cIbGS1/ljOATou4m5dzPbhFNYrtuebLtsHD+jr+Gc9loYrYWq/gnsAMGiIMLaSpp1tmaXta0uanEXGvU9RsCIBPpEgPf2IT2pgDJ2C+7+JbFHkJJ4PlinZK7spSIKKSwdYtw== 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=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=JOdnRuvCOzXu1OJNIDEk52DZrbXcXK3AWlpgtCeSzcDn8oLdZX6q8mfqqXB4By1JnwQmWFecDAtY9EhaJDFE4m5ss5beKAY4QHrbwN6p0t1l8R4KqSky4DwHarxIjZJiVeeR/wS1VwZNy7uj8pclXbSnfBQqERhdIs/l9n1WIoBExJhw3wQ5N/L6mcKZi9HFvo1/B8YxS4gWgQtSUq9Tvrikz6nPBYlBfE3wRnqvdkpC5JqbVFZwzuZ9cfenEgjp380539LZ8ssZChCg3XfLMD/B+RierTA2otOxG0pqVryd1AT+G3aTr76o3yOprWXlu5A7wVzyfqhnursxJe4L4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev 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=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=zUAwlXkO3HsOouGuiII0TbNTcNLGTfiYODHQnOU8XcnquggamJJ/R1xEIOurpHPhsSkHe2Mn+VN5j6xBYXA7jKkFC0lEB2qjo0Wgv0bRSTydaWesh+YrnMIMmzpbZTJgLsXtz/PXZd5GsxB273oLNs/Kw/TtaqaBmmCrmVsnkfY= Received: from DUZPR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::18) by AS8PR08MB8706.eurprd08.prod.outlook.com (2603:10a6:20b:564::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:41:35 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::cb) by DUZPR01CA0164.outlook.office365.com (2603:10a6:10:4b3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.35 via Frontend Transport; Fri, 27 Jan 2023 11:41: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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:34 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:41:27 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:21 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 02/27] arm: Expand SMCCC arguments and return values Date: Fri, 27 Jan 2023 11:40:43 +0000 Message-ID: <20230127114108.10025-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|AS8PR08MB8706:EE_|AM7EUR03FT017:EE_|GV2PR08MB8100:EE_ X-MS-Office365-Filtering-Correlation-Id: cf508e93-a44c-4c0b-5d81-08db005b7798 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: oQJjb/Wo+WCK/3gYJfPP3Z6forKMnlJbI/FRPW/46kP030cHpBi22Kahjb4HzTWB0uQtsVm+X8imP/rkMU4db8+CsTHFd/ehkxorog2cpAWglvv/0Ic24SzIzB1O1DyCZkh1G6CXb4/7W2vQWK8FqJ8iM0SEYRP6YqIpdcLAsDk0bMnMLJ7nvWL1PeEzJTy37rE+GMsLmxyY+nvv803SJVyc46KyvLv0A7rQWnl+Bld/RySh9FJ/UFA4A85qcubj/eTdSc2ROvf6urPdmx4XtPUyQeDfa7+yNKkpQpvxJ/W5YpxU4Y5Y6HD8oujG0mneDfJUZsoFh9ECabmjCB+JaOPTNQFb5a7baiJWj3XYL0GOHnDoR3Uv2vimdRqXqbWZHRK5sg/M2Yz9XQx/nIWLNz+TxHd+Tiqk6rwzmXpuDbLve/jFJEAKLW/GW9umaMJ14loGlRKdAU293bqKqcyh3QOV29LhcEJGSMoiszmmjnLrv9G4GyrEvtm85K60Tbm+vVMiYqhwhR8+QfbnH7zcDd63Mf6fUzPAxYyU7hidxhceuNa7IIJJOPJZ3HnRW1SNfFJ6Capss9981jU33EK/I0LDgk48iFOcj+TWL1masK77ttOtQ8L1iOSmS9jKuzpgZ1ebgcVje8UnlvAzdGYdktiIEHMVSLEhekRfC91UC19JEpLLcWL4epU70SZ6A67rf6FikfIAHuPqkdgcvtjMXBqwC45r4Pbx74Gu6ZcXUk0rse1zHWEYSbR6yqEHYYif 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:(13230025)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199018)(40470700004)(36840700001)(46966006)(7696005)(336012)(478600001)(6666004)(2906002)(4326008)(26005)(186003)(44832011)(1076003)(8676002)(70206006)(70586007)(426003)(47076005)(110136005)(2616005)(54906003)(83380400001)(356005)(36860700001)(82740400003)(316002)(36756003)(5660300002)(41300700001)(40460700003)(7416002)(40480700001)(81166007)(8936002)(82310400005)(86362001)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8706 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d055afe7-ace8-46c6-33e7-08db005b7115 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nrKyR4jNyayhEdziM22uajlH+oRk/9fdxhxFUnhWeOhpUutSB335Kkn6t0JlxWGyx5VoPAh6pWgHMpZccO5MNaeCEiLR7020oefheOTH0lJvWZaabDjW7XKEFqfajTjWEKRZqI9GYHWCRDczkkLeZRg55zB58wASQScWbIw2UxLQTvJszqJ4lFmrMu2EnAdhzh/h8FNRGKgPF6vMBTf8tWXWJEke79SDB5ePApeyXjdmuK8jeJlbijhwRoO6W9E2ODmgnMVvHHkaPR9imOjQkdBYDkvk/2XV82kmOUui4hq7dFHgn6L0Z74lhrcsyDodGZTEv1uOXBWMjDtli2tIj6ZEnKxeL+X80uxnxF67jmSN6pvN6d+rN4CReKtIGwJPWQHlHh52Wb4D5KveiNXxxOsblDUP1U5B98PzLUCgiiB7hnTFG6fN0YKqT5MAotYBi9FdAxoogaThFopCu10iYYDW4ZVziGgLGqdjvna2hwMgPab+rh07DMtVVG8vk6yMDaD7jm409PQ84fSa7Ytmc+xeAjMeFsUgkrKfZ6nyUXAhKtvAXHya8uHmprc0WaytYZN4HmQfeToYPh6j45jgcvIwo6DGosbhXJ1h3HI6J99WJP+14y0y0WZwdpbLR1B7pB31DWsc7nl+6HJvxjJZqL6hA3k1+yPUOjLyBI9W2VQ/mNb0E98nfgkGOczocJp1TTg68mY3I69f8BDRmt2uGheSN9xo0wLV9fXebdFkpiA= 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:(13230025)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(5660300002)(36860700001)(36756003)(82740400003)(83380400001)(1076003)(107886003)(26005)(7696005)(40480700001)(2616005)(47076005)(478600001)(316002)(6666004)(54906003)(110136005)(2906002)(44832011)(86362001)(8936002)(186003)(336012)(8676002)(81166007)(40460700003)(70206006)(70586007)(4326008)(82310400005)(41300700001)(426003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:41:45.0774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf508e93-a44c-4c0b-5d81-08db005b7798 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: AM7EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034154_305804_86EDCC98 X-CRM114-Status: GOOD ( 14.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Alexandru Elisei PSCI uses the SMC Calling Convention (SMCCC) to communicate with the higher level software. PSCI uses at most 4 arguments and expend only one return value. However, SMCCC has provisions for more arguments (upto 17 depending on the SMCCC version) and upto 10 distinct return values. We are going to be adding tests that make use of it, so add support for the extended number of arguments and return values. Also rename the SMCCC functions to generic, non-PSCI names, so they can be used for Realm services. Signed-off-by: Alexandru Elisei [ Expand the number of args to 11 /results 10] Signed-off-by: Joey Gouly --- arm/cstart.S | 49 ++++++++++++++++++++++++++++------ arm/cstart64.S | 55 +++++++++++++++++++++++++++++++++------ arm/selftest.c | 2 +- lib/arm/asm/arm-smccc.h | 44 +++++++++++++++++++++++++++++++ lib/arm/asm/psci.h | 13 +++++---- lib/arm/psci.c | 19 +++++++++++--- lib/arm64/asm/arm-smccc.h | 6 +++++ 7 files changed, 160 insertions(+), 28 deletions(-) create mode 100644 lib/arm/asm/arm-smccc.h create mode 100644 lib/arm64/asm/arm-smccc.h diff --git a/arm/cstart.S b/arm/cstart.S index 7036e67f..db377668 100644 --- a/arm/cstart.S +++ b/arm/cstart.S @@ -96,26 +96,59 @@ start: .text /* - * psci_invoke_hvc / psci_invoke_smc + * arm_smccc_hvc / arm_smccc_smc * * Inputs: * r0 -- function_id * r1 -- arg0 * r2 -- arg1 * r3 -- arg2 + * [sp] - arg3 + * [sp + #4] - arg4 + * [sp + #8] - arg5 + * [sp + #12] - arg6 + * [sp + #16] - arg7 + * [sp + #20] - arg8 + * [sp + #24] - arg9 + * [sp + #28] - arg10 + * [sp + #32] - result (as a pointer to a struct smccc_result) * * Outputs: * r0 -- return code + * + * If result pointer is not NULL: + * result.r0 -- return code + * result.r1 -- r1 + * result.r2 -- r2 + * result.r3 -- r3 + * result.r4 -- r4 + * result.r5 -- r5 + * result.r6 -- r6 + * result.r7 -- r7 + * result.r8 -- r8 + * result.r9 -- r9 */ -.globl psci_invoke_hvc -psci_invoke_hvc: - hvc #0 +.macro do_smccc_call instr + mov r12, sp + push {r4-r11} + ldm r12, {r4-r11} + \instr #0 + ldr r10, [sp, #64] + cmp r10, #0 + beq 1f + stm r10, {r0-r9} +1: + pop {r4-r11} mov pc, lr +.endm -.globl psci_invoke_smc -psci_invoke_smc: - smc #0 - mov pc, lr +.globl arm_smccc_hvc +arm_smccc_hvc: + do_smccc_call hvc + +.globl arm_smccc_smc +arm_smccc_smc: + do_smccc_call smc enable_vfp: /* Enable full access to CP10 and CP11: */ diff --git a/arm/cstart64.S b/arm/cstart64.S index e4ab7d06..b689b132 100644 --- a/arm/cstart64.S +++ b/arm/cstart64.S @@ -110,26 +110,65 @@ start: .text /* - * psci_invoke_hvc / psci_invoke_smc + * arm_smccc_hvc / arm_smccc_smc * * Inputs: * w0 -- function_id * x1 -- arg0 * x2 -- arg1 * x3 -- arg2 + * x4 -- arg3 + * x5 -- arg4 + * x6 -- arg5 + * x7 -- arg6 + * sp -- { arg7, arg8, arg9, arg10, result } * * Outputs: * x0 -- return code + * + * If result pointer is not NULL: + * result.r0 -- return code + * result.r1 -- x1 + * result.r2 -- x2 + * result.r3 -- x3 + * result.r4 -- x4 + * result.r5 -- x5 + * result.r6 -- x6 + * result.r7 -- x7 + * result.r8 -- x8 + * result.r9 -- x9 */ -.globl psci_invoke_hvc -psci_invoke_hvc: - hvc #0 +.macro do_smccc_call instr + /* Save x8-x11 on stack */ + stp x9, x8, [sp, #-16]! + stp x11, x10, [sp, #-16]! + /* Load arg7 - arg10 from the stack */ + ldp x8, x9, [sp, #32] + ldp x10, x11, [sp, #48] + \instr #0 + /* Get the result address */ + ldr x10, [sp, #64] + cmp x10, xzr + b.eq 1f + stp x0, x1, [x10, #0] + stp x2, x3, [x10, #16] + stp x4, x5, [x10, #32] + stp x6, x7, [x10, #48] + stp x8, x9, [x10, #64] +1: + /* Restore x8-x11 from stack */ + ldp x11, x10, [sp], #16 + ldp x9, x8, [sp], #16 ret +.endm -.globl psci_invoke_smc -psci_invoke_smc: - smc #0 - ret +.globl arm_smccc_hvc +arm_smccc_hvc: + do_smccc_call hvc + +.globl arm_smccc_smc +arm_smccc_smc: + do_smccc_call smc get_mmu_off: adrp x0, auxinfo diff --git a/arm/selftest.c b/arm/selftest.c index 9f459ed3..6f825add 100644 --- a/arm/selftest.c +++ b/arm/selftest.c @@ -405,7 +405,7 @@ static void psci_print(void) int ver = psci_invoke(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); report_info("PSCI version: %d.%d", PSCI_VERSION_MAJOR(ver), PSCI_VERSION_MINOR(ver)); - report_info("PSCI method: %s", psci_invoke == psci_invoke_hvc ? + report_info("PSCI method: %s", psci_invoke_fn == arm_smccc_hvc ? "hvc" : "smc"); } diff --git a/lib/arm/asm/arm-smccc.h b/lib/arm/asm/arm-smccc.h new file mode 100644 index 00000000..5d85b01a --- /dev/null +++ b/lib/arm/asm/arm-smccc.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#ifndef _ASMARM_ARM_SMCCC_H_ +#define _ASMARM_ARM_SMCCC_H_ + +struct smccc_result { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r9; +}; + +typedef int (*smccc_invoke_fn)(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); +extern int arm_smccc_hvc(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); +extern int arm_smccc_smc(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); + +#endif /* _ASMARM_ARM_SMCCC_H_ */ diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h index cf03449b..6a399621 100644 --- a/lib/arm/asm/psci.h +++ b/lib/arm/asm/psci.h @@ -3,13 +3,12 @@ #include #include -typedef int (*psci_invoke_fn)(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); -extern psci_invoke_fn psci_invoke; -extern int psci_invoke_hvc(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); -extern int psci_invoke_smc(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); +#include + +extern smccc_invoke_fn psci_invoke_fn; + +extern int psci_invoke(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2); extern void psci_set_conduit(void); extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point); extern void psci_system_reset(void); diff --git a/lib/arm/psci.c b/lib/arm/psci.c index 9c031a12..0a1d0e82 100644 --- a/lib/arm/psci.c +++ b/lib/arm/psci.c @@ -13,13 +13,24 @@ #include static int psci_invoke_none(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2) + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result) { printf("No PSCI method configured! Can't invoke...\n"); return PSCI_RET_NOT_PRESENT; } -psci_invoke_fn psci_invoke = psci_invoke_none; +smccc_invoke_fn psci_invoke_fn = psci_invoke_none; + +int psci_invoke(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2) +{ + return psci_invoke_fn(function_id, arg0, arg1, arg2, 0, 0, 0, 0, 0, 0, 0, 0, NULL); +} int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) { @@ -69,9 +80,9 @@ void psci_set_conduit(void) assert(method != NULL && len == 4); if (strcmp(method->data, "hvc") == 0) - psci_invoke = psci_invoke_hvc; + psci_invoke_fn = arm_smccc_hvc; else if (strcmp(method->data, "smc") == 0) - psci_invoke = psci_invoke_smc; + psci_invoke_fn = arm_smccc_smc; else assert_msg(false, "Unknown PSCI conduit: %s", method->data); } diff --git a/lib/arm64/asm/arm-smccc.h b/lib/arm64/asm/arm-smccc.h new file mode 100644 index 00000000..ab649489 --- /dev/null +++ b/lib/arm64/asm/arm-smccc.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#include "../../arm/asm/arm-smccc.h" -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel