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

[xen stable-4.17] tools/ocaml/xc: Fix binding for xc_domain_assign_device()



commit afdcc108566e5a4ee352b6427c98ebad6885a81d
Author:     Edwin Török <edwin.torok@xxxxxxxxx>
AuthorDate: Thu Jan 12 11:38:38 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu Feb 9 15:55:25 2023 +0000

    tools/ocaml/xc: Fix binding for xc_domain_assign_device()
    
    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@xxxxxxxxx>
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Christian Lindig <christian.lindig@xxxxxxxxxx>
    (cherry picked from commit 4250683842104f02996428f93927a035c8e19266)
---
 tools/ocaml/libs/xc/xenctrl_stubs.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c 
b/tools/ocaml/libs/xc/xenctrl_stubs.c
index e25367531b..f376d94334 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -1139,17 +1139,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));
@@ -1157,10 +1152,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));
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17



 


Rackspace

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