From: Mark Rutland <mark.rutland@arm.com>
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 [thread overview]
Message-ID: <20210729152050.23635-6-mark.rutland@arm.com> (raw)
In-Reply-To: <20210729152050.23635-1-mark.rutland@arm.com>
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 <mark.rutland@arm.com>
---
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
next prev parent reply other threads:[~2021-07-29 15:32 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-29 15:20 [boot-wrapper PATCH 00/12] Preparatory fixes and cleanup Mark Rutland
2021-07-29 15:20 ` [boot-wrapper PATCH 01/12] Ensure `kernel_address` is aligned Mark Rutland
2021-07-30 15:11 ` Andre Przywara
2021-07-29 15:20 ` [boot-wrapper PATCH 02/12] Output text separately from data Mark Rutland
2021-07-29 15:20 ` [boot-wrapper PATCH 03/12] Remove cache maintenance Mark Rutland
2021-07-30 15:12 ` Andre Przywara
2021-07-30 15:43 ` Mark Rutland
2021-07-29 15:20 ` [boot-wrapper PATCH 04/12] Remove `flag_no_el3` Mark Rutland
2021-07-30 15:13 ` Andre Przywara
2021-07-30 16:43 ` Mark Rutland
2021-08-02 14:43 ` Mark Rutland
2021-07-29 15:20 ` Mark Rutland [this message]
2021-07-29 15:20 ` [boot-wrapper PATCH 06/12] Move scripts to a `scripts` directory Mark Rutland
2021-07-30 15:13 ` Andre Przywara
2021-07-29 15:20 ` [boot-wrapper PATCH 07/12] aarch64: respect text offset Mark Rutland
2021-07-30 15:13 ` Andre Przywara
2021-07-30 15:43 ` Mark Rutland
2021-07-29 15:20 ` [boot-wrapper PATCH 08/12] Consistently use logical CPU IDs Mark Rutland
2021-07-30 17:38 ` Andre Przywara
2021-07-29 15:20 ` [boot-wrapper PATCH 09/12] Cleanup `.globl` usage Mark Rutland
2021-07-30 17:39 ` Andre Przywara
2021-07-29 15:20 ` [boot-wrapper PATCH 10/12] aarch32: rename `_spin_dead` -> `err_invalid_id` Mark Rutland
2021-07-30 17:39 ` Andre Przywara
2021-07-29 15:20 ` [boot-wrapper PATCH 11/12] Rename `spin.h` -> `boot.h` Mark Rutland
2021-07-30 17:39 ` Andre Przywara
2021-07-29 15:20 ` [boot-wrapper PATCH 12/12] Move common source files to `common` directory Mark Rutland
2021-07-30 17:40 ` Andre Przywara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210729152050.23635-6-mark.rutland@arm.com \
--to=mark.rutland@arm.com \
--cc=Andre.Przywara@arm.com \
--cc=Jaxson.Han@arm.com \
--cc=Wei.Chen@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).