aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanosch Frank <frankja@linux.ibm.com>2018-08-30 10:14:18 -0400
committerChristian Borntraeger <borntraeger@de.ibm.com>2018-09-04 05:40:26 -0400
commitdf88f3181f10565c6e3a89eb6f0f9e6afaaf15f1 (patch)
tree5ecdb676fe4a0bc80ffca99703385a239b107c75
parent204c97245612b6c255edf4e21e24d417c4a0c008 (diff)
KVM: s390: Properly lock mm context allow_gmap_hpage_1m setting
We have to do down_write on the mm semaphore to set a bitfield in the mm context. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Fixes: a4499382 ("KVM: s390: Add huge page enablement control") Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
-rw-r--r--arch/s390/include/asm/mmu.h8
-rw-r--r--arch/s390/kvm/kvm-s390.c2
2 files changed, 9 insertions, 1 deletions
diff --git a/arch/s390/include/asm/mmu.h b/arch/s390/include/asm/mmu.h
index f31a15044c24..a8418e1379eb 100644
--- a/arch/s390/include/asm/mmu.h
+++ b/arch/s390/include/asm/mmu.h
@@ -16,7 +16,13 @@ typedef struct {
16 unsigned long asce; 16 unsigned long asce;
17 unsigned long asce_limit; 17 unsigned long asce_limit;
18 unsigned long vdso_base; 18 unsigned long vdso_base;
19 /* The mmu context allocates 4K page tables. */ 19 /*
20 * The following bitfields need a down_write on the mm
21 * semaphore when they are written to. As they are only
22 * written once, they can be read without a lock.
23 *
24 * The mmu context allocates 4K page tables.
25 */
20 unsigned int alloc_pgste:1; 26 unsigned int alloc_pgste:1;
21 /* The mmu context uses extended page tables. */ 27 /* The mmu context uses extended page tables. */
22 unsigned int has_pgste:1; 28 unsigned int has_pgste:1;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 91ad4a9425c0..f69333fd2fa3 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -695,7 +695,9 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
695 r = -EINVAL; 695 r = -EINVAL;
696 else { 696 else {
697 r = 0; 697 r = 0;
698 down_write(&kvm->mm->mmap_sem);
698 kvm->mm->context.allow_gmap_hpage_1m = 1; 699 kvm->mm->context.allow_gmap_hpage_1m = 1;
700 up_write(&kvm->mm->mmap_sem);
699 /* 701 /*
700 * We might have to create fake 4k page 702 * We might have to create fake 4k page
701 * tables. To avoid that the hardware works on 703 * tables. To avoid that the hardware works on