diff mbox series

[kvm-unit-tests,v2,05/10] x86: efi: Stop using UEFI-provided stack

Message ID 20220412173407.13637-6-varad.gautam@suse.com (mailing list archive)
State New, archived
Headers show
Series SMP Support for x86 UEFI Tests | expand

Commit Message

Varad Gautam April 12, 2022, 5:34 p.m. UTC
UEFI test builds currently use the stack pointer configured by the
UEFI implementation.

Reserve stack space in .data for EFI testcases and switch %rsp to
use this memory on early boot. This provides one 4K page per CPU
to store its stack / percpu data.

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
---
 x86/efi/crt0-efi-x86_64.S | 3 +++
 x86/efi/efistart64.S      | 8 ++++++++
 2 files changed, 11 insertions(+)

Comments

Sean Christopherson April 13, 2022, 4:20 p.m. UTC | #1
On Tue, Apr 12, 2022, Varad Gautam wrote:
> UEFI test builds currently use the stack pointer configured by the
> UEFI implementation.
> 
> Reserve stack space in .data for EFI testcases and switch %rsp to
> use this memory on early boot. This provides one 4K page per CPU
> to store its stack / percpu data.
> 
> Signed-off-by: Varad Gautam <varad.gautam@suse.com>
> ---
>  x86/efi/crt0-efi-x86_64.S | 3 +++
>  x86/efi/efistart64.S      | 8 ++++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/x86/efi/crt0-efi-x86_64.S b/x86/efi/crt0-efi-x86_64.S
> index eaf1656..1708ed5 100644
> --- a/x86/efi/crt0-efi-x86_64.S
> +++ b/x86/efi/crt0-efi-x86_64.S
> @@ -58,6 +58,9 @@ _start:
>  	popq %rdi
>  	popq %rsi
>  
> +	/* Switch away from EFI stack. */
> +	lea stacktop(%rip), %rsp
> +
>  	call efi_main
>  	addq $8, %rsp
>  
> diff --git a/x86/efi/efistart64.S b/x86/efi/efistart64.S
> index 8eadca5..cb08230 100644
> --- a/x86/efi/efistart64.S
> +++ b/x86/efi/efistart64.S
> @@ -6,6 +6,14 @@
>  
>  .data
>  
> +max_cpus = MAX_TEST_CPUS

Why declare max_cpus?  MAX_TEST_CPUS can be used directly.

> +

Rather than align the stack top, wouldn't it be easier and more obvious to the
reader to pre-align to?

.align PAGE_SIZE

> +/* Reserve stack in .data */
> +	. = . + 4096 * max_cpus

Use PAGE_SIZE instead of open coding 4096.

E.g. this works for me with my MSR_GS_BASE suggestion in the next patch (spoiler
alert).

/* Reserve stack in .data */
.data
.align PAGE_SIZE
	. = . + PAGE_SIZE * MAX_TEST_CPUS
.globl stacktop
stacktop:


> +	.align 16
> +.globl stacktop
> +stacktop:
> +
>  .align PAGE_SIZE
>  .globl ptl2
>  ptl2:
> -- 
> 2.32.0
>
diff mbox series

Patch

diff --git a/x86/efi/crt0-efi-x86_64.S b/x86/efi/crt0-efi-x86_64.S
index eaf1656..1708ed5 100644
--- a/x86/efi/crt0-efi-x86_64.S
+++ b/x86/efi/crt0-efi-x86_64.S
@@ -58,6 +58,9 @@  _start:
 	popq %rdi
 	popq %rsi
 
+	/* Switch away from EFI stack. */
+	lea stacktop(%rip), %rsp
+
 	call efi_main
 	addq $8, %rsp
 
diff --git a/x86/efi/efistart64.S b/x86/efi/efistart64.S
index 8eadca5..cb08230 100644
--- a/x86/efi/efistart64.S
+++ b/x86/efi/efistart64.S
@@ -6,6 +6,14 @@ 
 
 .data
 
+max_cpus = MAX_TEST_CPUS
+
+/* Reserve stack in .data */
+	. = . + 4096 * max_cpus
+	.align 16
+.globl stacktop
+stacktop:
+
 .align PAGE_SIZE
 .globl ptl2
 ptl2: