Skip to content

Commit 37d9a8c

Browse files
committed
Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86: Fix included-by file reference comments x86, cpu: Only CPU features determine NX capabilities x86, cpu: Call verify_cpu during 32bit CPU startup x86, cpu: Clear XD_DISABLED flag on Intel to regain NX x86, cpu: Rename verify_cpu_64.S to verify_cpu.S
2 parents 017892c + 79250af commit 37d9a8c

5 files changed

Lines changed: 50 additions & 11 deletions

File tree

‎arch/x86/boot/compressed/head_64.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ no_longmode:
182182
hlt
183183
jmp 1b
184184

185-
#include "../../kernel/verify_cpu_64.S"
185+
#include "../../kernel/verify_cpu.S"
186186

187187
/*
188188
* Be careful here startup_64 needs to be at a predictable

‎arch/x86/kernel/head_32.S‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ ENTRY(startup_32_smp)
316316
subl $0x80000001, %eax
317317
cmpl $(0x8000ffff-0x80000001), %eax
318318
ja 6f
319+
320+
/* Clear bogus XD_DISABLE bits */
321+
call verify_cpu
322+
319323
mov $0x80000001, %eax
320324
cpuid
321325
/* Execute Disable bit supported? */
@@ -611,6 +615,8 @@ ignore_int:
611615
#endif
612616
iret
613617

618+
#include "verify_cpu.S"
619+
614620
__REFDATA
615621
.align 4
616622
ENTRY(initial_code)

‎arch/x86/kernel/trampoline_64.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ startup_64:
127127
no_longmode:
128128
hlt
129129
jmp no_longmode
130-
#include "verify_cpu_64.S"
130+
#include "verify_cpu.S"
131131

132132
# Careful these need to be in the same 64K segment as the above;
133133
tidt:
Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
* Copyright (c) 2007 Andi Kleen (ak@suse.de)
88
* Copyright (c) 2007 Eric Biederman (ebiederm@xmission.com)
99
* Copyright (c) 2007 Vivek Goyal (vgoyal@in.ibm.com)
10+
* Copyright (c) 2010 Kees Cook (kees.cook@canonical.com)
1011
*
1112
* This source code is licensed under the GNU General Public License,
1213
* Version 2. See the file COPYING for more details.
1314
*
1415
* This is a common code for verification whether CPU supports
1516
* long mode and SSE or not. It is not called directly instead this
1617
* file is included at various places and compiled in that context.
17-
* Following are the current usage.
18+
* This file is expected to run in 32bit code. Currently:
1819
*
19-
* This file is included by both 16bit and 32bit code.
20+
* arch/x86/boot/compressed/head_64.S: Boot cpu verification
21+
* arch/x86/kernel/trampoline_64.S: secondary processor verfication
22+
* arch/x86/kernel/head_32.S: processor startup
2023
*
21-
* arch/x86_64/boot/setup.S : Boot cpu verification (16bit)
22-
* arch/x86_64/boot/compressed/head.S: Boot cpu verification (32bit)
23-
* arch/x86_64/kernel/trampoline.S: secondary processor verfication (16bit)
24-
* arch/x86_64/kernel/acpi/wakeup.S:Verfication at resume (16bit)
25-
*
26-
* verify_cpu, returns the status of cpu check in register %eax.
24+
* verify_cpu, returns the status of longmode and SSE in register %eax.
2725
* 0: Success 1: Failure
2826
*
27+
* On Intel, the XD_DISABLE flag will be cleared as a side-effect.
28+
*
2929
* The caller needs to check for the error code and take the action
3030
* appropriately. Either display a message or halt.
3131
*/
@@ -62,8 +62,41 @@ verify_cpu:
6262
cmpl $0x444d4163,%ecx
6363
jnz verify_cpu_noamd
6464
mov $1,%di # cpu is from AMD
65+
jmp verify_cpu_check
6566

6667
verify_cpu_noamd:
68+
cmpl $0x756e6547,%ebx # GenuineIntel?
69+
jnz verify_cpu_check
70+
cmpl $0x49656e69,%edx
71+
jnz verify_cpu_check
72+
cmpl $0x6c65746e,%ecx
73+
jnz verify_cpu_check
74+
75+
# only call IA32_MISC_ENABLE when:
76+
# family > 6 || (family == 6 && model >= 0xd)
77+
movl $0x1, %eax # check CPU family and model
78+
cpuid
79+
movl %eax, %ecx
80+
81+
andl $0x0ff00f00, %eax # mask family and extended family
82+
shrl $8, %eax
83+
cmpl $6, %eax
84+
ja verify_cpu_clear_xd # family > 6, ok
85+
jb verify_cpu_check # family < 6, skip
86+
87+
andl $0x000f00f0, %ecx # mask model and extended model
88+
shrl $4, %ecx
89+
cmpl $0xd, %ecx
90+
jb verify_cpu_check # family == 6, model < 0xd, skip
91+
92+
verify_cpu_clear_xd:
93+
movl $MSR_IA32_MISC_ENABLE, %ecx
94+
rdmsr
95+
btrl $2, %edx # clear MSR_IA32_MISC_ENABLE_XD_DISABLE
96+
jnc verify_cpu_check # only write MSR if bit was changed
97+
wrmsr
98+
99+
verify_cpu_check:
67100
movl $0x1,%eax # Does the cpu have what it takes
68101
cpuid
69102
andl $REQUIRED_MASK0,%edx

‎arch/x86/mm/setup_nx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void __init x86_report_nx(void)
4141
{
4242
if (!cpu_has_nx) {
4343
printk(KERN_NOTICE "Notice: NX (Execute Disable) protection "
44-
"missing in CPU or disabled in BIOS!\n");
44+
"missing in CPU!\n");
4545
} else {
4646
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
4747
if (disable_nx) {

0 commit comments

Comments
 (0)