<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: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=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:"\B9D1\C740 \ACE0\B515";
panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
{font-family:"\@\B9D1\C740 \ACE0\B515";
panose-1:2 11 5 3 2 0 0 2 0 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
text-autospace:none;
word-break:break-hangul;
font-size:10.0pt;
font-family:"\B9D1\C740 \ACE0\B515";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"\B9D1\C740 \ACE0\B515";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"\B9D1\C740 \ACE0\B515";}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:3.0cm 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></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=KO link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hello all<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I’m doing a experiment and found a strange phenomenon.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>This is the vprintk_func( ) function defined in kernel/printk/printk_safe.c (in linux 5.4.21, I’ll update to recent version later, it’s arm64).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US>__printf(1, 0) int vprintk_func(const char *fmt, va_list args)<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US>{<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> /*<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> * Try to use the main logbuf even in NMI. But avoid calling console<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> * drivers that might have their own locks.<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> */<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> if ((this_cpu_read(printk_context) & PRINTK_NMI_DIRECT_CONTEXT_MASK) &&<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> raw_spin_trylock(&logbuf_lock)) {<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> int len;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> len = vprintk_store(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> raw_spin_unlock(&logbuf_lock);<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> defer_console_output();<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> return len;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> }<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> /* Use extra buffer in NMI when logbuf_lock is taken or in safe mode. */<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> if (this_cpu_read(printk_context) & PRINTK_NMI_CONTEXT_MASK)<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> return vprintk_nmi(fmt, args);<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> /* Use extra buffer to prevent a recursion deadlock in safe mode. */<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> if (this_cpu_read(printk_context) & PRINTK_SAFE_CONTEXT_MASK)<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> return vprintk_safe(fmt, args);<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> /* No obstacles. */<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US> return vprintk_default(fmt, args);<o:p></o:p></span></p><p class=MsoNormal style='margin-left:30.0pt;mso-para-margin-left:3.0gd'><span lang=EN-US>}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>In qemu test, it passes all the printk_context check and enters vprintk_default( ) funciton but in our FPGA board (with only 8MB ram instead of DDR), <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>by writing debug information to some variables, I found the program seems to enter vprintk_safe( ) function and stuck somewhere inside.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>But when I examine the System.map file, I cannot find the vprintk_safe function and vprintk_nmi (I can find vprintk_default). I’m curious if this may be related to the malfunction.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>How can this happen? And how should I understand this?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Thank you!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Chan Kim<o:p></o:p></span></p></div></body></html>