On 10/11/2017 02:24, Liran Alon wrote: > > @@ -6720,6 +6720,12 @@ static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu) > if (!kvm_apic_hw_enabled(vcpu->arch.apic)) > return; > > + if (is_guest_mode(vcpu)) { > + vcpu->arch.scan_ioapic_pending = true; > + return; > + } > + vcpu->arch.scan_ioapic_pending = false; > + > bitmap_zero(vcpu->arch.ioapic_handled_vectors, 256); > > if (irqchip_split(vcpu->kvm)) I am not sure it is correct to exit immediately. The bug is that you're losing the EOI exit bitmap in the vmcs01; however, with your patch you're losing it in the vmcs02. If the L1 hypervisor passes the local APIC registers to the L2 guest, you would have a similar bug. However, the patch is generally in the right direction. Another small issue: > @@ -6833,7 +6839,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) > goto out; > } > } > - if (kvm_check_request(KVM_REQ_SCAN_IOAPIC, vcpu)) > + if (kvm_check_request(KVM_REQ_SCAN_IOAPIC, vcpu) || > + (!is_guest_mode(vcpu) && vcpu->arch.scan_ioapic_pending)) > vcpu_scan_ioapic(vcpu); I think this is not reliable because kvm_request_pending(vcpu) might be false here---and then you never reach the "if" in the first place. Maybe you can add a if (vcpu->arch.scan_ioapic_pending) kvm_make_request(KVM_REQ_SCAN_IOAPIC, vcpu); to leave_guest_mode in arch/x86/kvm/kvm_cache_regs.h? Thanks, Paolo > if (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu)) > kvm_vcpu_reload_apic_access_page(vcpu); > @@ -7981,6 +7988,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) > kvm = vcpu->kvm; > > vcpu->arch.apicv_active = kvm_x86_ops->get_enable_apicv(vcpu); > + vcpu->arch.scan_ioapic_pending = false; > vcpu->arch.pv.pv_unhalted = false; > vcpu->arch.emulate_ctxt.ops = &emulate_ops; > if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_reset_bsp(vcpu)) >