From: David Woodhouse <dwmw2@infradead.org>
To: Mushahid Hussain <hmushi@amazon.co.uk>, kvm@vger.kernel.org
Cc: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
"K . Y . Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Long Li <longli@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
nh-open-source@amazon.com, mushi.shar@gmail.com
Subject: Re: [PATCH 0/3] KVM: x86: Support hibernation of a nested Hyper-V
Date: Tue, 06 Oct 2026 07:08:00 +0200 [thread overview]
Message-ID: <9405d5059486b587c5c7091bf9fa04766c650c1c.camel@infradead.org> (raw)
In-Reply-To: <20261005192431.87317-1-hmushi@amazon.co.uk>
[-- Attachment #1: Type: text/plain, Size: 2299 bytes --]
On Mon, 2026-10-05 at 19:24 +0000, Mushahid Hussain wrote:
> 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
Please test
https://git.infradead.org/?p=users/dwmw2/linux.git;a=shortlog;h=refs/heads/kvmclock10-hmushi
I kind of wish we didn't have to do this in the kernel at all, and
could punt to userspace. But we don't have that plumbing for Hv
hypercalls, do we? So we'd have to invent that, and then also a way for
userspace to set the sequence in the TSC page (which I wired up to be
restored as I think that's probably what should happen; can we
confirm?).
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 6179 bytes --]
prev parent reply other threads:[~2026-10-06 5:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` David Woodhouse [this message]
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=9405d5059486b587c5c7091bf9fa04766c650c1c.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hmushi@amazon.co.uk \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=mushi.shar@gmail.com \
--cc=nh-open-source@amazon.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox