Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp562475rwd; Thu, 1 Jun 2023 04:03:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7M2zVPlPGiSmDeLJWCN/Omk6Ka0E65Mfe9fWoyH4Db70nlOQWptCnuF8nbZEG7tmHes41J X-Received: by 2002:a05:6a20:c90b:b0:10c:9773:5e6 with SMTP id gx11-20020a056a20c90b00b0010c977305e6mr6062424pzb.47.1685617412882; Thu, 01 Jun 2023 04:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685617412; cv=none; d=google.com; s=arc-20160816; b=Fj41Tp2QokvfNeSmt1r7YDfojAqvmwRQoYEh78/Xm20STMOdq4gSaeImtl947w9Dy4 mrn81IliS1iONU/JtFPyARPOLXmnu8WCPkgV6m0wxIHIN7/IdsUizjYQLIbv7iGbfohY q6GoNTRNgm17IUy+EuY+ZJOKiyEJ2vDr9uziDGEKSYMp3wJ58zIYydnpzqz0sly+9z+E g2UAADFReCjoD4wL1RFFTjj+ymSLWIKRsJOM502913AVBsRHsVGMWNV0YBsqPhnu2Or6 XoWFojZw/fNOFD2qORTv/JIGg8kdL71tSEaMBvVayFLGNNj/HiMMDUTlop1h4bAeL3Tr vAYQ== 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=oBG6LSgcL4OvuvT5P5sO0vfG/HZ7VoTB8zrMnek3QXE=; b=N/fnoPGZki4mdHjxm4bydCcTfkKDRt9Zi1UFRWPXn834O6sWCMvKnTowIra6cpsS+W bgKqJ1F8DOkSatPb2oZzmPcGyWKeCrSPujJUxiuQhxH/OViGMpYgRnB93rHFosNkQ/PW OR121kIcUBdE6BlQAHNVaHWflCBCUksNFEjrira2D45VDtjyfnxoSuuD2BhZ16KGKt9b 7Py2o9/V7M1BYUC2fIDi5cXheqRK23Me1H+fDPF6L0cNyqEsK1OlLOUFzqHYoL0v4Twb Nq0PP/JjqFBrRN0hJUy/88W3A7XzYDQderPxdwcXXQrVpPNOcEg9aJCWtbfub2XqKc2M WTLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ok0pAI37; 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 k124-20020a636f82000000b0053fb1d02b00si1024658pgc.383.2023.06.01.04.03.18; Thu, 01 Jun 2023 04:03:32 -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=Ok0pAI37; 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 S233436AbjFAK13 (ORCPT + 99 others); Thu, 1 Jun 2023 06:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233409AbjFAK07 (ORCPT ); Thu, 1 Jun 2023 06:26:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D92F610CE; Thu, 1 Jun 2023 03:26:05 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685615163; 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=oBG6LSgcL4OvuvT5P5sO0vfG/HZ7VoTB8zrMnek3QXE=; b=Ok0pAI37eBUUxtyD72XEi/kWXDtqF2cyYqQakQgqv1gcVzpImTA0v1e4tUg95X+deC5XY9 lOx47kKlGoTmsXGCE7EJ8FFCDq0IIAETyX9nAxQzzMabggRrIUwUDHi3Q38QabiIEi/O69 lsy60XfNp/vNnOw4dz9L9Gsa11esS6vzwsjT7S0pn071wo0R1w/ccoe4RpM7TvQdijxVLK 350OsLzpSOPzbxwTX7gY8DVi3dtt4lbk4LWsqX0zWOwWz3FSomSuS5pM54azU6D79g2DK1 w5RLaq2RkizcDigKlOoH9QpZygySmYqEvWyDw9WX9SUW02hgYzsZ3BbnhSx2Tg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685615163; 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=oBG6LSgcL4OvuvT5P5sO0vfG/HZ7VoTB8zrMnek3QXE=; b=/tzvg4GZZVLmApTKNWPjobcVJPi6uoWunc8Omj06UJ53lq6lcsRwJ2UMOKZxbB4erfpMIa N71tNcFW6TSNEOBw== To: Muhammad Usama Anjum , 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" Cc: Muhammad Usama Anjum , Steven Noonan , kernel@collabora.com Subject: Re: Direct rdtsc call side-effect In-Reply-To: <6719fb05-382c-8ec4-ccda-72798906a54b@collabora.com> References: <6719fb05-382c-8ec4-ccda-72798906a54b@collabora.com> Date: Thu, 01 Jun 2023 12:26:02 +0200 Message-ID: <87mt1jeax1.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 13:45, Muhammad Usama Anjum wrote: > As more and more things are being added to Wine, Windows application can be > run pretty easily on Linux. But this rdtsc is a big hurdle. What are your > thoughts on solving this problem? Who would have thought that rdtsc() in applications can be a problem. Interfaces to query time exist for a reason and it's documented by Microsoft: https://learn.microsoft.com/en-us/windows/win32/dxtecharts/game-timing-and-multicore-processors But sure, reading documentation is overrated... > 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) Synchronizing TSC by writing the TSC MSR is fragile as hell. This has been tried so often and never reliably passed all synchronization tests on a wide range of systems. It kinda works on single socket, but not on larger systems. We spent an insane amount of time to make timekeeping correct and I'm not interested at all to deal with the fallout of such a mechanim. I could be persuaded to make this work when TSC_ADJUST is available, but that's it. But even that might turn out to be just a solution for the moment because there is a plan on the way that TSC grows an irreversible lock bit, which prevents everything including SMM from fiddling with it, which in turn spares the TSC_ADJUST sanity checks post boot. Thanks, tglx