implement is_hardware_domain using hardware_domain global
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 17 Apr 2014 08:10:33 +0000 (10:10 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 17 Apr 2014 08:10:33 +0000 (10:10 +0200)
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>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/arm/setup.c
xen/arch/x86/setup.c
xen/common/domain.c
xen/include/xen/sched.h

index 358eafb0941f4b59a7a01c707e4fb0d4dc0938e9..6b77a4c57b6b334ff685dfcc36e5dbed689f9d42 100644 (file)
@@ -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");
 
index 11c95fcd583f85c25b4e53433d1bf5bd95b9c048..2e307019299b8388b58e11b27c1388794c756a4e 100644 (file)
@@ -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");
 
index c4720a95fa2edf98387f4e24c7581a7b81845fb0..3c05711d5f6da07935e6f0944f78795884a7c0f6 100644 (file)
@@ -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);
index b080c9eefb3eccd8ba588b272998ff6440a3dc37..734f7a9745e0ea807ebd50d4916bba9cd25bef1a 100644 (file)
@@ -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)