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: 2241201 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 16A2C3FCF6 for ; Sat, 9 Mar 2013 06:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932261Ab3CIGtF (ORCPT ); Sat, 9 Mar 2013 01:49:05 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:64758 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932148Ab3CIGtB (ORCPT ); Sat, 9 Mar 2013 01:49:01 -0500 Received: by mail-ee0-f53.google.com with SMTP id e53so1373629eek.12 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 Cc: kvm@vger.kernel.org, gnatapov@redhat.com, mtosatti@redhat.com, jan.kiszka@siemens.com Subject: [PATCH uq/master 2/2] kvm: forward INIT signals coming from the chipset 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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);