Received: by 10.223.185.116 with SMTP id b49csp5726328wrg; Tue, 27 Feb 2018 19:59:21 -0800 (PST) X-Google-Smtp-Source: AG47ELuBrTM3Db3a69eZaa9lloVx3i5IqJ1bzeJJ+f1g5cpTeKOdSes5KxuDp7uW3IM7CQMc2ln3 X-Received: by 10.101.98.17 with SMTP id d17mr10039586pgv.221.1519790361669; Tue, 27 Feb 2018 19:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519790361; cv=none; d=google.com; s=arc-20160816; b=IYZ7TdX3AaQmKRUfSZKkzc6DDiySioxViBFBuE9mJhK1eG7IY0PrvqvUL/9rveJYv9 bGFoU8I6zETy9dUnM/5U7if56ejS1+Tvbeak/keZT+MtLiCKyd/NDLKc1P4bgRpUvE6F 1A8pNuS5oL6GKBZRuAlqfxkk3GDCJQRy2mg9Ft7vtRACnFprdcsPp+EcHcxRzAqGO8ZP vWica0Cxy/gHWP7yFiyvhF4Rsd5CEMofbUmNozdJFnpEptAOcGU3qfcJ7FGetsKMTvVv mqQwDbP/yPqCMazrBWNyKjSdUEU+ryvQZMnjpn/Jpf7fZ071HQdE6stlEIVkPzPvVx/s EdUQ== 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:dkim-signature:arc-authentication-results; bh=CnBAWrPsMy6/oPLDU3/iiTfetB2B2cU6YnCOS/tfJT8=; b=hWe+/7GQTeEMWIT0ZCfOtiyFdNrLk3uDaAtvMuFKwbdkB4LRxDub89Fl5RH1lTMzQw gadd9si3nUbu29/hOGDAdCpI004WzpR5tfMZy5UNpF/8q5j8R1nUQM52gDpz/rAnHbIp ykxuPmpWH8/rq3FRX36BsWnnvCvWGQ1UTofBglwoCzjN3C6LwpEH/ZuuRMnqVHUhO/bQ IKZSgLVEtVOkY3OdUjLPoGj9S8w0TgJpbcGRQZs+rAUH3a9xJaWulthu5Seh4eff2Ziy C4JnlD2YL5dLvAyJUec4qFLrpZ9yYrlT8hNHcdhv8DQRd1Q7OFdAR0k+sQizleYuLC5h GFvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h7zHUAXD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6-v6si541622plp.193.2018.02.27.19.59.07; Tue, 27 Feb 2018 19:59:21 -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; dkim=pass header.i=@linaro.org header.s=google header.b=h7zHUAXD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752029AbeB1D6J (ORCPT + 99 others); Tue, 27 Feb 2018 22:58:09 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38830 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814AbeB1D6G (ORCPT ); Tue, 27 Feb 2018 22:58:06 -0500 Received: by mail-pf0-f193.google.com with SMTP id d26so509733pfn.5 for ; Tue, 27 Feb 2018 19:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CnBAWrPsMy6/oPLDU3/iiTfetB2B2cU6YnCOS/tfJT8=; b=h7zHUAXDuHAlWLwpykzWPz/ygRPjuK7F0BngMHbMl22nGuMAmRgw6bxlodXZZTVvWD CqVezrVF7TEwY8KnGkX5WPIsxx031bBWg53s4Ss+E3vot5fPBcFDqN+CVVUTvyPjoBMA ATI8KiP9f3Bkv0liPg9UjbYj3AIcOmANLMaq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CnBAWrPsMy6/oPLDU3/iiTfetB2B2cU6YnCOS/tfJT8=; b=KdSgpghzhDeLDmWPXS0OAQKpp60dhxOtyPyZXMytKJMXCCCOHGd5+UmIeiqAgEzECk 5vTAdR8uE2GB++dVbSGzhZzX2ZnKr2vvFlKpdYV/XfzplVqgWdjTRSopEqCGOe0dn5W6 /3n1A9E1d9DpcO9NW9acgQE/s18Kpr4Y7XN/1TEkpvZibblqcnk65sdibInxAow+489A 3HZufgqrqLS39MMb5Wf9mjHJrQ6vhB88Q0wNkJ9C/laxO+QG+sIY3YGpjU2JRefPCs+6 kUnqOrYHEBBNSKxjrLlEasQZT82xpJy8BZbdAmWRMlNgGMrewzeuL5MFjqSvAUzJPV0E R+ug== X-Gm-Message-State: APf1xPAtlP/YkY5sZrAk12JTnyYEfFsdqetHv3CekWtVDV6aOX8MHtck /9LltmD2bVOMfHyzAR828LHpiQ== X-Received: by 10.99.153.1 with SMTP id d1mr12934030pge.338.1519790285840; Tue, 27 Feb 2018 19:58:05 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id q17sm739911pgt.7.2018.02.27.19.57.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 19:58:05 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 05/29] arm64: mm: Invalidate both kernel and user ASIDs when performing TLBI Date: Wed, 28 Feb 2018 11:56:27 +0800 Message-Id: <1519790211-16582-6-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> References: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon commit 9b0de864b5bc upstream. 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 Tested-by: Laura Abbott Tested-by: Shanker Donthineni Signed-off-by: Will Deacon Signed-off-by: Alex Shi --- arch/arm64/include/asm/tlbflush.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index deab523..ad6bd8b 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. @@ -42,6 +43,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 * ============== @@ -103,6 +109,7 @@ static inline void flush_tlb_mm(struct mm_struct *mm) dsb(ishst); __tlbi(aside1is, asid); + __tlbi_user(aside1is, asid); dsb(ish); } @@ -113,6 +120,7 @@ static inline void flush_tlb_page(struct vm_area_struct *vma, dsb(ishst); __tlbi(vale1is, addr); + __tlbi_user(vale1is, addr); dsb(ish); } @@ -139,10 +147,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); } @@ -182,6 +193,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); } -- 2.7.4