libvhost-user: return the backend mapping address for SET_MEM_TABLE
PATCH v2 1/1 libvhost-user: return the backend mapping address for SET_MEM_TABLE
During postcopy, the vhost-user backend ought to return the base address at which they mapped regions during SET_MEM_TABLE and ADD_MEM_REG calls [0]. This was done properly for ADD_MEM_REG, but not for SET_MEM_TABLE, so any frontend that was relying on that call would not work.
The bug appeared in d288eef3a0a8, which, to silence the address-of-packed-member warning, created a local copy of vhost message. That's fine for reading the table, but for postcopy, we also write into it to send the base addresses back, and after d288eef3a0a8 we ended up writing into the copy.
This bug was affecting ADD_MEM_REG and SET_MEM_TABLE alike, until 905e8c7e260d fixed the ADD_MEM_REG path by copying back the memory into the payload.
This commit fixes the SET_MEM_TABLE path by doing exactly that: copying back the memory table into the payload.
QEMU wasn't affected as it uses ADD_MEM_REG, but any combination of a frontend that uses SET_MEM_TABLE and libvhost-user backend is.
---
Changes in v2:
- Reword the commit message to better explain the original bug
- Link to v1: https://lists.nongnu.org/archive/html/qemu-devel/2026-11/msg02840.html
--- subprojects/libvhost-user/libvhost-user.c | 1 + 1 file changed, 1 insertion(+)
subprojects/libvhost-user/libvhost-user.c +1 -0
@@ -1119,6 +1119,7 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)if (dev->postcopy_listening) {/* Send the message back to qemu with the addresses filled in */ + vmsg->payload.memory = m; vmsg->fd_num =0 ;if (!vu_send_reply (dev, dev->sock, vmsg)) {vu_panic (dev,"failed to respond to set-mem-table for postcopy" );
---
base-commit: 144393da8d4bd307a22525c7feea2bb29a0a7556
change-id: 20261109-setmemtable-fix-d9841f2d0eb7
Best regards,
Signature · 1 line
Simon Lucido <[email protected]>
Quoted 25 lines · Simon Lucido
During postcopy, the vhost-user backend ought to return the base address at which they mapped regions during
SET_MEM_TABLEandADD_MEM_REGcalls [0]. This was done properly forADD_MEM_REG, but not forSET_MEM_TABLE, so any frontend that was relying on that call would not work.The bug appeared in
d288eef3a0a8, which, to silence the address-of-packed-member warning, created a local copy of vhost message. That's fine for reading the table, but for postcopy, we also write into it to send the base addresses back, and afterd288eef3a0a8we ended up writing into the copy.This bug was affecting
ADD_MEM_REGandSET_MEM_TABLEalike, until905e8c7e260dfixed theADD_MEM_REGpath by copying back the memory into the payload.This commit fixes the
SET_MEM_TABLEpath by doing exactly that: copying back the memory table into the payload.QEMU wasn't affected as it uses
ADD_MEM_REG, but any combination of a frontend that usesSET_MEM_TABLEand libvhost-user backend is.Fixes d288eef3a0a8 ("libvhost-user: fix -Waddress-of-packed-member")Signed-off-by Simon Lucido <[email protected]>
Quoted 7 lines
---
Changes in v2:
- Reword the commit message to better explain the original bug
- Link to v1: https://lists.nongnu.org/archive/html/qemu-devel/2026-11/msg02840.html
---subprojects/libvhost-user/libvhost-user.c| 1 +1 file changed, 1 insertion(+)