x86: new API for modifying CPU feature flags

Use an API for setting/clearing CPU features, so the
process can be debugged.

Adds:
set_cpu_feature()
clear_cpu_feature()
clear_all_cpu_features()

Todo:
mask_boot_cpu_features()
set_cpu_feature_word()
more?

(Hardcoded printk for now, should be dprintk.)

Signed-off-by: Chuck Ebbert <[EMAIL PROTECTED]>
---
 include/asm-i386/cpufeature.h |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

--- 2.6.21-rc7-d390.orig/include/asm-i386/cpufeature.h
+++ 2.6.21-rc7-d390/include/asm-i386/cpufeature.h
@@ -108,6 +108,23 @@
 #define cpu_has(c, bit)                test_bit(bit, (c)->x86_capability)
 #define boot_cpu_has(bit)      test_bit(bit, boot_cpu_data.x86_capability)
 
+#define alter_cpu_feature(fn, feat, c) \
+               do {    typeof(c) __c = (c); \
+                       printk("CPU: %s: %s feature %s for CPU %p", \
+                               __func__, #fn, #feat, __c); \
+                       fn ## _bit(X86_FEATURE_ ## feat, __c->x86_capability); \
+               } while (0)
+
+#define set_cpu_feature(f, c)  alter_cpu_feature(set, f, c)
+#define clear_cpu_feature(f, c)        alter_cpu_feature(clear, f, c)
+
+#define clear_all_cpu_features(c) \
+               do {    typeof(c) __c = (c); \
+                       printk("CPU: %s: clearing all capabilities for CPU %p", 
\
+                               __func__, __c); \
+                       memset(&__c->x86_capability, 0, sizeof 
__c->x86_capability); \
+               } while (0)
+
 #define cpu_has_fpu            boot_cpu_has(X86_FEATURE_FPU)
 #define cpu_has_vme            boot_cpu_has(X86_FEATURE_VME)
 #define cpu_has_de             boot_cpu_has(X86_FEATURE_DE)

Reply via email to