Re: [PATCH v10 02/28] KVM: VMX: Initialize VM entry/exit FRED controls in vmcs_config
From: Binbin Wu
Date: Mon Oct 26 2026 - 21:26:19 EST
On 10/26/2026 1:00 PM, Sohil Mehta wrote:
> On 10/22/2026 8:10 PM, Sohil Mehta wrote:
>
>> I couldn't find any precedent for this. I don't have a strong preference
>> here. Is it worth making future-proof?
>
>
> I did a bit of digging. The current entry in the table is the result of
> Sean's preference provided early on in the FRED series. See
>
> https://lore.kernel.org/all/Z739wdGmk4ZuWJ8v@xxxxxxxxxx/
> https://lore.kernel.org/all/ZUz3cPmnqSq7Lol9@xxxxxxxxxx/
>
> IIUC, we want the FRED entry/exit controls to be consistent without
> depending on the ordering.
>
> The current vmx_check_entry_exit_pairs() doesn't cover the FRED case (a
> single entry bit mapping to two exit bits). So, the updated check would
> cover this scenario.
OK, thanks for the info!
>
>> if (!(entry_controls & n_ctrl) == !(exit_controls & x_ctrl) &&
>> !(entry_controls & n_ctrl) == ((exit_controls & x_ctrl) != x_ctrl))
>> continue;
>>
>
>
> 1st line: the entry control is set if and only if *any* exit bit is set.
> 2nd line: the entry control is set if and only if *all* exit bits are
> set (which is specific to FRED for now).
>
> Also, to make it easier to read, planning to reformat it as:
>
> struct {
> u32 entry_control;
> u64 exit_control;
> } const vmcs_entry_exit2_pairs[] = {
> { VM_ENTRY_LOAD_IA32_FRED, SECONDARY_VM_EXIT_SAVE_IA32_FRED |
> SECONDARY_VM_EXIT_LOAD_IA32_FRED },
> };
>
> Please let me know if you disagree with the approach.
It looks good to me.