From patchwork Thu Nov 30 16:39:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 120238 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp21431qgn; Thu, 30 Nov 2017 08:47:10 -0800 (PST) X-Google-Smtp-Source: AGs4zMboHMZWVfhXNGvYTUPLCm6eL38oFN9pF+85e751bi0+MDoclxqGzjpRFH3eycyR6KhZ+KEo X-Received: by 10.98.204.198 with SMTP id j67mr7326582pfk.41.1512060430382; Thu, 30 Nov 2017 08:47:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060430; cv=none; d=google.com; s=arc-20160816; b=vwWI2pO2StTNep5AVshuBHjvp1QuPALkUZVDZr776wzXb9g5rawda6D4+sv4p6t0xM mEQxmR3lH5i6GlqEifiD8KZeFLK9oHwMRh1+GOQF/7XknW13IPlVLAkF+/YLHxAzAqLV 5hzGL3yi2NNU5zXo5yBhkShKzZ0+y1Ya5cTpnvL3xh5z01NsTv0zk1nANosTVB37x6qw 062cNjstWuLHtlWzTenqmHHS2sCDlY6kSepdIIs1oNoppfOMx5zL3AUMiyPke8s5Akg/ k8NXOl3X8mm6Isdr9oGJtlRANdXVy0h2yiAJlGkgjVWXsZcDyuAGWSXdmeBEfh94Yk8M ZRQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=TgdORaSKm/G1vHHhDw2jvbayLquZGlE/C67o8a6S314=; b=NL/OTtqmp9ocpvCx1egeClwCo0Ssy+xmY3nnXEytpnX5Yp3ui7ys/LSQAlcnUh5u3Y ItIUoCjMkvj0Mdes/giHdPY4JHq8B7DHmXW6nYiHh5rpcGIFbl85MRGqODq1MLQDkJ9L E1vsMY/0AP0wXBVuDD7SVeJZ6mhn4U1bP8gCJpvDcBV90rE8Wte4YSfFQojw0os42Hax h+smoMPBP9k44vGq81hFfP83U8blo+GIfrjFaVRuXHmEEf2FZtdHNfV0wNpVbndAo1+d 01noAjVvS+HIuQvMXZZi5JKMsKAY8Nl5VWhrKonmEO44Clr6lNsrM2rnVUMbZqSYKDA6 k3EQ== 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 33si3402730ple.802.2017.11.30.08.47.10; Thu, 30 Nov 2017 08:47:10 -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 S1753688AbdK3QqM (ORCPT + 28 others); Thu, 30 Nov 2017 11:46:12 -0500 Received: from foss.arm.com ([217.140.101.70]:57498 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753327AbdK3Qjp (ORCPT ); Thu, 30 Nov 2017 11:39:45 -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 6D90C169E; Thu, 30 Nov 2017 08:39:45 -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 3FA333F774; Thu, 30 Nov 2017 08:39:45 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 01D9B1AE3D63; 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 08/18] arm64: mm: Add arm64_kernel_unmapped_at_el0 helper Date: Thu, 30 Nov 2017 16:39:36 +0000 Message-Id: <1512059986-21325-9-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1512059986-21325-1-git-send-email-will.deacon@arm.com> References: <1512059986-21325-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order for code such as TLB invalidation to operate efficiently when the decision to map the kernel at EL0 is determined at runtime, this patch introduces a helper function, arm64_kernel_unmapped_at_el0, to determine whether or not the kernel is mapped whilst running in userspace. Currently, this just reports the value of CONFIG_UNMAP_KERNEL_AT_EL0, but will later be hooked up to a fake CPU capability using a static key. Signed-off-by: Will Deacon --- arch/arm64/include/asm/mmu.h | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.1.4 diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h index 01bfb184f2a8..c07954638658 100644 --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -19,6 +19,8 @@ #define MMCF_AARCH32 0x1 /* mm context flag for AArch32 executables */ #define USER_ASID_FLAG (UL(1) << 48) +#ifndef __ASSEMBLY__ + typedef struct { atomic64_t id; void *vdso; @@ -32,6 +34,11 @@ typedef struct { */ #define ASID(mm) ((mm)->context.id.counter & 0xffff) +static inline bool arm64_kernel_unmapped_at_el0(void) +{ + return IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0); +} + extern void paging_init(void); extern void bootmem_init(void); extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt); @@ -42,4 +49,5 @@ extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, extern void *fixmap_remap_fdt(phys_addr_t dt_phys); extern void mark_linear_text_alias_ro(void); +#endif /* !__ASSEMBLY__ */ #endif