On Mon, Jun 1, 2020 at 6:21 PM Sean Christopherson <sean.j.christopherson@xxxxxxxxx> wrote: > > On Mon, Jun 01, 2020 at 03:24:15PM -0700, Jim Mattson wrote: > > As we already do in svm, record the last logical processor on which a > > vCPU has run, so that it can be communicated to userspace for > > potential hardware errors. > > > > Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx> > > Reviewed-by: Oliver Upton <oupton@xxxxxxxxxx> > > Reviewed-by: Peter Shier <pshier@xxxxxxxxxx> > > --- > > arch/x86/kvm/vmx/vmx.c | 1 + > > arch/x86/kvm/vmx/vmx.h | 3 +++ > > 2 files changed, 4 insertions(+) > > > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > > index 170cc76a581f..42856970d3b8 100644 > > --- a/arch/x86/kvm/vmx/vmx.c > > +++ b/arch/x86/kvm/vmx/vmx.c > > @@ -6730,6 +6730,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) > > if (vcpu->arch.cr2 != read_cr2()) > > write_cr2(vcpu->arch.cr2); > > > > + vmx->last_cpu = vcpu->cpu; > > This is redundant in the EXIT_FASTPATH_REENTER_GUEST case. Setting it > before reenter_guest is technically wrong if emulation_required is true, but > that doesn't seem like it'd be an issue in practice. I really would like to capture the last logical processor to execute VMLAUNCH/VMRESUME (or VMRUN on the AMD side) on behalf of this vCPU. > > vmx->fail = __vmx_vcpu_run(vmx, (unsigned long *)&vcpu->arch.regs, > > vmx->loaded_vmcs->launched); > > > > diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h > > index 672c28f17e49..8a1e833cf4fb 100644 > > --- a/arch/x86/kvm/vmx/vmx.h > > +++ b/arch/x86/kvm/vmx/vmx.h > > @@ -302,6 +302,9 @@ struct vcpu_vmx { > > u64 ept_pointer; > > > > struct pt_desc pt_desc; > > + > > + /* which host CPU was used for running this vcpu */ > > + unsigned int last_cpu; > > Why not put this in struct kvm_vcpu_arch? I'd also vote to name it > last_run_cpu, as last_cpu is super misleading. I think last_run_cpu may also be misleading, since in the cases of interest, nothing actually 'ran.' Maybe last_attempted_vmentry_cpu? > And if it's in arch, what about setting it vcpu_enter_guest? As you point out above, this isn't entirely accurate. (But that's the way we roll in kvm, isn't it? :-) > > }; > > > > enum ept_pointers_status { > > -- > > 2.27.0.rc2.251.g90737beb825-goog > >