You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/04/08 13:36:28 UTC

[GitHub] [incubator-nuttx] davids5 commented on pull request #3471: arch: Fix the stack boundary calculation and check

davids5 commented on pull request #3471:
URL: https://github.com/apache/incubator-nuttx/pull/3471#issuecomment-815830500


   @xiaoxiang781216 - Do you find this super confusing? I do. Maybe it is my perspective on the naming, and you can shed some light on the naming, if not the why not fix the naming in this PR as well?
   
   As you describe, above  ARM refers to it as:
   
   Stack-oriented suffix | For store or push instructions | For load or pop instructions
   -- | -- | --
   FD (Full Descending stack) | DB (Decrement Before) | IA (Increment After)
   
   This sort of construct is very unclear. 
   
   `(sp < istackbase && sp >= istackbase - istacksize)` 
   
   For me the perspective is that `base` of a lamp is on a table, the `top` of a lamp is above the table, the higher up it is the higher the addresses is.
   
   `low` and `high` addresses are super clear the words `base` and `bound` or 'top' are also grock-able (if used consistently) 
   
   The definition of the stack can also be clearer:
   
   | Address increase
   v
   lowerbound  (lower address) : AKA base
              ds size
   upperbound (higher address) : AKA top 
   
   If it were written in terms of `lowerbound`  `upperbound`
   
   Given FD-DB-IA  - A test for a valid Stack would be clear:
   
   'sp  > lowerbound  &&  sp <= upperbound`
   
   'lowerbound == sp  - is invalid  as a push (DB) at this point would be out of bounds. It is valid if in the context of a handler that can NOT call deeper but will ONLY return pop (IA)
   upperbound` == sp - is valid if the stake is unused, as push is DB. It is invalid the context of a handler that will ONLY return pop (IA)


-- 
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.

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