Re: [RFC PATCH v5 064/104] KVM: TDX: Implement TDX vcpu enter/exit path

From: Isaku Yamahata
Date: Wed Mar 23 2022 - 13:55:58 EST


On Tue, Mar 22, 2022 at 10:28:42AM -0700,
Erdem Aktas <erdemaktas@xxxxxxxxxx> wrote:

> On Fri, Mar 4, 2022 at 11:50 AM <isaku.yamahata@xxxxxxxxx> wrote:
> > @@ -509,6 +512,37 @@ void tdx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
> > vcpu->kvm->vm_bugged = true;
> > }
> >
> > +u64 __tdx_vcpu_run(hpa_t tdvpr, void *regs, u32 regs_mask);
> > +
> > +static noinstr void tdx_vcpu_enter_exit(struct kvm_vcpu *vcpu,
> > + struct vcpu_tdx *tdx)
> > +{
> > + guest_enter_irqoff();
> > + tdx->exit_reason.full = __tdx_vcpu_run(tdx->tdvpr.pa, vcpu->arch.regs, 0);
> > + guest_exit_irqoff();
> > +}
> > +
> > +fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu)
> > +{
> > + struct vcpu_tdx *tdx = to_tdx(vcpu);
> > +
> > + if (unlikely(vcpu->kvm->vm_bugged)) {
> > + tdx->exit_reason.full = TDX_NON_RECOVERABLE_VCPU;
> > + return EXIT_FASTPATH_NONE;
> > + }
> > +
> > + trace_kvm_entry(vcpu);
> > +
> > + tdx_vcpu_enter_exit(vcpu, tdx);
> > +
> > + vcpu->arch.regs_avail &= ~VMX_REGS_LAZY_LOAD_SET;
> > + trace_kvm_exit(vcpu, KVM_ISA_VMX);
> > +
> > + if (tdx->exit_reason.error || tdx->exit_reason.non_recoverable)
> > + return EXIT_FASTPATH_NONE;
>
> Looks like the above if statement has no effect. Just checking if this
> is intentional.

I'm not sure if I get your point. tdx->exit_reason is updated by the above
tdx_cpu_enter_exit(). So it makes sense to check .error or .non_recoverable.
--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>