ARM split hardware and control domains
v4 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 v4 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 | 197 ++++++++++++++++------ 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 | 15 +- xen/common/grant_table.c | 14 ++ xen/include/public/bootfdt.h | 31 ++++ xen/include/xen/domain.h | 2 + xen/include/xen/grant_table.h | 4 + xen/include/xen/types.h | 1 + 14 files changed, 243 insertions(+), 64 deletions(-) create mode 100644 xen/include/public/bootfdt.h
Signature · 1 line
2.49.0
PATCH v4 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.
The assignment of d->cdf is moved later so CDF_hardware is added for the late_hwdom case. Also old_hwdom has the flag removed to reflect the change.
---
v4:
Move d->cdf assignment later
Remove Jan's R-b
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 | 15 +++++++++++---- xen/include/xen/domain.h | 2 ++ 4 files changed, 16 insertions(+), 6 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 +11 -4
@@ -804,9 +804,6 @@ struct domain *domain_create(domid_t domid, d->domain_id = domid; d->unique_id =get_unique_id (); -/* Holding CDF_* internal flags. */ - d->cdf = flags; -/* Debug sanity. */ ASSERT (is_system_domain (d) ? config ==NULL : config !=NULL );
@@ -820,15 +817,25 @@ 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; +if ( old_hwdom ) + old_hwdom->cdf &= ~CDF_hardware; } +/* Holding CDF_* internal flags. */ + d->cdf = flags; +TRACE_TIME (TRC_DOM0_DOM_ADD , d->domain_id);lock_profile_register_struct (LOCKPROF_TYPE_PERDOM , d, domid);
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 v4 1/7] xen: introduce hardware domain create flag
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.
The assignment of
d->cdfis moved later soCDF_hardwareis added for thelate_hwdomcase. Alsoold_hwdomhas the flag removed to reflect the change.Signed-off-by Daniel P. Smith <[email protected]>Signed-off-by Jason Andryuk <[email protected]>
i.e. ...
Quoted 3 lines
---
v4:
Moved->cdfassignment later
... despite my earlier concern this movement looks fine to me.
Jan
Re: [PATCH v4 1/7] xen: introduce hardware domain create flag
Quoted 12 lines · Jan Beulich
Quoted 11 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.
The assignment of
d->cdfis moved later soCDF_hardwareis added for thelate_hwdomcase. Alsoold_hwdomhas the flag removed to reflect the change.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Daniel P. Smith <[email protected]>Signed-off-by Jason Andryuk <[email protected]>Reviewed-by Jan Beulich <[email protected]>i.e. ...
Thanks.
Quoted 5 lines
Quoted 3 lines
---
v4:
Moved->cdfassignment later... despite my earlier concern this movement looks fine to me.
Double checking today, I see that in the failure case, hardware_domain is restored from old_hwdom. So in that case, CDF_hardware should be restored:
@@ -986,7 +987,11 @@ struct domain *domain_create(domid_t domid,
d->is_dying = DOMDYING_dead;
if ( hardware_domain == d )
+ {
+ if ( old_hwdom )
+ old_hwdom->cdf |= CDF_hardware;
hardware_domain = old_hwdom;
+ }
atomic_set(&d->refcnt, DOMAIN_DESTROYED);
sched_destroy_domain(d);I'll see what comments I get on the rest of the series before respinning.
Regards,
Jason
Re: [PATCH v4 1/7] xen: introduce hardware domain create flag
Quoted 33 lines · Jason Andryuk
Quoted 12 lines · Jan Beulich
Quoted 11 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.
The assignment of
d->cdfis moved later soCDF_hardwareis added for thelate_hwdomcase. Alsoold_hwdomhas the flag removed to reflect the change.Quoted 5 lines
Quoted 2 lines
Signed-off-by Daniel P. Smith <[email protected]>Signed-off-by Jason Andryuk <[email protected]>Reviewed-by Jan Beulich <[email protected]>i.e. ...
Thanks.
Quoted 5 lines
Quoted 3 lines
---
v4:
Moved->cdfassignment later... despite my earlier concern this movement looks fine to me.
Double checking today, I see that in the failure case,
hardware_domainis restored fromold_hwdom. So in that case,CDF_hardwareshould be restored:(quoted diff) +0
-0@@ -986,7 +987,11 @@ struct domain *domain_create(domid_t domid,
Review struct domain *domain_create(domid_t domid, · line 997
Quoted 10 lines
(quoted diff) +4
-0d->is_dying = DOMDYING_dead; if ( hardware_domain == d ) + { + if ( old_hwdom ) + old_hwdom->cdf |= CDF_hardware; hardware_domain = old_hwdom; + } atomic_set(&d->refcnt, DOMAIN_DESTROYED); sched_destroy_domain(d);
Oh, right. Please retain my R-b with this added.
Jan
PATCH v4 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
Re: [PATCH v4 2/7] xen/arm: dom0less hwdom construction
Quoted 10 lines · Jason Andryuk
When 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 forprocess_shmwhile a hwdom will use the value from its dom0less device tree node.Signed-off-by Jason Andryuk <[email protected]>
Quoted 127 lines
---
v3:
Rebase onprocess_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 v4 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.
---
v4:
Add Stefano R-b
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
PATCH v4 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).
Add a define to indicate the late alloc xsentore PFN, to better indicate what is being checked. Use UINT64_MAX instead of ~0ULL as the HVM_PARAM field is a uint64_t. UINT64_MAX is not defined, so add it.
---
v4:
ASSERT gfn against UINT32_MAX and use < to avoid INVALID_GFN on 32bit builds
Stefano gave R-b, but holding off addition because of changes Use IS_ENABLED(CONFIG_GRANT_TABLE) instead of wrapper
Add XENSTORE_PFN_LATE_ALLOC
Add UINT64_MAX
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 | 10 +++++++++- xen/common/grant_table.c | 14 ++++++++++++++ xen/include/xen/grant_table.h | 4 ++++ xen/include/xen/types.h | 1 + 4 files changed, 28 insertions(+), 1 deletion(-)
xen/arch/arm/dom0less-build.c +9 -1
@@ -20,6 +20,8 @@#include <asm/static-memory.h> #include <asm/static-shmem.h> +#define XENSTORE_PFN_LATE_ALLOC UINT64_MAX +static domid_t __initdata xs_domid =DOMID_INVALID ;static bool __initdata need_xenstore;
@@ -756,7 +758,7 @@ static int __init alloc_xenstore_params(struct kernel_info *kinfo)if ( (kinfo->dom0less_feature & (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY )) == (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY ) ) - d->arch.hvm.params[HVM_PARAM_STORE_PFN ] = ~0ULL ; + d->arch.hvm.params[HVM_PARAM_STORE_PFN ] =XENSTORE_PFN_LATE_ALLOC ;else if ( kinfo->dom0less_feature &DOM0LESS_XENSTORE ) { rc =alloc_xenstore_page (d);
@@ -788,6 +790,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 !=XENSTORE_PFN_LATE_ALLOC &&IS_ENABLED (CONFIG_GRANT_TABLE ) ) + { +ASSERT (gfn <UINT32_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 +4 -0
@@ -33,6 +33,10 @@struct grant_table ; +/* 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); +#ifdef CONFIG_GRANT_TABLE extern unsigned int opt_gnttab_max_version;
xen/include/xen/types.h +1 -0
@@ -44,6 +44,7 @@ typedef __UINTPTR_TYPE__ uintptr_t;#define UINT8_MAX (255)#define UINT16_MAX (65535)#define UINT32_MAX (4294967295U) +#define UINT64_MAX (18446744073709551615ULL)#define INT_MAX ((int)(~0U>>1))#define INT_MIN (-INT_MAX - 1)
Signature · 1 line
2.49.0
Re: [PATCH v4 4/7] xen/arm: dom0less seed xenstore grant table entry
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 5 lines
Add a define to indicate the late alloc xsentore PFN, to better indicate what is being checked. Use
UINT64_MAXinstead of ~0ULL as theHVM_PARAMfield is auint64_t.UINT64_MAXis not defined, so add it.Signed-off-by Jason Andryuk <[email protected]>
Quoted 118 lines
---
v4:
ASSERT gfn againstUINT32_MAXand use < to avoidINVALID_GFNon 32bit builds
Stefano gave R-b, but holding off addition because of changes UseIS_ENABLED(CONFIG_GRANT_TABLE)instead of wrapper
AddXENSTORE_PFN_LATE_ALLOC
AddUINT64_MAXv3:
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 | 10 +++++++++- xen/common/grant_table.c | 14 ++++++++++++++ xen/include/xen/grant_table.h | 4 ++++ xen/include/xen/types.h | 1 + 4 files changed, 28 insertions(+), 1 deletion(-)xen/arch/arm/dom0less-build.c +9
-1@@ -20,6 +20,8 @@#include <asm/static-memory.h> #include <asm/static-shmem.h> +#define XENSTORE_PFN_LATE_ALLOC UINT64_MAX +static domid_t __initdata xs_domid =DOMID_INVALID ;static bool __initdata need_xenstore;@@ -756,7 +758,7 @@ static int __init alloc_xenstore_params(struct kernel_info *kinfo)if ( (kinfo->dom0less_feature & (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY )) == (DOM0LESS_XENSTORE |DOM0LESS_XS_LEGACY ) ) - d->arch.hvm.params[HVM_PARAM_STORE_PFN ] = ~0ULL ; + d->arch.hvm.params[HVM_PARAM_STORE_PFN ] =XENSTORE_PFN_LATE_ALLOC ;else if ( kinfo->dom0less_feature &DOM0LESS_XENSTORE ) { rc =alloc_xenstore_page (d);@@ -788,6 +790,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 !=XENSTORE_PFN_LATE_ALLOC &&IS_ENABLED (CONFIG_GRANT_TABLE ) ) + { +ASSERT (gfn <UINT32_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 +4
-0@@ -33,6 +33,10 @@struct grant_table ; +/* 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); +#ifdef CONFIG_GRANT_TABLE extern unsigned int opt_gnttab_max_version;xen/include/xen/types.h +1
-0@@ -44,6 +44,7 @@ typedef __UINTPTR_TYPE__ uintptr_t;#define UINT8_MAX (255)#define UINT16_MAX (65535)#define UINT32_MAX (4294967295U) +#define UINT64_MAX (18446744073709551615ULL)#define INT_MAX ((int)(~0U>>1))#define INT_MIN (-INT_MAX - 1)Signature · 1 line
2.49.0
PATCH v4 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.
---
v4:
Add Stefano R-b
--- 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 v4 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.
---
v4:
Add Stefano R-b
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
@@ -1033,6 +1033,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;
@@ -1067,9 +1068,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 v4 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,
---
v4:
Add Stefano R-b
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