Trapping memory-accesses to a specific region

Trapping memory-accesses to a specific region

Hi Folks,

I have this requirement that i should be supporting a new hardware IP that does not exists in Intel Chipset. I know that the application running on my Linux OS will access this hardware IP thru some Memory-mapped address.

One way to fulfil my requirement is to simulate this hardware IP and 'hook-up' this IP to the Linux process-space memory-map. To do so, i need some virtualization concept wherein i can register a region in the process-space and any access to this space should be trapped and routed to my simulated Hardware IP.

Can someone point me to relavant links/doc?

Thanks and Regards,

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

A comment I received on your question:

"If the IP is in hardware / FPGA and the IP has a PCI/PCIe interface, then the system BIOS/OS will take care of it.

If the IP is in software such as SystemC (for example), they should be able to use a concept such as GreenSoc (see the link at where the SystemC IP can be used in mixed HW/SW simulation. This works with QEMU but I am sure with some innovation can be made to work with Xen/VBox if they have access to the hypervisor code."

David Ott

Another comment:

"One simple way to do this is as follows:

Lets say this MMIO address of this HW is 0x80000000 on the host. This is the HPA. If the access to this 0x80000000 is hardcoded in the guest as physical address, then the VMM can trap any access to 0x80000000 0x80000000+size and do appropriate handling on it by the HW simulator. Keep in mind that access to 0x80000000 is GPA. In the guest, the user can map to a GVA using ioremap, just make sure GVA is mapped to hardcoded GPA (0x80000000).

The trick is make sure dont provide any GPA to HPA mapping of this memory range make sure there is no RAM memory using this address. When there no mapping, access to this memory range will get trapped into the hypervisor."

David Ott

Hi David,

Thanks a ton for the answers. It in indeed informative. I have a couple of more question.

1. I am new to this work of virtualization and VMM. Does Xen/VBox provide hooks to the users to trap accesses to speficied region?
2. Can you please point me to relevant document?

Thanks and Regards,

Hi Nizam,

For info on Xen/VBox, you'll need to look at their documentation for authoritative answers.

For Intel virtualization documentation, the go-to place would be the Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3B: System Programming Guide, Part 2. Link below:

David Ott

Leave a Comment

Please sign in to add a comment. Not a member? Join today