summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordtucker <dtucker@openbsd.org>2012-09-11 04:40:14 +0000
committerdtucker <dtucker@openbsd.org>2012-09-11 04:40:14 +0000
commit560312f087d6d57aabd4cb7a3c2d6b52b42bc8ad (patch)
treec29bef7a6286af4b7490c69779e206447b54d83f
parentsh can move to PIE, for better or worse. maybe it becomes slower, maybe (diff)
downloadwireguard-openbsd-560312f087d6d57aabd4cb7a3c2d6b52b42bc8ad.tar.xz
wireguard-openbsd-560312f087d6d57aabd4cb7a3c2d6b52b42bc8ad.zip
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. with & ok jmatthew@ dlg@
-rw-r--r--sys/dev/vmt.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/sys/dev/vmt.c b/sys/dev/vmt.c
index d6bea7b8c8c..5fb5e1e30ef 100644
--- a/sys/dev/vmt.c
+++ b/sys/dev/vmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmt.c,v 1.11 2011/01/27 21:29:25 dtucker Exp $ */
+/* $OpenBSD: vmt.c,v 1.12 2012/09/11 04:40:14 dtucker Exp $ */
/*
* Copyright (c) 2007 David Crawshaw <david@zentus.com>
@@ -206,6 +206,7 @@ int vm_rpc_send_rpci_tx(struct vmt_softc *, const char *, ...)
__attribute__((__format__(__kprintf__,2,3)));
int vm_rpci_response_successful(struct vmt_softc *);
+void vmt_probe_cmd(struct vm_backdoor *, uint16_t);
void vmt_tclo_state_change_success(struct vmt_softc *, int, char);
void vmt_do_reboot(struct vmt_softc *);
void vmt_do_shutdown(struct vmt_softc *);
@@ -219,26 +220,35 @@ void vmt_shutdown_hook(void *);
extern char hostname[MAXHOSTNAMELEN];
-int
-vmt_probe(void)
+void
+vmt_probe_cmd(struct vm_backdoor *frame, uint16_t cmd)
{
- struct vm_backdoor frame;
+ bzero(frame, sizeof(*frame));
- bzero(&frame, 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;
- 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);
+}
- vm_cmd(&frame);
+int
+vmt_probe(void)
+{
+ struct vm_backdoor frame;
+ vmt_probe_cmd(&frame, VM_CMD_GET_VERSION);
if (frame.eax.word == 0xffffffff ||
frame.ebx.word != VM_MAGIC)
return (0);
+ vmt_probe_cmd(&frame, VM_CMD_GET_SPEED);
+ if (frame.eax.word == VM_MAGIC)
+ return (0);
+
return (1);
}