Received: by 10.213.65.68 with SMTP id h4csp238027imn; Mon, 26 Mar 2018 20:23:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELu6bTgkrMQpz4mOPUFXTNZC6I8BwTfYTGjb6lBMSlSqsb1KUF/vQN28rTegQ+dvi93Q2IH6 X-Received: by 10.99.95.142 with SMTP id t136mr9448021pgb.302.1522121010719; Mon, 26 Mar 2018 20:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522121010; cv=none; d=google.com; s=arc-20160816; b=KOG2ut4VW6oC4LLEJh8wThbKVcewtTUZQgPtkTewcYCYLwg9K4VBkKkvEFNaS721mY 43T3LQeflGHAz3+OsDJUUYi87j7/34dCu9iwMeJRP1T/sKP0ZDKaWYMwoBWC0XHxBdXb dkA3IBeHQ+H8+hYErVj+FBC6QN4vtSaRrMCUC8YWaQJ/DD19C2oyTg8kENEpzm5oIHcf w4iKSE3tO3GOQGqdDdrzeO4TLnqsGG/NAxYG9GKIPvKtUswyIE8KGjzPerxooXN2qZIP XM6xk8tyPko1dQ+XUuBSFXcK8OWKade812ygPj/VqhjgCZ28mAuwyyWZDW16E7eIG2i8 k6jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=Xz3h9A2ZlrT6fCIvHZDCOTT4oXXC5C2IWYVfnSBXe0o=; b=mns716pu7zptWTYdjVN6Bzi9sW5riT3F++rOcEBiReEBBNiFVnoeD++XN7TlwwuTDd EONuVpYLw+8K6KJXuLWefSKYMfPaZB2/D+TJW7g5M7RU2mO/zm1eji1R/G4zA7hdlAPX hgpCPKXh/LhAKXd+ILwodLW4YjhLKMwsBTbW6ZFraFMaHHKZMIQEZiSxtn8S9trPfKW7 bGcBVm4mc/Y9EFHq2dhQVxSJPQ9jZJrj7glVro3NxN8F9mld649gYRyXutw1jRO+zBgZ 4pYo/y24OtgW3gHqbPLXmtLsNh76oy94Q9Ymst8HiFFRF9GI0opO36LVxxJRzJdtgpSi LbVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=EFCYPgfD; dkim=pass header.i=@codeaurora.org header.s=default header.b=CSeoUn44; 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 x6-v6si249373pln.708.2018.03.26.20.23.16; Mon, 26 Mar 2018 20:23:30 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=EFCYPgfD; dkim=pass header.i=@codeaurora.org header.s=default header.b=CSeoUn44; 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 S1752283AbeC0DWG (ORCPT + 99 others); Mon, 26 Mar 2018 23:22:06 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:39258 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752218AbeC0DV6 (ORCPT ); Mon, 26 Mar 2018 23:21:58 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7A3D2607B9; 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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 Cc: Thomas Speier , Shanker Donthineni 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); -- Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.