All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: David Edmondson <david.edmondson@oracle.com>
Cc: linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Joerg Roedel <joro@8bytes.org>,
	x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Ingo Molnar <mingo@redhat.com>, Jim Mattson <jmattson@google.com>,
	Borislav Petkov <bp@alien8.de>,
	Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: Re: [PATCH v2 2/3] KVM: x86: dump_vmcs should not conflate EFER and PAT presence in VMCS
Date: Tue, 23 Feb 2021 14:58:29 -0800	[thread overview]
Message-ID: <YDWIlb0epWBcxFNr@google.com> (raw)
In-Reply-To: <20210219144632.2288189-3-david.edmondson@oracle.com>

On Fri, Feb 19, 2021, David Edmondson wrote:
> Show EFER and PAT based on their individual entry/exit controls.
> 
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
>  arch/x86/kvm/vmx/vmx.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 818051c9fa10..25090e3683ca 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -5805,11 +5805,12 @@ void dump_vmcs(void)
>  	vmx_dump_sel("LDTR:", GUEST_LDTR_SELECTOR);
>  	vmx_dump_dtsel("IDTR:", GUEST_IDTR_LIMIT);
>  	vmx_dump_sel("TR:  ", GUEST_TR_SELECTOR);
> -	if ((vmexit_ctl & (VM_EXIT_SAVE_IA32_PAT | VM_EXIT_SAVE_IA32_EFER)) ||
> -	    (vmentry_ctl & (VM_ENTRY_LOAD_IA32_PAT | VM_ENTRY_LOAD_IA32_EFER)))
> -		pr_err("EFER =     0x%016llx  PAT = 0x%016llx\n",
> -		       vmcs_read64(GUEST_IA32_EFER),
> -		       vmcs_read64(GUEST_IA32_PAT));
> +	if ((vmexit_ctl & VM_EXIT_SAVE_IA32_EFER) ||

Not your code, and completely benign since VM_EXIT_SAVE is never set, but I
don't like checking the VM_EXIT_SAVE_* flag as saving a field on VM-Exit has
zero impact on whether VM-Entry succeeds or fails.  Same complaint on the PAT
field.

> +	    (vmentry_ctl & VM_ENTRY_LOAD_IA32_EFER))
> +		pr_err("EFER= 0x%016llx\n", vmcs_read64(GUEST_IA32_EFER));

Tying into the previous patch, I think we should print both the effective EFER
and vmcs.EFER.  The effective EFER is relevant for several consistency checks.
Maybe something like this?

	pr_err("EFER= 0x%016llx  ", effective_efer);
	if (vmentry_ctl & VM_ENTRY_LOAD_IA32_EFER)
		pr_cont("vmcs.EFER= 0x%016llx\n", vmcs_read64(GUEST_IA32_EFER));
	else
		pr_cont("vmcs.EFER not loaded\n")

> +	if ((vmexit_ctl & VM_EXIT_SAVE_IA32_PAT) ||
> +	    (vmentry_ctl & VM_ENTRY_LOAD_IA32_PAT))
> +		pr_err("PAT = 0x%016llx\n", vmcs_read64(GUEST_IA32_PAT));
>  	pr_err("DebugCtl = 0x%016llx  DebugExceptions = 0x%016lx\n",
>  	       vmcs_read64(GUEST_IA32_DEBUGCTL),
>  	       vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS));
> @@ -5846,10 +5847,10 @@ void dump_vmcs(void)
>  	       vmcs_readl(HOST_IA32_SYSENTER_ESP),
>  	       vmcs_read32(HOST_IA32_SYSENTER_CS),
>  	       vmcs_readl(HOST_IA32_SYSENTER_EIP));
> -	if (vmexit_ctl & (VM_EXIT_LOAD_IA32_PAT | VM_EXIT_LOAD_IA32_EFER))
> -		pr_err("EFER = 0x%016llx  PAT = 0x%016llx\n",
> -		       vmcs_read64(HOST_IA32_EFER),
> -		       vmcs_read64(HOST_IA32_PAT));
> +	if (vmexit_ctl & VM_EXIT_LOAD_IA32_EFER)
> +		pr_err("EFER= 0x%016llx\n", vmcs_read64(HOST_IA32_EFER));
> +	if (vmexit_ctl & VM_EXIT_LOAD_IA32_PAT)
> +		pr_err("PAT = 0x%016llx\n", vmcs_read64(HOST_IA32_PAT));
>  	if (cpu_has_load_perf_global_ctrl() &&
>  	    vmexit_ctl & VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL)
>  		pr_err("PerfGlobCtl = 0x%016llx\n",
> -- 
> 2.30.0
> 

  reply	other threads:[~2021-02-23 23:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-19 14:46 [PATCH v2 0/3] KVM: x86: dump_vmcs: don't assume GUEST_IA32_EFER, show MSR autoloads/autosaves David Edmondson
2021-02-19 14:46 ` [PATCH v2 1/3] KVM: x86: dump_vmcs should not assume GUEST_IA32_EFER is valid David Edmondson
2021-02-23 22:51   ` Sean Christopherson
2021-02-23 23:13     ` Jim Mattson
2021-02-23 23:41       ` Sean Christopherson
2021-02-24 13:30       ` David Edmondson
2021-02-23 23:18   ` Jim Mattson
2021-02-19 14:46 ` [PATCH v2 2/3] KVM: x86: dump_vmcs should not conflate EFER and PAT presence in VMCS David Edmondson
2021-02-23 22:58   ` Sean Christopherson [this message]
2021-02-24 13:31     ` David Edmondson
2021-02-19 14:46 ` [PATCH v2 3/3] KVM: x86: dump_vmcs should include the autoload/autostore MSR lists David Edmondson

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=YDWIlb0epWBcxFNr@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=david.edmondson@oracle.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.