From patchwork Sat Mar 9 06:48:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 226310 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1A0E52C0364 for ; Sat, 9 Mar 2013 17:50:59 +1100 (EST) Received: from localhost ([::1]:40803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEDcP-0007dD-Dn for incoming@patchwork.ozlabs.org; Sat, 09 Mar 2013 01:50:57 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEDad-0005rS-Vn for qemu-devel@nongnu.org; Sat, 09 Mar 2013 01:49:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UEDaX-0005ox-0d for qemu-devel@nongnu.org; Sat, 09 Mar 2013 01:49:07 -0500 Received: from mail-ee0-f47.google.com ([74.125.83.47]:60902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEDaW-0005op-Qq for qemu-devel@nongnu.org; Sat, 09 Mar 2013 01:49:00 -0500 Received: by mail-ee0-f47.google.com with SMTP id e52so1369891eek.6 for ; Fri, 08 Mar 2013 22:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=AKur5PUqkwHWIwKql76uljEkhlYLNrf52G5rXaL9rJ4=; b=N3e1Z9bepJ5ki5JO8P0g5jifN9571c8wj/UJw4thHSWgvPql40yzyYhysV5bDpQ09K 9pY8LfutJF9SeGIz4V4jqT+iNmqyvtVKDCZaHJ6WSba6NG7/Z2kPb/N32sz03ztMMF/4 jout2kSFV0ww8NFZvIp2kD9L/yiuYOq3iIeuuRTsARQtVL0O6mfyook2tgJkLSQQJIrT scSuJAdOE+poK323xUx9Ss+BsjtOnxp5sbY0v9pWN3DY57HkXbLnJ2mMtlkgPIARwgLC lc6A1hFjgcMHbpIHEm1Vc1F3oM6c97wjnuUy4AC1B0l7SiNN8naTYGQpham7DoZT3vJS xTFQ== X-Received: by 10.14.218.71 with SMTP id j47mr13135629eep.28.1362811740056; Fri, 08 Mar 2013 22:49:00 -0800 (PST) Received: from yakj.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id 44sm11727906eek.5.2013.03.08.22.48.58 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 08 Mar 2013 22:48:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 9 Mar 2013 07:48:50 +0100 Message-Id: <1362811730-6716-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1362811730-6716-1-git-send-email-pbonzini@redhat.com> References: <1362811730-6716-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.83.47 Cc: jan.kiszka@siemens.com, gnatapov@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH uq/master 2/2] kvm: forward INIT signals coming from the chipset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org CPU_INTERRUPT_INIT can also be generated if you have an internal APIC, since the keyboard controller and the southbridge can also pulse the CPU's INIT# pin. Exit the VCPU is one is received, and process it by changing the mp_state to KVM_MP_STATE_INIT_RECEIVED. Signed-off-by: Paolo Bonzini --- target-i386/kvm.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 0cf413d..56de77c 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1772,14 +1772,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 (env->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 (env->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 && (env->interrupt_request & CPU_INTERRUPT_HARD) && @@ -1835,6 +1836,7 @@ int kvm_arch_process_async_events(CPUState *cs) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; + int ret; if (env->interrupt_request & CPU_INTERRUPT_MCE) { /* We must not raise CPU_INTERRUPT_MCE if it's not supported. */ @@ -1859,6 +1861,20 @@ int kvm_arch_process_async_events(CPUState *cs) } } + if (env->interrupt_request & CPU_INTERRUPT_INIT) { + kvm_cpu_synchronize_state(env); + if (kvm_irqchip_in_kernel()) { + env->mp_state = KVM_MP_STATE_INIT_RECEIVED; + env->interrupt_request = 0; + ret = kvm_put_mp_state(cpu); + if (ret < 0) { + return ret; + } + } else { + do_cpu_init(cpu); + } + } + if (kvm_irqchip_in_kernel()) { return 0; } @@ -1872,10 +1888,6 @@ int kvm_arch_process_async_events(CPUState *cs) (env->interrupt_request & CPU_INTERRUPT_NMI)) { env->halted = 0; } - if (env->interrupt_request & CPU_INTERRUPT_INIT) { - kvm_cpu_synchronize_state(env); - do_cpu_init(cpu); - } if (env->interrupt_request & CPU_INTERRUPT_SIPI) { kvm_cpu_synchronize_state(env); do_cpu_sipi(cpu);