mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ashok Raj <ashok.raj@intel.com>
To: "Chang S. Bae" <chang.seok.bae@intel.com>
Cc: <linux-kernel@vger.kernel.org>, <x86@kernel.org>,
	<platform-driver-x86@vger.kernel.org>, <tglx@linutronix.de>,
	<mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,
	<hdegoede@redhat.com>, <ilpo.jarvinen@linux.intel.com>,
	<tony.luck@intel.com>, <jithu.joseph@intel.com>,
	Ashok Raj <ashok.raj@intel.com>
Subject: Re: [PATCH 1/2] x86/fpu: Extend kernel_fpu_begin_mask() to initialize AMX state
Date: Tue, 30 Apr 2024 16:42:25 -0700	[thread overview]
Message-ID: <ZjGB4WPJWj58TF4r@a4bf019067fa.jf.intel.com> (raw)
In-Reply-To: <20240430212508.105117-2-chang.seok.bae@intel.com>

On Tue, Apr 30, 2024 at 02:25:07PM -0700, Bae, Chang Seok wrote:
> The In-Field Scan [1] test does not start its operation when the CPU is
> unprepared. If the AMX state is uninitialized, the scan test will
> immediately terminate. Therefore, a proper initialization of the AMX
> state is necessary to run the test.

Instead of using new terminology like "unprepared", maybe use the
term "non-initialized state" as in the SDM for clarity? 

	Maintaining AMX state in a non-initialized state will prevent In-field
	Scan test [1] to abort without making progress.

> 
> Although fpu_idle_fpregs() initializes the state, its usage should be
> limited to specialized cases, primarily before entering the sleep state.
> The restore_fpregs_from_fpstate() function offers a suitable mechanism
> for initializing fpstate in general, which remains within the core code.
> 
> Extend kernel_fpu_begin_mask() to include AMX state initialization,
> providing the in-field scan driver code access to the appropriate
> initialization method while maintaining compliance with established FPU
> API semantics.

Maybe simplify the above paragraph with

Extend kernel_fpu_begin_mask() to allow In-field scan driver to initialize
AMX state before running tests.

> 
> [1] https://docs.kernel.org/arch/x86/ifs.html
> Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
> ---
> The necessity for AMX initialization is clarified in the Intel Software
> Development Manual as of March 2024, particularly in Section 18.2
> RECOMMENDATIONS FOR SYSTEM SOFTWARE of Vol. 1.
> 
> Side note: restore_fpregs_from_fpstate() also sets the x87 state to a
> fixed value. However, this only applies to AMD CPUs with the FXSAVE_LEAK
> quirk.
> ---
>  arch/x86/include/asm/fpu/api.h | 1 +
>  arch/x86/kernel/fpu/core.c     | 3 +++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
> index a2be3aefff9f..67887fc45c24 100644
> --- a/arch/x86/include/asm/fpu/api.h
> +++ b/arch/x86/include/asm/fpu/api.h
> @@ -25,6 +25,7 @@
>  /* Kernel FPU states to initialize in kernel_fpu_begin_mask() */
>  #define KFPU_387	_BITUL(0)	/* 387 state will be initialized */
>  #define KFPU_MXCSR	_BITUL(1)	/* MXCSR will be initialized */
> +#define KFPU_AMX	_BITUL(2)	/* AMX will be initialized */
>  
>  extern void kernel_fpu_begin_mask(unsigned int kfpu_mask);
>  extern void kernel_fpu_end(void);
> diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
> index 520deb411a70..0c0235b4a901 100644
> --- a/arch/x86/kernel/fpu/core.c
> +++ b/arch/x86/kernel/fpu/core.c
> @@ -440,6 +440,9 @@ void kernel_fpu_begin_mask(unsigned int kfpu_mask)
>  
>  	if (unlikely(kfpu_mask & KFPU_387) && boot_cpu_has(X86_FEATURE_FPU))
>  		asm volatile ("fninit");
> +
> +	if (unlikely(kfpu_mask & KFPU_AMX) && boot_cpu_has(X86_FEATURE_AMX_TILE))
> +		restore_fpregs_from_fpstate(&init_fpstate, XFEATURE_MASK_XTILE);
>  }
>  EXPORT_SYMBOL_GPL(kernel_fpu_begin_mask);
>  
> -- 
> 2.34.1
> 

-- 
Cheers,
Ashok

  reply	other threads:[~2024-04-30 23:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 21:25 [PATCH 0/2] x86/fpu: Extend kernel_fpu_begin_mask() for the In-Field Scan driver Chang S. Bae
2024-04-30 21:25 ` [PATCH 1/2] x86/fpu: Extend kernel_fpu_begin_mask() to initialize AMX state Chang S. Bae
2024-04-30 23:42   ` Ashok Raj [this message]
2024-04-30 21:25 ` [PATCH 2/2] platform/x86/intel/ifs: Initialize AMX state for the scan test Chang S. Bae
2024-05-01  0:06   ` Ashok Raj
2024-05-01  8:58   ` Hans de Goede
2024-05-08  0:22     ` Chang S. Bae
2024-05-02 11:00   ` Ilpo Järvinen
2024-05-02 22:19     ` Chang S. Bae
2024-05-09  0:45   ` Kuppuswamy Sathyanarayanan
2024-05-02 20:52 ` [PATCH 0/2] x86/fpu: Extend kernel_fpu_begin_mask() for the In-Field Scan driver Chang S. Bae
2024-05-02 21:35   ` Chang S. Bae
2024-05-02 20:59 ` Dave Hansen
2024-05-07 23:53 ` [PATCH v2 " Chang S. Bae
2024-05-07 23:53   ` [PATCH v2 1/2] x86/fpu: Extend kernel_fpu_begin_mask() to initialize AMX state Chang S. Bae
2024-05-08 13:00     ` Thomas Gleixner
2024-05-08 14:40     ` Dave Hansen
2024-05-08 18:03       ` Chang S. Bae
2024-05-08 19:11         ` Dave Hansen
2024-05-09  0:29       ` Chang S. Bae
2024-05-09 17:36         ` Dave Hansen
2024-05-09 17:41           ` Dave Hansen
2024-05-09 18:41           ` Chang S. Bae
2024-05-09 18:50             ` Dave Hansen
2024-05-10  7:51           ` Thomas Gleixner
2024-05-07 23:53   ` [PATCH v2 2/2] platform/x86/intel/ifs: Initialize AMX state for the scan test Chang S. Bae
2024-05-08  0:19     ` Ashok Raj
2024-05-08  0:21       ` Chang S. Bae
2024-05-08  8:28   ` [PATCH v2 0/2] x86/fpu: Extend kernel_fpu_begin_mask() for the In-Field Scan driver Ilpo Järvinen

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=ZjGB4WPJWj58TF4r@a4bf019067fa.jf.intel.com \
    --to=ashok.raj@intel.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jithu.joseph@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@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

all inboxes | Powered by JetHome®