Skip to content

Commit 7816e58

Browse files
schlacfrankjaa
authored andcommitted
kvm: s390: Reject memory region operations for ucontrol VMs
This change rejects the KVM_SET_USER_MEMORY_REGION and KVM_SET_USER_MEMORY_REGION2 ioctls when called on a ucontrol VM. This is necessary since ucontrol VMs have kvm->arch.gmap set to 0 and would thus result in a null pointer dereference further in. Memory management needs to be performed in userspace and using the ioctls KVM_S390_UCAS_MAP and KVM_S390_UCAS_UNMAP. Also improve s390 specific documentation for KVM_SET_USER_MEMORY_REGION and KVM_SET_USER_MEMORY_REGION2. Signed-off-by: Christoph Schlameuss <[email protected]> Fixes: 27e0393 ("KVM: s390: ucontrol: per vcpu address spaces") Reviewed-by: Claudio Imbrenda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Janosch Frank <[email protected]> [[email protected]: commit message spelling fix, subject prefix fix] Message-ID: <[email protected]>
1 parent 33a729a commit 7816e58

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,12 @@ Instead, an abort (data abort if the cause of the page-table update
14031403
was a load or a store, instruction abort if it was an instruction
14041404
fetch) is injected in the guest.
14051405

1406+
S390:
1407+
^^^^^
1408+
1409+
Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set.
1410+
Returns -EINVAL if called on a protected VM.
1411+
14061412
4.36 KVM_SET_TSS_ADDR
14071413
---------------------
14081414

@@ -6273,6 +6279,12 @@ state. At VM creation time, all memory is shared, i.e. the PRIVATE attribute
62736279
is '0' for all gfns. Userspace can control whether memory is shared/private by
62746280
toggling KVM_MEMORY_ATTRIBUTE_PRIVATE via KVM_SET_MEMORY_ATTRIBUTES as needed.
62756281

6282+
S390:
6283+
^^^^^
6284+
6285+
Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set.
6286+
Returns -EINVAL if called on a protected VM.
6287+
62766288
4.141 KVM_SET_MEMORY_ATTRIBUTES
62776289
-------------------------------
62786290

arch/s390/kvm/kvm-s390.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5748,6 +5748,9 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
57485748
{
57495749
gpa_t size;
57505750

5751+
if (kvm_is_ucontrol(kvm))
5752+
return -EINVAL;
5753+
57515754
/* When we are protected, we should not change the memory slots */
57525755
if (kvm_s390_pv_get_handle(kvm))
57535756
return -EINVAL;

0 commit comments

Comments
 (0)