[kvm-unit-tests PATCH v4 0/4] More skey instr. emulation test

Janis Schoetterl-Glausch
2022-06-08T17:45:52Z

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 v2 of s390x: Rework TEID decoding and usage .
https://lore.kernel.org/kvm/20220608133303.1532166-1-scgl@linux.ibm.com/

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 | 381 +++++++++++++++++++++++++++++++++++++++++++-
s390x/unittests.cfg | 1 +
2 files changed, 376 insertions(+), 6 deletions(-)

Range-diff against v3:
1: 073ffb3c ! 1: fbfd7e3b 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");
+ break;
+ case SOP_ENHANCED_1:
-+ report(!teid.esop1_acc_list_or_dat, "valid protection code");
++ report(!teid.sop_teid_predictable, "valid protection code");
+ break;
+ case SOP_ENHANCED_2:
+ switch (teid_esop2_prot_code(teid)) {
@@ s390x/skey.c: static void test_set_prefix(void)

@@ s390x/skey.c: static void test_set_prefix(void)
install_page(root, virt_to_pte_phys(root, pagebuf), 0);
- set_prefix_key_1((uint32_t *)&mem_all[2048]);
+ set_prefix_key_1(OPAQUE_PTR(2048));
install_page(root, 0, 0);
- check_pgm_int_code(PGM_INT_CODE_PROTECTION);
+ check_key_prot_exc(ACC_FETCH, PROT_FETCH_STORE);
2: 9f300b87 ! 2: 868bb863 s390x: Test effect of storage keys on some more instructions
@@ Commit message
fetch protection override.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
+ Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

## s390x/skey.c ##
@@
@@ s390x/skey.c: static void test_set_prefix(void)
+ set_storage_key(pagebuf, 0x28, 0);
+ expect_pgm_int();
+ install_page(root, virt_to_pte_phys(root, pagebuf), 0);
-+ modify_subchannel_key_1(test_device_sid, (struct schib *)&mem_all[2048]);
++ modify_subchannel_key_1(test_device_sid, OPAQUE_PTR(2048));
+ install_page(root, 0, 0);
+ check_key_prot_exc(ACC_FETCH, PROT_FETCH_STORE);
+ cc = stsch(test_device_sid, schib);
3: c4ca0619 ! 3: d49934c0 s390x: Test effect of storage keys on diag 308
@@ Commit message
Test that key-controlled protection does not apply to diag 308.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
+ Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

## s390x/skey.c ##
@@ s390x/skey.c: static void test_store_cpu_address(void)

base-commit: 2eed0bf1096077144cc3a0dd9974689487f9511a
prerequisite-patch-id: aa682f50e4eba0e9b6cacd245d568f5bcca05e0f
prerequisite-patch-id: 79a88ac3faff3ae2ef214bf4a90de7463e2fdc8a
prerequisite-patch-id: bebbc71ca3cc8d085e36a049466dba5a420c9c75
prerequisite-patch-id: d38a4fc7bc1fa6e352502f294cb9413f0b738b99
prerequisite-patch-id: 181e4127db838f3a98fd2b27ea4f23c53da908d7
--
2.33.1