KVM: Bypass irq_pending get/set when using in kernel irqchip

vcpu->irq_pending is saved in get/set_sreg IOCTL, but when in-kernel
local APIC is used, doing this may occasionally overwrite vcpu->apic to
an invalid value, as in the vm restore path.

Signed-off-by: Qing He <qing.he@intel.com>
This commit is contained in:
He, Qing 2007-08-02 14:03:07 +03:00 committed by Avi Kivity
parent 6ceb9d791e
commit c52fb35a8b
1 changed files with 14 additions and 8 deletions

View File

@ -2145,8 +2145,12 @@ static int kvm_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
sregs->efer = vcpu->shadow_efer; sregs->efer = vcpu->shadow_efer;
sregs->apic_base = kvm_get_apic_base(vcpu); sregs->apic_base = kvm_get_apic_base(vcpu);
memcpy(sregs->interrupt_bitmap, vcpu->irq_pending, if (irqchip_in_kernel(vcpu->kvm))
sizeof sregs->interrupt_bitmap); memset(sregs->interrupt_bitmap, 0,
sizeof sregs->interrupt_bitmap);
else
memcpy(sregs->interrupt_bitmap, vcpu->irq_pending,
sizeof sregs->interrupt_bitmap);
vcpu_put(vcpu); vcpu_put(vcpu);
@ -2200,12 +2204,14 @@ static int kvm_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
if (mmu_reset_needed) if (mmu_reset_needed)
kvm_mmu_reset_context(vcpu); kvm_mmu_reset_context(vcpu);
memcpy(vcpu->irq_pending, sregs->interrupt_bitmap, if (!irqchip_in_kernel(vcpu->kvm)) {
sizeof vcpu->irq_pending); memcpy(vcpu->irq_pending, sregs->interrupt_bitmap,
vcpu->irq_summary = 0; sizeof vcpu->irq_pending);
for (i = 0; i < ARRAY_SIZE(vcpu->irq_pending); ++i) vcpu->irq_summary = 0;
if (vcpu->irq_pending[i]) for (i = 0; i < ARRAY_SIZE(vcpu->irq_pending); ++i)
__set_bit(i, &vcpu->irq_summary); if (vcpu->irq_pending[i])
__set_bit(i, &vcpu->irq_summary);
}
set_segment(vcpu, &sregs->cs, VCPU_SREG_CS); set_segment(vcpu, &sregs->cs, VCPU_SREG_CS);
set_segment(vcpu, &sregs->ds, VCPU_SREG_DS); set_segment(vcpu, &sregs->ds, VCPU_SREG_DS);