From 6f5296796595116674fad5b9f4be7d773f048e22 Mon Sep 17 00:00:00 2001 From: neel Date: Wed, 21 Nov 2012 00:14:03 +0000 Subject: Mask the %eax register properly based on whether the "out" instruction is operating on 1, 2 or 4 bytes. There could be garbage in the unused bytes so zero them off. Obtained from: NetApp --- usr.sbin/bhyve/inout.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'usr.sbin/bhyve/inout.c') diff --git a/usr.sbin/bhyve/inout.c b/usr.sbin/bhyve/inout.c index bf9c5f7..5f47a89f 100644 --- a/usr.sbin/bhyve/inout.c +++ b/usr.sbin/bhyve/inout.c @@ -74,6 +74,7 @@ emulate_inout(struct vmctx *ctx, int vcpu, int in, int port, int bytes, uint32_t *eax, int strict) { int flags; + uint32_t mask; inout_func_t handler; void *arg; @@ -84,6 +85,21 @@ emulate_inout(struct vmctx *ctx, int vcpu, int in, int port, int bytes, if (strict && handler == default_inout) return (-1); + if (!in) { + switch (bytes) { + case 1: + mask = 0xff; + break; + case 2: + mask = 0xffff; + break; + default: + mask = 0xffffffff; + break; + } + *eax = *eax & mask; + } + flags = inout_handlers[port].flags; arg = inout_handlers[port].arg; -- cgit v1.1