[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen stable-4.20] tools/ocaml: fix 32-bit truncation bug in stub_xc_domain_setmaxmem()



commit f833d29a3af7708b30b6076ed5c48c12481914ef
Author:     Edwin Török <edwin.torok@xxxxxxxxxx>
AuthorDate: Thu Feb 5 13:56:45 2026 +0000
Commit:     Anthony PERARD <anthony.perard@xxxxxxxxxx>
CommitDate: Fri Mar 6 15:02:04 2026 +0100

    tools/ocaml: fix 32-bit truncation bug in stub_xc_domain_setmaxmem()
    
    Observed when attempting to boot a >4TiB VM:
    
    After a call to domain_setmaxmem with 6370254848 (KiB), the domain's maxmem
    got set to 2075287552, which is exactly 2^32 smaller.
    
    xc_domain_setmaxmem takes an uint64_t as a parameter, and the OCaml value
    is 64-bit already, so fix the C variable to match the type and avoid the
    truncation.
    
    Fixes: f5b43e95facd ("libxl: fix "xl mem-set" regression from 0c029c4da2")
    Signed-off-by: Edwin Török <edwin.torok@xxxxxxxxxx>
    Acked-by: Christian Lindig <christian.lindig@xxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    (cherry picked from commit 381b4ff16f7ff83a2dc44f16b8dd0208f3255ec7)
---
 tools/ocaml/libs/xc/xenctrl_stubs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c 
b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 863ab3c778..90353ec89d 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -934,7 +934,7 @@ CAMLprim value stub_xc_domain_setmaxmem(value xch_val, 
value domid,
        int retval;
 
        uint32_t c_domid = Int_val(domid);
-       unsigned int c_max_memkb = Int64_val(max_memkb);
+       uint64_t c_max_memkb = Int64_val(max_memkb);
        caml_enter_blocking_section();
        retval = xc_domain_setmaxmem(xch, c_domid, c_max_memkb);
        caml_leave_blocking_section();
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.20



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.