From patchwork Sun Dec 6 17:24:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 65178 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB6HOJpv000855 for ; Sun, 6 Dec 2009 17:24:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933971AbZLFRYL (ORCPT ); Sun, 6 Dec 2009 12:24:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933970AbZLFRYL (ORCPT ); Sun, 6 Dec 2009 12:24:11 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:33278 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933963AbZLFRYK (ORCPT ); Sun, 6 Dec 2009 12:24:10 -0500 Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate03.web.de (Postfix) with ESMTP id 9747F13783770; Sun, 6 Dec 2009 18:24:16 +0100 (CET) Received: from [88.65.36.198] (helo=[192.168.1.10]) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NHKqG-0001wS-00; Sun, 06 Dec 2009 18:24:16 +0100 Message-ID: <4B1BE8BF.7030404@web.de> Date: Sun, 06 Dec 2009 18:24:15 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , kvm , Gleb Natapov Subject: [PATCH v2] KVM: x86: Extend KVM_SET_VCPU_EVENTS with selective updates References: <4B1BE216.2090407@web.de> <4B1BE452.6090107@redhat.com> In-Reply-To: <4B1BE452.6090107@redhat.com> X-Enigmail-Version: 0.95.7 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX1/xfq7D+ZyMl3+d7yAzJ8aU6c0xPJ5swBPyaieL +F4veMPx0vcVn+qZ1KJpmzjCrgaCzIAVK0TWS7F3kZ7SNXh/NQ moKG+6/ME= Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/Documentation/kvm/api.txt b/Documentation/kvm/api.txt index e1a1141..b22592d 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. Keep the +corresponding bits in the flags field cleared to suppress overwriting the +current in-kernel state. The bits are: + +KVM_VCPUEVENT_SET_NMI_PENDING - transfer nmi.pending to the kernel +KVM_VCPUEVENT_SET_SIPI_VECTOR - transfer 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..d1a67ae 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, include corresponding fields on KVM_SET_VCPU_EVENTS */ +#define KVM_VCPUEVENT_SET_NMI_PENDING 0x00000001 +#define KVM_VCPUEVENT_SET_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..e3c35ff 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_SET_NMI_PENDING | KVM_VCPUEVENT_SET_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_SET_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_SET_SIPI_VECTOR) + vcpu->arch.sipi_vector = events->sipi_vector; vcpu_put(vcpu);