mbox series

[kvm-unit-tests,v5,0/3] More skey instr. emulation test

Message ID 20220621143609.753452-1-scgl@linux.ibm.com (mailing list archive)
Headers show
Series More skey instr. emulation test | expand

Message

Janis Schoetterl-Glausch June 21, 2022, 2:36 p.m. UTC
Add test cases similar to those testing the effect of storage keys on
instructions emulated by KVM, but test instructions emulated by user
space/qemu instead.
Test that DIAG 308 is not subject to key protection.
Additionally, check the transaction exception identification on
protection exceptions.

This series is based on v3 of s390x: Rework TEID decoding and usage .

v4 -> v5
 * rebase onto v3 of TEID series
 * ignore ancient machines without at least ESOP-1

v3 -> v4
 * rebase on newest TEID decoding series
 * pick up r-b's (Thanks Claudio)
 * add check for protection code validity in case of basic SOP

v2 -> v3
 * move sclp patch and part of TEID test to series
       s390x: Rework TEID decoding and usage
 * make use of reworked TEID union in skey TEID test
 * get rid of pointer to array for diag 308 test
 * use lowcore symbol and mem_all
 * don't reset intparm when expecting exception in msch test

v1 -> v2
 * don't mixup sclp fix with new bits for the TEID patch
 * address feedback
       * cosmetic changes, i.e. shortening identifiers
       * remove unconditional report_info
 * add DIAG 308 test

Janis Schoetterl-Glausch (3):
  s390x: Test TEID values in storage key test
  s390x: Test effect of storage keys on some more instructions
  s390x: Test effect of storage keys on diag 308

 s390x/skey.c        | 379 +++++++++++++++++++++++++++++++++++++++++++-
 s390x/unittests.cfg |   1 +
 2 files changed, 374 insertions(+), 6 deletions(-)

Range-diff against v4:
1:  fbfd7e3b ! 1:  a30f2b45 s390x: Test TEID values in storage key test
    @@ s390x/skey.c: static void test_test_protection(void)
     +{
     +	union teid teid;
     +	int access_code;
    -+	bool dat;
     +
     +	check_pgm_int_code(PGM_INT_CODE_PROTECTION);
     +	report_prefix_push("TEID");
     +	teid.val = lowcore.trans_exc_id;
     +	switch (get_supp_on_prot_facility()) {
     +	case SOP_NONE:
    -+		break;
     +	case SOP_BASIC:
    -+		dat = extract_psw_mask() & PSW_MASK_DAT;
    -+		report(!teid.sop_teid_predictable || !dat || !teid.sop_acc_list,
    -+		       "valid protection code");
    ++		/* let's ignore ancient/irrelevant machines */
     +		break;
     +	case SOP_ENHANCED_1:
     +		report(!teid.sop_teid_predictable, "valid protection code");
    ++		/* no access code in case of key protection */
     +		break;
     +	case SOP_ENHANCED_2:
     +		switch (teid_esop2_prot_code(teid)) {
     +		case PROT_KEY:
    -+			access_code = teid.acc_exc_f_s;
    ++			/* ESOP-2: no need to check facility */
    ++			access_code = teid.acc_exc_fetch_store;
     +
     +			switch (access_code) {
     +			case 0:
    @@ s390x/skey.c: static void test_test_protection(void)
     +				break;
     +			}
     +			/* fallthrough */
    -+		case PROT_KEY_LAP:
    ++		case PROT_KEY_OR_LAP:
     +			report_pass("valid protection code");
     +			break;
     +		default:
2:  868bb863 = 2:  b194f716 s390x: Test effect of storage keys on some more instructions
3:  d49934c0 = 3:  460d77ec s390x: Test effect of storage keys on diag 308

base-commit: 610c15284a537484682adfb4b6d6313991ab954f
prerequisite-patch-id: bebbc71ca3cc8d085e36a049466dba5a420c9c75
prerequisite-patch-id: d38a4fc7bc1fa6e352502f294cb9413f0b738b99
prerequisite-patch-id: 15d25aaab40e81ad60a13218eaba370585c4a87e

Comments

Claudio Imbrenda June 21, 2022, 3:40 p.m. UTC | #1
On Tue, 21 Jun 2022 16:36:06 +0200
Janis Schoetterl-Glausch <scgl@linux.ibm.com> wrote:

> Add test cases similar to those testing the effect of storage keys on
> instructions emulated by KVM, but test instructions emulated by user
> space/qemu instead.
> Test that DIAG 308 is not subject to key protection.
> Additionally, check the transaction exception identification on
> protection exceptions.

thanks, queued

> 
> This series is based on v3 of s390x: Rework TEID decoding and usage .
> 
> v4 -> v5
>  * rebase onto v3 of TEID series
>  * ignore ancient machines without at least ESOP-1
> 
> v3 -> v4
>  * rebase on newest TEID decoding series
>  * pick up r-b's (Thanks Claudio)
>  * add check for protection code validity in case of basic SOP
> 
> v2 -> v3
>  * move sclp patch and part of TEID test to series
>        s390x: Rework TEID decoding and usage
>  * make use of reworked TEID union in skey TEID test
>  * get rid of pointer to array for diag 308 test
>  * use lowcore symbol and mem_all
>  * don't reset intparm when expecting exception in msch test
> 
> v1 -> v2
>  * don't mixup sclp fix with new bits for the TEID patch
>  * address feedback
>        * cosmetic changes, i.e. shortening identifiers
>        * remove unconditional report_info
>  * add DIAG 308 test
> 
> Janis Schoetterl-Glausch (3):
>   s390x: Test TEID values in storage key test
>   s390x: Test effect of storage keys on some more instructions
>   s390x: Test effect of storage keys on diag 308
> 
>  s390x/skey.c        | 379 +++++++++++++++++++++++++++++++++++++++++++-
>  s390x/unittests.cfg |   1 +
>  2 files changed, 374 insertions(+), 6 deletions(-)
> 
> Range-diff against v4:
> 1:  fbfd7e3b ! 1:  a30f2b45 s390x: Test TEID values in storage key test
>     @@ s390x/skey.c: static void test_test_protection(void)
>      +{
>      +	union teid teid;
>      +	int access_code;
>     -+	bool dat;
>      +
>      +	check_pgm_int_code(PGM_INT_CODE_PROTECTION);
>      +	report_prefix_push("TEID");
>      +	teid.val = lowcore.trans_exc_id;
>      +	switch (get_supp_on_prot_facility()) {
>      +	case SOP_NONE:
>     -+		break;
>      +	case SOP_BASIC:
>     -+		dat = extract_psw_mask() & PSW_MASK_DAT;
>     -+		report(!teid.sop_teid_predictable || !dat || !teid.sop_acc_list,
>     -+		       "valid protection code");
>     ++		/* let's ignore ancient/irrelevant machines */
>      +		break;
>      +	case SOP_ENHANCED_1:
>      +		report(!teid.sop_teid_predictable, "valid protection code");
>     ++		/* no access code in case of key protection */
>      +		break;
>      +	case SOP_ENHANCED_2:
>      +		switch (teid_esop2_prot_code(teid)) {
>      +		case PROT_KEY:
>     -+			access_code = teid.acc_exc_f_s;
>     ++			/* ESOP-2: no need to check facility */
>     ++			access_code = teid.acc_exc_fetch_store;
>      +
>      +			switch (access_code) {
>      +			case 0:
>     @@ s390x/skey.c: static void test_test_protection(void)
>      +				break;
>      +			}
>      +			/* fallthrough */
>     -+		case PROT_KEY_LAP:
>     ++		case PROT_KEY_OR_LAP:
>      +			report_pass("valid protection code");
>      +			break;
>      +		default:
> 2:  868bb863 = 2:  b194f716 s390x: Test effect of storage keys on some more instructions
> 3:  d49934c0 = 3:  460d77ec s390x: Test effect of storage keys on diag 308
> 
> base-commit: 610c15284a537484682adfb4b6d6313991ab954f
> prerequisite-patch-id: bebbc71ca3cc8d085e36a049466dba5a420c9c75
> prerequisite-patch-id: d38a4fc7bc1fa6e352502f294cb9413f0b738b99
> prerequisite-patch-id: 15d25aaab40e81ad60a13218eaba370585c4a87e