]>
Commit | Line | Data |
---|---|---|
8f2abe6a CB |
1 | /* |
2 | * intercept.c - in-kernel handling for sie intercepts | |
3 | * | |
4 | * Copyright IBM Corp. 2008 | |
5 | * | |
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) | |
8 | * as published by the Free Software Foundation. | |
9 | * | |
10 | * Author(s): Carsten Otte <cotte@de.ibm.com> | |
11 | * Christian Borntraeger <borntraeger@de.ibm.com> | |
12 | */ | |
13 | ||
14 | #include <linux/kvm_host.h> | |
15 | #include <linux/errno.h> | |
16 | #include <linux/pagemap.h> | |
17 | ||
18 | #include <asm/kvm_host.h> | |
19 | ||
20 | #include "kvm-s390.h" | |
21 | ||
22 | static int handle_noop(struct kvm_vcpu *vcpu) | |
23 | { | |
24 | switch (vcpu->arch.sie_block->icptcode) { | |
25 | case 0x10: | |
26 | vcpu->stat.exit_external_request++; | |
27 | break; | |
28 | case 0x14: | |
29 | vcpu->stat.exit_external_interrupt++; | |
30 | break; | |
31 | default: | |
32 | break; /* nothing */ | |
33 | } | |
34 | return 0; | |
35 | } | |
36 | ||
37 | static int handle_stop(struct kvm_vcpu *vcpu) | |
38 | { | |
39 | vcpu->stat.exit_stop_request++; | |
40 | VCPU_EVENT(vcpu, 3, "%s", "cpu stopped"); | |
41 | atomic_clear_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); | |
42 | return -ENOTSUPP; | |
43 | } | |
44 | ||
45 | static int handle_validity(struct kvm_vcpu *vcpu) | |
46 | { | |
47 | int viwhy = vcpu->arch.sie_block->ipb >> 16; | |
48 | vcpu->stat.exit_validity++; | |
49 | if (viwhy == 0x37) { | |
50 | fault_in_pages_writeable((char __user *) | |
51 | vcpu->kvm->arch.guest_origin + | |
52 | vcpu->arch.sie_block->prefix, | |
53 | PAGE_SIZE); | |
54 | return 0; | |
55 | } | |
56 | VCPU_EVENT(vcpu, 2, "unhandled validity intercept code %d", | |
57 | viwhy); | |
58 | return -ENOTSUPP; | |
59 | } | |
60 | ||
61 | static const intercept_handler_t intercept_funcs[0x48 >> 2] = { | |
62 | [0x00 >> 2] = handle_noop, | |
63 | [0x10 >> 2] = handle_noop, | |
64 | [0x14 >> 2] = handle_noop, | |
65 | [0x20 >> 2] = handle_validity, | |
66 | [0x28 >> 2] = handle_stop, | |
67 | }; | |
68 | ||
69 | int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu) | |
70 | { | |
71 | intercept_handler_t func; | |
72 | u8 code = vcpu->arch.sie_block->icptcode; | |
73 | ||
74 | if (code & 3 || code > 0x48) | |
75 | return -ENOTSUPP; | |
76 | func = intercept_funcs[code >> 2]; | |
77 | if (func) | |
78 | return func(vcpu); | |
79 | return -ENOTSUPP; | |
80 | } |