From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from aserp2130.oracle.com ([141.146.126.79]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fDCbh-0001Zt-LJ for speck@linutronix.de; Mon, 30 Apr 2018 19:28:58 +0200 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3UHQ0ZM135328 for ; Mon, 30 Apr 2018 17:28:50 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2hmeg5n69d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 30 Apr 2018 17:28:50 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w3UHSocG003818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 30 Apr 2018 17:28:50 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3UHSo2N021040 for ; Mon, 30 Apr 2018 17:28:50 GMT Date: Mon, 30 Apr 2018 13:28:49 -0400 From: Konrad Rzeszutek Wilk Subject: [MODERATED] Re: [patch V7 13/15] SBB 13 Message-ID: <20180430172849.GA10804@char.us.oracle.com> References: <20180429193045.711908246@linutronix.de> <20180429193938.557096663@linutronix.de> MIME-Version: 1.0 In-Reply-To: <20180429193938.557096663@linutronix.de> Content-Type: multipart/mixed; boundary="wRRV7LY7NUeQGEoC" Content-Disposition: inline To: speck@linutronix.de List-ID: --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > TODO: Tidy up spec_ctrl.rst and write a man prctl(2) patch. > It looks good (the .rst) document. Attached is a patch to the manpages. Both inline and attached. >From 5f3440b1025beb526b7a0c60e4e98d7b595b30b1 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Mon, 30 Apr 2018 13:25:20 -0400 Subject: [PATCH] SSB MANPAGE #1 prctl.2: PR_[SET|GET]_SPECULATION_CTRL field. Signed-off-by: Konrad Rzeszutek Wilk --- v8: New patch --- man2/prctl.2 | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/man2/prctl.2 b/man2/prctl.2 index 54764d881..77ceeb03f 100644 --- a/man2/prctl.2 +++ b/man2/prctl.2 @@ -1008,6 +1008,82 @@ 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-2 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 +.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 EUCLEAN. +.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 +.RE +.IP +Any other value in +.IR arg3 +will result in the call failure with the error +.BR ERANGE . +.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 +1577,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 +1592,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 @@ -1570,6 +1661,28 @@ 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 +. +.TP +.B EUCLEAN +.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.13.4 --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-SSB-MANPAGE-1.patch" >From 5f3440b1025beb526b7a0c60e4e98d7b595b30b1 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Mon, 30 Apr 2018 13:25:20 -0400 Subject: [PATCH] SSB MANPAGE #1 prctl.2: PR_[SET|GET]_SPECULATION_CTRL field. Signed-off-by: Konrad Rzeszutek Wilk --- v8: New patch --- man2/prctl.2 | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/man2/prctl.2 b/man2/prctl.2 index 54764d881..77ceeb03f 100644 --- a/man2/prctl.2 +++ b/man2/prctl.2 @@ -1008,6 +1008,82 @@ 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-2 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 +.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 EUCLEAN. +.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 +.RE +.IP +Any other value in +.IR arg3 +will result in the call failure with the error +.BR ERANGE . +.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 +1577,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 +1592,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 @@ -1570,6 +1661,28 @@ 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 +. +.TP +.B EUCLEAN +.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.13.4 --wRRV7LY7NUeQGEoC--