Commit f987a3ee authored by Heiko Carstens's avatar Heiko Carstens Committed by Christian Borntraeger

KVM: s390: convert handle lctl[g]()

Convert handle lctl[g]() to new guest access functions.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: default avatarThomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
parent 7d777d78
...@@ -755,32 +755,31 @@ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu) ...@@ -755,32 +755,31 @@ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu)
{ {
int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
int reg3 = vcpu->arch.sie_block->ipa & 0x000f; int reg3 = vcpu->arch.sie_block->ipa & 0x000f;
u64 useraddr;
u32 val = 0; u32 val = 0;
int reg, rc; int reg, rc;
u64 ga;
vcpu->stat.instruction_lctl++; vcpu->stat.instruction_lctl++;
if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
useraddr = kvm_s390_get_base_disp_rs(vcpu); ga = kvm_s390_get_base_disp_rs(vcpu);
if (useraddr & 3) if (ga & 3)
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
VCPU_EVENT(vcpu, 5, "lctl r1:%x, r3:%x, addr:%llx", reg1, reg3, VCPU_EVENT(vcpu, 5, "lctl r1:%x, r3:%x, addr:%llx", reg1, reg3, ga);
useraddr); trace_kvm_s390_handle_lctl(vcpu, 0, reg1, reg3, ga);
trace_kvm_s390_handle_lctl(vcpu, 0, reg1, reg3, useraddr);
reg = reg1; reg = reg1;
do { do {
rc = get_guest(vcpu, val, (u32 __user *) useraddr); rc = read_guest(vcpu, ga, &val, sizeof(val));
if (rc) if (rc)
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); return kvm_s390_inject_prog_cond(vcpu, rc);
vcpu->arch.sie_block->gcr[reg] &= 0xffffffff00000000ul; vcpu->arch.sie_block->gcr[reg] &= 0xffffffff00000000ul;
vcpu->arch.sie_block->gcr[reg] |= val; vcpu->arch.sie_block->gcr[reg] |= val;
useraddr += 4; ga += 4;
if (reg == reg3) if (reg == reg3)
break; break;
reg = (reg + 1) % 16; reg = (reg + 1) % 16;
...@@ -793,7 +792,7 @@ static int handle_lctlg(struct kvm_vcpu *vcpu) ...@@ -793,7 +792,7 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)
{ {
int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
int reg3 = vcpu->arch.sie_block->ipa & 0x000f; int reg3 = vcpu->arch.sie_block->ipa & 0x000f;
u64 useraddr; u64 ga, val;
int reg, rc; int reg, rc;
vcpu->stat.instruction_lctlg++; vcpu->stat.instruction_lctlg++;
...@@ -801,23 +800,22 @@ static int handle_lctlg(struct kvm_vcpu *vcpu) ...@@ -801,23 +800,22 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)
if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
useraddr = kvm_s390_get_base_disp_rsy(vcpu); ga = kvm_s390_get_base_disp_rsy(vcpu);
if (useraddr & 7) if (ga & 7)
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
reg = reg1; reg = reg1;
VCPU_EVENT(vcpu, 5, "lctlg r1:%x, r3:%x, addr:%llx", reg1, reg3, VCPU_EVENT(vcpu, 5, "lctlg r1:%x, r3:%x, addr:%llx", reg1, reg3, ga);
useraddr); trace_kvm_s390_handle_lctl(vcpu, 1, reg1, reg3, ga);
trace_kvm_s390_handle_lctl(vcpu, 1, reg1, reg3, useraddr);
do { do {
rc = get_guest(vcpu, vcpu->arch.sie_block->gcr[reg], rc = read_guest(vcpu, ga, &val, sizeof(val));
(u64 __user *) useraddr);
if (rc) if (rc)
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); return kvm_s390_inject_prog_cond(vcpu, rc);
useraddr += 8; vcpu->arch.sie_block->gcr[reg] = val;
ga += 8;
if (reg == reg3) if (reg == reg3)
break; break;
reg = (reg + 1) % 16; reg = (reg + 1) % 16;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment