aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2018-05-29 08:11:15 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2018-05-31 13:00:53 -0400
commit85478bab409171de501b719971fd25a3d5d639f9 (patch)
tree95c490c95a4435880b939673e2e5f6eafd969a90
parent9cdc0108baa8ef87c76ed834619886a46bd70cbe (diff)
arm64: KVM: Add HYP per-cpu accessors
As we're going to require to access per-cpu variables at EL2, let's craft the minimum set of accessors required to implement reading a per-cpu variable, relying on tpidr_el2 to contain the per-cpu offset. Reviewed-by: Christoffer Dall <christoffer.dall@arm.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/include/asm/kvm_asm.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
index f6648a3e4152..fefd8cf42c35 100644
--- a/arch/arm64/include/asm/kvm_asm.h
+++ b/arch/arm64/include/asm/kvm_asm.h
@@ -71,14 +71,37 @@ extern u32 __kvm_get_mdcr_el2(void);
71 71
72extern u32 __init_stage2_translation(void); 72extern u32 __init_stage2_translation(void);
73 73
74/* Home-grown __this_cpu_{ptr,read} variants that always work at HYP */
75#define __hyp_this_cpu_ptr(sym) \
76 ({ \
77 void *__ptr = hyp_symbol_addr(sym); \
78 __ptr += read_sysreg(tpidr_el2); \
79 (typeof(&sym))__ptr; \
80 })
81
82#define __hyp_this_cpu_read(sym) \
83 ({ \
84 *__hyp_this_cpu_ptr(sym); \
85 })
86
74#else /* __ASSEMBLY__ */ 87#else /* __ASSEMBLY__ */
75 88
76.macro get_host_ctxt reg, tmp 89.macro hyp_adr_this_cpu reg, sym, tmp
77 adr_l \reg, kvm_host_cpu_state 90 adr_l \reg, \sym
78 mrs \tmp, tpidr_el2 91 mrs \tmp, tpidr_el2
79 add \reg, \reg, \tmp 92 add \reg, \reg, \tmp
80.endm 93.endm
81 94
95.macro hyp_ldr_this_cpu reg, sym, tmp
96 adr_l \reg, \sym
97 mrs \tmp, tpidr_el2
98 ldr \reg, [\reg, \tmp]
99.endm
100
101.macro get_host_ctxt reg, tmp
102 hyp_adr_this_cpu \reg, kvm_host_cpu_state, \tmp
103.endm
104
82.macro get_vcpu_ptr vcpu, ctxt 105.macro get_vcpu_ptr vcpu, ctxt
83 get_host_ctxt \ctxt, \vcpu 106 get_host_ctxt \ctxt, \vcpu
84 ldr \vcpu, [\ctxt, #HOST_CONTEXT_VCPU] 107 ldr \vcpu, [\ctxt, #HOST_CONTEXT_VCPU]