Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp256077ybd; Tue, 25 Jun 2019 20:52:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLUMF8xoG+fyhP4AbnPKUpcSlxUdPljkl/g0+2EcCLzRhVsW6VoGrUUJfhoBOjOvMqCTPb X-Received: by 2002:a63:5656:: with SMTP id g22mr650667pgm.280.1561521131104; Tue, 25 Jun 2019 20:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561521131; cv=none; d=google.com; s=arc-20160816; b=So/ygInhjhZ25KMd98nPw6Vxsl90q9swWyd2Opd8g2CEOnS2qJidsQK+8WlqEGgwP1 MyScNynZ+RHNjDGZK86BrIifJwUJJ19n8A+BJFiTTZBaEOQZmY3pvdPL9zovEDG7sOK4 XNn/EowooDgQEmk8TYrqZWNZow+aWua1JUTBcggOtXW/NwBwNMuGhjjjF6zbQmyjWFYX 3oS36ZVvB5UkRP7njQlGtFkfuhhFaYcnfPw5KJwjkUSylpKrdg2Iwq85Hjci1qp0pwVR oxR9crQ4TOs6vYQhMLrwZGmpSDsFTE/OR8l5vyuSIa4KP7Y8oO/EsaIkwimFf9CCVguM 49zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NtoSoQnbUkHgaQeLhzjbBhnVMFES+BmGaTx8BtmjK4U=; b=zPwFtAbfg5B13nUBgW971egwO639Lq6Y9aMm0Th1WngTxcLwzy85uwo3qR3Kn2H7mM aoWebqieKoKd0zbiaFsHkIQ9tYh/H8hDCOknaaS52T/KWdneOdFJGOt1B/8Wybh6T7fs lQj+izl0mqEEJmDcPUCChFnJE4Crx64S+rPpJ8NOPSBmN1p1BBRFbUyqFoh/7Oq9haEE VDKMTf0RHvC0HUNOpVUa/GSXaVyUMugUpBcXzihtpT7wefipqAfdNpgXVgNKkGAR2Y/d SXbeNOAQI4jqPVtJfg1cPPik84Zr9ukGA+92rqaKtpruhywNwJBl8b+aM0iDfEGP0OV+ 881Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PGZxK0IO; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k71si798495pjb.83.2019.06.25.20.51.55; Tue, 25 Jun 2019 20:52:11 -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=@kernel.org header.s=default header.b=PGZxK0IO; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727365AbfFZDt5 (ORCPT + 99 others); Tue, 25 Jun 2019 23:49:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:54552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727295AbfFZDnW (ORCPT ); Tue, 25 Jun 2019 23:43:22 -0400 Received: from sasha-vm.mshome.net (mobile-107-77-172-74.mobile.att.net [107.77.172.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D0AE5205ED; Wed, 26 Jun 2019 03:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561520601; bh=d1+WP5N9McYnrs0TI4Boiqy40Gwh4H9/yG46Qc8deqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PGZxK0IOaJfeGa5/cSdz/f2gI0S2nEtobBSg0reAmrdxbY3h93libLk2Ok8znyK/i +LXSbnJHi4UfJPyM2aQ57BFzUX/RPY1wEoSD5eGeFqcThO3pAFj4n6NqY69FCTtAle cybtqBbF7Ag/82ONOUdLuvVG4UwKhSy3pq/K2CF8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Will Deacon , Catalin Marinas , Peter Zijlstra , Hanjun Guo , Sasha Levin Subject: [PATCH AUTOSEL 5.1 45/51] arm64: tlbflush: Ensure start/end of address range are aligned to stride Date: Tue, 25 Jun 2019 23:41:01 -0400 Message-Id: <20190626034117.23247-45-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626034117.23247-1-sashal@kernel.org> References: <20190626034117.23247-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon [ Upstream commit 01d57485fcdb9f9101a10a18e32d5f8b023cab86 ] Since commit 3d65b6bbc01e ("arm64: tlbi: Set MAX_TLBI_OPS to PTRS_PER_PTE"), we resort to per-ASID invalidation when attempting to perform more than PTRS_PER_PTE invalidation instructions in a single call to __flush_tlb_range(). Whilst this is beneficial, the mmu_gather code does not ensure that the end address of the range is rounded-up to the stride when freeing intermediate page tables in pXX_free_tlb(), which defeats our range checking. Align the bounds passed into __flush_tlb_range(). Cc: Catalin Marinas Cc: Peter Zijlstra Reported-by: Hanjun Guo Tested-by: Hanjun Guo Reviewed-by: Hanjun Guo Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/include/asm/tlbflush.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index 3a1870228946..dff8f9ea5754 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -195,6 +195,9 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, unsigned long asid = ASID(vma->vm_mm); unsigned long addr; + start = round_down(start, stride); + end = round_up(end, stride); + if ((end - start) >= (MAX_TLBI_OPS * stride)) { flush_tlb_mm(vma->vm_mm); return; -- 2.20.1