Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp818450imp; Wed, 20 Feb 2019 09:31:36 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibf+Y7JFfmaT4T541w27nN2b4PuXttBoi5hbIEpiWo/h/dpktnukyKEk+EuXHlbkGaUming X-Received: by 2002:a63:1013:: with SMTP id f19mr30353568pgl.38.1550683896062; Wed, 20 Feb 2019 09:31:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550683896; cv=none; d=google.com; s=arc-20160816; b=C8m72wt255hmM2hJroCsk0HMCINu9Lzdr0Q/PVkvkXZtPR/nmlO6iGkeXmEqFzosM0 cBgicEPgNeATJPopSJ1bkTBsEHpbG5al4MkFTSfzy4ICRYgRL29jQqroVuHfVHK7wM/V GtE+amX/RBo+t+rh0Tf9HjFLHyGkI00bKRcxXeqS3cu0yU8MWgMSG9oqKPmo2fGBQHgp Yn4EzGC4o3TTc6teG3FzPhUsBDWop+ivvDYpWcgN6bySuEbBdOMc6omNS43yd12nqQOh 1Zq9OyWWZYObmvw6OjRNo4cveBbjAA20ejw3riNVG98Xbx5vZBPTyrk8A52NhbtKrPak onMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=4BFSbPMUv8srPIHFQh77ZJKp9w0Q9MQxtL2VVB5bt/c=; b=a/aEyrXcaGlpdMrpqqFgZHH+MxFbqN/bj6Lz4N74TOE0RoHHIUslBkYiajhdMSuj8s AT9KZa/WzUQ4LIJw8kWCSKCSxftAWfSm9Dla+zICotDgebG7VCOF5Lhy5cy8d1EbMhGt dwy0+TtQWsO4sO06kNU7zJY8YE6vwe7dv62OiKRX82FMcy1uEHHFWnn84TIKEMzu2wAR t8FmQdJtAtrejNGEejaRAw1vUwi0Nm0rGmkJ5wrKVuX3y59IO5M1DcKFi74DJt4sN90q 05O/YTKJzRgv9/Qlj73mcknormhEJBhk7SZVxQGk+83YBd2Jbbde7bPkxeLKwQv7iVRM Yfjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=JP4IXofS; 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 gn10si2079918plb.94.2019.02.20.09.31.21; Wed, 20 Feb 2019 09:31:36 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b=JP4IXofS; 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 S1727157AbfBTRaE (ORCPT + 99 others); Wed, 20 Feb 2019 12:30:04 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:40285 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbfBTR3R (ORCPT ); Wed, 20 Feb 2019 12:29:17 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 444PjQ5njhz9v0gG; Wed, 20 Feb 2019 18:29:14 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=JP4IXofS; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id edA4ubqd21xz; Wed, 20 Feb 2019 18:29:14 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 444PjQ4kdXz9v0g0; Wed, 20 Feb 2019 18:29:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1550683754; bh=4BFSbPMUv8srPIHFQh77ZJKp9w0Q9MQxtL2VVB5bt/c=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=JP4IXofSq5vhxJAAJTxgGmCvDtX4lZ5Z3kRdWu/Rks8p41badOWbTZ7JUr2frz4kU PqJaR8UN7MfR4VgQjkkteb64MZS+g22dLP+MEU9sokj5iZIlHBZdezZEPUucSC5ocR I4cnPNI2sG33FkSfuuKt2FjWPcRBPS8lEGwRO+ck= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 55B088B84F; Wed, 20 Feb 2019 18:29:16 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Grzk_ZjX2kob; Wed, 20 Feb 2019 18:29:16 +0100 (CET) Received: from po16846vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3DD188B84A; Wed, 20 Feb 2019 18:29:16 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 25AF76E85E; Wed, 20 Feb 2019 17:29:16 +0000 (UTC) Message-Id: <4d63467db0d25d51c3f9b9e2fb320f8cdfdef3d3.1550648295.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v3 09/16] powerpc/mmu: add is_strict_kernel_rwx() helper To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , j.neuschaefer@gmx.net Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Wed, 20 Feb 2019 17:29:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper to know whether STRICT_KERNEL_RWX is enabled. This is based on rodata_enabled flag which is defined only when CONFIG_STRICT_KERNEL_RWX is selected. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/mmu.h | 11 +++++++++++ arch/powerpc/mm/init_32.c | 4 +--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 6d22a8e78fe2..d34ad1657d7b 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -289,6 +289,17 @@ static inline u16 get_mm_addr_key(struct mm_struct *mm, unsigned long address) } #endif /* CONFIG_PPC_MEM_KEYS */ +#ifdef CONFIG_STRICT_KERNEL_RWX +static inline bool strict_kernel_rwx_enabled(void) +{ + return rodata_enabled; +} +#else +static inline bool strict_kernel_rwx_enabled(void) +{ + return false; +} +#endif #endif /* !__ASSEMBLY__ */ /* The kernel use the constants below to index in the page sizes array. diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c index 3e59e5d64b01..ee5a430b9a18 100644 --- a/arch/powerpc/mm/init_32.c +++ b/arch/powerpc/mm/init_32.c @@ -108,12 +108,10 @@ static void __init MMU_setup(void) __map_without_bats = 1; __map_without_ltlbs = 1; } -#ifdef CONFIG_STRICT_KERNEL_RWX - if (rodata_enabled) { + if (strict_kernel_rwx_enabled()) { __map_without_bats = 1; __map_without_ltlbs = 1; } -#endif } /* -- 2.13.3