From: Sean Christopherson <seanjc@google.com>
To: Zhenzhong Duan <zhenzhong.duan@intel.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH] x86: Assign a canonical address before execute invpcid
Date: Thu, 30 Dec 2021 15:52:15 +0000 [thread overview]
Message-ID: <Yc3VryxgJbXXwyy3@google.com> (raw)
In-Reply-To: <20211230101452.380581-1-zhenzhong.duan@intel.com>
On Thu, Dec 30, 2021, Zhenzhong Duan wrote:
> Occasionally we see pcid test fail as INVPCID_DESC[127:64] is
> uninitialized before execute invpcid.
>
> According to Intel spec: "#GP If INVPCID_TYPE is 0 and the linear
> address in INVPCID_DESC[127:64] is not canonical."
>
> Assign desc's address which is guaranteed to be a real memory
> address and canonical.
>
> Fixes: b44d84dae10c ("Add PCID/INVPCID test")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
> x86/pcid.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/x86/pcid.c b/x86/pcid.c
> index 527a4a9..4828bbc 100644
> --- a/x86/pcid.c
> +++ b/x86/pcid.c
> @@ -75,6 +75,9 @@ static void test_invpcid_enabled(int pcid_enabled)
> struct invpcid_desc desc;
> desc.rsv = 0;
>
> + /* Initialize INVPCID_DESC[127:64] with a canonical address */
> + desc.addr = (u64)&desc;
Casting to a u64 is arguably wrong since the address is an unsigned long. It
doesn't cause problems because the test is 64-bit only, but it's a bit odd.
What about just replacing "desc.rsv = 0" with "memset(&desc, 0, sizeof(desc))"?
> +
> /* try executing invpcid when CR4.PCIDE=0, desc.pcid=0 and type=0..3
> * no exception expected
> */
> --
> 2.25.1
>
next prev parent reply other threads:[~2021-12-30 15:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-30 10:14 [kvm-unit-tests PATCH] x86: Assign a canonical address before execute invpcid Zhenzhong Duan
2021-12-30 15:52 ` Sean Christopherson [this message]
2021-12-30 17:50 ` Sean Christopherson
2022-01-11 8:22 ` Duan, Zhenzhong
2022-01-11 16:23 ` Sean Christopherson
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=Yc3VryxgJbXXwyy3@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=zhenzhong.duan@intel.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).