Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4982290imm; Tue, 18 Sep 2018 02:21:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaxPos9jER95YUR6LLvsK2+vqJNKxGzM6/oEGlTrSDKN9sOb9xFu6Oild8NfA+e4HNtUec3 X-Received: by 2002:a17:902:6689:: with SMTP id e9-v6mr28675657plk.115.1537262480647; Tue, 18 Sep 2018 02:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537262480; cv=none; d=google.com; s=arc-20160816; b=MXJTUeWDo3VOACiymT1Y+Fabye8oYUHhkWTBnW6kVAgG8gF+PzOz/k/vjGsPqIAFR0 1WbIbH9V2zdhv7/Q/+OY8vfGmp5Tl3JDjeTZZsQMgJDY9cIlkYjfbM1t5DSAU/1fb6At A5N+ghVssKzY7K2leX0was21bHrmzeuANV46ogBIAfIzhRhD2zG85Gwj7hFaXZ+PKO/M 1Y6nhCMagBAhTzDbxvWpSyr3duDSeW4Etide1UKZhpdlX5bkJWC6yFWXlEHWKeBXmkoL Q5BXEgSJonMLtvdRbAwkaKorbCf7Ykul39vBUP1JizgdVSAM7TN7v4rmroX5DE02JRok BK2g== 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=roj45tEvUVN4qUy6E9mxcf8Pwg6mZtoT0ZP9T7SqAhNKEnEM5mDh0m5uWg+L//E7u3 4tNfNFHEAD5xHuVIns8KrjKU30VlKfYiOSNMwqVlHAA40wygNuqXPLhiuCAZobnv84h7 fvTatNWkOrjnfpGg6nrdWCt/zfSAsq5jKOy5WfIwBZkCYQfwESscOsrCaicO3Ghc+mq5 pqStrLhvTLrGZR+IgYoy5onhEhccMHjnY6VWPL6s9cdpvVJlelmTu4MKz6FkQLD6DOkC R16BGzOB9l/Jool6kUUgR2+Fkfp4wdbTopElFvVULw1QJTW+syXvdECcrSn2EFBdrO0f D70Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Lnj+GEf9; 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 s126-v6si19235961pfc.222.2018.09.18.02.21.05; Tue, 18 Sep 2018 02:21:20 -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=Lnj+GEf9; 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 S1729631AbeIROwm (ORCPT + 99 others); Tue, 18 Sep 2018 10:52:42 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36145 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727757AbeIROwl (ORCPT ); Tue, 18 Sep 2018 10:52:41 -0400 Received: by mail-pf1-f193.google.com with SMTP id b11-v6so727076pfo.3 for ; Tue, 18 Sep 2018 02:20:57 -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=Lnj+GEf9yzZasOKq2IBmSzWeKh+3usnJKw+W6pOgBMnTym8yNxDDX5M98mftWqMotP MJzpXVP8z3QVr1YDlpgLnwTTGblNfxj/m5Aiuwyj0oxlOEUogZNs9QlXVJ2zlUyh0tlI PuPF6i7Dda0C8DWxotLXbKpMmwjGr1+1DenInFQK7EFycQzmh4DSSx/+L+bh7T63TOw1 o757FDzKcWffl7hEFRL16v9dnsJDCuzyW4e9PoECh7CZfBy6txaMIS+cD2j/zzhXl8RP Uj2fyTo+b5wRZI0vXfH+GTMpBWuZvta53ov+lepFKIQ0deDTSnxpIxDKu+PSeSnhz9Oy KhpA== 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=aSI7tDOUNJhgsR20VXCALILq6eikTMVxITEgpiCk+M3Fe8VgTNkVbwMml/H0jxJ+uk DK29P++EhQa5UWbC23du3BpTedeXHL+1qnkjdSMEVt4z/vCwIWouZpm7pqbxXVvNs7GQ BAIfyy9uElioOL1qt0HT3sQkELr8DFBpk17aAVAQZrNbkuakuD1uoHV4E4UOe4/NRAK7 usm6cRx55vBIWvXI7oShxs9qx5278Rxc13axqQJzN6dbbYAaceHhYj4kwXyU+Z+cpaey hlIsez2ZJWEyt8MZ1Lw+oeGWhf33OzuCNGIii1q/69n6TIi1f+sdMJ0VxLuhzgb/aUgl D7uQ== X-Gm-Message-State: APzg51CLHOHB2jaHF7ruJNkEJfocwBiqbePs2BjX3PBzvRXvXPP+3GtD iFK6huOE4L2+eog1UmpnqmQ= X-Received: by 2002:a63:931b:: with SMTP id b27-v6mr27020099pge.143.1537262457428; Tue, 18 Sep 2018 02:20:57 -0700 (PDT) Received: from app09.andestech.com ([118.163.51.199]) by smtp.gmail.com with ESMTPSA id 1-v6sm29932877pfm.145.2018.09.18.02.20.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Sep 2018 02:20:56 -0700 (PDT) From: Zong Li To: palmer@sifive.com, aou@eecs.berkeley.edu Cc: vincentc@andestech.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, zong@andestech.com Subject: [PATCH 5/5] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap Date: Tue, 18 Sep 2018 17:19:17 +0800 Message-Id: <9fc325660fb1e0ef9133705f7c05784dcc12c0c2.1537260207.git.zongbox@gmail.com> 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