mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jim Mattson <jmattson@google.com>
To: "Chang S. Bae" <chang.seok.bae@intel.com>
Cc: pbonzini@redhat.com, seanjc@google.com, kvm@vger.kernel.org,
	 x86@kernel.org, linux-kernel@vger.kernel.org,
	zhao1.liu@intel.com
Subject: Re: [PATCH v8 20/20] KVM: x86: selftests: Add APX state handling and XCR0 sanity checks
Date: Thu, 5 Nov 2026 21:36:14 -0800	[thread overview]
Message-ID: <CALMp9eRT-R18RT2iJLitYNYrqLn=qVFDdt1DYWHQbu20ks2Daw@mail.gmail.com> (raw)
In-Reply-To: <20260930210750.1487547-21-chang.seok.bae@intel.com>

On Wed, Sep 30, 2026 at 2:40 PM Chang S. Bae <chang.seok.bae@intel.com> wrote:
>
> Now that KVM exposes the APX feature to guests, extend some existing
> selftests to validate XCR0 configuration and state management.
>
> Since APX repurposes the XSAVE area previously used by MPX in the
> non-compacted format, add a check to ensure that MPX state is not set
> when APX is enabled.
>
> Also, load non-init APX state data in the guest so that XSTATE_BV[APX] is
> set, allowing validation of APX state testing.
>
> Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
> ---
>  tools/testing/selftests/kvm/x86/state_test.c  |  3 +++
>  .../selftests/kvm/x86/xcr0_cpuid_test.c       | 19 +++++++++++++++++++
>  2 files changed, 22 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/x86/state_test.c b/tools/testing/selftests/kvm/x86/state_test.c
> index 4a1056a6cb8d..9727dbb2b981 100644
> --- a/tools/testing/selftests/kvm/x86/state_test.c
> +++ b/tools/testing/selftests/kvm/x86/state_test.c
> @@ -164,6 +164,9 @@ static void __attribute__((__flatten__)) guest_code(void *arg)
>                         asm volatile ("vmovupd %0, %%zmm16" :: "m" (buffer));
>                 }
>
> +               if (supported_xcr0 & XFEATURE_MASK_APX)
> +                       write_egpr(16, 0xcccccccc);
> +

Nit: to match MPX and PKU below:

        if (this_cpu_has(X86_FEATURE_APX)) {
            GUEST_ASSERT(supported_xcr0 & XFEATURE_MASK_APX);
            write_egpr(16, 0xcccccccc);
        }

[ ... ]

> +#define ASSERT_XFEATURE_CONFLICT(supported_xcr0, xfeatures, conflicts)                 \
> +do {                                                                                   \
> +       uint64_t __supported = (supported_xcr0) & ((xfeatures) | (conflicts));          \

Nit: u64

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

  reply	other threads:[~2026-11-06  5:36 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 21:07 [PATCH v8 00/20] KVM: x86: Enable APX for guests Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 01/20] KVM: x86: Extend VCPU registers for EGPRs Chang S. Bae
2026-11-05 23:42   ` Jim Mattson
2026-11-06  5:32     ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 02/20] KVM: VMX: Save guest EGPRs in VCPU cache Chang S. Bae
2026-11-05 23:52   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 03/20] KVM: x86: Support APX state for XSAVE ABI Chang S. Bae
2026-11-06  0:13   ` Jim Mattson
2026-11-06  5:33     ` Chang S. Bae
2026-11-06  5:46       ` Jim Mattson
2026-11-06  5:57         ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 04/20] KVM: VMX: Refactor VMX instruction information access Chang S. Bae
2026-11-06  0:17   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 05/20] KVM: VMX: Refactor instruction information decoding Chang S. Bae
2026-11-06  0:19   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 06/20] KVM: VMX: Remove unused control-register access defines Chang S. Bae
2026-11-06  0:20   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 07/20] KVM: VMX: Refactor register index retrieval from exit qualification Chang S. Bae
2026-11-06  0:22   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 08/20] KVM: VMX: Support instruction information extension Chang S. Bae
2026-11-06  0:40   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 09/20] KVM: nVMX: Propagate extended instruction information Chang S. Bae
2026-11-06  0:53   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 10/20] KVM: x86: Support EGPR accessing and tracking for emulator Chang S. Bae
2026-11-06  0:55   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 11/20] KVM: x86: Handle EGPR index and REX2-incompatible opcodes Chang S. Bae
2026-11-06  4:34   ` Jim Mattson
2026-11-06 13:53     ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 12/20] KVM: x86: Support REX2-prefixed opcode decode Chang S. Bae
2026-11-06  4:48   ` Jim Mattson
2026-11-06 14:07     ` Jim Mattson
2026-11-17 18:38       ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 13/20] KVM: x86: Reject EVEX-prefixed instructions Chang S. Bae
2026-11-06  4:56   ` Jim Mattson
2026-11-06 14:17     ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 14/20] KVM: x86: Move KVM_SUPPORTED_{XCR0,XSS} into kvm_x86_vendor_init() Chang S. Bae
2026-11-06  4:58   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 15/20] KVM: x86: Guard valid XCR0.APX settings Chang S. Bae
2026-11-06  5:00   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 16/20] KVM: x86: Add APX to supported XCR0 Chang S. Bae
2026-11-06  5:01   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 17/20] KVM: x86: Expose APX foundation feature to userspace Chang S. Bae
2026-11-06  5:05   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 18/20] KVM: x86: Expose APX sub-features " Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 19/20] KVM: x86: selftests: Add APX state and ABI test Chang S. Bae
2026-11-06  5:31   ` Jim Mattson
2026-09-30 21:07 ` [PATCH v8 20/20] KVM: x86: selftests: Add APX state handling and XCR0 sanity checks Chang S. Bae
2026-11-06  5:36   ` Jim Mattson [this message]
2026-10-01 20:29 ` [PATCH v8 00/20] KVM: x86: Enable APX for guests Chang S. Bae
2026-11-04  0:45   ` Chang S. Bae

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='CALMp9eRT-R18RT2iJLitYNYrqLn=qVFDdt1DYWHQbu20ks2Daw@mail.gmail.com' \
    --to=jmattson@google.com \
    --cc=chang.seok.bae@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=x86@kernel.org \
    --cc=zhao1.liu@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

all inboxes | Powered by JetHome®