Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp787697imp; Thu, 21 Feb 2019 11:10:39 -0800 (PST) X-Google-Smtp-Source: AHgI3IajxlMGoEntYFpiwm1zet/UV/DVhYf4BOhpyDfDB/fu6zUqOYd5q1IWyImHF83vb40woryM X-Received: by 2002:a63:2ccb:: with SMTP id s194mr82262pgs.214.1550776239268; Thu, 21 Feb 2019 11:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776239; cv=none; d=google.com; s=arc-20160816; b=gjWdyhL2l93jEwYvnRAzhIzDb0ztBirwMa0wK5JwibgeQza7uWJLD3ZbI2JjvbP2lB TUm9OpnZSAH/Im5rGJfyqgosNNPUJGF8P16YUvgMa5OWYt9f0WEDkCvkEA++GQ1tbLEd vm8PZgyDYesv6wka4whW2k+/dO7EiYkMGjGKxuXtPHaaId3sOoZBvN00ssnNryBdW8Ly 5LCwaUadh9VsnVEYRtqOj+uqLwNW6Rz7rNJ9dP1TeJpmk7RdHO7IRKHhmOxSvq3XvshG Zat7wabOfVkhmeppddI4mI8hAhry/xh24WxCC/xD+82E9LyQBc/0+pzcM2HWVq/T4nFc 4Oww== 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=QpfEEtPPFPSgL0SsXuuuOy56zrX5ro/HmbJyhi8Ytk1BlE8s0nLV/GofjTUEizpEP+ jjHlwsJ+8PDLxAars/r51z6tVXOLbdo798f8eGhS4Fgjm7HB9H2Gf7aannG4Y83JX90a VsIikvX30PK4cJqcnegh1nNBjoBqiTFxk1A2FJ0+FrKgsj92o5Iw9DkcVU+yo8v4HoxM QpIK1spDXOgTl0NlxVegrlNcsMOz8ztct7YhdXnSWdi+ZxNUGg+2Ti/CYUiDVNuICnKb 1mm4bOtZnMkkseCFGQM68LI3fSDFvLr2/ZA6W8soxwf3erLElHARealtTDTFmnLpogxg WD0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=fShZDxlX; 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 j2si22202967pfb.214.2019.02.21.11.10.24; Thu, 21 Feb 2019 11:10:39 -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=fShZDxlX; 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 S1727043AbfBUTJf (ORCPT + 99 others); Thu, 21 Feb 2019 14:09:35 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:28952 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726591AbfBUTIr (ORCPT ); Thu, 21 Feb 2019 14:08:47 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4453sp0RDnz9v6l2; Thu, 21 Feb 2019 20:08:46 +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=fShZDxlX; 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 H2m_M2fMBEZz; Thu, 21 Feb 2019 20:08:45 +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 4453sn6VGYz9v6l1; Thu, 21 Feb 2019 20:08:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1550776125; bh=4BFSbPMUv8srPIHFQh77ZJKp9w0Q9MQxtL2VVB5bt/c=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=fShZDxlXXgyaK5YSKPwWYFHEHo/ujA+2e20uoW/LLlEnhqKCtHeTsu9eVQ6etcslq kmY29ElOVE5daHBy+hf4kMxykjDw5piR5sMAzMZsOpYOmVV3LzuN8L1GVdxmhyQXRe 5bWfv3wjUqN6H0MW3wozD+m9mrguefH5F411uqxw= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E32DA8B86A; Thu, 21 Feb 2019 20:08:45 +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 N9nvQkJzgO0u; Thu, 21 Feb 2019 20:08:45 +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 B70158B852; Thu, 21 Feb 2019 20:08:45 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 8DD676EF61; Thu, 21 Feb 2019 19:08:45 +0000 (UTC) Message-Id: <0c85871f259073ab3d9db74ef4f0f2cdb36907e3.1550775950.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v5 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 19:08:45 +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