Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79fb4ad6 authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt
Browse files

x86: Fix the NMI nesting comments



Some of the comments for the nesting NMI algorithm were stale and
had some references to some prototypes that were first tried.

I also updated the comments to be a little easier to understand
the flow of the code. It definitely needs the documentation.

Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 62610913
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -1624,11 +1624,12 @@ first_nmi:
	 * | pt_regs                 |
	 * | pt_regs                 |
	 * +-------------------------+
	 * +-------------------------+
	 *
	 *
	 * The saved RIP is used to fix up the copied RIP that a nested
	 * The saved stack frame is used to fix up the copied stack frame
	 * NMI may zero out. The original stack frame and the temp storage
	 * that a nested NMI may change to make the interrupted NMI iret jump
	 * to the repeat_nmi. The original stack frame and the temp storage
	 * is also used by nested NMIs and can not be trusted on exit.
	 * is also used by nested NMIs and can not be trusted on exit.
	 */
	 */
	/* Do not pop rdx, nested NMIs will corrupt it */
	/* Do not pop rdx, nested NMIs will corrupt that part of the stack */
	movq (%rsp), %rdx
	movq (%rsp), %rdx
	CFI_RESTORE rdx
	CFI_RESTORE rdx


@@ -1641,6 +1642,8 @@ first_nmi:
	.endr
	.endr
	CFI_DEF_CFA_OFFSET SS+8-RIP
	CFI_DEF_CFA_OFFSET SS+8-RIP


	/* Everything up to here is safe from nested NMIs */

	/*
	/*
	 * If there was a nested NMI, the first NMI's iret will return
	 * If there was a nested NMI, the first NMI's iret will return
	 * here. But NMIs are still enabled and we can take another
	 * here. But NMIs are still enabled and we can take another
@@ -1667,9 +1670,8 @@ end_repeat_nmi:


	/*
	/*
	 * Everything below this point can be preempted by a nested
	 * Everything below this point can be preempted by a nested
	 * NMI if the first NMI took an exception. Repeated NMIs
	 * NMI if the first NMI took an exception and reset our iret stack
	 * caused by an exception and nested NMI will start here, and
	 * so that we repeat another NMI.
	 * can still be preempted by another NMI.
	 */
	 */
	pushq_cfi $-1		/* ORIG_RAX: no syscall to restart */
	pushq_cfi $-1		/* ORIG_RAX: no syscall to restart */
	subq $ORIG_RAX-R15, %rsp
	subq $ORIG_RAX-R15, %rsp