From patchwork Wed Mar 21 21:02:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Elcan X-Patchwork-Id: 10300411 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 DB38E60385 for ; Wed, 21 Mar 2018 21:03:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3B6D2982E for ; Wed, 21 Mar 2018 21:03:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B67FF2985D; Wed, 21 Mar 2018 21:03:32 +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 489FD2982E for ; Wed, 21 Mar 2018 21:03:32 +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=2W0mVsBk9LaQKdFTAccdQpKIgxuyZjMtBFpiuRXVFQU=; b=NX8 Z43oJtNIViofloHr5+4OyTqpCHaRMbC1NkWZvwwkbYETcZbhgfuty6qvDZsyuirPV/ZY4E7JmV/z3 s10ykD6exlHW9Af8k00cQJWa1jLQOKpd6EBQnCwt1UFlbUHCKUesbSRqxBAo0a1qB93FmFAJxuqLQ 1fqvRN+3buDu68X+fRLBtBsFH50+3/nMbeqv8BnrRCrfNeO7I5iFx6nGAUP4tOM9DFhQF+wMWya1T pljfQhwSN6U41yb13XAdfN8ThBLLWiSdjkdIQNgRmeV2OCRmUvrlc07MVTKh/D7aE/TMgMkDSEGTJ WPxJfIZVGvMzEM/gSN9xXlKXy4AwCzQ==; 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 1eyktM-0000A9-JG; Wed, 21 Mar 2018 21:03:28 +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 1eyktB-00006o-2n for linux-arm-kernel@lists.infradead.org; Wed, 21 Mar 2018 21:03:25 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 766AF60F6C; Wed, 21 Mar 2018 21:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521666186; bh=PIUQIaBZuwO4Y1EiVq+j/WQIPS/1JMknTYPTnjZLIHE=; h=From:To:Cc:Subject:Date:From; b=Fn8Z+z9nxcBNKqRqXM59K8ziZhOWtvsO+iSACZgizx1cM+pSwtJzdHWV8/jw4qm5z kntnncYsEyOadRoDX4yC2ntZim+4z5o+mxyxIxctoHc0V6p22IH/qhrmtigZ/cfQ8G bTv38uxMPgkg8iq/Iic+uvb87fQ1v1F1xckLtqy0= 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 40B0F60F5C; Wed, 21 Mar 2018 21:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521666186; bh=PIUQIaBZuwO4Y1EiVq+j/WQIPS/1JMknTYPTnjZLIHE=; h=From:To:Cc:Subject:Date:From; b=Fn8Z+z9nxcBNKqRqXM59K8ziZhOWtvsO+iSACZgizx1cM+pSwtJzdHWV8/jw4qm5z kntnncYsEyOadRoDX4yC2ntZim+4z5o+mxyxIxctoHc0V6p22IH/qhrmtigZ/cfQ8G bTv38uxMPgkg8iq/Iic+uvb87fQ1v1F1xckLtqy0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 40B0F60F5C 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 , linux-kernel@vger.kernel.org Subject: [PATCH] arm64: tlbflush: avoid writing RES0 bits Date: Wed, 21 Mar 2018 17:02:52 -0400 Message-Id: <1521666172-2494-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-20180321_140317_334791_3B004186 X-CRM114-Status: GOOD ( 11.35 ) 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 Bits [47:44] of the TLBI register operand are RES0 for instructions that require a VA, per the ARM ARM spec, so TLBI operations should avoid writing non-zero values to these bits. Signed-off-by: Philip Elcan --- arch/arm64/include/asm/tlbflush.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index 9e82dd7..dbd22a9 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -60,6 +60,9 @@ __tlbi(op, (arg) | USER_ASID_FLAG); \ } while (0) +/* This macro masks out RES0 bits in the TLBI operand */ +#define __TLBI_VADDR(addr) (addr & ~GENMASK_ULL(47, 44)) + /* * TLB Management * ============== @@ -128,7 +131,8 @@ 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 >> 12) | + (ASID(vma->vm_mm) << 48); dsb(ishst); __tlbi(vale1is, addr); @@ -154,8 +158,8 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, return; } - start = asid | (start >> 12); - end = asid | (end >> 12); + start = asid | __TLBI_VADDR(start >> 12); + end = asid | __TLBI_VADDR(end >> 12); dsb(ishst); for (addr = start; addr < end; addr += 1 << (PAGE_SHIFT - 12)) { @@ -185,8 +189,8 @@ static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end return; } - start >>= 12; - end >>= 12; + start = __TLBI_VADDR(start >> 12); + end = __TLBI_VADDR(end >> 12); dsb(ishst); for (addr = start; addr < end; addr += 1 << (PAGE_SHIFT - 12)) @@ -202,7 +206,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 >> 12) | (ASID(mm) << 48); __tlbi(vae1is, addr); __tlbi_user(vae1is, addr);