]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: s390: Fix problem state check for b2 intercepts
authorChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 22 Jan 2009 09:28:29 +0000 (10:28 +0100)
committerAvi Kivity <avi@redhat.com>
Tue, 24 Mar 2009 09:03:07 +0000 (11:03 +0200)
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>
arch/s390/kvm/intercept.c
arch/s390/kvm/kvm-s390.h
arch/s390/kvm/priv.c

index 61236102203e8746933ae96dab4876b421d901d6..9d19803111bab26d8021d3aaf2f0f028092f8c8b 100644 (file)
@@ -103,7 +103,7 @@ static int handle_lctl(struct kvm_vcpu *vcpu)
 static intercept_handler_t instruction_handlers[256] = {
        [0x83] = kvm_s390_handle_diag,
        [0xae] = kvm_s390_handle_sigp,
-       [0xb2] = kvm_s390_handle_priv,
+       [0xb2] = kvm_s390_handle_b2,
        [0xb7] = handle_lctl,
        [0xeb] = handle_lctlg,
 };
index 3893cf12eacf4a4bc595b87ee632f84e6b8c7f89..00bbe69b78da97757b8da8840d0f55977a7aca8c 100644 (file)
@@ -50,7 +50,7 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
 int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code);
 
 /* implemented in priv.c */
-int kvm_s390_handle_priv(struct kvm_vcpu *vcpu);
+int kvm_s390_handle_b2(struct kvm_vcpu *vcpu);
 
 /* implemented in sigp.c */
 int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu);
index 3605df45dd419fb2082b193c8e7438bf5b815dfe..4b88834b8dd8bd4be94de20d5bf248b8f195bcd6 100644 (file)
@@ -304,12 +304,24 @@ static intercept_handler_t priv_handlers[256] = {
        [0xb1] = handle_stfl,
 };
 
-int kvm_s390_handle_priv(struct kvm_vcpu *vcpu)
+int kvm_s390_handle_b2(struct kvm_vcpu *vcpu)
 {
        intercept_handler_t handler;
 
+       /*
+        * a lot of B2 instructions are priviledged. We first check for
+        * the priviledges ones, that we can handle in the kernel. If the
+        * kernel can handle this instruction, we check for the problem
+        * state bit and (a) handle the instruction or (b) send a code 2
+        * program check.
+        * Anything else goes to userspace.*/
        handler = priv_handlers[vcpu->arch.sie_block->ipa & 0x00ff];
-       if (handler)
-               return handler(vcpu);
+       if (handler) {
+               if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
+                       return kvm_s390_inject_program_int(vcpu,
+                                                  PGM_PRIVILEGED_OPERATION);
+               else
+                       return handler(vcpu);
+       }
        return -ENOTSUPP;
 }