Commit f0a3eaff authored by Victor Kamensky's avatar Victor Kamensky Committed by Christoffer Dall

ARM64: KVM: fix big endian issue in access_vm_reg for 32bit guest

Fix issue with 32bit guests running on top of BE KVM host.
Indexes of high and low words of 64bit cp15 register are
swapped in case of big endian code, since 64bit cp15 state is
restored or saved with double word write or read instruction.

Define helper macro to access low words of 64bit cp15 register.
Signed-off-by: default avatarVictor Kamensky <victor.kamensky@linaro.org>
Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
parent 26c99af1
...@@ -140,6 +140,12 @@ struct kvm_vcpu_arch { ...@@ -140,6 +140,12 @@ struct kvm_vcpu_arch {
#define vcpu_sys_reg(v,r) ((v)->arch.ctxt.sys_regs[(r)]) #define vcpu_sys_reg(v,r) ((v)->arch.ctxt.sys_regs[(r)])
#define vcpu_cp15(v,r) ((v)->arch.ctxt.cp15[(r)]) #define vcpu_cp15(v,r) ((v)->arch.ctxt.cp15[(r)])
#ifdef CONFIG_CPU_BIG_ENDIAN
#define vcpu_cp15_64_low(v,r) ((v)->arch.ctxt.cp15[((r) + 1)])
#else
#define vcpu_cp15_64_low(v,r) ((v)->arch.ctxt.cp15[((r) + 0)])
#endif
struct kvm_vm_stat { struct kvm_vm_stat {
u32 remote_tlb_flush; u32 remote_tlb_flush;
}; };
......
...@@ -134,13 +134,11 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu, ...@@ -134,13 +134,11 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu,
BUG_ON(!p->is_write); BUG_ON(!p->is_write);
val = *vcpu_reg(vcpu, p->Rt); val = *vcpu_reg(vcpu, p->Rt);
if (!p->is_aarch32) { if (!p->is_aarch32 || !p->is_32bit)
vcpu_sys_reg(vcpu, r->reg) = val; vcpu_sys_reg(vcpu, r->reg) = val;
} else { else
vcpu_cp15(vcpu, r->reg) = val & 0xffffffffUL; vcpu_cp15_64_low(vcpu, r->reg) = val & 0xffffffffUL;
if (!p->is_32bit)
vcpu_cp15(vcpu, r->reg + 1) = val >> 32;
}
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment