Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH 0/3] KVM: x86: Support hibernation of a nested Hyper-V
@ 2026-10-05 19:24 Mushahid Hussain
  2026-10-05 19:24 ` [PATCH 1/3] KVM: nVMX: Clear stale vmcs02 sync flag in free_nested() Mushahid Hussain
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Mushahid Hussain @ 2026-10-05 19:24 UTC (permalink / raw)
  To: kvm
  Cc: Sean Christopherson, Paolo Bonzini, Vitaly Kuznetsov,
	K . Y . Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	linux-hyperv, linux-kernel, nh-open-source, mushi.shar

A Windows guest with the Hyper-V role enabled runs its own hypervisor
(hvix64) nested under KVM. When KVM advertises the Hyper-V time and
frequency MSRs, hvix64 lets KVM own the partition reference time. It
then offers hibernation to Windows only if KVM also advertises CPUID
0x40000004 EAX bit 20 (RestoreTimeOnResume), and on resume restores
the saved TSC and reference time through HvCallRestorePartitionTime
(0x103). Both are reserved in the TLFS and defined in Microsoft's
hvdef crate.

Patch 1 fixes a stale nVMX sync flag that zeroed the vmcs12 segment
state hvix64 reloads on resume. It stands alone and is tagged for
stable. Patch 2 is a refactor with no functional change. Patch 3
advertises the bit and implements the hypercall, restoring kvmclock
and every vCPU's TSC inside one pvclock update.

Tested on Windows Server 2025 with Hyper-V running, guest initiated
hibernate and resume, under QEMU with a matching CPU property:
https://github.com/hmushi/qemu/tree/hv-restore-time-on-resume

Mushahid Hussain (3):
  KVM: nVMX: Clear stale vmcs02 sync flag in free_nested()
  KVM: x86: Extract __kvm_set_clock() from kvm_vm_ioctl_set_clock()
  KVM: x86: hyper-v: Implement HvCallRestorePartitionTime

 arch/x86/include/asm/kvm_host.h |   5 ++
 arch/x86/kvm/hyperv.c           |  36 +++++++++
 arch/x86/kvm/vmx/nested.c       |   1 +
 arch/x86/kvm/x86.c              | 131 +++++++++++++++++++++++++++-----
 arch/x86/kvm/x86.h              |   1 +
 include/hyperv/hvgdk_mini.h     |  12 +++
 6 files changed, 168 insertions(+), 18 deletions(-)


base-commit: 6bd2905303c58679e303941b7d8ae8c074cd95ce
-- 
2.47.3


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

end of thread, other threads:[~2026-10-06  5:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-05 19:24 [PATCH 0/3] KVM: x86: Support hibernation of a nested Hyper-V Mushahid Hussain
2026-10-05 19:24 ` [PATCH 1/3] KVM: nVMX: Clear stale vmcs02 sync flag in free_nested() Mushahid Hussain
2026-10-05 19:24 ` [PATCH 2/3] KVM: x86: Extract __kvm_set_clock() from kvm_vm_ioctl_set_clock() Mushahid Hussain
2026-10-05 19:24 ` [PATCH 3/3] KVM: x86: hyper-v: Implement HvCallRestorePartitionTime Mushahid Hussain
2026-10-05 19:38   ` sashiko-bot
2026-10-05 22:30   ` David Woodhouse
2026-10-06  5:08 ` [PATCH 0/3] KVM: x86: Support hibernation of a nested Hyper-V David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox