Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Check that the host supports GET_SPEED as w...



details:   https://anonhg.NetBSD.org/src/rev/16ce486c61e7
branches:  trunk
changeset: 827149:16ce486c61e7
user:      maya <maya%NetBSD.org@localhost>
date:      Tue Oct 17 05:47:09 2017 +0000

description:
Check that the host supports GET_SPEED as well as GET_VERSION
before deciding vmt_probe has succeeded.

qemu supports GET_VERSION but not the RPC protocol so the probe succeeds
but the attach fails, resulting in "vmt0: failed to open backdoor RPC
channel (TCLO protocol)".  All known versions of vmware support GET_SPEED
and no known qemu versions do, so this prevents it from attempting to
attach (and failing) on qemu while still working on vmware.

stop checking vmt_type to avoid having to adapt this code.

- Taken from openbsd

diffstat:

 sys/arch/x86/x86/vmt.c |  55 ++++++++++++++++++++------------------------------
 1 files changed, 22 insertions(+), 33 deletions(-)

diffs (91 lines):

diff -r 9f85b71cb300 -r 16ce486c61e7 sys/arch/x86/x86/vmt.c
--- a/sys/arch/x86/x86/vmt.c    Tue Oct 17 00:26:35 2017 +0000
+++ b/sys/arch/x86/x86/vmt.c    Tue Oct 17 05:47:09 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmt.c,v 1.17 2017/06/01 02:45:08 chs Exp $ */
+/* $NetBSD: vmt.c,v 1.18 2017/10/17 05:47:09 maya Exp $ */
 /* $OpenBSD: vmt.c,v 1.11 2011/01/27 21:29:25 dtucker Exp $ */
 
 /*
@@ -126,28 +126,34 @@
 
 extern char hostname[MAXHOSTNAMELEN];
 
+static void
+vmt_probe_cmd(struct vm_backdoor *frame, uint16_t cmd)
+{
+       memset(frame, 0, sizeof(*frame));
+
+       (frame->eax).word = VM_MAGIC;
+       (frame->ebx).word = ~VM_MAGIC;
+       (frame->ecx).part.low = cmd;
+       (frame->ecx).part.high = 0xffff;
+       (frame->edx).part.low  = VM_PORT_CMD;
+       (frame->edx).part.high = 0;
+
+       vm_cmd(frame);
+}
+
 static bool
-vmt_probe(uint32_t *type)
+vmt_probe(void)
 {
        struct vm_backdoor frame;
 
-       memset(&frame, 0, sizeof(frame));
-
-       frame.eax.word = VM_MAGIC;
-       frame.ebx.word = ~VM_MAGIC;
-       frame.ecx.part.low = VM_CMD_GET_VERSION;
-       frame.ecx.part.high = 0xffff;
-       frame.edx.part.low  = VM_PORT_CMD;
-       frame.edx.part.high = 0;
-
-       vm_cmd(&frame);
-
+       vmt_probe_cmd(&frame, VM_CMD_GET_VERSION);
        if (frame.eax.word == 0xffffffff ||
            frame.ebx.word != VM_MAGIC)
                return false;
 
-       if (type)
-               *type = frame.ecx.word;
+       vmt_probe_cmd(&frame, VM_CMD_GET_SPEED);
+       if (frame.eax.word == VM_MAGIC)
+               return false;
 
        return true;
 }
@@ -163,23 +169,7 @@
        if ((ci->ci_flags & (CPUF_BSP|CPUF_SP|CPUF_PRIMARY)) == 0)
                return 0;
 
-       return vmt_probe(NULL);
-}
-
-static const char *
-vmt_type(void)
-{
-       uint32_t vmwaretype = 0;
-
-       vmt_probe(&vmwaretype);
-
-       switch (vmwaretype) {
-       case 1: return "Express";
-       case 2: return "ESX Server";
-       case 3: return "VMware Server";
-       case 4: return "Workstation";
-       default: return "Unknown";
-       }
+       return vmt_probe();
 }
 
 static void
@@ -189,7 +179,6 @@
        struct vmt_softc *sc = device_private(self);
 
        aprint_naive("\n");
-       aprint_normal(": %s\n", vmt_type());
 
        sc->sc_dev = self;
        sc->sc_log = NULL;



Home | Main Index | Thread Index | Old Index