Message ID | 20180522174254.27551-10-julien.grall@arm.com |
---|---|
State | Superseded |
Headers | show |
Series | xen/arm: SSBD (aka Spectre-v4) mitigation (XSA-263) | expand |
On Tue, 22 May 2018, Julien Grall wrote: > Add assembly macros to simplify assembly code: > - adr_cpu_info: Get the address to the current cpu_info structure > - ldr_this_cpu: Load a per-cpu value > > This is part of XSA-263. > > Signed-off-by: Julien Grall <julien.grall@arm.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> > --- > xen/include/asm-arm/arm64/macros.h | 25 +++++++++++++++++++++++++ > xen/include/asm-arm/macros.h | 2 +- > 2 files changed, 26 insertions(+), 1 deletion(-) > create mode 100644 xen/include/asm-arm/arm64/macros.h > > diff --git a/xen/include/asm-arm/arm64/macros.h b/xen/include/asm-arm/arm64/macros.h > new file mode 100644 > index 0000000000..9c5e676b37 > --- /dev/null > +++ b/xen/include/asm-arm/arm64/macros.h > @@ -0,0 +1,25 @@ > +#ifndef __ASM_ARM_ARM64_MACROS_H > +#define __ASM_ARM_ARM64_MACROS_H > + > + /* > + * @dst: Result of get_cpu_info() > + */ > + .macro adr_cpu_info, dst > + add \dst, sp, #STACK_SIZE > + and \dst, \dst, #~(STACK_SIZE - 1) > + sub \dst, \dst, #CPUINFO_sizeof > + .endm > + > + /* > + * @dst: Result of READ_ONCE(per_cpu(sym, smp_processor_id())) > + * @sym: The name of the per-cpu variable > + * @tmp: scratch register > + */ > + .macro ldr_this_cpu, dst, sym, tmp > + ldr \dst, =per_cpu__\sym > + mrs \tmp, tpidr_el2 > + ldr \dst, [\dst, \tmp] > + .endm > + > +#endif /* __ASM_ARM_ARM64_MACROS_H */ > + > diff --git a/xen/include/asm-arm/macros.h b/xen/include/asm-arm/macros.h > index 5d837cb38b..1d4bb41d15 100644 > --- a/xen/include/asm-arm/macros.h > +++ b/xen/include/asm-arm/macros.h > @@ -8,7 +8,7 @@ > #if defined (CONFIG_ARM_32) > # include <asm/arm32/macros.h> > #elif defined(CONFIG_ARM_64) > -/* No specific ARM64 macros for now */ > +# include <asm/arm64/macros.h> > #else > # error "unknown ARM variant" > #endif > -- > 2.11.0 >
diff --git a/xen/include/asm-arm/arm64/macros.h b/xen/include/asm-arm/arm64/macros.h new file mode 100644 index 0000000000..9c5e676b37 --- /dev/null +++ b/xen/include/asm-arm/arm64/macros.h @@ -0,0 +1,25 @@ +#ifndef __ASM_ARM_ARM64_MACROS_H +#define __ASM_ARM_ARM64_MACROS_H + + /* + * @dst: Result of get_cpu_info() + */ + .macro adr_cpu_info, dst + add \dst, sp, #STACK_SIZE + and \dst, \dst, #~(STACK_SIZE - 1) + sub \dst, \dst, #CPUINFO_sizeof + .endm + + /* + * @dst: Result of READ_ONCE(per_cpu(sym, smp_processor_id())) + * @sym: The name of the per-cpu variable + * @tmp: scratch register + */ + .macro ldr_this_cpu, dst, sym, tmp + ldr \dst, =per_cpu__\sym + mrs \tmp, tpidr_el2 + ldr \dst, [\dst, \tmp] + .endm + +#endif /* __ASM_ARM_ARM64_MACROS_H */ + diff --git a/xen/include/asm-arm/macros.h b/xen/include/asm-arm/macros.h index 5d837cb38b..1d4bb41d15 100644 --- a/xen/include/asm-arm/macros.h +++ b/xen/include/asm-arm/macros.h @@ -8,7 +8,7 @@ #if defined (CONFIG_ARM_32) # include <asm/arm32/macros.h> #elif defined(CONFIG_ARM_64) -/* No specific ARM64 macros for now */ +# include <asm/arm64/macros.h> #else # error "unknown ARM variant" #endif
Add assembly macros to simplify assembly code: - adr_cpu_info: Get the address to the current cpu_info structure - ldr_this_cpu: Load a per-cpu value This is part of XSA-263. Signed-off-by: Julien Grall <julien.grall@arm.com> --- xen/include/asm-arm/arm64/macros.h | 25 +++++++++++++++++++++++++ xen/include/asm-arm/macros.h | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 xen/include/asm-arm/arm64/macros.h