From: wubian <wubian@uniontech.com>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, wubian <wubian@uniontech.com>
Subject: [PATCH] uio: Fix bus error that access memory mapped by physical
Date: Wed, 23 Jun 2021 14:52:14 +0800 [thread overview]
Message-ID: <20210623065214.4525-1-wubian@uniontech.com> (raw)
On the arm64, register the uio driver and map a physical space
on the pci device to user space, then use memset write data to
the address space, a bus error will occur. This error is due to
the dc instruction(cache operation) used in the assembly of memset,
uio mapping physical memory will call pgprot_noncached() to set
non-cached and non-buffered, while pgprot_writecombine() has fewer
restrictions. It does not prohibit write buffer, so replacing
pgprot_noncached() with pgprot_writecombine() can solve this problem.
Signed-off-by: wubian <wubian@uniontech.com>
---
drivers/uio/uio.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index ea96e319c8a0..09b04b20fa30 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -739,7 +739,11 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
vma->vm_ops = &uio_physical_vm_ops;
if (idev->info->mem[mi].memtype == UIO_MEM_PHYS)
+#if defined(CONFIG_ARM64)
+ vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+#else
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+#endif
/*
* We cannot use the vm_iomap_memory() helper here,
--
2.20.1
next reply other threads:[~2021-06-23 6:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 6:52 wubian [this message]
2021-06-23 7:14 ` [PATCH] uio: Fix bus error that access memory mapped by physical Greg KH
2021-06-23 8:49 ` wubian
2021-06-23 9:25 ` Greg KH
2021-06-23 12:32 ` wubian
2021-06-24 8:26 ` Will Deacon
2021-06-24 9:48 ` wubian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210623065214.4525-1-wubian@uniontech.com \
--to=wubian@uniontech.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).