All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Mattson <jmattson@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, seanjc@google.com,
	like.xu.linux@gmail.com
Subject: Re: [PATCH 2/3] KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible
Date: Tue, 27 Dec 2022 13:23:32 -0800	[thread overview]
Message-ID: <CALMp9eS1Tap_fF4Yn-5yyqBPZQ0XBnzmUVThjDSQPfR8giqCmA@mail.gmail.com> (raw)
In-Reply-To: <20221227183713.29140-3-aaronlewis@google.com>

On Tue, Dec 27, 2022 at 10:38 AM Aaron Lewis <aaronlewis@google.com> wrote:
>
> The instructions XGETBV and XSETBV are useful to other tests.  Move
> them to processor.h to make them available to be used more broadly.
>
> No functional change intended.
>
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> ---
>  .../selftests/kvm/include/x86_64/processor.h  | 19 +++++++++++++++
>  tools/testing/selftests/kvm/x86_64/amx_test.c | 24 +++----------------
>  2 files changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
> index b1a31de7108ac..34957137be375 100644
> --- a/tools/testing/selftests/kvm/include/x86_64/processor.h
> +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
> @@ -492,6 +492,25 @@ static inline void set_cr4(uint64_t val)
>         __asm__ __volatile__("mov %0, %%cr4" : : "r" (val) : "memory");
>  }
>
> +static inline u64 xgetbv(u32 index)
> +{
> +       u32 eax, edx;
> +
> +       __asm__ __volatile__("xgetbv;"
> +                    : "=a" (eax), "=d" (edx)
> +                    : "c" (index));
> +       return eax | ((u64)edx << 32);
> +}
> +
> +static inline void xsetbv(u32 index, u64 value)
> +{
> +       u32 eax = value;
> +       u32 edx = value >> 32;
> +
> +       __asm__ __volatile__("xsetbv" :: "a" (eax), "d" (edx), "c" (index));
> +}
> +
> +

Not your change, but shouldn't both of these asm statements have
artificial "memory" clobbers, to prevent reordering?

Reviewed-by: Jim Mattson <jmattson@google.com>

  reply	other threads:[~2022-12-27 21:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27 18:37 [PATCH 0/3] Clean up AMX cpuid bits XTILE_CFG and XTILE_DATA Aaron Lewis
2022-12-27 18:37 ` [PATCH 1/3] KVM: x86: Clear XTILE_CFG if XTILE_DATA is clear Aaron Lewis
2022-12-27 19:56   ` Jim Mattson
2022-12-27 20:43     ` Aaron Lewis
2022-12-27 21:14       ` Jim Mattson
2022-12-27 21:36         ` Jim Mattson
2022-12-27 18:37 ` [PATCH 2/3] KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible Aaron Lewis
2022-12-27 21:23   ` Jim Mattson [this message]
2022-12-27 18:37 ` [PATCH 3/3] KVM: selftests: Add XCR0 Test Aaron Lewis
2022-12-27 22:07   ` Jim Mattson
2022-12-28  0:15     ` Aaron Lewis
2022-12-27 20:00 ` [PATCH 0/3] Clean up AMX cpuid bits XTILE_CFG and XTILE_DATA Jim Mattson
2022-12-27 20:40   ` Aaron Lewis

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=CALMp9eS1Tap_fF4Yn-5yyqBPZQ0XBnzmUVThjDSQPfR8giqCmA@mail.gmail.com \
    --to=jmattson@google.com \
    --cc=aaronlewis@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=like.xu.linux@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@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 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.