Skip to content

Commit df88f31

Browse files
frankjaaborntraeger
authored andcommitted
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: a449938 ("KVM: s390: Add huge page enablement control") Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
1 parent 204c972 commit df88f31

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

arch/s390/include/asm/mmu.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ typedef struct {
1616
unsigned long asce;
1717
unsigned long asce_limit;
1818
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+
*/
2026
unsigned int alloc_pgste:1;
2127
/* The mmu context uses extended page tables. */
2228
unsigned int has_pgste:1;

arch/s390/kvm/kvm-s390.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,9 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
695695
r = -EINVAL;
696696
else {
697697
r = 0;
698+
down_write(&kvm->mm->mmap_sem);
698699
kvm->mm->context.allow_gmap_hpage_1m = 1;
700+
up_write(&kvm->mm->mmap_sem);
699701
/*
700702
* We might have to create fake 4k page
701703
* tables. To avoid that the hardware works on

0 commit comments

Comments
 (0)