virt inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8610 -------------------------------------------------------------------- Enabling TLBI optimization via kvm-arm.dvmbm_enabled=1 permanently sets the LSUDVM_CTRL_EL2 control bit. Since CCA doesn't yet support this feature, CCA VMs will read an erroneous bitmap from SYS_LSUDVMBM_EL2 when performing TLB flushes, causing a panic. To avoid this issue, this patch dynamically sets/clears the bit in vcpu_load/vcpu_put, limiting the optimization to normal VMs only. Fixes: e85b97c7e2b4 ("KVM: arm64: Probe and configure DVMBM capability on HiSi CPUs") Signed-off-by: Tian Zheng <zhengtian10@huawei.com> Reviewed-by: Yanan Wang <wangyanan55@huawei.com> --- arch/arm64/kvm/hisilicon/hisi_virt.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kvm/hisilicon/hisi_virt.c b/arch/arm64/kvm/hisilicon/hisi_virt.c index d5a8a6d66dbc..1bd71044c2e7 100644 --- a/arch/arm64/kvm/hisilicon/hisi_virt.c +++ b/arch/arm64/kvm/hisilicon/hisi_virt.c @@ -145,7 +145,7 @@ static int __init early_dvmbm_enable(char *buf) } early_param("kvm-arm.dvmbm_enabled", early_dvmbm_enable); -static void hardware_enable_dvmbm(void *data) +static void hardware_enable_dvmbm(void) { u64 val; @@ -264,18 +264,10 @@ bool hisi_dvmbm_supported(void) if (!(read_sysreg(aidr_el1) & AIDR_EL1_DVMBM_MASK)) return false; - /* User provided kernel command-line parameter */ - if (!dvmbm_enabled) { - on_each_cpu(hardware_disable_dvmbm, NULL, 1); - return false; - } + /* reset */ + on_each_cpu(hardware_disable_dvmbm, NULL, 1); - /* - * Enable TLBI Broadcast optimization by setting - * LSUDVM_CTRL_EL2's bit[0]. - */ - on_each_cpu(hardware_enable_dvmbm, NULL, 1); - return true; + return dvmbm_enabled; } int kvm_sched_affinity_vcpu_init(struct kvm_vcpu *vcpu) @@ -574,6 +566,7 @@ void kvm_tlbi_dvmbm_vcpu_load(struct kvm_vcpu *vcpu) if (!kvm_dvmbm_support) return; + hardware_enable_dvmbm(); cpumask_copy(vcpu->arch.sched_cpus, current->cpus_ptr); if (likely(cpumask_equal(vcpu->arch.sched_cpus, @@ -624,6 +617,7 @@ void kvm_tlbi_dvmbm_vcpu_put(struct kvm_vcpu *vcpu) return; cpumask_copy(vcpu->arch.pre_sched_cpus, vcpu->arch.sched_cpus); + hardware_disable_dvmbm(NULL); } void kvm_get_pg_cfg(void) -- 2.33.0