Re: [PATCH v2 1/3] KVM: x86: assign two bits to track SPTE kinds

From: Paolo Bonzini
Date: Wed Dec 11 2019 - 19:33:53 EST


On 12/12/19 01:29, Sean Christopherson wrote:
>> */
>> -#define MMIO_SPTE_GEN_MASK GENMASK_ULL(18, 0)
>> +#define MMIO_SPTE_GEN_MASK GENMASK_ULL(17, 0)
>>
>> #define MMIO_SPTE_GEN_LOW_START 3
>> #define MMIO_SPTE_GEN_LOW_END 11
>> #define MMIO_SPTE_GEN_LOW_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_END, \
>> MMIO_SPTE_GEN_LOW_START)
>>
>> -#define MMIO_SPTE_GEN_HIGH_START 52
>> -#define MMIO_SPTE_GEN_HIGH_END 61
>> +/* Leave room for SPTE_SPECIAL_MASK. */
>> +#define MMIO_SPTE_GEN_HIGH_START PT64_SECOND_AVAIL_BITS_SHIFT
> I'd rather have GEN_HIGH_START be an explicit bit number and then add
> a BUILD_BUG_ON(GEN_HIGH_START < PT64_SECOND_AVAIL_BITS_SHIFT) to ensure
> the MMIO gen doesn't overlap other stuff. That way we get a build error
> if someone changes PT64_SECOND_AVAIL_BITS_SHIFT, otherwise the MMIO gen
> will end up who knows where and probably overwrite NX or EPT.SUPPRESS_VE.
>

Fair enough. While at it I'll also add MMIO_SPTE_GEN_BITS (
MMIO_SPTE_GEN_LOW_END - MMIO_SPTE_GEN_LOW_START + 1
+ MMIO_SPTE_GEN_HIGH_END - MMIO_SPTE_GEN_HIGH_START + 1) and use it in
MMIO_SPTE_GEN_MASK.

Paolo