ANDROID: KVM: arm64: Fix vcpu sys_reg accessors when running with VHE

Commit 36a84952bc ("ANDROID: KVM: arm64: refactor vcpu_read_sys_reg
and vcpu_write_sys_reg for hyp use") predicated direct access to the
live vCPU registers on an is_vhe_hyp_code() check, neglecting the fact
that these functions are also used by the VHE *kernel* code.

Restore the old behaviour by changing the check so that only the nVHE
hyp code unconditionally uses the 'ctxt_sys_reg' table.

Reported-by: Marc Zyngier <mzyngier@google.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I17d4c12ffdbbd95e8e8d1820ebb6438b138361aa
This commit is contained in:
Fuad Tabba
2022-01-21 14:03:01 +00:00
committed by Will Deacon
parent aebaed988e
commit 93b08c26e7

View File

@@ -684,7 +684,8 @@ static inline u64 vcpu_arch_read_sys_reg(const struct kvm_vcpu_arch *vcpu_arch,
{
u64 val = 0x8badf00d8badf00d;
if (is_vhe_hyp_code() && vcpu_arch->sysregs_loaded_on_cpu &&
/* sysregs_loaded_on_cpu is only used in VHE */
if (!is_nvhe_hyp_code() && vcpu_arch->sysregs_loaded_on_cpu &&
__vcpu_read_sys_reg_from_cpu(reg, &val))
return val;
@@ -693,7 +694,8 @@ static inline u64 vcpu_arch_read_sys_reg(const struct kvm_vcpu_arch *vcpu_arch,
static inline void vcpu_arch_write_sys_reg(struct kvm_vcpu_arch *vcpu_arch, u64 val, int reg)
{
if (is_vhe_hyp_code() && vcpu_arch->sysregs_loaded_on_cpu &&
/* sysregs_loaded_on_cpu is only used in VHE */
if (!is_nvhe_hyp_code() && vcpu_arch->sysregs_loaded_on_cpu &&
__vcpu_write_sys_reg_to_cpu(val, reg))
return;