linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Direct rdtsc call side-effect
@ 2023-06-01  8:45 Muhammad Usama Anjum
  2023-06-01  8:56 ` Peter Zijlstra
  2023-06-01 10:26 ` Thomas Gleixner
  0 siblings, 2 replies; 19+ messages in thread
From: Muhammad Usama Anjum @ 2023-06-01  8:45 UTC (permalink / raw)
  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
  Cc: Muhammad Usama Anjum, Steven Noonan, kernel

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-06-09  0:15 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-01  8:45 Direct rdtsc call side-effect Muhammad Usama Anjum
2023-06-01  8:56 ` Peter Zijlstra
2023-06-01  8:58   ` Peter Zijlstra
2023-06-01 10:31   ` Thomas Gleixner
2023-06-01 10:26 ` Thomas Gleixner
2023-06-01 18:20   ` Thomas Gleixner
2023-06-01 19:07     ` Steven Noonan
2023-06-01 19:31       ` H. Peter Anvin
2023-06-01 20:10       ` Thomas Gleixner
2023-06-01 20:13         ` Thomas Gleixner
2023-06-01 20:31       ` Peter Zijlstra
2023-06-01 21:41         ` Steven Noonan
2023-06-02  6:45           ` Peter Zijlstra
2023-06-05 10:27   ` David Laight
2023-06-05 14:43     ` Thomas Gleixner
2023-06-05 15:54       ` David Laight
2023-06-05 16:32         ` H. Peter Anvin
2023-06-06  8:23           ` David Laight
2023-06-09  0:14             ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).