From patchwork Tue Mar 27 03:21:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Elcan X-Patchwork-Id: 10309157 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 C73B560212 for ; Tue, 27 Mar 2018 03:22:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B838229A6E for ; Tue, 27 Mar 2018 03:22:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACA2D29A70; Tue, 27 Mar 2018 03:22:14 +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 36D4E29A6E for ; Tue, 27 Mar 2018 03:22:14 +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: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:In-Reply-To: References:List-Owner; bh=YuSxUgZdHItvVdcCYxBCPTPhBmVm03FAuU9zU9ZWsj8=; b=PEb c+XjWqAAiDhyNi+YkWgM5xuyAPCPjcjHgwrhbgsTTo351bKOyZzVHKg3scOlT5w+bXLvsnBOBuWPX sox4mO7Iwf/lbeSUCSpm3qFwGJomKokN4zuWbCUe4nl/Rk1fmfS4Q7dfKh+K/8IiJ7yC5OIrQImcI 9+QgGPn4odmMzfH7Ayu+gRHOIXRRiIUdidgCiq2NvXCIyD0dPD7O+SgRaFS7Y6ccph25NjDn+a1Yf f5b7uxnBKzhlbg23+qxxfWt2pJx8I+bsvObd/9RFQLPidXEVn3IhmeIDEbIdu/j1xUn9xOAhV92An 1CLM+ZXFU6Crq/q5nthb+yJd3YJXfcg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0fBb-00033h-3m; Tue, 27 Mar 2018 03:22:11 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0fBX-00031R-W1 for linux-arm-kernel@lists.infradead.org; Tue, 27 Mar 2018 03:22:09 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6BF1360ACA; Tue, 27 Mar 2018 03:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522120917; bh=IChlm5UOpSmKjq6M5p+Ny7pWVF1FLce9GiZpmhzgSZo=; h=From:To:Cc:Subject:Date:From; b=EFCYPgfDjbsxSSoERX8dxoigOzXAXpnM086blKcYpq710wvqLKTFgF1bu0Iea9X+B NVLGJr0npKf2w6Js4qFt18sAhNkde7q641nCTIoF26ZCadqwBtVe0QMHcicgO7AK8l MHOq095dZC/qH/FO5oVol3sUteFVA1yG7fpjow6I= Received: from krakatau.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pelcan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E1D53602FC; Tue, 27 Mar 2018 03:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522120916; bh=IChlm5UOpSmKjq6M5p+Ny7pWVF1FLce9GiZpmhzgSZo=; h=From:To:Cc:Subject:Date:From; b=CSeoUn44+SeDDuczGPiUSGFqo+0EJi0NjTeZ6oiKCWQkgq3KfyyI3oIsYQe1QYomI LGC7lLPUwEGZkJKw5kqTisHZXf7DWK+/6D4PcUIXzMlEJBTqg/GuSNnIGUtwqHIvqS vuXbZV8xefY5NpGl/o9k3RIol2mkADdW7gU9P3js= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E1D53602FC Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pelcan@codeaurora.org From: Philip Elcan To: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , linux-kernel@vger.kernel.org Subject: [PATCH V2] arm64: tlbflush: avoid writing RES0 bits Date: Mon, 26 Mar 2018 23:21:17 -0400 Message-Id: <1522120877-9136-1-git-send-email-pelcan@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180326_202208_066718_AFAD594F X-CRM114-Status: GOOD ( 12.07 ) 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: Thomas Speier , Shanker Donthineni 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 Several of the bits of the TLBI register operand are RES0 per the ARM ARM, so TLBI operations should avoid writing non-zero values to these bits. This patch adds a macro __TLBI_VADDR(addr, asid) that creates the operand register in the correct format and honors the RES0 bits. Signed-off-by: Philip Elcan Acked-by: Robin Murphy Tested-by: Shanker Donthineni --- arch/arm64/include/asm/tlbflush.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index 9e82dd7..b1205e9 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -60,6 +60,15 @@ __tlbi(op, (arg) | USER_ASID_FLAG); \ } while (0) +/* This macro creates a properly formatted VA operand for the TLBI */ +#define __TLBI_VADDR(addr, asid) \ + ({ \ + unsigned long __ta = (addr) >> 12; \ + __ta &= GENMASK_ULL(43, 0); \ + __ta |= (unsigned long)(asid) << 48; \ + __ta; \ + }) + /* * TLB Management * ============== @@ -117,7 +126,7 @@ static inline void flush_tlb_all(void) static inline void flush_tlb_mm(struct mm_struct *mm) { - unsigned long asid = ASID(mm) << 48; + unsigned long asid = __TLBI_VADDR(0, ASID(mm)); dsb(ishst); __tlbi(aside1is, asid); @@ -128,7 +137,7 @@ static inline void flush_tlb_mm(struct mm_struct *mm) static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr) { - unsigned long addr = uaddr >> 12 | (ASID(vma->vm_mm) << 48); + unsigned long addr = __TLBI_VADDR(uaddr, ASID(vma->vm_mm)); dsb(ishst); __tlbi(vale1is, addr); @@ -154,8 +163,8 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, return; } - start = asid | (start >> 12); - end = asid | (end >> 12); + start = __TLBI_VADDR(start, asid); + end = __TLBI_VADDR(end, asid); dsb(ishst); for (addr = start; addr < end; addr += 1 << (PAGE_SHIFT - 12)) { @@ -185,8 +194,8 @@ static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end return; } - start >>= 12; - end >>= 12; + start = __TLBI_VADDR(start, 0); + end = __TLBI_VADDR(end, 0); dsb(ishst); for (addr = start; addr < end; addr += 1 << (PAGE_SHIFT - 12)) @@ -202,7 +211,7 @@ static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end static inline void __flush_tlb_pgtable(struct mm_struct *mm, unsigned long uaddr) { - unsigned long addr = uaddr >> 12 | (ASID(mm) << 48); + unsigned long addr = __TLBI_VADDR(uaddr, ASID(mm)); __tlbi(vae1is, addr); __tlbi_user(vae1is, addr);