From: Andy Lutomirski <luto@kernel.org>
To: Lai Jiangshan <jiangshanlai@gmail.com>, linux-kernel@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>,
Lai Jiangshan <laijs@linux.alibaba.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [RFC PATCH 4/4] x86/entry/nmi: unmask NMIs on userspace NMI when entry debugging
Date: Thu, 3 Jun 2021 10:38:33 -0700 [thread overview]
Message-ID: <d487b2db-7179-285a-01d5-2f47c3a5bc47@kernel.org> (raw)
In-Reply-To: <20210601065217.23540-5-jiangshanlai@gmail.com>
On 5/31/21 11:52 PM, Lai Jiangshan wrote:
> From: Lai Jiangshan <laijs@linux.alibaba.com>
Why?
>
> Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
> ---
> arch/x86/entry/entry_64.S | 36 ++++++++++++++++++++----------------
> 1 file changed, 20 insertions(+), 16 deletions(-)
>
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index f54e06139d4b..309e63f4f391 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -1055,6 +1055,24 @@ SYM_CODE_START_LOCAL(error_return)
> jmp swapgs_restore_regs_and_return_to_usermode
> SYM_CODE_END(error_return)
>
> +.macro debug_entry_unmask_NMIs
> +#ifdef CONFIG_DEBUG_ENTRY
> + /*
> + * For ease of testing, unmask NMIs right away. Disabled by
> + * default because IRET is very expensive.
> + */
> + pushq $0 /* SS */
> + pushq %rsp /* RSP (minus 8 because of the previous push) */
> + addq $8, (%rsp) /* Fix up RSP */
> + pushfq /* RFLAGS */
> + pushq $__KERNEL_CS /* CS */
> + pushq $1f /* RIP */
> + iretq /* continues with NMI unmasked */
> + UNWIND_HINT_IRET_REGS
> +1:
> +#endif
> +.endm
> +
> /*
> * Runs on exception stack. Xen PV does not go through this path at all,
> * so we can use real assembly here.
> @@ -1145,6 +1163,7 @@ SYM_CODE_START(asm_exc_nmi)
> * At this point we no longer need to worry about stack damage
> * due to nesting -- we're done with the NMI stack.
> */
> + debug_entry_unmask_NMIs
> pushq $-1 /* pt_regs->orig_ax */
> idtentry_body exc_nmi has_error_code=0
>
> @@ -1286,22 +1305,7 @@ first_nmi:
> UNWIND_HINT_IRET_REGS
>
> /* Everything up to here is safe from nested NMIs */
> -
> -#ifdef CONFIG_DEBUG_ENTRY
> - /*
> - * For ease of testing, unmask NMIs right away. Disabled by
> - * default because IRET is very expensive.
> - */
> - pushq $0 /* SS */
> - pushq %rsp /* RSP (minus 8 because of the previous push) */
> - addq $8, (%rsp) /* Fix up RSP */
> - pushfq /* RFLAGS */
> - pushq $__KERNEL_CS /* CS */
> - pushq $1f /* RIP */
> - iretq /* continues at repeat_nmi below */
> - UNWIND_HINT_IRET_REGS
> -1:
> -#endif
> + debug_entry_unmask_NMIs
>
> repeat_nmi:
> /*
>
prev parent reply other threads:[~2021-06-03 17:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-01 6:52 [RFC PATCH 0/4] x86/entry/nmi: solidify userspace NMI entry Lai Jiangshan
2021-06-01 6:52 ` [RFC PATCH 1/4] x86/entry/nmi: Switch to the entry stack before switching to the thread stack Lai Jiangshan
2021-06-01 17:05 ` Steven Rostedt
2021-06-02 0:09 ` Lai Jiangshan
2021-06-02 0:16 ` Lai Jiangshan
2021-06-19 22:51 ` Thomas Gleixner
2021-06-20 3:13 ` Andy Lutomirski
2021-06-20 11:23 ` Thomas Gleixner
2021-06-25 10:40 ` Peter Zijlstra
2021-06-25 11:00 ` Peter Zijlstra
2021-06-26 7:03 ` Thomas Gleixner
2021-06-26 8:28 ` Peter Zijlstra
2021-06-01 6:52 ` [RFC PATCH 2/4] x86/entry/nmi: Use normal idtentry macro for NMI from userspace Lai Jiangshan
2021-06-03 17:36 ` Andy Lutomirski
2021-06-01 6:52 ` [RFC PATCH 3/4] x86/entry: Remove parameter rdx from macro PUSH_AND_CLEAR_REGS and PUSH_REGS Lai Jiangshan
2021-06-01 6:52 ` [RFC PATCH 4/4] x86/entry/nmi: unmask NMIs on userspace NMI when entry debugging Lai Jiangshan
2021-06-03 17:38 ` Andy Lutomirski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d487b2db-7179-285a-01d5-2f47c3a5bc47@kernel.org \
--to=luto@kernel.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jiangshanlai@gmail.com \
--cc=laijs@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).