Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2062029imm; Tue, 2 Oct 2018 20:13:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV61u3ElVEyfuzmP1Xi8orhPrnOA9kLPvoOgpECPV0qFKf7CwVRP615YkhPtrcPh0ojGZ3DJN X-Received: by 2002:a63:c54a:: with SMTP id g10-v6mr16766091pgd.201.1538536398659; Tue, 02 Oct 2018 20:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538536398; cv=none; d=google.com; s=arc-20160816; b=lu0JOoqE4tBu4eOQSHgfU9aLRhP2s4RNcdsIKVhhgO48MOxFytqOyPh1MWlX3AWubg mWm0479KNylLUMtr1KaZn4CxWkKEUy0BEM2tyvulcXthRCIO5n5tSQck/hNBgm9tOtt+ 8tW9FzTIj0HFiJnEpWsAdvIr08ABBEIT2G8vZebZ8VnA5+ArfsAaLp3QZmV/U5lHvemd egmq/BGFWlnV44N+wCjLT6IbhH1xktXZdMOY+Kt73DY6bwE5Z/h9VYGA2AkyU06SDLyp wcNGu3Igrdel5ZYKjDjRAWY0nd6/LocXymC4jrV8TxjR2qGFeJ7wMiFB5D2hchliHuID pzlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=UBDvynMlQ+CLa//vjhI1FniisjjUmkbIGiogOAJ0pDw=; b=HZanNKyJR/KJzWNYTfY6fgsgWFBlRyDIp3P8HS6jqwSiblG63UWAx7t4gjQtlWufXk CnWenNAnrnkWl2Y3xk9NLFPvElmzHfq/kuNn0ADLjs2XQulg9rsGp3+bzSuloJb66kn6 K5z3AOpJV6xE3m0hEv7AmCTC17ZBfsu2Uckh6IkAfTolytznJx9lROQ5o4bVtO6yo5S8 FMb7OPw3kl7gYopXYPMytqbkGacMBpcH8hVlkMtSgmfU6HtS/qBqwJo5y1RlSe6EfoKs FrrxWBxQ7M4wlD2dztuho/EYSfzpV5VyU5wTmHWLVWhW4bCdTiegMQEtS7TKjPXrDGEL LM4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=llJyOIKc; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12-v6si6601389pls.367.2018.10.02.20.13.03; Tue, 02 Oct 2018 20:13:18 -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=@gmail.com header.s=20161025 header.b=llJyOIKc; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbeJCJ7R (ORCPT + 99 others); Wed, 3 Oct 2018 05:59:17 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36191 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbeJCJ7P (ORCPT ); Wed, 3 Oct 2018 05:59:15 -0400 Received: by mail-pg1-f196.google.com with SMTP id f18-v6so880750pgv.3 for ; Tue, 02 Oct 2018 20:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UBDvynMlQ+CLa//vjhI1FniisjjUmkbIGiogOAJ0pDw=; b=llJyOIKcGT/3qJR9GzkclSLGh2c3cN4qwf+z2v31BO4vntlAGTBeojgVAUS6o8eIDm b4EIanPvZAB6xVNlJPmMFdICb9zRQqF23MM4otJ9jvdk6AcbOJemtwevF1X3UGPkkuvq wwFqegteig4g2rFsbbLaBOWzTeaJtIui8AoH7tn56H0YAU4LaWXtDb8J8heE6j9mTO7B ZFR9XZuphFa4dO3YhAPAAJqT5w9fUvW6gJZGkS4A/E5YmFBuk4hNCDzkidp68NMwcB3e iE7hxRzObyQo1jQtbLGsQPAvdEjv4d0V8lBuaUdqA4sVxOtM8H2p7U/28q0D4Pcvr1cv zLtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UBDvynMlQ+CLa//vjhI1FniisjjUmkbIGiogOAJ0pDw=; b=rWRRpJXVioKM2T04la7v7Qpgfg0WStF6YFwBUGe8LCWh3DKd7im090JlYIoJFEQBad 1mRKRRNNT+9J1GhRxa/+jqwQeC8BVwbkTQXM7+PbgnYtNk1w24psxpg7fZZVqmkfoS+9 UMrBwyvX9Y/OT+117CQZ8jyv0p/d0h9yVXc1n+P/CV5cMRZWuQab8WjkigO8GCWg0P3d vpF3MDQT91vx8ogF18tBTcEbjq6sW2AO3zIYmGmr8Qg1OvMaNxcuzL3v5c7+wlU2OrTd mXnqiLz84LK15HkHmjNHRQd/OL42TYVz+YiPbGpS6VTmpL53+pl6ZtNFZqWfIiKptxmZ aDvw== X-Gm-Message-State: ABuFfohZP3xm5+49ga/wr9vNeb/quI8s9NeG1gHQ9L3yN7AZeEsukJXV TJuA1qTu0NU6MjomX/Hvibg= X-Received: by 2002:a63:1411:: with SMTP id u17-v6mr16880911pgl.247.1538536368856; Tue, 02 Oct 2018 20:12:48 -0700 (PDT) Received: from app09.andestech.com (59-120-53-16.HINET-IP.hinet.net. [59.120.53.16]) by smtp.gmail.com with ESMTPSA id v23-v6sm21777747pfm.80.2018.10.02.20.12.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 20:12:48 -0700 (PDT) From: Zong Li To: palmer@sifive.com, aou@eecs.berkeley.edu Cc: hch@infradead.org, zong@andestech.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Vincent Chen Subject: [PATCH v4 5/5] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap Date: Wed, 3 Oct 2018 11:10:02 +0800 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Chen 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 --- 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 70ef272..bd2f2db 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.7.4