diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2017-06-06 06:57:04 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-09-27 07:45:28 -0400 |
commit | cd39e1176d320157831ce030b4c869bd2d5eb142 (patch) | |
tree | 354250af53fa932cb65433a854952eaf38e368a3 | |
parent | e001fa78d44d0b5c7b1498d1e4a038740efa3b1e (diff) |
KVM: VMX: extract __pi_post_block
Simple code movement patch, preparing for the next one.
Cc: Huangweidong <weidong.huang@huawei.com>
Cc: Gonglei <arei.gonglei@huawei.com>
Cc: wangxin <wangxinxin.wang@huawei.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Tested-by: Longpeng (Mike) <longpeng2@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/vmx.c | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index c83d28b0ab05..0002b14307ab 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -11705,6 +11705,43 @@ static void vmx_enable_log_dirty_pt_masked(struct kvm *kvm, | |||
11705 | kvm_mmu_clear_dirty_pt_masked(kvm, memslot, offset, mask); | 11705 | kvm_mmu_clear_dirty_pt_masked(kvm, memslot, offset, mask); |
11706 | } | 11706 | } |
11707 | 11707 | ||
11708 | static void __pi_post_block(struct kvm_vcpu *vcpu) | ||
11709 | { | ||
11710 | struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); | ||
11711 | struct pi_desc old, new; | ||
11712 | unsigned int dest; | ||
11713 | unsigned long flags; | ||
11714 | |||
11715 | do { | ||
11716 | old.control = new.control = pi_desc->control; | ||
11717 | |||
11718 | dest = cpu_physical_id(vcpu->cpu); | ||
11719 | |||
11720 | if (x2apic_enabled()) | ||
11721 | new.ndst = dest; | ||
11722 | else | ||
11723 | new.ndst = (dest << 8) & 0xFF00; | ||
11724 | |||
11725 | /* Allow posting non-urgent interrupts */ | ||
11726 | new.sn = 0; | ||
11727 | |||
11728 | /* set 'NV' to 'notification vector' */ | ||
11729 | new.nv = POSTED_INTR_VECTOR; | ||
11730 | } while (cmpxchg(&pi_desc->control, old.control, | ||
11731 | new.control) != old.control); | ||
11732 | |||
11733 | if(vcpu->pre_pcpu != -1) { | ||
11734 | spin_lock_irqsave( | ||
11735 | &per_cpu(blocked_vcpu_on_cpu_lock, | ||
11736 | vcpu->pre_pcpu), flags); | ||
11737 | list_del(&vcpu->blocked_vcpu_list); | ||
11738 | spin_unlock_irqrestore( | ||
11739 | &per_cpu(blocked_vcpu_on_cpu_lock, | ||
11740 | vcpu->pre_pcpu), flags); | ||
11741 | vcpu->pre_pcpu = -1; | ||
11742 | } | ||
11743 | } | ||
11744 | |||
11708 | /* | 11745 | /* |
11709 | * This routine does the following things for vCPU which is going | 11746 | * This routine does the following things for vCPU which is going |
11710 | * to be blocked if VT-d PI is enabled. | 11747 | * to be blocked if VT-d PI is enabled. |
@@ -11798,44 +11835,12 @@ static int vmx_pre_block(struct kvm_vcpu *vcpu) | |||
11798 | 11835 | ||
11799 | static void pi_post_block(struct kvm_vcpu *vcpu) | 11836 | static void pi_post_block(struct kvm_vcpu *vcpu) |
11800 | { | 11837 | { |
11801 | struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); | ||
11802 | struct pi_desc old, new; | ||
11803 | unsigned int dest; | ||
11804 | unsigned long flags; | ||
11805 | |||
11806 | if (!kvm_arch_has_assigned_device(vcpu->kvm) || | 11838 | if (!kvm_arch_has_assigned_device(vcpu->kvm) || |
11807 | !irq_remapping_cap(IRQ_POSTING_CAP) || | 11839 | !irq_remapping_cap(IRQ_POSTING_CAP) || |
11808 | !kvm_vcpu_apicv_active(vcpu)) | 11840 | !kvm_vcpu_apicv_active(vcpu)) |
11809 | return; | 11841 | return; |
11810 | 11842 | ||
11811 | do { | 11843 | __pi_post_block(vcpu); |
11812 | old.control = new.control = pi_desc->control; | ||
11813 | |||
11814 | dest = cpu_physical_id(vcpu->cpu); | ||
11815 | |||
11816 | if (x2apic_enabled()) | ||
11817 | new.ndst = dest; | ||
11818 | else | ||
11819 | new.ndst = (dest << 8) & 0xFF00; | ||
11820 | |||
11821 | /* Allow posting non-urgent interrupts */ | ||
11822 | new.sn = 0; | ||
11823 | |||
11824 | /* set 'NV' to 'notification vector' */ | ||
11825 | new.nv = POSTED_INTR_VECTOR; | ||
11826 | } while (cmpxchg(&pi_desc->control, old.control, | ||
11827 | new.control) != old.control); | ||
11828 | |||
11829 | if(vcpu->pre_pcpu != -1) { | ||
11830 | spin_lock_irqsave( | ||
11831 | &per_cpu(blocked_vcpu_on_cpu_lock, | ||
11832 | vcpu->pre_pcpu), flags); | ||
11833 | list_del(&vcpu->blocked_vcpu_list); | ||
11834 | spin_unlock_irqrestore( | ||
11835 | &per_cpu(blocked_vcpu_on_cpu_lock, | ||
11836 | vcpu->pre_pcpu), flags); | ||
11837 | vcpu->pre_pcpu = -1; | ||
11838 | } | ||
11839 | } | 11844 | } |
11840 | 11845 | ||
11841 | static void vmx_post_block(struct kvm_vcpu *vcpu) | 11846 | static void vmx_post_block(struct kvm_vcpu *vcpu) |