diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2009-01-22 04:28:29 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-03-24 05:03:07 -0400 |
commit | 70455a36a073cbb83ca17f92d135a6128c73cb3c (patch) | |
tree | ccc7b13f17703d9823ecb5967d09a99665d81f57 /arch/s390 | |
parent | 2c411b48af3e3c534b9cfb6a79be1df384d1ca1a (diff) |
KVM: s390: Fix problem state check for b2 intercepts
The kernel handles some priviledged instruction exits. While I was
unable to trigger such an exit from guest userspace, the code should
check for supervisor state before emulating a priviledged instruction.
I also renamed kvm_s390_handle_priv to kvm_s390_handle_b2. After all
there are non priviledged b2 instructions like stck (store clock).
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/kvm/intercept.c | 2 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.h | 2 | ||||
-rw-r--r-- | arch/s390/kvm/priv.c | 18 |
3 files changed, 17 insertions, 5 deletions
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c index 61236102203e..9d19803111ba 100644 --- a/arch/s390/kvm/intercept.c +++ b/arch/s390/kvm/intercept.c | |||
@@ -103,7 +103,7 @@ static int handle_lctl(struct kvm_vcpu *vcpu) | |||
103 | static intercept_handler_t instruction_handlers[256] = { | 103 | static intercept_handler_t instruction_handlers[256] = { |
104 | [0x83] = kvm_s390_handle_diag, | 104 | [0x83] = kvm_s390_handle_diag, |
105 | [0xae] = kvm_s390_handle_sigp, | 105 | [0xae] = kvm_s390_handle_sigp, |
106 | [0xb2] = kvm_s390_handle_priv, | 106 | [0xb2] = kvm_s390_handle_b2, |
107 | [0xb7] = handle_lctl, | 107 | [0xb7] = handle_lctl, |
108 | [0xeb] = handle_lctlg, | 108 | [0xeb] = handle_lctlg, |
109 | }; | 109 | }; |
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 3893cf12eacf..00bbe69b78da 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h | |||
@@ -50,7 +50,7 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu, | |||
50 | int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code); | 50 | int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code); |
51 | 51 | ||
52 | /* implemented in priv.c */ | 52 | /* implemented in priv.c */ |
53 | int kvm_s390_handle_priv(struct kvm_vcpu *vcpu); | 53 | int kvm_s390_handle_b2(struct kvm_vcpu *vcpu); |
54 | 54 | ||
55 | /* implemented in sigp.c */ | 55 | /* implemented in sigp.c */ |
56 | int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu); | 56 | int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu); |
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c index 3605df45dd41..4b88834b8dd8 100644 --- a/arch/s390/kvm/priv.c +++ b/arch/s390/kvm/priv.c | |||
@@ -304,12 +304,24 @@ static intercept_handler_t priv_handlers[256] = { | |||
304 | [0xb1] = handle_stfl, | 304 | [0xb1] = handle_stfl, |
305 | }; | 305 | }; |
306 | 306 | ||
307 | int kvm_s390_handle_priv(struct kvm_vcpu *vcpu) | 307 | int kvm_s390_handle_b2(struct kvm_vcpu *vcpu) |
308 | { | 308 | { |
309 | intercept_handler_t handler; | 309 | intercept_handler_t handler; |
310 | 310 | ||
311 | /* | ||
312 | * a lot of B2 instructions are priviledged. We first check for | ||
313 | * the priviledges ones, that we can handle in the kernel. If the | ||
314 | * kernel can handle this instruction, we check for the problem | ||
315 | * state bit and (a) handle the instruction or (b) send a code 2 | ||
316 | * program check. | ||
317 | * Anything else goes to userspace.*/ | ||
311 | handler = priv_handlers[vcpu->arch.sie_block->ipa & 0x00ff]; | 318 | handler = priv_handlers[vcpu->arch.sie_block->ipa & 0x00ff]; |
312 | if (handler) | 319 | if (handler) { |
313 | return handler(vcpu); | 320 | if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) |
321 | return kvm_s390_inject_program_int(vcpu, | ||
322 | PGM_PRIVILEGED_OPERATION); | ||
323 | else | ||
324 | return handler(vcpu); | ||
325 | } | ||
314 | return -ENOTSUPP; | 326 | return -ENOTSUPP; |
315 | } | 327 | } |