[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] x86/HVM: don't retain emulated insn cache when exiting back to guest



>>> On 05.12.17 at 17:44, <Paul.Durrant@xxxxxxxxxx> wrote:
>> From: Jan Beulich [mailto:JBeulich@xxxxxxxx]
>> Sent: 05 December 2017 16:14
>> --- a/xen/arch/x86/hvm/emulate.c
>> +++ b/xen/arch/x86/hvm/emulate.c
>> @@ -2109,20 +2109,22 @@ static int _hvm_emulate_one(struct hvm_e
>> 
>>      vio->mmio_retry = 0;
>> 
>> -    rc = x86_emulate(&hvmemul_ctxt->ctxt, ops);
>> -
>> -    if ( rc == X86EMUL_OKAY && vio->mmio_retry )
>> -        rc = X86EMUL_RETRY;
>> -    if ( rc != X86EMUL_RETRY )
>> +    switch ( rc = x86_emulate(&hvmemul_ctxt->ctxt, ops) )
>>      {
>> +    case X86EMUL_OKAY:
>> +        if ( vio->mmio_retry )
>> +            rc = X86EMUL_RETRY;
>> +        /* fall through */
>> +    default:
>>          vio->mmio_cache_count = 0;
>>          vio->mmio_insn_bytes = 0;
>> -    }
>> -    else
>> -    {
>> +        break;
>> +
>> +    case X86EMUL_RETRY:
>>          BUILD_BUG_ON(sizeof(vio->mmio_insn) < sizeof(hvmemul_ctxt-
>> >insn_buf));
>>          vio->mmio_insn_bytes = hvmemul_ctxt->insn_buf_bytes;
>>          memcpy(vio->mmio_insn, hvmemul_ctxt->insn_buf, vio-
>> >mmio_insn_bytes);
>> +        break;
> 
> So, we have two distinct cases when X86EMUL_RETRY will be returned: the 
> former when we do want to return to guest part way through a rep operation, 
> and another when an MMIO has been sent for external emulation and we are 
> expecting a completion. The code looks correct so...
> 
> Reviewed-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

Thanks.

> ...but I wonder there should be two distinct return codes for these two 
> cases.

The question is - does any of the callers care about the difference.
I think the relevant information has been recorded in data structures
by the time we get here.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.