On 2/12/19 15:31, Jan Beulich wrote:
>>>> On 08.02.19 at 14:44, <[email protected]> wrote:
>> @@ -33,10 +34,11 @@ unsigned long __read_mostly 
>> pdx_group_valid[BITS_TO_LONGS(
>>  
>>  bool __mfn_valid(unsigned long mfn)
>>  {
>> -    return likely(mfn < max_page) &&
>> -           likely(!(mfn & pfn_hole_mask)) &&
>> -           likely(test_bit(pfn_to_pdx(mfn) / PDX_GROUP_COUNT,
>> -                           pdx_group_valid));
>> +    return evaluate_nospec(
>> +        likely(mfn < max_page) &&
>> +        likely(!(mfn & pfn_hole_mask)) &&
>> +        likely(test_bit(pfn_to_pdx(array_index_nospec(mfn, max_page))
>> +                                   / PDX_GROUP_COUNT, pdx_group_valid)));
>>  }
> How about this instead:
>
> bool __mfn_valid(unsigned long mfn)
> {
>     if ( unlikely(evaluate_nospec(mfn >= max_page)) )
>         return false;
>     return likely(!(mfn & pfn_hole_mask)) &&
>            likely(test_bit(pfn_to_pdx(mfn) / PDX_GROUP_COUNT,
>                            pdx_group_valid));
> }
>
> Initially I really just wanted to improve the line wrapping (at the
> very least the / was misplaced), but I think this variant guards
> against all that's needed without even introducing wrapping
> headaches.

That works as well, I will adapt the commit accordingly.

Best,
Norbert

>
> Jan
>
>



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich
Ust-ID: DE 289 237 879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to