From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (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 13580471257 for ; Tue, 4 Aug 2026 23:39:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785886784; cv=none; b=q9+nwRFUIANnC5zIKUo6qZAYdzQs0+8jacpfZKoimjoviMt+IA9q5Z6nAn1lZWFUflxU0HuC86MOpH1N4u7okjbtjTdgmZHWB6ED9E4jlqeV+ywwIfuwRsjBh9Af3zhA8PRdHh74xVhtHtcAfcrIJ3wePjq/nH9rZuempz5KAvU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785886784; c=relaxed/simple; bh=GbDDxRlbvftUHclixcrVm6MYfFPNZU3v3cMbJe0/dSA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=u6QLYsuhviobHoEZyTCwf87sQ6QxYUpqnRnmKZG/iyZFjt0oiVeDW/6Smmod4bHs2IP3KquBp2oFbHCmKBCNAos9JxKf4liYvr8fcHNZ14HvhwnE21oeDmoHS/8VosgmOgB8ZcZmgtW7uvJfIKTEQLfn/8oBl1ZIf6xp6SDQJcY= 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=UG4kPBeo; arc=none smtp.client-ip=209.85.210.200 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="UG4kPBeo" Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-84a251c2e3eso1948613b3a.1 for ; Tue, 04 Aug 2026 16:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785886782; x=1786491582; 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=YqOvePDEGD7lsMrnIIEP459A6germ9Y0ToT6dwrTiHQ=; b=UG4kPBeoX/nzVapSgvaruEfaIW1qg4HcMXPjHLpr77Xc0aowSVJI0EX6v5OZZ4eJ3a CbabsN36j1w98lxtQJ6nVUwLTLQ/Hd+pjshrIFoIcEfIAnThF+tn+LA+S+nNGb7OouF2 /ulusf7C9nHp+u9xHVECFw1KXzlbbEYi/3DhEK7jb2OTVMExnp0miJt1cN13ybEmxPlJ h/bhbB64vU1HFim9MMGErXYV9OG/wUKuTNo1trbqmf4D2IiGZ9+RzGimLA9oXzae4N8V eVJYDIyeIxTZOAygCt2h6QsVXwBzEwiourfJtdeqhtEnamc0Smgv3GsLTEOhzyycHnC/ zjvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785886782; x=1786491582; 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=YqOvePDEGD7lsMrnIIEP459A6germ9Y0ToT6dwrTiHQ=; b=It2Zb+jxrjRL5zb1kSvfbrHXn/LvaD1SSVYg93W7Y1bof64Iw6vgjuMC9K9pbGrcPY 0ZnmhDbQ54kry6poaqafaktDQe0h6KeY1DpmJKVXHvx6cn+xgnuHyuj8DTjZIn8ZKmjs TXZj8NNdCES5O/eVJCMqm/qo44sm0CWme8CkYFPqInfA7mtZuKQW1QF5dPsJE4U+Hkmk SLahkhpXntrhrEz9jTXKiTo9hQyheu1jBaJoQAoqeBnuMi3EjUynkKVin0gWlg/G8Ekr 64tct+FrElM2dfVVJ0W0ZvhQKuHpqxo1zWm9sWVNVRW1qf7UiS2JHSY/unx1D0ksLpaj 2RvQ== X-Forwarded-Encrypted: i=1; AHgh+RruW4bG3NrQfX7EDbagm9dNOMkq6HqjZU62JyEgvab8KWC3V7s8anwvDcJsafaUcZ+88T77YWOKFprzXzM=@vger.kernel.org X-Gm-Message-State: AOJu0YyO64WfEiv3iAJP+ezppKcAsP7EhCQoQtJyX/UGLFlur00iELLB ia39MpsvsTuCAbDbQs2hoRWa8H0gjCwy1gC/ZCA4SRdH4R8FSuWtzbG2dhy9gUqn8yH4LoX7goV ET3d7XQ== X-Received: from pfnx14.prod.google.com ([2002:aa7:84ce:0:b0:84a:894f:23f2]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:a116:b0:848:2a69:97be with SMTP id d2e1a72fcca58-84f2dbf31b3mr2422634b3a.10.1785886782216; Tue, 04 Aug 2026 16:39:42 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 4 Aug 2026 16:39:18 -0700 In-Reply-To: <20260804233923.3504629-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: <20260804233923.3504629-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.571.g244d577d93-goog Message-ID: <20260804233923.3504629-15-seanjc@google.com> Subject: [PATCH v8 14/17] 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 providing 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 63702be799cc..070a12535788 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.571.g244d577d93-goog