diff options
-rw-r--r-- | arch/ia64/kvm/kvm-ia64.c | 12 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 12 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 19 | ||||
-rw-r--r-- | include/asm-x86/kvm_host.h | 5 | ||||
-rw-r--r-- | include/linux/kvm.h | 15 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 4 | ||||
-rw-r--r-- | 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 f7589dba75ab..6df073240135 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) | |||
1792 | { | 1792 | { |
1793 | return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE; | 1793 | return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE; |
1794 | } | 1794 | } |
1795 | |||
1796 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, | ||
1797 | struct kvm_mp_state *mp_state) | ||
1798 | { | ||
1799 | return -EINVAL; | ||
1800 | } | ||
1801 | |||
1802 | int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, | ||
1803 | struct kvm_mp_state *mp_state) | ||
1804 | { | ||
1805 | return -EINVAL; | ||
1806 | } | ||
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index d96613765973..98d1e73e01f1 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, | |||
414 | return -EINVAL; /* not implemented yet */ | 414 | return -EINVAL; /* not implemented yet */ |
415 | } | 415 | } |
416 | 416 | ||
417 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, | ||
418 | struct kvm_mp_state *mp_state) | ||
419 | { | ||
420 | return -EINVAL; /* not implemented yet */ | ||
421 | } | ||
422 | |||
423 | int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, | ||
424 | struct kvm_mp_state *mp_state) | ||
425 | { | ||
426 | return -EINVAL; /* not implemented yet */ | ||
427 | } | ||
428 | |||
417 | static void __vcpu_run(struct kvm_vcpu *vcpu) | 429 | static void __vcpu_run(struct kvm_vcpu *vcpu) |
418 | { | 430 | { |
419 | memcpy(&vcpu->arch.sie_block->gg14, &vcpu->arch.guest_gprs[14], 16); | 431 | 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 b364d192896c..5c3c9d38c780 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) | |||
817 | case KVM_CAP_CLOCKSOURCE: | 817 | case KVM_CAP_CLOCKSOURCE: |
818 | case KVM_CAP_PIT: | 818 | case KVM_CAP_PIT: |
819 | case KVM_CAP_NOP_IO_DELAY: | 819 | case KVM_CAP_NOP_IO_DELAY: |
820 | case KVM_CAP_MP_STATE: | ||
820 | r = 1; | 821 | r = 1; |
821 | break; | 822 | break; |
822 | case KVM_CAP_VAPIC: | 823 | case KVM_CAP_VAPIC: |
@@ -3083,6 +3084,24 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, | |||
3083 | return 0; | 3084 | return 0; |
3084 | } | 3085 | } |
3085 | 3086 | ||
3087 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, | ||
3088 | struct kvm_mp_state *mp_state) | ||
3089 | { | ||
3090 | vcpu_load(vcpu); | ||
3091 | mp_state->mp_state = vcpu->arch.mp_state; | ||
3092 | vcpu_put(vcpu); | ||
3093 | return 0; | ||
3094 | } | ||
3095 | |||
3096 | int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, | ||
3097 | struct kvm_mp_state *mp_state) | ||
3098 | { | ||
3099 | vcpu_load(vcpu); | ||
3100 | vcpu->arch.mp_state = mp_state->mp_state; | ||
3101 | vcpu_put(vcpu); | ||
3102 | return 0; | ||
3103 | } | ||
3104 | |||
3086 | static void set_segment(struct kvm_vcpu *vcpu, | 3105 | static void set_segment(struct kvm_vcpu *vcpu, |
3087 | struct kvm_segment *var, int seg) | 3106 | struct kvm_segment *var, int seg) |
3088 | { | 3107 | { |
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h index f35a6ad43c0a..9d963cd6533c 100644 --- a/include/asm-x86/kvm_host.h +++ b/include/asm-x86/kvm_host.h | |||
@@ -227,11 +227,6 @@ struct kvm_vcpu_arch { | |||
227 | u64 shadow_efer; | 227 | u64 shadow_efer; |
228 | u64 apic_base; | 228 | u64 apic_base; |
229 | struct kvm_lapic *apic; /* kernel irqchip context */ | 229 | struct kvm_lapic *apic; /* kernel irqchip context */ |
230 | #define KVM_MP_STATE_RUNNABLE 0 | ||
231 | #define KVM_MP_STATE_UNINITIALIZED 1 | ||
232 | #define KVM_MP_STATE_INIT_RECEIVED 2 | ||
233 | #define KVM_MP_STATE_SIPI_RECEIVED 3 | ||
234 | #define KVM_MP_STATE_HALTED 4 | ||
235 | int mp_state; | 230 | int mp_state; |
236 | int sipi_vector; | 231 | int sipi_vector; |
237 | u64 ia32_misc_enable_msr; | 232 | u64 ia32_misc_enable_msr; |
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index d302d63517e4..f8e211d8ce88 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -228,6 +228,18 @@ struct kvm_vapic_addr { | |||
228 | __u64 vapic_addr; | 228 | __u64 vapic_addr; |
229 | }; | 229 | }; |
230 | 230 | ||
231 | /* for KVM_SET_MPSTATE */ | ||
232 | |||
233 | #define KVM_MP_STATE_RUNNABLE 0 | ||
234 | #define KVM_MP_STATE_UNINITIALIZED 1 | ||
235 | #define KVM_MP_STATE_INIT_RECEIVED 2 | ||
236 | #define KVM_MP_STATE_HALTED 3 | ||
237 | #define KVM_MP_STATE_SIPI_RECEIVED 4 | ||
238 | |||
239 | struct kvm_mp_state { | ||
240 | __u32 mp_state; | ||
241 | }; | ||
242 | |||
231 | struct kvm_s390_psw { | 243 | struct kvm_s390_psw { |
232 | __u64 mask; | 244 | __u64 mask; |
233 | __u64 addr; | 245 | __u64 addr; |
@@ -326,6 +338,7 @@ struct kvm_trace_rec { | |||
326 | #define KVM_CAP_PIT 11 | 338 | #define KVM_CAP_PIT 11 |
327 | #define KVM_CAP_NOP_IO_DELAY 12 | 339 | #define KVM_CAP_NOP_IO_DELAY 12 |
328 | #define KVM_CAP_PV_MMU 13 | 340 | #define KVM_CAP_PV_MMU 13 |
341 | #define KVM_CAP_MP_STATE 14 | ||
329 | 342 | ||
330 | /* | 343 | /* |
331 | * ioctls for VM fds | 344 | * ioctls for VM fds |
@@ -387,5 +400,7 @@ struct kvm_trace_rec { | |||
387 | #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) | 400 | #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) |
388 | /* initial reset for s390 */ | 401 | /* initial reset for s390 */ |
389 | #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) | 402 | #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) |
403 | #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) | ||
404 | #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) | ||
390 | 405 | ||
391 | #endif | 406 | #endif |
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 0bc400387cae..81d4c3305a28 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, | |||
237 | struct kvm_sregs *sregs); | 237 | struct kvm_sregs *sregs); |
238 | int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | 238 | int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, |
239 | struct kvm_sregs *sregs); | 239 | struct kvm_sregs *sregs); |
240 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, | ||
241 | struct kvm_mp_state *mp_state); | ||
242 | int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, | ||
243 | struct kvm_mp_state *mp_state); | ||
240 | int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, | 244 | int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, |
241 | struct kvm_debug_guest *dbg); | 245 | struct kvm_debug_guest *dbg); |
242 | int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); | 246 | 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 47cbc6e3fafd..099845574901 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -979,6 +979,30 @@ out_free2: | |||
979 | r = 0; | 979 | r = 0; |
980 | break; | 980 | break; |
981 | } | 981 | } |
982 | case KVM_GET_MP_STATE: { | ||
983 | struct kvm_mp_state mp_state; | ||
984 | |||
985 | r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state); | ||
986 | if (r) | ||
987 | goto out; | ||
988 | r = -EFAULT; | ||
989 | if (copy_to_user(argp, &mp_state, sizeof mp_state)) | ||
990 | goto out; | ||
991 | r = 0; | ||
992 | break; | ||
993 | } | ||
994 | case KVM_SET_MP_STATE: { | ||
995 | struct kvm_mp_state mp_state; | ||
996 | |||
997 | r = -EFAULT; | ||
998 | if (copy_from_user(&mp_state, argp, sizeof mp_state)) | ||
999 | goto out; | ||
1000 | r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, &mp_state); | ||
1001 | if (r) | ||
1002 | goto out; | ||
1003 | r = 0; | ||
1004 | break; | ||
1005 | } | ||
982 | case KVM_TRANSLATE: { | 1006 | case KVM_TRANSLATE: { |
983 | struct kvm_translation tr; | 1007 | struct kvm_translation tr; |
984 | 1008 | ||