Blob Blame History Raw
From: Janosch Frank <frankja@linux.ibm.com>
Subject: KVM: s390: Make huge pages unavailable in ucontrol VMs
Patch-mainline: v4.19-rc5
Git-commit: 40ebdb8e59df36e2cc71810bd021a0808b16c956
References: FATE#326372, LTC#169184, bsc#1113484

Summary:     kernel: Introduce huge page KVM backing support
Description: This adds the KVM support for libhugetlbfs backings of
             s390 KVM guests.

Upstream-Description:

             KVM: s390: Make huge pages unavailable in ucontrol VMs

             We currently do not notify all gmaps when using gmap_pmdp_xchg(), due
             to locking constraints. This makes ucontrol VMs, which is the only VM
             type that creates multiple gmaps, incompatible with huge pages. Also
             we would need to hold the guest_table_lock of all gmaps that have this
             vmaddr maped to synchronize access to the pmd.

             ucontrol VMs are rather exotic and creating a new locking concept is
             no easy task. Hence we return EINVAL when trying to active
             KVM_CAP_S390_HPAGE_1M and report it as being not available when
             checking for it.

             Fixes: a4499382 ("KVM: s390: Add huge page enablement control")
             Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
             Reviewed-by: David Hildenbrand <david@redhat.com>
             Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
             Message-Id: <20180801112508.138159-1-frankja@linux.ibm.com>
             Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 Documentation/virtual/kvm/api.txt |    3 ++-
 arch/s390/kvm/kvm-s390.c          |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -4270,7 +4270,8 @@ branch to guests' 0x200 interrupt vector
 Architectures: s390
 Parameters: none
 Returns: 0 on success, -EINVAL if hpage module parameter was not set
-	 or cmma is enabled
+	 or cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL
+	 flag set
 
 With this capability the KVM support for memory backing with 1m pages
 through hugetlbfs can be enabled for a VM. After the capability is
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -460,7 +460,7 @@ int kvm_vm_ioctl_check_extension(struct
 		break;
 	case KVM_CAP_S390_HPAGE_1M:
 		r = 0;
-		if (hpage)
+		if (hpage && !kvm_is_ucontrol(kvm))
 			r = 1;
 		break;
 	case KVM_CAP_S390_MEM_OP:
@@ -670,7 +670,7 @@ static int kvm_vm_ioctl_enable_cap(struc
 		mutex_lock(&kvm->lock);
 		if (kvm->created_vcpus)
 			r = -EBUSY;
-		else if (!hpage || kvm->arch.use_cmma)
+		else if (!hpage || kvm->arch.use_cmma || kvm_is_ucontrol(kvm))
 			r = -EINVAL;
 		else {
 			r = 0;