From a9a8ba7348ef843c3306cb2fda3e347468b2903a Mon Sep 17 00:00:00 2001 From: Fuad Tabba Date: Fri, 21 Jan 2022 14:03:01 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Fix vcpu sys_reg accessors when running with VHE Commit 3f6536412f0b ("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 Signed-off-by: Fuad Tabba Bug: 209580772 Signed-off-by: Will Deacon Change-Id: I17d4c12ffdbbd95e8e8d1820ebb6438b138361aa --- arch/arm64/include/asm/kvm_host.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index a69284d07a28..3b69db40e003 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -686,7 +686,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; @@ -695,7 +696,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;