> On 08/12/2010 04:38 PM, Wei Yongjun wrote:
>
>> Introduce function write_register_operand() to write back the
>> register operand.
>>
>>
>>
>> +static void write_register_operand(struct operand *op, unsigned long val,
>> + unsigned int bytes)
>> +{
>> + /* The 4-byte case *is* correct: in 64-bit mode we zero-extend. */
>> + switch (bytes) {
>> + case 1:
>> + *(u8 *)op->addr.reg = (u8)val;
>> + break;
>> + case 2:
>> + *(u16 *)op->addr.reg = (u16)val;
>> + break;
>> + case 4:
>> + *op->addr.reg = (u32)val;
>> + break; /* 64b: zero-extend */
>> + case 8:
>> + *op->addr.reg = val;
>> + break;
>> + }
>> +}
>>
> It's cleaner to take val and bytes from struct operand, and do the
> assignment from the callers, no?
>
take val and bytes from struct operand may have other issue, when we
writeback
the source register, we need do the assignment from the caller, and then
change
the val back before write src val to dst val. Such as xadd:
c->src.val = c->dst.val;
write_register_operand(&c->src);
c->src.val = c->src.orig_val;
goto add;
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html