All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: Fix AMD K6 indirect call check
@ 2013-04-21  3:35 Andi Kleen
  2013-04-21  9:58 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2013-04-21  3:35 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

The AMD K6 errata check relies on timing a indirect call.
But the way it was written it could be optimized to a direct call.
Force gcc to actually do a indirect call and not just
constant resolve the target address.

Signed-off-by: Andi Kleen <ak@linux.intel.com>

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 4a549db..11ea6f6 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -115,7 +115,7 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
 		 */
 
 		n = K6_BUG_LOOP;
-		f_vide = vide;
+		asm("" : "=g" (f_vide) : "0" (vide));
 		rdtscl(d);
 		while (n--)
 			f_vide();

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

* Re: [PATCH] x86: Fix AMD K6 indirect call check
  2013-04-21  3:35 [PATCH] x86: Fix AMD K6 indirect call check Andi Kleen
@ 2013-04-21  9:58 ` Ingo Molnar
  2013-04-21 14:29   ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2013-04-21  9:58 UTC (permalink / raw)
  To: Andi Kleen; +Cc: x86, linux-kernel, Andi Kleen


* Andi Kleen <andi@firstfloor.org> wrote:

> From: Andi Kleen <ak@linux.intel.com>
> 
> The AMD K6 errata check relies on timing a indirect call.
> But the way it was written it could be optimized to a direct call.
> Force gcc to actually do a indirect call and not just
> constant resolve the target address.
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> 
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index 4a549db..11ea6f6 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -115,7 +115,7 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
>  		 */
>  
>  		n = K6_BUG_LOOP;
> -		f_vide = vide;
> +		asm("" : "=g" (f_vide) : "0" (vide));
>  		rdtscl(d);
>  		while (n--)
>  			f_vide();

Would be useful to read in the changelog about how you found the bug:

 - saw miscalculated values and figured out the reason
 - saw a new warning in GCC
 - saw it during review

?

	Ingo

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

* Re: [PATCH] x86: Fix AMD K6 indirect call check
  2013-04-21  9:58 ` Ingo Molnar
@ 2013-04-21 14:29   ` Andi Kleen
  0 siblings, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2013-04-21 14:29 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Andi Kleen, x86, linux-kernel, Andi Kleen

> Would be useful to read in the changelog about how you found the bug:
> 
>  - saw miscalculated values and figured out the reason
>  - saw a new warning in GCC
>  - saw it during review
> 
> ?

Saw it during code review when I was fixing the code for LTO.
I don't have a K6 anymore, but I still have fond memories of my K6
system.

-Andi


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

end of thread, other threads:[~2013-04-21 14:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-21  3:35 [PATCH] x86: Fix AMD K6 indirect call check Andi Kleen
2013-04-21  9:58 ` Ingo Molnar
2013-04-21 14:29   ` Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.