> On May 12, 2025, at 2:37 PM, Sean Christopherson <seanjc@google.com> wrote:
>
> On Thu, Mar 13, 2025, Jon Kohler wrote:
>> Define macros for READ, WRITE, EXEC protection bits, to be used by
>> MBEC-enabled systems.
>>
>> No functional change intended.
>>
>> Signed-off-by: Jon Kohler <jon@nutanix.com>
>>
>> ---
>> arch/x86/include/asm/vmx.h | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
>> index d7ab0ad63be6..ffc90d672b5d 100644
>> --- a/arch/x86/include/asm/vmx.h
>> +++ b/arch/x86/include/asm/vmx.h
>> @@ -593,8 +593,17 @@ enum vm_entry_failure_code {
>> #define EPT_VIOLATION_GVA_IS_VALID BIT(7)
>> #define EPT_VIOLATION_GVA_TRANSLATED BIT(8)
>>
>> +#define EPT_VIOLATION_READ_TO_PROT(__epte) (((__epte) & VMX_EPT_READABLE_MASK) << 3)
>> +#define EPT_VIOLATION_WRITE_TO_PROT(__epte) (((__epte) & VMX_EPT_WRITABLE_MASK) << 3)
>> +#define EPT_VIOLATION_EXEC_TO_PROT(__epte) (((__epte) & VMX_EPT_EXECUTABLE_MASK) << 3)
>> #define EPT_VIOLATION_RWX_TO_PROT(__epte) (((__epte) & VMX_EPT_RWX_MASK) << 3)
>>
>> +static_assert(EPT_VIOLATION_READ_TO_PROT(VMX_EPT_READABLE_MASK) ==
>> + (EPT_VIOLATION_PROT_READ));
>> +static_assert(EPT_VIOLATION_WRITE_TO_PROT(VMX_EPT_WRITABLE_MASK) ==
>> + (EPT_VIOLATION_PROT_WRITE));
>> +static_assert(EPT_VIOLATION_EXEC_TO_PROT(VMX_EPT_EXECUTABLE_MASK) ==
>> + (EPT_VIOLATION_PROT_EXEC));
>
> Again, as a general rule, introduce macros and helpers functions when they are
> first used, not as tiny prep patches. There are exceptions to that rule, e.g. to
> avoid cyclical dependencies or to isolate arch/vendor changes, but know of those
> exceptions apply in this series.
>
> Patches like this are effectively impossible to review from a design/intent
> perspective, because without peeking at the usage that comes along later, there's
> no way to determine whether or not it makes sense to add these macros.
>
> And looking ahead, I don't see any reason to slice n' dice the RWX=>prot macro.
>
> TL;DR: drop this patch.
Sold! Dropped this one and cleaned it all up for v1