KVM: s390: convert kvm_s390_store_status_unloaded()

Convert kvm_s390_store_status_unloaded() to new guest access functions.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
This commit is contained in:
Heiko Carstens 2014-01-01 16:45:58 +01:00 committed by Christian Borntraeger
parent 0040e7d20f
commit d0bce6054a

View File

@ -1249,83 +1249,50 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
return rc; return rc;
} }
static int __guestcopy(struct kvm_vcpu *vcpu, u64 guestdest, void *from,
unsigned long n, int prefix)
{
if (prefix)
return copy_to_guest(vcpu, guestdest, from, n);
else
return copy_to_guest_absolute(vcpu, guestdest, from, n);
}
/* /*
* store status at address * store status at address
* we use have two special cases: * we use have two special cases:
* KVM_S390_STORE_STATUS_NOADDR: -> 0x1200 on 64 bit * KVM_S390_STORE_STATUS_NOADDR: -> 0x1200 on 64 bit
* KVM_S390_STORE_STATUS_PREFIXED: -> prefix * KVM_S390_STORE_STATUS_PREFIXED: -> prefix
*/ */
int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr) int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa)
{ {
unsigned char archmode = 1; unsigned char archmode = 1;
int prefix;
u64 clkcomp; u64 clkcomp;
int rc;
if (addr == KVM_S390_STORE_STATUS_NOADDR) { if (gpa == KVM_S390_STORE_STATUS_NOADDR) {
if (copy_to_guest_absolute(vcpu, 163ul, &archmode, 1)) if (write_guest_abs(vcpu, 163, &archmode, 1))
return -EFAULT; return -EFAULT;
addr = SAVE_AREA_BASE; gpa = SAVE_AREA_BASE;
prefix = 0; } else if (gpa == KVM_S390_STORE_STATUS_PREFIXED) {
} else if (addr == KVM_S390_STORE_STATUS_PREFIXED) { if (write_guest_real(vcpu, 163, &archmode, 1))
if (copy_to_guest(vcpu, 163ul, &archmode, 1))
return -EFAULT; return -EFAULT;
addr = SAVE_AREA_BASE; gpa = kvm_s390_real_to_abs(vcpu, SAVE_AREA_BASE);
prefix = 1; }
} else rc = write_guest_abs(vcpu, gpa + offsetof(struct save_area, fp_regs),
prefix = 0; vcpu->arch.guest_fpregs.fprs, 128);
rc |= write_guest_abs(vcpu, gpa + offsetof(struct save_area, gp_regs),
if (__guestcopy(vcpu, addr + offsetof(struct save_area, fp_regs), vcpu->run->s.regs.gprs, 128);
vcpu->arch.guest_fpregs.fprs, 128, prefix)) rc |= write_guest_abs(vcpu, gpa + offsetof(struct save_area, psw),
return -EFAULT; &vcpu->arch.sie_block->gpsw, 16);
rc |= write_guest_abs(vcpu, gpa + offsetof(struct save_area, pref_reg),
if (__guestcopy(vcpu, addr + offsetof(struct save_area, gp_regs), &vcpu->arch.sie_block->prefix, 4);
vcpu->run->s.regs.gprs, 128, prefix)) rc |= write_guest_abs(vcpu,
return -EFAULT; gpa + offsetof(struct save_area, fp_ctrl_reg),
&vcpu->arch.guest_fpregs.fpc, 4);
if (__guestcopy(vcpu, addr + offsetof(struct save_area, psw), rc |= write_guest_abs(vcpu, gpa + offsetof(struct save_area, tod_reg),
&vcpu->arch.sie_block->gpsw, 16, prefix)) &vcpu->arch.sie_block->todpr, 4);
return -EFAULT; rc |= write_guest_abs(vcpu, gpa + offsetof(struct save_area, timer),
&vcpu->arch.sie_block->cputm, 8);
if (__guestcopy(vcpu, addr + offsetof(struct save_area, pref_reg),
&vcpu->arch.sie_block->prefix, 4, prefix))
return -EFAULT;
if (__guestcopy(vcpu,
addr + offsetof(struct save_area, fp_ctrl_reg),
&vcpu->arch.guest_fpregs.fpc, 4, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, tod_reg),
&vcpu->arch.sie_block->todpr, 4, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, timer),
&vcpu->arch.sie_block->cputm, 8, prefix))
return -EFAULT;
clkcomp = vcpu->arch.sie_block->ckc >> 8; clkcomp = vcpu->arch.sie_block->ckc >> 8;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, clk_cmp), rc |= write_guest_abs(vcpu, gpa + offsetof(struct save_area, clk_cmp),
&clkcomp, 8, prefix)) &clkcomp, 8);
return -EFAULT; rc |= write_guest_abs(vcpu, gpa + offsetof(struct save_area, acc_regs),
&vcpu->run->s.regs.acrs, 64);
if (__guestcopy(vcpu, addr + offsetof(struct save_area, acc_regs), rc |= write_guest_abs(vcpu, gpa + offsetof(struct save_area, ctrl_regs),
&vcpu->run->s.regs.acrs, 64, prefix)) &vcpu->arch.sie_block->gcr, 128);
return -EFAULT; return rc ? -EFAULT : 0;
if (__guestcopy(vcpu,
addr + offsetof(struct save_area, ctrl_regs),
&vcpu->arch.sie_block->gcr, 128, prefix))
return -EFAULT;
return 0;
} }
int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr) int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)