Skip to content

Commit c14b88d

Browse files
Janosch Frankborntraeger
authored andcommitted
KVM: s390: gaccess: simplify translation exception handling
The payload data for protection exceptions is a superset of the payload of other translation exceptions. Let's set the additional flags and use a fall through to minimize code duplication. Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
1 parent b1ffffb commit c14b88d

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

arch/s390/kvm/gaccess.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,18 @@ static int trans_exc(struct kvm_vcpu *vcpu, int code, unsigned long gva,
495495
tec = (struct trans_exc_code_bits *)&pgm->trans_exc_code;
496496

497497
switch (code) {
498+
case PGM_PROTECTION:
499+
switch (prot) {
500+
case PROT_TYPE_ALC:
501+
tec->b60 = 1;
502+
/* FALL THROUGH */
503+
case PROT_TYPE_DAT:
504+
tec->b61 = 1;
505+
break;
506+
default: /* LA and KEYC set b61 to 0, other params undefined */
507+
return code;
508+
}
509+
/* FALL THROUGH */
498510
case PGM_ASCE_TYPE:
499511
case PGM_PAGE_TRANSLATION:
500512
case PGM_REGION_FIRST_TRANS:
@@ -504,8 +516,7 @@ static int trans_exc(struct kvm_vcpu *vcpu, int code, unsigned long gva,
504516
/*
505517
* op_access_id only applies to MOVE_PAGE -> set bit 61
506518
* exc_access_id has to be set to 0 for some instructions. Both
507-
* cases have to be handled by the caller. We can always store
508-
* exc_access_id, as it is undefined for non-ar cases.
519+
* cases have to be handled by the caller.
509520
*/
510521
tec->addr = gva >> PAGE_SHIFT;
511522
tec->fsi = mode == GACC_STORE ? FSI_STORE : FSI_FETCH;
@@ -516,25 +527,13 @@ static int trans_exc(struct kvm_vcpu *vcpu, int code, unsigned long gva,
516527
case PGM_ASTE_VALIDITY:
517528
case PGM_ASTE_SEQUENCE:
518529
case PGM_EXTENDED_AUTHORITY:
530+
/*
531+
* We can always store exc_access_id, as it is
532+
* undefined for non-ar cases. It is undefined for
533+
* most DAT protection exceptions.
534+
*/
519535
pgm->exc_access_id = ar;
520536
break;
521-
case PGM_PROTECTION:
522-
switch (prot) {
523-
case PROT_TYPE_ALC:
524-
tec->b60 = 1;
525-
/* FALL THROUGH */
526-
case PROT_TYPE_DAT:
527-
tec->b61 = 1;
528-
tec->addr = gva >> PAGE_SHIFT;
529-
tec->fsi = mode == GACC_STORE ? FSI_STORE : FSI_FETCH;
530-
tec->as = psw_bits(vcpu->arch.sie_block->gpsw).as;
531-
/* exc_access_id is undefined for most cases */
532-
pgm->exc_access_id = ar;
533-
break;
534-
default: /* LA and KEYC set b61 to 0, other params undefined */
535-
break;
536-
}
537-
break;
538537
}
539538
return code;
540539
}

0 commit comments

Comments
 (0)