]> Git Repo - linux.git/commitdiff
kvm: s390: Reject memory region operations for ucontrol VMs
authorChristoph Schlameuss <[email protected]>
Mon, 24 Jun 2024 09:59:02 +0000 (11:59 +0200)
committerJanosch Frank <[email protected]>
Thu, 4 Jul 2024 07:07:24 +0000 (09:07 +0200)
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: 27e0393f15fc ("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: <20240624095902[email protected]>

Documentation/virt/kvm/api.rst
arch/s390/kvm/kvm-s390.c

index a71d91978d9ef51ef914f82083c4db63fcdd0c02..eec8df1dde06aa33d58dbb7d99946fb17da378a2 100644 (file)
@@ -1403,6 +1403,12 @@ Instead, an abort (data abort if the cause of the page-table update
 was a load or a store, instruction abort if it was an instruction
 fetch) is injected in the guest.
 
+S390:
+^^^^^
+
+Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set.
+Returns -EINVAL if called on a protected VM.
+
 4.36 KVM_SET_TSS_ADDR
 ---------------------
 
@@ -6273,6 +6279,12 @@ state.  At VM creation time, all memory is shared, i.e. the PRIVATE attribute
 is '0' for all gfns.  Userspace can control whether memory is shared/private by
 toggling KVM_MEMORY_ATTRIBUTE_PRIVATE via KVM_SET_MEMORY_ATTRIBUTES as needed.
 
+S390:
+^^^^^
+
+Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set.
+Returns -EINVAL if called on a protected VM.
+
 4.141 KVM_SET_MEMORY_ATTRIBUTES
 -------------------------------
 
index 82e9631cd9efb86defd13e029f0a737726ba853b..854d0d1410be9d1e1665ffcce718f2c99a546122 100644 (file)
@@ -5748,6 +5748,9 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
 {
        gpa_t size;
 
+       if (kvm_is_ucontrol(kvm))
+               return -EINVAL;
+
        /* When we are protected, we should not change the memory slots */
        if (kvm_s390_pv_get_handle(kvm))
                return -EINVAL;
This page took 0.087793 seconds and 4 git commands to generate.