Re: [PATCH v1 14/23] KVM: VMX: Dump FRED context in dump_vmcs()

Nikolay Borisov
2023-11-14T14:37:12Z

On 8.11.23 г. 20:29 ч., Xin Li wrote:
> Add FRED related VMCS fields to dump_vmcs() to have it dump FRED context.
>
> Tested-by: Shan Kang <shan.kang@intel.com>
> Signed-off-by: Xin Li <xin3.li@intel.com>
> ---
> arch/x86/kvm/vmx/vmx.c | 48 ++++++++++++++++++++++++++++++++++++------
> 1 file changed, 41 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 518e68ee5a0d..b826dc188fc7 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6429,7 +6429,7 @@ void dump_vmcs(struct kvm_vcpu *vcpu)
> struct vcpu_vmx *vmx = to_vmx(vcpu);
> u32 vmentry_ctl, vmexit_ctl;
> u32 cpu_based_exec_ctrl, pin_based_exec_ctrl, secondary_exec_control;
> - u64 tertiary_exec_control;
> + u64 tertiary_exec_control, secondary_vmexit_ctl;
> unsigned long cr4;
> int efer_slot;
>
> @@ -6440,6 +6440,8 @@ void dump_vmcs(struct kvm_vcpu *vcpu)
>
> vmentry_ctl = vmcs_read32(VM_ENTRY_CONTROLS);
> vmexit_ctl = vmcs_read32(VM_EXIT_CONTROLS);
> + secondary_vmexit_ctl = cpu_has_secondary_vmexit_ctrls() ?
> + vmcs_read64(SECONDARY_VM_EXIT_CONTROLS) : 0;
> cpu_based_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
> pin_based_exec_ctrl = vmcs_read32(PIN_BASED_VM_EXEC_CONTROL);
> cr4 = vmcs_readl(GUEST_CR4);
> @@ -6486,6 +6488,19 @@ void dump_vmcs(struct kvm_vcpu *vcpu)
> vmx_dump_sel("LDTR:", GUEST_LDTR_SELECTOR);
> vmx_dump_dtsel("IDTR:", GUEST_IDTR_LIMIT);
> vmx_dump_sel("TR: ", GUEST_TR_SELECTOR);
> +#ifdef CONFIG_X86_64
> + if (cpu_feature_enabled(X86_FEATURE_FRED)) {

Shouldn't this be gated on whether FRED is enabled in kvm aka the CPUID
bit is enumerated ?

<snip>