linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Methods to intercept accesses to mmaped page from userspace, or pretend to be mmio range
@ 2018-04-10 14:12 Thomas Fjellstrom
  0 siblings, 0 replies; only message in thread
From: Thomas Fjellstrom @ 2018-04-10 14:12 UTC (permalink / raw)
  To: linux-kernel

Hi,

I'm working on a little driver that wants to pretend to be a section of mmio so it can intercept accesses, or intercept accesses to a page after it's been mmaped in by a user space program. So far I haven't found a method that works.

I had been trying to allocate a page, and in the fault handler try and mark the page as readonly, and attempt to check for that in the next fault but as soon as the page is accessed its just assigned now, and there's no more faults (obviously). Other methods include trying ptrace but that seems not accessible from kernel modules, and inserting a uprobe on the instruction after the current one in the fault handler so I can remark the page as readonly but that requires some "clever" platform specific code to parse instructions which I'd prefer not to have to do. I don't really care about intercepting reads, but it might be something I care about at some point. At the very least I'd like to trap all writes, do some magic and then let the access proceede (or emulate it). I looked at providing my own pci bus and device, but I'm not sure that'd actually work.

For some background, I'm trying to emulate the /dev/gpiomem char device from the raspberry pi that lets userspace programs mmap in the gpio registers on the bcm283x SoC.

Is there any way to do what I want to do in a kernel module?

Thanks,

-- 
Thomas Fjellstrom
thomas@fjellstrom.ca

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

only message in thread, other threads:[~2018-04-10 14:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10 14:12 Methods to intercept accesses to mmaped page from userspace, or pretend to be mmio range Thomas Fjellstrom

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).