From: Peter Zijlstra <peterz@infradead.org>
To: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: X86 ML <x86@kernel.org>, Josh Poimboeuf <jpoimboe@redhat.com>,
Brian Gerst <brgerst@gmail.com>,
Andrew Cooper <Andrew.Cooper3@citrix.com>,
LKML <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v3] x86,entry: Use PUSH_AND_CLEAR_REGS for compat
Date: Fri, 29 Apr 2022 23:12:56 +0200 [thread overview]
Message-ID: <YmxU2JoswWMYm4nl@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAJhGHyBUzURTBBnkO5c5xRC+c9+KFvLXw06h5uQ7gODeiSR-QA@mail.gmail.com>
On Fri, Apr 29, 2022 at 08:00:37PM +0800, Lai Jiangshan wrote:
> On Fri, Apr 29, 2022 at 5:13 PM Peter Zijlstra <peterz@infradead.org> wrote:
> > Notably:
> >
> > - SYSENTER: didn't clear si, dx, cx.
> > - SYSCALL, INT80: *do* clear si since the C functions don't take a
> > second argument.
> >
>
> If CLEAR_REGS for SYSCALL, INT80 clears si, it is better, IMO, to
> make CLEAR_REGS clear si unconditionally.
Well, I didn't want to add the overhead to 64bit native syscalls, but
Linus just suggested the same thing elsewhere. So yeah.
He also suggested cleaning up INT80 like below to get rid of the
save_rdi wart.
(Linus, can I add your SoB to the thing?)
---
Subject: x86/entry: Simplify entry_INT80_compat()
From: Linus Torvalds <torvalds@linuxfoundation.org>
Date: Fri Apr 29 22:52:21 CEST 2022
Instead of playing silly games with rdi, use rax for simpler and more
consistent code.
[peterz: Changelog and fix off-by-one in offsets]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/entry/entry_64_compat.S | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -362,26 +362,25 @@ SYM_CODE_START(entry_INT80_compat)
/* switch to thread stack expects orig_ax and rdi to be pushed */
pushq %rax /* pt_regs->orig_ax */
- pushq %rdi /* pt_regs->di */
/* Need to switch before accessing the thread stack. */
- SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi
+ SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
/* In the Xen PV case we already run on the thread stack. */
ALTERNATIVE "", "jmp .Lint80_keep_stack", X86_FEATURE_XENPV
- movq %rsp, %rdi
+ movq %rsp, %rax
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
- pushq 6*8(%rdi) /* regs->ss */
- pushq 5*8(%rdi) /* regs->rsp */
- pushq 4*8(%rdi) /* regs->eflags */
- pushq 3*8(%rdi) /* regs->cs */
- pushq 2*8(%rdi) /* regs->ip */
- pushq 1*8(%rdi) /* regs->orig_ax */
- pushq (%rdi) /* pt_regs->di */
+ pushq 5*8(%rax) /* regs->ss */
+ pushq 4*8(%rax) /* regs->rsp */
+ pushq 3*8(%rax) /* regs->eflags */
+ pushq 2*8(%rax) /* regs->cs */
+ pushq 1*8(%rax) /* regs->ip */
+ pushq 0*8(%rax) /* regs->orig_ax */
.Lint80_keep_stack:
+ pushq %rdi /* pt_regs->di */
pushq %rsi /* pt_regs->si */
xorl %esi, %esi /* nospec si */
pushq %rdx /* pt_regs->dx */
next prev parent reply other threads:[~2022-04-29 21:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 9:13 [PATCH v3] x86,entry: Use PUSH_AND_CLEAR_REGS for compat Peter Zijlstra
2022-04-29 12:00 ` Lai Jiangshan
2022-04-29 21:12 ` Peter Zijlstra [this message]
2022-04-29 21:17 ` [PATCH v4] " Peter Zijlstra
2022-04-29 21:30 ` [PATCH v3] " Linus Torvalds
2022-04-29 22:14 ` Peter Zijlstra
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=YmxU2JoswWMYm4nl@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Andrew.Cooper3@citrix.com \
--cc=brgerst@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--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