Skip to contentSkip to conversation

lib: s390: fix guest length in uv_create_guest()

PATCH Applied Claudio Imbrenda 2 participants 3 messages Apr 18, 2024 – Apr 22, 2024 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: s390: fix guest length in uv_create_guest()

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.

---
 lib/s390x/uv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/s390x/uv.c +1 -1
index 23a86179..723bb4f2 100644
@@ -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 +
Signature · 1 line
2.44.0
Reviewed-by on v1 1/1
#1 lore raw

Quoting Claudio Imbrenda (2024-04-18 13:01:40)

Quoted 11 lines

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.

Applied
#2 lore raw
In reply to Claudio Imbrenda

Quoting Claudio Imbrenda (2024-04-18 13:01:40)

Quoted 11 lines

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.

Pushed to CI and queued, thanks.