x86_64 assembly: Don't touch %gs

With CPU_INFO_V2 enabled %gs holds the pointer to the cpu_info struct,
so don't clobber it. Backup and restore %gs where possible.
Fixes a crash in MPinit seen after calling FSP-S.

Change-Id: If9fc999b34530de5d8b6ad27b9af25fc552e9420
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/59764
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
Patrick Rudolph
2021-11-30 18:34:32 +01:00
committed by Patrick Georgi
parent c7f0bca9c2
commit 5b334b88a6
3 changed files with 16 additions and 5 deletions

View File

@@ -227,6 +227,10 @@ cond_clear_var_mtrrs:
movd %esp, %xmm0
movd %ebp, %xmm1
/* Backup %gs used by CPU_INFO_V2 */
movl %gs, %eax
movd %eax, %xmm2
/*
* Get function arguments.
* It's important to pass the exact ACM size as it's used by getsec to verify
@@ -261,6 +265,8 @@ cond_clear_var_mtrrs:
movl %eax, %es
movl %eax, %ss
movl %eax, %fs
/* Restore %gs used by CPU_INFO_V2 */
movd %xmm2, %eax
movl %eax, %gs
/* Disable cache */