diff mbox series

[for-4.16,1/4] domctl: introduce a macro to set the grant table max version

Message ID 20211115121741.3719-2-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series gnttab: fallout/improvements from max version | expand

Commit Message

Roger Pau Monné Nov. 15, 2021, 12:17 p.m. UTC
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>
---
Cc: Ian Jackson <iwj@xenproject.org>

Given it's a non functional change (or at least that's the intention)
it shouldn't have any impact on the release, it's just syntactic
sugar.
---
 tools/helpers/init-xenstore-domain.c | 2 +-
 tools/libs/light/libxl_create.c      | 2 +-
 tools/ocaml/libs/xc/xenctrl_stubs.c  | 3 ++-
 xen/arch/arm/domain_build.c          | 4 ++--
 xen/arch/x86/setup.c                 | 2 +-
 xen/include/public/domctl.h          | 1 +
 6 files changed, 8 insertions(+), 6 deletions(-)

Comments

Jan Beulich Nov. 15, 2021, 12:20 p.m. UTC | #1
On 15.11.2021 13:17, Roger Pau Monne wrote:
> 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>
Andrew Cooper Nov. 15, 2021, 12:26 p.m. UTC | #2
On 15/11/2021 12:17, Roger Pau Monne wrote:
> 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>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Bertrand Marquis Nov. 15, 2021, 1:23 p.m. UTC | #3
Hi Roger,

> On 15 Nov 2021, at 12:17, Roger Pau Monne <roger.pau@citrix.com> wrote:
> 
> 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: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> Cc: Ian Jackson <iwj@xenproject.org>
> 
> Given it's a non functional change (or at least that's the intention)
> it shouldn't have any impact on the release, it's just syntactic
> sugar.
> ---
> tools/helpers/init-xenstore-domain.c | 2 +-
> tools/libs/light/libxl_create.c      | 2 +-
> tools/ocaml/libs/xc/xenctrl_stubs.c  | 3 ++-
> xen/arch/arm/domain_build.c          | 4 ++--
> xen/arch/x86/setup.c                 | 2 +-
> xen/include/public/domctl.h          | 1 +
> 6 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c
> index 60469161bd..b205a79ee6 100644
> --- a/tools/helpers/init-xenstore-domain.c
> +++ b/tools/helpers/init-xenstore-domain.c
> @@ -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);
> diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
> index b6855c7b46..dcd09d32ba 100644
> --- a/tools/libs/light/libxl_create.c
> +++ b/tools/libs/light/libxl_create.c
> @@ -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),
>         };
> 
> diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
> index eca0b8b334..5b4fe72c8d 100644
> --- a/tools/ocaml/libs/xc/xenctrl_stubs.c
> +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
> @@ -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));
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 19487c79da..d02bacbcd1 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -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 */
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index ec6e686fac..da47cdea14 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -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,
> diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
> index 1c21d4dc75..b85e6170b0 100644
> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -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;
> 
> -- 
> 2.33.0
>
Julien Grall Nov. 15, 2021, 1:58 p.m. UTC | #4
Hi Roger,

On 15/11/2021 12:17, Roger Pau Monne wrote:
> 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>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,
Ian Jackson Nov. 16, 2021, 5:14 p.m. UTC | #5
Julien Grall writes ("Re: [PATCH for-4.16 1/4] domctl: introduce a macro to set the grant table max version"):
> On 15/11/2021 12:17, Roger Pau Monne wrote:
> > 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>
> 
> Acked-by: Julien Grall <jgrall@amazon.com>

Reviewed-by: Ian Jackson <iwj@xenproject.org>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
diff mbox series

Patch

diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c
index 60469161bd..b205a79ee6 100644
--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -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);
diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index b6855c7b46..dcd09d32ba 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -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),
         };
 
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index eca0b8b334..5b4fe72c8d 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -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));
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 19487c79da..d02bacbcd1 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -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 */
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index ec6e686fac..da47cdea14 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -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,
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 1c21d4dc75..b85e6170b0 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -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;