From patchwork Thu Nov 30 16:39:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 120223 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp14180qgn; Thu, 30 Nov 2017 08:40:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMaXrHlJGMpUsFeidNQ058Cp4++O4V/cg88Yc5wRvY3w3tXnLCguae/hGKwk124AE/tOLjYC X-Received: by 10.84.168.198 with SMTP id f64mr3279302plb.324.1512060043084; Thu, 30 Nov 2017 08:40:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060043; cv=none; d=google.com; s=arc-20160816; b=iTyAeJqKzpI+4JavpaiRErot9PG2GfyPZIxVodf7IX+YqTORN9v9xpckpC+LV5hpTF BgmL/Pc0rGBx1BQVvdfIPofHtcdA446kTcDRZouYNdfLmwdPVbby4bLwsphGnhHReGLm J/VEK5p6R748K973En19rw5tYiaxFVxOi02jaY2xqLSqxUSTityIL/O541qh9oF+zs40 l6NFguY9U3sp3FNwAP/EbVkNnKYlJpshOkp/9hk1XvgNX31eDQ560xmTGVEHmr+7izPq H7p/gMzkO/0xEcx04e2rX3NOfahDfpHKNi7dUL4/CoZpIfYLLw+hOcQP+dnn6917mMMD nQkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=MnvjddkZnSYXtLw0EacTqdsY3nNZSnqzEuHsvAAWoic=; b=PS5+FtARAPrACqjoQlynRtiZs4p/hp/iEqc51YmkPlhCc9I7HnaJIVSsPyzNt8L+Xf Rx1INYSYCmJfiSM33MI1HzrqdfQPjcxOO2orUn72/0RgzsaiDyowboyf5zUn47CFfJ6W rMxCdMgtJqECy6GAtPiXpnNwag3gjeNXqrbuhwhhNZ4AckiNuIaxsp8I63FZE6wRauK6 J+2/nGqViFzxz5JSNL6ahKljd+Q5bRxQcWa4i+goqytMrkNatS4bY0fAMfAvcMNGpaVD 78+F7sbY75dQsxdLlbRSNzj8WrjrDWCb2fJaLxBwj724E3WA4zrakieOghJHwgYUy1f1 84eQ== 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 h72si3532928pfj.20.2017.11.30.08.40.42; Thu, 30 Nov 2017 08:40:43 -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 S1753385AbdK3Qjs (ORCPT + 28 others); Thu, 30 Nov 2017 11:39:48 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57354 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752894AbdK3Qjo (ORCPT ); Thu, 30 Nov 2017 11:39:44 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 683CD1435; Thu, 30 Nov 2017 08:39:44 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3881A3F318; Thu, 30 Nov 2017 08:39:44 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 7D4AB1AE3BC8; Thu, 30 Nov 2017 16:39:47 +0000 (GMT) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, ard.biesheuvel@linaro.org, sboyd@codeaurora.org, dave.hansen@linux.intel.com, keescook@chromium.org, msalter@redhat.com, labbott@redhat.com, tglx@linutronix.de, Will Deacon Subject: [PATCH v2 00/18] arm64: Unmap the kernel whilst running in userspace (KAISER) Date: Thu, 30 Nov 2017 16:39:28 +0000 Message-Id: <1512059986-21325-1-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi again, This is version two of the patches previously posted here: http://lists.infradead.org/pipermail/linux-arm-kernel/2017-November/542751.html Changes since v1 include: * Based on v4.15-rc1 * Trampoline moved into FIXMAP area * Explicit static key replaced by cpu cap * Disable SPE for userspace profiling if kernel unmapped at EL0 * Changed polarity of cpu feature to match config option * Changed command-line option so we can force on in future if necessary * Changed Falkor workaround to invalidate different page within 2MB region * Reworked alternative sequences in entry.S, since the NOP slides with kaiser=off were measurable I experimented with leaving the vbar set to point at the kaiser vectors, but I couldn't measure any performance improvement from that and it made the code slightly more complicated, so I've left it as-is. Patches based on 4.15-rc1 and also pushed here: git://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git kaiser Feedback welcome, particularly on a better name for the command-line option. Will --->8 Will Deacon (18): arm64: mm: Use non-global mappings for kernel space arm64: mm: Temporarily disable ARM64_SW_TTBR0_PAN arm64: mm: Move ASID from TTBR0 to TTBR1 arm64: mm: Remove pre_ttbr0_update_workaround for Falkor erratum #E1003 arm64: mm: Rename post_ttbr0_update_workaround arm64: mm: Fix and re-enable ARM64_SW_TTBR0_PAN arm64: mm: Allocate ASIDs in pairs arm64: mm: Add arm64_kernel_unmapped_at_el0 helper arm64: mm: Invalidate both kernel and user ASIDs when performing TLBI arm64: entry: Add exception trampoline page for exceptions from EL0 arm64: mm: Map entry trampoline into trampoline and kernel page tables arm64: entry: Explicitly pass exception level to kernel_ventry macro arm64: entry: Hook up entry trampoline to exception vectors arm64: erratum: Work around Falkor erratum #E1003 in trampoline code arm64: tls: Avoid unconditional zeroing of tpidrro_el0 for native tasks arm64: entry: Add fake CPU feature for unmapping the kernel at EL0 arm64: Kconfig: Add CONFIG_UNMAP_KERNEL_AT_EL0 perf: arm_spe: Disallow userspace profiling when arm_kernel_unmapped_at_el0() arch/arm64/Kconfig | 30 +++-- arch/arm64/include/asm/asm-uaccess.h | 25 +++-- arch/arm64/include/asm/assembler.h | 27 +---- arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/fixmap.h | 4 + arch/arm64/include/asm/kernel-pgtable.h | 12 +- arch/arm64/include/asm/mmu.h | 10 ++ arch/arm64/include/asm/mmu_context.h | 9 +- arch/arm64/include/asm/pgtable-hwdef.h | 1 + arch/arm64/include/asm/pgtable-prot.h | 21 +++- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/include/asm/proc-fns.h | 6 - arch/arm64/include/asm/tlbflush.h | 16 ++- arch/arm64/include/asm/uaccess.h | 21 +++- arch/arm64/kernel/asm-offsets.c | 6 +- arch/arm64/kernel/cpufeature.c | 41 +++++++ arch/arm64/kernel/entry.S | 190 +++++++++++++++++++++++++++----- arch/arm64/kernel/process.c | 12 +- arch/arm64/kernel/vmlinux.lds.S | 17 +++ arch/arm64/lib/clear_user.S | 2 +- arch/arm64/lib/copy_from_user.S | 2 +- arch/arm64/lib/copy_in_user.S | 2 +- arch/arm64/lib/copy_to_user.S | 2 +- arch/arm64/mm/cache.S | 2 +- arch/arm64/mm/context.c | 36 +++--- arch/arm64/mm/mmu.c | 23 ++++ arch/arm64/mm/proc.S | 12 +- arch/arm64/xen/hypercall.S | 2 +- drivers/perf/arm_spe_pmu.c | 7 ++ 29 files changed, 407 insertions(+), 135 deletions(-) -- 2.1.4 Reviewed-by: Mark Rutland Tested-by: Shanker Donthineni