Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp917995imu; Wed, 28 Nov 2018 01:29:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wm6D7V7v/ROhmmX/5zqGgMAq5zlbPCFyCQNt+okpa6Rf6pqEjBvSe9CXglzFMr8B9odw+N X-Received: by 2002:a17:902:d891:: with SMTP id b17mr36811127plz.80.1543397367579; Wed, 28 Nov 2018 01:29:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543397367; cv=none; d=google.com; s=arc-20160816; b=bkYykd+AZCj4pyn0Lq9gwSLBeZjSIk3ovwJRNVhygapRLwoUwZUjnNsTiY+eXegVHn t3lBY+Oup4wug5BNmOJv0pOMKPvdAdWQxesffhe3FfYjNczP6uZ0eMKOhqGUrHpW9Wkj 7zFAq6Jb5YXJUHFJqDam2XBFq3IdzBzamaz5PJLUNEYBKfrULlpmcX1HkBhBYpaZg0gP Qy89/RUHd6fIGtWBRq+Ciok19IpgCJRUIOHpmZtOjG+KkvT2kipgRv9S2CsK+wL7rWzF MpZnRzKwyzoCHlXbOlcsHUiMOQUd9aQqz1kw7O4vOnqDlfwH6Ax0uV1vlScJpiqktri7 BYTg== 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; bh=CmDC/35jQ+WM5MjztPGHuir2gE0S0MBxx928pgTwQxo=; b=aXseAem5idNQnR79lFnVL+axCL3bW0xTwSNpUj3UqqUlW9OqpEHw3/WkkQRYyc11BB r7ndKdWI6Id7S30Eka/cHIiRpfkcy7z0erMj7VZWP8O+2LFUq7Zvq4dtE/i5oSzhqzHM 0CqbejgUTl40h9lhaS2EmqpxLM1uXWPdBFjE05fDhnqMv+K6EMcEFZcKnUKZ31OrlzZF 0FPrpIARDy2quDMdbDVNFPfvMuWsIQsa+iBaiOzZbF6fP/rgStgV3liH9nGAlg91o8If K2kpgJGIw7/pHx7EcQ2pS4NVHbDsTtNZr8vp+mwUKGCZ7w6h2IvsJGMUI70zrUJv+rDP 7Uzg== 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 o9si7135862pfe.63.2018.11.28.01.29.13; Wed, 28 Nov 2018 01:29:27 -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 S1728172AbeK1U2R (ORCPT + 99 others); Wed, 28 Nov 2018 15:28:17 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:20992 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727676AbeK1U2R (ORCPT ); Wed, 28 Nov 2018 15:28:17 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 434b043Dctz9vBKH; Wed, 28 Nov 2018 10:27:16 +0100 (CET) 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 yVDCI4cY_VC4; Wed, 28 Nov 2018 10:27:16 +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 434b042lZnz9vBK9; Wed, 28 Nov 2018 10:27:16 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 459678B85E; Wed, 28 Nov 2018 10:27:17 +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 7eKMAuisxiuX; Wed, 28 Nov 2018 10:27:17 +0100 (CET) Received: from po14163vm.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 C5BE68B85D; Wed, 28 Nov 2018 10:27:16 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id A3FBB69AFA; Wed, 28 Nov 2018 09:27:16 +0000 (UTC) Message-Id: <312a6ca863fb46569b705d0dc5f5e38dfcd64889.1543356926.git.christophe.leroy@c-s.fr> In-Reply-To: <76d777b36e54e7b8d4c196405decc712fc5eaf45.1543356926.git.christophe.leroy@c-s.fr> References: <76d777b36e54e7b8d4c196405decc712fc5eaf45.1543356926.git.christophe.leroy@c-s.fr> From: Russell Currey Subject: [RFC PATCH v2 07/11] powerpc/mm/radix: Use KUEP API for Radix MMU To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , ruscur@russell.cc Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Wed, 28 Nov 2018 09:27:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Execution protection already exists on radix, this just refactors the radix init to provide the KUEP setup function instead. Thus, the only functional change is that it can now be disabled. Signed-off-by: Russell Currey Signed-off-by: Christophe Leroy --- arch/powerpc/mm/pgtable-radix.c | 9 ++++++--- arch/powerpc/platforms/Kconfig.cputype | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c index 931156069a81..45aa9e501e76 100644 --- a/arch/powerpc/mm/pgtable-radix.c +++ b/arch/powerpc/mm/pgtable-radix.c @@ -535,8 +535,13 @@ static void radix_init_amor(void) mtspr(SPRN_AMOR, (3ul << 62)); } -static void radix_init_iamr(void) +void setup_kuep(bool disabled) { + if (disabled) + return; + + pr_info("Activating Kernel Userspace Execution Prevention\n"); + /* * Radix always uses key0 of the IAMR to determine if an access is * allowed. We set bit 0 (IBM bit 1) of key0, to prevent instruction @@ -605,7 +610,6 @@ void __init radix__early_init_mmu(void) memblock_set_current_limit(MEMBLOCK_ALLOC_ANYWHERE); - radix_init_iamr(); radix_init_pgtable(); /* Switch to the guard PID before turning on MMU */ radix__switch_mmu_context(NULL, &init_mm); @@ -627,7 +631,6 @@ void radix__early_init_mmu_secondary(void) __pa(partition_tb) | (PATB_SIZE_SHIFT - 12)); radix_init_amor(); } - radix_init_iamr(); radix__switch_mmu_context(NULL, &init_mm); if (cpu_has_feature(CPU_FTR_HVMODE)) diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index a20669a9ec13..e6831d0ec159 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -334,6 +334,7 @@ config PPC_RADIX_MMU bool "Radix MMU Support" depends on PPC_BOOK3S_64 select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA + select PPC_HAVE_KUEP default y help Enable support for the Power ISA 3.0 Radix style MMU. Currently this -- 2.13.3