From: Avi Kivity <avi@qumranet.com>
To: kvm-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [PATCH 13/31] KVM: add ioctls to save/store mpstate
Date: Mon, 21 Apr 2008 13:29:39 +0300 [thread overview]
Message-ID: <1208773797-7829-14-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <1208773797-7829-1-git-send-email-avi@qumranet.com>
From: Marcelo Tosatti <mtosatti@redhat.com>
So userspace can save/restore the mpstate during migration.
[avi: export the #define constants describing the value]
[christian: add s390 stubs]
[avi: ditto for ia64]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
KVM: ia64: provide get/set_mp_state stubs to fix compile error
Since
commit ded6fb24fb694bcc5f308a02ec504d45fbc8aaa6
Author: Marcelo Tosatti <mtosatti@redhat.com>
Date: Fri Apr 11 13:24:45 2008 -0300
KVM: add ioctls to save/store mpstate
kvm does not compile on ia64.
This patch provides ioctl stubs for ia64 to make kvm.git compile again.
Signed-off-by: Avi Kivity <avi@qumranet.com>
---
arch/ia64/kvm/kvm-ia64.c | 12 ++++++++++++
arch/s390/kvm/kvm-s390.c | 12 ++++++++++++
arch/x86/kvm/x86.c | 19 +++++++++++++++++++
include/asm-x86/kvm_host.h | 5 -----
include/linux/kvm.h | 15 +++++++++++++++
include/linux/kvm_host.h | 4 ++++
virt/kvm/kvm_main.c | 24 ++++++++++++++++++++++++
7 files changed, 86 insertions(+), 5 deletions(-)
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index f7589db..6df0732 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1792,3 +1792,15 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
{
return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE;
}
+
+int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
+ struct kvm_mp_state *mp_state)
+{
+ return -EINVAL;
+}
+
+int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
+ struct kvm_mp_state *mp_state)
+{
+ return -EINVAL;
+}
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index d966137..98d1e73 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -414,6 +414,18 @@ int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
return -EINVAL; /* not implemented yet */
}
+int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
+ struct kvm_mp_state *mp_state)
+{
+ return -EINVAL; /* not implemented yet */
+}
+
+int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
+ struct kvm_mp_state *mp_state)
+{
+ return -EINVAL; /* not implemented yet */
+}
+
static void __vcpu_run(struct kvm_vcpu *vcpu)
{
memcpy(&vcpu->arch.sie_block->gg14, &vcpu->arch.guest_gprs[14], 16);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b364d19..5c3c9d3 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -817,6 +817,7 @@ int kvm_dev_ioctl_check_extension(long ext)
case KVM_CAP_CLOCKSOURCE:
case KVM_CAP_PIT:
case KVM_CAP_NOP_IO_DELAY:
+ case KVM_CAP_MP_STATE:
r = 1;
break;
case KVM_CAP_VAPIC:
@@ -3083,6 +3084,24 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
return 0;
}
+int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
+ struct kvm_mp_state *mp_state)
+{
+ vcpu_load(vcpu);
+ mp_state->mp_state = vcpu->arch.mp_state;
+ vcpu_put(vcpu);
+ return 0;
+}
+
+int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
+ struct kvm_mp_state *mp_state)
+{
+ vcpu_load(vcpu);
+ vcpu->arch.mp_state = mp_state->mp_state;
+ vcpu_put(vcpu);
+ return 0;
+}
+
static void set_segment(struct kvm_vcpu *vcpu,
struct kvm_segment *var, int seg)
{
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index f35a6ad..9d963cd 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -227,11 +227,6 @@ struct kvm_vcpu_arch {
u64 shadow_efer;
u64 apic_base;
struct kvm_lapic *apic; /* kernel irqchip context */
-#define KVM_MP_STATE_RUNNABLE 0
-#define KVM_MP_STATE_UNINITIALIZED 1
-#define KVM_MP_STATE_INIT_RECEIVED 2
-#define KVM_MP_STATE_SIPI_RECEIVED 3
-#define KVM_MP_STATE_HALTED 4
int mp_state;
int sipi_vector;
u64 ia32_misc_enable_msr;
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index d302d63..f8e211d 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -228,6 +228,18 @@ struct kvm_vapic_addr {
__u64 vapic_addr;
};
+/* for KVM_SET_MPSTATE */
+
+#define KVM_MP_STATE_RUNNABLE 0
+#define KVM_MP_STATE_UNINITIALIZED 1
+#define KVM_MP_STATE_INIT_RECEIVED 2
+#define KVM_MP_STATE_HALTED 3
+#define KVM_MP_STATE_SIPI_RECEIVED 4
+
+struct kvm_mp_state {
+ __u32 mp_state;
+};
+
struct kvm_s390_psw {
__u64 mask;
__u64 addr;
@@ -326,6 +338,7 @@ struct kvm_trace_rec {
#define KVM_CAP_PIT 11
#define KVM_CAP_NOP_IO_DELAY 12
#define KVM_CAP_PV_MMU 13
+#define KVM_CAP_MP_STATE 14
/*
* ioctls for VM fds
@@ -387,5 +400,7 @@ struct kvm_trace_rec {
#define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw)
/* initial reset for s390 */
#define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97)
+#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state)
+#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state)
#endif
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 0bc4003..81d4c33 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -237,6 +237,10 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
struct kvm_sregs *sregs);
int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
struct kvm_sregs *sregs);
+int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
+ struct kvm_mp_state *mp_state);
+int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
+ struct kvm_mp_state *mp_state);
int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
struct kvm_debug_guest *dbg);
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 47cbc6e..0998455 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -979,6 +979,30 @@ out_free2:
r = 0;
break;
}
+ case KVM_GET_MP_STATE: {
+ struct kvm_mp_state mp_state;
+
+ r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state);
+ if (r)
+ goto out;
+ r = -EFAULT;
+ if (copy_to_user(argp, &mp_state, sizeof mp_state))
+ goto out;
+ r = 0;
+ break;
+ }
+ case KVM_SET_MP_STATE: {
+ struct kvm_mp_state mp_state;
+
+ r = -EFAULT;
+ if (copy_from_user(&mp_state, argp, sizeof mp_state))
+ goto out;
+ r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, &mp_state);
+ if (r)
+ goto out;
+ r = 0;
+ break;
+ }
case KVM_TRANSLATE: {
struct kvm_translation tr;
--
1.5.5
next prev parent reply other threads:[~2008-04-21 10:35 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-21 10:29 [PATCH 00/31] KVM updates for the 2.6.26 merge window (part IV, last) Avi Kivity
2008-04-21 10:29 ` [PATCH 01/31] KVM: MMU: Don't assume struct page for x86 Avi Kivity
2008-04-21 10:29 ` [PATCH 02/31] KVM: Register ioctl range Avi Kivity
2008-04-21 10:29 ` [PATCH 03/31] KVM: SVM: indent svm_set_cr4 with tabs instead of spaces Avi Kivity
2008-04-21 10:29 ` [PATCH 04/31] KVM: SVM: align shadow CR4.MCE with host Avi Kivity
2008-04-21 10:29 ` [PATCH 05/31] KVM: SVM: add intercept for machine check exception Avi Kivity
2008-04-21 10:29 ` [PATCH 06/31] KVM: Add trace markers Avi Kivity
2008-04-21 10:29 ` [PATCH 07/31] KVM: s390: Stub out kvmtrace Avi Kivity
2008-04-21 10:29 ` [PATCH 08/31] KVM: ia64: " Avi Kivity
2008-04-21 10:29 ` [PATCH 09/31] KVM: Add kvm trace userspace interface Avi Kivity
2008-04-21 10:29 ` [PATCH 10/31] KVM: SVM: do not intercept task switch with NPT Avi Kivity
2008-04-21 10:29 ` [PATCH 11/31] KVM: hlt emulation should take in-kernel APIC/PIT timers into account Avi Kivity
2008-04-21 10:29 ` [PATCH 12/31] KVM: Rename VCPU_MP_STATE_* to KVM_MP_STATE_* Avi Kivity
2008-04-21 10:29 ` Avi Kivity [this message]
2008-04-21 10:29 ` [PATCH 14/31] KVM: fix kvm_vcpu_kick vs __vcpu_run race Avi Kivity
2008-04-21 10:29 ` [PATCH 15/31] KVM: SVM: force a new asid when initializing the vmcb Avi Kivity
2008-04-21 10:29 ` [PATCH 16/31] KVM: x86 emulator: initialize src.val and dst.val for register operands Avi Kivity
2008-04-21 10:29 ` [PATCH 17/31] KVM: x86 emulator: fix smsw and lmsw with a memory operand Avi Kivity
2008-04-21 10:29 ` [PATCH 18/31] KVM: x86 emulator: fix lea to really get the effective address Avi Kivity
2008-04-21 10:29 ` [PATCH 19/31] KVM: Rename debugfs_dir to kvm_debugfs_dir Avi Kivity
2008-04-21 10:29 ` [PATCH 20/31] ppc: Export tlb_44x_hwater for KVM Avi Kivity
2008-04-21 10:29 ` [PATCH 21/31] KVM: ppc: Add DCR access information to struct kvm_run Avi Kivity
2008-04-21 10:29 ` [PATCH 22/31] KVM: Add MAINTAINERS entry for PowerPC KVM Avi Kivity
2008-04-21 10:29 ` [PATCH 23/31] KVM: ppc: PowerPC 440 KVM implementation Avi Kivity
2008-04-21 10:29 ` [PATCH 24/31] KVM: SVM: sync TPR value to V_TPR field in the VMCB Avi Kivity
2008-04-21 10:29 ` [PATCH 25/31] KVM: export kvm_lapic_set_tpr() to modules Avi Kivity
2008-04-21 10:29 ` [PATCH 26/31] KVM: SVM: sync V_TPR with LAPIC.TPR if CR8 write intercept is disabled Avi Kivity
2008-04-21 10:29 ` [PATCH 27/31] KVM: SVM: disable CR8 intercept when tpr is not masking interrupts Avi Kivity
2008-04-21 10:29 ` [PATCH 28/31] KVM: SVM: remove now obsolete FIXME comment Avi Kivity
2008-04-21 10:29 ` [PATCH 29/31] KVM: SVM: remove selective CR0 comment Avi Kivity
2008-04-21 10:29 ` [PATCH 30/31] KVM: ppc: Kconfig fixes Avi Kivity
2008-04-21 10:29 ` [PATCH 31/31] KVM: MMU: kvm_pv_mmu_op should not take mmap_sem 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=1208773797-7829-14-git-send-email-avi@qumranet.com \
--to=avi@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®