Skip to content

Commit 44ae766

Browse files
hcahcaVasily Gorbik
authored andcommitted
s390/mm: move translation-exception identification structure to fault.h
Move translation-exception identification structure to new fault.h header file, change it to a union, and change existing kvm code accordingly. The new union will be used by subsequent patches. Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 4416d2e commit 44ae766

2 files changed

Lines changed: 42 additions & 31 deletions

File tree

arch/s390/include/asm/fault.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright IBM Corp. 1999, 2023
4+
*/
5+
#ifndef _ASM_S390_FAULT_H
6+
#define _ASM_S390_FAULT_H
7+
8+
union teid {
9+
unsigned long val;
10+
struct {
11+
unsigned long addr : 52; /* Translation-exception Address */
12+
unsigned long fsi : 2; /* Access Exception Fetch/Store Indication */
13+
unsigned long : 2;
14+
unsigned long b56 : 1;
15+
unsigned long : 3;
16+
unsigned long b60 : 1;
17+
unsigned long b61 : 1;
18+
unsigned long as : 2; /* ASCE Identifier */
19+
};
20+
};
21+
22+
enum {
23+
TEID_FSI_UNKNOWN = 0, /* Unknown whether fetch or store */
24+
TEID_FSI_STORE = 1, /* Exception was due to store operation */
25+
TEID_FSI_FETCH = 2 /* Exception was due to fetch operation */
26+
};
27+
28+
#endif /* _ASM_S390_FAULT_H */

arch/s390/kvm/gaccess.c

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <linux/err.h>
1212
#include <linux/pgtable.h>
1313
#include <linux/bitfield.h>
14-
14+
#include <asm/fault.h>
1515
#include <asm/gmap.h>
1616
#include "kvm-s390.h"
1717
#include "gaccess.h"
@@ -466,23 +466,6 @@ static int ar_translation(struct kvm_vcpu *vcpu, union asce *asce, u8 ar,
466466
return 0;
467467
}
468468

469-
struct trans_exc_code_bits {
470-
unsigned long addr : 52; /* Translation-exception Address */
471-
unsigned long fsi : 2; /* Access Exception Fetch/Store Indication */
472-
unsigned long : 2;
473-
unsigned long b56 : 1;
474-
unsigned long : 3;
475-
unsigned long b60 : 1;
476-
unsigned long b61 : 1;
477-
unsigned long as : 2; /* ASCE Identifier */
478-
};
479-
480-
enum {
481-
FSI_UNKNOWN = 0, /* Unknown whether fetch or store */
482-
FSI_STORE = 1, /* Exception was due to store operation */
483-
FSI_FETCH = 2 /* Exception was due to fetch operation */
484-
};
485-
486469
enum prot_type {
487470
PROT_TYPE_LA = 0,
488471
PROT_TYPE_KEYC = 1,
@@ -497,11 +480,11 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,
497480
enum gacc_mode mode, enum prot_type prot, bool terminate)
498481
{
499482
struct kvm_s390_pgm_info *pgm = &vcpu->arch.pgm;
500-
struct trans_exc_code_bits *tec;
483+
union teid *teid;
501484

502485
memset(pgm, 0, sizeof(*pgm));
503486
pgm->code = code;
504-
tec = (struct trans_exc_code_bits *)&pgm->trans_exc_code;
487+
teid = (union teid *)&pgm->trans_exc_code;
505488

506489
switch (code) {
507490
case PGM_PROTECTION:
@@ -511,25 +494,25 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,
511494
WARN_ON_ONCE(1);
512495
break;
513496
case PROT_TYPE_IEP:
514-
tec->b61 = 1;
497+
teid->b61 = 1;
515498
fallthrough;
516499
case PROT_TYPE_LA:
517-
tec->b56 = 1;
500+
teid->b56 = 1;
518501
break;
519502
case PROT_TYPE_KEYC:
520-
tec->b60 = 1;
503+
teid->b60 = 1;
521504
break;
522505
case PROT_TYPE_ALC:
523-
tec->b60 = 1;
506+
teid->b60 = 1;
524507
fallthrough;
525508
case PROT_TYPE_DAT:
526-
tec->b61 = 1;
509+
teid->b61 = 1;
527510
break;
528511
}
529512
if (terminate) {
530-
tec->b56 = 0;
531-
tec->b60 = 0;
532-
tec->b61 = 0;
513+
teid->b56 = 0;
514+
teid->b60 = 0;
515+
teid->b61 = 0;
533516
}
534517
fallthrough;
535518
case PGM_ASCE_TYPE:
@@ -543,9 +526,9 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,
543526
* exc_access_id has to be set to 0 for some instructions. Both
544527
* cases have to be handled by the caller.
545528
*/
546-
tec->addr = gva >> PAGE_SHIFT;
547-
tec->fsi = mode == GACC_STORE ? FSI_STORE : FSI_FETCH;
548-
tec->as = psw_bits(vcpu->arch.sie_block->gpsw).as;
529+
teid->addr = gva >> PAGE_SHIFT;
530+
teid->fsi = mode == GACC_STORE ? TEID_FSI_STORE : TEID_FSI_FETCH;
531+
teid->as = psw_bits(vcpu->arch.sie_block->gpsw).as;
549532
fallthrough;
550533
case PGM_ALEN_TRANSLATION:
551534
case PGM_ALE_SEQUENCE:

0 commit comments

Comments
 (0)