Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp98605pxj; Thu, 3 Jun 2021 01:42:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPl696tAQuSfvF9CIF0VcqYFib0HgjRWl0RnovIiPYmk7b+2uBHRX+3NQZSh4jMTndwuSg X-Received: by 2002:a17:907:1c1b:: with SMTP id nc27mr39224915ejc.114.1622709778623; Thu, 03 Jun 2021 01:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622709778; cv=none; d=google.com; s=arc-20160816; b=hSwA+bAwOxgFHetstOiC5T8sARmM/x5ze9f8+r+eR21F8lzgVg0TvFDUhavgp8MmXS 6n1MyzLSjPxDJHk8Hv61S97FNxZcXLG4CuMrCFV73H+Q0dL2uJoAsOdzDoXWF0Ha1n7b FAaleBRUVktwjPCHSonnSoqlTdGwPwG1zQ5pOUBw1I6Lj7hr48TabOIe3JXszNgkYH6v Mvyxjs9PEdLT+H39MoPcD3B9/Sl/+JZvgqM1rob5YiUkNieP3qpBfcFg90+hOH9mKOL1 bV913WOA6R3t651OY1aXIXyLPf6JtYZdDtR0zws/hmXEAsMm7dFw+WWGU6JBIRE8pgRU ZoWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=PMMpY7lyGWlXP6Nt66SxrJPdQPCFvsFutBix+MCU8MI=; b=nBGOC2I8GernUuLSz0KTR2PeOcF+alVMl6HFvl7wv3yWte0UQEn0MUACXJD6CcTlVu 3li4xTykgqV6hBl9JlSeyoFxkGfH+eSmUBfl47ry/hh5alOApyUXNY+n05ndgiwEax8a XarZ+aTV2fLQAbVHU+6BcJwf1X+Eo4BKeeDONg7xWonfLYBzd29ZB8bKt/HKk8HtfzGJ m162AQ3awXRtFrA8++3zvC0JUmBf4mMj6AAk2GxQdwazQPAwcICNiWbEb4T9i7fuJSfd pI5CW4KWg/ykTwZImtG76i6JaHj0YtVdDKV/xyB6TBHT20iXAjbgkufyrw8+z5pohOVq lSNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si1702576ejl.205.2021.06.03.01.42.35; Thu, 03 Jun 2021 01:42:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbhFCInW (ORCPT + 99 others); Thu, 3 Jun 2021 04:43:22 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:28333 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbhFCInV (ORCPT ); Thu, 3 Jun 2021 04:43:21 -0400 Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4FwfWh2xqMzBC5j; Thu, 3 Jun 2021 10:41:36 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2aIBgItm49pb; Thu, 3 Jun 2021 10:41:36 +0200 (CEST) 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 4FwfWh223WzBC5Z; Thu, 3 Jun 2021 10:41:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3BC018B848; Thu, 3 Jun 2021 10:41:36 +0200 (CEST) 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 ScWqzpR0GDFX; Thu, 3 Jun 2021 10:41:36 +0200 (CEST) Received: from po15610vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DD36D8B767; Thu, 3 Jun 2021 10:41:35 +0200 (CEST) Received: by po15610vm.idsi0.si.c-s.fr (Postfix, from userid 0) id ADBBA64BD2; Thu, 3 Jun 2021 08:41:35 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH v2 00/12] powerpc: Optimise KUAP on book3s/32 To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 3 Jun 2021 08:41:35 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series is a rework of KUAP on book3s/32. On book3s32, KUAP is heavier than on other platform because it can't be opened globaly at once, it must be done for each 256Mb segment. Instead of opening access to all necessary segments via a heavy logic, only open access to the segment matching the start of the range. 99.999% of the time, the range doesn't cross segment limit so it is not worth checking and handling that corner case at the first place. If that happens, take a fault and do the additional segments opening in the fault handler. See patch 9 for details. This series also adds the capability to disable KUAP and KUEP at boot time via the "nosmap" and "nosmep" kernel parameters as PPC64 does. Last 2 patches are cleanup of generic KUAP code once book3s/32 has been simplified. Changes in v2: - Incorporated the conversion to C of switch_mmu_context() - Converted initial KUAP/KUEP setup to C - Added capability to disable KUAP and KUEP at boottime - Enable KUAP and KUEP by default Christophe Leroy (12): powerpc/32s: Move setup_{kuep/kuap}() into {kuep/kuap}.c powerpc/32s: Refactor update of user segment registers powerpc/32s: move CTX_TO_VSID() into mmu-hash.h powerpc/32s: Convert switch_mmu_context() to C powerpc/32s: Simplify calculation of segment register content powerpc/32s: Initialise KUAP and KUEP in C powerpc/32s: Allow disabling KUEP at boot time powerpc/32s: Allow disabling KUAP at boot time powerpc/32s: Rework Kernel Userspace Access Protection powerpc/32s: Activate KUAP and KUEP by default powerpc/kuap: Remove KUAP_CURRENT_XXX powerpc/kuap: Remove to/from/size parameters of prevent_user_access() arch/powerpc/include/asm/book3s/32/kup.h | 199 ++++++++++++------ arch/powerpc/include/asm/book3s/32/mmu-hash.h | 41 ++++ arch/powerpc/include/asm/book3s/64/kup.h | 3 +- arch/powerpc/include/asm/kup.h | 28 +-- arch/powerpc/include/asm/nohash/32/kup-8xx.h | 3 +- arch/powerpc/include/asm/processor.h | 10 +- arch/powerpc/kernel/asm-offsets.c | 5 - arch/powerpc/kernel/head_book3s_32.S | 64 ------ arch/powerpc/kernel/process.c | 3 + arch/powerpc/kernel/smp.c | 4 + arch/powerpc/kvm/book3s_32_mmu_host.c | 3 - arch/powerpc/mm/book3s32/Makefile | 1 + arch/powerpc/mm/book3s32/kuap.c | 30 +++ arch/powerpc/mm/book3s32/kuep.c | 42 +--- arch/powerpc/mm/book3s32/mmu.c | 20 -- arch/powerpc/mm/book3s32/mmu_context.c | 48 +++-- arch/powerpc/platforms/Kconfig.cputype | 4 +- 17 files changed, 276 insertions(+), 232 deletions(-) create mode 100644 arch/powerpc/mm/book3s32/kuap.c -- 2.25.0