I'm developing my own bare-metal hypervisor over intel vt-x technology.
My goal is to make it inaccessible to the OS I'm running over my hypervisor in any way, therefore I configured an EPT table to protect from memory access. I believe that now I'm missing protection from devices with DMA access.
I would like to know how do I prevent from all PCI devices access to my hypervisor memory area? Code examples would be perfect for me.
BTW: I test my project using QEMU environment if it's might affect the answer.
EPT limits access from CPU only, so you are right: you are missing protection from DMA accesses.
In order to operate IOMMU, you should search the ACPI. Look for a structure with signature
DMAR
(Intel VT-d) orIVRS
(AMD-Vi).You will be configuring a page table that has almost the same structure to long mode page tables.
Therefore, in addition to specifications of Intel VT-d and AMD-Vi, you should also read ACPI specification about how to look up ACPI tables.
Note that Intel VT-d is not tied with Intel VT-x, nor was AMD-Vi tied with AMD-V.
You can find Intel VT-d specification in Intel's website: https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html
You can find AMD-Vi specification in AMD's website: https://developer.amd.com/resources/developer-guides-manuals/
You can find ACPI specification in UEFI Forum's website: https://uefi.org/specifications