From: Chao Gao <chao.gao@intel.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: "Hansen, Dave" <dave.hansen@intel.com>,
"seanjc@google.com" <seanjc@google.com>,
"x86@kernel.org" <x86@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"ebiggers@google.com" <ebiggers@google.com>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"Spassov, Stanislav" <stanspas@amazon.de>,
"levymitchell0@gmail.com" <levymitchell0@gmail.com>,
"samuel.holland@sifive.com" <samuel.holland@sifive.com>,
"Li, Xin3" <xin3.li@intel.com>,
"Yang, Weijiang" <weijiang.yang@intel.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"mlevitsk@redhat.com" <mlevitsk@redhat.com>,
"john.allen@amd.com" <john.allen@amd.com>,
"Bae, Chang Seok" <chang.seok.bae@intel.com>,
"vigbalas@amd.com" <vigbalas@amd.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"aruna.ramakrishna@oracle.com" <aruna.ramakrishna@oracle.com>,
"bp@alien8.de" <bp@alien8.de>
Subject: Re: [PATCH v5 3/7] x86/fpu/xstate: Differentiate default features for host and guest FPUs
Date: Fri, 25 Apr 2025 16:24:55 +0800 [thread overview]
Message-ID: <aAtG13wd35yMNahd@intel.com> (raw)
In-Reply-To: <f53bea9b13bd8351dc9bba5e443d5e4f4934555d.camel@intel.com>
On Fri, Apr 25, 2025 at 06:52:59AM +0800, Edgecombe, Rick P wrote:
>On Thu, 2025-04-10 at 15:24 +0800, Chao Gao wrote:
>> +
>> + /*
>> + * @user_size:
>> + *
>> + * The default UABI size of the register state buffer in guest
>> + * FPUs. Includes all supported user features except independent
>> + * managed features and features which have to be requested by
>> + * user space before usage.
>> + */
>> + unsigned int user_size;
>> +
>> + /*
>> + * @features:
>> + *
>> + * The default supported features bitmap in guest FPUs. Does not
>> + * include independent managed features and features which have to
>> + * be requested by user space before usage.
>> + */
>> + u64 features;
>> +
>> + /*
>> + * @user_features:
>> + *
>> + * Same as @features except only user xfeatures are included.
>> + */
>> + u64 user_features;
>> +};
>
>Tracing through the code, it seems that fpu_user_cfg.default_features and
>guest_default_cfg.user_features are the same, leading to
>fpu_user_cfg.default_size and guest_default_cfg.user_size being also the same.
Right. This is primarily for readability and symmetry.
I slightly prefer __guest_fpstate_reset() in this series:
fpstate->size = guest_default_cfg.size;
fpstate->user_size = guest_default_cfg.user_size;
fpstate->xfeatures = guest_default_cfg.features;
fpstate->user_xfeatures = guest_default_cfg.user_features;
over this version:
fpstate->size = guest_default_cfg.size;
fpstate->xfeatures = guest_default_cfg.features;
/*
* use fpu_user_cfg for user_* settings for compatibility of exiting
* uAPIs.
*/
fpstate->user_size = fpu_user_cfg.user_size;
fpstate->user_xfeatures = fpu_user_cfg.default_features;
Referencing different structures for size/xfeatures and their user_*
counterparts is not elegant to me. The need for a comment indicates that
this chunk may cause confusion. And this pattern will repeat when
initializing fpu->guest_perm in fpstate_reset().
>
>In the later patches, it doesn't seem to change the "user" parts. These
>configurations end up controlling the default size and features that gets copied
>to userspace in KVM_SET_XSAVE. I guess today there is only one default size and
>feature set for xstate copied to userspace. The suggestion from Chang was that
>it makes the code more readable, but it seems like it also breaks apart a
>unified concept for no functional benefit.
In the future, the feature and size of the uABI buffer for guest FPUs may
differ from those of non-guest FPUs. Sean rejected the idea of saving/restoring
CET_S xstate in KVM partly because:
:Especially because another big negative is that not utilizing XSTATE bleeds into
:KVM's ABI. Userspace has to be told to manually save+restore MSRs instead of just
:letting KVM_{G,S}ET_XSAVE handle the state. And that will create a bit of a
:snafu if Linux does gain support for SSS.
*: https://lore.kernel.org/kvm/ZM1jV3UPL0AMpVDI@google.com/
[To be clear, it is not an issue caused by Chang's suggestion. v4 which adds
new members @guest_size @guest_default_features to fpu_state_config has the
same problem. i.e., fpu_user_cfg.guest_default_feaures is identical to
fpu_user_cfg.default_features, adding no functional benefit.]
>
>Maybe we don't need user_features or user_size here in vcpu_fpu_config? Or did I
I don't have a strong opinion on this. I am ok with dropping them. Do you have
a strong preference?
>get lost somewhere along the way in all the twists and turns that features and
>sizes go through.
No, your analysis is correct.
>
>
next prev parent reply other threads:[~2025-04-25 8:25 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 7:24 [PATCH v5 0/7] Introduce CET supervisor state support Chao Gao
2025-04-10 7:24 ` [PATCH v5 1/7] x86/fpu/xstate: Always preserve non-user xfeatures/flags in __state_perm Chao Gao
2025-04-18 20:50 ` Chang S. Bae
2025-04-10 7:24 ` [PATCH v5 2/7] x86/fpu: Drop @perm from guest pseudo FPU container Chao Gao
2025-04-18 20:51 ` Chang S. Bae
2025-04-18 20:54 ` Chang S. Bae
2025-04-19 1:01 ` Chao Gao
2025-04-10 7:24 ` [PATCH v5 3/7] x86/fpu/xstate: Differentiate default features for host and guest FPUs Chao Gao
2025-04-24 22:52 ` Edgecombe, Rick P
2025-04-25 8:24 ` Chao Gao [this message]
2025-04-25 16:09 ` Edgecombe, Rick P
2025-04-25 23:48 ` Sean Christopherson
2025-04-28 3:26 ` Chao Gao
2025-04-28 7:44 ` Xin Li
2025-04-28 14:28 ` Sean Christopherson
2025-04-28 6:31 ` Xin Li
2025-04-28 15:42 ` Edgecombe, Rick P
2025-04-29 1:11 ` Chang S. Bae
2025-04-29 2:50 ` Edgecombe, Rick P
2025-04-29 3:22 ` Chang S. Bae
2025-04-29 3:36 ` Edgecombe, Rick P
2025-04-30 3:27 ` Chao Gao
2025-04-30 15:01 ` Chang S. Bae
2025-04-30 15:33 ` Edgecombe, Rick P
2025-04-30 16:20 ` Sean Christopherson
2025-04-30 18:26 ` Chang S. Bae
2025-04-28 5:51 ` Xin Li
2025-04-28 6:12 ` Xin Li
2025-05-01 14:24 ` Chang S. Bae
2025-05-06 3:29 ` Chao Gao
2025-04-10 7:24 ` [PATCH v5 4/7] x86/fpu: Initialize guest FPU permissions from guest defaults Chao Gao
2025-04-30 15:45 ` Edgecombe, Rick P
2025-04-10 7:24 ` [PATCH v5 5/7] x86/fpu: Initialize guest fpstate and FPU pseudo container " Chao Gao
2025-04-30 18:29 ` Edgecombe, Rick P
2025-05-01 14:24 ` Chang S. Bae
2025-05-06 3:33 ` Chao Gao
2025-04-10 7:24 ` [PATCH v5 6/7] x86/fpu/xstate: Introduce "guest-only" supervisor xfeature set Chao Gao
2025-04-24 22:58 ` Edgecombe, Rick P
2025-04-10 7:24 ` [PATCH v5 7/7] x86/fpu/xstate: Add CET supervisor xfeature support as a guest-only feature Chao Gao
2025-04-24 23:28 ` [PATCH v5 0/7] Introduce CET supervisor state support Edgecombe, Rick P
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=aAtG13wd35yMNahd@intel.com \
--to=chao.gao@intel.com \
--cc=aruna.ramakrishna@oracle.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=ebiggers@google.com \
--cc=hpa@zytor.com \
--cc=john.allen@amd.com \
--cc=kvm@vger.kernel.org \
--cc=levymitchell0@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=samuel.holland@sifive.com \
--cc=seanjc@google.com \
--cc=stanspas@amazon.de \
--cc=tglx@linutronix.de \
--cc=vigbalas@amd.com \
--cc=weijiang.yang@intel.com \
--cc=x86@kernel.org \
--cc=xin3.li@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