RE: [PATCH v1 1/1] arch: microblaze: allocate stack space for register params

From: Frager, Neal

Date: Tue Apr 21 2026 - 06:50:47 EST


[AMD Official Use Only - AMD Internal Distribution Only]

Hi Gopi

> There should be 4 bytes for return address (place for link register) as well.

I tested with 24 bytes and I boot normally with your patch and gcc v15.
#define SYSCALL_ARGS_SIZE 24

If you are sure 28 bytes are needed, I will make the patch 28 with a comment
explaining the 6 argument registers plus the link register.

> Hi Michal,

> Thank you for your thorough review.

> C functions are invoked with arguments without allocating stack space for
> register params (for potential register spills). As a result kernel built
> with gcc v15 boot hangs at the point of starting init -.

> Remove -.

> Fixed for v2.

>
> This patch adds necessary stack space for few C function calls from entry.S

> Add necessary.

> Fixed for v2.

> (not all). After this patch, the kernel boots all the way to login prompt and
> root login works. Simple commands like ps work and show normal output.
>
> Signed-off-by: Gopi Kumar Bulusu <mailto:gopi@xxxxxxxxxxx>
> Tested-by: Neal Frager <mailto:neal.frager@xxxxxxx>

> If you are sending it you should have sob line here.

> Fixed for v2.

> ---
> arch/microblaze/kernel/entry.S | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S
> index 582d7256d815..2f9604640486 100644
> --- a/arch/microblaze/kernel/entry.S
> +++ b/arch/microblaze/kernel/entry.S
> @@ -339,6 +339,9 @@ C_ENTRY(mb_invalidate_icache):
> * Trap entered via brki instruction, so BIP bit is set, and interrupts
> * are masked. This is nice, means we don't have to CLI before state save
> */
> +
> +#define SYSCALL_ARGS_SIZE 36

> I am testing if 36 is really needed and am running a test using 24
> for the 6 registers that are used for arguments.

> +
> C_ENTRY(_user_exception):
> swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)) /* save stack */
> addi r14, r14, 4 /* return address is 4 byte after call */
> @@ -422,16 +425,19 @@ C_ENTRY(_user_exception):
> lwi r12, r12, sys_call_table
> /* where the trap should return need -8 to adjust for rtsd r15, 8 */
> addi r15, r0, ret_from_trap-8
> + addik r1, r1, -SYSCALL_ARGS_SIZE

> Please check coding style here.

> Fixed for v2.

> I will test it on real HW and will talk to you directly about results.

> Yes please. Thank you!

Best regards,
Neal Frager
AMD