* [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses
2025-05-30 13:45 [PATCH v3 0/5] xen/arm: Add option to optionally disable trapping on unmapped acceses Edgar E. Iglesias
@ 2025-05-30 13:45 ` Edgar E. Iglesias
2025-06-02 8:45 ` Jan Beulich
` (2 more replies)
2025-05-30 13:45 ` [PATCH v3 2/5] xen/arm: dom0less: Add trap-unmapped-accesses Edgar E. Iglesias
` (3 subsequent siblings)
4 siblings, 3 replies; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-05-30 13:45 UTC (permalink / raw)
To: xen-devel
Cc: sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias, Anthony PERARD,
Juergen Gross, Jan Beulich, Roger Pau Monné
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
Add a per-domain way to optionally disable traps for accesses
to unmapped addresses.
The domain flag is general but it's only implemented for ARM for now.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
tools/libs/light/libxl_arm.c | 3 +++
xen/arch/arm/dom0less-build.c | 3 +++
xen/arch/arm/domain.c | 3 ++-
xen/arch/arm/domain_build.c | 3 ++-
xen/arch/arm/io.c | 37 +++++++++++++++++++++++++++++++++--
xen/common/domain.c | 3 ++-
xen/include/public/domctl.h | 4 +++-
7 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index 75c811053c..9530996e72 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -233,6 +233,9 @@ 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;
}
diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index a49764f0ad..a4e0a33632 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -343,6 +343,9 @@ void __init arch_create_domUs(struct dt_device_node *node,
panic("'sve' property found, but CONFIG_ARM64_SVE not selected\n");
#endif
}
+
+ /* Trap accesses to unmapped areas. */
+ d_cfg->flags |= XEN_DOMCTL_CDF_trap_unmapped_accesses;
}
int __init init_intc_phandle(struct kernel_info *kinfo, const char *name,
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 45aeb8bddc..be58a23dd7 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -612,7 +612,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
unsigned int max_vcpus;
unsigned int flags_required = (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap);
unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu |
- XEN_DOMCTL_CDF_xs_domain );
+ XEN_DOMCTL_CDF_xs_domain |
+ XEN_DOMCTL_CDF_trap_unmapped_accesses );
unsigned int sve_vl_bits = sve_decode_vl(config->arch.sve_vl);
if ( (config->flags & ~flags_optional) != flags_required )
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index b189a7cfae..7ff9c1b584 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2003,7 +2003,8 @@ void __init create_dom0(void)
{
struct domain *dom0;
struct xen_domctl_createdomain dom0_cfg = {
- .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap,
+ .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap |
+ XEN_DOMCTL_CDF_trap_unmapped_accesses,
.max_evtchn_port = -1,
.max_grant_frames = gnttab_dom0_frames(),
.max_maptrack_frames = -1,
diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
index 5a4b0e8f25..e599bbe043 100644
--- a/xen/arch/arm/io.c
+++ b/xen/arch/arm/io.c
@@ -21,6 +21,32 @@
#include "decode.h"
+/* Handler for unmapped ranges. Writes ignored, reads return all ones. */
+static int unmapped_read(struct vcpu *v, mmio_info_t *info, register_t *r,
+ void *priv)
+{
+ uint64_t mask = GENMASK((1U << info->dabt.size) * 8 - 1, 0);
+
+ /* Mask off upper bits. */
+ *r = UINT64_MAX & mask;
+ return 1;
+}
+
+static int unmapped_write(struct vcpu *v, mmio_info_t *info, register_t r,
+ void *priv)
+{
+ return 1;
+}
+
+static const struct mmio_handler_ops unmapped_ops = {
+ .read = unmapped_read,
+ .write = unmapped_write
+};
+
+static const struct mmio_handler unmapped_handler = {
+ .ops = &unmapped_ops
+};
+
static enum io_state handle_read(const struct mmio_handler *handler,
struct vcpu *v,
mmio_info_t *info)
@@ -175,11 +201,18 @@ enum io_state try_handle_mmio(struct cpu_user_regs *regs,
handler = find_mmio_handler(v->domain, info->gpa);
if ( !handler )
{
+ bool trap_unmapped = v->domain->options &
+ XEN_DOMCTL_CDF_trap_unmapped_accesses;
rc = try_fwd_ioserv(regs, v, info);
if ( rc == IO_HANDLED )
return handle_ioserv(regs, v);
-
- return rc;
+ else if ( rc == IO_UNHANDLED && !trap_unmapped )
+ {
+ /* Fallback to the unmapped handler. */
+ handler = &unmapped_handler;
+ } else {
+ return rc;
+ }
}
/*
diff --git a/xen/common/domain.c b/xen/common/domain.c
index abf1969e60..ac4f58f638 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -721,7 +721,8 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config)
~(XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap |
XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off |
XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu |
- XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu) )
+ XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu |
+ XEN_DOMCTL_CDF_trap_unmapped_accesses) )
{
dprintk(XENLOG_INFO, "Unknown CDF flags %#x\n", config->flags);
return -EINVAL;
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 5b2063eed9..be19ab5e26 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -66,9 +66,11 @@ struct xen_domctl_createdomain {
#define XEN_DOMCTL_CDF_nested_virt (1U << _XEN_DOMCTL_CDF_nested_virt)
/* Should we expose the vPMU to the guest? */
#define XEN_DOMCTL_CDF_vpmu (1U << 7)
+/* Should we trap guest accesses to unmapped addresses? */
+#define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8)
/* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */
-#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_vpmu
+#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_trap_unmapped_accesses
uint32_t flags;
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses
2025-05-30 13:45 ` [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses Edgar E. Iglesias
@ 2025-06-02 8:45 ` Jan Beulich
2025-06-02 15:23 ` Edgar E. Iglesias
2025-06-02 22:35 ` Stefano Stabellini
2025-06-03 9:36 ` Julien Grall
2 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2025-06-02 8:45 UTC (permalink / raw)
To: Edgar E. Iglesias
Cc: sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias, Anthony PERARD,
Juergen Gross, Roger Pau Monné, xen-devel
On 30.05.2025 15:45, Edgar E. Iglesias wrote:
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -721,7 +721,8 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config)
> ~(XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap |
> XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off |
> XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu |
> - XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu) )
> + XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu |
> + XEN_DOMCTL_CDF_trap_unmapped_accesses) )
> {
> dprintk(XENLOG_INFO, "Unknown CDF flags %#x\n", config->flags);
> return -EINVAL;
> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -66,9 +66,11 @@ struct xen_domctl_createdomain {
> #define XEN_DOMCTL_CDF_nested_virt (1U << _XEN_DOMCTL_CDF_nested_virt)
> /* Should we expose the vPMU to the guest? */
> #define XEN_DOMCTL_CDF_vpmu (1U << 7)
> +/* Should we trap guest accesses to unmapped addresses? */
> +#define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8)
Besides being pretty long an identifier (and that's already with "guest" not
even in the name), if this is to be arch-independent, would this perhaps fit
x86'es recently introduced "advanced" PVH handling of holes? See [1].
Jan
[1] 104591f5dd67 ("x86/dom0: attempt to fixup p2m page-faults for PVH dom0")
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses
2025-06-02 8:45 ` Jan Beulich
@ 2025-06-02 15:23 ` Edgar E. Iglesias
0 siblings, 0 replies; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-06-02 15:23 UTC (permalink / raw)
To: Jan Beulich
Cc: sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias, Anthony PERARD,
Juergen Gross, Roger Pau Monné, xen-devel
On Mon, Jun 02, 2025 at 10:45:36AM +0200, Jan Beulich wrote:
> On 30.05.2025 15:45, Edgar E. Iglesias wrote:
> > --- a/xen/common/domain.c
> > +++ b/xen/common/domain.c
> > @@ -721,7 +721,8 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config)
> > ~(XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap |
> > XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off |
> > XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu |
> > - XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu) )
> > + XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu |
> > + XEN_DOMCTL_CDF_trap_unmapped_accesses) )
> > {
> > dprintk(XENLOG_INFO, "Unknown CDF flags %#x\n", config->flags);
> > return -EINVAL;
> > --- a/xen/include/public/domctl.h
> > +++ b/xen/include/public/domctl.h
> > @@ -66,9 +66,11 @@ struct xen_domctl_createdomain {
> > #define XEN_DOMCTL_CDF_nested_virt (1U << _XEN_DOMCTL_CDF_nested_virt)
> > /* Should we expose the vPMU to the guest? */
> > #define XEN_DOMCTL_CDF_vpmu (1U << 7)
> > +/* Should we trap guest accesses to unmapped addresses? */
> > +#define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8)
>
> Besides being pretty long an identifier (and that's already with "guest" not
> even in the name), if this is to be arch-independent, would this perhaps fit
> x86'es recently introduced "advanced" PVH handling of holes? See [1].
>
Looks like the implementation of the options would be related
but trap_unmapped_accesses is intended for domU's and pf-fixup is for
dom0 IIUC, so in terms of configuration they would be different...
I'm happy to change the name of trap_unmapped_accesses if there
are better (and shorter) ideas.
Thanks,
Edgar
> Jan
>
> [1] 104591f5dd67 ("x86/dom0: attempt to fixup p2m page-faults for PVH dom0")
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses
2025-05-30 13:45 ` [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses Edgar E. Iglesias
2025-06-02 8:45 ` Jan Beulich
@ 2025-06-02 22:35 ` Stefano Stabellini
2025-06-03 9:36 ` Julien Grall
2 siblings, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2025-06-02 22:35 UTC (permalink / raw)
To: Edgar E. Iglesias
Cc: xen-devel, sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias, Anthony PERARD,
Juergen Gross, Jan Beulich, Roger Pau Monné
On Fri, 30 May 2025, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
>
> Add a per-domain way to optionally disable traps for accesses
> to unmapped addresses.
>
> The domain flag is general but it's only implemented for ARM for now.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
I am OK with the name "XEN_DOMCTL_CDF_trap_unmapped_accesses" being long
but I would also be OK with a shorter name if it is still clear enough.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses
2025-05-30 13:45 ` [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses Edgar E. Iglesias
2025-06-02 8:45 ` Jan Beulich
2025-06-02 22:35 ` Stefano Stabellini
@ 2025-06-03 9:36 ` Julien Grall
2025-06-03 12:48 ` Edgar E. Iglesias
2 siblings, 1 reply; 19+ messages in thread
From: Julien Grall @ 2025-06-03 9:36 UTC (permalink / raw)
To: Edgar E. Iglesias, xen-devel
Cc: sstabellini, bertrand.marquis, michal.orzel, Volodymyr_Babchuk,
andrew.cooper3, edgar.iglesias, Anthony PERARD, Juergen Gross,
Jan Beulich, Roger Pau Monné
Hi Edgar,
On 30/05/2025 14:45, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
>
> Add a per-domain way to optionally disable traps for accesses
> to unmapped addresses.
>
> The domain flag is general but it's only implemented for ARM for now.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
> ---
> tools/libs/light/libxl_arm.c | 3 +++
> xen/arch/arm/dom0less-build.c | 3 +++
> xen/arch/arm/domain.c | 3 ++-
> xen/arch/arm/domain_build.c | 3 ++-
> xen/arch/arm/io.c | 37 +++++++++++++++++++++++++++++++++--
> xen/common/domain.c | 3 ++-
> xen/include/public/domctl.h | 4 +++-
> 7 files changed, 50 insertions(+), 6 deletions(-)
>
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index 75c811053c..9530996e72 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -233,6 +233,9 @@ 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;
> }
>
> diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
> index a49764f0ad..a4e0a33632 100644
> --- a/xen/arch/arm/dom0less-build.c
> +++ b/xen/arch/arm/dom0less-build.c
> @@ -343,6 +343,9 @@ void __init arch_create_domUs(struct dt_device_node *node,
> panic("'sve' property found, but CONFIG_ARM64_SVE not selected\n");
> #endif
> }
> +
> + /* Trap accesses to unmapped areas. */
> + d_cfg->flags |= XEN_DOMCTL_CDF_trap_unmapped_accesses;
> }
>
> int __init init_intc_phandle(struct kernel_info *kinfo, const char *name,
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 45aeb8bddc..be58a23dd7 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -612,7 +612,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
> unsigned int max_vcpus;
> unsigned int flags_required = (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap);
> unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu |
> - XEN_DOMCTL_CDF_xs_domain );
> + XEN_DOMCTL_CDF_xs_domain |
> + XEN_DOMCTL_CDF_trap_unmapped_accesses );
Just to double check, doesn't this mean the flag will be allowed on x86?
If so, shouldn't we reject it in an arch?
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses
2025-06-03 9:36 ` Julien Grall
@ 2025-06-03 12:48 ` Edgar E. Iglesias
0 siblings, 0 replies; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-06-03 12:48 UTC (permalink / raw)
To: Julien Grall
Cc: Edgar E. Iglesias, xen-devel, sstabellini, bertrand.marquis,
michal.orzel, Volodymyr_Babchuk, andrew.cooper3, Anthony PERARD,
Juergen Gross, Jan Beulich, Roger Pau Monné
On Tue, Jun 03, 2025 at 10:36:40AM +0100, Julien Grall wrote:
> Hi Edgar,
Hi Julien,
>
> On 30/05/2025 14:45, Edgar E. Iglesias wrote:
> > From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
> >
> > Add a per-domain way to optionally disable traps for accesses
> > to unmapped addresses.
> >
> > The domain flag is general but it's only implemented for ARM for now.
> >
> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
> > ---
> > tools/libs/light/libxl_arm.c | 3 +++
> > xen/arch/arm/dom0less-build.c | 3 +++
> > xen/arch/arm/domain.c | 3 ++-
> > xen/arch/arm/domain_build.c | 3 ++-
> > xen/arch/arm/io.c | 37 +++++++++++++++++++++++++++++++++--
> > xen/common/domain.c | 3 ++-
> > xen/include/public/domctl.h | 4 +++-
> > 7 files changed, 50 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> > index 75c811053c..9530996e72 100644
> > --- a/tools/libs/light/libxl_arm.c
> > +++ b/tools/libs/light/libxl_arm.c
> > @@ -233,6 +233,9 @@ 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;
> > }
> > diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
> > index a49764f0ad..a4e0a33632 100644
> > --- a/xen/arch/arm/dom0less-build.c
> > +++ b/xen/arch/arm/dom0less-build.c
> > @@ -343,6 +343,9 @@ void __init arch_create_domUs(struct dt_device_node *node,
> > panic("'sve' property found, but CONFIG_ARM64_SVE not selected\n");
> > #endif
> > }
> > +
> > + /* Trap accesses to unmapped areas. */
> > + d_cfg->flags |= XEN_DOMCTL_CDF_trap_unmapped_accesses;
> > }
> > int __init init_intc_phandle(struct kernel_info *kinfo, const char *name,
> > diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> > index 45aeb8bddc..be58a23dd7 100644
> > --- a/xen/arch/arm/domain.c
> > +++ b/xen/arch/arm/domain.c
> > @@ -612,7 +612,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
> > unsigned int max_vcpus;
> > unsigned int flags_required = (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap);
> > unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu |
> > - XEN_DOMCTL_CDF_xs_domain );
> > + XEN_DOMCTL_CDF_xs_domain |
> > + XEN_DOMCTL_CDF_trap_unmapped_accesses );
>
> Just to double check, doesn't this mean the flag will be allowed on x86? If
> so, shouldn't we reject it in an arch?
Yes, I had initially thought I could block the flag for x86 in xl but I
didn't consider go/ocaml bindings nor Xen internal missconfig. In v4,
I'm adding a check in x86's arch_sanitise_domain_config().
Cheers,
Edgar
>
> Cheers,
>
> --
> Julien Grall
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 2/5] xen/arm: dom0less: Add trap-unmapped-accesses
2025-05-30 13:45 [PATCH v3 0/5] xen/arm: Add option to optionally disable trapping on unmapped acceses Edgar E. Iglesias
2025-05-30 13:45 ` [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses Edgar E. Iglesias
@ 2025-05-30 13:45 ` Edgar E. Iglesias
2025-06-02 22:36 ` Stefano Stabellini
2025-05-30 13:45 ` [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option Edgar E. Iglesias
` (2 subsequent siblings)
4 siblings, 1 reply; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-05-30 13:45 UTC (permalink / raw)
To: xen-devel
Cc: sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
Add the trap-unmapped-accesses per-domain fdt property.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
docs/misc/arm/device-tree/booting.txt | 10 ++++++++++
xen/arch/arm/dom0less-build.c | 9 ++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt
index 59fa96a82e..9add6440de 100644
--- a/docs/misc/arm/device-tree/booting.txt
+++ b/docs/misc/arm/device-tree/booting.txt
@@ -225,6 +225,16 @@ with the following properties:
option is provided with a non zero value, but the platform doesn't support
SVE.
+- trap-unmapped-accesses
+
+ Optional. An integer that configures handling of accesses to unmapped
+ address ranges.
+ If set to 0, guest accesses will read all bits as ones, e.g 0xFFFFFFFF
+ for a 32bit access and writes will be ignored.
+ If set to 1, guest accesses will trap.
+
+ This option is only implemented for ARM where the default is 1.
+
- xen,enhanced
A string property. Possible property values are:
diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index a4e0a33632..69324aa597 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -344,8 +344,15 @@ void __init arch_create_domUs(struct dt_device_node *node,
#endif
}
- /* Trap accesses to unmapped areas. */
+ /* Trap unmapped accesses by default. */
d_cfg->flags |= XEN_DOMCTL_CDF_trap_unmapped_accesses;
+ if ( dt_property_read_u32(node, "trap-unmapped-accesses", &val) )
+ {
+ if ( val > 1 )
+ panic("trap-unmapped-accesses: supported values are 0 or 1");
+ if ( !val )
+ d_cfg->flags &= ~XEN_DOMCTL_CDF_trap_unmapped_accesses;
+ }
}
int __init init_intc_phandle(struct kernel_info *kinfo, const char *name,
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 2/5] xen/arm: dom0less: Add trap-unmapped-accesses
2025-05-30 13:45 ` [PATCH v3 2/5] xen/arm: dom0less: Add trap-unmapped-accesses Edgar E. Iglesias
@ 2025-06-02 22:36 ` Stefano Stabellini
2025-06-02 22:47 ` Julien Grall
0 siblings, 1 reply; 19+ messages in thread
From: Stefano Stabellini @ 2025-06-02 22:36 UTC (permalink / raw)
To: Edgar E. Iglesias
Cc: xen-devel, sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias
On Fri, 30 May 2025, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
>
> Add the trap-unmapped-accesses per-domain fdt property.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
> ---
> docs/misc/arm/device-tree/booting.txt | 10 ++++++++++
> xen/arch/arm/dom0less-build.c | 9 ++++++++-
> 2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt
> index 59fa96a82e..9add6440de 100644
> --- a/docs/misc/arm/device-tree/booting.txt
> +++ b/docs/misc/arm/device-tree/booting.txt
> @@ -225,6 +225,16 @@ with the following properties:
> option is provided with a non zero value, but the platform doesn't support
> SVE.
>
> +- trap-unmapped-accesses
> +
> + Optional. An integer that configures handling of accesses to unmapped
> + address ranges.
> + If set to 0, guest accesses will read all bits as ones, e.g 0xFFFFFFFF
> + for a 32bit access and writes will be ignored.
> + If set to 1, guest accesses will trap.
> +
> + This option is only implemented for ARM where the default is 1.
Please expand it to: "This option is only implemented for ARM where the
default is 1 when trap-unmapped-accesses is absent."
The change could be done on commit:
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> - xen,enhanced
>
> A string property. Possible property values are:
> diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
> index a4e0a33632..69324aa597 100644
> --- a/xen/arch/arm/dom0less-build.c
> +++ b/xen/arch/arm/dom0less-build.c
> @@ -344,8 +344,15 @@ void __init arch_create_domUs(struct dt_device_node *node,
> #endif
> }
>
> - /* Trap accesses to unmapped areas. */
> + /* Trap unmapped accesses by default. */
> d_cfg->flags |= XEN_DOMCTL_CDF_trap_unmapped_accesses;
> + if ( dt_property_read_u32(node, "trap-unmapped-accesses", &val) )
> + {
> + if ( val > 1 )
> + panic("trap-unmapped-accesses: supported values are 0 or 1");
> + if ( !val )
> + d_cfg->flags &= ~XEN_DOMCTL_CDF_trap_unmapped_accesses;
> + }
> }
>
> int __init init_intc_phandle(struct kernel_info *kinfo, const char *name,
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 2/5] xen/arm: dom0less: Add trap-unmapped-accesses
2025-06-02 22:36 ` Stefano Stabellini
@ 2025-06-02 22:47 ` Julien Grall
2025-06-02 22:57 ` Stefano Stabellini
0 siblings, 1 reply; 19+ messages in thread
From: Julien Grall @ 2025-06-02 22:47 UTC (permalink / raw)
To: Stefano Stabellini, Edgar E. Iglesias
Cc: xen-devel, bertrand.marquis, michal.orzel, Volodymyr_Babchuk,
andrew.cooper3, edgar.iglesias
Hi,
On 02/06/2025 23:36, Stefano Stabellini wrote:
> On Fri, 30 May 2025, Edgar E. Iglesias wrote:
>> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
>>
>> Add the trap-unmapped-accesses per-domain fdt property.
>>
>> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
>> ---
>> docs/misc/arm/device-tree/booting.txt | 10 ++++++++++
>> xen/arch/arm/dom0less-build.c | 9 ++++++++-
>> 2 files changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt
>> index 59fa96a82e..9add6440de 100644
>> --- a/docs/misc/arm/device-tree/booting.txt
>> +++ b/docs/misc/arm/device-tree/booting.txt
>> @@ -225,6 +225,16 @@ with the following properties:
>> option is provided with a non zero value, but the platform doesn't support
>> SVE.
>>
>> +- trap-unmapped-accesses
>> +
>> + Optional. An integer that configures handling of accesses to unmapped
>> + address ranges.
>> + If set to 0, guest accesses will read all bits as ones, e.g 0xFFFFFFFF
>> + for a 32bit access and writes will be ignored.
>> + If set to 1, guest accesses will trap.
>> +
>> + This option is only implemented for ARM where the default is 1.
>
> Please expand it to: "This option is only implemented for ARM where the
> default is 1 when trap-unmapped-accesses is absent."
I am confused. The document is part of "docs/misc/arm" and some options
like "sve" are Arm specific. We don't mention this is Arm only because
the documention is Arm specific.
I know that RISC-V is starting to share the bindings. So really (part
of) the documentation should be moved to common. Until then, I think it
is misleading to add "is only implemented for ARM".
BTW, the spelling for should be "Arm" ;).
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] xen/arm: dom0less: Add trap-unmapped-accesses
2025-06-02 22:47 ` Julien Grall
@ 2025-06-02 22:57 ` Stefano Stabellini
2025-06-03 12:59 ` Edgar E. Iglesias
0 siblings, 1 reply; 19+ messages in thread
From: Stefano Stabellini @ 2025-06-02 22:57 UTC (permalink / raw)
To: Julien Grall
Cc: Stefano Stabellini, Edgar E. Iglesias, xen-devel,
bertrand.marquis, michal.orzel, Volodymyr_Babchuk, andrew.cooper3,
edgar.iglesias
On Mon, 2 Jun 2025, Julien Grall wrote:
> Hi,
>
> On 02/06/2025 23:36, Stefano Stabellini wrote:
> > On Fri, 30 May 2025, Edgar E. Iglesias wrote:
> > > From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
> > >
> > > Add the trap-unmapped-accesses per-domain fdt property.
> > >
> > > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
> > > ---
> > > docs/misc/arm/device-tree/booting.txt | 10 ++++++++++
> > > xen/arch/arm/dom0less-build.c | 9 ++++++++-
> > > 2 files changed, 18 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/docs/misc/arm/device-tree/booting.txt
> > > b/docs/misc/arm/device-tree/booting.txt
> > > index 59fa96a82e..9add6440de 100644
> > > --- a/docs/misc/arm/device-tree/booting.txt
> > > +++ b/docs/misc/arm/device-tree/booting.txt
> > > @@ -225,6 +225,16 @@ with the following properties:
> > > option is provided with a non zero value, but the platform doesn't
> > > support
> > > SVE.
> > > +- trap-unmapped-accesses
> > > +
> > > + Optional. An integer that configures handling of accesses to unmapped
> > > + address ranges.
> > > + If set to 0, guest accesses will read all bits as ones, e.g
> > > 0xFFFFFFFF
> > > + for a 32bit access and writes will be ignored.
> > > + If set to 1, guest accesses will trap.
> > > +
> > > + This option is only implemented for ARM where the default is 1.
> >
> > Please expand it to: "This option is only implemented for ARM where the
> > default is 1 when trap-unmapped-accesses is absent."
>
> I am confused. The document is part of "docs/misc/arm" and some options like
> "sve" are Arm specific. We don't mention this is Arm only because the
> documention is Arm specific.
>
> I know that RISC-V is starting to share the bindings. So really (part of) the
> documentation should be moved to common. Until then, I think it is misleading
> to add "is only implemented for ARM".
Yes you are right. Maybe Oleksii or Alejandro can fix this, moving this
file to common.
For this smaller patch series, I would remove the "is only implemented
for ARM".
> BTW, the spelling for should be "Arm" ;).
:-)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] xen/arm: dom0less: Add trap-unmapped-accesses
2025-06-02 22:57 ` Stefano Stabellini
@ 2025-06-03 12:59 ` Edgar E. Iglesias
0 siblings, 0 replies; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-06-03 12:59 UTC (permalink / raw)
To: Stefano Stabellini
Cc: Julien Grall, Edgar E. Iglesias, xen-devel, bertrand.marquis,
michal.orzel, Volodymyr_Babchuk, andrew.cooper3
On Mon, Jun 02, 2025 at 03:57:28PM -0700, Stefano Stabellini wrote:
> On Mon, 2 Jun 2025, Julien Grall wrote:
> > Hi,
> >
> > On 02/06/2025 23:36, Stefano Stabellini wrote:
> > > On Fri, 30 May 2025, Edgar E. Iglesias wrote:
> > > > From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
> > > >
> > > > Add the trap-unmapped-accesses per-domain fdt property.
> > > >
> > > > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
> > > > ---
> > > > docs/misc/arm/device-tree/booting.txt | 10 ++++++++++
> > > > xen/arch/arm/dom0less-build.c | 9 ++++++++-
> > > > 2 files changed, 18 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/docs/misc/arm/device-tree/booting.txt
> > > > b/docs/misc/arm/device-tree/booting.txt
> > > > index 59fa96a82e..9add6440de 100644
> > > > --- a/docs/misc/arm/device-tree/booting.txt
> > > > +++ b/docs/misc/arm/device-tree/booting.txt
> > > > @@ -225,6 +225,16 @@ with the following properties:
> > > > option is provided with a non zero value, but the platform doesn't
> > > > support
> > > > SVE.
> > > > +- trap-unmapped-accesses
> > > > +
> > > > + Optional. An integer that configures handling of accesses to unmapped
> > > > + address ranges.
> > > > + If set to 0, guest accesses will read all bits as ones, e.g
> > > > 0xFFFFFFFF
> > > > + for a 32bit access and writes will be ignored.
> > > > + If set to 1, guest accesses will trap.
> > > > +
> > > > + This option is only implemented for ARM where the default is 1.
> > >
> > > Please expand it to: "This option is only implemented for ARM where the
> > > default is 1 when trap-unmapped-accesses is absent."
> >
> > I am confused. The document is part of "docs/misc/arm" and some options like
> > "sve" are Arm specific. We don't mention this is Arm only because the
> > documention is Arm specific.
> >
> > I know that RISC-V is starting to share the bindings. So really (part of) the
> > documentation should be moved to common. Until then, I think it is misleading
> > to add "is only implemented for ARM".
>
> Yes you are right. Maybe Oleksii or Alejandro can fix this, moving this
> file to common.
>
> For this smaller patch series, I would remove the "is only implemented
> for ARM".
Thanks, I've changed that line to:
"The default is 1 when trap-unmapped-accesses is absent."
Cheers,
Edgar
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option
2025-05-30 13:45 [PATCH v3 0/5] xen/arm: Add option to optionally disable trapping on unmapped acceses Edgar E. Iglesias
2025-05-30 13:45 ` [PATCH v3 1/5] xen/arm: Add way to disable traps on accesses to unmapped addresses Edgar E. Iglesias
2025-05-30 13:45 ` [PATCH v3 2/5] xen/arm: dom0less: Add trap-unmapped-accesses Edgar E. Iglesias
@ 2025-05-30 13:45 ` Edgar E. Iglesias
2025-06-02 22:42 ` Stefano Stabellini
2025-06-03 9:34 ` Julien Grall
2025-05-30 13:45 ` [PATCH v3 4/5] tools/ocaml: Update bindings for CDF_TRAP_UNMAPPED_ACCESSES Edgar E. Iglesias
2025-05-30 13:45 ` [PATCH v3 5/5] tools/golang: Regenerate bindings for trap_unmapped_accesses Edgar E. Iglesias
4 siblings, 2 replies; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-05-30 13:45 UTC (permalink / raw)
To: xen-devel
Cc: sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias, Anthony PERARD,
Juergen Gross
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
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
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option
2025-05-30 13:45 ` [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option Edgar E. Iglesias
@ 2025-06-02 22:42 ` Stefano Stabellini
2025-06-03 9:34 ` Julien Grall
1 sibling, 0 replies; 19+ messages in thread
From: Stefano Stabellini @ 2025-06-02 22:42 UTC (permalink / raw)
To: Edgar E. Iglesias
Cc: xen-devel, sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias, Anthony PERARD,
Juergen Gross
On Fri, 30 May 2025, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> ---
> 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
>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option
2025-05-30 13:45 ` [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option Edgar E. Iglesias
2025-06-02 22:42 ` Stefano Stabellini
@ 2025-06-03 9:34 ` Julien Grall
2025-06-03 12:49 ` Edgar E. Iglesias
1 sibling, 1 reply; 19+ messages in thread
From: Julien Grall @ 2025-06-03 9:34 UTC (permalink / raw)
To: Edgar E. Iglesias, xen-devel
Cc: sstabellini, bertrand.marquis, michal.orzel, Volodymyr_Babchuk,
andrew.cooper3, edgar.iglesias, Anthony PERARD, Juergen Gross
Hi Edgar,
On 30/05/2025 14:45, Edgar E. Iglesias wrote:
> @@ -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),
I think you want to add a LIBXL_HAVE in tools/include/libxl.h for this
new field.
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option
2025-06-03 9:34 ` Julien Grall
@ 2025-06-03 12:49 ` Edgar E. Iglesias
0 siblings, 0 replies; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-06-03 12:49 UTC (permalink / raw)
To: Julien Grall
Cc: Edgar E. Iglesias, xen-devel, sstabellini, bertrand.marquis,
michal.orzel, Volodymyr_Babchuk, andrew.cooper3, Anthony PERARD,
Juergen Gross
On Tue, Jun 03, 2025 at 10:34:53AM +0100, Julien Grall wrote:
> Hi Edgar,
>
> On 30/05/2025 14:45, Edgar E. Iglesias wrote:
> > @@ -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),
>
> I think you want to add a LIBXL_HAVE in tools/include/libxl.h for this new
> field.
Thanks, adding it in v4.
>
> Cheers,
>
> --
> Julien Grall
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 4/5] tools/ocaml: Update bindings for CDF_TRAP_UNMAPPED_ACCESSES
2025-05-30 13:45 [PATCH v3 0/5] xen/arm: Add option to optionally disable trapping on unmapped acceses Edgar E. Iglesias
` (2 preceding siblings ...)
2025-05-30 13:45 ` [PATCH v3 3/5] tools/arm: Add the trap_unmapped_accesses xl config option Edgar E. Iglesias
@ 2025-05-30 13:45 ` Edgar E. Iglesias
2025-05-30 13:49 ` Christian Lindig
2025-05-30 13:45 ` [PATCH v3 5/5] tools/golang: Regenerate bindings for trap_unmapped_accesses Edgar E. Iglesias
4 siblings, 1 reply; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-05-30 13:45 UTC (permalink / raw)
To: xen-devel
Cc: sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias,
Christian Lindig, David Scott, Anthony PERARD
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
tools/ocaml/libs/xc/xenctrl.ml | 1 +
tools/ocaml/libs/xc/xenctrl.mli | 1 +
2 files changed, 2 insertions(+)
diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index 2690f9a923..7e1aabad6c 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -70,6 +70,7 @@ type domain_create_flag =
| CDF_IOMMU
| CDF_NESTED_VIRT
| CDF_VPMU
+ | CDF_TRAP_UNMAPPED_ACCESSES
type domain_create_iommu_opts =
| IOMMU_NO_SHAREPT
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index febbe1f6ae..f44dba61ae 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -63,6 +63,7 @@ type domain_create_flag =
| CDF_IOMMU
| CDF_NESTED_VIRT
| CDF_VPMU
+ | CDF_TRAP_UNMAPPED_ACCESSES
type domain_create_iommu_opts =
| IOMMU_NO_SHAREPT
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 4/5] tools/ocaml: Update bindings for CDF_TRAP_UNMAPPED_ACCESSES
2025-05-30 13:45 ` [PATCH v3 4/5] tools/ocaml: Update bindings for CDF_TRAP_UNMAPPED_ACCESSES Edgar E. Iglesias
@ 2025-05-30 13:49 ` Christian Lindig
0 siblings, 0 replies; 19+ messages in thread
From: Christian Lindig @ 2025-05-30 13:49 UTC (permalink / raw)
To: Edgar E. Iglesias
Cc: xen-devel, sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias,
Christian Lindig, David Scott, Anthony PERARD
Acked-by: Christian Lindig <christian.lindig@cloud.com>
> On 30 May 2025, at 14:45, Edgar E. Iglesias <edgar.iglesias@gmail.com> wrote:
>
> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
> ---
> tools/ocaml/libs/xc/xenctrl.ml | 1 +
> tools/ocaml/libs/xc/xenctrl.mli | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
> index 2690f9a923..7e1aabad6c 100644
> --- a/tools/ocaml/libs/xc/xenctrl.ml
> +++ b/tools/ocaml/libs/xc/xenctrl.ml
> @@ -70,6 +70,7 @@ type domain_create_flag =
> | CDF_IOMMU
> | CDF_NESTED_VIRT
> | CDF_VPMU
> + | CDF_TRAP_UNMAPPED_ACCESSES
>
> type domain_create_iommu_opts =
> | IOMMU_NO_SHAREPT
> diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
> index febbe1f6ae..f44dba61ae 100644
> --- a/tools/ocaml/libs/xc/xenctrl.mli
> +++ b/tools/ocaml/libs/xc/xenctrl.mli
> @@ -63,6 +63,7 @@ type domain_create_flag =
> | CDF_IOMMU
> | CDF_NESTED_VIRT
> | CDF_VPMU
> + | CDF_TRAP_UNMAPPED_ACCESSES
>
> type domain_create_iommu_opts =
> | IOMMU_NO_SHAREPT
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 5/5] tools/golang: Regenerate bindings for trap_unmapped_accesses
2025-05-30 13:45 [PATCH v3 0/5] xen/arm: Add option to optionally disable trapping on unmapped acceses Edgar E. Iglesias
` (3 preceding siblings ...)
2025-05-30 13:45 ` [PATCH v3 4/5] tools/ocaml: Update bindings for CDF_TRAP_UNMAPPED_ACCESSES Edgar E. Iglesias
@ 2025-05-30 13:45 ` Edgar E. Iglesias
4 siblings, 0 replies; 19+ messages in thread
From: Edgar E. Iglesias @ 2025-05-30 13:45 UTC (permalink / raw)
To: xen-devel
Cc: sstabellini, julien, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, andrew.cooper3, edgar.iglesias, Nick Rosbrook,
George Dunlap, Anthony PERARD
From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
tools/golang/xenlight/helpers.gen.go | 6 ++++++
tools/golang/xenlight/types.gen.go | 1 +
2 files changed, 7 insertions(+)
diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go
index 90846ea8e8..191be87297 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -1170,6 +1170,9 @@ x.Altp2M = Altp2MMode(xc.altp2m)
x.VmtraceBufKb = int(xc.vmtrace_buf_kb)
if err := x.Vpmu.fromC(&xc.vpmu);err != nil {
return fmt.Errorf("converting field Vpmu: %v", err)
+}
+if err := x.TrapUnmappedAccesses.fromC(&xc.trap_unmapped_accesses);err != nil {
+return fmt.Errorf("converting field TrapUnmappedAccesses: %v", err)
}
return nil}
@@ -1695,6 +1698,9 @@ xc.altp2m = C.libxl_altp2m_mode(x.Altp2M)
xc.vmtrace_buf_kb = C.int(x.VmtraceBufKb)
if err := x.Vpmu.toC(&xc.vpmu); err != nil {
return fmt.Errorf("converting field Vpmu: %v", err)
+}
+if err := x.TrapUnmappedAccesses.toC(&xc.trap_unmapped_accesses); err != nil {
+return fmt.Errorf("converting field TrapUnmappedAccesses: %v", err)
}
return nil
diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go
index e7667f1ce3..656933c6c9 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -606,6 +606,7 @@ MsrRelaxed Defbool
Altp2M Altp2MMode
VmtraceBufKb int
Vpmu Defbool
+TrapUnmappedAccesses Defbool
}
type DomainBuildInfoTypeUnion interface {
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread