Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1914015ybi; Thu, 20 Jun 2019 06:07:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK+MD5GVhyLHtrV4L7nHPdQHsP0KpMWFoed5Qb6inv1Xu0Ps4afWqPVneKbGL5LUNkq6kL X-Received: by 2002:a62:8643:: with SMTP id x64mr96595772pfd.7.1561036068981; Thu, 20 Jun 2019 06:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561036068; cv=none; d=google.com; s=arc-20160816; b=WV9AKwqc2Y/+z5dRS23EgDEEtKfr8qf2WoL7vtOAIcP0R4HU1tou37SkMEckPq2FaE YbM5ASGulXrp63hdreR6dnqcQIo7v5Bu68n95JtmhvdVeeS4MQFX/Cm+/lqFlEBf/MHp KDQWuNJ3KJH3Fkg/fImwG/ch12xcGZ4GX7PMQ2ZIZlx5JQre/CNTt1dD5mrYfw4ZyZr/ NJ6GG21GZ5onG8QCkYNO8J6UxYIpq6GCr6qAF1sR9gqI201N48exPIPoZ9dm1w8UeUVj vQ5Gq576XMPOdHd2agIZvg784Sw9BS020GJQpVHY34iw3ZGCs1qVEnbiMKce3Z27T/PS hjgw== 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; bh=P19iB0RN+QVwJmlK/R/hy8q7m6sILENbHxPhaxnl15c=; b=Tk/dJZiAbLAZdHRuIiTGS+YItCTOPidSaDaP0EcDHM7m9NTNXuoBXKOIU4kweTrkQY IAolO2ZOGt+Fn01N2cpGf5xwlMxaC3VxvhNOKdkEEDfmLZcFskxPnvDOrZITMspEnn7W jHB8Bi33fMG4v027H5Q+9+uPW0cJBGOGVi0QBF0M979G7qWnOmVHe5mxiaRXcDrwuCQr QtpDhQivoZZUmlchCD+mX94Fhcciohda6xYEjkn+LGppO5cY7XIMphT+YEWOG8SxgHJh J7SKB7Ghy04luqPUUIspPrbkrmrN4nxO38ZA51g8+M8vLK9qpO0ME9VQ0SnX5ChkYkuG BIcQ== 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 j3si13934079pfh.178.2019.06.20.06.07.32; Thu, 20 Jun 2019 06:07:48 -0700 (PDT) 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 S1732040AbfFTNGl (ORCPT + 99 others); Thu, 20 Jun 2019 09:06:41 -0400 Received: from foss.arm.com ([217.140.110.172]:36808 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732029AbfFTNGi (ORCPT ); Thu, 20 Jun 2019 09:06:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8B5CB360; Thu, 20 Jun 2019 06:06:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3704F3F718; Thu, 20 Jun 2019 06:06:37 -0700 (PDT) From: Julien Grall To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: james.morse@arm.com, marc.zyngier@arm.com, julien.thierry@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Julien Grall Subject: [RFC v2 10/14] arm64/mm: Introduce a callback to flush the local context Date: Thu, 20 Jun 2019 14:06:04 +0100 Message-Id: <20190620130608.17230-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190620130608.17230-1-julien.grall@arm.com> References: <20190620130608.17230-1-julien.grall@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Flushing the local context will vary depending on the actual user of the ASID allocator. Introduce a new callback to flush the local context and move the call to flush local TLB in it. Signed-off-by: Julien Grall --- arch/arm64/mm/context.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index fbef5a5c5624..3df63a28856c 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -39,6 +39,8 @@ static struct asid_info cpumask_t flush_pending; /* Number of ASID allocated by context (shift value) */ unsigned int ctxt_shift; + /* Callback to locally flush the context. */ + void (*flush_cpu_ctxt_cb)(void); } asid_info; #define active_asid(info, cpu) *per_cpu_ptr((info)->active, cpu) @@ -266,7 +268,7 @@ static void asid_new_context(struct asid_info *info, atomic64_t *pasid, } if (cpumask_test_and_clear_cpu(cpu, &info->flush_pending)) - local_flush_tlb_all(); + info->flush_cpu_ctxt_cb(); atomic64_set(&active_asid(info, cpu), asid); raw_spin_unlock_irqrestore(&info->lock, flags); @@ -298,6 +300,11 @@ asmlinkage void post_ttbr_update_workaround(void) CONFIG_CAVIUM_ERRATUM_27456)); } +static void asid_flush_cpu_ctxt(void) +{ + local_flush_tlb_all(); +} + /* * Initialize the ASID allocator * @@ -308,10 +315,12 @@ asmlinkage void post_ttbr_update_workaround(void) * 2. */ static int asid_allocator_init(struct asid_info *info, - u32 bits, unsigned int asid_per_ctxt) + u32 bits, unsigned int asid_per_ctxt, + void (*flush_cpu_ctxt_cb)(void)) { info->bits = bits; info->ctxt_shift = ilog2(asid_per_ctxt); + info->flush_cpu_ctxt_cb = flush_cpu_ctxt_cb; /* * Expect allocation after rollover to fail if we don't have at least * one more ASID than CPUs. ASID #0 is always reserved. @@ -332,7 +341,8 @@ static int asids_init(void) { u32 bits = get_cpu_asid_bits(); - if (!asid_allocator_init(&asid_info, bits, ASID_PER_CONTEXT)) + if (!asid_allocator_init(&asid_info, bits, ASID_PER_CONTEXT, + asid_flush_cpu_ctxt)) panic("Unable to initialize ASID allocator for %lu ASIDs\n", 1UL << bits); -- 2.11.0