提交 a2252278 编写于 作者: Z Zenghui Yu 提交者: Yang Yingliang

KVM: arm64: Only flush VM for the first and the last vcpu

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: NZenghui Yu <yuzenghui@huawei.com>
Reviewed-by: Nzhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 ae0237a0
...@@ -2474,6 +2474,19 @@ void kvm_set_way_flush(struct kvm_vcpu *vcpu) ...@@ -2474,6 +2474,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) void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled)
{ {
bool now_enabled = vcpu_has_cache_enabled(vcpu); bool now_enabled = vcpu_has_cache_enabled(vcpu);
...@@ -2483,7 +2496,7 @@ void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled) ...@@ -2483,7 +2496,7 @@ void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled)
* If switching it off, need to clean the caches. * If switching it off, need to clean the caches.
* Clean + invalidate does the trick always. * 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); stage2_flush_vm(vcpu->kvm);
/* Caches are now on, stop trapping VM ops (until a S/W op) */ /* Caches are now on, stop trapping VM ops (until a S/W op) */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册