On Fri, 2026-07-31 at 09:51 +0000, Florian Schmidt wrote: > 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.
Hi Florian, was there any result from the community call in September? I was looking at this and found that windows only uses the hypercall in winload.efi once and then passes the result on to the kernel. Maybe it would be fine to track until this is called with userfaultfd UFFD_FEATURE_WP_ASYNC setup and PAGEMAP_SCAN in the first call of the hypercall and report/monitor nothing afterwards? I also took a look at virtualbox. It seems to report all normal memory as zeroed: https://github.com/VirtualBox/virtualbox/blob/b6bea72111fcff48f31c57c9f66365b1d3301bb9/src/VBox/VMM/VMMR3/PGMR3Phys.cpp#L1513 This seems wrong, but it is interesting that they have had it enabled for some time (Looks like at least 06.2024 for the current version). Thanks Steffen > > 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(-)
