Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp547826rwd; Thu, 1 Jun 2023 03:52:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42qQrSJm0pqwBo39Cu09fASzJibpuRSSuVDFuRA0tgKIxeoz4y1zPLrf68CMklITGaniFn X-Received: by 2002:a05:6808:1291:b0:398:f91:966e with SMTP id a17-20020a056808129100b003980f91966emr6968355oiw.57.1685616739944; Thu, 01 Jun 2023 03:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685616739; cv=none; d=google.com; s=arc-20160816; b=xm5vbvjs1bMl55YfAOe8y8v8418g20KEdKBGBgq2OwrPMrZiSSw7yWWwCKD8pVQRBe 1ScY1N1fTWzSnEpq8NJEs16Zeg/MsNdPI6/NR6kL7Hx1/MpMPGYVgQxRwG2tSeuTwfww ccohzGdJ7+aCDaWq5PyOzuU9dm0ZRZ82myUNuoa+IDHwtm9f8To7tXIVzKXHqDq23Awt eP3fHssIffXiEmYYNRC0f+bcDPVIp+iT+BTALOSB6Ubj0g/AtGZi7c0z/lK52aps1SVp rUa5xPEgFIBX3h7kB9unkD21dfPXIXud70u4eH5d3BuPEWrfjWSbJ8IJ4DvIpZ4yw5Zj qrHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=TgVq7drZsJEBdL8AdFHKWacRbn4TiHQy0G4VwBLZWg8=; b=fRPOlw7A0LQgmkXRZ2cqC13qwmPj3kyeL6XxvMUbS2hXalzOqCXYHaRaBH5y1AzlFR ZXK4xlDrwH152rdkMmuCAqgxHPwYze05XZ0HIbYW+85mp1ocLeT/qDjgZ7/vPEgknAdn dB8NMaTELjDMLstwOdLSSDkGifE6MA+QHP56oVOBwfTaqDLCqi/jI5x78mEhlFV5vapz L1xSD/wVFokX7dD0M/CGLpu9JpLtEmz/FtlLFR3ZS2CJHhoJDN1Q9WQcn0PXMKhAgYNx RSe92aMGAmfdNbPl18qOL02MlwOHsZhLsoTBDkuJ6NFf6J2+xAd0YOrf18sE5f6w37AK cSSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qQ8ijTwt; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020aa79468000000b0065024e5048csi898592pfq.301.2023.06.01.03.52.07; Thu, 01 Jun 2023 03:52:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qQ8ijTwt; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231594AbjFAKb2 (ORCPT + 99 others); Thu, 1 Jun 2023 06:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230399AbjFAKb0 (ORCPT ); Thu, 1 Jun 2023 06:31:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46CBB8E; Thu, 1 Jun 2023 03:31:25 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685615483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TgVq7drZsJEBdL8AdFHKWacRbn4TiHQy0G4VwBLZWg8=; b=qQ8ijTwtVbkGlFTXxnt/uY1ol7lxQwHP3oCigXefjoA2dlYMXXRCSa7uHBQu7kILHooIJi LMMHexiFC/VCp3YLjLISvUgfUWA6H4wRd++fPz80U9UygbIGTl+0vguAqtVv1axTxRyLdJ 2BSEsPgVm1f611w7Vm46vT3KZP3phnUqACE/gAdUTS+0PIlizJYcxdKH5zkvhRnNBLotlS nHkQxo4Y1Hj0OdKilbvrLV8yvRJjAoDyqVeZ/RYNgPDt5tn7gK4dgjWap4e9pTqpHH1VpR obFeiSPLwF2xLrHVRwl85gv63VSmpkKUspNAE5CGKpdAkhBgi6c0O8nXV7biWA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685615483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TgVq7drZsJEBdL8AdFHKWacRbn4TiHQy0G4VwBLZWg8=; b=OVUPsZJRJR6sR2J3EcBU7/UWxlDpug4m+eclZl8j12J4HOgjghePNUsGty6A/DvSfafVwi MGZ/5QoUOWTFEgBQ== To: Peter Zijlstra , Muhammad Usama Anjum Cc: Jonathan Corbet , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "open list:DOCUMENTATION" , open list , "Guilherme G. Piccoli" , Steven Noonan , kernel@collabora.com Subject: Re: Direct rdtsc call side-effect In-Reply-To: <20230601085602.GR4253@hirez.programming.kicks-ass.net> References: <6719fb05-382c-8ec4-ccda-72798906a54b@collabora.com> <20230601085602.GR4253@hirez.programming.kicks-ass.net> Date: Thu, 01 Jun 2023 12:31:22 +0200 Message-ID: <87jzwneao5.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 01 2023 at 10:56, Peter Zijlstra wrote: > On Thu, Jun 01, 2023 at 01:45:35PM +0500, Muhammad Usama Anjum wrote: >> We are thinking of saving and restoring the timestamp counter at suspend >> and resume time respectively. In theory it can work on Intel because of >> TSC_ADJUST register. But it'll never work on AMD until: >> * AMD supports the same kind of adjust register. (AMD has said that the >> adjust register cannot be implemented in their firmware. They'll have to >> add it to their hardware.) >> * by manual synchronization in kernel (I know you don't like this idea. But >> there is something Windows is doing to save/restore and sync the TSC) > > Wine could set TIF_NOTSC, which will cause it to run with CR4.TSD > cleared and cause RDTSC to #GP, at which point you can emulate it. We should ask Microsoft to do the same. That'll fix the direct RDTSC usage quickly. :)