From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgEX0-0003pO-TZ for qemu-devel@nongnu.org; Fri, 02 May 2014 10:33:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WgEWr-0007A8-Ra for qemu-devel@nongnu.org; Fri, 02 May 2014 10:33:42 -0400 Received: from mail-ee0-x232.google.com ([2a00:1450:4013:c00::232]:41380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgEWr-0007A0-K5 for qemu-devel@nongnu.org; Fri, 02 May 2014 10:33:33 -0400 Received: by mail-ee0-f50.google.com with SMTP id c13so3155578eek.37 for ; Fri, 02 May 2014 07:33:32 -0700 (PDT) Received: from playground.lan (net-37-117-141-58.cust.vodafonedsl.it. [37.117.141.58]) by mx.google.com with ESMTPSA id x45sm5013195eeu.23.2014.05.02.07.33.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 May 2014 07:33:31 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 2 May 2014 16:33:16 +0200 Message-Id: <1399041202-26184-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1399041202-26184-1-git-send-email-pbonzini@redhat.com> References: <1399041202-26184-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/8] kvm: forward INIT signals coming from the chipset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Reviewed-by: Gleb Natapov Signed-off-by: Paolo Bonzini --- target-i386/helper.c | 4 ++++ target-i386/kvm.c | 36 +++++++++++++++++++++++++----------- target-i386/kvm_i386.h | 1 + 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 372f0e3..27b3582 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -19,6 +19,7 @@ #include "cpu.h" #include "sysemu/kvm.h" +#include "kvm_i386.h" #ifndef CONFIG_USER_ONLY #include "sysemu/sysemu.h" #include "monitor/monitor.h" @@ -1335,6 +1336,9 @@ void do_cpu_init(X86CPU *cpu) cpu_reset(cs); cs->interrupt_request = sipi; env->pat = pat; + if (kvm_enabled()) { + kvm_arch_do_init_vcpu(cpu); + } apic_init_reset(cpu->apic_state); } diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 2319d78..1c0565f 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -30,6 +30,8 @@ #include "qemu/config-file.h" #include "hw/i386/pc.h" #include "hw/i386/apic.h" +#include "hw/i386/apic_internal.h" +#include "hw/i386/apic-msidef.h" #include "exec/ioport.h" #include #include "hw/pci/pci.h" @@ -739,6 +741,16 @@ void kvm_arch_reset_vcpu(X86CPU *cpu) } } +void kvm_arch_do_init_vcpu(X86CPU *cpu) +{ + CPUX86State *env = &cpu->env; + + /* APs get directly into wait-for-SIPI state. */ + if (env->mp_state == KVM_MP_STATE_UNINITIALIZED) { + env->mp_state = KVM_MP_STATE_INIT_RECEIVED; + } +} + static int kvm_get_supported_msrs(KVMState *s) { static int kvm_supported_msrs; @@ -2004,14 +2016,15 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run) } } - if (!kvm_irqchip_in_kernel()) { - /* Force the VCPU out of its inner loop to process any INIT requests - * or pending TPR access reports. */ - if (cpu->interrupt_request & - (CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR)) { - cpu->exit_request = 1; - } + /* Force the VCPU out of its inner loop to process any INIT requests + * or (for userspace APIC, but it is cheap to combine the checks here) + * pending TPR access reports. + */ + if (cpu->interrupt_request & (CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR)) { + cpu->exit_request = 1; + } + if (!kvm_irqchip_in_kernel()) { /* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && (cpu->interrupt_request & CPU_INTERRUPT_HARD) && @@ -2091,6 +2104,11 @@ int kvm_arch_process_async_events(CPUState *cs) } } + if (cs->interrupt_request & CPU_INTERRUPT_INIT) { + kvm_cpu_synchronize_state(cs); + do_cpu_init(cpu); + } + if (kvm_irqchip_in_kernel()) { return 0; } @@ -2104,10 +2122,6 @@ int kvm_arch_process_async_events(CPUState *cs) (cs->interrupt_request & CPU_INTERRUPT_NMI)) { cs->halted = 0; } - if (cs->interrupt_request & CPU_INTERRUPT_INIT) { - kvm_cpu_synchronize_state(cs); - do_cpu_init(cpu); - } if (cs->interrupt_request & CPU_INTERRUPT_SIPI) { kvm_cpu_synchronize_state(cs); do_cpu_sipi(cpu); diff --git a/target-i386/kvm_i386.h b/target-i386/kvm_i386.h index b0b2193..cac30fd 100644 --- a/target-i386/kvm_i386.h +++ b/target-i386/kvm_i386.h @@ -15,6 +15,7 @@ bool kvm_allows_irq0_override(void); void kvm_arch_reset_vcpu(X86CPU *cs); +void kvm_arch_do_init_vcpu(X86CPU *cs); int kvm_device_pci_assign(KVMState *s, PCIHostDeviceAddress *dev_addr, uint32_t flags, uint32_t *dev_id); -- 1.8.3.1