All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Doru Blânzeanu" <dblanzeanu@linux.microsoft.com>
To: qemu-devel@nongnu.org
Cc: "Doru Blânzeanu" <dblanzeanu@linux.microsoft.com>,
	"Wei Liu" <liuwe@microsoft.com>,
	"Magnus Kulke" <magnuskulke@microsoft.com>,
	"Doru Blânzeanu" <dblanzeanu@microsoft.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Wei Liu" <wei.liu@kernel.org>,
	"Magnus Kulke" <magnuskulke@linux.microsoft.com>
Subject: [PATCH 0/5] Fix register page use for guests using mshv accel
Date: Tue,  7 Jul 2026 11:25:26 +0300	[thread overview]
Message-ID: <20260707082531.178539-1-dblanzeanu@linux.microsoft.com> (raw)

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



             reply	other threads:[~2026-07-07  8:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  8:25 Doru Blânzeanu [this message]
2026-07-07  8:25 ` [PATCH 1/5] include/hw/hyperv: move hv_vp_register_page struct definition Doru Blânzeanu
2026-07-07  8:25 ` [PATCH 2/5] target/i386/mshv: abort when hv_vp_register_page setup fails Doru Blânzeanu
2026-07-07  8:25 ` [PATCH 3/5] target/i386/mshv: remove fallback for register page get registers Doru Blânzeanu
2026-07-07  8:25 ` [PATCH 4/5] target/i386/mshv: remove fallback for register page set registers Doru Blânzeanu
2026-07-07  8:25 ` [PATCH 5/5] target/i386/mshv: fix pio handlers clobbering device-modified registers Doru Blânzeanu
  -- strict thread matches above, loose matches on Subject: below --
2026-07-07 22:16 [PATCH 0/5] Fix register page use for guests using mshv accel Doru Blânzeanu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260707082531.178539-1-dblanzeanu@linux.microsoft.com \
    --to=dblanzeanu@linux.microsoft.com \
    --cc=dblanzeanu@microsoft.com \
    --cc=liuwe@microsoft.com \
    --cc=magnuskulke@linux.microsoft.com \
    --cc=magnuskulke@microsoft.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.