The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
	Lai Jiangshan <laijs@linux.alibaba.com>,
	Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 1/4] x86/entry: Make paranoid_exit() callable
Date: Mon, 20 Dec 2021 19:56:55 +0100	[thread overview]
Message-ID: <YcDR92+JFkVAZi5c@zn.tnic> (raw)
In-Reply-To: <20211213150340.9419-2-jiangshanlai@gmail.com>

On Mon, Dec 13, 2021 at 11:03:37PM +0800, Lai Jiangshan wrote:
> From: Lai Jiangshan <laijs@linux.alibaba.com>
> 
> Move the last JMP out of paranoid_exit() and make it callable.
> 
> It will allow asm_exc_nmi() to call it and avoid duplicated code.
> 
> No functional change intended.
> 
> Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
> ---
>  arch/x86/entry/entry_64.S | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index 44dadea935f7..3dc3cec03425 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -439,7 +439,8 @@ SYM_CODE_START(\asmsym)
>  
>  	call	\cfunc
>  
> -	jmp	paranoid_exit
> +	call	paranoid_exit
> +	jmp	restore_regs_and_return_to_kernel

I guess but I don't like the glueing of the CALL to paranoid_exit with
the JMP to the restore_regs_and_return_to_kernel label. That reads
to me as, "if you're calling paranoid_exit() you must jump to the
restore_regs_and_return_to_kernel label but not always."

So I'm thinking you should leave the jump to that label inside
paranoid_exit() and use its %rbx argument to control when to jump to it
and when not.

I.e., not jump to it in the NMI case.

AFAICT, ofc. asm is always nasty to stare at.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  reply	other threads:[~2021-12-20 18:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13 15:03 [PATCH 0/4] x86/nmi: NMI cleanups Lai Jiangshan
2021-12-13 15:03 ` [PATCH 1/4] x86/entry: Make paranoid_exit() callable Lai Jiangshan
2021-12-20 18:56   ` Borislav Petkov [this message]
2021-12-21  2:22     ` Lai Jiangshan
2021-12-21 10:49       ` Borislav Petkov
2021-12-13 15:03 ` [PATCH 2/4] x86/entry: Call paranoid_exit() in asm_exc_nmi() Lai Jiangshan
2021-12-13 15:03 ` [PATCH 3/4] x86/nmi: Use DEFINE_IDTENTRY_NMI for NMI handler Lai Jiangshan
2021-12-13 15:03 ` [PATCH 4/4] x86/nmi: Convert nmi_cr2/nmi_dr7 to be func-local variable Lai Jiangshan

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=YcDR92+JFkVAZi5c@zn.tnic \
    --to=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jiangshanlai@gmail.com \
    --cc=laijs@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --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