]> xenbits.xensource.com Git - xen.git/commitdiff
domctl: introduce a macro to set the grant table max version
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 17 Nov 2021 07:12:00 +0000 (08:12 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 17 Nov 2021 07:12:00 +0000 (08:12 +0100)
Such macro just clamps the passed version to fit in the designated
bits of the domctl field. The main purpose is to make it clearer in
the code when max grant version is being set in the grant_opts field.

Existing users that where setting the version in the grant_opts field
are switched to use the macro.

No functional change intended.

Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Ian Jackson <iwj@xenproject.org>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
tools/helpers/init-xenstore-domain.c
tools/libs/light/libxl_create.c
tools/ocaml/libs/xc/xenctrl_stubs.c
xen/arch/arm/domain_build.c
xen/arch/x86/setup.c
xen/include/public/domctl.h

index 60469161bd475922b23cf1a8e69de0f4e69c3244..b205a79ee6d8cb027736a35c3d5de2d9b8afbacd 100644 (file)
@@ -89,7 +89,7 @@ static int build(xc_interface *xch)
          */
         .max_grant_frames = 4,
         .max_maptrack_frames = 128,
-        .grant_opts = 1,
+        .grant_opts = XEN_DOMCTL_GRANT_version(1),
     };
 
     xs_fd = open("/dev/xen/xenbus_backend", O_RDWR);
index b6855c7b4605c15498fd84d0eb710716ef7caa6f..dcd09d32ba0b7f3e21e7faa4381c582fc063da99 100644 (file)
@@ -629,7 +629,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
             .max_evtchn_port = b_info->event_channels,
             .max_grant_frames = b_info->max_grant_frames,
             .max_maptrack_frames = b_info->max_maptrack_frames,
-            .grant_opts = b_info->max_grant_version,
+            .grant_opts = XEN_DOMCTL_GRANT_version(b_info->max_grant_version),
             .vmtrace_size = ROUNDUP(b_info->vmtrace_buf_kb << 10, XC_PAGE_SHIFT),
         };
 
index eca0b8b3344e43c43e8c8acacba8b24528bb1da7..5b4fe72c8dece9dad16391c69adec51806d2fe0f 100644 (file)
@@ -199,7 +199,8 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
                .max_evtchn_port = Int_val(VAL_MAX_EVTCHN_PORT),
                .max_grant_frames = Int_val(VAL_MAX_GRANT_FRAMES),
                .max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES),
-               .grant_opts = Int_val(VAL_MAX_GRANT_VERSION),
+               .grant_opts =
+                   XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)),
        };
 
        domain_handle_of_uuid_string(cfg.handle, String_val(VAL_HANDLE));
index 19487c79da238de0281c7fb7d3a2d6b56f74b80e..d02bacbcd1edbd86ab7c8ffedd4ad1143494c319 100644 (file)
@@ -2986,7 +2986,7 @@ void __init create_domUs(void)
             .max_evtchn_port = -1,
             .max_grant_frames = -1,
             .max_maptrack_frames = -1,
-            .grant_opts = opt_gnttab_max_version,
+            .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version),
         };
 
         if ( !dt_device_is_compatible(node, "xen,domain") )
@@ -3094,7 +3094,7 @@ void __init create_dom0(void)
         .max_evtchn_port = -1,
         .max_grant_frames = gnttab_dom0_frames(),
         .max_maptrack_frames = -1,
-        .grant_opts = opt_gnttab_max_version,
+        .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version),
     };
 
     /* The vGIC for DOM0 is exactly emulating the hardware GIC */
index ec6e686facc7199c4c68113e06e234128201ceea..da47cdea14a1b22fdbf0f409251aa0f98d6ee3f9 100644 (file)
@@ -755,7 +755,7 @@ static struct domain *__init create_dom0(const module_t *image,
         .max_evtchn_port = -1,
         .max_grant_frames = -1,
         .max_maptrack_frames = -1,
-        .grant_opts = opt_gnttab_max_version,
+        .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version),
         .max_vcpus = dom0_max_vcpus(),
         .arch = {
             .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0,
index 1c21d4dc7512ee2eeec2247ddb77da092857c9f0..b85e6170b0aa9ca104b70cc59ef02fdd5c637946 100644 (file)
@@ -99,6 +99,7 @@ struct xen_domctl_createdomain {
 
 /* Grant version, use low 4 bits. */
 #define XEN_DOMCTL_GRANT_version_mask    0xf
+#define XEN_DOMCTL_GRANT_version(v)      ((v) & XEN_DOMCTL_GRANT_version_mask)
 
     uint32_t grant_opts;