Kernel Stack Management during Kernel Module Calls
Modules are used for repetitive tasks like scheduling, managing resources, buffer, etc.
A module may take several arguments has a single return value.
When a kernel routine invokes a module, the return address from the module gets pushed into currently active stack.
Because the caller and the callee are both executing in kernel mode, they share the same kernel stack.
Actions done by caller before a call to the kernel module
1) Save the registers in use to the kernel stack 2) Store the arguements arg1.... respectively in registers 3) Transfer control to the kernel module to be executed
**Pseudo code**
// save the registers in use
MOV R0, argument_1
MOV R1, argument_2
MOV R2, argument_3 ...
// store the arguments
CALL MODULE_N
// invoke the kernel module ....`
Actions done by the kernel module before return
1) Store the return value in R0 2) Pop off the space used during its execution from the kernel stack 3) Use RET instruction to transfer control back to the kernel module.