From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) by sourceware.org (Postfix) with ESMTPS id 6CD8D383F85E for ; Sat, 16 May 2020 17:27:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6CD8D383F85E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=deneb.enyo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fw@deneb.enyo.de Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1ja0ak-0007PK-Qb; Sat, 16 May 2020 17:27:18 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1ja0ak-0001rr-Mr; Sat, 16 May 2020 19:27:18 +0200 From: Florian Weimer To: "H.J. Lu via Libc-alpha" Subject: Re: [PATCH 1/3] CET: Rename CET_MAX to CET_CONTROL_MASK [BZ #25887] References: <20200428215243.236312-1-hjl.tools@gmail.com> <20200428215243.236312-2-hjl.tools@gmail.com> Date: Sat, 16 May 2020 19:27:18 +0200 In-Reply-To: <20200428215243.236312-2-hjl.tools@gmail.com> (H. J. Lu via Libc-alpha's message of "Tue, 28 Apr 2020 14:52:41 -0700") Message-ID: <871rnjoknd.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2020 17:27:22 -0000 * 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 > . */ > > -/* 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?