x86/AMD: fold redundant parameters of cpu_has_amd_erratum()
authorJan Beulich <jbeulich@suse.com>
Mon, 19 Dec 2011 08:37:52 +0000 (09:37 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 19 Dec 2011 08:37:52 +0000 (09:37 +0100)
The boolean 'osvw' indicator and 'osvw_id' can be folded - the function
can as well distinguish the non-OSVW case by checking for a negative
'osvw_id'. That way the whole variable argument list processing is only
needed on the legacy code path.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
Acked-by: Wei Huang <wei.huang2@amd.com>
xen/arch/x86/cpu/amd.c
xen/include/asm-x86/amd.h

index 33b8912297151c0e03f49cbeb068e49553647e90..f7019915c027620e29e3a2a225f518cf2a8f350b 100644 (file)
@@ -186,7 +186,7 @@ static void __devinit set_cpuidmask(const struct cpuinfo_x86 *c)
  * Check for the presence of an AMD erratum. Arguments are defined in amd.h 
  * for each known erratum. Return 1 if erratum is found.
  */
-int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, int osvw, ...) 
+int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, int osvw_id, ...)
 {
        va_list ap;
        u32 range;
@@ -195,27 +195,24 @@ int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, int osvw, ...)
        if (cpu->x86_vendor != X86_VENDOR_AMD)
                return 0;
 
-       va_start(ap, osvw);
+       if (osvw_id >= 0 && cpu_has(cpu, X86_FEATURE_OSVW)) {
+               u64 osvw_len;
 
-       if (osvw) {
-               u16 osvw_id = va_arg(ap, int);
+               rdmsrl(MSR_AMD_OSVW_ID_LENGTH, osvw_len);
 
-               if (cpu_has(cpu, X86_FEATURE_OSVW)) {
-                       u64 osvw_len;
-                       rdmsrl(MSR_AMD_OSVW_ID_LENGTH, osvw_len);
+               if (osvw_id < osvw_len) {
+                       u64 osvw_bits;
 
-                       if (osvw_id < osvw_len) {
-                               u64 osvw_bits;
-                               rdmsrl(MSR_AMD_OSVW_STATUS + (osvw_id >> 6), 
-                                      osvw_bits);
+                       rdmsrl(MSR_AMD_OSVW_STATUS + (osvw_id >> 6),
+                              osvw_bits);
 
-                               va_end(ap);
-                               return (osvw_bits >> (osvw_id & 0x3f)) & 0x01;
-                       }
+                       return (osvw_bits >> (osvw_id & 0x3f)) & 1;
                }
        }
 
        /* OSVW unavailable or ID unknown, match family-model-stepping range */
+       va_start(ap, osvw_id);
+
        ms = (cpu->x86_model << 4) | cpu->x86_mask;
        while ((range = va_arg(ap, int))) {
                if ((cpu->x86 == AMD_MODEL_RANGE_FAMILY(range)) &&
index 2ff818872f3f7d49637b8bff4ac8d70249381d23..9a7fa3be655f193d81b49473a5a72ecfca0867c7 100644 (file)
  *   
  */
 
-#define AMD_LEGACY_ERRATUM(...)         0 /* legacy */, __VA_ARGS__, 0
-#define AMD_OSVW_ERRATUM(osvw_id, ...)  1 /* osvw */, osvw_id, __VA_ARGS__, 0
+#define AMD_LEGACY_ERRATUM(...)         -1 /* legacy */, __VA_ARGS__, 0
+#define AMD_OSVW_ERRATUM(osvw_id, ...)  osvw_id, __VA_ARGS__, 0
 #define AMD_MODEL_RANGE(f, m_start, s_start, m_end, s_end)              \
     ((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end))
 #define AMD_MODEL_RANGE_FAMILY(range)   (((range) >> 24) & 0xff)