While reading the vector_swi()
routine for arm linux system call, I found that r0-r12 registers are copied to the kernel stack(below is the code)
ENTRY(vector_swi)
#ifdef CONFIG_CPU_V7M
v7m_exception_entry
#else
sub sp, sp, #S_FRAME_SIZE
stmia sp, {r0 - r12} @ Calling r0 - r12
As per my understanding, during system call arm enters into svc mode and jumps to vector_swi()
routine and begins execution. The sp register of svc mode(sp_svc
)points to kernel stack. r0-r12 registers are copied to the kernel stack.
My question is how is the sp (sp_svc
) register setup?
How does it know the address of kernel stack? Is this kernel stack same as the process's(the process that called system call) kernel stack?