jlaitine commented on PR #15815:
URL: https://github.com/apache/nuttx/pull/15815#issuecomment-2696414230

   > > @jlaitine @tmedicci should we revert it?
   > 
   > No need to revert it for mpfs yet, I can check tomorrow if there is some 
simple.fix for it. I just didn't immediately see why it uses the offset of 12 
bytes there.
   
   I gave the patch another look; I don't quite understand what is being done 
here:
   
     addi       sp, sp, -16
     REGSTORE   ra, 12(sp)
     REGSTORE   s0, 8(sp)
     add         s0, sp, 16
   
   I see that one wants to store ra and s0 to stack. But where does the offsets 
come from? For two registers on rv32 you'd need 2 * INT_REG_SIZE, that is 8 
bytes, so for that it would be addi sp,sp,-8, REGSTORE ra, 8(sp), REGSTORE s0, 
4(sp), add s0,sp, 8  and so worth. So offsets for those registers would be 8,4 
for rv32 and 16,8 for rv64.
   
   I made a quick check that just fixing the alignment for "REGSTORE ra, 
12(sp)" -> "REGSTORE ra, 16(sp)" (and  for the corresponding regload as well) 
fixes the booting issue.
   
   But could you @tmedicci  , @fdcavalcanti explain why the offset of 12 has 
been used here, and hence on rv32 4 bytes of "gap" left in stack here? Should 
this just always spend 16 bytes for these registers or perhaps use the 
INT_REG_SIZE to properly calculate the stack usage and offsets here?
   
   It is quite straightforward to just  fix this to boot also on platforms 
which require strict 8-byte stack alignment, but I'd need to understand the 
original code first, where does the offsets of 12,8 come in here?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to