Factory and control pages

The QNX hypervisor shared memory implementation uses factory pages and control pages.

Factory and control pages store the shmem vdev's virtual registers (see Virtual registers (guest_shm.h) in this chapter). A driver in the guest can access these registers in guest-physical memory, and interract with them as it would physical registers, reading from and writing to them at specified offsets.

Factory and control pages are the same size as a QNX hypervisor kernel page (4 KB).

Factory pages

Including shmem vdevs in the qvm configuration for the VM hosting a guest (see Configuring the VMs) causes the qvm process to create a factory page for the VM. Typically, there is only one shmem vdev per qvm configuration file, hence one factory page per VM.

A factory page contains information about the shared memory, including a field with the guest-physical address for each shared memory region's control page. This field changes value as the guest creates or attaches to different shared memory regions.

A factory page may be located anywhere in unallocated memory that the guest can access. For example, assuming no other memory has been allocated yet, if we allocated 192 MB of RAM (ram 192M set in the qvm configuration), we can place the factory page outside this allocated RAM at 0x10000000 (256 MB). This address is a guest-physical address, not an actual physical address in hardware. The shmem vdev virtualizes the factory page for the guest. No other device may use this location.

When an application in the guest attempts to create a shared memory region, it describes the shared memory region it needs to the hypervisor by writing to the shmem vdev's registers in the factory page. The hypervisor uses the factory page to create the new shared memory region and its control page, updating the shmem vdev's registers.

Registers are described in the data types defined in the <qvm/guest_shm.h> header file (see Virtual registers (guest_shm.h) in this chapter).

Control pages

A shared memory control page contains registers to which shmem vdev client applications can write to manage their relationship with a shared memory region and its other users (e.g., inform other users of a change to the contents of the region, detach from the region).

The first request from a guest for a new shared memory region sets up the requested shared memory region, plus a control page for that region. Every shared memory region has its own control page that prefixes the shared memory region; there are as many control pages as there are shared memory regions.

After a guest creates a shared memory region or attaches to it, the guest uses a field on the system page to locate the region's control page. When guests need to communicate with other guests, they write to the control page.

Figure 1. A factory page with its pointer to the control page for a shared memory region.

The diagram above illustrates how a VM's factory page points to a control page that is prefixed to a shared memory region.

For more information, see Configuring the VMs in this chapter.