From: slash.tmp@free.fr (Mason)
To: linux-arm-kernel@lists.infradead.org
Subject: Unhandled fault: page domain fault (0x81b) at 0x00e41008
Date: Wed, 27 Jan 2016 11:36:51 +0100 [thread overview]
Message-ID: <56A89DC3.8010309@free.fr> (raw)
In-Reply-To: <56A4D13D.3030906@free.fr>
On 24/01/2016 14:27, Mason wrote:
> Our "software stack" provides the kernel API under discussion:
>
> {read,write}_data{8,16,32}
>
> These 6 functions must be implemented, because they are part
> of the API we provide to customers. As the "page domain fault"
> underscores, my own implementation is incorrect. I am grateful
> for the implementation you suggested up-thread, and will test
> its performance on Monday.
For the record, I've now changed the implementation as follows.
I'll benchmark performance as soon as I fix the other bug in
the module.
#define DEFINE_BLOCK_READ(N) \
static int read##N(void __user *dest, void *buf, void __iomem *io, size_t len) \
{ \
size_t i; u##N *temp = buf; \
for (i = 0; i < len; i += N/8) temp[i] = RD##N(io + i); \
return copy_to_user(dest, temp, len) ? -EFAULT : 0; \
}
#define RD8 readb_relaxed
#define RD16 readw_relaxed
#define RD32 readl_relaxed
DEFINE_BLOCK_READ(8)
DEFINE_BLOCK_READ(16)
DEFINE_BLOCK_READ(32)
#define DEFINE_BLOCK_WRITE(N) \
static int write##N(void __user *src, void *buf, void __iomem *io, size_t len) \
{ \
size_t i; u##N *temp = buf; \
if (copy_from_user(temp, src, len)) return -EFAULT; \
for (i = 0; i < len; i += N/8) WR##N(temp[i], io + i); \
return 0; \
}
#define WR8 writeb_relaxed
#define WR16 writew_relaxed
#define WR32 writel_relaxed
DEFINE_BLOCK_WRITE(8)
DEFINE_BLOCK_WRITE(16)
DEFINE_BLOCK_WRITE(32)
#define TILE_SIZE (16u << 10)
typedef int fun_t(void __user *ua, void *buf, void __iomem *io, size_t len);
static int block_copy(void __user *ua, phys_addr_t pa, size_t bytes, fun_t *fun)
{
int err = 0;
size_t pos = 0;
void *buf = kmalloc(TILE_SIZE, GFP_KERNEL);
if (buf == NULL) err = -ENOMEM;
while (pos < bytes && !err)
{
size_t tile = min(bytes-pos, TILE_SIZE);
void __iomem *va = ioremap(pa + pos, tile);
err = va ? fun(ua + pos, buf, va, tile) : -EFAULT;
iounmap(va);
pos += tile;
}
kfree(buf);
return err;
}
and then the ioctl dispatcher calls e.g.
block_copy(user_addr, phys_addr, count*4, read32);
IIUC, Arnd mentioned that there might be an issue using readl_relaxed
on a memory region with a big-endian kernel.
The access_ok() macro could be hoisted out of the inner functions,
into block_copy() => that would save about 350 bytes. (I'm not sure
it is worth it.)
text data bss dec hex filename
18111 188 15036 33335 8237 kllad.o
text data bss dec hex filename
17759 188 15036 32983 80d7 kllad.o
Regards.
next prev parent reply other threads:[~2016-01-27 10:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-22 17:37 Unhandled fault: page domain fault (0x81b) at 0x00e41008 Mason
2016-01-22 17:48 ` Russell King - ARM Linux
2016-01-22 18:59 ` Mason
2016-01-22 19:34 ` Russell King - ARM Linux
2016-01-22 23:15 ` Mason
2016-01-22 23:57 ` Russell King - ARM Linux
2016-01-23 11:14 ` Mason
2016-01-23 11:34 ` Russell King - ARM Linux
2016-01-23 20:53 ` Mason
2016-01-23 22:46 ` Mason
2016-01-23 23:59 ` Russell King - ARM Linux
2016-01-24 13:27 ` Mason
2016-01-27 10:36 ` Mason [this message]
2016-01-27 10:48 ` Russell King - ARM Linux
2016-01-27 12:04 ` Mason
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=56A89DC3.8010309@free.fr \
--to=slash.tmp@free.fr \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.