Re: [kvm-unit-tests PATCH 2/9] s390x: pfmf: Fix 1MB handling

Claudio Imbrenda
2021-09-22T09:35:41Z

On Wed, 22 Sep 2021 07:18:04 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> On everything larger than 4k pfmf will update the address in GR2 when
> it's interrupted so we should loop on pfmf and not trust that it
> doesn't get interrupted.
>
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
> s390x/pfmf.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/s390x/pfmf.c b/s390x/pfmf.c
> index 2f3cb110..b0095bd7 100644
> --- a/s390x/pfmf.c
> +++ b/s390x/pfmf.c
> @@ -54,6 +54,7 @@ static void test_1m_key(void)
> bool rp = true;
> union pfmf_r1 r1;
> union skey skey;
> + void *addr = pagebuf;
>
> report_prefix_push("1M");
> if (test_facility(169)) {
> @@ -64,7 +65,9 @@ static void test_1m_key(void)
> r1.reg.sk = 1;
> r1.reg.fsc = PFMF_FSC_1M;
> r1.reg.key = 0x30;
> - pfmf(r1.val, pagebuf);
> + do {
> + addr = pfmf(r1.val, addr);
> + } while ((uintptr_t)addr != (uintptr_t)pagebuf + HPAGE_SIZE);
> for (i = 0; i < 256; i++) {
> skey.val = get_storage_key(pagebuf + i * PAGE_SIZE);
> skey.val &= SKEY_ACC | SKEY_FP;
> @@ -99,6 +102,7 @@ static void test_1m_clear(void)
> int i;
> union pfmf_r1 r1;
> unsigned long sum = 0;
> + void *addr = pagebuf;
>
> r1.val = 0;
> r1.reg.cf = 1;
> @@ -106,7 +110,9 @@ static void test_1m_clear(void)
>
> report_prefix_push("1M");
> memset(pagebuf, 42, PAGE_SIZE * 256);
> - pfmf(r1.val, pagebuf);
> + do {
> + addr = pfmf(r1.val, addr);
> + } while ((uintptr_t)addr != (uintptr_t)pagebuf + HPAGE_SIZE);
> for (i = 0; i < PAGE_SIZE * 256; i++)
> sum |= pagebuf[i];
> report(!sum, "clear memory");