Re: [PATCH 2/3] KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 27, 2022 at 10:38 AM Aaron Lewis <aaronlewis@xxxxxxxxxx> 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@xxxxxxxxxx>
> ---
>  .../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@xxxxxxxxxx>



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux