Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1064412imm; Tue, 2 Oct 2018 01:59:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV60kmhD3kZLEefnCpkpR7yfkTe63tJOhPTLuHslPwWyOw6aKs8OaoQiHDjcKwIpO7mniWLHC X-Received: by 2002:a63:66c3:: with SMTP id a186-v6mr13669491pgc.330.1538470795758; Tue, 02 Oct 2018 01:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538470795; cv=none; d=google.com; s=arc-20160816; b=Kuu/ndlmiS0T6KwMJI6j/TCEMWZTs4qY3jVQ0pBzpsUOpNF2a6XO1ymN6g5Np3qxit 9bM3uXjxRkgenc0CjXEMutiKM5YCCWV3IcvFuZutJvjc1yDVp14k7XwBgEC1vAa15VoV +zcVbBxesEBrb3RzG/3IY02uqrcXYJ+rNLLZ6UnZz4px26v6/81b/wcbThKtNuHdql6b CNx3e9idVS9kHlVNwV4m9gDmVGHXR0IxNNti/cLUSenNIqU6N2arPqDlCksiPDa/ipTn 8z+5hWxPW8Kd5lUjwUvSETRF1ekfOiP/w/zIcXbpH95dngettd5yoxNeHj72F/N0+IVA H8wA== 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=yBDu2O0W/mBPNUJyp/8RDB7ziXVKlZQi5gxmGZfu7g4oHFoBNRAvQ3i3ffMlUZImzE UrybBfabhSS+xQUKe+X6heb1/kQGFg4areCX4h552dtQO2yIw4AudoAgjpzc4zOwfpLX dG3dzRdxguuqVTvfq0jAM80WDzKT3A01i2RqUAjXAYsaHGRSpxaB0z8P0ESrGT0HQW7V JY/S0qGKL683UF2VFfX6/gDIYeVy+zRnqe3KRe72rExrbiXaKy6FEQQuTmqKsRHf90Da CEpSkSBcRoEih5mL7bYTgioOmGH1WNKVMrW75n09Tof0CgjInsdJv1DpB+JB7e0TK+Uv lifA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DbFrjbMm; 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 l4-v6si12061775plb.181.2018.10.02.01.59.41; Tue, 02 Oct 2018 01:59:55 -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=DbFrjbMm; 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 S1727432AbeJBPlo (ORCPT + 99 others); Tue, 2 Oct 2018 11:41:44 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40888 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeJBPln (ORCPT ); Tue, 2 Oct 2018 11:41:43 -0400 Received: by mail-pl1-f196.google.com with SMTP id 1-v6so656146plv.7 for ; Tue, 02 Oct 2018 01:59:31 -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=DbFrjbMmT4p0bJUM3+yKMpB1AeTWcf1ftcYv0Uuc06JmbhA3RekiXD2VLDFJiIXp/M OncOHk6jrhOSoprYufsQt0DnfcVOYzbKDDbl7Z+LTNYS8QBTTsaCzzBtAXgMEtu2p0rw 2/llz50TH7rKF58z0jjXR5kgZPJVQWzRhVtEZUlGC4ZZP/3BkFJEVg8xitwOoo55RXbL tj/3RXzmm0yO79n5Ighwn/2/yOvjNm2uHMK3sKhBX35T9wSdB0AfLFQCrpAAJTtmWQxO P7kIR+KApXgiAfeXl6YsXFB3rmHH9VV2Stxm9sYFfQCPsga9XpldN0xVTLqQDlN8VAFJ YSaQ== 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=sExwtVPRdsANc4DR/SGn0j9Ad2wKArciHDhUtvGq1n2mfXQO7/lzhRfYh7X4xzS+RM ru7+qUbZ2ETAGWsdO4JsuyRelfjeE2+Ngad6RbhDUgQRF0jIKN4Oab50LvI1uW9WtjeD QpfmNDO9CA94VaDL7l36qajlfSaOn/4KxfxSiLXrjKg2EfNtU5DV99WtFoBHK4Is1kl7 d26uSOxXjgjmwOil9KTxuz+h+EtdG54p9lh36S/nQwIzzpv4Ug94cupMDc09aeyJ23CS BrEtK3KxjdwXlzgkkY5X7fgJTd1lOccpvwdpnCxPImSf98a/X5EuopgmqgghoLCsIi5X VorQ== X-Gm-Message-State: ABuFfohj1yXljbvNYTZ1+w5P4SI8GoXuEwP3L/JJDKOZtBDaeWSi29dG WrH0AG41Kc9Do9nqY5o6uTE= X-Received: by 2002:a17:902:b611:: with SMTP id b17-v6mr15707352pls.217.1538470771131; Tue, 02 Oct 2018 01:59:31 -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 62-v6sm5057927pgc.58.2018.10.02.01.59.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 01:59:30 -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 v3 5/5] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap Date: Tue, 2 Oct 2018 16:52:31 +0800 Message-Id: <54849b9d9a709525640011814872155eafa7a9d7.1538470103.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