[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 04/21] hw/xen: Publish backend features before setting state to InitWait



On 24/11/2026 16:22, David Woodhouse wrote:
From: David Woodhouse <dwmw@xxxxxxxxxxxx>

The XenbusStateInitWait transition tells the frontend that the
backend's parameters are readable, but xen_device_realize() set it
before calling the implementation's realize method — which is what
writes the feature nodes ('max-ring-page-order' et al. for xen-block,
'feature-rx-copy' for xen-net).

Linux blkfront reads 'max-ring-page-order' with xenbus_read_unsigned():
no wait, no retry, default 0. Lose the race and it silently negotiates
a single-page ring — 32 request slots instead of 256. A device
hot-plugged into a running guest loses essentially every time; at boot
the frontend doesn't come looking until long after realize finished.
Netfront reads its feature nodes the same way.

Commit 240cc11369fc ("hw/xen: Avoid crash when backend watch fires too
early") introduced this by moving the realize call after the block of
code which both populates the initial xenstore nodes *and* sets
InitWait. The crash it fixed was real — xen-block's realize processes
watch events via blkconf_geometry()'s aio_poll(), and the handlers fell
over when the nodes didn't yet exist — but only the node population
needed to come first.

So keep the node population and the 'online' write before realize, and
move only the InitWait transition after it. A watch event during
realize now finds the frontend in Initialising and no backend 'state'
node, which the handlers tolerate; none of the three realize
implementations reads the backend state. Verified against the original
2023 crash reproducer as well as the ring-order negotiation.

Fixes: 240cc11369fc ("hw/xen: Avoid crash when backend watch fires too early")
Reported-by: Mark Syms <mark.syms@xxxxxxxxxx>
Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
---
  hw/xen/xen-bus.c | 16 +++++++++++++++-
  1 file changed, 15 insertions(+), 1 deletion(-)

Reviewed-by: Paul Durrant <paul@xxxxxxx>



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.