KVM: s390: Helper for converting real addresses to absolute
Added a separate helper function that translates guest real addresses to guest absolute addresses by applying the prefix of the guest CPU. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Родитель
ff7158b227
Коммит
732e563373
|
@ -18,20 +18,27 @@
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include "kvm-s390.h"
|
#include "kvm-s390.h"
|
||||||
|
|
||||||
|
/* Convert real to absolute address by applying the prefix of the CPU */
|
||||||
|
static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
|
||||||
|
unsigned long gaddr)
|
||||||
|
{
|
||||||
|
unsigned long prefix = vcpu->arch.sie_block->prefix;
|
||||||
|
if (gaddr < 2 * PAGE_SIZE)
|
||||||
|
gaddr += prefix;
|
||||||
|
else if (gaddr >= prefix && gaddr < prefix + 2 * PAGE_SIZE)
|
||||||
|
gaddr -= prefix;
|
||||||
|
return gaddr;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu,
|
static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu,
|
||||||
void __user *gptr,
|
void __user *gptr,
|
||||||
int prefixing)
|
int prefixing)
|
||||||
{
|
{
|
||||||
unsigned long prefix = vcpu->arch.sie_block->prefix;
|
|
||||||
unsigned long gaddr = (unsigned long) gptr;
|
unsigned long gaddr = (unsigned long) gptr;
|
||||||
unsigned long uaddr;
|
unsigned long uaddr;
|
||||||
|
|
||||||
if (prefixing) {
|
if (prefixing)
|
||||||
if (gaddr < 2 * PAGE_SIZE)
|
gaddr = kvm_s390_real_to_abs(vcpu, gaddr);
|
||||||
gaddr += prefix;
|
|
||||||
else if ((gaddr >= prefix) && (gaddr < prefix + 2 * PAGE_SIZE))
|
|
||||||
gaddr -= prefix;
|
|
||||||
}
|
|
||||||
uaddr = gmap_fault(gaddr, vcpu->arch.gmap);
|
uaddr = gmap_fault(gaddr, vcpu->arch.gmap);
|
||||||
if (IS_ERR_VALUE(uaddr))
|
if (IS_ERR_VALUE(uaddr))
|
||||||
uaddr = -EFAULT;
|
uaddr = -EFAULT;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче