arm/arm64: fixes and convenience
cover arm/arm64: fixes and convenience
Andrew Jones (4):
arm64: irq handlers don't use esr
arm64: start_usr: no default vectors
arm64: include esr.h from processor.h
arm/arm64: make stack creation user friendly
arm/selftest.c | 4 +--- lib/arm/asm/thread_info.h | 7 ++++++ lib/arm/smp.c | 4 +--- lib/arm64/asm/processor.h | 9 +++++-- lib/arm64/processor.c | 60 +++++++++++++++++++++++++++++++++++++---------- 5 files changed, 63 insertions(+), 21 deletions(-)
Signature · 1 line
2.4.3
PATCH 1/4 arm64: irq handlers don't use esr
irq handlers need to be run from a different default vector handler, and have a different "install" API, than sync exception handlers.
--- lib/arm64/asm/processor.h | 8 ++++++-- lib/arm64/processor.c | 50 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 46 insertions(+), 12 deletions(-)
lib/arm64/asm/processor.h +6 -2
@@ -44,11 +44,15 @@ enum vector {typedef void (*vector_fn )(enum vector v,struct pt_regs *regs,unsigned int esr);typedef void (*exception_fn )(struct pt_regs *regs,unsigned int esr); +typedef void (*irq_handler_fn )(struct pt_regs *regs);extern void install_vector_handler (enum vector v,vector_fn fn);extern void install_exception_handler (enum vector v,unsigned int ec,exception_fn fn); -extern void default_vector_handler (enum vector v,struct pt_regs *regs, -unsigned int esr); +extern void install_irq_handler (enum vector v,irq_handler_fn fn); +extern void default_vector_sync_handler (enum vector v,struct pt_regs *regs, +unsigned int esr); +extern void default_vector_irq_handler (enum vector v,struct pt_regs *regs, +unsigned int esr);extern void vector_handlers_default_init (vector_fn *handlers);extern void show_regs (struct pt_regs *regs);
lib/arm64/processor.c +40 -10
84 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH 2/4 arm64: start_usr: no default vectors
In reply to Andrew JonesDon't install default vector handlers on the usermode stack, as they'll override handlers installed on the kernel stack.
--- lib/arm64/processor.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/arm64/processor.c +7 -2
@@ -221,11 +221,16 @@ void install_vector_handler(enum vector v, vector_fn fn) ti->vector_handlers[v] = fn; } -void thread_info_init (struct thread_info *ti,unsigned int flags) +static void __thread_info_init (struct thread_info *ti,unsigned int flags) {memset (ti,0 ,sizeof (struct thread_info )); ti->cpu =mpidr_to_cpu (get_mpidr ()); ti->flags = flags; +} + +void thread_info_init (struct thread_info *ti,unsigned int flags) +{ +__thread_info_init (ti, flags);vector_handlers_default_init (ti->vector_handlers); }
@@ -233,7 +238,7 @@ void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr) { sp_usr &= (~15UL );/* stack ptr needs 16-byte alignment */ -thread_info_init (thread_info_sp (sp_usr),TIF_USER_MODE ); +__thread_info_init (thread_info_sp (sp_usr),TIF_USER_MODE ); asmvolatile ( "mov x0, %0\n"
Signature · 1 line
2.4.3
PATCH 3/4 arm64: include esr.h from processor.h
In reply to Andrew JonesWe prefer to require explicitly including headers in each file that need them, rather than creating headers that include everything, and then just always including those. But, we can make an exception for esr.h, as includers of processor.h will frequently need esr.h, and by embedding that inclusion we avoid requiring something like
#include <asm/processor.h> #ifdef __aarch64__ #include <asm/esr.h> #endif
in every test that runs on both arm and arm64.
--- arm/selftest.c | 1 - lib/arm64/asm/processor.h | 1 + lib/arm64/processor.c | 1 - 3 files changed, 1 insertion(+), 2 deletions(-)
arm/selftest.c +0 -1
@@ -177,7 +177,6 @@ static bool check_svc(void) return svc_works; }#elif defined(__aarch64__) -#include <asm/esr.h> /* * Capture the current register state and execute an instruction
lib/arm64/asm/processor.h +1 -0
@@ -18,6 +18,7 @@#ifndef __ASSEMBLY__#include <asm/ptrace.h> +#include <asm/esr.h> enum vector { EL1T_SYNC,
lib/arm64/processor.c +0 -1
@@ -8,7 +8,6 @@#include <libcflat.h> #include <asm/ptrace.h> #include <asm/processor.h> -#include <asm/esr.h> #include <asm/thread_info.h> static const char *vector_names[] = {
Signature · 1 line
2.4.3
PATCH 4/4 arm/arm64: make stack creation user friendly
In reply to Andrew Jones--- arm/selftest.c | 3 +-- lib/arm/asm/thread_info.h | 7 +++++++ lib/arm/smp.c | 4 +--- 3 files changed, 9 insertions(+), 5 deletions(-)
arm/selftest.c +1 -2
@@ -356,9 +356,8 @@ int main(int argc, char **argv) }else if (strcmp (argv[0 ],"vectors-user" ) ==0 ) { -void *sp =memalign (THREAD_SIZE ,THREAD_SIZE );start_usr (check_vectors,NULL , - (unsigned long )sp +THREAD_START_SP ); + (unsigned long )thread_stack_alloc ()); }else if (strcmp (argv[0 ],"smp" ) ==0 ) {
lib/arm/asm/thread_info.h +7 -0
@@ -22,6 +22,7 @@#ifndef __ASSEMBLY__#include <asm/processor.h> +#include <alloc.h> #ifdef __arm__#include <asm/ptrace.h>
@@ -35,6 +36,12 @@#define THREAD_START_SP (THREAD_SIZE - 16)#endif +static inline void *thread_stack_alloc (void ) +{ +void *sp =memalign (THREAD_SIZE ,THREAD_SIZE ); +return sp +THREAD_START_SP ; +} +#define TIF_USER_MODE (1U << 0)struct thread_info {
lib/arm/smp.c +1 -3
@@ -6,7 +6,6 @@* This work is licensed under the terms of the GNU LGPL, version 2. */ #include <libcflat.h> -#include <alloc.h> #include <asm/thread_info.h> #include <asm/cpumask.h> #include <asm/barrier.h>
@@ -43,10 +42,9 @@ secondary_entry_fn secondary_cinit(void)void smp_boot_secondary (int cpu,secondary_entry_fn entry) { -void *stack_base =memalign (THREAD_SIZE ,THREAD_SIZE );int ret; - secondary_data.stack = stack_base +THREAD_START_SP ; + secondary_data.stack =thread_stack_alloc (); secondary_data.entry = entry;mmu_mark_disabled (cpu); ret =cpu_psci_cpu_boot (cpu);
Signature · 1 line
2.4.3
Paolo Bonzini
maintainerRe: [kvm-unit-tests PATCH 4/4] arm/arm64: make stack creation user friendly
Changing subject to: "arm/arm64: wrap thread stack creation in a function that returns SP".
Paolo
Quoted 72 lines · Andrew Jones
Signed-off-by Andrew Jones <[email protected]>--- arm/selftest.c | 3 +-- lib/arm/asm/thread_info.h | 7 +++++++ lib/arm/smp.c | 4 +--- 3 files changed, 9 insertions(+), 5 deletions(-)arm/selftest.c +1
-2@@ -356,9 +356,8 @@ int main(int argc, char **argv) }else if (strcmp (argv[0 ],"vectors-user" ) ==0 ) { -void *sp =memalign (THREAD_SIZE ,THREAD_SIZE );start_usr (check_vectors,NULL , - (unsigned long )sp +THREAD_START_SP ); + (unsigned long )thread_stack_alloc ()); }else if (strcmp (argv[0 ],"smp" ) ==0 ) {lib/arm/asm/thread_info.h +7
-0@@ -22,6 +22,7 @@#ifndef __ASSEMBLY__#include <asm/processor.h> +#include <alloc.h> #ifdef __arm__#include <asm/ptrace.h> @@ -35,6 +36,12 @@#define THREAD_START_SP (THREAD_SIZE - 16)#endif +static inline void *thread_stack_alloc (void ) +{ +void *sp =memalign (THREAD_SIZE ,THREAD_SIZE ); +return sp +THREAD_START_SP ; +} +#define TIF_USER_MODE (1U << 0)struct thread_info {lib/arm/smp.c +1
-3@@ -6,7 +6,6 @@* This work is licensed under the terms of the GNU LGPL, version 2. */ #include <libcflat.h> -#include <alloc.h> #include <asm/thread_info.h> #include <asm/cpumask.h> #include <asm/barrier.h> @@ -43,10 +42,9 @@ secondary_entry_fn secondary_cinit(void)void smp_boot_secondary (int cpu,secondary_entry_fn entry) { -void *stack_base =memalign (THREAD_SIZE ,THREAD_SIZE );int ret; - secondary_data.stack = stack_base +THREAD_START_SP ; + secondary_data.stack =thread_stack_alloc (); secondary_data.entry = entry;mmu_mark_disabled (cpu); ret =cpu_psci_cpu_boot (cpu);
Quoted 6 lines · Andrew Jones
Andrew Jones (4):
arm64: irq handlers don't use esr
arm64:start_usr: no default vectors
arm64: includeesr.hfromprocessor.h
arm/arm64: make stack creation user friendly
Quoted 7 lines
arm/selftest.c | 4 +--- lib/arm/asm/thread_info.h | 7 ++++++ lib/arm/smp.c | 4 +--- lib/arm64/asm/processor.h | 9 +++++-- lib/arm64/processor.c | 60 +++++++++++++++++++++++++++++++++++++---------- 5 files changed, 63 insertions(+), 21 deletions(-)
Applied, thanks.
Paolo