public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Janis Schoetterl-Glausch <scgl@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [kvm-unit-tests PATCH v2 0/3] s390x: Rework TEID decoding and usage
Date: Wed,  8 Jun 2022 15:33:00 +0200	[thread overview]
Message-ID: <20220608133303.1532166-1-scgl@linux.ibm.com> (raw)

The translation-exception identification (TEID) contains information to
identify the cause of certain program exceptions, including translation
exceptions occurring during dynamic address translation, as well as
protection exceptions.
The meaning of fields in the TEID is complex, depending on the exception
occurring and various potentially installed facilities.

Add function to query which suppression-on-protection facility is
installed.
Rework the type describing the TEID, in order to ease decoding.
Change the existing code interpreting the TEID and extend it to take the
installed suppression-on-protection facility into account.

Also fix the sclp bit order.
This series is based on  v3 of series s390x: Avoid gcc 12 warnings .
The sclp fix is taken from v2 More skey instr. emulation test,
and could be picked independently from the rest of the series.

v1 -> v2
 * pick up r-b
 * get rid of esop1 alias of sop_teid_predictable
 * assert that the esop2 protection code is valid
 * use string literal array and indexing for protection code printing
 * fix protection exception check in edat.c

Janis Schoetterl-Glausch (3):
  s390x: Fix sclp facility bit numbers
  s390x: lib: SOP facility query function
  s390x: Rework TEID decoding and usage

 lib/s390x/asm/facility.h  | 21 +++++++++++++
 lib/s390x/asm/interrupt.h | 61 +++++++++++++++++++++++++++---------
 lib/s390x/fault.h         | 30 +++++-------------
 lib/s390x/sclp.h          | 18 ++++++-----
 lib/s390x/fault.c         | 65 ++++++++++++++++++++++++++-------------
 lib/s390x/interrupt.c     |  2 +-
 lib/s390x/sclp.c          |  2 ++
 s390x/edat.c              | 26 ++++++++++------
 8 files changed, 149 insertions(+), 76 deletions(-)

Range-diff against v1:
1:  abb9b37a = 1:  6427944a s390x: Fix sclp facility bit numbers
2:  5662f4bc ! 2:  a08fce3b s390x: lib: SOP facility query function
    @@ Commit message
         installed.
     
         Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
    +    Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
     
      ## lib/s390x/asm/facility.h ##
     @@
3:  b716e5ef ! 3:  eb268af1 s390x: Rework TEID decoding and usage
    @@ lib/s390x/asm/interrupt.h
     +			uint64_t addr			: 52 -  0;
     +			uint64_t acc_exc_f_s		: 54 - 52;
     +			uint64_t side_effect_acc	: 55 - 54;
    -+			uint64_t /* reserved */		: 55 - 54;
    ++			uint64_t /* reserved */		: 62 - 55;
     +			uint64_t asce_id		: 64 - 62;
     +		};
     +		/* DAT exc */
    @@ lib/s390x/asm/interrupt.h
     +			uint64_t sop_acc_list		: 61 - 60;
     +			uint64_t sop_teid_predictable	: 62 - 61;
     +		};
    -+		/* enhanced suppression on protection 1 */
    -+		struct {
    -+			uint64_t /* pad */		: 61 -  0;
    -+			uint64_t esop1_acc_list_or_dat	: 62 - 61;
    -+		};
     +		/* enhanced suppression on protection 2 */
     +		struct {
     +			uint64_t /* pad */		: 56 -  0;
    @@ lib/s390x/asm/interrupt.h
     +
     +static inline enum prot_code teid_esop2_prot_code(union teid teid)
     +{
    -+	int code = 0;
    ++	int code = (teid.esop2_prot_code_0 << 2 |
    ++		    teid.esop2_prot_code_1 << 1 |
    ++		    teid.esop2_prot_code_2);
     +
    -+	code = code << 1 | teid.esop2_prot_code_0;
    -+	code = code << 1 | teid.esop2_prot_code_1;
    -+	code = code << 1 | teid.esop2_prot_code_2;
    ++	assert(code < 6);
     +	return (enum prot_code)code;
     +}
     +
    @@ lib/s390x/fault.c
     -		printf("Type: LAP\n");
     -		return;
     -	}
    --
    + 
     -	if (prot_is_iep(teid)) {
     -		printf("Type: IEP\n");
     -		return;
     -	}
    - 
    --	if (prot_is_datp(teid)) {
    --		printf("Type: DAT\n");
    --		return;
     +static void print_decode_pgm_prot(union teid teid, bool dat)
     +{
     +	switch (get_supp_on_prot_facility()) {
    @@ lib/s390x/fault.c
     +			printf("Type: ?\n");
     +		break;
     +	case SOP_ENHANCED_1:
    -+		if (teid.esop1_acc_list_or_dat) {
    ++		if (teid.sop_teid_predictable) {/* implies access list or DAT */
     +			if (teid.sop_acc_list)
     +				printf("Type: ACC\n");
     +			else
    @@ lib/s390x/fault.c
     +			printf("Type: KEY or LAP\n");
     +		}
     +		break;
    -+	case SOP_ENHANCED_2:
    -+		switch (teid_esop2_prot_code(teid)) {
    -+		case PROT_KEY_LAP:
    -+			printf("Type: KEY or LAP\n");
    -+			break;
    -+		case PROT_DAT:
    -+			printf("Type: DAT\n");
    -+			break;
    -+		case PROT_KEY:
    -+			printf("Type: KEY\n");
    -+			break;
    -+		case PROT_ACC_LIST:
    -+			printf("Type: ACC\n");
    -+			break;
    -+		case PROT_LAP:
    -+			printf("Type: LAP\n");
    -+			break;
    -+		case PROT_IEP:
    -+			printf("Type: IEP\n");
    -+			break;
    ++	case SOP_ENHANCED_2: {
    ++		static const char * const prot_str[] = {
    ++			"KEY or LAP",
    ++			"DAT",
    ++			"KEY",
    ++			"ACC",
    ++			"LAP",
    ++			"IEP",
    ++		};
    ++		int prot_code = teid_esop2_prot_code(teid);
    + 
    +-	if (prot_is_datp(teid)) {
    +-		printf("Type: DAT\n");
    +-		return;
    ++		assert(0 <= prot_code && prot_code < ARRAY_SIZE(prot_str));
    ++		printf("Type: %s\n", prot_str[prot_code]);
     +		}
      	}
      }
    @@ lib/s390x/interrupt.c: static void fixup_pgm_int(struct stack_frame_int *stack)
      			 * the exception so we can use the return
     
      ## s390x/edat.c ##
    +@@ s390x/edat.c: static void *root, *mem, *m;
    + volatile unsigned int *p;
    + 
    + /*
    +- * Check if a non-access-list protection exception happened for the given
    +- * address, in the primary address space.
    ++ * Check if the exception is consistent with DAT protection and has the correct
    ++ * address and primary address space.
    +  */
    + static bool check_pgm_prot(void *ptr)
    + {
     @@ s390x/edat.c: static bool check_pgm_prot(void *ptr)
      		return false;
      
    @@ s390x/edat.c: static bool check_pgm_prot(void *ptr)
     +	case SOP_BASIC:
     +		if (!teid.sop_teid_predictable)
     +			return true;
    ++		break;
     +	case SOP_ENHANCED_1:
    -+		if (!teid.esop1_acc_list_or_dat)
    ++		if (!teid.sop_teid_predictable) /* implies key or low addr */
     +			return false;
    ++		break;
     +	case SOP_ENHANCED_2:
    -+		if (teid_esop2_prot_code(teid) != 1)
    ++		if (teid_esop2_prot_code(teid) != PROT_DAT)
     +			return false;
     +	}
     +	return (!teid.sop_acc_list && !teid.asce_id &&

base-commit: 2eed0bf1096077144cc3a0dd9974689487f9511a
prerequisite-patch-id: aa682f50e4eba0e9b6cacd245d568f5bcca05e0f
prerequisite-patch-id: 79a88ac3faff3ae2ef214bf4a90de7463e2fdc8a
-- 
2.33.1


             reply	other threads:[~2022-06-08 13:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 13:33 Janis Schoetterl-Glausch [this message]
2022-06-08 13:33 ` [kvm-unit-tests PATCH v2 1/3] s390x: Fix sclp facility bit numbers Janis Schoetterl-Glausch
2022-06-08 13:33 ` [kvm-unit-tests PATCH v2 2/3] s390x: lib: SOP facility query function Janis Schoetterl-Glausch
2022-06-08 13:33 ` [kvm-unit-tests PATCH v2 3/3] s390x: Rework TEID decoding and usage Janis Schoetterl-Glausch
2022-06-08 14:03   ` Claudio Imbrenda
2022-06-08 15:55     ` Janis Schoetterl-Glausch
2022-06-08 16:40       ` Claudio Imbrenda
2022-06-10  9:31   ` Janosch Frank
2022-06-10 10:37     ` Janis Schoetterl-Glausch
2022-06-10 12:10       ` Janosch Frank
2022-06-13 12:40         ` Janis Schoetterl-Glausch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608133303.1532166-1-scgl@linux.ibm.com \
    --to=scgl@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox