qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Avi Kivity <avi@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH 1/1 V5] kernel/kvm: introduce KVM_SET_LINT1 and fix improper nmi emulation
Date: Fri, 14 Oct 2011 11:07:05 +0200	[thread overview]
Message-ID: <4E97FBB9.2040909@web.de> (raw)
In-Reply-To: <4E97FAC7.6080007@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 3794 bytes --]

On 2011-10-14 11:03, Lai Jiangshan wrote:
> Currently, NMI interrupt is blindly sent to all the vCPUs when NMI
> button event happens. This doesn't properly emulate real hardware on
> which NMI button event triggers LINT1. Because of this, NMI is sent to
> the processor even when LINT1 is masked in LVT. For example, this
> causes the problem that kdump initiated by NMI sometimes doesn't work
> on KVM, because kdump assumes NMI is masked on CPUs other than CPU0.
> 
> With this patch, we introduce introduce KVM_SET_LINT1,
> and we can use KVM_SET_LINT1 to correctly emulate NMI button
> without change the old KVM_NMI behavior.
> 
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> Reported-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
> ---
>  arch/x86/include/asm/kvm.h |    1 +
>  arch/x86/kvm/irq.h         |    1 +
>  arch/x86/kvm/lapic.c       |    7 +++++++
>  arch/x86/kvm/x86.c         |    8 ++++++++
>  include/linux/kvm.h        |    5 +++++
>  5 files changed, 22 insertions(+), 0 deletions(-)
> diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
> index 4d8dcbd..88d0ac3 100644
> --- a/arch/x86/include/asm/kvm.h
> +++ b/arch/x86/include/asm/kvm.h
> @@ -24,6 +24,7 @@
>  #define __KVM_HAVE_DEBUGREGS
>  #define __KVM_HAVE_XSAVE
>  #define __KVM_HAVE_XCRS
> +#define __KVM_HAVE_SET_LINT1
>  
>  /* Architectural interrupt line count. */
>  #define KVM_NR_INTERRUPTS 256
> diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
> index 53e2d08..0c96315 100644
> --- a/arch/x86/kvm/irq.h
> +++ b/arch/x86/kvm/irq.h
> @@ -95,6 +95,7 @@ void kvm_pic_reset(struct kvm_kpic_state *s);
>  void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
>  void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu);
>  void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu);
> +void kvm_apic_lint1_deliver(struct kvm_vcpu *vcpu);
>  void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu);
>  void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu);
>  void __kvm_migrate_timers(struct kvm_vcpu *vcpu);
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 57dcbd4..87fe36a 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1039,6 +1039,13 @@ void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu)
>  		kvm_apic_local_deliver(apic, APIC_LVT0);
>  }
>  
> +void kvm_apic_lint1_deliver(struct kvm_vcpu *vcpu)
> +{
> +	struct kvm_lapic *apic = vcpu->arch.apic;
> +
> +	kvm_apic_local_deliver(apic, APIC_LVT1);
> +}
> +
>  static struct kvm_timer_ops lapic_timer_ops = {
>  	.is_periodic = lapic_is_periodic,
>  };
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 84a28ea..fccd094 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2077,6 +2077,7 @@ int kvm_dev_ioctl_check_extension(long ext)
>  	case KVM_CAP_XSAVE:
>  	case KVM_CAP_ASYNC_PF:
>  	case KVM_CAP_GET_TSC_KHZ:
> +	case KVM_CAP_SET_LINT1:
>  		r = 1;
>  		break;
>  	case KVM_CAP_COALESCED_MMIO:
> @@ -3264,6 +3265,13 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  
>  		goto out;
>  	}
> +	case KVM_SET_LINT1: {
> +		r = -EINVAL;
> +		if (!irqchip_in_kernel(vcpu->kvm))
> +			goto out;
> +		r = 0;
> +		kvm_apic_lint1_deliver(vcpu);
> +	}
>  	default:
>  		r = -EINVAL;
>  	}
> diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> index aace6b8..3a10572 100644
> --- a/include/linux/kvm.h
> +++ b/include/linux/kvm.h
> @@ -554,6 +554,9 @@ struct kvm_ppc_pvinfo {
>  #define KVM_CAP_PPC_SMT 64
>  #define KVM_CAP_PPC_RMA	65
>  #define KVM_CAP_S390_GMAP 71
> +#ifdef __KVM_HAVE_SET_LINT1
> +#define KVM_CAP_SET_LINT1 72
> +#endif

Actually, there is no need for __KVM_HAVE_SET_LINT1 and #ifdef. User
land will just do a runtime check.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2011-10-14  9:12 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110913093835.GB4265@localhost.localdomain>
     [not found] ` <20110914093441.e2bb305c.kamezawa.hiroyu@jp.fujitsu.com>
     [not found]   ` <4E705BC3.5000508@cn.fujitsu.com>
     [not found]     ` <20110915164704.9cacd407.kamezawa.hiroyu@jp.fujitsu.com>
     [not found]       ` <4E71B28F.7030201@cn.fujitsu.com>
     [not found]         ` <4E72F3BA.2000603@jp.fujitsu.com>
     [not found]           ` <4E73200A.7040908@jp.fujitsu.com>
     [not found]             ` <4E76C6AA.9080403@cn.fujitsu.com>
2011-09-22  9:50               ` [Qemu-devel] [PATCH] qemu: Fix inject-nmi Lai Jiangshan
2011-09-22 14:51                 ` Jan Kiszka
2011-09-23  9:31                   ` Lai Jiangshan
2011-09-23  9:35                     ` Jan Kiszka
2011-09-25 14:07                     ` Avi Kivity
2011-09-25 17:22                       ` Jan Kiszka
2011-09-26  8:21                         ` Avi Kivity
2011-10-10  6:06                           ` Lai Jiangshan
2011-10-10  6:06                           ` [Qemu-devel] [PATCH] kernel/kvm: fix improper nmi emulation (was: Re: [PATCH] qemu: Fix inject-nmi) Lai Jiangshan
2011-10-10  6:40                             ` [Qemu-devel] [PATCH] kernel/kvm: fix improper nmi emulation Jan Kiszka
2011-10-10 10:26                             ` Avi Kivity
2011-10-11 17:00                               ` [Qemu-devel] [PATCH 1/1 V2] " Lai Jiangshan
2011-10-11 18:06                                 ` Jan Kiszka
2011-10-14  0:54                                   ` [Qemu-devel] [PATCH 1/1 V3] " Lai Jiangshan
2011-10-16  8:54                                     ` Avi Kivity
2011-10-16  9:05                                       ` Jan Kiszka
2011-10-16  9:28                                         ` Avi Kivity
2011-10-12  7:02                                 ` [Qemu-devel] [PATCH 1/1 V2] " Kenji Kaneshige
2011-10-12  7:01                               ` [Qemu-devel] [PATCH] " Kenji Kaneshige
2011-10-10  6:06                           ` [Qemu-devel] [PATCH] qemu-kvm: fix improper nmi emulation (was: Re: [PATCH] qemu: Fix inject-nmi) Lai Jiangshan
2011-10-10  6:49                             ` [Qemu-devel] [PATCH] qemu-kvm: fix improper nmi emulation Jan Kiszka
2011-10-10  9:47                               ` Andreas Färber
2011-10-11 17:03                               ` [Qemu-devel] [PATCH 1/2 V2] qemu-kvm: Synchronize kernel headers Lai Jiangshan
2011-10-11 17:03                               ` [Qemu-devel] [PATCH 2/2 V2] qemu-kvm: fix improper nmi emulation Lai Jiangshan
2011-10-11 18:17                                 ` Jan Kiszka
2011-10-14  0:53                                   ` Lai Jiangshan
2011-10-14  5:53                                     ` Jan Kiszka
2011-10-14  6:36                                       ` [Qemu-devel] [PATCH 1/1 V4] " Lai Jiangshan
2011-10-14  6:49                                         ` Jan Kiszka
2011-10-14  7:43                                           ` Lai Jiangshan
2011-10-14  8:31                                             ` Jan Kiszka
2011-10-14  9:03                                           ` [Qemu-devel] [PATCH 1/1 V5] kernel/kvm: introduce KVM_SET_LINT1 and " Lai Jiangshan
2011-10-14  9:07                                             ` Jan Kiszka [this message]
2011-10-14  9:27                                               ` Lai Jiangshan
2011-10-14  9:32                                                 ` Jan Kiszka
2011-10-16  9:39                                             ` Avi Kivity
2011-10-17  9:17                                               ` Lai Jiangshan
2011-10-17  9:54                                                 ` Avi Kivity
2011-10-17 10:21                                                   ` Jan Kiszka
2011-10-17  9:40                                               ` Lai Jiangshan
2011-10-17  9:49                                                 ` Avi Kivity
2011-10-17 16:00                                                   ` [Qemu-devel] [PATCH 1/1 V6] qemu-kvm: " Lai Jiangshan
2011-10-18 19:41                                                     ` Jan Kiszka
2011-10-19  6:33                                                       ` Lai Jiangshan
2011-10-19 10:57                                                         ` Jan Kiszka
2011-10-19 15:21                                                           ` [Qemu-devel] [PATCH 1/1 V6] qemu: " Lai Jiangshan
2011-10-19  9:29                                                       ` [Qemu-devel] [PATCH 1/1 V6] qemu-kvm: " Avi Kivity
2011-10-19 15:32                                                         ` Lai Jiangshan
2011-12-07 10:29                                                     ` Avi Kivity
2011-12-08  9:42                                                       ` Jan Kiszka
2011-12-08 10:20                                                         ` Jan Kiszka
2011-10-14  9:03                                           ` [Qemu-devel] [PATCH 1/2 V5] qemu-kvm: Synchronize kernel headers Lai Jiangshan
2011-10-14  9:03                                           ` [Qemu-devel] [PATCH 2/2 V5] qemu-kvm: fix improper nmi emulation Lai Jiangshan
2011-10-14  9:22                                             ` Jan Kiszka
2011-10-14  9:51                                           ` [Qemu-devel] [PATCH 1/1 V5 tuning] kernel/kvm: introduce KVM_SET_LINT1 and " Lai Jiangshan
2011-10-14 11:59                                             ` Sasha Levin
2011-10-14 12:07                                               ` Jan Kiszka
2011-10-16 15:01                                                 ` Lai Jiangshan
2011-10-14  9:51                                           ` [Qemu-devel] [PATCH 1/2 V5 tuning] qemu-kvm: Synchronize kernel headers Lai Jiangshan
2011-10-14  0:54                                   ` [Qemu-devel] [PATCH 1/1 V3] qemu-kvm: fix improper nmi emulation Lai Jiangshan
2011-10-10  6:06                           ` [Qemu-devel] [PATCH 1/2] seabios: Add Local APIC NMI Structure to ACPI MADT (was: Re: [PATCH] qemu: Fix inject-nmi) Lai Jiangshan
2011-10-28 12:08                             ` [Qemu-devel] [PATCH 1/2] seabios: Add Local APIC NMI Structure to ACPI MADT Kenji Kaneshige
2011-10-28 12:19                               ` Gleb Natapov
2011-10-28 12:48                               ` Jun Koi
2011-10-31  8:00                                 ` Kenji Kaneshige
2011-10-30 14:44                             ` Avi Kivity
2011-10-30 14:44                               ` Avi Kivity
2011-10-10  6:06                           ` [Qemu-devel] [PATCH 2/2] seabios: fix mptable nmi entry (was: Re: [PATCH] qemu: Fix inject-nmi) Lai Jiangshan
2011-10-30 17:52                             ` Kevin O'Connor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E97FBB9.2040909@web.de \
    --to=jan.kiszka@web.de \
    --cc=avi@redhat.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kaneshige.kenji@jp.fujitsu.com \
    --cc=kvm@vger.kernel.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).