On 10/27/2024 11:33 PM, Chao Gao wrote:
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index d81144bd648f..03f42b218554 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -1910,8 +1910,11 @@ void vmx_inject_exception(struct kvm_vcpu *vcpu)
vmcs_write32(VM_ENTRY_INSTRUCTION_LEN,
vmx->vcpu.arch.event_exit_inst_len);
intr_info |= INTR_TYPE_SOFT_EXCEPTION;
- } else
+ } else {
intr_info |= INTR_TYPE_HARD_EXCEPTION;
+ if (ex->nested)
+ intr_info |= INTR_INFO_NESTED_EXCEPTION_MASK;
how about moving the is_fred_enable() check from kvm_multiple_exception() to here? i.e.,
if (ex->nested && is_fred_enabled(vcpu))
intr_info |= INTR_INFO_NESTED_EXCEPTION_MASK;
It is slightly clearer because FRED details don't bleed into kvm_multiple_exception().
But FRED is all about events, including exception/interrupt/trap/...
logically VMX nested exception only works when FRED is enabled, see how it is
set at 2 places in kvm_multiple_exception().
"VMX nested exception only works ..." is what I referred to as "FRED details"
I believe there are several reasons to decouple the "nested exception" concept
from FRED:
1. Readers new to FRED can understand kvm_multiple_exception() without needing
to know FRED details. Readers just need to know nested exceptions are
exceptions encountered during delivering another event (exception/NMI/interrupts).
2. Developing KVM's generic "nested exception" concept can support other vendors.
"nested" becomes a property of an exception. only how nested exceptions are
reported to guests is specific to vendors (i.e., VMX/SVM).
3. This series handles ex->event_data in a similar approach: set it regardless
of FRED enablement and let VMX/SVM code decide to consume or ignore it.
This is a nice way to look at the nature of nested exception, and I have
made the change for the next iteration.
Thanks!
Xin