]> xenbits.xensource.com Git - xen.git/commitdiff
tools: Drop xc_cpuid_check() and bindings
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 17 Jul 2017 12:38:03 +0000 (13:38 +0100)
committerWei Liu <wei.liu2@citrix.com>
Thu, 20 Jul 2017 16:35:52 +0000 (17:35 +0100)
There are no current users which I can locate.  One piece of xend which didn't
move forwards into xl/libxl is this:

  #   Configure host CPUID consistency checks, which must be satisfied for this
  #   VM to be allowed to run on this host's processor type:
  #cpuid_check=[ '1:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx1xxxxx' ]
  # - Host must have VMX feature flag set

The implementation of xc_cpuid_check() is conceptually broken.  Dom0's view of
CPUID is not the approprite view to check, and will be wrong in the presence
of CPUID masking/faulting, and for HVM-based toolstack domains.

If it turns out that the functionality is required, it should be implemented
in terms of XEN_SYSCTL_get_cpuid_policy to use the proper CPUID view.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxc/include/xenctrl.h
tools/libxc/xc_cpuid_x86.c
tools/ocaml/libs/xc/xenctrl.ml
tools/ocaml/libs/xc/xenctrl.mli
tools/ocaml/libs/xc/xenctrl_stubs.c
tools/python/xen/lowlevel/xc/xc.c

index 552a4fd47d54e78823eac5e1a0199abf0b732716..bde831397a4394605f16e656112bdce2195ca3b4 100644 (file)
@@ -1793,10 +1793,6 @@ int xc_domain_debug_control(xc_interface *xch,
                             uint32_t vcpu);
 
 #if defined(__i386__) || defined(__x86_64__)
-int xc_cpuid_check(xc_interface *xch,
-                   const unsigned int *input,
-                   const char **config,
-                   char **config_transformed);
 int xc_cpuid_set(xc_interface *xch,
                  domid_t domid,
                  const unsigned int *input,
index 1bedf050b8e6a19a554017acd1a3504961a52879..d89093504465ac1c7fb3a67d49266ba27882e46e 100644 (file)
@@ -776,63 +776,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, domid_t domid,
     return rc;
 }
 
-/*
- * Check whether a VM is allowed to launch on this host's processor type.
- *
- * @config format is similar to that of xc_cpuid_set():
- *  '1' -> the bit must be set to 1
- *  '0' -> must be 0
- *  'x' -> we don't care
- *  's' -> (same) must be the same
- */
-int xc_cpuid_check(
-    xc_interface *xch, const unsigned int *input,
-    const char **config,
-    char **config_transformed)
-{
-    int i, j, rc;
-    unsigned int regs[4];
-
-    memset(config_transformed, 0, 4 * sizeof(*config_transformed));
-
-    cpuid(input, regs);
-
-    for ( i = 0; i < 4; i++ )
-    {
-        if ( config[i] == NULL )
-            continue;
-        config_transformed[i] = alloc_str();
-        if ( config_transformed[i] == NULL )
-        {
-            rc = -ENOMEM;
-            goto fail_rc;
-        }
-        for ( j = 0; j < 32; j++ )
-        {
-            unsigned char val = !!((regs[i] & (1U << (31 - j))));
-            if ( !strchr("10xs", config[i][j]) ||
-                 ((config[i][j] == '1') && !val) ||
-                 ((config[i][j] == '0') && val) )
-                goto fail;
-            config_transformed[i][j] = config[i][j];
-            if ( config[i][j] == 's' )
-                config_transformed[i][j] = '0' + val;
-        }
-    }
-
-    return 0;
-
- fail:
-    rc = -EPERM;
- fail_rc:
-    for ( i = 0; i < 4; i++ )
-    {
-        free(config_transformed[i]);
-        config_transformed[i] = NULL;
-    }
-    return rc;
-}
-
 /*
  * Configure a single input with the informatiom from config.
  *
index 75006e711cbe09354b699add364c584412e84b46..70a325b0e9dad816187ef0dd88b1ffd8f144ab58 100644 (file)
@@ -218,8 +218,6 @@ external domain_cpuid_set: handle -> domid -> (int64 * (int64 option))
        = "stub_xc_domain_cpuid_set"
 external domain_cpuid_apply_policy: handle -> domid -> unit
        = "stub_xc_domain_cpuid_apply_policy"
-external cpuid_check: handle -> (int64 * (int64 option)) -> string option array -> (bool * string option array)
-       = "stub_xc_cpuid_check"
 
 external map_foreign_range: handle -> domid -> int
                          -> nativeint -> Xenmmap.mmap_interface
index 720e4b2f9295d148708e524fbf58d103464fd3dc..702d8a7ab8192a2633d9844f0fdfec7450f29abc 100644 (file)
@@ -179,6 +179,3 @@ external domain_cpuid_set: handle -> domid -> (int64 * (int64 option))
        = "stub_xc_domain_cpuid_set"
 external domain_cpuid_apply_policy: handle -> domid -> unit
        = "stub_xc_domain_cpuid_apply_policy"
-external cpuid_check: handle -> (int64 * (int64 option)) -> string option array -> (bool * string option array)
-       = "stub_xc_cpuid_check"
-
index f1b28db53a05b8f471fa4d4b3adc5eab0c5c85e0..c66732f67c892fe9eacee049779cfb94e6a55b7d 100644 (file)
@@ -805,49 +805,6 @@ CAMLprim value stub_xc_domain_cpuid_apply_policy(value xch, value domid)
        CAMLreturn(Val_unit);
 }
 
-CAMLprim value stub_xc_cpuid_check(value xch, value input, value config)
-{
-       CAMLparam3(xch, input, config);
-       CAMLlocal3(ret, array, tmp);
-#if defined(__i386__) || defined(__x86_64__)
-       int r;
-       unsigned int c_input[2];
-       char *c_config[4], *out_config[4];
-
-       c_config[0] = string_of_option_array(config, 0);
-       c_config[1] = string_of_option_array(config, 1);
-       c_config[2] = string_of_option_array(config, 2);
-       c_config[3] = string_of_option_array(config, 3);
-
-       cpuid_input_of_val(c_input[0], c_input[1], input);
-
-       array = caml_alloc(4, 0);
-       for (r = 0; r < 4; r++) {
-               tmp = Val_none;
-               if (c_config[r]) {
-                       tmp = caml_alloc_small(1, 0);
-                       Field(tmp, 0) = caml_alloc_string(32);
-               }
-               Store_field(array, r, tmp);
-       }
-
-       for (r = 0; r < 4; r++)
-               out_config[r] = (c_config[r]) ? String_val(Field(Field(array, r), 0)) : NULL;
-
-       r = xc_cpuid_check(_H(xch), c_input, (const char **)c_config, out_config);
-       if (r < 0)
-               failwith_xc(_H(xch));
-
-       ret = caml_alloc_tuple(2);
-       Store_field(ret, 0, Val_bool(r));
-       Store_field(ret, 1, array);
-
-#else
-       caml_failwith("xc_domain_cpuid_check: not implemented");
-#endif
-       CAMLreturn(ret);
-}
-
 CAMLprim value stub_xc_version_version(value xch)
 {
        CAMLparam1(xch);
index 5d112af6e04cee75b2571b225db2b00d7e96e637..aa9f8e4d9e6d82209f9aaa294c6d49a300aba5b0 100644 (file)
@@ -711,29 +711,6 @@ static PyObject *pyxc_create_cpuid_dict(char **regs)
    return dict;
 }
 
-static PyObject *pyxc_dom_check_cpuid(XcObject *self,
-                                      PyObject *args)
-{
-    PyObject *sub_input, *config;
-    unsigned int input[2];
-    char *regs[4], *regs_transform[4];
-
-    if ( !PyArg_ParseTuple(args, "iOO", &input[0], &sub_input, &config) )
-        return NULL;
-
-    pyxc_dom_extract_cpuid(config, regs);
-
-    input[1] = XEN_CPUID_INPUT_UNUSED;
-    if ( PyLong_Check(sub_input) )
-        input[1] = PyLong_AsUnsignedLong(sub_input);
-
-    if ( xc_cpuid_check(self->xc_handle, input,
-                        (const char **)regs, regs_transform) )
-        return pyxc_error_to_exception(self->xc_handle);
-
-    return pyxc_create_cpuid_dict(regs_transform);
-}
-
 static PyObject *pyxc_dom_set_policy_cpuid(XcObject *self,
                                            PyObject *args)
 {
@@ -2467,17 +2444,6 @@ static PyMethodDef pyxc_methods[] = {
       " keys    [str]: String of keys to inject.\n" },
 
 #if defined(__i386__) || defined(__x86_64__)
-    { "domain_check_cpuid", 
-      (PyCFunction)pyxc_dom_check_cpuid, 
-      METH_VARARGS, "\n"
-      "Apply checks to host CPUID.\n"
-      " input [long]: Input for cpuid instruction (eax)\n"
-      " sub_input [long]: Second input (optional, may be None) for cpuid "
-      "                     instruction (ecx)\n"
-      " config [dict]: Dictionary of register\n"
-      " config [dict]: Dictionary of register, use for checking\n\n"
-      "Returns: [int] 0 on success; exception on error.\n" },
-    
     { "domain_set_cpuid", 
       (PyCFunction)pyxc_dom_set_cpuid, 
       METH_VARARGS, "\n"