All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Fix register page use for guests using mshv accel
@ 2026-07-07 22:16 Doru Blânzeanu
  2026-07-07 22:16 ` [PATCH 1/5] include/hw/hyperv: move hv_vp_register_page struct definition Doru Blânzeanu
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Doru Blânzeanu @ 2026-07-07 22:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Doru Blânzeanu, Magnus Kulke, Wei Liu,
	Magnus Kulke, Doru Blânzeanu, Wei Liu

This patch series is a fix for the recent merge of the outdated patch series:
https://lore.kernel.org/all/20260428135053.251200-1-dblanzeanu@linux.microsoft.com/

The above patch series had some newer versions that fixed addressed feedback
from reviewers.

The commits do the following:
1. Moves the definition for the `hv_vp_register_page` to `hvhdk.h`
   Fixes: 8afb40b7fe
2. Changes the register page setup to fail in case the mmap of the page fails.
   This way it signals an issue early.
   Fixes: a173f8f170
3. Rename functions local to the `mshv-cpu.c` linked to register page get.
   Use the register page to read registers on VM exit. General purpose
   registers, RIP, RFLAGS, segment registers, and control registers
   (CR0, CR4, CR4, CR8, EFER) are read directly from the page. Registers
   not present on the page (TR, LDTR, GDTR, IDTR, CR2, APIC_BASE) are not
   fetched anymore for performance reasons.
   Removes the fallback to ioctls in case the register page is not correctly set
   up and aborts.
   Fixes: 40072a7391
4. Changes the registers storing to only use the register page and not rely on
   ioctls for perfomance improvements. From local tests, the special registers
   that are not stored, do not get modified when emulating. However, if there's
   an issue discovered, we'll fix later.
   Fixes: 80c7f8e9cd
5. When a device handler (e.g. vmport) calls cpu_synchronize_state() during
   I/O port dispatch, it sets cpu->accel->dirty = true and may modify
   registers directly in env. The old PIO code ignored this: it
   unconditionally wrote the stale info->rax from the VM-exit intercept
   message back to the hypervisor and then cleared dirty, discarding any
   register changes made by the device.
   Note: This was a change present in version 3 of the patch series but not
   present in the version 1 of the patch series (the one merged)

The register page is only used when it has been successfully mmapped and
the hypervisor has marked it as valid (`isvalid != 0`). Otherwise, an error is
returned and execution aborted to signal something faulty and unexpected.

Changes since v1:
- Rebased on latest master to fix a merge conflict coming from the elimination
  of the accel specific dirty field

-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAAE0AAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgF4l9Pi
ZyIMDy0ZI4SCYaMCvjXS3h6Dpo3xDFvSh0I7oAAAAHc3NoOmdpdAAAAANnaXQAAAAAAAAA
BnNoYTUxMgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABA4egRAbnGLI
XkdzHMqxAMQj1wQNIw+Ja9we8xUkEiJW96FaummDyD2h2TxplwF93KnWYW/sUYZMX5b1C3
3OOcBgUAACUF
-----END SSH SIGNATURE-----
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAAE0AAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgF4l9Pi
ZyIMDy0ZI4SCYaMCvjXS3h6Dpo3xDFvSh0I7oAAAAHc3NoOmdpdAAAAANnaXQAAAAAAAAA
BnNoYTUxMgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAqkJRImazba
3Xjj17Hi7FDcJ5XC7f+rFXUvDc58gax1GyCHtOu16ldDx3ldSi2Zl8iGFtauFsLHRAdPpK
IoPyDAUAACUR
-----END SSH SIGNATURE-----
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAAE0AAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgF4l9Pi
ZyIMDy0ZI4SCYaMCvjXS3h6Dpo3xDFvSh0I7oAAAAHc3NoOmdpdAAAAANnaXQAAAAAAAAA
BnNoYTUxMgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAJ1tI5FyxL+
GZ8gHzwMy4Bvk3bYniUpXhdKF+Y41Ec6aSaK92zZEILSBmpioCBTjawsYF7/0Gqju5Ukjg
Fai0CQUAACV5
-----END SSH SIGNATURE-----

Doru Blânzeanu (5):
  include/hw/hyperv: move hv_vp_register_page struct definition
  target/i386/mshv: abort when hv_vp_register_page setup fails
  target/i386/mshv: remove fallback for register page get registers
  target/i386/mshv: remove fallback for register page set registers
  target/i386/mshv: fix pio handlers clobbering device-modified
    registers

 include/hw/hyperv/hvgdk.h      |   2 +
 include/hw/hyperv/hvgdk_mini.h | 103 --------------
 include/hw/hyperv/hvhdk.h      | 106 ++++++++++++++
 target/i386/mshv/mshv-cpu.c    | 247 +++++++++++++++------------------
 4 files changed, 219 insertions(+), 239 deletions(-)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH 0/5] Fix register page use for guests using mshv accel
@ 2026-07-07  8:25 Doru Blânzeanu
  2026-07-07  8:25 ` [PATCH 1/5] include/hw/hyperv: move hv_vp_register_page struct definition Doru Blânzeanu
  0 siblings, 1 reply; 13+ messages in thread
From: Doru Blânzeanu @ 2026-07-07  8:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Doru Blânzeanu, Wei Liu, Magnus Kulke, Doru Blânzeanu,
	Paolo Bonzini, Wei Liu, Magnus Kulke

This patch series is a fix for the recent merge of the outdated patch series:
https://lore.kernel.org/all/20260428135053.251200-1-dblanzeanu@linux.microsoft.com/

The above patch series had some newer versions that fixed addressed feedback
from reviewers.

The commits do the following:
1. Moves the definition for the `hv_vp_register_page` to `hvhdk.h`
   Fixes: 8afb40b7fe
2. Changes the register page setup to fail in case the mmap of the page fails.
   This way it signals an issue early.
   Fixes: a173f8f170
3. Rename functions local to the `mshv-cpu.c` linked to register page get.
   Use the register page to read registers on VM exit. General purpose
   registers, RIP, RFLAGS, segment registers, and control registers
   (CR0, CR4, CR4, CR8, EFER) are read directly from the page. Registers
   not present on the page (TR, LDTR, GDTR, IDTR, CR2, APIC_BASE) are not
   fetched anymore for performance reasons.
   Removes the fallback to ioctls in case the register page is not correctly set
   up and aborts.
   Fixes: 40072a7391
4. Changes the registers storing to only use the register page and not rely on
   ioctls for perfomance improvements. From local tests, the special registers
   that are not stored, do not get modified when emulating. However, if there's
   an issue discovered, we'll fix later.
   Fixes: 80c7f8e9cd
5. When a device handler (e.g. vmport) calls cpu_synchronize_state() during
   I/O port dispatch, it sets cpu->accel->dirty = true and may modify
   registers directly in env. The old PIO code ignored this: it
   unconditionally wrote the stale info->rax from the VM-exit intercept
   message back to the hypervisor and then cleared dirty, discarding any
   register changes made by the device.
   Note: This was a change present in version 3 of the patch series but not
   present in the version 1 of the patch series (the one merged)

The register page is only used when it has been successfully mmapped and
the hypervisor has marked it as valid (`isvalid != 0`). Otherwise, an error is
returned and execution aborted to signal something faulty and unexpected.
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAAE0AAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgF4l9Pi
ZyIMDy0ZI4SCYaMCvjXS3h6Dpo3xDFvSh0I7oAAAAHc3NoOmdpdAAAAANnaXQAAAAAAAAA
BnNoYTUxMgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABA4egRAbnGLI
XkdzHMqxAMQj1wQNIw+Ja9we8xUkEiJW96FaummDyD2h2TxplwF93KnWYW/sUYZMX5b1C3
3OOcBgUAACUF
-----END SSH SIGNATURE-----
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAAE0AAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgF4l9Pi
ZyIMDy0ZI4SCYaMCvjXS3h6Dpo3xDFvSh0I7oAAAAHc3NoOmdpdAAAAANnaXQAAAAAAAAA
BnNoYTUxMgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAqkJRImazba
3Xjj17Hi7FDcJ5XC7f+rFXUvDc58gax1GyCHtOu16ldDx3ldSi2Zl8iGFtauFsLHRAdPpK
IoPyDAUAACUR
-----END SSH SIGNATURE-----

Doru Blânzeanu (5):
  include/hw/hyperv: move hv_vp_register_page struct definition
  target/i386/mshv: abort when hv_vp_register_page setup fails
  target/i386/mshv: remove fallback for register page get registers
  target/i386/mshv: remove fallback for register page set registers
  target/i386/mshv: fix pio handlers clobbering device-modified
    registers

 include/hw/hyperv/hvgdk.h      |   2 +
 include/hw/hyperv/hvgdk_mini.h | 103 --------------
 include/hw/hyperv/hvhdk.h      | 106 ++++++++++++++
 target/i386/mshv/mshv-cpu.c    | 249 +++++++++++++++------------------
 4 files changed, 220 insertions(+), 240 deletions(-)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-07-08 16:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 22:16 [PATCH 0/5] Fix register page use for guests using mshv accel Doru Blânzeanu
2026-07-07 22:16 ` [PATCH 1/5] include/hw/hyperv: move hv_vp_register_page struct definition Doru Blânzeanu
2026-07-08 16:36   ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 2/5] target/i386/mshv: abort when hv_vp_register_page setup fails Doru Blânzeanu
2026-07-08 16:37   ` Magnus Kulke
2026-07-08 16:38   ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 3/5] target/i386/mshv: remove fallback for register page get registers Doru Blânzeanu
2026-07-08 16:49   ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 4/5] target/i386/mshv: remove fallback for register page set registers Doru Blânzeanu
2026-07-08 16:44   ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 5/5] target/i386/mshv: fix pio handlers clobbering device-modified registers Doru Blânzeanu
2026-07-08 16:50   ` Magnus Kulke
  -- strict thread matches above, loose matches on Subject: below --
2026-07-07  8:25 [PATCH 0/5] Fix register page use for guests using mshv accel Doru Blânzeanu
2026-07-07  8:25 ` [PATCH 1/5] include/hw/hyperv: move hv_vp_register_page struct definition Doru Blânzeanu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.