[tip:x86/urgent] x86/asm: Use CC_SET()/CC_OUT() in __gen_sigismember()

2018-08-30 Thread tip-bot for Uros Bizjak
Commit-ID:  26e609eccd37967d3681662433086894830c5d62
Gitweb: https://git.kernel.org/tip/26e609eccd37967d3681662433086894830c5d62
Author: Uros Bizjak 
AuthorDate: Tue, 14 Aug 2018 18:59:51 +0200
Committer:  Thomas Gleixner 
CommitDate: Thu, 30 Aug 2018 13:02:31 +0200

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

Replace open-coded set instructions with CC_SET()/CC_OUT().

Signed-off-by: Uros Bizjak 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/20180814165951.13538-1-ubiz...@gmail.com

---
 arch/x86/include/asm/signal.h | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/signal.h b/arch/x86/include/asm/signal.h
index 5f9012ff52ed..33d3c88a7225 100644
--- a/arch/x86/include/asm/signal.h
+++ b/arch/x86/include/asm/signal.h
@@ -39,6 +39,7 @@ extern void do_signal(struct pt_regs *regs);
 
 #define __ARCH_HAS_SA_RESTORER
 
+#include 
 #include 
 
 #ifdef __i386__
@@ -86,9 +87,9 @@ static inline int __const_sigismember(sigset_t *set, int _sig)
 
 static inline int __gen_sigismember(sigset_t *set, int _sig)
 {
-   unsigned char ret;
-   asm("btl %2,%1\n\tsetc %0"
-   : "=qm"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
+   bool ret;
+   asm("btl %2,%1" CC_SET(c)
+   : CC_OUT(c) (ret) : "m"(*set), "Ir"(_sig-1));
return ret;
 }
 


[tip:x86/boot] x86/boot: Use CC_SET()/CC_OUT() instead of open coding it

2018-08-02 Thread tip-bot for Uros Bizjak
Commit-ID:  216a37202f10b7d78f2f98e26a6681f367165f05
Gitweb: https://git.kernel.org/tip/216a37202f10b7d78f2f98e26a6681f367165f05
Author: Uros Bizjak 
AuthorDate: Fri, 29 Jun 2018 16:28:44 +0200
Committer:  Thomas Gleixner 
CommitDate: Thu, 2 Aug 2018 14:30:42 +0200

x86/boot: Use CC_SET()/CC_OUT() instead of open coding it

Remove open-coded uses of set instructions with CC_SET()/CC_OUT().

Signed-off-by: Uros Bizjak 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/20180629142844.15200-1-ubiz...@gmail.com

---
 arch/x86/boot/bitops.h | 3 ++-
 arch/x86/boot/string.c | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
index 0d41d68131cc..2e1382486e91 100644
--- a/arch/x86/boot/bitops.h
+++ b/arch/x86/boot/bitops.h
@@ -17,6 +17,7 @@
 #define _LINUX_BITOPS_H/* Inhibit inclusion of 
 */
 
 #include 
+#include 
 
 static inline bool constant_test_bit(int nr, const void *addr)
 {
@@ -28,7 +29,7 @@ static inline bool variable_test_bit(int nr, const void *addr)
bool v;
const u32 *p = (const u32 *)addr;
 
-   asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
+   asm("btl %2,%1" CC_SET(c) : CC_OUT(c) (v) : "m" (*p), "Ir" (nr));
return v;
 }
 
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index 16f49123d747..c4428a176973 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -13,6 +13,7 @@
  */
 
 #include 
+#include 
 #include "ctype.h"
 #include "string.h"
 
@@ -28,8 +29,8 @@
 int memcmp(const void *s1, const void *s2, size_t len)
 {
bool diff;
-   asm("repe; cmpsb; setnz %0"
-   : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
+   asm("repe; cmpsb" CC_SET(nz)
+   : CC_OUT(nz) (diff), "+D" (s1), "+S" (s2), "+c" (len));
return diff;
 }
 


[tip:x86/asm] x86: Use POPCNT mnemonics in arch_hweight.h

2018-11-05 Thread tip-bot for Uros Bizjak
Commit-ID:  566b62a3676caed1f8c626e26066ff3ae3a38918
Gitweb: https://git.kernel.org/tip/566b62a3676caed1f8c626e26066ff3ae3a38918
Author: Uros Bizjak 
AuthorDate: Sun, 14 Oct 2018 22:23:54 +0200
Committer:  Borislav Petkov 
CommitDate: Mon, 5 Nov 2018 10:42:32 +0100

x86: Use POPCNT mnemonics in arch_hweight.h

Recently, the minimum required version of binutils was changed to
2.20, which supports POPCNT instruction mnemonics.

Replace the byte-wise specification of POPCNT with those proper
mnemonics.

 [ bp: massage commit message and remove line breaks. ]

Signed-off-by: Uros Bizjak 
Signed-off-by: Borislav Petkov 
CC: "H. Peter Anvin" 
CC: Ingo Molnar 
CC: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20181014202354.21281-1-ubiz...@gmail.com
---
 arch/x86/include/asm/arch_hweight.h | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/arch_hweight.h 
b/arch/x86/include/asm/arch_hweight.h
index 34a10b2d5b73..fc0693569f7a 100644
--- a/arch/x86/include/asm/arch_hweight.h
+++ b/arch/x86/include/asm/arch_hweight.h
@@ -5,15 +5,9 @@
 #include 
 
 #ifdef CONFIG_64BIT
-/* popcnt %edi, %eax */
-#define POPCNT32 ".byte 0xf3,0x0f,0xb8,0xc7"
-/* popcnt %rdi, %rax */
-#define POPCNT64 ".byte 0xf3,0x48,0x0f,0xb8,0xc7"
 #define REG_IN "D"
 #define REG_OUT "a"
 #else
-/* popcnt %eax, %eax */
-#define POPCNT32 ".byte 0xf3,0x0f,0xb8,0xc0"
 #define REG_IN "a"
 #define REG_OUT "a"
 #endif
@@ -24,7 +18,7 @@ static __always_inline unsigned int __arch_hweight32(unsigned 
int w)
 {
unsigned int res;
 
-   asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, X86_FEATURE_POPCNT)
+   asm (ALTERNATIVE("call __sw_hweight32", "popcntl %1, %0", 
X86_FEATURE_POPCNT)
 : "="REG_OUT (res)
 : REG_IN (w));
 
@@ -52,7 +46,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
 {
unsigned long res;
 
-   asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
+   asm (ALTERNATIVE("call __sw_hweight64", "popcntq %1, %0", 
X86_FEATURE_POPCNT)
 : "="REG_OUT (res)
 : REG_IN (w));
 


[tip:x86/cache] x86/resctrl: Use _ASM_BX to avoid ifdeffery

2019-06-10 Thread tip-bot for Uros Bizjak
Commit-ID:  515f0453752e3daba7c47d37d9172a66509a56fd
Gitweb: https://git.kernel.org/tip/515f0453752e3daba7c47d37d9172a66509a56fd
Author: Uros Bizjak 
AuthorDate: Thu, 6 Jun 2019 22:00:44 +0200
Committer:  Borislav Petkov 
CommitDate: Mon, 10 Jun 2019 22:36:38 +0200

x86/resctrl: Use _ASM_BX to avoid ifdeffery

Use the _ASM_BX macro which expands to either %rbx or %ebx, depending on
the 32-bit or 64-bit config selected.

Signed-off-by: Uros Bizjak 
Signed-off-by: Borislav Petkov 
Acked-by: Reinette Chatre 
Cc: Fenghua Yu 
Cc: "H. Peter Anvin" 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: x86-ml 
Link: https://lkml.kernel.org/r/20190606200044.5730-1-ubiz...@gmail.com
---
 arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c 
b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
index 604c0e3bcc83..09408794eab2 100644
--- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
+++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
@@ -431,11 +431,7 @@ static int pseudo_lock_fn(void *_rdtgrp)
 #else
register unsigned int line_size asm("esi");
register unsigned int size asm("edi");
-#ifdef CONFIG_X86_64
-   register void *mem_r asm("rbx");
-#else
-   register void *mem_r asm("ebx");
-#endif /* CONFIG_X86_64 */
+   register void *mem_r asm(_ASM_BX);
 #endif /* CONFIG_KASAN */
 
/*


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

2018-10-01 Thread tip-bot for Uros Bizjak
Commit-ID:  c808c09b527cd60d9a0d53799935f75e2452174d
Gitweb: https://git.kernel.org/tip/c808c09b527cd60d9a0d53799935f75e2452174d
Author: Uros Bizjak 
AuthorDate: Fri, 28 Sep 2018 10:33:05 +0200
Committer:  Borislav Petkov 
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 
Signed-off-by: Borislav Petkov 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: "H. Peter Anvin" 
Link: 
https://lkml.kernel.org/r/cafuld4ydvwwhxwhqqpsgk5+tlg71ozgssctznsqmrm+jzg9...@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;  \
 })


[tip:x86/asm] x86/asm: Remove unnecessary \n\t in front of CC_SET() from asm templates

2017-09-24 Thread tip-bot for Uros Bizjak
Commit-ID:  3c52b5c64326d9dcfee4e10611c53ec1b1b20675
Gitweb: http://git.kernel.org/tip/3c52b5c64326d9dcfee4e10611c53ec1b1b20675
Author: Uros Bizjak 
AuthorDate: Wed, 6 Sep 2017 17:18:08 +0200
Committer:  Ingo Molnar 
CommitDate: Sun, 24 Sep 2017 11:19:01 +0200

x86/asm: Remove unnecessary \n\t in front of CC_SET() from asm templates

There is no need for \n\t in front of CC_SET(), as the macro already includes 
these two.

Signed-off-by: Uros Bizjak 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20170906151808.5634-1-ubiz...@gmail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/archrandom.h |  8 
 arch/x86/include/asm/bitops.h | 10 +-
 arch/x86/include/asm/percpu.h |  2 +-
 arch/x86/include/asm/rmwcc.h  |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/x86/include/asm/archrandom.h 
b/arch/x86/include/asm/archrandom.h
index 5b0579a..3ac991d 100644
--- a/arch/x86/include/asm/archrandom.h
+++ b/arch/x86/include/asm/archrandom.h
@@ -45,7 +45,7 @@ static inline bool rdrand_long(unsigned long *v)
bool ok;
unsigned int retry = RDRAND_RETRY_LOOPS;
do {
-   asm volatile(RDRAND_LONG "\n\t"
+   asm volatile(RDRAND_LONG
 CC_SET(c)
 : CC_OUT(c) (ok), "=a" (*v));
if (ok)
@@ -59,7 +59,7 @@ static inline bool rdrand_int(unsigned int *v)
bool ok;
unsigned int retry = RDRAND_RETRY_LOOPS;
do {
-   asm volatile(RDRAND_INT "\n\t"
+   asm volatile(RDRAND_INT
 CC_SET(c)
 : CC_OUT(c) (ok), "=a" (*v));
if (ok)
@@ -71,7 +71,7 @@ static inline bool rdrand_int(unsigned int *v)
 static inline bool rdseed_long(unsigned long *v)
 {
bool ok;
-   asm volatile(RDSEED_LONG "\n\t"
+   asm volatile(RDSEED_LONG
 CC_SET(c)
 : CC_OUT(c) (ok), "=a" (*v));
return ok;
@@ -80,7 +80,7 @@ static inline bool rdseed_long(unsigned long *v)
 static inline bool rdseed_int(unsigned int *v)
 {
bool ok;
-   asm volatile(RDSEED_INT "\n\t"
+   asm volatile(RDSEED_INT
 CC_SET(c)
 : CC_OUT(c) (ok), "=a" (*v));
return ok;
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 8540227..8cee8db 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -142,7 +142,7 @@ static __always_inline void __clear_bit(long nr, volatile 
unsigned long *addr)
 static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, 
volatile unsigned long *addr)
 {
bool negative;
-   asm volatile(LOCK_PREFIX "andb %2,%1\n\t"
+   asm volatile(LOCK_PREFIX "andb %2,%1"
CC_SET(s)
: CC_OUT(s) (negative), ADDR
: "ir" ((char) ~(1 << nr)) : "memory");
@@ -245,7 +245,7 @@ static __always_inline bool __test_and_set_bit(long nr, 
volatile unsigned long *
 {
bool oldbit;
 
-   asm("bts %2,%1\n\t"
+   asm("bts %2,%1"
CC_SET(c)
: CC_OUT(c) (oldbit), ADDR
: "Ir" (nr));
@@ -285,7 +285,7 @@ static __always_inline bool __test_and_clear_bit(long nr, 
volatile unsigned long
 {
bool oldbit;
 
-   asm volatile("btr %2,%1\n\t"
+   asm volatile("btr %2,%1"
 CC_SET(c)
 : CC_OUT(c) (oldbit), ADDR
 : "Ir" (nr));
@@ -297,7 +297,7 @@ static __always_inline bool __test_and_change_bit(long nr, 
volatile unsigned lon
 {
bool oldbit;
 
-   asm volatile("btc %2,%1\n\t"
+   asm volatile("btc %2,%1"
 CC_SET(c)
 : CC_OUT(c) (oldbit), ADDR
 : "Ir" (nr) : "memory");
@@ -328,7 +328,7 @@ static __always_inline bool variable_test_bit(long nr, 
volatile const unsigned l
 {
bool oldbit;
 
-   asm volatile("bt %2,%1\n\t"
+   asm volatile("bt %2,%1"
 CC_SET(c)
 : CC_OUT(c) (oldbit)
 : "m" (*(unsigned long *)addr), "Ir" (nr));
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 9fa0360..b21a475 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -525,7 +525,7 @@ static inline bool x86_this_cpu_variable_test_bit(int nr,
 {
bool oldbit;
 
-   asm volatile("bt "__percpu_arg(2)",%1\n\t"
+   asm volatile("bt "__percpu_arg(2)",%1"
CC_SET(c)
: CC_OUT(c) (oldbit)
: "m" (*(unsigned long __percpu *)addr), "Ir" (nr));
diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
index 045f992..0c411c8 100644
--- a/arch/x86/include/asm/rmwcc.h
+++ b/arch/x86/include/asm/rmwcc.h
@@ -28,7 +28,7 @@ cc_label: