Re: [PATCH 2/7] KVM: TDX: Add a place holder for handler of TDX hypercalls (TDG.VP.VMCALL)

Binbin Wu
2024-12-10T02:34:10Z

On 12/9/2024 7:28 PM, Chao Gao wrote:
[...]
>>
>> #define VMX_EXIT_REASONS \
>> { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \
>> @@ -155,7 +156,8 @@
>> { EXIT_REASON_UMWAIT, "UMWAIT" }, \
>> { EXIT_REASON_TPAUSE, "TPAUSE" }, \
>> { EXIT_REASON_BUS_LOCK, "BUS_LOCK" }, \
>> - { EXIT_REASON_NOTIFY, "NOTIFY" }
>> + { EXIT_REASON_NOTIFY, "NOTIFY" }, \
>> + { EXIT_REASON_TDCALL, "TDCALL" }
> Side topic:
> Strictly speaking, TDCALL vm-exit handling can happen for normal VMs.
Oh, yes. TDX CPU architectural specification, TDCALL in VMX non-root mode
causes VM exit with exit reason TDCALL. So, normal VM could exit with TDCALL.

> so, KVM may
> need to handle it by injecting #UD. Of course, it is not necessary for this series.
Currently, the handling of TDCALL for VMX VMs will return to userspace
with KVM_EXIT_INTERNAL_ERROR + KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON.
Since it's not an expected VM Exit reason for normal VMs, maybe it doesn't
worth a dedicated handler?