Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp241365imp; Thu, 21 Feb 2019 00:06:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ+CVfpUUuujNocUB3eDHWZ1ok7nioY9ZCQ6I4vMc7Zwsbp66CrwI7OdYX7Y+wwuZgO85Bx X-Received: by 2002:a63:545:: with SMTP id 66mr32836242pgf.102.1550736404807; Thu, 21 Feb 2019 00:06:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550736404; cv=none; d=google.com; s=arc-20160816; b=QiT8moI6eS9jJN1MnVgVFO8TN6ukf+qECIadtMfcaR0a/z6x7kHKsICYch9+5gS7hk ActV5UKtZ2IXnvFqoPga67YIJgxLY2JYt0HBvJgYjR7nPyUgIW9PtlFdwugSOuxSdTwr frhXzTJorVWvx7H2GtZCqbK9tyLBEWu4S9YDDr3wQcrfjg/80tFluC2XER0QqWZvVUr5 pmd5uJB+m/BlIa0iTyDoocAjHoMq2Nj/w9jrULAYfIuZ1LYuaO3LForBJVTAVQoryLBz 3Szew3MmHQi8gJlUWhdIl8Q64Vd102x/8kQ8CY3Nh6qLHGcqOwdyXrDsoVZxkks/3MEK nC8Q== 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=ouYdvlyRGKnakMble/6xWdFiuffixmhU+fgNaX3fe/g=; b=q/igM07VaPQznfy1WnXJlySBfk1BpM/p82LgBTBr75lc0pyECXVMgnK816HrZQDY14 ElVHFM13xXdFenq8HbeIgOM03cbCOBBkFscctBzkTWrnKk+FiU7AeVyBB0Lm3XFFeD3g 8bzTogJ7OXntPoLzCl8xBkiF6TShCfg5muwJPWLqqy7RRqWBn4YkIFGgM7PLy+Qr3/tD DZKr6MT02xb0yZBqzTe9HbgJFS3mMfz1vgUgOYab0Pvfb9jkaF8IQaURZddBtkOzmCsQ UUaukEgOO6Wl2XC06bzQmdeO7usGl1Dx9rODKuza4L2dDZNzUA90lY4YSrL8fvtUd4g9 2eXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=d6cpQVeT; 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 j6si12567892plt.179.2019.02.21.00.06.29; Thu, 21 Feb 2019 00:06:44 -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=d6cpQVeT; 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 S1727590AbfBUIFj (ORCPT + 99 others); Thu, 21 Feb 2019 03:05:39 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:55271 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727407AbfBUIE7 (ORCPT ); Thu, 21 Feb 2019 03:04:59 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 444n7s1k8wz9vJgF; Thu, 21 Feb 2019 09:04:57 +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=d6cpQVeT; 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 X7uAW1EHYs94; Thu, 21 Feb 2019 09:04:57 +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 444n7s0gjCz9vJg1; Thu, 21 Feb 2019 09:04:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1550736297; bh=ouYdvlyRGKnakMble/6xWdFiuffixmhU+fgNaX3fe/g=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=d6cpQVeTrApaCcO/EMeKKOle221U1CESOxwJ4kXs8WZ5xZ94Zo/F/eqWMqoi/XolS 05NHlcNNsqOs0iVF1Kh7pX3acUlazA3l4KB0sLB6fLOTRMD2R6zYBto9JTMc6kcsCG HwORsXPFx1EmJkPQTI3RlUjxMn3EHxJ3wr3hTf+o= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 004358B78F; Thu, 21 Feb 2019 09:04:57 +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 13Wv_0KlREMK; Thu, 21 Feb 2019 09:04:57 +0100 (CET) Received: from po16846vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id CF2A68B75B; Thu, 21 Feb 2019 09:04:57 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id A53CC6E866; Thu, 21 Feb 2019 08:04:57 +0000 (UTC) Message-Id: <31076b8d9ac4d923ededf039644db4508a3ed61e.1550692943.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v4 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: Thu, 21 Feb 2019 08:04:57 +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 25607604a7a5..f5e27f4a0c29 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