From nobody Thu Aug 27 06:19:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1782934546; cv=none; d=zohomail.com; s=zohoarc; b=RMknG6Nk8nOQtbCjjiMPbeoJi/4AouQ4bCQd+K8AFlU3ONZgEfKCBvLRc+lyyR//vOUj6y8KvcVrickoClH1ajR469F9+IXhsLPbbDTmXtdD8c91x0hBRjYrW6l4XPQ1xtdxTJ60e6BZS3fhuVvlQJW5pdZpWZE3+RK6ylrhQv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782934546; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=bEdSCU5mjiDv3GADlP0fC3hWLpC5/Jr71iPsXhxCK9Y=; b=HjCDKoocxrnZkqE1WAU96t3fyB6hw7kDaYwbnw2fIUag8/pp++HDkwchbgNz9grlL+QRVykcJpgpwqvRnQinttC3l5kgO84lR9qS84OTWhF6NMBr5j89b9c9SNqY1QWbk6HNIXANNP+d1olnYbkTh7H4Ks5BPncdAD05uvn3JTA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1782934546411408.5776261673276; Wed, 1 Jul 2026 12:35:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1350654.1608168 (Exim 4.92) (envelope-from ) id 1wf0iJ-0008SC-3S; Wed, 01 Jul 2026 19:35:15 +0000 Received: by outflank-mailman (output) from mailman id 1350654.1608168; Wed, 01 Jul 2026 19:35:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wf0iI-0008Rq-Si; Wed, 01 Jul 2026 19:35:14 +0000 Received: by outflank-mailman (input) for mailman id 1350654; Wed, 01 Jul 2026 19:35:13 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3dWtFagYKCboxjfsohlttlqj.htr2js-ij0jqqnxyx.2jsuwtojhy.twl@flex--seanjc.bounces.google.com>) id 1wf0iG-0008CK-Vb for xen-devel@lists.xenproject.org; Wed, 01 Jul 2026 19:35:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wf0iG-00BwWE-CE for xen-devel@lists.xenproject.org; Wed, 01 Jul 2026 21:35:12 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3dWtFagYKCboxjfsohlttlqj.htr2js-ij0jqqnxyx.2jsuwtojhy.twl@flex--seanjc.bounces.google.com>) id 6a456be5-5cb7-0a2a0a5109dd-0a2a4509a272-10 for ; Wed, 01 Jul 2026 21:35:12 +0200 Received: from [209.85.210.201] (helo=mail-pf1-f201.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3dWtFagYKCboxjfsohlttlqj.htr2js-ij0jqqnxyx.2jsuwtojhy.twl@flex--seanjc.bounces.google.com>) id 6a456b76-97e6-0a2a45090019-d155d2c9cc4a-3 for ; Wed, 01 Jul 2026 21:33:12 +0200 Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-847a90cc5e2so1365548b3a.0 for ; Wed, 01 Jul 2026 12:33:11 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=google.com header.i="@google.com" header.h="Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782934390; x=1783539190; darn=lists.xenproject.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=bEdSCU5mjiDv3GADlP0fC3hWLpC5/Jr71iPsXhxCK9Y=; b=wdevGvroHRkQ3LBPn8LO/8Q4/dbwUPa0fQHgC2hH4FLtVNFDnb9Ni99iX3z0t+mE3D qOjR17AqEyBxoqluFq6vG86t20Q06VpufcJ8psHLRCPjhOzO1VW9yCKfDGgDoH7cL2gu iX1DSW2gUu4J1cmCj7jFKRaQ4POpvv/Te6N6qO4IL03uDsedlCQMyUBZvQy0BFAkjIAT MoAG/S4oH/1gqw6RzaPXaZi7VQ04qblXZiFVV6I8BM7zgRAOxrFeDxlAYHAros/0tnsx QbPsr4vR4nsVJ/t+mBu9Khh+BirGE55G6zjjdF5i4gaWy20bEj8cKYH+fHC4ICUiVi0L H1Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782934390; x=1783539190; h=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; bh=bEdSCU5mjiDv3GADlP0fC3hWLpC5/Jr71iPsXhxCK9Y=; b=MjB2iEASi6y3yprTDdo3iVEoD2PBItiezdrbIBmi1/DHgDkpsgrS7T3UA43/ENSQjv buO9fI1eyVX+nn0vVv28b56Di87lkf3ue58dC1nuCrw/z+uPuHDtfewv5xS7aEXbberU pCw1NSmEE9EtkdqTPh5qKVlJUpG4Pzu0bDTo3DwjWz2ZCLaO+iEciEDI7vWYUAtJqe1p HF/rClvzmboeqjUZfRchgBU88xSilL6tmqLLUDgxh3yJ627LMAFareFekKrR9gXjFAmt 9JgvIYgrEWeXVAtVhXBN7ejQB0S8QMp4h+Be6li/f34tjWRdizUMZ5yKzOaQT9awNSoL 65kw== X-Forwarded-Encrypted: i=1; AFNElJ9cCcgdlP19wYcydxmaFh88YIjaH3iij11dB49BLUEVTmv1ACuyfvdnbrjiBFuldLV5SbxB/AJ5wAM=@lists.xenproject.org X-Gm-Message-State: AOJu0YwlZXA2GV+Y7BPHtjSKsM3A2GaH0k3oqcVex5ftn48b28Zy8SiG gacIfXjZKlET5KwXOfkqEsN2m6q2ZQev+eqDmSb/g/9iafnCEQKqrmgWYYVWeGACJS01DbRhR3L LsPJu4g== X-Received: from pgh6.prod.google.com ([2002:a05:6a02:4e06:b0:c8b:19f4:6228]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:4320:b0:3bf:6c08:fb88 with SMTP id adf61e73a8af0-3bfed4b9441mr3531733637.56.1782934389876; Wed, 01 Jul 2026 12:33:09 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 1 Jul 2026 12:31:56 -0700 In-Reply-To: <20260701193212.749551-1-seanjc@google.com> Mime-Version: 1.0 References: <20260701193212.749551-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260701193212.749551-36-seanjc@google.com> Subject: [PATCH v5 35/51] x86/tsc: WARN if TSC sched_clock save/restore used with PV sched_clock From: Sean Christopherson To: Jonathan Corbet , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Kiryl Shutsemau , Rick Edgecombe , Sean Christopherson , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Ajay Kaher , Alexey Makhalov , Jan Kiszka , Andy Lutomirski , Peter Zijlstra , Juergen Gross , Daniel Lezcano , John Stultz Cc: Shuah Khan , "H. Peter Anvin" , Vitaly Kuznetsov , Broadcom internal kernel review list , Boris Ostrovsky , Stephen Boyd , linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, xen-devel@lists.xenproject.org, Tom Lendacky , Nikunj A Dadhania , David Woodhouse , David Woodhouse , Michael Kelley , Thomas Gleixner X-purgate-ID: tlsNG-bad1c0/1782934392-573AB986-DA0568FE/13/0 X-purgate-type: clean X-purgate-size: 1426 X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1782934547195158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that all PV clocksources override the sched_clock save/restore hooks when overriding sched_clock, WARN if the "default" TSC hooks are invoked when using a PV sched_clock, e.g. to guard against regressions. Reviewed-by: David Woodhouse Signed-off-by: Sean Christopherson --- arch/x86/kernel/tsc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index a762cb5cec0f..7473dcab4775 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -947,9 +947,17 @@ EXPORT_SYMBOL_FOR_MODULES(recalibrate_cpu_khz, "p4-clo= ckmod,powernow-k7"); =20 static unsigned long long cyc2ns_suspend; =20 +static __always_inline bool tsc_is_save_restore_needed(void) +{ + if (WARN_ON_ONCE(!using_native_sched_clock())) + return false; + + return static_branch_likely(&__use_tsc) || sched_clock_stable(); +} + void tsc_save_sched_clock_state(void) { - if (!static_branch_likely(&__use_tsc) && !sched_clock_stable()) + if (!tsc_is_save_restore_needed()) return; =20 cyc2ns_suspend =3D sched_clock(); @@ -969,7 +977,7 @@ void tsc_restore_sched_clock_state(void) unsigned long flags; int cpu; =20 - if (!static_branch_likely(&__use_tsc) && !sched_clock_stable()) + if (!tsc_is_save_restore_needed()) return; =20 local_irq_save(flags); --=20 2.55.0.rc0.799.gd6f94ed593-goog