[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALMp9eQi1xU_YgYBTa=zvAkD8=4WAntSFt6V2zcR6G9eQFg2GQ@mail.gmail.com>
Date: Wed, 5 Jan 2022 14:30:45 -0800
From: Jim Mattson <jmattson@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Yang Zhong <yang.zhong@...el.com>, x86@...nel.org,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kselftest@...r.kernel.org,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, pbonzini@...hat.com, corbet@....net,
shuah@...nel.org, jun.nakajima@...el.com, kevin.tian@...el.com,
jing2.liu@...ux.intel.com, jing2.liu@...el.com,
guang.zeng@...el.com, wei.w.wang@...el.com
Subject: Re: [PATCH v5 12/21] kvm: x86: Intercept #NM for saving IA32_XFD_ERR
On Wed, Jan 5, 2022 at 2:22 PM Sean Christopherson <seanjc@...gle.com> wrote:
>
> On Wed, Jan 05, 2022, Yang Zhong wrote:
> > @@ -6399,6 +6424,26 @@ static void handle_interrupt_nmi_irqoff(struct kvm_vcpu *vcpu,
> > kvm_after_interrupt(vcpu);
> > }
> >
> > +static void handle_nm_fault_irqoff(struct kvm_vcpu *vcpu)
> > +{
> > + /*
> > + * Save xfd_err to guest_fpu before interrupt is enabled, so the
> > + * MSR value is not clobbered by the host activity before the guest
> > + * has chance to consume it.
> > + *
> > + * We should not blindly read xfd_err here, since this exception
>
> Nit, avoid "we", and explain what KVM does (or doesn't) do, not what KVM "should"
> do, e.g. just say
>
> * Do not blindly read ...
>
> > + * might be caused by L1 interception on a platform which doesn't
> > + * support xfd at all.
> > + *
> > + * Do it conditionally upon guest_fpu::xfd. xfd_err matters
> > + * only when xfd contains a non-zero value.
> > + *
> > + * Queuing exception is done in vmx_handle_exit. See comment there.
>
> Another nit, it's worth explaining why XFD_ERR needs to be read here regardless
> of is_guest_mode(). E.g.
>
> * Injecting the #NM back into the guest is handled in the standard path
> * as an #NM in L2 may be reflected into L1 as a VM-Exit. Read XFD_ERR
> * even if the #NM is from L2, as L1 may have exposed XFD to L2.
Do we have tests of L1 passing through XFD to L2?
Powered by blists - more mailing lists