As I created myself VFIO-MDEV driver/virtual device, the next steps I can think are:
1) make virtual machine can access real hardware through this VFIO-MDEV driver.
2) hardware/VFIO-MDEV driver can access the buffer in virtual machine. Because many HW will write/read data from buffer/memory. If we vituralize a HW and provide its virtual device to the virtual machine, we will need this feature.
So this blog will introduce:
1) How does virtual machine access HW(VFIO-MDEV virtual device's) registers.
2) How does VFIO-MDEV driver access virtual machine's buffer/memory.
1. How does virtual machine access HW registers.
On host VFIO-MDEV driver:
Firstly I fixed a bug on virtual device's PCI configure space. That is the PCI device class. Last time I set it to 0x0. This will cause pci_enable_device() error. So I modified it to 0xFF(misc device).