Re: [PATCH v2 05/27] include/hw/hyperv: Add MSHV ABI header definitions

2025-07-02 Thread Magnus Kulke
On Wed, Jul 02, 2025 at 12:32:05PM +0200, Cornelia Huck wrote: > On Wed, Jul 02 2025, Magnus Kulke wrote: > > > I might not have completely understood the process though, do you > > suggest to run `update-linux-headers.sh` on a current kernel (the other > > headers seem

Re: [PATCH v2 05/27] include/hw/hyperv: Add MSHV ABI header definitions

2025-07-02 Thread Magnus Kulke
On Wed, Jul 02, 2025 at 11:11:41AM +0200, Cornelia Huck wrote: > On Tue, Jul 01 2025, Magnus Kulke wrote: > > > Introduce headers for the Microsoft Hypervisor (MSHV) userspace ABI, > > including IOCTLs and structures used to interface with the hypervisor. > > > >

[PATCH v2 13/27] accel/mshv: Add vCPU signal handling

2025-07-01 Thread Magnus Kulke
Implement signal handling for MSHV vCPUs to support asynchronous interrupts from the main thread. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index

[PATCH v2 14/27] target/i386/mshv: Add CPU create and remove logic

2025-07-01 Thread Magnus Kulke
Implement MSHV-specific hooks for vCPU creation and teardown in the i386 target. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 23 +-- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c

[PATCH v2 10/27] accel/mshv: Add ioeventfd support

2025-07-01 Thread Magnus Kulke
Implement ioeventfd registration in the MSHV accelerator backend to handle guest-triggered events. This enables integration with QEMU's eventfd-based I/O mechanism. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c | 116 accel/mshv/trace-e

[PATCH v2 08/27] accel/mshv: Initialize VM partition

2025-07-01 Thread Magnus Kulke
Create the MSHV virtual machine by opening a partition and issuing the necessary ioctl to initialize it. This sets up the basic VM structure and initial configuration used by MSHV to manage guest state. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c| 210

[PATCH v2 09/27] accel/mshv: Register guest memory regions with hypervisor

2025-07-01 Thread Magnus Kulke
that's not the case, it will be addressed in a later commit in the series. Signed-off-by: Magnus Kulke --- accel/mshv/mem.c| 127 +++- accel/mshv/trace-events | 16 + include/system/mshv.h | 11 3 files changed, 151 insertions(+), 3 dele

[PATCH v2 22/27] target/i386/mshv: Integrate x86 instruction decoder/emulator

2025-07-01 Thread Magnus Kulke
memory regions (e.g. OVMF will probe 0xfed4 for a vTPM). In those cases 0xFF bytes is returned instead of aborting the execution. Signed-off-by: Magnus Kulke --- accel/mshv/mem.c| 65 +++ accel/mshv/mshv-all.c | 2 +- include/system/mshv.h | 6

[PATCH v2 24/27] target/i386/mshv: Implement mshv_vcpu_run()

2025-07-01 Thread Magnus Kulke
decoder/emulator is invoked to perform the operation in user space. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 463 +++- 1 file changed, 461 insertions(+), 2 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index

[PATCH v2 20/27] target/i386/mshv: Register CPUID entries with MSHV

2025-07-01 Thread Magnus Kulke
Convert the guest CPU's CPUID model into MSHV's format and register it with the hypervisor. This ensures that the guest observes the correct CPU feature set during CPUID instructions. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 199 ++

[PATCH v2 15/27] target/i386/mshv: Implement mshv_store_regs()

2025-07-01 Thread Magnus Kulke
Add support for writing general-purpose registers to MSHV vCPUs during initialization or migration using the MSHV register interface. A generic set_register call is introduced to abstract the HV call over the various register types. Signed-off-by: Magnus Kulke --- include/system/mshv.h

Re: [PATCH v2 25/27] target/i386/mshv: Handle HVMSG_X64_HALT vm exit

2025-07-01 Thread Magnus Kulke
ohno, I planned to drop this commit (we do not receive hlt exits from the hypervisor anymore), plz ignore.

[PATCH v2 16/27] target/i386/mshv: Implement mshv_get_standard_regs()

2025-07-01 Thread Magnus Kulke
ff-by: Magnus Kulke --- include/system/mshv.h | 1 + target/i386/mshv/mshv-cpu.c | 69 +++-- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/include/system/mshv.h b/include/system/mshv.h index adce4153d9..65f7fa15a0 100644 --- a/include/system/m

[PATCH v2 26/27] accel/mshv: Workaround for overlappig mem mappings

2025-07-01 Thread Magnus Kulke
0 Signed-off-by: Magnus Kulke --- accel/mshv/mem.c| 264 accel/mshv/trace-events | 7 +- include/system/mshv.h | 16 ++- target/i386/mshv/mshv-cpu.c | 43 ++ 4 files changed, 295 insertions(+), 35 deletions(-) diff --git a/accel/ms

[PATCH v2 21/27] target/i386/mshv: Register MSRs with MSHV

2025-07-01 Thread Magnus Kulke
Build and register the guest vCPU's model-specific registers using the MSHV interface. Signed-off-by: Magnus Kulke --- accel/mshv/meson.build | 1 + accel/mshv/msr.c| 372 include/system/mshv.h | 23 +++ target/i386/

[PATCH v2 06/27] accel/mshv: Add accelerator skeleton

2025-07-01 Thread Magnus Kulke
Introduce the initial scaffold for the MSHV (Microsoft Hypervisor) accelerator backend. This includes the basic directory structure and stub implementations needed to integrate with QEMU's accelerator framework. Signed-off-by: Magnus Kulke --- accel/meson.build | 1 + accel

[PATCH v2 23/27] target/i386/mshv: Write MSRs to the hypervisor

2025-07-01 Thread Magnus Kulke
Push current model-specific register (MSR) values to MSHV's vCPUs as part of setting state to the hypervisor. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 68 +++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/target/i386

[PATCH v2 27/27] docs: Add mshv to documentation

2025-07-01 Thread Magnus Kulke
Added mshv to the list of accelerators in doc text. Signed-off-by: Magnus Kulke --- docs/devel/codebase.rst | 2 +- qemu-options.hx | 16 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/devel/codebase.rst b/docs/devel/codebase.rst index 2a3143787a

[PATCH v2 25/27] target/i386/mshv: Handle HVMSG_X64_HALT vm exit

2025-07-01 Thread Magnus Kulke
Implemented handler for HVMSG_X64_HALT exit messages from the hypervisor. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c | 3 +++ include/system/mshv.h | 1 + target/i386/mshv/mshv-cpu.c | 26 ++ 3 files changed, 30 insertions(+) diff --git a/accel

[PATCH v2 05/27] include/hw/hyperv: Add MSHV ABI header definitions

2025-07-01 Thread Magnus Kulke
being the header `linux-mshv.h` is also being included to allow building on machines that do not ship the header yet. The header will be available in kernel 6.15 (at the time of writing we're at -rc6) we will probably drop it in later revisions of the patch set. Signed-off-by: Magnus

[PATCH v2 19/27] target/i386/mshv: Set local interrupt controller state

2025-07-01 Thread Magnus Kulke
To set the local interrupt controller state, perform hv calls retrieving partition state from the hypervisor. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 117 target/i386/mshv/x86.c | 3 +- 2 files changed, 119 insertions(+), 1

[PATCH v2 17/27] target/i386/mshv: Implement mshv_get_special_regs()

2025-07-01 Thread Magnus Kulke
Retrieve special registers (e.g. segment, control, and descriptor table registers) from MSHV vCPUs. Various helper functions to map register state representations between Qemu and MSHV are introduced. Signed-off-by: Magnus Kulke --- include/system/mshv.h | 1 + target/i386/mshv/mshv

[PATCH v2 18/27] target/i386/mshv: Implement mshv_arch_put_registers()

2025-07-01 Thread Magnus Kulke
Write CPU register state to MSHV vCPUs. Various mapping functions to prepare the payload for the HV call have been implemented. Signed-off-by: Magnus Kulke --- include/system/mshv.h | 15 +++ target/i386/mshv/mshv-cpu.c | 239 2 files changed, 254

[PATCH v2 11/27] accel/mshv: Add basic interrupt injection support

2025-07-01 Thread Magnus Kulke
Implement initial interrupt handling logic in the MSHV backend. This includes management of MSI and un/registering of irqfd mechanisms. Co-authored-by: Stanislav Kinsburskii Signed-off-by: Magnus Kulke --- accel/mshv/irq.c| 369 accel/mshv

[PATCH v2 12/27] accel/mshv: Add vCPU creation and execution loop

2025-07-01 Thread Magnus Kulke
. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c | 187 +--- accel/mshv/trace-events | 1 + include/system/mshv.h | 17 target/i386/mshv/mshv-cpu.c | 63 4 files changed, 256 insertions(+), 12 deletions(-) diff --git a/accel

[PATCH v2 07/27] accel/mshv: Register memory region listeners

2025-07-01 Thread Magnus Kulke
. Signed-off-by: Magnus Kulke --- accel/mshv/mem.c | 25 accel/mshv/meson.build | 1 + accel/mshv/mshv-all.c | 68 -- include/system/mshv.h | 4 +++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 accel/mshv

[PATCH v2 02/27] target/i386/emulate: Allow instruction decoding from stream

2025-07-01 Thread Magnus Kulke
ction()" op to x86_emul_ops() to improve traceability. Signed-off-by: Magnus Kulke --- target/i386/emulate/x86_decode.c | 31 +++ target/i386/emulate/x86_decode.h | 10 ++ target/i386/emulate/x86_emu.c| 3 ++- target/i386/emulate/x86_emu.h| 1

[PATCH v2 03/27] target/i386/mshv: Add x86 decoder/emu implementation

2025-07-01 Thread Magnus Kulke
The MSHV accelerator requires a x86 decoder/emulator in userland to emulate MMIO instructions. This change contains the implementations for the generalized i386 instruction decoder/emulator. Signed-off-by: Magnus Kulke --- include/system/mshv.h | 25 +++ target/i386/cpu.h

[PATCH v2 01/27] accel: Add Meson and config support for MSHV accelerator

2025-07-01 Thread Magnus Kulke
Introduce a Meson feature option and default-config entry to allow building QEMU with MSHV (Microsoft Hypervisor) acceleration support. This is the first step toward implementing an MSHV backend in QEMU. Signed-off-by: Magnus Kulke --- accel/Kconfig | 3 +++ meson.build

[PATCH v2 04/27] hw/intc: Generalize APIC helper names from kvm_* to accel_*

2025-07-01 Thread Magnus Kulke
Rename APIC helper functions to use an accel_* prefix instead of kvm_* to support use by accelerators other than KVM. This is a preparatory step for integrating MSHV support with common APIC logic. Signed-off-by: Magnus Kulke --- accel/accel-irq.c | 95

[PATCH v2 00/27] Implementing a MSHV (Microsoft Hypervisor) accelerator

2025-07-01 Thread Magnus Kulke
ng discussed. For now commit #26 will work around this limitation. - A kernel ioctl "set_immediate_exit" will be added to the mshv driver to avoid a race condition when handling signals (like ctrl-a x). Magnus Kulke (27): accel: Add Meson and config support for MSHV accelerator

Re: [RFC PATCH 24/25] target/i386/mshv: Implement mshv_vcpu_run()

2025-07-01 Thread Magnus Kulke
On Tue, Jul 01, 2025 at 03:11:39PM +, Wei Liu wrote: > On Tue, Jul 01, 2025 at 10:35:34AM +0200, Magnus Kulke wrote: > > On Tue, May 20, 2025 at 10:52:39PM +, Wei Liu wrote: > > > On Tue, May 20, 2025 at 01:30:17PM +0200, Magnus Kulke wrote: > > > > +

Re: [RFC PATCH 24/25] target/i386/mshv: Implement mshv_vcpu_run()

2025-07-01 Thread Magnus Kulke
On Tue, Jul 01, 2025 at 03:47:40PM +, Wei Liu wrote: > > We can leave the out for now as long as the guest shutdown works. > > Wei. yup, shutdown works fine, so I will drop the commit from the next patch set, thanks!

Re: [RFC PATCH 24/25] target/i386/mshv: Implement mshv_vcpu_run()

2025-07-01 Thread Magnus Kulke
On Tue, May 20, 2025 at 10:52:39PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:17PM +0200, Magnus Kulke wrote: > > +default: > > +msg = &exit_msg; > > Do you not get any HALT exit? How are you going to shut down the VM? > In the WHPX accel

Re: [RFC PATCH 24/25] target/i386/mshv: Implement mshv_vcpu_run()

2025-06-03 Thread Magnus Kulke
On Tue, May 20, 2025 at 10:52:39PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:17PM +0200, Magnus Kulke wrote: > > +case HVMSG_GPA_INTERCEPT: > > I'm not sure why you want to handle UNMAPPED_GPA and GPA_INTERCEPT > separately. In Cloud Hypervisor there is

Re: [RFC PATCH 22/25] target/i386/mshv: Integrate x86 instruction decoder/emulator

2025-05-28 Thread Magnus Kulke
On Tue, May 20, 2025 at 10:38:28PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:15PM +0200, Magnus Kulke wrote: > > +init_emu(&mshv_x86_emul_ops); > > If I'm not mistaken, the name mshv_init_cpu_logic suggests this function > is called every time a CPU

Re: [RFC PATCH 18/25] target/i386/mshv: Implement mshv_arch_put_registers()

2025-05-28 Thread Magnus Kulke
On Tue, May 20, 2025 at 10:22:27PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:11PM +0200, Magnus Kulke wrote: > > +/* > > + * TODO: support asserting an interrupt using interrup_bitmap > > + * it should be possible if we use the vm_fd > > + *

Re: [RFC PATCH 17/25] target/i386/mshv: Implement mshv_get_special_regs()

2025-05-28 Thread Magnus Kulke
On Tue, May 20, 2025 at 10:15:23PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:10PM +0200, Magnus Kulke wrote: > > > > +static enum hv_register_name SPECIAL_REGISTER_NAMES[18] = { > [...] > > +HV_REGISTER_PENDING_INTERRUPTION, > > Why do you thin

Re: [RFC PATCH 11/25] accel/mshv: Add basic interrupt injection support

2025-05-27 Thread Magnus Kulke
On Tue, May 20, 2025 at 08:15:20PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:04PM +0200, Magnus Kulke wrote: > > Implement initial interrupt handling logic in the MSHV backend. This > > includes management of MSI and un/registering of irqfd mechanisms. > > >

Re: [RFC PATCH 08/25] accel/mshv: Initialize VM partition

2025-05-23 Thread Magnus Kulke
On Fri, May 23, 2025 at 03:37:02PM +, Wei Liu wrote: > On Fri, May 23, 2025 at 10:23:58AM +0200, Magnus Kulke wrote: > > On Tue, May 20, 2025 at 07:07:06PM +, Wei Liu wrote: > > > On Tue, May 20, 2025 at 01:30:01PM +0200, Magnus Kulke wrote: > > > > Crea

Re: [RFC PATCH 09/25] accel/mshv: Register guest memory regions with hypervisor

2025-05-23 Thread Magnus Kulke
On Tue, May 20, 2025 at 08:07:27PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:02PM +0200, Magnus Kulke wrote: > > Handle region_add events by invoking the MSHV memory registration > > +return set_guest_memory(vm_fd, ®ion); > > +} > > +

Re: [RFC PATCH 08/25] accel/mshv: Initialize VM partition

2025-05-23 Thread Magnus Kulke
On Tue, May 20, 2025 at 07:07:06PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:01PM +0200, Magnus Kulke wrote: > > Create the MSHV virtual machine by opening a partition and issuing > > the necessary ioctl to initialize it. This sets up the basic VM > >

Re: [RFC PATCH 08/25] accel/mshv: Initialize VM partition

2025-05-22 Thread Magnus Kulke
On Tue, May 20, 2025 at 07:07:06PM +, Wei Liu wrote: > On Tue, May 20, 2025 at 01:30:01PM +0200, Magnus Kulke wrote: > > +static void mshv_reset(void *param) > > +{ > > +warn_report("mshv reset"); > > What's missing for this hook? > Ah, I su

Re: [RFC PATCH 25/25] accel/mshv: Add memory remapping workaround

2025-05-22 Thread Magnus Kulke
On Tue, May 20, 2025 at 03:53:10PM +0200, Paolo Bonzini wrote: > On 5/20/25 13:30, Magnus Kulke wrote: > > Qemu maps regions of userland multiple times into the guest. The MSHV > > kernel driver detects those overlapping regions and rejects those > > mappings. > > C

[RFC PATCH 11/25] accel/mshv: Add basic interrupt injection support

2025-05-20 Thread Magnus Kulke
Implement initial interrupt handling logic in the MSHV backend. This includes management of MSI and un/registering of irqfd mechanisms. Signed-off-by: Magnus Kulke --- accel/mshv/irq.c| 370 accel/mshv/meson.build | 1 + accel/mshv/mshv-all.c

[RFC PATCH 15/25] target/i386/mshv: Implement mshv_store_regs()

2025-05-20 Thread Magnus Kulke
Add support for writing general-purpose registers to MSHV vCPUs during initialization or migration using the MSHV register interface. A generic set_register call is introduced to abstract the HV call over the various register types. Signed-off-by: Magnus Kulke --- include/system/mshv.h

[RFC PATCH 20/25] target/i386/mshv: Register CPUID entries with MSHV

2025-05-20 Thread Magnus Kulke
Convert the guest CPU's CPUID model into MSHV's format and register it with the hypervisor. This ensures that the guest observes the correct CPU feature set during CPUID instructions. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 199 ++

[RFC PATCH 07/25] accel/mshv: Register memory region listeners

2025-05-20 Thread Magnus Kulke
. Signed-off-by: Magnus Kulke --- accel/mshv/mem.c | 25 accel/mshv/meson.build | 1 + accel/mshv/mshv-all.c | 68 -- include/system/mshv.h | 4 +++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 accel/mshv

[RFC PATCH 24/25] target/i386/mshv: Implement mshv_vcpu_run()

2025-05-20 Thread Magnus Kulke
decoder/emulator is invoked to perform the operation in user space. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 554 ++-- 1 file changed, 524 insertions(+), 30 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c

[RFC PATCH 09/25] accel/mshv: Register guest memory regions with hypervisor

2025-05-20 Thread Magnus Kulke
that's not the case, it will be addressed in a later commit in the series. Signed-off-by: Magnus Kulke --- accel/mshv/mem.c| 116 ++-- accel/mshv/trace-events | 1 + include/system/mshv.h | 11 3 files changed, 125 insertions(+), 3 dele

[RFC PATCH 13/25] accel/mshv: Add vCPU signal handling

2025-05-20 Thread Magnus Kulke
Implement signal handling for MSHV vCPUs to support asynchronous interrupts from the main thread. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c | 28 1 file changed, 28 insertions(+) diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index

[RFC PATCH 06/25] accel/mshv: Add accelerator skeleton

2025-05-20 Thread Magnus Kulke
Introduce the initial scaffold for the MSHV (Microsoft Hypervisor) accelerator backend. This includes the basic directory structure and stub implementations needed to integrate with QEMU's accelerator framework. Signed-off-by: Magnus Kulke --- accel/meson.build | 1 + accel

[RFC PATCH 25/25] accel/mshv: Add memory remapping workaround

2025-05-20 Thread Magnus Kulke
would qualify and is currently unmapped, the current region is unmapped and the requested region is mapped in. Signed-off-by: Magnus Kulke --- accel/mshv/mem.c| 229 +++- accel/mshv/mshv-all.c | 2 + include/system/mshv.h | 13 ++ target

[RFC PATCH 00/25] Implementing a MSHV (Microsoft Hypervisor) accelerator

2025-05-20 Thread Magnus Kulke
mware: - Since the MHSV accelerator requires a HyperV hypervisor to be present, it would make sense to provide testing infrastructure for integration testing on Azure. We are looking into options how to implement that. best, magnus Magnus Kulke (25): accel: Add Meson and config supp

[RFC PATCH 18/25] target/i386/mshv: Implement mshv_arch_put_registers()

2025-05-20 Thread Magnus Kulke
Write CPU register state to MSHV vCPUs. Various mapping functions to prepare the payload for the HV call have been implemented. Signed-off-by: Magnus Kulke --- include/system/mshv.h | 41 ++ target/i386/mshv/mshv-cpu.c | 249 2 files changed, 290

[RFC PATCH 01/25] accel: Add Meson and config support for MSHV accelerator

2025-05-20 Thread Magnus Kulke
Introduce a Meson feature option and default-config entry to allow building QEMU with MSHV (Microsoft Hypervisor) acceleration support. This is the first step toward implementing an MSHV backend in QEMU. Signed-off-by: Magnus Kulke --- accel/Kconfig | 3 +++ meson.build

[RFC PATCH 12/25] accel/mshv: Add vCPU creation and execution loop

2025-05-20 Thread Magnus Kulke
. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c | 197 +--- accel/mshv/trace-events | 1 + include/system/mshv.h | 19 target/i386/mshv/mshv-cpu.c | 63 4 files changed, 268 insertions(+), 12 deletions(-) diff --git a/accel

[RFC PATCH 02/25] target/i386/emulate: allow instruction decoding from stream

2025-05-20 Thread Magnus Kulke
Introduce a new helper function to decode x86 instructions from a raw instruction byte stream. MSHV delivers an instruction stream in a buffer of the vm_exit message. It can be used to speed up MMIO emulation, since instructions do not have to be fetched and translated. Signed-off-by: Magnus

[RFC PATCH 14/25] target/i386/mshv: Add CPU create and remove logic

2025-05-20 Thread Magnus Kulke
Implement MSHV-specific hooks for vCPU creation and teardown in the i386 target. A list of locks per vCPU is maintained to lock CPU state in MMIO operations. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 61 + 1 file changed, 55 insertions

[RFC PATCH 10/25] accel/mshv: Add ioeventfd support

2025-05-20 Thread Magnus Kulke
Implement ioeventfd registration in the MSHV accelerator backend to handle guest-triggered events. This enables integration with QEMU's eventfd-based I/O mechanism. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c | 115 accel/mshv/trace-e

[RFC PATCH 08/25] accel/mshv: Initialize VM partition

2025-05-20 Thread Magnus Kulke
Create the MSHV virtual machine by opening a partition and issuing the necessary ioctl to initialize it. This sets up the basic VM structure and initial configuration used by MSHV to manage guest state. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c| 204

[RFC PATCH 21/25] target/i386/mshv: Register MSRs with MSHV

2025-05-20 Thread Magnus Kulke
Build and register the guest vCPU's model-specific registers using the MSHV interface. Signed-off-by: Magnus Kulke --- accel/mshv/meson.build | 1 + accel/mshv/msr.c| 375 include/system/mshv.h | 26 +++ target/i386/mshv/mshv-

[RFC PATCH 23/25] target/i386/mshv: Write MSRs to the hypervisor

2025-05-20 Thread Magnus Kulke
Push current model-specific register (MSR) values to MSHV's vCPUs as part of setting state to the hypervisor. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 70 +++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/target/i386

[RFC PATCH 22/25] target/i386/mshv: Integrate x86 instruction decoder/emulator

2025-05-20 Thread Magnus Kulke
memory regions (e.g. OVMF will probe 0xfed4 for a vTPM). In those cases 0xFF bytes is returned instead of aborting the execution. Signed-off-by: Magnus Kulke --- accel/mshv/mem.c| 72 accel/mshv/trace-events | 3 + include/system/mshv.h | 4

[RFC PATCH 16/25] target/i386/mshv: Implement mshv_get_standard_regs()

2025-05-20 Thread Magnus Kulke
ff-by: Magnus Kulke --- include/system/mshv.h | 1 + target/i386/mshv/mshv-cpu.c | 70 + 2 files changed, 71 insertions(+) diff --git a/include/system/mshv.h b/include/system/mshv.h index b2dec5a7ec..9b78b66a24 100644 --- a/include/system/mshv.h +++ b/include/s

[RFC PATCH 17/25] target/i386/mshv: Implement mshv_get_special_regs()

2025-05-20 Thread Magnus Kulke
Retrieve special registers (e.g. segment, control, and descriptor table registers) from MSHV vCPUs. Various helper functions to map register state representations between Qemu and MSHV are introduced. Signed-off-by: Magnus Kulke --- include/system/mshv.h | 1 + target/i386/mshv/mshv

[RFC PATCH 04/25] hw/intc: Generalize APIC helper names from kvm_* to accel_*

2025-05-20 Thread Magnus Kulke
Rename APIC helper functions to use an accel_* prefix instead of kvm_* to support use by accelerators other than KVM. This is a preparatory step for integrating MSHV support with common APIC logic. Signed-off-by: Magnus Kulke --- accel/accel-irq.c | 95

[RFC PATCH 05/25] include/hw/hyperv: Add MSHV ABI header definitions

2025-05-20 Thread Magnus Kulke
being the header `linux-mshv.h` is also being included to allow building on machines that do not ship the header yet. The header will be available in kernel 6.15 (at the time of writing we're at -rc6) we will probably drop it in later revisions of the patch set. Signed-off-by: Magnus

[RFC PATCH 19/25] target/i386/mshv: Set local interrupt controller state

2025-05-20 Thread Magnus Kulke
To set the local interrupt controller state, perform hv calls retrieving partition state from the hypervisor. Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 120 1 file changed, 120 insertions(+) diff --git a/target/i386/mshv/mshv-cpu.c b

[RFC PATCH 03/25] target/i386/mshv: Add x86 decoder/emu implementation

2025-05-20 Thread Magnus Kulke
The MSHV accelerator requires a x86 decoder/emulator in userland to emulate MMIO instructions. This change contains the implementations for the generalized i386 instruction decoder/emulator. Signed-off-by: Magnus Kulke --- include/system/mshv.h | 32 target/i386/cpu.h

Re: [CFT PATCH 0/4] target/i386/emulate: cleanups

2025-05-09 Thread Magnus Kulke
Hey Paolo, I applied your patches to the x86 emulator in our MSHV branch. They compile cleanly (some off this we had changed on our branch already). I also performed some manual testing and didn't spot any regressions with the changes in the emulator. magnus already). I also performed some manua

Re: [PATCH v3] target/i386/emulate: remove rflags leftovers

2025-04-29 Thread Magnus Kulke
On Tue, Apr 29, 2025 at 02:27:21PM +0200, Paolo Bonzini wrote: > Il mar 29 apr 2025, 14:17 Magnus Kulke ha > scritto: > > > Yes, I'm using the generalized emulator in the context of adding the MSHV > > accelerator. (I'll probably get around sending an RFC pa

Re: [PATCH v3] target/i386/emulate: remove rflags leftovers

2025-04-29 Thread Magnus Kulke
On Tue, Apr 29, 2025 at 12:02:48PM +0200, Paolo Bonzini wrote: > Il mar 29 apr 2025, 11:33 Magnus Kulke ha > scritto: > > > Fixes: c901905ea670 ("target/i386/emulate: remove flags_mask") > > > > In c901905ea670 rflags have been removed from `x86_decod

[PATCH v3] target/i386/emulate: remove rflags leftovers

2025-04-29 Thread Magnus Kulke
Fixes: c901905ea670 ("target/i386/emulate: remove flags_mask") In c901905ea670 rflags have been removed from `x86_decode`, but there were some leftovers. Signed-off-by: Magnus Kulke --- target/i386/emulate/x86_decode.c | 17 ++--- 1 file changed, 6 insertions(+), 11

[PATCH v2] i386/emulate: remove rflags leftovers

2025-04-28 Thread Magnus Kulke
In c901905 rflags have been removed from `x86_decode`, but there were some leftovers. Signed-off-by: Magnus Kulke --- target/i386/emulate/x86_decode.c | 17 ++--- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/target/i386/emulate/x86_decode.c b/target/i386/emulate

[PATCH] i386/emulate: remove rflags leftovers

2025-04-28 Thread Magnus Kulke
In c901905 rflags have been removed from `x86_decode`, but there were some leftovers. Signed-off-by: Magnus Kulke --- target/i386/emulate/x86_decode.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/target/i386/emulate/x86_decode.c b/target/i386/emulate

ANN: working on an accelerator for MSHV

2025-03-20 Thread Magnus Kulke
Hi all, We would like to informally announce an effort we started at Microsoft to expose the Microsoft Hypervisor (MSHV) as an alternative accelerator in Qemu on Linux hosts. L1 VMs that have been launched on Azure or HyperV will be able to use a /dev/mshv device to accelerate the operation of L2