Commit 89ef0f21 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: VMX: Save/restore IRQs (instead of CLI/STI) during PI pre/post block

Save/restore IRQs when disabling IRQs in posted interrupt pre/post block
in preparation for moving the code into vcpu_put/load(), where it would be
called with IRQs already disabled.

No functional changed intended.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Message-Id: <20211009021236.4122790-26-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 29802380
...@@ -145,13 +145,13 @@ int pi_pre_block(struct kvm_vcpu *vcpu) ...@@ -145,13 +145,13 @@ int pi_pre_block(struct kvm_vcpu *vcpu)
{ {
struct pi_desc old, new; struct pi_desc old, new;
struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
unsigned long flags;
if (!vmx_can_use_vtd_pi(vcpu->kvm) || if (!vmx_can_use_vtd_pi(vcpu->kvm) ||
vmx_interrupt_blocked(vcpu)) vmx_interrupt_blocked(vcpu))
return 0; return 0;
WARN_ON(irqs_disabled()); local_irq_save(flags);
local_irq_disable();
vcpu->pre_pcpu = vcpu->cpu; vcpu->pre_pcpu = vcpu->cpu;
spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->cpu)); spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->cpu));
...@@ -175,19 +175,20 @@ int pi_pre_block(struct kvm_vcpu *vcpu) ...@@ -175,19 +175,20 @@ int pi_pre_block(struct kvm_vcpu *vcpu)
if (pi_test_on(pi_desc)) if (pi_test_on(pi_desc))
__pi_post_block(vcpu); __pi_post_block(vcpu);
local_irq_enable(); local_irq_restore(flags);
return (vcpu->pre_pcpu == -1); return (vcpu->pre_pcpu == -1);
} }
void pi_post_block(struct kvm_vcpu *vcpu) void pi_post_block(struct kvm_vcpu *vcpu)
{ {
unsigned long flags;
if (vcpu->pre_pcpu == -1) if (vcpu->pre_pcpu == -1)
return; return;
WARN_ON(irqs_disabled()); local_irq_save(flags);
local_irq_disable();
__pi_post_block(vcpu); __pi_post_block(vcpu);
local_irq_enable(); local_irq_restore(flags);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment