<div dir="ltr"><div dir="ltr"><div dir="auto">>> <span style="font-family:arial,helvetica,sans-serif;font-size:12.8px">interrupts being serviced while the page fault is in progress on x86 but not on ARM or did I miss something in my reading of the code?</span><div dir="auto"><span style="font-family:arial,helvetica,sans-serif;font-size:12.8px"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></span></span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:12.8px"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">Turns out I did miss something in my reading of the code. Interrupts are indeed disabled on x86 on entry into the page fault handler until we save the CR2 register (which holds the faulting address). Local IRQs are enabled in the fault handler after that. This prevents an interrupt (or maybe another thread too?) clobbering the CR2 value <span style="font-family:arial,helvetica,sans-serif;font-size:12.8px"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">before the faulting address is saved. </span></span></span></span></div></div><div dir="auto"><br></div><div dir="auto"><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">However, this still leaves me with my original "guesses":</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">>> I would have guessed that (non-threaded) interrupts be disabled during
page faults because of the possibility of a recursive lock acquire or
stack overflow if the interrupt handler itself page faults.</div></div><div dir="auto"><br></div><div dir="auto"><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">I assume this is not a problem because we don't actually "handle" page faults that happen because of interrupts? Going off of this comment:</div><br><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">_</span>If we're in an interrupt, have no user context or are running in a region with pagefaults disabled then we must not take the fault<span class="gmail_default" style="font-family:arial,helvetica,sans-serif">_</span><span class="gmail_default" style="font-family:arial,helvetica,sans-serif"></span><br><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">in arch/x86/mm/fault.c I does indeed look like that. I'd be glad if someone can clarify this.</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Shrikant<br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 7, 2019, 10:19 AM Shrikant Giridhar <<a href="mailto:shrikantgiridhar@gmail.com" target="_blank">shrikantgiridhar@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Hi,</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">I was looking at arch code setting up page fault handling in the kernel and came away with a couple of questions.</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Can hardware interrupts (non-NMI) occur during page faults? On x86, I notice that the page fault handler is set up with an interrupt gate which should clear the IF (Interrupt Enable) bit - disabling maskable interrupts in the process. I also don't see interrupts being enabled later in the handler (arch/x86/mm/fault.c:do_page_fault).<br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">However, from a quick skim, it doesn't look like the same rule is followed on ARM (32-bit) where local IRQs are enabled after we enter the page fault handler (arch/arm/mm/fault.c:do_page_fault).</div><div><br></div><div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Is there a general policy for interrupt handling during page faults? I would have guessed that (non-threaded) interrupts be disabled during page faults because of the possibility of a recursive lock acquire or stack overflow if the interrupt handler itself page faults.</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Is there an arch-specific factor involved which prevents (AFAICT) interrupts being serviced while the page fault is in progress on x86 but not on ARM or did I miss something in my reading of the code?</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Shrikant<br></div></div></div>
</blockquote></div>