Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Sep 2001 11:26:33 -0700 (PDT)
From:      John Polstra <jdp@polstra.com>
To:        stable@freebsd.org
Subject:   Re: sys/i386/i386/identcpu.c bugfix
Message-ID:  <200109161826.f8GIQXu77119@vashon.polstra.com>
In-Reply-To: <200109151906.f8FJ6Kk74842@vashon.polstra.com>
References:  <20010905160610.U1222-100000@earth.serd.org> <200109151906.f8FJ6Kk74842@vashon.polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <200109151906.f8FJ6Kk74842@vashon.polstra.com>,
John Polstra  <jdp@polstra.com> wrote:
> 
> About your patch: I made a different version which I think is slightly
> better, because it specifies the memory clobbers more specifically.
> It's simpler, too.  I checked the compiler's assembly language output,
> and it looks like it's doing the right thing.  Could you please give
> it a try?  Note, I removed the clobber of "cc" because the Intel
> book says that no flags are affected by the CPUID instruction.
> 
> This is relative to today's -stable:
> 
> Index: identcpu.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/i386/i386/identcpu.c,v
> retrieving revision 1.80.2.6
> diff -c -r1.80.2.6 identcpu.c
> *** identcpu.c	2001/07/19 09:12:07	1.80.2.6
> --- identcpu.c	2001/09/15 19:04:23
> ***************
> *** 114,127 ****
>   do_cpuid(u_int ax, u_int *p)
>   {
>   	__asm __volatile(
> ! 	".byte	0x0f, 0xa2;"
> ! 	"movl	%%eax, (%2);"
> ! 	"movl	%%ebx, 4(%2);"
> ! 	"movl	%%ecx, 8(%2);"
> ! 	"movl	%%edx, 12(%2);"
> ! 	: "=a" (ax)
>   	:  "0" (ax), "S" (p)
> - 	: "bx", "cx", "dx"
>   	);
>   }
>   
> --- 114,122 ----
>   do_cpuid(u_int ax, u_int *p)
>   {
>   	__asm __volatile(
> ! 	".byte	0x0f, 0xa2"
> ! 	: "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
>   	:  "0" (ax), "S" (p)
>   	);
>   }
>   

Oops, this can be simplified further, because it is no longer
necessary to specify %esi as an input.  Here's a new patch:

Index: identcpu.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/identcpu.c,v
retrieving revision 1.80.2.6
diff -c -r1.80.2.6 identcpu.c
*** identcpu.c	2001/07/19 09:12:07	1.80.2.6
--- identcpu.c	2001/09/16 18:25:00
***************
*** 114,127 ****
  do_cpuid(u_int ax, u_int *p)
  {
  	__asm __volatile(
! 	".byte	0x0f, 0xa2;"
! 	"movl	%%eax, (%2);"
! 	"movl	%%ebx, 4(%2);"
! 	"movl	%%ecx, 8(%2);"
! 	"movl	%%edx, 12(%2);"
! 	: "=a" (ax)
! 	:  "0" (ax), "S" (p)
! 	: "bx", "cx", "dx"
  	);
  }
  
--- 114,122 ----
  do_cpuid(u_int ax, u_int *p)
  {
  	__asm __volatile(
! 	".byte	0x0f, 0xa2"
! 	: "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
! 	:  "0" (ax)
  	);
  }
  

John
-- 
  John Polstra                                               jdp@polstra.com
  John D. Polstra & Co., Inc.                        Seattle, Washington USA
  "Disappointment is a good sign of basic intelligence."  -- Chögyam Trungpa


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109161826.f8GIQXu77119>