All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>, Gleb Natapov <gleb@redhat.com>
Subject: Re: [PATCH] KVM: x86: Extend KVM_SET_VCPU_EVENTS with selective updates
Date: Mon, 14 Dec 2009 11:32:46 +0100	[thread overview]
Message-ID: <4B26144E.6040503@siemens.com> (raw)
In-Reply-To: <4B1BE216.2090407@web.de>

Jan Kiszka wrote:
> User space may not want to overwrite asynchronously changing VCPU event
> states on write-back. So allow to skip nmi.pending and sipi_vector by
> setting corresponding bits in the flags field of kvm_vcpu_events.
> 

What will happen to this patch now? Merge during 2.6.33 window or drop?

Jan

> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
>  Documentation/kvm/api.txt  |   10 +++++++++-
>  arch/x86/include/asm/kvm.h |    4 ++++
>  arch/x86/kvm/x86.c         |    9 ++++++---
>  3 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/kvm/api.txt b/Documentation/kvm/api.txt
> index e1a1141..ee07e3a 100644
> --- a/Documentation/kvm/api.txt
> +++ b/Documentation/kvm/api.txt
> @@ -685,7 +685,7 @@ struct kvm_vcpu_events {
>  		__u8 pad;
>  	} nmi;
>  	__u32 sipi_vector;
> -	__u32 flags;   /* must be zero */
> +	__u32 flags;
>  };
>  
>  4.30 KVM_SET_VCPU_EVENTS
> @@ -701,6 +701,14 @@ vcpu.
>  
>  See KVM_GET_VCPU_EVENTS for the data structure.
>  
> +Fields that may be modified asynchronously by running VCPUs can be excluded
> +from the update. These fields are nmi.pending and sipi_vector. Set the
> +corresponding mask bits in the flags field to suppress overwriting their
> +current state:
> +
> +KVM_VCPUEVENT_MASK_NMI_PENDING - do not update nmi.pending
> +KVM_VCPUEVENT_MASK_SIPI_VECTOR - do not update sipi_vector
> +
>  
>  5. The kvm_run structure
>  
> diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
> index 950df43..acf8585 100644
> --- a/arch/x86/include/asm/kvm.h
> +++ b/arch/x86/include/asm/kvm.h
> @@ -254,6 +254,10 @@ struct kvm_reinject_control {
>  	__u8 reserved[31];
>  };
>  
> +/* When set in flags, skip corresponding fields on KVM_SET_VCPU_EVENTS */
> +#define KVM_VCPUEVENT_MASK_NMI_PENDING	0x00000001
> +#define KVM_VCPUEVENT_MASK_SIPI_VECTOR	0x00000002
> +
>  /* for KVM_GET/SET_VCPU_EVENTS */
>  struct kvm_vcpu_events {
>  	struct {
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index dd15d7a..368843c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1953,7 +1953,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
>  static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
>  					      struct kvm_vcpu_events *events)
>  {
> -	if (events->flags)
> +	if (events->flags &
> +	    ~(KVM_VCPUEVENT_MASK_NMI_PENDING | KVM_VCPUEVENT_MASK_SIPI_VECTOR))
>  		return -EINVAL;
>  
>  	vcpu_load(vcpu);
> @@ -1970,10 +1971,12 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
>  		kvm_pic_clear_isr_ack(vcpu->kvm);
>  
>  	vcpu->arch.nmi_injected = events->nmi.injected;
> -	vcpu->arch.nmi_pending = events->nmi.pending;
> +	if (!(events->flags & KVM_VCPUEVENT_MASK_NMI_PENDING))
> +		vcpu->arch.nmi_pending = events->nmi.pending;
>  	kvm_x86_ops->set_nmi_mask(vcpu, events->nmi.masked);
>  
> -	vcpu->arch.sipi_vector = events->sipi_vector;
> +	if (!(events->flags & KVM_VCPUEVENT_MASK_SIPI_VECTOR))
> +		vcpu->arch.sipi_vector = events->sipi_vector;
>  
>  	vcpu_put(vcpu);
>  
> 

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  parent reply	other threads:[~2009-12-14 10:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-06 16:55 [PATCH] KVM: x86: Extend KVM_SET_VCPU_EVENTS with selective updates Jan Kiszka
2009-12-06 17:05 ` Avi Kivity
2009-12-06 17:12   ` Jan Kiszka
2009-12-15 14:54     ` Avi Kivity
2009-12-15 16:41       ` Jan Kiszka
2009-12-15 17:08         ` Avi Kivity
2009-12-15 22:57           ` [PATCH] KVM: x86: Adjust KVM_VCPUEVENT flag names Jan Kiszka
2009-12-16  9:59             ` Avi Kivity
2009-12-06 17:24   ` [PATCH v2] KVM: x86: Extend KVM_SET_VCPU_EVENTS with selective updates Jan Kiszka
2009-12-08 14:02     ` Marcelo Tosatti
2009-12-08 14:07       ` Avi Kivity
2009-12-08 20:52         ` Marcelo Tosatti
2009-12-08 21:17           ` Jan Kiszka
2009-12-15 14:50             ` Avi Kivity
2009-12-15 16:43               ` Jan Kiszka
2009-12-15 17:10                 ` Avi Kivity
2009-12-15 17:29                   ` Jan Kiszka
2009-12-14 10:32 ` Jan Kiszka [this message]
2009-12-14 10:34   ` [PATCH] " Avi Kivity

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=4B26144E.6040503@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.