From: Al Viro <viro@zeniv.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH v2 6/8] x86: don't reload after cmpxchg in unsafe_atomic_op2() loop
Date: Fri, 27 Mar 2020 03:50:05 +0000 [thread overview]
Message-ID: <20200327035005.GU23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CAHk-=wga5Z9qk0Wa-Jpwb7x+4BG6C17cHfqX4KKqWm9jATpQUw@mail.gmail.com>
On Thu, Mar 26, 2020 at 08:23:59PM -0700, Linus Torvalds wrote:
> On Thu, Mar 26, 2020 at 7:28 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > From: Al Viro <viro@zeniv.linux.org.uk>
> >
> > lock cmpxchg leaves the current value in eax; no need to reload it.
>
> I think this one is buggy.
>
> Patch edited to remove the "-" lines, so that you see the end result:
>
> > int oldval = 0, ret, tem; \
> > asm volatile("1:\tmovl %2, %0\n" \
> > + "2:\tmovl\t%0, %3\n" \
> > "\t" insn "\n" \
> > + "3:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
> > + "\tjnz\t2b\n" \
> > + "4:\n" \
> > "\t.section .fixup,\"ax\"\n" \
> > + "5:\tmov\t%5, %1\n" \
> > "\tjmp\t3b\n" \
> > "\t.previous\n" \
> > + _ASM_EXTABLE_UA(1b, 5b) \
> > + _ASM_EXTABLE_UA(3b, 5b) \
> > : "=&a" (oldval), "=&r" (ret), \
> > "+m" (*uaddr), "=&r" (tem) \
> > : "r" (oparg), "i" (-EFAULT), "1" (0)); \
>
> I think that
>
> "\tjmp\t3b\n"
>
> line in the fixup section should be
>
> "\tjmp\t4b\n"
>
> because you don't want to jump to the cmpxchg instruction.
>
> Maybe I'm misreading it.
You are not - I'd missed that one while renumbering the labels. Fixed and
pushed.
next prev parent reply other threads:[~2020-03-27 3:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <x86: unsafe_put-style macro for sigmask>
2020-03-27 2:28 ` [RFC][PATCH v2 1/8] futex: arch_futex_atomic_op_inuser() calling conventions change Al Viro
2020-03-27 2:28 ` [RFC][PATCH v2 2/8] sh: no need of access_ok() in arch_futex_atomic_op_inuser() Al Viro
2020-03-27 2:28 ` [RFC][PATCH v2 3/8] [parisc, s390, sparc64] no need for access_ok() in futex handling Al Viro
2020-03-27 2:28 ` [RFC][PATCH v2 4/8] objtool: whitelist __sanitizer_cov_trace_switch() Al Viro
2020-03-27 2:28 ` [RFC][PATCH v2 5/8] x86: convert arch_futex_atomic_op_inuser() to user_access_begin/user_access_end() Al Viro
2020-03-27 2:28 ` [RFC][PATCH v2 6/8] x86: don't reload after cmpxchg in unsafe_atomic_op2() loop Al Viro
2020-03-27 3:23 ` Linus Torvalds
2020-03-27 3:50 ` Al Viro [this message]
2020-03-27 2:28 ` [RFC][PATCH v2 7/8] generic arch_futex_atomic_op_inuser() doesn't need access_ok() Al Viro
2020-03-27 2:28 ` [RFC][PATCH v2 8/8] x86: get rid of user_atomic_cmpxchg_inatomic() Al Viro
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=20200327035005.GU23230@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--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
Powered by JetHome