ARM split hardware and control domains
v3 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 dom1 as control, dom2 as a domU, and dom3 as hardware and xenstore.
To keep things more managable, this v3 is only the ARM hypervisor changes, and one associated init-dom0less change. The series is slightly re-ordered to move xenstore changes ahead of adding the capabilities.
"xen/arm: dom0less use has_dtb local variable" is a new patch to slightly simplify "xen/arm: Add capabilities to dom0less".
Setting hardware domain as domid 0 is removed.
I've been unable to run a combined control/xenstore. Linux console output stops shortly after the domain determines it should be XS_LOCAL. I have not investigated further.
Daniel P. Smith (1):
xen: introduce hardware domain create flag
Jason Andryuk (6):
xen/arm: dom0less hwdom construction xen/arm: dom0less delay xenstore initialization xen/arm: dom0less seed xenstore grant table entry tools/init-dom0less: Only seed legacy xenstore grants xen/arm: dom0less use has_dtb local variable xen/arm: Add capabilities to dom0less
docs/misc/arm/device-tree/booting.txt | 11 ++ tools/helpers/init-dom0less.c | 10 +- xen/arch/arm/dom0less-build.c | 195 ++++++++++++++++------ xen/arch/arm/domain.c | 3 +- xen/arch/arm/domain_build.c | 11 +- xen/arch/arm/include/asm/dom0less-build.h | 2 + xen/arch/arm/include/asm/domain_build.h | 3 +- xen/arch/x86/setup.c | 3 +- xen/common/domain.c | 7 +- xen/common/grant_table.c | 14 ++ xen/include/public/bootfdt.h | 31 ++++ xen/include/xen/domain.h | 2 + xen/include/xen/grant_table.h | 7 + 13 files changed, 238 insertions(+), 61 deletions(-) create mode 100644 xen/include/public/bootfdt.h
Signature · 1 line
2.49.0
PATCH v3 1/7 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.
---
v3:
Or-in CDF_hardware for late hwdom case
Add Jan's R-b
v2:
() around binary &
Only allow late_hwdom for dom0
--- xen/arch/arm/domain_build.c | 2 +- xen/arch/x86/setup.c | 3 ++- xen/common/domain.c | 7 ++++++- xen/include/xen/domain.h | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-)
xen/arch/arm/domain_build.c +1 -1
@@ -2369,7 +2369,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
@@ -1018,7 +1018,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 +6 -1
@@ -820,13 +820,18 @@ 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" ); +/* late_hwdom is only allowed for dom0. */ +if ( hardware_domain && hardware_domain->domain_id ) +return ERR_PTR (-EINVAL ); + old_hwdom = hardware_domain; hardware_domain = d; + flags |= CDF_hardware; }TRACE_TIME (TRC_DOM0_DOM_ADD , d->domain_id);
xen/include/xen/domain.h +2 -0
@@ -53,6 +53,8 @@ domid_t get_initial_domain_id(void);#else #define CDF_staticmem 0#endif +/* This is the hardware domain. Only 1 allowed. */ +#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.49.0
Re: [PATCH v3 1/7] xen: introduce hardware domain create flag
Quoted 10 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]>Reviewed-by Jan Beulich <[email protected]>
ARM:
Quoted 82 lines
---
v3:
Or-inCDF_hardwarefor late hwdom case
Add Jan's R-bv2:
() around binary &
Only allowlate_hwdomfor dom0--- xen/arch/arm/domain_build.c | 2 +- xen/arch/x86/setup.c | 3 ++- xen/common/domain.c | 7 ++++++- xen/include/xen/domain.h | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-)xen/arch/arm/domain_build.c +1
-1@@ -2369,7 +2369,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@@ -1018,7 +1018,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 +6
-1@@ -820,13 +820,18 @@ 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" ); +/* late_hwdom is only allowed for dom0. */ +if ( hardware_domain && hardware_domain->domain_id ) +return ERR_PTR (-EINVAL ); + old_hwdom = hardware_domain; hardware_domain = d; + flags |= CDF_hardware; }TRACE_TIME (TRC_DOM0_DOM_ADD , d->domain_id);xen/include/xen/domain.h +2
-0@@ -53,6 +53,8 @@ domid_t get_initial_domain_id(void);#else #define CDF_staticmem 0#endif +/* This is the hardware domain. Only 1 allowed. */ +#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.49.0
Re: [PATCH v3 1/7] xen: introduce hardware domain create flag
In reply to Jason AndryukQuoted 5 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.
Quoted 8 lines
This allows more flexibility with domain creation.
Signed-off-by Daniel P. Smith <[email protected]>Signed-off-by Jason Andryuk <[email protected]>Reviewed-by Jan Beulich <[email protected]>---
v3:
Or-inCDF_hardwarefor late hwdom case
Except that ...
Quoted 10 lines
xen/common/domain.c +1
-1@@ -820,13 +820,18 @@ 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 )
xen/common/domain.c struct domain *domain_create(domid_t domid, · line 835
Quoted 10 lines
xen/common/domain.c +5
-0panic ("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 ERR_PTR (-EINVAL ); + old_hwdom = hardware_domain; hardware_domain = d; + flags |= CDF_hardware; }
... this isn't quite enough. You're only modifying what will go out of scope when returning from the function. What's at least equally important to OR into is d->cdf.
Jan
Re: [PATCH v3 1/7] xen: introduce hardware domain create flag
Quoted 29 lines · Jan Beulich
Quoted 5 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.
Quoted 8 lines
This allows more flexibility with domain creation.
Signed-off-by Daniel P. Smith <[email protected]>Signed-off-by Jason Andryuk <[email protected]>Reviewed-by Jan Beulich <[email protected]>---
v3:
Or-inCDF_hardwarefor late hwdom caseExcept that ...
Quoted 12 lines
xen/common/domain.c +1
-1@@ -820,13 +820,18 @@ 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" );
Quoted 12 lines
xen/common/domain.c struct domain *domain_create(domid_t domid, · line 835
Quoted 8 lines
xen/common/domain.c +5
-0+/* late_hwdom is only allowed for dom0. */ +if ( hardware_domain && hardware_domain->domain_id ) +return ERR_PTR (-EINVAL ); + old_hwdom = hardware_domain; hardware_domain = d; + flags |= CDF_hardware; }... this isn't quite enough. You're only modifying what will go out of scope when returning from the function. What's at least equally important to OR into is
d->cdf.
Yes, thanks for catching that.
I'll move d->cdf assignment to after here instead of or-ing in a second time.
With that, it seems like it should also be removed from old_hwdom?
old_hwdom->cdf &= ~CDF_hardware
Regards,
Jason
Re: [PATCH v3 1/7] xen: introduce hardware domain create flag
Quoted 43 lines · Jason Andryuk
Quoted 29 lines · Jan Beulich
Quoted 5 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.
Quoted 8 lines
This allows more flexibility with domain creation.
Signed-off-by Daniel P. Smith <[email protected]>Signed-off-by Jason Andryuk <[email protected]>Reviewed-by Jan Beulich <[email protected]>---
v3:
Or-inCDF_hardwarefor late hwdom caseExcept that ...
Quoted 12 lines
xen/common/domain.c +1
-1@@ -820,13 +820,18 @@ 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" );Quoted 12 lines
xen/common/domain.c struct domain *domain_create(domid_t domid, · line 835
Quoted 8 lines
xen/common/domain.c +5
-0+/* late_hwdom is only allowed for dom0. */ +if ( hardware_domain && hardware_domain->domain_id ) +return ERR_PTR (-EINVAL ); + old_hwdom = hardware_domain; hardware_domain = d; + flags |= CDF_hardware; }... this isn't quite enough. You're only modifying what will go out of scope when returning from the function. What's at least equally important to OR into is
d->cdf.
Quoted 4 lines
Yes, thanks for catching that.
I'll move
d->cdfassignment to after here instead of or-ing in a second time.
Not sure that'll be good to do - intermediate code (in particular passing d to other functions) may need to have that set already. And even if not now, then maybe going forward.
Quoted 3 lines
With that, it seems like it should also be removed from
old_hwdom?
old_hwdom->cdf&= ~CDF_hardware
Oh, indeed. Thanks in turn for catching this further aspect.
Jan
PATCH v3 2/7 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.
---
v3:
Rebase on process_shm_chosen() removal
--- xen/arch/arm/dom0less-build.c | 57 ++++++++++++++----------- xen/arch/arm/domain_build.c | 7 +-- xen/arch/arm/include/asm/domain_build.h | 3 +- 3 files changed, 39 insertions(+), 28 deletions(-)
xen/arch/arm/dom0less-build.c +33 -24
@@ -929,36 +929,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 +4 -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;
@@ -2327,7 +2328,7 @@ int __init construct_hwdom(struct kernel_info *kinfo)if ( acpi_disabled ) { - rc =process_shm (d, kinfo,NULL ); + rc =process_shm (d, kinfo, node);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.49.0
PATCH v3 3/7 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 created 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 creation and grant 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.
The domain running xenstored needs to be the handler for VIRQ_DOM_EXC, so set that as well - it otherwise defaults to hardware domain.
---
v3:
Use uint64_t to check for xenstore pfn read from HVM_PARAM Rebase after mem paging changes
v2:
Re-order ahead of seeding.
Fix created type in commit message
Change set_xs_domid to set_xs_domain
Set xenstore domain as VIRQ_DOM_EXC handler
--- xen/arch/arm/dom0less-build.c | 67 +++++++++++++++++------ xen/arch/arm/domain_build.c | 2 + xen/arch/arm/include/asm/dom0less-build.h | 2 + 3 files changed, 53 insertions(+), 18 deletions(-)
xen/arch/arm/dom0less-build.c +49 -18
@@ -20,6 +20,15 @@#include <asm/static-memory.h> #include <asm/static-shmem.h> +static domid_t __initdata xs_domid =DOMID_INVALID ; +static bool __initdata need_xenstore; + +void __init set_xs_domain (struct domain *d) +{ + xs_domid = d->domain_id; +set_global_virq_handler (d,VIRQ_DOM_EXC ); +} +bool __init is_dom0less_mode (void ) {struct bootmodules *mods = &bootinfo.modules;
@@ -679,7 +688,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 ) {
@@ -745,16 +754,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 )
@@ -764,6 +767,30 @@ static int __init alloc_xenstore_params(struct kernel_info *kinfo)return rc; } +static void __init initialize_domU_xenstore (void ) +{ +struct domain *d; + +if ( xs_domid ==DOMID_INVALID ) +return ; + +for_each_domain ( d ) + { +uint64_t 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); + } +} +static void __init domain_vcpu_affinity (struct domain *d,const struct dt_device_node *node) {
@@ -899,17 +926,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 ;
@@ -1156,7 +1179,15 @@ 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 ) +set_xs_domain (d); } + +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 +2 -0
@@ -2408,6 +2408,8 @@ void __init create_dom0(void) rc =construct_dom0 (dom0);if ( rc )panic ("Could not set up DOM0 guest OS (rc = %d)\n" , rc); + +set_xs_domain (dom0); }/*
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_domain (struct domain *d);#else /* !CONFIG_DOM0LESS_BOOT */
@@ -17,6 +18,7 @@ static inline bool is_dom0less_mode(void) {return false; } +static inline void set_xs_domain (struct domain *d) {}#endif /* CONFIG_DOM0LESS_BOOT */
Signature · 1 line
2.49.0
Re: [PATCH v3 3/7] xen/arm: dom0less delay xenstore initialization
Quoted 13 lines · Jason Andryuk
To allocate the xenstore event channel and initialize the grant table entry, the xenstore domid is neeed. A dom0 is created 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 creation and grant 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.
Quoted 6 lines
dom0 needs to set
xs_domidwhen it is serving as the xenstore domain.The domain running xenstored needs to be the handler for
VIRQ_DOM_EXC, so set that as well - it otherwise defaults to hardware domain.Signed-off-by Jason Andryuk <[email protected]>
PATCH v3 4/7 xen/arm: dom0less seed xenstore grant table entry
In reply to Jason Andryukxenstored 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.
C xenstored uses grants, so it can map the xenstore pages from a non-dom0 xenstore domain. OCaml xenstored uses foreign mappings, so it can only run from a privileged domain (dom0).
---
v3:
Expand commit message about C vs. OCaml xenstored. Remove __init and flags from gnttab_seed_entry() Change frame to uint32_t
ASSERT gfn fits in a uint32_t
Rebase on mem paging changes
v2:
Tweak commit message
Mark gnttab_seed_entry() __init and put inside CONFIG_DOM0LESS_BOOT Add ASSERT(!d->creation_finished) and ASSERT(gt->gt_version == 1); const struct domain & struct grant_table
--- xen/arch/arm/dom0less-build.c | 6 ++++++ xen/common/grant_table.c | 14 ++++++++++++++ xen/include/xen/grant_table.h | 7 +++++++ 3 files changed, 27 insertions(+)
xen/arch/arm/dom0less-build.c +6 -0
@@ -788,6 +788,12 @@ static void __init initialize_domU_xenstore(void) rc =alloc_xenstore_evtchn (d);if ( rc <0 )panic ("%pd: Failed to allocate xenstore_evtchn\n" , d); + +if ( gfn != ~0ULL ) + { +ASSERT (gfn <=UINT_MAX ); +gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, gfn); + } } }
xen/common/grant_table.c +14 -0
@@ -4346,6 +4346,20 @@ static void gnttab_usage_print(struct domain *rd)printk ("no active grant table entries\n" ); } +#ifdef CONFIG_DOM0LESS_BOOT +void __init gnttab_seed_entry (const struct domain *d,unsigned int idx, +domid_t be_domid,uint32_t frame) +{ +const struct grant_table *gt = d->grant_table; + +ASSERT (!d->creation_finished); +ASSERT (gt->gt_version ==1 ); +shared_entry_v1 (gt, idx).flags = GTF_permit_access; +shared_entry_v1 (gt, idx).domid = be_domid; +shared_entry_v1 (gt, idx).frame = frame; +} +#endif + static void cf_check gnttab_usage_print_all(unsigned char key) {struct domain *d;
xen/include/xen/grant_table.h +7 -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 (const struct domain *d,unsigned int idx, +domid_t be_domid,uint32_t frame); +/* * Check if domain has active grants and log first 10 of them. */
@@ -85,6 +89,9 @@ 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,uint32_t frame) {} +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.49.0
Re: [PATCH v3 4/7] xen/arm: dom0less seed xenstore grant table entry
Quoted 8 lines · Jason Andryuk
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.
Quoted 5 lines
C xenstored uses grants, so it can map the xenstore pages from a non-dom0 xenstore domain. OCaml xenstored uses foreign mappings, so it can only run from a privileged domain (dom0).
Signed-off-by Jason Andryuk <[email protected]>
Quoted 89 lines
---
v3:
Expand commit message about C vs. OCaml xenstored. Remove__initand flags fromgnttab_seed_entry()Change frame touint32_t
ASSERT gfn fits in auint32_t
Rebase on mem paging changesv2:
Tweak commit message
Markgnttab_seed_entry()__initand put insideCONFIG_DOM0LESS_BOOTAddASSERT(!d->creation_finished)andASSERT(gt->gt_version == 1); const struct domain & structgrant_table--- xen/arch/arm/dom0less-build.c | 6 ++++++ xen/common/grant_table.c | 14 ++++++++++++++ xen/include/xen/grant_table.h | 7 +++++++ 3 files changed, 27 insertions(+)xen/arch/arm/dom0less-build.c +6
-0@@ -788,6 +788,12 @@ static void __init initialize_domU_xenstore(void) rc =alloc_xenstore_evtchn (d);if ( rc <0 )panic ("%pd: Failed to allocate xenstore_evtchn\n" , d); + +if ( gfn != ~0ULL ) + { +ASSERT (gfn <=UINT_MAX ); +gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, gfn); + } } }xen/common/grant_table.c +14
-0@@ -4346,6 +4346,20 @@ static void gnttab_usage_print(struct domain *rd)printk ("no active grant table entries\n" ); } +#ifdef CONFIG_DOM0LESS_BOOT +void __init gnttab_seed_entry (const struct domain *d,unsigned int idx, +domid_t be_domid,uint32_t frame) +{ +const struct grant_table *gt = d->grant_table; + +ASSERT (!d->creation_finished); +ASSERT (gt->gt_version ==1 ); +shared_entry_v1 (gt, idx).flags = GTF_permit_access; +shared_entry_v1 (gt, idx).domid = be_domid; +shared_entry_v1 (gt, idx).frame = frame; +} +#endif + static void cf_check gnttab_usage_print_all(unsigned char key) {struct domain *d;xen/include/xen/grant_table.h +7
-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 (const struct domain *d,unsigned int idx, +domid_t be_domid,uint32_t frame); +/* * Check if domain has active grants and log first 10 of them. */ @@ -85,6 +89,9 @@ 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,uint32_t frame) {} +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.49.0
Re: [PATCH v3 4/7] xen/arm: dom0less seed xenstore grant table entry
In reply to Jason AndryukQuoted 12 lines · Jason Andryuk
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.
C xenstored uses grants, so it can map the xenstore pages from a non-dom0 xenstore domain. OCaml xenstored uses foreign mappings, so it can only run from a privileged domain (dom0).
Quoted 7 lines
Signed-off-by Jason Andryuk <[email protected]>---
v3:
Expand commit message about C vs. OCaml xenstored. Remove__initand flags fromgnttab_seed_entry()Change frame touint32_t
ASSERT gfn fits in auint32_t
Ehem. For this you need to use ...
xen/arch/arm/dom0less-build.c static void __init initialize_domU_xenstore(void) · line 794
Quoted 10 lines
xen/arch/arm/dom0less-build.c +4
-0@@ -788,6 +788,12 @@ static void __init initialize_domU_xenstore(void) rc =alloc_xenstore_evtchn (d);if ( rc <0 )panic ("%pd: Failed to allocate xenstore_evtchn\n" , d); + +if ( gfn != ~0ULL ) + { +ASSERT (gfn <=UINT_MAX );
... UINT32_MAX here. Furthermore may I remind you that INVALID_GFN == UINT32_MAX in 32-bit environments.
The ~0ULL may also better be UINT64_MAX.
xen/arch/arm/dom0less-build.c static inline void grant_table_destroy(struct domain *d) {} · line 93
Quoted 6 lines
xen/arch/arm/dom0less-build.c +2
-0@@ -85,6 +89,9 @@ 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,uint32_t frame) {}
Hmm. While generally I prefer using such wrappers, I wonder if in this case it wouldn't end up more clear if a conditional was added in initialize_domU_xenstore(). Ideally using IS_ENABLED(), which - aiui - would require moving the declaration of the function.
Jan
Re: [PATCH v3 4/7] xen/arm: dom0less seed xenstore grant table entry
Quoted 23 lines · Jan Beulich
Quoted 12 lines · Jason Andryuk
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.
C xenstored uses grants, so it can map the xenstore pages from a non-dom0 xenstore domain. OCaml xenstored uses foreign mappings, so it can only run from a privileged domain (dom0).
Quoted 7 lines
Signed-off-by Jason Andryuk <[email protected]>---
v3:
Expand commit message about C vs. OCaml xenstored. Remove__initand flags fromgnttab_seed_entry()Change frame touint32_t
ASSERT gfn fits in auint32_tEhem. For this you need to use ...
Quoted 13 lines
xen/arch/arm/dom0less-build.c static void __init initialize_domU_xenstore(void) · line 794
Quoted 10 lines
xen/arch/arm/dom0less-build.c +4
-0@@ -788,6 +788,12 @@ static void __init initialize_domU_xenstore(void) rc =alloc_xenstore_evtchn (d);if ( rc <0 )panic ("%pd: Failed to allocate xenstore_evtchn\n" , d); + +if ( gfn != ~0ULL ) + { +ASSERT (gfn <=UINT_MAX );...
UINT32_MAXhere. Furthermore may I remind you thatINVALID_GFN==UINT32_MAXin 32-bit environments.
Yes, thanks.
Quoted 1 line
The ~0ULL may also better be
UINT64_MAX.
I'll also add
#define XENSTORE_PFN_LATE_ALLOC UINT64_MAX
Quoted 11 lines
xen/arch/arm/dom0less-build.c static inline void grant_table_destroy(struct domain *d) {} · line 93
Quoted 6 lines
xen/arch/arm/dom0less-build.c +2
-0@@ -85,6 +89,9 @@ 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,uint32_t frame) {}Hmm. While generally I prefer using such wrappers, I wonder if in this case it wouldn't end up more clear if a conditional was added in
initialize_domU_xenstore(). Ideally usingIS_ENABLED(), which - aiui - would require moving the declaration of the function.
Ok.
Thanks,
Jason
PATCH v3 5/7 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.49.0
Re: [PATCH v3 5/7] tools/init-dom0less: Only seed legacy xenstore grants
Quoted 9 lines · Jason Andryuk
The 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.
Signed-off-by Jason Andryuk <[email protected]>
I was thinking whether it is an issue that we change behavior of init-dom0less for the new protocol. I convinced myself it is not an issue because init-dom0less is supposed to be a matched set with the Xen hypervisor version. I also thought whether we could check if the call to xc_dom_gnttab_seed is needed and only do it if it is, so that init-dom0less.c could be less depedent on the specific Xen behavior.
Overall I thought it is not worth it, so:
Quoted 30 lines
--- 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.49.0
PATCH v3 6/7 xen/arm: dom0less use has_dtb local variable
In reply to Jason AndryukStore the result of finding a "multiboot,device-tree" node. This will simplity adding hardware domain checks.
---
v3:
New
Could be squashed into the next patch, but this helps make the next one cleaner.
--- xen/arch/arm/dom0less-build.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
xen/arch/arm/dom0less-build.c +5 -3
@@ -1031,6 +1031,7 @@ void __init create_domUs(void) .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), };unsigned int flags =0U ; +bool has_dtb = false;uint32_t val;int rc;
@@ -1065,9 +1066,10 @@ void __init create_domUs(void) !strcmp(dom0less_iommu, "enabled") ) iommu = true; -if ( iommu_enabled && - (iommu ||dt_find_compatible_node (node,NULL , -"multiboot,device-tree" )) ) +if (dt_find_compatible_node (node,NULL ,"multiboot,device-tree" ) ) + has_dtb = true; + +if ( iommu_enabled && (iommu || has_dtb) ) d_cfg.flags |= XEN_DOMCTL_CDF_iommu;if ( !dt_property_read_u32 (node,"nr_spis" , &d_cfg.arch.nr_spis) )
Signature · 1 line
2.49.0
Re: [PATCH v3 6/7] xen/arm: dom0less use has_dtb local variable
Quoted 4 lines · Jason Andryuk
Store the result of finding a "multiboot,device-tree" node. This will simplity adding hardware domain checks.
Signed-off-by Jason Andryuk <[email protected]>
Quoted 39 lines
---
v3:
NewCould be squashed into the next patch, but this helps make the next one cleaner.
--- xen/arch/arm/dom0less-build.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)xen/arch/arm/dom0less-build.c +5
-3@@ -1031,6 +1031,7 @@ void __init create_domUs(void) .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), };unsigned int flags =0U ; +bool has_dtb = false;uint32_t val;int rc;@@ -1065,9 +1066,10 @@ void __init create_domUs(void) !strcmp(dom0less_iommu, "enabled") ) iommu = true; -if ( iommu_enabled && - (iommu ||dt_find_compatible_node (node,NULL , -"multiboot,device-tree" )) ) +if (dt_find_compatible_node (node,NULL ,"multiboot,device-tree" ) ) + has_dtb = true; + +if ( iommu_enabled && (iommu || has_dtb) ) d_cfg.flags |= XEN_DOMCTL_CDF_iommu;if ( !dt_property_read_u32 (node,"nr_spis" , &d_cfg.arch.nr_spis) )Signature · 1 line
2.49.0
PATCH v3 7/7 xen/arm: Add capabilities to dom0less
In reply to Jason AndryukAdd a capabilities property to dom0less to allow building a disaggregated system. Only a single hardware domain and single xenstore domain can be specified. Multiple control domains are possible.
Introduce bootfdt.h to contain these constants.
When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
For a hardware domain, disallow specifying "vpl011", "nr_spis", "multiboot,device-tree" and "passthrough" nodes. Also, require an IOMMU when not direct-mapped,
---
v3:
Specify 32bit integer in booting.txt & s/all all/all/ Panic on !direct-map && !iommu
Panic "multiboot,device-tree" or "passthrough" with hardware domain Include asm/grant_table.h for CONFIG_GRANT_TABLE=n
v2:
Fix comment style
Make DOMAIN_CAPS_* unsigned
Remove forced directmap & iommu
Require iommu with use of hardware domain
Limit to a single xenstore domain
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. Hardware domain receiving all hardware can only have a single domain.
For Xenstore, the logic latches the single xs_domid and uses that for all domains. Also, only a single domain can register for VIRQ_DOM_EXC.
--- docs/misc/arm/device-tree/booting.txt | 11 ++++++ xen/arch/arm/dom0less-build.c | 57 +++++++++++++++++++++++++-- xen/arch/arm/domain.c | 3 +- xen/include/public/bootfdt.h | 31 +++++++++++++++ 4 files changed, 98 insertions(+), 4 deletions(-) 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 32-bit integer representing a bit field of domain capabilities + for a disaggregated system. A traditional dom0 has 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 +54 -3
95 lines not on this page · raw message
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 +31 -0
@@ -0,0 +1,31 @@ +/* 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 (1U << 0) +/* +* Hardware domain controlling physical hardware. Typically providing +* backends to other domains. +*/ +#define DOMAIN_CAPS_HARDWARE (1U << 1) +/* Xenstore domain. */ +#define DOMAIN_CAPS_XENSTORE (1U << 2) +#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ + DOMAIN_CAPS_XENSTORE) + +#endif /* __XEN_PUBLIC_BOOTFDT_H__ */
Signature · 1 line
2.49.0
Re: [PATCH v3 7/7] xen/arm: Add capabilities to dom0less
Quoted 6 lines · Jason Andryuk
Add a capabilities property to dom0less to allow building a disaggregated system. Only a single hardware domain and single xenstore domain can be specified. Multiple control domains are possible.
Introduce
bootfdt.hto contain these constants.
Quoted 8 lines
When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0.
For a hardware domain, disallow specifying "vpl011", "
nr_spis", "multiboot,device-tree" and "passthrough" nodes. Also, require an IOMMU when not direct-mapped,Signed-off-by Jason Andryuk <[email protected]>