* [PATCH v1 1/1] arch: microblaze: allocate stack space for register params
@ 2026-03-27 8:54 Neal Frager
2026-04-21 8:47 ` Michal Simek
0 siblings, 1 reply; 5+ messages in thread
From: Neal Frager @ 2026-03-27 8:54 UTC (permalink / raw)
To: linux-kernel; +Cc: michal.simek, gopi, Neal Frager
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 -.
This patch adds necessary stack space for few C function calls from entry.S
(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 <gopi@sankhya.com>
Tested-by: Neal Frager <neal.frager@amd.com>
---
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
+
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
bra r12
/* The syscall number is invalid, return an error. */
5:
- braid ret_from_trap
+ braid ret_from_trap2
addi r3, r0, -ENOSYS;
/* Entry point used to return from a syscall/trap */
/* We re-enable BIP bit before state restore */
C_ENTRY(ret_from_trap):
+ addik r1, r1, SYSCALL_ARGS_SIZE
+C_ENTRY(ret_from_trap2):
swi r3, r1, PT_R3
swi r4, r1, PT_R4
@@ -504,7 +510,7 @@ C_ENTRY(ret_from_fork):
bralid r15, schedule_tail; /* ...which is schedule_tail's arg */
add r5, r3, r0; /* switch_thread returns the prev task */
/* ( in the delay slot ) */
- brid ret_from_trap; /* Do normal trap return */
+ brid ret_from_trap2; /* Do normal trap return */
add r3, r0, r0; /* Child's fork call should return 0. */
C_ENTRY(ret_from_kernel_thread):
@@ -513,13 +519,13 @@ C_ENTRY(ret_from_kernel_thread):
/* ( in the delay slot ) */
brald r15, r20 /* fn was left in r20 */
addk r5, r0, r19 /* ... and argument - in r19 */
- brid ret_from_trap
+ brid ret_from_trap2
add r3, r0, r0
C_ENTRY(sys_rt_sigreturn_wrapper):
addik r30, r0, 0 /* no restarts */
brid sys_rt_sigreturn /* Do real work */
- addik r5, r1, 0; /* add user context as 1st arg */
+ addik r5, r1, SYSCALL_ARGS_SIZE; /* add user context as 1st arg */
/*
* HW EXCEPTION rutine start
@@ -729,11 +735,13 @@ C_ENTRY(_interrupt):
lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE));
tovirt(r1,r1)
addik r15, r0, irq_call;
+ addik r1, r1, -8
irq_call:rtbd r0, do_IRQ;
- addik r5, r1, 0;
+ addik r5, r1, 8;
/* MS: we are in virtual mode */
ret_from_irq:
+ addik r1, r1, 8
lwi r11, r1, PT_MODE;
bnei r11, 2f;
@@ -1302,7 +1310,7 @@ type_SYSCALL_PREEMPT:
.global microblaze_trap_handlers
microblaze_trap_handlers:
/* Exact matches come first */
- .word ret_from_trap; .word ret_from_trap ; .word type_SYSCALL
+ .word ret_from_trap; .word ret_from_trap2 ; .word type_SYSCALL
.word ret_from_irq ; .word ret_from_irq ; .word type_IRQ
/* Fuzzy matches go here */
.word ret_from_irq ; .word no_intr_resched ; .word type_IRQ_PREEMPT
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] arch: microblaze: allocate stack space for register params
2026-03-27 8:54 [PATCH v1 1/1] arch: microblaze: allocate stack space for register params Neal Frager
@ 2026-04-21 8:47 ` Michal Simek
2026-04-21 10:17 ` Frager, Neal
0 siblings, 1 reply; 5+ messages in thread
From: Michal Simek @ 2026-04-21 8:47 UTC (permalink / raw)
To: Neal Frager, linux-kernel; +Cc: gopi
On 3/27/26 09:54, Neal Frager wrote:
> 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 -.
>
> This patch adds necessary stack space for few C function calls from entry.S
Add necessary.
> (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 <gopi@sankhya.com>
> Tested-by: Neal Frager <neal.frager@amd.com>
If you are sending it you should have sob line here.
> ---
> 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
> +
> 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.
I will test it on real HW and will talk to you directly about results.
Thanks,
Michal
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v1 1/1] arch: microblaze: allocate stack space for register params
2026-04-21 8:47 ` Michal Simek
@ 2026-04-21 10:17 ` Frager, Neal
[not found] ` <CAL1P33weRJ4GBhrNUxWZ63Tv_2+VcL_WLU7vPk=FFHKHMiF3XQ@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Frager, Neal @ 2026-04-21 10:17 UTC (permalink / raw)
To: Simek, Michal, linux-kernel; +Cc: gopi
[AMD Official Use Only - AMD Internal Distribution Only]
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 <gopi@sankhya.com>
> Tested-by: Neal Frager <neal.frager@amd.com>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v1 1/1] arch: microblaze: allocate stack space for register params
[not found] ` <CAL1P33weRJ4GBhrNUxWZ63Tv_2+VcL_WLU7vPk=FFHKHMiF3XQ@mail.gmail.com>
@ 2026-04-21 10:46 ` Frager, Neal
2026-04-21 11:33 ` Gopi Kumar Bulusu
0 siblings, 1 reply; 5+ messages in thread
From: Frager, Neal @ 2026-04-21 10:46 UTC (permalink / raw)
To: Gopi Kumar Bulusu; +Cc: Simek, Michal, linux-kernel
[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@sankhya.com>
> Tested-by: Neal Frager <mailto:neal.frager@amd.com>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] arch: microblaze: allocate stack space for register params
2026-04-21 10:46 ` Frager, Neal
@ 2026-04-21 11:33 ` Gopi Kumar Bulusu
0 siblings, 0 replies; 5+ messages in thread
From: Gopi Kumar Bulusu @ 2026-04-21 11:33 UTC (permalink / raw)
To: Frager, Neal; +Cc: Simek, Michal, linux-kernel
namaskaaram
Yes, please refer to Microblaze Processor Reference Guide, ABI section
https://docs.amd.com/r/en-US/ug984-vivado-microblaze-ref/Stack-Convention
dhanyavaadaaha
gopi
Sankhya Technologies
www.sankhya.com
On Tue, Apr 21, 2026 at 4:16 PM Frager, Neal <neal.frager@amd.com> wrote:
>
> [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@sankhya.com>
> > Tested-by: Neal Frager <mailto:neal.frager@amd.com>
>
> > 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-21 11:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-27 8:54 [PATCH v1 1/1] arch: microblaze: allocate stack space for register params Neal Frager
2026-04-21 8:47 ` Michal Simek
2026-04-21 10:17 ` Frager, Neal
[not found] ` <CAL1P33weRJ4GBhrNUxWZ63Tv_2+VcL_WLU7vPk=FFHKHMiF3XQ@mail.gmail.com>
2026-04-21 10:46 ` Frager, Neal
2026-04-21 11:33 ` Gopi Kumar Bulusu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®