2 * intercept.c - in-kernel handling for sie intercepts
4 * Copyright IBM Corp. 2008
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.
10 * Author(s): Carsten Otte <cotte@de.ibm.com>
11 * Christian Borntraeger <borntraeger@de.ibm.com>
14 #include <linux/kvm_host.h>
15 #include <linux/errno.h>
16 #include <linux/pagemap.h>
18 #include <asm/kvm_host.h>
22 static int handle_noop(struct kvm_vcpu
*vcpu
)
24 switch (vcpu
->arch
.sie_block
->icptcode
) {
26 vcpu
->stat
.exit_external_request
++;
29 vcpu
->stat
.exit_external_interrupt
++;
37 static int handle_stop(struct kvm_vcpu
*vcpu
)
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
);
45 static int handle_validity(struct kvm_vcpu
*vcpu
)
47 int viwhy
= vcpu
->arch
.sie_block
->ipb
>> 16;
48 vcpu
->stat
.exit_validity
++;
50 fault_in_pages_writeable((char __user
*)
51 vcpu
->kvm
->arch
.guest_origin
+
52 vcpu
->arch
.sie_block
->prefix
,
56 VCPU_EVENT(vcpu
, 2, "unhandled validity intercept code %d",
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
,
69 int kvm_handle_sie_intercept(struct kvm_vcpu
*vcpu
)
71 intercept_handler_t func
;
72 u8 code
= vcpu
->arch
.sie_block
->icptcode
;
74 if (code
& 3 || code
> 0x48)
76 func
= intercept_funcs
[code
>> 2];