Re: [tip:x86/alternatives] x86, alternatives: Use 16-bit numbers for cpufeature index

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

 



On 06/28/2010 12:58 AM, Lai Jiangshan wrote:
> 
> There is alternative in use_xsave().
> use_xsave() should return false in my system, but it returns true after this patch applied.
> 

Does this patch solve your problem?

	-hpa

>From be5f348a31cbfa7587903952fa398c8511e23ee9 Mon Sep 17 00:00:00 2001
From: H. Peter Anvin <hpa@xxxxxxxxxxxxxxx>
Date: Mon, 28 Jun 2010 12:00:18 -0700
Subject: [PATCH] x86, alternatives: correct obsolete use of "u8" in static_cpu_has()

gcc seems to pass unsigned words on as signed to the assembler, at
least with the %P format.  As such, it is critical to get the correct
type.

Furthermore we are no longer limited to features < 256.

Reported-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
LKML-Reference: <4C2474EF.4050902@xxxxxxxxxxxxxx>
Signed-off-by: H. Peter Anvin <hpa@xxxxxxxxxxxxxxx>
---
 arch/x86/include/asm/cpufeature.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 66878c5..e8b8896 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -291,7 +291,7 @@ extern const char * const x86_power_flags[32];
  * patch the target code for additional performance.
  *
  */
-static __always_inline __pure bool __static_cpu_has(u8 bit)
+static __always_inline __pure bool __static_cpu_has(u16 bit)
 {
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
 		asm goto("1: jmp %l[t_no]\n"
@@ -339,7 +339,7 @@ static __always_inline __pure bool __static_cpu_has(u8 bit)
 (								\
 	__builtin_constant_p(boot_cpu_has(bit)) ?		\
 		boot_cpu_has(bit) :				\
-	(__builtin_constant_p(bit) && !((bit) & ~0xff)) ?	\
+	__builtin_constant_p(bit) ?				\
 		__static_cpu_has(bit) :				\
 		boot_cpu_has(bit)				\
 )
-- 
1.7.0.1


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux