Kernel Newbies archive on lore.kernel.org
 help / Atom feed
* function stack frames in the kernel
@ 2018-11-11 17:03 cartercheng
  2018-11-11 17:03 ` Carter Cheng
  2018-11-11 17:55 ` augustocaringi
  0 siblings, 2 replies; 10+ messages in thread
From: cartercheng @ 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 cartercheng
@ 2018-11-11 17:03 ` Carter Cheng
  2018-11-11 17:55 ` augustocaringi
  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 --]

<div dir="ltr">Hello,<div><br></div><div>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?</div><div><br></div><div>Thanks,</div><div><br></div><div>Carter</div></div>

[-- 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 cartercheng
  2018-11-11 17:03 ` Carter Cheng
@ 2018-11-11 17:55 ` augustocaringi
  2018-11-11 17:55   ` Augusto Mecking Caringi
  2018-11-11 18:00   ` cartercheng
  1 sibling, 2 replies; 10+ messages in thread
From: augustocaringi @ 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 ` augustocaringi
@ 2018-11-11 17:55   ` Augusto Mecking Caringi
  2018-11-11 18:00   ` cartercheng
  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 ` augustocaringi
  2018-11-11 17:55   ` Augusto Mecking Caringi
@ 2018-11-11 18:00   ` cartercheng
  2018-11-11 18:00     ` Carter Cheng
  2018-11-12  7:09     ` valdis.kletnieks
  1 sibling, 2 replies; 10+ messages in thread
From: cartercheng @ 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   ` cartercheng
@ 2018-11-11 18:00     ` Carter Cheng
  2018-11-12  7:09     ` valdis.kletnieks
  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 --]

<div dir="ltr">Thanks for the reply but the link doesn&#39;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.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 12, 2018 at 1:55 AM Augusto Mecking Caringi &lt;<a href="mailto:augustocaringi@gmail.com">augustocaringi@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, Nov 11, 2018 at 6:04 PM Carter Cheng &lt;<a href="mailto:cartercheng@gmail.com" target="_blank">cartercheng@gmail.com</a>&gt; wrote:<br>
&gt; 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?<br>
<br>
I think this link can answer your question...<br>
<br>
<a href="https://stackoverflow.com/questions/12911841/kernel-stack-and-user-space-stack" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/12911841/kernel-stack-and-user-space-stack</a><br>
<br>
-- <br>
Augusto Mecking Caringi<br>
</blockquote></div>

[-- 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   ` cartercheng
  2018-11-11 18:00     ` Carter Cheng
@ 2018-11-12  7:09     ` valdis.kletnieks
  2018-11-12  7:09       ` valdis.kletnieks
  2018-11-12 16:43       ` cartercheng
  1 sibling, 2 replies; 10+ messages in thread
From: valdis.kletnieks @ 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
@ 2018-11-12  7:09       ` valdis.kletnieks
  2018-11-12 16:43       ` cartercheng
  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
  2018-11-12  7:09       ` valdis.kletnieks
@ 2018-11-12 16:43       ` cartercheng
  2018-11-12 16:43         ` Carter Cheng
  1 sibling, 1 reply; 10+ messages in thread
From: cartercheng @ 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       ` cartercheng
@ 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 --]

<div dir="ltr">Thanks for the clarification.<br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 12, 2018 at 3:09 PM &lt;<a href="mailto:valdis.kletnieks@vt.edu">valdis.kletnieks@vt.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, 12 Nov 2018 02:00:02 +0800, Carter Cheng said:<br>
&gt; Thanks for the reply but the link doesn&#39;t quite answer the question. I am<br>
&gt; wondering how the pointer is handled so that there is one per thread by the<br>
&gt; compiler. I perhaps was under the perhaps mistaken impression that the<br>
&gt; stack pointer frame pointer management inside the compiler makes certain<br>
&gt; assumptions in user space- but i am unsure how this applies to kernel space.<br>
<br>
For regular function calls, a kernel stack works exactly the same as a function<br>
stack in userspace (remember, it&#39;s the same compiler, and other tools like the<br>
linker and gdb need to be able to understand function calls).<br>
<br>
Where things are different are what happens if an interrupt or a call to<br>
schedule() or enter/exit the kernel (or a few other similar situations I can&#39;t<br>
remember at 2AM) causes a different thread to start running - for those cases,<br>
there&#39;s architecture-dependent shim code (usually involving at least a bit of<br>
assembler) to do the register swapping needed.<br>
<br>
</blockquote></div>

[-- 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, back to index

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 cartercheng
2018-11-11 17:03 ` Carter Cheng
2018-11-11 17:55 ` augustocaringi
2018-11-11 17:55   ` Augusto Mecking Caringi
2018-11-11 18:00   ` cartercheng
2018-11-11 18:00     ` Carter Cheng
2018-11-12  7:09     ` valdis.kletnieks
2018-11-12  7:09       ` valdis.kletnieks
2018-11-12 16:43       ` cartercheng
2018-11-12 16:43         ` Carter Cheng

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org kernelnewbies@archiver.kernel.org
	public-inbox-index kernelnewbies


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/ public-inbox