2018-09-28 08:35:59

by Uros Bizjak

[permalink] [raw]
Subject: [PATCH resend] x86, asm: Use CC_SET()/CC_OUT() for __cmpxchg_double

Remove open-coded uses of set instructions to use CC_SET()/CC_OUT()
for __cmpxchg_double.

Signed-off-by: Uros Bizjak <[email protected]>
---
arch/x86/include/asm/cmpxchg.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
index a55d79b233d3..bfb85e5844ab 100644
--- a/arch/x86/include/asm/cmpxchg.h
+++ b/arch/x86/include/asm/cmpxchg.h
@@ -242,10 +242,12 @@ extern void __add_wrong_size(void)
BUILD_BUG_ON(sizeof(*(p2)) != sizeof(long)); \
VM_BUG_ON((unsigned long)(p1) % (2 * sizeof(long))); \
VM_BUG_ON((unsigned long)((p1) + 1) != (unsigned long)(p2)); \
- asm volatile(pfx "cmpxchg%c4b %2; sete %0" \
- : "=a" (__ret), "+d" (__old2), \
- "+m" (*(p1)), "+m" (*(p2)) \
- : "i" (2 * sizeof(long)), "a" (__old1), \
+ asm volatile(pfx "cmpxchg%c5b %1" \
+ CC_SET(e) \
+ : CC_OUT(e) (__ret), \
+ "+m" (*(p1)), "+m" (*(p2)), \
+ "+a" (__old1), "+d" (__old2) \
+ : "i" (2 * sizeof(long)), \
"b" (__new1), "c" (__new2)); \
__ret; \
})
--
2.17.1


2018-10-01 10:28:27

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH resend] x86, asm: Use CC_SET()/CC_OUT() for __cmpxchg_double

On Fri, Sep 28, 2018 at 10:33:05AM +0200, Uros Bizjak wrote:
> Remove open-coded uses of set instructions to use CC_SET()/CC_OUT()
> for __cmpxchg_double.
>
> Signed-off-by: Uros Bizjak <[email protected]>
> ---
> arch/x86/include/asm/cmpxchg.h | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
> index a55d79b233d3..bfb85e5844ab 100644
> --- a/arch/x86/include/asm/cmpxchg.h
> +++ b/arch/x86/include/asm/cmpxchg.h
> @@ -242,10 +242,12 @@ extern void __add_wrong_size(void)
> BUILD_BUG_ON(sizeof(*(p2)) != sizeof(long)); \
> VM_BUG_ON((unsigned long)(p1) % (2 * sizeof(long))); \
> VM_BUG_ON((unsigned long)((p1) + 1) != (unsigned long)(p2)); \
> - asm volatile(pfx "cmpxchg%c4b %2; sete %0" \
> - : "=a" (__ret), "+d" (__old2), \
> - "+m" (*(p1)), "+m" (*(p2)) \
> - : "i" (2 * sizeof(long)), "a" (__old1), \
> + asm volatile(pfx "cmpxchg%c5b %1" \
> + CC_SET(e) \
> + : CC_OUT(e) (__ret), \
> + "+m" (*(p1)), "+m" (*(p2)), \
> + "+a" (__old1), "+d" (__old2) \
> + : "i" (2 * sizeof(long)), \

To quote checkpatch:

WARNING: please, no spaces at the start of a line
#34: FILE: arch/x86/include/asm/cmpxchg.h:245:
+ asm volatile(pfx "cmpxchg%c5b %1" \$

ERROR: code indent should use tabs where possible
#35: FILE: arch/x86/include/asm/cmpxchg.h:246:
+ CC_SET(e) \$

WARNING: please, no spaces at the start of a line
#35: FILE: arch/x86/include/asm/cmpxchg.h:246:
+ CC_SET(e) \$

ERROR: code indent should use tabs where possible
#36: FILE: arch/x86/include/asm/cmpxchg.h:247:
+ : CC_OUT(e) (__ret), \$


...

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

2018-10-01 11:04:56

by Uros Bizjak

[permalink] [raw]
Subject: Re: [PATCH resend] x86, asm: Use CC_SET()/CC_OUT() for __cmpxchg_double

On Mon, Oct 1, 2018 at 12:28 PM Borislav Petkov <[email protected]> wrote:
>
> On Fri, Sep 28, 2018 at 10:33:05AM +0200, Uros Bizjak wrote:
> > Remove open-coded uses of set instructions to use CC_SET()/CC_OUT()
> > for __cmpxchg_double.
> >
> > Signed-off-by: Uros Bizjak <[email protected]>
> > ---
> > arch/x86/include/asm/cmpxchg.h | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
> > index a55d79b233d3..bfb85e5844ab 100644
> > --- a/arch/x86/include/asm/cmpxchg.h
> > +++ b/arch/x86/include/asm/cmpxchg.h
> > @@ -242,10 +242,12 @@ extern void __add_wrong_size(void)
> > BUILD_BUG_ON(sizeof(*(p2)) != sizeof(long)); \
> > VM_BUG_ON((unsigned long)(p1) % (2 * sizeof(long))); \
> > VM_BUG_ON((unsigned long)((p1) + 1) != (unsigned long)(p2)); \
> > - asm volatile(pfx "cmpxchg%c4b %2; sete %0" \
> > - : "=a" (__ret), "+d" (__old2), \
> > - "+m" (*(p1)), "+m" (*(p2)) \
> > - : "i" (2 * sizeof(long)), "a" (__old1), \
> > + asm volatile(pfx "cmpxchg%c5b %1" \
> > + CC_SET(e) \
> > + : CC_OUT(e) (__ret), \
> > + "+m" (*(p1)), "+m" (*(p2)), \
> > + "+a" (__old1), "+d" (__old2) \
> > + : "i" (2 * sizeof(long)), \
>
> To quote checkpatch:

Looks like gmail forward mangled whitespace. The original, archived at
Patchwork [1] passes checkpatch without problems.

[1] https://mail.google.com/mail/u/0/#inbox/LXphbRLrghxkrJptDWnbbJcrVBkBsRQgcnbtRLjbGSq

Uros.

2018-10-01 11:36:12

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH resend] x86, asm: Use CC_SET()/CC_OUT() for __cmpxchg_double

On Mon, Oct 01, 2018 at 01:03:47PM +0200, Uros Bizjak wrote:
> Looks like gmail forward mangled whitespace. The original, archived at
> Patchwork [1] passes checkpatch without problems.
>
> [1] https://mail.google.com/mail/u/0/#inbox/LXphbRLrghxkrJptDWnbbJcrVBkBsRQgcnbtRLjbGSq

This is a gmail link *into* your inbox?!?!

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

2018-10-01 11:42:18

by Uros Bizjak

[permalink] [raw]
Subject: Re: [PATCH resend] x86, asm: Use CC_SET()/CC_OUT() for __cmpxchg_double

On Mon, Oct 1, 2018 at 1:35 PM Borislav Petkov <[email protected]> wrote:
>
> On Mon, Oct 01, 2018 at 01:03:47PM +0200, Uros Bizjak wrote:
> > Looks like gmail forward mangled whitespace. The original, archived at
> > Patchwork [1] passes checkpatch without problems.
> >
> > [1] https://mail.google.com/mail/u/0/#inbox/LXphbRLrghxkrJptDWnbbJcrVBkBsRQgcnbtRLjbGSq
>
> This is a gmail link *into* your inbox?!?!

I don't know how I managed to copy and paste the wrong link :( Here is
the correct one:

https://lore.kernel.org/patchwork/patch/975764/

Uros.
Uros.

Subject: [tip:x86/asm] x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()

Commit-ID: c808c09b527cd60d9a0d53799935f75e2452174d
Gitweb: https://git.kernel.org/tip/c808c09b527cd60d9a0d53799935f75e2452174d
Author: Uros Bizjak <[email protected]>
AuthorDate: Fri, 28 Sep 2018 10:33:05 +0200
Committer: Borislav Petkov <[email protected]>
CommitDate: Mon, 1 Oct 2018 13:46:32 +0200

x86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double()

Replace open-coded use of the SETcc instruction with CC_SET()/CC_OUT()
in __cmpxchg_double().

Signed-off-by: Uros Bizjak <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Link: https://lkml.kernel.org/r/CAFULd4YdvwwhXWHqqPsGk5+TLG71ozgSscTZNsqmrm+Jzg941w@mail.gmail.com
---
arch/x86/include/asm/cmpxchg.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
index a55d79b233d3..bfb85e5844ab 100644
--- a/arch/x86/include/asm/cmpxchg.h
+++ b/arch/x86/include/asm/cmpxchg.h
@@ -242,10 +242,12 @@ extern void __add_wrong_size(void)
BUILD_BUG_ON(sizeof(*(p2)) != sizeof(long)); \
VM_BUG_ON((unsigned long)(p1) % (2 * sizeof(long))); \
VM_BUG_ON((unsigned long)((p1) + 1) != (unsigned long)(p2)); \
- asm volatile(pfx "cmpxchg%c4b %2; sete %0" \
- : "=a" (__ret), "+d" (__old2), \
- "+m" (*(p1)), "+m" (*(p2)) \
- : "i" (2 * sizeof(long)), "a" (__old1), \
+ asm volatile(pfx "cmpxchg%c5b %1" \
+ CC_SET(e) \
+ : CC_OUT(e) (__ret), \
+ "+m" (*(p1)), "+m" (*(p2)), \
+ "+a" (__old1), "+d" (__old2) \
+ : "i" (2 * sizeof(long)), \
"b" (__new1), "c" (__new2)); \
__ret; \
})