Re: [RESEND PATCH 5/6] KVM: x86/VMX: add kvm_vmx_reinject_nmi_irq() for NMI/IRQ reinjection

Sean Christopherson
2022-11-28T16:28:20Z

On Thu, Nov 24, 2022, Li, Xin3 wrote:
> > > > thouh we'd like want a fair bit of refactoring so that all of
> > > > vmx_vcpu_run() and
> > > > svm_vcpu_run() don't need to be noinstr.
> >
> > For the record, svm_vcpu_run() is fine, at least as far as NMIs are concerned.
> >
> > > This sounds reasonable to me, however from
> > > Documentation/core-api/entry.rst, we do need it.
> >
> > Why do you say that?
> >
>
> Copy/Paste from Documentation/core-api/entry.rst:

I'm very confused. What do you mean by "we do need it". What is "it"? And what
does "it" have to do with the below documentation? The documentation does nothing
more than explain how KVM handles task work.

> KVM
> ---
>
> Entering or exiting guest mode is very similar to syscalls. From the host
> kernel point of view the CPU goes off into user space when entering the
> guest and returns to the kernel on exit.
>
> kvm_guest_enter_irqoff() is a KVM-specific variant of exit_to_user_mode()
> and kvm_guest_exit_irqoff() is the KVM variant of enter_from_user_mode().
> The state operations have the same ordering.
>
> Task work handling is done separately for guest at the boundary of the
> vcpu_run() loop via xfer_to_guest_mode_handle_work() which is a subset of
> the work handled on return to user space.
>
> Do not nest KVM entry/exit transitions because doing so is nonsensical.