diff mbox series

[v1,1/1] lib: s390: fix guest length in uv_create_guest()

Message ID 20240418110140.62406-1-imbrenda@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/1] lib: s390: fix guest length in uv_create_guest() | expand

Commit Message

Claudio Imbrenda April 18, 2024, 11:01 a.m. UTC
The current code creates secure guests with significantly more memory
than expected, but since none of that memory is ever touched,
everything still works.

Fix the issue by specifying the actual guest length.

The MSL does not contain the length of the guest, but the address of
the last 1M block of guest memory. In order to get the length, MSO
needs to be subtracted, and 1M needs to be added.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 lib/s390x/uv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nico Boehr April 18, 2024, 12:38 p.m. UTC | #1
Quoting Claudio Imbrenda (2024-04-18 13:01:40)
> The current code creates secure guests with significantly more memory
> than expected, but since none of that memory is ever touched,
> everything still works.
> 
> Fix the issue by specifying the actual guest length.
> 
> The MSL does not contain the length of the guest, but the address of
> the last 1M block of guest memory. In order to get the length, MSO
> needs to be subtracted, and 1M needs to be added.
> 
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Nico Boehr April 22, 2024, 1:40 p.m. UTC | #2
Quoting Claudio Imbrenda (2024-04-18 13:01:40)
> The current code creates secure guests with significantly more memory
> than expected, but since none of that memory is ever touched,
> everything still works.
> 
> Fix the issue by specifying the actual guest length.
> 
> The MSL does not contain the length of the guest, but the address of
> the last 1M block of guest memory. In order to get the length, MSO
> needs to be subtracted, and 1M needs to be added.
> 
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

Pushed to CI and queued, thanks.
diff mbox series

Patch

diff --git a/lib/s390x/uv.c b/lib/s390x/uv.c
index 23a86179..723bb4f2 100644
--- a/lib/s390x/uv.c
+++ b/lib/s390x/uv.c
@@ -146,7 +146,7 @@  void uv_create_guest(struct vm *vm)
 	int cc;
 
 	uvcb_cgc.guest_stor_origin = vm->sblk->mso;
-	uvcb_cgc.guest_stor_len = vm->sblk->msl;
+	uvcb_cgc.guest_stor_len = vm->sblk->msl - vm->sblk->mso + SZ_1M;
 
 	/* Config allocation */
 	vsize = uvcb_qui.conf_base_virt_stor_len +