From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C423B3F58C1 for ; Mon, 10 Aug 2026 22:55:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786402527; cv=none; b=h92JO1gGvqWg29wi0v+Iy9WqIi48POllO5xokVmvlHeRwbiSgfktNNOiPxw2jtwfOOwoTMTLEvqpta/qXoMoPDixEMxZ79jg7OYgCFwFNAgkJpI6GEaT1eEVDIRwyoIkcsr59BB/2cKUUaS6X9B0p4Bgw7d6e8gyPdwUu9/eCB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786402527; c=relaxed/simple; bh=AnYa9DsB3pC5ovwAQxf38sSPtNt8qCo49QzZbAmqaJw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gn2PNpq2yMeaRBVDeTmXIgWkzsQqCndrWa7Fmj5oTtVHUT+4y4+s+3nNn87Xh1faPx2ZRCC9OHer7iC+doO1CpLuz5l0S/t3v89Sh1yFXIXHzbw2GekBUb5V2nUPrr6Vzx6ZV802ZF3HoBaQIU0iAtxH8la66/nNN+Cw4sxxxps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oYqa5uQo; arc=none smtp.client-ip=209.85.210.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oYqa5uQo" Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-848568a6f62so4849612b3a.0 for ; Mon, 10 Aug 2026 15:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786402522; x=1787007322; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=lVlimL3Aj8kSsMDGDfvignTmc+0OEOZcp7iMQk31IH8=; b=oYqa5uQoDsY/Zs77sINbsZ+SUmOQ3OvFoQQ6u363qFkdmJHGep3VM84qIwUpOB+qCk VuxylniXkthXJT+U5SXZKNh9swTea9m/+Njf3QNvWax9bGHkngwT6sWabhthhbqfexXa q+7+bcpqKW0qIsA6+hf4F9GHKjHTOO6tnt2lLKERbM9zx0wGo2ufyEjDclyTzu7FJ/bJ r2+MB1kFpzAXab5Wl5RDotlGZDpJf0aphRIdHjZdKAzZh8nbkjg9vD8miPsjzEt55lje PotrATiVin8iAWKjpq+/7MzfSwOHfcDZUwuJgnBn7sqfnf84WRDv8BeaAkxAxE8qJIRG rmHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786402522; x=1787007322; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=lVlimL3Aj8kSsMDGDfvignTmc+0OEOZcp7iMQk31IH8=; b=IkM4Dw5tF+G8tIbMaK6rbqYguVuHfctqXmD8Ivf5HDnZJcGfP9luF82GO8nbMqIXrF mVFGJMD612u4QKQ397hqcoA7ttWBel20KQir+kCP/pvsm+/KRxgDk/oGR47HeUXMM1nF 5sVzBR4YMunnRI1I5ZBx5QVPCnG9CIJbyn1yoKIbcFNbZT/TI2n1/SHaNAgH7nmOA3d9 TspWBamG8CyDfA9tMUeXqNeTVfBnmmTLf6iu0R4u5JgLhWWs3U+W+zCjV56mCPr+VePK AH1mHdtO0eqnJRM3lyhYaesR4TdDwV+Flb/jWK5ae1bxDuCXUoSX0HCLUxbcH31Wvbx7 qUpw== X-Forwarded-Encrypted: i=1; AHgh+Rpf74yueMmoS8UdnOuNQmCG4ysoiriXEmlZcqBIC4/gEOhJ3R5RkhP8xERzflBe0TF+Rw1SpSRr3qKgrCE=@vger.kernel.org X-Gm-Message-State: AOJu0YxAYduCjJIWCpJnNZ2QS640uqvUVq0YEsAq+TwcZHEUGV5JoHwe sSraVg71zFEXCjrOAVPV1CMAowq+2hiWHsnrI6eNM1mzxbBkOqIx7c53NmZ9EU+WBxvfPSRxLf8 qRWDWvQ== X-Received: from pfuu5.prod.google.com ([2002:a05:6a00:6f85:b0:848:4e44:7f19]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:2e19:b0:845:4928:8655 with SMTP id d2e1a72fcca58-84f2e0edaddmr45671680b3a.39.1786402521754; Mon, 10 Aug 2026 15:55:21 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 10 Aug 2026 15:54:53 -0700 In-Reply-To: <20260810225500.869288-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260810225500.869288-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.679.g6767b8d81c-goog Message-ID: <20260810225500.869288-16-seanjc@google.com> Subject: [PATCH v9 15/21] KVM: x86: Make master clock logic in guest PV clock updates 64-bit only From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Durrant , David Woodhouse , Dongli Zhang Content-Type: text/plain; charset="UTF-8" Wrap kvm_guest_time_update()'s entire use_master_clock block in #ifdef CONFIG_X86_64 and provide a hardcoded-to-false variable for the 32-bit path, as use_master_clock is never true on 32-bit (host_tsc_clocksource is only set under CONFIG_X86_64) Keep the local "ka" variable outside of the 64-bit-only code as it's also used for Xen code, but tag it as potentially unused since it's not used on 32-bit kernels without Xen emulation. For all intents and purposes, no functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a8dde1d898fb..d3630b2bfd3b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1796,22 +1796,21 @@ static void kvm_setup_guest_pvclock(struct pvclock_vcpu_time_info *ref_hv_clock, int kvm_guest_time_update(struct kvm_vcpu *v) { + struct kvm_arch *ka __maybe_unused = &v->kvm->arch; struct pvclock_vcpu_time_info hv_clock = {}; u64 tgt_tsc_hz; - unsigned seq; struct kvm_vcpu_arch *vcpu = &v->arch; - struct kvm_arch *ka = &v->kvm->arch; s64 kernel_ns; u64 tsc_timestamp, host_tsc; + + /* + * If the host uses TSC clock, then passthrough TSC as stable + * to the guest. + */ +#ifdef CONFIG_X86_64 bool use_master_clock; + unsigned int seq; - kernel_ns = 0; - host_tsc = 0; - - /* - * If the host uses TSC clock, then passthrough TSC as stable - * to the guest. - */ do { seq = read_seqcount_begin(&ka->pvclock_sc); use_master_clock = ka->use_master_clock; @@ -1820,7 +1819,9 @@ int kvm_guest_time_update(struct kvm_vcpu *v) kernel_ns = ka->master_kernel_ns; } } while (read_seqcount_retry(&ka->pvclock_sc, seq)); - +#else + const bool use_master_clock = false; +#endif /* * Ensure reading the TSC+frequency pair is done on the same CPU. When * NOT using the master clock, the TSC frequency may vary between CPUs. -- 2.55.0.679.g6767b8d81c-goog