kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: ksourav <sourav.jb1988@gmail.com>
To: kernelnewbies@kernelnewbies.org
Subject: 8 bytes reserved at the top of the stack in arm
Date: Fri, 28 Dec 2018 23:29:16 +0530	[thread overview]
Message-ID: <CAAJhNesFY8Yhj9geb4cVNNr+Z2EYNcY4s0hW+HbiM57UAtgD7w@mail.gmail.com> (raw)

Hi,

In arm linux, kernel stack is 8KB(two consecutive pages). struct
pt_regs lie at the top of the stack and thread_info lie at the bottom
of the stack.

In arch/arm/include/asm/processor.h
#define task_pt_regs(p) \
                    ((struct pt_regs *)(THREAD_START_SP +
task_stack_page(p)) - 1)

In arch/arm/include/asm/threadinfo.h
#define THREAD_START_SP         (THREAD_SIZE - 8)

Why are 8 bytes reserved at the top ?

Also, seeing similar thing in arch/arm/include/asm/ptrace.h

#define current_pt_regs(void) ({ (struct pt_regs *)                     \
                     ((current_stack_pointer | (THREAD_SIZE - 1)) - 7)
- 1;  \ })

(current_stack_pointer | (THREAD_SIZE - 1) It will get the top of
stack and the we are subtracting 7 from it ?
Why are these bytes reserved ?

Thanks & Regards

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

                 reply	other threads:[~2018-12-28 18:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAJhNesFY8Yhj9geb4cVNNr+Z2EYNcY4s0hW+HbiM57UAtgD7w@mail.gmail.com \
    --to=sourav.jb1988@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).