From patchwork Wed Dec 6 12:35:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 120839 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7003543qgn; Wed, 6 Dec 2017 04:40:32 -0800 (PST) X-Google-Smtp-Source: AGs4zMZGwXIljjJhHgCDdav/Ju1n+AO4J5lMRXdJTMtvSBoF1352a8eGBEs3pcU0sPFUTJyyBpKO X-Received: by 10.98.153.221 with SMTP id t90mr2661646pfk.210.1512564032289; Wed, 06 Dec 2017 04:40:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512564032; cv=none; d=google.com; s=arc-20160816; b=qFgJKnO14HSN42zh3xS58UKR2rH2/8sxLdJ1p0dhlZ4w+wTMseGiIDH4AVrl+nBdVU DCDEEu7DbJn5/gHfZPmr4xzr0xEM7G0NdzdmshvKKV+XvgNpyQngK4Q6217h0VPlMEmX U81+r/b6fAN4GeLN87kD0YWCt1cQSXjF2b9bDhTqo2JomborlFloXhYRtcOlxSDjcRSg SwKvIj64lGq4w6EfYxgJ8u6CY0NVppIc9vOCeGwKO4DZamRKDSuWhQWyUyEIW8IpXx+h RPkF4plTQtGQ+bg5pCq/+rLXwEcGkwg+sBtgl2F4CmSvyZNZxHmupwDuS/KxBPmxXDPb Pkdg== 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=SH81J+ySp5Q8ZwdDnG6GDnzY+iTGLqepGx9CviqoXLI=; b=cPs7zgjTSFMCJjfYW2tmrmE1GDr2QrTcZqmpDt3WY/2mu0PjjSzUPBcASdqVJU3sCD 2+/MfEaWl5IKNW/wRUzI024sfbpyCGa/6fkxTd3OucXYMT/+bCpIeMrSwSzqxvUbzVyH qvzzhmNRxmuWnMrL9q3aFXUwnHLRnLJ9CethRsbv71/OyN4eenfhiBCZbozD84gWqQty TIZSmaTSwwOw7k86qV639dMWGXN0HdTwjmfdYcp+eDpouBuhtaQgGoOjXob/6AyDngS1 VXusjObcPwrVC0JlLDPYWmo56vfd5NbI8WfDgqBc2mOBBEMg/foVkqDk3H1KjgdBkfHS tiog== 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 g8si133054plt.245.2017.12.06.04.40.32; Wed, 06 Dec 2017 04:40:32 -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 S1752564AbdLFMka (ORCPT + 28 others); Wed, 6 Dec 2017 07:40:30 -0500 Received: from foss.arm.com ([217.140.101.70]:34704 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752143AbdLFMgL (ORCPT ); Wed, 6 Dec 2017 07:36:11 -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 721F81688; Wed, 6 Dec 2017 04:36:11 -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 43F153F627; Wed, 6 Dec 2017 04:36:11 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 489811AE37AD; Wed, 6 Dec 2017 12:36:16 +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 v3 08/20] arm64: mm: Add arm64_kernel_unmapped_at_el0 helper Date: Wed, 6 Dec 2017 12:35:27 +0000 Message-Id: <1512563739-25239-9-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1512563739-25239-1-git-send-email-will.deacon@arm.com> References: <1512563739-25239-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. Reviewed-by: Mark Rutland 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