Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5990126ybc; Wed, 27 Nov 2019 13:01:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxa6UUPvceXbLKByiBtUp8HP3QFxNQL1I080ErFVhoOvLx3Cj4qowIga1vUNCDE0pmYEJ5e X-Received: by 2002:a17:906:4e94:: with SMTP id v20mr52046824eju.34.1574888480338; Wed, 27 Nov 2019 13:01:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888480; cv=none; d=google.com; s=arc-20160816; b=zQk8P8vyPbb2OXzbyXPGRM8zwy9WGls6fT8Nhd2VcwfdQufCi4jDP+5upLA0R7QMMY V2gvppn1eMN1HwgeeG/HK+Tbw8+RAHa621g86xQXKJ79fMoq/Xc0GDSSBV8K8TboUZf6 ZqvyX6abbaAsotSwLoTiLaoKRPzdnVWa9AiQ1RRIzN+hloapTUJwL5rtrtAF962yZIZq 64zZKWiJMAkNiBPhgM1c/MzouBnp1+9jjE8nWhKh0QWVDNiCN2xVX/JUhyJTqdJV/y0S 4iYph2d4TXfgKOmajikWNRY78AsrHzcwyWKk2wMSswwmf1KOQCO+h0zrqEPYkw9Q1DCn SbqQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iTXCQ6ixbTmtSw7ZMsaFu7dBuR6bfW2zvO9T7Bg21KU=; b=AX/1LxiXVl36sxciz93dMdfNdmFXc9REKU/EqAO9YwX3XSbgnpLFcPTsqrU8v/cBF9 1tL+g3iUrZDXLCyZtp4iBxATTkKIm4d0CIBFQNbmX73qwivwqBkYPDHJk8imY9nLq2yj PmSQjsluayuAIYwbs3bNQcskZVPDUS7YDTcszilMAGbVNjKO0iCib4DqQybPWoDa5O7y oICDasU0BYYnMKbjDGgco6LSFBLhIgHKAdI2FJ//WwXh+mCf66lHNuJoF3glOjXqYLEw UP1NigAc2k3J3fzO4lTS4DQma2sGZ1HouxTwGLIbdT0ej/1EVZm/Vnq1NSq8HnWBkHaw VRZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Eq7iZmcM; 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 g21si201375ejr.195.2019.11.27.13.00.56; Wed, 27 Nov 2019 13:01:20 -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=Eq7iZmcM; 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 S1731515AbfK0VAF (ORCPT + 99 others); Wed, 27 Nov 2019 16:00:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:51750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731493AbfK0VAC (ORCPT ); Wed, 27 Nov 2019 16:00:02 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D7AD32086A; Wed, 27 Nov 2019 21:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888402; bh=+Gp/Ucoi8x7JyealqIPzKeZooLRZaL/FpBDtaJX4OzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eq7iZmcMHPwmVU56V/gdGJYlUshziTcApAwNoyZZJXu+DVCuveDUdU/pKyif/UTIl btMtfypj3/THEuANPRxZvJRWDAcc+ldgu43itSbvUKurHSuTgcapAZZQpkfyz83m9E RdFa5G32bhO6502bthXpH+xJWY2XFom12HDn+3oY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Chen , Christoph Hellwig , Palmer Dabbelt , Sasha Levin Subject: [PATCH 4.19 120/306] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap Date: Wed, 27 Nov 2019 21:29:30 +0100 Message-Id: <20191127203123.912390742@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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