@@ -164,7 +164,7 @@ static inline unsigned long *vcpu_pc(const struct kvm_vcpu *vcpu)
static inline unsigned long *__vcpu_elr_el1(const struct kvm_vcpu *vcpu)
{
- return (unsigned long *)&vcpu->arch.ctxt.elr_el1;
+ return (unsigned long *)__ctxt_sys_reg(&vcpu->arch.ctxt, ELR_EL1);
}
static inline unsigned long vcpu_read_elr_el1(const struct kvm_vcpu *vcpu)
@@ -264,6 +264,7 @@ enum vcpu_sysreg {
VNCR(CONTEXTIDR_EL1), /* Context ID Register */
VNCR(AMAIR_EL1),/* Aux Memory Attribute Indirection Register */
VNCR(MDSCR_EL1),/* Monitor Debug System Control Register */
+ VNCR(ELR_EL1),
VNCR(VPIDR_EL2),/* Virtualization Processor ID Register */
VNCR(VMPIDR_EL2),/* Virtualization Multiprocessor ID Register */
VNCR(HCR_EL2), /* Hypervisor Configuration Register */
@@ -335,7 +336,6 @@ struct kvm_cpu_context {
struct user_pt_regs regs; /* sp = sp_el0 */
u64 sp_el1;
- u64 elr_el1;
u64 spsr[KVM_NR_SPSR];
@@ -128,7 +128,7 @@ static void *core_reg_addr(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
return &vcpu->arch.ctxt.sp_el1;
case KVM_REG_ARM_CORE_REG(elr_el1):
- return &vcpu->arch.ctxt.elr_el1;
+ return __vcpu_elr_el1(vcpu);
case KVM_REG_ARM_CORE_REG(spsr[0]) ...
KVM_REG_ARM_CORE_REG(spsr[KVM_NR_SPSR - 1]):
@@ -59,7 +59,7 @@ static void __hyp_text __sysreg_save_vel1_state(struct kvm_cpu_context *ctxt)
ctxt_sys_reg(ctxt, CNTKCTL_EL1) = read_sysreg_el1(SYS_CNTKCTL);
ctxt->sp_el1 = read_sysreg(sp_el1);
- ctxt->elr_el1 = read_sysreg_el1(SYS_ELR);
+ ctxt_sys_reg(ctxt, ELR_EL1) = read_sysreg_el1(SYS_ELR);
ctxt->spsr[KVM_SPSR_EL1] = read_sysreg_el1(SYS_SPSR);
}
@@ -324,7 +324,7 @@ static void __hyp_text __sysreg_restore_vel1_state(struct kvm_cpu_context *ctxt)
}
write_sysreg(ctxt->sp_el1, sp_el1);
- write_sysreg_el1(ctxt->elr_el1, SYS_ELR);
+ write_sysreg_el1(ctxt_sys_reg(ctxt, ELR_EL1), SYS_ELR);
write_sysreg_el1(ctxt->spsr[KVM_SPSR_EL1], SYS_SPSR);
}
@@ -1833,9 +1833,9 @@ static bool access_elr(struct kvm_vcpu *vcpu,
return false;
if (p->is_write)
- vcpu->arch.ctxt.elr_el1 = p->regval;
+ *__vcpu_elr_el1(vcpu) = p->regval;
else
- p->regval = vcpu->arch.ctxt.elr_el1;
+ p->regval = *__vcpu_elr_el1(vcpu);
return true;
}
ELR_EL1 being a VNCR-capable register, let's flag it as such, and repaint all the accesses Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/include/asm/kvm_emulate.h | 2 +- arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/kvm/guest.c | 2 +- arch/arm64/kvm/hyp/sysreg-sr.c | 4 ++-- arch/arm64/kvm/sys_regs.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-)