All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] implement is_hardware_domain using hardware_domain global
@ 2014-04-14 21:23 Daniel De Graaf
  2014-04-14 21:23 ` [PATCH v4 2/2] allow hardware domain != dom0 Daniel De Graaf
  2014-04-15  8:56 ` [PATCH 1/2] implement is_hardware_domain using hardware_domain global Ian Campbell
  0 siblings, 2 replies; 9+ messages in thread
From: Daniel De Graaf @ 2014-04-14 21:23 UTC (permalink / raw)
  To: xen-devel
  Cc: Keir Fraser, Ian Campbell, Tim Deegan, Ian Jackson,
	Stefano Stabellini, Jan Beulich, Daniel De Graaf

This requires setting the hardware_domain variable earlier in
domain_create so that functions called from it (primarily in
arch_domain_create) observe the correct results when they call
is_hardware_domain.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Stefano Stabellini <stefano.stabellini@citrix.com>
Cc: Tim Deegan <tim@xen.org>
---
 xen/arch/arm/setup.c    | 2 +-
 xen/arch/x86/setup.c    | 2 +-
 xen/common/domain.c     | 5 ++++-
 xen/include/xen/sched.h | 4 ++--
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 358eafb..6b77a4c 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -761,7 +761,7 @@ void __init start_xen(unsigned long boot_phys_offset,
     do_initcalls();
 
     /* Create initial domain 0. */
-    hardware_domain = dom0 = domain_create(0, 0, 0);
+    dom0 = domain_create(0, 0, 0);
     if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) )
             panic("Error creating domain 0");
 
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 11c95fc..2e30701 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1339,7 +1339,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
         panic("Could not protect TXT memory regions");
 
     /* Create initial domain 0. */
-    hardware_domain = dom0 = domain_create(0, DOMCRF_s3_integrity, 0);
+    dom0 = domain_create(0, DOMCRF_s3_integrity, 0);
     if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) )
         panic("Error creating domain 0");
 
diff --git a/xen/common/domain.c b/xen/common/domain.c
index c4720a9..3c05711 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -237,10 +237,11 @@ struct domain *domain_create(
     else if ( domcr_flags & DOMCRF_pvh )
         d->guest_type = guest_type_pvh;
 
-    if ( is_hardware_domain(d) )
+    if ( domid == 0 )
     {
         d->is_pinned = opt_dom0_vcpus_pin;
         d->disable_migrate = 1;
+        hardware_domain = d;
     }
 
     rangeset_domain_initialise(d);
@@ -319,6 +320,8 @@ struct domain *domain_create(
 
  fail:
     d->is_dying = DOMDYING_dead;
+    if ( hardware_domain == d )
+        hardware_domain = NULL;
     atomic_set(&d->refcnt, DOMAIN_DESTROYED);
     xfree(d->mem_event);
     xfree(d->pbuf);
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index b080c9e..734f7a9 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -795,9 +795,9 @@ void watchdog_domain_destroy(struct domain *d);
  * Use this check when the following are both true:
  *  - Using this feature or interface requires full access to the hardware
  *    (that is, this would not be suitable for a driver domain)
- *  - There is never a reason to deny dom0 access to this
+ *  - There is never a reason to deny the hardware domain access to this
  */
-#define is_hardware_domain(_d) ((_d)->domain_id == 0)
+#define is_hardware_domain(_d) ((_d) == hardware_domain)
 
 /* This check is for functionality specific to a control domain */
 #define is_control_domain(_d) ((_d)->is_privileged)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-04-16  9:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-14 21:23 [PATCH 1/2] implement is_hardware_domain using hardware_domain global Daniel De Graaf
2014-04-14 21:23 ` [PATCH v4 2/2] allow hardware domain != dom0 Daniel De Graaf
2014-04-15  7:53   ` Jan Beulich
2014-04-15 14:45   ` Andrew Cooper
2014-04-15 22:07     ` Daniel De Graaf
2014-04-15 23:37       ` Andrew Cooper
2014-04-16  9:08         ` Jan Beulich
2014-04-16  9:41           ` Andrew Cooper
2014-04-15  8:56 ` [PATCH 1/2] implement is_hardware_domain using hardware_domain global Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.