diff options
author | neel <neel@FreeBSD.org> | 2012-11-21 00:14:03 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2012-11-21 00:14:03 +0000 |
commit | 6f5296796595116674fad5b9f4be7d773f048e22 (patch) | |
tree | d36b1f7ab332f7114bcaaccb7453f1a480eaa087 | |
parent | 6f600a733a70db5bd790d25fb885e348be51f240 (diff) | |
download | FreeBSD-src-6f5296796595116674fad5b9f4be7d773f048e22.zip FreeBSD-src-6f5296796595116674fad5b9f4be7d773f048e22.tar.gz |
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
-rw-r--r-- | usr.sbin/bhyve/inout.c | 16 |
1 files changed, 16 insertions, 0 deletions
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; |