Skip to content

Commit f7a960a

Browse files
committed
KVM: s390/cmm: Fix prefix handling for diag 10 balloon
The old handling of prefix pages was broken in the diag10 ballooner. We now rely on gmap_discard to check for start > end and do a slow path if the prefix swap pages are affected: 1. discard the pages from start to prefix 2. discard the absolute 0 pages 3. discard the pages after prefix swap to end Signed-off-by: Christian Borntraeger <[email protected]> Reviewed-by: Thomas Huth <[email protected]>
1 parent 6b33195 commit f7a960a

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

arch/s390/kvm/diag.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,32 @@ static int diag_release_pages(struct kvm_vcpu *vcpu)
2828
start = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4];
2929
end = vcpu->run->s.regs.gprs[vcpu->arch.sie_block->ipa & 0xf] + 4096;
3030

31-
if (start & ~PAGE_MASK || end & ~PAGE_MASK || start > end
31+
if (start & ~PAGE_MASK || end & ~PAGE_MASK || start >= end
3232
|| start < 2 * PAGE_SIZE)
3333
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
3434

3535
VCPU_EVENT(vcpu, 5, "diag release pages %lX %lX", start, end);
3636
vcpu->stat.diagnose_10++;
3737

38-
/* we checked for start > end above */
39-
if (end < prefix || start >= prefix + 2 * PAGE_SIZE) {
38+
/*
39+
* We checked for start >= end above, so lets check for the
40+
* fast path (no prefix swap page involved)
41+
*/
42+
if (end <= prefix || start >= prefix + 2 * PAGE_SIZE) {
4043
gmap_discard(vcpu->arch.gmap, start, end);
4144
} else {
42-
if (start < prefix)
43-
gmap_discard(vcpu->arch.gmap, start, prefix);
44-
if (end >= prefix)
45-
gmap_discard(vcpu->arch.gmap,
46-
prefix + 2 * PAGE_SIZE, end);
45+
/*
46+
* This is slow path. gmap_discard will check for start
47+
* so lets split this into before prefix, prefix, after
48+
* prefix and let gmap_discard make some of these calls
49+
* NOPs.
50+
*/
51+
gmap_discard(vcpu->arch.gmap, start, prefix);
52+
if (start <= prefix)
53+
gmap_discard(vcpu->arch.gmap, 0, 4096);
54+
if (end > prefix + 4096)
55+
gmap_discard(vcpu->arch.gmap, 4096, 8192);
56+
gmap_discard(vcpu->arch.gmap, prefix + 2 * PAGE_SIZE, end);
4757
}
4858
return 0;
4959
}

0 commit comments

Comments
 (0)