I am new in RISC-V architecture and I am trying to understand the behaviour switching between User Mode and the Machine Mode.
I am running Freertos PMP examples on HiFive RevB.
The example creates a thread in user mode and makes a call to Machine Mode, but as I see, after the call, the machine mode continues from the thread stack (as I see from the SP register).
In the arm architecture, the thread and interrupt stacks are separated, so after the system call (machine mode), the Service Call uses its own stack.
Do Machine Mode calls the caller (user mode) stack?
My concern is that we can create a thread with a finite stack size but we may not know the stack depth of the Machine Call, so if the Machine call uses the user mode stack, it may overflow the stack.
I could not find enough information so could you please clarify, how it works or which documents should I read?