KVM: arm64: Remove patching of fn pointers in hyp
Storing a function pointer in hyp now generates relocation information used at early boot to convert the address to hyp VA. The existing alternative-based conversion mechanism is therefore obsolete. Remove it and simplify its users. Acked-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: David Brazdil <dbrazdil@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20210105180541.65031-8-dbrazdil@google.com
This commit is contained in:
parent
97cbd2fc02
commit
537db4af26
@ -135,24 +135,6 @@ static __always_inline unsigned long __kern_hyp_va(unsigned long v)
|
|||||||
|
|
||||||
#define kern_hyp_va(v) ((typeof(v))(__kern_hyp_va((unsigned long)(v))))
|
#define kern_hyp_va(v) ((typeof(v))(__kern_hyp_va((unsigned long)(v))))
|
||||||
|
|
||||||
static __always_inline unsigned long __kimg_hyp_va(unsigned long v)
|
|
||||||
{
|
|
||||||
unsigned long offset;
|
|
||||||
|
|
||||||
asm volatile(ALTERNATIVE_CB("movz %0, #0\n"
|
|
||||||
"movk %0, #0, lsl #16\n"
|
|
||||||
"movk %0, #0, lsl #32\n"
|
|
||||||
"movk %0, #0, lsl #48\n",
|
|
||||||
kvm_update_kimg_phys_offset)
|
|
||||||
: "=r" (offset));
|
|
||||||
|
|
||||||
return __kern_hyp_va((v - offset) | PAGE_OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define kimg_fn_hyp_va(v) ((typeof(*v))(__kimg_hyp_va((unsigned long)(v))))
|
|
||||||
|
|
||||||
#define kimg_fn_ptr(x) (typeof(x) **)(x)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We currently support using a VM-specified IPA size. For backward
|
* We currently support using a VM-specified IPA size. For backward
|
||||||
* compatibility, the default IPA size is fixed to 40bits.
|
* compatibility, the default IPA size is fixed to 40bits.
|
||||||
|
@ -64,7 +64,6 @@ __efistub__ctype = _ctype;
|
|||||||
/* Alternative callbacks for init-time patching of nVHE hyp code. */
|
/* Alternative callbacks for init-time patching of nVHE hyp code. */
|
||||||
KVM_NVHE_ALIAS(kvm_patch_vector_branch);
|
KVM_NVHE_ALIAS(kvm_patch_vector_branch);
|
||||||
KVM_NVHE_ALIAS(kvm_update_va_mask);
|
KVM_NVHE_ALIAS(kvm_update_va_mask);
|
||||||
KVM_NVHE_ALIAS(kvm_update_kimg_phys_offset);
|
|
||||||
KVM_NVHE_ALIAS(kvm_get_kimage_voffset);
|
KVM_NVHE_ALIAS(kvm_get_kimage_voffset);
|
||||||
|
|
||||||
/* Global kernel state accessed by nVHE hyp code. */
|
/* Global kernel state accessed by nVHE hyp code. */
|
||||||
|
@ -108,9 +108,9 @@ static void handle___vgic_v3_restore_aprs(struct kvm_cpu_context *host_ctxt)
|
|||||||
|
|
||||||
typedef void (*hcall_t)(struct kvm_cpu_context *);
|
typedef void (*hcall_t)(struct kvm_cpu_context *);
|
||||||
|
|
||||||
#define HANDLE_FUNC(x) [__KVM_HOST_SMCCC_FUNC_##x] = kimg_fn_ptr(handle_##x)
|
#define HANDLE_FUNC(x) [__KVM_HOST_SMCCC_FUNC_##x] = (hcall_t)handle_##x
|
||||||
|
|
||||||
static const hcall_t *host_hcall[] = {
|
static const hcall_t host_hcall[] = {
|
||||||
HANDLE_FUNC(__kvm_vcpu_run),
|
HANDLE_FUNC(__kvm_vcpu_run),
|
||||||
HANDLE_FUNC(__kvm_flush_vm_context),
|
HANDLE_FUNC(__kvm_flush_vm_context),
|
||||||
HANDLE_FUNC(__kvm_tlb_flush_vmid_ipa),
|
HANDLE_FUNC(__kvm_tlb_flush_vmid_ipa),
|
||||||
@ -130,7 +130,6 @@ static const hcall_t *host_hcall[] = {
|
|||||||
static void handle_host_hcall(struct kvm_cpu_context *host_ctxt)
|
static void handle_host_hcall(struct kvm_cpu_context *host_ctxt)
|
||||||
{
|
{
|
||||||
DECLARE_REG(unsigned long, id, host_ctxt, 0);
|
DECLARE_REG(unsigned long, id, host_ctxt, 0);
|
||||||
const hcall_t *kfn;
|
|
||||||
hcall_t hfn;
|
hcall_t hfn;
|
||||||
|
|
||||||
id -= KVM_HOST_SMCCC_ID(0);
|
id -= KVM_HOST_SMCCC_ID(0);
|
||||||
@ -138,13 +137,11 @@ static void handle_host_hcall(struct kvm_cpu_context *host_ctxt)
|
|||||||
if (unlikely(id >= ARRAY_SIZE(host_hcall)))
|
if (unlikely(id >= ARRAY_SIZE(host_hcall)))
|
||||||
goto inval;
|
goto inval;
|
||||||
|
|
||||||
kfn = host_hcall[id];
|
hfn = host_hcall[id];
|
||||||
if (unlikely(!kfn))
|
if (unlikely(!hfn))
|
||||||
goto inval;
|
goto inval;
|
||||||
|
|
||||||
cpu_reg(host_ctxt, 0) = SMCCC_RET_SUCCESS;
|
cpu_reg(host_ctxt, 0) = SMCCC_RET_SUCCESS;
|
||||||
|
|
||||||
hfn = kimg_fn_hyp_va(kfn);
|
|
||||||
hfn(host_ctxt);
|
hfn(host_ctxt);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -283,12 +283,6 @@ static void generate_mov_q(u64 val, __le32 *origptr, __le32 *updptr, int nr_inst
|
|||||||
*updptr++ = cpu_to_le32(insn);
|
*updptr++ = cpu_to_le32(insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_update_kimg_phys_offset(struct alt_instr *alt,
|
|
||||||
__le32 *origptr, __le32 *updptr, int nr_inst)
|
|
||||||
{
|
|
||||||
generate_mov_q(kimage_voffset + PHYS_OFFSET, origptr, updptr, nr_inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
void kvm_get_kimage_voffset(struct alt_instr *alt,
|
void kvm_get_kimage_voffset(struct alt_instr *alt,
|
||||||
__le32 *origptr, __le32 *updptr, int nr_inst)
|
__le32 *origptr, __le32 *updptr, int nr_inst)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user