kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* function stack frames in the kernel
@ 2018-11-11 17:03 Carter Cheng
  2018-11-11 17:03 ` Carter Cheng
  2018-11-11 17:55 ` Augusto Mecking Caringi
  0 siblings, 2 replies; 10+ messages in thread
From: Carter Cheng @ 2018-11-11 17:03 UTC (permalink / raw)
  To: kernelnewbies

Hello,

I am wondering how the compiler divines which stack to use for function
calls and placement of locals and arguments when a function call is made
inside the kernel since the kernel has multiple call stacks. Are function
calls handled manually inside kernel code or is there something special
inside the compiler for handling this?

Thanks,

Carter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20181112/553f5c9a/attachment.html>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* function stack frames in the kernel
  2018-11-11 17:03 function stack frames in the kernel Carter Cheng
@ 2018-11-11 17:03 ` Carter Cheng
  2018-11-11 17:55 ` Augusto Mecking Caringi
  1 sibling, 0 replies; 10+ messages in thread
From: Carter Cheng @ 2018-11-11 17:03 UTC (permalink / raw)
  To: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 355 bytes --]

Hello,

I am wondering how the compiler divines which stack to use for function
calls and placement of locals and arguments when a function call is made
inside the kernel since the kernel has multiple call stacks. Are function
calls handled manually inside kernel code or is there something special
inside the compiler for handling this?

Thanks,

Carter

[-- Attachment #1.2: Type: text/html, Size: 449 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 10+ messages in thread

* function stack frames in the kernel
  2018-11-11 17:03 function stack frames in the kernel Carter Cheng
  2018-11-11 17:03 ` Carter Cheng
@ 2018-11-11 17:55 ` Augusto Mecking Caringi
  2018-11-11 17:55   ` Augusto Mecking Caringi
  2018-11-11 18:00   ` Carter Cheng
  1 sibling, 2 replies; 10+ messages in thread
From: Augusto Mecking Caringi @ 2018-11-11 17:55 UTC (permalink / raw)
  To: kernelnewbies

On Sun, Nov 11, 2018 at 6:04 PM Carter Cheng <cartercheng@gmail.com> wrote:
> I am wondering how the compiler divines which stack to use for function calls and placement of locals and arguments when a function call is made inside the kernel since the kernel has multiple call stacks. Are function calls handled manually inside kernel code or is there something special inside the compiler for handling this?

I think this link can answer your question...

https://stackoverflow.com/questions/12911841/kernel-stack-and-user-space-stack

-- 
Augusto Mecking Caringi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: function stack frames in the kernel
  2018-11-11 17:55 ` Augusto Mecking Caringi
@ 2018-11-11 17:55   ` Augusto Mecking Caringi
  2018-11-11 18:00   ` Carter Cheng
  1 sibling, 0 replies; 10+ messages in thread
From: Augusto Mecking Caringi @ 2018-11-11 17:55 UTC (permalink / raw)
  To: cartercheng; +Cc: kernelnewbies

On Sun, Nov 11, 2018 at 6:04 PM Carter Cheng <cartercheng@gmail.com> wrote:
> I am wondering how the compiler divines which stack to use for function calls and placement of locals and arguments when a function call is made inside the kernel since the kernel has multiple call stacks. Are function calls handled manually inside kernel code or is there something special inside the compiler for handling this?

I think this link can answer your question...

https://stackoverflow.com/questions/12911841/kernel-stack-and-user-space-stack

-- 
Augusto Mecking Caringi

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 10+ messages in thread

* function stack frames in the kernel
  2018-11-11 17:55 ` Augusto Mecking Caringi
  2018-11-11 17:55   ` Augusto Mecking Caringi
@ 2018-11-11 18:00   ` Carter Cheng
  2018-11-11 18:00     ` Carter Cheng
  2018-11-12  7:09     ` valdis.kletnieks at vt.edu
  1 sibling, 2 replies; 10+ messages in thread
From: Carter Cheng @ 2018-11-11 18:00 UTC (permalink / raw)
  To: kernelnewbies

Thanks for the reply but the link doesn't quite answer the question. I am
wondering how the pointer is handled so that there is one per thread by the
compiler. I perhaps was under the perhaps mistaken impression that the
stack pointer frame pointer management inside the compiler makes certain
assumptions in user space- but i am unsure how this applies to kernel space.

On Mon, Nov 12, 2018 at 1:55 AM Augusto Mecking Caringi <
augustocaringi@gmail.com> wrote:

> On Sun, Nov 11, 2018 at 6:04 PM Carter Cheng <cartercheng@gmail.com>
> wrote:
> > I am wondering how the compiler divines which stack to use for function
> calls and placement of locals and arguments when a function call is made
> inside the kernel since the kernel has multiple call stacks. Are function
> calls handled manually inside kernel code or is there something special
> inside the compiler for handling this?
>
> I think this link can answer your question...
>
>
> https://stackoverflow.com/questions/12911841/kernel-stack-and-user-space-stack
>
> --
> Augusto Mecking Caringi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20181112/bf4ec2c3/attachment.html>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: function stack frames in the kernel
  2018-11-11 18:00   ` Carter Cheng
@ 2018-11-11 18:00     ` Carter Cheng
  2018-11-12  7:09     ` valdis.kletnieks at vt.edu
  1 sibling, 0 replies; 10+ messages in thread
From: Carter Cheng @ 2018-11-11 18:00 UTC (permalink / raw)
  To: augustocaringi; +Cc: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 1056 bytes --]

Thanks for the reply but the link doesn't quite answer the question. I am
wondering how the pointer is handled so that there is one per thread by the
compiler. I perhaps was under the perhaps mistaken impression that the
stack pointer frame pointer management inside the compiler makes certain
assumptions in user space- but i am unsure how this applies to kernel space.

On Mon, Nov 12, 2018 at 1:55 AM Augusto Mecking Caringi <
augustocaringi@gmail.com> wrote:

> On Sun, Nov 11, 2018 at 6:04 PM Carter Cheng <cartercheng@gmail.com>
> wrote:
> > I am wondering how the compiler divines which stack to use for function
> calls and placement of locals and arguments when a function call is made
> inside the kernel since the kernel has multiple call stacks. Are function
> calls handled manually inside kernel code or is there something special
> inside the compiler for handling this?
>
> I think this link can answer your question...
>
>
> https://stackoverflow.com/questions/12911841/kernel-stack-and-user-space-stack
>
> --
> Augusto Mecking Caringi
>

[-- Attachment #1.2: Type: text/html, Size: 1516 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 10+ messages in thread

* function stack frames in the kernel
  2018-11-11 18:00   ` Carter Cheng
  2018-11-11 18:00     ` Carter Cheng
@ 2018-11-12  7:09     ` valdis.kletnieks at vt.edu
  2018-11-12  7:09       ` valdis.kletnieks
  2018-11-12 16:43       ` Carter Cheng
  1 sibling, 2 replies; 10+ messages in thread
From: valdis.kletnieks at vt.edu @ 2018-11-12  7:09 UTC (permalink / raw)
  To: kernelnewbies

On Mon, 12 Nov 2018 02:00:02 +0800, Carter Cheng said:
> Thanks for the reply but the link doesn't quite answer the question. I am
> wondering how the pointer is handled so that there is one per thread by the
> compiler. I perhaps was under the perhaps mistaken impression that the
> stack pointer frame pointer management inside the compiler makes certain
> assumptions in user space- but i am unsure how this applies to kernel space.

For regular function calls, a kernel stack works exactly the same as a function
stack in userspace (remember, it's the same compiler, and other tools like the
linker and gdb need to be able to understand function calls).

Where things are different are what happens if an interrupt or a call to
schedule() or enter/exit the kernel (or a few other similar situations I can't
remember at 2AM) causes a different thread to start running - for those cases,
there's architecture-dependent shim code (usually involving at least a bit of
assembler) to do the register swapping needed.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20181112/de611c35/attachment.sig>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: function stack frames in the kernel
  2018-11-12  7:09     ` valdis.kletnieks at vt.edu
@ 2018-11-12  7:09       ` valdis.kletnieks
  2018-11-12 16:43       ` Carter Cheng
  1 sibling, 0 replies; 10+ messages in thread
From: valdis.kletnieks @ 2018-11-12  7:09 UTC (permalink / raw)
  To: Carter Cheng; +Cc: augustocaringi, kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 1016 bytes --]

On Mon, 12 Nov 2018 02:00:02 +0800, Carter Cheng said:
> Thanks for the reply but the link doesn't quite answer the question. I am
> wondering how the pointer is handled so that there is one per thread by the
> compiler. I perhaps was under the perhaps mistaken impression that the
> stack pointer frame pointer management inside the compiler makes certain
> assumptions in user space- but i am unsure how this applies to kernel space.

For regular function calls, a kernel stack works exactly the same as a function
stack in userspace (remember, it's the same compiler, and other tools like the
linker and gdb need to be able to understand function calls).

Where things are different are what happens if an interrupt or a call to
schedule() or enter/exit the kernel (or a few other similar situations I can't
remember at 2AM) causes a different thread to start running - for those cases,
there's architecture-dependent shim code (usually involving at least a bit of
assembler) to do the register swapping needed.


[-- Attachment #1.2: Type: application/pgp-signature, Size: 486 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 10+ messages in thread

* function stack frames in the kernel
  2018-11-12  7:09     ` valdis.kletnieks at vt.edu
  2018-11-12  7:09       ` valdis.kletnieks
@ 2018-11-12 16:43       ` Carter Cheng
  2018-11-12 16:43         ` Carter Cheng
  1 sibling, 1 reply; 10+ messages in thread
From: Carter Cheng @ 2018-11-12 16:43 UTC (permalink / raw)
  To: kernelnewbies

Thanks for the clarification.

On Mon, Nov 12, 2018 at 3:09 PM <valdis.kletnieks@vt.edu> wrote:

> On Mon, 12 Nov 2018 02:00:02 +0800, Carter Cheng said:
> > Thanks for the reply but the link doesn't quite answer the question. I am
> > wondering how the pointer is handled so that there is one per thread by
> the
> > compiler. I perhaps was under the perhaps mistaken impression that the
> > stack pointer frame pointer management inside the compiler makes certain
> > assumptions in user space- but i am unsure how this applies to kernel
> space.
>
> For regular function calls, a kernel stack works exactly the same as a
> function
> stack in userspace (remember, it's the same compiler, and other tools like
> the
> linker and gdb need to be able to understand function calls).
>
> Where things are different are what happens if an interrupt or a call to
> schedule() or enter/exit the kernel (or a few other similar situations I
> can't
> remember at 2AM) causes a different thread to start running - for those
> cases,
> there's architecture-dependent shim code (usually involving at least a bit
> of
> assembler) to do the register swapping needed.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20181113/9dc7a70c/attachment.html>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: function stack frames in the kernel
  2018-11-12 16:43       ` Carter Cheng
@ 2018-11-12 16:43         ` Carter Cheng
  0 siblings, 0 replies; 10+ messages in thread
From: Carter Cheng @ 2018-11-12 16:43 UTC (permalink / raw)
  To: Valdis Kletnieks; +Cc: Augusto Caringi, kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 1160 bytes --]

Thanks for the clarification.

On Mon, Nov 12, 2018 at 3:09 PM <valdis.kletnieks@vt.edu> wrote:

> On Mon, 12 Nov 2018 02:00:02 +0800, Carter Cheng said:
> > Thanks for the reply but the link doesn't quite answer the question. I am
> > wondering how the pointer is handled so that there is one per thread by
> the
> > compiler. I perhaps was under the perhaps mistaken impression that the
> > stack pointer frame pointer management inside the compiler makes certain
> > assumptions in user space- but i am unsure how this applies to kernel
> space.
>
> For regular function calls, a kernel stack works exactly the same as a
> function
> stack in userspace (remember, it's the same compiler, and other tools like
> the
> linker and gdb need to be able to understand function calls).
>
> Where things are different are what happens if an interrupt or a call to
> schedule() or enter/exit the kernel (or a few other similar situations I
> can't
> remember at 2AM) causes a different thread to start running - for those
> cases,
> there's architecture-dependent shim code (usually involving at least a bit
> of
> assembler) to do the register swapping needed.
>
>

[-- Attachment #1.2: Type: text/html, Size: 1478 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-11-12 16:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-11 17:03 function stack frames in the kernel Carter Cheng
2018-11-11 17:03 ` Carter Cheng
2018-11-11 17:55 ` Augusto Mecking Caringi
2018-11-11 17:55   ` Augusto Mecking Caringi
2018-11-11 18:00   ` Carter Cheng
2018-11-11 18:00     ` Carter Cheng
2018-11-12  7:09     ` valdis.kletnieks at vt.edu
2018-11-12  7:09       ` valdis.kletnieks
2018-11-12 16:43       ` Carter Cheng
2018-11-12 16:43         ` Carter Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).