kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jim Mattson <jmattson@google.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Liran Alon <liran.alon@oracle.com>,
	Oliver Upton <oupton@google.com>, Peter Shier <pshier@google.com>
Subject: Re: [PATCH v3 3/4] kvm: vmx: Add last_cpu to struct vcpu_vmx
Date: Mon, 1 Jun 2020 18:21:39 -0700	[thread overview]
Message-ID: <20200602012139.GF21661@linux.intel.com> (raw)
In-Reply-To: <20200601222416.71303-4-jmattson@google.com>

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@google.com>
> Reviewed-by: Oliver Upton <oupton@google.com>
> Reviewed-by: Peter Shier <pshier@google.com>
> ---
>  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.

>  	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.

And if it's in arch, what about setting it vcpu_enter_guest?

>  };
>  
>  enum ept_pointers_status {
> -- 
> 2.27.0.rc2.251.g90737beb825-goog
> 

  reply	other threads:[~2020-06-02  1:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-01 22:24 [PATCH v3 0/4] Add logical CPU to KVM_EXIT_FAIL_ENTRY info Jim Mattson
2020-06-01 22:24 ` [PATCH v3 1/4] kvm: svm: Prefer vcpu->cpu to raw_smp_processor_id() Jim Mattson
2020-06-01 22:24 ` [PATCH v3 2/4] kvm: svm: Always set svm->last_cpu on VMRUN Jim Mattson
2020-06-01 22:24 ` [PATCH v3 3/4] kvm: vmx: Add last_cpu to struct vcpu_vmx Jim Mattson
2020-06-02  1:21   ` Sean Christopherson [this message]
2020-06-02 17:33     ` Jim Mattson
2020-06-03  2:24       ` Sean Christopherson
2020-06-03 20:18         ` Jim Mattson
2020-06-04 18:46           ` Sean Christopherson
2020-06-04 19:00             ` Jim Mattson
2020-06-04 19:26               ` Sean Christopherson
2020-06-04 20:54                 ` Jim Mattson
2020-06-01 22:24 ` [PATCH v3 4/4] kvm: x86: Add "last CPU" to some KVM_EXIT information Jim Mattson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200602012139.GF21661@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=liran.alon@oracle.com \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=pshier@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).