Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp468267imm; Wed, 26 Sep 2018 01:34:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV63yII7iVC0PgAzEY3uNXlUJxpaYA7W51j7mPwLnyySl8U0pq3xWJnbGCVIfj8hSeu+Uhnfe X-Received: by 2002:a62:2c53:: with SMTP id s80-v6mr5064771pfs.154.1537950894926; Wed, 26 Sep 2018 01:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537950894; cv=none; d=google.com; s=arc-20160816; b=ZBc4Fisx2WoO7+FYl5vXlqQ2uCpyiU1wio8EHxVG8GM6G3rYkl+Cu8p8AHtSFsEE00 PXQpBoDgccPhClvKpsDkIH9aAuOtblT0y/JQiehtjPmKwWB86ibN8ydtvKLb1Iw2IWeF DOSo+8aOUz2cctmoyJWYjhmgibyX5828mR8sxkMHqBP1XNY/d/S6upeKqHwGt09O5rXd l9BZ26zCsdcXXn27MXh5+GBc34jklB0UdURtGdoQp2itFTgiA/JAo1X5/L0Ey6Ig+NTR 1EUAs7mN4RDFkvBGdEeNBt5JmSdaf0CdKRD6EIlbP7Tt6GfLCT8TAhdKBcR14pEo/GR0 jSbw== 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=HPMwK7iIRyZFAhkD3YHNuZ3Q8bDJZrSD3GxDaItPCa6XEtUZqI3Nmi/Wt4aNNCmU1A /i+J1xKoVvbZG3yASoxupZvLy3PU3NM1CBNEUciAf574HEAak3TxzSO6VzbADfE1U6l/ KNfUQGAigL5agSuvYlwsP/7xBB6dCN80WZJDrmbpCvUlVIXkhVmCu6OCK17WGCNRtz0Y RsprnoMIxCBvZREyc3Uj6EDQ7aTyXpt7kLrwBdTI5YnjytvJytlBY/a/gvSqLSgONaWC 8ZVXtdHefdF4PemGLbH6sZgYmNZautToxY0K28w/n53JrFf9Ue0++8jxHBeQYZ94wORk I4ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nlpQoW6g; 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 l12-v6si4732832plc.332.2018.09.26.01.34.39; Wed, 26 Sep 2018 01:34:54 -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=nlpQoW6g; 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 S1727328AbeIZOo4 (ORCPT + 99 others); Wed, 26 Sep 2018 10:44:56 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45303 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727244AbeIZOoz (ORCPT ); Wed, 26 Sep 2018 10:44:55 -0400 Received: by mail-pf1-f193.google.com with SMTP id a23-v6so5412851pfi.12 for ; Wed, 26 Sep 2018 01:33:07 -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=nlpQoW6gTNn0ZvJ6d3TtBZiUM/dTyRg/qvqxtod61+lEcMu9xu3ryWfBe0YHMB2RJa 3e0arhfbXSga29nBn5n4iAzoWkJiSTAI8yJGbLHp8THp0Tzs9S12z1ndhxXrGbBaRtoi OTtNLwvTftEWq1SB3fM450H0BnLUw9WKbs+oit5cHFcl/UBHZBTQwWzMql6NaS/yIGDC Sf7doqUJ/uR8LWqTqzBPmVdVbpVNngzn7k5Z5nWcgPxQKaunWeenhwlakMALH4E2Wrm7 AxebaQHcOH/NgxOGnszKorbRPJFaKe3Wb/z53p/ehs3ZbQyZvOZPhHGj4BIlP2ceTj6U 4Vxw== 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=t3Gi1Kz5wN77iEhgEzO8nMoVEBbO91MvqFbfoaR2jsrlWiHx1LGpg0Khx8o1PwgD8A 2ttIo1PueuqT742/97ioH8RtZ1EjV+5JtI/8/+D60d/lrtj6qLhhnjf1MRP6AAjGtTKc FnwauS+lxmzjjp4dc7U2STCARQyOogWG3uEQxfRswfkVto5OJRwt27aKdxdhIdBBV0sO wmCuz45Do1VSsX/rBd+TQ1m8HLC6jgdb/0TO6IqhAx0LlTTUun3Aq0/LXSlRdpEM/xAP EU84fmgLH780/KwOHrzWy1wHhcwLxodCiDAiHE/30LYfR7Rop8R9OQiqPFI9MC9pGyVe dgUQ== X-Gm-Message-State: ABuFfohSxXqNT+1+Tk04gEvjLUn5ksb7rzrtTFhvLN87gkKpyWpbgzpW HpBM65IKNkhfC2X+hTKQmXA= X-Received: by 2002:a63:1566:: with SMTP id 38-v6mr4621863pgv.383.1537950786910; Wed, 26 Sep 2018 01:33:06 -0700 (PDT) Received: from app09.andestech.com ([118.163.51.199]) by smtp.gmail.com with ESMTPSA id f15-v6sm5530764pgv.66.2018.09.26.01.33.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Sep 2018 01:33:06 -0700 (PDT) From: Zong Li To: palmer@sifive.com, aou@eecs.berkeley.edu Cc: hch@infradead.org, zong@andestech.com, vincentc@andestech.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap Date: Wed, 26 Sep 2018 16:31:14 +0800 Message-Id: <341d3a765c0078280eb99d49559b5f9a27b93fe4.1537949825.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