ARM split hardware and control domains
cover ARM split hardware and control domains
This series implements separation of dom0 into separate hardware and control domains. It uses the capabilities idea from Hyperlaunch - hardware, control, and xenstore. It's been tested with dom0 as hardware & xenstore, dom1 as control, and dom2 as a domU.
Running hardware and xenstore together eases the implementation. Xenstore permissions were tested with a hyperlaunched xenstore stubdom. C xenstored is needed to use grant mapping instead of foreign mapping - this is especially needed for hwdom to provide the xenstore to control. Xen seeds the xenstore grant entries since init-dom0less in hardware domain does not have permission to map the grant table.
There is a dependency on an ImageBuilder update to generate the capability device tree nodes. An update for the automation is in the last commit - not to be commited.
The early patches re-work dom0less code to allow construction of hwdom. There are some changes to expose the capabilities to the toolstack.
xenstored is changed to track dom0_domid (hwdom) and priv_domid. This works for only a single one of each.
Then there are a bunch of changes to the XSM dummy policy. The sysctls are the most problematic. With a coarse grain policy, they are allowed for both hwdom and control. Flask can be used for fine grain control.
Finally, an automation test is added.
Daniel P. Smith (1):
xen: introduce hardware domain create flag
Jason Andryuk (22):
xen/arm: Factor out construct_hwdom()
xen/arm: dom0less hwdom construction
xen/arm: dom0less use domid 0 for hwdom
xen/arm: Add capabilities to dom0less
xen/domctl: Expose privileged and hardware capabilities tools/libxl: Expose hardware and privileged flags xen/arm: dom0less seed xenstore grant table entry tools/init-dom0less: Only seed legacy xenstore grants xen/arm: dom0less delay xenstore initialization tools/xenstored: Automatically set dom0_domid and priv_domid tools/xl: Print domain capabilities with verbose xsm/dummy: Allow XS_PRIV XEN_SYSCTL_getdomaininfolist xsm/dummy: Allow XS_PRIV to call get_hvm_param xen/xsm: Add XSM_HW_PRIV
xsm/dummy: Allow hwdom xen_version
xsm/dummy: Allow hwdom more - except targeting control xsm/dummy: Allow hwdom SYSCTL_readconsole/physinfo xsm/dummy: Allow sysctls to both hardware and control xsm/silo: Support hwdom/control domains automation/dom0less-arm64: Use double quotes
automation: Add arm64 hardware/control split test DO NOT COMMIT: automation: updated imagebuilder
automation/gitlab-ci/test.yaml | 8 + .../scripts/qemu-smoke-dom0less-arm64.sh | 87 ++++++++-- docs/man/xl.1.pod.in | 3 +- docs/misc/arm/device-tree/booting.txt | 11 ++ tools/helpers/init-dom0less.c | 10 +- tools/include/libxl.h | 16 ++ tools/libs/light/libxl_domain.c | 2 + tools/libs/light/libxl_types.idl | 2 + tools/xenstored/domain.c | 16 ++ tools/xl/xl_info.c | 24 ++- xen/arch/arm/dom0less-build.c | 164 +++++++++++++----- xen/arch/arm/domain.c | 3 +- xen/arch/arm/domain_build.c | 35 ++-- xen/arch/arm/hvm.c | 2 +- xen/arch/arm/include/asm/dom0less-build.h | 2 + xen/arch/arm/include/asm/domain_build.h | 2 + xen/arch/arm/platform_hypercall.c | 2 +- xen/arch/x86/hvm/hvm.c | 8 +- xen/arch/x86/msi.c | 2 +- xen/arch/x86/physdev.c | 12 +- xen/arch/x86/platform_hypercall.c | 2 +- xen/arch/x86/setup.c | 3 +- xen/common/domain.c | 2 +- xen/common/domctl.c | 2 + xen/common/grant_table.c | 10 ++ xen/common/sysctl.c | 2 +- xen/drivers/passthrough/pci.c | 5 +- xen/drivers/pci/physdev.c | 2 +- xen/include/public/bootfdt.h | 27 +++ xen/include/public/domctl.h | 6 + xen/include/xen/domain.h | 2 + xen/include/xen/grant_table.h | 8 + xen/include/xsm/dummy.h | 55 ++++-- xen/include/xsm/xsm.h | 1 + xen/xsm/silo.c | 9 +- 35 files changed, 431 insertions(+), 116 deletions(-) create mode 100644 xen/include/public/bootfdt.h
Signature · 1 line
2.48.1
PATCH 1/23 xen: introduce hardware domain create flag
From: "Daniel P. Smith" <[email protected]>
Add and use a new internal create domain flag to specify the hardware domain. This removes the hardcoding of domid 0 as the hardware domain.
This allows more flexibility with domain creation.
--- xen/arch/arm/domain_build.c | 2 +- xen/arch/x86/setup.c | 3 ++- xen/common/domain.c | 2 +- xen/include/xen/domain.h | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-)
xen/arch/arm/domain_build.c +1 -1
@@ -2358,7 +2358,7 @@ void __init create_dom0(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; -unsigned int flags = CDF_privileged; +unsigned int flags = CDF_privileged | CDF_hardware;int rc;/* The vGIC for DOM0 is exactly emulating the hardware GIC */
xen/arch/x86/setup.c +2 -1
@@ -1017,7 +1017,8 @@ static struct domain *__init create_dom0(struct boot_info *bi)/* Create initial domain. Not d0 for pvshim. */ domid =get_initial_domain_id (); - d =domain_create (domid, &dom0_cfg, pv_shim ?0 : CDF_privileged); + d =domain_create (domid, &dom0_cfg, + pv_shim ?0 : CDF_privileged | CDF_hardware);if (IS_ERR (d) )panic ("Error creating d%u: %ld\n" , domid,PTR_ERR (d));
xen/common/domain.c +1 -1
@@ -699,7 +699,7 @@ struct domain *domain_create(domid_t domid, d->is_privileged = flags & CDF_privileged;/* Sort out our idea of is_hardware_domain(). */ -if ( domid ==0 || domid == hardware_domid ) +if ( flags & CDF_hardware || domid == hardware_domid ) {if ( hardware_domid <0 || hardware_domid >=DOMID_FIRST_RESERVED )panic ("The value of hardware_dom must be a valid domain ID\n" );
xen/include/xen/domain.h +2 -0
@@ -50,6 +50,8 @@ void arch_get_domain_info(const struct domain *d,#else #define CDF_staticmem 0#endif +/* Is this the hardware? */ +#define CDF_hardware (1U << 3)#define is_domain_direct_mapped (d) ((d)->cdf & CDF_directmap)#define is_domain_using_staticmem (d) ((d)->cdf & CDF_staticmem)
Signature · 1 line
2.48.1
Re: [PATCH 01/23] xen: introduce hardware domain create flag
Quoted 9 lines · Jason Andryuk
From: "Daniel P. Smith" <[email protected]>
Add and use a new internal create domain flag to specify the hardware domain. This removes the hardcoding of domid 0 as the hardware domain.
This allows more flexibility with domain creation.
Signed-off-by Daniel P. Smith <[email protected]>Signed-off-by Jason Andryuk <[email protected]>
I definitely like the removal of the late_hwdom bodges.
However, there are several things to be aware of here.
First, CDF_privileged probably wants renaming to CDF_control, now that CDF_hardware is being split out.
Second, you've created a case where we can make multiple hardware domains, yet it is very much a singleton object from Xen's point of view.
This might be ok it's addressed by later in the series. One especially nasty bit of late_hwdom was how dom0 started as both, then the late_hwdom stole dom0's hw-ness. I expect untangling this is more complicated than a single patch.
But, by the end, I think we do need to have reasonable confidence that only a single domain can be constructed as the hardware domain.
xen/include/xen/domain.h void arch_get_domain_info(const struct domain *d, · line 54
Quoted 10 lines
xen/include/xen/domain.h +2
-0@@ -50,6 +50,8 @@ void arch_get_domain_info(const struct domain *d,#else #define CDF_staticmem 0#endif +/* Is this the hardware? */ +#define CDF_hardware (1U << 3)
No, this one CDF flag isn't the hardware. That would be the CPU we're running on.
~Andrew
Re: [PATCH 01/23] xen: introduce hardware domain create flag
Quoted 13 lines · Andrew Cooper
Quoted 9 lines · Jason Andryuk
From: "Daniel P. Smith" <[email protected]>
Add and use a new internal create domain flag to specify the hardware domain. This removes the hardcoding of domid 0 as the hardware domain.
This allows more flexibility with domain creation.
Signed-off-by Daniel P. Smith <[email protected]>Signed-off-by Jason Andryuk <[email protected]>I definitely like the removal of the
late_hwdombodges.
Quoted 7 lines
However, there are several things to be aware of here.
First,
CDF_privilegedprobably wants renaming toCDF_control, now thatCDF_hardwareis being split out.Second, you've created a case where we can make multiple hardware domains, yet it is very much a singleton object from Xen's point of view.
hardware_domain still remains the check for is_hardware_domain(), so it's still a singleton.
A later ARM patch for the dom0less code adds a panic() if the device tree defines a second hardware domains.
Quoted 4 lines
This might be ok it's addressed by later in the series. One especially nasty bit of
late_hwdomwas how dom0 started as both, then thelate_hwdomstole dom0's hw-ness. I expect untangling this is more complicated than a single patch.
I didn't address the late_hwdom path. I don't think I broken anything. But this hardware stealing is why I added the 2nd hwdom check in the ARM code.
Quoted 2 lines
But, by the end, I think we do need to have reasonable confidence that only a single domain can be constructed as the hardware domain.
What do you think about multiple control/privileged domains?
Quoted 5 lines
Quoted 5 lines
xen/include/xen/domain.h +0
-0@@ -50,6 +50,8 @@ void arch_get_domain_info(const struct domain *d,
Quoted 8 lines
xen/include/xen/domain.h void arch_get_domain_info(const struct domain *d, · line 54
Quoted 5 lines
xen/include/xen/domain.h +2
-0#else #define CDF_staticmem 0#endif +/* Is this the hardware? */ +#define CDF_hardware (1U << 3)No, this one CDF flag isn't the hardware. That would be the CPU we're running on.
:)
-Jason
Re: [PATCH 01/23] xen: introduce hardware domain create flag
Quoted 7 lines · Jason Andryuk
Quoted 3 lines · Andrew Cooper
Second, you've created a case where we can make multiple hardware domains, yet it is very much a singleton object from Xen's point of view.
hardware_domainstill remains the check foris_hardware_domain(), so it's still a singleton.
Multiple domains can pass in CDF_hardware and latest-takes-precedence for hardware_domain.
That only exists because late_hwdom is a bodge and relies on stealing.
Quoted 2 lines
A later ARM patch for the dom0less code adds a
panic()if the device tree defines a second hardware domains.
Another option might be to strip out late_hwdom, and do this more nicely. I have little confidence that it works, seeing as it only gets touched to fix build issues.
Either way, I think the common code wants to be ultimately responsible for refusing to create multiple hardware domains.
Quoted 5 lines
Quoted 3 lines
But, by the end, I think we do need to have reasonable confidence that only a single domain can be constructed as the hardware domain.
What do you think about multiple control/privileged domains?
Well, I am the author of
https://github.com/xenserver/xen.pg/blob/XS-8.2.x/patches/xen-domctl-set-privileged-domain.patch
and this is deployed in production for XenServer+HVMI.
"Works on my hypervisor".
~Andrew
Re: [PATCH 01/23] xen: introduce hardware domain create flag
Quoted 12 lines · Andrew Cooper
Quoted 7 lines · Jason Andryuk
Quoted 3 lines · Andrew Cooper
Second, you've created a case where we can make multiple hardware domains, yet it is very much a singleton object from Xen's point of view.
hardware_domainstill remains the check foris_hardware_domain(), so it's still a singleton.Multiple domains can pass in
CDF_hardwareand latest-takes-precedence forhardware_domain.
Quoted 8 lines
That only exists because
late_hwdomis a bodge and relies on stealing.Quoted 2 lines
A later ARM patch for the dom0less code adds a
panic()if the device tree defines a second hardware domains.Another option might be to strip out
late_hwdom, and do this more nicely. I have little confidence that it works, seeing as it only gets touched to fix build issues.
I don't want late_hwdom to hold up ARM side changes. I'm not using late_hwdom, so I'd be fine removing it. But until Hyperlaunch is merged, removal seems a little premature.
Quoted 6 lines
Either way, I think the common code wants to be ultimately responsible for refusing to create multiple hardware domains.
Quoted 3 lines
Quoted 3 lines
But, by the end, I think we do need to have reasonable confidence that only a single domain can be constructed as the hardware domain.
Would just an addition check be okay? Only allow the late_hwdom behaviour for dom0.
xen/common/domain.c +0 -0
@@ -704,6 +704,10 @@ struct domain *domain_create(domid_t domid, if ( hardware_domid < 0 || hardware_domid >=
DOMID_FIRST_RESERVED )
panic("The value of hardware_dom must be a valid domain
ID\n");
+ /* late_hwdom is only allowed for dom0. */
+ if ( hardware_domain && hardware_domain->domain_id )
+ return -EINVAL;
+
old_hwdom = hardware_domain;
hardware_domain = d;
}CDF_hardware is a Xen-internal flag, so it's not something the toolstack can pass in.
Regards,
Jason
Re: [PATCH 01/23] xen: introduce hardware domain create flag
In reply to Jason Andryukxen/common/domain.c struct domain *domain_create(domid_t domid, · line 702
Quoted 8 lines · Jason Andryuk
xen/common/domain.c +1
-1@@ -699,7 +699,7 @@ struct domain *domain_create(domid_t domid, d->is_privileged = flags & CDF_privileged;/* Sort out our idea of is_hardware_domain(). */ -if ( domid ==0 || domid == hardware_domid ) +if ( flags & CDF_hardware || domid == hardware_domid )
Nit: If the rhs of the || needs to stay for the time being (does it?), parentheses please around the & expression.
Jan
PATCH 2/23 xen/arm: Factor out construct_hwdom()
In reply to Jason AndryukFactor out construct_hwdom() from construct_dom0(). This will be re-used by the dom0less code when building a domain with the hardware capability.
iommu_hwdom_init(d) is moved into construct_hwdom() which moves it after kernel_probe(). kernel_probe() doesn't seem to depend on its setting.
--- xen/arch/arm/domain_build.c | 28 ++++++++++++++++--------- xen/arch/arm/include/asm/domain_build.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)
xen/arch/arm/domain_build.c +18 -10
@@ -2296,8 +2296,6 @@ static int __init construct_dom0(struct domain *d) dom0_mem =MB (512 ); } -iommu_hwdom_init (d); - d->max_pages = dom0_mem >>PAGE_SHIFT ; kinfo.unassigned_mem = dom0_mem;
@@ -2307,17 +2305,27 @@ static int __init construct_dom0(struct domain *d)if ( rc <0 )return rc; +return construct_hwdom (&kinfo); +} + +int __init construct_hwdom (struct kernel_info *kinfo) +{ +struct domain *d = kinfo->d; +int rc; + +iommu_hwdom_init (d); +#ifdef CONFIG_ARM_64 /* type must be set before allocate_memory */ - d->arch.type = kinfo.type; + d->arch.type = kinfo->type;#endif -find_gnttab_region (d, &kinfo); +find_gnttab_region (d, kinfo);if (is_domain_direct_mapped (d) ) -allocate_memory_11 (d, &kinfo); +allocate_memory_11 (d, kinfo);else -allocate_memory (d, &kinfo); +allocate_memory (d, kinfo); - rc =process_shm_chosen (d, &kinfo); + rc =process_shm_chosen (d, kinfo);if ( rc <0 )return rc;
@@ -2332,7 +2340,7 @@ static int __init construct_dom0(struct domain *d)if ( acpi_disabled ) { - rc =prepare_dtb_hwdom (d, &kinfo); + rc =prepare_dtb_hwdom (d, kinfo);if ( rc <0 )return rc;#ifdef CONFIG_HAS_PCI
@@ -2340,12 +2348,12 @@ static int __init construct_dom0(struct domain *d)#endif }else - rc =prepare_acpi (d, &kinfo); + rc =prepare_acpi (d, kinfo);if ( rc <0 )return rc; -return construct_domain (d, &kinfo); +return construct_domain (d, kinfo); }void __init create_dom0 (void )
xen/arch/arm/include/asm/domain_build.h +1 -0
@@ -13,6 +13,7 @@ bool allocate_bank_memory(struct kernel_info *kinfo, gfn_t sgfn, paddr_t tot_size);void allocate_memory (struct domain *d,struct kernel_info *kinfo);int construct_domain (struct domain *d,struct kernel_info *kinfo); +int construct_hwdom (struct kernel_info *kinfo);int domain_fdt_begin_node (void *fdt,const char *name,uint64_t unit);int make_chosen_node (const struct kernel_info *kinfo);int make_cpus_node (const struct domain *d,void *fdt);
Signature · 1 line
2.48.1
Re: [PATCH 02/23] xen/arm: Factor out construct_hwdom()
Quoted 8 lines · Jason Andryuk
Factor out
construct_hwdom()fromconstruct_dom0(). This will be re-used by the dom0less code when building a domain with the hardware capability.
iommu_hwdom_init(d)is moved intoconstruct_hwdom()which moves it afterkernel_probe().kernel_probe()doesn't seem to depend on its setting.Signed-off-by Jason Andryuk <[email protected]>
Quoted 90 lines
--- xen/arch/arm/domain_build.c | 28 ++++++++++++++++--------- xen/arch/arm/include/asm/domain_build.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)xen/arch/arm/domain_build.c +18
-10@@ -2296,8 +2296,6 @@ static int __init construct_dom0(struct domain *d) dom0_mem =MB (512 ); } -iommu_hwdom_init (d); - d->max_pages = dom0_mem >>PAGE_SHIFT ; kinfo.unassigned_mem = dom0_mem;@@ -2307,17 +2305,27 @@ static int __init construct_dom0(struct domain *d)if ( rc <0 )return rc; +return construct_hwdom (&kinfo); +} + +int __init construct_hwdom (struct kernel_info *kinfo) +{ +struct domain *d = kinfo->d; +int rc; + +iommu_hwdom_init (d); +#ifdef CONFIG_ARM_64 /* type must be set before allocate_memory */ - d->arch.type = kinfo.type; + d->arch.type = kinfo->type;#endif -find_gnttab_region (d, &kinfo); +find_gnttab_region (d, kinfo);if (is_domain_direct_mapped (d) ) -allocate_memory_11 (d, &kinfo); +allocate_memory_11 (d, kinfo);else -allocate_memory (d, &kinfo); +allocate_memory (d, kinfo); - rc =process_shm_chosen (d, &kinfo); + rc =process_shm_chosen (d, kinfo);if ( rc <0 )return rc;@@ -2332,7 +2340,7 @@ static int __init construct_dom0(struct domain *d)if ( acpi_disabled ) { - rc =prepare_dtb_hwdom (d, &kinfo); + rc =prepare_dtb_hwdom (d, kinfo);if ( rc <0 )return rc;#ifdef CONFIG_HAS_PCI @@ -2340,12 +2348,12 @@ static int __init construct_dom0(struct domain *d)#endif }else - rc =prepare_acpi (d, &kinfo); + rc =prepare_acpi (d, kinfo);if ( rc <0 )return rc; -return construct_domain (d, &kinfo); +return construct_domain (d, kinfo); }void __init create_dom0 (void )xen/arch/arm/include/asm/domain_build.h +1
-0@@ -13,6 +13,7 @@ bool allocate_bank_memory(struct kernel_info *kinfo, gfn_t sgfn, paddr_t tot_size);void allocate_memory (struct domain *d,struct kernel_info *kinfo);int construct_domain (struct domain *d,struct kernel_info *kinfo); +int construct_hwdom (struct kernel_info *kinfo);int domain_fdt_begin_node (void *fdt,const char *name,uint64_t unit);int make_chosen_node (const struct kernel_info *kinfo);int make_cpus_node (const struct domain *d,void *fdt);Signature · 1 line
2.48.1
PATCH 3/23 xen/arm: dom0less hwdom construction
In reply to Jason AndryukWhen creating a hardware domain, have the dom0less code call construct_hwdom() which is shared with the dom0 code. The hardware domain requires building that best matches the dom0 build path. Re-use it to keep them in sync.
The device tree node of the dom0less config is now passed into construct_hwdom(). dom0 uses /chosen for process_shm while a hwdom will use the value from its dom0less device tree node.
--- xen/arch/arm/dom0less-build.c | 57 ++++++++++++++----------- xen/arch/arm/domain_build.c | 10 +++-- xen/arch/arm/include/asm/domain_build.h | 3 +- 3 files changed, 42 insertions(+), 28 deletions(-)
xen/arch/arm/dom0less-build.c +33 -24
@@ -911,36 +911,45 @@ static int __init construct_domU(struct domain *d,/* type must be set before allocate memory */ d->arch.type = kinfo.type;#endif -if ( !dt_find_property (node,"xen,static-mem" ,NULL ) ) -allocate_memory (d, &kinfo); -else if ( !is_domain_direct_mapped (d) ) -allocate_static_memory (d, &kinfo, node); -else -assign_static_memory_11 (d, &kinfo, node); - - rc =process_shm (d, &kinfo, node); -if ( rc <0 ) -return rc; - -/* -* Base address and irq number are needed when creating vpl011 device -* tree node in prepare_dtb_domU, so initialization on related variables -* shall be done first. -*/ -if ( kinfo.vpl011 ) +if (is_hardware_domain (d) ) { - rc =domain_vpl011_init (d,NULL ); + rc =construct_hwdom (&kinfo, node);if ( rc <0 )return rc; } +else + { +if ( !dt_find_property (node,"xen,static-mem" ,NULL ) ) +allocate_memory (d, &kinfo); +else if ( !is_domain_direct_mapped (d) ) +allocate_static_memory (d, &kinfo, node); +else +assign_static_memory_11 (d, &kinfo, node); - rc =prepare_dtb_domU (d, &kinfo); -if ( rc <0 ) -return rc; + rc =process_shm (d, &kinfo, node); +if ( rc <0 ) +return rc; - rc =construct_domain (d, &kinfo); -if ( rc <0 ) -return rc; +/* +* Base address and irq number are needed when creating vpl011 device +* tree node in prepare_dtb_domU, so initialization on related variables +* shall be done first. +*/ +if ( kinfo.vpl011 ) + { + rc =domain_vpl011_init (d,NULL ); +if ( rc <0 ) +return rc; + } + + rc =prepare_dtb_domU (d, &kinfo); +if ( rc <0 ) +return rc; + + rc =construct_domain (d, &kinfo); +if ( rc <0 ) +return rc; + }domain_vcpu_affinity (d, node);
xen/arch/arm/domain_build.c +7 -3
@@ -2305,10 +2305,11 @@ static int __init construct_dom0(struct domain *d)if ( rc <0 )return rc; -return construct_hwdom (&kinfo); +return construct_hwdom (&kinfo,NULL ); } -int __init construct_hwdom (struct kernel_info *kinfo) +int __init construct_hwdom (struct kernel_info *kinfo, +const struct dt_device_node *node) {struct domain *d = kinfo->d;int rc;
@@ -2325,7 +2326,10 @@ int __init construct_hwdom(struct kernel_info *kinfo)else allocate_memory (d, kinfo); - rc =process_shm_chosen (d, kinfo); +if ( node ) + rc =process_shm (d, kinfo, node); +else + rc =process_shm_chosen (d, kinfo);if ( rc <0 )return rc;
xen/arch/arm/include/asm/domain_build.h +2 -1
@@ -13,7 +13,8 @@ bool allocate_bank_memory(struct kernel_info *kinfo, gfn_t sgfn, paddr_t tot_size);void allocate_memory (struct domain *d,struct kernel_info *kinfo);int construct_domain (struct domain *d,struct kernel_info *kinfo); -int construct_hwdom (struct kernel_info *kinfo); +int construct_hwdom (struct kernel_info *kinfo, +const struct dt_device_node *node);int domain_fdt_begin_node (void *fdt,const char *name,uint64_t unit);int make_chosen_node (const struct kernel_info *kinfo);int make_cpus_node (const struct domain *d,void *fdt);
Signature · 1 line
2.48.1
PATCH 4/23 xen/arm: dom0less use domid 0 for hwdom
In reply to Jason AndryukAssign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
--- xen/arch/arm/dom0less-build.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
xen/arch/arm/dom0less-build.c +7 -1
@@ -969,6 +969,7 @@ void __init create_domUs(void)dt_for_each_child_node (chosen, node) {struct domain *d; +domid_t domid;struct xen_domctl_createdomain d_cfg = { .arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE , .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap,
@@ -1121,7 +1122,12 @@ void __init create_domUs(void)* very important to use the pre-increment operator to call * domain_create() with a domid > 0. (domid == 0 is reserved for Dom0) */ - d =domain_create (++max_init_domid, &d_cfg, flags); +if ( flags & CDF_hardware ) + domid =0 ; +else + domid = ++max_init_domid; + + d =domain_create (domid, &d_cfg, flags);if (IS_ERR (d) )panic ("Error creating domain %s (rc = %ld)\n" ,dt_node_name (node),PTR_ERR (d));
Signature · 1 line
2.48.1
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Quoted 6 lines · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
Signed-off-by Jason Andryuk <[email protected]>
I hope there is a check already in the code somewhere that triggers an error if multiple domains are created with domid 0 ?
Quoted 33 lines
--- xen/arch/arm/dom0less-build.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/arch/arm/dom0less-build.c +7
-1@@ -969,6 +969,7 @@ void __init create_domUs(void)dt_for_each_child_node (chosen, node) {struct domain *d; +domid_t domid;struct xen_domctl_createdomain d_cfg = { .arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE , .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap,@@ -1121,7 +1122,12 @@ void __init create_domUs(void)* very important to use the pre-increment operator to call * domain_create() with a domid > 0. (domid == 0 is reserved for Dom0) */ - d =domain_create (++max_init_domid, &d_cfg, flags); +if ( flags & CDF_hardware ) + domid =0 ; +else + domid = ++max_init_domid; + + d =domain_create (domid, &d_cfg, flags);if (IS_ERR (d) )panic ("Error creating domain %s (rc = %ld)\n" ,dt_node_name (node),PTR_ERR (d));Signature · 1 line
2.48.1
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Quoted 10 lines · Stefano Stabellini
Quoted 6 lines · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
Signed-off-by Jason Andryuk <[email protected]>I hope there is a check already in the code somewhere that triggers an error if multiple domains are created with domid 0 ?
Hmm, no, the existence check is in the domctl code and not in domain_create(). The next patch in the series, "xen/arm: Add capabilities to dom0less", adds a panic when trying to create a second hardware_domain. That check could be moved here to keep it all together.
Regards,
Jason
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
In reply to Jason AndryukHi,
Quoted 1 line · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
A few years ago, we went to great length to avoid making the assumption that the hardware domain is domid 0. See all the calls to "is_hardware_domain()". So I am reluctant to force the domain ID to 0.
Quoted 3 lines
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
I had a brief look at drivers/char/console.c and I can't find any place assuming "domid 0". Do you have any pointer?
Quoted 22 lines
Signed-off-by Jason Andryuk <[email protected]>--- xen/arch/arm/dom0less-build.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/arch/arm/dom0less-build.c +1
-0@@ -969,6 +969,7 @@ void __init create_domUs(void)dt_for_each_child_node (chosen, node) {struct domain *d; +domid_t domid;struct xen_domctl_createdomain d_cfg = { .arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE , .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap,@@ -1121,7 +1122,12 @@ void __init create_domUs(void)* very important to use the pre-increment operator to call * domain_create() with a domid > 0. (domid == 0 is reserved for Dom0) */
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1133
Quoted 10 lines
xen/arch/arm/dom0less-build.c +6
-1- d =domain_create (++max_init_domid, &d_cfg, flags); +if ( flags & CDF_hardware ) + domid =0 ; +else + domid = ++max_init_domid; + + d =domain_create (domid, &d_cfg, flags);if (IS_ERR (d) )panic ("Error creating domain %s (rc = %ld)\n" ,dt_node_name (node),PTR_ERR (d));
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Quoted 6 lines · Julien Grall
Hi,
Quoted 1 line · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
A few years ago, we went to great length to avoid making the assumption that the hardware domain is domid 0. See all the calls to "
is_hardware_domain()". So I am reluctant to force the domain ID to 0.
I was disappointed when it didn't "just work".
Quoted 5 lines
Quoted 3 lines
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
I had a brief look at
drivers/char/console.cand I can't find any place assuming "domid 0". Do you have any pointer?
As Jan pointed out, Denis Mukhin's patch removed the domid 0 assumption.
This was developed without this patch when it mattered.
I tested before posting without this patch (and with Denis's), and again now, and I didn't get a hwdom login. Turns out xenstored was assuming domid 0. Changing that with --master-domid gets to the login prompt.
Still, there are now other userspace errors. xen-init-dom0 hardcodes domid 0 which doesn't exist. init-dom0less only initializes non-introduced domains, so hwdom doesn't get its "domid" xenstore node populated. That leads to other errors.
So I think with Denis's patch, this isn't strictly needed. It does help existing toolstack code work today.
Regards,
Jason
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Hi Jason,
Quoted 14 lines · Jason Andryuk
Quoted 6 lines · Julien Grall
Hi,
Quoted 1 line · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
A few years ago, we went to great length to avoid making the assumption that the hardware domain is domid 0. See all the calls to "
is_hardware_domain()". So I am reluctant to force the domain ID to 0.I was disappointed when it didn't "just work".
Quoted 4 lines
Quoted 3 lines
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
Quoted 6 lines
Quoted 1 line
I had a brief look at
drivers/char/console.cand I can't find any place assuming "domid 0". Do you have any pointer?As Jan pointed out, Denis Mukhin's patch removed the domid 0 assumption.
This was developed without this patch when it mattered.I tested before posting without this patch (and with Denis's), and again now, and I didn't get a hwdom login. Turns out xenstored was assuming domid 0. Changing that with --master-domid gets to the login prompt.
Hmmm, I am not sure --master-domid should point to the hardware domain. Instead, it feels like it should be the control domain because it needs to manage the VMs so needs to create any nodes in Xenstore.
Quoted 2 lines
Still, there are now other userspace errors. xen-init-dom0 hardcodes domid 0 which doesn't exist.
I am confused. Why would you call xen-init-dom0 in a domain that is meant to be the hardware domain rather than dom0?
Quoted 3 lines
init-dom0less only initializes non- introduced domains, so hwdom doesn't get its "domid" xenstore node populated. That leads to other errors.
Quoted 1 line
So I think with Denis's patch, this isn't strictly needed. It does help
existing toolstack code work today.
I don't think the toolstack is ready for a split between control/hardware domain. That said, shouldn't the toolstack run in the control domain? Same for xenstored (unless you have a xenstored domain)?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Quoted 17 lines · Julien Grall
Hi Jason,
Quoted 14 lines · Jason Andryuk
Quoted 6 lines · Julien Grall
Hi,
Quoted 1 line · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
A few years ago, we went to great length to avoid making the assumption that the hardware domain is domid 0. See all the calls to "
is_hardware_domain()". So I am reluctant to force the domain ID to 0.I was disappointed when it didn't "just work".
Quoted 4 lines
Quoted 3 lines
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I had a brief look at
drivers/char/console.cand I can't find any place assuming "domid 0". Do you have any pointer?As Jan pointed out, Denis Mukhin's patch removed the domid 0 assumption. This was developed without this patch when it mattered.
I tested before posting without this patch (and with Denis's), and again now, and I didn't get a hwdom login. Turns out xenstored was assuming domid 0. Changing that with --master-domid gets to the login prompt.
Hmmm, I am not sure --master-domid should point to the hardware domain. Instead, it feels like it should be the control domain because it needs to manage the VMs so needs to create any nodes in Xenstore.
--master-domid encompasses "the domid where xenstored is running" (which really xenstored should figure out itself), and is needed for xenstored to start.
There is an additional --priv-domid, which can point at the control domain.
Quoted 4 lines
Quoted 2 lines
Still, there are now other userspace errors. xen-init-dom0 hardcodes domid 0 which doesn't exist.
I am confused. Why would you call xen-init-dom0 in a domain that is meant to be the hardware domain rather than dom0?
I was using domid 0 :) Also, it's called by default in xencommons and sets up the cpupools.
Quoted 6 lines
Quoted 2 lines
init-dom0less only initializes non- introduced domains, so hwdom doesn't get its "domid" xenstore node populated. That leads to other errors.
Quoted 1 line
So I think with Denis's patch, this isn't strictly needed. It does
help
Quoted 1 line
existing toolstack code work today.
I don't think the toolstack is ready for a split between control/ hardware domain. That said, shouldn't the toolstack run in the control domain? Same for xenstored (unless you have a xenstored domain)?
Yes, maybe running control and xenstore together is better. I came from the perspective of dom0less with a hardware/control split, the toolstack is less important.
But in general, it's all intertwined. You have to start somewhere untangling.
Running xenstored in the hardware domain, and leaving hardware domain at domid 0 seemed like a good way to keep most things working while splitting out the hardware/control permissions.
There was also this practical consideration:
Xen:
if ( is_hardware_domain(d) )
fi.submap |= 1U << XENFEAT_dom0;
arch/arm/xen/enlighten.c
if (xen_feature(XENFEAT_dom0))
xen_start_flags |= SIF_INITDOMAIN|SIF_PRIVILEGED;drivers/xen/xenfs/super.c
if (xen_initial_domain())
tmp = "control_d\n";So control_d is set in /proc/xen/capabilities for the hardware domain/initial domain. That is checked in xencommons. Sure, that can be worked around, but I was trying to get something going.
I tried a combined control|xenstore domain, but it doesn't have /proc/xen/xsd_port, so xenstored fails:
Failed to initialize dom0 port: No such file or directory
Regards,
Jason
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Quoted 64 lines · Jason Andryuk
Quoted 25 lines · Julien Grall
Hi Jason,
Quoted 22 lines · Jason Andryuk
Quoted 8 lines · Julien Grall
Hi,
Quoted 1 line · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
A few years ago, we went to great length to avoid making the assumption that the hardware domain is domid 0. See all the calls to "
is_hardware_domain()". So I am reluctant to force the domain ID to 0.I was disappointed when it didn't "just work".
Quoted 6 lines
Quoted 3 lines
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
I had a brief look at
drivers/char/console.cand I can't find any place assuming "domid 0". Do you have any pointer?As Jan pointed out, Denis Mukhin's patch removed the domid 0 assumption. This was developed without this patch when it mattered.
Quoted 7 lines
Quoted 3 lines
I tested before posting without this patch (and with Denis's), and again now, and I didn't get a hwdom login. Turns out xenstored was assuming domid 0. Changing that with --master-domid gets to the login prompt.
Hmmm, I am not sure --master-domid should point to the hardware domain. Instead, it feels like it should be the control domain because it needs to manage the VMs so needs to create any nodes in Xenstore.
--master-domid encompasses "the domid where xenstored is running" (which really xenstored should figure out itself), and is needed for xenstored to start.
There is an additional --priv-domid, which can point at the control domain.
Quoted 6 lines
Quoted 3 lines
Still, there are now other userspace errors. xen-init-dom0 hardcodes domid 0 which doesn't exist.
I am confused. Why would you call xen-init-dom0 in a domain that is meant to be the hardware domain rather than dom0?
I was using domid 0 :) Also, it's called by default in xencommons and sets up the cpupools.
Quoted 9 lines
Quoted 3 lines
init-dom0less only initializes non- introduced domains, so hwdom doesn't get its "domid" xenstore node populated. That leads to other errors.
Quoted 1 line
So I think with Denis's patch, this isn't strictly needed. It does
help
Quoted 1 line
existing toolstack code work today.
I don't think the toolstack is ready for a split between control/ hardware domain. That said, shouldn't the toolstack run in the control domain? Same for xenstored (unless you have a xenstored domain)?
Yes, maybe running control and xenstore together is better. I came from the perspective of dom0less with a hardware/control split, the toolstack is less important.
Quoted 5 lines
But in general, it's all intertwined. You have to start somewhere untangling.
Running xenstored in the hardware domain, and leaving hardware domain at domid 0 seemed like a good way to keep most things working while splitting out the hardware/control permissions.
In my opinion, there are reasons for placing xenstored in the control domain and also reasons for placing it in the hardware domain. I think this is the kind of policy decision I would leave to the user.
In an embedded environment where safety is a concern, it also depends on whether the user wants to keep xenstore only between non-safe VMs, in which case I would put it in the hardware domain so that the control domain is fully isolated and protected. xenstore could be a source of interference.
Or whether the user wants to use xenstore also for safe VMs, in which case they are likely to reimplement xenstored in a way that is safety certified and as part of a safety certified OS such as Zephyr. In this type of configuration, it would make sense to have xenstored in the control domain.
I would suggest to make the location of xenstored configurable, and only provide a sensible default when the user doesn't explicitly say. With the state of the codebase and protocols that we have today, I think we are not ready for a xenstore free-from-interference implementation, so it would be safer to leave xenstored in the hardware domain as default, but we should make also the other configurations possible.
This is the first patch series aimed at untangling the whole thing, so not everything can be done here. For example, if the location of Xenstore is not configurable in this series, it may still be OK. We just need to be careful in the docs and interfaces not to bake it into an assumption.
I would also say the same for domid == 0: while it would be ideal to avoid relying on domid == 0 for the hardware domain, we don't have to resolve everything immediately. This series already achieves a significant improvement by separating the hardware domain from the control domain, which is valuable in itself.
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Hi Stefano,
Quoted 67 lines · Stefano Stabellini
Quoted 66 lines · Jason Andryuk
Quoted 25 lines · Julien Grall
Hi Jason,
Quoted 22 lines · Jason Andryuk
Quoted 8 lines · Julien Grall
Hi,
Quoted 1 line · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
A few years ago, we went to great length to avoid making the assumption that the hardware domain is domid 0. See all the calls to "
is_hardware_domain()". So I am reluctant to force the domain ID to 0.I was disappointed when it didn't "just work".
Quoted 6 lines
Quoted 3 lines
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
I had a brief look at
drivers/char/console.cand I can't find any place assuming "domid 0". Do you have any pointer?As Jan pointed out, Denis Mukhin's patch removed the domid 0 assumption.
This was developed without this patch when it mattered.Quoted 7 lines
Quoted 3 lines
I tested before posting without this patch (and with Denis's), and again now, and I didn't get a hwdom login. Turns out xenstored was assuming domid 0. Changing that with --master-domid gets to the login prompt.
Hmmm, I am not sure --master-domid should point to the hardware domain. Instead, it feels like it should be the control domain because it needs to manage the VMs so needs to create any nodes in Xenstore.
--master-domid encompasses "the domid where xenstored is running" (which really xenstored should figure out itself), and is needed for xenstored to start.
There is an additional --priv-domid, which can point at the control domain.
Quoted 6 lines
Quoted 3 lines
Still, there are now other userspace errors. xen-init-dom0 hardcodes domid 0 which doesn't exist.
I am confused. Why would you call xen-init-dom0 in a domain that is meant to be the hardware domain rather than dom0?
I was using domid 0 :) Also, it's called by default in xencommons and sets up the cpupools.
Quoted 9 lines
Quoted 3 lines
init-dom0less only initializes non- introduced domains, so hwdom doesn't get its "domid" xenstore node populated. That leads to other errors.
Quoted 1 line
So I think with Denis's patch, this isn't strictly needed. It does
help
Quoted 1 line
existing toolstack code work today.
I don't think the toolstack is ready for a split between control/ hardware domain. That said, shouldn't the toolstack run in the control domain? Same for xenstored (unless you have a xenstored domain)?
Yes, maybe running control and xenstore together is better. I came from the perspective of dom0less with a hardware/control split, the toolstack is less important.
But in general, it's all intertwined. You have to start somewhere untangling.
Quoted 7 lines
Quoted 3 lines
Running xenstored in the hardware domain, and leaving hardware domain at domid 0 seemed like a good way to keep most things working while splitting out the hardware/control permissions.
In my opinion, there are reasons for placing xenstored in the control domain and also reasons for placing it in the hardware domain. I think this is the kind of policy decision I would leave to the user.
I agree it should be a policy decision. But as a default setup, I think this is muddying the difference between the control domain and hardware domain. Today's toolstack can't work without xenstored. So intuitively, xenstored would belong to the control domain in a default setup.
Quoted 6 lines
In an embedded environment where safety is a concern, it also depends on whether the user wants to keep xenstore only between non-safe VMs, in which case I would put it in the hardware domain so that the control domain is fully isolated and protected. xenstore could be a source of interference.
So your hardware domain is not really an hardware domain, right? This is more a dom0 minus toolstack? If so, I think it might be helpful if you add a document explaining what a hardware domain really means with this series.
Quoted 19 lines
Or whether the user wants to use xenstore also for safe VMs, in which case they are likely to reimplement xenstored in a way that is safety certified and as part of a safety certified OS such as Zephyr. In this type of configuration, it would make sense to have xenstored in the control domain.
Quoted 1 line
I would suggest to make the location of xenstored configurable, and only
provide a sensible default when the user doesn't explicitly say. With the state of the codebase and protocols that we have today, I think we are not ready for a xenstore free-from-interference implementation, so it would be safer to leave xenstored in the hardware domain as default, but we should make also the other configurations possible.
This is the first patch series aimed at untangling the whole thing, so not everything can be done here. For example, if the location of Xenstore is not configurable in this series, it may still be OK. We just need to be careful in the docs and interfaces not to bake it into an assumption.
Quoted 3 lines
I would also say the same for domid == 0: while it would be ideal to avoid relying on domid == 0 for the hardware domain, we don't have to resolve everything immediately.
I have to disagree. If we start shipping Xen with "hwdomid == 0", it will be quite difficult to remove this behavior because new tooling (which may not be under our control) will likely start/continue to rely on it. So ...
Quoted 3 lines
This series already achieves a
significant improvement by separating the hardware domain from the control domain, which is valuable in itself.
... while I agree this series is a good step, I don't want to have any version of Xen where hwdomid == 0 (even temporarily).
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Quoted 91 lines · Julien Grall
Quoted 90 lines · Stefano Stabellini
Quoted 88 lines · Jason Andryuk
Quoted 35 lines · Julien Grall
Hi Jason,
Quoted 23 lines · Jason Andryuk
Quoted 11 lines · Julien Grall
Hi,
Quoted 2 lines · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
A few years ago, we went to great length to avoid making the assumption
that the hardware domain is domid 0. See all the calls to "is_hardware_domain()". So I am reluctant to force the domain ID to 0.I was disappointed when it didn't "just work".
Quoted 7 lines
Quoted 3 lines
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
I had a brief look at
drivers/char/console.cand I can't find any place
assuming "domid 0". Do you have any pointer?Quoted 8 lines
As Jan pointed out, Denis Mukhin's patch removed the domid 0 assumption.
This was developed without this patch when it mattered.I tested before posting without this patch (and with Denis's), and again
now, and I didn't get a hwdom login. Turns out xenstored was assuming domid 0. Changing that with --master-domid gets to the login prompt.Quoted 4 lines
Hmmm, I am not sure --master-domid should point to the hardware domain. Instead, it feels like it should be the control domain because it needs to
manage the VMs so needs to create any nodes in Xenstore.--master-domid encompasses "the domid where xenstored is running" (which really xenstored should figure out itself), and is needed for xenstored to start.
There is an additional --priv-domid, which can point at the control domain.
Quoted 7 lines
Quoted 3 lines
Still, there are now other userspace errors. xen-init-dom0 hardcodes domid 0 which doesn't exist.
I am confused. Why would you call xen-init-dom0 in a domain that is meant to
be the hardware domain rather than dom0?I was using domid 0 :) Also, it's called by default in xencommons and sets up
the cpupools.Quoted 6 lines
Quoted 4 lines
init-dom0less only initializes non- introduced domains, so hwdom doesn't
get its "domid" xenstore node populated. That leads to other errors.Quoted 1 line
So I think with Denis's patch, this isn't strictly needed. It
does
helpQuoted 7 lines
Quoted 1 line
existing toolstack code work today.
I don't think the toolstack is ready for a split between control/ hardware
domain. That said, shouldn't the toolstack run in the control domain? Same
for xenstored (unless you have a xenstored domain)?Yes, maybe running control and xenstore together is better. I came from the
perspective of dom0less with a hardware/control split, the toolstack is less
important.But in general, it's all intertwined. You have to start somewhere untangling.
Running xenstored in the hardware domain, and leaving hardware domain at domid
0 seemed like a good way to keep most things working while splitting out the
hardware/control permissions.
Quoted 8 lines
Quoted 3 lines
In my opinion, there are reasons for placing xenstored in the control domain and also reasons for placing it in the hardware domain. I think this is the kind of policy decision I would leave to the user.
I agree it should be a policy decision. But as a default setup, I think this is muddying the difference between the control domain and hardware domain. Today's toolstack can't work without xenstored. So intuitively, xenstored would belong to the control domain in a default setup.
I wrote more in another email.
Quoted 9 lines
Quoted 5 lines
In an embedded environment where safety is a concern, it also depends on whether the user wants to keep xenstore only between non-safe VMs, in which case I would put it in the hardware domain so that the control domain is fully isolated and protected. xenstore could be a source of interference.
So your hardware domain is not really an hardware domain, right? This is more a dom0 minus toolstack? If so, I think it might be helpful if you add a document explaining what a hardware domain really means with this series.
Yes, it is as you wrote: dom0 minus toolstack and without d->is_priv. I can help document it better.
Quoted 26 lines
Quoted 18 lines
Or whether the user wants to use xenstore also for safe VMs, in which case they are likely to reimplement xenstored in a way that is safety certified and as part of a safety certified OS such as Zephyr. In this type of configuration, it would make sense to have xenstored in the control domain.
Quoted 1 line
I would suggest to make the location of xenstored configurable, and only
provide a sensible default when the user doesn't explicitly say. With the state of the codebase and protocols that we have today, I think we are not ready for a xenstore free-from-interference implementation, so it would be safer to leave xenstored in the hardware domain as default, but we should make also the other configurations possible.
This is the first patch series aimed at untangling the whole thing, so not everything can be done here. For example, if the location of Xenstore is not configurable in this series, it may still be OK. We just need to be careful in the docs and interfaces not to bake it into an assumption.
Quoted 3 lines
I would also say the same for domid == 0: while it would be ideal to avoid relying on domid == 0 for the hardware domain, we don't have to resolve everything immediately.
I have to disagree. If we start shipping Xen with "hwdomid == 0", it will be quite difficult to remove this behavior because new tooling (which may not be under our control) will likely start/continue to rely on it. So ...
Quoted 6 lines
Quoted 3 lines
This series already achieves a
significant improvement by separating the hardware domain from the control domain, which is valuable in itself.... while I agree this series is a good step, I don't want to have any version of Xen where hwdomid == 0 (even temporarily).
I don't feel strongly either way. If Jason is OK with ensuring the hardware domain domid != 0 from the start, I am happy with it too.
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
In reply to Julien GrallQuoted 8 lines · Julien Grall
Quoted 4 lines
init-dom0less only initializes non- introduced domains, so hwdom doesn't get its "domid" xenstore node populated. That leads to other errors.
Quoted 1 line
So I think with Denis's patch, this isn't strictly needed. It does help
existing toolstack code work today.
I don't think the toolstack is ready for a split between control/hardware domain. That said, shouldn't the toolstack run in the control domain? Same for xenstored (unless you have a xenstored domain)?
Yes, the toolstack (if present) would be in the control domain. xenstored doesn't have to be in the control domain and in fact it might not be advisable to place it there today.
The main difference between the toolstack and xenstored is that the toolstack only talks to Xen, while xenstored talks to all other VMs, which is dangerous in many configurations.
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Hi,
Quoted 10 lines · Stefano Stabellini
Quoted 8 lines · Julien Grall
Quoted 4 lines
init-dom0less only initializes non- introduced domains, so hwdom doesn't get its "domid" xenstore node populated. That leads to other errors.
Quoted 1 line
So I think with Denis's patch, this isn't strictly needed. It does help
existing toolstack code work today.
I don't think the toolstack is ready for a split between control/hardware domain. That said, shouldn't the toolstack run in the control domain? Same for xenstored (unless you have a xenstored domain)?
Quoted 7 lines
Yes, the toolstack (if present) would be in the control domain. xenstored doesn't have to be in the control domain and in fact it might not be advisable to place it there today.
The main difference between the toolstack and xenstored is that the toolstack only talks to Xen, while xenstored talks to all other VMs, which is dangerous in many configurations.
It is not really clear which toolstack you are referring to.
Someone using vanilla Xen upstream will end up to use "xl" which has to talk to xenstored and also indirectly to each domain (e.g. shutdown/suspend node in xenstored). So for this setup, "xenstored" is not optional and I would argue should be part of the control domain (or in a xenstore stubdomain which IIRC is not supported on Arm today).
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
Quoted 18 lines · Julien Grall
Quoted 17 lines · Stefano Stabellini
Quoted 11 lines · Julien Grall
Quoted 6 lines
init-dom0less only initializes non- introduced domains, so hwdom doesn't get
its "domid" xenstore node populated. That leads to other errors.Quoted 2 lines
So I think with Denis's patch, this isn't strictly needed. It does help
existing toolstack code work today.
I don't think the toolstack is ready for a split between control/hardware domain. That said, shouldn't the toolstack run in the control domain? Same for
xenstored (unless you have a xenstored domain)?Yes, the toolstack (if present) would be in the control domain. xenstored doesn't have to be in the control domain and in fact it might not be advisable to place it there today.
Quoted 5 lines
Quoted 3 lines
The main difference between the toolstack and xenstored is that the toolstack only talks to Xen, while xenstored talks to all other VMs, which is dangerous in many configurations.
It is not really clear which toolstack you are referring to.
You make a good point, I'll be clearer and distinguish between the implementation and the interfaces. This exercise helped me clarify my own thoughts as well.
Quoted 5 lines
Someone using vanilla Xen upstream will end up to use "xl" which has to talk to xenstored and also indirectly to each domain (e.g. shutdown/suspend node in xenstored). So for this setup, "xenstored" is not optional and I would argue should be part of the control domain (or in a xenstore stubdomain which IIRC is not supported on Arm today).
The control domain is the guest with the highest level of privilege and the only virtual machine that can use hypercalls to affect other VMs. A simple example is that the control domain could issue a hypercall to reboot other VMs.
The hardware domain does not have privilege (d->is_priv=false).
In the configuration for safety, we use dom0less for domain creation, so there is no toolstack is the traditional sense of the word. But we could have a Zephyr guest issuing a SHUTDOWN_poweroff hypercall for instance. Certainly, we cannot run Linux and xl/libxl in the control domain.
Due to its high level of privilege and the fact that it can affect others, if present, the control domain must be safety certified. The current toolstack implementation is based on Linux. While the larger Open Source community is working on Linux for safety, it is still a challenge. xenstored itself would need to be safety certified as well to run there, think of MISRA C, and also requirements, tests, etc. In addition, xenstored communicates directly with other VMs over shared memory, which means it would need to be developed with extreme care to prevent interference through shared memory. Even if a safety certified version of Linux were available in the future, the current toolstack implementation might not be suitable for use in that environment. As of today, safety deployments would not be able to run xl/libxl and/or xenstored in the control domain. However, they could run a safety certified RTOS, maybe Zephyr, issuing individual hypercalls, such as SHUTDOWN_reboot.
If we had a safety certified free-from-interference implementation of xenstored as a Zephyr application, with Zephyr safety-certified, then I would run it in the control domain.
On the other hand, the hardware domain might not be safety certified. So we could run xl/libxl and xenstored in the hardware domain. Of course most operations will be refused, e.g. SHUTDOWN_poweroff returns error because d->is_priv=false, but at least the user could run today's implementation of xenstored successfully. (domain creation is done using dom0less anyway so xl is optional.)
Conceptually, it could make sense to think of xenstored being part of the control domain, not today's xenstored but a safe re-implementation of xenstored based on Zephyr.
If you look at what we have today available and what people could deploy with the current codebase this year or next year, it makes sense to place xenstored in the hardware domain, or not at all.
Re: [PATCH 04/23] xen/arm: dom0less use domid 0 for hwdom
In reply to Jason AndryukQuoted 4 lines · Jason Andryuk
Assign domid 0 to the hwdom. Normally, dom0less does not use domid 0.
This fixes using the Xen console which assumes domid 0 to use the hypercall interface.
Iirc a patch by Denis Mukhin is taking care of that, if what's meant is the input focus switching logic.
Jan
PATCH 5/23 xen/arm: Add capabilities to dom0less
In reply to Jason AndryukAdd capabilities property to dom0less to allow building a disaggregated system.
Introduce bootfdt.h to contain these constants.
When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
Also for the hardware domain, set directmap and iommu. This brings its configuration in line with a dom0.
---
There is overlap with hyperlaunch. The numeric values are the same. Hyperlaunch doesn't expose the values in a public header as done here. Is this to be expected for dom0less? It seems most of dom0less isn't in a header, but just in docs.
Hyperlaunch uses BUILD_CAPS_, but I chose DOMAIN_CAPS_ since there are domain-level capabilities.
Only a single xenstore and hardware domain make sense. A check to limit to only a single hardware domain is in place - building two breaks. But nothing prevents the dom0less configuration from only having multiple xenstore domains. Each xenstore domain would have slightly more permissions, but only the last one would be used.
--- docs/misc/arm/device-tree/booting.txt | 11 ++++++++++ xen/arch/arm/dom0less-build.c | 29 +++++++++++++++++++++++++++ xen/arch/arm/domain.c | 3 ++- xen/include/public/bootfdt.h | 27 +++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 xen/include/public/bootfdt.h
docs/misc/arm/device-tree/booting.txt +11 -0
@@ -167,6 +167,17 @@ with the following properties: Refer to docs/misc/cache_coloring.rst for syntax. This option is applicable only to Arm64 guests. +- capabilities + Optional. A bit field of domain capabilities for a disaggregated + system. A traditional dom0 has all all of these capabilities, and a + domU has none of them. + + 0x1 DOMAIN_CAPS_CONTROL - A privileged, control domain + 0x2 DOMAIN_CAPS_HARDWARE - The hardware domain - there can be only 1 + 0x4 DOMAIN_CAPS_XENSTORE - The xenstore domain - there can be only 1 + + The default is no capabilities. + - vpl011 An empty property to enable/disable a virtual pl011 for the guest to
xen/arch/arm/dom0less-build.c +29 -0
@@ -12,6 +12,7 @@#include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h>
@@ -994,6 +995,34 @@ void __init create_domUs(void)if ( (max_init_domid +1 ) >=DOMID_FIRST_RESERVED )panic ("No more domain IDs available\n" ); +if (dt_property_read_u32 (node,"capabilities" , &val) ) + { +if ( val & ~DOMAIN_CAPS_MASK ) +panic ("Invalid capabilities (%" PRIx32")\n" , val); + +if ( val &DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged; + +if ( val &DOMAIN_CAPS_HARDWARE ) + { +if ( hardware_domain ) +panic ("Only 1 hardware domain can be specified! (%pd)\n" , + hardware_domain); + + d_cfg.max_grant_frames =gnttab_dom0_frames (); + d_cfg.max_evtchn_port =-1 ; + flags |= CDF_hardware; + flags |= CDF_directmap; + iommu = true; + } + +if ( val &DOMAIN_CAPS_XENSTORE ) + { + d_cfg.flags |= XEN_DOMCTL_CDF_xs_domain; + d_cfg.max_evtchn_port =-1 ; + } + } +if (dt_find_property (node,"xen,static-mem" ,NULL ) ) {if ( llc_coloring_enabled )
xen/arch/arm/domain.c +2 -1
@@ -608,7 +608,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); +unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu | + XEN_DOMCTL_CDF_xs_domain );unsigned int sve_vl_bits =sve_decode_vl (config->arch.sve_vl);if ( (config->flags & ~flags_optional) != flags_required )
xen/include/public/bootfdt.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Xen Device Tree boot information +* +* Information for configuring Xen domains created at boot time. +*/ + +#ifndef __XEN_PUBLIC_BOOTFDT_H__ +#define __XEN_PUBLIC_BOOTFDT_H__ + +/* Domain Capabilities specified in the "capabilities" property. Use of +* this property allows splitting up the monolithic dom0 into separate, +* less privileged components. A regular domU has no capabilities +* (which is the default if nothing is specified). A traditional dom0 +* has all three capabilities.*/ + +/* Control/Privileged domain capable of affecting other domains. */ +#define DOMAIN_CAPS_CONTROL (1 << 0) +/* Hardware domain controlling physical hardware. Typically providing +* backends to other domains. */ +#define DOMAIN_CAPS_HARDWARE (1 << 1) +/* Xenstore domain. */ +#define DOMAIN_CAPS_XENSTORE (1 << 2) +#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ + DOMAIN_CAPS_XENSTORE) + +#endif /* __XEN_PUBLIC_BOOTFDT_H__ */
Signature · 1 line
2.48.1
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Quoted 78 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
Also for the hardware domain, set directmap and iommu. This brings its configuration in line with a dom0.
Signed-off-by Jason Andryuk <[email protected]>---
There is overlap with hyperlaunch. The numeric values are the same. Hyperlaunch doesn't expose the values in a public header as done here. Is this to be expected for dom0less? It seems most of dom0less isn't in a header, but just in docs.Hyperlaunch uses
BUILD_CAPS_, but I choseDOMAIN_CAPS_since there are domain-level capabilities.Only a single xenstore and hardware domain make sense. A check to limit to only a single hardware domain is in place - building two breaks. But nothing prevents the dom0less configuration from only having multiple xenstore domains. Each xenstore domain would have slightly more permissions, but only the last one would be used.
--- docs/misc/arm/device-tree/booting.txt | 11 ++++++++++ xen/arch/arm/dom0less-build.c | 29 +++++++++++++++++++++++++++ xen/arch/arm/domain.c | 3 ++- xen/include/public/bootfdt.h | 27 +++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 xen/include/public/bootfdt.hdocs/misc/arm/device-tree/booting.txt +11
-0@@ -167,6 +167,17 @@ with the following properties: Refer to docs/misc/cache_coloring.rst for syntax. This option is applicable only to Arm64 guests. +- capabilities + Optional. A bit field of domain capabilities for a disaggregated + system. A traditional dom0 has all all of these capabilities, and a + domU has none of them. + + 0x1 DOMAIN_CAPS_CONTROL - A privileged, control domain + 0x2 DOMAIN_CAPS_HARDWARE - The hardware domain - there can be only 1 + 0x4 DOMAIN_CAPS_XENSTORE - The xenstore domain - there can be only 1 + + The default is no capabilities. + - vpl011 An empty property to enable/disable a virtual pl011 for the guest toxen/arch/arm/dom0less-build.c +7
-0@@ -12,6 +12,7 @@#include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h> @@ -994,6 +995,34 @@ void __init create_domUs(void)if ( (max_init_domid +1 ) >=DOMID_FIRST_RESERVED )panic ("No more domain IDs available\n" ); +if (dt_property_read_u32 (node,"capabilities" , &val) ) + { +if ( val & ~DOMAIN_CAPS_MASK ) +panic ("Invalid capabilities (%" PRIx32")\n" , val); + +if ( val &DOMAIN_CAPS_CONTROL )
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 10 lines
xen/arch/arm/dom0less-build.c +10
-0+ flags |= CDF_privileged; + +if ( val &DOMAIN_CAPS_HARDWARE ) + { +if ( hardware_domain ) +panic ("Only 1 hardware domain can be specified! (%pd)\n" , + hardware_domain); + + d_cfg.max_grant_frames =gnttab_dom0_frames (); + d_cfg.max_evtchn_port =-1 ;
max_maptrack_frames = -1 ?
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1021
Quoted 8 lines
xen/arch/arm/dom0less-build.c +8
-0+ flags |= CDF_hardware; + flags |= CDF_directmap; + iommu = true; + } + +if ( val &DOMAIN_CAPS_XENSTORE ) + { + d_cfg.flags |= XEN_DOMCTL_CDF_xs_domain;
shouldn't we take the opportunity to also set XEN_DOMCTL_CDF_xs_domain in xen/arch/arm/domain_build.c:create_dom0 ?
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1022
Quoted 1 line
xen/arch/arm/dom0less-build.c +1
-0+ d_cfg.max_evtchn_port =-1 ;
Why this one?
Quoted 31 lines
xen/arch/arm/dom0less-build.c +3
-0+ } + } +if (dt_find_property (node,"xen,static-mem" ,NULL ) ) {if ( llc_coloring_enabled )xen/arch/arm/domain.c +2
-1@@ -608,7 +608,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); +unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu | + XEN_DOMCTL_CDF_xs_domain );unsigned int sve_vl_bits =sve_decode_vl (config->arch.sve_vl);if ( (config->flags & ~flags_optional) != flags_required )xen/include/public/bootfdt.h new file +5
-0@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Xen Device Tree boot information +* +* Information for configuring Xen domains created at boot time.
xen/include/public/bootfdt.h line 15
Quoted 10 lines
xen/include/public/bootfdt.h new file +10
-0+*/ + +#ifndef __XEN_PUBLIC_BOOTFDT_H__ +#define __XEN_PUBLIC_BOOTFDT_H__ + +/* Domain Capabilities specified in the "capabilities" property. Use of +* this property allows splitting up the monolithic dom0 into separate, +* less privileged components. A regular domU has no capabilities +* (which is the default if nothing is specified). A traditional dom0 +* has all three capabilities.*/
The multiline comment coding style is:
/*
* comment
* comment
*/
Quoted 14 lines
xen/include/public/bootfdt.h new file +11
-0+/* Control/Privileged domain capable of affecting other domains. */ +#define DOMAIN_CAPS_CONTROL (1 << 0) +/* Hardware domain controlling physical hardware. Typically providing +* backends to other domains. */ +#define DOMAIN_CAPS_HARDWARE (1 << 1) +/* Xenstore domain. */ +#define DOMAIN_CAPS_XENSTORE (1 << 2) +#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ + DOMAIN_CAPS_XENSTORE) + +#endif /* __XEN_PUBLIC_BOOTFDT_H__ */ Signature · 1 line
2.48.1
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Quoted 54 lines · Stefano Stabellini
Quoted 53 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
Also for the hardware domain, set directmap and iommu. This brings its configuration in line with a dom0.
Signed-off-by Jason Andryuk <[email protected]>---
There is overlap with hyperlaunch. The numeric values are the same. Hyperlaunch doesn't expose the values in a public header as done here. Is this to be expected for dom0less? It seems most of dom0less isn't in a header, but just in docs.Hyperlaunch uses
BUILD_CAPS_, but I choseDOMAIN_CAPS_since there are domain-level capabilities.Only a single xenstore and hardware domain make sense. A check to limit to only a single hardware domain is in place - building two breaks. But nothing prevents the dom0less configuration from only having multiple xenstore domains. Each xenstore domain would have slightly more permissions, but only the last one would be used.
xen/arch/arm/dom0less-build.c +11
-0@@ -12,6 +12,7 @@#include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h> @@ -994,6 +995,34 @@ void __init create_domUs(void)if ( (max_init_domid +1 ) >=DOMID_FIRST_RESERVED )panic ("No more domain IDs available\n" ); +if (dt_property_read_u32 (node,"capabilities" , &val) ) + { +if ( val & ~DOMAIN_CAPS_MASK ) +panic ("Invalid capabilities (%" PRIx32")\n" , val); + +if ( val &DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged; + +if ( val &DOMAIN_CAPS_HARDWARE ) + {
Quoted 8 lines
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 6 lines
xen/arch/arm/dom0less-build.c +6
-0+if ( hardware_domain ) +panic ("Only 1 hardware domain can be specified! (%pd)\n" , + hardware_domain); + + d_cfg.max_grant_frames =gnttab_dom0_frames (); + d_cfg.max_evtchn_port =-1 ;
max_maptrack_frames= -1 ?
Yes.
Quoted 10 lines
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1021
Quoted 9 lines
xen/arch/arm/dom0less-build.c +8
-0+ flags |= CDF_hardware; + flags |= CDF_directmap; + iommu = true; + } + +if ( val &DOMAIN_CAPS_XENSTORE ) + { + d_cfg.flags |= XEN_DOMCTL_CDF_xs_domain;
Quoted 2 lines
shouldn't we take the opportunity to also set
XEN_DOMCTL_CDF_xs_domainin xen/arch/arm/domain_build.c:create_dom0 ?
We could. It isn't normally used except for a standalone xenstore domain, which is why I didn't add it.
Quoted 4 lines
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1022
Quoted 2 lines
xen/arch/arm/dom0less-build.c +1
-0+ d_cfg.max_evtchn_port =-1 ;Why this one?
It mirrors what is done in init-xenstore for a xenstore stubdom. It's to remove the limit so the xenstore domain can create as many as necessary for however many domains.
Quoted 32 lines
Quoted 19 lines
xen/arch/arm/dom0less-build.c +3
-0+ } + } +if (dt_find_property (node,"xen,static-mem" ,NULL ) ) {if ( llc_coloring_enabled )xen/include/public/bootfdt.h new file +5
-0@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Xen Device Tree boot information +* +* Information for configuring Xen domains created at boot time. xen/include/public/bootfdt.h line 15
Quoted 10 lines
xen/include/public/bootfdt.h new file +10
-0+*/ + +#ifndef __XEN_PUBLIC_BOOTFDT_H__ +#define __XEN_PUBLIC_BOOTFDT_H__ + +/* Domain Capabilities specified in the "capabilities" property. Use of +* this property allows splitting up the monolithic dom0 into separate, +* less privileged components. A regular domU has no capabilities +* (which is the default if nothing is specified). A traditional dom0 +* has all three capabilities.*/ The multiline comment coding style is:
Quoted 4 lines
/*
* comment
* comment
*/
Ok.
Thanks,
Jason
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Quoted 36 lines · Jason Andryuk
Quoted 26 lines · Stefano Stabellini
Quoted 24 lines · Jason Andryuk
xen/arch/arm/dom0less-build.c +12
-0@@ -12,6 +12,7 @@ #include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h>@@ -994,6 +995,34 @@ void __init create_domUs(void) if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); + if ( dt_property_read_u32(node, "capabilities", &val) ) + { + if ( val & ~DOMAIN_CAPS_MASK ) + panic("Invalid capabilities (%"PRIx32")\n", val); + + if ( val & DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged; + + if ( val & DOMAIN_CAPS_HARDWARE ) + { + if ( hardware_domain )Quoted 8 lines
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 6 lines
xen/arch/arm/dom0less-build.c +5
-0+ panic("Only 1 hardware domain can be specified! (%pd)\n", + hardware_domain); + + d_cfg.max_grant_frames = gnttab_dom0_frames(); + d_cfg.max_evtchn_port = -1;
max_maptrack_frames= -1 ?
Quoted 1 line
Yes.
Actually, -1 is already used to initialize d_cfg.max_maptrack_frames.
Regards,
Jason
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
In reply to Jason AndryukHi,
Quoted 9 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
Quoted 1 line
Also for the hardware domain, set directmap and iommu. This brings its
configuration in line with a dom0.
Looking the device tree bindings, a user would be allowed to disable "passthrough" or even "directmap". This means, we would never be able to disable "directmap" for the hardware domain in the future with the existing property (this is to avoid break backwards compatibility).
Instead, I think we should check what the user provided and confirm this is matching our expectation for an hardware domain.
That said, I am not entirely sure why we should force directmap for the HW domain. We are starting from a clean slate, so I think it would be better to have by default no directmap and imposing the presence of an IOMMU in the system.
Lastly, can you provide an example of what the hardware domain DT node would looke like?
Quoted 67 lines
Signed-off-by Jason Andryuk <[email protected]>---
There is overlap with hyperlaunch. The numeric values are the same. Hyperlaunch doesn't expose the values in a public header as done here. Is this to be expected for dom0less? It seems most of dom0less isn't in a header, but just in docs.Hyperlaunch uses
BUILD_CAPS_, but I choseDOMAIN_CAPS_since there are domain-level capabilities.Only a single xenstore and hardware domain make sense. A check to limit to only a single hardware domain is in place - building two breaks. But nothing prevents the dom0less configuration from only having multiple xenstore domains. Each xenstore domain would have slightly more permissions, but only the last one would be used.
--->docs/misc/arm/device-tree/booting.txt| 11 ++++++++++xen/arch/arm/dom0less-build.c | 29 +++++++++++++++++++++++++++ xen/arch/arm/domain.c | 3 ++- xen/include/public/bootfdt.h | 27 +++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-)create mode 100644
xen/include/public/bootfdt.hdocs/misc/arm/device-tree/booting.txt +11
-0@@ -167,6 +167,17 @@ with the following properties: Refer to docs/misc/cache_coloring.rst for syntax. This option is applicable only to Arm64 guests. +- capabilities + Optional. A bit field of domain capabilities for a disaggregated + system. A traditional dom0 has all all of these capabilities, and a + domU has none of them. + + 0x1 DOMAIN_CAPS_CONTROL - A privileged, control domain + 0x2 DOMAIN_CAPS_HARDWARE - The hardware domain - there can be only 1 + 0x4 DOMAIN_CAPS_XENSTORE - The xenstore domain - there can be only 1 + + The default is no capabilities. + - vpl011 An empty property to enable/disable a virtual pl011 for the guest toxen/arch/arm/dom0less-build.c +7
-0@@ -12,6 +12,7 @@#include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h> @@ -994,6 +995,34 @@ void __init create_domUs(void)if ( (max_init_domid +1 ) >=DOMID_FIRST_RESERVED )panic ("No more domain IDs available\n" ); +if (dt_property_read_u32 (node,"capabilities" , &val) ) + { +if ( val & ~DOMAIN_CAPS_MASK ) +panic ("Invalid capabilities (%" PRIx32")\n" , val); + +if ( val &DOMAIN_CAPS_CONTROL )
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 10 lines
xen/arch/arm/dom0less-build.c +10
-0+ flags |= CDF_privileged; + +if ( val &DOMAIN_CAPS_HARDWARE ) + { +if ( hardware_domain ) +panic ("Only 1 hardware domain can be specified! (%pd)\n" , + hardware_domain); + + d_cfg.max_grant_frames =gnttab_dom0_frames (); + d_cfg.max_evtchn_port =-1 ;
What about d_cfg.arch.nr_spis? Are we expecting the user to pass "nr_spis"?
Quoted 61 lines
xen/arch/arm/dom0less-build.c +11
-0+ flags |= CDF_hardware; + flags |= CDF_directmap; + iommu = true;> + } + +if ( val &DOMAIN_CAPS_XENSTORE ) + { + d_cfg.flags |= XEN_DOMCTL_CDF_xs_domain; + d_cfg.max_evtchn_port =-1 ; + } + } +if (dt_find_property (node,"xen,static-mem" ,NULL ) ) {if ( llc_coloring_enabled )xen/arch/arm/domain.c +2
-1@@ -608,7 +608,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); +unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu | + XEN_DOMCTL_CDF_xs_domain );unsigned int sve_vl_bits =sve_decode_vl (config->arch.sve_vl);if ( (config->flags & ~flags_optional) != flags_required )xen/include/public/bootfdt.h new file +27
-0@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Xen Device Tree boot information +* +* Information for configuring Xen domains created at boot time. +*/ + +#ifndef __XEN_PUBLIC_BOOTFDT_H__ +#define __XEN_PUBLIC_BOOTFDT_H__ + +/* Domain Capabilities specified in the "capabilities" property. Use of +* this property allows splitting up the monolithic dom0 into separate, +* less privileged components. A regular domU has no capabilities +* (which is the default if nothing is specified). A traditional dom0 +* has all three capabilities.*/ + +/* Control/Privileged domain capable of affecting other domains. */ +#define DOMAIN_CAPS_CONTROL (1 << 0) +/* Hardware domain controlling physical hardware. Typically providing +* backends to other domains. */ +#define DOMAIN_CAPS_HARDWARE (1 << 1) +/* Xenstore domain. */ +#define DOMAIN_CAPS_XENSTORE (1 << 2) +#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ + DOMAIN_CAPS_XENSTORE) + +#endif /* __XEN_PUBLIC_BOOTFDT_H__ */
Signature · 1 line
Julien Grall
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Quoted 11 lines · Julien Grall
Hi,
Quoted 8 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
Quoted 1 line
Also for the hardware domain, set directmap and iommu. This brings
Quoted 8 lines
its
Quoted 1 line
configuration in line with a dom0.
Looking the device tree bindings, a user would be allowed to disable "passthrough" or even "directmap". This means, we would never be able to disable "directmap" for the hardware domain in the future with the existing property (this is to avoid break backwards compatibility).
Instead, I think we should check what the user provided and confirm this is matching our expectation for an hardware domain.
That said, I am not entirely sure why we should force directmap for the HW domain. We are starting from a clean slate, so I think it would be better to have by default no directmap and imposing the presence of an IOMMU in the system.
Ok, it seems like directmap is not necessary. It was helpful early on to get things booting, but I think it's no longer necessary after factoring out construct_hwdom().
What exactly do you mean by imposing with respect to the iommu? Require one, or mirror the dom0 code and set it for the hwdom?
if ( iommu_enabled )
dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;
Quoted 1 line
Lastly, can you provide an example of what the hardware domain DT node would looke like?
I've attached a dump of /sys/firmware/fdt from hwdom. (This is direct mapped).
Quoted 22 lines
Quoted 22 lines
xen/arch/arm/dom0less-build.c +12
-0@@ -12,6 +12,7 @@ #include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h>@@ -994,6 +995,34 @@ void __init create_domUs(void) if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); + if ( dt_property_read_u32(node, "capabilities", &val) ) + { + if ( val & ~DOMAIN_CAPS_MASK ) + panic("Invalid capabilities (%"PRIx32")\n", val); + + if ( val & DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged; + + if ( val & DOMAIN_CAPS_HARDWARE ) + { + if ( hardware_domain )
Quoted 8 lines
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 6 lines
xen/arch/arm/dom0less-build.c +5
-0+ panic("Only 1 hardware domain can be specified! (%pd)\n", + hardware_domain); + + d_cfg.max_grant_frames = gnttab_dom0_frames(); + d_cfg.max_evtchn_port = -1;What about d_cfg.arch.nr_spis? Are we expecting the user to pass "
nr_spis"?
Further down, when nr_spis isn't specified in the DT, it defaults to:
d_cfg.arch.nr_spis = gic_number_lines() - 32;
Dom0 does:
/*
* Xen vGIC supports a maximum of 992 interrupt lines.
* 32 are substracted to cover local IRQs.
*/
dom0_cfg.arch.nr_spis = min(gic_number_lines(), (unsigned int) 992)
- 32;
if ( gic_number_lines() > 992 )
printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded.\n");So I think it's fine as-is? I could add the min() and warning if you think it's necessary.
Regards,
Jason
/dts-v1/;
/ {
interrupt-parent = <0x8005>;
dma-coherent;
model = "linux,dummy-virt";
#size-cells = <0x02>;
#address-cells = <0x02>;
compatible = "linux,dummy-virt";
platform-bus@c000000 {
interrupt-parent = <0x8005>;
ranges = <0x00 0x00 0xc000000 0x2000000>;
#address-cells = <0x01>;
#size-cells = <0x01>;
compatible = "qemu,platform", "simple-bus";
};
fw-cfg@9020000 {
dma-coherent;
reg = <0x00 0x9020000 0x00 0x18>;
compatible = "qemu,fw-cfg-mmio";
};
virtio_mmio@a000000 {
dma-coherent;
interrupts = <0x00 0x10 0x01>;
reg = <0x00 0xa000000 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a000200 {
dma-coherent;
interrupts = <0x00 0x11 0x01>;
reg = <0x00 0xa000200 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a000400 {
dma-coherent;
interrupts = <0x00 0x12 0x01>;
reg = <0x00 0xa000400 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a000600 {
dma-coherent;
interrupts = <0x00 0x13 0x01>;
reg = <0x00 0xa000600 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a000800 {
dma-coherent;
interrupts = <0x00 0x14 0x01>;
reg = <0x00 0xa000800 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a000a00 {
dma-coherent;
interrupts = <0x00 0x15 0x01>;
reg = <0x00 0xa000a00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a000c00 {
dma-coherent;
interrupts = <0x00 0x16 0x01>;
reg = <0x00 0xa000c00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a000e00 {
dma-coherent;
interrupts = <0x00 0x17 0x01>;
reg = <0x00 0xa000e00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a001000 {
dma-coherent;
interrupts = <0x00 0x18 0x01>;
reg = <0x00 0xa001000 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a001200 {
dma-coherent;
interrupts = <0x00 0x19 0x01>;
reg = <0x00 0xa001200 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a001400 {
dma-coherent;
interrupts = <0x00 0x1a 0x01>;
reg = <0x00 0xa001400 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a001600 {
dma-coherent;
interrupts = <0x00 0x1b 0x01>;
reg = <0x00 0xa001600 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a001800 {
dma-coherent;
interrupts = <0x00 0x1c 0x01>;
reg = <0x00 0xa001800 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a001a00 {
dma-coherent;
interrupts = <0x00 0x1d 0x01>;
reg = <0x00 0xa001a00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a001c00 {
dma-coherent;
interrupts = <0x00 0x1e 0x01>;
reg = <0x00 0xa001c00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a001e00 {
dma-coherent;
interrupts = <0x00 0x1f 0x01>;
reg = <0x00 0xa001e00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a002000 {
dma-coherent;
interrupts = <0x00 0x20 0x01>;
reg = <0x00 0xa002000 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a002200 {
dma-coherent;
interrupts = <0x00 0x21 0x01>;
reg = <0x00 0xa002200 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a002400 {
dma-coherent;
interrupts = <0x00 0x22 0x01>;
reg = <0x00 0xa002400 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a002600 {
dma-coherent;
interrupts = <0x00 0x23 0x01>;
reg = <0x00 0xa002600 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a002800 {
dma-coherent;
interrupts = <0x00 0x24 0x01>;
reg = <0x00 0xa002800 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a002a00 {
dma-coherent;
interrupts = <0x00 0x25 0x01>;
reg = <0x00 0xa002a00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a002c00 {
dma-coherent;
interrupts = <0x00 0x26 0x01>;
reg = <0x00 0xa002c00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a002e00 {
dma-coherent;
interrupts = <0x00 0x27 0x01>;
reg = <0x00 0xa002e00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a003000 {
dma-coherent;
interrupts = <0x00 0x28 0x01>;
reg = <0x00 0xa003000 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a003200 {
dma-coherent;
interrupts = <0x00 0x29 0x01>;
reg = <0x00 0xa003200 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a003400 {
dma-coherent;
interrupts = <0x00 0x2a 0x01>;
reg = <0x00 0xa003400 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a003600 {
dma-coherent;
interrupts = <0x00 0x2b 0x01>;
reg = <0x00 0xa003600 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a003800 {
dma-coherent;
interrupts = <0x00 0x2c 0x01>;
reg = <0x00 0xa003800 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a003a00 {
dma-coherent;
interrupts = <0x00 0x2d 0x01>;
reg = <0x00 0xa003a00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a003c00 {
dma-coherent;
interrupts = <0x00 0x2e 0x01>;
reg = <0x00 0xa003c00 0x00 0x200>;
compatible = "virtio,mmio";
};
virtio_mmio@a003e00 {
dma-coherent;
interrupts = <0x00 0x2f 0x01>;
reg = <0x00 0xa003e00 0x00 0x200>;
compatible = "virtio,mmio";
};
gpio-keys {
compatible = "gpio-keys";
poweroff {
gpios = <0x8007 0x03 0x00>;
linux,code = <0x74>;
label = "GPIO Key Poweroff";
};
};
pl061@9030000 {
phandle = <0x8007>;
clock-names = "apb_pclk";
clocks = <0x8000>;
interrupts = <0x00 0x07 0x04>;
gpio-controller;
#gpio-cells = <0x02>;
compatible = "arm,pl061", "arm,primecell";
reg = <0x00 0x9030000 0x00 0x1000>;
status = "disabled";
};
pcie@10000000 {
interrupt-map-mask = <0x1800 0x00 0x00 0x07>;
interrupt-map = <0x00 0x00 0x00 0x01 0x8005 0x00 0x00 0x00 0x03 0x04 0x00 0x00 0x00 0x02 0x8005 0x00 0x00 0x00 0x04 0x04 0x00 0x00 0x00 0x03 0x8005 0x00 0x00 0x00 0x05 0x04 0x00 0x00 0x00 0x04 0x8005 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x01 0x8005 0x00 0x00 0x00 0x04 0x04 0x800 0x00 0x00 0x02 0x8005 0x00 0x00 0x00 0x05 0x04 0x800 0x00 0x00 0x03 0x8005 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x04 0x8005 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x01 0x8005 0x00 0x00 0x00 0x05 0x04 0x1000 0x00 0x00 0x02 0x8005 0x00 0x00 0x00 0x06 0x04 0x1000 0x00 0x00 0x03 0x8005 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x04 0x8005 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x01 0x8005 0x00 0x00 0x00 0x06 0x04 0x1800 0x00 0x00 0x02 0x8005 0x00 0x00 0x00 0x03 0x04 0x1800 0x00 0x00 0x03 0x8005 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x04 0x8005 0x00 0x00 0x00 0x05 0x04>;
#interrupt-cells = <0x01>;
ranges = <0x1000000 0x00 0x00 0x00 0x3eff0000 0x00 0x10000 0x2000000 0x00 0x10000000 0x00 0x10000000 0x00 0x2eff0000 0x3000000 0x80 0x00 0x80 0x00 0x80 0x00>;
reg = <0x40 0x10000000 0x00 0x10000000>;
msi-map = <0x00 0x8006 0x00 0x10000>;
dma-coherent;
bus-range = <0x00 0xff>;
linux,pci-domain = <0x00>;
#size-cells = <0x02>;
#address-cells = <0x03>;
device_type = "pci";
compatible = "pci-host-ecam-generic";
};
pl031@9010000 {
clock-names = "apb_pclk";
clocks = <0x8000>;
interrupts = <0x00 0x02 0x04>;
reg = <0x00 0x9010000 0x00 0x1000>;
compatible = "arm,pl031", "arm,primecell";
};
intc@8000000 {
phandle = <0x8005>;
#address-cells = <0x02>;
#size-cells = <0x02>;
#interrupt-cells = <0x03>;
interrupt-controller;
compatible = "arm,gic-v3";
#redistributor-regions = <0x01>;
reg = <0x00 0x8000000 0x00 0x10000 0x00 0x80a0000 0x00 0xf60000>;
};
flash@0 {
bank-width = <0x04>;
reg = <0x00 0x00 0x00 0x4000000 0x00 0x4000000 0x00 0x4000000>;
compatible = "cfi-flash";
};
timer {
compatible = "arm,armv8-timer";
interrupts = <0x01 0x0d 0xf08 0x01 0x0e 0xf08 0x01 0x0b 0xf08>;
interrupt-parent = <0x8005>;
};
apb-pclk {
phandle = <0x8000>;
clock-output-names = "clk24mhz";
clock-frequency = <0x16e3600>;
#clock-cells = <0x00>;
compatible = "fixed-clock";
};
aliases {
serial0 = "/pl011@9000000";
};
chosen {
u-boot,version = "2024.10";
#size-cells = <0x02>;
#address-cells = <0x02>;
kaslr-seed = <0xcfbd6cf4 0xaf233870>;
bootargs = "console=hvc0 console=ttyAMA0 earlycon=xen earlyprintk=xen clk_ignore_unused";
linux,initrd-start = <0x00 0xc8200000>;
linux,initrd-end = <0x00 0xcbd2faef>;
};
hypervisor {
compatible = "xen,xen-4.21", "xen,xen";
reg = <0x00 0x4d200000 0x00 0x40000 0x00 0x40000000 0x00 0xd000000 0x00 0x4d400000 0x00 0x72a00000 0x00 0xe0000000 0x00 0xfe00000 0x00 0xf8000000 0x00 0x32600000 0x01 0x2f400000 0x00 0x10a00000>;
interrupts = <0x01 0x00 0xf08>;
interrupt-parent = <0x8005>;
};
psci {
compatible = "arm,psci-1.0", "arm,psci-0.2", "arm,psci";
method = "hvc";
cpu_off = <0x01>;
cpu_on = <0x02>;
};
cpus {
#address-cells = <0x01>;
#size-cells = <0x00>;
cpu@0 {
compatible = "arm,cortex-a57";
device_type = "cpu";
reg = <0x00>;
enable-method = "psci";
};
};
memory@c0000000 {
device_type = "memory";
reg = <0x00 0xc0000000 0x00 0x20000000 0x00 0xf0000000 0x00 0x8000000 0x01 0x2a800000 0x00 0x3800000 0x01 0x2f000000 0x00 0x400000>;
};
};Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Hi Jason,
Quoted 18 lines · Jason Andryuk
Quoted 17 lines · Julien Grall
Hi,
Quoted 7 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
> > Also for the hardware domain, set directmap and iommu. This brings its
Quoted 1 line
configuration in line with a dom0.
Looking the device tree bindings, a user would be allowed to disable "passthrough" or even "directmap". This means, we would never be able to disable "directmap" for the hardware domain in the future with the existing property (this is to avoid break backwards compatibility).
Instead, I think we should check what the user provided and confirm this is matching our expectation for an hardware domain.
Quoted 8 lines
Quoted 1 line
That said, I am not entirely sure why we should force directmap for the HW domain. We are starting from a clean slate, so I think it would be better to have by default no directmap and imposing the presence of an IOMMU in the system.
Ok, it seems like directmap is not necessary. It was helpful early on to get things booting, but I think it's no longer necessary after factoring out
construct_hwdom().What exactly do you mean by imposing with respect to the iommu? Require one, or mirror the dom0 code and set it for the hwdom?
if (
iommu_enabled)
dom0_cfg.flags |=XEN_DOMCTL_CDF_iommu;
I mean requires one. Without it, you would need to set directmap and I don't think this should be allowed (at least for now) for the HW domain.
Quoted 4 lines
Quoted 2 lines
Lastly, can you provide an example of what the hardware domain DT node would looke like?
I've attached a dump of
/sys/firmware/fdtfrom hwdom. (This is direct mapped).
Sorry if this was not clear, I am asking for the configuration you wrote in the host DT for create the hardware domain. I am interested to know which properties you set...
Quoted 32 lines
Quoted 23 lines
Quoted 23 lines
xen/arch/arm/dom0less-build.c +12
-0@@ -12,6 +12,7 @@ #include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h>@@ -994,6 +995,34 @@ void __init create_domUs(void) if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); + if ( dt_property_read_u32(node, "capabilities", &val) ) + { + if ( val & ~DOMAIN_CAPS_MASK ) + panic("Invalid capabilities (%"PRIx32")\n", val); + + if ( val & DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged; + + if ( val & DOMAIN_CAPS_HARDWARE ) + { + if ( hardware_domain )Quoted 8 lines
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 6 lines
xen/arch/arm/dom0less-build.c +5
-0+ panic("Only 1 hardware domain can be specified! (%pd)\n", + hardware_domain); + + d_cfg.max_grant_frames = gnttab_dom0_frames(); + d_cfg.max_evtchn_port = -1;What about d_cfg.arch.nr_spis? Are we expecting the user to pass "
nr_spis"?
Quoted 2 lines
Further down, when
nr_spisisn't specified in the DT, it defaults to:
d_cfg.arch.nr_spis =gic_number_lines()- 32;
Thanks. One further question, what if the user pass "nr_spis" for the HW domain. Wouldn't this result to more issue further down the line?
Quoted 11 lines
Dom0 does:
/*
* Xen vGIC supports a maximum of 992 interrupt lines.
* 32 are substracted to cover local IRQs.
*/
dom0_cfg.arch.nr_spis =min(gic_number_lines(), (unsigned int) 992)
- 32;
if (gic_number_lines()> 992 )
printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded.\n");
Quoted 1 line
So I think it's fine as-is? I could add the
min()and warning if you think it's necessary.
Regardless this discussion, I wonder why we didn't add the min(...) here like for dom0 because we are using the same vGIC emulation. So the max SPIs supported is the same...
What I am trying to understand is whether it is ok to allow the user to select "nr_spis", "vpl011" & co if they are either not honored (like for vpl011) or could introduce further issue (like for nr_spis as the HW domain is supposed to have the same configuration as dom0).
I also don't think it is a good idea to silently ignore what the user requested. So far, on Arm, we mainly decided to reject/panic early if the setup is not correct.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Quoted 30 lines · Julien Grall
Hi Jason,
Quoted 18 lines · Jason Andryuk
Quoted 8 lines · Julien Grall
Hi,
Quoted 5 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.Quoted 8 lines
Quoted 2 lines
When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
> > Also for the hardware domain, set directmap and iommu. This brings its
Quoted 1 line
configuration in line with a dom0.
Looking the device tree bindings, a user would be allowed to disable "passthrough" or even "directmap". This means, we would never be able to disable "directmap" for the hardware domain in the future with the existing property (this is to avoid break backwards compatibility).
Instead, I think we should check what the user provided and confirm this is matching our expectation for an hardware domain.
>
Quoted 8 lines
Quoted 1 line
That said, I am not entirely sure why we should force directmap for the HW domain. We are starting from a clean slate, so I think it would be better to have by default no directmap and imposing the presence of an IOMMU in the system.
Ok, it seems like directmap is not necessary. It was helpful early on to get things booting, but I think it's no longer necessary after factoring out
construct_hwdom().What exactly do you mean by imposing with respect to the iommu? Require one, or mirror the dom0 code and set it for the hwdom?
if (
iommu_enabled)
dom0_cfg.flags |=XEN_DOMCTL_CDF_iommu;
Quoted 8 lines
I mean requires one. Without it, you would need to set directmap and I don't think this should be allowed (at least for now) for the HW domain.
Quoted 4 lines
Quoted 2 lines
Lastly, can you provide an example of what the hardware domain DT node would looke like?
I've attached a dump of
/sys/firmware/fdtfrom hwdom. (This is direct mapped).Sorry if this was not clear, I am asking for the configuration you wrote in the host DT for create the hardware domain. I am interested to know which properties you set...
I've attached the u-boot fdt commands which generate the DT. Hopefully that works for you.
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 19 lines
xen/arch/arm/dom0less-build.c +8
-0@@ -12,6 +12,7 @@ #include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h>@@ -994,6 +995,34 @@ void __init create_domUs(void) if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); + if ( dt_property_read_u32(node, "capabilities", &val) ) + { + if ( val & ~DOMAIN_CAPS_MASK ) + panic("Invalid capabilities (%"PRIx32")\n", val); + + if ( val & DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged;xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 10 lines
xen/arch/arm/dom0less-build.c +9
-0+ + if ( val & DOMAIN_CAPS_HARDWARE ) + { + if ( hardware_domain ) + panic("Only 1 hardware domain can be specified! (%pd)\n", + hardware_domain); + + d_cfg.max_grant_frames = gnttab_dom0_frames(); + d_cfg.max_evtchn_port = -1;What about d_cfg.arch.nr_spis? Are we expecting the user to pass "
nr_spis"?
Quoted 4 lines
Quoted 2 lines
Further down, when
nr_spisisn't specified in the DT, it defaults to:
d_cfg.arch.nr_spis =gic_number_lines()- 32;Thanks. One further question, what if the user pass "
nr_spis" for the HW domain. Wouldn't this result to more issue further down the line?
I'm not familiar with ARM, so I'll to whatever is best. I did put the capabilities first, thinking it would set defaults, and then later options could override them.
Quoted 10 lines
Quoted 10 lines
Dom0 does:
/*
* Xen vGIC supports a maximum of 992 interrupt lines.
* 32 are substracted to cover local IRQs.
*/
dom0_cfg.arch.nr_spis =min(gic_number_lines(), (unsigned int) 992)- 32; if (gic_number_lines()> 992 )
printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded. \n");
Quoted 7 lines
Quoted 1 line
So I think it's fine as-is? I could add the
min()and warning if you think it's necessary.Regardless this discussion, I wonder why we didn't add the min(...) here like for dom0 because we are using the same vGIC emulation. So the max SPIs supported is the same...
What I am trying to understand is whether it is ok to allow the user to select "
nr_spis", "vpl011" & co if they are either not honored (like for vpl011) or could introduce further issue (like fornr_spisas the HW domain is supposed to have the same configuration as dom0).I also don't think it is a good idea to silently ignore what the user requested. So far, on Arm, we mainly decided to reject/panic early if the setup is not correct.
Again, I'll do whatever is best.
Regards,
Jason
tftpb 0x40400000 Image
tftpb 0x42000000 dom0-rootfs.cpio.gz
tftpb 0x45C00000 Image
tftpb 0x47800000 initrd
tftpb 0x47A00000 Image
tftpb 0x49600000 domU-rootfs.cpio.gz
tftpb 0x4D200000 xen
tftpb 0x4D400000 virt-gicv3.dtb
fdt addr 0x4D400000
fdt resize 1024
fdt set /chosen \#address-cells <0x2>
fdt set /chosen \#size-cells <0x2>
fdt set /chosen xen,xen-bootargs "console=dtuart dtuart=serial0 bootscrub=0 vwfi=native sched=null"
fdt mknod /chosen domU0
fdt set /chosen/domU0 compatible "xen,domain"
fdt set /chosen/domU0 \#address-cells <0x2>
fdt set /chosen/domU0 \#size-cells <0x2>
fdt set /chosen/domU0 memory <0x0 0xAF000 >
fdt set /chosen/domU0 cpus <1>
fdt set /chosen/domU0 vpl011
fdt set /chosen/domU0 capabilities <6>
fdt set /chosen/domU0 passthrough ""
fdt mknod /chosen/domU0 module@40400000
fdt set /chosen/domU0/module@40400000 compatible "multiboot,kernel" "multiboot,module"
fdt set /chosen/domU0/module@40400000 reg <0x0 0x40400000 0x0 0x1A80000 >
fdt set /chosen/domU0/module@40400000 bootargs "console=hvc0 console=ttyAMA0 earlycon=xen earlyprintk=xen clk_ignore_unused" fdt mknod /chosen/domU0 module@42000000
fdt set /chosen/domU0/module@42000000 compatible "multiboot,ramdisk" "multiboot,module"
fdt set /chosen/domU0/module@42000000 reg <0x0 0x42000000 0x0 0x3B2EFB6 >
fdt mknod /chosen domU1
fdt set /chosen/domU1 compatible "xen,domain"
fdt set /chosen/domU1 \#address-cells <0x2>
fdt set /chosen/domU1 \#size-cells <0x2>
fdt set /chosen/domU1 memory <0x0 0x64000 >
fdt set /chosen/domU1 cpus <2>
fdt set /chosen/domU1 vpl011
fdt set /chosen/domU1 xen,enhanced "enabled"
fdt set /chosen/domU1 capabilities <0>
fdt mknod /chosen/domU1 module@45C00000
fdt set /chosen/domU1/module@45C00000 compatible "multiboot,kernel" "multiboot,module"
fdt set /chosen/domU1/module@45C00000 reg <0x0 0x45C00000 0x0 0x1A80000 >
fdt set /chosen/domU1/module@45C00000 bootargs "console=ttyAMA0"
fdt mknod /chosen/domU1 module@47800000
fdt set /chosen/domU1/module@47800000 compatible "multiboot,ramdisk" "multiboot,module"
fdt set /chosen/domU1/module@47800000 reg <0x0 0x47800000 0x0 0x151205 >
fdt mknod /chosen domU2
fdt set /chosen/domU2 compatible "xen,domain"
fdt set /chosen/domU2 \#address-cells <0x2>
fdt set /chosen/domU2 \#size-cells <0x2>
fdt set /chosen/domU2 memory <0x0 0xAF000 >
fdt set /chosen/domU2 cpus <1>
fdt set /chosen/domU2 vpl011
fdt set /chosen/domU2 xen,enhanced "enabled"
fdt set /chosen/domU2 capabilities <1>
fdt mknod /chosen/domU2 module@47A00000
fdt set /chosen/domU2/module@47A00000 compatible "multiboot,kernel" "multiboot,module"
fdt set /chosen/domU2/module@47A00000 reg <0x0 0x47A00000 0x0 0x1A80000 >
fdt set /chosen/domU2/module@47A00000 bootargs "console=ttyAMA0"
fdt mknod /chosen/domU2 module@49600000
fdt set /chosen/domU2/module@49600000 compatible "multiboot,ramdisk" "multiboot,module"
fdt set /chosen/domU2/module@49600000 reg <0x0 0x49600000 0x0 0x3B2F182 >
setenv fdt_high 0xffffffffffffffff
booti 0x4D200000 - 0x4D400000
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Hi Jason,
Quoted 74 lines · Jason Andryuk
Quoted 30 lines · Julien Grall
Hi Jason,
Quoted 18 lines · Jason Andryuk
Quoted 8 lines · Julien Grall
Hi,
Quoted 5 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.Quoted 8 lines
Quoted 2 lines
When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
> > Also for the hardware domain, set directmap and iommu. This brings its
Quoted 1 line
configuration in line with a dom0.
Looking the device tree bindings, a user would be allowed to disable "passthrough" or even "directmap". This means, we would never be able to disable "directmap" for the hardware domain in the future with the existing property (this is to avoid break backwards compatibility).
Instead, I think we should check what the user provided and confirm this is matching our expectation for an hardware domain.
>
Quoted 8 lines
Quoted 1 line
That said, I am not entirely sure why we should force directmap for the HW domain. We are starting from a clean slate, so I think it would be better to have by default no directmap and imposing the presence of an IOMMU in the system.
Ok, it seems like directmap is not necessary. It was helpful early on to get things booting, but I think it's no longer necessary after factoring out
construct_hwdom().What exactly do you mean by imposing with respect to the iommu? Require one, or mirror the dom0 code and set it for the hwdom?
if (
iommu_enabled)
dom0_cfg.flags |=XEN_DOMCTL_CDF_iommu;Quoted 8 lines
I mean requires one. Without it, you would need to set directmap and I don't think this should be allowed (at least for now) for the HW domain.
Quoted 4 lines
Quoted 2 lines
Lastly, can you provide an example of what the hardware domain DT node would looke like?
I've attached a dump of
/sys/firmware/fdtfrom hwdom. (This is direct mapped).Sorry if this was not clear, I am asking for the configuration you wrote in the host DT for create the hardware domain. I am interested to know which properties you set...
I've attached the u-boot fdt commands which generate the DT. Hopefully that works for you.
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 19 lines
xen/arch/arm/dom0less-build.c +8
-0@@ -12,6 +12,7 @@ #include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h>@@ -994,6 +995,34 @@ void __init create_domUs(void) if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); + if ( dt_property_read_u32(node, "capabilities", &val) ) + { + if ( val & ~DOMAIN_CAPS_MASK ) + panic("Invalid capabilities (%"PRIx32")\n", val); + + if ( val & DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged;xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 10 lines
xen/arch/arm/dom0less-build.c +9
-0+ + if ( val & DOMAIN_CAPS_HARDWARE ) + { + if ( hardware_domain ) + panic("Only 1 hardware domain can be specified! (%pd)\n", + hardware_domain); + + d_cfg.max_grant_frames = gnttab_dom0_frames(); + d_cfg.max_evtchn_port = -1;What about d_cfg.arch.nr_spis? Are we expecting the user to pass "
nr_spis"?
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Further down, when
nr_spisisn't specified in the DT, it defaults to:
d_cfg.arch.nr_spis =gic_number_lines()- 32;Thanks. One further question, what if the user pass "
nr_spis" for the HW domain. Wouldn't this result to more issue further down the line?I'm not familiar with ARM, so I'll to whatever is best. I did put the capabilities first, thinking it would set defaults, and then later options could override them.
I am not sure it is related to Arm. It is more that the HW domain is going to re-use the memory layout of the host (this is including the mapping for the GIC) and also have all the irqs with pirq == virq.
I am a bit concerned that letting the users mistakenly tweaking the defaults could prevent attaching devices (for instance if the IRQ ID is above > nr_spis).
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Dom0 does:
/*
* Xen vGIC supports a maximum of 992 interrupt lines.
* 32 are substracted to cover local IRQs.
*/
dom0_cfg.arch.nr_spis =min(gic_number_lines(), (unsigned int) 992)- 32; if (gic_number_lines()> 992 )
printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded. \n");So I think it's fine as-is? I could add the
min()and warning if you think it's necessary.
Quoted 7 lines
Quoted 5 lines
Regardless this discussion, I wonder why we didn't add the min(...) here like for dom0 because we are using the same vGIC emulation. So the max SPIs supported is the same...
What I am trying to understand is whether it is ok to allow the user to select "
nr_spis", "vpl011" & co if they are either not honored (like for vpl011) or could introduce further issue (like fornr_spisas the HW domain is supposed to have the same configuration as dom0).I also don't think it is a good idea to silently ignore what the user requested. So far, on Arm, we mainly decided to reject/panic early if the setup is not correct.
Again, I'll do whatever is best.
Bertrand, Michal, Stefano, any opinions?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Hi,
Quoted 98 lines · Julien Grall
Hi Jason,
Quoted 71 lines · Jason Andryuk
Quoted 30 lines · Julien Grall
Hi Jason,
Quoted 18 lines · Jason Andryuk
Quoted 17 lines · Julien Grall
Hi,
Quoted 9 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
Quoted 1 line
Also for the hardware domain, set directmap and iommu. This brings its
configuration in line with a dom0.
Looking the device tree bindings, a user would be allowed to disable "passthrough" or even "directmap". This means, we would never be able to disable "directmap" for the hardware domain in the future with the existing property (this is to avoid break backwards compatibility).
Instead, I think we should check what the user provided and confirm this is matching our expectation for an hardware domain.
Quoted 8 lines
Quoted 1 line
That said, I am not entirely sure why we should force directmap for the HW domain. We are starting from a clean slate, so I think it would be better to have by default no directmap and imposing the presence of an IOMMU in the system.
Ok, it seems like directmap is not necessary. It was helpful early on to get things booting, but I think it's no longer necessary after factoring out
construct_hwdom().What exactly do you mean by imposing with respect to the iommu? Require one, or mirror the dom0 code and set it for the hwdom?
if (
iommu_enabled)
dom0_cfg.flags |=XEN_DOMCTL_CDF_iommu;Quoted 8 lines
I mean requires one. Without it, you would need to set directmap and I don't think this should be allowed (at least for now) for the HW domain.
Quoted 4 lines
Quoted 2 lines
Lastly, can you provide an example of what the hardware domain DT node would looke like?
I've attached a dump of
/sys/firmware/fdtfrom hwdom. (This is direct mapped).Sorry if this was not clear, I am asking for the configuration you wrote in the host DT for create the hardware domain. I am interested to know which properties you set...
I've attached the u-boot fdt commands which generate the DT. Hopefully that works for you.
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 18 lines
xen/arch/arm/dom0less-build.c +7
-0@@ -12,6 +12,7 @@#include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h> @@ -994,6 +995,34 @@ void __init create_domUs(void)if ( (max_init_domid +1 ) >=DOMID_FIRST_RESERVED )panic ("No more domain IDs available\n" ); +if (dt_property_read_u32 (node,"capabilities" , &val) ) + { +if ( val & ~DOMAIN_CAPS_MASK ) +panic ("Invalid capabilities (%" PRIx32")\n" , val); + +if ( val &DOMAIN_CAPS_CONTROL )xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1012
Quoted 10 lines
xen/arch/arm/dom0less-build.c +10
-0+ flags |= CDF_privileged; + +if ( val &DOMAIN_CAPS_HARDWARE ) + { +if ( hardware_domain ) +panic ("Only 1 hardware domain can be specified! (%pd)\n" , + hardware_domain); + + d_cfg.max_grant_frames =gnttab_dom0_frames (); + d_cfg.max_evtchn_port =-1 ;What about d_cfg.arch.nr_spis? Are we expecting the user to pass "
nr_spis"?Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Further down, when
nr_spisisn't specified in the DT, it defaults to:d_cfg.arch.nr_spis = gic_number_lines() - 32;Thanks. One further question, what if the user pass "
nr_spis" for the HW domain. Wouldn't this result to more issue further down the line?I'm not familiar with ARM, so I'll to whatever is best. I did put the capabilities first, thinking it would set defaults, and then later options could override them.
I am not sure it is related to Arm. It is more that the HW domain is going to re-use the memory layout of the host (this is including the mapping for the GIC) and also have all the irqs with pirq == virq.
I am a bit concerned that letting the users mistakenly tweaking the defaults could prevent attaching devices (for instance if the IRQ ID is above >
nr_spis).Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Dom0 does:
/* * Xen vGIC supports a maximum of 992 interrupt lines. * 32 are substracted to cover local IRQs. */ dom0_cfg.arch.nr_spis = min(gic_number_lines(), (unsigned int) 992) - 32; if ( gic_number_lines() > 992 ) printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded. \n");So I think it's fine as-is? I could add the
min()and warning if you think it's necessary.
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Regardless this discussion, I wonder why we didn't add the min(...) here like for dom0 because we are using the same vGIC emulation. So the max SPIs supported is the same...
What I am trying to understand is whether it is ok to allow the user to select "
nr_spis", "vpl011" & co if they are either not honored (like for vpl011) or could introduce further issue (like fornr_spisas the HW domain is supposed to have the same configuration as dom0).I also don't think it is a good idea to silently ignore what the user requested. So far, on Arm, we mainly decided to reject/panic early if the setup is not correct.
Again, I'll do whatever is best.
Bertrand, Michal, Stefano, any opinions?
I definitely think that any user configuration mistake should end up in a panic, a warning message is definitely not enough. Here the user might discover or not at runtime that what he thought was configured is not.
So a panic here would be better from my point of view.
Cheers
Bertrand
Quoted 5 lines
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
Quoted 106 lines · Bertrand Marquis
Hi,
Quoted 102 lines · Julien Grall
Hi Jason,
Quoted 71 lines · Jason Andryuk
Quoted 30 lines · Julien Grall
Hi Jason,
Quoted 18 lines · Jason Andryuk
Quoted 17 lines · Julien Grall
Hi,
Quoted 9 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
Quoted 1 line
Also for the hardware domain, set directmap and iommu. This brings its
configuration in line with a dom0.
Looking the device tree bindings, a user would be allowed to disable "passthrough" or even "directmap". This means, we would never be able to disable "directmap" for the hardware domain in the future with the existing property (this is to avoid break backwards compatibility).
Instead, I think we should check what the user provided and confirm this is matching our expectation for an hardware domain.
Quoted 8 lines
Quoted 1 line
That said, I am not entirely sure why we should force directmap for the HW domain. We are starting from a clean slate, so I think it would be better to have by default no directmap and imposing the presence of an IOMMU in the system.
Ok, it seems like directmap is not necessary. It was helpful early on to get things booting, but I think it's no longer necessary after factoring out
construct_hwdom().What exactly do you mean by imposing with respect to the iommu? Require one, or mirror the dom0 code and set it for the hwdom?
if (
iommu_enabled)
dom0_cfg.flags |=XEN_DOMCTL_CDF_iommu;Quoted 8 lines
I mean requires one. Without it, you would need to set directmap and I don't think this should be allowed (at least for now) for the HW domain.
Quoted 4 lines
Quoted 2 lines
Lastly, can you provide an example of what the hardware domain DT node would looke like?
I've attached a dump of
/sys/firmware/fdtfrom hwdom. (This is direct mapped).Sorry if this was not clear, I am asking for the configuration you wrote in the host DT for create the hardware domain. I am interested to know which properties you set...
I've attached the u-boot fdt commands which generate the DT. Hopefully that works for you.
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 18 lines
xen/arch/arm/dom0less-build.c +7
-0@@ -12,6 +12,7 @@#include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h> @@ -994,6 +995,34 @@ void __init create_domUs(void)if ( (max_init_domid +1 ) >=DOMID_FIRST_RESERVED )panic ("No more domain IDs available\n" ); +if (dt_property_read_u32 (node,"capabilities" , &val) ) + { +if ( val & ~DOMAIN_CAPS_MASK ) +panic ("Invalid capabilities (%" PRIx32")\n" , val); + +if ( val &DOMAIN_CAPS_CONTROL )xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1012
Quoted 10 lines
xen/arch/arm/dom0less-build.c +10
-0+ flags |= CDF_privileged; + +if ( val &DOMAIN_CAPS_HARDWARE ) + { +if ( hardware_domain ) +panic ("Only 1 hardware domain can be specified! (%pd)\n" , + hardware_domain); + + d_cfg.max_grant_frames =gnttab_dom0_frames (); + d_cfg.max_evtchn_port =-1 ;What about d_cfg.arch.nr_spis? Are we expecting the user to pass "
nr_spis"?Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Further down, when
nr_spisisn't specified in the DT, it defaults to:d_cfg.arch.nr_spis = gic_number_lines() - 32;Thanks. One further question, what if the user pass "
nr_spis" for the HW domain. Wouldn't this result to more issue further down the line?I'm not familiar with ARM, so I'll to whatever is best. I did put the capabilities first, thinking it would set defaults, and then later options could override them.
I am not sure it is related to Arm. It is more that the HW domain is going to re-use the memory layout of the host (this is including the mapping for the GIC) and also have all the irqs with pirq == virq.
I am a bit concerned that letting the users mistakenly tweaking the defaults could prevent attaching devices (for instance if the IRQ ID is above >
nr_spis).Quoted 16 lines
Quoted 16 lines
Quoted 11 lines
Dom0 does:
/* * Xen vGIC supports a maximum of 992 interrupt lines. * 32 are substracted to cover local IRQs. */ dom0_cfg.arch.nr_spis = min(gic_number_lines(), (unsigned int) 992) - 32; if ( gic_number_lines() > 992 ) printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded. \n");So I think it's fine as-is? I could add the
min()and warning if you think it's necessary.Regardless this discussion, I wonder why we didn't add the min(...) here like for dom0 because we are using the same vGIC emulation. So the max SPIs supported is the same...
What I am trying to understand is whether it is ok to allow the user to select "
nr_spis", "vpl011" & co if they are either not honored (like for vpl011) or could introduce further issue (like fornr_spisas the HW domain is supposed to have the same configuration as dom0).
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
I also don't think it is a good idea to silently ignore what the user requested. So far, on Arm, we mainly decided to reject/panic early if the setup is not correct.
Again, I'll do whatever is best.
Bertrand, Michal, Stefano, any opinions?
I definitely think that any user configuration mistake should end up in a panic, a warning message is definitely not enough. Here the user might discover or not at runtime that what he thought was configured is not.
So a panic here would be better from my point of view.
I think this code handling is a bit messy today.
GIC supports max 1020 lines. That's 1020-32=988 SPIs. In our vGICs we round up SPIs to 32, so the true vGIC max SPI is 960. Issues:
1) We warn about current lines exceeding max vGIC lines only for hwdom. This should be made common:
xen/arch/arm/domain_build.c +0 -2
@@ -2368,8 +2368,6 @@ void __init create_dom0(void)* 32 are substracted to cover local IRQs. */ dom0_cfg.arch.nr_spis =min (gic_number_lines (), (unsigned int )992 ) -32 ; -if (gic_number_lines () >992 ) -printk (XENLOG_WARNING "Maximum number of vGIC IRQs exceeded.\n" ); dom0_cfg.arch.tee_type =tee_get_type (); dom0_cfg.max_vcpus =dom0_max_vcpus ();
xen/arch/arm/vgic.c +3 -0
@@ -116,6 +116,9 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis)int i;int ret; +if (gic_number_lines () >992 ) +printk (XENLOG_WARNING "Maximum number of vGIC IRQs exceeded\n" ); + d->arch.vgic.ctlr =0 ;/*
xen/arch/arm/vgic/vgic-init.c +3 -0
@@ -132,6 +132,9 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis)unsigned int i;int ret; +if (gic_number_lines () >992 ) +printk (XENLOG_WARNING "Maximum number of vGIC IRQs exceeded\n" ); +/* The number of SPIs must be a multiple of 32 per the GIC spec. */ nr_spis =ROUNDUP (nr_spis,32 );
2) If user does not specify nr_spis for dom0less domUs, we should take the max vGIC lines into account as we do for hwdom:
xen/arch/arm/dom0less-build.c +2 -1
@@ -1018,7 +1018,8 @@ void __init create_domUs(void) {int vpl011_virq =GUEST_VPL011_SPI ; - d_cfg.arch.nr_spis =gic_number_lines () -32 ; + d_cfg.arch.nr_spis =min (gic_number_lines (), + (unsigned int )992 ) -32 ;/* * The VPL011 virq is GUEST_VPL011_SPI, unless direct-map is
3) Doc for xl cfg nr_spis is utterly wrong. First it mentions 991 as the number of max SPIs where it should be 960.
4) Handling in libxl silently ignores user provided value if the calculated number of required SPIs (e.g. vpl011, virtio, etc.) is bigger than user provided value. We should bail out.
I think we should first fix the above (I can prepare patches) and then continue adding logic if user specifies nr_spis for hwdom (not possible today).
~Michal
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
In reply to Julien GrallQuoted 137 lines · Julien Grall
Quoted 96 lines · Jason Andryuk
Quoted 49 lines · Julien Grall
Hi Jason,
Quoted 33 lines · Jason Andryuk
Quoted 15 lines · Julien Grall
Hi,
Quoted 8 lines · Jason Andryuk
Add capabilities property to dom0less to allow building a disaggregated system.
Introduce
bootfdt.hto contain these constants.When using the hardware or xenstore capabilities, adjust the grant and
event channel limits similar to dom0.> > Also for the hardware domain, set directmap and iommu. This brings its
Quoted 1 line
configuration in line with a dom0.
Quoted 7 lines
Looking the device tree bindings, a user would be allowed to disable "passthrough" or even "directmap". This means, we would never be able to disable "directmap" for the hardware domain in the future with the existing property (this is to avoid break backwards compatibility).
Instead, I think we should check what the user provided and confirm this is matching our expectation for an hardware domain.
>
Quoted 4 lines
That said, I am not entirely sure why we should force directmap for the HW domain. We are starting from a clean slate, so I think it would be better to have by default no directmap and imposing the presence of an IOMMU in the system.
Ok, it seems like directmap is not necessary. It was helpful early on to get things booting, but I think it's no longer necessary after factoring out
construct_hwdom().Quoted 5 lines
What exactly do you mean by imposing with respect to the iommu? Require one, or mirror the dom0 code and set it for the hwdom?
if (
iommu_enabled)
dom0_cfg.flags |=XEN_DOMCTL_CDF_iommu;I mean requires one. Without it, you would need to set directmap and I don't think this should be allowed (at least for now) for the HW domain.
Quoted 4 lines
Quoted 3 lines
Lastly, can you provide an example of what the hardware domain DT node would looke like?
Quoted 6 lines
Quoted 2 lines
I've attached a dump of
/sys/firmware/fdtfrom hwdom. (This is direct mapped).Sorry if this was not clear, I am asking for the configuration you wrote in the host DT for create the hardware domain. I am interested to know which properties you set...
I've attached the u-boot fdt commands which generate the DT. Hopefully that works for you.
Quoted 36 lines
Quoted 35 lines
Quoted 24 lines
Quoted 24 lines
xen/arch/arm/dom0less-build.c +13
-0@@ -12,6 +12,7 @@ #include <xen/sizes.h> #include <xen/vmap.h> +#include <public/bootfdt.h> #include <public/io/xs_wire.h> #include <asm/arm64/sve.h>@@ -994,6 +995,34 @@ void __init create_domUs(void) if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); + if ( dt_property_read_u32(node, "capabilities", &val) ) + { + if ( val & ~DOMAIN_CAPS_MASK ) + panic("Invalid capabilities (%"PRIx32")\n", val); + + if ( val & DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged; + + if ( val & DOMAIN_CAPS_HARDWARE ) + { + if ( hardware_domain ) + panic("Only 1 hardware domain can be specified!Quoted 8 lines
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1013
Quoted 5 lines
xen/arch/arm/dom0less-build.c +4
-0(%pd)\n", + hardware_domain); + + d_cfg.max_grant_frames = gnttab_dom0_frames(); + d_cfg.max_evtchn_port = -1;What about d_cfg.arch.nr_spis? Are we expecting the user to pass "
nr_spis"?Further down, when
nr_spisisn't specified in the DT, it defaults to:
d_cfg.arch.nr_spis =gic_number_lines()- 32;Quoted 6 lines
Quoted 2 lines
Thanks. One further question, what if the user pass "
nr_spis" for the HW domain. Wouldn't this result to more issue further down the line?I'm not familiar with ARM, so I'll to whatever is best. I did put the capabilities first, thinking it would set defaults, and then later options could override them.
I am not sure it is related to Arm. It is more that the HW domain is going to re-use the memory layout of the host (this is including the mapping for the GIC) and also have all the irqs with pirq == virq.
I am a bit concerned that letting the users mistakenly tweaking the defaults could prevent attaching devices (for instance if the IRQ ID is above >
nr_spis).Quoted 25 lines
Quoted 25 lines
Quoted 13 lines
Dom0 does:
/*
* Xen vGIC supports a maximum of 992 interrupt lines.
* 32 are substracted to cover local IRQs.
*/
dom0_cfg.arch.nr_spis =min(gic_number_lines(), (unsigned int) 992)
- 32;
if (gic_number_lines()> 992 )
printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded. \n");Quoted 2 lines
So I think it's fine as-is? I could add the
min()and warning if you think it's necessary.Regardless this discussion, I wonder why we didn't add the min(...) here like for dom0 because we are using the same vGIC emulation. So the max SPIs supported is the same...
What I am trying to understand is whether it is ok to allow the user to select "
nr_spis", "vpl011" & co if they are either not honored (like for vpl011) or could introduce further issue (like fornr_spisas the HW domain is supposed to have the same configuration as dom0).
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I also don't think it is a good idea to silently ignore what the user requested. So far, on Arm, we mainly decided to reject/panic early if the setup is not correct.
Again, I'll do whatever is best.
Bertrand, Michal, Stefano, any opinions?
As a first step, I would try to make the hardware domain as similar as dom0 as possible in terms of these configurations. That's because I would prioritize having something working reliably. So I think it is OK to panic if the provided configuration is not what we expect, such as "nr_spis" being provided.
direct-map is different because we know dom0 works fine today without it, as an example cache coloring requires it. So I think it could be a good idea to default direct-map to off, also to align better with the DomU DT bindings. But the address map should still match the host layout.
Re: [PATCH 05/23] xen/arm: Add capabilities to dom0less
In reply to Julien GrallQuoted 8 lines · Julien Grall
Quoted 5 lines
What exactly do you mean by imposing with respect to the iommu? Require one, or mirror the dom0 code and set it for the hwdom?
if (
iommu_enabled)
dom0_cfg.flags |=XEN_DOMCTL_CDF_iommu;I mean requires one. Without it, you would need to set directmap and I don't think this should be allowed (at least for now) for the HW domain.
I think the directmap should be optional for the hardware domain. In practice, we already have not direct-mapped dom0 today when the user enables cache coloring.
PATCH 6/23 xen/domctl: Expose privileged and hardware capabilities
In reply to Jason AndryukThere isn't currently a way to determine if a domain is the hardware domain or a privilged (control) domain. Add new domain info flags to indicate these properties.
This is useful for a hyperlaunch-ed xenstore domain to determine which domains are privileged.
--- xen/common/domctl.c | 2 ++ xen/include/public/domctl.h | 6 ++++++ 2 files changed, 8 insertions(+)
xen/common/domctl.c +2 -0
@@ -103,6 +103,8 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info) (d->debugger_attached ? XEN_DOMINF_debugged :0 ) | (is_xenstore_domain (d) ? XEN_DOMINF_xs_domain :0 ) | (is_hvm_domain (d) ? XEN_DOMINF_hvm_guest :0 ) | + (is_hardware_domain (d) ? XEN_DOMINF_hardware :0 ) | + (is_control_domain (d) ? XEN_DOMINF_priv :0 ) | d->shutdown_code << XEN_DOMINF_shutdownshift;xsm_security_domaininfo (d, info);
xen/include/public/domctl.h +6 -0
@@ -155,6 +155,12 @@ struct xen_domctl_getdomaininfo {/* domain has hardware assisted paging */ #define _XEN_DOMINF_hap 8#define XEN_DOMINF_hap (1U<<_XEN_DOMINF_hap) +/* domain is hardware domain */ +#define _XEN_DOMINF_hardware 9 +#define XEN_DOMINF_hardware (1U<<_XEN_DOMINF_hardware) +/* domain is privileged */ +#define _XEN_DOMINF_priv 10 +#define XEN_DOMINF_priv (1U<<_XEN_DOMINF_priv)/* XEN_DOMINF_shutdown guest-supplied code. */ #define XEN_DOMINF_shutdownmask 255#define XEN_DOMINF_shutdownshift 16
Signature · 1 line
2.48.1
Re: [PATCH 06/23] xen/domctl: Expose privileged and hardware capabilities
xen/include/public/domctl.h struct xen_domctl_getdomaininfo { · line 163
Quoted 12 lines · Jason Andryuk
xen/include/public/domctl.h +6
-0@@ -155,6 +155,12 @@ struct xen_domctl_getdomaininfo {/* domain has hardware assisted paging */ #define _XEN_DOMINF_hap 8#define XEN_DOMINF_hap (1U<<_XEN_DOMINF_hap) +/* domain is hardware domain */ +#define _XEN_DOMINF_hardware 9 +#define XEN_DOMINF_hardware (1U<<_XEN_DOMINF_hardware) +/* domain is privileged */ +#define _XEN_DOMINF_priv 10 +#define XEN_DOMINF_priv (1U<<_XEN_DOMINF_priv)
Better use "control" in place of "priv", as "privileged" can also be a gradual thing?
Jan
Re: [PATCH 06/23] xen/domctl: Expose privileged and hardware capabilities
In reply to Jason Andryukxen/include/public/domctl.h struct xen_domctl_getdomaininfo { · line 163
Quoted 12 lines · Jason Andryuk
xen/include/public/domctl.h +6
-0@@ -155,6 +155,12 @@ struct xen_domctl_getdomaininfo {/* domain has hardware assisted paging */ #define _XEN_DOMINF_hap 8#define XEN_DOMINF_hap (1U<<_XEN_DOMINF_hap) +/* domain is hardware domain */ +#define _XEN_DOMINF_hardware 9 +#define XEN_DOMINF_hardware (1U<<_XEN_DOMINF_hardware) +/* domain is privileged */ +#define _XEN_DOMINF_priv 10 +#define XEN_DOMINF_priv (1U<<_XEN_DOMINF_priv)
Oh, and: If we really need both constants (I doubt we do), the latter wants to follow style even if all of its siblings don't (i.e. blanks around binary operators).
Jan
Re: [PATCH 06/23] xen/domctl: Expose privileged and hardware capabilities
Quoted 17 lines · Jan Beulich
xen/include/public/domctl.h struct xen_domctl_getdomaininfo { · line 163
Quoted 12 lines · Jason Andryuk
xen/include/public/domctl.h +6
-0@@ -155,6 +155,12 @@ struct xen_domctl_getdomaininfo {/* domain has hardware assisted paging */ #define _XEN_DOMINF_hap 8#define XEN_DOMINF_hap (1U<<_XEN_DOMINF_hap) +/* domain is hardware domain */ +#define _XEN_DOMINF_hardware 9 +#define XEN_DOMINF_hardware (1U<<_XEN_DOMINF_hardware) +/* domain is privileged */ +#define _XEN_DOMINF_priv 10 +#define XEN_DOMINF_priv (1U<<_XEN_DOMINF_priv)Oh, and: If we really need both constants (I doubt we do), the latter wants to follow style even if all of its siblings don't (i.e. blanks around binary operators).
Ok on this and the rename.
Why do you think they are not necessary? I did not see a way to expose the capabilities for other domains.
Or do you mean if they are added to XEN_DOMCTL_get_domain_state that won't be necessary?
Thanks,
Jason
Re: [PATCH 06/23] xen/domctl: Expose privileged and hardware capabilities
Quoted 19 lines · Jason Andryuk
Quoted 17 lines · Jan Beulich
xen/include/public/domctl.h struct xen_domctl_getdomaininfo { · line 163
Quoted 12 lines · Jason Andryuk
xen/include/public/domctl.h +6
-0@@ -155,6 +155,12 @@ struct xen_domctl_getdomaininfo {/* domain has hardware assisted paging */ #define _XEN_DOMINF_hap 8#define XEN_DOMINF_hap (1U<<_XEN_DOMINF_hap) +/* domain is hardware domain */ +#define _XEN_DOMINF_hardware 9 +#define XEN_DOMINF_hardware (1U<<_XEN_DOMINF_hardware) +/* domain is privileged */ +#define _XEN_DOMINF_priv 10 +#define XEN_DOMINF_priv (1U<<_XEN_DOMINF_priv)Oh, and: If we really need both constants (I doubt we do), the latter wants to follow style even if all of its siblings don't (i.e. blanks around binary operators).
Quoted 7 lines
Ok on this and the rename.
Why do you think they are not necessary? I did not see a way to expose the capabilities for other domains.
Or do you mean if they are added to
XEN_DOMCTL_get_domain_statethat won't be necessary?
Oh, I guess "both" was ambiguous: I meant both _XEN_DOMINF_* and XEN_DOMINF_*. Of course we need both a hardware and control bit here.
Jan
PATCH 7/23 tools/libxl: Expose hardware and privileged flags
In reply to Jason AndryukExpose the new hardware and privileged domain flags in libxl_domain as boolean fields.
--- tools/include/libxl.h | 16 ++++++++++++++++ tools/libs/light/libxl_domain.c | 2 ++ tools/libs/light/libxl_types.idl | 2 ++ 3 files changed, 20 insertions(+)
tools/include/libxl.h +16 -0
@@ -1010,6 +1010,22 @@ typedef struct libxl__ctx libxl_ctx;*/ #define LIBXL_HAVE_DOMINFO_GPADDR_BITS 1 +/* +* LIBXL_HAVE_DOMINFO_HARDWARE +* +* If this is defined, libxl_dominfo will contain a flag called hardware +* indicating that the specific domain is the hardware domain. +*/ +#define LIBXL_HAVE_DOMINFO_HARDWARE 1 + +/* +* LIBXL_HAVE_DOMINFO_PRIVILEGED +* +* If this is defined, libxl_dominfo will contain a flag called privileged +* indicating that the specific domain is privileged. +*/ +#define LIBXL_HAVE_DOMINFO_PRIVILEGED 1 +/* * LIBXL_HAVE_QXL *
tools/libs/light/libxl_domain.c +2 -0
@@ -291,6 +291,8 @@ void libxl__xcinfo2xlinfo(libxl_ctx *ctx, xlinfo->blocked = !!(xcinfo->flags&XEN_DOMINF_blocked); xlinfo->running = !!(xcinfo->flags&XEN_DOMINF_running); xlinfo->never_stop = !!(xcinfo->flags&XEN_DOMINF_xs_domain); + xlinfo->hardware = !!(xcinfo->flags&XEN_DOMINF_hardware); + xlinfo->privileged = !!(xcinfo->flags&XEN_DOMINF_priv);if (xlinfo->shutdown) xlinfo->shutdown_reason = (xcinfo->flags>>XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask;
tools/libs/light/libxl_types.idl +2 -0
@@ -365,6 +365,8 @@ libxl_dominfo = Struct("dominfo",[ ("shutdown", bool), ("dying", bool), ("never_stop", bool), + ("hardware", bool), + ("privileged", bool), # Valid iff ->shutdown is true. #
Signature · 1 line
2.48.1
PATCH 8/23 xen/arm: dom0less seed xenstore grant table entry
In reply to Jason AndryukWith a split hardware and control domain, the control domain may still want and xenstore access. Currently this relies on init-dom0less to seed the grants. This is problematic since we don't want hardware domain to be able to map the control domain's resources. Instead have the hypervisor see the grant table entry. The grant is then accessible as normal.
This is also useful with a xenstore stubdom to setup the xenbus page much earlier.
This works with C xenstored. OCaml xenstored does not use grants and would fail to foreign map the page.
--- xen/arch/arm/dom0less-build.c | 9 +++++++++ xen/common/grant_table.c | 10 ++++++++++ xen/include/xen/grant_table.h | 8 ++++++++ 3 files changed, 27 insertions(+)
xen/arch/arm/dom0less-build.c +9 -0
@@ -21,6 +21,8 @@#include <asm/static-memory.h> #include <asm/static-shmem.h> +static domid_t __initdata xs_domid =DOMID_INVALID ; +bool __init is_dom0less_mode (void ) {struct bootmodules *mods = &bootinfo.modules;
@@ -753,6 +755,10 @@ static int __init alloc_xenstore_page(struct domain *d) interface->connection =XENSTORE_RECONNECT ;unmap_domain_page (interface); +if ( xs_domid !=DOMID_INVALID ) +gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, +gfn_x (gfn), GTF_permit_access); +return 0 ; }
@@ -1173,6 +1179,9 @@ void __init create_domUs(void)if ( rc )panic ("Could not set up domain %s (rc = %d)\n" ,dt_node_name (node), rc); + +if ( d_cfg.flags & XEN_DOMCTL_CDF_xs_domain ) + xs_domid = d->domain_id; } }
xen/common/grant_table.c +10 -0
@@ -4346,6 +4346,16 @@ static void gnttab_usage_print(struct domain *rd)printk ("no active grant table entries\n" ); } +void gnttab_seed_entry (struct domain *d,int idx,domid_t be_domid, +uint64_t frame,unsigned int flags) +{ +struct grant_table *gt = d->grant_table; + +shared_entry_v1 (gt, idx).flags = flags; +shared_entry_v1 (gt, idx).domid = be_domid; +shared_entry_v1 (gt, idx).frame = frame; +} + static void cf_check gnttab_usage_print_all(unsigned char key) {struct domain *d;
xen/include/xen/grant_table.h +8 -0
@@ -45,6 +45,10 @@ void grant_table_destroy( struct domain *d);void grant_table_init_vcpu (struct vcpu *v); +/* Seed a gnttab entry for Hyperlaunch/dom0less. */ +void gnttab_seed_entry (struct domain *d,int idx,domid_t be_domid, +uint64_t frame,unsigned int flags); +/* * Check if domain has active grants and log first 10 of them. */
@@ -85,6 +89,10 @@ static inline void grant_table_destroy(struct domain *d) {}static inline void grant_table_init_vcpu (struct vcpu *v) {} +static inline void gnttab_seed_entry (struct domain *d,int idx, +domid_t be_domid,uint64_t frame, +unsigned int flags) {} +static inline void grant_table_warn_active_grants (struct domain *d) {}static inline int gnttab_release_mappings (struct domain *d) {return 0 ; }
Signature · 1 line
2.48.1
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
Quoted 9 lines · Jason Andryuk
With a split hardware and control domain, the control domain may still want and xenstore access. Currently this relies on init-dom0less to seed the grants. This is problematic since we don't want hardware domain to be able to map the control domain's resources. Instead have the hypervisor see the grant table entry. The grant is then accessible as normal.
This is also useful with a xenstore stubdom to setup the xenbus page much earlier.
Reading the patch, it seems that what is doing is letting the xenstore domain map the domU's grant table page. Is that correct?
If so, I would suggest to update the commit message as follows:
With split hardware/control/xenstore domains, the xenstore domain may still want to access other domains' xenstore page. Currently this relies on init-dom0less to seed the grants from Dom0. This is problematic since we don't want the hardware domain to be able to map other domains' resources without their permission. Instead have the hypervisor seed the grant table entry for every dom0less domain. The grant is then accessible as normal.
Quoted 95 lines
This works with C xenstored. OCaml xenstored does not use grants and would fail to foreign map the page.
Signed-off-by Jason Andryuk <[email protected]>--- xen/arch/arm/dom0less-build.c | 9 +++++++++ xen/common/grant_table.c | 10 ++++++++++ xen/include/xen/grant_table.h | 8 ++++++++ 3 files changed, 27 insertions(+)xen/arch/arm/dom0less-build.c +9
-0@@ -21,6 +21,8 @@#include <asm/static-memory.h> #include <asm/static-shmem.h> +static domid_t __initdata xs_domid =DOMID_INVALID ; +bool __init is_dom0less_mode (void ) {struct bootmodules *mods = &bootinfo.modules;@@ -753,6 +755,10 @@ static int __init alloc_xenstore_page(struct domain *d) interface->connection =XENSTORE_RECONNECT ;unmap_domain_page (interface); +if ( xs_domid !=DOMID_INVALID ) +gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, +gfn_x (gfn), GTF_permit_access); +return 0 ; }@@ -1173,6 +1179,9 @@ void __init create_domUs(void)if ( rc )panic ("Could not set up domain %s (rc = %d)\n" ,dt_node_name (node), rc); + +if ( d_cfg.flags & XEN_DOMCTL_CDF_xs_domain ) + xs_domid = d->domain_id; } }xen/common/grant_table.c +10
-0@@ -4346,6 +4346,16 @@ static void gnttab_usage_print(struct domain *rd)printk ("no active grant table entries\n" ); } +void gnttab_seed_entry (struct domain *d,int idx,domid_t be_domid, +uint64_t frame,unsigned int flags) +{ +struct grant_table *gt = d->grant_table; + +shared_entry_v1 (gt, idx).flags = flags; +shared_entry_v1 (gt, idx).domid = be_domid; +shared_entry_v1 (gt, idx).frame = frame; +} + static void cf_check gnttab_usage_print_all(unsigned char key) {struct domain *d;xen/include/xen/grant_table.h +8
-0@@ -45,6 +45,10 @@ void grant_table_destroy( struct domain *d);void grant_table_init_vcpu (struct vcpu *v); +/* Seed a gnttab entry for Hyperlaunch/dom0less. */ +void gnttab_seed_entry (struct domain *d,int idx,domid_t be_domid, +uint64_t frame,unsigned int flags); +/* * Check if domain has active grants and log first 10 of them. */ @@ -85,6 +89,10 @@ static inline void grant_table_destroy(struct domain *d) {}static inline void grant_table_init_vcpu (struct vcpu *v) {} +static inline void gnttab_seed_entry (struct domain *d,int idx, +domid_t be_domid,uint64_t frame, +unsigned int flags) {} +static inline void grant_table_warn_active_grants (struct domain *d) {}static inline int gnttab_release_mappings (struct domain *d) {return 0 ; }Signature · 1 line
2.48.1
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Jason Andryuk
With a split hardware and control domain, the control domain may still want and xenstore access. Currently this relies on init-dom0less to seed the grants. This is problematic since we don't want hardware domain to be able to map the control domain's resources. Instead have the hypervisor see the grant table entry. The grant is then accessible as normal.
Quoted 5 lines
Quoted 2 lines
This is also useful with a xenstore stubdom to setup the xenbus page much earlier.
Reading the patch, it seems that what is doing is letting the xenstore domain map the domU's grant table page. Is that correct?
The end result is everything is setup for xenstored to map GNTTAB_RESERVED_XENSTORE at some time later.
Quoted 9 lines
If so, I would suggest to update the commit message as follows:
With split hardware/control/xenstore domains, the xenstore domain may still want to access other domains' xenstore page. Currently this relies on init-dom0less to seed the grants from Dom0. This is problematic since we don't want the hardware domain to be able to map other domains' resources without their permission. Instead have the hypervisor seed the grant table entry for every dom0less domain. The grant is then accessible as normal.
I'll go with a tweaked version of yours:
xenstored maps other domains' xenstore pages. Currently this relies
on init-dom0less or xl to seed the grants from Dom0. With split hardware/control/xenstore domains, this is problematic since we don't want the hardware domain to be able to map other domains' resources without their permission. Instead have the hypervisor seed the grant table entry for every dom0less domain. The grant is then accessible as normal.
Regards,
Jason
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
In reply to Jason AndryukHi,
Quoted 6 lines · Jason Andryuk
With a split hardware and control domain, the control domain may still want and xenstore access. Currently this relies on init-dom0less to seed the grants. This is problematic since we don't want hardware domain to be able to map the control domain's resources. Instead have the hypervisor see the grant table entry. The grant is then accessible as normal.
I am probably missing something, but why would run xenstored in the hardware domain rather than the control domain? Isn't xenstored more related to the VM management than HW?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
Quoted 11 lines · Julien Grall
Hi,
Quoted 6 lines · Jason Andryuk
With a split hardware and control domain, the control domain may still want and xenstore access. Currently this relies on init-dom0less to seed the grants. This is problematic since we don't want hardware domain to be able to map the control domain's resources. Instead have the hypervisor see the grant table entry. The grant is then accessible as normal.
I am probably missing something, but why would run xenstored in the hardware domain rather than the control domain? Isn't xenstored more related to the VM management than HW?
I addressed this in my other email. You're probably right that xenstored should run in control, but implementation details prevent that in the short term.
Regardless, of the xenstored placement, I think it's a better design for Xen to seed the grants. With Xen allocating the xenstore page and event channel, and now seeding the grant table, they can just be used. A xenstore stubdom can just establish all the connections without relying on another domain to perform an action.
I tested that with hyperlaunching the xenstore stubdom. That is where the two XS_PRIV changes later in the series come from. xenstore stubdom iterates the domains, reads the hvm_param for the event channel, and then runs introduce to set up the connection.
Regards,
Jason
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
Quoted 11 lines · Jason Andryuk
Quoted 10 lines · Julien Grall
Hi,
Quoted 6 lines · Jason Andryuk
With a split hardware and control domain, the control domain may still want and xenstore access. Currently this relies on init-dom0less to seed the grants. This is problematic since we don't want hardware domain to be able to map the control domain's resources. Instead have the hypervisor see the grant table entry. The grant is then accessible as normal.
Quoted 7 lines
Quoted 3 lines
I am probably missing something, but why would run xenstored in the hardware domain rather than the control domain? Isn't xenstored more related to the VM management than HW?
I addressed this in my other email. You're probably right that xenstored should run in control, but implementation details prevent that in the short term.
I wrote a longer reply here:
https://marc.info/?l=xen-devel&m=174139414000462
I think there are valid reasons to run xenstored in either the control domain or the hardware domain, so it should be configurable. If no specific preference is indicated, I would place it in the hardware domain because the control domain must remain free from interference. Given that I don't think we know for sure today whether the Xenstore protocol could be a potential vector for interference, it is safer to avoid placing it in the control domain by default.
Quoted 5 lines
Regardless, of the xenstored placement, I think it's a better design for Xen to seed the grants. With Xen allocating the xenstore page and event channel, and now seeding the grant table, they can just be used. A xenstore stubdom can just establish all the connections without relying on another domain to perform an action.
+1
Quoted 4 lines
I tested that with hyperlaunching the xenstore stubdom. That is where the two
XS_PRIVchanges later in the series come from. xenstore stubdom iterates the domains, reads thehvm_paramfor the event channel, and then runs introduce to set up the connection.
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
In reply to Jason Andryukxen/common/grant_table.c static void gnttab_usage_print(struct domain *rd) · line 4349
Quoted 7 lines · Jason Andryuk
xen/common/grant_table.c +1
-0@@ -4346,6 +4346,16 @@ static void gnttab_usage_print(struct domain *rd)printk ("no active grant table entries\n" ); } +void gnttab_seed_entry(struct domain *d, int idx, domid_t be_domid,
Can idx be negative? If not, unsigned int please.
Furthermore, as with any additions to common code, please keep in mind
Misra: We better wouldn't gain new unreachable code for certain configs, even if - didn't check - the respective rule continues to be non-blocking.
xen/common/grant_table.c static void gnttab_usage_print(struct domain *rd) · line 4352
Quoted 3 lines
xen/common/grant_table.c +3
-0+ uint64_t frame, unsigned int flags) +{ +struct grant_table *gt = d->grant_table;
This looks like it could be pointer-to-const. Same apparently for the d function parameter. Question is - would it perhaps make sense to have const struct grant_table *gt be the function parameter in the first place?
xen/common/grant_table.c static void gnttab_usage_print(struct domain *rd) · line 4357
Quoted 4 lines
xen/common/grant_table.c +4
-0+shared_entry_v1 (gt, idx).flags = flags; +shared_entry_v1 (gt, idx).domid = be_domid; +shared_entry_v1 (gt, idx).frame = frame; +}
In common code there shouldn't be an assumption that gnttab v1 is in use.
Jan
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
Quoted 7 lines · Jan Beulich
xen/common/grant_table.c static void gnttab_usage_print(struct domain *rd) · line 4357
Quoted 4 lines · Jason Andryuk
xen/common/grant_table.c +4
-0+shared_entry_v1 (gt, idx).flags = flags; +shared_entry_v1 (gt, idx).domid = be_domid; +shared_entry_v1 (gt, idx).frame = frame; +}In common code there shouldn't be an assumption that gnttab v1 is in use.
But isn't the grant table in V1 format until the guest potentially switches to V2?
Juergen
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
Quoted 11 lines · Juergen Gross
Quoted 7 lines · Jan Beulich
xen/common/grant_table.c static void gnttab_usage_print(struct domain *rd) · line 4357
Quoted 4 lines · Jason Andryuk
xen/common/grant_table.c +4
-0+shared_entry_v1 (gt, idx).flags = flags; +shared_entry_v1 (gt, idx).domid = be_domid; +shared_entry_v1 (gt, idx).frame = frame; +}In common code there shouldn't be an assumption that gnttab v1 is in use.
But isn't the grant table in V1 format until the guest potentially switches to V2?
Strictly speaking it's in v0 format initially. But yes, I see your point. Provided this function is made clear that it may only ever be used on a domain that wasn't started yet (perhaps proven by way of an assertion).
Jan
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Juergen Gross
Quoted 6 lines · Jan Beulich
Quoted 4 lines · Jason Andryuk
xen/common/grant_table.c +4
-0+shared_entry_v1 (gt, idx).flags = flags; +shared_entry_v1 (gt, idx).domid = be_domid; +shared_entry_v1 (gt, idx).frame = frame; +}
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
In common code there shouldn't be an assumption that gnttab v1 is in use.
But isn't the grant table in V1 format until the guest potentially switches to V2?
Strictly speaking it's in v0 format initially. But yes, I see your point. Provided this function is made clear that it may only ever be used on a domain that wasn't started yet (perhaps proven by way of an assertion).
Yes, this is what I was relying on.
If d is still passed in, we could doASSERT(!d->creation_finished);
Hmmm, the function might could be marked __init, too, I think.
struct grant_table and shared_entry_v1 are defined in xen/common/grant_table.c, which is why the function lives there (and it'll be useful for hyperlaunch). To avoid unreachable code, I guess I'll wrap it inside #ifdef CONFIG_DOM0LESS_BOOT.
Regards,
Jason
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
In reply to Jason AndryukHi Jason,
Quoted 34 lines · Jason Andryuk
With a split hardware and control domain, the control domain may still want and xenstore access. Currently this relies on init-dom0less to seed the grants. This is problematic since we don't want hardware domain to be able to map the control domain's resources. Instead have the hypervisor see the grant table entry. The grant is then accessible as normal.
This is also useful with a xenstore stubdom to setup the xenbus page much earlier.
This works with C xenstored. OCaml xenstored does not use grants and would fail to foreign map the page.
Signed-off-by Jason Andryuk <[email protected]>--- xen/arch/arm/dom0less-build.c | 9 +++++++++ xen/common/grant_table.c | 10 ++++++++++ xen/include/xen/grant_table.h | 8 ++++++++ 3 files changed, 27 insertions(+)xen/arch/arm/dom0less-build.c +2
-0@@ -21,6 +21,8 @@#include <asm/static-memory.h> #include <asm/static-shmem.h> +static domid_t __initdata xs_domid =DOMID_INVALID ; +bool __init is_dom0less_mode (void ) {struct bootmodules *mods = &bootinfo.modules;
xen/arch/arm/dom0less-build.c static int __init alloc_xenstore_page(struct domain *d) · line 758
Quoted 4 lines
xen/arch/arm/dom0less-build.c +1
-0@@ -753,6 +755,10 @@ static int __init alloc_xenstore_page(struct domain *d) interface->connection =XENSTORE_RECONNECT ;unmap_domain_page (interface); +if ( xs_domid !=DOMID_INVALID )
Looking at this patch again, is this guarantee that the xenstore domain will be created first? If not, then I think your series needs to be re-ordered so patch #10 is before this patch.
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1184
Quoted 13 lines
xen/arch/arm/dom0less-build.c +6
-0+gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, +gfn_x (gfn), GTF_permit_access); +return 0 ; }@@ -1173,6 +1179,9 @@ void __init create_domUs(void)if ( rc )panic ("Could not set up domain %s (rc = %d)\n" ,dt_node_name (node), rc); + +if ( d_cfg.flags & XEN_DOMCTL_CDF_xs_domain ) + xs_domid = d->domain_id;
What if there is multiple domain with XEN_DOMCTL_CDF_xs_domain? Should we throw an error?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 08/23] xen/arm: dom0less seed xenstore grant table entry
Quoted 34 lines · Julien Grall
Hi Jason,
Quoted 31 lines · Jason Andryuk
With a split hardware and control domain, the control domain may still want and xenstore access. Currently this relies on init-dom0less to seed the grants. This is problematic since we don't want hardware domain to be able to map the control domain's resources. Instead have the hypervisor see the grant table entry. The grant is then accessible as normal.
This is also useful with a xenstore stubdom to setup the xenbus page much earlier.
This works with C xenstored. OCaml xenstored does not use grants and would fail to foreign map the page.
Signed-off-by Jason Andryuk <[email protected]>---
xen/arch/arm/dom0less-build.c| 9 +++++++++
xen/common/grant_table.c | 10 ++++++++++
xen/include/xen/grant_table.h| 8 ++++++++3 files changed, 27 insertions(+)xen/arch/arm/dom0less-build.c +2
-0@@ -21,6 +21,8 @@ #include <asm/static-memory.h> #include <asm/static-shmem.h> +static domid_t __initdata xs_domid =DOMID_INVALID ; + bool __init is_dom0less_mode(void) {
Quoted 8 lines
xen/arch/arm/dom0less-build.c static int __init alloc_xenstore_page(struct · line 758
Quoted 6 lines
xen/arch/arm/dom0less-build.c +1
-0struct bootmodules *mods = &bootinfo.modules;@@ -753,6 +755,10 @@ static int __init alloc_xenstore_page(struct domain *d) interface->connection = XENSTORE_RECONNECT; unmap_domain_page(interface); + if ( xs_domid != DOMID_INVALID )Looking at this patch again, is this guarantee that the xenstore domain will be created first? If not, then I think your series needs to be re- ordered so patch #10 is before this patch.
Yes, you are right.
Quoted 6 lines
Quoted 6 lines
xen/arch/arm/dom0less-build.c +3
-0+ gnttab_seed_entry(d, GNTTAB_RESERVED_XENSTORE, xs_domid, + gfn_x(gfn), GTF_permit_access); + return 0; }@@ -1173,6 +1179,9 @@ void __init create_domUs(void)
Quoted 8 lines
xen/arch/arm/dom0less-build.c void __init create_domUs(void) · line 1184
Quoted 6 lines
xen/arch/arm/dom0less-build.c +3
-0if ( rc ) panic("Could not set up domain %s (rc = %d)\n", dt_node_name(node), rc); + + if ( d_cfg.flags & XEN_DOMCTL_CDF_xs_domain ) + xs_domid = d->domain_id;What if there is multiple domain with
XEN_DOMCTL_CDF_xs_domain? Should we throw an error?
Before this series, there was no restriction on its use, but only init-xenstore-domain used it. The XEN_DOMCTL_CDF_xs_domain flag allows the domain XSM_XS_PRIV, which grants a few more operations to an otherwise unprivileged domU
With the use of xs_domid (only during construction), maybe it should be limited to just 1 to avoid surprises. Otherwise the last built xenstore domain would be configured as the backend. Nothing would break - it would just be surprising. I'll restrict to just 1.
Thanks,
Jason
PATCH 9/23 tools/init-dom0less: Only seed legacy xenstore grants
In reply to Jason AndryukThe hardware domain is unable to seed a control domain, but we want the control domain to use xenstore. Rely on the hypervisor to seed dom0less grant table entries for Xenstore, so this seeding is unnecessary.
However, that only works for the new xenstore late init. The legacy protocol which uses init-dom0less to populate the page still needs to seed the grant.
--- tools/helpers/init-dom0less.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/helpers/init-dom0less.c +5 -5
@@ -286,12 +286,12 @@ static int init_domain(struct xs_handle *xsh, xenstore_pfn);if (rc <0 )return rc; - } - rc =xc_dom_gnttab_seed (xch, info->domid, true, - (xen_pfn_t)-1 , xenstore_pfn,0 ,0 ); -if (rc) -err (1 ,"xc_dom_gnttab_seed" ); + rc =xc_dom_gnttab_seed (xch, info->domid, true, + (xen_pfn_t)-1 , xenstore_pfn,0 ,0 ); +if (rc) +err (1 ,"xc_dom_gnttab_seed" ); + }libxl_uuid_generate (&uuid);xc_domain_sethandle (xch, info->domid,libxl_uuid_bytearray (&uuid));
Signature · 1 line
2.48.1
PATCH 10/23 xen/arm: dom0less delay xenstore initialization
In reply to Jason AndryukTo allocate the xenstore event channel and initialize the grant table entry, the xenstore domid is neeed. A dom0 is craeted before the domUs, so it is normally available through hardware_domain. With capabilities and dom0less, the xenstore domain may not be created first.
Keep the population of the page and HVM_PARAM_STORE_PFN in the normal domain construction, but delay event channel and seeding to after all domUs are created. HVM_PARAM_STORE_PFN now serves as indication to setup xenstore since the device tree is no longer immediately available. 0 means no xenstore. ~0ULL means legacy so only the event channel needs setup, and any other value means to seed the page.
dom0 needs to set xs_domid when it is serving as the xenstore domain.
--- xen/arch/arm/dom0less-build.c | 71 +++++++++++++++-------- xen/arch/arm/domain_build.c | 1 + xen/arch/arm/include/asm/dom0less-build.h | 2 + 3 files changed, 51 insertions(+), 23 deletions(-)
xen/arch/arm/dom0less-build.c +48 -23
@@ -22,6 +22,12 @@#include <asm/static-shmem.h> static domid_t __initdata xs_domid =DOMID_INVALID ; +static bool __initdata need_xenstore; + +void __init set_xs_domid (domid_t domid) +{ + xs_domid = domid; +}bool __init is_dom0less_mode (void ) {
@@ -697,7 +703,7 @@ static int __init alloc_xenstore_evtchn(struct domain *d)int rc; alloc.dom = d->domain_id; - alloc.remote_dom = hardware_domain->domain_id; + alloc.remote_dom = xs_domid; rc =evtchn_alloc_unbound (&alloc,0 );if ( rc ) {
@@ -755,10 +761,6 @@ static int __init alloc_xenstore_page(struct domain *d) interface->connection =XENSTORE_RECONNECT ;unmap_domain_page (interface); -if ( xs_domid !=DOMID_INVALID ) -gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, -gfn_x (gfn), GTF_permit_access); -return 0 ; }
@@ -767,16 +769,10 @@ static int __init alloc_xenstore_params(struct kernel_info *kinfo)struct domain *d = kinfo->d;int rc =0 ; -if ( kinfo->dom0less_feature & (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY ) ) - { -ASSERT (hardware_domain); - rc =alloc_xenstore_evtchn (d); -if ( rc <0 ) -return rc; +if ( (kinfo->dom0less_feature & (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY )) + == (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY ) ) d->arch.hvm.params[HVM_PARAM_STORE_PFN ] = ~0ULL ; - } - -if ( kinfo->dom0less_feature &DOM0LESS_XENSTORE ) +else if ( kinfo->dom0less_feature &DOM0LESS_XENSTORE ) { rc =alloc_xenstore_page (d);if ( rc <0 )
@@ -848,6 +844,34 @@ static void __init domain_vcpu_affinity(struct domain *d, } } +static void __init initialize_domU_xenstore (void ) +{ +struct domain *d; + +if ( xs_domid ==DOMID_INVALID ) +return ; + +for_each_domain ( d ) + { +unsigned long gfn = d->arch.hvm.params[HVM_PARAM_STORE_PFN ]; +int rc; + +if ( gfn ==0 ) +continue ; + +if (is_xenstore_domain (d) ) +continue ; + + rc =alloc_xenstore_evtchn (d); +if ( rc <0 ) +panic ("%pd: Failed to allocate xenstore_evtchn\n" , d); + +if ( gfn != ~0ULL ) +gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, + gfn, GTF_permit_access); + } +} +static int __init construct_domU (struct domain *d,const struct dt_device_node *node) {
@@ -888,17 +912,13 @@ static int __init construct_domU(struct domain *d, rc == -ENODATA || (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) ) { -if ( hardware_domain ) - kinfo.dom0less_feature =DOM0LESS_ENHANCED ; -else -panic ("At the moment, Xenstore support requires dom0 to be present\n" ); + need_xenstore = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED ; } else if ( rc == 0 && !strcmp(dom0less_enhanced, "legacy") ) { -if ( hardware_domain ) - kinfo.dom0less_feature =DOM0LESS_ENHANCED_LEGACY ; -else -panic ("At the moment, Xenstore support requires dom0 to be present\n" ); + need_xenstore = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED_LEGACY ; } else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) kinfo.dom0less_feature =DOM0LESS_ENHANCED_NO_XS ;
@@ -1181,8 +1201,13 @@ void __init create_domUs(void) dt_node_name(node), rc);if ( d_cfg.flags & XEN_DOMCTL_CDF_xs_domain ) - xs_domid = d->domain_id; +set_xs_domid (d->domain_id); } + +if ( need_xenstore && xs_domid ==DOMID_INVALID ) +panic ("xenstore requested, but xenstore domain not present\n" ); + +initialize_domU_xenstore (); }/*
xen/arch/arm/domain_build.c +1 -0
@@ -2373,6 +2373,7 @@ void __init create_dom0(void)unsigned int flags = CDF_privileged | CDF_hardware;int rc; +set_xs_domid (0 );/* The vGIC for DOM0 is exactly emulating the hardware GIC */ dom0_cfg.arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE ;/*
xen/arch/arm/include/asm/dom0less-build.h +2 -0
@@ -9,6 +9,7 @@void create_domUs (void );bool is_dom0less_mode (void ); +void set_xs_domid (domid_t );#else /* !CONFIG_DOM0LESS_BOOT */
@@ -17,6 +18,7 @@ static inline bool is_dom0less_mode(void) {return false; } +static inline void set_xs_domid (domid_t ) {}#endif /* CONFIG_DOM0LESS_BOOT */
Signature · 1 line
2.48.1
Re: [PATCH 10/23] xen/arm: dom0less delay xenstore initialization
Quoted 59 lines · Jason Andryuk
To allocate the xenstore event channel and initialize the grant table entry, the xenstore domid is neeed. A dom0 is craeted before the domUs, so it is normally available through
hardware_domain. With capabilities and dom0less, the xenstore domain may not be created first.Keep the population of the page and
HVM_PARAM_STORE_PFNin the normal domain construction, but delay event channel and seeding to after all domUs are created.HVM_PARAM_STORE_PFNnow serves as indication to setup xenstore since the device tree is no longer immediately available. 0 means no xenstore. ~0ULL means legacy so only the event channel needs setup, and any other value means to seed the page.dom0 needs to set
xs_domidwhen it is serving as the xenstore domain.Signed-off-by Jason Andryuk <[email protected]>--- xen/arch/arm/dom0less-build.c | 71 +++++++++++++++-------- xen/arch/arm/domain_build.c | 1 + xen/arch/arm/include/asm/dom0less-build.h | 2 + 3 files changed, 51 insertions(+), 23 deletions(-)xen/arch/arm/dom0less-build.c +7
-5@@ -22,6 +22,12 @@#include <asm/static-shmem.h> static domid_t __initdata xs_domid =DOMID_INVALID ; +static bool __initdata need_xenstore; + +void __init set_xs_domid (domid_t domid) +{ + xs_domid = domid; +}bool __init is_dom0less_mode (void ) {@@ -697,7 +703,7 @@ static int __init alloc_xenstore_evtchn(struct domain *d)int rc; alloc.dom = d->domain_id; - alloc.remote_dom = hardware_domain->domain_id; + alloc.remote_dom = xs_domid; rc =evtchn_alloc_unbound (&alloc,0 );if ( rc ) {@@ -755,10 +761,6 @@ static int __init alloc_xenstore_page(struct domain *d) interface->connection =XENSTORE_RECONNECT ;unmap_domain_page (interface); -if ( xs_domid !=DOMID_INVALID ) -gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, -gfn_x (gfn), GTF_permit_access); -return 0 ; }
xen/arch/arm/dom0less-build.c static int __init alloc_xenstore_params(struct kernel_info *kinfo) · line 773
Quoted 7 lines
xen/arch/arm/dom0less-build.c +0
-4@@ -767,16 +769,10 @@ static int __init alloc_xenstore_params(struct kernel_info *kinfo)struct domain *d = kinfo->d;int rc =0 ; -if ( kinfo->dom0less_feature & (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY ) ) - { -ASSERT (hardware_domain); - rc =alloc_xenstore_evtchn (d);
This patch looks correct. However, I don't understand why you didn't keep the call to alloc_xenstore_evtchn in alloc_xenstore_params.
Quoted 120 lines
xen/arch/arm/dom0less-build.c +41
-14-if ( rc <0 ) -return rc; +if ( (kinfo->dom0less_feature & (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY )) + == (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY ) ) d->arch.hvm.params[HVM_PARAM_STORE_PFN ] = ~0ULL ; - } - -if ( kinfo->dom0less_feature &DOM0LESS_XENSTORE ) +else if ( kinfo->dom0less_feature &DOM0LESS_XENSTORE ) { rc =alloc_xenstore_page (d);if ( rc <0 )@@ -848,6 +844,34 @@ static void __init domain_vcpu_affinity(struct domain *d, } } +static void __init initialize_domU_xenstore (void ) +{ +struct domain *d; + +if ( xs_domid ==DOMID_INVALID ) +return ; + +for_each_domain ( d ) + { +unsigned long gfn = d->arch.hvm.params[HVM_PARAM_STORE_PFN ]; +int rc; + +if ( gfn ==0 ) +continue ; + +if (is_xenstore_domain (d) ) +continue ; + + rc =alloc_xenstore_evtchn (d); +if ( rc <0 ) +panic ("%pd: Failed to allocate xenstore_evtchn\n" , d); + +if ( gfn != ~0ULL ) +gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, + gfn, GTF_permit_access); + } +} +static int __init construct_domU (struct domain *d,const struct dt_device_node *node) {@@ -888,17 +912,13 @@ static int __init construct_domU(struct domain *d, rc == -ENODATA || (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) ) { -if ( hardware_domain ) - kinfo.dom0less_feature =DOM0LESS_ENHANCED ; -else -panic ("At the moment, Xenstore support requires dom0 to be present\n" ); + need_xenstore = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED ; } else if ( rc == 0 && !strcmp(dom0less_enhanced, "legacy") ) { -if ( hardware_domain ) - kinfo.dom0less_feature =DOM0LESS_ENHANCED_LEGACY ; -else -panic ("At the moment, Xenstore support requires dom0 to be present\n" ); + need_xenstore = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED_LEGACY ; } else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) kinfo.dom0less_feature =DOM0LESS_ENHANCED_NO_XS ;@@ -1181,8 +1201,13 @@ void __init create_domUs(void) dt_node_name(node), rc);if ( d_cfg.flags & XEN_DOMCTL_CDF_xs_domain ) - xs_domid = d->domain_id; +set_xs_domid (d->domain_id); } + +if ( need_xenstore && xs_domid ==DOMID_INVALID ) +panic ("xenstore requested, but xenstore domain not present\n" ); + +initialize_domU_xenstore (); }/* xen/arch/arm/domain_build.c +1
-0@@ -2373,6 +2373,7 @@ void __init create_dom0(void)unsigned int flags = CDF_privileged | CDF_hardware;int rc; +set_xs_domid (0 );/* The vGIC for DOM0 is exactly emulating the hardware GIC */ dom0_cfg.arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE ;/* xen/arch/arm/include/asm/dom0less-build.h +2
-0@@ -9,6 +9,7 @@void create_domUs (void );bool is_dom0less_mode (void ); +void set_xs_domid (domid_t );#else /* !CONFIG_DOM0LESS_BOOT */ @@ -17,6 +18,7 @@ static inline bool is_dom0less_mode(void) {return false; } +static inline void set_xs_domid (domid_t ) {}#endif /* CONFIG_DOM0LESS_BOOT */ Signature · 1 line
2.48.1
Re: [PATCH 10/23] xen/arm: dom0less delay xenstore initialization
Quoted 8 lines · Stefano Stabellini
xen/arch/arm/dom0less-build.c static int __init alloc_xenstore_evtchn(struct domain *d) · line 706
Quoted 6 lines · Jason Andryuk
xen/arch/arm/dom0less-build.c +1
-1@@ -697,7 +703,7 @@ static int __init alloc_xenstore_evtchn(struct domain *d)int rc; alloc.dom = d->domain_id; - alloc.remote_dom = hardware_domain->domain_id; + alloc.remote_dom = xs_domid;
This...
Quoted 8 lines
Quoted 8 lines
xen/arch/arm/dom0less-build.c +0
-0rc =evtchn_alloc_unbound (&alloc,0 );if ( rc ) {@@ -767,16 +769,10 @@ static int __init alloc_xenstore_params(struct kernel_info *kinfo)struct domain *d = kinfo->d;int rc =0 ;
Quoted 7 lines
xen/arch/arm/dom0less-build.c static int __init alloc_xenstore_params(struct kernel_info *kinfo) · line 773
Quoted 4 lines
xen/arch/arm/dom0less-build.c +0
-4-if ( kinfo->dom0less_feature & (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY ) ) - { -ASSERT (hardware_domain); - rc =alloc_xenstore_evtchn (d);This patch looks correct. However, I don't understand why you didn't keep the call to
alloc_xenstore_evtchninalloc_xenstore_params.
alloc_xenstore_evtchn() needs to be delayed so that xs_domid is available.
Regards,
Jason
PATCH 11/23 tools/xenstored: Automatically set dom0_domid and priv_domid
In reply to Jason AndryukWith split hardware and control domains, each domain should be privileged with respect to xenstore. When adding domains to xenstore, look at their privilege and add them to xenstored as appropriate. dom0_domid is used for the hardware domain, and priv_domid is used for a control domain.
Only one of each is allowed for now.
--- tools/xenstored/domain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/xenstored/domain.c +16 -0
@@ -795,6 +795,20 @@ static struct domain *find_or_alloc_existing_domain(unsigned int domid)return domain; } +static void domain_set_privileged (struct domain *domain) +{ +xc_domaininfo_t dominfo; + +if ( !get_domain_info (domain->domid, &dominfo) ) +return ; + +if ( dominfo.flags & XEN_DOMINF_priv ) + priv_domid = domain->domid; + +if ( dominfo.flags & XEN_DOMINF_hardware ) + dom0_domid = domain->domid; +} +static int new_domain (struct domain *domain,int port,bool restore) {int rc;
@@ -831,6 +845,8 @@ static int new_domain(struct domain *domain, int port, bool restore) domain->conn->domain = domain; domain->conn->id = domain->domid; +domain_set_privileged (domain); +return 0 ; }
Signature · 1 line
2.48.1
Re: [PATCH 11/23] tools/xenstored: Automatically set dom0_domid and priv_domid
Quoted 24 lines · Jason Andryuk
With split hardware and control domains, each domain should be privileged with respect to xenstore. When adding domains to xenstore, look at their privilege and add them to xenstored as appropriate.
dom0_domidis used for the hardware domain, andpriv_domidis used for a control domain.Only one of each is allowed for now.
Signed-off-by Jason Andryuk <[email protected]>--- tools/xenstored/domain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)tools/xenstored/domain.c +3
-0@@ -795,6 +795,20 @@ static struct domain *find_or_alloc_existing_domain(unsigned int domid)return domain; } +static void domain_set_privileged (struct domain *domain) +{ +xc_domaininfo_t dominfo;
tools/xenstored/domain.c static struct domain *find_or_alloc_existing_domain(unsigned int domid) · line 810
Quoted 10 lines
tools/xenstored/domain.c +10
-0+ +if ( !get_domain_info (domain->domid, &dominfo) ) +return ; + +if ( dominfo.flags & XEN_DOMINF_priv ) + priv_domid = domain->domid; + +if ( dominfo.flags & XEN_DOMINF_hardware ) + dom0_domid = domain->domid; +}
Please no use of libxenctrl. I have worked hard to eliminate the usage in order to enable a xenstore-stubdom being used across Xen versions (C Xenstore is relying on stable hypercalls only now).
You need to add the needed flags to the rather new stable domctl XEN_DOMCTL_get_domain_state and to libxenmanage.
tools/xenstored/domain.c static int new_domain(struct domain *domain, int port, bool restore) · line 848
Quoted 9 lines
tools/xenstored/domain.c +2
-0+static int new_domain (struct domain *domain,int port,bool restore) {int rc;@@ -831,6 +845,8 @@ static int new_domain(struct domain *domain, int port, bool restore) domain->conn->domain = domain; domain->conn->id = domain->domid; +domain_set_privileged (domain);
The name implies you are changing the domain to be privileged, but this is done conditionally only.
Maybe name the function domain_apply_privileges()?
Juergen
Re: [PATCH 11/23] tools/xenstored: Automatically set dom0_domid and priv_domid
Quoted 31 lines · Jürgen Groß
Quoted 30 lines · Jason Andryuk
With split hardware and control domains, each domain should be privileged with respect to xenstore. When adding domains to xenstore, look at their privilege and add them to xenstored as appropriate.
dom0_domidis used for the hardware domain, andpriv_domidis used for a control domain.Only one of each is allowed for now.
Signed-off-by Jason Andryuk <[email protected]>---
tools/xenstored/domain.c| 16 ++++++++++++++++1 file changed, 16 insertions(+)tools/xenstored/domain.c +9
-0@@ -795,6 +795,20 @@ static struct domain *find_or_alloc_existing_domain(unsigned int domid) return domain; } +static void domain_set_privileged (struct domain *domain) +{ + xc_domaininfo_t dominfo; + + if ( !get_domain_info(domain->domid, &dominfo) ) + return; + + if ( dominfo.flags & XEN_DOMINF_priv ) + priv_domid = domain->domid;
Quoted 8 lines
tools/xenstored/domain.c static struct domain *find_or_alloc_existing_domain(unsigned int domid) · line 810
Quoted 4 lines
tools/xenstored/domain.c +4
-0+ + if ( dominfo.flags & XEN_DOMINF_hardware ) + dom0_domid = domain->domid; +}Please no use of libxenctrl. I have worked hard to eliminate the usage in order to enable a xenstore-stubdom being used across Xen versions (C Xenstore is relying on stable hypercalls only now).
Right. Yes, nice work on switching to stable hypercalls.
Quoted 2 lines
You need to add the needed flags to the rather new stable domctl
XEN_DOMCTL_get_domain_stateand to libxenmanage.
Ok.
Quoted 13 lines
tools/xenstored/domain.c static int new_domain(struct domain *domain, int · line 848
Quoted 9 lines
tools/xenstored/domain.c +2
-0+ static int new_domain(struct domain *domain, int port, bool restore) { int rc;@@ -831,6 +845,8 @@ static int new_domain(struct domain *domain, int port, bool restore) domain->conn->domain = domain; domain->conn->id = domain->domid; + domain_set_privileged(domain);The name implies you are changing the domain to be privileged, but this is done conditionally only.
Quoted 1 line
Maybe name the function
domain_apply_privileges()?
I'm thinking domain_apply_capabilities() since they are being referred to as capabilities.
But I'll have to revisit this. To make xenstored "just work" when domid != 0, it should auto-detect its domain id, and that has to be done earlier than this.
Regards,
Jason
Re: [PATCH 11/23] tools/xenstored: Automatically set dom0_domid and priv_domid
Quoted 63 lines · Jason Andryuk
Quoted 31 lines · Jürgen Groß
Quoted 30 lines · Jason Andryuk
With split hardware and control domains, each domain should be privileged with respect to xenstore. When adding domains to xenstore, look at their privilege and add them to xenstored as appropriate.
dom0_domidis used for the hardware domain, andpriv_domidis used for a control domain.Only one of each is allowed for now.
Signed-off-by Jason Andryuk <[email protected]>---
tools/xenstored/domain.c| 16 ++++++++++++++++1 file changed, 16 insertions(+)tools/xenstored/domain.c +9
-0@@ -795,6 +795,20 @@ static struct domain *find_or_alloc_existing_domain(unsigned int domid) return domain; } +static void domain_set_privileged (struct domain *domain) +{ + xc_domaininfo_t dominfo; + + if ( !get_domain_info(domain->domid, &dominfo) ) + return; + + if ( dominfo.flags & XEN_DOMINF_priv ) + priv_domid = domain->domid;Quoted 8 lines
tools/xenstored/domain.c static struct domain *find_or_alloc_existing_domain(unsigned int domid) · line 810
Quoted 4 lines
tools/xenstored/domain.c +4
-0+ + if ( dominfo.flags & XEN_DOMINF_hardware ) + dom0_domid = domain->domid; +}Please no use of libxenctrl. I have worked hard to eliminate the usage in order to enable a xenstore-stubdom being used across Xen versions (C Xenstore is relying on stable hypercalls only now).
Right. Yes, nice work on switching to stable hypercalls.
Quoted 2 lines
You need to add the needed flags to the rather new stable domctl
XEN_DOMCTL_get_domain_stateand to libxenmanage.Ok.
Quoted 13 lines
tools/xenstored/domain.c static int new_domain(struct domain *domain, int port, · line 848
Quoted 9 lines
tools/xenstored/domain.c +2
-0+ static int new_domain(struct domain *domain, int port, bool restore) { int rc;@@ -831,6 +845,8 @@ static int new_domain(struct domain *domain, int port, bool restore) domain->conn->domain = domain; domain->conn->id = domain->domid; + domain_set_privileged(domain);The name implies you are changing the domain to be privileged, but this is done conditionally only.
Quoted 5 lines
Quoted 1 line
Maybe name the function
domain_apply_privileges()?I'm thinking
domain_apply_capabilities()since they are being referred to as capabilities.But I'll have to revisit this. To make xenstored "just work" when domid != 0, it should auto-detect its domain id, and that has to be done earlier than this.
I think with the 3 remaining patches of my series [1] this should be handled already.
[1]: https://lists.xen.org/archives/html/xen-devel/2025-02/msg00120.html
https://lists.xen.org/archives/html/xen-devel/2025-02/msg00121.html https://lists.xen.org/archives/html/xen-devel/2025-02/msg00122.html
Juergen
PATCH 12/23 tools/xl: Print domain capabilities with verbose
In reply to Jason AndryukCapabilities are show like this (long lines trimmed):
xl list --verbose
Name Security Label Capabilities
Domain-0 - hardware xenstore dom0less-1 - - dom0less-2 - privileged
--- docs/man/xl.1.pod.in | 3 ++- tools/xl/xl_info.c | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-)
docs/man/xl.1.pod.in +2 -1
@@ -313,7 +313,8 @@ Also displays the security labels. =item B<-v>, B<--verbose> -Also displays the domain UUIDs, the shutdown reason and security labels. +Also displays the domain UUIDs, the shutdown reason, security labels, +and capabilities. =item B<-c>, B<--cpupool>
tools/xl/xl_info.c +23 -1
@@ -384,7 +384,7 @@ static void list_domains(bool verbose, bool context, bool claim, bool numa,libxl_physinfo_init (&physinfo);printf ("Name ID Mem VCPUs\tState\tTime(s)" ); -if (verbose)printf (" UUID Reason-Code\tSecurity Label" ); +if (verbose)printf (" UUID Reason-Code\tSecurity Label Capabilities" );if (context && !verbose)printf (" Security Label" );if (claim)printf (" Claimed" );if (cpupool)printf (" Cpupool" );
@@ -443,6 +443,28 @@ static void list_domains(bool verbose, bool context, bool claim, bool numa,putchar (' ' );print_bitmap (nodemap.map, physinfo.nr_nodes, stdout); } +if (verbose) { +bool cap = false; + +if ( info[i].privileged ) + { + cap = true; +printf (" privileged" ); + } +if ( info[i].hardware ) + { + cap = true; +printf (" hardware" ); + } +if ( info[i].never_stop ) + { + cap = true; +printf (" xenstore" ); + } +if ( !cap ) +printf (" %17s" ,"-" ); + } +putchar ('\n' ); }
Signature · 1 line
2.48.1
PATCH 1/1 Add domain capabilities
In reply to Jason AndryukAdd domain capabilities to creating disaggregated systems.
--- README.md | 16 ++++++++++++++ scripts/uboot-script-gen | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
README.md +16 -0
@@ -250,6 +250,22 @@ Where: Set driver_domain in xl config file. This option is only available for the disk_image script. +- DOMU_CAPS[number] = "string" or "hex" (optional) + A "|"-concatentated string of capabilities: + - control + - hardware + - xenstore + - dom0 (All of the above) + - none + + e.g. "control|hardware" + + Or a numeric bitwise flags to specify domain capabilities: + 0: None + 1: Control + 2: Hardware + 4: Xenstore + - LINUX is optional but specifies the Linux kernel for when Xen is NOT used. To enable this set any LINUX\_\* variables and do NOT set the XEN variable.
scripts/uboot-script-gen +47 -0
59 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [IMAGEBUILDER PATCH] Add domain capabilities
Quoted 3 lines · Jason Andryuk
Add domain capabilities to creating disaggregated systems.
Signed-off-by Jason Andryuk <[email protected]>
Quoted 100 lines
--- README.md | 16 ++++++++++++++ scripts/uboot-script-gen | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)README.md +16
-0@@ -250,6 +250,22 @@ Where: Set driver_domain in xl config file. This option is only available for the disk_image script. +- DOMU_CAPS[number] = "string" or "hex" (optional) + A "|"-concatentated string of capabilities: + - control + - hardware + - xenstore + - dom0 (All of the above) + - none + + e.g. "control|hardware" + + Or a numeric bitwise flags to specify domain capabilities: + 0: None + 1: Control + 2: Hardware + 4: Xenstore + - LINUX is optional but specifies the Linux kernel for when Xen is NOT used. To enable this set any LINUX\_\* variables and do NOT set the XEN variable.scripts/uboot-script-gen +47
-0@@ -309,6 +309,43 @@ function add_device_tree_cpupools() done } +function parse_domain_caps() +{ + local caps_str="$1" + local caps=0 + + for x in $( echo $caps_str | sed 's/|/ /g' | tr '[:upper:]' '[:lower:]' ) + do + case "$x" in + none) + caps=$(( caps | 0 )) + ;; + control) + caps=$(( caps | 0x1 )) + ;; + hardware) + caps=$(( caps | 0x2 )) + ;; + xenstore) + caps=$(( caps | 0x4 )) + ;; + dom0|domain0) + caps=$(( caps | 0x7 )) + ;; + [0-9]*|0x[0-9a-fA-f]*) + caps=$(( caps | $x )) + ;; + *) + return 1 + ;; + esac + done + + echo "$caps" + + return 0 +} + function xen_device_tree_editing() { dt_set "/chosen" "#address-cells" "hex" "0x2"@@ -386,6 +423,16 @@ function xen_device_tree_editing() then dt_set "/chosen/domU$i" "max_maptrack_frames" "int" "${DOMU_MAPTRACK_FRAMES[i]}" fi + if test -n "${DOMU_CAPS[i]}" + then + local caps + + if ! caps=$( parse_domain_caps ${DOMU_CAPS[i]} ) ; then + echo "Invalid DOMU_CAPS[$i] \"${DOMU_CAPS[i]}\"" + cleanup_and_return_err + fi + dt_set "/chosen/domU$i" "capabilities" "int" "$caps" + fi if test -n "${DOMU_SHARED_MEM[i]}" thenSignature · 1 line
2.48.1
PATCH 13/23 xsm/dummy: Allow XS_PRIV XEN_SYSCTL_getdomaininfolist
In reply to Jason AndryukTo hyperlaunch xenstore, we want it to automatically introduce all domains it finds while initializing. To do that, change xsm_sysctl to allow XS_PRIV to call XEN_SYSCTL_getdomaininfolist.
Xenstore can already call XEN_DOMCTL_getdomaininfo for the same information, but it requires knowing the domid. XEN_SYSCTL_getdomaininfolist eliminates the need to guess domains.
init-dom0less also calls XEN_SYSCTL_getdomaininfolist to determine running domains to initalize.
--- xen/common/sysctl.c | 2 +- xen/include/xsm/dummy.h | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-)
xen/common/sysctl.c +1 -1
@@ -42,7 +42,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)if ( op->interface_version !=XEN_SYSCTL_INTERFACE_VERSION )return -EACCES ; - ret =xsm_sysctl (XSM_PRIV , op->cmd); + ret =xsm_sysctl (XSM_OTHER , op->cmd);if ( ret )return ret;
xen/include/xsm/dummy.h +8 -2
@@ -181,8 +181,14 @@ static XSM_INLINE int cf_check xsm_domctl( static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +XSM_ASSERT_ACTION (XSM_OTHER ); +switch ( cmd ) + { +case XEN_SYSCTL_getdomaininfolist: +return xsm_default_action (XSM_XS_PRIV , current->domain,NULL ); +default : +return xsm_default_action (XSM_PRIV , current->domain,NULL ); + } } static XSM_INLINE int cf_check xsm_readconsole(XSM_DEFAULT_ARG uint32_t clear)
Signature · 1 line
2.48.1
Re: [PATCH 13/23] xsm/dummy: Allow XS_PRIV XEN_SYSCTL_getdomaininfolist
Quoted 7 lines · Jason Andryuk
To hyperlaunch xenstore, we want it to automatically introduce all domains it finds while initializing. To do that, change
xsm_sysctlto allowXS_PRIVto callXEN_SYSCTL_getdomaininfolist.Xenstore can already call
XEN_DOMCTL_getdomaininfofor the same information, but it requires knowing the domid.XEN_SYSCTL_getdomaininfolisteliminates the need to guess domains.
Yet then - is it a good idea to make such changes here for the sake of a new feature? If existing Xenstore was enhanced to use this, I'd find it easier to accept the change. Otherwise can't the hyperlaunched Xenstore behave like the "normal" one, not needing the change here to be made?
Jan
Re: [PATCH 13/23] xsm/dummy: Allow XS_PRIV XEN_SYSCTL_getdomaininfolist
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Jason Andryuk
To hyperlaunch xenstore, we want it to automatically introduce all domains it finds while initializing. To do that, change
xsm_sysctlto allowXS_PRIVto callXEN_SYSCTL_getdomaininfolist.
Quoted 8 lines
Quoted 3 lines
Xenstore can already call
XEN_DOMCTL_getdomaininfofor the same information, but it requires knowing the domid.XEN_SYSCTL_getdomaininfolisteliminates the need to guess domains.Yet then - is it a good idea to make such changes here for the sake of a new feature? If existing Xenstore was enhanced to use this, I'd find it easier to accept the change. Otherwise can't the hyperlaunched Xenstore behave like the "normal" one, not needing the change here to be made?
Sorry, the description is a lacking. It was originally written for xenstore stubdom, but I pulled it over for this dom0less work. With a combined xenstore & hardware domain, and running init-dom0less, it was a needed permission.
In light of Juergen's libxenmanage work, this may not longer by applicable for xenstore stubdom. And I'll re-evaluate with dom0less side re-work.
Thanks,
Jason
PATCH 14/23 xsm/dummy: Allow XS_PRIV to call get_hvm_param
In reply to Jason AndryukThis is useful for a combined hardware/xenstore domain that will run init-dom0less and xenstored. init-dom0less calls xc_hvm_param_get() to retrieve the xenstore event channel and pfn to configure xenstore for a guest. With a hypervisor-allocated event channel and page, the set_hvm_param is not needed, and the normal domid permissions will allow xenstored to connect.
Similarly, a hyperlaunch-ed xenstore stubdom needs to read a domain's xenstore event channel out of hvm_param.
This allows reading but not modifying the guest, so allow the permission.
--- xen/arch/arm/hvm.c | 2 +- xen/arch/x86/hvm/hvm.c | 8 ++++---- xen/include/xsm/dummy.h | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 7 deletions(-)
xen/arch/arm/hvm.c +1 -1
@@ -89,7 +89,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( d ==NULL )return -ESRCH ; - rc =xsm_hvm_param (XSM_TARGET , d, op); + rc =xsm_hvm_param (XSM_OTHER , d, op);if ( rc ) goto param_fail;
xen/arch/x86/hvm/hvm.c +4 -4
@@ -4177,7 +4177,7 @@ static int hvm_allow_set_param(struct domain *d,uint64_t value;int rc; - rc =xsm_hvm_param (XSM_TARGET , d, HVMOP_set_param); + rc =xsm_hvm_param (XSM_OTHER , d, HVMOP_set_param);if ( rc )return rc;
@@ -4458,7 +4458,7 @@ static int hvm_allow_get_param(struct domain *d, {int rc; - rc =xsm_hvm_param (XSM_TARGET , d, HVMOP_get_param); + rc =xsm_hvm_param (XSM_OTHER , d, HVMOP_get_param);if ( rc )return rc;
@@ -5055,7 +5055,7 @@ static int hvmop_get_mem_type(if ( d ==NULL )return -ESRCH ; - rc =xsm_hvm_param (XSM_TARGET , d, HVMOP_get_mem_type); + rc =xsm_hvm_param (XSM_OTHER , d, HVMOP_get_mem_type);if ( rc ) goto out;
@@ -5148,7 +5148,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)if (unlikely (d != current->domain) ) rc = -EOPNOTSUPP ;else if (is_hvm_domain (d) &&paging_mode_shadow (d) ) - rc =xsm_hvm_param (XSM_TARGET , d, op); + rc =xsm_hvm_param (XSM_OTHER , d, op);if ( !rc )pagetable_dying (a.gpa);
xen/include/xsm/dummy.h +12 -2
@@ -614,8 +614,18 @@ static XSM_INLINE int cf_check xsm_map_gmfn_foreign( static XSM_INLINE int cf_check xsm_hvm_param( XSM_DEFAULT_ARG struct domain *d, unsigned long op) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, current->domain, d); +XSM_ASSERT_ACTION (XSM_OTHER ); +switch ( op ) + { +case HVMOP_get_param: +/* A domain can query itself, or a DM can query its target. */ +if ( !xsm_default_action (XSM_TARGET , current->domain, d) ) +return 0 ; +/* Xenstore domain needs to be able to query for mapping. */ +return xsm_default_action (XSM_XS_PRIV , current->domain, d); +default : +return xsm_default_action (XSM_TARGET , current->domain, d); + } } static XSM_INLINE int cf_check xsm_hvm_param_altp2mhvm(
Signature · 1 line
2.48.1
Re: [PATCH 14/23] xsm/dummy: Allow XS_PRIV to call get_hvm_param
Quoted 7 lines · Jason Andryuk
This is useful for a combined hardware/xenstore domain that will run init-dom0less and xenstored. init-dom0less calls
xc_hvm_param_get()to retrieve the xenstore event channel and pfn to configure xenstore for a guest. With a hypervisor-allocated event channel and page, theset_hvm_paramis not needed, and the normal domid permissions will allow xenstored to connect.
Quoted 6 lines
Similarly, a hyperlaunch-ed xenstore stubdom needs to read a domain's xenstore event channel out of
hvm_param.This allows reading but not modifying the guest, so allow the permission.
Signed-off-by Jason Andryuk <[email protected]>
Since this is exposing the entire param space to Xenstore, what I'm missing is a security discussion for existing as well as potential future params. There could well be some that better wouldn't be available for Xenstrore to fetch.
Jan
Re: [PATCH 14/23] xsm/dummy: Allow XS_PRIV to call get_hvm_param
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Jason Andryuk
This is useful for a combined hardware/xenstore domain that will run init-dom0less and xenstored. init-dom0less calls
xc_hvm_param_get()to retrieve the xenstore event channel and pfn to configure xenstore for a guest. With a hypervisor-allocated event channel and page, theset_hvm_paramis not needed, and the normal domid permissions will allow xenstored to connect.Similarly, a hyperlaunch-ed xenstore stubdom needs to read a domain's xenstore event channel out of
hvm_param.
Quoted 8 lines
Quoted 3 lines
This allows reading but not modifying the guest, so allow the permission.
Signed-off-by Jason Andryuk <[email protected]>Since this is exposing the entire param space to Xenstore, what I'm missing is a security discussion for existing as well as potential future params. There could well be some that better wouldn't be available for Xenstrore to fetch.
I can't speak for future parameters, but existing HVM_PARAMs didn't seem sensitive to me. The safest choice is to just pass the index to xsm_hvm_param() and allow just HVM_PARAM_STORE_EVTCHN (and HVM_PARAM_STORE_PFN) for the xenstore domain.
This works for ARM and x86 HVM/PVH. PV doesn't have a way to determine a domain's event channel port, FWICT.
Regards,
Jason
Re: [PATCH 14/23] xsm/dummy: Allow XS_PRIV to call get_hvm_param
Quoted 16 lines · Jason Andryuk
Quoted 15 lines · Jan Beulich
Quoted 13 lines · Jason Andryuk
This is useful for a combined hardware/xenstore domain that will run init-dom0less and xenstored. init-dom0less calls
xc_hvm_param_get()to retrieve the xenstore event channel and pfn to configure xenstore for a guest. With a hypervisor-allocated event channel and page, theset_hvm_paramis not needed, and the normal domid permissions will allow xenstored to connect.Similarly, a hyperlaunch-ed xenstore stubdom needs to read a domain's xenstore event channel out of
hvm_param.This allows reading but not modifying the guest, so allow the permission.
Signed-off-by Jason Andryuk <[email protected]>
Quoted 8 lines
Quoted 4 lines
Since this is exposing the entire param space to Xenstore, what I'm missing is a security discussion for existing as well as potential future params. There could well be some that better wouldn't be available for Xenstrore to fetch.
I can't speak for future parameters, but existing
HVM_PARAMsdidn't seem sensitive to me. The safest choice is to just pass the index toxsm_hvm_param()and allow justHVM_PARAM_STORE_EVTCHN(andHVM_PARAM_STORE_PFN) for the xenstore domain.This works for ARM and x86 HVM/PVH. PV doesn't have a way to determine a domain's event channel port, FWICT.
For what are you needing HVM_PARAM_STORE_PFN? The GNTTAB_RESERVED_XENSTORE grant id should be enough to map the guest's Xenstore page?
And with that I'd rather suggest to expand struct xenstore_domain_interface with the event channel port and let the component doing the seeding of the grant table write the port into the struct.
This would enable Xenstore to just map the guest's Xenstore page and read the event channel port from it. No additional hypercall permission needed. And this would even work with PV domains. And as the Xenstore page is zeroed initially, any event channel port != 0 could be regarded to be valid (a guest choosing to write a bogus value there would just shoot itself in the foot by harming its own Xenstore connection).
Juergen
Re: [PATCH 14/23] xsm/dummy: Allow XS_PRIV to call get_hvm_param
Quoted 22 lines · Juergen Gross
Quoted 21 lines · Jason Andryuk
Quoted 19 lines · Jan Beulich
Quoted 7 lines · Jason Andryuk
This is useful for a combined hardware/xenstore domain that will run init-dom0less and xenstored. init-dom0less calls
xc_hvm_param_get()to retrieve the xenstore event channel and pfn to configure xenstore for a guest. With a hypervisor-allocated event channel and page, theset_hvm_paramis not needed, and the normal domid permissions will allow xenstored to connect.Quoted 6 lines
Similarly, a hyperlaunch-ed xenstore stubdom needs to read a domain's xenstore event channel out of
hvm_param.This allows reading but not modifying the guest, so allow the permission.
Signed-off-by Jason Andryuk <[email protected]>Since this is exposing the entire param space to Xenstore, what I'm missing is a security discussion for existing as well as potential future params. There could well be some that better wouldn't be available for Xenstrore to fetch.
Quoted 6 lines
Quoted 3 lines
I can't speak for future parameters, but existing
HVM_PARAMsdidn't seem sensitive to me. The safest choice is to just pass the index toxsm_hvm_param()and allow justHVM_PARAM_STORE_EVTCHN(andHVM_PARAM_STORE_PFN) for the xenstore domain.This works for ARM and x86 HVM/PVH. PV doesn't have a way to determine a domain's event channel port, FWICT.
For what are you needing
HVM_PARAM_STORE_PFN? TheGNTTAB_RESERVED_XENSTOREgrant id should be enough to map the guest's Xenstore page?
Indeed, HVM_PARAM_STORE_PFN is not needed and I expect only using GNTTAB_RESERVED_XENSTORE to map the grant. I just listed it as a compliment to the event channel.
Quoted 10 lines
And with that I'd rather suggest to expand struct
xenstore_domain_interfacewith the event channel port and let the component doing the seeding of the grant table write the port into the struct.This would enable Xenstore to just map the guest's Xenstore page and read the event channel port from it. No additional hypercall permission needed. And this would even work with PV domains. And as the Xenstore page is zeroed initially, any event channel port != 0 could be regarded to be valid (a guest choosing to write a bogus value there would just shoot itself in the foot by harming its own Xenstore connection).
Yes, that is a good idea. I had also considered defining a reserved event channel for xenstore, but wasn't sure how that would be received. I like this better.
Thanks,
Jason
PATCH 15/23 xen/xsm: Add XSM_HW_PRIV
In reply to Jason AndryukXen includes disctinct concepts of a control domain (privileged) and a hardware domain, but there is only a single XSM_PRIV check. For dom0 this is not an issue as they are one and the same.
With hyperlaunch and its build capabiliies, a non-privileged hwdom and a privileged control domain should be possible. Today the hwdom fails the XSM_PRIV checks for hardware-related hooks which it should be allowed access to.
Introduce XSM_HW_PRIV, and use it to mark many of the physdev_op and platform_op.
Previously, xsm_default_action() was almost linearly increasing in permissions with its fallthroughs. When it gets to XSM_PRIV, all permissions were allowed for the control domain. That needs to change so the control domain cannot access XSM_HW_PRIV.
The hwdom is allowed access for XSM_HW_PRIV and XSM_DM_PRIV. The hardware domain providing a device model for a domU is an expected use case, so those permission are needed as well.
Testing was performed with hardware+xenstore capabilities for dom0 and a control dom3 booted from hyperlaunch. The additional xenstore permissions allowed hwdom+xenstore XSM_XS_PRIV which are necesary for xenstore.
A traditional dom0 will be both privileged and hardware domain, so it continues to have all accesses.
Why not XSM:Flask? XSM:Flask is fine grain, and this aims to allow coarse grain. domUs are still domUs. If capabilities are meant to be a first class citizen, they should be usable by the default XSM policy.
--- xen/arch/arm/platform_hypercall.c | 2 +- xen/arch/x86/msi.c | 2 +- xen/arch/x86/physdev.c | 12 ++++++------ xen/arch/x86/platform_hypercall.c | 2 +- xen/drivers/passthrough/pci.c | 5 +++-- xen/drivers/pci/physdev.c | 2 +- xen/include/xsm/dummy.h | 22 +++++++++++++--------- xen/include/xsm/xsm.h | 1 + 8 files changed, 27 insertions(+), 21 deletions(-)
xen/arch/arm/platform_hypercall.c +1 -1
@@ -35,7 +35,7 @@ long do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)if ( d ==NULL )return -ESRCH ; - ret =xsm_platform_op (XSM_PRIV , op->cmd); + ret =xsm_platform_op (XSM_HW_PRIV , op->cmd);if ( ret )return ret;
xen/arch/x86/msi.c +1 -1
@@ -1355,7 +1355,7 @@ int pci_restore_msi_state(struct pci_dev *pdev)if ( !use_msi )return -EOPNOTSUPP ; - ret =xsm_resource_setup_pci (XSM_PRIV , + ret =xsm_resource_setup_pci (XSM_HW_PRIV , (pdev->seg <<16 ) | (pdev->bus <<8 ) | pdev->devfn);if ( ret )
xen/arch/x86/physdev.c +6 -6
@@ -358,7 +358,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) ret = -EFAULT ;if (copy_from_guest (&apic, arg,1 ) !=0 )break ; - ret =xsm_apic (XSM_PRIV , currd, cmd); + ret =xsm_apic (XSM_HW_PRIV , currd, cmd);if ( ret )break ; ret =ioapic_guest_read (apic.apic_physbase, apic.reg, &apic.value);
@@ -372,7 +372,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) ret = -EFAULT ;if (copy_from_guest (&apic, arg,1 ) !=0 )break ; - ret =xsm_apic (XSM_PRIV , currd, cmd); + ret =xsm_apic (XSM_HW_PRIV , currd, cmd);if ( ret )break ; ret =ioapic_guest_write (apic.apic_physbase, apic.reg, apic.value);
@@ -388,7 +388,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)/* Use the APIC check since this dummy hypercall should still only * be called by the domain with access to program the ioapic */ - ret =xsm_apic (XSM_PRIV , currd, cmd); + ret =xsm_apic (XSM_HW_PRIV , currd, cmd);if ( ret )break ;
@@ -490,7 +490,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&dev, arg,1 ) ) ret = -EFAULT ;else - ret =xsm_resource_setup_pci (XSM_PRIV , + ret =xsm_resource_setup_pci (XSM_HW_PRIV , (dev.seg <<16 ) | (dev.bus <<8 ) | dev.devfn) ?: pci_prepare_msix(dev.seg, dev.bus, dev.devfn,
@@ -501,7 +501,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)case PHYSDEVOP_pci_mmcfg_reserved: {struct physdev_pci_mmcfg_reserved info; - ret =xsm_resource_setup_misc (XSM_PRIV ); + ret =xsm_resource_setup_misc (XSM_HW_PRIV );if ( ret )break ;
@@ -567,7 +567,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if ( setup_gsi.gsi <0 || setup_gsi.gsi >= nr_irqs_gsi )break ; - ret =xsm_resource_setup_gsi (XSM_PRIV , setup_gsi.gsi); + ret =xsm_resource_setup_gsi (XSM_HW_PRIV , setup_gsi.gsi);if ( ret )break ;
xen/arch/x86/platform_hypercall.c +1 -1
@@ -228,7 +228,7 @@ ret_t do_platform_op(if ( op->interface_version !=XENPF_INTERFACE_VERSION )return -EACCES ; - ret =xsm_platform_op (XSM_PRIV , op->cmd); + ret =xsm_platform_op (XSM_HW_PRIV , op->cmd);if ( ret )return ret;
xen/drivers/passthrough/pci.c +3 -2
@@ -678,7 +678,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,else type ="device" ; - ret =xsm_resource_plug_pci (XSM_PRIV , (seg <<16 ) | (bus <<8 ) | devfn); + ret =xsm_resource_plug_pci (XSM_HW_PRIV , (seg <<16 ) | (bus <<8 ) | devfn);if ( ret )return ret;
@@ -830,7 +830,8 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)struct pci_dev *pdev;int ret; - ret =xsm_resource_unplug_pci (XSM_PRIV , (seg <<16 ) | (bus <<8 ) | devfn); + ret =xsm_resource_unplug_pci (XSM_HW_PRIV , + (seg <<16 ) | (bus <<8 ) | devfn);if ( ret )return ret;
xen/drivers/pci/physdev.c +1 -1
@@ -86,7 +86,7 @@ ret_t pci_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) dev_reset.dev.bus, dev_reset.dev.devfn); - ret =xsm_resource_setup_pci (XSM_PRIV , sbdf.sbdf); + ret =xsm_resource_setup_pci (XSM_HW_PRIV , sbdf.sbdf);if ( ret )break ;
xen/include/xsm/dummy.h +13 -9
@@ -95,7 +95,11 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_PRIV : -if (is_control_domain (src) ) +case XSM_HW_PRIV : +if (is_control_domain (src) && action !=XSM_HW_PRIV ) +return 0 ; +if (is_hardware_domain (src) && + (action ==XSM_HW_PRIV || action ==XSM_DM_PRIV ) )return 0 ;return -EPERM ;default :
@@ -280,7 +284,7 @@ static XSM_INLINE int cf_check xsm_console_io(if ( cmd == CONSOLEIO_write )return xsm_default_action (XSM_HOOK , d,NULL );#endif -return xsm_default_action (XSM_PRIV , d,NULL ); +return xsm_default_action (XSM_HW_PRIV , d,NULL ); } static XSM_INLINE int cf_check xsm_profile(
@@ -460,33 +464,33 @@ static XSM_INLINE int cf_check xsm_resource_unplug_core(XSM_DEFAULT_VOID) static XSM_INLINE int cf_check xsm_resource_plug_pci( XSM_DEFAULT_ARG uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_PRIV ); +XSM_ASSERT_ACTION (XSM_HW_PRIV );return xsm_default_action (action, current->domain,NULL ); } static XSM_INLINE int cf_check xsm_resource_unplug_pci( XSM_DEFAULT_ARG uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_PRIV ); +XSM_ASSERT_ACTION (XSM_HW_PRIV );return xsm_default_action (action, current->domain,NULL ); } static XSM_INLINE int cf_check xsm_resource_setup_pci( XSM_DEFAULT_ARG uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_PRIV ); +XSM_ASSERT_ACTION (XSM_HW_PRIV );return xsm_default_action (action, current->domain,NULL ); } static XSM_INLINE int cf_check xsm_resource_setup_gsi(XSM_DEFAULT_ARG int gsi) { -XSM_ASSERT_ACTION (XSM_PRIV ); +XSM_ASSERT_ACTION (XSM_HW_PRIV );return xsm_default_action (action, current->domain,NULL ); } static XSM_INLINE int cf_check xsm_resource_setup_misc(XSM_DEFAULT_VOID) { -XSM_ASSERT_ACTION (XSM_PRIV ); +XSM_ASSERT_ACTION (XSM_HW_PRIV );return xsm_default_action (action, current->domain,NULL ); }
@@ -688,7 +692,7 @@ static XSM_INLINE int cf_check xsm_mem_sharing(XSM_DEFAULT_ARG struct domain *d) static XSM_INLINE int cf_check xsm_platform_op(XSM_DEFAULT_ARG uint32_t op) { -XSM_ASSERT_ACTION (XSM_PRIV ); +XSM_ASSERT_ACTION (XSM_HW_PRIV );return xsm_default_action (action, current->domain,NULL ); }
@@ -716,7 +720,7 @@ static XSM_INLINE int cf_check xsm_mem_sharing_op( static XSM_INLINE int cf_check xsm_apic( XSM_DEFAULT_ARG struct domain *d, int cmd) { -XSM_ASSERT_ACTION (XSM_PRIV ); +XSM_ASSERT_ACTION (XSM_HW_PRIV );return xsm_default_action (action, d,NULL ); }
xen/include/xsm/xsm.h +1 -0
@@ -36,6 +36,7 @@ enum xsm_default {XSM_DM_PRIV ,/* Device model can perform on its target domain */ XSM_TARGET ,/* Can perform on self or your target domain */ XSM_PRIV ,/* Privileged - normally restricted to dom0 */ +XSM_HW_PRIV ,/* Hardware Privileged - normally restricted to dom0/hwdom */ XSM_XS_PRIV ,/* Xenstore domain - can do some privileged operations */ XSM_OTHER /* Something more complex */ };
Signature · 1 line
2.48.1
Re: [PATCH 15/23] xen/xsm: Add XSM_HW_PRIV
Quoted 4 lines · Jason Andryuk
xen/include/xsm/dummy.h +0
-0@@ -95,7 +95,11 @@ static always_inline int xsm_default_action(return 0 ;
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 104
Quoted 10 lines
xen/include/xsm/dummy.h +5
-1fallthrough;case XSM_PRIV : -if (is_control_domain (src) ) +case XSM_HW_PRIV : +if (is_control_domain (src) && action !=XSM_HW_PRIV ) +return 0 ; +if (is_hardware_domain (src) && + (action ==XSM_HW_PRIV || action ==XSM_DM_PRIV ) )return 0 ;return -EPERM ;
Hmm. Isn't DM_PRIV a property applying to the control domain (besides any stub domains), but not the hardware one?
Jan
Re: [PATCH 15/23] xen/xsm: Add XSM_HW_PRIV
Quoted 10 lines · Jan Beulich
Quoted 9 lines · Jason Andryuk
xen/include/xsm/dummy.h +2
-1@@ -95,7 +95,11 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_PRIV : -if (is_control_domain (src) ) +case XSM_HW_PRIV : +if (is_control_domain (src) && action !=XSM_HW_PRIV )
Quoted 8 lines
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 104
Quoted 5 lines
xen/include/xsm/dummy.h +3
-0+return 0 ; +if (is_hardware_domain (src) && + (action ==XSM_HW_PRIV || action ==XSM_DM_PRIV ) )return 0 ;return -EPERM ;Hmm. Isn't
DM_PRIVa property applying to the control domain (besides any stub domains), but not the hardware one?
I ran QEMU in hardware domain to provide devices to a domU. I thought QEMU would better run in hardware domain than control domain.
Regards,
Jason
Re: [PATCH 15/23] xen/xsm: Add XSM_HW_PRIV
Quoted 20 lines · Jason Andryuk
Quoted 10 lines · Jan Beulich
Quoted 9 lines · Jason Andryuk
xen/include/xsm/dummy.h +2
-1@@ -95,7 +95,11 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_PRIV : -if (is_control_domain (src) ) +case XSM_HW_PRIV : +if (is_control_domain (src) && action !=XSM_HW_PRIV )Quoted 8 lines
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 104
Quoted 5 lines
xen/include/xsm/dummy.h +3
-0+return 0 ; +if (is_hardware_domain (src) && + (action ==XSM_HW_PRIV || action ==XSM_DM_PRIV ) )return 0 ;return -EPERM ;Hmm. Isn't
DM_PRIVa property applying to the control domain (besides any stub domains), but not the hardware one?
Quoted 2 lines
I ran QEMU in hardware domain to provide devices to a domU. I thought QEMU would better run in hardware domain than control domain.
Leaving stubdoms aside, QEMU has to run in the hardware domain because the hardware domain is less privileged. QEMU can be attacked or affected by the guest so it is undesirable to run QEMU in the control domain which is highly privileged, and considered highly secure / safe.
Re: [PATCH 15/23] xen/xsm: Add XSM_HW_PRIV
Quoted 21 lines · Stefano Stabellini
Quoted 20 lines · Jason Andryuk
Quoted 18 lines · Jan Beulich
Quoted 4 lines · Jason Andryuk
xen/include/xsm/dummy.h +0
-0@@ -95,7 +95,11 @@ static always_inline int xsm_default_action(return 0 ;xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 104
Quoted 10 lines
xen/include/xsm/dummy.h +5
-1fallthrough;case XSM_PRIV : -if (is_control_domain (src) ) +case XSM_HW_PRIV : +if (is_control_domain (src) && action !=XSM_HW_PRIV ) +return 0 ; +if (is_hardware_domain (src) && + (action ==XSM_HW_PRIV || action ==XSM_DM_PRIV ) )return 0 ;return -EPERM ;Hmm. Isn't
DM_PRIVa property applying to the control domain (besides any stub domains), but not the hardware one?
Quoted 7 lines
Quoted 2 lines
I ran QEMU in hardware domain to provide devices to a domU. I thought QEMU would better run in hardware domain than control domain.
Leaving stubdoms aside, QEMU has to run in the hardware domain because the hardware domain is less privileged. QEMU can be attacked or affected by the guest so it is undesirable to run QEMU in the control domain which is highly privileged, and considered highly secure / safe.
Yet having access to the hardware, hwdom can likely also do about anything to the system. IOW I'd consider this "highly privileged" too, just not from a pure software perspective. If you want a secure / safe environment, I fear you won't get around using further (stub?) domain(s) to run qemu in.
Jan
Re: [PATCH 15/23] xen/xsm: Add XSM_HW_PRIV
Quoted 30 lines · Jan Beulich
Quoted 21 lines · Stefano Stabellini
Quoted 20 lines · Jason Andryuk
Quoted 18 lines · Jan Beulich
Quoted 4 lines · Jason Andryuk
xen/include/xsm/dummy.h +0
-0@@ -95,7 +95,11 @@ static always_inline int xsm_default_action(return 0 ;xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 104
Quoted 10 lines
xen/include/xsm/dummy.h +5
-1fallthrough;case XSM_PRIV : -if (is_control_domain (src) ) +case XSM_HW_PRIV : +if (is_control_domain (src) && action !=XSM_HW_PRIV ) +return 0 ; +if (is_hardware_domain (src) && + (action ==XSM_HW_PRIV || action ==XSM_DM_PRIV ) )return 0 ;return -EPERM ;Hmm. Isn't
DM_PRIVa property applying to the control domain (besides any stub domains), but not the hardware one?Quoted 7 lines
Quoted 2 lines
I ran QEMU in hardware domain to provide devices to a domU. I thought QEMU would better run in hardware domain than control domain.
Leaving stubdoms aside, QEMU has to run in the hardware domain because the hardware domain is less privileged. QEMU can be attacked or affected by the guest so it is undesirable to run QEMU in the control domain which is highly privileged, and considered highly secure / safe.
Quoted 4 lines
Yet having access to the hardware, hwdom can likely also do about anything to the system. IOW I'd consider this "highly privileged" too, just not from a pure software perspective. If you want a secure / safe environment, I fear you won't get around using further (stub?) domain(s) to run qemu in.
Traditionally, from an upstream Xen Project perspective, it is important to support as many hardware platforms as possible. The goal is to provide the best possible out-of-the-box experience, including support for devices like the Raspberry Pi 4 (RPi4), which has certain quirks and limited IOMMU support.
However, when considering safety (similar concepts also apply to security) it is necessary to write down assumptions. One key assumption is that the system includes an IOMMU and that all DMA-capable devices are protected by it.
There are boards, such as the RPi4, that do not meet these assumptions. While Xen can and should run on such hardware, the level of flexibility in configuring safe environments on these boards will be limited.
For example, on the RPi4, I would not recommend to run QEMU in an unsafe hardware domaini because the hardware domain will end up having control over unprotected DMA-capable devices that can be used to harm the system. However, it will be possible to run QEMU in an unsafe hardware domains on platforms were all DMA-capable devices that can harm the system are IOMMU protected, such as Xilinx MPSoC when configured correctly.
PATCH 16/23 xsm/dummy: Allow hwdom xen_version
In reply to Jason AndryukRunning xl queries XENVER_commandline and XENVER_build_id. The hardware domain should have access to the command line. The hardware domain is at least semi-trusted - just allow it access to all the xen_version info.
--- xen/include/xsm/dummy.h | 2 ++ 1 file changed, 2 insertions(+)
xen/include/xsm/dummy.h +2 -0
@@ -859,6 +859,8 @@ static XSM_INLINE int cf_check xsm_xen_version(XSM_DEFAULT_ARG uint32_t op)/* These MUST always be accessible to any guest by default. */ return xsm_default_action (XSM_HOOK , current->domain,NULL );default : +if (is_hardware_domain (current->domain) ) +return xsm_default_action (XSM_HW_PRIV , current->domain,NULL );return xsm_default_action (XSM_PRIV , current->domain,NULL ); } }
Signature · 1 line
2.48.1
Re: [PATCH 16/23] xsm/dummy: Allow hwdom xen_version
Quoted 2 lines · Jason Andryuk
Running xl queries
XENVER_commandlineandXENVER_build_id. The hardware domain should have access to the command line.
And that's because of?
Quoted 3 lines
The hardware domain is
at least semi-trusted - just allow it access to all thexen_versioninfo.
I'm unconvinced.
Jan
PATCH 17/23 xsm/dummy: Allow hwdom more - except targeting control
In reply to Jason AndryukAllow hwdom all perms, except XSM_PRIV, and except commands where the target is the control domain. This protects the control domain from hwdom while allowing the hardware domain to serve as the backend and device model for other domUs.
--- xen/include/xsm/dummy.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
xen/include/xsm/dummy.h +5 -2
@@ -98,9 +98,12 @@ static always_inline int xsm_default_action(case XSM_HW_PRIV :if (is_control_domain (src) && action !=XSM_HW_PRIV )return 0 ; -if (is_hardware_domain (src) && - (action ==XSM_HW_PRIV || action ==XSM_DM_PRIV ) ) +if (is_hardware_domain (src) && action !=XSM_PRIV ) + { +if ( target &&is_control_domain (target) ) +return -EPERM ;return 0 ; + }return -EPERM ;default :LINKER_BUG_ON (1 );
Signature · 1 line
2.48.1
Re: [PATCH 17/23] xsm/dummy: Allow hwdom more - except targeting control
Quoted 4 lines · Jason Andryuk
Allow hwdom all perms, except
XSM_PRIV, and except commands where the target is the control domain. This protects the control domain from hwdom while allowing the hardware domain to serve as the backend and device model for other domUs.
I can see why backends may need to live there. But device models don't belong in the hardware domain, do they?
Jan
Re: [PATCH 17/23] xsm/dummy: Allow hwdom more - except targeting control
Quoted 8 lines · Jan Beulich
Quoted 4 lines · Jason Andryuk
Allow hwdom all perms, except
XSM_PRIV, and except commands where the target is the control domain. This protects the control domain from hwdom while allowing the hardware domain to serve as the backend and device model for other domUs.I can see why backends may need to live there. But device models don't belong in the hardware domain, do they?
One of my tests was on x86 with hardware domain running QEMU providing virtio-gpu to a domU. QEMU needs to access the GPU for virtio-gpu. Also HVM/QEMU PCI passthrough would need to run from hardware domain. for the config space access.
I viewed the hardware domain as the place to run the device model - sort of like a stubdom moving out of dom0.
Regards,
Jason
Re: [PATCH 17/23] xsm/dummy: Allow hwdom more - except targeting control
Quoted 10 lines · Jason Andryuk
Quoted 8 lines · Jan Beulich
Quoted 4 lines · Jason Andryuk
Allow hwdom all perms, except
XSM_PRIV, and except commands where the target is the control domain. This protects the control domain from hwdom while allowing the hardware domain to serve as the backend and device model for other domUs.I can see why backends may need to live there. But device models don't belong in the hardware domain, do they?
Quoted 7 lines
One of my tests was on x86 with hardware domain running QEMU providing virtio-gpu to a domU. QEMU needs to access the GPU for virtio-gpu. Also HVM/QEMU PCI passthrough would need to run from hardware domain. for the config space access.
I viewed the hardware domain as the place to run the device model - sort of like a stubdom moving out of dom0.
Hmm, yes, when dealing with hardware made accessible to a guest, the DM would need to live in hwdom (in the absence of stubdom-s). For non-pass- through guests that's less clear though.
Jan
Re: [PATCH 17/23] xsm/dummy: Allow hwdom more - except targeting control
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Jason Andryuk
Quoted 8 lines · Jan Beulich
Quoted 4 lines · Jason Andryuk
Allow hwdom all perms, except
XSM_PRIV, and except commands where the target is the control domain. This protects the control domain from hwdom while allowing the hardware domain to serve as the backend and device model for other domUs.I can see why backends may need to live there. But device models don't belong in the hardware domain, do they?
One of my tests was on x86 with hardware domain running QEMU providing virtio-gpu to a domU. QEMU needs to access the GPU for virtio-gpu. Also HVM/QEMU PCI passthrough would need to run from hardware domain. for the config space access.
Quoted 6 lines
Quoted 2 lines
I viewed the hardware domain as the place to run the device model - sort of like a stubdom moving out of dom0.
Hmm, yes, when dealing with hardware made accessible to a guest, the DM would need to live in hwdom (in the absence of stubdom-s). For non-pass- through guests that's less clear though.
So perhaps I'm in (conceptual) trouble with this kind of dis-aggregation:
To split ctrldom from hwdom without moving DMs to stubdom-s feels a little "incomplete" to me.
Jan
PATCH 18/23 xsm/dummy: Allow hwdom SYSCTL_readconsole/physinfo
In reply to Jason AndryukAllow the hwdom to access the console, and to access physical information about the system.
--- xen/include/xsm/dummy.h | 3 +++ 1 file changed, 3 insertions(+)
xen/include/xsm/dummy.h +3 -0
@@ -193,6 +193,9 @@ static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd) {case XEN_SYSCTL_getdomaininfolist:return xsm_default_action (XSM_XS_PRIV , current->domain,NULL ); +case XEN_SYSCTL_readconsole: +case XEN_SYSCTL_physinfo: +return xsm_default_action (XSM_HW_PRIV , current->domain,NULL );default :return xsm_default_action (XSM_PRIV , current->domain,NULL ); }
Signature · 1 line
2.48.1
PATCH 19/23 xsm/dummy: Allow sysctls to both hardware and control
In reply to Jason Andryukxl queries SYSCTL_physinfo for the physical cpus:
domU:~# xl list libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus Name ID Mem VCPUs State Time(s) Domain-0 0 800 1 r----- 130.0 dom0less-1 1 400 1 r----- 130.3 dom0less-2 2 800 1 r----- 130.3
Hardware and control are both privileged. Allow them both access to sysctls so they have insight into the running system. This is coarse grained permissions for the dummy policy.
Now the only sysctl denied to a control domain is readconsole.
---
Could just allow physinfo to control as an alternative. There could be follow on sysctls needed in that case.
--- xen/include/xsm/dummy.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/include/xsm/dummy.h +2 -1
@@ -194,9 +194,10 @@ static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd)case XEN_SYSCTL_getdomaininfolist:return xsm_default_action (XSM_XS_PRIV , current->domain,NULL );case XEN_SYSCTL_readconsole: -case XEN_SYSCTL_physinfo:return xsm_default_action (XSM_HW_PRIV , current->domain,NULL );default : +if (is_hardware_domain (current->domain) ) +return xsm_default_action (XSM_HW_PRIV , current->domain,NULL );return xsm_default_action (XSM_PRIV , current->domain,NULL ); } }
Signature · 1 line
2.48.1
Re: [PATCH 19/23] xsm/dummy: Allow sysctls to both hardware and control
Quoted 10 lines · Jason Andryuk
xl queries
SYSCTL_physinfofor the physical cpus:domU:~# xl list libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus Name ID Mem VCPUs State Time(s) Domain-0 0 800 1 r----- 130.0 dom0less-1 1 400 1 r----- 130.3 dom0less-2 2 800 1 r----- 130.3
Quoted 3 lines
Hardware and control are both privileged. Allow them both access to sysctls so they have insight into the running system. This is coarse grained permissions for the dummy policy.
In an earlier patch you alluded to the control domain being guarded against the hardware one. Shouldn't hwdom be limited operations retrieving info, but refused to make any changes to the system? Or maybe some kinds of changes are to be done by hwdom, but then shouldn't be possible to be made by the control domain?
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd) · line 197
Quoted 7 lines
xen/include/xsm/dummy.h +0
-1@@ -194,9 +194,10 @@ static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd)case XEN_SYSCTL_getdomaininfolist:return xsm_default_action (XSM_XS_PRIV , current->domain,NULL );case XEN_SYSCTL_readconsole: -case XEN_SYSCTL_physinfo:
Didn't you add this line just a single patch ago?
Jan
Quoted 7 lines
xen/include/xsm/dummy.h +2
-0return xsm_default_action (XSM_HW_PRIV , current->domain,NULL );default : +if (is_hardware_domain (current->domain) ) +return xsm_default_action (XSM_HW_PRIV , current->domain,NULL );return xsm_default_action (XSM_PRIV , current->domain,NULL ); } }
Re: [PATCH 19/23] xsm/dummy: Allow sysctls to both hardware and control
Quoted 15 lines · Jan Beulich
Quoted 10 lines · Jason Andryuk
xl queries
SYSCTL_physinfofor the physical cpus:domU:~# xl list libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus libxl: error: libxl_utils.c:817:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus Name ID Mem VCPUs State Time(s) Domain-0 0 800 1 r----- 130.0 dom0less-1 1 400 1 r----- 130.3 dom0less-2 2 800 1 r----- 130.3Quoted 3 lines
Hardware and control are both privileged. Allow them both access to sysctls so they have insight into the running system. This is coarse grained permissions for the dummy policy.
Quoted 5 lines
In an earlier patch you alluded to the control domain being guarded against the hardware one. Shouldn't hwdom be limited operations retrieving info, but refused to make any changes to the system? Or maybe some kinds of changes are to be done by hwdom, but then shouldn't be possible to be made by the control domain?
As an example, with ACPI living in the hardware_domain, it would be the domain to issue XEN_SYSCTL_pm_op to upload cpufreq data. But then control domain should be in charge of controlling how the system is running by setting cpufreq parameters.
Quoted 9 lines
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd) · line 197
Quoted 7 lines
xen/include/xsm/dummy.h +0
-1@@ -194,9 +194,10 @@ static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd)case XEN_SYSCTL_getdomaininfolist:return xsm_default_action (XSM_XS_PRIV , current->domain,NULL );case XEN_SYSCTL_readconsole: -case XEN_SYSCTL_physinfo:Didn't you add this line just a single patch ago?
Yes. The previous patch was a minimal change. This patch is a maximal change. I thought this could be rejected and didn't want to merge the two. Though XEN_SYSCTL_physinfo should be handled better even for the minimal change.
This patch may go too far, hardware domain does have legitimate use to some sysctls. For a coarse, base policy I went with allowing more to hardware domain. Hardware domain can't be untrusted, so I erred on the side of more permissions rather than fewer.
Regards,
Jason
PATCH 20/23 xsm/silo: Support hwdom/control domains
In reply to Jason AndryukThe is_control_domain() check is not sufficient for a split hardware/control domain. Add is_priv_domain() to support allowing for either control or hardware.
Without this, a xenstore/hardware domain is unable to map a domU's grants.
This silo check is for grants, events and argo. The dummy policy handles other calls, so hardware is prevented from foreign mapping control's memory with that.
This would need to be expanded for a standalone Xenstore domain.
--- xen/xsm/silo.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
xen/xsm/silo.c +7 -2
@@ -20,6 +20,11 @@#define XSM_NO_WRAPPERS #include <xsm/dummy.h> +static always_inline bool is_priv_domain(const struct domain *d) +{ +return is_control_domain (d) ||is_hardware_domain (d); +} +/* * Check if inter-domain communication is allowed. * Return true when pass check.
@@ -29,8 +34,8 @@ static bool silo_mode_dom_check(const struct domain *ldom, {const struct domain *currd = current->domain; -return (is_control_domain (currd) ||is_control_domain (ldom) || -is_control_domain (rdom) || ldom == rdom); +return (is_priv_domain (currd) ||is_priv_domain (ldom) || +is_priv_domain (rdom) || ldom == rdom); } static int cf_check silo_evtchn_unbound(
Signature · 1 line
2.48.1
Re: [PATCH 20/23] xsm/silo: Support hwdom/control domains
Quoted 7 lines · Jason Andryuk
The
is_control_domain()check is not sufficient for a split hardware/control domain. Addis_priv_domain()to support allowing for either control or hardware.Without this, a xenstore/hardware domain is unable to map a domU's grants.
Quoted 7 lines
This silo check is for grants, events and argo. The dummy policy handles other calls, so hardware is prevented from foreign mapping control's memory with that.
This would need to be expanded for a standalone Xenstore domain.
Signed-off-by Jason Andryuk <[email protected]>
I think what first needs spelling out is what the function of SILO is when it comes to specifically the control and hardware domains. Should the two be able to communicate? The answer isn't obviously "yes" imo. Yet if it isn't, ...
xen/xsm/silo.c line 23
Quoted 7 lines
xen/xsm/silo.c +1
-0@@ -20,6 +20,11 @@#define XSM_NO_WRAPPERS #include <xsm/dummy.h> +static always_inline bool is_priv_domain(const struct domain *d)
(Side note: I don't think always_inline is warranted here. Even inline we prefer to only put on functions defined in headers.)
Quoted 8 lines
xen/xsm/silo.c +4
-0+{ +return is_control_domain (d) ||is_hardware_domain (d); +} +/* * Check if inter-domain communication is allowed. * Return true when pass check.
xen/xsm/silo.c static bool silo_mode_dom_check(const struct domain *ldom, · line 39
Quoted 8 lines
xen/xsm/silo.c +2
-2@@ -29,8 +34,8 @@ static bool silo_mode_dom_check(const struct domain *ldom, {const struct domain *currd = current->domain; -return (is_control_domain (currd) ||is_control_domain (ldom) || -is_control_domain (rdom) || ldom == rdom); +return (is_priv_domain (currd) ||is_priv_domain (ldom) || +is_priv_domain (rdom) || ldom == rdom); }
... this would end up being overly lax.
Jan
PATCH 21/23 automation/dom0less-arm64: Use double quotes
In reply to Jason AndryukUse double quotes so we can change the contents of the base imagebuilder config. Specifically, we'll want to remove the dom0 entries for a split hardware/control domain test.
--- .../scripts/qemu-smoke-dom0less-arm64.sh | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-)
automation/scripts/qemu-smoke-dom0less-arm64.sh +17 -17
@@ -147,26 +147,26 @@ find . | cpio -H newc -o | gzip > ../binaries/dom0-rootfs.cpio.gz cd .. # ImageBuilder -echo 'MEMORY_START="0x40000000" -MEMORY_END="0x50000000" +echo "MEMORY_START='0x40000000' +MEMORY_END='0x50000000' -DEVICE_TREE="virt.dtb" -XEN="xen" -DOM0_KERNEL="Image" -DOM0_RAMDISK="dom0-rootfs.cpio.gz" -XEN_CMD="console=dtuart dom0_mem=512M console_timestamps=boot" +DEVICE_TREE='virt.dtb' +XEN='xen' +DOM0_KERNEL='Image' +DOM0_RAMDISK='dom0-rootfs.cpio.gz' +XEN_CMD='console=dtuart dom0_mem=512M console_timestamps=boot' NUM_DOMUS=1 -DOMU_KERNEL[0]="Image" -DOMU_RAMDISK[0]="initrd" -DOMU_MEM[0]="256" -DOMU_KERNEL[1]="Image" -DOMU_RAMDISK[1]="initrd" -DOMU_MEM[1]="256" - -LOAD_CMD="tftpb" -UBOOT_SOURCE="boot.source" -UBOOT_SCRIPT="boot.scr"' > binaries/config +DOMU_KERNEL[0]='Image' +DOMU_RAMDISK[0]='initrd' +DOMU_MEM[0]='256' +DOMU_KERNEL[1]='Image' +DOMU_RAMDISK[1]='initrd' +DOMU_MEM[1]='256' + +LOAD_CMD='tftpb' +UBOOT_SOURCE='boot.source' +UBOOT_SCRIPT='boot.scr'" > binaries/config if [[ "${test_variant}" == "static-mem" ]]; then echo -e "\nDOMU_STATIC_MEM[0]=\"${domu_base} ${domu_size}\"" >> binaries/config
Signature · 1 line
2.48.1
PATCH 22/23 automation: Add arm64 hardware/control split test
In reply to Jason AndryukUse dom0less to create a hardware+xenstore domain, a control domain, and a regular domU.
Create a domU-rootfs that does not run the xen scripts, but does have the xen tools installed. The domU also uses a console on ttyAMA0 instead of hvc0.
We need to increate dom0less test memory or ImageBuilder fails with:
Error, not enough memory to load all binaries
Use C xenstored so hardware/xenstore can grant map control's xenstore grant.
---
Initially, I tried to put xl list into control. That executes before dom0 runs init-dom0less, and it hangs. I expected it to recover after init-dom0less introduces it, but it does not. That needs further investigation.
--- automation/gitlab-ci/test.yaml | 8 +++ .../scripts/qemu-smoke-dom0less-arm64.sh | 67 ++++++++++++++++--- 2 files changed, 66 insertions(+), 9 deletions(-)
automation/gitlab-ci/test.yaml +8 -0
@@ -403,6 +403,14 @@ qemu-smoke-dom0less-arm64-gcc-debug-gicv3: - *arm64-test-needs - alpine-3.18-gcc-debug-arm64 +qemu-smoke-dom0less-arm64-gcc-debug-hwdom-control: + extends: .qemu-arm64 + script: + - ./automation/scripts/qemu-smoke-dom0less-arm64.sh hwdom-control 2>&1 | tee ${LOGFILE} + needs: + - *arm64-test-needs + - alpine-3.18-gcc-debug-arm64 + qemu-smoke-dom0less-arm64-gcc-debug-staticmem: extends: .qemu-arm64 script:
automation/scripts/qemu-smoke-dom0less-arm64.sh +58 -9
104 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH 23/23 DO NOT COMMIT: automation: updated imagebuilder
In reply to Jason AndryukTemp commit to update imagebuilder repo for domain capabilities.
--- automation/scripts/qemu-smoke-dom0less-arm64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
automation/scripts/qemu-smoke-dom0less-arm64.sh +1 -1
@@ -250,7 +250,7 @@ NUM_CPUPOOLS=1' >> binaries/config fi rm -rf imagebuilder -git clone --depth 1 https://gitlab.com/xen-project/imagebuilder.git +git clone --depth 1 https://gitlab.com/jandryuk-amd/imagebuilder.git -b dom0less-caps bash imagebuilder/scripts/uboot-script-gen -t tftp -d binaries/ -c binaries/config
Signature · 1 line
2.48.1