<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.c
{mso-style-name:c;}
span.n
{mso-style-name:n;}
span.EmailStyle23
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle24
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle25
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle26
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.s
{mso-style-name:s;}
span.EmailStyle28
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle29
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle30
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle31
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle32
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:644748614;
mso-list-type:hybrid;
mso-list-template-ids:-465118728 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-tab-stop:1.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-tab-stop:1.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level4
{mso-level-tab-stop:2.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-tab-stop:2.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-tab-stop:3.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level7
{mso-level-tab-stop:3.5in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-tab-stop:4.0in;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-tab-stop:4.5in;
mso-level-number-position:left;
text-indent:-.25in;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Recently I’m studying linux kernel. I have a question about the space after struct pt_regs in kernel stack. <o:p></o:p></p><p class=MsoNormal>Why reserved 8 bytes at the end of kernel stack for ARM and 32 bytes for MIPS?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Do you know what’s the purpose for it? Who and where use it?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I checked the real kernel stack for some processes. Some of them are all zero. Some of them are not.<o:p></o:p></p><p class=MsoNormal>Here are some sample data on ARM for those 8 bytes in different kernel stack:<o:p></o:p></p><p class=MsoNormal>0x55555575 0x55155545<o:p></o:p></p><p class=MsoNormal>0x5d555574 0xf17d5552<o:p></o:p></p><p class=MsoNormal>0x55155555 0x15155151<o:p></o:p></p><p class=MsoNormal>0x51555d55 0x55515545<o:p></o:p></p><p class=MsoNormal>0x5d555574 0x7579d552<o:p></o:p></p><p class=MsoNormal>0x55795534 0xf1055515<o:p></o:p></p><p class=MsoNormal>0xa83fc821 0xa83fcc21<o:p></o:p></p><p class=MsoNormal>0x55795534 0xf1055d15<o:p></o:p></p><p class=MsoNormal>0x557555dd 0x55659155<o:p></o:p></p><p class=MsoNormal>0x51555d55 0x55515545<o:p></o:p></p><p class=MsoNormal>0x5355545d 0x54c45135<o:p></o:p></p><p class=MsoNormal>0x57555455 0x6f45f545<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Br/Dander<o:p></o:p></p><div style='mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt;padding:0in 0in 1.0pt 0in'><p class=MsoNormal style='border:none;padding:0in'><o:p> </o:p></p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'> </span></span><![endif]>In arm, it’s reserved 8 bytes<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>kernel/arch/arm/include/asm/thread_info.h<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>#define THREAD_START_SP (THREAD_SIZE <span style='color:red'>- 8</span>)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'> </span></span><![endif]>In mips, it’s reserved 32 bytes.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-left:.5in'>kernel/arch/mips/kernel/r4k_switch.S<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p><p class=MsoNormal style='margin-left:.5in'>/*<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>* Offset to the current process status flags, the first 32 bytes of the<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>* stack are not used.<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>*/<o:p></o:p></p><p class=MsoNormal style='margin-left:.5in'>#define ST_OFF (_THREAD_SIZE <span style='color:red'>- 32</span> - PT_SIZE + PT_STATUS)<o:p></o:p></p><p class=MsoNormal style='margin-left:.25in'><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p></div></body></html>