Re: RFC: outb 0x80 in inb_p, outb_p harmful on some modern AMD64 with MCP51 laptops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11-12-07 18:00, David P. Reed wrote:

Which port do you want me to test?

Oh, thought your previous reply was already responding to this. The "other diagnostic port", 0xed. The point is not so much that it's going to be a good alternate solution but to exclude it being a possible solution.

Also, I can run the timing test on my machine if you share the source
code so I can build it.

Thanks, would be interesting. This one:

Rene.
#include <stdlib.h>
#include <stdio.h>

#include <sys/io.h>

#define LOOPS 1000

unsigned long cycles[LOOPS];

int main(void)
{
	unsigned long overhead;
	unsigned long total;
	int i;

	if (iopl(3) < 0) {
		perror("iopl");
		return EXIT_FAILURE;
	}

	/* pull it in */
	for (i = 0; i < LOOPS; i++)
		cycles[i] = 0;

	asm volatile ("cli");
	for (i = 0; i < LOOPS; i++)
		asm (
			"xor	%%eax, %%eax	\n\t"
			"cpuid			\n\t"	
			"rdtsc			\n\t"
			"movl	%%eax, %%esi	\n\t"	
			"xor	%%eax, %%eax	\n\t"
			"cpuid			\n\t"
			"rdtsc			\n\t"
			"subl	%%esi, %%eax	\n\t"

			: "=a" (cycles[i]) : : "ecx", "edx", "ebx", "esi");
	asm volatile ("sti");

	overhead = 0;
	for (i = 0; i < LOOPS; i++)
		overhead += cycles[i];

	asm volatile ("cli");
	for (i = 0; i < LOOPS; i++)
		asm (
			"xor	%%eax, %%eax	\n\t"
			"cpuid			\n\t"	
			"rdtsc			\n\t"
			"movl	%%eax, %%esi	\n\t"	
			"outb	%%al, $0x80	\n\t"
			"xor	%%eax, %%eax	\n\t"
			"cpuid			\n\t"
			"rdtsc			\n\t"
			"subl	%%esi, %%eax	\n\t"

			: "=a" (cycles[i]) : : "ecx", "edx", "ebx", "esi");
	asm volatile ("sti");

	total = 0;
	for (i = 0; i < LOOPS; i++)
		total += cycles[i];
	total -= overhead;

	printf("out: %lu\n", total / LOOPS);

	asm volatile ("cli");
	for (i = 0; i < LOOPS; i++)
		asm (
			"xor	%%eax, %%eax	\n\t"
			"cpuid			\n\t"	
			"rdtsc			\n\t"
			"movl	%%eax, %%esi	\n\t"	
			"inb	$0x80, %%al	\n\t"
			"xor	%%eax, %%eax	\n\t"
			"cpuid			\n\t"
			"rdtsc			\n\t"
			"subl	%%esi, %%eax	\n\t"

			: "=a" (cycles[i]) : : "ecx", "edx", "ebx", "esi");
	asm volatile ("sti");

	total = 0;
	for (i = 0; i < LOOPS; i++)
		total += cycles[i];
	total -= overhead;

	printf("in : %lu\n", total / LOOPS);

	return EXIT_SUCCESS;
}

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux