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/kvm/priv.c | |
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/kvm/priv.c')
-rw-r--r-- | arch/s390/kvm/priv.c | 18 |
1 files changed, 15 insertions, 3 deletions
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 | } |