Skip to content

Commit 3bb045f

Browse files
author
H. Peter Anvin
committed
Merge branch 'x86/pat' into x86/urgent
Merge reason: Suresh Siddha (1): x86, pat: don't use rb-tree based lookup in reserve_memtype() ... requires previous x86/pat commits already pushed to Linus. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2 parents 8093833 + dcb73bf commit 3bb045f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1523
-1150
lines changed

arch/ia64/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ config IA64_UNCACHED_ALLOCATOR
112112
bool
113113
select GENERIC_ALLOCATOR
114114

115+
config ARCH_USES_PG_UNCACHED
116+
def_bool y
117+
depends on IA64_UNCACHED_ALLOCATOR
118+
115119
config AUDIT_ARCH
116120
bool
117121
default y

arch/x86/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,10 @@ config X86_PAT
14141414

14151415
If unsure, say Y.
14161416

1417+
config ARCH_USES_PG_UNCACHED
1418+
def_bool y
1419+
depends on X86_PAT
1420+
14171421
config EFI
14181422
bool "EFI runtime service support"
14191423
depends on ACPI

arch/x86/include/asm/cacheflush.h

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,58 @@ static inline void copy_from_user_page(struct vm_area_struct *vma,
4343
memcpy(dst, src, len);
4444
}
4545

46-
#define PG_non_WB PG_arch_1
47-
PAGEFLAG(NonWB, non_WB)
46+
#define PG_WC PG_arch_1
47+
PAGEFLAG(WC, WC)
48+
49+
#ifdef CONFIG_X86_PAT
50+
/*
51+
* X86 PAT uses page flags WC and Uncached together to keep track of
52+
* memory type of pages that have backing page struct. X86 PAT supports 3
53+
* different memory types, _PAGE_CACHE_WB, _PAGE_CACHE_WC and
54+
* _PAGE_CACHE_UC_MINUS and fourth state where page's memory type has not
55+
* been changed from its default (value of -1 used to denote this).
56+
* Note we do not support _PAGE_CACHE_UC here.
57+
*
58+
* Caller must hold memtype_lock for atomicity.
59+
*/
60+
static inline unsigned long get_page_memtype(struct page *pg)
61+
{
62+
if (!PageUncached(pg) && !PageWC(pg))
63+
return -1;
64+
else if (!PageUncached(pg) && PageWC(pg))
65+
return _PAGE_CACHE_WC;
66+
else if (PageUncached(pg) && !PageWC(pg))
67+
return _PAGE_CACHE_UC_MINUS;
68+
else
69+
return _PAGE_CACHE_WB;
70+
}
71+
72+
static inline void set_page_memtype(struct page *pg, unsigned long memtype)
73+
{
74+
switch (memtype) {
75+
case _PAGE_CACHE_WC:
76+
ClearPageUncached(pg);
77+
SetPageWC(pg);
78+
break;
79+
case _PAGE_CACHE_UC_MINUS:
80+
SetPageUncached(pg);
81+
ClearPageWC(pg);
82+
break;
83+
case _PAGE_CACHE_WB:
84+
SetPageUncached(pg);
85+
SetPageWC(pg);
86+
break;
87+
default:
88+
case -1:
89+
ClearPageUncached(pg);
90+
ClearPageWC(pg);
91+
break;
92+
}
93+
}
94+
#else
95+
static inline unsigned long get_page_memtype(struct page *pg) { return -1; }
96+
static inline void set_page_memtype(struct page *pg, unsigned long memtype) { }
97+
#endif
4898

4999
/*
50100
* The set_memory_* API can be used to change various attributes of a virtual

arch/x86/include/asm/iomap.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626
#include <asm/pgtable.h>
2727
#include <asm/tlbflush.h>
2828

29-
int
30-
is_io_mapping_possible(resource_size_t base, unsigned long size);
31-
3229
void *
3330
iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot);
3431

3532
void
3633
iounmap_atomic(void *kvaddr, enum km_type type);
3734

35+
int
36+
iomap_create_wc(resource_size_t base, unsigned long size, pgprot_t *prot);
37+
38+
void
39+
iomap_free(resource_size_t base, unsigned long size);
40+
3841
#endif /* _ASM_X86_IOMAP_H */

arch/x86/include/asm/mtrr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ extern int mtrr_del_page(int reg, unsigned long base, unsigned long size);
121121
extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
122122
extern void mtrr_ap_init(void);
123123
extern void mtrr_bp_init(void);
124+
extern void set_mtrr_aps_delayed_init(void);
125+
extern void mtrr_aps_init(void);
126+
extern void mtrr_bp_restore(void);
124127
extern int mtrr_trim_uncached_memory(unsigned long end_pfn);
125128
extern int amd_special_default_mtrr(void);
126129
# else
@@ -161,6 +164,9 @@ static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
161164

162165
#define mtrr_ap_init() do {} while (0)
163166
#define mtrr_bp_init() do {} while (0)
167+
#define set_mtrr_aps_delayed_init() do {} while (0)
168+
#define mtrr_aps_init() do {} while (0)
169+
#define mtrr_bp_restore() do {} while (0)
164170
# endif
165171

166172
#ifdef CONFIG_COMPAT

arch/x86/include/asm/pat.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ extern int free_memtype(u64 start, u64 end);
1919
extern int kernel_map_sync_memtype(u64 base, unsigned long size,
2020
unsigned long flag);
2121

22+
int io_reserve_memtype(resource_size_t start, resource_size_t end,
23+
unsigned long *type);
24+
25+
void io_free_memtype(resource_size_t start, resource_size_t end);
26+
2227
#endif /* _ASM_X86_PAT_H */

arch/x86/kernel/apic/ipi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ int safe_smp_processor_id(void)
153153
{
154154
int apicid, cpuid;
155155

156-
if (!boot_cpu_has(X86_FEATURE_APIC))
156+
if (!cpu_has_apic)
157157
return 0;
158158

159159
apicid = hard_smp_processor_id();

arch/x86/kernel/cpu/amd.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <linux/bitops.h>
33
#include <linux/mm.h>
44

5-
#include <asm/io.h>
5+
#include <linux/io.h>
66
#include <asm/processor.h>
77
#include <asm/apic.h>
88
#include <asm/cpu.h>
@@ -45,8 +45,8 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
4545
#define CBAR_ENB (0x80000000)
4646
#define CBAR_KEY (0X000000CB)
4747
if (c->x86_model == 9 || c->x86_model == 10) {
48-
if (inl (CBAR) & CBAR_ENB)
49-
outl (0 | CBAR_KEY, CBAR);
48+
if (inl(CBAR) & CBAR_ENB)
49+
outl(0 | CBAR_KEY, CBAR);
5050
}
5151
}
5252

@@ -87,9 +87,10 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
8787
d = d2-d;
8888

8989
if (d > 20*K6_BUG_LOOP)
90-
printk("system stability may be impaired when more than 32 MB are used.\n");
90+
printk(KERN_CONT
91+
"system stability may be impaired when more than 32 MB are used.\n");
9192
else
92-
printk("probably OK (after B9730xxxx).\n");
93+
printk(KERN_CONT "probably OK (after B9730xxxx).\n");
9394
printk(KERN_INFO "Please see http://membres.lycos.fr/poulot/k6bug.html\n");
9495
}
9596

@@ -219,8 +220,9 @@ static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
219220
if ((c->x86_model == 8 && c->x86_mask >= 1) || (c->x86_model > 8)) {
220221
rdmsr(MSR_K7_CLK_CTL, l, h);
221222
if ((l & 0xfff00000) != 0x20000000) {
222-
printk ("CPU: CLK_CTL MSR was %x. Reprogramming to %x\n", l,
223-
((l & 0x000fffff)|0x20000000));
223+
printk(KERN_INFO
224+
"CPU: CLK_CTL MSR was %x. Reprogramming to %x\n",
225+
l, ((l & 0x000fffff)|0x20000000));
224226
wrmsr(MSR_K7_CLK_CTL, (l & 0x000fffff)|0x20000000, h);
225227
}
226228
}
@@ -398,7 +400,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
398400
u32 level;
399401

400402
level = cpuid_eax(1);
401-
if((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)
403+
if ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)
402404
set_cpu_cap(c, X86_FEATURE_REP_GOOD);
403405

404406
/*
@@ -494,27 +496,30 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
494496
* benefit in doing so.
495497
*/
496498
if (!rdmsrl_safe(MSR_K8_TSEG_ADDR, &tseg)) {
497-
printk(KERN_DEBUG "tseg: %010llx\n", tseg);
498-
if ((tseg>>PMD_SHIFT) <
499+
printk(KERN_DEBUG "tseg: %010llx\n", tseg);
500+
if ((tseg>>PMD_SHIFT) <
499501
(max_low_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) ||
500-
((tseg>>PMD_SHIFT) <
502+
((tseg>>PMD_SHIFT) <
501503
(max_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) &&
502-
(tseg>>PMD_SHIFT) >= (1ULL<<(32 - PMD_SHIFT))))
503-
set_memory_4k((unsigned long)__va(tseg), 1);
504+
(tseg>>PMD_SHIFT) >= (1ULL<<(32 - PMD_SHIFT))))
505+
set_memory_4k((unsigned long)__va(tseg), 1);
504506
}
505507
}
506508
#endif
507509
}
508510

509511
#ifdef CONFIG_X86_32
510-
static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
512+
static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
513+
unsigned int size)
511514
{
512515
/* AMD errata T13 (order #21922) */
513516
if ((c->x86 == 6)) {
514-
if (c->x86_model == 3 && c->x86_mask == 0) /* Duron Rev A0 */
517+
/* Duron Rev A0 */
518+
if (c->x86_model == 3 && c->x86_mask == 0)
515519
size = 64;
520+
/* Tbird rev A1/A2 */
516521
if (c->x86_model == 4 &&
517-
(c->x86_mask == 0 || c->x86_mask == 1)) /* Tbird rev A1/A2 */
522+
(c->x86_mask == 0 || c->x86_mask == 1))
518523
size = 256;
519524
}
520525
return size;

arch/x86/kernel/cpu/bugs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void __init check_fpu(void)
8181

8282
boot_cpu_data.fdiv_bug = fdiv_bug;
8383
if (boot_cpu_data.fdiv_bug)
84-
printk("Hmm, FPU with FDIV bug.\n");
84+
printk(KERN_WARNING "Hmm, FPU with FDIV bug.\n");
8585
}
8686

8787
static void __init check_hlt(void)
@@ -98,7 +98,7 @@ static void __init check_hlt(void)
9898
halt();
9999
halt();
100100
halt();
101-
printk("OK.\n");
101+
printk(KERN_CONT "OK.\n");
102102
}
103103

104104
/*
@@ -122,9 +122,9 @@ static void __init check_popad(void)
122122
* CPU hard. Too bad.
123123
*/
124124
if (res != 12345678)
125-
printk("Buggy.\n");
125+
printk(KERN_CONT "Buggy.\n");
126126
else
127-
printk("OK.\n");
127+
printk(KERN_CONT "OK.\n");
128128
#endif
129129
}
130130

@@ -156,7 +156,7 @@ void __init check_bugs(void)
156156
{
157157
identify_boot_cpu();
158158
#ifndef CONFIG_SMP
159-
printk("CPU: ");
159+
printk(KERN_INFO "CPU: ");
160160
print_cpu_info(&boot_cpu_data);
161161
#endif
162162
check_config();

arch/x86/kernel/cpu/bugs_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void __init check_bugs(void)
1515
{
1616
identify_boot_cpu();
1717
#if !defined(CONFIG_SMP)
18-
printk("CPU: ");
18+
printk(KERN_INFO "CPU: ");
1919
print_cpu_info(&boot_cpu_data);
2020
#endif
2121
alternative_instructions();

arch/x86/kernel/cpu/common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include <asm/hypervisor.h>
1919
#include <asm/processor.h>
2020
#include <asm/sections.h>
21-
#include <asm/topology.h>
22-
#include <asm/cpumask.h>
21+
#include <linux/topology.h>
22+
#include <linux/cpumask.h>
2323
#include <asm/pgtable.h>
2424
#include <asm/atomic.h>
2525
#include <asm/proto.h>
@@ -28,13 +28,13 @@
2828
#include <asm/desc.h>
2929
#include <asm/i387.h>
3030
#include <asm/mtrr.h>
31-
#include <asm/numa.h>
31+
#include <linux/numa.h>
3232
#include <asm/asm.h>
3333
#include <asm/cpu.h>
3434
#include <asm/mce.h>
3535
#include <asm/msr.h>
3636
#include <asm/pat.h>
37-
#include <asm/smp.h>
37+
#include <linux/smp.h>
3838

3939
#ifdef CONFIG_X86_LOCAL_APIC
4040
#include <asm/uv/uv.h>
@@ -982,7 +982,7 @@ static __init int setup_disablecpuid(char *arg)
982982
__setup("clearcpuid=", setup_disablecpuid);
983983

984984
#ifdef CONFIG_X86_64
985-
struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
985+
struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
986986

987987
DEFINE_PER_CPU_FIRST(union irq_stack_union,
988988
irq_stack_union) __aligned(PAGE_SIZE);

arch/x86/kernel/cpu/cyrix.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#include <linux/delay.h>
44
#include <linux/pci.h>
55
#include <asm/dma.h>
6-
#include <asm/io.h>
6+
#include <linux/io.h>
77
#include <asm/processor-cyrix.h>
88
#include <asm/processor-flags.h>
9-
#include <asm/timer.h>
9+
#include <linux/timer.h>
1010
#include <asm/pci-direct.h>
1111
#include <asm/tsc.h>
1212

@@ -282,7 +282,8 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
282282
* The 5510/5520 companion chips have a funky PIT.
283283
*/
284284
if (vendor == PCI_VENDOR_ID_CYRIX &&
285-
(device == PCI_DEVICE_ID_CYRIX_5510 || device == PCI_DEVICE_ID_CYRIX_5520))
285+
(device == PCI_DEVICE_ID_CYRIX_5510 ||
286+
device == PCI_DEVICE_ID_CYRIX_5520))
286287
mark_tsc_unstable("cyrix 5510/5520 detected");
287288
}
288289
#endif
@@ -299,7 +300,8 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
299300
* ? : 0x7x
300301
* GX1 : 0x8x GX1 datasheet 56
301302
*/
302-
if ((0x30 <= dir1 && dir1 <= 0x6f) || (0x80 <= dir1 && dir1 <= 0x8f))
303+
if ((0x30 <= dir1 && dir1 <= 0x6f) ||
304+
(0x80 <= dir1 && dir1 <= 0x8f))
303305
geode_configure();
304306
return;
305307
} else { /* MediaGX */
@@ -427,9 +429,12 @@ static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c)
427429
printk(KERN_INFO "Enabling CPUID on Cyrix processor.\n");
428430
local_irq_save(flags);
429431
ccr3 = getCx86(CX86_CCR3);
430-
setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */
431-
setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80); /* enable cpuid */
432-
setCx86(CX86_CCR3, ccr3); /* disable MAPEN */
432+
/* enable MAPEN */
433+
setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10);
434+
/* enable cpuid */
435+
setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);
436+
/* disable MAPEN */
437+
setCx86(CX86_CCR3, ccr3);
433438
local_irq_restore(flags);
434439
}
435440
}

arch/x86/kernel/cpu/hypervisor.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@
2828
static inline void __cpuinit
2929
detect_hypervisor_vendor(struct cpuinfo_x86 *c)
3030
{
31-
if (vmware_platform()) {
31+
if (vmware_platform())
3232
c->x86_hyper_vendor = X86_HYPER_VENDOR_VMWARE;
33-
} else {
33+
else
3434
c->x86_hyper_vendor = X86_HYPER_VENDOR_NONE;
35-
}
3635
}
3736

3837
unsigned long get_hypervisor_tsc_freq(void)

0 commit comments

Comments
 (0)