[PATCH 2/4] pc-bios/s390-ccw: Provide space for initial stack frame in start.S

Thomas Huth posted 4 patches 2 years, 7 months ago
Maintainers: Thomas Huth <thuth@redhat.com>, Christian Borntraeger <borntraeger@linux.ibm.com>
There is a newer version of this series
[PATCH 2/4] pc-bios/s390-ccw: Provide space for initial stack frame in start.S
Posted by Thomas Huth 2 years, 7 months ago
Providing the space of a stack frame is the duty of the caller,
so we should reserve 160 bytes before jumping into the main function.
Otherwise the main() function might write past the stack array.

While we're at it, add a proper STACK_SIZE macro for the stack size
instead of using magic numbers (this is also required for the following
patch).

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/start.S | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S
index d29de09cc6..29b0a9ece0 100644
--- a/pc-bios/s390-ccw/start.S
+++ b/pc-bios/s390-ccw/start.S
@@ -10,10 +10,12 @@
  * directory.
  */
 
+#define STACK_SIZE 0x8000
+
     .globl _start
 _start:
 
-    larl    %r15,stack + 0x8000     /* Set up stack */
+    larl    %r15,stack + STACK_SIZE - 160   /* Set up stack */
 
     /* clear bss */
     larl    %r2,__bss_start
-- 
2.39.3
Re: [PATCH 2/4] pc-bios/s390-ccw: Provide space for initial stack frame in start.S
Posted by Christian Borntraeger 2 years, 7 months ago
Am 26.06.23 um 15:21 schrieb Thomas Huth:
> Providing the space of a stack frame is the duty of the caller,
> so we should reserve 160 bytes before jumping into the main function.
> Otherwise the main() function might write past the stack array.
> 
> While we're at it, add a proper STACK_SIZE macro for the stack size
> instead of using magic numbers (this is also required for the following
> patch).
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   pc-bios/s390-ccw/start.S | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S
> index d29de09cc6..29b0a9ece0 100644
> --- a/pc-bios/s390-ccw/start.S
> +++ b/pc-bios/s390-ccw/start.S
> @@ -10,10 +10,12 @@
>    * directory.
>    */
>   
> +#define STACK_SIZE 0x8000
> +
>       .globl _start
>   _start:
>   
> -    larl    %r15,stack + 0x8000     /* Set up stack */
> +    larl    %r15,stack + STACK_SIZE - 160   /* Set up stack */

Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Re: [PATCH 2/4] pc-bios/s390-ccw: Provide space for initial stack frame in start.S
Posted by Cédric Le Goater 2 years, 7 months ago
On 6/26/23 15:21, Thomas Huth wrote:
> Providing the space of a stack frame is the duty of the caller,
> so we should reserve 160 bytes before jumping into the main function.
> Otherwise the main() function might write past the stack array.
> 
> While we're at it, add a proper STACK_SIZE macro for the stack size
> instead of using magic numbers (this is also required for the following
> patch).
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.

> ---
>   pc-bios/s390-ccw/start.S | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S
> index d29de09cc6..29b0a9ece0 100644
> --- a/pc-bios/s390-ccw/start.S
> +++ b/pc-bios/s390-ccw/start.S
> @@ -10,10 +10,12 @@
>    * directory.
>    */
>   
> +#define STACK_SIZE 0x8000
> +
>       .globl _start
>   _start:
>   
> -    larl    %r15,stack + 0x8000     /* Set up stack */
> +    larl    %r15,stack + STACK_SIZE - 160   /* Set up stack */
>   
>       /* clear bss */
>       larl    %r2,__bss_start