[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YsXIJ50adC+TVejy@google.com>
Date: Wed, 6 Jul 2022 17:36:39 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Maxim Levitsky <mlevitsk@...hat.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Oliver Upton <oupton@...gle.com>,
Peter Shier <pshier@...gle.com>
Subject: Re: [PATCH v2 13/21] KVM: x86: Formalize blocking of nested pending
exceptions
On Wed, Jul 06, 2022, Maxim Levitsky wrote:
> On Tue, 2022-06-14 at 20:47 +0000, Sean Christopherson wrote:
> > Capture nested_run_pending as block_pending_exceptions so that the logic
> > of why exceptions are blocked only needs to be documented once instead of
> > at every place that employs the logic.
> >
> > No functional change intended.
> >
> > Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> > ---
> > arch/x86/kvm/svm/nested.c | 20 ++++++++++----------
> > arch/x86/kvm/vmx/nested.c | 23 ++++++++++++-----------
> > 2 files changed, 22 insertions(+), 21 deletions(-)
> >
> > diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> > index 471d40e97890..460161e67ce5 100644
> > --- a/arch/x86/kvm/svm/nested.c
> > +++ b/arch/x86/kvm/svm/nested.c
> > @@ -1347,10 +1347,16 @@ static inline bool nested_exit_on_init(struct vcpu_svm *svm)
> >
> > static int svm_check_nested_events(struct kvm_vcpu *vcpu)
> > {
> > - struct vcpu_svm *svm = to_svm(vcpu);
> > - bool block_nested_events =
> > - kvm_event_needs_reinjection(vcpu) || svm->nested.nested_run_pending;
> > struct kvm_lapic *apic = vcpu->arch.apic;
> > + struct vcpu_svm *svm = to_svm(vcpu);
> > + /*
> > + * Only a pending nested run blocks a pending exception. If there is a
> > + * previously injected event, the pending exception occurred while said
> > + * event was being delivered and thus needs to be handled.
> > + */
>
> Tiny nitpick about the comment:
>
> One can say that if there is an injected event, this means that we
> are in the middle of handling it, thus we are not on instruction boundary,
> and thus we don't process events (e.g interrupts).
>
> So maybe write something like that?
Hmm, that's another way to look at things. My goal with the comment was to try
and call out that any pending exception is a continuation of the injected event,
i.e. that the injected event won't be lost. Talking about instruction boundaries
only explains why non-exception events are blocked, it doesn't explain why exceptions
are _not_ blocked.
I'll add a second comment above block_nested_events to capture the instruction
boundary angle.
> > + bool block_nested_exceptions = svm->nested.nested_run_pending;
> > + bool block_nested_events = block_nested_exceptions ||
> > + kvm_event_needs_reinjection(vcpu);
>
> Tiny nitpick: I don't like that much the name 'nested' as
> it can also mean a nested exception (e.g exception that
> happened while jumping to an exception handler).
>
> Here we mean just exception/events for the guest, so I would suggest
> to just drop the word 'nested'.
I don't disagree, but I'd prefer to keep the current naming because the helper
itself is *_check_nested_events(). I'm not opposed to renaming things in the
future, but I don't want to do that in this series.
Powered by blists - more mailing lists