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

From: Paolo Bonzini
Date: Wed Jan 15 2020 - 13:17:34 EST


On 10/01/20 17:04, Sean Christopherson wrote:
> Ya, I don't love the code, but it was the least awful of the options I
> tried, in that it's the most readable without being too obnoxious.
>
>
> 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 macrofying the call to keep the call site clean, but IMO this obfuscates
> things too much.
>
> return __is_rsvd_bits_set(&mmu->guest_rsvd_check, gpte, level) ||
> IS_BAD_MT_XWR(&mmu->guest_rsvd_check, gpte);

I think what you posted is the best (David's comes second).

Queued, thanks.

Paolo