Linux system call

I can get system call execution and kernel processing. But so far I know little. When entering the Swi routine, the kernel keeps the user mode registered on the stack. Question:

  • Who is laying it? (Since swi processing and the corresponding system call routine require the stack frame to work)

  • If this is your own kernel stitch, where will the stack be allocated from ..? Will he use the current stack? If so, then the current process can be any process that can currently be executed in the kernel. Does this not exhaust the current stack?

  • If it uses the current executable user stack in the swi handler, this will be the user address space that the kernel will now access. Is it possible? Since the address memory of the kernel is within 1 GB (if in the memory of 4 GB of RAM the ratio between the kernel and the user is used).

+4
source share
2 answers

Most ARM modes have a separate stack. Stacks are usually installed shortly after the reset handler. From arch / arm / kernel / setup.c:

/* * setup stacks for re-entrant exception handlers */ __asm__ ( "msr cpsr_c, %1\n\t" "add sp, %0, %2\n\t" "msr cpsr_c, %3\n\t" "add sp, %0, %4\n\t" "msr cpsr_c, %5\n\t" "add sp, %0, %6\n\t" "msr cpsr_c, %7" : : "r" (stk), "I" (PSR_F_BIT | PSR_I_BIT | IRQ_MODE), "I" (offsetof(struct stack, irq[0])), "I" (PSR_F_BIT | PSR_I_BIT | ABT_MODE), "I" (offsetof(struct stack, abt[0])), "I" (PSR_F_BIT | PSR_I_BIT | UND_MODE), "I" (offsetof(struct stack, und[0])), "I" (PSR_F_BIT | PSR_I_BIT | SVC_MODE) : "r14"); 

PS SVC is the current name of the so-called SWI.

+5
source

It is true that the stack is specific to ARM modes.

This is a quick response to return to standby. We do as little as possible here, and this involves saving r0 back to the SVC stack.

The above lines are quoted in entry-common.S . Thus, the stack is an SVC stack. (Note: swi is replaced by svc).

0
source

All Articles