xen/arm: Add option to optionally disable trapping on unmapped acceses
v2 cover xen/arm: Add option to optionally disable trapping on unmapped acceses
From: "Edgar E. Iglesias" <[email protected]>
This follows up on the virtio-pci discussion and adds a per-domain option to select the behaviour of accesses to unmapped address ranges. The new option is trap_unmapped_accesses, it's general but for now only implemented for ARM.
I'm happy with any name, so if you have better ideas please suggest them!
Thanks,
Edgar
ChangeLog:
v1 -> v2:
* Rename trap_unmapped_mmio to trap_unmapped_accesses
* Generalize to allow other archs to later support this option
* Change dom0less DT binding from boolean to integer
* Remove changes to autogenerated go bindings
Edgar E. Iglesias (3):
xen/arm: Add way to disable traps on accesses to unmapped addresses xen/arm: dom0less: Add trap-unmapped-accesses
tools/arm: Add the trap_unmapped_accesses xl config option
docs/man/xl.cfg.5.pod.in | 8 ++++++ docs/misc/arm/device-tree/booting.txt | 9 +++++++ tools/libs/light/libxl_arm.c | 3 +++ 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 +++ xen/arch/arm/dom0less-build.c | 10 ++++++++ xen/arch/arm/domain.c | 3 ++- xen/arch/arm/domain_build.c | 3 ++- xen/arch/arm/io.c | 36 +++++++++++++++++++++++++-- xen/common/domain.c | 3 ++- xen/include/public/domctl.h | 4 ++- 13 files changed, 86 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/3 xen/arm: Add way to disable traps on accesses to unmapped addresses
From: "Edgar E. Iglesias" <[email protected]>
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.
--- 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 | 36 +++++++++++++++++++++++++++++++++-- xen/common/domain.c | 3 ++- xen/include/public/domctl.h | 4 +++- 7 files changed, 49 insertions(+), 6 deletions(-)
tools/libs/light/libxl_arm.c +3 -0
@@ -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 ; }
xen/arch/arm/dom0less-build.c +3 -0
@@ -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,
xen/arch/arm/domain.c +2 -1
@@ -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 )
xen/arch/arm/domain_build.c +2 -1
@@ -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 ,
xen/arch/arm/io.c +34 -2
@@ -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_ULL ((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,17 @@ 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; }/*
xen/common/domain.c +2 -1
@@ -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 ;
xen/include/public/domctl.h +3 -1
@@ -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_accessesuint32_t flags;
Signature · 1 line
2.43.0
Re: [PATCH v2 1/3] xen/arm: Add way to disable traps on accesses to unmapped addresses
Hi Edgar,
Quoted 8 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
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 <[email protected]>
Quoted 8 lines
--- 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 | 36 +++++++++++++++++++++++++++++++++-- xen/common/domain.c | 3 ++- xen/include/public/domctl.h | 4 +++-
Looking at the changelog, I saw you removed the go bindings (although, they were in patch 3). But I don't quite understand why.
Also, I think you need to update the OCaml bindings.
Quoted 63 lines
7 files changed, 49 insertions(+), 6 deletions(-)tools/libs/light/libxl_arm.c +3
-0@@ -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 ; }xen/arch/arm/dom0less-build.c +3
-0@@ -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,xen/arch/arm/domain.c +2
-1@@ -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 )xen/arch/arm/domain_build.c +2
-1@@ -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 ,xen/arch/arm/io.c +0
-0
xen/arch/arm/io.c line 28
Quoted 8 lines
xen/arch/arm/io.c +5
-0@@ -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_ULL ((1U << info->dabt.size) *8 -1 ,0 );
NIT: Looking at the other part of io.c, we are using GENMASK. Any reason to not use the same?
Quoted 30 lines
xen/arch/arm/io.c +23
-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,17 @@ 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;
xen/arch/arm/io.c enum io_state try_handle_mmio(struct cpu_user_regs *regs, · line 213
Quoted 10 lines
xen/arch/arm/io.c +5
-2rc =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
Style:
else if ( ... )
{
}
else
{
}
Quoted 35 lines
xen/arch/arm/io.c +1
-0+return rc; }/* xen/common/domain.c +2
-1@@ -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 ;xen/include/public/domctl.h +3
-1@@ -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_accessesuint32_t flags;
Signature · 1 line
Julien Grall
Re: [PATCH v2 1/3] xen/arm: Add way to disable traps on accesses to unmapped addresses
Quoted 1 line · Julien Grall
Hi Edgar,
Hi Julien,
Quoted 19 lines · Edgar E. Iglesias
Quoted 8 lines
From: "Edgar E. Iglesias" <[email protected]>
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 <[email protected]>Quoted 8 lines
--- 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 | 36 +++++++++++++++++++++++++++++++++-- xen/common/domain.c | 3 ++- xen/include/public/domctl.h | 4 +++-
Quoted 2 lines
Looking at the changelog, I saw you removed the go bindings (although, they were in patch 3). But I don't quite understand why.
I got a little confused. The file tools/golang/xenlight/helpers.gen.go has the following at the top:
// Code generated by gengotypes.py. DO NOT EDIT.
// source: libxl_types.idl
So I got the impression that we shouldn't be editing it. Should I edit it manually? Or should I try to rerun gengotypes.py to generate these bindings?
Quoted 2 lines
Also, I think you need to update the OCaml bindings.
I see, I'll have a look.
Quoted 62 lines
Quoted 62 lines
7 files changed, 49 insertions(+), 6 deletions(-)tools/libs/light/libxl_arm.c +3
-0@@ -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 ; }xen/arch/arm/dom0less-build.c +3
-0@@ -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,xen/arch/arm/domain.c +2
-1@@ -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 )xen/arch/arm/domain_build.c +2
-1@@ -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 ,xen/arch/arm/io.c +0
-0@@ -21,6 +21,32 @@#include "decode.h"
Quoted 8 lines
xen/arch/arm/io.c line 28
Quoted 5 lines
xen/arch/arm/io.c +5
-0+/* 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_ULL ((1U << info->dabt.size) *8 -1 ,0 );NIT: Looking at the other part of
io.c, we are using GENMASK. Any reason to not use the same?
Looking closer at it now and no, there's no good reason. I'll change to GENMASK in v3.
Quoted 44 lines
Quoted 31 lines
xen/arch/arm/io.c +23
-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,17 @@ 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;xen/arch/arm/io.c enum io_state try_handle_mmio(struct cpu_user_regs *regs, · line 213
Quoted 10 lines
xen/arch/arm/io.c +5
-2rc =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 Style:
Quoted 6 lines
else if ( ... )
{
}
else
{
}
Will fix for v3.
Thanks,
Edgar
Quoted 36 lines
Quoted 32 lines
xen/arch/arm/io.c +1
-0+return rc; }/* xen/common/domain.c +2
-1@@ -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 ;xen/include/public/domctl.h +3
-1@@ -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_accessesuint32_t flags;Signature · 1 line
Julien Grall
Re: [PATCH v2 1/3] xen/arm: Add way to disable traps on accesses to unmapped addresses
Quoted 34 lines · Edgar E. Iglesias
Quoted 1 line · Julien Grall
Hi Edgar,
Hi Julien,
Quoted 19 lines · Edgar E. Iglesias
Quoted 8 lines
From: "Edgar E. Iglesias" <[email protected]>
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 <[email protected]>Quoted 8 lines
--- 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 | 36 +++++++++++++++++++++++++++++++++-- xen/common/domain.c | 3 ++- xen/include/public/domctl.h | 4 +++-Quoted 2 lines
Looking at the changelog, I saw you removed the go bindings (although, they were in patch 3). But I don't quite understand why.
I got a little confused. The file
tools/golang/xenlight/helpers.gen.gohas the following at the top:
// Code generated bygengotypes.py. DO NOT EDIT.
// source: libxl_types.idl
Quoted 3 lines
So I got the impression that we shouldn't be editing it. Should I edit it manually? Or should I try to rerun
gengotypes.pyto generate these bindings?
As the file is checked in, I think we expect the developper to rerun gengotypes.py. Anthony, can you confirm?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 1/3] xen/arm: Add way to disable traps on accesses to unmapped addresses
Quoted 37 lines · Julien Grall
Quoted 34 lines · Edgar E. Iglesias
Quoted 1 line · Julien Grall
Hi Edgar,
Hi Julien,
Quoted 19 lines · Edgar E. Iglesias
Quoted 8 lines
From: "Edgar E. Iglesias" <[email protected]>
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 <[email protected]>Quoted 8 lines
--- 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 | 36 +++++++++++++++++++++++++++++++++-- xen/common/domain.c | 3 ++- xen/include/public/domctl.h | 4 +++-Quoted 2 lines
Looking at the changelog, I saw you removed the go bindings (although, they were in patch 3). But I don't quite understand why.
I got a little confused. The file
tools/golang/xenlight/helpers.gen.gohas the following at the top:
// Code generated bygengotypes.py. DO NOT EDIT.
// source: libxl_types.idl
Quoted 7 lines
Quoted 3 lines
So I got the impression that we shouldn't be editing it. Should I edit it manually? Or should I try to rerun
gengotypes.pyto generate these bindings?As the file is checked in, I think we expect the developper to rerun
gengotypes.py. Anthony, can you confirm?
Thanks, I've included a regeneration of the bindings in v3. If it for some reason is not needed we can drop it.
Cheers,
Edgar
PATCH v2 2/3 xen/arm: dom0less: Add trap-unmapped-accesses
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add the trap-unmapped-accesses per-domain fdt property.
--- docs/misc/arm/device-tree/booting.txt | 9 +++++++++ xen/arch/arm/dom0less-build.c | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
docs/misc/arm/device-tree/booting.txt +9 -0
@@ -225,6 +225,15 @@ 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 0xFFFFFFFF 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:
xen/arch/arm/dom0less-build.c +8 -1
@@ -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,
Signature · 1 line
2.43.0
Re: [PATCH v2 2/3] xen/arm: dom0less: Add trap-unmapped-accesses
Hi Edgar,
Quoted 15 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add the trap-unmapped-accesses per-domain fdt property.
Signed-off-by Edgar E. Iglesias <[email protected]>--- docs/misc/arm/device-tree/booting.txt | 9 +++++++++ xen/arch/arm/dom0less-build.c | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)docs/misc/arm/device-tree/booting.txt +0
-0
docs/misc/arm/device-tree/booting.txt with the following properties: · line 232
Quoted 8 lines
docs/misc/arm/device-tree/booting.txt +5
-0@@ -225,6 +225,15 @@ 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 0xFFFFFFFF and writes will be ignored.
Looking at the code, if I am not mistaken, it will only return this value for 32-bit. For 64-bit there will be a few Fs more and for less there will be less. So I think this needs to be reworded.
The rest looks good to me.
Quoted 17 lines
docs/misc/arm/device-tree/booting.txt +3
-0+ + This option is only implemented for ARM where the default is 1. + - xen,enhanced A string property. Possible property values are:xen/arch/arm/dom0less-build.c +1
-1@@ -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;
xen/arch/arm/dom0less-build.c void __init arch_create_domUs(struct dt_device_node *node, · line 358
Quoted 10 lines
xen/arch/arm/dom0less-build.c +7
-0+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,
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 2/3] xen/arm: dom0less: Add trap-unmapped-accesses
Quoted 30 lines · Julien Grall
Hi Edgar,
Quoted 15 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add the trap-unmapped-accesses per-domain fdt property.
Signed-off-by Edgar E. Iglesias <[email protected]>--- docs/misc/arm/device-tree/booting.txt | 9 +++++++++ xen/arch/arm/dom0less-build.c | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)docs/misc/arm/device-tree/booting.txt +0
-0docs/misc/arm/device-tree/booting.txt with the following properties: · line 231
Quoted 7 lines
docs/misc/arm/device-tree/booting.txt +5
-0@@ -225,6 +225,15 @@ 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 0xFFFFFFFF and writes will be ignored.Looking at the code, if I am not mistaken, it will only return this value for 32-bit. For 64-bit there will be a few Fs more and for less there will be less. So I think this needs to be reworded.
Quoted 1 line
The rest looks good to me.
Thanks, in v3 I'll change it to:
If set to 0, guest accesses will read all bits as ones, e.g 0xFFFFFFFF for a 32bit access and writes will be ignored.
Cheers,
Edgar
Quoted 31 lines
Quoted 15 lines
docs/misc/arm/device-tree/booting.txt +3
-0+ + This option is only implemented for ARM where the default is 1. + - xen,enhanced A string property. Possible property values are:xen/arch/arm/dom0less-build.c +1
-1@@ -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. */ xen/arch/arm/dom0less-build.c void __init arch_create_domUs(struct dt_device_node *node, · line 356
Quoted 10 lines
xen/arch/arm/dom0less-build.c +7
-0d_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,Cheers,
Signature · 1 line
Julien Grall
PATCH v2 3/3 tools/arm: Add the trap_unmapped_accesses xl config option
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- docs/man/xl.cfg.5.pod.in | 8 ++++++++ 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, 24 insertions(+), 3 deletions(-)
docs/man/xl.cfg.5.pod.in +8 -0
@@ -3089,6 +3089,14 @@ 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 0xFFFFFFFF and writes will be ignored. + +This option is only implemented for ARM where the default is enabled. + =back =head3 x86
tools/libs/light/libxl_arm.c +3 -3
@@ -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 =
tools/libs/light/libxl_create.c +3 -0
@@ -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));
tools/libs/light/libxl_types.idl +1 -0
@@ -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",
tools/libs/light/libxl_x86.c +6 -0
@@ -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".
tools/xl/xl_parse.c +3 -0
@@ -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 ;
Signature · 1 line
2.43.0