title: why does arm-linux switch to SVC mode to handle exception?
body: <p><a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0013b/" rel="nofollow noreferrer">arm doc reads</a> </p>
  
  <blockquote>
    <p>This is because a fresh interrupt could occur at any time, which would cause
    the core to store the return address of the new interrupt and overwrite the original interrupt.
    When the original interrupt attempts to return to the main program, it will cause the system to
    fail. The nested handler must change into an alternative kernel mode before re-enabling
    interrupts in order to prevent this.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/Ekp4z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ekp4z.png" alt="enter image description here"></a></p>
  
  <p>according to the context, the main reason is that new-coming irq would overwrite R14(LR), so that the first irq cannot return to main program.</p>
  
  <p>In my understanding, to solve this problem, I just need to push R14(LR_irq), SPSR_irq to R13(SP_irq) before next irq raising.</p>
  
  <p><a href="https://i.stack.imgur.com/2eiFM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2eiFM.png" alt="enter image description here"></a></p>
  
  <p>There is no need for nested handler to switch to alternative mode before re-enabling interrupts.</p>
  
  <p>Thank you!</p>