diff options
author | Carsten Otte <cotte@de.ibm.com> | 2012-01-04 04:25:20 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-03-05 07:52:18 -0500 |
commit | e08b96371625aaa84cb03f51acc4c8e0be27403a (patch) | |
tree | d0b140e8558c6145e1a3183809c7797be443bd68 /arch/s390 | |
parent | a138fe7535c0ec778465c7b54b1aaaf4cfd885b7 (diff) |
KVM: s390: add parameter for KVM_CREATE_VM
This patch introduces a new config option for user controlled kernel
virtual machines. It introduces a parameter to KVM_CREATE_VM that
allows to set bits that alter the capabilities of the newly created
virtual machine.
The parameter is passed to kvm_arch_init_vm for all architectures.
The only valid modifier bit for now is KVM_VM_S390_UCONTROL.
This requires CAP_SYS_ADMIN privileges and creates a user controlled
virtual machine on s390 architectures.
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/kvm/Kconfig | 9 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 24 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.h | 10 |
3 files changed, 38 insertions, 5 deletions
diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig index a21634173a66..78eb9847008f 100644 --- a/arch/s390/kvm/Kconfig +++ b/arch/s390/kvm/Kconfig | |||
@@ -34,6 +34,15 @@ config KVM | |||
34 | 34 | ||
35 | If unsure, say N. | 35 | If unsure, say N. |
36 | 36 | ||
37 | config KVM_S390_UCONTROL | ||
38 | bool "Userspace controlled virtual machines" | ||
39 | depends on KVM | ||
40 | ---help--- | ||
41 | Allow CAP_SYS_ADMIN users to create KVM virtual machines that are | ||
42 | controlled by userspace. | ||
43 | |||
44 | If unsure, say N. | ||
45 | |||
37 | # OK, it's a little counter-intuitive to do this, but it puts it neatly under | 46 | # OK, it's a little counter-intuitive to do this, but it puts it neatly under |
38 | # the virtualization menu. | 47 | # the virtualization menu. |
39 | source drivers/vhost/Kconfig | 48 | source drivers/vhost/Kconfig |
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index d1c445732451..f0937552175b 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -171,11 +171,22 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
171 | return r; | 171 | return r; |
172 | } | 172 | } |
173 | 173 | ||
174 | int kvm_arch_init_vm(struct kvm *kvm) | 174 | int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) |
175 | { | 175 | { |
176 | int rc; | 176 | int rc; |
177 | char debug_name[16]; | 177 | char debug_name[16]; |
178 | 178 | ||
179 | rc = -EINVAL; | ||
180 | #ifdef CONFIG_KVM_S390_UCONTROL | ||
181 | if (type & ~KVM_VM_S390_UCONTROL) | ||
182 | goto out_err; | ||
183 | if ((type & KVM_VM_S390_UCONTROL) && (!capable(CAP_SYS_ADMIN))) | ||
184 | goto out_err; | ||
185 | #else | ||
186 | if (type) | ||
187 | goto out_err; | ||
188 | #endif | ||
189 | |||
179 | rc = s390_enable_sie(); | 190 | rc = s390_enable_sie(); |
180 | if (rc) | 191 | if (rc) |
181 | goto out_err; | 192 | goto out_err; |
@@ -198,10 +209,13 @@ int kvm_arch_init_vm(struct kvm *kvm) | |||
198 | debug_register_view(kvm->arch.dbf, &debug_sprintf_view); | 209 | debug_register_view(kvm->arch.dbf, &debug_sprintf_view); |
199 | VM_EVENT(kvm, 3, "%s", "vm created"); | 210 | VM_EVENT(kvm, 3, "%s", "vm created"); |
200 | 211 | ||
201 | kvm->arch.gmap = gmap_alloc(current->mm); | 212 | if (type & KVM_VM_S390_UCONTROL) { |
202 | if (!kvm->arch.gmap) | 213 | kvm->arch.gmap = NULL; |
203 | goto out_nogmap; | 214 | } else { |
204 | 215 | kvm->arch.gmap = gmap_alloc(current->mm); | |
216 | if (!kvm->arch.gmap) | ||
217 | goto out_nogmap; | ||
218 | } | ||
205 | return 0; | 219 | return 0; |
206 | out_nogmap: | 220 | out_nogmap: |
207 | debug_unregister(kvm->arch.dbf); | 221 | debug_unregister(kvm->arch.dbf); |
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 99b0b7597115..45b236a7c730 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h | |||
@@ -47,6 +47,16 @@ static inline int __cpu_is_stopped(struct kvm_vcpu *vcpu) | |||
47 | return atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_STOP_INT; | 47 | return atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_STOP_INT; |
48 | } | 48 | } |
49 | 49 | ||
50 | static inline int kvm_is_ucontrol(struct kvm *kvm) | ||
51 | { | ||
52 | #ifdef CONFIG_KVM_S390_UCONTROL | ||
53 | if (kvm->arch.gmap) | ||
54 | return 0; | ||
55 | return 1; | ||
56 | #else | ||
57 | return 0; | ||
58 | #endif | ||
59 | } | ||
50 | int kvm_s390_handle_wait(struct kvm_vcpu *vcpu); | 60 | int kvm_s390_handle_wait(struct kvm_vcpu *vcpu); |
51 | enum hrtimer_restart kvm_s390_idle_wakeup(struct hrtimer *timer); | 61 | enum hrtimer_restart kvm_s390_idle_wakeup(struct hrtimer *timer); |
52 | void kvm_s390_tasklet(unsigned long parm); | 62 | void kvm_s390_tasklet(unsigned long parm); |