Return-path: Received: from aserp2120.oracle.com ([141.146.126.78]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fEeba-00006Q-96 for speck@linutronix.de; Fri, 04 May 2018 19:34:51 +0200 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w44HPpIY047503 for ; Fri, 4 May 2018 17:34:43 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2hmgxg78u5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 May 2018 17:34:43 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w44HYgEm017518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 4 May 2018 17:34:42 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w44HYfrO006137 for ; Fri, 4 May 2018 17:34:41 GMT Date: Fri, 4 May 2018 13:34:40 -0400 From: Konrad Rzeszutek Wilk Subject: [MODERATED] Re: [patch 0/6] SSB update 0 Message-ID: <20180504173440.GB24767@char.us.oracle.com> References: <20180504132317.028193533@linutronix.de> MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Fri, May 04, 2018 at 03:34:22PM +0200, speck for Thomas Gleixner wrote: > On Fri, 4 May 2018, speck for Thomas Gleixner wrote: > > > > Applies on top of the master branch. Git bundle follows in separate mail. > > Attached. And inline is the man-page update with the new PR_SPEC_FORCE_DISABLE. From 4d7a129d5a64fdb86950ede67dae6c24c53740cd Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Mon, 30 Apr 2018 13:25:20 -0400 Subject: [PATCH v12.1] prctl.2: PR_[SET|GET]_SPECULATION_CTRL field. Signed-off-by: Konrad Rzeszutek Wilk --- v8: New patch v9: s/EUCLEAN/EINVAL/ Also add section in PR_SET_SPECULATION_CTRL about arg[4,5] being zero. v12.1: s/bits 0-2/bits 0-3/ Add PR_SPEC_FORCE_DISABLE and its EPERM return value. --- man2/prctl.2 | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/man2/prctl.2 b/man2/prctl.2 index 54764d881..87135a0b3 100644 --- a/man2/prctl.2 +++ b/man2/prctl.2 @@ -1008,6 +1008,102 @@ the "securebits" flags of the calling thread. See .BR capabilities (7). .TP +.BR PR_GET_SPECULATION_CTRL +Returns the state of the speculation misfeature which is selected with +the value of +.IR arg2 , +which must be +.B PR_SPEC_STORE_BYPASS. +Otherwise the call fails with the error +.BR ENODEV . +The return value uses bit 0-3 with the following meaning: +.RS +.TP +.BR PR_SPEC_PRCTL +Mitigation can be controlled per task by +.B PR_SET_SPECULATION_CTRL +.TP +.BR PR_SPEC_ENABLE +The speculation feature is enabled, mitigation is disabled. +.TP +.BR PR_SPEC_DISABLE +The speculation feature is disabled, mitigation is enabled +.TP +.BR PR_SPEC_FORCE_DISABLE +Same as +.B PR_SPEC_DISABLE +but cannot be undone. +.RE +.IP +If all bits are +.B 0 +then the CPU is not affected by the speculation misfeature. +.IP +If +.B PR_SPEC_PRCTL +is set, then the per task control of the mitigation is available. If not set, +.B prctl() +for the speculation misfeature will fail. +In the above operation +.I arg3 +, +.I arg4, +and +.I arg5 +must be specified as 0, otherwise the call fails with the error +.BR EINVAL. +.TP +.BR PR_SET_SPECULATION_CTRL +Sets the state of the speculation misfeature which is selected with +the value of +.IR arg2 , +which must be +.B PR_SPEC_STORE_BYPASS. +Otherwise the call fails with the error +.BR ENODEV . +This control is per task. The +.IR arg3 +is used to hand in the control value, which can be either: +.RS +.TP +.BR PR_SPEC_ENABLE +The speculation feature is enabled, mitigation is disabled. +.TP +.BR PR_SPEC_DISABLE +The speculation feature is disabled, mitigation is enabled +.TP +.BR PR_SPEC_FORCE_DISABLE +Same as +.B PR_SPEC_DISABLE +but cannot be undone. A subsequent +.B +prctl(..., PR_SPEC_ENABLE) +will fail with +.BR EPERM. +.RE +.IP +Any other value in +.IR arg3 +will result in the call failure with the error +.BR ERANGE . +Also +.I arg4, +and +.I arg5 +must be specified as 0, otherwise the call fails with ethe rror +.BR EINVAL. +.IP +Furtheremore this speculation feature can also be controlled by the boot-time +parameter of +.B +spec_store_bypass_disable= +Which could enforce a read-only policy which will result in the call failure +with the error +.BR ENXIO . +Consult the +.B PR_GET_SPECULATION_CTRL +for details on the possible enumerations. +.TP .BR PR_SET_THP_DISABLE " (since Linux 3.15)" .\" commit a0715cc22601e8830ace98366c0c2bd8da52af52 Set the state of the "THP disable" flag for the calling thread. @@ -1501,6 +1597,12 @@ and .IR arg3 does not specify a valid capability. .TP +.B ENODEV +.I option +was +.BR PR_SET_SPECULATION_CTRL +the kernel or CPU does not support the requested speculation misfeature. +.TP .B ENXIO .I option was @@ -1510,6 +1612,15 @@ or and the kernel or the CPU does not support MPX management. Check that the kernel and processor have MPX support. .TP +.B ENXIO +.I option +was +.BR PR_SET_SPECULATION_CTRL +implies that the control of the selected speculation misfeature is not possible. +See +.BR PR_GET_SPECULATION_CTRL +for the bit fields to determine which option is available. +.TP .B EOPNOTSUPP .I option is @@ -1533,6 +1644,14 @@ or tried to set a flag whose corresponding locked flag was set .B EPERM .I option is +.BR PR_SET_SPECULATION_CTRL +wherein the speculation was disabled with +.B PR_SPEC_FORCE_DISABLE +and caller tried to enable it again. +.TP +.B EPERM +.I option +is .BR PR_SET_KEEPCAPS , and the caller's .B SECBIT_KEEP_CAPS_LOCKED @@ -1570,6 +1689,30 @@ is not present in the process's permitted and inheritable capability sets, or the .B PR_CAP_AMBIENT_LOWER securebit has been set. +.TP +.B ERANGE +.I option +was +.BR PR_SET_SPECULATION_CTRL +and +.IR arg3 +is incorrect - neither +.B PR_SPEC_ENABLE +nor +.B PR_SPEC_DISABLE +nor +.B PR_SPEC_FORCE_DISABLE +was choosen +.TP +.B EINVAL +.I option +was +.BR PR_GET_SPECULATION_CTRL +or +.BR PR_SET_SPECULATION_CTRL +and unused arguments to +.B prctl() +are not 0. .SH VERSIONS The .BR prctl () -- 2.14.3