[PATCH v2 04/28] KVM: apply nGPA->GPA translation to KVM_HC_CLOCK_PAIRING

From: Paolo Bonzini

Date: Fri Sep 18 2026 - 04:16:21 EST


KVM_HC_CLOCK_PAIRING writes to a guest physical addresses. Treat it
as an L2 address when running nested, which is consistent with the
Hyper-V TLB flush hypercalls for example.

This is technically backwards incompatible, but it should be extremely
rare and thus we can treat it as a bugfix, I think.

Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
arch/x86/kvm/x86.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4b3681796c75..2fbaa070f741 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7217,6 +7217,11 @@ static int kvm_pv_clock_pairing(struct kvm_vcpu *vcpu, gpa_t paddr,
clock_pairing.flags = 0;
memset(&clock_pairing.pad, 0, sizeof(clock_pairing.pad));

+ paddr = kvm_translate_gpa(vcpu, &vcpu->arch.gva_walk, paddr,
+ PFERR_WRITE_MASK | PFERR_GUEST_FINAL_MASK, NULL, 0);
+ if (paddr == INVALID_GPA)
+ return -KVM_EFAULT;
+
ret = 0;
if (kvm_write_guest(vcpu->kvm, paddr, &clock_pairing,
sizeof(struct kvm_clock_pairing)))
--
2.52.0