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

Re: [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option



On Fri, 30 May 2025, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xxxxxxx>
> 
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xxxxxxx>

Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>


> ---
>  docs/man/xl.cfg.5.pod.in         | 9 +++++++++
>  tools/libs/light/libxl_arm.c     | 6 +++---
>  tools/libs/light/libxl_create.c  | 3 +++
>  tools/libs/light/libxl_types.idl | 1 +
>  tools/libs/light/libxl_x86.c     | 6 ++++++
>  tools/xl/xl_parse.c              | 3 +++
>  6 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
> index 7339c44efd..6c303e8efa 100644
> --- a/docs/man/xl.cfg.5.pod.in
> +++ b/docs/man/xl.cfg.5.pod.in
> @@ -3089,6 +3089,15 @@ will be used for the domain. Otherwise, the value 
> specified by the `nr_spis`
>  parameter will be used. The number of SPIs should match the highest interrupt
>  ID that will be assigned to the domain.
>  
> +=item B<trap_unmapped_accesses=BOOLEAN>
> +
> +An Optional boolean parameter that configures handling of accesses to 
> unmapped
> +address ranges. If enabled, guest accesses will trap. If disabled, guest
> +accesses will read all bits as ones, e.g 0xFFFFFFFF for a 32bit access and
> +writes will be ignored.
> +
> +This option is only implemented for ARM where the default is enabled.
> +
>  =back
>  
>  =head3 x86
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index 9530996e72..afc62a5299 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -233,9 +233,6 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>          config->arch.sve_vl = d_config->b_info.arch_arm.sve_vl / 128U;
>      }
>  
> -    /* Trap accesses to unmapped areas. */
> -    config->flags |= XEN_DOMCTL_CDF_trap_unmapped_accesses;
> -
>      return 0;
>  }
>  
> @@ -1714,6 +1711,9 @@ int libxl__arch_domain_build_info_setdefault(libxl__gc 
> *gc,
>      /* ACPI is disabled by default */
>      libxl_defbool_setdefault(&b_info->acpi, false);
>  
> +    /* Trapping of unmapped accesses enabled by default.  */
> +    libxl_defbool_setdefault(&b_info->trap_unmapped_accesses, true);
> +
>      /* Sanitise SVE parameter */
>      if (b_info->arch_arm.sve_vl) {
>          unsigned int max_sve_vl =
> diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
> index e03599ea99..38770eea5b 100644
> --- a/tools/libs/light/libxl_create.c
> +++ b/tools/libs/light/libxl_create.c
> @@ -667,6 +667,9 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config 
> *d_config,
>          if (libxl_defbool_val(b_info->vpmu))
>              create.flags |= XEN_DOMCTL_CDF_vpmu;
>  
> +        if (libxl_defbool_val(b_info->trap_unmapped_accesses))
> +            create.flags |= XEN_DOMCTL_CDF_trap_unmapped_accesses;
> +
>          assert(info->passthrough != LIBXL_PASSTHROUGH_DEFAULT);
>          LOG(DETAIL, "passthrough: %s",
>              libxl_passthrough_to_string(info->passthrough));
> diff --git a/tools/libs/light/libxl_types.idl 
> b/tools/libs/light/libxl_types.idl
> index 9bb2969931..e33785c661 100644
> --- a/tools/libs/light/libxl_types.idl
> +++ b/tools/libs/light/libxl_types.idl
> @@ -736,6 +736,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
>      ("vmtrace_buf_kb", integer),
>  
>      ("vpmu", libxl_defbool),
> +    ("trap_unmapped_accesses", libxl_defbool),
>  
>      ], dir=DIR_IN,
>         copy_deprecated_fn="libxl__domain_build_info_copy_deprecated",
> diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c
> index 0b1c2d3a96..a9d470c9f6 100644
> --- a/tools/libs/light/libxl_x86.c
> +++ b/tools/libs/light/libxl_x86.c
> @@ -26,6 +26,11 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>      if (libxl_defbool_val(d_config->b_info.arch_x86.msr_relaxed))
>          config->arch.misc_flags |= XEN_X86_MSR_RELAXED;
>  
> +    if (libxl_defbool_val(d_config->b_info.trap_unmapped_accesses)) {
> +            LOG(ERROR, "trap_unmapped_accesses is not supported on x86\n");
> +            return ERROR_FAIL;
> +    }
> +
>      return 0;
>  }
>  
> @@ -813,6 +818,7 @@ int libxl__arch_domain_build_info_setdefault(libxl__gc 
> *gc,
>  {
>      libxl_defbool_setdefault(&b_info->acpi, true);
>      libxl_defbool_setdefault(&b_info->arch_x86.msr_relaxed, false);
> +    libxl_defbool_setdefault(&b_info->trap_unmapped_accesses, false);
>  
>      /*
>       * The config parameter "altp2m" replaces the parameter "altp2mhvm".
> diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
> index 089a88935a..40da75ef74 100644
> --- a/tools/xl/xl_parse.c
> +++ b/tools/xl/xl_parse.c
> @@ -2975,6 +2975,9 @@ skip_usbdev:
>      if (!xlu_cfg_get_long (config, "nr_spis", &l, 0))
>          b_info->arch_arm.nr_spis = l;
>  
> +    xlu_cfg_get_defbool(config, "trap_unmapped_accesses",
> +                        &b_info->trap_unmapped_accesses, 0);
> +
>      parse_vkb_list(config, d_config);
>  
>      d_config->virtios = NULL;
> -- 
> 2.43.0
> 



 


Rackspace

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