From patchwork Wed Feb 28 03:56:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10246719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF0AE60594 for ; Wed, 28 Feb 2018 04:01:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB9C28980 for ; Wed, 28 Feb 2018 04:01:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B462828CBA; Wed, 28 Feb 2018 04:01:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 36F8028CB3 for ; Wed, 28 Feb 2018 04:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zi/YLf6rcfLYx4BrT0rjuMf1ZpYmSmUbL3afhCk17+o=; b=lzBmtsOOPnk9H1wOQrxzPOqj21 5A8sZe0YTU9BqDZbcColsbibeICgzS7duTCzwvb2YVde8ub3jwqIkA51nIH7wrja0EVz2GcogB4IN dJhsFY2i2ATYeXgK4dLVOjfKE01MwEvKNwaG+y4voKD7wytmE87+KdLcl3xEXw8mmOmevpmUBAZTo BHeWsYu9vU31WABIFrkagt+Rwj4Ef7stE09MEPm9qNvKvQPxtgqDYiCiL09IivgnR2OvbuU8nCASn vfojfy1xJ+AQ3d2YVJk6MYDncf5NLsrfxUk3dIU3f4U8CxXFdppV7DZ9WsNYqlA6krJS/Vew1uBDp c+/IPtwA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqsvI-0001M8-5d; Wed, 28 Feb 2018 04:00:56 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqssi-0006pi-L9 for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2018 03:58:19 +0000 Received: by mail-pf0-x241.google.com with SMTP id u5so507366pfh.6 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=WkrMHQ6AzZnCEy2QnQ86JftlomUL9tEe17/h5d4bcX3ASWWaNcxiLb7W7oL5OB6vMC tvKBj5J3PWkuJ2CwTdiEGMvG4BNd/dMhVDUUy3SBXgHGnBepmGCs9dSkH7j5IfW5yJFK 2HthyCqiFG2TX7MjJ1Imy+Dj+De4Rj3g7nKCFtegOB++xgx9tEb/8ga9rkGw/camHWiO TSZbe7yPuwU/PjRpv7G+xaSlrlDnIyJkQBxF9o9QVp1qhO3kT6fnZj7vEPvz0cBIY+Hz 5kWztGI1HtnlPZm1KkEvS4sSaEoOy63ZNBfi8xC1y82lS2cZBy5IPFbfcYOXIO7uA+cE l2MA== X-Gm-Message-State: APf1xPDcyq6JF03hXP01c4XIAE2LxzA2Q4UBtOb8pcSVY/fCdzEDTwpL 9bH/pyQreMhen02+nrH7B4MXeoBq+4k= X-Google-Smtp-Source: AH8x227F1dSnjXMRA88Vt6JAODMuHBKSWux92ZhhgqDd0QuvLKDWH6wRr2fjgQo1KtKzALsca7cb6w== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_195816_924883_7C60B57B X-CRM114-Status: GOOD ( 13.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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); }