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
tho...@fjellstrom.ca



Reply via email to