Skip to content

s390x: Test effect of storage keys on some instructions

Janis Schoetterl-Glausch kvm linux-s390 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest3 patches 4 repliesIn review
  2. v63 patches 7 repliesSuperseded

Changes in v7 from the cover letter

* Add fetch-protection override test case to TPROT test
* Change reporting of TPROT test to be more in line with other tests

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3s390x: Give name to return value of tprot()lib/s390x/asm/arch_def.h lib/s390x/sclp.c s390x/tprot.c+24 -171 reply
2/3s390x: Test effect of storage keys on some instructionslib/s390x/asm/arch_def.h s390x/skey.c+260 -92 replies
3/3Disable s390x skey test in GitLab CI.gitlab-ci.yml+1 -10 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchClaudio ImbrendaJanosch FrankThomas Huth
1/3R-b R-b R-b
2/3A-b A-b
3/3A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v7 thread

Cover letter [kvm-unit-tests PATCH v7 0/3] s390x: Test effect of storage keys on some instructions

See range diff below for changes. Since I messed up the addressees for the cover letter for the last version, the diff is against v5.

v6 -> v7:
* Add fetch-protection override test case to TPROT test
* Change reporting of TPROT test to be more in line with other tests

v5 -> v6:
* Disable skey test in GitLab CI, needs kernel 5.18
* Added comment to test_set_prefix
* Introduce names for tprot return values

...

v2 -> v3:
* fix asm for SET PREFIX zero key test: make input
* implement Thomas' suggestions:
https://lore.kernel.org/kvm/[email protected]/

v1 -> v2:
* use install_page instead of manual page table entry manipulation
* check that no store occurred if none is expected
* try to check that no fetch occurred if not expected, although in practice a fetch would probably cause the test to crash
* reset storage key to 0 after test

Janis Schoetterl-Glausch (3):
s390x: Give name to return value of tprot()
s390x: Test effect of storage keys on some instructions Disable s390x skey test in GitLab CI

 lib/s390x/asm/arch_def.h |  31 +++--
 lib/s390x/sclp.c         |   6 +-
 s390x/skey.c             | 250 +++++++++++++++++++++++++++++++++++++++
 s390x/tprot.c            |  24 ++--
 .gitlab-ci.yml           |   2 +-
 5 files changed, 286 insertions(+), 27 deletions(-)

Range-diff against v5:

-:  -------- > 1:  6b11f01d s390x: Give name to return value of tprot()
1:  89e59626 ! 2:  e3df88c6 s390x: Test effect of storage keys on some instructions
    @@ s390x/skey.c: static void test_invalid_address(void)
     +	report_prefix_push("TPROT");
     +
     +	set_storage_key(pagebuf, 0x10, 0);
    -+	report(tprot(addr, 0) == 0, "access key 0 -> no protection");
    -+	report(tprot(addr, 1) == 0, "access key matches -> no protection");
    -+	report(tprot(addr, 2) == 1, "access key mismatches, no fetch protection -> store protection");
    ++	report(tprot(addr, 0) == TPROT_READ_WRITE, "zero key: no protection");
    ++	report(tprot(addr, 1) == TPROT_READ_WRITE, "matching key: no protection");
    ++
    ++	report_prefix_push("mismatching key");
    ++
    ++	report(tprot(addr, 2) == TPROT_READ, "no fetch protection: store protection");
    ++
     +
     +	set_storage_key(pagebuf, 0x18, 0);
    -+	report(tprot(addr, 2) == 2, "access key mismatches, fetch protection -> fetch & store protection");
    ++	report(tprot(addr, 2) == TPROT_RW_PROTECTED,
    ++	       "fetch protection: fetch & store protection");
    ++
    ++	report_prefix_push("fetch-protection override");
    ++	set_storage_key(0, 0x18, 0);
    ++	report(tprot(0, 2) == TPROT_RW_PROTECTED, "disabled: fetch & store protection");
    ++	ctl_set_bit(0, CTL0_FETCH_PROTECTION_OVERRIDE);
    ++	report(tprot(0, 2) == TPROT_READ, "enabled: store protection");
    ++	report(tprot(2048, 2) == TPROT_RW_PROTECTED, "invalid: fetch & store protection");
    ++	ctl_clear_bit(0, CTL0_FETCH_PROTECTION_OVERRIDE);
    ++	set_storage_key(0, 0x00, 0);
    ++	report_prefix_pop();
     +
     +	ctl_set_bit(0, CTL0_STORAGE_PROTECTION_OVERRIDE);
     +	set_storage_key(pagebuf, 0x90, 0);
    -+	report(tprot(addr, 2) == 0, "access key mismatches, storage protection override -> no protection");
    ++	report(tprot(addr, 2) == TPROT_READ_WRITE,
    ++	       "storage-protection override: no protection");
     +	ctl_clear_bit(0, CTL0_STORAGE_PROTECTION_OVERRIDE);
     +
    ++	report_prefix_pop();
     +	set_storage_key(pagebuf, 0x00, 0);
     +	report_prefix_pop();
     +}
    @@ s390x/skey.c: static void test_invalid_address(void)
     +#define PREFIX_AREA_SIZE (PAGE_SIZE * 2)
     +static char lowcore_tmp[PREFIX_AREA_SIZE] __attribute__((aligned(PREFIX_AREA_SIZE)));
     +
    ++/*
    ++ * Test accessibility of the operand to SET PREFIX given different configurations
    ++ * with regards to storage keys. That is, check the accessibility of the location
    ++ * holding the new prefix, not that of the new prefix area. The new prefix area
    ++ * is a valid lowcore, so that the test does not crash on failure.
    ++ */
     +static void test_set_prefix(void)
     +{
     +	uint32_t *prefix_ptr = (uint32_t *)pagebuf;

-: -------- > 3: c3236718 Disable s390x skey test in GitLab CI

base-commit: 6a7a83ed106211fc0ee530a3a05f171f6a4c4e66

Signature · 1 line
2.33.1