Skip to content

Commit d6404de

Browse files
David Hildenbrandborntraeger
authored andcommitted
KVM: s390: factor out actual delivery of machine checks
Let's factor this out to prepare for bigger changes. Reorder to calls to match the logical order given in the PoP. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
1 parent fa8410b commit d6404de

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

arch/s390/kvm/interrupt.c

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,40 @@ static int __must_check __deliver_pfault_init(struct kvm_vcpu *vcpu)
400400
return rc ? -EFAULT : 0;
401401
}
402402

403+
static int __write_machine_check(struct kvm_vcpu *vcpu,
404+
struct kvm_s390_mchk_info *mchk)
405+
{
406+
unsigned long ext_sa_addr;
407+
int rc;
408+
409+
/* Extended save area */
410+
rc = read_guest_lc(vcpu, __LC_VX_SAVE_AREA_ADDR, &ext_sa_addr,
411+
sizeof(unsigned long));
412+
rc |= kvm_s390_vcpu_store_adtl_status(vcpu, ext_sa_addr);
413+
414+
/* General interruption information */
415+
rc |= write_guest_lc(vcpu, __LC_MCK_OLD_PSW,
416+
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
417+
rc |= read_guest_lc(vcpu, __LC_MCK_NEW_PSW,
418+
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
419+
rc |= put_guest_lc(vcpu, mchk->mcic, (u64 __user *) __LC_MCCK_CODE);
420+
421+
/* Register-save areas */
422+
rc |= kvm_s390_vcpu_store_status(vcpu, KVM_S390_STORE_STATUS_PREFIXED);
423+
424+
/* Extended interruption information */
425+
rc |= put_guest_lc(vcpu, mchk->failing_storage_address,
426+
(u64 __user *) __LC_MCCK_FAIL_STOR_ADDR);
427+
rc |= write_guest_lc(vcpu, __LC_PSW_SAVE_AREA, &mchk->fixed_logout,
428+
sizeof(mchk->fixed_logout));
429+
return rc ? -EFAULT : 0;
430+
}
431+
403432
static int __must_check __deliver_machine_check(struct kvm_vcpu *vcpu)
404433
{
405434
struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
406435
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
407436
struct kvm_s390_mchk_info mchk = {};
408-
unsigned long adtl_status_addr;
409437
int deliver = 0;
410438
int rc = 0;
411439

@@ -446,29 +474,9 @@ static int __must_check __deliver_machine_check(struct kvm_vcpu *vcpu)
446474
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
447475
KVM_S390_MCHK,
448476
mchk.cr14, mchk.mcic);
449-
450-
rc = kvm_s390_vcpu_store_status(vcpu,
451-
KVM_S390_STORE_STATUS_PREFIXED);
452-
rc |= read_guest_lc(vcpu, __LC_VX_SAVE_AREA_ADDR,
453-
&adtl_status_addr,
454-
sizeof(unsigned long));
455-
rc |= kvm_s390_vcpu_store_adtl_status(vcpu,
456-
adtl_status_addr);
457-
rc |= put_guest_lc(vcpu, mchk.mcic,
458-
(u64 __user *) __LC_MCCK_CODE);
459-
rc |= put_guest_lc(vcpu, mchk.failing_storage_address,
460-
(u64 __user *) __LC_MCCK_FAIL_STOR_ADDR);
461-
rc |= write_guest_lc(vcpu, __LC_PSW_SAVE_AREA,
462-
&mchk.fixed_logout,
463-
sizeof(mchk.fixed_logout));
464-
rc |= write_guest_lc(vcpu, __LC_MCK_OLD_PSW,
465-
&vcpu->arch.sie_block->gpsw,
466-
sizeof(psw_t));
467-
rc |= read_guest_lc(vcpu, __LC_MCK_NEW_PSW,
468-
&vcpu->arch.sie_block->gpsw,
469-
sizeof(psw_t));
477+
rc = __write_machine_check(vcpu, &mchk);
470478
}
471-
return rc ? -EFAULT : 0;
479+
return rc;
472480
}
473481

474482
static int __must_check __deliver_restart(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)