Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Florian Schmidt <flosch@nutanix.com>
To: Cornelia Huck <cohuck@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>,
	Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Cc: kvm@vger.kernel.org, "Philippe Mathieu-Daudé" <philmd@mailo.com>,
	qemu-devel@nongnu.org, "Zhao Liu" <zhao1.liu@intel.com>,
	"Florian Schmidt" <flosch@nutanix.com>
Subject: [PATCH 0/2] Support for Hyper-V's HvExtCallGetBootZeroedMemory()
Date: Fri, 31 Jul 2026 09:51:10 +0000	[thread overview]
Message-ID: <20260731095112.2975175-1-flosch@nutanix.com> (raw)

This patch series implements two new Hyper-V hypercalls. The primary goal is
to support "zeroed memory" enlightenment via HvExtCallGetBootZeroedMemory().
To do so, we also need to implement HvExtCallQueryCapabilities(). While
HvExtCallQueryCapabilities() uses another bit in EBX on CPUID leaf
0x40000003, it then allows the guest to query for further "extended"
hypercalls via the return value of that call.

HvExtCallGetBootZeroedMemory() allows a Windows guest to enquire which areas
of memory that were provided by the hypervisor are already zeroed out,
meaning that there's no need for the guest to do so again. This has obvious
performance benefits.

To get a rough idea of the performance benefit, looking at a 4-core, 64GB
Windows 11 guest, we can see that an otherwise idle guest takes a bit less
than 90 seconds to finish zeroing and settle down from the time the qemu
process is started. If we look at CPU usage for each vCPU task 90 seconds
after starting, we get:
1559 498
1294 343
1451 314
4015 2729
Conversely, after enabling HvExtCallGetBootZeroedMemory(), CPU usage is
reduced:
1583 458
1441 361
1279 312
1337 264
These are taken from the respective /proc/<pid>/task/<tid>/stat entries,
denoting user and system time per "CPU X/KVM" task, in ticks.
We can clearly see which to which vCPU fell the tasks of zeroing.

It also has the benefit of not touching all pages at boot. This can be useful
if, for example, the VM is started with a balloon target already set to
overcommit memory on the host. In this case, we don't risk memory usage spikes
on the host if the VM touches all memory before the balloon can catch up.

Major changes since RFC v2:
* integrated KVM ioctl (under review in parallel) into
  HvExtCallBootZeroedMemory handler.

Florian Schmidt (2):
  Add HvExtCallQueryCapabilities
  Add HvExtCallGetBootZeroedMemory

 docs/system/i386/hyperv.rst      |  14 +++
 hw/hyperv/hyperv.c               | 202 +++++++++++++++++++++++++++++++
 include/hw/hyperv/hyperv-proto.h |  12 ++
 include/hw/hyperv/hyperv.h       |  13 ++
 include/system/physmem.h         |   8 ++
 linux-headers/linux/kvm.h        |  15 +++
 system/memory.c                  |   7 +-
 system/physmem.c                 |  50 ++++++++
 target/i386/cpu.c                |   4 +
 target/i386/cpu.h                |   2 +
 target/i386/kvm/hyperv-proto.h   |   6 +
 target/i386/kvm/hyperv.c         |  14 +++
 target/i386/kvm/kvm.c            |  91 ++++++++++++++
 target/i386/kvm/kvm_i386.h       |   2 +
 14 files changed, 438 insertions(+), 2 deletions(-)

-- 
2.47.3


             reply	other threads:[~2026-07-31  9:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  9:51 Florian Schmidt [this message]
2026-07-31  9:51 ` [PATCH 1/2] Add HvExtCallQueryCapabilities Florian Schmidt
2026-07-31  9:51 ` [PATCH 2/2] Add HvExtCallGetBootZeroedMemory Florian Schmidt

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=20260731095112.2975175-1-flosch@nutanix.com \
    --to=flosch@nutanix.com \
    --cc=cohuck@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@mailo.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox