xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools: fix xen-detect to correctly identify domU type
@ 2016-03-23  7:50 Juergen Gross
  2016-03-23  9:10 ` Jan Beulich
       [not found] ` <56F26B7C02000078000DF896@suse.com>
  0 siblings, 2 replies; 28+ messages in thread
From: Juergen Gross @ 2016-03-23  7:50 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, wei.liu2, ian.jackson, stefano.stabellini

xen-detect always thinks a domU is running as HVM guest as the cpuid
instruction used to identify a Xen guest will always work.

In order to identify a pv guest first try the pv special case of
cpuid (prefixed with an ud2a instruction and "xen" in ASCII). This
will fail on HVM and thus can be used to distinguish the guest types.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/misc/xen-detect.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/misc/xen-detect.c b/tools/misc/xen-detect.c
index 787b5da..342856c 100644
--- a/tools/misc/xen-detect.c
+++ b/tools/misc/xen-detect.c
@@ -133,15 +133,10 @@ int main(int argc, char **argv)
         }
     }
 
-    /* Check for execution in HVM context. */
-    detected = XEN_HVM;
-    if ( (version = check_for_xen(0)) != 0 )
-        goto out;
-
     /*
      * Set up a signal handler to test the paravirtualised CPUID instruction.
      * If executed outside Xen PV context, the extended opcode will fault, we
-     * will longjmp via the signal handler, and print "Not running on Xen".
+     * will longjmp via the signal handler, and test for HVM.
      */
     detected = XEN_PV;
     if ( !setjmp(sigill_jmp)
@@ -149,6 +144,11 @@ int main(int argc, char **argv)
          && ((version = check_for_xen(1)) != 0) )
         goto out;
 
+    /* Check for execution in HVM context. */
+    detected = XEN_HVM;
+    if ( !setjmp(sigill_jmp) && (version = check_for_xen(0)) != 0 )
+        goto out;
+
     detected = XEN_NONE;
 
  out:
-- 
2.6.2


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2016-03-29 14:05 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-23  7:50 [PATCH] tools: fix xen-detect to correctly identify domU type Juergen Gross
2016-03-23  9:10 ` Jan Beulich
     [not found] ` <56F26B7C02000078000DF896@suse.com>
2016-03-23  9:19   ` Juergen Gross
2016-03-23  9:29     ` Jan Beulich
     [not found]     ` <56F26FF602000078000DF8C8@suse.com>
2016-03-23 10:14       ` Juergen Gross
2016-03-23 10:25         ` Jan Beulich
2016-03-23 10:32           ` David Vrabel
2016-03-23 10:52             ` Juergen Gross
2016-03-23 10:55               ` Andrew Cooper
2016-03-23 10:59                 ` David Vrabel
2016-03-23 11:12                   ` Andrew Cooper
2016-03-23 11:18                     ` David Vrabel
2016-03-23 11:25                       ` Andrew Cooper
2016-03-23 19:03                         ` Juergen Gross
2016-03-24 10:22                           ` David Vrabel
2016-03-24 10:58                             ` Juergen Gross
2016-03-24 11:23                               ` Andrew Cooper
2016-03-24 11:38                                 ` George Dunlap
2016-03-25  8:54                                   ` Juergen Gross
2016-03-29  6:49                                     ` Jan Beulich
2016-03-29 13:54                                     ` George Dunlap
2016-03-29 14:00                                       ` Juergen Gross
2016-03-29 14:05                                         ` George Dunlap
2016-03-23 11:33                 ` Juergen Gross
2016-03-23 12:50                   ` Boris Ostrovsky
2016-03-23 10:34           ` Andrew Cooper
2016-03-23 10:48             ` Juergen Gross
2016-03-23 10:29         ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).