Re: [PATCH v9 13/22] KVM: VMX: Virtualize FRED nested exception tracking
From: Chao Gao
Date: Wed Nov 19 2025 - 01:55:12 EST
On Sun, Oct 26, 2025 at 01:19:01PM -0700, Xin Li (Intel) wrote:
>From: Xin Li <xin3.li@xxxxxxxxx>
>
>Set the VMX nested exception bit in VM-entry interruption information
>field when injecting a nested exception using FRED event delivery to
>ensure:
> 1) A nested exception is injected on a correct stack level.
> 2) The nested bit defined in FRED stack frame is set.
>
>The event stack level used by FRED event delivery depends on whether
>the event was a nested exception encountered during delivery of an
>earlier event, because a nested exception is "regarded" as happening
>on ring 0. E.g., when #PF is configured to use stack level 1 in
>IA32_FRED_STKLVLS MSR:
> - nested #PF will be delivered on the stack pointed by IA32_FRED_RSP1
> MSR when encountered in ring 3 and ring 0.
> - normal #PF will be delivered on the stack pointed by IA32_FRED_RSP0
> MSR when encountered in ring 3.
>
>The VMX nested-exception support ensures a correct event stack level is
>chosen when a VM entry injects a nested exception.
>
>Signed-off-by: Xin Li <xin3.li@xxxxxxxxx>
>[ Sean: reworked kvm_requeue_exception() to simply the code changes ]
>Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
>Signed-off-by: Xin Li (Intel) <xin@xxxxxxxxx>
>Tested-by: Shan Kang <shan.kang@xxxxxxxxx>
>Tested-by: Xuelian Guo <xuelian.guo@xxxxxxxxx>
Reviewed-by: Chao Gao <chao.gao@xxxxxxxxx>