Patches contributed by Eötvös Lorand University
commit 38f0f12793a490ac633dbba2418172b7abfa077e
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:43 2008 +0100
x86: page.h: move and unify types for pagetable entry, #5
based on:
Subject: x86: page.h: move and unify types for pagetable entry
From: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
index 530439e0d340..014f087d7c27 100644
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -181,6 +181,78 @@ static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
+#ifdef CONFIG_X86_64
+typedef struct { pgdval_t pgd; } pgd_t;
+typedef struct { pgprotval_t pgprot; } pgprot_t;
+
+static inline pgd_t native_make_pgd(pgdval_t val)
+{
+ return (pgd_t) { val };
+}
+
+static inline pgdval_t native_pgd_val(pgd_t pgd)
+{
+ return pgd.pgd;
+}
+
+#if PAGETABLE_LEVELS >= 3
+#if PAGETABLE_LEVELS == 4
+typedef struct { pudval_t pud; } pud_t;
+
+static inline pud_t native_make_pud(pmdval_t val)
+{
+ return (pud_t) { val };
+}
+
+static inline pudval_t native_pud_val(pud_t pud)
+{
+ return pud.pud;
+}
+#else /* PAGETABLE_LEVELS == 3 */
+#include <asm-generic/pgtable-nopud.h>
+#endif /* PAGETABLE_LEVELS == 4 */
+
+typedef struct { pmdval_t pmd; } pmd_t;
+
+static inline pmd_t native_make_pmd(pmdval_t val)
+{
+ return (pmd_t) { val };
+}
+
+static inline pmdval_t native_pmd_val(pmd_t pmd)
+{
+ return pmd.pmd;
+}
+#else /* PAGETABLE_LEVELS == 2 */
+#include <asm-generic/pgtable-nopmd.h>
+#endif /* PAGETABLE_LEVELS >= 3 */
+
+#define pgprot_val(x) ((x).pgprot)
+#define __pgprot(x) ((pgprot_t) { (x) } )
+
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else /* !CONFIG_PARAVIRT */
+
+#define pgd_val(x) native_pgd_val(x)
+#define __pgd(x) native_make_pgd(x)
+
+#ifndef __PAGETABLE_PUD_FOLDED
+#define pud_val(x) native_pud_val(x)
+#define __pud(x) native_make_pud(x)
+#endif
+
+#ifndef __PAGETABLE_PMD_FOLDED
+#define pmd_val(x) native_pmd_val(x)
+#define __pmd(x) native_make_pmd(x)
+#endif
+
+#define pte_val(x) native_pte_val(x)
+#define __pte(x) native_make_pte(x)
+
+#endif /* CONFIG_PARAVIRT */
+
+#endif /* CONFIG_X86_64 */
#endif /* __ASSEMBLY__ */
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index f5e82c695d26..f8a07bf54c3c 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -7,30 +7,9 @@
extern unsigned long end_pfn;
extern unsigned long end_pfn_map;
-/*
- * These are used to make use of C type-checking..
- */
-typedef struct { unsigned long pmd; } pmd_t;
-typedef struct { unsigned long pud; } pud_t;
-typedef struct { unsigned long pgd; } pgd_t;
-#define PTE_MASK PHYSICAL_PAGE_MASK
-
-typedef struct { unsigned long pgprot; } pgprot_t;
extern unsigned long phys_base;
-#define pte_val(x) ((x).pte)
-#define pmd_val(x) ((x).pmd)
-#define pud_val(x) ((x).pud)
-#define pgd_val(x) ((x).pgd)
-#define pgprot_val(x) ((x).pgprot)
-
-#define __pte(x) ((pte_t) { (x) } )
-#define __pmd(x) ((pmd_t) { (x) } )
-#define __pud(x) ((pud_t) { (x) } )
-#define __pgd(x) ((pgd_t) { (x) } )
-#define __pgprot(x) ((pgprot_t) { (x) } )
-
#endif /* !__ASSEMBLY__ */
#ifndef __ASSEMBLY__
commit d6e3cf63e927310f65e21132f1d1c50e3aa4c2b0
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:43 2008 +0100
x86: page.h: move and unify types for pagetable entry, #4
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
index a522fbada97e..530439e0d340 100644
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -92,6 +92,9 @@ typedef unsigned long phys_addr_t;
typedef struct { pteval_t pte; } pte_t;
+#define native_pte_val(x) ((x).pte)
+#define native_make_pte(x) ((pte_t) { (x) } )
+
#endif /* !__ASSEMBLY__ */
#endif /* CONFIG_X86_64 */
commit ba2b6c525eec459e1c6397f0f3eaeeafad153eab
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:42 2008 +0100
x86: page.h: move and unify types for pagetable entry, #3
based on:
Subject: x86: page.h: move and unify types for pagetable entry
From: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
index 911d7e0b3cd9..a522fbada97e 100644
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -79,6 +79,19 @@
#ifndef __ASSEMBLY__
void clear_page(void *page);
void copy_page(void *to, void *from);
+
+/*
+ * These are used to make use of C type-checking..
+ */
+typedef unsigned long pteval_t;
+typedef unsigned long pmdval_t;
+typedef unsigned long pudval_t;
+typedef unsigned long pgdval_t;
+typedef unsigned long pgprotval_t;
+typedef unsigned long phys_addr_t;
+
+typedef struct { pteval_t pte; } pte_t;
+
#endif /* !__ASSEMBLY__ */
#endif /* CONFIG_X86_64 */
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index f5e0543b8afa..f5e82c695d26 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -10,7 +10,6 @@ extern unsigned long end_pfn_map;
/*
* These are used to make use of C type-checking..
*/
-typedef struct { unsigned long pte; } pte_t;
typedef struct { unsigned long pmd; } pmd_t;
typedef struct { unsigned long pud; } pud_t;
typedef struct { unsigned long pgd; } pgd_t;
commit 7a2389b457a03f226b441b5c53f9808d4eefdcea
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:42 2008 +0100
x86: page.h: move and unify types for pagetable entry, #2
based on:
Subject: x86: page.h: move and unify types for pagetable entry
From: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 5c252d9fee1b..3f280105d7b3 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -79,12 +79,12 @@ static inline void set_pte(pte_t *dst, pte_t val)
static inline void set_pmd(pmd_t *dst, pmd_t val)
{
- pmd_val(*dst) = pmd_val(val);
+ *dst = val;
}
static inline void set_pud(pud_t *dst, pud_t val)
{
- pud_val(*dst) = pud_val(val);
+ *dst = val;
}
static inline void pud_clear (pud_t *pud)
@@ -94,7 +94,7 @@ static inline void pud_clear (pud_t *pud)
static inline void set_pgd(pgd_t *dst, pgd_t val)
{
- pgd_val(*dst) = pgd_val(val);
+ *dst = val;
}
static inline void pgd_clear (pgd_t * pgd)
commit 3da1bcc2659de27094592e5a037d0b1d59351e03
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:42 2008 +0100
x86: page.h: move and unify types for pagetable entry, #1
based on:
Subject: x86: page.h: move and unify types for pagetable entry
From: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
index 2ebb6977e00c..911d7e0b3cd9 100644
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -9,6 +9,7 @@
#define PAGE_MASK (~(PAGE_SIZE-1))
#define PHYSICAL_PAGE_MASK (PAGE_MASK & __PHYSICAL_MASK)
+#define PTE_MASK PHYSICAL_PAGE_MASK
#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT)
#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
@@ -24,8 +25,13 @@
#define __PHYSICAL_MASK ((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1)
#define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1)
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+#endif
#ifdef CONFIG_X86_64
+#define PAGETABLE_LEVELS 4
+
#define THREAD_ORDER 1
#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
#define CURRENT_MASK (~(THREAD_SIZE-1))
commit 92767af0e3904b4d35ed547fb514ff6cb227e678
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:40 2008 +0100
x86: fix sched_clock()
[ andi@firstfloor.org: build fix ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 276cb7073ab1..eb9b1a198f5e 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -196,14 +196,9 @@ int update_persistent_clock(struct timespec now)
return set_rtc_mmss(now.tv_sec);
}
-unsigned long long __vsyscall_fn native_read_tsc(void)
+unsigned long long native_read_tsc(void)
{
- DECLARE_ARGS(val, low, high);
-
- rdtsc_barrier();
- asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
- rdtsc_barrier();
-
- return EAX_EDX_VAL(val, low, high);
+ return __native_read_tsc();
}
-EXPORT_SYMBOL_GPL(native_read_tsc);
+EXPORT_SYMBOL(native_read_tsc);
+
diff --git a/include/asm-x86/msr.h b/include/asm-x86/msr.h
index decfec4ab17c..204a8a30fecf 100644
--- a/include/asm-x86/msr.h
+++ b/include/asm-x86/msr.h
@@ -93,6 +93,17 @@ static inline int native_write_msr_safe(unsigned int msr,
extern unsigned long long native_read_tsc(void);
+static __always_inline unsigned long long __native_read_tsc(void)
+{
+ DECLARE_ARGS(val, low, high);
+
+ rdtsc_barrier();
+ asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
+ rdtsc_barrier();
+
+ return EAX_EDX_VAL(val, low, high);
+}
+
static inline unsigned long long native_read_pmc(int counter)
{
DECLARE_ARGS(val, low, high);
diff --git a/include/asm-x86/tsc.h b/include/asm-x86/tsc.h
index f51a50da35aa..071e0ce5b664 100644
--- a/include/asm-x86/tsc.h
+++ b/include/asm-x86/tsc.h
@@ -46,7 +46,7 @@ static inline cycles_t vget_cycles(void)
if (!cpu_has_tsc)
return 0;
#endif
- return (cycles_t) native_read_tsc();
+ return (cycles_t) __native_read_tsc();
}
extern void tsc_init(void);
commit f06e4ec1c15691b0cfd2397ae32214fa36c90d71
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:39 2008 +0100
x86: read_tsc sync
make native_read_tsc() always non-speculative.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index c42cf1263882..276cb7073ab1 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -200,7 +200,10 @@ unsigned long long __vsyscall_fn native_read_tsc(void)
{
DECLARE_ARGS(val, low, high);
+ rdtsc_barrier();
asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
+ rdtsc_barrier();
+
return EAX_EDX_VAL(val, low, high);
}
EXPORT_SYMBOL_GPL(native_read_tsc);
commit e4026440130b84101f2da7f5a0c7a3b046173d3c
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:39 2008 +0100
x86: map vsyscalls early enough
map vsyscalls early enough. This is important if a __vsyscall_fn
function is used by other kernel code too.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index bc7758ea06af..8618178db842 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -45,6 +45,7 @@
#include <asm/mtrr.h>
#include <asm/uaccess.h>
#include <asm/system.h>
+#include <asm/vsyscall.h>
#include <asm/io.h>
#include <asm/smp.h>
#include <asm/msr.h>
@@ -453,6 +454,7 @@ void __init setup_arch(char **cmdline_p)
#endif
reserve_crashkernel();
paging_init();
+ map_vsyscall();
early_quirks();
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index e5c1118a8098..3f8242774580 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -319,7 +319,7 @@ cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
return NOTIFY_DONE;
}
-static void __init map_vsyscall(void)
+void __init map_vsyscall(void)
{
extern char __vsyscall_0;
unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
@@ -335,7 +335,6 @@ static int __init vsyscall_init(void)
BUG_ON((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime));
BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
BUG_ON((unsigned long) &vgetcpu != VSYSCALL_ADDR(__NR_vgetcpu));
- map_vsyscall();
#ifdef CONFIG_SYSCTL
register_sysctl_table(kernel_root_table2);
#endif
diff --git a/include/asm-x86/vsyscall.h b/include/asm-x86/vsyscall.h
index f01c49f5d108..17b3700949bf 100644
--- a/include/asm-x86/vsyscall.h
+++ b/include/asm-x86/vsyscall.h
@@ -36,6 +36,8 @@ extern volatile unsigned long __jiffies;
extern int vgetcpu_mode;
extern struct timezone sys_tz;
+extern void map_vsyscall(void);
+
#endif /* __KERNEL__ */
#endif /* _ASM_X86_64_VSYSCALL_H_ */
commit cdc7957d1954908a39a6964e9c6f643916e76c4b
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:39 2008 +0100
x86: move native_read_tsc() offline
move native_read_tsc() offline.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index d040840ff1b6..c42cf1263882 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -6,6 +6,7 @@
#include <linux/mc146818rtc.h>
#include <asm/time.h>
+#include <asm/vsyscall.h>
#ifdef CONFIG_X86_32
# define CMOS_YEARS_OFFS 1900
@@ -194,3 +195,12 @@ int update_persistent_clock(struct timespec now)
{
return set_rtc_mmss(now.tv_sec);
}
+
+unsigned long long __vsyscall_fn native_read_tsc(void)
+{
+ DECLARE_ARGS(val, low, high);
+
+ asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
+ return EAX_EDX_VAL(val, low, high);
+}
+EXPORT_SYMBOL_GPL(native_read_tsc);
diff --git a/include/asm-x86/msr.h b/include/asm-x86/msr.h
index bca8c3950132..decfec4ab17c 100644
--- a/include/asm-x86/msr.h
+++ b/include/asm-x86/msr.h
@@ -91,13 +91,7 @@ static inline int native_write_msr_safe(unsigned int msr,
return err;
}
-static inline unsigned long long native_read_tsc(void)
-{
- DECLARE_ARGS(val, low, high);
-
- asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
- return EAX_EDX_VAL(val, low, high);
-}
+extern unsigned long long native_read_tsc(void);
static inline unsigned long long native_read_pmc(int counter)
{
commit 6d5f718a497375f853d90247f5f6963368e89803
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Jan 30 13:32:38 2008 +0100
x86: lfence fix
LFENCE is available on XMM2 or higher Intel CPUs - not XMM or higher...
this caused boot failures on XMM1 & !XMM1 capable CPUs.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 0a4abdb61ae4..5731de3e1bd1 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -203,7 +203,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
}
#endif
- if (cpu_has_xmm)
+ if (cpu_has_xmm2)
set_bit(X86_FEATURE_LFENCE_RDTSC, c->x86_capability);
if (c->x86 == 15) {
set_bit(X86_FEATURE_P4, c->x86_capability);