[lkml]   [2002]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC] [PATCH] tsc_disable_B2 with "soft" rdtsc
john stultz wrote:
> Hello all,
> Here is my next rev of the tsc-disable patch. This one corrects a
> typo (Caught by Gabriel Paubert), and probably more
> controversial, implements a soft rdtsc instruction via do_gettimeofday.
> This avoids the earlier "box won't boot" problems with i686 optimized
> glibc's that called rdtsc. The rdtsc instruction will now be caught, and
> faked returning to the user program the same value of gettimeofday. Yes,
> its pretty hackish, but it works, albeit slowly.

+#ifdef CONFIG_X86_NUMA
+ /* "soft" rdtsc implementation */
+ if(!cpu_has_tsc)
+ {
+ char rdtsc_inst[2] = {0x0f, 0x31}; /*rdtsc opcode*/
+ char* inst_ptr = (char*)regs->eip;
+ if((inst_ptr[0] == rdtsc_inst[0])
+ &&(inst_ptr[1] == rdtsc_inst[1])){

Any particular reason for puting the opcode in an
array and verify against that instead of just
verifying inst_ptr[i] against the constants?

+ struct timeval tv;
+ do_gettimeofday(&tv);
+ regs->eax = tv.tv_usec;
+ regs->edx = tv.tv_sec;

Looks like the soft tsc is going to be jumping
rather than runing. It is going to be increasing
at a constat rate most of the time, but will make
a big jump ahead every second. Couldn't the jump
easilly be made a lot smaller by using:
regs->eax = tv.tv_usec<<2;

Of course this is not completely accurate either,
are we willing to pay the price for a more
accurate version?

+ regs->eip += 2; /*= size of opcode*/
+ return;
+ }
+ }

Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:26    [W:0.032 / U:0.612 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site