Re: [PATCH 3/3] KVM: selftests: Add XCR0 Test

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

 



> > +#include "kvm_util.h"
> > +#include "processor.h"
> > +
> > +#define XFEATURE_MASK_SSE              (1ul << 1)
> > +#define XFEATURE_MASK_YMM              (1ul << 2)
> > +#define XFEATURE_MASK_BNDREGS          (1ul << 3)
> > +#define XFEATURE_MASK_BNDCSR           (1ul << 4)
> > +#define XFEATURE_MASK_OPMASK           (1ul << 5)
> > +#define XFEATURE_MASK_ZMM_Hi256                (1ul << 6)
> > +#define XFEATURE_MASK_Hi16_ZMM         (1ul << 7)
> > +#define XFEATURE_MASK_XTILECFG         (1ul << 17)
> > +#define XFEATURE_MASK_XTILEDATA                (1ul << 18)
> > +#define XFEATURE_MASK_XTILE            (XFEATURE_MASK_XTILECFG | \
> > +                                        XFEATURE_MASK_XTILEDATA)
>
> With XSETBV hoisted into processor.h, shouldn't these macros be more
> widely available as well?

Sure, I'll hoist them up there too.

>
> > +static uint64_t get_supported_user_xfeatures(void)
> > +{
> > +       uint32_t a, b, c, d;
> > +
> > +       cpuid(0xd, &a, &b, &c, &d);
> > +
> > +       return a | ((uint64_t)d << 32);
> > +}
> > +
> > +       GUEST_ASSERT(xcr0_rest == 1ul);
> > +
> > +       /* Check AVX */
> > +       xfeature_mask = XFEATURE_MASK_SSE | XFEATURE_MASK_YMM;
> > +       supported_state = supported_xcr0 & xfeature_mask;
> > +       GUEST_ASSERT(supported_state != XFEATURE_MASK_YMM);
> > +
> > +       /* Check MPX */
> > +       xfeature_mask = XFEATURE_MASK_BNDREGS | XFEATURE_MASK_BNDCSR;
> > +       supported_state = supported_xcr0 & xfeature_mask;
> > +       GUEST_ASSERT((supported_state == xfeature_mask) ||
> > +                    (supported_state == 0ul));
> > +
> > +       /* Check AVX-512 */
> > +       xfeature_mask = XFEATURE_MASK_OPMASK |
> > +                       XFEATURE_MASK_ZMM_Hi256 |
> > +                       XFEATURE_MASK_Hi16_ZMM;
> > +       supported_state = supported_xcr0 & xfeature_mask;
> > +       GUEST_ASSERT((supported_state == xfeature_mask) ||
> > +                    (supported_state == 0ul));
> > +
> > +       /* Check AMX */
> > +       xfeature_mask = XFEATURE_MASK_XTILE;
> > +       supported_state = supported_xcr0 & xfeature_mask;
> > +       GUEST_ASSERT((supported_state == xfeature_mask) ||
> > +                    (supported_state == 0ul));
>
> In this series, you've added code to __do_cpuid_func() to ensure that
> XFEATURE_MASK_XTILECFG and XFEATURE_MASK_XTILEDATA can't be set unless
> the other is set. Do we need to do something similar for AVX-512 and
> MPX?

That does sound like a natural extension of this.  I can add support
for that in v2.

>
> > +       GUEST_SYNC(0);
> > +
> > +       xsetbv(0, supported_xcr0);
> > +
> > +       GUEST_DONE();
> > +}
> > +
> > +static void guest_gp_handler(struct ex_regs *regs)
> > +{
> > +       GUEST_ASSERT(!"Failed to set the supported xfeature bits in XCR0.");
> > +}
> > +



[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