[PATCH v2 08/27] hw/xen: Create initial XenStore nodes

2023-03-07 Thread David Woodhouse
From: Paul Durrant Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_xenstore.c | 70 ++ 1 file changed, 70 insertions(+) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index

[PATCH v2 03/27] hw/xen: Implement XenStore watches

2023-03-07 Thread David Woodhouse
From: David Woodhouse Starts out fairly simple: a hash table of watches based on the path. Except there can be multiple watches on the same path, so the watch ends up being a simple linked list, and the head of that list is in the hash table. Which makes removal a bit of a PITA but it's n

[PATCH v2 13/27] hw/xen: Add xenstore operations to allow redirection to internal emulation

2023-03-07 Thread David Woodhouse
From: Paul Durrant Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- accel/xen/xen-all.c | 11 +- hw/char/xen_console.c | 2 +- hw/i386/kvm/xen_xenstore.c | 3 - hw/i386/kvm/xenstore_impl.h | 8

[PATCH v2 14/27] hw/xen: Move xenstore_store_pv_console_info to xen_console.c

2023-03-07 Thread David Woodhouse
From: David Woodhouse There's no need for this to be in the Xen accel code, and as we want to use the Xen console support with KVM-emulated Xen we'll want to have a platform-agnostic version of it. Make it use GString to build up the path while we're at it. Signed-off-by:

[PATCH v2 02/27] hw/xen: Add basic XenStore tree walk and write/read/directory support

2023-03-07 Thread David Woodhouse
From: David Woodhouse This is a fairly simple implementation of a copy-on-write tree. The node walk function starts off at the root, with 'inplace == true'. If it ever encounters a node with a refcount greater than one (including the root node), then that node is shared with other

[PATCH v2 00/27] Enable PV backends with Xen/KVM emulation

2023-03-07 Thread David Woodhouse
). • Disable migration for emulated XenStore device. • Update docs and add MAINTAINERS entry. v1: https://lore.kernel.org/qemu-devel/20230302153435.1170111-1-dw...@infradead.org/ https://git.infradead.org/users/dwmw2/qemu.git/shortlog/refs/heads/xenfv-1 David Woodhouse (23): hw/xen: A

[PATCH v2 27/27] docs: Update Xen-on-KVM documentation for PV disk support

2023-03-07 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- docs/system/i386/xen.rst | 30 +++--- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/system/i386/xen.rst b/docs/system/i386/xen.rst index a00523b492..f06765e88c

[PATCH v2 12/27] hw/xen: Add foreignmem operations to allow redirection to internal emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/char/xen_console.c| 8 +++--- hw/display/xenfb.c | 20 +++--- hw/xen/xen-operations.c | 45 include/hw/xen/xen_backend_ops.h | 26

[PATCH v2 17/27] hw/xen: Build PV backend drivers for CONFIG_XEN_BUS

2023-03-07 Thread David Woodhouse
From: David Woodhouse Now that we have the redirectable Xen backend operations we can build the PV backends even without the Xen libraries. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/9pfs/meson.build| 2 +- hw/block/dataplane/meson.build | 2 +- hw/block

[PATCH v2 21/27] hw/xen: Add emulated implementation of grant table operations

2023-03-07 Thread David Woodhouse
From: David Woodhouse This is limited to mapping a single grant at a time, because under Xen the pages are mapped *contiguously* into qemu's address space, and that's very hard to do when those pages actually come from anonymous mappings in qemu in the first place. Eventually perh

[PATCH v2 26/27] MAINTAINERS: Add entry for Xen on KVM emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 5340de0515..640deb2895 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -443,6 +443,15 @@ F: target/i386/kvm

[PATCH v2 23/27] hw/xen: Map guest XENSTORE_PFN grant in emulated Xenstore

2023-03-07 Thread David Woodhouse
From: David Woodhouse We don't actually access the guest's page through the grant, because this isn't real Xen, and we can just use the page we gave it in the first place. Map the grant anyway, mostly for cosmetic purposes so it *looks* like it's in use in the guest-visible

[PATCH v2 06/27] hw/xen: Implement XenStore permissions

2023-03-07 Thread David Woodhouse
From: Paul Durrant Store perms as a GList of strings, check permissions. Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_xenstore.c | 2 +- hw/i386/kvm/xenstore_impl.c | 259 +--- hw/i386/kvm

[PATCH v2 20/27] hw/xen: Hook up emulated implementation for event channel operations

2023-03-07 Thread David Woodhouse
From: David Woodhouse We provided the backend-facing evtchn functions very early on as part of the core Xen platform support, since things like timers and xenstore need to use them. By what may or may not be an astonishing coincidence, those functions just *happen* all to have exactly the right

[PATCH v2 09/27] hw/xen: Add evtchn operations to allow redirection to internal emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse The existing implementation calling into the real libxenevtchn moves to a new file hw/xen/xen-operations.c, and is called via a function table which in a subsequent commit will also be able to invoke the emulated event channel support. Signed-off-by: David Woodhouse

[PATCH v2 15/27] hw/xen: Use XEN_PAGE_SIZE in PV backend drivers

2023-03-07 Thread David Woodhouse
From: David Woodhouse XC_PAGE_SIZE comes from the actual Xen libraries, while XEN_PAGE_SIZE is provided by QEMU itself in xen_backend_ops.h. For backends which may be built for emulation mode, use the latter. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/block/dataplane/xen

[PATCH v2 07/27] hw/xen: Implement core serialize/deserialize methods for xenstore_impl

2023-03-07 Thread David Woodhouse
From: David Woodhouse This implements the basic migration support in the back end, with unit tests that give additional confidence in the node-counting already in the tree. However, the existing PV back ends like xen-disk don't support migration yet. They will reset the ring and fa

[PATCH v2 04/27] hw/xen: Implement XenStore transactions

2023-03-07 Thread David Woodhouse
From: David Woodhouse Given that the whole thing supported copy on write from the beginning, transactions end up being fairly simple. On starting a transaction, just take a ref of the existing root; swap it back in on a successful commit. The main tree has a transaction ID too, and we keep a

[PATCH v2 11/27] hw/xen: Pass grant ref to gnttab unmap operation

2023-03-07 Thread David Woodhouse
From: David Woodhouse The previous commit introduced redirectable gnttab operations fairly much like-for-like, with the exception of the extra arguments to the ->open() call which were always NULL/0 anyway. This *changes* the arguments to the ->unmap() operation to include the origin

[PATCH v2 10/27] hw/xen: Add gnttab operations to allow redirection to internal emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse Move the existing code using libxengnttab to xen-operations.c and allow the operations to be redirected so that we can add emulation of grant table mapping for backend drivers. In emulation, mapping more than one grant ref to be virtually contiguous would be fairly

[PATCH v2 22/27] hw/xen: Add emulated implementation of XenStore operations

2023-03-07 Thread David Woodhouse
From: David Woodhouse Now that we have an internal implementation of XenStore, we can populate the xenstore_backend_ops to allow PV backends to talk to it. Watches can't be processed with immediate callbacks because that would call back into XenBus code recursively. Defer them to a QEMUBH

[PATCH v2 16/27] hw/xen: Rename xen_common.h to xen_native.h

2023-03-07 Thread David Woodhouse
From: David Woodhouse This header is now only for native Xen code, not PV backends that may be used in Xen emulation. Since the toolstack libraries may depend on the specific version of Xen headers that they pull in (and will set the __XEN_TOOLS__ macro to enable internal definitions that they

[PATCH v2 05/27] hw/xen: Watches on XenStore transactions

2023-03-07 Thread David Woodhouse
From: David Woodhouse Firing watches on the nodes that still exist is relatively easy; just walk the tree and look at the nodes with refcount of one. Firing watches on *deleted* nodes is more fun. We add 'modified_in_tx' and 'deleted_in_tx' flags to each node. Nodes with t

[PULL 05/27] hw/xen: Watches on XenStore transactions

2023-03-07 Thread David Woodhouse
From: David Woodhouse Firing watches on the nodes that still exist is relatively easy; just walk the tree and look at the nodes with refcount of one. Firing watches on *deleted* nodes is more fun. We add 'modified_in_tx' and 'deleted_in_tx' flags to each node. Nodes with t

[PULL 17/27] hw/xen: Build PV backend drivers for CONFIG_XEN_BUS

2023-03-07 Thread David Woodhouse
From: David Woodhouse Now that we have the redirectable Xen backend operations we can build the PV backends even without the Xen libraries. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/9pfs/meson.build| 2 +- hw/block/dataplane/meson.build | 2 +- hw/block

[PULL 03/27] hw/xen: Implement XenStore watches

2023-03-07 Thread David Woodhouse
From: David Woodhouse Starts out fairly simple: a hash table of watches based on the path. Except there can be multiple watches on the same path, so the watch ends up being a simple linked list, and the head of that list is in the hash table. Which makes removal a bit of a PITA but it's n

[PULL 22/27] hw/xen: Add emulated implementation of XenStore operations

2023-03-07 Thread David Woodhouse
From: David Woodhouse Now that we have an internal implementation of XenStore, we can populate the xenstore_backend_ops to allow PV backends to talk to it. Watches can't be processed with immediate callbacks because that would call back into XenBus code recursively. Defer them to a QEMUBH

[PULL 19/27] hw/xen: Only advertise ring-page-order for xen-block if gnttab supports it

2023-03-07 Thread David Woodhouse
From: David Woodhouse Whem emulating Xen, multi-page grants are distinctly non-trivial and we have elected not to support them for the time being. Don't advertise them to the guest. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/block/xen-block.c | 11 --- 1

[PULL 00/27] Enable PV backends with Xen/KVM emulation

2023-03-07 Thread David Woodhouse
bian guest. -------- David Woodhouse (23): hw/xen: Add xenstore wire implementation and implementation stubs hw/xen: Add basic XenStore tree walk and write/read/directory support hw/xen: Implement XenStore watches hw/xen: Implement XenStore transactions

[PULL 07/27] hw/xen: Implement core serialize/deserialize methods for xenstore_impl

2023-03-07 Thread David Woodhouse
From: David Woodhouse This implements the basic migration support in the back end, with unit tests that give additional confidence in the node-counting already in the tree. However, the existing PV back ends like xen-disk don't support migration yet. They will reset the ring and fa

[PULL 23/27] hw/xen: Map guest XENSTORE_PFN grant in emulated Xenstore

2023-03-07 Thread David Woodhouse
From: David Woodhouse We don't actually access the guest's page through the grant, because this isn't real Xen, and we can just use the page we gave it in the first place. Map the grant anyway, mostly for cosmetic purposes so it *looks* like it's in use in the guest-visible

[PULL 24/27] hw/xen: Implement soft reset for emulated gnttab

2023-03-07 Thread David Woodhouse
From: David Woodhouse This is only part of it; we will also need to get the PV back end drivers to tear down their own mappings (or do it for them, but they kind of need to stop using the pointers too). Some more work on the actual PV back ends and xen-bus code is going to be needed to really

[PULL 21/27] hw/xen: Add emulated implementation of grant table operations

2023-03-07 Thread David Woodhouse
From: David Woodhouse This is limited to mapping a single grant at a time, because under Xen the pages are mapped *contiguously* into qemu's address space, and that's very hard to do when those pages actually come from anonymous mappings in qemu in the first place. Eventually perh

[PULL 16/27] hw/xen: Rename xen_common.h to xen_native.h

2023-03-07 Thread David Woodhouse
From: David Woodhouse This header is now only for native Xen code, not PV backends that may be used in Xen emulation. Since the toolstack libraries may depend on the specific version of Xen headers that they pull in (and will set the __XEN_TOOLS__ macro to enable internal definitions that they

[PULL 11/27] hw/xen: Pass grant ref to gnttab unmap operation

2023-03-07 Thread David Woodhouse
From: David Woodhouse The previous commit introduced redirectable gnttab operations fairly much like-for-like, with the exception of the extra arguments to the ->open() call which were always NULL/0 anyway. This *changes* the arguments to the ->unmap() operation to include the origin

[PULL 14/27] hw/xen: Move xenstore_store_pv_console_info to xen_console.c

2023-03-07 Thread David Woodhouse
From: David Woodhouse There's no need for this to be in the Xen accel code, and as we want to use the Xen console support with KVM-emulated Xen we'll want to have a platform-agnostic version of it. Make it use GString to build up the path while we're at it. Signed-off-by:

[PULL 04/27] hw/xen: Implement XenStore transactions

2023-03-07 Thread David Woodhouse
From: David Woodhouse Given that the whole thing supported copy on write from the beginning, transactions end up being fairly simple. On starting a transaction, just take a ref of the existing root; swap it back in on a successful commit. The main tree has a transaction ID too, and we keep a

[PULL 25/27] i386/xen: Initialize Xen backends from pc_basic_device_init() for emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse Now that all the work is done to enable the PV backends to work without actual Xen, instantiate the bus from pc_basic_device_init() for emulated mode. This allows us finally to launch an emulated Xen guest with PV disk. qemu-system-x86_64 -serial mon:stdio -M q35 -cpu

[PULL 26/27] MAINTAINERS: Add entry for Xen on KVM emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 5340de0515..640deb2895 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -443,6 +443,15 @@ F: target/i386/kvm

[PULL 10/27] hw/xen: Add gnttab operations to allow redirection to internal emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse Move the existing code using libxengnttab to xen-operations.c and allow the operations to be redirected so that we can add emulation of grant table mapping for backend drivers. In emulation, mapping more than one grant ref to be virtually contiguous would be fairly

[PULL 20/27] hw/xen: Hook up emulated implementation for event channel operations

2023-03-07 Thread David Woodhouse
From: David Woodhouse We provided the backend-facing evtchn functions very early on as part of the core Xen platform support, since things like timers and xenstore need to use them. By what may or may not be an astonishing coincidence, those functions just *happen* all to have exactly the right

[PULL 27/27] docs: Update Xen-on-KVM documentation for PV disk support

2023-03-07 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- docs/system/i386/xen.rst | 30 +++--- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/system/i386/xen.rst b/docs/system/i386/xen.rst index a00523b492..f06765e88c

[PULL 15/27] hw/xen: Use XEN_PAGE_SIZE in PV backend drivers

2023-03-07 Thread David Woodhouse
From: David Woodhouse XC_PAGE_SIZE comes from the actual Xen libraries, while XEN_PAGE_SIZE is provided by QEMU itself in xen_backend_ops.h. For backends which may be built for emulation mode, use the latter. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/block/dataplane/xen

[PULL 18/27] hw/xen: Avoid crash when backend watch fires too early

2023-03-07 Thread David Woodhouse
re it is fully set up, leading to the crash. By simply moving the call to xendev_class->realize() after the initial xenstore nodes are populated, this sorry state of affairs is avoided. Reported-by: David Woodhouse Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse Reviewed-by: Paul Dur

[PULL 06/27] hw/xen: Implement XenStore permissions

2023-03-07 Thread David Woodhouse
From: Paul Durrant Store perms as a GList of strings, check permissions. Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_xenstore.c | 2 +- hw/i386/kvm/xenstore_impl.c | 259 +--- hw/i386/kvm

[PULL 13/27] hw/xen: Add xenstore operations to allow redirection to internal emulation

2023-03-07 Thread David Woodhouse
From: Paul Durrant Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- accel/xen/xen-all.c | 11 +- hw/char/xen_console.c | 2 +- hw/i386/kvm/xen_xenstore.c | 3 - hw/i386/kvm/xenstore_impl.h | 8

[PULL 12/27] hw/xen: Add foreignmem operations to allow redirection to internal emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/char/xen_console.c| 8 +++--- hw/display/xenfb.c | 20 +++--- hw/xen/xen-operations.c | 45 include/hw/xen/xen_backend_ops.h | 26

[PULL 02/27] hw/xen: Add basic XenStore tree walk and write/read/directory support

2023-03-07 Thread David Woodhouse
From: David Woodhouse This is a fairly simple implementation of a copy-on-write tree. The node walk function starts off at the root, with 'inplace == true'. If it ever encounters a node with a refcount greater than one (including the root node), then that node is shared with other

[PULL 08/27] hw/xen: Create initial XenStore nodes

2023-03-07 Thread David Woodhouse
From: Paul Durrant Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_xenstore.c | 70 ++ 1 file changed, 70 insertions(+) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index

[PULL 01/27] hw/xen: Add xenstore wire implementation and implementation stubs

2023-03-07 Thread David Woodhouse
From: David Woodhouse This implements the basic wire protocol for the XenStore commands, punting all the actual implementation to xs_impl_* functions which all just return errors for now. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/meson.build | 1 + hw

Re: [PATCH v2 00/27] Enable PV backends with Xen/KVM emulation

2023-03-07 Thread David Woodhouse
On Tue, 2023-03-07 at 17:57 +, Paul Durrant wrote: > I think the series is good to go now so time to send a PR. Done, thank you! smime.p7s Description: S/MIME cryptographic signature

[PULL 09/27] hw/xen: Add evtchn operations to allow redirection to internal emulation

2023-03-07 Thread David Woodhouse
From: David Woodhouse The existing implementation calling into the real libxenevtchn moves to a new file hw/xen/xen-operations.c, and is called via a function table which in a subsequent commit will also be able to invoke the emulated event channel support. Signed-off-by: David Woodhouse

Re: [PULL 00/27] Enable PV backends with Xen/KVM emulation

2023-03-07 Thread David Woodhouse
On Tue, 2023-03-07 at 21:20 +0100, Philippe Mathieu-Daudé wrote: > > This tag only appears in the cover letter, and is missing in each patch. > It would have been acceptable if it were in the PR tag, but > the tag (which for some reason isn't displayed in your cover letter) > is simply "PV back en

Re: [PULL 13/27] hw/xen: Add xenstore operations to allow redirection to internal emulation

2023-03-13 Thread David Woodhouse
On Sun, 2023-03-12 at 15:19 -0400, Jason Andryuk wrote: > > This breaks dm_restrict=1 since the xs_open is not allowed by the > time > this is called.  There are other evtchn errors before this as well: > # cat /var/log/xen/qemu-dm-debian.log > char device redirected to /dev/pts/8 (label serial0)

Re: [PATCH] xen: fix dm_restrict startup

2023-03-13 Thread David Woodhouse
On Sun, 2023-03-12 at 19:41 -0400, Jason Andryuk wrote: > QEMU is failing to signal it start when launched by libxl with > dm_restrict=1.  When xenstore_record_dm_state() is called, the > restrictions prevent xs_open() from succeeding.  QEMU can't write > running to the xenstore, and libxl fails th

Re: [PULL 13/27] hw/xen: Add xenstore operations to allow redirection to internal emulation

2023-03-14 Thread David Woodhouse
On Mon, 2023-03-13 at 19:17 -0400, Jason Andryuk wrote: > This looks good, better than what I posted, and seems to work for both > dm_restrict set and unset. Thanks. > For dm_restricted, xs_write() does fail.  I verified that with a print > statement.  I think "shouldn't even try" makes sense.  I

[PATCH] accel/xen: Fix DM state change notification in dm_restrict mode

2023-03-14 Thread David Woodhouse
From: David Woodhouse When dm_restrict is set, QEMU isn't permitted to update the XenStore node to indicate its running status. Previously, the xs_write() call would fail but the failure was ignored. However, in refactoring to allow for emulated XenStore operations, a new call to xs_open(

[PATCH] Fix PCI hotplug AML

2023-03-17 Thread David Woodhouse
From: David Woodhouse The emulated PIIX3 uses a nybble for the status of each PCI function, so the status for e.g. slot 0 functions 0 and 1 respectively can be read as (\_GPE.PH00 & 0x0F), and (\_GPE.PH00 >> 0x04). The AML that Xen gives to a guest gets the operand order for the odd

Re: [PATCH v2 09/27] hw/xen: Add evtchn operations to allow redirection to internal emulation

2023-03-23 Thread David Woodhouse
On Thu, 2023-03-23 at 10:29 +, Anthony PERARD wrote: > On Tue, Mar 07, 2023 at 05:17:32PM +0000, David Woodhouse wrote: > > From: David Woodhouse > > > > The existing implementation calling into the real libxenevtchn moves to > > a new file hw/xen/xen-operat

[PATCH] hw/xenpv: Initialize Xen backend operations

2023-03-23 Thread David Woodhouse
From: David Woodhouse As the Xen backend operations were abstracted out into a function table to allow for internally emulated Xen support, we missed the xen_init_pv() code path which also needs to install the operations for the true Xen libraries. Add the missing call to setup_xen_backend_ops

Re: [PATCH 08/13] hw/xen: do not use aio_set_fd_handler(is_external=true) in xen_xenstore

2023-04-04 Thread David Woodhouse
sable_external() API. > > Signed-off-by: Stefan Hajnoczi Reviewed-by: David Woodhouse Thanks. > --- >  hw/i386/kvm/xen_xenstore.c | 2 +- >  1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c > index 90067

Re: [PULL 13/27] hw/xen: Add xenstore operations to allow redirection to internal emulation

2023-04-04 Thread David Woodhouse
On Tue, 2023-04-04 at 18:35 +0100, Peter Maydell wrote: > On Tue, 7 Mar 2023 at 18:27, David Woodhouse > wrote: > > > > From: Paul Durrant > > > > Signed-off-by: Paul Durrant > > Signed-off-by: David Woodhouse > > Reviewed-by: Paul Durrant > >

Re: [PULL 13/27] hw/xen: Add xenstore operations to allow redirection to internal emulation

2023-04-04 Thread David Woodhouse
On Tue, 2023-04-04 at 18:45 +0100, Peter Maydell wrote: > On Tue, 4 Apr 2023 at 18:45, David Woodhouse > wrote: > > > > On Tue, 2023-04-04 at 18:35 +0100, Peter Maydell wrote: > > > On Tue, 7 Mar 2023 at 18:27, David Woodhouse > > > > > &g

[PATCH] hw/xen: Fix memory leak in libxenstore_open() for Xen

2023-04-04 Thread David Woodhouse
From: David Woodhouse There was a superfluous allocation of the XS handle, leading to it being leaked on both the error path and the success path (where it gets allocated again). Spotted by Coverity (CID 1508098). Fixes: ba2a92db1ff6 ("hw/xen: Add xenstore operations to allow redirecti

Re: [PULL 22/27] hw/xen: Add emulated implementation of XenStore operations

2023-04-12 Thread David Woodhouse
On Tue, 2023-04-11 at 19:07 +0100, Peter Maydell wrote: > > > > +static void xs_be_unwatch(struct qemu_xs_handle *h, struct > > qemu_xs_watch *w) > > +{ > > +    xs_impl_unwatch(h->impl, DOMID_QEMU, w->path, NULL, > > xs_be_watch_cb, w); > > Coverity points out that this is the only call to xs_i

[PATCH 5/5] hw/xen: Fix broken check for invalid state in xs_be_open()

2023-04-12 Thread David Woodhouse
From: David Woodhouse Coverity points out that if (!s && !s->impl) isn't really what we intended to do here. CID 1508131. Fixes: 032475127225 ("hw/xen: Add emulated implementation of XenStore operations") Signed-off-by: David Woodhouse --- hw/i386/kvm/xen_xenstore.c

[PATCH 4/5] hw/xen: Fix double-free in xen_console store_con_info()

2023-04-12 Thread David Woodhouse
From: David Woodhouse Coverity spotted a double-free (CID 1508254); we g_string_free(path) and then for some reason immediately call free(path) too. We should just use g_autoptr() for it anyway, which simplifies the code a bit. Fixes: 7a8a749da7d3 ("hw/xen: Move xenstore_store_pv_console

[PATCH 1/5] hw/xen: Simplify emulated Xen platform init

2023-04-12 Thread David Woodhouse
From: David Woodhouse I initially put the basic platform init (overlay pages, grant tables, event channels) into mc->kvm_type because that was the earliest place that could sensibly test for xen_mode==XEN_EMULATE. The intent was to do this early enough that we could then initialise the Xen

[PATCH for-8.0 0/5] Xen emulation build/Coverity fixes

2023-04-12 Thread David Woodhouse
MSI→PIRQ mappings in the first place, and I doubt any other guests care either. I'd like to establish the 'correct' behaviour and implement it, ideally before the 8.0 release, but it's going to take me a few days more. David Woodhouse (5): hw/xen: Simplify emulated

[PATCH 3/5] xen: Drop support for Xen versions below 4.7.1

2023-04-12 Thread David Woodhouse
From: David Woodhouse In restructuring to allow for internal emulation of Xen functionality, I broke compatibility for Xen 4.6 and earlier. Fix this by explicitly removing support for anything older than 4.7.1, which is also ancient but it does still build, and the compatibility support for it

[PATCH 2/5] hw/xen: Fix memory leak in libxenstore_open() for Xen

2023-04-12 Thread David Woodhouse
From: David Woodhouse There was a superfluous allocation of the XS handle, leading to it being leaked on both the error path and the success path (where it gets allocated again). Spotted by Coverity (CID 1508098). Fixes: ba2a92db1ff6 ("hw/xen: Add xenstore operations to allow redirecti

Re: [PATCH for-8.0 0/5] Xen emulation build/Coverity fixes

2023-04-12 Thread David Woodhouse
On Wed, 2023-04-12 at 19:55 +0100, Peter Maydell wrote: > On Wed, 12 Apr 2023 at 19:52, David Woodhouse wrote: > > > > Some Coverity fixes and minor cleanups. And most notably, dropping > > support for Xen libraries older than 4.7.1. > > > > I believe there

Re: [PATCH for-8.0 0/5] Xen emulation build/Coverity fixes

2023-04-12 Thread David Woodhouse
On Wed, 2023-04-12 at 20:01 +0100, David Woodhouse wrote: > On Wed, 2023-04-12 at 19:55 +0100, Peter Maydell wrote: > > On Wed, 12 Apr 2023 at 19:52, David Woodhouse wrote: > > > > > > Some Coverity fixes and minor cleanups. And most notably, dropping > > >

(Ab)using xenstored without Xen

2022-12-20 Thread David Woodhouse
I've been working on getting qemu to support Xen HVM guests 'natively' under KVM: https://lore.kernel.org/qemu-devel/20221216004117.862106-1-dw...@infradead.org/T/ The basic platform is mostly working and I can start XTF tests with 'qemu -kernel'. Now it really needs a xenstore. I'm thinking of i

Re: [PATCH v2 3/6] hw/isa/piix: Wire up Xen PCI IRQ handling outside of PIIX3

2023-01-06 Thread David Woodhouse
On Wed, 2023-01-04 at 15:44 +0100, Bernhard Beschow wrote: > +    if (xen_enabled()) { Could this perhaps be if (xen_mode != XEN_DISABLED) once we merge the Xen-on-KVM series? smime.p7s Description: S/MIME cryptographic signature

Re: (Ab)using xenstored without Xen

2023-01-09 Thread David Woodhouse
On 9 January 2023 07:40:06 GMT, Juergen Gross wrote: >Sorry for the late answer, but I was pretty busy before my 3 week time off. :-) No problem, I had lots of other things to work on, including my own time off. Hope you enjoyed it! >On 20.12.22 13:02, David Woodhouse wrote: >&g

Re: [PATCH v7 1/2] KVM: x86/cpuid: generalize kvm_update_kvm_cpuid_base() and also capture limit

2023-01-11 Thread David Woodhouse
re > so we can neatly store both the base and limit leaf indices. > > Signed-off-by: Paul Durrant > --- Reviewed-by: David Woodhouse smime.p7s Description: S/MIME cryptographic signature

Re: [PATCH v7 2/2] KVM: x86/xen: update Xen CPUID Leaf 4 (tsc info) sub-leaves, if present

2023-01-11 Thread David Woodhouse
able to the VMM. > The offset values are not set since a TSC offset is already applied. > The TSC frequency should also be set in sub-leaf 2. > > Signed-off-by: Paul Durrant > --- Reviewed-by: David Woodhouse smime.p7s Description: S/MIME cryptographic signature

Re: [patch V2 30/46] x86/xen: Wrap XEN MSI management into irqdomain

2023-01-15 Thread David Woodhouse
On Wed, 2020-08-26 at 13:16 +0200, Thomas Gleixner wrote: > From: Thomas Gleixner > > To allow utilizing the irq domain pointer in struct device it is necessary > to make XEN/MSI irq domain compatible. > > While the right solution would be to truly convert XEN to irq domains, this > is an exerci

Re: [patch V2 30/46] x86/xen: Wrap XEN MSI management into irqdomain

2023-01-15 Thread David Woodhouse
On Sun, 2023-01-15 at 14:12 +, David Woodhouse wrote: > On Wed, 2020-08-26 at 13:16 +0200, Thomas Gleixner wrote: > > From: Thomas Gleixner > > > > To allow utilizing the irq domain pointer in struct device it is necessary > > to make XEN/MSI irq domain compatibl

Re: [PULL 05/27] hw/xen: Watches on XenStore transactions

2023-06-20 Thread David Woodhouse
On Tue, 2023-06-20 at 13:19 +0100, Peter Maydell wrote: > On Fri, 2 Jun 2023 at 18:06, Peter Maydell > wrote: > > > > On Tue, 2 May 2023 at 18:08, Peter Maydell > > wrote: > > > > > > On Tue, 7 Mar 2023 at 18:27, David Woodhouse > > > wrote:

[PATCH] hw/xen: Clarify (lack of) error handling in transaction_commit()

2023-06-20 Thread David Woodhouse
From: David Woodhouse Coverity was unhappy (CID 1508359) because we didn't check the return of init_walk_op() in transaction_commit(), despite doing so at every other call site. Strictly speaking, this is a false positive since it can never fail. It only fails for invalid user

Re: [Xen-devel] [PATCH] x86/sm{e, a}p: do not enable SMEP/SMAP in PV shim by default on AMD

2023-10-11 Thread David Woodhouse
> > On 16/01/2020 16:00, Igor Druzhinin wrote: > > Due to AMD and Hygon being unable to selectively trap CR4 bit modifications > > running 32-bit PV guest inside PV shim comes with significant performance > > hit. Moreover, for SMEP in particular every time CR4.SMEP changes on context > > switch t

Re: [Xen-devel] [PATCH] x86/sm{e, a}p: do not enable SMEP/SMAP in PV shim by default on AMD

2023-10-12 Thread David Woodhouse
On Thu, 2023-10-12 at 10:13 +0800, andrew.coop...@citrix.com wrote: > On 11/10/2023 7:34 pm, David Woodhouse wrote: > > But why does the shim even need to turn it off when switching to the > > guest context? Its guest isn't running in supervisor mode so surely it > > doe

Re: [PATCH v6 06/38] mm: Add default definition of set_ptes()

2023-10-12 Thread David Woodhouse
On Wed, 2023-08-02 at 16:13 +0100, Matthew Wilcox (Oracle) wrote: > Most architectures can just define set_pte() and PFN_PTE_SHIFT to > use this definition.  It's also a handy spot to document the guarantees > provided by the MM. > > Suggested-by: Mike Rapoport (IBM) > Signed-off-by: Matthew Wilc

Re: [PATCH v6 06/38] mm: Add default definition of set_ptes()

2023-10-12 Thread David Woodhouse
On Thu, 2023-10-12 at 15:05 +0100, Matthew Wilcox wrote: > On Thu, Oct 12, 2023 at 02:53:05PM +0100, David Woodhouse wrote: > > > +   arch_enter_lazy_mmu_mode(); > > > +   for (;;) { > > > +   set_pte(ptep, pte); >

[PATCH 01/12] i386/xen: fix per-vCPU upcall vector for Xen emulation

2023-10-16 Thread David Woodhouse
From: David Woodhouse The per-vCPU upcall vector support had two problems. Firstly it was using the wrong hypercall argument and would always return -EFAULT. And secondly it was using the wrong ioctl() to pass the vector to the kernel and thus the *kernel* would always return -EINVAL. Linux

[PATCH 11/12] hw/xen: automatically assign device index to block devices

2023-10-16 Thread David Woodhouse
From: David Woodhouse There's no need to force the user to assign a vdev. We can automatically assign one, starting at xvda and searching until we find the first disk name that's unused. This means we can now allow '-drive if=xen,file=xxx' to work without an explicit separ

[PATCH 10/12] hw/xen: automatically assign device index to console devices

2023-10-16 Thread David Woodhouse
From: David Woodhouse Now that we can reliably tell whether a given device already exists, we can allow the user to add console devices on the command line with just '-device xen-console,chardev=foo'. Start at 1, because we can't add the *primary* console; that's special b

[PATCH 05/12] hw/xen: populate store frontend nodes with XenStore PFN/port

2023-10-16 Thread David Woodhouse
From: David Woodhouse This is kind of redundant since without being able to get these through ome other method (HVMOP_get_param) the guest wouldn't be able to access XenStore in order to find them. But Xen populates them, and it does allow guests to *rebind* to the event channel port af

[PATCH 08/12] hw/xen: do not repeatedly try to create a failing backend device

2023-10-16 Thread David Woodhouse
From: David Woodhouse If xen_backend_device_create() fails to instantiate a device, the XenBus code will just keep trying over and over again each time the bus is re-enumerated, as long as the backend appears online and in XenbusStateInitialising. The only thing which prevents the XenBus code

[PATCH 07/12] hw/xen: update Xen console to XenDevice model

2023-10-16 Thread David Woodhouse
This allows (non-primary) console devices to be created on the command line. Signed-off-by: David Woodhouse --- hw/char/trace-events| 8 + hw/char/xen_console.c | 502 +++- hw/xen/xen-legacy-backend.c | 1 - 3 files changed, 381 insertions

[PATCH 03/12] include: update Xen public headers to Xen 4.17.2 release

2023-10-16 Thread David Woodhouse
From: David Woodhouse ... in order to advertise the XEN_HVM_CPUID_UPCALL_VECTOR feature, which will come in a subsequent commit. Signed-off-by: David Woodhouse --- hw/i386/kvm/xen_xenstore.c| 2 +- include/hw/xen/interface/arch-arm.h | 37 +++--- include

[PATCH 02/12] hw/xen: select kernel mode for per-vCPU event channel upcall vector

2023-10-16 Thread David Woodhouse
From: David Woodhouse A guest which has configured the per-vCPU upcall vector may set the HVM_PARAM_CALLBACK_IRQ param to fairly much anything other than zero. For example, Linux v6.0+ after commit b1c3497e604 ("x86/xen: Add support for HVMOP_set_evtchn_upcall_vector") will just do

[PATCH 0/12] Get Xen PV shim running in qemu

2023-10-16 Thread David Woodhouse
I hadn't got round to getting the PV shim running yet; I thought it would need work on the multiboot loader. Turns out it doesn't. I *did* need to fix a couple of brown-paper-bag bugs in the per-vCPU upcall vector support, and implement Xen console support though. Now I can test PV guests: $ qemu

[PATCH 09/12] hw/xen: prevent duplicate device registrations

2023-10-16 Thread David Woodhouse
From: David Woodhouse Ensure that we have a XenBackendInstance for every device regardless of whether it was "discovered" in XenStore or created directly in QEMU. This allows the backend_list to be a source of truth about whether a given backend exists, and allows us to reject duplica

[PATCH 12/12] hw/xen: add support for Xen primary console in emulated mode

2023-10-16 Thread David Woodhouse
From: David Woodhouse The primary console is special because the toolstack maps a page at a fixed GFN and also allocates the guest-side event channel. Add support for that in emulated mode, so that we can have a primary console. Add a *very* rudimentary stub of foriegnmem ops for emulated mode

[PATCH 04/12] i386/xen: advertise XEN_HVM_CPUID_UPCALL_VECTOR in CPUID

2023-10-16 Thread David Woodhouse
From: David Woodhouse This will allow Linux guests (since v6.0) to use the per-vCPU upcall vector delivered as MSI through the local APIC. Signed-off-by: David Woodhouse --- target/i386/kvm/kvm.c | 4 1 file changed, 4 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm

[PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass

2023-10-16 Thread David Woodhouse
From: David Woodhouse The primary Xen console is special. The guest's side is set up for it by the toolstack automatically and not by the standard PV init sequence. Accordingly, its *frontend* doesn't appear in …/device/console/0 either; instead it appears under …/console in t

Re: [PATCH 11/12] hw/xen: automatically assign device index to block devices

2023-10-17 Thread David Woodhouse
On Tue, 2023-10-17 at 12:21 +0200, Kevin Wolf wrote: > Am 16.10.2023 um 17:19 hat David Woodhouse geschrieben: > > From: David Woodhouse > > > > There's no need to force the user to assign a vdev. We can automatically > > assign one, starting at xvda and search

<    1   2   3   4   5   6   7   8   9   10   >