RE: [PATCH v2 2/2] KVM: x86/mmu: Micro-optimize nEPT's bad memptype/XWR checks

From: David Laight
Date: Fri Jan 10 2020 - 11:13:32 EST


From: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
> Sent: 10 January 2020 16:05
...
> Similar to your suggestion, but it avoids evaluating __is_bad_mt_xwr() if
> reserved bits are set, which is admittedly rare.
>
> return __is_rsvd_bits_set(&mmu->guest_rsvd_check, gpte, level)
> #if PTTYPE == PTTYPE_EPT
> || __is_bad_mt_xwr(&mmu->guest_rsvd_check, gpte)
> #endif
> ;

Or:
return __is_rsvd_bits_set(&mmu->guest_rsvd_check, gpte, level) ||
(PTTYPE == PTTYPE_EPT && __is_bad_mt_xwr(&mmu->guest_rsvd_check, gpte));

Relying in the compiler to optimise it away.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)