From: Zenghui Yu yuzenghui@huawei.com
euleros inclusion category: bugfix
-------------------------------------------------
stage_flush_vm() can be pretty time-consuming if lots of stage-2 mappings had been setup before booting secondary processors. Sidestep the heavy D-cache maintenance operations on D05 *only*.
Signed-off-by: Zenghui Yu yuzenghui@huawei.com Reviewed-by: zhanghailiang zhang.zhanghailiang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- virt/kvm/arm/mmu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 3db352c..77105fd 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -2475,6 +2475,19 @@ void kvm_set_way_flush(struct kvm_vcpu *vcpu) } }
+static bool kvm_need_flush_vm(struct kvm_vcpu *vcpu) +{ + if (kvm_ncsnp_support) + return false; + + /* Hackish... */ + if (vcpu->vcpu_id == 0 || (vcpu->vcpu_id + 1 == + atomic_read(&vcpu->kvm->online_vcpus))) + return true; + + return false; +} + void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled) { bool now_enabled = vcpu_has_cache_enabled(vcpu); @@ -2484,7 +2497,7 @@ void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled) * If switching it off, need to clean the caches. * Clean + invalidate does the trick always. */ - if (now_enabled != was_enabled && !kvm_ncsnp_support) + if (now_enabled != was_enabled && kvm_need_flush_vm(vcpu)) stage2_flush_vm(vcpu->kvm);
/* Caches are now on, stop trapping VM ops (until a S/W op) */