aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 484c903544f4..ba4275d06fb7 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -552,10 +552,11 @@ static void ack_flush(void *_completed)
552{ 552{
553} 553}
554 554
555void kvm_flush_remote_tlbs(struct kvm *kvm) 555static bool make_all_cpus_request(struct kvm *kvm, unsigned int req)
556{ 556{
557 int i, cpu, me; 557 int i, cpu, me;
558 cpumask_t cpus; 558 cpumask_t cpus;
559 bool called = false;
559 struct kvm_vcpu *vcpu; 560 struct kvm_vcpu *vcpu;
560 561
561 me = get_cpu(); 562 me = get_cpu();
@@ -564,45 +565,30 @@ void kvm_flush_remote_tlbs(struct kvm *kvm)
564 vcpu = kvm->vcpus[i]; 565 vcpu = kvm->vcpus[i];
565 if (!vcpu) 566 if (!vcpu)
566 continue; 567 continue;
567 if (test_and_set_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests)) 568 if (test_and_set_bit(req, &vcpu->requests))
568 continue; 569 continue;
569 cpu = vcpu->cpu; 570 cpu = vcpu->cpu;
570 if (cpu != -1 && cpu != me) 571 if (cpu != -1 && cpu != me)
571 cpu_set(cpu, cpus); 572 cpu_set(cpu, cpus);
572 } 573 }
573 if (cpus_empty(cpus)) 574 if (!cpus_empty(cpus)) {
574 goto out; 575 smp_call_function_mask(cpus, ack_flush, NULL, 1);
575 ++kvm->stat.remote_tlb_flush; 576 called = true;
576 smp_call_function_mask(cpus, ack_flush, NULL, 1); 577 }
577out:
578 put_cpu(); 578 put_cpu();
579 return called;
579} 580}
580 581
581void kvm_reload_remote_mmus(struct kvm *kvm) 582void kvm_flush_remote_tlbs(struct kvm *kvm)
582{ 583{
583 int i, cpu, me; 584 if (make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH))
584 cpumask_t cpus; 585 ++kvm->stat.remote_tlb_flush;
585 struct kvm_vcpu *vcpu;
586
587 me = get_cpu();
588 cpus_clear(cpus);
589 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
590 vcpu = kvm->vcpus[i];
591 if (!vcpu)
592 continue;
593 if (test_and_set_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests))
594 continue;
595 cpu = vcpu->cpu;
596 if (cpu != -1 && cpu != me)
597 cpu_set(cpu, cpus);
598 }
599 if (cpus_empty(cpus))
600 goto out;
601 smp_call_function_mask(cpus, ack_flush, NULL, 1);
602out:
603 put_cpu();
604} 586}
605 587
588void kvm_reload_remote_mmus(struct kvm *kvm)
589{
590 make_all_cpus_request(kvm, KVM_REQ_MMU_RELOAD);
591}
606 592
607int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id) 593int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id)
608{ 594{