diff mbox series

[kvm-unit-tests,1/8] s390x: uv-host: Fix UV init test memory allocation

Message ID 20230323103913.40720-2-frankja@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390x: uv-host: Fixups and extensions part 1 | expand

Commit Message

Janosch Frank March 23, 2023, 10:39 a.m. UTC
The init memory has to be above 2G and 1M aligned but we're currently
aligning on 2G which means the allocations need a lot of unused
memory.

Let's fix that.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/uv-host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nico Boehr March 23, 2023, 12:29 p.m. UTC | #1
Quoting Janosch Frank (2023-03-23 11:39:06)
> The init memory has to be above 2G and 1M aligned but we're currently
> aligning on 2G which means the allocations need a lot of unused
> memory.
> 
> Let's fix that.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  s390x/uv-host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/s390x/uv-host.c b/s390x/uv-host.c
> index 33e6eec6..68de47e7 100644
> --- a/s390x/uv-host.c
> +++ b/s390x/uv-host.c
> @@ -555,7 +555,7 @@ static void test_init(void)
>         rc = uv_call(0, (uint64_t)&uvcb_init);
>         report(rc == 0 && uvcb_init.header.rc == UVC_RC_EXECUTED, "successful");
>  
> -       mem = (uint64_t)memalign(1UL << 31, uvcb_qui.uv_base_stor_len);
> +       mem = (uint64_t)memalign_pages_flags(HPAGE_SIZE, uvcb_qui.uv_base_stor_len, AREA_NORMAL);
>         rc = uv_call(0, (uint64_t)&uvcb_init);
>         report(rc == 1 && uvcb_init.header.rc == 0x101, "double init");
>         free((void *)mem);

Your fix looks reasonable, but I think this is still broken, no?

We allocate a new mem, initalize the ultravisor again and then free the memory. We do absolutely nothing with the allocated memory, do we?

Are we maybe missing a
  uvcb_init.stor_origin = mem;
here?

Also, a comment stating that AREA_NORMAL starts at PFN 524288 (2G) might be nice.
diff mbox series

Patch

diff --git a/s390x/uv-host.c b/s390x/uv-host.c
index 33e6eec6..68de47e7 100644
--- a/s390x/uv-host.c
+++ b/s390x/uv-host.c
@@ -555,7 +555,7 @@  static void test_init(void)
 	rc = uv_call(0, (uint64_t)&uvcb_init);
 	report(rc == 0 && uvcb_init.header.rc == UVC_RC_EXECUTED, "successful");
 
-	mem = (uint64_t)memalign(1UL << 31, uvcb_qui.uv_base_stor_len);
+	mem = (uint64_t)memalign_pages_flags(HPAGE_SIZE, uvcb_qui.uv_base_stor_len, AREA_NORMAL);
 	rc = uv_call(0, (uint64_t)&uvcb_init);
 	report(rc == 1 && uvcb_init.header.rc == 0x101, "double init");
 	free((void *)mem);