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

Re: [Xen-devel] [PATCH 3/6] x86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest()



On 22/06/17 13:09, Tim Deegan wrote:
> Hi,
>
> At 16:12 +0100 on 21 Jun (1498061549), Andrew Cooper wrote:
>> sh_emulate_map_dest() predates the introduction of the generic ERR_PTR()
>> infrasturcture, but take the opportunity to avoid opencoding it.
> s/sturct/struct/.

D'oh - I'm sure you spotted this before.  I will try to actually fix it
this time.

>
>> @@ -4752,8 +4752,8 @@ sh_x86_emulate_write(struct vcpu *v, unsigned long 
>> vaddr, void *src,
>>          return X86EMUL_UNHANDLEABLE;
>>  
>>      addr = sh_emulate_map_dest(v, vaddr, bytes, sh_ctxt);
>> -    if ( sh_emulate_map_dest_failed(addr) )
>> -        return (long)addr;
>> +    if ( IS_ERR(addr) )
>> +        return ~PTR_ERR(addr);
> Using "return ~PTR_ERR(addr)" when the usual idiom is
> "return -PTR_ERR(foo)" is a bit subtle.  Still, the code seems to be
> correct, so if people prefer it,
>
> Acked-by: Tim Deegan <tim@xxxxxxx>

It is necessary to use ~ rather than - because of MAPPING_SILENT_FAIL
being X86EMUL_OKAY under the hood.

Short of sliding the X86EMUL_* constants along by 1 (which itself would
cause other chaos, as there are plenty of return value checks against 0
rather than X86EMUL_OKAY), I can't see any other way of making this
function.

All in all, write-discard p2m types are a pain to work with :(

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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