From: Chao Gao <chao.gao@intel.com>
To: "Chang S. Bae" <chang.seok.bae@intel.com>
Cc: <tglx@linutronix.de>, <dave.hansen@intel.com>, <x86@kernel.org>,
<seanjc@google.com>, <pbonzini@redhat.com>,
<linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>,
<peterz@infradead.org>, <rick.p.edgecombe@intel.com>,
<weijiang.yang@intel.com>, <john.allen@amd.com>, <bp@alien8.de>
Subject: Re: [PATCH v3 09/10] x86/fpu/xstate: Introduce XFEATURE_MASK_KERNEL_DYNAMIC xfeature set
Date: Mon, 10 Mar 2025 11:49:19 +0800 [thread overview]
Message-ID: <Z85hPxSAYAAmv16p@intel.com> (raw)
In-Reply-To: <e15d1074-d5ec-431d-86e5-a58bc6297df8@intel.com>
>When introducing user dynamic features, AMX required a large state, so buffer
>reallocation for expansion was deferred until it was actually used. This
>introduction was associated with introducing a permission mechanism, which
>was expected to be requested by userspace.
>
>For VCPU tasks, the userspace component (QEMU) requests permission [1], and
>buffer expansion then follows based on the exposed CPUID determination [2].
>
>Now, regarding the new kernel dynamic features, I’m unsure whether this
>changelog or anything else sufficiently describes its semantics distintively.
>It appears that both permission grant and buffer allocation for the kernel
>dynamic feature occur at VCPU allocation time. However, this model differs
>from the deferred buffer expansion model for user dynamic features.
>
>If the kernel dynamic feature model were to follow the same deferred
>reallocation approach as user dynamic features, buffer reallocation would be
>expected. In that case, I'd also question whether fpu_guest_cfg is truly
>necessary.
>
>VCPU allocation could still rely on fpu_kernel_cfg, and fpu->guest_perm could
>be extrapolated from fpu->perm or fpu_kernel_cfg. Then, reallocation could
>proceed as usual based on the permission, extending
>fpu_enable_guest_xfd_features(), possibly renaming it to
>fpu_enable_dynamic_features().
>
>That said, this is a relatively small state.
Yes, there's no need to make the guest FPU dynamically sized for the CET
supervisor state, as it is only 24 bytes.
XFEATURE_MASK_KERNEL_DYNAMIC is a misnomer. It is misleading readers into
thinking it involves permission requests and dynamic sizing, similar to
XFEATURE_MASK_USER_DYNAMIC
>Even if the intent was to
>introduce a new semantic model distinct from user dynamic features, it should
>be clearly documented to avoid confusion.
The goal isn't to add a new semantic model for dynamic features.
>
>On the other hand, if the goal is rather to establish a new approach for
>handling a previously nonexistent set of guest-exclusive features, then the
Yes. This is the goal of this patch.
>current approach remains somewhat convoluted without clear descriptions.
>Perhaps, I'm missing something.
Do you mean this patch is "somewhat convoluted"? or the whole series?
I am assuming you meant this series as this patch itself is quite small.
Here is how this series is organized:
Patches 1–4 : Cleanups and preparatory fixes.
Patches 5–7 : Introduce fpu_guest_cfg to formalize guest FPU configuration.
Patch 8 (Primary Goal): Add CET supervisor state support.
Patches 9–10 : make CET supserviosr state a guest-only feature to save XSAVE buffer
space for non-guest FPUs (placed at the end for easier review/drop).
I believe the "somewhat convoluted" impression comes from the introduction of
fpu_guest_cfg. But as I alluded to in patch 5's changelog, fpu_guest_cfg
actually simplifies the architecture rather than adding complexity, with
minimal overhead, i.e., a single global config. It was suggested by Sean [1].
In my view, it offers three benefits:
- Readability: Removes ambiguity in fpu_alloc_guest_fpstate() by initializing
the guest FPU with its own config.
- Extensibility: Supports clean addition of guest-only features (e.g., CET
supervisor state) or potentially kernel-only features (e.g.,
PASID, which is not used by guest FPUs)
- Robustness: Prevent issues like those addressed by patches 3/4.
It is possible to make some features guest-only without fpu_guest_cfg, but
doing so would make fpu_alloc_guest_fpstate() a bit difficult to understand.
See [2].
[1]: https://lore.kernel.org/kvm/ZTf5wPKXuHBQk0AN@google.com/
[2]: https://lore.kernel.org/kvm/20230914063325.85503-8-weijiang.yang@intel.com/
>
>Thanks,
>Chang
>
>[1] https://github.com/qemu/qemu/blob/master/target/i386/kvm/kvm.c#L6395
>[2] https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kvm/cpuid.c#n195
Thanks for these references.
next prev parent reply other threads:[~2025-03-10 3:50 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 16:41 [PATCH v3 00/10] Introduce CET supervisor state support Chao Gao
2025-03-07 16:41 ` [PATCH v3 01/10] x86/fpu/xstate: Always preserve non-user xfeatures/flags in __state_perm Chao Gao
2025-03-07 16:41 ` [PATCH v3 02/10] x86/fpu/xstate: Drop @perm from guest pseudo FPU container Chao Gao
2025-03-07 16:41 ` [PATCH v3 03/10] x86/fpu/xstate: Correct xfeatures cache in guest pseudo fpu container Chao Gao
2025-03-07 17:48 ` Dave Hansen
2025-03-08 2:44 ` Chao Gao
2025-03-07 16:41 ` [PATCH v3 04/10] x86/fpu/xstate: Correct guest fpstate size calculation Chao Gao
2025-03-07 17:53 ` Dave Hansen
2025-03-08 2:56 ` Chao Gao
2025-03-07 21:37 ` Chang S. Bae
2025-03-08 2:49 ` Chao Gao
2025-03-09 22:06 ` Chang S. Bae
2025-03-10 1:33 ` Chao Gao
2025-03-10 5:21 ` Chang S. Bae
2025-03-10 7:06 ` Chao Gao
2025-03-10 17:33 ` Chang S. Bae
2025-03-11 12:09 ` Chao Gao
2025-03-12 1:03 ` Chang S. Bae
2025-03-07 16:41 ` [PATCH v3 05/10] x86/fpu/xstate: Introduce guest FPU configuration Chao Gao
2025-03-07 18:06 ` Dave Hansen
2025-03-08 3:00 ` Chao Gao
2025-03-07 16:41 ` [PATCH v3 06/10] x86/fpu/xstate: Initialize guest perm with fpu_guest_cfg Chao Gao
2025-03-07 18:14 ` Dave Hansen
2025-03-08 3:14 ` Chao Gao
2025-03-07 16:41 ` [PATCH v3 07/10] x86/fpu/xstate: Initialize guest fpstate with fpu_guest_config Chao Gao
2025-03-07 18:41 ` Dave Hansen
2025-03-08 3:38 ` Chao Gao
2025-03-07 16:41 ` [PATCH v3 08/10] x86/fpu/xstate: Add CET supervisor xfeature support Chao Gao
2025-03-07 18:39 ` Dave Hansen
2025-03-08 3:24 ` Chao Gao
2025-03-07 16:41 ` [PATCH v3 09/10] x86/fpu/xstate: Introduce XFEATURE_MASK_KERNEL_DYNAMIC xfeature set Chao Gao
2025-03-09 22:06 ` Chang S. Bae
2025-03-10 3:49 ` Chao Gao [this message]
2025-03-10 5:20 ` Chang S. Bae
2025-03-10 5:53 ` Chao Gao
2025-03-11 12:27 ` Chao Gao
2025-03-12 1:03 ` Chang S. Bae
2025-03-07 16:41 ` [PATCH v3 10/10] x86/fpu/xstate: Warn if CET supervisor state is detected in normal fpstate Chao Gao
2025-03-07 19:09 ` [PATCH v3 00/10] Introduce CET supervisor state support Dave Hansen
2025-03-18 15:24 ` Chao Gao
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=Z85hPxSAYAAmv16p@intel.com \
--to=chao.gao@intel.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=dave.hansen@intel.com \
--cc=john.allen@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=weijiang.yang@intel.com \
--cc=x86@kernel.org \
/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.