* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 12:28 ` Arnd Bergmann
0 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2019-07-11 12:28 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: linux-arch, Shuah Khan, Linux Kernel Mailing List,
Andy Lutomirski, Dmitry Safonov, Huw Davies, Catalin Marinas,
Daniel Lezcano, Will Deacon, linux-mips, Ralf Baechle,
Russell King, clang-built-linux, Paul Burton,
open list:KERNEL SELFTEST FRAMEWORK, Rasmus Villemoes,
Thomas Gleixner, Mark Salyzyn, Peter Collingbourne, Linux ARM
On Thu, Jul 11, 2019 at 2:14 PM Vincenzo Frascino
<vincenzo.frascino@arm.com> wrote:
>
>
> Could you please tell me which version of the compiler did you use?
>
> My building command is:
>
> # make mrproper && make CC=clang HOSTCC=clang i386_defconfig && make ARCH=i386
> CC=clang HOSTCC=clang -j56
>
See below for the patch I am using locally to work around this.
That patch is probably wrong, so I have not submitted it yet, but it
gives you a clean build ;-)
Arnd
8<---
Subject: [PATCH] x86: percpu: fix clang 32-bit build
clang does not like an inline assembly with a "=q" contraint for
a 64-bit output:
arch/x86/events/perf_event.h:824:21: error: invalid output size for
constraint '=q'
u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
^
include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
raw_cpu_read(pcp); \
^
include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp)
__pcpu_size_call_return(raw_cpu_read_, pcp)
^
include/linux/percpu-defs.h:322:23: note: expanded from macro
'__pcpu_size_call_return'
case 1: pscr_ret__ = stem##1(variable); break; \
^
<scratch space>:357:1: note: expanded from here
raw_cpu_read_1
^
arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
#define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
^
arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret__) \
^
According to the commit that introduced the "q" constraint, this was
needed to fix miscompilation, but it gives no further detail.
Using the normal "=r" constraint seems to work so far.
Fixes: 3c598766a2ba ("x86: fix percpu_{to,from}_op()")
Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 2278797c769d..e791fbf4018f 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -99,7 +99,7 @@ do { \
case 1: \
asm qual (op "b %1,"__percpu_arg(0) \
: "+m" (var) \
- : "qi" ((pto_T__)(val))); \
+ : "ri" ((pto_T__)(val))); \
break; \
case 2: \
asm qual (op "w %1,"__percpu_arg(0) \
@@ -144,7 +144,7 @@ do {
\
else \
asm qual ("addb %1, "__percpu_arg(0) \
: "+m" (var) \
- : "qi" ((pao_T__)(val))); \
+ : "ri" ((pao_T__)(val))); \
break; \
case 2: \
if (pao_ID__ == 1) \
@@ -186,7 +186,7 @@ do {
\
switch (sizeof(var)) { \
case 1: \
asm qual (op "b "__percpu_arg(1)",%0" \
- : "=q" (pfo_ret__) \
+ : "=r" (pfo_ret__) \
: "m" (var)); \
break; \
case 2: \
@@ -215,7 +215,7 @@ do {
\
switch (sizeof(var)) { \
case 1: \
asm(op "b "__percpu_arg(P1)",%0" \
- : "=q" (pfo_ret__) \
+ : "=r" (pfo_ret__) \
: "p" (&(var))); \
break; \
case 2: \
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 12:28 ` Arnd Bergmann
0 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2019-07-11 12:28 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: Andy Lutomirski, Thomas Gleixner, linux-arch, Linux ARM,
linux-mips, open list:KERNEL SELFTEST FRAMEWORK, Catalin Marinas,
Will Deacon, Russell King, Ralf Baechle, Paul Burton,
Daniel Lezcano, Mark Salyzyn, Peter Collingbourne, Shuah Khan,
Dmitry Safonov, Rasmus Villemoes, Huw Davies,
Linux Kernel Mailing List, clang-built-linux
On Thu, Jul 11, 2019 at 2:14 PM Vincenzo Frascino
<vincenzo.frascino@arm.com> wrote:
>
>
> Could you please tell me which version of the compiler did you use?
>
> My building command is:
>
> # make mrproper && make CC=clang HOSTCC=clang i386_defconfig && make ARCH=i386
> CC=clang HOSTCC=clang -j56
>
See below for the patch I am using locally to work around this.
That patch is probably wrong, so I have not submitted it yet, but it
gives you a clean build ;-)
Arnd
8<---
Subject: [PATCH] x86: percpu: fix clang 32-bit build
clang does not like an inline assembly with a "=q" contraint for
a 64-bit output:
arch/x86/events/perf_event.h:824:21: error: invalid output size for
constraint '=q'
u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
^
include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
raw_cpu_read(pcp); \
^
include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp)
__pcpu_size_call_return(raw_cpu_read_, pcp)
^
include/linux/percpu-defs.h:322:23: note: expanded from macro
'__pcpu_size_call_return'
case 1: pscr_ret__ = stem##1(variable); break; \
^
<scratch space>:357:1: note: expanded from here
raw_cpu_read_1
^
arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
#define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
^
arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret__) \
^
According to the commit that introduced the "q" constraint, this was
needed to fix miscompilation, but it gives no further detail.
Using the normal "=r" constraint seems to work so far.
Fixes: 3c598766a2ba ("x86: fix percpu_{to,from}_op()")
Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 2278797c769d..e791fbf4018f 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -99,7 +99,7 @@ do { \
case 1: \
asm qual (op "b %1,"__percpu_arg(0) \
: "+m" (var) \
- : "qi" ((pto_T__)(val))); \
+ : "ri" ((pto_T__)(val))); \
break; \
case 2: \
asm qual (op "w %1,"__percpu_arg(0) \
@@ -144,7 +144,7 @@ do {
\
else \
asm qual ("addb %1, "__percpu_arg(0) \
: "+m" (var) \
- : "qi" ((pao_T__)(val))); \
+ : "ri" ((pao_T__)(val))); \
break; \
case 2: \
if (pao_ID__ == 1) \
@@ -186,7 +186,7 @@ do {
\
switch (sizeof(var)) { \
case 1: \
asm qual (op "b "__percpu_arg(1)",%0" \
- : "=q" (pfo_ret__) \
+ : "=r" (pfo_ret__) \
: "m" (var)); \
break; \
case 2: \
@@ -215,7 +215,7 @@ do {
\
switch (sizeof(var)) { \
case 1: \
asm(op "b "__percpu_arg(P1)",%0" \
- : "=q" (pfo_ret__) \
+ : "=r" (pfo_ret__) \
: "p" (&(var))); \
break; \
case 2: \
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 12:28 ` Arnd Bergmann
0 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2019-07-11 12:28 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: Andy Lutomirski, Thomas Gleixner, linux-arch, Linux ARM,
linux-mips, open list:KERNEL SELFTEST FRAMEWORK, Catalin Marinas,
Will Deacon, Russell King, Ralf Baechle, Paul Burton,
Daniel Lezcano, Mark Salyzyn, Peter Collingbourne, Shuah Khan,
Dmitry Safonov, Rasmus Villemoes, Huw Davies
On Thu, Jul 11, 2019 at 2:14 PM Vincenzo Frascino
<vincenzo.frascino@arm.com> wrote:
>
>
> Could you please tell me which version of the compiler did you use?
>
> My building command is:
>
> # make mrproper && make CC=clang HOSTCC=clang i386_defconfig && make ARCH=i386
> CC=clang HOSTCC=clang -j56
>
See below for the patch I am using locally to work around this.
That patch is probably wrong, so I have not submitted it yet, but it
gives you a clean build ;-)
Arnd
8<---
Subject: [PATCH] x86: percpu: fix clang 32-bit build
clang does not like an inline assembly with a "=q" contraint for
a 64-bit output:
arch/x86/events/perf_event.h:824:21: error: invalid output size for
constraint '=q'
u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
^
include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
raw_cpu_read(pcp); \
^
include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp)
__pcpu_size_call_return(raw_cpu_read_, pcp)
^
include/linux/percpu-defs.h:322:23: note: expanded from macro
'__pcpu_size_call_return'
case 1: pscr_ret__ = stem##1(variable); break; \
^
<scratch space>:357:1: note: expanded from here
raw_cpu_read_1
^
arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
#define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
^
arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret__) \
^
According to the commit that introduced the "q" constraint, this was
needed to fix miscompilation, but it gives no further detail.
Using the normal "=r" constraint seems to work so far.
Fixes: 3c598766a2ba ("x86: fix percpu_{to,from}_op()")
Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 2278797c769d..e791fbf4018f 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -99,7 +99,7 @@ do { \
case 1: \
asm qual (op "b %1,"__percpu_arg(0) \
: "+m" (var) \
- : "qi" ((pto_T__)(val))); \
+ : "ri" ((pto_T__)(val))); \
break; \
case 2: \
asm qual (op "w %1,"__percpu_arg(0) \
@@ -144,7 +144,7 @@ do {
\
else \
asm qual ("addb %1, "__percpu_arg(0) \
: "+m" (var) \
- : "qi" ((pao_T__)(val))); \
+ : "ri" ((pao_T__)(val))); \
break; \
case 2: \
if (pao_ID__ == 1) \
@@ -186,7 +186,7 @@ do {
\
switch (sizeof(var)) { \
case 1: \
asm qual (op "b "__percpu_arg(1)",%0" \
- : "=q" (pfo_ret__) \
+ : "=r" (pfo_ret__) \
: "m" (var)); \
break; \
case 2: \
@@ -215,7 +215,7 @@ do {
\
switch (sizeof(var)) { \
case 1: \
asm(op "b "__percpu_arg(P1)",%0" \
- : "=q" (pfo_ret__) \
+ : "=r" (pfo_ret__) \
: "p" (&(var))); \
break; \
case 2: \
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
2019-07-11 12:28 ` Arnd Bergmann
(?)
(?)
@ 2019-07-11 13:08 ` Vincenzo Frascino
-1 siblings, 0 replies; 28+ messages in thread
From: Vincenzo Frascino @ 2019-07-11 13:08 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Andy Lutomirski, Thomas Gleixner, linux-arch, Linux ARM,
linux-mips, open list:KERNEL SELFTEST FRAMEWORK, Catalin Marinas,
Will Deacon, Russell King, Ralf Baechle, Paul Burton,
Daniel Lezcano, Mark Salyzyn, Peter Collingbourne, Shuah Khan,
Dmitry Safonov, Rasmus Villemoes, Huw Davies,
Linux Kernel Mailing List, clang-built-linux
Hi Arnd,
On 11/07/2019 13:28, Arnd Bergmann wrote:
> On Thu, Jul 11, 2019 at 2:14 PM Vincenzo Frascino
> <vincenzo.frascino@arm.com> wrote:
>>
>>
>> Could you please tell me which version of the compiler did you use?
>>
>> My building command is:
>>
>> # make mrproper && make CC=clang HOSTCC=clang i386_defconfig && make ARCH=i386
>> CC=clang HOSTCC=clang -j56
>>
>
> See below for the patch I am using locally to work around this.
> That patch is probably wrong, so I have not submitted it yet, but it
> gives you a clean build ;-)
>
> Arnd
>
Thank you, I will give it a go :-)
> 8<---
> Subject: [PATCH] x86: percpu: fix clang 32-bit build
>
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
>
> arch/x86/events/perf_event.h:824:21: error: invalid output size for
> constraint '=q'
> u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
> ^
> include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
> raw_cpu_read(pcp); \
> ^
> include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
> #define raw_cpu_read(pcp)
> __pcpu_size_call_return(raw_cpu_read_, pcp)
> ^
> include/linux/percpu-defs.h:322:23: note: expanded from macro
> '__pcpu_size_call_return'
> case 1: pscr_ret__ = stem##1(variable); break; \
> ^
> <scratch space>:357:1: note: expanded from here
> raw_cpu_read_1
> ^
> arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
> #define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
> ^
> arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
> : "=q" (pfo_ret__) \
> ^
>
> According to the commit that introduced the "q" constraint, this was
> needed to fix miscompilation, but it gives no further detail.
>
> Using the normal "=r" constraint seems to work so far.
>
> Fixes: 3c598766a2ba ("x86: fix percpu_{to,from}_op()")
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> index 2278797c769d..e791fbf4018f 100644
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -99,7 +99,7 @@ do { \
> case 1: \
> asm qual (op "b %1,"__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pto_T__)(val))); \
> + : "ri" ((pto_T__)(val))); \
> break; \
> case 2: \
> asm qual (op "w %1,"__percpu_arg(0) \
> @@ -144,7 +144,7 @@ do {
> \
> else \
> asm qual ("addb %1, "__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pao_T__)(val))); \
> + : "ri" ((pao_T__)(val))); \
> break; \
> case 2: \
> if (pao_ID__ == 1) \
> @@ -186,7 +186,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm qual (op "b "__percpu_arg(1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "m" (var)); \
> break; \
> case 2: \
> @@ -215,7 +215,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm(op "b "__percpu_arg(P1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "p" (&(var))); \
> break; \
> case 2: \
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 13:08 ` Vincenzo Frascino
0 siblings, 0 replies; 28+ messages in thread
From: Vincenzo Frascino @ 2019-07-11 13:08 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-arch, Shuah Khan, Linux Kernel Mailing List,
Andy Lutomirski, Dmitry Safonov, Huw Davies, Catalin Marinas,
Daniel Lezcano, Will Deacon, linux-mips, Ralf Baechle,
Russell King, clang-built-linux, Paul Burton,
open list:KERNEL SELFTEST FRAMEWORK, Rasmus Villemoes,
Thomas Gleixner, Mark Salyzyn, Peter Collingbourne, Linux ARM
Hi Arnd,
On 11/07/2019 13:28, Arnd Bergmann wrote:
> On Thu, Jul 11, 2019 at 2:14 PM Vincenzo Frascino
> <vincenzo.frascino@arm.com> wrote:
>>
>>
>> Could you please tell me which version of the compiler did you use?
>>
>> My building command is:
>>
>> # make mrproper && make CC=clang HOSTCC=clang i386_defconfig && make ARCH=i386
>> CC=clang HOSTCC=clang -j56
>>
>
> See below for the patch I am using locally to work around this.
> That patch is probably wrong, so I have not submitted it yet, but it
> gives you a clean build ;-)
>
> Arnd
>
Thank you, I will give it a go :-)
> 8<---
> Subject: [PATCH] x86: percpu: fix clang 32-bit build
>
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
>
> arch/x86/events/perf_event.h:824:21: error: invalid output size for
> constraint '=q'
> u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
> ^
> include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
> raw_cpu_read(pcp); \
> ^
> include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
> #define raw_cpu_read(pcp)
> __pcpu_size_call_return(raw_cpu_read_, pcp)
> ^
> include/linux/percpu-defs.h:322:23: note: expanded from macro
> '__pcpu_size_call_return'
> case 1: pscr_ret__ = stem##1(variable); break; \
> ^
> <scratch space>:357:1: note: expanded from here
> raw_cpu_read_1
> ^
> arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
> #define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
> ^
> arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
> : "=q" (pfo_ret__) \
> ^
>
> According to the commit that introduced the "q" constraint, this was
> needed to fix miscompilation, but it gives no further detail.
>
> Using the normal "=r" constraint seems to work so far.
>
> Fixes: 3c598766a2ba ("x86: fix percpu_{to,from}_op()")
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> index 2278797c769d..e791fbf4018f 100644
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -99,7 +99,7 @@ do { \
> case 1: \
> asm qual (op "b %1,"__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pto_T__)(val))); \
> + : "ri" ((pto_T__)(val))); \
> break; \
> case 2: \
> asm qual (op "w %1,"__percpu_arg(0) \
> @@ -144,7 +144,7 @@ do {
> \
> else \
> asm qual ("addb %1, "__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pao_T__)(val))); \
> + : "ri" ((pao_T__)(val))); \
> break; \
> case 2: \
> if (pao_ID__ == 1) \
> @@ -186,7 +186,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm qual (op "b "__percpu_arg(1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "m" (var)); \
> break; \
> case 2: \
> @@ -215,7 +215,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm(op "b "__percpu_arg(P1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "p" (&(var))); \
> break; \
> case 2: \
>
--
Regards,
Vincenzo
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 13:08 ` Vincenzo Frascino
0 siblings, 0 replies; 28+ messages in thread
From: Vincenzo Frascino @ 2019-07-11 13:08 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Andy Lutomirski, Thomas Gleixner, linux-arch, Linux ARM,
linux-mips, open list:KERNEL SELFTEST FRAMEWORK, Catalin Marinas,
Will Deacon, Russell King, Ralf Baechle, Paul Burton,
Daniel Lezcano, Mark Salyzyn, Peter Collingbourne, Shuah Khan,
Dmitry Safonov, Rasmus Villemoes, Huw Davies,
Linux Kernel Mailing List, clang-built-linux
Hi Arnd,
On 11/07/2019 13:28, Arnd Bergmann wrote:
> On Thu, Jul 11, 2019 at 2:14 PM Vincenzo Frascino
> <vincenzo.frascino@arm.com> wrote:
>>
>>
>> Could you please tell me which version of the compiler did you use?
>>
>> My building command is:
>>
>> # make mrproper && make CC=clang HOSTCC=clang i386_defconfig && make ARCH=i386
>> CC=clang HOSTCC=clang -j56
>>
>
> See below for the patch I am using locally to work around this.
> That patch is probably wrong, so I have not submitted it yet, but it
> gives you a clean build ;-)
>
> Arnd
>
Thank you, I will give it a go :-)
> 8<---
> Subject: [PATCH] x86: percpu: fix clang 32-bit build
>
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
>
> arch/x86/events/perf_event.h:824:21: error: invalid output size for
> constraint '=q'
> u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
> ^
> include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
> raw_cpu_read(pcp); \
> ^
> include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
> #define raw_cpu_read(pcp)
> __pcpu_size_call_return(raw_cpu_read_, pcp)
> ^
> include/linux/percpu-defs.h:322:23: note: expanded from macro
> '__pcpu_size_call_return'
> case 1: pscr_ret__ = stem##1(variable); break; \
> ^
> <scratch space>:357:1: note: expanded from here
> raw_cpu_read_1
> ^
> arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
> #define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
> ^
> arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
> : "=q" (pfo_ret__) \
> ^
>
> According to the commit that introduced the "q" constraint, this was
> needed to fix miscompilation, but it gives no further detail.
>
> Using the normal "=r" constraint seems to work so far.
>
> Fixes: 3c598766a2ba ("x86: fix percpu_{to,from}_op()")
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> index 2278797c769d..e791fbf4018f 100644
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -99,7 +99,7 @@ do { \
> case 1: \
> asm qual (op "b %1,"__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pto_T__)(val))); \
> + : "ri" ((pto_T__)(val))); \
> break; \
> case 2: \
> asm qual (op "w %1,"__percpu_arg(0) \
> @@ -144,7 +144,7 @@ do {
> \
> else \
> asm qual ("addb %1, "__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pao_T__)(val))); \
> + : "ri" ((pao_T__)(val))); \
> break; \
> case 2: \
> if (pao_ID__ == 1) \
> @@ -186,7 +186,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm qual (op "b "__percpu_arg(1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "m" (var)); \
> break; \
> case 2: \
> @@ -215,7 +215,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm(op "b "__percpu_arg(P1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "p" (&(var))); \
> break; \
> case 2: \
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 13:08 ` Vincenzo Frascino
0 siblings, 0 replies; 28+ messages in thread
From: Vincenzo Frascino @ 2019-07-11 13:08 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Andy Lutomirski, Thomas Gleixner, linux-arch, Linux ARM,
linux-mips, open list:KERNEL SELFTEST FRAMEWORK, Catalin Marinas,
Will Deacon, Russell King, Ralf Baechle, Paul Burton,
Daniel Lezcano, Mark Salyzyn, Peter Collingbourne, Shuah Khan,
Dmitry Safonov, Rasmus Villemoes, Huw Davies
Hi Arnd,
On 11/07/2019 13:28, Arnd Bergmann wrote:
> On Thu, Jul 11, 2019 at 2:14 PM Vincenzo Frascino
> <vincenzo.frascino@arm.com> wrote:
>>
>>
>> Could you please tell me which version of the compiler did you use?
>>
>> My building command is:
>>
>> # make mrproper && make CC=clang HOSTCC=clang i386_defconfig && make ARCH=i386
>> CC=clang HOSTCC=clang -j56
>>
>
> See below for the patch I am using locally to work around this.
> That patch is probably wrong, so I have not submitted it yet, but it
> gives you a clean build ;-)
>
> Arnd
>
Thank you, I will give it a go :-)
> 8<---
> Subject: [PATCH] x86: percpu: fix clang 32-bit build
>
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
>
> arch/x86/events/perf_event.h:824:21: error: invalid output size for
> constraint '=q'
> u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
> ^
> include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
> raw_cpu_read(pcp); \
> ^
> include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
> #define raw_cpu_read(pcp)
> __pcpu_size_call_return(raw_cpu_read_, pcp)
> ^
> include/linux/percpu-defs.h:322:23: note: expanded from macro
> '__pcpu_size_call_return'
> case 1: pscr_ret__ = stem##1(variable); break; \
> ^
> <scratch space>:357:1: note: expanded from here
> raw_cpu_read_1
> ^
> arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
> #define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
> ^
> arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
> : "=q" (pfo_ret__) \
> ^
>
> According to the commit that introduced the "q" constraint, this was
> needed to fix miscompilation, but it gives no further detail.
>
> Using the normal "=r" constraint seems to work so far.
>
> Fixes: 3c598766a2ba ("x86: fix percpu_{to,from}_op()")
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> index 2278797c769d..e791fbf4018f 100644
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -99,7 +99,7 @@ do { \
> case 1: \
> asm qual (op "b %1,"__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pto_T__)(val))); \
> + : "ri" ((pto_T__)(val))); \
> break; \
> case 2: \
> asm qual (op "w %1,"__percpu_arg(0) \
> @@ -144,7 +144,7 @@ do {
> \
> else \
> asm qual ("addb %1, "__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pao_T__)(val))); \
> + : "ri" ((pao_T__)(val))); \
> break; \
> case 2: \
> if (pao_ID__ == 1) \
> @@ -186,7 +186,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm qual (op "b "__percpu_arg(1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "m" (var)); \
> break; \
> case 2: \
> @@ -215,7 +215,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm(op "b "__percpu_arg(P1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "p" (&(var))); \
> break; \
> case 2: \
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
2019-07-11 12:28 ` Arnd Bergmann
(?)
(?)
@ 2019-07-11 17:14 ` Nick Desaulniers
-1 siblings, 0 replies; 28+ messages in thread
From: Nick Desaulniers @ 2019-07-11 17:14 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Vincenzo Frascino, Andy Lutomirski, Thomas Gleixner, linux-arch,
Linux ARM, linux-mips, open list:KERNEL SELFTEST FRAMEWORK,
Catalin Marinas, Will Deacon, Russell King, Ralf Baechle,
Paul Burton, Daniel Lezcano, Mark Salyzyn, Peter Collingbourne,
Shuah Khan, Dmitry Safonov, Rasmus Villemoes, Huw Davies,
Linux Kernel Mailing List, clang-built-linux
On Thu, Jul 11, 2019 at 5:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
Seems like starting in GCC 7, GCC may not like it either:
https://godbolt.org/z/UyBUfh
it simply warns then proceeds with code gen. Another difference may
come from when GCC vs Clang perform dead code elimination (DCE) vs
semantic analysis.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 17:14 ` Nick Desaulniers
0 siblings, 0 replies; 28+ messages in thread
From: Nick Desaulniers @ 2019-07-11 17:14 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-arch, Shuah Khan, Linux Kernel Mailing List,
open list:KERNEL SELFTEST FRAMEWORK, Dmitry Safonov,
Mark Salyzyn, Huw Davies, Catalin Marinas, Daniel Lezcano,
Will Deacon, linux-mips, Ralf Baechle, Russell King,
clang-built-linux, Paul Burton, Andy Lutomirski,
Rasmus Villemoes, Thomas Gleixner, Vincenzo Frascino,
Peter Collingbourne, Linux ARM
On Thu, Jul 11, 2019 at 5:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
Seems like starting in GCC 7, GCC may not like it either:
https://godbolt.org/z/UyBUfh
it simply warns then proceeds with code gen. Another difference may
come from when GCC vs Clang perform dead code elimination (DCE) vs
semantic analysis.
--
Thanks,
~Nick Desaulniers
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 17:14 ` Nick Desaulniers
0 siblings, 0 replies; 28+ messages in thread
From: Nick Desaulniers @ 2019-07-11 17:14 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Vincenzo Frascino, Andy Lutomirski, Thomas Gleixner, linux-arch,
Linux ARM, linux-mips, open list:KERNEL SELFTEST FRAMEWORK,
Catalin Marinas, Will Deacon, Russell King, Ralf Baechle,
Paul Burton, Daniel Lezcano, Mark Salyzyn, Peter Collingbourne,
Shuah Khan, Dmitry Safonov, Rasmus Villemoes, Huw Davies,
Linux Kernel Mailing List, clang-built-linux
On Thu, Jul 11, 2019 at 5:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
Seems like starting in GCC 7, GCC may not like it either:
https://godbolt.org/z/UyBUfh
it simply warns then proceeds with code gen. Another difference may
come from when GCC vs Clang perform dead code elimination (DCE) vs
semantic analysis.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 17:14 ` Nick Desaulniers
0 siblings, 0 replies; 28+ messages in thread
From: Nick Desaulniers @ 2019-07-11 17:14 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Vincenzo Frascino, Andy Lutomirski, Thomas Gleixner, linux-arch,
Linux ARM, linux-mips, open list:KERNEL SELFTEST FRAMEWORK,
Catalin Marinas, Will Deacon, Russell King, Ralf Baechle,
Paul Burton, Daniel Lezcano, Mark Salyzyn, Peter Collingbourne,
Shuah Khan, Dmitry Safonov, Rasmus Villemoes, Huw
On Thu, Jul 11, 2019 at 5:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
Seems like starting in GCC 7, GCC may not like it either:
https://godbolt.org/z/UyBUfh
it simply warns then proceeds with code gen. Another difference may
come from when GCC vs Clang perform dead code elimination (DCE) vs
semantic analysis.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
2019-07-11 17:14 ` Nick Desaulniers
(?)
(?)
@ 2019-07-11 20:55 ` Arnd Bergmann
-1 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2019-07-11 20:55 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Vincenzo Frascino, Andy Lutomirski, Thomas Gleixner, linux-arch,
Linux ARM, linux-mips, open list:KERNEL SELFTEST FRAMEWORK,
Catalin Marinas, Will Deacon, Russell King, Ralf Baechle,
Paul Burton, Daniel Lezcano, Mark Salyzyn, Peter Collingbourne,
Shuah Khan, Dmitry Safonov, Rasmus Villemoes, Huw Davies,
Linux Kernel Mailing List, clang-built-linux
On Thu, Jul 11, 2019 at 7:14 PM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@googlegroups.com> wrote:
>
> On Thu, Jul 11, 2019 at 5:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> > clang does not like an inline assembly with a "=q" contraint for
> > a 64-bit output:
>
> Seems like starting in GCC 7, GCC may not like it either:
> https://godbolt.org/z/UyBUfh
> it simply warns then proceeds with code gen. Another difference may
> come from when GCC vs Clang perform dead code elimination (DCE) vs
> semantic analysis.
Right, I also had the idea to work around it with a set of
__builtin_choos_expr()
instead of the switch()/case but did not complete that patch as the percpu
code is rather complex and this would touch lots of code.
Arnd
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 20:55 ` Arnd Bergmann
0 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2019-07-11 20:55 UTC (permalink / raw)
To: Nick Desaulniers
Cc: linux-arch, Shuah Khan, Linux Kernel Mailing List,
open list:KERNEL SELFTEST FRAMEWORK, Dmitry Safonov,
Mark Salyzyn, Huw Davies, Catalin Marinas, Daniel Lezcano,
Will Deacon, linux-mips, Ralf Baechle, Russell King,
clang-built-linux, Paul Burton, Andy Lutomirski,
Rasmus Villemoes, Thomas Gleixner, Vincenzo Frascino,
Peter Collingbourne, Linux ARM
On Thu, Jul 11, 2019 at 7:14 PM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@googlegroups.com> wrote:
>
> On Thu, Jul 11, 2019 at 5:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> > clang does not like an inline assembly with a "=q" contraint for
> > a 64-bit output:
>
> Seems like starting in GCC 7, GCC may not like it either:
> https://godbolt.org/z/UyBUfh
> it simply warns then proceeds with code gen. Another difference may
> come from when GCC vs Clang perform dead code elimination (DCE) vs
> semantic analysis.
Right, I also had the idea to work around it with a set of
__builtin_choos_expr()
instead of the switch()/case but did not complete that patch as the percpu
code is rather complex and this would touch lots of code.
Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 20:55 ` Arnd Bergmann
0 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2019-07-11 20:55 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Vincenzo Frascino, Andy Lutomirski, Thomas Gleixner, linux-arch,
Linux ARM, linux-mips, open list:KERNEL SELFTEST FRAMEWORK,
Catalin Marinas, Will Deacon, Russell King, Ralf Baechle,
Paul Burton, Daniel Lezcano, Mark Salyzyn, Peter Collingbourne,
Shuah Khan, Dmitry Safonov, Rasmus Villemoes, Huw Davies,
Linux Kernel Mailing List, clang-built-linux
On Thu, Jul 11, 2019 at 7:14 PM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@googlegroups.com> wrote:
>
> On Thu, Jul 11, 2019 at 5:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> > clang does not like an inline assembly with a "=q" contraint for
> > a 64-bit output:
>
> Seems like starting in GCC 7, GCC may not like it either:
> https://godbolt.org/z/UyBUfh
> it simply warns then proceeds with code gen. Another difference may
> come from when GCC vs Clang perform dead code elimination (DCE) vs
> semantic analysis.
Right, I also had the idea to work around it with a set of
__builtin_choos_expr()
instead of the switch()/case but did not complete that patch as the percpu
code is rather complex and this would touch lots of code.
Arnd
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-11 20:55 ` Arnd Bergmann
0 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2019-07-11 20:55 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Vincenzo Frascino, Andy Lutomirski, Thomas Gleixner, linux-arch,
Linux ARM, linux-mips, open list:KERNEL SELFTEST FRAMEWORK,
Catalin Marinas, Will Deacon, Russell King, Ralf Baechle,
Paul Burton, Daniel Lezcano, Mark Salyzyn, Peter Collingbourne,
Shuah Khan, Dmitry Safonov, Rasmus Villemoes, Huw
On Thu, Jul 11, 2019 at 7:14 PM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@googlegroups.com> wrote:
>
> On Thu, Jul 11, 2019 at 5:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> > clang does not like an inline assembly with a "=q" contraint for
> > a 64-bit output:
>
> Seems like starting in GCC 7, GCC may not like it either:
> https://godbolt.org/z/UyBUfh
> it simply warns then proceeds with code gen. Another difference may
> come from when GCC vs Clang perform dead code elimination (DCE) vs
> semantic analysis.
Right, I also had the idea to work around it with a set of
__builtin_choos_expr()
instead of the switch()/case but did not complete that patch as the percpu
code is rather complex and this would touch lots of code.
Arnd
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
2019-07-11 12:28 ` Arnd Bergmann
` (4 preceding siblings ...)
(?)
@ 2019-07-22 10:10 ` Thomas Gleixner
2019-07-22 10:38 ` Jan Beulich
-1 siblings, 1 reply; 28+ messages in thread
From: Thomas Gleixner @ 2019-07-22 10:10 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Vincenzo Frascino, Andy Lutomirski, Linux Kernel Mailing List,
clang-built-linux, Jan Beulich, x86
On Thu, 11 Jul 2019, Arnd Bergmann wrote:
Trimmed CC list and added Jan
> See below for the patch I am using locally to work around this.
> That patch is probably wrong, so I have not submitted it yet, but it
> gives you a clean build ;-)
>
> Arnd
> 8<---
> Subject: [PATCH] x86: percpu: fix clang 32-bit build
>
> clang does not like an inline assembly with a "=q" contraint for
> a 64-bit output:
>
> arch/x86/events/perf_event.h:824:21: error: invalid output size for
> constraint '=q'
> u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
> ^
> include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
> raw_cpu_read(pcp); \
> ^
> include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
> #define raw_cpu_read(pcp)
> __pcpu_size_call_return(raw_cpu_read_, pcp)
> ^
> include/linux/percpu-defs.h:322:23: note: expanded from macro
> '__pcpu_size_call_return'
> case 1: pscr_ret__ = stem##1(variable); break; \
> ^
> <scratch space>:357:1: note: expanded from here
> raw_cpu_read_1
> ^
> arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
> #define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
> ^
> arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
> : "=q" (pfo_ret__) \
> ^
>
> According to the commit that introduced the "q" constraint, this was
> needed to fix miscompilation, but it gives no further detail.
Jan, do you have any memory why you added those 'q' constraints? The
changelog of 3c598766a2ba is not really helpful.
Thanks,
tglx
> Using the normal "=r" constraint seems to work so far.
>
> Fixes: 3c598766a2ba ("x86: fix percpu_{to,from}_op()")
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> index 2278797c769d..e791fbf4018f 100644
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -99,7 +99,7 @@ do { \
> case 1: \
> asm qual (op "b %1,"__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pto_T__)(val))); \
> + : "ri" ((pto_T__)(val))); \
> break; \
> case 2: \
> asm qual (op "w %1,"__percpu_arg(0) \
> @@ -144,7 +144,7 @@ do {
> \
> else \
> asm qual ("addb %1, "__percpu_arg(0) \
> : "+m" (var) \
> - : "qi" ((pao_T__)(val))); \
> + : "ri" ((pao_T__)(val))); \
> break; \
> case 2: \
> if (pao_ID__ == 1) \
> @@ -186,7 +186,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm qual (op "b "__percpu_arg(1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "m" (var)); \
> break; \
> case 2: \
> @@ -215,7 +215,7 @@ do {
> \
> switch (sizeof(var)) { \
> case 1: \
> asm(op "b "__percpu_arg(P1)",%0" \
> - : "=q" (pfo_ret__) \
> + : "=r" (pfo_ret__) \
> : "p" (&(var))); \
> break; \
> case 2: \
>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
2019-07-22 10:10 ` Thomas Gleixner
@ 2019-07-22 10:38 ` Jan Beulich
2019-07-22 10:48 ` Arnd Bergmann
0 siblings, 1 reply; 28+ messages in thread
From: Jan Beulich @ 2019-07-22 10:38 UTC (permalink / raw)
To: Thomas Gleixner, Arnd Bergmann
Cc: Vincenzo Frascino, clang-built-linux, Andy Lutomirski, x86,
Linux Kernel Mailing List
On 22.07.2019 12:10, Thomas Gleixner wrote:
> On Thu, 11 Jul 2019, Arnd Bergmann wrote:
>
> Trimmed CC list and added Jan
>
>> See below for the patch I am using locally to work around this.
>> That patch is probably wrong, so I have not submitted it yet, but it
>> gives you a clean build ;-)
>>
>> Arnd
>> 8<---
>> Subject: [PATCH] x86: percpu: fix clang 32-bit build
>>
>> clang does not like an inline assembly with a "=q" contraint for
>> a 64-bit output:
>>
>> arch/x86/events/perf_event.h:824:21: error: invalid output size for
>> constraint '=q'
>> u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
>> ^
>> include/linux/percpu-defs.h:447:2: note: expanded from macro '__this_cpu_read'
>> raw_cpu_read(pcp); \
>> ^
>> include/linux/percpu-defs.h:421:28: note: expanded from macro 'raw_cpu_read'
>> #define raw_cpu_read(pcp)
>> __pcpu_size_call_return(raw_cpu_read_, pcp)
>> ^
>> include/linux/percpu-defs.h:322:23: note: expanded from macro
>> '__pcpu_size_call_return'
>> case 1: pscr_ret__ = stem##1(variable); break; \
>> ^
>> <scratch space>:357:1: note: expanded from here
>> raw_cpu_read_1
>> ^
>> arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
>> #define raw_cpu_read_1(pcp) percpu_from_op(, "mov", pcp)
>> ^
>> arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
>> : "=q" (pfo_ret__) \
>> ^
>>
>> According to the commit that introduced the "q" constraint, this was
>> needed to fix miscompilation, but it gives no further detail.
>
> Jan, do you have any memory why you added those 'q' constraints? The
> changelog of 3c598766a2ba is not really helpful.
"q" was used in that commit exclusively for byte sized operands, simply
because that _is_ the constraint to use in such cases. Using "r" is
wrong on 32-bit, as it would include inaccessible byte portions of %sp,
%bp, %si, and %di. This is how it's described in gcc sources / docs:
"Any register accessible as @code{@var{r}l}. In 32-bit mode, @code{a},
@code{b}, @code{c}, and @code{d}; in 64-bit mode, any integer register."
What I'm struggling with is why clang would evaluate that asm() in the
first place when a 64-bit field (perf_ctr_virt_mask) is being accessed.
Jan
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH] vsyscall: use __iter_div_u64_rem()
2019-07-22 10:38 ` Jan Beulich
@ 2019-07-22 10:48 ` Arnd Bergmann
0 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2019-07-22 10:48 UTC (permalink / raw)
To: Jan Beulich
Cc: Thomas Gleixner, Vincenzo Frascino, clang-built-linux,
Andy Lutomirski, x86, Linux Kernel Mailing List
On Mon, Jul 22, 2019 at 12:39 PM Jan Beulich <JBeulich@suse.com> wrote:
> On 22.07.2019 12:10, Thomas Gleixner wrote:
> > On Thu, 11 Jul 2019, Arnd Bergmann wrote:
> "q" was used in that commit exclusively for byte sized operands, simply
> because that _is_ the constraint to use in such cases. Using "r" is
> wrong on 32-bit, as it would include inaccessible byte portions of %sp,
> %bp, %si, and %di. This is how it's described in gcc sources / docs:
>
> "Any register accessible as @code{@var{r}l}. In 32-bit mode, @code{a},
> @code{b}, @code{c}, and @code{d}; in 64-bit mode, any integer register."
>
> What I'm struggling with is why clang would evaluate that asm() in the
> first place when a 64-bit field (perf_ctr_virt_mask) is being accessed.
clang does the optimization and warning checking in a different order,
in this case the argument type checks for the inline assembly is done
before it eliminates the dead code.
Arnd
^ permalink raw reply [flat|nested] 28+ messages in thread