Skip to content

Commit 304e298

Browse files
author
Marc Zyngier
committed
KVM: arm64: Move hyp_symbol_addr() to kvm_asm.h
Recent refactoring of the arm64 code make it awkward to have hyp_symbol_addr() in kvm_mmu.h. Instead, move it next to its main user, which is __hyp_this_cpu_ptr(). Signed-off-by: Marc Zyngier <[email protected]>
1 parent 07da1ff commit 304e298

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

arch/arm64/include/asm/kvm_asm.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ extern u32 __kvm_get_mdcr_el2(void);
8181

8282
extern char __smccc_workaround_1_smc[__SMCCC_WORKAROUND_1_SMC_SZ];
8383

84+
/*
85+
* Obtain the PC-relative address of a kernel symbol
86+
* s: symbol
87+
*
88+
* The goal of this macro is to return a symbol's address based on a
89+
* PC-relative computation, as opposed to a loading the VA from a
90+
* constant pool or something similar. This works well for HYP, as an
91+
* absolute VA is guaranteed to be wrong. Only use this if trying to
92+
* obtain the address of a symbol (i.e. not something you obtained by
93+
* following a pointer).
94+
*/
95+
#define hyp_symbol_addr(s) \
96+
({ \
97+
typeof(s) *addr; \
98+
asm("adrp %0, %1\n" \
99+
"add %0, %0, :lo12:%1\n" \
100+
: "=r" (addr) : "S" (&s)); \
101+
addr; \
102+
})
103+
84104
/*
85105
* Home-grown __this_cpu_{ptr,read} variants that always work at HYP,
86106
* provided that sym is really a *symbol* and not a pointer obtained from

arch/arm64/include/asm/kvm_mmu.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,6 @@ static __always_inline unsigned long __kern_hyp_va(unsigned long v)
107107

108108
#define kern_hyp_va(v) ((typeof(v))(__kern_hyp_va((unsigned long)(v))))
109109

110-
/*
111-
* Obtain the PC-relative address of a kernel symbol
112-
* s: symbol
113-
*
114-
* The goal of this macro is to return a symbol's address based on a
115-
* PC-relative computation, as opposed to a loading the VA from a
116-
* constant pool or something similar. This works well for HYP, as an
117-
* absolute VA is guaranteed to be wrong. Only use this if trying to
118-
* obtain the address of a symbol (i.e. not something you obtained by
119-
* following a pointer).
120-
*/
121-
#define hyp_symbol_addr(s) \
122-
({ \
123-
typeof(s) *addr; \
124-
asm("adrp %0, %1\n" \
125-
"add %0, %0, :lo12:%1\n" \
126-
: "=r" (addr) : "S" (&s)); \
127-
addr; \
128-
})
129-
130110
/*
131111
* We currently support using a VM-specified IPA size. For backward
132112
* compatibility, the default IPA size is fixed to 40bits.

0 commit comments

Comments
 (0)