Re: [PATCH] net: tun: fix tun_xdp_one() for IFF_TUN mode
From: David Woodhouse <dwmw2@infradead.org>
Date: 2021-06-22 07:28:56
Attachments
- smime.p7s [application/x-pkcs7-signature] 5174 bytes
From: David Woodhouse <dwmw2@infradead.org>
Date: 2021-06-22 07:28:56
On Tue, 2021-06-22 at 12:34 +0800, Jason Wang wrote:
quoted
Secondly, I need to pull numbers out of my posterior for the VHOST_SET_MEM_TABLE call. This works for x86_64: vmem->nregions = 1; vmem->regions[0].guest_phys_addr = 4096; vmem->regions[0].memory_size = 0x7fffffffe000; vmem->regions[0].userspace_addr = 4096; if (ioctl(vpninfo->vhost_fd, VHOST_SET_MEM_TABLE, vmem) < 0) { Is there a way to bypass that and just unconditionally set a 1:1 mapping of *all* userspace address space?Memory Table is one of the basic abstraction of the vhost. Basically, you only need to map the userspace buffers. This is how DPDK virtio-user PMD did. Vhost will validate the addresses through access_ok() during VHOST_SET_MEM_TABLE. The range of all usersapce space seems architecture specific, I'm not sure if it's worth to bother.
The buffers are just malloc'd. I just need a full 1:1 mapping of all "guest" memory to userspace addresses, and was trying to avoid having to map them on demand *just* because I don't know the full range of possible addresses that malloc will return, in advance. I'm tempted to add a new feature for that 1:1 access, with no ->umem or ->iotlb at all. And then I can use it as a key to know that the XDP bugs are fixed too :)