Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp733723ybc; Sat, 16 Nov 2019 07:46:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyq27iLxZnJ+66ai5kTpT0acR7dv0Yvgrg/YKQ59QHLR426NQoi9AtoKOeE/xsYnS0TK+pe X-Received: by 2002:a17:906:c7d5:: with SMTP id dc21mr10730503ejb.267.1573919163839; Sat, 16 Nov 2019 07:46:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573919163; cv=none; d=google.com; s=arc-20160816; b=DQ1+zmPMi1YMaIEawo8+GgGIWjMCs0WJLO/1OQpnZoCfrCPoVNiTfvyQG1ae8CtrHx Kfi9eb0Krfw9EPS0y75lbEVaOi0v3b8P1MFWulEp8Yib/tDvFYq0YMPp1AsiTYf4qQCt fVOukHbbzRUzKS4wLRijOQAmZ1KltYgOyGxq3EWIemydWwt5BLYa/rlzvS1t04w9acUt 5Cup8r5Yloc5tanU0nG6tGlGB0T1GVhlqnzIQ9MEhmVb3gk9aIM26RucKwFdhRAwXLHl 17VvetEoBqn5CLhpG3mpaur8trBSivSUsVJ3Xu03QtVP9v0bhbTHpKHaMacTqE4xgOJH dxhA== 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=iTXCQ6ixbTmtSw7ZMsaFu7dBuR6bfW2zvO9T7Bg21KU=; b=so3s6X5OK+DG83N9U8ZoZSfw6VFuhOJ9j+LrFqFa+9rX8nVe7xMYEay/7vHRx1ilPw 9yGssD1pIMBqrwm9sPbDic9Cb6Dr0M7rO4ybQAgANbVrbPjKqk7AYVQd/6DjAvswfY5K PS3APcPtzqunkLwKhKgNf49TmUobomLY0ypVnxdBlBpzsgKEj0lR/zlRjUVgpCtGSy08 JPO2UhnL4lMMk/zvnX5h3uFoxs5gOb1cGhG4ZLovwNS5avVvBZg4vQk2HhlaBGC5I4JS +pdrBJCVrO8Ry4eyEdYXnoPNXxUj1d7+vHy3ajVP5hkd5pPxwbpxZj9lsnWCMaxb9q9y W12Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qq2UlGPn; 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 i19si8154022edy.125.2019.11.16.07.45.38; Sat, 16 Nov 2019 07:46:03 -0800 (PST) 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=Qq2UlGPn; 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 S1728704AbfKPPnX (ORCPT + 99 others); Sat, 16 Nov 2019 10:43:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:47246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728684AbfKPPnT (ORCPT ); Sat, 16 Nov 2019 10:43:19 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (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 26ECA2073B; Sat, 16 Nov 2019 15:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918999; bh=+Gp/Ucoi8x7JyealqIPzKeZooLRZaL/FpBDtaJX4OzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qq2UlGPneYgu563krDdGtZvoOdMTOECvjhmcRFXVfYtcnyON6YiLoJq9r4Rwt3nWm XWnKGG7UIR5DS9FN3PpuBXfyjNnOkbjVnfFpL1U+ve8Y6guvi4psmAftZ3f8FgRBXp r5uK2eKUJ8oNmK+1If44RyDIL9rUTqJf+GXiXjb4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vincent Chen , Christoph Hellwig , Palmer Dabbelt , Sasha Levin , linux-riscv@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 102/237] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap Date: Sat, 16 Nov 2019 10:38:57 -0500 Message-Id: <20191116154113.7417-102-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-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: Vincent Chen [ Upstream commit 827a438156e4c423b6875a092e272933952a2910 ] For 32bit, the upper 32-bit of phys_addr_t will be flushed to zero after AND with PAGE_MASK because the data type of PAGE_MASK is unsigned long. To fix this problem, the page alignment is done by subtracting the page offset instead of AND with PAGE_MASK. Signed-off-by: Vincent Chen Reviewed-by: Christoph Hellwig Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- arch/riscv/mm/ioremap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/mm/ioremap.c b/arch/riscv/mm/ioremap.c index 70ef2724cdf61..bd2f2db557cc5 100644 --- a/arch/riscv/mm/ioremap.c +++ b/arch/riscv/mm/ioremap.c @@ -42,7 +42,7 @@ static void __iomem *__ioremap_caller(phys_addr_t addr, size_t size, /* Page-align mappings */ offset = addr & (~PAGE_MASK); - addr &= PAGE_MASK; + addr -= offset; size = PAGE_ALIGN(size + offset); area = get_vm_area_caller(size, VM_IOREMAP, caller); -- 2.20.1