有什么方法可以触发RDTSC的旧模式? [英] There is any way to trigger a legacy mode for RDTSC?

查看:187
本文介绍了有什么方法可以触发RDTSC的旧模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重写了整个问题,人们显然不明白.

I rewrote the entire question, people clearly weren't understanding it.

RDTSC用于计数CPU周期,并且随CPU节流而变化.

RDTSC used to count CPU cycles, and it varied with the CPU throttling.

当前,RDTSC不会随CPU限制而变化.

Currently, RDTSC don't vary with CPU throttling.

一些旧的应用程序,期望RDTSC随CPU节流而变化.

Some old applications, expect RDTSC to vary with CPU throttling.

我如何使RDTSC给予他们期望的结果?

How I make RDTSC give them what they expect?

我不想分析代码,我不想重写大量代码,我不想强​​迫用户弄乱BIOS或内核权限,我只想让旧版应用程序像他们应该.

I don't want to profile code, I don't want to rewrite massive amounts of code, I don't want to oblige users to mess with the BIOS or Kernel permissions, I just want to make legacy apps work as they should.

推荐答案

简而言之,轻按一下开关就无法做到

英特尔开发人员手册3B 第17章,显式读取

不变的TSC将在所有ACPI P-,C-中以恒定速率运行.和T状态.这是向前发展的建筑行为.

The invariant TSC will run at a constant rate in all ACPI P-, C-. and T-states. This is the architectural behavior moving forward.

这是告诉您无法切换回以前的行为的另一种方式.

Which is another way to tell you that there is no way to switch back to the previous behavior.

但是,如果您真的喜欢它,可以尝试一下.

However if you really feel like it, you can try something.

rdtsc从可写的 IA32_TIME_STAMP_COUNTER 中获取其值.
因此,您可以在不更改任何程序的情况下伪造" rdtsc的读取,但是需要驱动程序.
更改 IA32_TIME_STAMP_COUNTER 来调整内部时钟计数可能并不容易.

rdtsc takes its value from the IA32_TIME_STAMP_COUNTER, which is writable.
So you can "fake" the read of rdtsc without changing any program, but you need a driver.
Changing IA32_TIME_STAMP_COUNTER to adjust for internal clock count may not be so easy.

我不记得是否有一个性能事件自复位以来对内部时钟进行计数,如果存在,那么从理论上讲,您只需读取该值并写入 IA32_TIME_STAMP_COUNTER .
较新的CPU还支持 IA32_TSC_ADJUST ,可用于相对调整 TSC :从 IA32_TSC_ADJUST 中添加/减去的任何内容来自 IA32_TIME_STAMP_COUNTER .因此,您可以减慢或加快计数器的速度.

I don't remember if there is a performance event that count internal clocks since reset, if there is, then in theory you have just to read that value and write in IA32_TIME_STAMP_COUNTER.
Newer CPU also support IA32_TSC_ADJUST which can be used to adjust the TSC in a relative way: Whatever you add/subtract from IA32_TSC_ADJUST is added/subtracted from IA32_TIME_STAMP_COUNTER. So you can slow down or speed up the counter.

您需要的两种方式:

  • 创建驱动程序以交付给您的用户.可能没有特权安装它.
  • 要知道CPU的确切节流,与gudok答案的投票计数相反,性能计数器寄存器是唯一的解决方法.除非您想了解OS电源管理器的功能/事件并进行有根据的猜测.
  • 将节流映射为 TSC 值.
  • 选择更新 TSC 的频率(非常简单).
  • To create a driver to deliver to your users. Which may not have privileges to install it.
  • To know the exact throttling of the CPU, contrary to the vote count of gudok answer, performance counter registers are the only way to go. Unless you want to hook for OS power manager functions/events and go with educated guesses.
  • To map that throttling into a TSC value.
  • Choose how often to update the TSC (non trivial).

这篇关于有什么方法可以触发RDTSC的旧模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆