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
This commit is contained in:
Neel Natu 2012-11-21 00:14:03 +00:00
parent 430a787224
commit 4662939d55
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/bhyve/; revision=243349

View File

@ -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;