KVM: s390: Take addressing mode into account for MVPG interception
authorThomas Huth <thuth@linux.vnet.ibm.com>
Wed, 7 Jan 2015 15:27:02 +0000 (16:27 +0100)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Fri, 23 Jan 2015 12:25:38 +0000 (13:25 +0100)
The handler for MVPG partial execution interception does not take
the current CPU addressing mode into account yet, so addresses are
always treated as 64-bit addresses. For correct behaviour, we should
properly handle 24-bit and 31-bit addresses, too.

Since MVPG is defined to work with logical addresses, we can simply
use guest_translate_address() to achieve the required behaviour
(since DAT is disabled here, guest_translate_address() skips the MMU
translation and only translates the address via kvm_s390_logical_to_effective()
and kvm_s390_real_to_abs(), which is exactly what we want here).

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
arch/s390/kvm/intercept.c

index 7c868a9914116afee6409f23a501c5f3743fd070..bebd2157edd019448ff772c9ac75a778e7e124f4 100644 (file)
@@ -318,17 +318,19 @@ static int handle_mvpg_pei(struct kvm_vcpu *vcpu)
        kvm_s390_get_regs_rre(vcpu, &reg1, &reg2);
 
        /* Make sure that the source is paged-in */
-       srcaddr = kvm_s390_real_to_abs(vcpu, vcpu->run->s.regs.gprs[reg2]);
-       if (kvm_is_error_gpa(vcpu->kvm, srcaddr))
-               return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
+       rc = guest_translate_address(vcpu, vcpu->run->s.regs.gprs[reg2],
+                                    &srcaddr, 0);
+       if (rc)
+               return kvm_s390_inject_prog_cond(vcpu, rc);
        rc = kvm_arch_fault_in_page(vcpu, srcaddr, 0);
        if (rc != 0)
                return rc;
 
        /* Make sure that the destination is paged-in */
-       dstaddr = kvm_s390_real_to_abs(vcpu, vcpu->run->s.regs.gprs[reg1]);
-       if (kvm_is_error_gpa(vcpu->kvm, dstaddr))
-               return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
+       rc = guest_translate_address(vcpu, vcpu->run->s.regs.gprs[reg1],
+                                    &dstaddr, 1);
+       if (rc)
+               return kvm_s390_inject_prog_cond(vcpu, rc);
        rc = kvm_arch_fault_in_page(vcpu, dstaddr, 1);
        if (rc != 0)
                return rc;