@@ -2,5 +2,6 @@
generic-y += device.h
generic-y += iocap.h
generic-y += paging.h
+generic-y += percpu.h
generic-y += random.h
generic-y += vm_event.h
@@ -5,6 +5,7 @@
#include <xen/percpu.h>
#include <asm/processor.h>
+#include <asm/sysregs.h>
/* Tell whether the guest vCPU enabled Workaround 2 (i.e variant 4) */
#define CPUINFO_WORKAROUND_2_FLAG_SHIFT 0
@@ -60,6 +61,8 @@ do { \
this_cpu(cpu_id) = (id); \
} while ( 0 )
+#define get_per_cpu_offset() READ_SYSREG(TPIDR_EL2)
+
#endif
#endif /* __ARM_CURRENT_H__ */
@@ -3,5 +3,6 @@ generic-y += device.h
generic-y += hypercall.h
generic-y += iocap.h
generic-y += paging.h
+generic-y += percpu.h
generic-y += random.h
generic-y += vm_event.h
@@ -4,6 +4,8 @@
#include <xen/percpu.h>
+#include <asm/processor.h>
+
#ifndef __ASSEMBLY__
struct vcpu;
@@ -38,6 +40,10 @@ static inline struct cpu_info *get_cpu_info(void)
#define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)
+#define smp_processor_id() 0 /* TODO: Fix this */
+
+#define get_per_cpu_offset() smp_processor_id() /* TODO: Fix this */
+
#endif /* __ASSEMBLY__ */
#endif /* __ASM_PPC_CURRENT_H__ */
deleted file mode 100644
@@ -1,24 +0,0 @@
-#ifndef __PPC_PERCPU_H__
-#define __PPC_PERCPU_H__
-
-#ifndef __ASSEMBLY__
-
-extern char __per_cpu_start[], __per_cpu_data_end[];
-extern unsigned long __per_cpu_offset[NR_CPUS];
-void percpu_init_areas(void);
-
-#define smp_processor_id() 0 /* TODO: Fix this */
-
-#define per_cpu(var, cpu) \
- (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
-#define this_cpu(var) \
- (*RELOC_HIDE(&per_cpu__##var, smp_processor_id()))
-
-#define per_cpu_ptr(var, cpu) \
- (*RELOC_HIDE(var, __per_cpu_offset[cpu]))
-#define this_cpu_ptr(var) \
- (*RELOC_HIDE(var, smp_processor_id()))
-
-#endif
-
-#endif /* __PPC_PERCPU_H__ */
new file mode 100644
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+generic-y += percpu.h
@@ -102,6 +102,8 @@ static inline struct cpu_info *get_cpu_info(void)
#define smp_processor_id() (get_cpu_info()->processor_id)
#define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)
+#define get_per_cpu_offset() (get_cpu_info()->per_cpu_offset)
+
/*
* Get the bottom-of-stack, as stored in the per-CPU TSS. This actually points
* into the middle of cpu_info.guest_cpu_user_regs, at the section that
deleted file mode 100644
@@ -1,22 +0,0 @@
-#ifndef __X86_PERCPU_H__
-#define __X86_PERCPU_H__
-
-#ifndef __ASSEMBLY__
-extern char __per_cpu_start[], __per_cpu_data_end[];
-extern unsigned long __per_cpu_offset[NR_CPUS];
-void percpu_init_areas(void);
-#endif
-
-/* var is in discarded region: offset to particular copy we want */
-#define per_cpu(var, cpu) \
- (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
-#define this_cpu(var) \
- (*RELOC_HIDE(&per_cpu__##var, get_cpu_info()->per_cpu_offset))
-
-#define this_cpu_ptr(var) \
- (*RELOC_HIDE(var, get_cpu_info()->per_cpu_offset))
-
-#define per_cpu_ptr(var, cpu) \
- (*RELOC_HIDE(var, __per_cpu_offset[cpu]))
-
-#endif /* __X86_PERCPU_H__ */
similarity index 57%
rename from xen/arch/arm/include/asm/percpu.h
rename to xen/include/asm-generic/percpu.h
@@ -1,28 +1,32 @@
-#ifndef __ARM_PERCPU_H__
-#define __ARM_PERCPU_H__
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_PERCPU_H__
+#define __ASM_GENERIC_PERCPU_H__
#ifndef __ASSEMBLY__
#include <xen/types.h>
-#include <asm/sysregs.h>
+#include <asm/current.h>
-extern char __per_cpu_start[], __per_cpu_data_end[];
+extern char __per_cpu_start[];
+extern const char __per_cpu_data_end[];
extern unsigned long __per_cpu_offset[NR_CPUS];
void percpu_init_areas(void);
#define per_cpu(var, cpu) \
(*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
+
#define this_cpu(var) \
- (*RELOC_HIDE(&per_cpu__##var, READ_SYSREG(TPIDR_EL2)))
+ (*RELOC_HIDE(&per_cpu__##var, get_per_cpu_offset()))
#define per_cpu_ptr(var, cpu) \
(*RELOC_HIDE(var, __per_cpu_offset[cpu]))
#define this_cpu_ptr(var) \
- (*RELOC_HIDE(var, READ_SYSREG(TPIDR_EL2)))
+ (*RELOC_HIDE(var, get_per_cpu_offset()))
#endif
-#endif /* __ARM_PERCPU_H__ */
+#endif /* __ASM_GENERIC_PERCPU_H__ */
+
/*
* Local variables:
* mode: C
@@ -1,8 +1,6 @@
#ifndef __XEN_PERCPU_H__
#define __XEN_PERCPU_H__
-#include <asm/percpu.h>
-
#define DECLARE_PER_CPU(type, name) \
extern __typeof__(type) per_cpu__ ## name
@@ -29,6 +27,8 @@
#define get_per_cpu_var(var) (per_cpu__##var)
+#include <asm/percpu.h>
+
/* Linux compatibility. */
#define get_cpu_var(var) this_cpu(var)
#define put_cpu_var(var)