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 X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51243C4338F for ; Thu, 29 Jul 2021 15:32:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1EA8460F4B for ; Thu, 29 Jul 2021 15:32:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1EA8460F4B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=LvVOag1dqJDa3ORO0/xb8T/QEG5ykqgT3HhBdK+VGcA=; b=uSvjCIBNiuaFf8 axVZjfiGGIHkckvhqTgcNW2My9w5nKQmcBdQjxYnMRvSYX8RWL6PZTKExdPyvZc27m4/d4QKXxhbT yaZWhwVeEvkEIM8tS64JSEDFKV8ItLsOEvNIZa55q/XrnDAIo4w8ndC8UEec+1OspXEl8aNinT/+q LKjF9g9wjHV+aaiYJVVxa5p/iMJi3KDqOIB4idz1Wruo7I7aM6+DB0OWApLvHvPXkpCd05KFa4XrC IaIJPTGM73F/KTeo20Pv/Hi9dPr843ve4eSiYKURXSjfgIKoOWNZcYJSZpXpQh7B4+yWwH1tkBN21 5sdKktsevSxmwXRdmg8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m97yl-004irF-P3; Thu, 29 Jul 2021 15:29:47 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m97qO-004gcG-C5 for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 15:21:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A16E5113E; Thu, 29 Jul 2021 08:21:03 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D4FF93F73D; Thu, 29 Jul 2021 08:21:02 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: Andre.Przywara@arm.com, Jaxson.Han@arm.com, mark.rutland@arm.com, Wei.Chen@arm.com Subject: [boot-wrapper PATCH 05/12] Move PSCI triage to C Date: Thu, 29 Jul 2021 16:20:43 +0100 Message-Id: <20210729152050.23635-6-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210729152050.23635-1-mark.rutland@arm.com> References: <20210729152050.23635-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_082108_592580_5FD3766E X-CRM114-Status: GOOD ( 11.80 ) 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: , MIME-Version: 1.0 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 There's no reason we need to test the PSCI function IDs in assembly; move this to C so that it can be shared across AArch64 and AArch32. At the same time, limit the PSCI_CPU_ON FIDs to match the register width of the kernel. Signed-off-by: Mark Rutland --- arch/aarch32/psci.S | 23 +---------------------- arch/aarch64/psci.S | 21 +-------------------- psci.c | 21 +++++++++++++++++++-- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/arch/aarch32/psci.S b/arch/aarch32/psci.S index 78dca96..0b7663e 100644 --- a/arch/aarch32/psci.S +++ b/arch/aarch32/psci.S @@ -33,32 +33,11 @@ handle_smc: @ Follow the SMC32 calling convention: preserve r4 - r14 push {r4 - r12, lr} - ldr r4, =PSCI_CPU_ON_32 - cmp r4, r0 - ldr r4, =psci_cpu_on - beq do_psci_call - - ldr r4, =PSCI_CPU_OFF - cmp r4, r0 - ldr r4, =psci_cpu_off - beq do_psci_call - - adr r4, psci_invalid - -do_psci_call: - mov r0, r1 - mov r1, r2 - mov r2, r3 - - blx r4 + blx psci_call pop {r4 - r12, lr} movs pc, lr -psci_invalid: - mov r0, #PSCI_RET_NOT_SUPPORTED - bx lr - ENTRY(start_el3) ldr r0, =smc_vectors blx setup_vector diff --git a/arch/aarch64/psci.S b/arch/aarch64/psci.S index 01ebe7d..6dbca11 100644 --- a/arch/aarch64/psci.S +++ b/arch/aarch64/psci.S @@ -51,13 +51,6 @@ vector: err_exception: b err_exception - .macro branch_if val, addr - ldr x7, =\val - cmp x0, x7 - adr x7, \addr - b.eq do_call - .endm - smc_entry32: /* Clear upper bits */ mov w0, w0 @@ -74,22 +67,10 @@ smc_entry64: // Keep sp aligned to 16 bytes stp x30, xzr, [sp, #-16]! - /* If function ID matches, do_call with procedure address in x7 */ - branch_if PSCI_CPU_ON_32, psci_cpu_on - branch_if PSCI_CPU_ON_64, psci_cpu_on - branch_if PSCI_CPU_OFF, psci_cpu_off + bl psci_call - /* Otherwise, return error in x0/w0 */ - mov x0, PSCI_RET_NOT_SUPPORTED b smc_exit -do_call: - mov x0, x1 - mov x1, x2 - mov x2, x3 - - blr x7 - smc_exit: ldp x30, xzr, [sp], #16 ldp x28, x29, [sp], #16 diff --git a/psci.c b/psci.c index fad6f5d..e5d54b7 100644 --- a/psci.c +++ b/psci.c @@ -31,7 +31,7 @@ static int psci_store_address(unsigned int cpu, unsigned long address) return PSCI_RET_SUCCESS; } -int psci_cpu_on(unsigned long target_mpidr, unsigned long address) +static int psci_cpu_on(unsigned long target_mpidr, unsigned long address) { int ret; unsigned int cpu = find_logical_id(target_mpidr); @@ -47,7 +47,7 @@ int psci_cpu_on(unsigned long target_mpidr, unsigned long address) return ret; } -int psci_cpu_off(void) +static int psci_cpu_off(void) { unsigned long mpidr = read_mpidr(); unsigned int cpu = find_logical_id(mpidr); @@ -62,6 +62,23 @@ int psci_cpu_off(void) unreachable(); } +long psci_call(unsigned long fid, unsigned long arg1, unsigned long arg2) +{ + switch (fid) { + case PSCI_CPU_OFF: + return psci_cpu_off(); +#ifdef KERNEL_32 + case PSCI_CPU_ON_32: + return psci_cpu_on(arg1, arg2); +#else + case PSCI_CPU_ON_64: + return psci_cpu_on(arg1, arg2); +#endif + default: + return PSCI_RET_NOT_SUPPORTED; + } +} + void __noreturn psci_first_spin(unsigned int cpu) { if (cpu == MPIDR_INVALID) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel