XSM changes for split hardware / control domain
v2 cover XSM changes for split hardware / control domain
Theses are the broad changes needed for a split hardware / control domain. I'm mainly focused on the XSM changes, but there are additional xenstored and init-dom0less changes to make things work.
An earlier posting gave device_model privileges to hardware domain. For this posting, it was split out into a new capability. This way the operator can choose where to run the device models without making the hardware domain have the permissions.
The first patch add XSM_HW_PRIV for the hardware hypercalls. In this posting, the control domain cannot call these hypercalls.
There is also a new XEN_DOMCTL_CDF_not_hypercall_target flag. This is used to mark a domain that cannot be the target of hypercalls. This is useful for ensuring a domain has freedom from interference from control and device model domains. The control domain can still issue XSM_DM_PRIV hypercalls.
SILO is changed to allow hardware and xenstore to service domUs. Xenstore and hardware will use grants for PV interfaces.
xenstored runs in the xenstore domain. C xenstored is updated to read the event channel from the domU's grant. C xenstored must also be used since it uses grants instead of foreign mapping.
init-dom0less is run from control domain. auto-introduction of domains is needed for this to work. init-dom0less issues xs_introduce_domain over the xenbus, so it must be functional for control to issue it.
The special casing in "xsm/dummy: Allow HVMOP_get_param for control domain" is needed for init-dom0less to know if it should or should not configure xenstore for dom0less xen.enhanced = "no-xenstore".
There are some cosmetic errors from xl related to SYSCTL_physinfo.
libxl: error: libxl_utils.c:818:libxl_cpu_bitmap_alloc: failed to retrieve the maximum number of cpus
Jason Andryuk (17):
xen/xsm: Add XSM_HW_PRIV
xsm/silo: Support hardware & xenstore domains
xen: Add DOMAIN_CAPS_DEVICE_MODEL & XEN_DOMCTL_CDF_device_model
xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target xen/dom0less: Workaround XSM for evtchn_alloc_unbound xen/xsm: Expand XSM_XS_PRIV for untargetable domains xsm/dummy: Allow HVMOP_get_param for control domain public/io: xs_wire: Include event channel in interface page xen/dom0less: store xenstore event channel in page tools/xenstored: Read event channel from xenstored page
xen: Add capabilities to get_domain_state tools/manage: Expose domain capabilities tools/xenstored: Delay firing special watches tools/xenstored: Auto-introduce domains tools/init-dom0less: Factor out xenstore setup tools/init-dom0less: Configure already-introduced domains tools/init-dom0less: Continue on error
docs/misc/arm/device-tree/booting.txt | 6 ++ tools/helpers/init-dom0less.c | 78 +++++++++++++++---------- tools/include/xenmanage.h | 14 ++++- tools/libs/manage/core.c | 21 +++++-- tools/ocaml/libs/xc/xenctrl.ml | 2 + tools/ocaml/libs/xc/xenctrl.mli | 2 + tools/xenstored/core.c | 7 ++- tools/xenstored/core.h | 1 + tools/xenstored/domain.c | 65 ++++++++++++++++----- tools/xenstored/domain.h | 2 +- xen/arch/arm/domain.c | 4 +- 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/common/device-tree/dom0less-build.c | 25 ++++++++ xen/common/domain.c | 11 +++- xen/drivers/passthrough/pci.c | 5 +- xen/drivers/pci/physdev.c | 2 +- xen/include/public/bootfdt.h | 18 +++++- xen/include/public/domctl.h | 13 ++++- xen/include/public/io/xs_wire.h | 7 +++ xen/include/xen/sched.h | 21 +++++++ xen/include/xsm/dummy.h | 34 +++++++---- xen/include/xsm/xsm.h | 1 + xen/xsm/silo.c | 15 ++++- 26 files changed, 285 insertions(+), 87 deletions(-)
Signature · 1 line
2.50.0
PATCH v2 1/17 xen/xsm: Add XSM_HW_PRIV
Xen 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 capabilities, 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. The hwdom is allowed access for XSM_HW_PRIV.
Make XSM_HW_PRIV a new privilege level that is exclusive to the hardware domain
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.
---
v2:
Make XSM_HW_PRIV exclusive to hardware_domain
--- 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 | 20 ++++++++++++-------- xen/include/xsm/xsm.h | 1 + 8 files changed, 26 insertions(+), 20 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
@@ -1360,7 +1360,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
@@ -672,7 +672,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;
@@ -824,7 +824,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 +12 -8
@@ -98,6 +98,10 @@ static always_inline int xsm_default_action(if (is_control_domain (src) )return 0 ;return -EPERM ; +case XSM_HW_PRIV : +if (is_hardware_domain (src) ) +return 0 ; +return -EPERM ;default :LINKER_BUG_ON (1 );return -EPERM ;
@@ -275,7 +279,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(
@@ -455,33 +459,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 ); }
@@ -673,7 +677,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 ); }
@@ -701,7 +705,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.50.0
Re: [PATCH v2 01/17] xen/xsm: Add XSM_HW_PRIV
Quoted 15 lines · Jason Andryuk
Xen includes disctinct concepts of a control domain (privileged) and a hardware domain, but there is only a single
XSM_PRIVcheck. For dom0 this is not an issue as they are one and the same.With hyperlaunch and its build capabilities, a non-privileged hwdom and a privileged control domain should be possible. Today the hwdom fails the
XSM_PRIVchecks for hardware-related hooks which it should be allowed access to.Introduce
XSM_HW_PRIV, and use it to mark many of thephysdev_opandplatform_op. The hwdom is allowed access forXSM_HW_PRIV.Make
XSM_HW_PRIVa new privilege level that is exclusive to the hardware domain
Quoted 6 lines
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.
Despite this added paragraph, my prior concern remains of this adding finer granularity than what may be desirable in a coarse-grained world.
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_console_io( · line 283
Quoted 7 lines
xen/include/xsm/dummy.h +1
-1@@ -275,7 +279,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 ); }
This change I'm uncertain about: Why would the control domain not be permitted to interact with the console? It may, in the end, be more important for it to have access than for hwdom.
And yes, there is the ->is_console check earlier on. But for the consideration here its presence ought to not matter. Or else the change itself is meaningless (e.g. if we assumed that both would have the flag set).
Jan
Re: [PATCH v2 01/17] xen/xsm: Add XSM_HW_PRIV
Quoted 38 lines · Jan Beulich
Quoted 15 lines · Jason Andryuk
Xen includes disctinct concepts of a control domain (privileged) and a hardware domain, but there is only a single
XSM_PRIVcheck. For dom0 this is not an issue as they are one and the same.With hyperlaunch and its build capabilities, a non-privileged hwdom and a privileged control domain should be possible. Today the hwdom fails the
XSM_PRIVchecks for hardware-related hooks which it should be allowed access to.Introduce
XSM_HW_PRIV, and use it to mark many of thephysdev_opandplatform_op. The hwdom is allowed access forXSM_HW_PRIV.Make
XSM_HW_PRIVa new privilege level that is exclusive to the hardware domainQuoted 6 lines
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.
Despite this added paragraph, my prior concern remains of this adding finer granularity than what may be desirable in a coarse-grained world.
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_console_io( · line 283
Quoted 7 lines
xen/include/xsm/dummy.h +1
-1@@ -275,7 +279,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 ); }This change I'm uncertain about: Why would the control domain not be permitted to interact with the console? It may, in the end, be more important for it to have access than for hwdom.
Quoted 4 lines
And yes, there is the ->is_console check earlier on. But for the consideration here its presence ought to not matter. Or else the change itself is meaningless (e.g. if we assumed that both would have the flag set).
Linux uses the console hypercalls for xen_initial_domain(), which is hwdom. This change was useful to get that working. Looking again, is_console is not set on x86.
So setting is_console and leaving this as XSM_PRIV sounds reasonable to me.
Thanks for taking a look.
Regards,
Jason
PATCH v2 2/17 xsm/silo: Support hardware & xenstore domains
In reply to Jason AndryukIn a disaggregated environment, dom0 is split into Control, Hardware, and Xenstore domains, along with domUs. The is_control_domain() check is not sufficient to handle all these cases. Add is_priv_domain() to support allowing for the various domains.
The purpose of SILO mode is to prevent domUs from interacting with each other. But dom0 was allowed to communicate with domUs to provide services.
To provide xenstore connections, the Xenstore domain must be allowed to connect via grants and event channels. Xenstore domain must also be allowed to connect to Control and Hardware to provide xenstore to them.
Hardware domain will provide PV devices to domains, so it must be allowed to connect to domains.
That leaves Control. Xenstore and Hardware would already allow access to Control, so it can obtain services that way. Control should be "privileged", which would mean it can make the connections. But with Xenstore and Hardware providing their services to domUs, there may not be a reason to allow Control to use grants or event channels with domUs.
This silo check is for grants, event channels and argo. The dummy policy handles other calls, so Hardware is prevented from foreign mapping Control's memory with that.
---
v2:
Use single evaluate_nospec() for checks.
Remove Control
Add xenstore domain
Expand commit message
Remove always_inline
--- xen/xsm/silo.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
xen/xsm/silo.c +13 -2
@@ -20,6 +20,17 @@#define XSM_NO_WRAPPERS #include <xsm/dummy.h> +static bool is_priv_domain (const struct domain *d) +{ +/* +* Open coding of: +* is_xenstore_domain(d) || is_hardware_domain(d) +* to place all within one speculative barrier. +*/ +return evaluate_nospec ((d->options & XEN_DOMCTL_CDF_xs_domain) || + d == hardware_domain); +} +/* * Check if inter-domain communication is allowed. * Return true when pass check.
@@ -29,8 +40,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.50.0
Re: [PATCH v2 02/17] xsm/silo: Support hardware & xenstore domains
Quoted 43 lines · Jason Andryuk
In a disaggregated environment, dom0 is split into Control, Hardware, and Xenstore domains, along with domUs. The
is_control_domain()check is not sufficient to handle all these cases. Addis_priv_domain()to support allowing for the various domains.The purpose of SILO mode is to prevent domUs from interacting with each other. But dom0 was allowed to communicate with domUs to provide services.
To provide xenstore connections, the Xenstore domain must be allowed to connect via grants and event channels. Xenstore domain must also be allowed to connect to Control and Hardware to provide xenstore to them.
Hardware domain will provide PV devices to domains, so it must be allowed to connect to domains.
That leaves Control. Xenstore and Hardware would already allow access to Control, so it can obtain services that way. Control should be "privileged", which would mean it can make the connections. But with Xenstore and Hardware providing their services to domUs, there may not be a reason to allow Control to use grants or event channels with domUs.
This silo check is for grants, event channels and argo. The dummy policy handles other calls, so Hardware is prevented from foreign mapping Control's memory with that.
Signed-off-by Jason Andryuk <[email protected]>---
v2:
Use singleevaluate_nospec()for checks.
Remove Control
Add xenstore domain
Expand commit message
Removealways_inline--- xen/xsm/silo.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)xen/xsm/silo.c +0
-0
xen/xsm/silo.c line 28
Quoted 9 lines
xen/xsm/silo.c +6
-0@@ -20,6 +20,17 @@#define XSM_NO_WRAPPERS #include <xsm/dummy.h> +static bool is_priv_domain (const struct domain *d) +{ +/* +* Open coding of: +* is_xenstore_domain(d) || is_hardware_domain(d) +* to place all within one speculative barrier.
Please add a comment on why Control Domain, while privileged, is not part of this list
Quoted 23 lines
xen/xsm/silo.c +7
-2+*/ +return evaluate_nospec ((d->options & XEN_DOMCTL_CDF_xs_domain) || + d == hardware_domain); +} +/* * Check if inter-domain communication is allowed. * Return true when pass check. @@ -29,8 +40,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.50.0
Re: [PATCH v2 02/17] xsm/silo: Support hardware & xenstore domains
In reply to Jason AndryukQuoted 2 lines · Jason Andryuk
In a disaggregated environment, dom0 is split into Control, Hardware, and Xenstore domains, along with domUs.
Here we are with terminology again. In a truly disaggregated env, yet more (service) domains would come into play. What you mean here is only coarse disaggregation, as you're trying to get away without using Flask.
Quoted 12 lines
The
is_control_domain()check
is not sufficient to handle all these cases. Addis_priv_domain()to support allowing for the various domains.The purpose of SILO mode is to prevent domUs from interacting with each other. But dom0 was allowed to communicate with domUs to provide services.
To provide xenstore connections, the Xenstore domain must be allowed to connect via grants and event channels. Xenstore domain must also be allowed to connect to Control and Hardware to provide xenstore to them.
Quoted 8 lines
Hardware domain will provide PV devices to domains, so it must be allowed to connect to domains.
That leaves Control. Xenstore and Hardware would already allow access to Control, so it can obtain services that way. Control should be "privileged", which would mean it can make the connections. But with Xenstore and Hardware providing their services to domUs, there may not be a reason to allow Control to use grants or event channels with domUs.
"may not be" is too weak for my taste to forbid such.
Quoted 3 lines
This silo check is for grants, event channels and argo. The dummy policy handles other calls, so Hardware is prevented from foreign mapping Control's memory with that.
By "foreign mapping" you only mean what would result in p2m_foreign entries? But grant mapping is okay?
xen/xsm/silo.c static bool silo_mode_dom_check(const struct domain *ldom, · line 45
Quoted 9 lines
xen/xsm/silo.c +2
-2@@ -29,8 +40,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); }
IOW we're turning by 180°? Interesting ...
Jan
Re: [PATCH v2 02/17] xsm/silo: Support hardware & xenstore domains
Quoted 8 lines · Jan Beulich
Quoted 2 lines · Jason Andryuk
In a disaggregated environment, dom0 is split into Control, Hardware, and Xenstore domains, along with domUs.
Here we are with terminology again. In a truly disaggregated env, yet more (service) domains would come into play. What you mean here is only coarse disaggregation, as you're trying to get away without using Flask.
If disaggregation only means, fine grain disaggregation, then I'm not sure how to differentiate coarse. I could write "split control and hardware domain".
Quoted 15 lines
Quoted 15 lines
The
is_control_domain()check
is not sufficient to handle all these cases. Addis_priv_domain()to support allowing for the various domains.The purpose of SILO mode is to prevent domUs from interacting with each other. But dom0 was allowed to communicate with domUs to provide services.
To provide xenstore connections, the Xenstore domain must be allowed to connect via grants and event channels. Xenstore domain must also be allowed to connect to Control and Hardware to provide xenstore to them.
Hardware domain will provide PV devices to domains, so it must be allowed to connect to domains.
Quoted 7 lines
Quoted 5 lines
That leaves Control. Xenstore and Hardware would already allow access to Control, so it can obtain services that way. Control should be "privileged", which would mean it can make the connections. But with Xenstore and Hardware providing their services to domUs, there may not be a reason to allow Control to use grants or event channels with domUs.
"may not be" is too weak for my taste to forbid such.
I can't come up with a concrete example of why Control needs to directly communicate with a domU. Originally I allowed it, but it was your previous feedback which made me remove Control.
I don't have a strong opinion on the handling of Control. I can see it argued either way.
Quoted 6 lines
Quoted 3 lines
This silo check is for grants, event channels and argo. The dummy policy handles other calls, so Hardware is prevented from foreign mapping Control's memory with that.
By "foreign mapping" you only mean what would result in
p2m_foreignentries? But grant mapping is okay?
Yes, "foreign mapping" = p2m_foreign.
Using grants requires explicit actions on both sides. silo_mode_dom_check() passing still requires action by both sides to establish a communication channel.
This is different from a foreign mapping, which is a unilateral action by the privileged side.
My intent was to highlight that allowing hardware domain to pass the silo_mode_dom_check() does not grant additional is_privilege permissions.
Quoted 11 lines
xen/xsm/silo.c static bool silo_mode_dom_check(const struct domain *ldom, · line 45
Quoted 9 lines
xen/xsm/silo.c +2
-2@@ -29,8 +40,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); }IOW we're turning by 180°? Interesting ...
While the previous code is written "is_control_domain()" its use in silo mode is really "is_dom0()".
(Working on this, I've been thinking about how dom0 is like the god Janus with two faces. A single entity with two faces. We use is_control_domain() and is_hardware_domain(), but often it is just a different name for the single dom0)
As stated above, domU <-> Xenstore and domU <-> Hardware (for PV devices) are needed to allow those services. So while it looks like a 180°, maybe is_control_domain() was the wrong name for dom0?
Regards,
Jason
Re: [PATCH v2 02/17] xsm/silo: Support hardware & xenstore domains
Quoted 5 lines · Jason Andryuk
Quoted 4 lines · Jan Beulich
Quoted 2 lines · Jason Andryuk
In a disaggregated environment, dom0 is split into Control, Hardware, and Xenstore domains, along with domUs.
Quoted 8 lines
Quoted 4 lines
Here we are with terminology again. In a truly disaggregated env, yet more (service) domains would come into play. What you mean here is only coarse disaggregation, as you're trying to get away without using Flask.
If disaggregation only means, fine grain disaggregation, then I'm not sure how to differentiate coarse. I could write "split control and hardware domain".
IMO that would be better here.
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
The
is_control_domain()check
is not sufficient to handle all these cases. Addis_priv_domain()to support allowing for the various domains.The purpose of SILO mode is to prevent domUs from interacting with each other. But dom0 was allowed to communicate with domUs to provide services.
To provide xenstore connections, the Xenstore domain must be allowed to connect via grants and event channels. Xenstore domain must also be allowed to connect to Control and Hardware to provide xenstore to them.
Hardware domain will provide PV devices to domains, so it must be allowed to connect to domains.
That leaves Control. Xenstore and Hardware would already allow access to Control, so it can obtain services that way. Control should be "privileged", which would mean it can make the connections. But with Xenstore and Hardware providing their services to domUs, there may not be a reason to allow Control to use grants or event channels with domUs.
Quoted 8 lines
Quoted 1 line
"may not be" is too weak for my taste to forbid such.
I can't come up with a concrete example of why Control needs to directly communicate with a domU. Originally I allowed it, but it was your previous feedback which made me remove Control.
I don't have a strong opinion on the handling of Control. I can see it argued either way.
My comment was merely on the wording: If Control is to be excluded, the wording imo wants to be firm.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
This silo check is for grants, event channels and argo. The dummy policy handles other calls, so Hardware is prevented from foreign mapping Control's memory with that.
By "foreign mapping" you only mean what would result in
p2m_foreignentries? But grant mapping is okay?
Quoted 8 lines
Yes, "foreign mapping" =
p2m_foreign.Using grants requires explicit actions on both sides.
silo_mode_dom_check()passing still requires action by both sides to establish a communication channel.This is different from a foreign mapping, which is a unilateral action by the privileged side.
Right, yet protecting from interference may want to extend to Control e.g. having some forgotten code path installing a grant entry, which some other domain may then map.
Quoted 15 lines
Quoted 11 lines
xen/xsm/silo.c static bool silo_mode_dom_check(const struct domain *ldom, · line 45
Quoted 9 lines
xen/xsm/silo.c +2
-2@@ -29,8 +40,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); }IOW we're turning by 180°? Interesting ...
While the previous code is written "
is_control_domain()" its use in silo mode is really "is_dom0()".
Quoted 8 lines
(Working on this, I've been thinking about how dom0 is like the god Janus with two faces. A single entity with two faces. We use
is_control_domain()andis_hardware_domain(), but often it is just a different name for the single dom0)As stated above, domU <-> Xenstore and domU <-> Hardware (for PV devices) are needed to allow those services. So while it looks like a 180°, maybe
is_control_domain()was the wrong name for dom0?
The mix was - imo - a direct result of the boundaries never having been drawn properly. That's necessary now, first in an abstract way, then carried through to actual code. (Right here my remark really was just a remark anyway, because the move looked particularly heavy on the surface.)
Jan
PATCH v2 3/17 xen: Add DOMAIN_CAPS_DEVICE_MODEL & XEN_DOMCTL_CDF_device_model
In reply to Jason AndryukTo add more flexibility in system configuration add the new DOMAIN_CAPS_DEVICE_MODEL flag and XEN_DOMCTL_CDF_device_model.
Thie new flag corresponds to allowing XSM_DM_PRIV for the domain. This will enable running device model emulators (QEMU) from the assigned domain for multiple target domains.
Stubdoms assign target allowing the stubdom to serve as the device model for a single domain. This new flag allows the single domain to provide emulators for multiple guests.
The specific scenario is a disaggregated system with the hardware domain providing device models for multiple guest domains.
This permission is also enough to run xenconsoled in the hardware domain. This is a byproduct of getdomaininfo being available. The grant permissions are also configured for the console page.
The OCaml code needs the flag added in as well.
---
v2:
Add Christian's Ack
XSM_DM_PRIV falls through to the is_control_domain() check - should this be a return to make them into disjoint sets?
--- tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + xen/arch/arm/domain.c | 3 ++- xen/common/device-tree/dom0less-build.c | 3 +++ xen/common/domain.c | 3 ++- xen/include/public/bootfdt.h | 12 ++++++++++-- xen/include/public/domctl.h | 4 +++- xen/include/xen/sched.h | 9 +++++++++ xen/include/xsm/dummy.h | 2 ++ 9 files changed, 33 insertions(+), 5 deletions(-)
tools/ocaml/libs/xc/xenctrl.ml +1 -0
@@ -71,6 +71,7 @@ type domain_create_flag = | CDF_NESTED_VIRT | CDF_VPMU | CDF_TRAP_UNMAPPED_ACCESSES + | CDF_DEVICE_MODEL type domain_create_iommu_opts = | IOMMU_NO_SHAREPT
tools/ocaml/libs/xc/xenctrl.mli +1 -0
@@ -64,6 +64,7 @@ type domain_create_flag = | CDF_NESTED_VIRT | CDF_VPMU | CDF_TRAP_UNMAPPED_ACCESSES + | CDF_DEVICE_MODEL type domain_create_iommu_opts = | IOMMU_NO_SHAREPT
xen/arch/arm/domain.c +2 -1
@@ -613,7 +613,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)unsigned int flags_required = (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap);unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu | XEN_DOMCTL_CDF_xs_domain | - XEN_DOMCTL_CDF_trap_unmapped_accesses ); + XEN_DOMCTL_CDF_trap_unmapped_accesses | + XEN_DOMCTL_CDF_device_model);unsigned int sve_vl_bits =sve_decode_vl (config->arch.sve_vl);if ( (config->flags & ~flags_optional) != flags_required )
xen/common/device-tree/dom0less-build.c +3 -0
@@ -883,6 +883,9 @@ void __init create_domUs(void) d_cfg.flags |= XEN_DOMCTL_CDF_xs_domain; d_cfg.max_evtchn_port =-1 ; } + +if ( val &DOMAIN_CAPS_DEVICE_MODEL ) + d_cfg.flags |= XEN_DOMCTL_CDF_device_model; }if (dt_find_property (node,"xen,static-mem" ,NULL ) )
xen/common/domain.c +2 -1
@@ -722,7 +722,8 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off | XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu | - XEN_DOMCTL_CDF_trap_unmapped_accesses) ) + XEN_DOMCTL_CDF_trap_unmapped_accesses | + XEN_DOMCTL_CDF_device_model) ) {dprintk (XENLOG_INFO ,"Unknown CDF flags %#x\n" , config->flags);return -EINVAL ;
xen/include/public/bootfdt.h +10 -2
@@ -25,7 +25,15 @@#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) +/* +* Device model capability allows the use of the dm_op hypercalls to provide +* the device model emulation (run QEMU) for other domains. This is a +* subset of the Control capability which can be granted to the +* Hardware domain for running QEMU. +*/ +#define DOMAIN_CAPS_DEVICE_MODEL (1U << 3) + +#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ + DOMAIN_CAPS_XENSTORE | DOMAIN_CAPS_DEVICE_MODEL )#endif /* __XEN_PUBLIC_BOOTFDT_H__ */
xen/include/public/domctl.h +3 -1
@@ -68,9 +68,11 @@ struct xen_domctl_createdomain {#define XEN_DOMCTL_CDF_vpmu (1U << 7)/* Should we trap guest accesses to unmapped addresses? */ #define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8) +/* Allow domain to provide device model for multiple other domains */ +#define XEN_DOMCTL_CDF_device_model (1U << 9)/* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_trap_unmapped_accesses +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_device_modeluint32_t flags;
xen/include/xen/sched.h +9 -0
@@ -1148,6 +1148,15 @@ static always_inline bool is_control_domain(const struct domain *d)return evaluate_nospec (d->is_privileged); } +/* This check is for functionality specific to a device model domain */ +static always_inline bool is_dm_domain(const struct domain *d) +{ +if (IS_ENABLED (CONFIG_PV_SHIM_EXCLUSIVE ) ) +return false; + +return evaluate_nospec (d->options & XEN_DOMCTL_CDF_device_model); +} +#define VM_ASSIST (d, t) (test_bit(VMASST_TYPE_ ## t, &(d)->vm_assist)) static always_inline bool is_pv_domain(const struct domain *d)
xen/include/xsm/dummy.h +2 -0
@@ -91,6 +91,8 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_DM_PRIV : +if (is_dm_domain (src) ) +return 0 ;if ( target &&evaluate_nospec (src->target == target) )return 0 ; fallthrough;
Signature · 1 line
2.50.0
Re: [PATCH v2 03/17] xen: Add DOMAIN_CAPS_DEVICE_MODEL & XEN_DOMCTL_CDF_device_model
Quoted 14 lines · Jason Andryuk
To add more flexibility in system configuration add the new
DOMAIN_CAPS_DEVICE_MODELflag andXEN_DOMCTL_CDF_device_model.Thie new flag corresponds to allowing
XSM_DM_PRIVfor the domain. This will enable running device model emulators (QEMU) from the assigned domain for multiple target domains.Stubdoms assign target allowing the stubdom to serve as the device model for a single domain. This new flag allows the single domain to provide emulators for multiple guests.
The specific scenario is a disaggregated system with the hardware domain providing device models for multiple guest domains.
Quoted 8 lines
This permission is also enough to run xenconsoled in the hardware domain. This is a byproduct of getdomaininfo being available. The grant permissions are also configured for the console page.
The OCaml code needs the flag added in as well.
Signed-off-by Jason Andryuk <[email protected]>Acked-by Christian Lindig <[email protected]>
PATCH v2 4/17 xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
In reply to Jason AndryukAdd a new create domain flag to indicate if a domain can be the target of hypercalls. By default all domains can be targetted - subject to any other permission checks.
This property is useful in a safety environment to isolate domains for freedom from interference.
---DOMAIN_CAPS_NOT_HYPERCALL_TARGET duplicates the hypercall-untargetable DT property, so it could be removed. Leaving it here for now to at least illustrate the alternate approach.
--- docs/misc/arm/device-tree/booting.txt | 6 ++++++ tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + xen/arch/arm/domain.c | 3 ++- xen/common/device-tree/dom0less-build.c | 6 ++++++ xen/common/domain.c | 2 +- xen/include/public/bootfdt.h | 10 ++++++++-- xen/include/public/domctl.h | 4 +++- xen/include/xen/sched.h | 12 ++++++++++++ xen/include/xsm/dummy.h | 4 ++++ 10 files changed, 44 insertions(+), 5 deletions(-)
docs/misc/arm/device-tree/booting.txt +6 -0
@@ -307,6 +307,12 @@ with the following properties: passed through. This option is the default if this property is missing and the user does not provide the device partial device tree for the domain. +- hypercall-untargetable + + Optional. An empty property to specify the domain cannot be the target + of hypercalls. This protects a domain for freedom of interference from + other domains. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk.
tools/ocaml/libs/xc/xenctrl.ml +1 -0
@@ -72,6 +72,7 @@ type domain_create_flag = | CDF_VPMU | CDF_TRAP_UNMAPPED_ACCESSES | CDF_DEVICE_MODEL + | CDF_NOT_HYPERCALL_TARGET type domain_create_iommu_opts = | IOMMU_NO_SHAREPT
tools/ocaml/libs/xc/xenctrl.mli +1 -0
@@ -65,6 +65,7 @@ type domain_create_flag = | CDF_VPMU | CDF_TRAP_UNMAPPED_ACCESSES | CDF_DEVICE_MODEL + | CDF_NOT_HYPERCALL_TARGET type domain_create_iommu_opts = | IOMMU_NO_SHAREPT
xen/arch/arm/domain.c +2 -1
@@ -614,7 +614,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu | XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_trap_unmapped_accesses | - XEN_DOMCTL_CDF_device_model); + XEN_DOMCTL_CDF_device_model | + XEN_DOMCTL_CDF_not_hypercall_target);unsigned int sve_vl_bits =sve_decode_vl (config->arch.sve_vl);if ( (config->flags & ~flags_optional) != flags_required )
xen/common/device-tree/dom0less-build.c +6 -0
@@ -886,6 +886,9 @@ void __init create_domUs(void)if ( val &DOMAIN_CAPS_DEVICE_MODEL ) d_cfg.flags |= XEN_DOMCTL_CDF_device_model; + +if ( val &DOMAIN_CAPS_NOT_HYPERCALL_TARGET ) + d_cfg.flags |= XEN_DOMCTL_CDF_not_hypercall_target; }if (dt_find_property (node,"xen,static-mem" ,NULL ) )
@@ -896,6 +899,9 @@ void __init create_domUs(void) flags |= CDF_staticmem; } +if (dt_property_read_bool (node,"hypercall-untargetable" ) ) + d_cfg.flags |= XEN_DOMCTL_CDF_not_hypercall_target; +if (dt_property_read_bool (node,"direct-map" ) ) {if ( !(flags & CDF_staticmem) )
xen/common/domain.c +1 -1
@@ -723,7 +723,7 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu | XEN_DOMCTL_CDF_trap_unmapped_accesses | - XEN_DOMCTL_CDF_device_model) ) + XEN_DOMCTL_CDF_device_model | XEN_DOMCTL_CDF_not_hypercall_target) ) {dprintk (XENLOG_INFO ,"Unknown CDF flags %#x\n" , config->flags);return -EINVAL ;
xen/include/public/bootfdt.h +8 -2
@@ -32,8 +32,14 @@* Hardware domain for running QEMU. */ #define DOMAIN_CAPS_DEVICE_MODEL (1U << 3) +/* +* Domain cannot be the target of hypercalls. This provides the domain +* freedom from interference from other domains. +*/ +#define DOMAIN_CAPS_NOT_HYPERCALL_TARGET (1U << 4) -#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ - DOMAIN_CAPS_XENSTORE | DOMAIN_CAPS_DEVICE_MODEL ) +#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ + DOMAIN_CAPS_XENSTORE | DOMAIN_CAPS_DEVICE_MODEL | \ + DOMAIN_CAPS_NOT_HYPERCALL_TARGET)#endif /* __XEN_PUBLIC_BOOTFDT_H__ */
xen/include/public/domctl.h +3 -1
@@ -70,9 +70,11 @@ struct xen_domctl_createdomain {#define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8)/* Allow domain to provide device model for multiple other domains */ #define XEN_DOMCTL_CDF_device_model (1U << 9) +/* Domain cannot be the target of hypercalls */ +#define XEN_DOMCTL_CDF_not_hypercall_target (1U << 10)/* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_device_model +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_not_hypercall_targetuint32_t flags;
xen/include/xen/sched.h +12 -0
@@ -1157,6 +1157,18 @@ static always_inline bool is_dm_domain(const struct domain *d)return evaluate_nospec (d->options & XEN_DOMCTL_CDF_device_model); } +/* +* Return whether this domain can be the target of hypercalls from other +* domains. +*/ +static always_inline bool is_hypercall_target(const struct domain *d) +{ +if (IS_ENABLED (CONFIG_PV_SHIM_EXCLUSIVE ) ) +return true; + +return evaluate_nospec (!(d->options & XEN_DOMCTL_CDF_not_hypercall_target)); +} +#define VM_ASSIST (d, t) (test_bit(VMASST_TYPE_ ## t, &(d)->vm_assist)) static always_inline bool is_pv_domain(const struct domain *d)
xen/include/xsm/dummy.h +4 -0
@@ -91,12 +91,16 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_DM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_dm_domain (src) )return 0 ;if ( target &&evaluate_nospec (src->target == target) )return 0 ; fallthrough;case XSM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_control_domain (src) )return 0 ;return -EPERM ;
Signature · 1 line
2.50.0
Re: [PATCH v2 04/17] xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
Quoted 30 lines · Jason Andryuk
Add a new create domain flag to indicate if a domain can be the target of hypercalls. By default all domains can be targetted - subject to any other permission checks.
This property is useful in a safety environment to isolate domains for freedom from interference.
Signed-off-by Jason Andryuk <[email protected]>---
DOMAIN_CAPS_NOT_HYPERCALL_TARGETduplicates the hypercall-untargetable DT property, so it could be removed. Leaving it here for now to at least illustrate the alternate approach.--- docs/misc/arm/device-tree/booting.txt | 6 ++++++ tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + xen/arch/arm/domain.c | 3 ++- xen/common/device-tree/dom0less-build.c | 6 ++++++ xen/common/domain.c | 2 +- xen/include/public/bootfdt.h | 10 ++++++++-- xen/include/public/domctl.h | 4 +++- xen/include/xen/sched.h | 12 ++++++++++++ xen/include/xsm/dummy.h | 4 ++++ 10 files changed, 44 insertions(+), 5 deletions(-)docs/misc/arm/device-tree/booting.txt +0
-0
docs/misc/arm/device-tree/booting.txt with the following properties: · line 314
Quoted 8 lines
docs/misc/arm/device-tree/booting.txt +5
-0@@ -307,6 +307,12 @@ with the following properties: passed through. This option is the default if this property is missing and the user does not provide the device partial device tree for the domain. +- hypercall-untargetable + + Optional. An empty property to specify the domain cannot be the target + of hypercalls. This protects a domain for freedom of interference from + other domains.
This protects a domain from interference
or
This protects a domain ensuring freedom of interference from other domains
Quoted 164 lines
docs/misc/arm/device-tree/booting.txt +0
-0Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk.tools/ocaml/libs/xc/xenctrl.ml +1
-0@@ -72,6 +72,7 @@ type domain_create_flag = | CDF_VPMU | CDF_TRAP_UNMAPPED_ACCESSES | CDF_DEVICE_MODEL + | CDF_NOT_HYPERCALL_TARGET type domain_create_iommu_opts = | IOMMU_NO_SHAREPTtools/ocaml/libs/xc/xenctrl.mli +1
-0@@ -65,6 +65,7 @@ type domain_create_flag = | CDF_VPMU | CDF_TRAP_UNMAPPED_ACCESSES | CDF_DEVICE_MODEL + | CDF_NOT_HYPERCALL_TARGET type domain_create_iommu_opts = | IOMMU_NO_SHAREPTxen/arch/arm/domain.c +2
-1@@ -614,7 +614,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu | XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_trap_unmapped_accesses | - XEN_DOMCTL_CDF_device_model); + XEN_DOMCTL_CDF_device_model | + XEN_DOMCTL_CDF_not_hypercall_target);unsigned int sve_vl_bits =sve_decode_vl (config->arch.sve_vl);if ( (config->flags & ~flags_optional) != flags_required )xen/common/device-tree/dom0less-build.c +6
-0@@ -886,6 +886,9 @@ void __init create_domUs(void)if ( val &DOMAIN_CAPS_DEVICE_MODEL ) d_cfg.flags |= XEN_DOMCTL_CDF_device_model; + +if ( val &DOMAIN_CAPS_NOT_HYPERCALL_TARGET ) + d_cfg.flags |= XEN_DOMCTL_CDF_not_hypercall_target; }if (dt_find_property (node,"xen,static-mem" ,NULL ) )@@ -896,6 +899,9 @@ void __init create_domUs(void) flags |= CDF_staticmem; } +if (dt_property_read_bool (node,"hypercall-untargetable" ) ) + d_cfg.flags |= XEN_DOMCTL_CDF_not_hypercall_target; +if (dt_property_read_bool (node,"direct-map" ) ) {if ( !(flags & CDF_staticmem) )xen/common/domain.c +1
-1@@ -723,7 +723,7 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu | XEN_DOMCTL_CDF_trap_unmapped_accesses | - XEN_DOMCTL_CDF_device_model) ) + XEN_DOMCTL_CDF_device_model | XEN_DOMCTL_CDF_not_hypercall_target) ) {dprintk (XENLOG_INFO ,"Unknown CDF flags %#x\n" , config->flags);return -EINVAL ;xen/include/public/bootfdt.h +8
-2@@ -32,8 +32,14 @@* Hardware domain for running QEMU. */ #define DOMAIN_CAPS_DEVICE_MODEL (1U << 3) +/* +* Domain cannot be the target of hypercalls. This provides the domain +* freedom from interference from other domains. +*/ +#define DOMAIN_CAPS_NOT_HYPERCALL_TARGET (1U << 4) -#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ - DOMAIN_CAPS_XENSTORE | DOMAIN_CAPS_DEVICE_MODEL ) +#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ + DOMAIN_CAPS_XENSTORE | DOMAIN_CAPS_DEVICE_MODEL | \ + DOMAIN_CAPS_NOT_HYPERCALL_TARGET)#endif /* __XEN_PUBLIC_BOOTFDT_H__ */ xen/include/public/domctl.h +3
-1@@ -70,9 +70,11 @@ struct xen_domctl_createdomain {#define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8)/* Allow domain to provide device model for multiple other domains */ #define XEN_DOMCTL_CDF_device_model (1U << 9) +/* Domain cannot be the target of hypercalls */ +#define XEN_DOMCTL_CDF_not_hypercall_target (1U << 10)/* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_device_model +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_not_hypercall_targetuint32_t flags;xen/include/xen/sched.h +12
-0@@ -1157,6 +1157,18 @@ static always_inline bool is_dm_domain(const struct domain *d)return evaluate_nospec (d->options & XEN_DOMCTL_CDF_device_model); } +/* +* Return whether this domain can be the target of hypercalls from other +* domains. +*/ +static always_inline bool is_hypercall_target(const struct domain *d) +{ +if (IS_ENABLED (CONFIG_PV_SHIM_EXCLUSIVE ) ) +return true; + +return evaluate_nospec (!(d->options & XEN_DOMCTL_CDF_not_hypercall_target)); +} +#define VM_ASSIST (d, t) (test_bit(VMASST_TYPE_ ## t, &(d)->vm_assist)) static always_inline bool is_pv_domain(const struct domain *d)xen/include/xsm/dummy.h +4
-0@@ -91,12 +91,16 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_DM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_dm_domain (src) )return 0 ;if ( target &&evaluate_nospec (src->target == target) )return 0 ; fallthrough;case XSM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_control_domain (src) )return 0 ;return -EPERM ;Signature · 1 line
2.50.0
Re: [PATCH v2 04/17] xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
In reply to Jason AndryukHi Jason,
Quoted 6 lines · Jason Andryuk
Add a new create domain flag to indicate if a domain can be the target of hypercalls. By default all domains can be targetted - subject to any other permission checks.
This property is useful in a safety environment to isolate domains for freedom from interference.
I see the flag is exposed to the toolstack. However, I don't see how you can successfully create a VM if you are not allowed to call hypercalls (for instance to add some memory).
I think, at minimum, you would want to allow hypercalls while the domain is created. That said, I wonder if this setup would not be better to describe with XSM?
[...]
Quoted 5 lines
xen/include/public/domctl.h +0
-0
xen/include/public/domctl.h struct xen_domctl_createdomain { · line 77
Quoted 9 lines
xen/include/public/domctl.h +3
-1@@ -70,9 +70,11 @@ struct xen_domctl_createdomain {#define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8)/* Allow domain to provide device model for multiple other domains */ #define XEN_DOMCTL_CDF_device_model (1U << 9) +/* Domain cannot be the target of hypercalls */ +#define XEN_DOMCTL_CDF_not_hypercall_target (1U << 10)/* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_device_model +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_not_hypercall_target
I am not sure where to comment. But aren't both flags mutually exclusive?
Quoted 11 lines
xen/include/xsm/dummy.h +2
-0@@ -91,12 +91,16 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_DM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_dm_domain (src) )
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 106
Quoted 10 lines
xen/include/xsm/dummy.h +2
-0return 0 ;if ( target &&evaluate_nospec (src->target == target) )return 0 ; fallthrough;case XSM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_control_domain (src) )return 0 ;return -EPERM ;
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 04/17] xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
Hi Julien,
Thanks for taking a look.
Quoted 11 lines · Julien Grall
Hi Jason,
Quoted 6 lines · Jason Andryuk
Add a new create domain flag to indicate if a domain can be the target of hypercalls. By default all domains can be targetted - subject to any other permission checks.
This property is useful in a safety environment to isolate domains for freedom from interference.
I see the flag is exposed to the toolstack. However, I don't see how you can successfully create a VM if you are not allowed to call hypercalls (for instance to add some memory).
Yes, you are right. With dom0less/Hyperlaunch, I'd not been considering the toolstack.
Quoted 1 line
I think, at minimum, you would want to allow hypercalls while the domain is created. That said, I wonder if this setup would not be better to describe with XSM?
Re-labeling with Flask would allow different permissions between building and running. domain_unpause would need to be allowed, but that doesn't stop a domain.
At first glance, like you say, the untargetable property could be enabled when domain creation finishes.
Quoted 18 lines
[...]
xen/include/public/domctl.h struct xen_domctl_createdomain { · line 76
Quoted 13 lines
xen/include/public/domctl.h +3
-1@@ -70,9 +70,11 @@ struct xen_domctl_createdomain { #define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8) /* Allow domain to provide device model for multiple other domains */ #define XEN_DOMCTL_CDF_device_model (1U << 9) +/* Domain cannot be the target of hypercalls */ +#define XEN_DOMCTL_CDF_not_hypercall_target (1U << 10) /* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_device_model +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_not_hypercall_targetI am not sure where to comment. But aren't both flags mutually exclusive?
No, XEN_DOMCTL_CDF_device_model is *this* domain providing the device model to other domains:
+ * Device model capability allows the use of the dm_op hypercalls to provide
+ * the device model emulation (run QEMU) for other domains. This is a
+ * subset of the Control capability which can be granted to the
+ * Hardware domain for running QEMU.
Whereas XEN_DOMCTL_CDF_not_hypercall_target removes targeting on *this* domain. So the domain with XEN_DOMCTL_CDF_device_model cannot target the XEN_DOMCTL_CDF_not_hypercall_target domain.
Regards,
Jason
Re: [PATCH v2 04/17] xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
Hi Jason,
Quoted 18 lines · Jason Andryuk
Quoted 7 lines
Quoted 7 lines
xen/include/public/domctl.h +0
-0@@ -70,9 +70,11 @@ struct xen_domctl_createdomain { #define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8) /* Allow domain to provide device model for multiple other domains */Quoted 8 lines
xen/include/public/domctl.h struct xen_domctl_createdomain { · line 77
Quoted 6 lines
xen/include/public/domctl.h +3
-1#define XEN_DOMCTL_CDF_device_model (1U << 9) +/* Domain cannot be the target of hypercalls */ +#define XEN_DOMCTL_CDF_not_hypercall_target (1U << 10) /* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_device_model +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_not_hypercall_targetI am not sure where to comment. But aren't both flags mutually exclusive?
No,
XEN_DOMCTL_CDF_device_modelis *this* domain providing the device model to other domains:
Quoted 7 lines
+ * Device model capability allows the use of the
dm_ophypercalls to provide
+ * the device model emulation (run QEMU) for other domains. This is a
+ * subset of the Control capability which can be granted to the
+ * Hardware domain for running QEMU.Whereas
XEN_DOMCTL_CDF_not_hypercall_targetremoves targeting on *this* domain. So the domain withXEN_DOMCTL_CDF_device_modelcannot target theXEN_DOMCTL_CDF_not_hypercall_targetdomain.
Thanks for the clarification. I misunderstood the goal of XEN_DOMCTL_CDF_device_model. That said, I think there is still a problem because with CDF_not_hypercall_target, you would not be able to have a device-emulator for that domain. Is this intended?
Cheers,
Quoted 3 lines
Regards,
Jason
Signature · 1 line
Julien Grall
Re: [PATCH v2 04/17] xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
Quoted 27 lines · Julien Grall
Hi Jason,
Quoted 24 lines · Jason Andryuk
Quoted 7 lines
Quoted 7 lines
xen/include/public/domctl.h +0
-0@@ -70,9 +70,11 @@ struct xen_domctl_createdomain { #define XEN_DOMCTL_CDF_trap_unmapped_accesses (1U << 8) /* Allow domain to provide device model for multiple other domains */Quoted 8 lines
xen/include/public/domctl.h struct xen_domctl_createdomain { · line 77
Quoted 6 lines
xen/include/public/domctl.h +3
-1#define XEN_DOMCTL_CDF_device_model (1U << 9) +/* Domain cannot be the target of hypercalls */ +#define XEN_DOMCTL_CDF_not_hypercall_target (1U << 10) /* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_device_model +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_not_hypercall_targetI am not sure where to comment. But aren't both flags mutually exclusive?
No,
XEN_DOMCTL_CDF_device_modelis *this* domain providing the device model to other domains:+ * Device model capability allows the use of the
dm_ophypercalls to provide
+ * the device model emulation (run QEMU) for other domains. This is a
+ * subset of the Control capability which can be granted to the
+ * Hardware domain for running QEMU.
Quoted 3 lines
Quoted 1 line
Whereas
XEN_DOMCTL_CDF_not_hypercall_targetremoves targeting on *this* domain. So the domain withXEN_DOMCTL_CDF_device_modelcannot target theXEN_DOMCTL_CDF_not_hypercall_targetdomain.Thanks for the clarification. I misunderstood the goal of
XEN_DOMCTL_CDF_device_model. That said, I think there is still a problem because withCDF_not_hypercall_target, you would not be able to have a device-emulator for that domain. Is this intended?
Yes, it is intentional that CDF_not_hypercall_target prevents using a device model. With out safety use-case, we want to be able to avoid interference for specific domains.
Regards,
Jason
Re: [PATCH v2 04/17] xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
In reply to Jason AndryukQuoted 3 lines · Jason Andryuk
Add a new create domain flag to indicate if a domain can be the target of hypercalls. By default all domains can be targetted - subject to any other permission checks.
I think terminology needs clarifying here: What exactly does "targeted" mean? Is that e.g. also intended to cover XENMEM_{current,maximum}_reservation, which "target" a particular domain, when at the same time they don't interfere with the targeted domain in any way?
Quoted 6 lines
xen/include/xsm/dummy.h +0
-0@@ -91,12 +91,16 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_DM_PRIV :
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 103
Quoted 10 lines
xen/include/xsm/dummy.h +4
-0+if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_dm_domain (src) )return 0 ;if ( target &&evaluate_nospec (src->target == target) )return 0 ; fallthrough;case XSM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;
Hmm, for TARGET, XS_PRIV, and DM_PRIV we're now doing the same check twice.
Jan
Quoted 3 lines
xen/include/xsm/dummy.h +0
-0if (is_control_domain (src) )return 0 ;return -EPERM ;
Re: [PATCH v2 04/17] xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
Quoted 10 lines · Jan Beulich
Quoted 3 lines · Jason Andryuk
Add a new create domain flag to indicate if a domain can be the target of hypercalls. By default all domains can be targetted - subject to any other permission checks.
I think terminology needs clarifying here: What exactly does "targeted" mean? Is that e.g. also intended to cover XENMEM_{current,maximum}_reservation, which "target" a particular domain, when at the same time they don't interfere with the targeted domain in any way?
Avoiding interference is the primary goal. Those hypercalls definitely need to be blocked. xsm_default_action() has limited information available, so we can't differentiate particular hypercalls. Blocking extra non-interfering hypercalls is not a problem for us.
Quoted 11 lines
Quoted 11 lines
xen/include/xsm/dummy.h +2
-0@@ -91,12 +91,16 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_DM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_dm_domain (src) )return 0 ;if ( target &&evaluate_nospec (src->target == target) )
Quoted 8 lines
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 103
Quoted 5 lines
xen/include/xsm/dummy.h +2
-0return 0 ; fallthrough;case XSM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;Hmm, for TARGET,
XS_PRIV, andDM_PRIVwe're now doing the same check twice.
The different cases need to be covered somehow. I didn't see a good way to avoid the duplication.
Regards,
Jason
Re: [PATCH v2 04/17] xen: Introduce XEN_DOMCTL_CDF_not_hypercall_target
Quoted 12 lines · Jason Andryuk
Quoted 10 lines · Jan Beulich
Quoted 3 lines · Jason Andryuk
Add a new create domain flag to indicate if a domain can be the target of hypercalls. By default all domains can be targetted - subject to any other permission checks.
I think terminology needs clarifying here: What exactly does "targeted" mean? Is that e.g. also intended to cover XENMEM_{current,maximum}_reservation, which "target" a particular domain, when at the same time they don't interfere with the targeted domain in any way?
Quoted 4 lines
Avoiding interference is the primary goal. Those hypercalls definitely need to be blocked.
xsm_default_action()has limited information available, so we can't differentiate particular hypercalls. Blocking extra non-interfering hypercalls is not a problem for us.
Except that later patches then "punch holes" into the fence pulled up here. And over time we may learn that more holes are needed, or at least wanted.
Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
xen/include/xsm/dummy.h +2
-0@@ -91,12 +91,16 @@ static always_inline int xsm_default_action(return 0 ; fallthrough;case XSM_DM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;if (is_dm_domain (src) )return 0 ;if ( target &&evaluate_nospec (src->target == target) )Quoted 8 lines
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 103
Quoted 5 lines
xen/include/xsm/dummy.h +2
-0return 0 ; fallthrough;case XSM_PRIV : +if ( target && !is_hypercall_target (target) ) +return -EPERM ;Hmm, for TARGET,
XS_PRIV, andDM_PRIVwe're now doing the same check twice.
Quoted 2 lines
The different cases need to be covered somehow. I didn't see a good way to avoid the duplication.
Maybe this is the point where the fall-through wants (needs?) doing away with.
Jan
PATCH v2 5/17 xen/dom0less: Workaround XSM for evtchn_alloc_unbound
In reply to Jason AndryukWhen used with an untargetable domain, xsm_evtchn_unbound fails even though the idle domain has is_privileged = true. Switch current to the domain under construction so that event channel creation is allowed as XSM_TARGET.
---
v2:
New
This was Jan's suggestion when dom0less originally had trouble with evtchn_alloc_unbound() and xsm_set_system_active() was introduced. As noted, is_privileged is insufficient for operating on an untargetable domain.
--- xen/common/device-tree/dom0less-build.c | 9 +++++++++ 1 file changed, 9 insertions(+)
xen/common/device-tree/dom0less-build.c +9 -0
@@ -77,11 +77,20 @@ bool __init is_dom0less_mode(void)static int __init alloc_xenstore_evtchn (struct domain *d) {evtchn_alloc_unbound_t alloc; +struct vcpu *old_current;int rc; alloc.dom = d->domain_id; alloc.remote_dom = xs_domid; +/* +* Switch current from the Xen idle vcpu to the domain's vcpu. This is to +* pass the xsm_evtchn_unbound() check for an untargetable domain. +*/ + old_current = current; +set_current (d->vcpu[0 ]); rc =evtchn_alloc_unbound (&alloc,0 ); +/* Restore Xen idle vcpu. */ +set_current (old_current);if ( rc ) {printk ("Failed allocating event channel for domain\n" );
Signature · 1 line
2.50.0
Re: [PATCH v2 05/17] xen/dom0less: Workaround XSM for evtchn_alloc_unbound
Quoted 6 lines · Jason Andryuk
When used with an untargetable domain,
xsm_evtchn_unboundfails even though the idle domain hasis_privileged= true. Switch current to the domain under construction so that event channel creation is allowed asXSM_TARGET.Signed-off-by Jason Andryuk <[email protected]>
Quoted 41 lines
---
v2:
NewThis was Jan's suggestion when dom0less originally had trouble with
evtchn_alloc_unbound()andxsm_set_system_active()was introduced. As noted,is_privilegedis insufficient for operating on an untargetable domain.--- xen/common/device-tree/dom0less-build.c | 9 +++++++++ 1 file changed, 9 insertions(+)xen/common/device-tree/dom0less-build.c +9
-0@@ -77,11 +77,20 @@ bool __init is_dom0less_mode(void)static int __init alloc_xenstore_evtchn (struct domain *d) {evtchn_alloc_unbound_t alloc; +struct vcpu *old_current;int rc; alloc.dom = d->domain_id; alloc.remote_dom = xs_domid; +/* +* Switch current from the Xen idle vcpu to the domain's vcpu. This is to +* pass the xsm_evtchn_unbound() check for an untargetable domain. +*/ + old_current = current; +set_current (d->vcpu[0 ]); rc =evtchn_alloc_unbound (&alloc,0 ); +/* Restore Xen idle vcpu. */ +set_current (old_current);if ( rc ) {printk ("Failed allocating event channel for domain\n" );Signature · 1 line
2.50.0
PATCH v2 6/17 xen/xsm: Expand XSM_XS_PRIV for untargetable domains
In reply to Jason AndryukUntargetable domains are currently hidden from the control domain - e.g. xl list will not show them. getdomaininfo fails on the !is_hypercall_target() check in XSM_TARGET. Add control domain to the XSM_XS_PRIV check so it can pass.
--- xen/include/xsm/dummy.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/include/xsm/dummy.h +2 -1
@@ -87,7 +87,8 @@ static always_inline int xsm_default_action( fallthrough;case XSM_XS_PRIV :if ( action ==XSM_XS_PRIV && -evaluate_nospec (is_xenstore_domain (src)) ) + (evaluate_nospec (is_xenstore_domain (src)) || +is_control_domain (src)) )return 0 ; fallthrough;case XSM_DM_PRIV :
Signature · 1 line
2.50.0
Re: [PATCH v2 06/17] xen/xsm: Expand XSM_XS_PRIV for untargetable domains
Quoted 6 lines · Jason Andryuk
Untargetable domains are currently hidden from the control domain - e.g. xl list will not show them. getdomaininfo fails on the !is_hypercall_target() check in
XSM_TARGET. Add control domain to theXSM_XS_PRIVcheck so it can pass.Signed-off-by Jason Andryuk <[email protected]>
XSM_XS_PRIV is only used in XEN_DOMCTL_get_domain_state, XEN_DOMCTL_getdomaininfo and XEN_SYSCTL_getdomaininfolist, so it makes sense to me
Quoted 22 lines
--- xen/include/xsm/dummy.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/include/xsm/dummy.h +2
-1@@ -87,7 +87,8 @@ static always_inline int xsm_default_action( fallthrough;case XSM_XS_PRIV :if ( action ==XSM_XS_PRIV && -evaluate_nospec (is_xenstore_domain (src)) ) + (evaluate_nospec (is_xenstore_domain (src)) || +is_control_domain (src)) )return 0 ; fallthrough;case XSM_DM_PRIV :Signature · 1 line
2.50.0
Re: [PATCH v2 06/17] xen/xsm: Expand XSM_XS_PRIV for untargetable domains
In reply to Jason AndryukQuoted 4 lines · Jason Andryuk
Untargetable domains are currently hidden from the control domain - e.g. xl list will not show them. getdomaininfo fails on the !is_hypercall_target() check in
XSM_TARGET. Add control domain to theXSM_XS_PRIVcheck so it can pass.
This feels like a pretty gross abuse of XS_PRIV. It once again supports my take that the level of granularity you want will require Flask. Or of course you could also come up with a new access control mechanism, much lighter-weight than Flask, but still not dummy nor SILO.
As per my reply to an earlier patch - whether it is okay to prevent e.g. "xl list" to see all domains is questionable as well. I'm not seeing "interference" there.
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 91
Quoted 9 lines
xen/include/xsm/dummy.h +2
-1@@ -87,7 +87,8 @@ static always_inline int xsm_default_action( fallthrough;case XSM_XS_PRIV :if ( action ==XSM_XS_PRIV && -evaluate_nospec (is_xenstore_domain (src)) ) + (evaluate_nospec (is_xenstore_domain (src)) || +is_control_domain (src)) )
Like in patch 2 (in is_priv_domain()), I think this wants collapsing the two evaluate_nospec() into a single one.
Jan
Re: [PATCH v2 06/17] xen/xsm: Expand XSM_XS_PRIV for untargetable domains
Quoted 10 lines · Jan Beulich
Quoted 4 lines · Jason Andryuk
Untargetable domains are currently hidden from the control domain - e.g. xl list will not show them. getdomaininfo fails on the !is_hypercall_target() check in
XSM_TARGET. Add control domain to theXSM_XS_PRIVcheck so it can pass.This feels like a pretty gross abuse of
XS_PRIV. It once again supports my take that the level of granularity you want will require Flask. Or of course you could also come up with a new access control mechanism, much lighter-weight than Flask, but still not dummy nor SILO.
I considered a new XSM module, but it just seemed so close to the dummy policy. From my perspective the board permissions of xsm_default_action() already implement the coarse permissions we need.
SILO works well because it builds on that and overrides a few hooks. A new XSM module would need to re-implement ~every hook since xsm_default_action() needs to change. So expanding xsm_default_action() seemed like a better approach to try.
Quoted 3 lines
As per my reply to an earlier patch - whether it is okay to prevent e.g. "xl list" to see all domains is questionable as well. I'm not seeing "interference" there.
Yes, hiding domains from xl list seemed like it was going too far. A system administrator should be able to see everything running on the system. That's why this patch allows it.
Quoted 4 lines
Quoted 4 lines
xen/include/xsm/dummy.h +0
-0@@ -87,7 +87,8 @@ static always_inline int xsm_default_action( fallthrough;
Quoted 8 lines
xen/include/xsm/dummy.h static always_inline int xsm_default_action( · line 91
Quoted 5 lines
xen/include/xsm/dummy.h +2
-1case XSM_XS_PRIV :if ( action ==XSM_XS_PRIV && -evaluate_nospec (is_xenstore_domain (src)) ) + (evaluate_nospec (is_xenstore_domain (src)) || +is_control_domain (src)) )Like in patch 2 (in
is_priv_domain()), I think this wants collapsing the twoevaluate_nospec()into a single one.
Ok, thanks.
Regards,
Jason
PATCH v2 7/17 xsm/dummy: Allow HVMOP_get_param for control domain
In reply to Jason AndryukThe Control domain is denied access to an untargetable domain. However init-dom0less wants to read the xenstore event channel HVM param to determine if xenstore should be set up.
This is a read operation, so it is not modifying the domain. Special case the HVMOP_get_param operation for is_control_domain(). It is done in xsm_hvm_param() because xsm_default_action() is too complicated. HVMOP_get_param should be allowed for a domain itself (XSM_TARGET) and its device model - src->target or is_dm_domain(). It should otherwise be denied for untargetable domains. xsm_default_action() doesn't have sufficient information to identify the particular operation, so put it in xsm_hvm_param().
---
It's messy, but I couldn't think of a better way.
--- xen/include/xsm/dummy.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
xen/include/xsm/dummy.h +4 -1
@@ -621,7 +621,10 @@ 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); +/* Special case to allow init-dom0less to read HVM params. */ +if ( op == HVMOP_get_param &&is_control_domain (current->domain) ) +return 0 ; +return xsm_default_action (XSM_TARGET , current->domain, d); } static XSM_INLINE int cf_check xsm_hvm_param_altp2mhvm(
Signature · 1 line
2.50.0
Re: [PATCH v2 07/17] xsm/dummy: Allow HVMOP_get_param for control domain
Quoted 3 lines · Jason Andryuk
The Control domain is denied access to an untargetable domain. However init-dom0less wants to read the xenstore event channel HVM param to determine if xenstore should be set up.
This could be done differently, for instance if xs_is_domain_introduced returns true, we can assume that xenstore doesn't need to be setup. Then we don't need to call xc_hvm_param_get. At that point we don't need this patch?
Quoted 36 lines
This is a read operation, so it is not modifying the domain. Special case the
HVMOP_get_paramoperation foris_control_domain(). It is done inxsm_hvm_param()becausexsm_default_action()is too complicated.HVMOP_get_paramshould be allowed for a domain itself (XSM_TARGET) and its device model -src->targetoris_dm_domain(). It should otherwise be denied for untargetable domains.xsm_default_action()doesn't have sufficient information to identify the particular operation, so put it inxsm_hvm_param().Signed-off-by Jason Andryuk <[email protected]>---
It's messy, but I couldn't think of a better way.--- xen/include/xsm/dummy.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)xen/include/xsm/dummy.h +4
-1@@ -621,7 +621,10 @@ 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); +/* Special case to allow init-dom0less to read HVM params. */ +if ( op == HVMOP_get_param &&is_control_domain (current->domain) ) +return 0 ; +return xsm_default_action (XSM_TARGET , current->domain, d); } static XSM_INLINE int cf_check xsm_hvm_param_altp2mhvm(Signature · 1 line
2.50.0
Re: [PATCH v2 07/17] xsm/dummy: Allow HVMOP_get_param for control domain
In reply to Jason AndryukQuoted 13 lines · Jason Andryuk
The Control domain is denied access to an untargetable domain. However init-dom0less wants to read the xenstore event channel HVM param to determine if xenstore should be set up.
This is a read operation, so it is not modifying the domain. Special case the
HVMOP_get_paramoperation foris_control_domain(). It is done inxsm_hvm_param()becausexsm_default_action()is too complicated.HVMOP_get_paramshould be allowed for a domain itself (XSM_TARGET) and its device model -src->targetoris_dm_domain(). It should otherwise be denied for untargetable domains.xsm_default_action()doesn't have sufficient information to identify the particular operation, so put it inxsm_hvm_param().
Quoted 3 lines
Signed-off-by Jason Andryuk <[email protected]>---
It's messy, but I couldn't think of a better way.
Fits well with my remarks on earlier patches. The granularity you want simply can't be had this way, unless you use such undesirable "overrides".
Jan
Re: [PATCH v2 07/17] xsm/dummy: Allow HVMOP_get_param for control domain
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Jason Andryuk
The Control domain is denied access to an untargetable domain. However init-dom0less wants to read the xenstore event channel HVM param to determine if xenstore should be set up.
This is a read operation, so it is not modifying the domain. Special case the
HVMOP_get_paramoperation foris_control_domain(). It is done inxsm_hvm_param()becausexsm_default_action()is too complicated.HVMOP_get_paramshould be allowed for a domain itself (XSM_TARGET) and its device model -src->targetoris_dm_domain(). It should otherwise be denied for untargetable domains.xsm_default_action()doesn't have sufficient information to identify the particular operation, so put it inxsm_hvm_param().
Quoted 6 lines
Quoted 3 lines
Signed-off-by Jason Andryuk <[email protected]>---
It's messy, but I couldn't think of a better way.Fits well with my remarks on earlier patches. The granularity you want simply can't be had this way, unless you use such undesirable "overrides".
Following Stefano's suggestion, this patch can be dropped. With xenstored auto-introducing predefined domains, init-dom0less can use the introduced state to determine which domains to handle.
Regards,
Jason
PATCH v2 8/17 public/io: xs_wire: Include event channel in interface page
In reply to Jason AndryukInclude the event channel in struct xenstore_domain_interface. This way the toolstack or xen can communicate the event channel to xenstored in memory xenstored already needs to access.
xenstored maps the grant with the well known GNTTAB_RESERVED_XENSTORE index, so no further information is needed.
--- xen/include/public/io/xs_wire.h | 7 +++++++ 1 file changed, 7 insertions(+)
xen/include/public/io/xs_wire.h +7 -0
@@ -110,6 +110,7 @@ struct xenstore_domain_interface {uint32_t server_features;/* Bitmap of features supported by the server */ uint32_t connection;uint32_t error; +uint32_t evtchn_port; };/* Violating this is very bad. See docs/misc/xenstore.txt. */
@@ -134,6 +135,12 @@ struct xenstore_domain_interface {#define XENSTORE_ERROR_RINGIDX 2/* Invalid ring index */ #define XENSTORE_ERROR_PROTO 3/* Protocol violation (payload too long) */ +/* +* The evtchn_port field is the domU's event channel for xenstored to signal. +* It is filled in by Xen for dom0less/Hyperlaunch domains. It is only used +* when non-zero. Otherwise the event channel from XS_INTRODUCE is used. +*/ +#endif /* _XS_WIRE_H */ /*
Signature · 1 line
2.50.0
Re: [PATCH v2 08/17] public/io: xs_wire: Include event channel in interface page
Quoted 26 lines · Jason Andryuk
Include the event channel in struct
xenstore_domain_interface. This way the toolstack or xen can communicate the event channel to xenstored in memory xenstored already needs to access.xenstored maps the grant with the well known
GNTTAB_RESERVED_XENSTOREindex, so no further information is needed.Suggested-by Juergen Gross <[email protected]>Signed-off-by Jason Andryuk <[email protected]>--- xen/include/public/io/xs_wire.h | 7 +++++++ 1 file changed, 7 insertions(+)xen/include/public/io/xs_wire.h +1
-0@@ -110,6 +110,7 @@ struct xenstore_domain_interface {uint32_t server_features;/* Bitmap of features supported by the server */ uint32_t connection;uint32_t error; +uint32_t evtchn_port; };/* Violating this is very bad. See docs/misc/xenstore.txt. */
xen/include/public/io/xs_wire.h struct xenstore_domain_interface { · line 139
Quoted 5 lines
xen/include/public/io/xs_wire.h +2
-0@@ -134,6 +135,12 @@ struct xenstore_domain_interface {#define XENSTORE_ERROR_RINGIDX 2/* Invalid ring index */ #define XENSTORE_ERROR_PROTO 3/* Protocol violation (payload too long) */ +/* +* The evtchn_port field is the domU's event channel for xenstored to signal.
Nit:
s/domU/domain/
This might be the interface of dom0 to a xenstore-stubdom, so "domU" is not fully appropriate.
With that fixed:
Juergen
PATCH v2 9/17 xen/dom0less: store xenstore event channel in page
In reply to Jason AndryukWrite the associated event channel into the xenstore page so xenstored can read it. xenstored can map the grant by the reserved grant table entry, and then read out the event channel and bind it. This eliminates the need for an additional mechanism to discover the event channel.
--- xen/common/device-tree/dom0less-build.c | 7 +++++++ 1 file changed, 7 insertions(+)
xen/common/device-tree/dom0less-build.c +7 -0
@@ -26,6 +26,7 @@#include <public/io/xs_wire.h> #include <asm/dom0less-build.h> +#include <asm/guest_access.h> #include <asm/setup.h> #include <xen/static-memory.h>
@@ -126,8 +127,14 @@ static void __init initialize_domU_xenstore(void)if ( gfn !=XENSTORE_PFN_LATE_ALLOC &&IS_ENABLED (CONFIG_GRANT_TABLE ) ) { +evtchn_port_t port = d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN ]; +paddr_t evtchn_gaddr =gfn_to_gaddr (_gfn (gfn)) + + offsetof(struct xenstore_domain_interface , evtchn_port); +ASSERT (gfn <UINT32_MAX );gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, gfn); +access_guest_memory_by_gpa (d, evtchn_gaddr, &port,sizeof (port), + true/* is_write */ ); } } }
Signature · 1 line
2.50.0
Re: [PATCH v2 09/17] xen/dom0less: store xenstore event channel in page
Quoted 24 lines · Jason Andryuk
Write the associated event channel into the xenstore page so xenstored can read it. xenstored can map the grant by the reserved grant table entry, and then read out the event channel and bind it. This eliminates the need for an additional mechanism to discover the event channel.
Signed-off-by Jason Andryuk <[email protected]>--- xen/common/device-tree/dom0less-build.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/common/device-tree/dom0less-build.c +1
-0@@ -26,6 +26,7 @@#include <public/io/xs_wire.h> #include <asm/dom0less-build.h> +#include <asm/guest_access.h> #include <asm/setup.h> #include <xen/static-memory.h> @@ -126,8 +127,14 @@ static void __init initialize_domU_xenstore(void)
xen/common/device-tree/dom0less-build.c static void __init initialize_domU_xenstore(void) · line 137
Quoted 10 lines
xen/common/device-tree/dom0less-build.c +6
-0if ( gfn !=XENSTORE_PFN_LATE_ALLOC &&IS_ENABLED (CONFIG_GRANT_TABLE ) ) { +evtchn_port_t port = d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN ]; +paddr_t evtchn_gaddr =gfn_to_gaddr (_gfn (gfn)) + + offsetof(struct xenstore_domain_interface , evtchn_port); +ASSERT (gfn <UINT32_MAX );gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, gfn); +access_guest_memory_by_gpa (d, evtchn_gaddr, &port,sizeof (port), + true/* is_write */ );
I couldn't find access_guest_memory_by_gpa() for x86. I think you either need to introduce it for all archs, or you need to handle this differently.
Juergen
Re: [PATCH v2 09/17] xen/dom0less: store xenstore event channel in page
Quoted 25 lines · Juergen Gross
Quoted 24 lines · Jason Andryuk
Write the associated event channel into the xenstore page so xenstored can read it. xenstored can map the grant by the reserved grant table entry, and then read out the event channel and bind it. This eliminates the need for an additional mechanism to discover the event channel.
Signed-off-by Jason Andryuk <[email protected]>--- xen/common/device-tree/dom0less-build.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/common/device-tree/dom0less-build.c +1
-0@@ -26,6 +26,7 @@#include <public/io/xs_wire.h> #include <asm/dom0less-build.h> +#include <asm/guest_access.h> #include <asm/setup.h> #include <xen/static-memory.h> @@ -126,8 +127,14 @@ static void __init initialize_domU_xenstore(void)
Quoted 13 lines
xen/common/device-tree/dom0less-build.c static void __init initialize_domU_xenstore(void) · line 137
Quoted 10 lines
xen/common/device-tree/dom0less-build.c +6
-0if ( gfn !=XENSTORE_PFN_LATE_ALLOC &&IS_ENABLED (CONFIG_GRANT_TABLE ) ) { +evtchn_port_t port = d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN ]; +paddr_t evtchn_gaddr =gfn_to_gaddr (_gfn (gfn)) + + offsetof(struct xenstore_domain_interface , evtchn_port); +ASSERT (gfn <UINT32_MAX );gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, gfn); +access_guest_memory_by_gpa (d, evtchn_gaddr, &port,sizeof (port), + true/* is_write */ );I couldn't find
access_guest_memory_by_gpa()for x86. I think you either need to introduce it for all archs, or you need to handle this differently.
This code isn't buildable (yet) for x86, is it? There's a series of Alejandro's moving in that direction, but that didn't go in yet. And even then aiui this file would still be excluded.
Jan
Re: [PATCH v2 09/17] xen/dom0less: store xenstore event channel in page
Quoted 40 lines · Jan Beulich
Quoted 25 lines · Juergen Gross
Quoted 24 lines · Jason Andryuk
Write the associated event channel into the xenstore page so xenstored can read it. xenstored can map the grant by the reserved grant table entry, and then read out the event channel and bind it. This eliminates the need for an additional mechanism to discover the event channel.
Signed-off-by Jason Andryuk <[email protected]>--- xen/common/device-tree/dom0less-build.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/common/device-tree/dom0less-build.c +1
-0@@ -26,6 +26,7 @@#include <public/io/xs_wire.h> #include <asm/dom0less-build.h> +#include <asm/guest_access.h> #include <asm/setup.h> #include <xen/static-memory.h> @@ -126,8 +127,14 @@ static void __init initialize_domU_xenstore(void)Quoted 13 lines
xen/common/device-tree/dom0less-build.c static void __init initialize_domU_xenstore(void) · line 137
Quoted 10 lines
xen/common/device-tree/dom0less-build.c +6
-0if ( gfn !=XENSTORE_PFN_LATE_ALLOC &&IS_ENABLED (CONFIG_GRANT_TABLE ) ) { +evtchn_port_t port = d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN ]; +paddr_t evtchn_gaddr =gfn_to_gaddr (_gfn (gfn)) + + offsetof(struct xenstore_domain_interface , evtchn_port); +ASSERT (gfn <UINT32_MAX );gnttab_seed_entry (d,GNTTAB_RESERVED_XENSTORE , xs_domid, gfn); +access_guest_memory_by_gpa (d, evtchn_gaddr, &port,sizeof (port), + true/* is_write */ );I couldn't find
access_guest_memory_by_gpa()for x86. I think you either need to introduce it for all archs, or you need to handle this differently.
Quoted 3 lines
This code isn't buildable (yet) for x86, is it? There's a series of Alejandro's moving in that direction, but that didn't go in yet. And even then aiui this file would still be excluded.
I think this would need to be explicitly mentioned in the commit message then. I thought this whole work would be targeting x86 as well, but I might be wrong, of course.
Juergen
Re: [PATCH v2 09/17] xen/dom0less: store xenstore event channel in page
Quoted 41 lines · Jürgen Groß
Quoted 40 lines · Jan Beulich
Quoted 38 lines · Juergen Gross
Quoted 24 lines · Jason Andryuk
Write the associated event channel into the xenstore page so xenstored can read it. xenstored can map the grant by the reserved grant table entry, and then read out the event channel and bind it. This eliminates the need for an additional mechanism to discover the event channel.
Signed-off-by Jason Andryuk <[email protected]>---
xen/common/device-tree/dom0less-build.c| 7 +++++++1 file changed, 7 insertions(+)xen/common/device-tree/dom0less-build.c +2
-0@@ -26,6 +26,7 @@ #include <public/io/xs_wire.h> #include <asm/dom0less-build.h> +#include <asm/guest_access.h> #include <asm/setup.h> #include <xen/static-memory.h>@@ -126,8 +127,14 @@ static void __init initialize_domU_xenstore(void) if ( gfn != XENSTORE_PFN_LATE_ALLOC && IS_ENABLED(CONFIG_GRANT_TABLE) ) { + evtchn_port_t port = d-xen/common/device-tree/dom0less-build.c static void __init initialize_domU_xenstore(void) · line 139
Quoted 10 lines
xen/common/device-tree/dom0less-build.c +5
-0>arch.hvm.params[HVM_PARAM_STORE_EVTCHN]; + paddr_t evtchn_gaddr = gfn_to_gaddr(_gfn(gfn)) + + offsetof(struct xenstore_domain_interface, evtchn_port); + ASSERT(gfn < UINT32_MAX); gnttab_seed_entry(d, GNTTAB_RESERVED_XENSTORE, xs_domid, gfn); + access_guest_memory_by_gpa(d, evtchn_gaddr, &port,sizeof (port), + true /* is_write */);I couldn't find
access_guest_memory_by_gpa()for x86. I think you either need to introduce it for all archs, or you need to handle this differently.
Quoted 7 lines
Quoted 3 lines
This code isn't buildable (yet) for x86, is it? There's a series of Alejandro's moving in that direction, but that didn't go in yet. And even then aiui this file would still be excluded.
I think this would need to be explicitly mentioned in the commit message then. I thought this whole work would be targeting x86 as well, but I might be wrong, of course.
Truth be told, I wrote this when dom0less was still in arch/arm. For x86, I modified the hyperlaunch code to use hvm_copy_to_guest_phys(). Looks like Xen needs some unified accessors.
Thanks,
Jason
PATCH v2 10/17 tools/xenstored: Read event channel from xenstored page
In reply to Jason AndryukMake introduce_domain() use an event channel from the the xenstore page. It is only used if non-zero. Otherwise the passed in event channel port is used.
The is useful for a xenstored stubdom to configure domains autonomously.
--- tools/xenstored/domain.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/xenstored/domain.c +6 -0
@@ -1021,9 +1021,15 @@ static struct domain *introduce_domain(const void *ctx,return NULL ;if (!domain->introduced) { +evtchn_port_t iface_port; interface =map_interface (domid);if (!interface && !restore)return NULL ; + + iface_port = interface->evtchn_port; +if (iface_port) + port = iface_port; +if (new_domain (domain, port, restore)) { rc = errno;if (interface)
Signature · 1 line
2.50.0
Re: [PATCH v2 10/17] tools/xenstored: Read event channel from xenstored page
Quoted 18 lines · Jason Andryuk
Make
introduce_domain()use an event channel from the the xenstore page. It is only used if non-zero. Otherwise the passed in event channel port is used.The is useful for a xenstored stubdom to configure domains autonomously.
Signed-off-by Jason Andryuk <[email protected]>--- tools/xenstored/domain.c | 6 ++++++ 1 file changed, 6 insertions(+)tools/xenstored/domain.c +0
-0@@ -1021,9 +1021,15 @@ static struct domain *introduce_domain(const void *ctx,return NULL ;
tools/xenstored/domain.c static struct domain *introduce_domain(const void *ctx, · line 1032
Quoted 10 lines
tools/xenstored/domain.c +6
-0if (!domain->introduced) { +evtchn_port_t iface_port; interface =map_interface (domid);if (!interface && !restore)return NULL ; + + iface_port = interface->evtchn_port; +if (iface_port) + port = iface_port; +
Any reason you introduced iface_port?
I think you could just use:
+ if (interface->evtchn_port)
+ port = interface->evtchn_port;
In case the guest is modifying the field in parallel, it would only shoot itself in the foot. So there is no real risk in a possible double read.
Juergen
Re: [PATCH v2 10/17] tools/xenstored: Read event channel from xenstored page
Quoted 32 lines · Juergen Gross
Quoted 18 lines · Jason Andryuk
Make
introduce_domain()use an event channel from the the xenstore page. It is only used if non-zero. Otherwise the passed in event channel port is used.The is useful for a xenstored stubdom to configure domains autonomously.
Signed-off-by Jason Andryuk <[email protected]>---
tools/xenstored/domain.c| 6 ++++++1 file changed, 6 insertions(+)tools/xenstored/domain.c +0
-0@@ -1021,9 +1021,15 @@ static struct domain *introduce_domain(const void *ctx, return NULL;tools/xenstored/domain.c static struct domain *introduce_domain(const · line 1032
Quoted 10 lines
tools/xenstored/domain.c +6
-0if (!domain->introduced) { + evtchn_port_t iface_port; interface = map_interface(domid); if (!interface && !restore) return NULL; + + iface_port = interface->evtchn_port; + if (iface_port) + port = iface_port; +Any reason you introduced
iface_port?
Quoted 4 lines
I think you could just use:
+ if (
interface->evtchn_port)
+ port =interface->evtchn_port;
Yes, I think this would be fine.
Thanks,
Jason
PATCH v2 11/17 xen: Add capabilities to get_domain_state
In reply to Jason AndryukExpose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.
The xenstore domain can use this information to assign appropriate permissions on connections.
Repurpose the 16bit pad field for this purpose.
--- xen/common/domain.c | 8 +++++++- xen/include/public/domctl.h | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-)
xen/common/domain.c +7 -1
@@ -195,6 +195,12 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info, info->state |=XEN_DOMCTL_GETDOMSTATE_STATE_DYING ;if ( d->is_dying == DOMDYING_dead ) info->state |=XEN_DOMCTL_GETDOMSTATE_STATE_DEAD ; +if (is_control_domain (d) ) + info->caps |=XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL ; +if (is_hardware_domain (d) ) + info->caps |=XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE ; +if (is_xenstore_domain (d) ) + info->caps |=XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE ; info->unique_id = d->unique_id; }
@@ -205,7 +211,7 @@ int get_domain_state(struct xen_domctl_get_domain_state *info, struct domain *d,int rc = -ENOENT ;struct domain *hdl; -if ( info->pad0 || info->pad1 ) +if ( info->pad0 )return -EINVAL ;if ( d )
xen/include/public/domctl.h +5 -2
@@ -1269,8 +1269,11 @@ struct xen_domctl_get_domain_state {#define XEN_DOMCTL_GETDOMSTATE_STATE_SHUTDOWN 0x0002/* Shutdown finished. */ #define XEN_DOMCTL_GETDOMSTATE_STATE_DYING 0x0004/* Domain dying. */ #define XEN_DOMCTL_GETDOMSTATE_STATE_DEAD 0x0008/* Domain dead. */ -uint16_t pad0;/* Must be 0 on input, returned as 0. */ -uint32_t pad1;/* Must be 0 on input, returned as 0. */ +uint16_t caps;/* Must be 0 on input, returned as 0. */ +#define XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL 0x0001/* Control domain. */ +#define XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE 0x0002/* Hardware domain. */ +#define XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE 0x0004/* Xenstore domain. */ +uint32_t pad0;/* Must be 0 on input, returned as 0. */ uint64_t unique_id;/* Unique domain identifier. */ };
Signature · 1 line
2.50.0
Re: [PATCH v2 11/17] xen: Add capabilities to get_domain_state
Quoted 45 lines · Jason Andryuk
Expose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.
The xenstore domain can use this information to assign appropriate permissions on connections.
Repurpose the 16bit pad field for this purpose.
Signed-off-by Jason Andryuk <[email protected]>--- xen/common/domain.c | 8 +++++++- xen/include/public/domctl.h | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-)xen/common/domain.c +7
-1@@ -195,6 +195,12 @@ static void set_domain_state_info(struct xen_domctl_get_domain_state *info, info->state |=XEN_DOMCTL_GETDOMSTATE_STATE_DYING ;if ( d->is_dying == DOMDYING_dead ) info->state |=XEN_DOMCTL_GETDOMSTATE_STATE_DEAD ; +if (is_control_domain (d) ) + info->caps |=XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL ; +if (is_hardware_domain (d) ) + info->caps |=XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE ; +if (is_xenstore_domain (d) ) + info->caps |=XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE ; info->unique_id = d->unique_id; }@@ -205,7 +211,7 @@ int get_domain_state(struct xen_domctl_get_domain_state *info, struct domain *d,int rc = -ENOENT ;struct domain *hdl; -if ( info->pad0 || info->pad1 ) +if ( info->pad0 )return -EINVAL ;if ( d )xen/include/public/domctl.h +0
-0
xen/include/public/domctl.h struct xen_domctl_get_domain_state { · line 1272
Quoted 6 lines
xen/include/public/domctl.h +1
-2@@ -1269,8 +1269,11 @@ struct xen_domctl_get_domain_state {#define XEN_DOMCTL_GETDOMSTATE_STATE_SHUTDOWN 0x0002/* Shutdown finished. */ #define XEN_DOMCTL_GETDOMSTATE_STATE_DYING 0x0004/* Domain dying. */ #define XEN_DOMCTL_GETDOMSTATE_STATE_DEAD 0x0008/* Domain dead. */ -uint16_t pad0;/* Must be 0 on input, returned as 0. */ -uint32_t pad1;/* Must be 0 on input, returned as 0. */ +uint16_t caps;/* Must be 0 on input, returned as 0. */
I'd drop the "returned as 0" in the comment. :-)
With that fixed:
Juergen
Re: [PATCH v2 11/17] xen: Add capabilities to get_domain_state
Quoted 15 lines · Juergen Gross
Quoted 14 lines · Jason Andryuk
Expose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.
The xenstore domain can use this information to assign appropriate permissions on connections.
Repurpose the 16bit pad field for this purpose.
Signed-off-by Jason Andryuk <[email protected]>---
xen/common/domain.c | 8 +++++++-
xen/include/public/domctl.h| 7 +++++--2 files changed, 12 insertions(+), 3 deletions(-)
Quoted 9 lines
xen/common/domain.c static void set_domain_state_info(struct · line 198
Quoted 9 lines
xen/common/domain.c +0
-0@@ -195,6 +195,12 @@ static void set_domain_state_info(structxen_domctl_get_domain_state *info, info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING; if ( d->is_dying == DOMDYING_dead ) info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;
I'll add:
+
+ info->caps = 0
here, to ensure all the caps bits start off cleared.
Quoted 9 lines
Quoted 8 lines
xen/common/domain.c +6
-0+ if ( is_control_domain(d) ) + info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL; + if ( is_hardware_domain(d) ) + info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE; + if ( is_xenstore_domain(d) ) + info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE; info->unique_id = d->unique_id; }
Quoted 13 lines
xen/include/public/domctl.h struct xen_domctl_get_domain_state { · line 1272
Quoted 11 lines
xen/include/public/domctl.h +1
-2@@ -1269,8 +1269,11 @@ struct xen_domctl_get_domain_state { #define XEN_DOMCTL_GETDOMSTATE_STATE_SHUTDOWN 0x0002 /* Shutdown finished. */ #define XEN_DOMCTL_GETDOMSTATE_STATE_DYING 0x0004 /* Domain dying. */ #define XEN_DOMCTL_GETDOMSTATE_STATE_DEAD 0x0008 /* Domain dead. */ - uint16_t pad0; /* Must be 0 on input, returned as 0. */ - uint32_t pad1; /* Must be 0 on input, returned as 0. */ + uint16_t caps; /* Must be 0 on input, returned as 0. */I'd drop the "returned as 0" in the comment. :-)
:)
I'll drop the whole comment since the input value is not checked.
Quoted 3 lines
With that fixed:
Reviewed-by Juergen Gross <[email protected]>
Does this stand with the above changes?
Thanks,
Jason
Re: [PATCH v2 11/17] xen: Add capabilities to get_domain_state
Quoted 58 lines · Jason Andryuk
Quoted 15 lines · Juergen Gross
Quoted 14 lines · Jason Andryuk
Expose a domain's capabilities - control, hardware or xenstore - through stable get domain state hypercall.
The xenstore domain can use this information to assign appropriate permissions on connections.
Repurpose the 16bit pad field for this purpose.
Signed-off-by Jason Andryuk <[email protected]>---
xen/common/domain.c | 8 +++++++-
xen/include/public/domctl.h| 7 +++++--2 files changed, 12 insertions(+), 3 deletions(-)Quoted 9 lines
xen/common/domain.c static void set_domain_state_info(struct · line 198
Quoted 9 lines
xen/common/domain.c +0
-0@@ -195,6 +195,12 @@ static void set_domain_state_info(structxen_domctl_get_domain_state *info, info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DYING; if ( d->is_dying == DOMDYING_dead ) info->state |= XEN_DOMCTL_GETDOMSTATE_STATE_DEAD;I'll add:
+
+info->caps= 0here, to ensure all the caps bits start off cleared.
Quoted 9 lines
Quoted 8 lines
xen/common/domain.c +6
-0+ if ( is_control_domain(d) ) + info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL; + if ( is_hardware_domain(d) ) + info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE; + if ( is_xenstore_domain(d) ) + info->caps |= XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE; info->unique_id = d->unique_id; }Quoted 13 lines
xen/include/public/domctl.h struct xen_domctl_get_domain_state { · line 1272
Quoted 11 lines
xen/include/public/domctl.h +1
-2@@ -1269,8 +1269,11 @@ struct xen_domctl_get_domain_state { #define XEN_DOMCTL_GETDOMSTATE_STATE_SHUTDOWN 0x0002 /* Shutdown finished. */ #define XEN_DOMCTL_GETDOMSTATE_STATE_DYING 0x0004 /* Domain dying. */ #define XEN_DOMCTL_GETDOMSTATE_STATE_DEAD 0x0008 /* Domain dead. */ - uint16_t pad0; /* Must be 0 on input, returned as 0. */ - uint32_t pad1; /* Must be 0 on input, returned as 0. */ + uint16_t caps; /* Must be 0 on input, returned as 0. */I'd drop the "returned as 0" in the comment. :-)
:)
Quoted 7 lines
I'll drop the whole comment since the input value is not checked.
Quoted 3 lines
With that fixed:
Reviewed-by Juergen Gross <[email protected]>Does this stand with the above changes?
Yes, it does.
Juergen
PATCH v2 12/17 tools/manage: Expose domain capabilities
In reply to Jason AndryukAdd an additional "caps" argument to the libxenmanage functions to obtain a domains capabilities - control, hardware, and xenstore.
Update the xenstored callers at the same time.
--- tools/include/xenmanage.h | 14 ++++++++++++-- tools/libs/manage/core.c | 21 +++++++++++++++++---- tools/xenstored/domain.c | 8 ++++---- 3 files changed, 33 insertions(+), 10 deletions(-)
tools/include/xenmanage.h +12 -2
@@ -45,6 +45,12 @@ int xenmanage_close(xenmanage_handle *hdl);#define XENMANAGE_GETDOMSTATE_STATE_DYING 0x0004/* Domain dying. */ #define XENMANAGE_GETDOMSTATE_STATE_DEAD 0x0008/* Domain dead. */ +/* Control Domain capability. */ +#define XENMANAGE_GETDOMSTATE_CAP_CONTROL 0x0001 +/* Hardware Domain capability. */ +#define XENMANAGE_GETDOMSTATE_CAP_HARDWARE 0x0002 +/* Xenstore Domain capability. */ +#define XENMANAGE_GETDOMSTATE_CAP_XENSTORE 0x0004/* * Return state information of an existing domain. *
@@ -59,7 +65,8 @@ int xenmanage_close(xenmanage_handle *hdl);* Return value: 0 if information was stored, -1 else (errno is set) */ int xenmanage_get_domain_info (xenmanage_handle *hdl,unsigned int domid, -unsigned int *state,uint64_t *unique_id); +unsigned int *state,unsigned int *caps, +uint64_t *unique_id);/* * Return information of a domain having changed state recently.
@@ -73,12 +80,15 @@ int xenmanage_get_domain_info(xenmanage_handle *hdl, unsigned int domid,* domid: where to store the domid of the domain (not NULL) * state: where to store the state (XENMANAGE_GETDOMSTATE_STATE_ flags, * nothing stored if NULL) +* caps: where to store the capabilities (XENMANAGE_GETDOMSTATE_CAP_ +* flags, nothing stored if NULL) * unique_id: where to store the unique id of the domain (nothing stored if * NULL) * Return value: 0 if information was stored, -1 else (errno is set) */ int xenmanage_poll_changed_domain (xenmanage_handle *hdl,unsigned int *domid, -unsigned int *state,uint64_t *unique_id); +unsigned int *state,unsigned int *caps, +uint64_t *unique_id);#endif /* XENMANAGE_H */ /*
tools/libs/manage/core.c +17 -4
@@ -92,6 +92,7 @@ static int xenmanage_do_domctl_get_domain_state(xenmanage_handle *hdl,unsigned int domid_in, unsigned int *domid_out, unsigned int *state, + unsigned int *caps, uint64_t *unique_id) { struct xen_domctl *buf;
@@ -130,6 +131,16 @@ static int xenmanage_do_domctl_get_domain_state(xenmanage_handle *hdl,if ( st->state &XEN_DOMCTL_GETDOMSTATE_STATE_DEAD ) *state |=XENMANAGE_GETDOMSTATE_STATE_DEAD ; } +if ( caps ) + { + *caps =0 ; +if ( st->caps &XEN_DOMCTL_GETDOMSTATE_CAP_CONTROL ) + *caps |=XENMANAGE_GETDOMSTATE_CAP_CONTROL ; +if ( st->caps &XEN_DOMCTL_GETDOMSTATE_CAP_HARDWARE ) + *caps |=XENMANAGE_GETDOMSTATE_CAP_HARDWARE ; +if ( st->caps &XEN_DOMCTL_GETDOMSTATE_CAP_XENSTORE ) + *caps |=XENMANAGE_GETDOMSTATE_CAP_XENSTORE ; + }if ( unique_id ) *unique_id = st->unique_id; }
@@ -142,7 +153,8 @@ static int xenmanage_do_domctl_get_domain_state(xenmanage_handle *hdl, }int xenmanage_get_domain_info (xenmanage_handle *hdl,unsigned int domid, -unsigned int *state,uint64_t *unique_id) +unsigned int *state,unsigned int *caps, +uint64_t *unique_id) {if ( !hdl || domid >=DOMID_FIRST_RESERVED ) {
@@ -150,12 +162,13 @@ int xenmanage_get_domain_info(xenmanage_handle *hdl, unsigned int domid,return -1 ; } -return xenmanage_do_domctl_get_domain_state (hdl, domid,NULL , state, +return xenmanage_do_domctl_get_domain_state (hdl, domid,NULL , state, caps, unique_id); }int xenmanage_poll_changed_domain (xenmanage_handle *hdl,unsigned int *domid, -unsigned int *state,uint64_t *unique_id) +unsigned int *state,unsigned int *caps, +uint64_t *unique_id) {if ( !hdl || !domid ) {
@@ -164,5 +177,5 @@ int xenmanage_poll_changed_domain(xenmanage_handle *hdl, unsigned int *domid, }return xenmanage_do_domctl_get_domain_state (hdl,DOMID_INVALID , domid, - state, unique_id); + state, caps, unique_id); }
tools/xenstored/domain.c +4 -4
@@ -667,7 +667,7 @@ static int check_domain(const void *k, void *v, void *arg)unsigned int state;uint64_t unique_id; -if (xenmanage_get_domain_info (xm_handle, domain->domid, &state, +if (xenmanage_get_domain_info (xm_handle, domain->domid, &state,NULL , &unique_id)) { unique_id =0 ; state =0 ;
@@ -700,7 +700,7 @@ static void do_check_domains(void)struct domain *domain;bool notify = false; -while (!xenmanage_poll_changed_domain (xm_handle, &domid, &state, +while (!xenmanage_poll_changed_domain (xm_handle, &domid, &state,NULL , &unique_id)) { domain =find_domain_struct (domid);if (domain)
@@ -829,7 +829,7 @@ static struct domain *find_or_alloc_existing_domain(unsigned int domid) domain =find_domain_struct (domid);if (!domain || !domain->unique_id) dom_valid = !xenmanage_get_domain_info (xm_handle, domid, -NULL , &unique_id); +NULL ,NULL , &unique_id);if (dom_valid) {if (!domain)
@@ -1383,7 +1383,7 @@ int domain_alloc_permrefs(struct node_perms *perms) domid = perms->p[i].id; d =find_domain_struct (domid);if (!d) { -if (xenmanage_get_domain_info (xm_handle, domid, +if (xenmanage_get_domain_info (xm_handle, domid,NULL ,NULL , &unique_id)) perms->p[i].perms |=XS_PERM_IGNORE ;else if (!alloc_domain (NULL , domid, unique_id))
Signature · 1 line
2.50.0
Re: [PATCH v2 12/17] tools/manage: Expose domain capabilities
Quoted 4 lines · Jason Andryuk
Add an additional "caps" argument to the libxenmanage functions to obtain a domains capabilities - control, hardware, and xenstore.
Update the xenstored callers at the same time.
Luckily the interface was only introduced in the current devel cycle, so no need for playing "stable interface" games. :-)
Quoted 2 lines
Signed-off-by Jason Andryuk <[email protected]>
Juergen
Re: [PATCH v2 12/17] tools/manage: Expose domain capabilities
Quoted 8 lines · Juergen Gross
Quoted 4 lines · Jason Andryuk
Add an additional "caps" argument to the libxenmanage functions to obtain a domains capabilities - control, hardware, and xenstore.
Update the xenstored callers at the same time.
Luckily the interface was only introduced in the current devel cycle, so no need for playing "stable interface" games. :-)
Yes :)
Having said that, for compatibility, will we need some way to query Xen for a mask of valid capability bits? That way a caller can differentiate between "this domain doesn't have a capability" and "this hypervisor doesn't support a capability."
Quoted 4 lines
Quoted 2 lines
Signed-off-by Jason Andryuk <[email protected]>Reviewed-by Juergen Gross <[email protected]>
Thanks,
Jason
Re: [PATCH v2 12/17] tools/manage: Expose domain capabilities
Quoted 5 lines · Jason Andryuk
Quoted 4 lines · Juergen Gross
Quoted 3 lines · Jason Andryuk
Add an additional "caps" argument to the libxenmanage functions to obtain a domains capabilities - control, hardware, and xenstore.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Update the xenstored callers at the same time.
Luckily the interface was only introduced in the current devel cycle, so no need for playing "stable interface" games. :-)
Yes :)
Having said that, for compatibility, will we need some way to query Xen for a mask of valid capability bits? That way a caller can differentiate between "this domain doesn't have a capability" and "this hypervisor doesn't support a capability."
Not for now, but in future this will probably be needed, whenever new states and/or capabilities are added.
Juergen
PATCH v2 13/17 tools/xenstored: Delay firing special watches
In reply to Jason Andryukfire_special_watches() can only be called after setup_structure() has been called. If it is called before setup_structure(), the hashtable search will segfault as the nodes hashtable has not been allocated.
Normally, dom0 is setup up first and setup_structure() runs before any other domain.
If we iterate xenmanage_poll_changed_domain() to discover domains, there is no guarantee the local domain running xenstored will be created first. Suppress firing special watches until the hashtable has been allocated.
---
With a known domid, xenstored could construct that first and the iterate skipping itself.
--- tools/xenstored/core.c | 5 +++++ tools/xenstored/core.h | 1 + tools/xenstored/domain.c | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-)
tools/xenstored/core.c +5 -0
@@ -2321,6 +2321,11 @@ void setup_structure(bool live_update) } } +bool setup_structure_complete (void ) +{ +return nodes !=NULL ; +} +int remember_string (struct hashtable *hash,const char *str) {char *k =talloc_strdup (NULL , str);
tools/xenstored/core.h +1 -0
@@ -301,6 +301,7 @@ const struct node *read_node_const(struct connection *conn, const void *ctx,int rm_node (struct connection *conn,const void *ctx,const char *name);void setup_structure (bool live_update); +bool setup_structure_complete (void );struct connection *new_connection (const struct interface_funcs *funcs);struct connection *add_socket_connection (int fd);struct connection *get_connection_by_id (unsigned int conn_id);
tools/xenstored/domain.c +5 -1
@@ -579,9 +579,13 @@ static void domain_tree_remove(struct domain *domain)static void fire_special_watches (const char *name) { -void *ctx =talloc_new (NULL ); +void *ctx;const struct node *node; +if (!setup_structure_complete ()) +return ; + + ctx =talloc_new (NULL );if (!ctx)return ;
Signature · 1 line
2.50.0
Re: [PATCH v2 13/17] tools/xenstored: Delay firing special watches
Quoted 12 lines · Jason Andryuk
fire_special_watches()can only be called aftersetup_structure()has been called. If it is called beforesetup_structure(), the hashtable search will segfault as the nodes hashtable has not been allocated.Normally, dom0 is setup up first and
setup_structure()runs before any other domain.If we iterate
xenmanage_poll_changed_domain()to discover domains, there is no guarantee the local domain running xenstored will be created first. Suppress firing special watches until the hashtable has been allocated.
Quoted 4 lines
Signed-off-by Jason Andryuk <[email protected]>---
With a known domid, xenstored could construct that first and the iterate skipping itself.
Another solution would be to modify the next patch to first scan the initial domains in a loop and only then introduce them after knowing which one is hosting Xenstore.
Juergen
PATCH v2 14/17 tools/xenstored: Auto-introduce domains
In reply to Jason AndryukReplace dom0_init() with init_domains() which uses libxenmanage to iterate through all existing domains and introduce them.
dom0_domid is updated with the xenstore domain, since it really indicates the local domain.
priv_domid is set to the control domain. This makes it limited to a single domain.
These features let xenstore automatically connect any existing domains, which means it doesn't need to be done manually from init-dom0less.
For a legacy dom0, the result should be unchanged.
For a late xenstore stubdom it should also be the same, but priv_domid would be set automatically to control domain (which default to 0 normally).
Always signal the event channel for initial domains. This gets dom0 (a local xenstored domain) to connect.
Also always write XENSTORE_CONNECTED since we know we are connected at this point.
--- tools/xenstored/core.c | 2 +- tools/xenstored/domain.c | 45 +++++++++++++++++++++++++++++++--------- tools/xenstored/domain.h | 2 +- 3 files changed, 37 insertions(+), 12 deletions(-)
tools/xenstored/core.c +1 -1
@@ -2762,7 +2762,7 @@ int main(int argc, char *argv[])/* Listen to hypervisor. */ if (!live_update) {domain_init (-1 ); -dom0_init (); +init_domains (); }/* redirect to /dev/null now we're ready to accept connections */
tools/xenstored/domain.c +35 -10
55 lines not on this page · raw message
tools/xenstored/domain.h +1 -1
@@ -84,7 +84,7 @@ int do_reset_watches(const void *ctx, struct connection *conn,void domain_early_init (void );void domain_init (int evtfd); -void dom0_init (void ); +void init_domains (void );void stubdom_init (void );void domain_deinit (void );void ignore_connection (struct connection *conn,unsigned int err);
Signature · 1 line
2.50.0
Re: [PATCH v2 14/17] tools/xenstored: Auto-introduce domains
Quoted 5 lines · Jason Andryuk
Replace
dom0_init()withinit_domains()which uses libxenmanage to iterate through all existing domains and introduce them.
dom0_domidis updated with the xenstore domain, since it really indicates the local domain.
I agree with that explanation, but I wonder whether this explanation doesn't indicate that a rename of the dom0_domid variable is wanted, e.g. to "store_domid".
Quoted 2 lines
priv_domidis set to the control domain. This makes it limited to a single domain.
Maybe another candidate for renaming (ctrl_domid?).
Quoted 63 lines
These features let xenstore automatically connect any existing domains, which means it doesn't need to be done manually from init-dom0less.
For a legacy dom0, the result should be unchanged.
For a late xenstore stubdom it should also be the same, but
priv_domidwould be set automatically to control domain (which default to 0 normally).Always signal the event channel for initial domains. This gets dom0 (a local xenstored domain) to connect.
Also always write
XENSTORE_CONNECTEDsince we know we are connected at this point.Signed-off-by Jason Andryuk <[email protected]>--- tools/xenstored/core.c | 2 +- tools/xenstored/domain.c | 45 +++++++++++++++++++++++++++++++--------- tools/xenstored/domain.h | 2 +- 3 files changed, 37 insertions(+), 12 deletions(-)tools/xenstored/core.c +1
-1@@ -2762,7 +2762,7 @@ int main(int argc, char *argv[])/* Listen to hypervisor. */ if (!live_update) {domain_init (-1 ); -dom0_init (); +init_domains (); }/* redirect to /dev/null now we're ready to accept connections */ tools/xenstored/domain.c +16
-3@@ -1257,20 +1257,45 @@ const char *get_implicit_path(const struct connection *conn)return conn->domain->path; } -void dom0_init (void ) +void init_domains (void ) { -evtchn_port_t port; -struct domain *dom0; +unsigned int domid; +unsigned int state; +unsigned int caps; +uint64_t unique_id; + +while (!xenmanage_poll_changed_domain (xm_handle, &domid, &state, &caps, + &unique_id)) { +evtchn_port_t port =0 ; +struct domain *domain; + +if (caps &XENMANAGE_GETDOMSTATE_CAP_XENSTORE ) + dom0_domid = domid; + +if (caps &XENMANAGE_GETDOMSTATE_CAP_CONTROL ) + priv_domid = domid;
tools/xenstored/domain.c const char *get_implicit_path(const struct connection *conn) · line 1283
Quoted 10 lines
tools/xenstored/domain.c +6
-3- port =get_xenbus_evtchn (); -if (port ==-1 ) -barf_perror ("Failed to initialize dom0 port" ); +if (domid == dom0_domid) { + port =get_xenbus_evtchn (); +if (port ==-1 ) +barf_perror ("Failed to initialize dom%u port" , + domid); + }
I don't think this is correct for a xenstore-stubdom. See stubdom_init().
Quoted 27 lines
tools/xenstored/domain.c +13
-4+ + domain =introduce_domain (NULL , domid, port, false); +if (!domain) { +xprintf ("Could not initialize dom%u" , domid); +continue ; + } - dom0 =introduce_domain (NULL ,xenbus_master_domid (), port, false); -if (!dom0) -barf_perror ("Failed to initialize dom0" ); +domain_conn_reset (domain); -xenevtchn_notify (xce_handle, dom0->port); +if (domain->interface) + domain->interface->connection =XENSTORE_CONNECTED ; + +/* Notify the domain that xenstore is available */ +xenevtchn_notify (xce_handle, domain->port); + } }void stubdom_init (void )tools/xenstored/domain.h +0
-0
tools/xenstored/domain.h int do_reset_watches(const void *ctx, struct connection *conn, · line 90
Quoted 8 lines
tools/xenstored/domain.h +1
-1@@ -84,7 +84,7 @@ int do_reset_watches(const void *ctx, struct connection *conn,void domain_early_init (void );void domain_init (int evtfd); -void dom0_init (void ); +void init_domains (void );void stubdom_init (void );void domain_deinit (void );void ignore_connection (struct connection *conn,unsigned int err);
Juergen
Re: [PATCH v2 14/17] tools/xenstored: Auto-introduce domains
Quoted 10 lines · Juergen Gross
Quoted 5 lines · Jason Andryuk
Replace
dom0_init()withinit_domains()which uses libxenmanage to iterate through all existing domains and introduce them.
dom0_domidis updated with the xenstore domain, since it really indicates the local domain.I agree with that explanation, but I wonder whether this explanation doesn't indicate that a rename of the
dom0_domidvariable is wanted, e.g. to "store_domid".
I've written a patch using "local_domid", though "store_domid" would be fine. I used "local" since I thought that would be better for indicating when we need to use /proc/xen/xsd_* for a "local" access. And for xenstore-stubdom, local_domain would use the special case code.
Quoted 4 lines
Quoted 2 lines
priv_domidis set to the control domain. This makes it limited to a single domain.Maybe another candidate for renaming (
ctrl_domid?).
I've further experimented with replacing priv_domid checks with a per-connection is_priv flag. Though now that I've written that down, maybe we don't want to support multiple domains having Xenstore privilege?
Quoted 66 lines
Quoted 66 lines
These features let xenstore automatically connect any existing domains, which means it doesn't need to be done manually from init-dom0less.
For a legacy dom0, the result should be unchanged.
For a late xenstore stubdom it should also be the same, but
priv_domidwould be set automatically to control domain (which default to 0 normally).Always signal the event channel for initial domains. This gets dom0 (a local xenstored domain) to connect.
Also always write
XENSTORE_CONNECTEDsince we know we are connected at this point.Signed-off-by Jason Andryuk <[email protected]>---
tools/xenstored/core.c | 2 +-
tools/xenstored/domain.c| 45 +++++++++++++++++++++++++++++++---------tools/xenstored/domain.h| 2 +-3 files changed, 37 insertions(+), 12 deletions(-)tools/xenstored/core.c +1
-1@@ -2762,7 +2762,7 @@ int main(int argc, char *argv[]) /* Listen to hypervisor. */ if (!live_update) { domain_init(-1); - dom0_init(); + init_domains(); } /* redirect to /dev/null now we're ready to accept connections */tools/xenstored/domain.c +16
-6@@ -1257,20 +1257,45 @@ const char *get_implicit_path(const struct connection *conn) return conn->domain->path; } -void dom0_init (void ) +void init_domains (void ) { - evtchn_port_t port; - struct domain *dom0; + unsigned int domid; + unsigned int state; + unsigned int caps; + uint64_t unique_id; + + while (!xenmanage_poll_changed_domain(xm_handle, &domid, &state, &caps, + &unique_id)) { + evtchn_port_t port = 0; + struct domain *domain; + + if (caps & XENMANAGE_GETDOMSTATE_CAP_XENSTORE) + dom0_domid = domid; + + if (caps & XENMANAGE_GETDOMSTATE_CAP_CONTROL) + priv_domid = domid; - port = get_xenbus_evtchn(); - if (port == -1) - barf_perror("Failed to initialize dom0 port");
Quoted 8 lines
tools/xenstored/domain.c const char *get_implicit_path(const struct connection *conn) · line 1283
Quoted 6 lines
tools/xenstored/domain.c +6
-0+ if (domid == dom0_domid) { + port = get_xenbus_evtchn(); + if (port == -1) + barf_perror("Failed to initialize dom%u port", + domid); + }I don't think this is correct for a xenstore-stubdom. See
stubdom_init().
Yes, you are right. There is a mismatch where for xenstored, dom0_domid means the local domain, but for stubdom, dom0_domid is dom0. I have some further changes I need to revisit that work to address that. Basically, make minios.c and posix.c only handle the "local" case. Anything that is not local is just a grant map. With that in place, stubdom_init() does not need an introduce_domain() call.
I think I hadn't figured out exactly how to handle the dom0 event channel passed on the command line to the stubdom.
Quoted 5 lines
tools/xenstored/domain.c const char *get_implicit_path(const struct connection *conn) · line 1288
Quoted 5 lines
tools/xenstored/domain.c +5
-0+ + domain = introduce_domain(NULL, domid, port, false); + if (!domain) { + xprintf("Could not initialize dom%u", domid); + continue;
I need to expand the commit message to mention this change. Here I made failure non-fatal since for ARM there can be domains without xenstore access. They can be identified by an hvm_param, but xenstore doesn't have permission to read those. Here introduce_domain() is called on them, and the grant mapping fails. So we note the error here and continue on.
Thanks,
Jason
Re: [PATCH v2 14/17] tools/xenstored: Auto-introduce domains
Quoted 5 lines · Jason Andryuk
Quoted 4 lines · Juergen Gross
Quoted 3 lines · Jason Andryuk
Replace
dom0_init()withinit_domains()which uses libxenmanage to iterate through all existing domains and introduce them.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
dom0_domidis updated with the xenstore domain, since it really indicates the local domain.I agree with that explanation, but I wonder whether this explanation doesn't indicate that a rename of the
dom0_domidvariable is wanted, e.g. to "store_domid".I've written a patch using "
local_domid", though "store_domid" would be fine. I used "local" since I thought that would be better for indicating when we need to use/proc/xen/xsd_*for a "local" access. And for xenstore-stubdom,local_domainwould use the special case code.
I'd prefer store_domid.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
priv_domidis set to the control domain. This makes it limited to a single domain.Maybe another candidate for renaming (
ctrl_domid?).I've further experimented with replacing
priv_domidchecks with a per-connectionis_privflag. Though now that I've written that down, maybe we don't want to support multiple domains having Xenstore privilege?
At least not per default. When needed it might be possible to add a new privileged XS_ command to grant another domain that status.
Quoted 75 lines
Quoted 66 lines
Quoted 66 lines
These features let xenstore automatically connect any existing domains, which means it doesn't need to be done manually from init-dom0less.
For a legacy dom0, the result should be unchanged.
For a late xenstore stubdom it should also be the same, but
priv_domidwould be set automatically to control domain (which default to 0 normally).Always signal the event channel for initial domains. This gets dom0 (a local xenstored domain) to connect.
Also always write
XENSTORE_CONNECTEDsince we know we are connected at this point.Signed-off-by Jason Andryuk <[email protected]>---
tools/xenstored/core.c | 2 +-
tools/xenstored/domain.c| 45 +++++++++++++++++++++++++++++++---------tools/xenstored/domain.h| 2 +-3 files changed, 37 insertions(+), 12 deletions(-)tools/xenstored/core.c +1
-1@@ -2762,7 +2762,7 @@ int main(int argc, char *argv[]) /* Listen to hypervisor. */ if (!live_update) { domain_init(-1); - dom0_init(); + init_domains(); } /* redirect to /dev/null now we're ready to accept connections */tools/xenstored/domain.c +16
-6@@ -1257,20 +1257,45 @@ const char *get_implicit_path(const struct connection *conn) return conn->domain->path; } -void dom0_init (void ) +void init_domains (void ) { - evtchn_port_t port; - struct domain *dom0; + unsigned int domid; + unsigned int state; + unsigned int caps; + uint64_t unique_id; + + while (!xenmanage_poll_changed_domain(xm_handle, &domid, &state, &caps, + &unique_id)) { + evtchn_port_t port = 0; + struct domain *domain; + + if (caps & XENMANAGE_GETDOMSTATE_CAP_XENSTORE) + dom0_domid = domid; + + if (caps & XENMANAGE_GETDOMSTATE_CAP_CONTROL) + priv_domid = domid; - port = get_xenbus_evtchn(); - if (port == -1) - barf_perror("Failed to initialize dom0 port");Quoted 8 lines
tools/xenstored/domain.c const char *get_implicit_path(const struct connection *conn) · line 1283
Quoted 6 lines
tools/xenstored/domain.c +6
-0+ if (domid == dom0_domid) { + port = get_xenbus_evtchn(); + if (port == -1) + barf_perror("Failed to initialize dom%u port", + domid); + }I don't think this is correct for a xenstore-stubdom. See
stubdom_init().
Quoted 1 line
Yes, you are right. There is a mismatch where for xenstored,
dom0_domidmeans the local domain, but for stubdom,dom0_domidis dom0. I have some further changes I need to revisit that work to address that. Basically, makeminios.candposix.conly handle the "local" case. Anything that is not local is just a grant map. With that in place,stubdom_init()does not need anintroduce_domain()call.
I agree with that approach.
Quoted 10 lines
I think I hadn't figured out exactly how to handle the dom0 event channel passed on the command line to the stubdom.
Quoted 5 lines
tools/xenstored/domain.c const char *get_implicit_path(const struct connection *conn) · line 1288
Quoted 5 lines
tools/xenstored/domain.c +5
-0+ + domain = introduce_domain(NULL, domid, port, false); + if (!domain) { + xprintf("Could not initialize dom%u", domid); + continue;I need to expand the commit message to mention this change. Here I made failure non-fatal since for ARM there can be domains without xenstore access. They can be identified by an
hvm_param, but xenstore doesn't have permission to read those. Hereintroduce_domain()is called on them, and the grant mapping fails. So we note the error here and continue on.
Right, but I think you should print errno as well, which means that you need to make sure that errno is set to a specific value in case the mapping fails.
This might be needed to distinguish this case from other errors, like ENOMEM (which would be rather strange at this early phase, though).
Juergen
PATCH v2 15/17 tools/init-dom0less: Factor out xenstore setup
In reply to Jason AndryukFactor out the xenstore setup code into configure_xenstore(). This is in preparation for handling already-introduced domains.
--- tools/helpers/init-dom0less.c | 51 ++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 15 deletions(-)
tools/helpers/init-dom0less.c +36 -15
@@ -235,43 +235,43 @@ err:return rc; } -static int init_domain (struct xs_handle *xsh, -struct xc_interface_core *xch, -xenforeignmemory_handle *xfh, -libxl_dominfo *info) +static int configure_xenstore (struct xs_handle *xsh, +struct xc_interface_core *xch, +xenforeignmemory_handle *xfh, +libxl_dominfo *info, +uint64_t *xenstore_evtchn, +uint64_t *xenstore_pfn) { -libxl_uuid uuid; -uint64_t xenstore_evtchn, xenstore_pfn;int rc; -printf ("Init dom0less domain: %u\n" , info->domid); +printf ("Introduce dom0less domain: %u\n" , info->domid); rc =xc_hvm_param_get (xch, info->domid,HVM_PARAM_STORE_EVTCHN , - &xenstore_evtchn); + xenstore_evtchn);if (rc !=0 ) {printf ("Failed to get HVM_PARAM_STORE_EVTCHN\n" );return 1 ; }/* no xen,enhanced; nothing to do */ -if (!xenstore_evtchn) +if (!*xenstore_evtchn)return 0 ;/* Get xenstore page */ -if (get_xs_page (xch, info, &xenstore_pfn) !=0 ) +if (get_xs_page (xch, info, xenstore_pfn) !=0 )return 1 ; -if (xenstore_pfn == ~0ULL ) { +if (*xenstore_pfn == ~0ULL ) {struct xenstore_domain_interface *intf; - rc =alloc_xs_page (xch, info, &xenstore_pfn); + rc =alloc_xs_page (xch, info, xenstore_pfn);if (rc !=0 ) {printf ("Error on getting xenstore page\n" );return 1 ; } intf =xenforeignmemory_map (xfh, info->domid,PROT_READ |PROT_WRITE ,1 , - &xenstore_pfn,NULL ); + xenstore_pfn,NULL );if (!intf) {printf ("Error mapping xenstore page\n" );return 1 ;
@@ -282,16 +282,37 @@ static int init_domain(struct xs_handle *xsh,/* Now everything is ready: set HVM_PARAM_STORE_PFN */ rc =xc_hvm_param_set (xch, info->domid,HVM_PARAM_STORE_PFN , - xenstore_pfn); + *xenstore_pfn);if (rc <0 )return rc; rc =xc_dom_gnttab_seed (xch, info->domid, true, - (xen_pfn_t)-1 , xenstore_pfn,0 ,0 ); + (xen_pfn_t)-1 , *xenstore_pfn,0 ,0 );if (rc)err (1 ,"xc_dom_gnttab_seed" ); } +return 0 ; +} + +static int init_domain (struct xs_handle *xsh, +struct xc_interface_core *xch, +xenforeignmemory_handle *xfh, +libxl_dominfo *info) +{ +uint64_t xenstore_evtchn, xenstore_pfn =0 ; +libxl_uuid uuid; +int rc; + + rc =configure_xenstore (xsh, xch, xfh, info, &xenstore_evtchn, + &xenstore_pfn); +if (rc) +return rc; + +if (xenstore_evtchn ==0 ) { +return 0 ; + } +libxl_uuid_generate (&uuid);xc_domain_sethandle (xch, info->domid,libxl_uuid_bytearray (&uuid));
Signature · 1 line
2.50.0
Re: [PATCH v2 15/17] tools/init-dom0less: Factor out xenstore setup
Quoted 16 lines · Jason Andryuk
Factor out the xenstore setup code into
configure_xenstore(). This is in preparation for handling already-introduced domains.Signed-off-by Jason Andryuk <[email protected]>--- tools/helpers/init-dom0less.c | 51 ++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 15 deletions(-)tools/helpers/init-dom0less.c +0
-0@@ -235,43 +235,43 @@ err:return rc; }
tools/helpers/init-dom0less.c err: · line 243
Quoted 10 lines
tools/helpers/init-dom0less.c +6
-4-static int init_domain (struct xs_handle *xsh, -struct xc_interface_core *xch, -xenforeignmemory_handle *xfh, -libxl_dominfo *info) +static int configure_xenstore (struct xs_handle *xsh, +struct xc_interface_core *xch, +xenforeignmemory_handle *xfh, +libxl_dominfo *info, +uint64_t *xenstore_evtchn, +uint64_t *xenstore_pfn)
This is becoming a little bit convoluted.
Wouldn't it be better to have a struct containing most of the parameters (at least the handles and info)?
An alternative might be to make those global variables in order to avoid passing them around everywhere.
Juergen
Re: [PATCH v2 15/17] tools/init-dom0less: Factor out xenstore setup
Quoted 29 lines · Juergen Gross
Quoted 15 lines · Jason Andryuk
Factor out the xenstore setup code into configure_xenstore(). This is in preparation for handling already-introduced domains.
Signed-off-by Jason Andryuk <[email protected]>---
tools/helpers/init-dom0less.c| 51 ++++++++++++++++++++++++-----------1 file changed, 36 insertions(+), 15 deletions(-)tools/helpers/init-dom0less.c +0
-0@@ -235,43 +235,43 @@ err: return rc; }tools/helpers/init-dom0less.c err: · line 242
Quoted 10 lines
tools/helpers/init-dom0less.c +6
-4-static int init_domain (struct xs_handle *xsh, - struct xc_interface_core *xch, - xenforeignmemory_handle *xfh, - libxl_dominfo *info) +static int configure_xenstore (struct xs_handle *xsh, + struct xc_interface_core *xch, + xenforeignmemory_handle *xfh, + libxl_dominfo *info, + uint64_t *xenstore_evtchn, + uint64_t *xenstore_pfn)This is becoming a little bit convoluted.
Quoted 5 lines
Wouldn't it be better to have a struct containing most of the parameters (at least the handles and info)?
An alternative might be to make those global variables in order to avoid passing them around everywhere.
Yes, I'd be happy with either of those options.
Thanks,
Jason
PATCH v2 16/17 tools/init-dom0less: Configure already-introduced domains
In reply to Jason AndryukWith xenstore automatically introducing domains at startup, the xs_is_domain_introduced() check is no longer accurate. Instead, process all domains and introduce non-introduced domains. This writes the xenstore entries and xl configuration for xenstore-enhanced domains as those entries are still useful with an already-introduced domain.
Non-xenstore domains are still skipped.
While at it, remove domain_exists() which is just a simple wrapper.
--- tools/helpers/init-dom0less.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
tools/helpers/init-dom0less.c +11 -17
@@ -324,16 +324,14 @@ static int init_domain(struct xs_handle *xsh,if (rc)err (1 ,"writing to xenstore" ); - rc =xs_introduce_domain (xsh, info->domid, xenstore_pfn, xenstore_evtchn); -if (!rc) -err (1 ,"xs_introduce_domain" ); -return 0 ; -} +if (!xs_is_domain_introduced (xsh, info->domid)) { + rc =xs_introduce_domain (xsh, info->domid, xenstore_pfn, + xenstore_evtchn); +if (!rc) +err (1 ,"xs_introduce_domain" ); + } -/* Check if domain has been configured in XS */ -static bool domain_exists (struct xs_handle *xsh,int domid) -{ -return xs_is_domain_introduced (xsh, domid); +return 0 ; }int main (int argc,char **argv)
@@ -376,14 +374,10 @@ int main(int argc, char **argv)continue ;printf ("Checking domid: %u\n" , domid); -if (!domain_exists (xsh, domid)) { - rc =init_domain (xsh, xch, xfh, &info[i]); -if (rc <0 ) { -fprintf (stderr,"init_domain failed.\n" ); - goto out; - } - }else { -printf ("Domain %u has already been initialized\n" , domid); + rc =init_domain (xsh, xch, xfh, &info[i]); +if (rc <0 ) { +fprintf (stderr,"init_domain failed.\n" ); + goto out; } } out:
Signature · 1 line
2.50.0
Re: [PATCH v2 16/17] tools/init-dom0less: Configure already-introduced domains
Quoted 2 lines · Jason Andryuk
With xenstore automatically introducing domains at startup, the
xs_is_domain_introduced()check is no longer accurate.
We can still use xs_is_domain_introduced() to skip configure_xenstore?
Quoted 4 lines
Instead, process
all domains and introduce non-introduced domains. This writes the xenstore entries and xl configuration for xenstore-enhanced domains as those entries are still useful with an already-introduced domain.
This is OK but to protect against mistakes such as calling init-dom0less twice, we could simply check if one of the mandatory xenstore entries is already present, and if so return early from create_xenstore.
Quoted 60 lines
Non-xenstore domains are still skipped.
While at it, remove
domain_exists()which is just a simple wrapper.Signed-off-by Jason Andryuk <[email protected]>--- tools/helpers/init-dom0less.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)tools/helpers/init-dom0less.c +11
-17@@ -324,16 +324,14 @@ static int init_domain(struct xs_handle *xsh,if (rc)err (1 ,"writing to xenstore" ); - rc =xs_introduce_domain (xsh, info->domid, xenstore_pfn, xenstore_evtchn); -if (!rc) -err (1 ,"xs_introduce_domain" ); -return 0 ; -} +if (!xs_is_domain_introduced (xsh, info->domid)) { + rc =xs_introduce_domain (xsh, info->domid, xenstore_pfn, + xenstore_evtchn); +if (!rc) +err (1 ,"xs_introduce_domain" ); + } -/* Check if domain has been configured in XS */ -static bool domain_exists (struct xs_handle *xsh,int domid) -{ -return xs_is_domain_introduced (xsh, domid); +return 0 ; }int main (int argc,char **argv)@@ -376,14 +374,10 @@ int main(int argc, char **argv)continue ;printf ("Checking domid: %u\n" , domid); -if (!domain_exists (xsh, domid)) { - rc =init_domain (xsh, xch, xfh, &info[i]); -if (rc <0 ) { -fprintf (stderr,"init_domain failed.\n" ); - goto out; - } - }else { -printf ("Domain %u has already been initialized\n" , domid); + rc =init_domain (xsh, xch, xfh, &info[i]); +if (rc <0 ) { +fprintf (stderr,"init_domain failed.\n" ); + goto out; } } out:Signature · 1 line
2.50.0
PATCH v2 17/17 tools/init-dom0less: Continue on error
In reply to Jason AndryukAn error on one domain doesn't apply to others. Continue the loop over all domains if init_domain() fails.
--- tools/helpers/init-dom0less.c | 1 - 1 file changed, 1 deletion(-)
tools/helpers/init-dom0less.c +0 -1
@@ -377,7 +377,6 @@ int main(int argc, char **argv) rc =init_domain (xsh, xch, xfh, &info[i]);if (rc <0 ) {fprintf (stderr,"init_domain failed.\n" ); - goto out; } } out:
Signature · 1 line
2.50.0
Re: [PATCH v2 17/17] tools/init-dom0less: Continue on error
Quoted 13 lines · Jason Andryuk
An error on one domain doesn't apply to others. Continue the loop over all domains if
init_domain()fails.Signed-off-by Jason Andryuk <[email protected]>--- tools/helpers/init-dom0less.c | 1 - 1 file changed, 1 deletion(-)tools/helpers/init-dom0less.c +0
-0
tools/helpers/init-dom0less.c int main(int argc, char **argv) · line 380
Quoted 4 lines
tools/helpers/init-dom0less.c +0
-1@@ -377,7 +377,6 @@ int main(int argc, char **argv) rc =init_domain (xsh, xch, xfh, &info[i]);if (rc <0 ) {fprintf (stderr,"init_domain failed.\n" ); - goto out;
init_domain doesn't always return < 0 on error
That said, this change is still good.