public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: <tglx@linutronix.de>, <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 06/10] x86/fpu/xstate: Initialize guest perm with fpu_guest_cfg
Date: Sat, 8 Mar 2025 11:14:25 +0800	[thread overview]
Message-ID: <Z8u2EWAkqQ+6O5i3@intel.com> (raw)
In-Reply-To: <63044dfe-7f44-4a3d-9a27-82c036232241@intel.com>

On Fri, Mar 07, 2025 at 10:14:19AM -0800, Dave Hansen wrote:
>On 3/7/25 08:41, Chao Gao wrote:
>> From: Yang Weijiang <weijiang.yang@intel.com>
>> 
>> Use the new fpu_guest_cfg to initialize guest permissions.
>
>Background, please.
>
>What are the guest permissions currently set to? Why does it need to change?

Ok. Will add:

Currently, fpu->guest_perm is copied from fpu->perm, which is derived from
fpu_kernel_cfg. To separate the guest FPU from the kernel FPU, switch to use
the new fpu_guest_cfg to initialize guest permissions. This ensures that any
future changes to fpu_guest_cfg will automatically update the guest permissions

The __user_state_size is tied to existing uAPIs, so it remains unchanged.

>
>> Note fpu_guest_cfg and fpu_kernel_cfg remain the same for now. So there
>> is no functional change.
>> 
>> Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
>> [Gao Chao: Extrace this from the previous patch ]
>> Signed-off-by: Chao Gao <chao.gao@intel.com>
>> ---
>>  arch/x86/kernel/fpu/core.c | 11 +++++++++--
>>  1 file changed, 9 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
>> index b0c1ef40d105..d7ae684adbad 100644
>> --- a/arch/x86/kernel/fpu/core.c
>> +++ b/arch/x86/kernel/fpu/core.c
>> @@ -534,8 +534,15 @@ void fpstate_reset(struct fpu *fpu)
>>  	fpu->perm.__state_perm		= fpu_kernel_cfg.default_features;
>>  	fpu->perm.__state_size		= fpu_kernel_cfg.default_size;
>>  	fpu->perm.__user_state_size	= fpu_user_cfg.default_size;
>> -	/* Same defaults for guests */
>> -	fpu->guest_perm = fpu->perm;
>> +
>> +	/* Guest permission settings */
>> +	fpu->guest_perm.__state_perm	= fpu_guest_cfg.default_features;
>> +	fpu->guest_perm.__state_size	= fpu_guest_cfg.default_size;
>> +	/*
>> +	 * Set guest's __user_state_size to fpu_user_cfg.default_size so that
>> +	 * existing uAPIs can still work.
>> +	 */
>
>I suspect that readers here will understand that this line:
>
>> +	fpu->guest_perm.__user_state_size = fpu_user_cfg.default_size;
>>  }
>
>means "Set guest's __user_state_size to fpu_user_cfg.default_size". The
>comment basically just literally restates what the code does. That part
>of the comment doesn't add value.

Will drop this useless comment.

  reply	other threads:[~2025-03-08  3:14 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 [this message]
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
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=Z8u2EWAkqQ+6O5i3@intel.com \
    --to=chao.gao@intel.com \
    --cc=bp@alien8.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox