Re: [PATCH] [4/7] Convert TSC disabling to generic cpuid disablebitmap

From: Ian Campbell
Date: Sat Jan 19 2008 - 13:19:03 EST


Should have added Jeremy to CC, sorry for the duplicate message.

On Fri, 2008-01-18 at 18:27 +0100, Andi Kleen wrote:
> Index: linux/arch/x86/xen/time.c
> ===================================================================
> --- linux.orig/arch/x86/xen/time.c
> +++ linux/arch/x86/xen/time.c
> @@ -592,7 +592,7 @@ __init void xen_time_init(void)
> set_normalized_timespec(&wall_to_monotonic,
> -xtime.tv_sec, -xtime.tv_nsec);
>
> - tsc_disable = 0;
> + setup_clear_cpu_cap(X86_FEATURE_TSC);
>
> xen_setup_timer(cpu);
> xen_setup_cpu_clockevents();

That inverts the meaning, doesn't it? Previously the code force the TSC
to be on and now it forcefully disables it. Now when booting a Xen guest
I get:
Kernel panic - not syncing: Kernel compiled for Pentium+, requires TSC feature!

I think you want something like the following
---
>From eab0f03f2659670673496b48c03c0f79151e7bbf Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@xxxxxxxxxxxxxx>
Date: Sat, 19 Jan 2008 18:08:23 +0000
Subject: [PATCH] x86: Xen requires TSC support to be forced on, not disabled.

Signed-off-by: Ian Campbell <ijc@xxxxxxxxxxxxxx>
---
arch/x86/xen/time.c | 2 +-
include/asm-x86/cpufeature.h | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 6f5c74a..b3721fd 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -592,7 +592,7 @@ __init void xen_time_init(void)
set_normalized_timespec(&wall_to_monotonic,
-xtime.tv_sec, -xtime.tv_nsec);

- setup_clear_cpu_cap(X86_FEATURE_TSC);
+ setup_force_cpu_cap(X86_FEATURE_TSC);

xen_setup_timer(cpu);
xen_setup_cpu_clockevents();
diff --git a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h
index 91a7665..b6f969c 100644
--- a/include/asm-x86/cpufeature.h
+++ b/include/asm-x86/cpufeature.h
@@ -135,6 +135,10 @@
clear_cpu_cap(&boot_cpu_data, bit); \
set_bit(bit, cleared_cpu_caps); \
} while (0)
+#define setup_force_cpu_cap(bit) do { \
+ set_cpu_cap(&boot_cpu_data, bit); \
+ clear_bit(bit, cleared_cpu_caps); \
+} while (0)

#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
--
1.5.3.8


--
Ian Campbell

All that glitters is not gold; all that wander are not lost.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/