linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Brendan Jackman <jackmanb@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	Balbir Singh <sblbir@amazon.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] Documentation: clarify PR_SPEC_L1D_FLUSH
Date: Wed, 15 Oct 2025 14:41:18 -0700	[thread overview]
Message-ID: <202510151438.DA62BB421@keescook> (raw)
In-Reply-To: <20251015-l1d-flush-doc-v1-1-f8cefea3f2f2@google.com>

On Wed, Oct 15, 2025 at 05:02:05PM +0000, Brendan Jackman wrote:
> For PR_SPEC_STORE_BYPASS and PR_SPEC_INDIRECT_BRANCH, PR_SPEC_DISABLE
> means "disable the speculation bug" i.e. "enable the mitigation".
> 
> For PR_SPEC_L1D_FLUSH, PR_SPEC_DISABLE means "disable the mitigation".
> This is not obvious, so document it.

The only thing I can find in Debian Code Search that actually uses
PR_SPEC_L1D_FLUSH is stress-ng, and it literally just toggles it before
restoring it:
https://sources.debian.org/src/stress-ng/0.19.05-1/stress-prctl.c?hl=893#L893

I wonder if we should just fix the prctl to match the existing
behaviors?

-Kees

> 
> Signed-off-by: Brendan Jackman <jackmanb@google.com>
> ---
>  Documentation/userspace-api/spec_ctrl.rst | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/userspace-api/spec_ctrl.rst b/Documentation/userspace-api/spec_ctrl.rst
> index 5e8ed9eef9aa84f12fa255af7b15c163ff01aab8..ca89151fc0a8e7205e0a0062134d63b213b9ef11 100644
> --- a/Documentation/userspace-api/spec_ctrl.rst
> +++ b/Documentation/userspace-api/spec_ctrl.rst
> @@ -26,7 +26,8 @@ PR_GET_SPECULATION_CTRL
>  
>  PR_GET_SPECULATION_CTRL returns the state of the speculation misfeature
>  which is selected with arg2 of prctl(2). The return value uses bits 0-3 with
> -the following meaning:
> +the following meaning (with the caveat that PR_SPEC_L1D_FLUSH has less obvious
> +semantics, see documentation for that specific control below):
>  
>  ==== ====================== ==================================================
>  Bit  Define                 Description
> @@ -110,6 +111,9 @@ Speculation misfeature controls
>  - PR_SPEC_L1D_FLUSH: Flush L1D Cache on context switch out of the task
>                          (works only when tasks run on non SMT cores)
>  
> +For this control, PR_SPEC_ENABLE means that the **mitigation** is enabled (L1D
> +is flushed), PR_SPEC_DISABLE means it is disabled.
> +
>    Invocations:
>     * prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_L1D_FLUSH, 0, 0, 0);
>     * prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_L1D_FLUSH, PR_SPEC_ENABLE, 0, 0);
> 
> -- 
> 2.50.1
> 

-- 
Kees Cook

  reply	other threads:[~2025-10-15 21:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 17:02 [PATCH 0/2] Documentation: fixups for L1D flushing Brendan Jackman
2025-10-15 17:02 ` [PATCH 1/2] Documentation: clarify PR_SPEC_L1D_FLUSH Brendan Jackman
2025-10-15 21:41   ` Kees Cook [this message]
2025-10-15 23:42     ` Josh Poimboeuf
2025-10-16  8:28       ` Brendan Jackman
2025-10-15 17:02 ` [PATCH 2/2] Documentation: fix reference to PR_SPEC_L1D_FLUSH Brendan Jackman
2025-10-16 14:54 ` [PATCH 0/2] Documentation: fixups for L1D flushing Brendan Jackman
2025-10-30 14:00   ` Brendan Jackman
2025-10-29 16:15 ` Jonathan Corbet

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=202510151438.DA62BB421@keescook \
    --to=kees@kernel.org \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=jackmanb@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=sblbir@amazon.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).