]> xenbits.xensource.com Git - xen.git/commitdiff
tools/ocaml/xc: Fix binding for xc_domain_assign_device()
authorEdwin Török <edwin.torok@cloud.com>
Thu, 12 Jan 2023 11:38:38 +0000 (11:38 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Feb 2023 10:22:12 +0000 (10:22 +0000)
The patch adding this binding was plain broken, and unreviewed.  It modified
the C stub to add a 4th parameter without an equivalent adjustment in the
Ocaml side of the bindings.

In 64bit builds, this causes us to dereference whatever dead value is in %rcx
when trying to interpret the rflags parameter.

This has gone unnoticed because Xapi doesn't use this binding (it has its
own), but unbreak the binding by passing RDM_RELAXED unconditionally for
now (matching the libxl default behaviour).

Fixes: 9b34056cb4 ("tools: extend xc_assign_device() to support rdm reservation policy")
Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/libs/xc/xenctrl_stubs.c

index fd1f306f020238c331b2238e06eafaf2b029785f..291663bb278adb55071b8b27173408765f65fff6 100644 (file)
@@ -1245,17 +1245,12 @@ CAMLprim value stub_xc_domain_test_assign_device(value xch, value domid, value d
        CAMLreturn(Val_bool(ret == 0));
 }
 
-static int domain_assign_device_rdm_flag_table[] = {
-    XEN_DOMCTL_DEV_RDM_RELAXED,
-};
-
-CAMLprim value stub_xc_domain_assign_device(value xch, value domid, value desc,
-                                            value rflag)
+CAMLprim value stub_xc_domain_assign_device(value xch, value domid, value desc)
 {
-       CAMLparam4(xch, domid, desc, rflag);
+       CAMLparam3(xch, domid, desc);
        int ret;
        int domain, bus, dev, func;
-       uint32_t sbdf, flag;
+       uint32_t sbdf;
 
        domain = Int_val(Field(desc, 0));
        bus = Int_val(Field(desc, 1));
@@ -1263,10 +1258,8 @@ CAMLprim value stub_xc_domain_assign_device(value xch, value domid, value desc,
        func = Int_val(Field(desc, 3));
        sbdf = encode_sbdf(domain, bus, dev, func);
 
-       ret = Int_val(Field(rflag, 0));
-       flag = domain_assign_device_rdm_flag_table[ret];
-
-       ret = xc_assign_device(_H(xch), _D(domid), sbdf, flag);
+       ret = xc_assign_device(_H(xch), _D(domid), sbdf,
+                              XEN_DOMCTL_DEV_RDM_RELAXED);
 
        if (ret < 0)
                failwith_xc(_H(xch));