Skip to content

Commit eaed895

Browse files
committed
x86/efi/mixed: Check CPU compatibility without relying on verify_cpu()
In order for the EFI mixed mode startup code to be reusable in a context where the legacy decompressor is not used, replace the call to verify_cpu() [which performs an elaborate set of checks] with a simple check against the 'long mode' bit in the appropriate CPUID leaf. This is reasonable, given that EFI support is implied when booting in this manner, and so there is no need to consider very old CPUs when performing this check. Acked-by: Ingo Molnar <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent dac628e commit eaed895

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

arch/x86/boot/compressed/efi_mixed.S

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -279,24 +279,20 @@ SYM_FUNC_END(efi32_entry)
279279
* efi_system_table_32_t *sys_table)
280280
*/
281281
SYM_FUNC_START(efi32_pe_entry)
282-
pushl %ebp
283-
movl %esp, %ebp
284282
pushl %ebx // save callee-save registers
285-
pushl %edi
286-
287-
call verify_cpu // check for long mode support
288-
testl %eax, %eax
289-
movl $0x80000003, %eax // EFI_UNSUPPORTED
290-
jnz 2f
291283

292-
movl 8(%ebp), %ecx // image_handle
293-
movl 12(%ebp), %edx // sys_table
284+
/* Check whether the CPU supports long mode */
285+
movl $0x80000001, %eax // assume extended info support
286+
cpuid
287+
btl $29, %edx // check long mode bit
288+
jnc 1f
289+
leal 8(%esp), %esp // preserve stack alignment
290+
movl (%esp), %ecx // image_handle
291+
movl 4(%esp), %edx // sys_table
294292
jmp efi32_entry // pass %ecx, %edx
295293
// no other registers remain live
296-
297-
2: popl %edi // restore callee-save registers
294+
1: movl $0x80000003, %eax // EFI_UNSUPPORTED
298295
popl %ebx
299-
leave
300296
RET
301297
SYM_FUNC_END(efi32_pe_entry)
302298

0 commit comments

Comments
 (0)