Re: [PATCH v2 8/8] KVM: TDX: Handle TDX PV MMIO hypercall

Binbin Wu
2025-02-12T02:40:01Z

On 2/12/2025 10:28 AM, Chao Gao wrote:
>> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
>> index f13da28dd4a2..8f3147c6e602 100644
>> --- a/arch/x86/kvm/vmx/tdx.c
>> +++ b/arch/x86/kvm/vmx/tdx.c
>> @@ -849,8 +849,12 @@ static __always_inline u32 tdx_to_vmx_exit_reason(struct kvm_vcpu *vcpu)
>> if (tdvmcall_exit_type(vcpu))
>> return EXIT_REASON_VMCALL;
>>
>> - if (tdvmcall_leaf(vcpu) < 0x10000)
>> + if (tdvmcall_leaf(vcpu) < 0x10000) {
>> + if (tdvmcall_leaf(vcpu) == EXIT_REASON_EPT_VIOLATION)
>> + return EXIT_REASON_EPT_MISCONFIG;
> IIRC, a TD-exit may occur due to an EPT MISCONFIG. Do you need to distinguish
> between a genuine EPT MISCONFIG and a morphed one, and handle them differently?
It will be handled separately, which will be in the last section of the KVM
basic support.  But the v2 of "the rest" section is on hold because there is
a discussion related to MTRR MSR handling:
https://lore.kernel.org/all/20250201005048.657470-1-seanjc@google.com/
Want to send the v2 of "the rest" section after the MTRR discussion is
finalized.

For the genuine EPT misconfig handling, you can refer to the patch on the