x86, xen: short-circuit tests for dom0
authorJeremy Fitzhardinge <jeremy@goop.org>
Fri, 6 Feb 2009 21:35:44 +0000 (13:35 -0800)
committerIngo Molnar <mingo@elte.hu>
Mon, 16 Feb 2009 07:55:50 +0000 (08:55 +0100)
When testing for a dom0/initial/privileged domain, make sure the
predicate evaluates to a compile-time 0 if CONFIG_XEN_DOM0 isn't
enabled.  This will make most of the dom0 code evaporate without
much more effort.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/include/asm/xen/hypervisor.h

index 81fbd735aec47e3edbed57a5d83eb142f3c3571e..d5b7e90c0edfd3ca1bf7d05e3f4c4e642f8e6fb7 100644 (file)
@@ -38,22 +38,30 @@ extern struct shared_info *HYPERVISOR_shared_info;
 extern struct start_info *xen_start_info;
 
 enum xen_domain_type {
-       XEN_NATIVE,
-       XEN_PV_DOMAIN,
-       XEN_HVM_DOMAIN,
+       XEN_NATIVE,             /* running on bare hardware    */
+       XEN_PV_DOMAIN,          /* running in a PV domain      */
+       XEN_HVM_DOMAIN,         /* running in a Xen hvm domain */
 };
 
-extern enum xen_domain_type xen_domain_type;
-
 #ifdef CONFIG_XEN
-#define xen_domain()           (xen_domain_type != XEN_NATIVE)
+extern enum xen_domain_type xen_domain_type;
 #else
-#define xen_domain()           (0)
+#define xen_domain_type                XEN_NATIVE
 #endif
 
-#define xen_pv_domain()                (xen_domain() && xen_domain_type == XEN_PV_DOMAIN)
-#define xen_hvm_domain()       (xen_domain() && xen_domain_type == XEN_HVM_DOMAIN)
+#define xen_domain()           (xen_domain_type != XEN_NATIVE)
+#define xen_pv_domain()                (xen_domain() &&                        \
+                                xen_domain_type == XEN_PV_DOMAIN)
+#define xen_hvm_domain()       (xen_domain() &&                        \
+                                xen_domain_type == XEN_HVM_DOMAIN)
+
+#ifdef CONFIG_XEN_DOM0
+#include <xen/interface/xen.h>
 
-#define xen_initial_domain()   (xen_pv_domain() && xen_start_info->flags & SIF_INITDOMAIN)
+#define xen_initial_domain()   (xen_pv_domain() && \
+                                xen_start_info->flags & SIF_INITDOMAIN)
+#else  /* !CONFIG_XEN_DOM0 */
+#define xen_initial_domain()   (0)
+#endif /* CONFIG_XEN_DOM0 */
 
 #endif /* _ASM_X86_XEN_HYPERVISOR_H */