Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1069525imu; Tue, 11 Dec 2018 12:10:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/WgsCLeeL/6GcduKsNVWvgP9tShj2oasnH4OmQdqCjeUAVuOUyclTHKpzK8Bn1ad15WXJzG X-Received: by 2002:a62:3603:: with SMTP id d3mr18306657pfa.146.1544559028097; Tue, 11 Dec 2018 12:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544559028; cv=none; d=google.com; s=arc-20160816; b=yszcs7QJ2Kmjw/WSCIW7zaStclsG/8R1/wXRsuzZAOAC8tUVejS0ujGu8FojAfYubO EEXuWV2J1EvGLu74jppiVQf5W6CTyfPMfJyOfV+zW0KysO5Pe4Bk/ZRhJ5gA/JSWZOsu kZiXIyTPWykPCjCGpjiJ0jXjvPSRliEqTxchHpJFEu/CD3Kk5unM9gJCv1QXf/NAHi2D 4zCbmZLx+rcBk0YSFn343jE9JXz56/UeTmMINUz8HOrmZIOFTnocqXBLEpVNR3/ZyOXA wCN74A5yNQi2zlPwQ6dE7VzG7Ycx8FvWuMmHGFstky+SEVOEy9xstIKyKnYFbZPuafYK hNEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hba9UUYQn6vBHpNO9bMwZxwT3FJKma32e3WfL7aHguY=; b=M1BSQrwEmXOL4Tylaa+Yte+Z721r8pN3ON/mD5bXuT6+ly7cxvGh2xjmxwadquV0QF hwcqYgjnvwHVB/EedU+JW0Acd9+O09CK5wfxwpCiAWEqhqctfyiatnd36p3uHs1EE3SP vhX7Mim4YEPjvqfk8LoHMQ9PdKA5sTecA/oXuQpAMdpFwNztolSayVypCim9eqJmmXMr NbWlHqCvdeBG/XjsPp2pnug0et1xffbUFt85mFeVvkK3GHRPy5YvYFGV8Mb8Lf+3dM3g 7y4uerEeHOircdWowpbWDeSnzde1b8X8Elfs9aE/qlAYfpBCJBUy8nG3XNb9FNpcfnTG VGRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si13607167plb.253.2018.12.11.12.10.12; Tue, 11 Dec 2018 12:10:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726233AbeLKUIL (ORCPT + 99 others); Tue, 11 Dec 2018 15:08:11 -0500 Received: from foss.arm.com ([217.140.101.70]:56620 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbeLKUIL (ORCPT ); Tue, 11 Dec 2018 15:08:11 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0944280D; Tue, 11 Dec 2018 12:08:11 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C99803F6A8; Tue, 11 Dec 2018 12:08:10 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id E4F2C1AE0B70; Tue, 11 Dec 2018 20:08:33 +0000 (GMT) Date: Tue, 11 Dec 2018 20:08:33 +0000 From: Will Deacon To: Kristina Martsenko Cc: Richard Henderson , linux-arm-kernel@lists.infradead.org, Adam Wallis , Amit Kachhap , Andrew Jones , Ard Biesheuvel , Catalin Marinas , Christoffer Dall , Cyrill Gorcunov , Dave P Martin , Jacob Bramley , Kees Cook , Marc Zyngier , Mark Rutland , Ramana Radhakrishnan , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 02/13] arm64: add pointer authentication register bits Message-ID: <20181211200754.GA5218@edgewater-inn.cambridge.arm.com> References: <20181207183931.4285-1-kristina.martsenko@arm.com> <20181207183931.4285-3-kristina.martsenko@arm.com> <1e72484b-f89f-eacd-1976-14fdf6f23e26@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1e72484b-f89f-eacd-1976-14fdf6f23e26@arm.com> User-Agent: Mutt/1.11.1+30 (d10eec459b35) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 10, 2018 at 07:54:25PM +0000, Kristina Martsenko wrote: > On 09/12/2018 14:24, Richard Henderson wrote: > > On 12/7/18 12:39 PM, Kristina Martsenko wrote: > >> #define SCTLR_ELx_DSSBS (1UL << 44) > >> +#define SCTLR_ELx_ENIA (1 << 31) > > > > 1U or 1UL lest you produce signed -0x80000000. > > Thanks, this was setting all SCTLR bits above 31 as well... Now fixed. Ouch, that's subtle and a mistake that we're likely to keep making in the future, I fear. I've bitten the bullet and replaced all these definitions with the _BITUL() macro instead. That also means we don't have to worry about these constants being used in assembly files when using older versions of binutils. Will --->8 From 25f3852cd8912174c3410414115783799357230a Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Tue, 11 Dec 2018 16:42:31 +0000 Subject: [PATCH] arm64: sysreg: Use _BITUL() when defining register bits Using shifts directly is error-prone and can cause inadvertent sign extensions or build problems with older versions of binutils. Consistent use of the _BITUL() macro makes these problems disappear. Signed-off-by: Will Deacon --- arch/arm64/include/asm/sysreg.h | 81 +++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index cea9e53be729..8310cc58d50c 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -20,6 +20,7 @@ #ifndef __ASM_SYSREG_H #define __ASM_SYSREG_H +#include #include /* @@ -444,31 +445,31 @@ #define SYS_ICH_LR15_EL2 __SYS__LR8_EL2(7) /* Common SCTLR_ELx flags. */ -#define SCTLR_ELx_DSSBS (1UL << 44) -#define SCTLR_ELx_ENIA (1 << 31) -#define SCTLR_ELx_ENIB (1 << 30) -#define SCTLR_ELx_ENDA (1 << 27) -#define SCTLR_ELx_EE (1 << 25) -#define SCTLR_ELx_IESB (1 << 21) -#define SCTLR_ELx_WXN (1 << 19) -#define SCTLR_ELx_ENDB (1 << 13) -#define SCTLR_ELx_I (1 << 12) -#define SCTLR_ELx_SA (1 << 3) -#define SCTLR_ELx_C (1 << 2) -#define SCTLR_ELx_A (1 << 1) -#define SCTLR_ELx_M 1 +#define SCTLR_ELx_DSSBS (_BITUL(44)) +#define SCTLR_ELx_ENIA (_BITUL(31)) +#define SCTLR_ELx_ENIB (_BITUL(30)) +#define SCTLR_ELx_ENDA (_BITUL(27)) +#define SCTLR_ELx_EE (_BITUL(25)) +#define SCTLR_ELx_IESB (_BITUL(21)) +#define SCTLR_ELx_WXN (_BITUL(19)) +#define SCTLR_ELx_ENDB (_BITUL(13)) +#define SCTLR_ELx_I (_BITUL(12)) +#define SCTLR_ELx_SA (_BITUL(3)) +#define SCTLR_ELx_C (_BITUL(2)) +#define SCTLR_ELx_A (_BITUL(1)) +#define SCTLR_ELx_M (_BITUL(0)) #define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_IESB) /* SCTLR_EL2 specific flags. */ -#define SCTLR_EL2_RES1 ((1 << 4) | (1 << 5) | (1 << 11) | (1 << 16) | \ - (1 << 18) | (1 << 22) | (1 << 23) | (1 << 28) | \ - (1 << 29)) -#define SCTLR_EL2_RES0 ((1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | \ - (1 << 10) | (1 << 13) | (1 << 14) | (1 << 15) | \ - (1 << 17) | (1 << 20) | (1 << 24) | (1 << 26) | \ - (1 << 27) | (1 << 30) | (1 << 31) | \ +#define SCTLR_EL2_RES1 ((_BITUL(4)) | (_BITUL(5)) | (_BITUL(11)) | (_BITUL(16)) | \ + (_BITUL(18)) | (_BITUL(22)) | (_BITUL(23)) | (_BITUL(28)) | \ + (_BITUL(29))) +#define SCTLR_EL2_RES0 ((_BITUL(6)) | (_BITUL(7)) | (_BITUL(8)) | (_BITUL(9)) | \ + (_BITUL(10)) | (_BITUL(13)) | (_BITUL(14)) | (_BITUL(15)) | \ + (_BITUL(17)) | (_BITUL(20)) | (_BITUL(24)) | (_BITUL(26)) | \ + (_BITUL(27)) | (_BITUL(30)) | (_BITUL(31)) | \ (0xffffefffUL << 32)) #ifdef CONFIG_CPU_BIG_ENDIAN @@ -490,23 +491,23 @@ #endif /* SCTLR_EL1 specific flags. */ -#define SCTLR_EL1_UCI (1 << 26) -#define SCTLR_EL1_E0E (1 << 24) -#define SCTLR_EL1_SPAN (1 << 23) -#define SCTLR_EL1_NTWE (1 << 18) -#define SCTLR_EL1_NTWI (1 << 16) -#define SCTLR_EL1_UCT (1 << 15) -#define SCTLR_EL1_DZE (1 << 14) -#define SCTLR_EL1_UMA (1 << 9) -#define SCTLR_EL1_SED (1 << 8) -#define SCTLR_EL1_ITD (1 << 7) -#define SCTLR_EL1_CP15BEN (1 << 5) -#define SCTLR_EL1_SA0 (1 << 4) - -#define SCTLR_EL1_RES1 ((1 << 11) | (1 << 20) | (1 << 22) | (1 << 28) | \ - (1 << 29)) -#define SCTLR_EL1_RES0 ((1 << 6) | (1 << 10) | (1 << 13) | (1 << 17) | \ - (1 << 27) | (1 << 30) | (1 << 31) | \ +#define SCTLR_EL1_UCI (_BITUL(26)) +#define SCTLR_EL1_E0E (_BITUL(24)) +#define SCTLR_EL1_SPAN (_BITUL(23)) +#define SCTLR_EL1_NTWE (_BITUL(18)) +#define SCTLR_EL1_NTWI (_BITUL(16)) +#define SCTLR_EL1_UCT (_BITUL(15)) +#define SCTLR_EL1_DZE (_BITUL(14)) +#define SCTLR_EL1_UMA (_BITUL(9)) +#define SCTLR_EL1_SED (_BITUL(8)) +#define SCTLR_EL1_ITD (_BITUL(7)) +#define SCTLR_EL1_CP15BEN (_BITUL(5)) +#define SCTLR_EL1_SA0 (_BITUL(4)) + +#define SCTLR_EL1_RES1 ((_BITUL(11)) | (_BITUL(20)) | (_BITUL(22)) | (_BITUL(28)) | \ + (_BITUL(29))) +#define SCTLR_EL1_RES0 ((_BITUL(6)) | (_BITUL(10)) | (_BITUL(13)) | (_BITUL(17)) | \ + (_BITUL(27)) | (_BITUL(30)) | (_BITUL(31)) | \ (0xffffefffUL << 32)) #ifdef CONFIG_CPU_BIG_ENDIAN @@ -706,13 +707,13 @@ #define ZCR_ELx_LEN_SIZE 9 #define ZCR_ELx_LEN_MASK 0x1ff -#define CPACR_EL1_ZEN_EL1EN (1 << 16) /* enable EL1 access */ -#define CPACR_EL1_ZEN_EL0EN (1 << 17) /* enable EL0 access, if EL1EN set */ +#define CPACR_EL1_ZEN_EL1EN (_BITUL(16)) /* enable EL1 access */ +#define CPACR_EL1_ZEN_EL0EN (_BITUL(17)) /* enable EL0 access, if EL1EN set */ #define CPACR_EL1_ZEN (CPACR_EL1_ZEN_EL1EN | CPACR_EL1_ZEN_EL0EN) /* Safe value for MPIDR_EL1: Bit31:RES1, Bit30:U:0, Bit24:MT:0 */ -#define SYS_MPIDR_SAFE_VAL (1UL << 31) +#define SYS_MPIDR_SAFE_VAL (_BITUL(31)) #ifdef __ASSEMBLY__ -- 2.1.4