Subject: Re: RFC: virtio-hostmem (+ Continuation of discussion from [virtio-dev] Memory sharing device)
> > â The host does not back the region at all and a page fault happens. > > Then what? Guest dies? > That doesn't sound reasonable, in particular if you want to > allow userspace to map this memory. In our implementation we call mmap after asking the host to back the region. https://photos.app.goo.gl/NJvPBvvFS3S3n9mn6 Nothing prevents a guest to call mmap on an unbacked region, then the guest will die. If it is possible for the device to figure out if an address range is backed in VM, the guest driver could talk to the device to fail an mmap call if a region is not accessible. > > â The host has already allocated host RAM (from some source; vkMapMemory, > > malloc(), mmap, etc) memory of some kind and maps a page-aligned host > > pointer to the guest physical address corresponding to the region. > > I'm not sure what does "of some kind" mean here. Memory from any API call that could be used for access through this address range. > Also host and guest might have different ideas about > what does page-aligned mean. In our implementation we do aligning (for VM operations) and unaligning in the guest userspace (because mmap is page aligned) to get the pointer to handle pointers in the middle of a page (we have no control on pointers returned from a third party API). Regards, Roman.