[PATCH v13 06/60] i386/kvm: Set Xen vCPU ID in KVM

2023-02-23 Thread David Woodhouse
From: David Woodhouse There are (at least) three different vCPU ID number spaces. One is the internal KVM vCPU index, based purely on which vCPU was chronologically created in the kernel first. If userspace threads are all spawned and create their KVM vCPUs in essentially random order

[PATCH v13 24/60] i386/xen: implement HYPERVISOR_event_channel_op

2023-02-23 Thread David Woodhouse
From: Joao Martins Signed-off-by: Joao Martins [dwmw2: Ditch event_channel_op_compat which was never available to HVM guests] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 25 + 1 file changed, 25 insertions(+) diff --git

[PATCH v13 13/60] hw/xen: Add xen_overlay device for emulating shared xenheap pages

2023-02-23 Thread David Woodhouse
From: David Woodhouse For the shared info page and for grant tables, Xen shares its own pages from the "Xen heap" to the guest. The guest requests that a given page from a certain address space (XENMAPSPACE_shared_info, etc.) be mapped to a given GPA using the XENMEM_add_to_physmap

[PATCH v13 38/60] hw/xen: Implement EVTCHNOP_reset

2023-02-23 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 30 ++ hw/i386/kvm/xen_evtchn.h | 3 +++ target/i386/kvm/xen-emu.c | 17 + 3 files changed, 50 insertions(+) diff --git a/hw/i386/kvm

[PATCH v13 31/60] hw/xen: Implement EVTCHNOP_unmask

2023-02-23 Thread David Woodhouse
From: David Woodhouse This finally comes with a mechanism for actually injecting events into the guest vCPU, with all the atomic-test-and-set that's involved in setting the bit in the shinfo, then the index in the vcpu_info, and injecting either the lapic vector as MSI, or letting KVM inject

[PATCH v13 10/60] i386/xen: implement HYPERVISOR_xen_version

2023-02-23 Thread David Woodhouse
-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 86 +++ 1 file changed, 86 insertions(+) diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index 476f464ee2..56b80a7880 100644 --- a/target/i386/kvm/xen-emu.c +++ b

[PATCH v13 42/60] kvm/i386: Add xen-gnttab-max-frames property

2023-02-23 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- accel/kvm/kvm-all.c | 1 + include/sysemu/kvm_int.h | 1 + include/sysemu/kvm_xen.h | 1 + target/i386/kvm/kvm.c | 34 ++ target/i386/kvm/xen-emu.c | 6 ++ 5

[PATCH v13 09/60] i386/xen: handle guest hypercalls

2023-02-23 Thread David Woodhouse
off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/kvm.c| 5 target/i386/kvm/trace-events | 3 +++ target/i386/kvm/xen-emu.c| 44 target/i386/kvm/xen-emu.h| 1 + 4 files changed, 53 insertions(+) diff --git a/target/i

[PATCH v13 53/60] hw/xen: Automatically add xen-platform PCI device for emulated Xen guests

2023-02-23 Thread David Woodhouse
From: David Woodhouse It isn't strictly mandatory but Linux guests at least will only map their grant tables over the dummy BAR that it provides, and don't have sufficient wit to map them in any other unused part of their guest address space. So include it by default for minimal surprise factor

[PATCH v13 25/60] i386/xen: implement HVMOP_set_evtchn_upcall_vector

2023-02-23 Thread David Woodhouse
used by Windows and Xen (PV shim) guests but normally not by Linux. Signed-off-by: Ankur Arora Signed-off-by: Joao Martins [dwmw2: Rework for upstream kernel changes and split from HVMOP_set_param] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/cpu.h| 1

[PATCH v13 37/60] hw/xen: Implement EVTCHNOP_bind_vcpu

2023-02-23 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 40 +++ hw/i386/kvm/xen_evtchn.h | 2 ++ target/i386/kvm/xen-emu.c | 12 3 files changed, 54 insertions(+) diff --git a/hw/i386

[PATCH v13 20/60] i386/xen: implement HYPERVISOR_vcpu_op

2023-02-23 Thread David Woodhouse
From: Joao Martins This is simply when guest tries to register a vcpu_info and since vcpu_info placement is optional in the minimum ABI therefore we can just fail with -ENOSYS Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c

[PATCH v13 47/60] i386/xen: handle PV timer hypercalls

2023-02-23 Thread David Woodhouse
hypercalls Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 31 + hw/i386/kvm/xen_evtchn.h | 2 + target/i386/cpu.h | 5 + target/i386/kvm/xen-emu.c | 260 +- target/i386

[PATCH v13 05/60] i386/kvm: handle Xen HVM cpuid leaves

2023-02-23 Thread David Woodhouse
it automatic] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/cpu.c | 1 + target/i386/cpu.h | 2 + target/i386/kvm/kvm.c | 77 ++- target/i386/kvm/xen-emu.c | 4 +- target/i386/kvm/xen-emu.h | 13 ++- 5 files

Re: [PATCH v12 47/60] i386/xen: handle PV timer hypercalls

2023-02-22 Thread David Woodhouse
On Wed, 2023-02-22 at 13:32 +, Paul Durrant wrote: > > > > > > NB I think you still need to fix kvm_xen_hcall_vcpu_op() to not > > > return the -ENOENT too. > > > > > >   Didn't I already do that? > > Ah, so you did. So many versions... but with the above change > incorporated... Indeed,

Re: [PATCH v12 47/60] i386/xen: handle PV timer hypercalls

2023-02-22 Thread David Woodhouse
On 22 February 2023 12:14:00 GMT, Paul Durrant wrote: >On 22/02/2023 12:03, Paul Durrant wrote: >> On 22/02/2023 09:21, David Woodhouse wrote: >>> On Mon, 2023-02-20 at 20:47 +0000, David Woodhouse wrote: >>>> @@ -1246,6 +1470,16 @@ static bool do_kvm_xen_handle_

Re: [PATCH v12 47/60] i386/xen: handle PV timer hypercalls

2023-02-22 Thread David Woodhouse
On Mon, 2023-02-20 at 20:47 +, David Woodhouse wrote: > @@ -1246,6 +1470,16 @@ static bool do_kvm_xen_handle_exit(X86CPU *cpu, struct > kvm_xen_exit *exit) > } >   > switch (code) { > +    case __HYPERVISOR_set_timer_op: > +    if (exit->u.hcall.longmode)

[PATCH v12 26/60] i386/xen: implement HVMOP_set_param

2023-02-20 Thread David Woodhouse
From: Ankur Arora This is the hook for adding the HVM_PARAM_CALLBACK_IRQ parameter in a subsequent commit. Signed-off-by: Ankur Arora Signed-off-by: Joao Martins [dwmw2: Split out from another commit] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c

[PATCH v12 53/60] hw/xen: Automatically add xen-platform PCI device for emulated Xen guests

2023-02-20 Thread David Woodhouse
From: David Woodhouse It isn't strictly mandatory but Linux guests at least will only map their grant tables over the dummy BAR that it provides, and don't have sufficient wit to map them in any other unused part of their guest address space. So include it by default for minimal surprise factor

[PATCH v12 00/60] Xen HVM support under KVM

2023-02-20 Thread David Woodhouse
21205173137.607044-1-dw...@infradead.org/ https://git.infradead.org/users/dwmw2/qemu.git/shortlog/refs/heads/xenfv-kvm-1 v0: https://github.com/jpemartins/qemu/commits/xen-shim-rfc (Joao et al.) Ankur Arora (2): i386/xen: implement HVMOP_set_evtchn_upcall_vector i386/xen: implement HVMOP_se

[PATCH v12 31/60] hw/xen: Implement EVTCHNOP_unmask

2023-02-20 Thread David Woodhouse
From: David Woodhouse This finally comes with a mechanism for actually injecting events into the guest vCPU, with all the atomic-test-and-set that's involved in setting the bit in the shinfo, then the index in the vcpu_info, and injecting either the lapic vector as MSI, or letting KVM inject

[PATCH v12 23/60] i386/xen: handle VCPUOP_register_runstate_memory_area

2023-02-20 Thread David Woodhouse
From: Joao Martins Allow guest to setup the vcpu runstates which is used as steal clock. Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/cpu.h | 1 + target/i386/kvm/xen-emu.c | 57 +++ target

[PATCH v12 48/60] i386/xen: Reserve Xen special pages for console, xenstore rings

2023-02-20 Thread David Woodhouse
From: David Woodhouse Xen has eight frames at 0xfeff8000 for this; we only really need two for now and KVM puts the identity map at 0xfeffc000, so limit ourselves to four. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- include/sysemu/kvm_xen.h | 8 target/i386/kvm

[PATCH v12 27/60] hw/xen: Add xen_evtchn device for event channel emulation

2023-02-20 Thread David Woodhouse
From: David Woodhouse Include basic support for setting HVM_PARAM_CALLBACK_IRQ to the global vector method HVM_PARAM_CALLBACK_TYPE_VECTOR, which is handled in-kernel by raising the vector whenever the vCPU's vcpu_info->evtchn_upcall_pending flag is set. Signed-off-by: David Woodhouse Revie

[PATCH v12 35/60] hw/xen: Implement EVTCHNOP_alloc_unbound

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 32 hw/i386/kvm/xen_evtchn.h | 2 ++ target/i386/kvm/xen-emu.c | 15 +++ 3 files changed, 49 insertions(+) diff --git a/hw/i386/kvm

[PATCH v12 28/60] i386/xen: Add support for Xen event channel delivery to vCPU

2023-02-20 Thread David Woodhouse
From: David Woodhouse The kvm_xen_inject_vcpu_callback_vector() function will either deliver the per-vCPU local APIC vector (as an MSI), or just kick the vCPU out of the kernel to trigger KVM's automatic delivery of the global vector. Support for asserting the GSI/PCI_INTX callbacks will come

[PATCH v12 47/60] i386/xen: handle PV timer hypercalls

2023-02-20 Thread David Woodhouse
hypercalls Signed-off-by: Joao Martins Signed-off-by: David Woodhouse --- hw/i386/kvm/xen_evtchn.c | 31 + hw/i386/kvm/xen_evtchn.h | 2 + target/i386/cpu.h | 5 + target/i386/kvm/xen-emu.c | 256 +- target/i386/machine.c | 1 + 5 files

[PATCH v12 43/60] hw/xen: Add xen_gnttab device for grant table emulation

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/meson.build | 1 + hw/i386/kvm/xen_gnttab.c | 111 ++ hw/i386/kvm/xen_gnttab.h | 18 +++ hw/i386/pc.c | 2 + target/i386/kvm/xen-emu.c

[PATCH v12 55/60] hw/xen: Implement emulated PIRQ hypercall support

2023-02-20 Thread David Woodhouse
From: David Woodhouse This wires up the basic infrastructure but the actual interrupts aren't there yet, so don't advertise it to the guest. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/trace-events | 4 + hw/i386/kvm/trace.h | 1 + hw/i386/kvm

[PATCH v12 40/60] hw/xen: Support HVM_PARAM_CALLBACK_TYPE_GSI callback

2023-02-20 Thread David Woodhouse
From: David Woodhouse The GSI callback (and later PCI_INTX) is a level triggered interrupt. It is asserted when an event channel is delivered to vCPU0, and is supposed to be cleared when the vcpu_info->evtchn_upcall_pending field for vCPU0 is cleared again. Thankfully, Xen does *not* ass

[PATCH v12 36/60] hw/xen: Implement EVTCHNOP_bind_interdomain

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 78 +++ hw/i386/kvm/xen_evtchn.h | 2 + target/i386/kvm/xen-emu.c | 16 3 files changed, 96 insertions(+) diff --git a/hw/i386/kvm

[PATCH v12 59/60] i386/xen: Document Xen HVM emulation

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- docs/system/i386/xen.rst| 76 + docs/system/target-i386.rst | 1 + 2 files changed, 77 insertions(+) create mode 100644 docs/system/i386/xen.rst diff --git a/docs

[PATCH v12 54/60] i386/xen: Implement HYPERVISOR_physdev_op

2023-02-20 Thread David Woodhouse
From: David Woodhouse Just hook up the basic hypercalls to stubs in xen_evtchn.c for now. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 25 hw/i386/kvm/xen_evtchn.h | 11 target/i386/kvm/xen-compat.h | 19 ++ target/i386

[PATCH v12 11/60] i386/xen: implement HYPERVISOR_sched_op, SCHEDOP_shutdown

2023-02-20 Thread David Woodhouse
for HVM guests, Add SCHEDOP_soft_reset] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- include/sysemu/kvm_xen.h | 1 + target/i386/kvm/trace-events | 1 + target/i386/kvm/xen-emu.c| 75 3 files changed, 77 insertions(+) diff --git

[PATCH v12 50/60] hw/xen: Add backend implementation of interdomain event channel support

2023-02-20 Thread David Woodhouse
From: David Woodhouse The provides the QEMU side of interdomain event channels, allowing events to be sent to/from the guest. The API mirrors libxenevtchn, and in time both this and the real Xen one will be available through ops structures so that the PV backend drivers can use the correct one

[PATCH v12 08/60] xen-platform: allow its creation with XEN_EMULATE mode

2023-02-20 Thread David Woodhouse
without actual Xen, move it to CONFIG_XEN_BUS to include it in the KVM-only builds. Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/xen/meson.build| 5 - hw/i386/xen/xen_platform.c | 39 +- 2 files changed

[PATCH v12 58/60] kvm/i386: Add xen-evtchn-max-pirq property

2023-02-20 Thread David Woodhouse
From: David Woodhouse The default number of PIRQs is set to 256 to avoid issues with 32-bit MSI devices. Allow it to be increased if the user desires. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- accel/kvm/kvm-all.c | 1 + hw/i386/kvm/xen_evtchn.c | 21

[PATCH v12 25/60] i386/xen: implement HVMOP_set_evtchn_upcall_vector

2023-02-20 Thread David Woodhouse
used by Windows and Xen (PV shim) guests but normally not by Linux. Signed-off-by: Ankur Arora Signed-off-by: Joao Martins [dwmw2: Rework for upstream kernel changes and split from HVMOP_set_param] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/cpu.h| 1

[PATCH v12 19/60] i386/xen: implement HYPERVISOR_hvm_op

2023-02-20 Thread David Woodhouse
From: Joao Martins This is when guest queries for support for HVMOP_pagetable_dying. Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 17 + 1 file changed, 17 insertions(+) diff --git a/target/i386/kvm/xen

[PATCH v12 24/60] i386/xen: implement HYPERVISOR_event_channel_op

2023-02-20 Thread David Woodhouse
From: Joao Martins Signed-off-by: Joao Martins [dwmw2: Ditch event_channel_op_compat which was never available to HVM guests] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 25 + 1 file changed, 25 insertions(+) diff --git

[PATCH v12 42/60] kvm/i386: Add xen-gnttab-max-frames property

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- accel/kvm/kvm-all.c | 1 + include/sysemu/kvm_int.h | 1 + include/sysemu/kvm_xen.h | 1 + target/i386/kvm/kvm.c | 34 ++ target/i386/kvm/xen-emu.c | 6 ++ 5

[PATCH v12 14/60] xen: Permit --xen-domid argument when accel is KVM

2023-02-20 Thread David Woodhouse
From: Paul Durrant Signed-off-by: Paul Durrant Signed-off-by: David Wooodhouse --- softmmu/vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 459588aa7d..289bbb27a5 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3366,7 +3366,7 @@ void

[PATCH v12 49/60] i386/xen: handle HVMOP_get_param

2023-02-20 Thread David Woodhouse
From: Joao Martins Which is used to fetch xenstore PFN and port to be used by the guest. This is preallocated by the toolstack when guest will just read those and use it straight away. Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm

[PATCH v12 46/60] hw/xen: Implement GNTTABOP_query_size

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_gnttab.c | 19 +++ hw/i386/kvm/xen_gnttab.h | 2 ++ target/i386/kvm/xen-emu.c | 16 +++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/hw/i386/kvm

[PATCH v12 34/60] hw/xen: Implement EVTCHNOP_send

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 180 ++ hw/i386/kvm/xen_evtchn.h | 2 + target/i386/kvm/xen-emu.c | 12 +++ 3 files changed, 194 insertions(+) diff --git a/hw/i386/kvm

[PATCH v12 44/60] hw/xen: Support mapping grant frames

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_gnttab.c | 73 ++- hw/i386/kvm/xen_overlay.c | 2 +- hw/i386/kvm/xen_overlay.h | 2 ++ 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/hw

[PATCH v12 51/60] hw/xen: Add xen_xenstore device for xenstore emulation

2023-02-20 Thread David Woodhouse
From: David Woodhouse Just the basic shell, with the event channel hookup. It only dumps the buffer for now; a real ring implmentation will come in a subsequent patch. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/meson.build| 1 + hw/i386/kvm/xen_evtchn.c

[PATCH v12 33/60] hw/xen: Implement EVTCHNOP_bind_ipi

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 69 +++ hw/i386/kvm/xen_evtchn.h | 2 ++ target/i386/kvm/xen-emu.c | 15 + 3 files changed, 86 insertions(+) diff --git a/hw/i386/kvm

[PATCH v12 02/60] xen: add CONFIG_XEN_BUS and CONFIG_XEN_EMU options for Xen emulation

2023-02-20 Thread David Woodhouse
From: David Woodhouse The XEN_EMU option will cover core Xen support in target/, which exists only for x86 with KVM today but could theoretically also be implemented on Arm/Aarch64 and with TCG or other accelerators (if anyone wants to run the gauntlet of struct layout compatibility, errno

[PATCH v12 13/60] hw/xen: Add xen_overlay device for emulating shared xenheap pages

2023-02-20 Thread David Woodhouse
From: David Woodhouse For the shared info page and for grant tables, Xen shares its own pages from the "Xen heap" to the guest. The guest requests that a given page from a certain address space (XENMAPSPACE_shared_info, etc.) be mapped to a given GPA using the XENMEM_add_to_physmap

[PATCH v12 37/60] hw/xen: Implement EVTCHNOP_bind_vcpu

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 40 +++ hw/i386/kvm/xen_evtchn.h | 2 ++ target/i386/kvm/xen-emu.c | 12 3 files changed, 54 insertions(+) diff --git a/hw/i386

[PATCH v12 06/60] i386/hvm: Set Xen vCPU ID in KVM

2023-02-20 Thread David Woodhouse
From: David Woodhouse There are (at least) three different vCPU ID number spaces. One is the internal KVM vCPU index, based purely on which vCPU was chronologically created in the kernel first. If userspace threads are all spawned and create their KVM vCPUs in essentially random order

[PATCH v12 56/60] hw/xen: Support GSI mapping to PIRQ

2023-02-20 Thread David Woodhouse
From: David Woodhouse If I advertise XENFEAT_hvm_pirqs then a guest now boots successfully as long as I tell it 'pci=nomsi'. [root@localhost ~]# cat /proc/interrupts CPU0 0: 52 IO-APIC 2-edge timer 1: 16 xen-pirq 1-ioapic-edge i8042 4: 1534

[PATCH v12 20/60] i386/xen: implement HYPERVISOR_vcpu_op

2023-02-20 Thread David Woodhouse
From: Joao Martins This is simply when guest tries to register a vcpu_info and since vcpu_info placement is optional in the minimum ABI therefore we can just fail with -ENOSYS Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c

[PATCH v12 52/60] hw/xen: Add basic ring handling to xenstore

2023-02-20 Thread David Woodhouse
From: David Woodhouse Extract requests, return ENOSYS to all of them. This is enough to allow older Linux guests to boot, as they need *something* back but it doesn't matter much what. A full implementation of a single-tentant internal XenStore copy-on-write tree with transactions and watches

[PATCH v12 29/60] hw/xen: Implement EVTCHNOP_status

2023-02-20 Thread David Woodhouse
From: David Woodhouse This adds the basic structure for maintaining the port table and reporting the status of ports therein. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 104 ++ hw/i386/kvm/xen_evtchn.h | 3

[PATCH v12 18/60] i386/xen: implement XENMEM_add_to_physmap_batch

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-compat.h | 24 + target/i386/kvm/xen-emu.c| 69 2 files changed, 93 insertions(+) diff --git a/target/i386/kvm/xen-compat.h b/target

[PATCH v12 16/60] i386/xen: manage and save/restore Xen guest long_mode setting

2023-02-20 Thread David Woodhouse
From: David Woodhouse Xen will "latch" the guest's 32-bit or 64-bit ("long mode") setting when the guest writes the MSR to fill in the hypercall page, or when the guest sets the event channel callback in HVM_PARAM_CALLBACK_IRQ. KVM handles the former and sets the ker

[PATCH v12 03/60] xen: Add XEN_DISABLED mode and make it default

2023-02-20 Thread David Woodhouse
From: David Woodhouse Also set XEN_ATTACH mode in xen_init() to reflect the truth; not that anyone ever cared before. It was *only* ever checked in xen_init_pv() before. Suggested-by: Paolo Bonzini Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- accel/xen/xen-all.c | 2

[PATCH v12 15/60] i386/xen: add pc_machine_kvm_type to initialize XEN_EMULATE mode

2023-02-20 Thread David Woodhouse
From: David Woodhouse The xen_overlay device (and later similar devices for event channels and grant tables) need to be instantiated. Do this from a kvm_type method on the PC machine derivatives, since KVM is only way to support Xen emulation for now. Signed-off-by: David Woodhouse Reviewed

[PATCH v12 21/60] i386/xen: handle VCPUOP_register_vcpu_info

2023-02-20 Thread David Woodhouse
is invoked. Add the vcpu_info (and default) GPA to the vmstate_x86_cpu for migration, and restore it in kvm_arch_put_registers() appropriately. Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/cpu.h| 2 + target/i386/kvm/kvm.c

[PATCH v12 05/60] i386/kvm: handle Xen HVM cpuid leaves

2023-02-20 Thread David Woodhouse
it automatic] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/cpu.c | 1 + target/i386/cpu.h | 2 + target/i386/kvm/kvm.c | 77 ++- target/i386/kvm/xen-emu.c | 4 +- target/i386/kvm/xen-emu.h | 13 ++- 5 files

[PATCH v12 04/60] i386/kvm: Add xen-version KVM accelerator property and init KVM Xen support

2023-02-20 Thread David Woodhouse
From: David Woodhouse This just initializes the basic Xen support in KVM for now. Only permitted on TYPE_PC_MACHINE because that's where the sysbus devices for Xen heap overlay, event channel, grant tables and other stuff will exist. There's no point having the basic hypercall support if nothing

[PATCH v12 09/60] i386/xen: handle guest hypercalls

2023-02-20 Thread David Woodhouse
off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/kvm.c| 5 target/i386/kvm/trace-events | 3 +++ target/i386/kvm/xen-emu.c| 44 target/i386/kvm/xen-emu.h| 1 + 4 files changed, 53 insertions(+) diff --git a/target/i

[PATCH v12 12/60] i386/xen: Implement SCHEDOP_poll and SCHEDOP_yield

2023-02-20 Thread David Woodhouse
From: David Woodhouse They both do the same thing and just call sched_yield. This is enough to stop the Linux guest panicking when running on a host kernel which doesn't intercept SCHEDOP_poll and lets it reach userspace. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target

[PATCH v12 57/60] hw/xen: Support MSI mapping to PIRQ

2023-02-20 Thread David Woodhouse
From: David Woodhouse The way that Xen handles MSI PIRQs is kind of awful. There is a special MSI message which targets a PIRQ. The vector in the low bits of data must be zero. The low 8 bits of the PIRQ# are in the destination ID field, the extended destination ID field is unused, and instead

[PATCH v12 30/60] hw/xen: Implement EVTCHNOP_close

2023-02-20 Thread David Woodhouse
From: David Woodhouse It calls an internal close_port() helper which will also be used from EVTCHNOP_reset and will actually do the work to disconnect/unbind a port once any of that is actually implemented in the first place. That in turn calls a free_port() internal function which

[PATCH v12 32/60] hw/xen: Implement EVTCHNOP_bind_virq

2023-02-20 Thread David Woodhouse
From: David Woodhouse Add the array of virq ports to each vCPU so that we can deliver timers, debug ports, etc. Global virqs are allocated against vCPU 0 initially, but can be migrated to other vCPUs (when we implement that). The kernel needs to know about VIRQ_TIMER in order to accelerate

[PATCH v12 38/60] hw/xen: Implement EVTCHNOP_reset

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 30 ++ hw/i386/kvm/xen_evtchn.h | 3 +++ target/i386/kvm/xen-emu.c | 17 + 3 files changed, 50 insertions(+) diff --git a/hw/i386/kvm

[PATCH v12 45/60] i386/xen: Implement HYPERVISOR_grant_table_op and GNTTABOP_[gs]et_verson

2023-02-20 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_gnttab.c | 31 hw/i386/kvm/xen_gnttab.h | 5 target/i386/kvm/xen-emu.c | 60 +++ 3 files changed, 96 insertions(+) diff --git

[PATCH v12 60/60] hw/xen: Subsume xen_be_register_common() into xen_be_init()

2023-02-20 Thread David Woodhouse
From: David Woodhouse Every caller of xen_be_init() checks and exits on error, then calls xen_be_register_common(). Just make xen_be_init() abort for itself and return void, and register the common devices too. Signed-off-by: David Woodhouse --- hw/i386/xen/xen-hvm.c | 8

[PATCH v12 07/60] xen-platform: exclude vfio-pci from the PCI platform unplug

2023-02-20 Thread David Woodhouse
From: Joao Martins Such that PCI passthrough devices work for Xen emulated guests. Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/xen/xen_platform.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/hw

[PATCH v12 39/60] i386/xen: add monitor commands to test event injection

2023-02-20 Thread David Woodhouse
From: Joao Martins Specifically add listing, injection of event channels. Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Acked-by: Dr. David Alan Gilbert Reviewed-by: Paul Durrant --- hmp-commands.hx | 29 + hw/i386/kvm/xen_evtchn.c | 137

[PATCH v12 41/60] hw/xen: Support HVM_PARAM_CALLBACK_TYPE_PCI_INTX callback

2023-02-20 Thread David Woodhouse
From: David Woodhouse The guest is permitted to specify an arbitrary domain/bus/device/function and INTX pin from which the callback IRQ shall appear to have come. In QEMU we can only easily do this for devices that actually exist, and even that requires us "knowing" that it's a

[PATCH v12 10/60] i386/xen: implement HYPERVISOR_xen_version

2023-02-20 Thread David Woodhouse
-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 86 +++ 1 file changed, 86 insertions(+) diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index 476f464ee2..56b80a7880 100644 --- a/target/i386/kvm/xen-emu.c +++ b

[PATCH v12 17/60] i386/xen: implement HYPERVISOR_memory_op

2023-02-20 Thread David Woodhouse
From: Joao Martins Specifically XENMEM_add_to_physmap with space XENMAPSPACE_shared_info to allow the guest to set its shared_info page. Signed-off-by: Joao Martins [dwmw2: Use the xen_overlay device, add compat support] Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target

[PATCH v12 22/60] i386/xen: handle VCPUOP_register_vcpu_time_info

2023-02-20 Thread David Woodhouse
From: Joao Martins In order to support Linux vdso in Xen. Signed-off-by: Joao Martins Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/cpu.h | 1 + target/i386/kvm/xen-emu.c | 100 +- target/i386/machine.c | 1 + 3

Re: [PATCH v11 47/59] i386/xen: handle PV timer hypercalls

2023-02-20 Thread David Woodhouse
On Mon, 2023-02-20 at 14:29 +, Paul Durrant wrote: > [snip] > >    static bool kvm_xen_hcall_vcpu_op(struct kvm_xen_exit *exit, X86CPU *cpu, > > int cmd, int vcpu_id, uint64_t arg) > >    { > > -    CPUState *dest = qemu_get_cpu(vcpu_id); > >   

Re: Runnig solaris binary(32 bit) on linux(64 bit)

2023-02-16 Thread David Woodhouse
On Thu, 2023-02-16 at 09:29 -1000, Richard Henderson wrote: > On 2/16/23 09:02, David Woodhouse wrote: > > It wouldn't be beyond the wit of man to extend qemu-user to support the > > similar personality variations for SCO/Solaris/etc. using that as a > > guide. > >

Re: Runnig solaris binary(32 bit) on linux(64 bit)

2023-02-16 Thread David Woodhouse
On Thu, 2023-02-16 at 14:36 +, Peter Maydell wrote: > On Thu, 16 Feb 2023 at 14:30, ginu samuel > wrote: > > > > Hi, > >     I have a requirement to run a Solaris binary ( 32 bit ) on > > linux (64 bit). > > > > Since some of the sources for the binary are not available, > > recompilation

Re: [RFC PATCH v11bis 00/26] Emulated XenStore and PV backend support

2023-02-16 Thread David Woodhouse
On Thu, 2023-02-16 at 15:02 +0100, Juan Quintela wrote: > David Woodhouse wrote: > > --=-jDk4SYxkcOAZoZa6DCVr > > Content-Type: text/plain; charset="UTF-8" > > Content-Transfer-Encoding: quoted-printable > > > > On Thu, 2023-02-16 at 11:49 +0100, Juan Q

Re: [RFC PATCH v11bis 00/26] Emulated XenStore and PV backend support

2023-02-16 Thread David Woodhouse
On Thu, 2023-02-16 at 11:49 +0100, Juan Quintela wrote: > David Woodhouse wrote: > > The non-RFC patch submisson¹ is just the basic platform support for Xen > > on KVM. This RFC series is phase 2, adding an internal XenStore and > > hooking up the PV back end drivers to

[RFC PATCH v11bis 15/26] hw/xen: Use XEN_PAGE_SIZE in PV backend drivers

2023-02-16 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 --- hw/block/dataplane/xen-block.c | 8 hw

[RFC PATCH v11bis 11/26] hw/xen: Pass grant ref to gnttab unmap operation

2023-02-16 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

[RFC PATCH v11bis 17/26] hw/xen: Build PV backend drivers for CONFIG_XEN_BUS

2023-02-16 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 --- hw/9pfs/meson.build| 2 +- hw/block/dataplane/meson.build | 2 +- hw/block/meson.build | 2

[RFC PATCH v11bis 05/26] hw/xen: Watches on XenStore transactions

2023-02-16 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 those flags cannot

[RFC PATCH v11bis 13/26] hw/xen: Add xenstore operations to allow redirection to internal emulation

2023-02-16 Thread David Woodhouse
From: Paul Durrant Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse --- 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 +- hw/xen/xen-bus-helper.c

[RFC PATCH v11bis 10/26] hw/xen: Add gnttab operations to allow redirection to internal emulation

2023-02-16 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

[RFC PATCH v11bis 22/26] hw/xen: Add emulated implementation of XenStore operations

2023-02-16 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

[RFC PATCH v11bis 18/26] hw/xen: Avoid crash when backend watch fires too early

2023-02-16 Thread David Woodhouse
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 --- hw/xen/xen-bus.

[RFC PATCH v11bis 09/26] hw/xen: Add evtchn operations to allow redirection to internal emulation

2023-02-16 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

[RFC PATCH v11bis 07/26] hw/xen: Implement core serialize/deserialize methods for xenstore_impl

2023-02-16 Thread David Woodhouse
From: David Woodhouse In fact I think we want to only serialize the contents of the domain's path in /local/domain/${domid} and leave the rest to be recreated? Will defer to Paul for that. Signed-off-by: David Woodhouse --- hw/i386/kvm/xen_xenstore.c | 25 +- hw/i386/kvm/xenstore_impl.c

[RFC PATCH v11bis 00/26] Emulated XenStore and PV backend support

2023-02-16 Thread David Woodhouse
do so without my brain exploding. Since the first time the XenStore code was showed, I've stopped the XsNode from being an actual Object; that just made it larger for almost no benefit. ¹ https://lore.kernel.org/qemu-devel/20230216062444.2129371-1-dw...@infradead.org/ David Woodhouse (22

[RFC PATCH v11bis 19/26] hw/xen: Only advertise ring-page-order for xen-block if gnttab supports it

2023-02-16 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 --- hw/block/xen-block.c | 11 --- 1 file changed, 8 insertions(+), 3

[RFC PATCH v11bis 01/26] hw/xen: Add xenstore wire implementation and implementation stubs

2023-02-16 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 --- hw/i386/kvm/meson.build | 1 + hw/i386/kvm/trace-events| 15

[RFC PATCH v11bis 14/26] hw/xen: Move xenstore_store_pv_console_info to xen_console.c

2023-02-16 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: David Woodhouse

[RFC PATCH v11bis 26/26] i386/xen: Initialize Xen backends from pc_basic_device_init() for emulation

2023-02-16 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

[RFC PATCH v11bis 16/26] hw/xen: Rename xen_common.h to xen_native.h

2023-02-16 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

[RFC PATCH v11bis 21/26] hw/xen: Add emulated implementation of grant table operations

2023-02-16 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 perhaps we can

[RFC PATCH v11bis 03/26] hw/xen: Implement XenStore watches

2023-02-16 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 not so

<    5   6   7   8   9   10   11   12   13   14   >