[PATCH v3 0/2] arm64: spectre: Fix hard lockup and cleanup mitigation messages

shechenglong posted 2 patches 3 months, 1 week ago
arch/arm64/include/asm/spectre.h |  1 +
arch/arm64/kernel/cpufeature.c   |  6 ++++++
arch/arm64/kernel/proton-pack.c  | 37 +++++++++++++++++---------------
3 files changed, 27 insertions(+), 17 deletions(-)
[PATCH v3 0/2] arm64: spectre: Fix hard lockup and cleanup mitigation messages
Posted by shechenglong 3 months, 1 week ago
On Wed, Oct 29, 2025 at 11:45:54AM +0800, Will Deacon wrote:
> Is the compiler smart enough to store a single string for the
> "mitigation disabled by command-line option\n" part? If not,
> you might want to use %s to avoid wasting memory. (I was going to
> check with llvm but I'm unable to apply your changes due to whitespace
> corruption).

Thanks, Will, for the helpful review. v3 incorporates your suggestion by
factoring the common suffix into a single const string and switching the
pr_info() calls to use "%s". The whitespace corruption has also been fixed
(restore tabs, no line-wrapped literals), so this version should apply
cleanly.


This series addresses one main issues around Spectre mitigation messages:

  1) Avoid multiple copies of the common suffix
     "mitigation disabled by command-line option\n" by using a single
     constant string and "%s" in pr_info().

v3 changes:
  - Fix whitespace corruption (tabs vs spaces).
  - Factor out the common suffix into a single static const and
    use "%s" as suggested.

shechenglong (2):
  cpu:Remove the print when the CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
    Kconfig option is disabled.
  cpu: fix hard lockup triggered by printk calls within scheduling
    context

 arch/arm64/include/asm/spectre.h |  1 +
 arch/arm64/kernel/cpufeature.c   |  6 ++++++
 arch/arm64/kernel/proton-pack.c  | 37 +++++++++++++++++---------------
 3 files changed, 27 insertions(+), 17 deletions(-)

-- 
2.33.0
Re: [PATCH v3 0/2] arm64: spectre: Fix hard lockup and cleanup mitigation messages
Posted by Will Deacon 3 months ago
On Fri, 31 Oct 2025 17:15:04 +0800, shechenglong wrote:
> On Wed, Oct 29, 2025 at 11:45:54AM +0800, Will Deacon wrote:
> > Is the compiler smart enough to store a single string for the
> > "mitigation disabled by command-line option\n" part? If not,
> > you might want to use %s to avoid wasting memory. (I was going to
> > check with llvm but I'm unable to apply your changes due to whitespace
> > corruption).
> 
> [...]

Applied to arm64 (for-next/fixes), thanks!

[1/2] arm64: proton-pack: Drop print when !CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
      https://git.kernel.org/arm64/c/62e72463ca71
[2/2] arm64: proton-pack: Fix hard lockup due to print in scheduler context
      https://git.kernel.org/arm64/c/7f1635737823

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev