[kvm-unit-tests PATCH v2 8/8] s390x: uv-host: Fix init storage origin and length check

Janosch Frank
2022-07-06T06:41:33Z

The origin and length are masked with the HPAGE_MASK and PAGE_MASK
respectively so adding a few bytes doesn't matter at all.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
s390x/uv-host.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/s390x/uv-host.c b/s390x/uv-host.c
index 1ed8ded1..b1412a20 100644
--- a/s390x/uv-host.c
+++ b/s390x/uv-host.c
@@ -516,17 +516,22 @@ static void test_init(void)
"storage invalid length");
uvcb_init.stor_len += 8;

- uvcb_init.stor_origin = get_max_ram_size() + 8;
+ /* Storage origin is 1MB aligned, the length is 4KB aligned */
+ uvcb_init.stor_origin = get_max_ram_size();
rc = uv_call(0, (uint64_t)&uvcb_init);
- report(rc == 1 && uvcb_init.header.rc == 0x104,
+ report(rc == 1 && (uvcb_init.header.rc == 0x104 || uvcb_init.header.rc == 0x105),
"storage origin invalid");
uvcb_init.stor_origin = mem;

- uvcb_init.stor_origin = get_max_ram_size() - 8;
- rc = uv_call(0, (uint64_t)&uvcb_init);
- report(rc == 1 && uvcb_init.header.rc == 0x105,
- "storage + length invalid");
- uvcb_init.stor_origin = mem;
+ if (uvcb_init.stor_len >= HPAGE_SIZE) {
+ uvcb_init.stor_origin = get_max_ram_size() - HPAGE_SIZE;
+ rc = uv_call(0, (uint64_t)&uvcb_init);
+ report(rc == 1 && uvcb_init.header.rc == 0x105,
+ "storage + length invalid");
+ uvcb_init.stor_origin = mem;
+ } else {
+ report_skip("storage + length invalid, stor_len < HPAGE_SIZE");
+ }

uvcb_init.stor_origin = 1UL << 30;
rc = uv_call(0, (uint64_t)&uvcb_init);
--
2.34.1