From patchwork Tue Apr 3 11:09:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 132715 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3665646ljb; Tue, 3 Apr 2018 04:09:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Lv4UEOfc5OXHEF8h+iPkjPu668voiGNv/QTWTlr5hyu8heUTZt9tThpnolidm7Mm2wMSs X-Received: by 2002:a17:902:4481:: with SMTP id l1-v6mr13784697pld.43.1522753793854; Tue, 03 Apr 2018 04:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522753793; cv=none; d=google.com; s=arc-20160816; b=ukwVO9AqoXPbdH+92fy9MMkLGaWon2SoOYmWYbI7knoVEgmybWpkDh2YptkkplVzRH AhuI6Mgv0Ua72aTSBhAGEqAGVItSfzD1jjD/tb6GcwIUIjBoPPRAvaEeqS662Vsr512L CcvM5ltAO7nj36kpWCqZapOBwD2lu1h5O6f98MU3SpznfFypEQ98iZkmeqLsNRN8qpFC n2P2Fpc8JGY+8d0ECsDsPCKGd3aUQERhGgldDiflPzbEC3DyXe4g2tomkJS80BlUCnNU OtOFzS0Mhu9w+n87uK8WjTdezGENQSLmdvUjRR5NQxvUUzAOQgtdZfborMm8wWiY6cqc QSTQ== 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=xSQJNOZ8OWbKD/Rm9JtTYEBveTC1+4wIrAMazFqpyPE=; b=lNEkub+8UPqPEVwC1QmaWOK9DCk1xDjWjPyT2/O1+ZdLW6QslSjNNP6NhSMHgJRaUI 6HBKIaXG3gTYa0ueVZIfQmP9/OofsbI953pm6tb10XZTo257kuFvoZz/Pgl/MrkHGPFP fSQPfGTwFMXejNLMJOMEQNrW0icPGqVWKol1+oc3natICPz5EWzX8gU5NHydoghc+Zr0 5pLEbtwOCRt6d9UVlIg43pdWeSTB8BnGTEuXrm1gKvJLxC8j585SDHlzm/ZJ5eT0YrFi NfoN0RgEOvONWt3VXHtdtihEHORjGKb5OoKrlxad9AlleWp5Z2U6idzYKaDwmctYXydA j+VQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 d14-v6si302866plj.191.2018.04.03.04.09.53; Tue, 03 Apr 2018 04:09:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755287AbeDCLJx (ORCPT + 11 others); Tue, 3 Apr 2018 07:09:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59298 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755063AbeDCLJw (ORCPT ); Tue, 3 Apr 2018 07:09:52 -0400 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 92F151435; Tue, 3 Apr 2018 04:09:52 -0700 (PDT) Received: from lakrids.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 623523F587; Tue, 3 Apr 2018 04:09:51 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com Subject: [PATCH v4.9.y 04/27] arm64: mm: Add arm64_kernel_unmapped_at_el0 helper Date: Tue, 3 Apr 2018 12:09:00 +0100 Message-Id: <20180403110923.43575-5-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180403110923.43575-1-mark.rutland@arm.com> References: <20180403110923.43575-1-mark.rutland@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Will Deacon commit fc0e1299da54 upstream. 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 Tested-by: Laura Abbott Tested-by: Shanker Donthineni Signed-off-by: Will Deacon Signed-off-by: Alex Shi [v4.9 backport] Signed-off-by: Mark Rutland [v4.9 backport] --- arch/arm64/include/asm/mmu.h | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.11.0 diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h index 49924e56048e..279e75b8a49e 100644 --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -18,6 +18,8 @@ #define USER_ASID_FLAG (UL(1) << 48) +#ifndef __ASSEMBLY__ + typedef struct { atomic64_t id; void *vdso; @@ -30,6 +32,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); @@ -39,4 +46,5 @@ extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, pgprot_t prot, bool allow_block_mappings); extern void *fixmap_remap_fdt(phys_addr_t dt_phys); +#endif /* !__ASSEMBLY__ */ #endif