From patchwork Wed Dec 6 12:35: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: 120837 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7002192qgn; Wed, 6 Dec 2017 04:39:00 -0800 (PST) X-Google-Smtp-Source: AGs4zMa5Dmu/fZMDVoTwWuQXt3/XbGYEuN1w/tqPvEv6Q8Qhh6yE9H12nguTuSBPgFDkBTfrSNwM X-Received: by 10.98.206.133 with SMTP id y127mr2617234pfg.152.1512563940621; Wed, 06 Dec 2017 04:39:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512563940; cv=none; d=google.com; s=arc-20160816; b=n/zp30xiSMADfAGI5Kyq02Z+9gou3nJdht9qd9vnxt295nD89Xmw652NLS335vgGRo pq/2eKrRz0x9wWzl1+CRX7UDLpPYRdxnms0+rtr7C5uoHyn3KT60Dd+/M65AiYVvhvFK yLQLc8/kINbfeDmEZaJJxrbsTcIOic0oSpdBlu/wS7ZrodOTt7wpmUbyhnukxtMR80qS W8zQX8hT0RRaj398twg+4obB9RB3IK9+UXW0xFgwIRx14CTY0q0h9wWZVle0dlxColoI V/qZIo1tI6jkDc43Fy2SisTCs87JcKD0FGRyRIXUsb7Twk4lLMg5qdb/6ljXXEAnmrL2 6Fbg== 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=8q4P6pK8i5ZhwdriSm1KrtzGkdE6ze/BH2aPvOP04oE=; b=kK0KlF+bkiITgIZ+r1hiiSfksUQ0wIcJje72M+czudBniDZAijvDHR4vHw5AVa3FuR mcWlYL/68MKIJVp8BsFnlX1VZ+Os9/rJqK2IFdddnMVE8kax1LwAYumoSS+bCsI0j8jp X84JbDtl5vyLpp6K3NqMBHgyR6//oRKsZCpevexWl3W1h40J1GWjl3K4/FYsz7dwXH+2 dgoK5rZmjbbhLubzg3dLYrFnZD15eHADMw1kMPrfApLJi0KPX+k1osbHmedcrs9iHkfc 9Gyy1JnSWmXFi1eVvBk+/20LealhB0mQzTfFyEiWdu2uWW3A4MvIk5ZG8vctq4V/PDFD OhUw== 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 w9si431875plp.783.2017.12.06.04.39.00; Wed, 06 Dec 2017 04:39:00 -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 S1752676AbdLFMi5 (ORCPT + 28 others); Wed, 6 Dec 2017 07:38:57 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34728 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbdLFMgL (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 7B57D169E; 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 4D95F3F7A6; Wed, 6 Dec 2017 04:36:11 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 5E54E1AE37CA; 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 09/20] arm64: mm: Invalidate both kernel and user ASIDs when performing TLBI Date: Wed, 6 Dec 2017 12:35:28 +0000 Message-Id: <1512563739-25239-10-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 Since an mm has both a kernel and a user ASID, we need to ensure that broadcast TLB maintenance targets both address spaces so that things like CoW continue to work with the uaccess primitives in the kernel. Reviewed-by: Mark Rutland Signed-off-by: Will Deacon --- arch/arm64/include/asm/tlbflush.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index af1c76981911..9e82dd79c7db 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -23,6 +23,7 @@ #include #include +#include /* * Raw TLBI operations. @@ -54,6 +55,11 @@ #define __tlbi(op, ...) __TLBI_N(op, ##__VA_ARGS__, 1, 0) +#define __tlbi_user(op, arg) do { \ + if (arm64_kernel_unmapped_at_el0()) \ + __tlbi(op, (arg) | USER_ASID_FLAG); \ +} while (0) + /* * TLB Management * ============== @@ -115,6 +121,7 @@ static inline void flush_tlb_mm(struct mm_struct *mm) dsb(ishst); __tlbi(aside1is, asid); + __tlbi_user(aside1is, asid); dsb(ish); } @@ -125,6 +132,7 @@ static inline void flush_tlb_page(struct vm_area_struct *vma, dsb(ishst); __tlbi(vale1is, addr); + __tlbi_user(vale1is, addr); dsb(ish); } @@ -151,10 +159,13 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, dsb(ishst); for (addr = start; addr < end; addr += 1 << (PAGE_SHIFT - 12)) { - if (last_level) + if (last_level) { __tlbi(vale1is, addr); - else + __tlbi_user(vale1is, addr); + } else { __tlbi(vae1is, addr); + __tlbi_user(vae1is, addr); + } } dsb(ish); } @@ -194,6 +205,7 @@ static inline void __flush_tlb_pgtable(struct mm_struct *mm, unsigned long addr = uaddr >> 12 | (ASID(mm) << 48); __tlbi(vae1is, addr); + __tlbi_user(vae1is, addr); dsb(ish); }