diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2011-10-30 10:17:03 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2011-10-30 10:16:45 -0400 |
commit | 388186bc920d9200202e4d25de66fa95b1b8fc68 (patch) | |
tree | c7e1bc3231a50a91d298a8da59e8fefe2935d6da /arch/s390/kvm | |
parent | 499069e1a421e2a85e76846c3237f00f1a5cb435 (diff) |
[S390] kvm: Handle diagnose 0x10 (release pages)
Linux on System z uses a ballooner based on diagnose 0x10. (aka as
collaborative memory management). This patch implements diagnose
0x10 on the guest address space.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kvm')
-rw-r--r-- | arch/s390/kvm/diag.c | 32 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 1 |
2 files changed, 32 insertions, 1 deletions
diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c index 9e4c84187cf5..87cedd61be04 100644 --- a/arch/s390/kvm/diag.c +++ b/arch/s390/kvm/diag.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * diag.c - handling diagnose instructions | 2 | * diag.c - handling diagnose instructions |
3 | * | 3 | * |
4 | * Copyright IBM Corp. 2008 | 4 | * Copyright IBM Corp. 2008,2011 |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License (version 2 only) | 7 | * it under the terms of the GNU General Public License (version 2 only) |
@@ -15,6 +15,34 @@ | |||
15 | #include <linux/kvm_host.h> | 15 | #include <linux/kvm_host.h> |
16 | #include "kvm-s390.h" | 16 | #include "kvm-s390.h" |
17 | 17 | ||
18 | static int diag_release_pages(struct kvm_vcpu *vcpu) | ||
19 | { | ||
20 | unsigned long start, end; | ||
21 | unsigned long prefix = vcpu->arch.sie_block->prefix; | ||
22 | |||
23 | start = vcpu->arch.guest_gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4]; | ||
24 | end = vcpu->arch.guest_gprs[vcpu->arch.sie_block->ipa & 0xf] + 4096; | ||
25 | |||
26 | if (start & ~PAGE_MASK || end & ~PAGE_MASK || start > end | ||
27 | || start < 2 * PAGE_SIZE) | ||
28 | return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); | ||
29 | |||
30 | VCPU_EVENT(vcpu, 5, "diag release pages %lX %lX", start, end); | ||
31 | vcpu->stat.diagnose_10++; | ||
32 | |||
33 | /* we checked for start > end above */ | ||
34 | if (end < prefix || start >= prefix + 2 * PAGE_SIZE) { | ||
35 | gmap_discard(start, end, vcpu->arch.gmap); | ||
36 | } else { | ||
37 | if (start < prefix) | ||
38 | gmap_discard(start, prefix, vcpu->arch.gmap); | ||
39 | if (end >= prefix) | ||
40 | gmap_discard(prefix + 2 * PAGE_SIZE, | ||
41 | end, vcpu->arch.gmap); | ||
42 | } | ||
43 | return 0; | ||
44 | } | ||
45 | |||
18 | static int __diag_time_slice_end(struct kvm_vcpu *vcpu) | 46 | static int __diag_time_slice_end(struct kvm_vcpu *vcpu) |
19 | { | 47 | { |
20 | VCPU_EVENT(vcpu, 5, "%s", "diag time slice end"); | 48 | VCPU_EVENT(vcpu, 5, "%s", "diag time slice end"); |
@@ -57,6 +85,8 @@ int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) | |||
57 | int code = (vcpu->arch.sie_block->ipb & 0xfff0000) >> 16; | 85 | int code = (vcpu->arch.sie_block->ipb & 0xfff0000) >> 16; |
58 | 86 | ||
59 | switch (code) { | 87 | switch (code) { |
88 | case 0x10: | ||
89 | return diag_release_pages(vcpu); | ||
60 | case 0x44: | 90 | case 0x44: |
61 | return __diag_time_slice_end(vcpu); | 91 | return __diag_time_slice_end(vcpu); |
62 | case 0x308: | 92 | case 0x308: |
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index dc2b580e27bc..189d6bdcac08 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -69,6 +69,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
69 | { "instruction_sigp_set_arch", VCPU_STAT(instruction_sigp_arch) }, | 69 | { "instruction_sigp_set_arch", VCPU_STAT(instruction_sigp_arch) }, |
70 | { "instruction_sigp_set_prefix", VCPU_STAT(instruction_sigp_prefix) }, | 70 | { "instruction_sigp_set_prefix", VCPU_STAT(instruction_sigp_prefix) }, |
71 | { "instruction_sigp_restart", VCPU_STAT(instruction_sigp_restart) }, | 71 | { "instruction_sigp_restart", VCPU_STAT(instruction_sigp_restart) }, |
72 | { "diagnose_10", VCPU_STAT(diagnose_10) }, | ||
72 | { "diagnose_44", VCPU_STAT(diagnose_44) }, | 73 | { "diagnose_44", VCPU_STAT(diagnose_44) }, |
73 | { NULL } | 74 | { NULL } |
74 | }; | 75 | }; |