I'm less confident now that caching-related page table flags will be an issue, at least on x86; IIUC both Intel VT-x and AMD SVM effectively take the least caching specified by both guest page tables and EPT/NPT respectively, and I think KVM should configure memory type in EPT/NPT consistently with host page tables. The major known problem is mmap of /dev/nvidia-uvm, as described by the third paragraph of
section "Unified Virtual Memory (UVM)"; in short, /dev/nvidia-uvm must be mapped into the sentry at specific addresses, which might conflict with existing mappings in the sentry.
How much of a problem this is is unclear. Apps might in practice consistently map /dev/nvidia-uvm at a fixed address that happens not to conflict with any existing sentry mappings, in which case simply enabling nvproxy and nvidia-uvm mmap on platform/kvm might just work. I think this could be attempted fairly easily:
- Change
https://github.com/google/gvisor/blob/30c58b6a6bbdf9c6fa7759fa1b54cd96145940c9/pkg/sentry/platform/kvm/kvm.go#L70 to platform.DoesNotOwnPageTables
- Change
https://github.com/google/gvisor/blob/30c58b6a6bbdf9c6fa7759fa1b54cd96145940c9/pkg/sentry/devices/nvproxy/uvm_mmap.go#L80 to use fsutil.PreciseHostFileMapper, as in
https://github.com/google/gvisor/blob/30c58b6a6bbdf9c6fa7759fa1b54cd96145940c9/pkg/sentry/devices/tpuproxy/vfio/pci_device_fd_mmap.go#L78- Change
https://github.com/google/gvisor/blob/30c58b6a6bbdf9c6fa7759fa1b54cd96145940c9/pkg/sentry/fsutil/precise_host_file_mapper.go#L189 to pass address hint fr.Start (instead of 0) and pass flag MAP_FIXED_NOREPLACE (in addition to MAP_SHARED)
If you do try this, please let us know how it goes. If apps instead consistently map /dev/nvidia-uvm at a fixed address that *does* conflict with sentry mappings, it might still be possible to work around the issue by messing around with build flags to place runsc executable mappings at specific (non-conflicting) addresses, but I have little experience with this.