Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] mtd: fix oops when writing to phram device on arm64
@ 2019-09-22  6:37 Huaijie Yi
  0 siblings, 0 replies; only message in thread
From: Huaijie Yi @ 2019-09-22  6:37 UTC (permalink / raw)
  To: joern, dwmw2, computersforpeace, marek.vasut, richard.weinberger,
	vigneshr, richard
  Cc: yihuaijie, linux-mtd

From: yihuaijie <yihuaijie@huawei.com>

memcpy() to memory remaped by ioremap() at an address not aligned
to 8-bytes will cause oops on arm64 platform, fixing this by using
ioremap_wc().

e.g.
writing through jffs2 on a phram device cause following error:

Unable to handle kernel paging request at virtual address ffffff800f93700c
pgd = ffffffc00385c000
[ffffff800f93700c] *pgd=0000000000000000, *pud=0000000000000000
Internal error: Oops: 96000061 [#1] PREEMPT SMP
task: ffffffc003549b10 task.stack: ffffffc0b8bc8000
PC is at __memcpy+0xc0/0x180
LR is at phram_write+0x5c/0x78 [phram]
pc : [<ffffff8008484740>] lr : [<ffffff8000d731a4>] pstate: 80000005
sp : ffffffc0b8bcb8c0
x29: ffffffc0b8bcb8c0 x28: 000000000093700c
x27: 0000000000000001 x26: 0000000000000000
x25: 0000000000000001 x24: 0000000000000000
x23: ffffffc5b6db8480 x22: ffffffc0b8bcb990
x21: ffffff800f000000 x20: 000000000093700c
x19: 0000000000000044 x18: 000000000000000a
x17: 0000000000000c00 x16: 0000000000000400
x15: 000000000001e125 x14: 34347830203a6e65
x13: 6c202c6330303733 x12: 397830203a726464
x11: 61202c3030303030 x10: 3066303038666666
x9 : 6666667830203a56 x8 : 0000000298f7fb1d
x7 : 00000044e0021985 x6 : ffffff800f93700c
x5 : 0000000000000000 x4 : 0000000000000000
x3 : ffffff8008cbe018 x2 : ffffffffffffffc4
x1 : ffffffc5b6db8490 x0 : ffffff800f93700c

Signed-off-by: Huaijie Yi <yihuaijie@huawei.com>
---
v1->v2:
fix this only on ARM64 arch.

 drivers/mtd/devices/phram.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index c467286..89ca8bb 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -98,7 +98,11 @@ static int register_device(char *name, phys_addr_t start, size_t len)
 		goto out0;
 
 	ret = -EIO;
+#ifdef CONFIG_ARM64
+	new->mtd.priv = ioremap_wc(start, len);
+#else
 	new->mtd.priv = ioremap(start, len);
+#endif
 	if (!new->mtd.priv) {
 		pr_err("ioremap failed\n");
 		goto out1;
-- 
1.8.5.6



______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-22  6:37 [PATCH v2] mtd: fix oops when writing to phram device on arm64 Huaijie Yi

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org linux-mtd@archiver.kernel.org
	public-inbox-index linux-mtd

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/ public-inbox