aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/trampoline.S
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@in.ibm.com>2007-05-02 13:27:08 -0400
committerAndi Kleen <andi@basil.nowhere.org>2007-05-02 13:27:08 -0400
commita4831e08b7f3ed51623c9eb25e8c945b76b3eda3 (patch)
treecc38c9df02560fba778dfbff5f389e4ac3b720b9 /arch/x86_64/kernel/trampoline.S
parent8035d3ea78c2a61a9738c7857742370e0aa74d5c (diff)
[PATCH] x86-64: Move cpu verification code to common file
o This patch moves the code to verify long mode and SSE to a common file. This code is now shared by trampoline.S, wakeup.S, boot/setup.S and boot/compressed/head.S o So far we used to do very limited check in trampoline.S, wakeup.S and in 32bit entry point. Now all the entry paths are forced to do the exhaustive check, including SSE because verify_cpu is shared. o I am keeping this patch as last in the x86 relocatable series because previous patches have got quite some amount of testing done and don't want to distrub that. So that if there is problem introduced by this patch, at least it can be easily isolated. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com> Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch/x86_64/kernel/trampoline.S')
-rw-r--r--arch/x86_64/kernel/trampoline.S51
1 files changed, 3 insertions, 48 deletions
diff --git a/arch/x86_64/kernel/trampoline.S b/arch/x86_64/kernel/trampoline.S
index 13eee63c7bb..e7e2764c461 100644
--- a/arch/x86_64/kernel/trampoline.S
+++ b/arch/x86_64/kernel/trampoline.S
@@ -54,6 +54,8 @@ r_base = .
54 movw $(trampoline_stack_end - r_base), %sp 54 movw $(trampoline_stack_end - r_base), %sp
55 55
56 call verify_cpu # Verify the cpu supports long mode 56 call verify_cpu # Verify the cpu supports long mode
57 testl %eax, %eax # Check for return code
58 jnz no_longmode
57 59
58 mov %cs, %ax 60 mov %cs, %ax
59 movzx %ax, %esi # Find the 32bit trampoline location 61 movzx %ax, %esi # Find the 32bit trampoline location
@@ -121,57 +123,10 @@ startup_64:
121 jmp *%rax 123 jmp *%rax
122 124
123 .code16 125 .code16
124verify_cpu:
125 pushl $0 # Kill any dangerous flags
126 popfl
127
128 /* minimum CPUID flags for x86-64 */
129 /* see http://www.x86-64.org/lists/discuss/msg02971.html */
130#define REQUIRED_MASK1 ((1<<0)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<8)|\
131 (1<<13)|(1<<15)|(1<<24)|(1<<25)|(1<<26))
132#define REQUIRED_MASK2 (1<<29)
133
134 pushfl # check for cpuid
135 popl %eax
136 movl %eax, %ebx
137 xorl $0x200000,%eax
138 pushl %eax
139 popfl
140 pushfl
141 popl %eax
142 pushl %ebx
143 popfl
144 cmpl %eax, %ebx
145 jz no_longmode
146
147 xorl %eax, %eax # See if cpuid 1 is implemented
148 cpuid
149 cmpl $0x1, %eax
150 jb no_longmode
151
152 movl $0x01, %eax # Does the cpu have what it takes?
153 cpuid
154 andl $REQUIRED_MASK1, %edx
155 xorl $REQUIRED_MASK1, %edx
156 jnz no_longmode
157
158 movl $0x80000000, %eax # See if extended cpuid is implemented
159 cpuid
160 cmpl $0x80000001, %eax
161 jb no_longmode
162
163 movl $0x80000001, %eax # Does the cpu have what it takes?
164 cpuid
165 andl $REQUIRED_MASK2, %edx
166 xorl $REQUIRED_MASK2, %edx
167 jnz no_longmode
168
169 ret # The cpu supports long mode
170
171no_longmode: 126no_longmode:
172 hlt 127 hlt
173 jmp no_longmode 128 jmp no_longmode
174 129#include "verify_cpu.S"
175 130
176 # Careful these need to be in the same 64K segment as the above; 131 # Careful these need to be in the same 64K segment as the above;
177tidt: 132tidt: