lkml.org 
[lkml]   [2022]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH v6 087/104] KVM: TDX: handle EXCEPTION_NMI and EXTERNAL_INTERRUPT
    Date
    From: Isaku Yamahata <isaku.yamahata@intel.com>

    Because guest TD state is protected, exceptions in guest TDs can't be
    intercepted. TDX VMM doesn't need to handle exceptions.
    tdx_handle_exit_irqoff() handles NMI and machine check. Ignore NMI and
    machine check and continue guest TD execution.

    For external interrupt, increment stats same to the VMX case.

    Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
    Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
    ---
    arch/x86/kvm/vmx/tdx.c | 23 +++++++++++++++++++++++
    1 file changed, 23 insertions(+)

    diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
    index 82bfdb05e67b..2f88871b5b86 100644
    --- a/arch/x86/kvm/vmx/tdx.c
    +++ b/arch/x86/kvm/vmx/tdx.c
    @@ -851,6 +851,25 @@ void tdx_handle_exit_irqoff(struct kvm_vcpu *vcpu)
    tdexit_intr_info(vcpu));
    }

    +static int tdx_handle_exception(struct kvm_vcpu *vcpu)
    +{
    + u32 intr_info = tdexit_intr_info(vcpu);
    +
    + if (is_nmi(intr_info) || is_machine_check(intr_info))
    + return 1;
    +
    + kvm_pr_unimpl("unexpected exception 0x%x(exit_reason 0x%llx qual 0x%lx)\n",
    + intr_info,
    + to_tdx(vcpu)->exit_reason.full, tdexit_exit_qual(vcpu));
    + return -EFAULT;
    +}
    +
    +static int tdx_handle_external_interrupt(struct kvm_vcpu *vcpu)
    +{
    + ++vcpu->stat.irq_exits;
    + return 1;
    +}
    +
    static int tdx_handle_triple_fault(struct kvm_vcpu *vcpu)
    {
    vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN;
    @@ -1251,6 +1270,10 @@ int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath)
    WARN_ON_ONCE(fastpath != EXIT_FASTPATH_NONE);

    switch (exit_reason.basic) {
    + case EXIT_REASON_EXCEPTION_NMI:
    + return tdx_handle_exception(vcpu);
    + case EXIT_REASON_EXTERNAL_INTERRUPT:
    + return tdx_handle_external_interrupt(vcpu);
    case EXIT_REASON_EPT_VIOLATION:
    return tdx_handle_ept_violation(vcpu);
    case EXIT_REASON_EPT_MISCONFIG:
    --
    2.25.1
    \
     
     \ /
      Last update: 2022-05-05 20:29    [W:9.799 / U:0.220 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site