Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp413764rwd; Thu, 1 Jun 2023 01:54:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eVAZ+XNqz0uAf3hMTtcL1ng+mbiN/VhoaP1tQuQz0Y6Y6v1oEcR8hlk7TEPxlyWpDhiXV X-Received: by 2002:aa7:88cf:0:b0:63d:24d0:2c32 with SMTP id k15-20020aa788cf000000b0063d24d02c32mr10901775pff.33.1685609683460; Thu, 01 Jun 2023 01:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685609683; cv=none; d=google.com; s=arc-20160816; b=0T0pluLsSBcJLZ/YzrhLtWRaSoc3IYfKhocNbV8+4YH13zhSi44JZwoxN5MztTuvyW bf6WSEvP4FT6ikWGitphgL1lM7cmXU8pIU+KIIMJn1QYS6xweiHvxt+fidsqNtsmIHdO SKPnUnPMyW8gqng/8z1aDZU9pPYXyXUwZBpcviT0uxu7+Owz0oOX9C7Tg4eGIwDriLqQ /vE3EWr0F8ukOSJld+awgjkPmWLO0AIbI+wbVNixBUJAIvTZDcTFh7TJt4GdeS+iDCIE OhdWCS+klLGL8onyxD7glSMYnb4erzQU2kVV0Mwf1aDukbeMd4H6q6c3ouqiTajD3TT9 SAbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:from:to :content-language:cc:user-agent:mime-version:date:message-id :dkim-signature; bh=z3s6dqpEmFAltLG2BJvUC7wor1y+sdyJtbPs2BVpOFE=; b=vqVgB3grKIou2lySikcN0o7EqUxT42UgWIClf2y+auzOS3Yfy7+z0qtfahmE7HJHFh 1reJzDtH4WnU8/K2TiYdmOWL/qc18vZjtxUA+dLXS8T0mTENR3ZdEH5M6IYG6I22Cv5z iCV+C9914K+SO71TsWQQurgAke5WgrjTg1T59yYIZz7HtCiB4/Td2T+tDWcQbRm5C3+S JXEJKcxDFIz548aDxbs1yDoSKkGTTX2uTsCDB40sVaZ15QxnoyInxkTc//kLSO3ucY4L C7uOiUspcklM1/p1ogjRZLKagJr0sqwIXa2lhB4UwjGZ19FIrI4zby9sl1TKUYUqvFDR lQdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FgYlzH1l; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020aa78ec8000000b0064d3a44770esi1779828pfr.84.2023.06.01.01.54.31; Thu, 01 Jun 2023 01:54:43 -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=@collabora.com header.s=mail header.b=FgYlzH1l; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbjFAIp4 (ORCPT + 99 others); Thu, 1 Jun 2023 04:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232208AbjFAIpp (ORCPT ); Thu, 1 Jun 2023 04:45:45 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 822A6125; Thu, 1 Jun 2023 01:45:43 -0700 (PDT) Received: from [192.168.10.48] (unknown [119.152.150.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id E24FD660322C; Thu, 1 Jun 2023 09:45:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685609141; bh=b9IUPiW6SWyyXL2LT/U9gtQHuJcEEu15KtqA0O6EN+g=; h=Date:Cc:To:From:Subject:From; b=FgYlzH1lShmkSH8uSRNhevv1vPqgd9wvZu5AA/nzE4JiznqoIApbmO1DskeWRW1TS +7WItDIfI4PwQmtPaj5K9yRfB4PT4u27KSeVElekiPyx3MjLOXQ2+pDAmbPSKxjX53 orIgwxM0sAz8HqGGmd4DKMQVKkQlnvy34MzXtU8aN2RHHndqdzEBLDhmXRg0cTszRm +D9QpZ3l023GAMRR867joNUWC2sWUFbTx9u7GgZ6yvim8HtSvkX38pJhPQVcVPECSs wo+rTWZNgIIIWTrkmkAEtIg9EcstmepusuzXASZYTohcDrO+z5bCWRIDrxKYDzvpA4 o9cedIeKvcEzg== Message-ID: <6719fb05-382c-8ec4-ccda-72798906a54b@collabora.com> Date: Thu, 1 Jun 2023 13:45:35 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Cc: Muhammad Usama Anjum , Steven Noonan , kernel@collabora.com Content-Language: en-US To: Thomas Gleixner , Jonathan Corbet , Thomas Gleixner , 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" From: Muhammad Usama Anjum Subject: Direct rdtsc call side-effect Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Hi, I've been looking into a problem where Windows applications misbehave across suspend/resume when run on Wine on x86. These applications see time going backwards. The timestamp counter (TSC) is reset when system resumes. In case of Windows on Intel and AMD, the timestamp is saved and restored when the system resumes from suspend. These applications read timestamp by rdtsc directly. These calls cannot be intercepted by Wine. The application should be fixed such that it handles these scenarios correctly. But there are hundreds of applications which cannot be fixed. So some support is required in Wine or kernel. There isn't anything which Wine can do as rdtsc call directly reads the timestamp. The only option is that we support something in kernel. 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? 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) I really hope that you share some thoughts. -- BR, Muhammad Usama Anjum