public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 05/11] KVM: selftests: Configure XCR0 to max supported value by default
Date: Fri, 4 Oct 2024 06:35:29 -0700	[thread overview]
Message-ID: <Zv_uvVT9RmiN84y_@google.com> (raw)
In-Reply-To: <87v7y8i6m3.fsf@redhat.com>

On Fri, Oct 04, 2024, Vitaly Kuznetsov wrote:
> Sean Christopherson <seanjc@google.com> writes:
> 
> > To play nice with compilers generating AVX instructions, set CR4.OSXSAVE
> > and configure XCR0 by default when creating selftests vCPUs.  Some distros
> > have switched gcc to '-march=x86-64-v3' by default, and while it's hard to
> > find a CPU which doesn't support AVX today, many KVM selftests fail with
> >
> >   ==== Test Assertion Failure ====
> >     lib/x86_64/processor.c:570: Unhandled exception in guest
> >     pid=72747 tid=72747 errno=4 - Interrupted system call
> >     Unhandled exception '0x6' at guest RIP '0x4104f7'
> >
> > due to selftests not enabling AVX by default for the guest.  The failure
> > is easy to reproduce elsewhere with:
> >
> >    $ make clean && CFLAGS='-march=x86-64-v3' make -j && ./x86_64/kvm_pv_test
> >
> > E.g. gcc-13 with -march=x86-64-v3 compiles this chunk from selftests'
> > kvm_fixup_exception():
> >
> >         regs->rip = regs->r11;
> >         regs->r9 = regs->vector;
> >         regs->r10 = regs->error_code;
> >
> > into this monstronsity (which is clever, but oof):
> >
> >   405313:       c4 e1 f9 6e c8          vmovq  %rax,%xmm1
> >   405318:       48 89 68 08             mov    %rbp,0x8(%rax)
> >   40531c:       48 89 e8                mov    %rbp,%rax
> >   40531f:       c4 c3 f1 22 c4 01       vpinsrq $0x1,%r12,%xmm1,%xmm0
> >   405325:       49 89 6d 38             mov    %rbp,0x38(%r13)
> >   405329:       c5 fa 7f 45 00          vmovdqu %xmm0,0x0(%rbp)
> >
> > Alternatively, KVM selftests could explicitly restrict the compiler to
> > -march=x86-64-v2, but odds are very good that punting on AVX enabling will
> > simply result in tests that "need" AVX doing their own thing, e.g. there
> > are already three or so additional cleanups that can be done on top.
> 
> Ideally, we may still want to precisely pin the set of instructions
> which are used to generete guest code in selftests as the environment
> where this code runs is defined by us and it may not match the host. I
> can easily imaging future CPU features leading to similar issues in case
> they require explicit enablement.

Maybe.  I suspect the cross-section of features that require explicit enablement
*and* will be generated by the compiler for "regular" code will be limited to AVX
and the like.  E.g. the only new in -v4 is AVX512.

> To achive this, we can probably separate guest code from each test into its
> own compilation unit.

Hopefully we don't need to worry about that for years and years :-)

  reply	other threads:[~2024-10-04 13:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 23:43 [PATCH 00/11] KVM: selftests: AVX support + fixes Sean Christopherson
2024-10-03 23:43 ` [PATCH 01/11] KVM: selftests: Fix out-of-bounds reads in CPUID test's array lookups Sean Christopherson
2024-10-04  8:22   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 02/11] KVM: selftests: Precisely mask off dynamic fields in CPUID test Sean Christopherson
2024-10-04  9:02   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 03/11] KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID entries Sean Christopherson
2024-10-04  9:02   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 04/11] KVM: selftests: Rework OSXSAVE CR4=>CPUID test to play nice with AVX insns Sean Christopherson
2024-10-04  9:02   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 05/11] KVM: selftests: Configure XCR0 to max supported value by default Sean Christopherson
2024-10-04  9:01   ` Vitaly Kuznetsov
2024-10-04 13:35     ` Sean Christopherson [this message]
2024-10-03 23:43 ` [PATCH 06/11] KVM: selftests: Verify XCR0 can be "downgraded" and "upgraded" Sean Christopherson
2024-10-04  9:04   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 07/11] KVM: selftests: Drop manual CR4.OSXSAVE enabling from CR4/CPUID sync test Sean Christopherson
2024-10-04  9:05   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 08/11] KVM: selftests: Drop manual XCR0 configuration from AMX test Sean Christopherson
2024-10-04  9:09   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 09/11] KVM: selftests: Drop manual XCR0 configuration from state test Sean Christopherson
2024-10-04  9:10   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 10/11] KVM: selftests: Drop manual XCR0 configuration from SEV smoke test Sean Christopherson
2024-10-03 23:43 ` [PATCH 11/11] KVM: selftests: Ensure KVM supports AVX for SEV-ES VMSA FPU test Sean Christopherson
2024-10-04  9:14   ` Vitaly Kuznetsov
2024-10-20 11:28 ` [PATCH 00/11] KVM: selftests: AVX support + fixes Paolo Bonzini
2024-10-31 19:51 ` Sean Christopherson
2024-11-01 19:31   ` 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=Zv_uvVT9RmiN84y_@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vkuznets@redhat.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