[PATCH 1/3] CET: Rename CET_MAX to CET_CONTROL_MASK [BZ #25887]
Florian Weimer
fw@deneb.enyo.de
Sat May 16 17:27:18 GMT 2020
* H. J. Lu via Libc-alpha:
> diff --git a/sysdeps/x86/cet-tunables.h b/sysdeps/x86/cet-tunables.h
> index 5e1e42df10..0088b89d3e 100644
> --- a/sysdeps/x86/cet-tunables.h
> +++ b/sysdeps/x86/cet-tunables.h
> @@ -16,14 +16,32 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> -/* Valid control values:
> +#ifndef _CET_TUNABLES_H
> +#define _CET_TUNABLES_H
> +
> +/* For each CET feature, IBT and SHSTK, valid control values:
> 0: Enable CET features based on ELF property note.
> 1: Always disable CET features.
> 2: Always enable CET features.
> 3: Enable CET features permissively.
> +
> + Bits 0-1: IBT
> + Bits 2-3: SHSTK
> */
> #define CET_ELF_PROPERTY 0
> #define CET_ALWAYS_OFF 1
> #define CET_ALWAYS_ON 2
> #define CET_PERMISSIVE 3
> -#define CET_MAX CET_PERMISSIVE
> +#define CET_CONTROL_MASK 3
> +#define CET_IBT_SHIFT 0
> +#define CET_SHSTK_SHIFT 2
> +
> +/* Get CET control value. */
> +
> +static inline unsigned int
> +get_cet_control_value (unsigned int shift)
> +{
> + return (GL(dl_x86_feature_1)[1] >> shift) & CET_CONTROL_MASK;
> +}
> +
> +#endif /* cet-tunables.h */
Is there a reason why this has to be a single bitmask? Maybe a
bitfield would better document the intent?
More information about the Libc-alpha
mailing list