aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/kvm/gaccess.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/s390/kvm/gaccess.h b/arch/s390/kvm/gaccess.h
index 374a439ccc60..ae3cb638f220 100644
--- a/arch/s390/kvm/gaccess.h
+++ b/arch/s390/kvm/gaccess.h
@@ -30,6 +30,31 @@ static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
30 return gaddr; 30 return gaddr;
31} 31}
32 32
33/**
34 * kvm_s390_logical_to_effective - convert guest logical to effective address
35 * @vcpu: guest virtual cpu
36 * @ga: guest logical address
37 *
38 * Convert a guest vcpu logical address to a guest vcpu effective address by
39 * applying the rules of the vcpu's addressing mode defined by PSW bits 31
40 * and 32 (extendended/basic addressing mode).
41 *
42 * Depending on the vcpu's addressing mode the upper 40 bits (24 bit addressing
43 * mode), 33 bits (31 bit addressing mode) or no bits (64 bit addressing mode)
44 * of @ga will be zeroed and the remaining bits will be returned.
45 */
46static inline unsigned long kvm_s390_logical_to_effective(struct kvm_vcpu *vcpu,
47 unsigned long ga)
48{
49 psw_t *psw = &vcpu->arch.sie_block->gpsw;
50
51 if (psw_bits(*psw).eaba == PSW_AMODE_64BIT)
52 return ga;
53 if (psw_bits(*psw).eaba == PSW_AMODE_31BIT)
54 return ga & ((1UL << 31) - 1);
55 return ga & ((1UL << 24) - 1);
56}
57
33static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu, 58static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu,
34 void __user *gptr, 59 void __user *gptr,
35 int prefixing) 60 int prefixing)