Re: [patch 22/24] x86/speculation: Create PRCTL interface to restrict indirect branch speculation

From: Ingo Molnar
Date: Thu Nov 22 2018 - 02:10:54 EST



* Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:

> From: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
>
> Add the PR_SPEC_INDIR_BRANCH option for the PR_GET_SPECULATION_CTRL and
> PR_SET_SPECULATION_CTRL prctls to allow fine grained per task control of
> indirect branch speculation via STIBP.
>
> Invocations:
> Check indirect branch speculation status with
> - prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH, 0, 0, 0);
>
> Enable indirect branch speculation with
> - prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH, PR_SPEC_ENABLE, 0, 0);
>
> Disable indirect branch speculation with
> - prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH, PR_SPEC_DISABLE, 0, 0);
>
> Force disable indirect branch speculation with
> - prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIR_BRANCH, PR_SPEC_FORCE_DISABLE, 0, 0);
>
> See Documentation/userspace-api/spec_ctrl.rst.
>
> Signed-off-by: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

Please either de-capitalize the title to 'prctl()', or use PR_SPEC_PRCTL
or PR_SET/GET_SPECULATION_CTRL - there's no such thing as 'PRCTL'
interface - the interface is called prctl() and the speculation control
ABIs have their own names.

This applies to the next patch as well.

> --- a/include/uapi/linux/prctl.h
> +++ b/include/uapi/linux/prctl.h
> @@ -212,6 +212,7 @@ struct prctl_mm_map {
> #define PR_SET_SPECULATION_CTRL 53
> /* Speculation control variants */
> # define PR_SPEC_STORE_BYPASS 0
> +# define PR_SPEC_INDIR_BRANCH 1
> /* Return and control values for PR_SET/GET_SPECULATION_CTRL */
> # define PR_SPEC_NOT_AFFECTED 0
> # define PR_SPEC_PRCTL (1UL << 0)
> --- a/tools/include/uapi/linux/prctl.h
> +++ b/tools/include/uapi/linux/prctl.h
> @@ -212,6 +212,7 @@ struct prctl_mm_map {
> #define PR_SET_SPECULATION_CTRL 53
> /* Speculation control variants */
> # define PR_SPEC_STORE_BYPASS 0
> +# define PR_SPEC_INDIR_BRANCH 1
> /* Return and control values for PR_SET/GET_SPECULATION_CTRL */
> # define PR_SPEC_NOT_AFFECTED 0
> # define PR_SPEC_PRCTL (1UL << 0)

Please de-abbreviate the new ABI: PR_SPEC_INDIRECT_BRANCH?

Thanks,

Ingo