[PATCH 7/7] x86/percpu: Clean up percpu_cmpxchg_op()

2020-05-17 Thread Brian Gerst
The core percpu macros already have a switch on the data size, so the switch
in the x86 code is redundant and produces more dead code.

Also use appropriate types for the width of the instructions.  This avoids
errors when compiling with Clang.

Signed-off-by: Brian Gerst 
---
 arch/x86/include/asm/percpu.h | 58 +++
 1 file changed, 18 insertions(+), 40 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 3c95ab3c99cd..b61d4fc5568e 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -236,39 +236,17 @@ do {  
\
  * cmpxchg has no such implied lock semantics as a result it is much
  * more efficient for cpu local operations.
  */
-#define percpu_cmpxchg_op(qual, var, oval, nval)   \
+#define percpu_cmpxchg_op(size, qual, _var, _oval, _nval)  \
 ({ \
-   typeof(var) pco_ret__;  \
-   typeof(var) pco_old__ = (oval); \
-   typeof(var) pco_new__ = (nval); \
-   switch (sizeof(var)) {  \
-   case 1: \
-   asm qual ("cmpxchgb %2, "__percpu_arg(1)\
-   : "=a" (pco_ret__), "+m" (var)  \
-   : "q" (pco_new__), "0" (pco_old__)  \
-   : "memory");\
-   break;  \
-   case 2: \
-   asm qual ("cmpxchgw %2, "__percpu_arg(1)\
-   : "=a" (pco_ret__), "+m" (var)  \
-   : "r" (pco_new__), "0" (pco_old__)  \
-   : "memory");\
-   break;  \
-   case 4: \
-   asm qual ("cmpxchgl %2, "__percpu_arg(1)\
-   : "=a" (pco_ret__), "+m" (var)  \
-   : "r" (pco_new__), "0" (pco_old__)  \
-   : "memory");\
-   break;  \
-   case 8: \
-   asm qual ("cmpxchgq %2, "__percpu_arg(1)\
-   : "=a" (pco_ret__), "+m" (var)  \
-   : "r" (pco_new__), "0" (pco_old__)  \
-   : "memory");\
-   break;  \
-   default: __bad_percpu_size();   \
-   }   \
-   pco_ret__;  \
+   __pcpu_type_##size pco_old__ = __pcpu_cast_##size(_oval);   \
+   __pcpu_type_##size pco_new__ = __pcpu_cast_##size(_nval);   \
+   asm qual (__pcpu_op2_##size("cmpxchg", "%[nval]",   \
+   __percpu_arg([var]))\
+ : [oval] "+a" (pco_old__),\
+   [var] "+m" (_var)   \
+ : [nval] __pcpu_reg_##size(, pco_new__)   \
+ : "memory");  \
+   (typeof(_var))(unsigned long) pco_old__;\
 })
 
 /*
@@ -336,16 +314,16 @@ do {  
\
 #define raw_cpu_add_return_1(pcp, val) percpu_add_return_op(1, , pcp, 
val)
 #define raw_cpu_add_return_2(pcp, val) percpu_add_return_op(2, , pcp, 
val)
 #define raw_cpu_add_return_4(pcp, val) percpu_add_return_op(4, , pcp, 
val)
-#define raw_cpu_cmpxchg_1(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, 
nval)
-#define raw_cpu_cmpxchg_2(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, 
nval)
-#define raw_cpu_cmpxchg_4(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, 
nval)
+#define raw_cpu_cmpxchg_1(pcp, oval, nval) percpu_cmpxchg_op(1, , pcp, 
oval, nval)
+#define raw_cpu_cmpxchg_2(pcp, oval, nval) percpu_cmpxchg_op(2, , pcp, 
oval, nval)
+#define raw_cpu_cmpxchg_4(pcp, oval, nval) percpu_cmpxchg_op(4, , pcp, 
oval, nval)
 
 #define this_cpu_add_return_1(pcp, val)percpu_add_return_op(1, 
volatile, pcp, val)
 #define 

[PATCH 6/7] x86/percpu: Clean up percpu_xchg_op()

2020-05-17 Thread Brian Gerst
The core percpu macros already have a switch on the data size, so the switch
in the x86 code is redundant and produces more dead code.

Also use appropriate types for the width of the instructions.  This avoids
errors when compiling with Clang.

Signed-off-by: Brian Gerst 
---
 arch/x86/include/asm/percpu.h | 61 +++
 1 file changed, 18 insertions(+), 43 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index ac8c391a190e..3c95ab3c99cd 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -215,46 +215,21 @@ do {  
\
  * expensive due to the implied lock prefix.  The processor cannot prefetch
  * cachelines if xchg is used.
  */
-#define percpu_xchg_op(qual, var, nval)
\
+#define percpu_xchg_op(size, qual, _var, _nval)
\
 ({ \
-   typeof(var) pxo_ret__;  \
-   typeof(var) pxo_new__ = (nval); \
-   switch (sizeof(var)) {  \
-   case 1: \
-   asm qual ("\n\tmov "__percpu_arg(1)",%%al"  \
-   "\n1:\tcmpxchgb %2, "__percpu_arg(1)\
-   "\n\tjnz 1b"\
-   : "=" (pxo_ret__), "+m" (var) \
-   : "q" (pxo_new__)   \
-   : "memory");\
-   break;  \
-   case 2: \
-   asm qual ("\n\tmov "__percpu_arg(1)",%%ax"  \
-   "\n1:\tcmpxchgw %2, "__percpu_arg(1)\
-   "\n\tjnz 1b"\
-   : "=" (pxo_ret__), "+m" (var) \
-   : "r" (pxo_new__)   \
-   : "memory");\
-   break;  \
-   case 4: \
-   asm qual ("\n\tmov "__percpu_arg(1)",%%eax" \
-   "\n1:\tcmpxchgl %2, "__percpu_arg(1)\
-   "\n\tjnz 1b"\
-   : "=" (pxo_ret__), "+m" (var) \
-   : "r" (pxo_new__)   \
-   : "memory");\
-   break;  \
-   case 8: \
-   asm qual ("\n\tmov "__percpu_arg(1)",%%rax" \
-   "\n1:\tcmpxchgq %2, "__percpu_arg(1)\
-   "\n\tjnz 1b"\
-   : "=" (pxo_ret__), "+m" (var) \
-   : "r" (pxo_new__)   \
-   : "memory");\
-   break;  \
-   default: __bad_percpu_size();   \
-   }   \
-   pxo_ret__;  \
+   __pcpu_type_##size pxo_old__;   \
+   __pcpu_type_##size pxo_new__ = __pcpu_cast_##size(_nval);   \
+   asm qual (__pcpu_op2_##size("mov", __percpu_arg([var]), \
+   "%[oval]")  \
+ "\n1:\t"  \
+ __pcpu_op2_##size("cmpxchg", "%[nval]",   \
+   __percpu_arg([var]))\
+ "\n\tjnz 1b"  \
+ : [oval] "=" (pxo_old__),   \
+   [var] "+m" (_var)   \
+ : [nval] __pcpu_reg_##size(, pxo_new__)   \
+ : "memory");  \
+   (typeof(_var))(unsigned long) pxo_old__;\
 })
 
 /*
@@ -354,9 +329,9 @@ do {
\
 #define this_cpu_or_1(pcp, val)percpu_to_op(1, volatile, "or", 

[PATCH 4/7] x86/percpu: Clean up percpu_add_op()

2020-05-17 Thread Brian Gerst
The core percpu macros already have a switch on the data size, so the switch
in the x86 code is redundant and produces more dead code.

Also use appropriate types for the width of the instructions.  This avoids
errors when compiling with Clang.

Signed-off-by: Brian Gerst 
---
 arch/x86/include/asm/percpu.h | 99 ---
 1 file changed, 22 insertions(+), 77 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 93f33202492d..21c5013a681a 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -130,64 +130,32 @@ do {  
\
: [val] __pcpu_reg_imm_##size(pto_val__));  \
 } while (0)
 
+#define percpu_unary_op(size, qual, op, _var)  \
+({ \
+   asm qual (__pcpu_op1_##size(op, __percpu_arg([var]))\
+   : [var] "+m" (_var));   \
+})
+
 /*
  * Generate a percpu add to memory instruction and optimize code
  * if one is added or subtracted.
  */
-#define percpu_add_op(qual, var, val)  \
+#define percpu_add_op(size, qual, var, val)\
 do {   \
-   typedef typeof(var) pao_T__;\
const int pao_ID__ = (__builtin_constant_p(val) &&  \
  ((val) == 1 || (val) == -1)) ?\
(int)(val) : 0; \
if (0) {\
-   pao_T__ pao_tmp__;  \
+   typeof(var) pao_tmp__;  \
pao_tmp__ = (val);  \
(void)pao_tmp__;\
}   \
-   switch (sizeof(var)) {  \
-   case 1: \
-   if (pao_ID__ == 1)  \
-   asm qual ("incb "__percpu_arg(0) : "+m" (var)); \
-   else if (pao_ID__ == -1)\
-   asm qual ("decb "__percpu_arg(0) : "+m" (var)); \
-   else\
-   asm qual ("addb %1, "__percpu_arg(0)\
-   : "+m" (var)\
-   : "qi" ((pao_T__)(val)));   \
-   break;  \
-   case 2: \
-   if (pao_ID__ == 1)  \
-   asm qual ("incw "__percpu_arg(0) : "+m" (var)); \
-   else if (pao_ID__ == -1)\
-   asm qual ("decw "__percpu_arg(0) : "+m" (var)); \
-   else\
-   asm qual ("addw %1, "__percpu_arg(0)\
-   : "+m" (var)\
-   : "ri" ((pao_T__)(val)));   \
-   break;  \
-   case 4: \
-   if (pao_ID__ == 1)  \
-   asm qual ("incl "__percpu_arg(0) : "+m" (var)); \
-   else if (pao_ID__ == -1)\
-   asm qual ("decl "__percpu_arg(0) : "+m" (var)); \
-   else\
-   asm qual ("addl %1, "__percpu_arg(0)\
-   : "+m" (var)\
-   : "ri" ((pao_T__)(val)));   \
-   break;  \
-   case 8: \
-   if (pao_ID__ == 1)  \
-   asm qual ("incq "__percpu_arg(0) : "+m" (var)); \
-   else if (pao_ID__ == -1)\
-   asm qual ("decq "__percpu_arg(0) : "+m" (var)); \
-   else\
-   asm qual ("addq %1, "__percpu_arg(0)\
-   : "+m" 

[PATCH 3/7] x86/percpu: Clean up percpu_from_op()

2020-05-17 Thread Brian Gerst
The core percpu macros already have a switch on the data size, so the switch
in the x86 code is redundant and produces more dead code.

Also use appropriate types for the width of the instructions.  This avoids
errors when compiling with Clang.

Signed-off-by: Brian Gerst 
---
 arch/x86/include/asm/percpu.h | 50 +++
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 233c7a78d1a6..93f33202492d 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -190,33 +190,13 @@ do {  
\
}   \
 } while (0)
 
-#define percpu_from_op(qual, op, var)  \
-({ \
-   typeof(var) pfo_ret__;  \
-   switch (sizeof(var)) {  \
-   case 1: \
-   asm qual (op "b "__percpu_arg(1)",%0"   \
-   : "=q" (pfo_ret__)  \
-   : "m" (var));   \
-   break;  \
-   case 2: \
-   asm qual (op "w "__percpu_arg(1)",%0"   \
-   : "=r" (pfo_ret__)  \
-   : "m" (var));   \
-   break;  \
-   case 4: \
-   asm qual (op "l "__percpu_arg(1)",%0"   \
-   : "=r" (pfo_ret__)  \
-   : "m" (var));   \
-   break;  \
-   case 8: \
-   asm qual (op "q "__percpu_arg(1)",%0"   \
-   : "=r" (pfo_ret__)  \
-   : "m" (var));   \
-   break;  \
-   default: __bad_percpu_size();   \
-   }   \
-   pfo_ret__;  \
+#define percpu_from_op(size, qual, op, _var)   \
+({ \
+   __pcpu_type_##size pfo_val__;   \
+   asm qual (__pcpu_op2_##size(op, __percpu_arg([var]), "%[val]")  \
+   : [val] __pcpu_reg_##size("=", pfo_val__)   \
+   : [var] "m" (_var));\
+   (typeof(_var))(unsigned long) pfo_val__;\
 })
 
 #define percpu_stable_op(op, var)  \
@@ -401,9 +381,9 @@ do {
\
  */
 #define this_cpu_read_stable(var)  percpu_stable_op("mov", var)
 
-#define raw_cpu_read_1(pcp)percpu_from_op(, "mov", pcp)
-#define raw_cpu_read_2(pcp)percpu_from_op(, "mov", pcp)
-#define raw_cpu_read_4(pcp)percpu_from_op(, "mov", pcp)
+#define raw_cpu_read_1(pcp)percpu_from_op(1, , "mov", pcp)
+#define raw_cpu_read_2(pcp)percpu_from_op(2, , "mov", pcp)
+#define raw_cpu_read_4(pcp)percpu_from_op(4, , "mov", pcp)
 
 #define raw_cpu_write_1(pcp, val)  percpu_to_op(1, , "mov", (pcp), val)
 #define raw_cpu_write_2(pcp, val)  percpu_to_op(2, , "mov", (pcp), val)
@@ -433,9 +413,9 @@ do {
\
 #define raw_cpu_xchg_2(pcp, val)   raw_percpu_xchg_op(pcp, val)
 #define raw_cpu_xchg_4(pcp, val)   raw_percpu_xchg_op(pcp, val)
 
-#define this_cpu_read_1(pcp)   percpu_from_op(volatile, "mov", pcp)
-#define this_cpu_read_2(pcp)   percpu_from_op(volatile, "mov", pcp)
-#define this_cpu_read_4(pcp)   percpu_from_op(volatile, "mov", pcp)
+#define this_cpu_read_1(pcp)   percpu_from_op(1, volatile, "mov", pcp)
+#define this_cpu_read_2(pcp)   percpu_from_op(2, volatile, "mov", pcp)
+#define this_cpu_read_4(pcp)   percpu_from_op(4, volatile, "mov", pcp)
 #define this_cpu_write_1(pcp, val) percpu_to_op(1, volatile, "mov", (pcp), 
val)
 #define this_cpu_write_2(pcp, val) percpu_to_op(2, volatile, "mov", (pcp), 
val)
 #define this_cpu_write_4(pcp, val) percpu_to_op(4, volatile, "mov", (pcp), 
val)
@@ -488,7 +468,7 @@ do {
\
  * 32 bit must fall back to generic operations.
  */
 #ifdef CONFIG_X86_64
-#define raw_cpu_read_8(pcp)percpu_from_op(, "mov", pcp)
+#define raw_cpu_read_8(pcp)percpu_from_op(8, , "mov", pcp)
 #define 

[PATCH 2/7] x86/percpu: Clean up percpu_to_op()

2020-05-17 Thread Brian Gerst
The core percpu macros already have a switch on the data size, so the switch
in the x86 code is redundant and produces more dead code.

Also use appropriate types for the width of the instructions.  This avoids
errors when compiling with Clang.

Signed-off-by: Brian Gerst 
---
 arch/x86/include/asm/percpu.h | 90 ++-
 1 file changed, 35 insertions(+), 55 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 89f918a3e99b..233c7a78d1a6 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -117,37 +117,17 @@ extern void __bad_percpu_size(void);
 #define __pcpu_reg_imm_4(x) "ri" (x)
 #define __pcpu_reg_imm_8(x) "re" (x)
 
-#define percpu_to_op(qual, op, var, val)   \
-do {   \
-   typedef typeof(var) pto_T__;\
-   if (0) {\
-   pto_T__ pto_tmp__;  \
-   pto_tmp__ = (val);  \
-   (void)pto_tmp__;\
-   }   \
-   switch (sizeof(var)) {  \
-   case 1: \
-   asm qual (op "b %1,"__percpu_arg(0) \
-   : "+m" (var)\
-   : "qi" ((pto_T__)(val)));   \
-   break;  \
-   case 2: \
-   asm qual (op "w %1,"__percpu_arg(0) \
-   : "+m" (var)\
-   : "ri" ((pto_T__)(val)));   \
-   break;  \
-   case 4: \
-   asm qual (op "l %1,"__percpu_arg(0) \
-   : "+m" (var)\
-   : "ri" ((pto_T__)(val)));   \
-   break;  \
-   case 8: \
-   asm qual (op "q %1,"__percpu_arg(0) \
-   : "+m" (var)\
-   : "re" ((pto_T__)(val)));   \
-   break;  \
-   default: __bad_percpu_size();   \
-   }   \
+#define percpu_to_op(size, qual, op, _var, _val)   \
+do {   \
+   __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val);\
+   if (0) {\
+   typeof(_var) pto_tmp__; \
+   pto_tmp__ = (_val); \
+   (void)pto_tmp__;\
+   }   \
+   asm qual(__pcpu_op2_##size(op, "%[val]", __percpu_arg([var]))   \
+   : [var] "+m" (_var) \
+   : [val] __pcpu_reg_imm_##size(pto_val__));  \
 } while (0)
 
 /*
@@ -425,18 +405,18 @@ do {  
\
 #define raw_cpu_read_2(pcp)percpu_from_op(, "mov", pcp)
 #define raw_cpu_read_4(pcp)percpu_from_op(, "mov", pcp)
 
-#define raw_cpu_write_1(pcp, val)  percpu_to_op(, "mov", (pcp), val)
-#define raw_cpu_write_2(pcp, val)  percpu_to_op(, "mov", (pcp), val)
-#define raw_cpu_write_4(pcp, val)  percpu_to_op(, "mov", (pcp), val)
+#define raw_cpu_write_1(pcp, val)  percpu_to_op(1, , "mov", (pcp), val)
+#define raw_cpu_write_2(pcp, val)  percpu_to_op(2, , "mov", (pcp), val)
+#define raw_cpu_write_4(pcp, val)  percpu_to_op(4, , "mov", (pcp), val)
 #define raw_cpu_add_1(pcp, val)percpu_add_op(, (pcp), val)
 #define raw_cpu_add_2(pcp, val)percpu_add_op(, (pcp), val)
 #define raw_cpu_add_4(pcp, val)percpu_add_op(, (pcp), val)
-#define raw_cpu_and_1(pcp, val)percpu_to_op(, "and", (pcp), 
val)
-#define raw_cpu_and_2(pcp, val)percpu_to_op(, "and", (pcp), 
val)
-#define raw_cpu_and_4(pcp, val)percpu_to_op(, "and", (pcp), 
val)
-#define raw_cpu_or_1(pcp, val) percpu_to_op(, "or", (pcp), val)
-#define raw_cpu_or_2(pcp, val) percpu_to_op(, "or", (pcp), val)
-#define raw_cpu_or_4(pcp, val) percpu_to_op(, "or", (pcp), val)
+#define raw_cpu_and_1(pcp, val)percpu_to_op(1, , "and", (pcp), 
val)
+#define raw_cpu_and_2(pcp, val)percpu_to_op(2, , "and", (pcp), 
val)
+#define raw_cpu_and_4(pcp, val)percpu_to_op(4, , "and", (pcp), 

[PATCH 5/7] x86/percpu: Clean up percpu_add_return_op()

2020-05-17 Thread Brian Gerst
The core percpu macros already have a switch on the data size, so the switch
in the x86 code is redundant and produces more dead code.

Also use appropriate types for the width of the instructions.  This avoids
errors when compiling with Clang.

Signed-off-by: Brian Gerst 
---
 arch/x86/include/asm/percpu.h | 51 +++
 1 file changed, 16 insertions(+), 35 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 21c5013a681a..ac8c391a190e 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -199,34 +199,15 @@ do {  
\
 /*
  * Add return operation
  */
-#define percpu_add_return_op(qual, var, val)   \
+#define percpu_add_return_op(size, qual, _var, _val)   \
 ({ \
-   typeof(var) paro_ret__ = val;   \
-   switch (sizeof(var)) {  \
-   case 1: \
-   asm qual ("xaddb %0, "__percpu_arg(1)   \
-   : "+q" (paro_ret__), "+m" (var) \
-   : : "memory");  \
-   break;  \
-   case 2: \
-   asm qual ("xaddw %0, "__percpu_arg(1)   \
-   : "+r" (paro_ret__), "+m" (var) \
-   : : "memory");  \
-   break;  \
-   case 4: \
-   asm qual ("xaddl %0, "__percpu_arg(1)   \
-   : "+r" (paro_ret__), "+m" (var) \
-   : : "memory");  \
-   break;  \
-   case 8: \
-   asm qual ("xaddq %0, "__percpu_arg(1)   \
-   : "+re" (paro_ret__), "+m" (var)\
-   : : "memory");  \
-   break;  \
-   default: __bad_percpu_size();   \
-   }   \
-   paro_ret__ += val;  \
-   paro_ret__; \
+   __pcpu_type_##size paro_tmp__ = __pcpu_cast_##size(_val);   \
+   asm qual (__pcpu_op2_##size("xadd", "%[tmp]",   \
+__percpu_arg([var]))   \
+ : [tmp] __pcpu_reg_##size("+", paro_tmp__),   \
+   [var] "+m" (_var)   \
+ : : "memory");\
+   (typeof(_var))(unsigned long) (paro_tmp__ + _val);  \
 })
 
 /*
@@ -377,16 +358,16 @@ do {  
\
 #define this_cpu_xchg_2(pcp, nval) percpu_xchg_op(volatile, pcp, nval)
 #define this_cpu_xchg_4(pcp, nval) percpu_xchg_op(volatile, pcp, nval)
 
-#define raw_cpu_add_return_1(pcp, val) percpu_add_return_op(, pcp, val)
-#define raw_cpu_add_return_2(pcp, val) percpu_add_return_op(, pcp, val)
-#define raw_cpu_add_return_4(pcp, val) percpu_add_return_op(, pcp, val)
+#define raw_cpu_add_return_1(pcp, val) percpu_add_return_op(1, , pcp, 
val)
+#define raw_cpu_add_return_2(pcp, val) percpu_add_return_op(2, , pcp, 
val)
+#define raw_cpu_add_return_4(pcp, val) percpu_add_return_op(4, , pcp, 
val)
 #define raw_cpu_cmpxchg_1(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, 
nval)
 #define raw_cpu_cmpxchg_2(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, 
nval)
 #define raw_cpu_cmpxchg_4(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, 
nval)
 
-#define this_cpu_add_return_1(pcp, val)
percpu_add_return_op(volatile, pcp, val)
-#define this_cpu_add_return_2(pcp, val)
percpu_add_return_op(volatile, pcp, val)
-#define this_cpu_add_return_4(pcp, val)
percpu_add_return_op(volatile, pcp, val)
+#define this_cpu_add_return_1(pcp, val)percpu_add_return_op(1, 
volatile, pcp, val)
+#define this_cpu_add_return_2(pcp, val)percpu_add_return_op(2, 
volatile, pcp, val)
+#define this_cpu_add_return_4(pcp, val)percpu_add_return_op(4, 
volatile, pcp, 

[PATCH 0/7] x86: Clean up percpu operations

2020-05-17 Thread Brian Gerst
The core percpu operations already have a switch on the width of the
data type, which resulted in an extra amount of dead code being
generated with the x86 operations having another switch.  This patch set
rewrites the x86 ops to remove the switch.  Additional cleanups are to
use named assembly operands, and to cast variables to the width used in
the assembly to make Clang happy.

Brian Gerst (7):
  x86/percpu: Introduce size abstraction macros
  x86/percpu: Clean up percpu_to_op()
  x86/percpu: Clean up percpu_from_op()
  x86/percpu: Clean up percpu_add_op()
  x86/percpu: Clean up percpu_add_return_op()
  x86/percpu: Clean up percpu_xchg_op()
  x86/percpu: Clean up percpu_cmpxchg_op()

 arch/x86/include/asm/percpu.h | 447 --
 1 file changed, 158 insertions(+), 289 deletions(-)

-- 
2.25.4



[PATCH 1/7] x86/percpu: Introduce size abstraction macros

2020-05-17 Thread Brian Gerst
In preparation for cleaning up the percpu operations, define macros for
abstraction based on the width of the operation.

Signed-off-by: Brian Gerst 
---
 arch/x86/include/asm/percpu.h | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 2278797c769d..89f918a3e99b 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -87,6 +87,36 @@
  * don't give an lvalue though). */
 extern void __bad_percpu_size(void);
 
+#define __pcpu_type_1 u8
+#define __pcpu_type_2 u16
+#define __pcpu_type_4 u32
+#define __pcpu_type_8 u64
+
+#define __pcpu_cast_1(val) ((u8)((unsigned long) val))
+#define __pcpu_cast_2(val) ((u16)((unsigned long) val))
+#define __pcpu_cast_4(val) ((u32)((unsigned long) val))
+#define __pcpu_cast_8(val) ((u64)(val))
+
+#define __pcpu_op1_1(op, dst) op "b " dst
+#define __pcpu_op1_2(op, dst) op "w " dst
+#define __pcpu_op1_4(op, dst) op "l " dst
+#define __pcpu_op1_8(op, dst) op "q " dst
+
+#define __pcpu_op2_1(op, src, dst) op "b " src ", " dst
+#define __pcpu_op2_2(op, src, dst) op "w " src ", " dst
+#define __pcpu_op2_4(op, src, dst) op "l " src ", " dst
+#define __pcpu_op2_8(op, src, dst) op "q " src ", " dst
+
+#define __pcpu_reg_1(out, x) out "q" (x)
+#define __pcpu_reg_2(out, x) out "r" (x)
+#define __pcpu_reg_4(out, x) out "r" (x)
+#define __pcpu_reg_8(out, x) out "r" (x)
+
+#define __pcpu_reg_imm_1(x) "qi" (x)
+#define __pcpu_reg_imm_2(x) "ri" (x)
+#define __pcpu_reg_imm_4(x) "ri" (x)
+#define __pcpu_reg_imm_8(x) "re" (x)
+
 #define percpu_to_op(qual, op, var, val)   \
 do {   \
typedef typeof(var) pto_T__;\
-- 
2.25.4



Re: [PATCH v2 2/2] ARM: dts: kirkwood: Add Check Point L-50 board

2020-05-17 Thread Gregory CLEMENT
Hi Pawel Dembicki,

> This patch adds dts for the Check Point L-50 from 600/1100 series
> routers.
>
> Specification:
> -CPU: Marvell Kirkwood 88F6821 1200MHz
> -RAM: 512MB
> -Flash: NAND 512MB
> -WiFi: mPCIe card based on Atheros AR9287 b/g/n
> -WAN: 1 Gigabit Port (Marvell 88E1116R PHY)
> -LAN: 9 Gigabit Ports (2x Marvell 88E6171(5+3))
> -USB: 2x USB2.0
> -Express card slot
> -SD card slot
> -Serial console: RJ-45 115200 8n1
> -Unsupported DSL
>
> Signed-off-by: Pawel Dembicki 


Applied on mvebu/dt. I think the first patch should be applied by the
device tree maintainers.

Thanks,

Gregory


> ---
> Changes in v2:
> - none
>
>  arch/arm/boot/dts/Makefile  |   1 +
>  arch/arm/boot/dts/kirkwood-l-50.dts | 441 
>  2 files changed, 442 insertions(+)
>  create mode 100644 arch/arm/boot/dts/kirkwood-l-50.dts
>
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index e8dd99201397..eba030b3ba69 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -279,6 +279,7 @@ dtb-$(CONFIG_MACH_KIRKWOOD) += \
>   kirkwood-iomega_ix2_200.dtb \
>   kirkwood-is2.dtb \
>   kirkwood-km_kirkwood.dtb \
> + kirkwood-l-50.dtb \
>   kirkwood-laplug.dtb \
>   kirkwood-linkstation-lsqvl.dtb \
>   kirkwood-linkstation-lsvl.dtb \
> diff --git a/arch/arm/boot/dts/kirkwood-l-50.dts 
> b/arch/arm/boot/dts/kirkwood-l-50.dts
> new file mode 100644
> index ..ab3a90287260
> --- /dev/null
> +++ b/arch/arm/boot/dts/kirkwood-l-50.dts
> @@ -0,0 +1,441 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Check Point L-50 Board Description
> + * Copyright 2020 Pawel Dembicki 
> + */
> +
> +/dts-v1/;
> +
> +#include "kirkwood.dtsi"
> +#include "kirkwood-6281.dtsi"
> +
> +/ {
> + model = "Check Point L-50";
> + compatible = "checkpoint,l-50", "marvell,kirkwood-88f6281", 
> "marvell,kirkwood";
> +
> + memory {
> + device_type = "memory";
> + reg = <0x 0x2000>;
> + };
> +
> + chosen {
> + bootargs = "console=ttyS0,115200n8";
> + stdout-path = 
> + };
> +
> + ocp@f100 {
> + pinctrl: pin-controller@1 {
> + pinctrl-0 = <_led38 _sysrst _button29>;
> + pinctrl-names = "default";
> +
> + pmx_sysrst: pmx-sysrst {
> + marvell,pins = "mpp6";
> + marvell,function = "sysrst";
> + };
> +
> + pmx_button29: pmx_button29 {
> + marvell,pins = "mpp29";
> + marvell,function = "gpio";
> + };
> +
> + pmx_led38: pmx_led38 {
> + marvell,pins = "mpp38";
> + marvell,function = "gpio";
> + };
> +
> + pmx_sdio_cd: pmx-sdio-cd {
> + marvell,pins = "mpp46";
> + marvell,function = "gpio";
> + };
> + };
> +
> + serial@12000 {
> + status = "okay";
> + };
> +
> + mvsdio@9 {
> + status = "okay";
> + cd-gpios = < 14 9>;
> + };
> +
> + i2c@11000 {
> + status = "okay";
> + clock-frequency = <40>;
> +
> + gpio2: gpio-expander@20{
> + #gpio-cells = <2>;
> + #interrupt-cells = <2>;
> + compatible = "semtech,sx1505q";
> + reg = <0x20>;
> +
> + gpio-controller;
> + };
> +
> + /* Three GPIOs from 0x21 exp. are undescribed in dts:
> +  * 1: DSL module reset (active low)
> +  * 5: mPCIE reset (active low)
> +  * 6: Express card reset (active low)
> +  */
> + gpio3: gpio-expander@21{
> + #gpio-cells = <2>;
> + #interrupt-cells = <2>;
> + compatible = "semtech,sx1505q";
> + reg = <0x21>;
> +
> + gpio-controller;
> + };
> +
> + rtc@30 {
> + compatible = "s35390a";
> + reg = <0x30>;
> + };
> + };
> + };
> +
> + leds {
> + compatible = "gpio-leds";
> +
> + status_green {
> + label = "l-50:green:status";
> + gpios = < 6 GPIO_ACTIVE_LOW>;
> + };
> +
> + status_orange {
> + label = "l-50:orange:status";
> + 

Re: [PATCH for-5.7 0/2] fortify async punt preparation

2020-05-17 Thread Jens Axboe
On 5/17/20 5:02 AM, Pavel Begunkov wrote:
> [2] fixes FORCE_ASYNC. I don't want to go through every bit, so
> not sure whether this is an actual issue with [1], but it's just
> safer this way. Please, consider it for-5.7

LGTM, applied.

-- 
Jens Axboe



Re: INFO: trying to register non-static key in io_cqring_ev_posted (3)

2020-05-17 Thread Jens Axboe
On 5/16/20 10:30 PM, syzbot wrote:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:ac935d22 Add linux-next specific files for 20200415
> git tree:   linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=12deaa5e10
> kernel config:  https://syzkaller.appspot.com/x/.config?x=bc498783097e9019
> dashboard link: https://syzkaller.appspot.com/bug?extid=8c91f5d054e998721c57
> compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=11d54c0210
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17461e0610
> 
> The bug was bisected to:
> 
> commit b41e98524e424d104aa7851d54fd65820759875a
> Author: Jens Axboe 
> Date:   Mon Feb 17 16:52:41 2020 +
> 
> io_uring: add per-task callback handler
> 
> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1488dc3c10
> final crash:https://syzkaller.appspot.com/x/report.txt?x=1688dc3c10
> console output: https://syzkaller.appspot.com/x/log.txt?x=1288dc3c10
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+8c91f5d054e998721...@syzkaller.appspotmail.com
> Fixes: b41e98524e42 ("io_uring: add per-task callback handler")
> 
> RSP: 002b:7fffb1fb9aa8 EFLAGS: 0246 ORIG_RAX: 01a9
> RAX: ffda RBX:  RCX: 00441319
> RDX: 0001 RSI: 2140 RDI: 047b
> RBP: 00010475 R08: 0001 R09: 004002c8
> R10:  R11: 0246 R12: 00402260
> R13: 004022f0 R14:  R15: 
> INFO: trying to register non-static key.
> the code is fine but needs lockdep annotation.
> turning off the locking correctness validator.
> CPU: 1 PID: 7090 Comm: syz-executor222 Not tainted 
> 5.7.0-rc1-next-20200415-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> Google 01/01/2011
> Call Trace:
>  __dump_stack lib/dump_stack.c:77 [inline]
>  dump_stack+0x188/0x20d lib/dump_stack.c:118
>  assign_lock_key kernel/locking/lockdep.c:913 [inline]
>  register_lock_class+0x1664/0x1760 kernel/locking/lockdep.c:1225
>  __lock_acquire+0x104/0x4c50 kernel/locking/lockdep.c:4234
>  lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4934
>  __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
>  _raw_spin_lock_irqsave+0x8c/0xbf kernel/locking/spinlock.c:159
>  __wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:122
>  io_cqring_ev_posted+0xa5/0x1e0 fs/io_uring.c:1160
>  io_poll_remove_all fs/io_uring.c:4357 [inline]
>  io_ring_ctx_wait_and_kill+0x2bc/0x5a0 fs/io_uring.c:7305
>  io_uring_create fs/io_uring.c:7843 [inline]
>  io_uring_setup+0x115e/0x22b0 fs/io_uring.c:7870
>  do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
>  entry_SYSCALL_64_after_hwframe+0x49/0xb3

I think this will likely fix it.


diff --git a/fs/io_uring.c b/fs/io_uring.c
index 70ae7e840c85..79c90eb28c0d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -924,6 +924,7 @@ static struct io_ring_ctx *io_ring_ctx_alloc(struct 
io_uring_params *p)
goto err;
 
ctx->flags = p->flags;
+   init_waitqueue_head(>sqo_wait);
init_waitqueue_head(>cq_wait);
INIT_LIST_HEAD(>cq_overflow_list);
init_completion(>completions[0]);
@@ -6837,7 +6838,6 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
 {
int ret;
 
-   init_waitqueue_head(>sqo_wait);
mmgrab(current->mm);
ctx->sqo_mm = current->mm;
 

-- 
Jens Axboe



Re: [PATCH v2] ia64: enable HAVE_COPY_THREAD_TLS, switch to kernel_clone_args

2020-05-17 Thread Christian Brauner
On Sun, May 17, 2020 at 05:16:35PM +0200, Christian Brauner wrote:
> This is part of a larger series that aims at getting rid of the
> copy_thread()/copy_thread_tls() split that makes the process creation
> codepaths in the kernel more convoluted and error-prone than they need
> to be.
> I'm converting all the remaining arches that haven't yet switched and
> am collecting individual acks. Once I have them, I'll send the whole series
> removing the copy_thread()/copy_thread_tls() split, the
> HAVE_COPY_THREAD_TLS define and the legacy do_fork() helper. The only
> kernel-wide process creation entry point for anything not going directly
> through the syscall path will then be based on struct kernel_clone_args.
> No more danger of weird process creation abi quirks between architectures
> hopefully, and easier to maintain overall.
> It also unblocks implementing clone3() on architectures not support
> copy_thread_tls(). Any architecture that wants to implement clone3()
> will need to select HAVE_COPY_THREAD_TLS and thus need to implement
> copy_thread_tls(). So both goals are connected but independently
> beneficial.
> 
> HAVE_COPY_THREAD_TLS means that a given architecture supports
> CLONE_SETTLS and not setting it should usually mean that the
> architectures doesn't implement it but that's not how things are. In
> fact all architectures support CLONE_TLS it's just that they don't
> follow the calling convention that HAVE_COPY_THREAD_TLS implies. That
> means all architectures can be switched over to select
> HAVE_COPY_THREAD_TLS. Once that is done we can remove that macro (yay,
> less code), the unnecessary do_fork() export in kernel/fork.c, and also
> rename copy_thread_tls() back to copy_thread(). At this point
> copy_thread() becomes the main architecture specific part of process
> creation but it will be the same layout and calling convention for all
> architectures. (Once that is done we can probably cleanup each
> copy_thread() function even more but that's for the future.)
> 
> Since ia64 does support CLONE_SETTLS there's no reason to not select
> HAVE_COPY_THREAD_TLS. This brings us one step closer to getting rid of
> the copy_thread()/copy_thread_tls() split we still have and ultimately
> the HAVE_COPY_THREAD_TLS define in general. A lot of architectures have
> already converted and ia64 is one of the few hat haven't yet. This also
> unblocks implementing the clone3() syscall on ia64. Once that is done we
> can get of another ARCH_WANTS_* macro.
> 
> Once Any architecture that supports HAVE_COPY_THREAD_TLS cannot call the
> do_fork() helper anymore. This is fine and intended since it should be
> removed in favor of the new, cleaner _do_fork() calling convention based
> on struct kernel_clone_args. In fact, most architectures have already
> switched.  With this patch, ia64 joins the other arches which can't use
> the fork(), vfork(), clone(), clone3() syscalls directly and who follow
> the new process creation calling convention that is based on struct
> kernel_clone_args which we introduced a while back. This means less
> custom assembly in the architectures entry path to set up the registers
> before calling into the process creation helper and it is easier to to
> support new features without having to adapt calling conventions. It
> also unifies all process creation paths between fork(), vfork(),
> clone(), and clone3(). (We can't fix the ABI nightmare that legacy
> clone() is but we can prevent stuff like this happening in the future.)
> 
> Well, the first version I nothing to test this with. I don't know how to
> reasonably explain what happened but thanks to Adrian I'm now sitting at
> home next to a HP Integrity RX2600. I've done some testing and my initial
> version had a bug that became obvious when I took a closer look. The switch
> stack logic assumes that ar.pfs is stored in r16 and I changed that to r2.
> So with that fixed the following test program runs without any problems:
> 
>  #ifndef _GNU_SOURCE
>  #define _GNU_SOURCE 1
>  #endif
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> 
>  #define IA64_SYSCALL_OFFSET 1024
>  #ifndef __NR_clone
>  #define __NR_clone (104 + IA64_SYSCALL_OFFSET)
>  #endif
> 
>  #ifndef __NR_clone2
>  #define __NR_clone2 (189 + IA64_SYSCALL_OFFSET)
>  #endif
> 
>  /*
>   * sys_clone(unsigned long flags,
>   *unsigned long stack,
>   *int *parent_tidptr,
>   *int *child_tidptr,
>   *unsigned long tls)
>   */
>  static pid_t ia64_raw_clone(void)
>  {
>   return syscall(__NR_clone, SIGCHLD, 0, NULL, NULL, 0);
>  }
> 
>  /*
>   * sys_clone2(unsigned long flags,
>   * unsigned long stack,
>   * unsigned long stack_size,
>   * int *parent_tidptr,
>   * int *child_tidptr,
>   * unsigned long tls)
>   */
>  static pid_t ia64_raw_clone2(void)
>  {
>   

[PATCH v2] ia64: enable HAVE_COPY_THREAD_TLS, switch to kernel_clone_args

2020-05-17 Thread Christian Brauner
This is part of a larger series that aims at getting rid of the
copy_thread()/copy_thread_tls() split that makes the process creation
codepaths in the kernel more convoluted and error-prone than they need
to be.
I'm converting all the remaining arches that haven't yet switched and
am collecting individual acks. Once I have them, I'll send the whole series
removing the copy_thread()/copy_thread_tls() split, the
HAVE_COPY_THREAD_TLS define and the legacy do_fork() helper. The only
kernel-wide process creation entry point for anything not going directly
through the syscall path will then be based on struct kernel_clone_args.
No more danger of weird process creation abi quirks between architectures
hopefully, and easier to maintain overall.
It also unblocks implementing clone3() on architectures not support
copy_thread_tls(). Any architecture that wants to implement clone3()
will need to select HAVE_COPY_THREAD_TLS and thus need to implement
copy_thread_tls(). So both goals are connected but independently
beneficial.

HAVE_COPY_THREAD_TLS means that a given architecture supports
CLONE_SETTLS and not setting it should usually mean that the
architectures doesn't implement it but that's not how things are. In
fact all architectures support CLONE_TLS it's just that they don't
follow the calling convention that HAVE_COPY_THREAD_TLS implies. That
means all architectures can be switched over to select
HAVE_COPY_THREAD_TLS. Once that is done we can remove that macro (yay,
less code), the unnecessary do_fork() export in kernel/fork.c, and also
rename copy_thread_tls() back to copy_thread(). At this point
copy_thread() becomes the main architecture specific part of process
creation but it will be the same layout and calling convention for all
architectures. (Once that is done we can probably cleanup each
copy_thread() function even more but that's for the future.)

Since ia64 does support CLONE_SETTLS there's no reason to not select
HAVE_COPY_THREAD_TLS. This brings us one step closer to getting rid of
the copy_thread()/copy_thread_tls() split we still have and ultimately
the HAVE_COPY_THREAD_TLS define in general. A lot of architectures have
already converted and ia64 is one of the few hat haven't yet. This also
unblocks implementing the clone3() syscall on ia64. Once that is done we
can get of another ARCH_WANTS_* macro.

Once Any architecture that supports HAVE_COPY_THREAD_TLS cannot call the
do_fork() helper anymore. This is fine and intended since it should be
removed in favor of the new, cleaner _do_fork() calling convention based
on struct kernel_clone_args. In fact, most architectures have already
switched.  With this patch, ia64 joins the other arches which can't use
the fork(), vfork(), clone(), clone3() syscalls directly and who follow
the new process creation calling convention that is based on struct
kernel_clone_args which we introduced a while back. This means less
custom assembly in the architectures entry path to set up the registers
before calling into the process creation helper and it is easier to to
support new features without having to adapt calling conventions. It
also unifies all process creation paths between fork(), vfork(),
clone(), and clone3(). (We can't fix the ABI nightmare that legacy
clone() is but we can prevent stuff like this happening in the future.)

Well, the first version I nothing to test this with. I don't know how to
reasonably explain what happened but thanks to Adrian I'm now sitting at
home next to a HP Integrity RX2600. I've done some testing and my initial
version had a bug that became obvious when I took a closer look. The switch
stack logic assumes that ar.pfs is stored in r16 and I changed that to r2.
So with that fixed the following test program runs without any problems:

 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE 1
 #endif
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 

 #define IA64_SYSCALL_OFFSET 1024
 #ifndef __NR_clone
 #define __NR_clone (104 + IA64_SYSCALL_OFFSET)
 #endif

 #ifndef __NR_clone2
 #define __NR_clone2 (189 + IA64_SYSCALL_OFFSET)
 #endif

 /*
  * sys_clone(unsigned long flags,
  *  unsigned long stack,
  *  int *parent_tidptr,
  *  int *child_tidptr,
  *  unsigned long tls)
  */
 static pid_t ia64_raw_clone(void)
 {
return syscall(__NR_clone, SIGCHLD, 0, NULL, NULL, 0);
 }

 /*
  * sys_clone2(unsigned long flags,
  *   unsigned long stack,
  *   unsigned long stack_size,
  *   int *parent_tidptr,
  *   int *child_tidptr,
  *   unsigned long tls)
  */
 static pid_t ia64_raw_clone2(void)
 {
return syscall(__NR_clone2, SIGCHLD, 0, 0, NULL, NULL, 0);
 }

 /*
  * Let's use the "standard stack limit" (i.e. glibc thread size default) for
  * stack sizes: 8MB.
  */
 #define __STACK_SIZE (8 * 1024 * 1024)

 /* This is not always defined in sched.h. */
 extern int 

Re: [PATCH v2 4/7] serial: 8250: Handle implementations not having TEMT interrupt using em485

2020-05-17 Thread Heiko Stübner
Hi Giulio,

Am Donnerstag, 26. März 2020, 03:02:39 CEST schrieb Giulio Benetti:
> Il 26/03/2020 01:05, Heiko Stübner ha scritto:
> > Am Donnerstag, 26. März 2020, 00:47:38 CET schrieb Giulio Benetti:
> >> very cleaner way to handle TEMT as a capability!
> >> And I've found one thing...
> >>
> >> Il 26/03/2020 00:14, Heiko Stuebner ha scritto:
> >>> From: Giulio Benetti 
> >>>
> >>> Some 8250 ports have a TEMT interrupt but it's not a part of the 8250
> >>> standard, instead only available on some implementations.
> >>>
> >>> The current em485 implementation does not work on ports without it.
> >>> The only chance to make it work is to loop-read on LSR register.
> >>>
> >>> So add UART_CAP_TEMT to mark 8250 uarts having this interrupt,
> >>> update all current em485 users with that capability and make
> >>> the stop_tx function loop-read on uarts not having it.
> >>>
> >>> Signed-off-by: Giulio Benetti 
> >>> [moved to use added UART_CAP_TEMT, use readx_poll_timeout]
> >>> Signed-off-by: Heiko Stuebner 
> >>> ---
> >>>drivers/tty/serial/8250/8250.h|  1 +
> >>>drivers/tty/serial/8250/8250_bcm2835aux.c |  2 +-
> >>>drivers/tty/serial/8250/8250_of.c |  2 ++
> >>>drivers/tty/serial/8250/8250_omap.c   |  2 +-
> >>>drivers/tty/serial/8250/8250_port.c   | 25 +++
> >>>5 files changed, 26 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/drivers/tty/serial/8250/8250.h 
> >>> b/drivers/tty/serial/8250/8250.h
> >>> index 52bb21205bb6..770eb00db497 100644
> >>> --- a/drivers/tty/serial/8250/8250.h
> >>> +++ b/drivers/tty/serial/8250/8250.h
> >>> @@ -82,6 +82,7 @@ struct serial8250_config {
> >>>#define UART_CAP_MINI  (1 << 17)   /* Mini UART on BCM283X family 
> >>> lacks:
> >>>* STOP PARITY EPAR SPAR WLEN5 
> >>> WLEN6
> >>>*/
> >>> +#define UART_CAP_TEMT(1 << 18)   /* UART has TEMT interrupt */
> >>>
> >>>#define UART_BUG_QUOT  (1 << 0)/* UART has buggy quot LSB */
> >>>#define UART_BUG_TXEN  (1 << 1)/* UART has buggy TX IIR status 
> >>> */
> >>> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c 
> >>> b/drivers/tty/serial/8250/8250_bcm2835aux.c
> >>> index 12d03e678295..3881242424ca 100644
> >>> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
> >>> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
> >>> @@ -91,7 +91,7 @@ static int bcm2835aux_serial_probe(struct 
> >>> platform_device *pdev)
> >>>   return -ENOMEM;
> >>>
> >>>   /* initialize data */
> >>> - up.capabilities = UART_CAP_FIFO | UART_CAP_MINI;
> >>> + up.capabilities = UART_CAP_FIFO | UART_CAP_MINI | UART_CAP_TEMT;
> >>>   up.port.dev = >dev;
> >>>   up.port.regshift = 2;
> >>>   up.port.type = PORT_16550;
> >>> diff --git a/drivers/tty/serial/8250/8250_of.c 
> >>> b/drivers/tty/serial/8250/8250_of.c
> >>> index 65e9045dafe6..841f6fcb2878 100644
> >>> --- a/drivers/tty/serial/8250/8250_of.c
> >>> +++ b/drivers/tty/serial/8250/8250_of.c
> >>> @@ -225,6 +225,8 @@ static int of_platform_serial_probe(struct 
> >>> platform_device *ofdev)
> >>>   _backoff_time_ms) != 0)
> >>>   port8250.overrun_backoff_time_ms = 0;
> >>>
> >>> + port8250.capabilities |= UART_CAP_TEMT;
> >>> +
> >>
> >> Shouldn't this be NOT UART_CAP_TEMT set by default? On all other
> >> vendor specific files you enable it, I think here you shouldn't enable
> >> it too by default. Right?
> > 
> > 8250_of does use the em485 emulation - see of_platform_serial_setup()
> > So I did go by the lazy assumption that any 8250 driver using rs485
> > before my series always used the interrupt driver code path, so
> > implicitly required to have the TEMT interrupt.
> > 
> > Of course, you're right that with the 8250_of maybe not all variants
> > actually do have this interrupt, so falling back to the polling here might
> > be safer.
> 
> Probably here it's worth introducing a dt boolean property like
> "temt-capability", then you set or not UART_CAP_TEMT according to its 
> presence in dts. This way all cases are covered and we can act 
> completely through dts files.
> 
> What about that?

Sorry that this was sitting around for over a month.

I think there are two problems with this:

(1) this would break backwards compatibility ... right now the whole code
just assumes that everyone does support the TEMT interrupt, so adding
a property to keep it working would break old DTs, which is something that
should not happen ... I guess one option would be to use the inverse
no-temt-interrupt

(2) uarts handled by 8250_of are still identified by their compatible
though and there is no generic 8250-of compatible, so the
presence / absence of the temt capability should actually just be
bound to the relevant compatible.


So my "gut feeling" is to just keep the current way
(was expecting temt-capability 

Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-17 Thread Tycho Andersen
On Sun, May 17, 2020 at 08:46:03AM -0600, Tycho Andersen wrote:
> On Sun, May 17, 2020 at 04:33:11PM +0200, Christian Brauner wrote:
> > struct seccomp_notif2 {
> > __u32 notif_size;
> > __u64 id;
> > __u32 pid;
> > __u32 flags;
> > struct seccomp_data data;
> > __u32 data_size;
> > };
> 
> I guess you need to put data_size before data, otherwise old userspace
> with a smaller struct seccomp_data will look in the wrong place.
> 
> But yes, that'll work if you put two sizes in, which is probably
> reasonable since we're talking about two structs.

Well, no, it doesn't either. Suppose we add a new field first to
struct seccomp_notif2:

struct seccomp_notif2 {
__u32 notif_size;
__u64 id;
__u32 pid;
__u32 flags;
struct seccomp_data data;
__u32 data_size;
__u32 new_field;
};

And next we add a new field to struct secccomp_data. When a userspace
compiled with just the new seccomp_notif2 field does:

seccomp_notif2.new_field = ...;

the compiler will put it in the wrong place for the kernel with the
new seccomp_data field too.

Sort of feels like we should do:

struct seccomp_notif2 {
struct seccomp_notif *notif;
struct seccomp_data *data;
};

?

Tycho


Re: [PATCH 0/3] sparc: port to copy_thread_tls() and struct kernel_clone_args

2020-05-17 Thread Christian Brauner
On Tue, May 12, 2020 at 01:06:33PM -0700, David Miller wrote:
> From: Christian Brauner 
> Date: Tue, 12 May 2020 19:15:24 +0200
> 
> > I've tested this series with qemu-system-sparc64 and a Debian Sid image
> > and it comes up no problem (Here's a little recording
> > https://asciinema.org/a/329510 ).
> 
> Can you show how you put this environment together and also what
> compilation tools you used?  Looks great.

Sorry for the delay. That mail somehow got lost in my inbox.

So in general, I used qemu-system-sparc64 which is available in Universe
with either Debian or Ubuntu and that's what I've been using as host
distro. So you need a 

deb http://us.archive.ubuntu.com/ubuntu/  universe
deb-src http://us.archive.ubuntu.com/ubuntu/  universe
deb http://us.archive.ubuntu.com/ubuntu/ -updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ -updates universe

int /etc/apt/sources.list

So after this, you should be able to install

apt install qemu-system-sparc

Now we need an image and believe it or not there's a guy who lives in
Berlin too who builds Debian images for all crazy architectures. You can
download them from:

https://cdimage.debian.org/cdimage/ports/

They're built quite frequently. Sometimes you get unlucky because a new
kernel won't boot anymore then going a couple of months back usually
helps. So for this experiment I downloaded:

https://cdimage.debian.org/cdimage/ports/9.0/sparc64/iso-cd/debian-9.0-sparc64-NETINST-1.iso

then I did:

cd .local/share/qemu
truncate -s 15GB sparc64.img

And then to _install_:

qemu-system-sparc64 \
-m 4096 \
-device virtio-blk-pci,bus=pciB,drive=hd \
-drive 
file=/home/brauner/Downloads/debian-9.0-sparc64-NETINST-1.iso,format=raw,if=ide,bus=1,unit=0,media=cdrom,readonly=on
 \
-drive 
file=/home/brauner/.local/share/qemu/sparc64.img,format=raw,if=none,id=hd \
-boot order=d \
-net nic \
-net user \
-nographic \

Then the Debian install will run after it finishes you can boot with:

qemu-system-sparc64 \
-name debian-unstable-sparc64 -machine sun4u,accel=tcg,usb=off -m 4096 \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid ccd8b5c2-b8e4-4d5e-af19-9322cd8e55bf -rtc base=utc -no-reboot 
-no-shutdown \
-boot strict=on \
-drive 
file=/home/brauner/.local/share/qemu/sparc64.img,if=none,id=drive-ide0-0-1,format=raw,cache=none,aio=native
 \
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-1,id=ide0-0-1 \
-msg timestamp=on -nographic

If the install isn't setting up the repos right and you can't install
stuff the correct url is:
http://ftp.ports.debian.org/debian-ports/
to put into sources.list

> 
> > This is the sparc specific bit and _if_ you agree with the changes here
> > it'd be nice if I could get your review, and if technically correct,
> > your ack so I can fold this into a larger series and move on to the next
> > arch.
> 
> With the delay slot instruction indentation fixed:
> 
> Acked-by: David S. Miller 

Thank you, Dave!
Christian


Re: [RFC v1 2/3] drivers: nvmem: Add driver for QTI qfprom-efuse support

2020-05-17 Thread Ravi Kumar Bokka (Temp)

Hi Doug,
Thanks for your feedback.
I have taken care most of the comments given by you initially and send 
to you as first patch-set. I thought to address other pending comments 
in next patch-set along with upstream maintainer suggestions as well.

I will address rest of the comments and send for the review asap.


Regards,
Ravi Kumar.B

On 5/14/2020 11:51 PM, Doug Anderson wrote:

Hi,

I notice that you didn't respond to any of my feedback [1], only
Srinivas's.  Any reason why?  It turns out that Srinivas had quite a
lot of the same feedback as I did, but please make sure you didn't
miss anything I suggested.  More inline below.

On Thu, May 14, 2020 at 5:26 AM Ravi Kumar Bokka (Temp)
 wrote:


Hi Srinivas,
Thanks for your feedback by giving review comments. Please find my
inline comments.


Regards,
Ravi Kumar.B

On 5/13/2020 6:50 PM, Srinivas Kandagatla wrote:



On 12/05/2020 19:17, Ravi Kumar Bokka wrote:

This patch adds new driver for QTI qfprom-efuse controller. This
driver can
access the raw qfprom regions for fuse blowing.


QTI?


guidance I have received from internal Legal/LOST team is that the QCOM
prefix needs to be changed to QTI everywhere it is used


I'll let Srinivas comment if he cares.  I'm really not sure why a
legal team cares about the Kconfig name in a GPL-licensed Linux
kernel.



The current existed qfprom driver is only supports for cpufreq,
thermal sensors
drivers by read out calibration data, speed bins..etc which is stored
by qfprom efuses.


Can you explain bit more about this QFPROM instance, Is this QFPROM part
of secure controller address space?
Is this closely tied to SoC or Secure controller version?

Any reason why this can not be integrated into qfprom driver with
specific compatible.



QFPROM driver communicates with sec_controller address space however
scope and functionalities of this driver is different and not limited as
existing qfprom fuse Read-Only driver for specific “fuse buckets’ like
cpufreq, thermal sensors etc. QFPROM fuse write driver in this patch
requires specific sequence to write/blow fuses unlike other driver.
Scope/functionalities are different and this is separate driver.


If the underlying IP blocks are the same it should be one driver and
it should just work in read-only mode for the other range of stuff.



Signed-off-by: Ravi Kumar Bokka 
---
   drivers/nvmem/Kconfig|  10 +
   drivers/nvmem/Makefile   |   2 +
   drivers/nvmem/qfprom-efuse.c | 476
+++
   3 files changed, 488 insertions(+)
   create mode 100644 drivers/nvmem/qfprom-efuse.c


...


diff --git a/drivers/nvmem/qfprom-efuse.c b/drivers/nvmem/qfprom-efuse.c
new file mode 100644
index 000..2e3c275
--- /dev/null
+++ b/drivers/nvmem/qfprom-efuse.c
@@ -0,0 +1,476 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define QFPROM_BLOW_STATUS_BUSY 0x1
+#define QFPROM_BLOW_STATUS_READY 0x0
+
+/* Blow timer clock frequency in Mhz for 10nm LPe technology */
+#define QFPROM_BLOW_TIMER_OFFSET 0x03c
+#define QFPROM_BLOW_TIMER_RESET_VALUE 0x0
+
+/* Amount of time required to hold charge to blow fuse in
micro-seconds */
+#define QFPROM_FUSE_BLOW_POLL_PERIOD 100
+#define QFPROM_BLOW_STATUS_OFFSET 0x048
+
+#define QFPROM_ACCEL_OFFSET 0x044
+
+/**
+ * struct qfprom_efuse_platform_data - structure holding qfprom-efuse
+ * platform data
+ *
+ * @name: qfprom-efuse compatible name


??


Thanks for your feedback. I will address this change


+ * @fuse_blow_time_in_us: Should contain the wait time when doing the
fuse blow
+ * @accel_value: Should contain qfprom accel value
+ * @accel_reset_value: The reset value of qfprom accel value
+ * @qfprom_blow_timer_value: The timer value of qfprom when doing
efuse blow
+ * @qfprom_blow_reset_freq: The frequency required to set when fuse
blowing
+ * is done
+ * @qfprom_blow_set_freq: The frequency required to set when we start
the
+ * fuse blowing
+ * @qfprom_max_vol: max voltage required to set fuse blow
+ * @qfprom_min_vol: min voltage required to set fuse blow


How specific are these values per SoC?



This voltage level may change based on SoC and/or fuse-hardware
technology, it would change for SoC with different technology, hence we
have kept it in SOC specific settings.


Generally I'd expect the SoC specific settings to be in the device
tree.  Drivers don't need to specify this.  Please respond to the
comments I posed in my review.



+ */
+struct qfprom_efuse_platform_data {
+const char *name;
+u8 fuse_blow_time_in_us;
+u32 accel_value;
+u32 accel_reset_value;
+u32 qfprom_blow_timer_value;
+u32 qfprom_blow_reset_freq;
+u32 qfprom_blow_set_freq;
+u32 qfprom_max_vol;
+u32 qfprom_min_vol;
+};
+
+/**
+ * struct qfprom_efuse_priv - structure holding qfprom-efuse 

Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-17 Thread Tycho Andersen
On Sun, May 17, 2020 at 04:33:11PM +0200, Christian Brauner wrote:
> On Sun, May 17, 2020 at 08:23:16AM -0600, Tycho Andersen wrote:
> > On Sun, May 17, 2020 at 09:21:56PM +1000, Aleksa Sarai wrote:
> > > On 2020-05-17, Christian Brauner  wrote:
> > > > Or... And that's more invasive but ultimately cleaner we v2 the whole
> > > > thing so e.g. SECCOMP_IOCTL_NOTIF_RECV2, SECCOMP_IOCTL_NOTIF_SEND2, and
> > > > embedd the size argument in the structs. Userspace sets the size
> > > > argument, we use get_user() to get the size first and then
> > > > copy_struct_from_user() to handle it cleanly based on that. A similar
> > > > model as with sched (has other unrelated quirks because they messed up
> > > > something too):
> > > > 
> > > > static int sched_copy_attr(struct sched_attr __user *uattr, struct 
> > > > sched_attr *attr)
> > > > {
> > > > u32 size;
> > > > int ret;
> > > > 
> > > > /* Zero the full structure, so that a short copy will be nice: 
> > > > */
> > > > memset(attr, 0, sizeof(*attr));
> > > > 
> > > > ret = get_user(size, >size);
> > > > if (ret)
> > > > return ret;
> > > > 
> > > > /* ABI compatibility quirk: */
> > > > if (!size)
> > > > size = SCHED_ATTR_SIZE_VER0;
> > > > if (size < SCHED_ATTR_SIZE_VER0 || size > PAGE_SIZE)
> > > > goto err_size;
> > > > 
> > > > ret = copy_struct_from_user(attr, sizeof(*attr), uattr, size);
> > > > if (ret) {
> > > > if (ret == -E2BIG)
> > > > goto err_size;
> > > > return ret;
> > > > }
> > > > 
> > > > We're probably the biggest user of this right now and I'd be ok with
> > > > that change. If it's a v2 than whatever. :)
> > > 
> > > I'm :+1: on a new version and switch to copy_struct_from_user(). I was a
> > > little surprised when I found out that user_notif doesn't do it this
> > > way a while ago (and although in theory it is userspace's fault, ideally
> > > we could have an API that doesn't have built-in footguns).
> > 
> > But I thought the whole point was that we couldn't do that, because
> > there's two things that can vary in length (struct seccomp_notif and
> > struct seccomp_data)?
> 
> I may have missed that discussion you linked.
> But why wouldn't:
> 
> struct seccomp_notif2 {
>   __u32 notif_size;
>   __u64 id;
>   __u32 pid;
>   __u32 flags;
>   struct seccomp_data data;
>   __u32 data_size;
> };

I guess you need to put data_size before data, otherwise old userspace
with a smaller struct seccomp_data will look in the wrong place.

But yes, that'll work if you put two sizes in, which is probably
reasonable since we're talking about two structs.

Tycho


Re: [PATCH 2/2] regulator: max8998: Add charger regulator

2020-05-17 Thread Jonathan Bakker
Hmm, while searching around looking for documentation on other parts of the 
charging
system for max8998, I've come across the originally patch for charger 
regulator(1).
It turns out the lp3974 has different current values.

It was never merged, as, to quote Mark Brown(2),

"As I've said before I'm still not really happy that these regulators can
meaningfully be generic regulator drivers rather than just being handled
as part of the PMU driver."

My use case for the generic regulator is so that the charger can be controlled
via charger-manager and the currents changed based on what type of cable is
connected (ie dedicated charger or USB charger).  The other reason that I'm
looking to use charger-manager is you can specify the over-temp and over-voltage
values (when there's external monitoring) while this part of the max8998/lp3974
isn't documented in the least (and based on registers sizes there a max of 4
options for each).

Is it worthwhile me spinning up a v2 with corrected currents for lp3974?

Thanks,
Jonathan

1) 
https://lore.kernel.org/lkml/1308909859-3674-3-git-send-email-dg77@samsung.com/
2) 
https://lore.kernel.org/lkml/20110709030853.ga23...@opensource.wolfsonmicro.com/

On 2020-05-16 12:47 p.m., Jonathan Bakker wrote:
> The max8998 has a current regulator for charging control.  The
> charger driver in drivers/power/supply/max8998_charger.c has a
> comment in it stating that 'charger control is done by a current
> regulator "CHARGER"', but this regulator was never added until
> now.
> 
> The current values have been extracted from a downstream driver
> for the SGH-T959V.
> 
> Signed-off-by: Jonathan Bakker 
> ---
>  drivers/regulator/max8998.c | 105 
>  include/linux/mfd/max8998.h |   1 +
>  2 files changed, 106 insertions(+)
> 
> diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
> index 60599c3bb845..668ced006417 100644
> --- a/drivers/regulator/max8998.c
> +++ b/drivers/regulator/max8998.c
> @@ -33,6 +33,10 @@ struct max8998_data {
>   unsigned intbuck2_idx;
>  };
>  
> +static const unsigned int charger_current_table[] = {
> + 9, 38, 475000, 55, 57, 60, 70, 80,
> +};
> +
>  static int max8998_get_enable_register(struct regulator_dev *rdev,
>   int *reg, int *shift)
>  {
> @@ -63,6 +67,10 @@ static int max8998_get_enable_register(struct 
> regulator_dev *rdev,
>   *reg = MAX8998_REG_CHGR2;
>   *shift = 7 - (ldo - MAX8998_ESAFEOUT1);
>   break;
> + case MAX8998_CHARGER:
> + *reg = MAX8998_REG_CHGR2;
> + *shift = 0;
> + break;
>   default:
>   return -EINVAL;
>   }
> @@ -88,6 +96,11 @@ static int max8998_ldo_is_enabled(struct regulator_dev 
> *rdev)
>   return val & (1 << shift);
>  }
>  
> +static int max8998_ldo_is_enabled_inverted(struct regulator_dev *rdev)
> +{
> + return (!max8998_ldo_is_enabled(rdev));
> +}
> +
>  static int max8998_ldo_enable(struct regulator_dev *rdev)
>  {
>   struct max8998_data *max8998 = rdev_get_drvdata(rdev);
> @@ -358,6 +371,74 @@ static int max8998_set_voltage_buck_time_sel(struct 
> regulator_dev *rdev,
>   return 0;
>  }
>  
> +int max8998_set_current_limit(struct regulator_dev *rdev,
> +   int min_uA, int max_uA)
> +{
> + struct max8998_data *max8998 = rdev_get_drvdata(rdev);
> + struct i2c_client *i2c = max8998->iodev->i2c;
> + unsigned int n_currents = rdev->desc->n_current_limits;
> + int i, sel = -1;
> +
> + if (n_currents == 0)
> + return -EINVAL;
> +
> + if (rdev->desc->curr_table) {
> + const unsigned int *curr_table = rdev->desc->curr_table;
> + bool ascend = curr_table[n_currents - 1] > curr_table[0];
> +
> + /* search for closest to maximum */
> + if (ascend) {
> + for (i = n_currents - 1; i >= 0; i--) {
> + if (min_uA <= curr_table[i] &&
> + curr_table[i] <= max_uA) {
> + sel = i;
> + break;
> + }
> + }
> + } else {
> + for (i = 0; i < n_currents; i++) {
> + if (min_uA <= curr_table[i] &&
> + curr_table[i] <= max_uA) {
> + sel = i;
> + break;
> + }
> + }
> + }
> + }
> +
> + if (sel < 0)
> + return -EINVAL;
> +
> + sel <<= ffs(rdev->desc->csel_mask) - 1;
> +
> + return max8998_update_reg(i2c, rdev->desc->csel_reg,
> +   sel, rdev->desc->csel_mask);
> +}
> +
> +int max8998_get_current_limit(struct regulator_dev *rdev)

Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-17 Thread Christian Brauner
On Sun, May 17, 2020 at 04:33:11PM +0200, Christian Brauner wrote:
> On Sun, May 17, 2020 at 08:23:16AM -0600, Tycho Andersen wrote:
> > On Sun, May 17, 2020 at 09:21:56PM +1000, Aleksa Sarai wrote:
> > > On 2020-05-17, Christian Brauner  wrote:
> > > > Or... And that's more invasive but ultimately cleaner we v2 the whole
> > > > thing so e.g. SECCOMP_IOCTL_NOTIF_RECV2, SECCOMP_IOCTL_NOTIF_SEND2, and
> > > > embedd the size argument in the structs. Userspace sets the size
> > > > argument, we use get_user() to get the size first and then
> > > > copy_struct_from_user() to handle it cleanly based on that. A similar
> > > > model as with sched (has other unrelated quirks because they messed up
> > > > something too):
> > > > 
> > > > static int sched_copy_attr(struct sched_attr __user *uattr, struct 
> > > > sched_attr *attr)
> > > > {
> > > > u32 size;
> > > > int ret;
> > > > 
> > > > /* Zero the full structure, so that a short copy will be nice: 
> > > > */
> > > > memset(attr, 0, sizeof(*attr));
> > > > 
> > > > ret = get_user(size, >size);
> > > > if (ret)
> > > > return ret;
> > > > 
> > > > /* ABI compatibility quirk: */
> > > > if (!size)
> > > > size = SCHED_ATTR_SIZE_VER0;
> > > > if (size < SCHED_ATTR_SIZE_VER0 || size > PAGE_SIZE)
> > > > goto err_size;
> > > > 
> > > > ret = copy_struct_from_user(attr, sizeof(*attr), uattr, size);
> > > > if (ret) {
> > > > if (ret == -E2BIG)
> > > > goto err_size;
> > > > return ret;
> > > > }
> > > > 
> > > > We're probably the biggest user of this right now and I'd be ok with
> > > > that change. If it's a v2 than whatever. :)
> > > 
> > > I'm :+1: on a new version and switch to copy_struct_from_user(). I was a
> > > little surprised when I found out that user_notif doesn't do it this
> > > way a while ago (and although in theory it is userspace's fault, ideally
> > > we could have an API that doesn't have built-in footguns).
> > 
> > But I thought the whole point was that we couldn't do that, because
> > there's two things that can vary in length (struct seccomp_notif and
> > struct seccomp_data)?
> 
> I may have missed that discussion you linked.
> But why wouldn't:
> 
> struct seccomp_notif2 {
>   __u32 notif_size;
>   __u64 id;
>   __u32 pid;
>   __u32 flags;
>   struct seccomp_data data;
>   __u32 data_size;
> };
> 
> struct seccomp_notif_resp2 {
>   __u32 notif_resp_size;
>   __u64 id;
>   __s64 val;
>   __s32 error;
>   __u32 flags;
> };

(Ignore the missing 32 bits here.)


Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-17 Thread Christian Brauner
On Sun, May 17, 2020 at 08:23:16AM -0600, Tycho Andersen wrote:
> On Sun, May 17, 2020 at 09:21:56PM +1000, Aleksa Sarai wrote:
> > On 2020-05-17, Christian Brauner  wrote:
> > > Or... And that's more invasive but ultimately cleaner we v2 the whole
> > > thing so e.g. SECCOMP_IOCTL_NOTIF_RECV2, SECCOMP_IOCTL_NOTIF_SEND2, and
> > > embedd the size argument in the structs. Userspace sets the size
> > > argument, we use get_user() to get the size first and then
> > > copy_struct_from_user() to handle it cleanly based on that. A similar
> > > model as with sched (has other unrelated quirks because they messed up
> > > something too):
> > > 
> > > static int sched_copy_attr(struct sched_attr __user *uattr, struct 
> > > sched_attr *attr)
> > > {
> > >   u32 size;
> > >   int ret;
> > > 
> > >   /* Zero the full structure, so that a short copy will be nice: */
> > >   memset(attr, 0, sizeof(*attr));
> > > 
> > >   ret = get_user(size, >size);
> > >   if (ret)
> > >   return ret;
> > > 
> > >   /* ABI compatibility quirk: */
> > >   if (!size)
> > >   size = SCHED_ATTR_SIZE_VER0;
> > >   if (size < SCHED_ATTR_SIZE_VER0 || size > PAGE_SIZE)
> > >   goto err_size;
> > > 
> > >   ret = copy_struct_from_user(attr, sizeof(*attr), uattr, size);
> > >   if (ret) {
> > >   if (ret == -E2BIG)
> > >   goto err_size;
> > >   return ret;
> > >   }
> > > 
> > > We're probably the biggest user of this right now and I'd be ok with
> > > that change. If it's a v2 than whatever. :)
> > 
> > I'm :+1: on a new version and switch to copy_struct_from_user(). I was a
> > little surprised when I found out that user_notif doesn't do it this
> > way a while ago (and although in theory it is userspace's fault, ideally
> > we could have an API that doesn't have built-in footguns).
> 
> But I thought the whole point was that we couldn't do that, because
> there's two things that can vary in length (struct seccomp_notif and
> struct seccomp_data)?

I may have missed that discussion you linked.
But why wouldn't:

struct seccomp_notif2 {
__u32 notif_size;
__u64 id;
__u32 pid;
__u32 flags;
struct seccomp_data data;
__u32 data_size;
};

struct seccomp_notif_resp2 {
__u32 notif_resp_size;
__u64 id;
__s64 val;
__s32 error;
__u32 flags;
};

work?


Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-17 Thread Tycho Andersen
On Sun, May 17, 2020 at 09:21:56PM +1000, Aleksa Sarai wrote:
> On 2020-05-17, Christian Brauner  wrote:
> > Or... And that's more invasive but ultimately cleaner we v2 the whole
> > thing so e.g. SECCOMP_IOCTL_NOTIF_RECV2, SECCOMP_IOCTL_NOTIF_SEND2, and
> > embedd the size argument in the structs. Userspace sets the size
> > argument, we use get_user() to get the size first and then
> > copy_struct_from_user() to handle it cleanly based on that. A similar
> > model as with sched (has other unrelated quirks because they messed up
> > something too):
> > 
> > static int sched_copy_attr(struct sched_attr __user *uattr, struct 
> > sched_attr *attr)
> > {
> > u32 size;
> > int ret;
> > 
> > /* Zero the full structure, so that a short copy will be nice: */
> > memset(attr, 0, sizeof(*attr));
> > 
> > ret = get_user(size, >size);
> > if (ret)
> > return ret;
> > 
> > /* ABI compatibility quirk: */
> > if (!size)
> > size = SCHED_ATTR_SIZE_VER0;
> > if (size < SCHED_ATTR_SIZE_VER0 || size > PAGE_SIZE)
> > goto err_size;
> > 
> > ret = copy_struct_from_user(attr, sizeof(*attr), uattr, size);
> > if (ret) {
> > if (ret == -E2BIG)
> > goto err_size;
> > return ret;
> > }
> > 
> > We're probably the biggest user of this right now and I'd be ok with
> > that change. If it's a v2 than whatever. :)
> 
> I'm :+1: on a new version and switch to copy_struct_from_user(). I was a
> little surprised when I found out that user_notif doesn't do it this
> way a while ago (and although in theory it is userspace's fault, ideally
> we could have an API that doesn't have built-in footguns).

But I thought the whole point was that we couldn't do that, because
there's two things that can vary in length (struct seccomp_notif and
struct seccomp_data)?

https://lore.kernel.org/lkml/cagxu5j+zpxu6ege1fer+n9+zlx3n+sj_vbs_zzj9_hrdwrr...@mail.gmail.com/

Tycho


Re: [PATCH ghak25 v4 3/3] audit: add subj creds to NETFILTER_CFG record to cover async unregister

2020-05-17 Thread Richard Guy Briggs
On 2020-04-28 18:25, Paul Moore wrote:
> On Wed, Apr 22, 2020 at 5:40 PM Richard Guy Briggs  wrote:
> > Some table unregister actions seem to be initiated by the kernel to
> > garbage collect unused tables that are not initiated by any userspace
> > actions.  It was found to be necessary to add the subject credentials to
> > cover this case to reveal the source of these actions.  A sample record:
> >
> >   type=NETFILTER_CFG msg=audit(2020-03-11 21:25:21.491:269) : table=nat 
> > family=bridge entries=0 op=unregister pid=153 uid=root auid=unset 
> > tty=(none) ses=unset subj=system_u:system_r:kernel_t:s0 comm=kworker/u4:2 
> > exe=(null)
> 
> [I'm going to comment up here instead of in the code because it is a
> bit easier for everyone to see what the actual impact might be on the
> records.]
> 
> Steve wants subject info in this case, okay, but let's try to trim out
> some of the fields which simply don't make sense in this record; I'm
> thinking of fields that are unset/empty in the kernel case and are
> duplicates of other records in the userspace/syscall case.  I think
> that means we can drop "tty", "ses", "comm", and "exe" ... yes?
> 
> While "auid" is a potential target for removal based on the
> dup-or-unset criteria, I think it falls under Steve's request for
> subject info here, even if it is garbage in this case.

Can you explain why auid falls under this criteria but ses does not if
both are unset?  If auid is unset then we know ses is unset?  If subj
contains *:kernel_t:* then uid can also be dropped even though it is
set, no?  I figure if we are going to start dropping fields, might as
well drop enough to make it worth the effort, even though this is a rare
event.

As for searchability, I have solved that easily in the parser.

> > Signed-off-by: Richard Guy Briggs 
> > ---
> >  kernel/auditsc.c | 18 ++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > index d281c18d1771..d7a45b181be0 100644
> > --- a/kernel/auditsc.c
> > +++ b/kernel/auditsc.c
> > @@ -2557,12 +2557,30 @@ void __audit_log_nfcfg(const char *name, u8 af, 
> > unsigned int nentries,
> >enum audit_nfcfgop op)
> >  {
> > struct audit_buffer *ab;
> > +   const struct cred *cred;
> > +   struct tty_struct *tty;
> > +   char comm[sizeof(current->comm)];
> >
> > ab = audit_log_start(audit_context(), GFP_KERNEL, 
> > AUDIT_NETFILTER_CFG);
> > if (!ab)
> > return;
> > audit_log_format(ab, "table=%s family=%u entries=%u op=%s",
> >  name, af, nentries, audit_nfcfgs[op].s);
> > +
> > +   cred = current_cred();
> > +   tty = audit_get_tty();
> > +   audit_log_format(ab, " pid=%u uid=%u auid=%u tty=%s ses=%u",
> > +task_pid_nr(current),
> > +from_kuid(_user_ns, cred->uid),
> > +from_kuid(_user_ns, 
> > audit_get_loginuid(current)),
> > +tty ? tty_name(tty) : "(none)",
> > +audit_get_sessionid(current));
> > +   audit_put_tty(tty);
> > +   audit_log_task_context(ab); /* subj= */
> > +   audit_log_format(ab, " comm=");
> > +   audit_log_untrustedstring(ab, get_task_comm(comm, current));
> > +   audit_log_d_path_exe(ab, current->mm); /* exe= */
> > +
> > audit_log_end(ab);
> >  }
> >  EXPORT_SYMBOL_GPL(__audit_log_nfcfg);
> 
> paul moore

- RGB

--
Richard Guy Briggs 
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635



Re: [PATCH 1/1] arm64: dts: imx8mp: add "fsl,imx6sx-fec" compatible string

2020-05-17 Thread Shawn Guo
On Wed, Apr 29, 2020 at 06:04:14PM +0800, fugang.d...@nxp.com wrote:
> From: Fugang Duan 
> 
> Add "fsl,imx6sx-fec" compatible string for fec node, then
> i.MX8MP EVK ethernet function can work now.
> 
> Signed-off-by: Fugang Duan 

Applied, thanks.


Re: [patch v2 1/2] ls1043ardb: add qe node to ls1043ardb

2020-05-17 Thread Shawn Guo
On Wed, Apr 29, 2020 at 04:20:51PM +0800, Qiang Zhao wrote:
> From: Zhao Qiang 
> 
> Add qe node to fsl-ls1043a.dtsi and fsl-ls1043a-rdb.dts
> 
> Signed-off-by: Zhao Qiang 

Subject prefix should be like 'arm64: dts: ...'


> ---
> v2:
> - add commit msg and drop a new blank line
> 
>  arch/arm64/boot/dts/freescale/fsl-ls1043a-rdb.dts | 16 ++
>  arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi| 65 
> +++
>  2 files changed, 81 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1043a-rdb.dts 
> b/arch/arm64/boot/dts/freescale/fsl-ls1043a-rdb.dts
> index 4223a23..96e87ba 100644
> --- a/arch/arm64/boot/dts/freescale/fsl-ls1043a-rdb.dts
> +++ b/arch/arm64/boot/dts/freescale/fsl-ls1043a-rdb.dts
> @@ -96,6 +96,22 @@
>   };
>  };
>  
> + {

Keep labeling node sort alphabetically.

> + ucc_hdlc: ucc@2000 {
> + compatible = "fsl,ucc-hdlc";
> + rx-clock-name = "clk8";
> + tx-clock-name = "clk9";
> + fsl,rx-sync-clock = "rsync_pin";
> + fsl,tx-sync-clock = "tsync_pin";
> + fsl,tx-timeslot-mask = <0xfffe>;
> + fsl,rx-timeslot-mask = <0xfffe>;
> + fsl,tdm-framer-type = "e1";
> + fsl,tdm-id = <0>;
> + fsl,siram-entry-id = <0>;
> + fsl,tdm-interface;
> + };
> +};
> +
>   {
>   status = "okay";
>  };
> diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi 
> b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
> index c084c7a4..674e671 100644
> --- a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
> +++ b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
> @@ -525,6 +525,71 @@
>   #interrupt-cells = <2>;
>   };
>  
> + uqe: uqe@240 {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + device_type = "qe";

Is this really needed?  I can not find it in bindings doc qe.txt.

> + compatible = "fsl,qe", "simple-bus";
> + ranges = <0x0 0x0 0x240 0x4>;
> + reg = <0x0 0x240 0x0 0x480>;
> + brg-frequency = <1>;
> + bus-frequency = <2>;
> + fsl,qe-num-riscs = <1>;
> + fsl,qe-num-snums = <28>;
> +
> + qeic: qeic@80 {
> + compatible = "fsl,qe-ic";
> + reg = <0x80 0x80>;
> + #address-cells = <0>;
> + interrupt-controller;
> + #interrupt-cells = <1>;
> + interrupts = <0 77 0x04 0 77 0x04>;

Two identical interrupts?  Also, please use GIC_SPI and
IRQ_TYPE_LEVEL_HIGH defines.

Shawn

> + };
> +
> + si1: si@700 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + compatible = "fsl,ls1043-qe-si",
> + "fsl,t1040-qe-si";
> + reg = <0x700 0x80>;
> + };
> +
> + siram1: siram@1000 {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + compatible = "fsl,ls1043-qe-siram",
> + "fsl,t1040-qe-siram";
> + reg = <0x1000 0x800>;
> + };
> +
> + ucc@2000 {
> + cell-index = <1>;
> + reg = <0x2000 0x200>;
> + interrupts = <32>;
> + interrupt-parent = <>;
> + };
> +
> + ucc@2200 {
> + cell-index = <3>;
> + reg = <0x2200 0x200>;
> + interrupts = <34>;
> + interrupt-parent = <>;
> + };
> +
> + muram@1 {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + compatible = "fsl,qe-muram", "fsl,cpm-muram";
> + ranges = <0x0 0x1 0x6000>;
> +
> + data-only@0 {
> + compatible = "fsl,qe-muram-data",
> + "fsl,cpm-muram-data";
> + reg = <0x0 0x6000>;
> + };
> + };
> + };
> +
>   lpuart0: serial@295 {
>   compatible = "fsl,ls1021a-lpuart";
>   reg = <0x0 0x295 0x0 0x1000>;
> -- 
> 2.9.5
> 


Re: [RFC PATCH 00/14] iio: buffer: add support for multiple buffers

2020-05-17 Thread Jonathan Cameron
On Sun, 17 May 2020 06:26:17 +
"Ardelean, Alexandru"  wrote:

> On Sat, 2020-05-16 at 17:24 +0100, Jonathan Cameron wrote:
> > [External]
> > 
> > On Sat, 16 May 2020 13:08:46 +
> > "Ardelean, Alexandru"  wrote:
> >   
> > > On Tue, 2020-05-12 at 06:26 +, Ardelean, Alexandru wrote:  
> > > > [External]
> > > > 
> > > > On Mon, 2020-05-11 at 21:56 +0200, Lars-Peter Clausen wrote:
> > > > > [External]
> > > > > 
> > > > > On 5/11/20 4:56 PM, Ardelean, Alexandru wrote:
> > > > > > On Mon, 2020-05-11 at 15:58 +0200, Lars-Peter Clausen wrote:
> > > > > > > [External]
> > > > > > > 
> > > > > > > On 5/11/20 3:24 PM, Ardelean, Alexandru wrote:
> > > > > > > > On Mon, 2020-05-11 at 13:03 +, Ardelean, Alexandru wrote:   
> > > > > > > >  
> > > > > > > > > [External]
> > > > > > > > > 
> > > > > > > > > On Mon, 2020-05-11 at 12:37 +0200, Lars-Peter Clausen wrote:  
> > > > > > > > >   
> > > > > > > > > > [External]
> > > > > > > > > > 
> > > > > > > > > > On 5/11/20 12:33 PM, Ardelean, Alexandru wrote:
> > > > > > > > > > > On Sun, 2020-05-10 at 11:09 +0100, Jonathan Cameron 
> > > > > > > > > > > wrote:
> > > > > > > > > > > > [External]
> > > > > > > > > > > > 
> > > > > > > > > > > > On Sat, 9 May 2020 10:52:14 +0200
> > > > > > > > > > > > Lars-Peter Clausen  wrote:
> > > > > > > > > > > > 
> > > > > > > > > > > > > On 5/8/20 3:53 PM, Alexandru Ardelean wrote:
> > > > > > > > > > > > > > [...]
> > > > > > > > > > > > > > What I don't like, is that iio:device3 has
> > > > > > > > > > > > > > iio:buffer3:0
> > > > > > > > > > > > > > (to
> > > > > > > > > > > > > > 3).
> > > > > > > > > > > > > > This is because the 'buffer->dev.parent =
> > > > > > > > > > > > > > _dev-
> > > > > > > > > > > > > > > dev'.
> > > > > > > > > > > > > > But I do feel this is correct.
> > > > > > > > > > > > > > So, now I don't know whether to leave it like that 
> > > > > > > > > > > > > > or
> > > > > > > > > > > > > > symlink to
> > > > > > > > > > > > > > shorter
> > > > > > > > > > > > > > versions like 'iio:buffer3:Y' ->
> > > > > > > > > > > > > > 'iio:device3/bufferY'.
> > > > > > > > > > > > > > The reason for naming the IIO buffer devices to
> > > > > > > > > > > > > > 'iio:bufferX:Y'
> > > > > > > > > > > > > > is
> > > > > > > > > > > > > > mostly to make the names unique. It would have 
> > > > > > > > > > > > > > looked
> > > > > > > > > > > > > > weird
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > do
> > > > > > > > > > > > > > '/dev/buffer1' if I would have named the buffer
> > > > > > > > > > > > > > devices
> > > > > > > > > > > > > > 'bufferX'.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > So, now I'm thinking of whether all this is
> > > > > > > > > > > > > > acceptable.
> > > > > > > > > > > > > > Or what is acceptable?
> > > > > > > > > > > > > > Should I symlink 'iio:device3/iio:buffer3:0' ->
> > > > > > > > > > > > > > 'iio:device3/buffer0'?
> > > > > > > > > > > > > > What else should I consider moving forward?
> > > > > > > > > > > > > > What means forward?
> > > > > > > > > > > > > > Where did I leave my beer?
> > > > > > > > > > > > > Looking at how the /dev/ devices are named I think we
> > > > > > > > > > > > > can
> > > > > > > > > > > > > provide
> > > > > > > > > > > > > a
> > > > > > > > > > > > > name
> > > > > > > > > > > > > that is different from the dev_name() of the device.
> > > > > > > > > > > > > Have a
> > > > > > > > > > > > > look
> > > > > > > > > > > > > at
> > > > > > > > > > > > > device_get_devnode() in drivers/base/core.c. We should
> > > > > > > > > > > > > be
> > > > > > > > > > > > > able
> > > > > > > > > > > > > to
> > > > > > > > > > > > > provide the name for the chardev through the devnode()
> > > > > > > > > > > > > callback.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > While we are at this, do we want to move the new 
> > > > > > > > > > > > > devices
> > > > > > > > > > > > > into
> > > > > > > > > > > > > an
> > > > > > > > > > > > > iio
> > > > > > > > > > > > > subfolder? So iio/buffer0:0 instead of iio:buffer0:0? 
> > > > > > > > > > > > >
> > > > > > > > > > > > Possibly on the folder.  I can't for the life of me
> > > > > > > > > > > > remember
> > > > > > > > > > > > why
> > > > > > > > > > > > I
> > > > > > > > > > > > decided
> > > > > > > > > > > > not to do that the first time around - I'll leave it at
> > > > > > > > > > > > the
> > > > > > > > > > > > mysterious "it may turn out to be harder than you'd
> > > > > > > > > > > > think..."
> > > > > > > > > > > > Hopefully not ;)
> > > > > > > > > > > I was also thinking about the /dev/iio subfolder while 
> > > > > > > > > > > doing
> > > > > > > > > > > this.
> > > > > > > > > > > I can copy that from /dev/input
> > > > > > > > > > > They seem to do it already.
> > > > > > > > > > > I don't know how difficult it would be. But it looks like 
> > > > > > > > > > > a
> > > > > > > > > > > good
> > > > > > > > > > 

Re: [PATCH] tick/nohz: Narrow down noise while setting current task's tick dependency

2020-05-17 Thread Frederic Weisbecker
On Fri, May 15, 2020 at 08:07:18PM -0700, Paul E. McKenney wrote:
> On Fri, May 15, 2020 at 02:34:29AM +0200, Frederic Weisbecker wrote:
> > So far setting a tick dependency on any task, including current, used to
> > trigger an IPI to all CPUs. That's of course suboptimal but it wasn't
> > an issue as long as it was only used by posix-cpu-timers on nohz_full,
> > a combo that nobody seemed to use in real life.
> > 
> > But RCU started to use task tick dependency on current task to fix
> > stall issues on callbacks processing. These trigger regular and
> > undesired system wide IPIs on nohz_full.
> > 
> > The fix is very easy while setting a tick dependency on the current
> > task, only its CPU needs an IPI.
> 
> This passes moderate rcutorture testing.  If you want me to take it, please
> let me know, and otherwise:
> 
> Tested-by: Paul E. McKenney 

If you already have a pending urgent queue, I'd love you to take it.
If not I can take it.

Thanks.


Re: [PATCH v11 33/56] Input: atmel_mxt_ts - delay enabling IRQ when not using regulators

2020-05-17 Thread Dmitry Osipenko
17.05.2020 16:08, Dmitry Osipenko пишет:
> 17.05.2020 06:32, Wang, Jiada пишет:
>> Hello Dmitry
>>
>> On 2020/05/14 13:53, Dmitry Osipenko wrote:
>>> 13.05.2020 08:07, Wang, Jiada пишет:
 Hello Dmitry

 On 2020/05/12 8:13, Dmitry Osipenko wrote:
> 11.05.2020 05:05, Wang, Jiada пишет:
>> Hello Dmitry
>>
>> Thanks for your comment and test,
>>
>> can you let me know which platform (board) you are using for test,
>> and DTS changes if you have added any.
>
> That's this device-tree [1] without any extra changes.
>
 I am using Samsung Chromebook Pro for testing,
 but obviously some of the use cases it can't cover.

 I also would like to test on same device you are using,
 would you please let me know how to boot Acer Iconia Tab A500
 with custom images. Are you booting Linux or Android on it?
>>>
>>> I'm using Ubuntu 20.04 on it at the moment. In order to boot custom
>>> images you'll need at least to install a custom recovery, which will
>>> allow to flash boot.img on eMMC storage.
>>>
>>> Ideally, you'll need to install an unlocked bootloader that will enable
>>> Android's fastboot, and thus, allow to easily boot kernel zImage without
>>> messing with flashing boot images.
>>>
>>> Could you please tell what is the current state of yours device: does it
>>> have a stock Android installed? is it rooted? is custom recovery
>>> installed?
>>>
>> Thanks for your information
>>
>> By following instructions found in XDA forums,
>> now I am able to install an unlocked bootloader,
>> boot among primary kernel, recovery kernel or fastboot,
>> an Android custom stock rom also has been installed
> 
> Awesome!
> 
>> Could you please let me know how to install local built ubuntu images
> 
> Sure, please follow these steps:
> 
> 1. Download rootfs from
> http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04-base-armhf.tar.gz
> 
> 2. Extract it wherever you want yours root to be, like ExternalSD card
> or eMMC /data partition or even NFS directory if you'll use usbnet.
> 
> 3. Clone this kernel https://github.com/grate-driver/linux which is a
> recent upstream linux-next + work-in-progress patches that haven't been
> merged into upstream yet. For example DRM bridges and Tegra Partition
> Table patches are under review now.
> 
> 4. Select tegra_defconfig:
> 
>   ARCH=arm make tegra_defconfig
> 
> 5. Compile kernel:
> 
>   ARCH=arm make
> 
> 6. Append DTB to zImage:
> 
>   cat arch/arm/boot/zImage
> arch/arm/boot/dts/tegra20-acer-a500-picasso.dtb > arch/arm/boot/zImage-dtb
> 
> 7. Turn on A500 and select 'fastboot' option in the bootloader's menu.
> 
> 8. Boot compiled kernel:
> 
>   fastboot -c "root=/dev/mmcblk2p8 gpt tegraboot=sdmmc" boot
> arch/arm/boot/zImage-dtb
> 
> 9. Grab touchscreen/WiFi/Bluetooth firmware files from
> https://github.com/digetx/linux-firmware
> 
> 10. Grab ALSA UCM rule from https://github.com/digetx/alsa-ucm-conf
> 
> 11. Enjoy!
> 
> Please let me know you'll experience any problems, I'll be glad to help.
> 

Also, there is an Ubuntu PPA for Tegra20/30 devices with drivers from
GRATE-driver project:
https://launchpad.net/~grate-driver/+archive/ubuntu/ppa

Please keep in mind that there is no GL driver that work with upstream
kernel.

I'd recommend to use KDE Plasma 5 for the desktop environment. For the
good experience you'll need to tell Qt to use software render, the
easiest way is to set required env variables globally:

echo -e
"QT_QUICK_BACKEND=software\nLIBGL_ALWAYS_SOFTWARE=1\nQT_IM_MODULE=qtvirtualkeyboard"
>> /etc/security/pam_env.conf


Re: [PATCH V7 00/15] perf/x86: Add perf text poke events

2020-05-17 Thread Adrian Hunter
On 12/05/20 3:19 pm, Adrian Hunter wrote:
> Hi
> 
> Here are patches to add a text poke event to record changes to kernel text
> (i.e. self-modifying code) in order to support tracers like Intel PT
> decoding through jump labels, kprobes and ftrace trampolines.
> 
> The first 8 patches make the kernel changes and the subsequent patches are
> tools changes.
> 
> The next 4 patches add support for updating perf tools' data cache
> with the changed bytes.
> 
> The next patch is an Intel PT specific tools change.
> 
> The final 2 patches add perf script --show-text-poke-events option
> 
> Patches also here:
> 
>   git://git.infradead.org/users/ahunter/linux-perf.git text_poke
> 
> Changes in V7
> 
>   perf: Add perf text poke event
>   perf/x86: Add support for perf text poke event for text_poke_bp_batch() 
> callers
>   kprobes: Add symbols for kprobe insn pages
>   kprobes: Add perf ksymbol events for kprobe insn pages
>   perf/x86: Add perf text poke events for kprobes
>   ftrace: Add symbols for ftrace trampolines
>   ftrace: Add perf ksymbol events for ftrace trampolines
>   ftrace: Add perf text poke events for ftrace trampolines
> 
>   Added Peter's Ack
>   Improved commit message for text_poke events for ftrace trampolines
> 
>   perf kcore_copy: Fix module map when there are no modules loaded
>   perf evlist: Disable 'immediate' events last
>   perf tools: Add support for PERF_RECORD_TEXT_POKE
>   perf tools: Add support for PERF_RECORD_KSYMBOL_TYPE_OOL
>   perf intel-pt: Add support for text poke events
>   perf script: Add option --show-text-poke-events
>   perf script: Show text poke address symbol
> 
>   Re-based on Arnaldo's perf/core branch
> 

Arnaldo, any comments on the tools patches?


[PATCH v5 0/2] Add Qualcomm MSM8939 GCC binding and driver

2020-05-17 Thread Bryan O'Donoghue
V5:
- Drops unnecessary .name = "xo" - Stephen
- Re-orders probe to put PLL configuration and regmap before
  qcom_cc_really_probe() - Stephen
- Removes MODULE_ALIAS("platform:gcc-msm8939"); - Stephen
- Marks Shawn's contribution as Co-developed-by - Stephen
- https://github.com/bryanodonoghue/linux/pull/new/clk-next+msm8939-v4
- https://github.com/bryanodonoghue/linux/pull/new/clk-next+msm8939-v5
- https://github.com/bryanodonoghue/linux/pull/new/clk-next+msm8939-tip-v5

V4:
- Moves headers from 1/1 to 0/1 - patch squashing error - Rob
- Identifies licensing as GPL v2.0-only, thanks for pointing this out. - Rob
- Adds Tested-by: Vincent Knecht , thanks for
  testing this. - Vincent
- https://github.com/bryanodonoghue/linux/pull/new/clk-next+msm8939-v2.1
- https://github.com/bryanodonoghue/linux/pull/new/clk-next+msm8939-v4

V3:
This update removes the old clock name arrays which I forgot to prune in
the previous V2.

git diff bod/clk-next+msm8939 bod/clk-next+msm8939-v2.1

V2:
This update does the following

1. Drops code in the probe routine to add xo and sleep_clk. Instead
   the DTS for the GCC will need to declare both of those clocks for the
   GCC controller.

2. Supplants parent_names for parent_data for all clocks.

3. Squashes down the previous three patches into two.

4. Drops the git log of copying files. The git log makes clear the silicon
   is highly similar, so, you can just as easily read the log and do a
   diff.

5. Doesn't update the MSM8916 with parent_data.
   Happy to do this at a later date but, don't have the time to validate
   this properly at the moment. This set focuses on the MSM8939 alone.

6. Dropped comment and boilerplate license text as indicated.

7. Dropped dependency on COMMON_CLK_QCOM seems to not be needed.

8. Easily view the changes here:
   git add bod https://github.com/bryanodonoghue/linux.git
   git fetch bod
   git diff bod/clk-next+msm8939 bod/clk-next+msm8939-v2   

V1:
These three patches add support for the MSM8939 Global Clock Controller.
The MSM8939 is a derivation of the MSM8916 sharing the large majority of
its clock settings with MSM8916, however, there are enough changes, in some
cases mutually incompatible changes that necessitate a separate driver.

I thought it was both important and useful to show in the git log the
differences between MSM8916 and MSM8939 so, one patch copies the MSM8916
driver while another patch applies the entire gamut of MSM8939 changes,
squashing down from a git log of approximately 31 separate commits.

For reference that log is here:
https://github.com/bryanodonoghue/linux/pull/new/msm8939-clk-next-reference-log

Generally speaking MSM8939 differes from MSM8916 in two key ways.

- New and higher clock frequencies for existing IP blocks.
- New PLLs to drive those higher frequencies

Bryan O'Donoghue (2):
  clk: qcom: Add DT bindings for MSM8939 GCC
  clk: qcom: gcc-msm8939: Add MSM8939 Generic Clock Controller

 .../devicetree/bindings/clock/qcom,gcc.yaml   |3 +
 drivers/clk/qcom/Kconfig  |8 +
 drivers/clk/qcom/Makefile |1 +
 drivers/clk/qcom/gcc-msm8939.c| 3989 +
 include/dt-bindings/clock/qcom,gcc-msm8939.h  |  206 +
 include/dt-bindings/reset/qcom,gcc-msm8939.h  |  110 +
 6 files changed, 4317 insertions(+)
 create mode 100644 drivers/clk/qcom/gcc-msm8939.c
 create mode 100644 include/dt-bindings/clock/qcom,gcc-msm8939.h
 create mode 100644 include/dt-bindings/reset/qcom,gcc-msm8939.h

-- 
2.25.1



[PATCH v5 2/2] clk: qcom: gcc-msm8939: Add MSM8939 Generic Clock Controller

2020-05-17 Thread Bryan O'Donoghue
This patch adds support for the MSM8939 GCC. The MSM8939 is based on the
MSM8916. MSM8939 is compatible in several ways with MSM8916 but, has
additional functional blocks added which require additional PLL sources. In
some cases functional blocks from the MSM8916 have different clock sources
or different supported frequencies.

Cc: Andy Gross 
Cc: Bjorn Andersson 
Cc: Michael Turquette 
Cc: Stephen Boyd 
Cc: Rob Herring 
Cc: Philipp Zabel 
Cc: linux-arm-...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: devicet...@vger.kernel.org
Co-developed-by: Shawn Guo 
Signed-off-by: Shawn Guo 
Tested-by: Vincent Knecht 
Signed-off-by: Bryan O'Donoghue 
---
 drivers/clk/qcom/Kconfig   |8 +
 drivers/clk/qcom/Makefile  |1 +
 drivers/clk/qcom/gcc-msm8939.c | 3989 
 3 files changed, 3998 insertions(+)
 create mode 100644 drivers/clk/qcom/gcc-msm8939.c

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 11ec6f466467..54c4e3a02636 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -142,6 +142,14 @@ config MSM_GCC_8916
  Say Y if you want to use devices such as UART, SPI i2c, USB,
  SD/eMMC, display, graphics, camera etc.
 
+config MSM_GCC_8939
+   tristate "MSM8939 Global Clock Controller"
+   select QCOM_GDSC
+   help
+ Support for the global clock controller on msm8939 devices.
+ Say Y if you want to use devices such as UART, SPI i2c, USB,
+ SD/eMMC, display, graphics, camera etc.
+
 config MSM_GCC_8960
tristate "APQ8064/MSM8960 Global Clock Controller"
help
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index 691efbf7e81f..7ec8561a1270 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_MDM_GCC_9615) += gcc-mdm9615.o
 obj-$(CONFIG_MDM_LCC_9615) += lcc-mdm9615.o
 obj-$(CONFIG_MSM_GCC_8660) += gcc-msm8660.o
 obj-$(CONFIG_MSM_GCC_8916) += gcc-msm8916.o
+obj-$(CONFIG_MSM_GCC_8939) += gcc-msm8939.o
 obj-$(CONFIG_MSM_GCC_8960) += gcc-msm8960.o
 obj-$(CONFIG_MSM_GCC_8974) += gcc-msm8974.o
 obj-$(CONFIG_MSM_GCC_8994) += gcc-msm8994.o
diff --git a/drivers/clk/qcom/gcc-msm8939.c b/drivers/clk/qcom/gcc-msm8939.c
new file mode 100644
index ..03e90b0610e5
--- /dev/null
+++ b/drivers/clk/qcom/gcc-msm8939.c
@@ -0,0 +1,3989 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2020 Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "common.h"
+#include "clk-regmap.h"
+#include "clk-pll.h"
+#include "clk-rcg.h"
+#include "clk-branch.h"
+#include "reset.h"
+#include "gdsc.h"
+
+enum {
+   P_XO,
+   P_GPLL0,
+   P_GPLL0_AUX,
+   P_BIMC,
+   P_GPLL1,
+   P_GPLL1_AUX,
+   P_GPLL2,
+   P_GPLL2_AUX,
+   P_GPLL3,
+   P_GPLL3_AUX,
+   P_GPLL4,
+   P_GPLL5,
+   P_GPLL5_AUX,
+   P_GPLL5_EARLY,
+   P_GPLL6,
+   P_GPLL6_AUX,
+   P_SLEEP_CLK,
+   P_DSI0_PHYPLL_BYTE,
+   P_DSI0_PHYPLL_DSI,
+   P_EXT_PRI_I2S,
+   P_EXT_SEC_I2S,
+   P_EXT_MCLK,
+};
+
+static struct clk_pll gpll0 = {
+   .l_reg = 0x21004,
+   .m_reg = 0x21008,
+   .n_reg = 0x2100c,
+   .config_reg = 0x21010,
+   .mode_reg = 0x21000,
+   .status_reg = 0x2101c,
+   .status_bit = 17,
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "gpll0",
+   .parent_data = &(const struct clk_parent_data) {
+   .fw_name = "xo",
+   },
+   .num_parents = 1,
+   .ops = _pll_ops,
+   },
+};
+
+static struct clk_regmap gpll0_vote = {
+   .enable_reg = 0x45000,
+   .enable_mask = BIT(0),
+   .hw.init = &(struct clk_init_data){
+   .name = "gpll0_vote",
+   .parent_data = &(const struct clk_parent_data) {
+   .hw = ,
+   },
+   .num_parents = 1,
+   .ops = _pll_vote_ops,
+   },
+};
+
+static struct clk_pll gpll1 = {
+   .l_reg = 0x20004,
+   .m_reg = 0x20008,
+   .n_reg = 0x2000c,
+   .config_reg = 0x20010,
+   .mode_reg = 0x2,
+   .status_reg = 0x2001c,
+   .status_bit = 17,
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "gpll1",
+   .parent_data = &(const struct clk_parent_data) {
+   .fw_name = "xo",
+   },
+   .num_parents = 1,
+   .ops = _pll_ops,
+   },
+};
+
+static struct clk_regmap gpll1_vote = {
+   .enable_reg = 0x45000,
+   .enable_mask = BIT(1),
+   .hw.init = &(struct clk_init_data){
+   .name = "gpll1_vote",
+   .parent_data = &(const struct clk_parent_data) {
+   .hw = ,
+   },
+   

[PATCH v5 1/2] clk: qcom: Add DT bindings for MSM8939 GCC

2020-05-17 Thread Bryan O'Donoghue
Add compatible strings and the include files for the MSM8939 GCC.

Cc: Andy Gross 
Cc: Bjorn Andersson 
Cc: Michael Turquette 
Cc: Stephen Boyd 
Cc: Rob Herring 
Cc: linux-arm-...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: devicet...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Tested-by: Vincent Knecht 
Signed-off-by: Bryan O'Donoghue 
---
 .../devicetree/bindings/clock/qcom,gcc.yaml   |   3 +
 include/dt-bindings/clock/qcom,gcc-msm8939.h  | 206 ++
 include/dt-bindings/reset/qcom,gcc-msm8939.h  | 110 ++
 3 files changed, 319 insertions(+)
 create mode 100644 include/dt-bindings/clock/qcom,gcc-msm8939.h
 create mode 100644 include/dt-bindings/reset/qcom,gcc-msm8939.h

diff --git a/Documentation/devicetree/bindings/clock/qcom,gcc.yaml 
b/Documentation/devicetree/bindings/clock/qcom,gcc.yaml
index e533bb0cfd2b..ee0467fb5e31 100644
--- a/Documentation/devicetree/bindings/clock/qcom,gcc.yaml
+++ b/Documentation/devicetree/bindings/clock/qcom,gcc.yaml
@@ -22,6 +22,8 @@ description: |
   - dt-bindings/reset/qcom,gcc-ipq6018.h
   - dt-bindings/clock/qcom,gcc-ipq806x.h (qcom,gcc-ipq8064)
   - dt-bindings/reset/qcom,gcc-ipq806x.h (qcom,gcc-ipq8064)
+  - dt-bindings/clock/qcom,gcc-msm8939.h
+  - dt-bindings/reset/qcom,gcc-msm8939.h
   - dt-bindings/clock/qcom,gcc-msm8660.h
   - dt-bindings/reset/qcom,gcc-msm8660.h
   - dt-bindings/clock/qcom,gcc-msm8974.h
@@ -41,6 +43,7 @@ properties:
   - qcom,gcc-ipq8064
   - qcom,gcc-msm8660
   - qcom,gcc-msm8916
+  - qcom,gcc-msm8939
   - qcom,gcc-msm8960
   - qcom,gcc-msm8974
   - qcom,gcc-msm8974pro
diff --git a/include/dt-bindings/clock/qcom,gcc-msm8939.h 
b/include/dt-bindings/clock/qcom,gcc-msm8939.h
new file mode 100644
index ..0634467c4ce5
--- /dev/null
+++ b/include/dt-bindings/clock/qcom,gcc-msm8939.h
@@ -0,0 +1,206 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2020 Linaro Limited
+ */
+
+#ifndef _DT_BINDINGS_CLK_MSM_GCC_8939_H
+#define _DT_BINDINGS_CLK_MSM_GCC_8939_H
+
+#define GPLL0  0
+#define GPLL0_VOTE 1
+#define BIMC_PLL   2
+#define BIMC_PLL_VOTE  3
+#define GPLL1  4
+#define GPLL1_VOTE 5
+#define GPLL2  6
+#define GPLL2_VOTE 7
+#define PCNOC_BFDCD_CLK_SRC8
+#define SYSTEM_NOC_BFDCD_CLK_SRC   9
+#define CAMSS_AHB_CLK_SRC  10
+#define APSS_AHB_CLK_SRC   11
+#define CSI0_CLK_SRC   12
+#define CSI1_CLK_SRC   13
+#define GFX3D_CLK_SRC  14
+#define VFE0_CLK_SRC   15
+#define BLSP1_QUP1_I2C_APPS_CLK_SRC16
+#define BLSP1_QUP1_SPI_APPS_CLK_SRC17
+#define BLSP1_QUP2_I2C_APPS_CLK_SRC18
+#define BLSP1_QUP2_SPI_APPS_CLK_SRC19
+#define BLSP1_QUP3_I2C_APPS_CLK_SRC20
+#define BLSP1_QUP3_SPI_APPS_CLK_SRC21
+#define BLSP1_QUP4_I2C_APPS_CLK_SRC22
+#define BLSP1_QUP4_SPI_APPS_CLK_SRC23
+#define BLSP1_QUP5_I2C_APPS_CLK_SRC24
+#define BLSP1_QUP5_SPI_APPS_CLK_SRC25
+#define BLSP1_QUP6_I2C_APPS_CLK_SRC26
+#define BLSP1_QUP6_SPI_APPS_CLK_SRC27
+#define BLSP1_UART1_APPS_CLK_SRC   28
+#define BLSP1_UART2_APPS_CLK_SRC   29
+#define CCI_CLK_SRC30
+#define CAMSS_GP0_CLK_SRC  31
+#define CAMSS_GP1_CLK_SRC  32
+#define JPEG0_CLK_SRC  33
+#define MCLK0_CLK_SRC  34
+#define MCLK1_CLK_SRC  35
+#define CSI0PHYTIMER_CLK_SRC   36
+#define CSI1PHYTIMER_CLK_SRC   37
+#define CPP_CLK_SRC38
+#define CRYPTO_CLK_SRC 39
+#define GP1_CLK_SRC40
+#define GP2_CLK_SRC41
+#define GP3_CLK_SRC42
+#define BYTE0_CLK_SRC  43
+#define ESC0_CLK_SRC   44
+#define MDP_CLK_SRC45
+#define PCLK0_CLK_SRC  46
+#define VSYNC_CLK_SRC  47
+#define PDM2_CLK_SRC   48
+#define SDCC1_APPS_CLK_SRC 49
+#define SDCC2_APPS_CLK_SRC 50
+#define APSS_TCU_CLK_SRC   51
+#define USB_HS_SYSTEM_CLK_SRC  52
+#define VCODEC0_CLK_SRC53
+#define GCC_BLSP1_AHB_CLK  54
+#define GCC_BLSP1_SLEEP_CLK55
+#define GCC_BLSP1_QUP1_I2C_APPS_CLK56
+#define GCC_BLSP1_QUP1_SPI_APPS_CLK57

[tip: x86/build] x86/build: Use $(CONFIG_SHELL)

2020-05-17 Thread tip-bot2 for Andrew Morton
The following commit has been merged into the x86/build branch of tip:

Commit-ID: 0be11088b848774ae1f693169fdb9575e0ff06ba
Gitweb:
https://git.kernel.org/tip/0be11088b848774ae1f693169fdb9575e0ff06ba
Author:Andrew Morton 
AuthorDate:Tue, 05 May 2020 14:26:51 -07:00
Committer: Ingo Molnar 
CommitterDate: Sun, 17 May 2020 16:01:33 +03:00

x86/build: Use $(CONFIG_SHELL)

When scripts/x86-check-compiler.sh doesn't have the executable bit set:

  q:/usr/src/25> make clean
  make: execvp: ./scripts/x86-check-compiler.sh: Permission denied

Fix this by using $(CONFIG_SHELL).

This will happen if the user downloads and applies patch-5.7.tar.gz, since
patch(1) doesn't preserve the x bit.

Fixes: 73da86741e7f7 ("x86/build: Check whether the compiler is sane")
Signed-off-by: Andrew Morton 
Signed-off-by: Borislav Petkov 
Link: https://lkml.kernel.org/r/20200505211932.ge6...@zn.tnic
Signed-off-by: Ingo Molnar 
---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 38d3eec..9e22791 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -2,7 +2,7 @@
 # Unified Makefile for i386 and x86_64
 
 #  Check the compiler
-sane_compiler := $(shell $(srctree)/scripts/x86-check-compiler.sh $(CC))
+sane_compiler := $($(CONFIG_SHELL) $(srctree)/scripts/x86-check-compiler.sh 
$(CC))
 $(if $(sane_compiler),$(error $(CC) check failed. Aborting),)
 
 # select defconfig based on actual architecture


Re: [PATCH v11 33/56] Input: atmel_mxt_ts - delay enabling IRQ when not using regulators

2020-05-17 Thread Dmitry Osipenko
17.05.2020 06:32, Wang, Jiada пишет:
> Hello Dmitry
> 
> On 2020/05/14 13:53, Dmitry Osipenko wrote:
>> 13.05.2020 08:07, Wang, Jiada пишет:
>>> Hello Dmitry
>>>
>>> On 2020/05/12 8:13, Dmitry Osipenko wrote:
 11.05.2020 05:05, Wang, Jiada пишет:
> Hello Dmitry
>
> Thanks for your comment and test,
>
> can you let me know which platform (board) you are using for test,
> and DTS changes if you have added any.

 That's this device-tree [1] without any extra changes.

>>> I am using Samsung Chromebook Pro for testing,
>>> but obviously some of the use cases it can't cover.
>>>
>>> I also would like to test on same device you are using,
>>> would you please let me know how to boot Acer Iconia Tab A500
>>> with custom images. Are you booting Linux or Android on it?
>>
>> I'm using Ubuntu 20.04 on it at the moment. In order to boot custom
>> images you'll need at least to install a custom recovery, which will
>> allow to flash boot.img on eMMC storage.
>>
>> Ideally, you'll need to install an unlocked bootloader that will enable
>> Android's fastboot, and thus, allow to easily boot kernel zImage without
>> messing with flashing boot images.
>>
>> Could you please tell what is the current state of yours device: does it
>> have a stock Android installed? is it rooted? is custom recovery
>> installed?
>>
> Thanks for your information
> 
> By following instructions found in XDA forums,
> now I am able to install an unlocked bootloader,
> boot among primary kernel, recovery kernel or fastboot,
> an Android custom stock rom also has been installed

Awesome!

> Could you please let me know how to install local built ubuntu images

Sure, please follow these steps:

1. Download rootfs from
http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04-base-armhf.tar.gz

2. Extract it wherever you want yours root to be, like ExternalSD card
or eMMC /data partition or even NFS directory if you'll use usbnet.

3. Clone this kernel https://github.com/grate-driver/linux which is a
recent upstream linux-next + work-in-progress patches that haven't been
merged into upstream yet. For example DRM bridges and Tegra Partition
Table patches are under review now.

4. Select tegra_defconfig:

ARCH=arm make tegra_defconfig

5. Compile kernel:

ARCH=arm make

6. Append DTB to zImage:

cat arch/arm/boot/zImage
arch/arm/boot/dts/tegra20-acer-a500-picasso.dtb > arch/arm/boot/zImage-dtb

7. Turn on A500 and select 'fastboot' option in the bootloader's menu.

8. Boot compiled kernel:

fastboot -c "root=/dev/mmcblk2p8 gpt tegraboot=sdmmc" boot
arch/arm/boot/zImage-dtb

9. Grab touchscreen/WiFi/Bluetooth firmware files from
https://github.com/digetx/linux-firmware

10. Grab ALSA UCM rule from https://github.com/digetx/alsa-ucm-conf

11. Enjoy!

Please let me know you'll experience any problems, I'll be glad to help.


[PATCH 5/7] x86/boot: Mark global variables as static

2020-05-17 Thread Ard Biesheuvel
From: Arvind Sankar 

Mike Lothian reports that after commit
  964124a97b97 ("efi/x86: Remove extra headroom for setup block")
gcc 10.1.0 fails with

  HOSTCC  arch/x86/boot/tools/build
  
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld:
  error: linker defined: multiple definition of '_end'
  
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld:
  /tmp/ccEkW0jM.o: previous definition here
  collect2: error: ld returned 1 exit status
  make[1]: *** [scripts/Makefile.host:103: arch/x86/boot/tools/build] Error 1
  make: *** [arch/x86/Makefile:303: bzImage] Error 2

The issue is with the _end variable that was added, to hold the end of
the compressed kernel from zoffsets.h (ZO__end). The name clashes with
the linker-defined _end symbol that indicates the end of the build
program itself.

Even when there is no compile-time error, this causes build to use
memory past the end of its .bss section.

To solve this, mark _end as static, and for symmetry, mark the rest of
the variables that keep track of symbols from the compressed kernel as
static as well.

Fixes: 964124a97b97 ("efi/x86: Remove extra headroom for setup block")
Reported-by: Mike Lothian 
Tested-by: Mike Lothian 
Signed-off-by: Arvind Sankar 
Link: https://lore.kernel.org/r/20200511225849.1311869-1-nived...@alum.mit.edu
Signed-off-by: Ard Biesheuvel 
---
 arch/x86/boot/tools/build.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c
index 8f8c8e386cea..c8b8c1a8d1fc 100644
--- a/arch/x86/boot/tools/build.c
+++ b/arch/x86/boot/tools/build.c
@@ -59,14 +59,14 @@ u8 buf[SETUP_SECT_MAX*512];
 #define PECOFF_COMPAT_RESERVE 0x0
 #endif
 
-unsigned long efi32_stub_entry;
-unsigned long efi64_stub_entry;
-unsigned long efi_pe_entry;
-unsigned long efi32_pe_entry;
-unsigned long kernel_info;
-unsigned long startup_64;
-unsigned long _ehead;
-unsigned long _end;
+static unsigned long efi32_stub_entry;
+static unsigned long efi64_stub_entry;
+static unsigned long efi_pe_entry;
+static unsigned long efi32_pe_entry;
+static unsigned long kernel_info;
+static unsigned long startup_64;
+static unsigned long _ehead;
+static unsigned long _end;
 
 /*--*/
 
-- 
2.17.1



[PATCH 4/7] efi: cper: Add support for printing Firmware Error Record Reference

2020-05-17 Thread Ard Biesheuvel
From: Punit Agrawal 

While debugging a boot failure, the following unknown error record was
seen in the boot logs.

<...>
BERT: Error records from previous boot:
[Hardware Error]: event severity: fatal
[Hardware Error]:  Error 0, type: fatal
[Hardware Error]:   section type: unknown, 
81212a96-09ed-4996-9471-8d729c8e69ed
[Hardware Error]:   section length: 0x290
[Hardware Error]:   : 0001   00020002  

[Hardware Error]:   0010: 00020002 001f 0320    
...
[Hardware Error]:   0020:      

[Hardware Error]:   0030:      

<...>

On further investigation, it was found that the error record with
UUID (81212a96-09ed-4996-9471-8d729c8e69ed) has been defined in the
UEFI Specification at least since v2.4 and has recently had additional
fields defined in v2.7 Section N.2.10 Firmware Error Record Reference.

Add support for parsing and printing the defined fields to give users
a chance to figure out what went wrong.

Signed-off-by: Punit Agrawal 
Cc: Ard Biesheuvel 
Cc: Borislav Petkov 
Cc: linux-a...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Link: 
https://lore.kernel.org/r/20200512045502.3810339-1-punit1.agra...@toshiba.co.jp
Signed-off-by: Ard Biesheuvel 
---
 drivers/firmware/efi/cper.c | 62 +
 include/linux/cper.h|  9 ++
 2 files changed, 71 insertions(+)

diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 9d2512913d25..f564e15fbc7e 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -407,6 +407,58 @@ static void cper_print_pcie(const char *pfx, const struct 
cper_sec_pcie *pcie,
}
 }
 
+static const char * const fw_err_rec_type_strs[] = {
+   "IPF SAL Error Record",
+   "SOC Firmware Error Record Type1 (Legacy CrashLog Support)",
+   "SOC Firmware Error Record Type2",
+};
+
+static void cper_print_fw_err(const char *pfx,
+ struct acpi_hest_generic_data *gdata,
+ const struct cper_sec_fw_err_rec_ref *fw_err)
+{
+   void *buf = acpi_hest_get_payload(gdata);
+   u32 offset, length = gdata->error_data_length;
+
+   printk("%s""Firmware Error Record Type: %s\n", pfx,
+  fw_err->record_type < ARRAY_SIZE(fw_err_rec_type_strs) ?
+  fw_err_rec_type_strs[fw_err->record_type] : "unknown");
+   printk("%s""Revision: %d\n", pfx, fw_err->revision);
+
+   /* Record Type based on UEFI 2.7 */
+   if (fw_err->revision == 0) {
+   printk("%s""Record Identifier: %08llx\n", pfx,
+  fw_err->record_identifier);
+   } else if (fw_err->revision == 2) {
+   printk("%s""Record Identifier: %pUl\n", pfx,
+  _err->record_identifier_guid);
+   }
+
+   /*
+* The FW error record may contain trailing data beyond the
+* structure defined by the specification. As the fields
+* defined (and hence the offset of any trailing data) vary
+* with the revision, set the offset to account for this
+* variation.
+*/
+   if (fw_err->revision == 0) {
+   /* record_identifier_guid not defined */
+   offset = offsetof(struct cper_sec_fw_err_rec_ref,
+ record_identifier_guid);
+   } else if (fw_err->revision == 1) {
+   /* record_identifier not defined */
+   offset = offsetof(struct cper_sec_fw_err_rec_ref,
+ record_identifier);
+   } else {
+   offset = sizeof(*fw_err);
+   }
+
+   buf += offset;
+   length -= offset;
+
+   print_hex_dump(pfx, "", DUMP_PREFIX_OFFSET, 16, 4, buf, length, true);
+}
+
 static void cper_print_tstamp(const char *pfx,
   struct acpi_hest_generic_data_v300 *gdata)
 {
@@ -494,6 +546,16 @@ cper_estatus_print_section(const char *pfx, struct 
acpi_hest_generic_data *gdata
else
goto err_section_too_small;
 #endif
+   } else if (guid_equal(sec_type, _SEC_FW_ERR_REC_REF)) {
+   struct cper_sec_fw_err_rec_ref *fw_err = 
acpi_hest_get_payload(gdata);
+
+   printk("%ssection_type: Firmware Error Record Reference\n",
+  newpfx);
+   /* The minimal FW Error Record contains 16 bytes */
+   if (gdata->error_data_length >= SZ_16)
+   cper_print_fw_err(newpfx, gdata, fw_err);
+   else
+   goto err_section_too_small;
} else {
const void *err = acpi_hest_get_payload(gdata);
 
diff --git a/include/linux/cper.h b/include/linux/cper.h
index 4f005d95ce88..8537e9282a65 100644
--- a/include/linux/cper.h
+++ 

[PATCH 1/7] efi/libstub: Avoid returning uninitialized data from setup_graphics()

2020-05-17 Thread Ard Biesheuvel
From: Heinrich Schuchardt 

Currently, setup_graphics() ignores the return value of efi_setup_gop(). As
AllocatePool() does not zero out memory, the screen information table will
contain uninitialized data in this case.

We should free the screen information table if efi_setup_gop() returns an
error code.

Signed-off-by: Heinrich Schuchardt 
Link: https://lore.kernel.org/r/20200426194946.112768-1-xypron.g...@gmx.de
Signed-off-by: Ard Biesheuvel 
---
 drivers/firmware/efi/libstub/arm-stub.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/arm-stub.c 
b/drivers/firmware/efi/libstub/arm-stub.c
index 99a5cde7c2d8..48161b1dd098 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -60,7 +60,11 @@ static struct screen_info *setup_graphics(void)
si = alloc_screen_info();
if (!si)
return NULL;
-   efi_setup_gop(si, _proto, size);
+   status = efi_setup_gop(si, _proto, size);
+   if (status != EFI_SUCCESS) {
+   free_screen_info(si);
+   return NULL;
+   }
}
return si;
 }
-- 
2.17.1



[PATCH 3/7] efi/libstub/x86: Avoid EFI map buffer alloc in allocate_e820()

2020-05-17 Thread Ard Biesheuvel
From: Lenny Szubowicz 

In allocate_e820(), call the EFI get_memory_map() service directly
instead of indirectly via efi_get_memory_map(). This avoids allocation
of a buffer and return of the full EFI memory map, which is not needed
here and would otherwise need to be freed.

Routine allocate_e820() only needs to know how many EFI memory
descriptors there are in the map to allocate an adequately sized
e820ext buffer, if it's needed. Note that since efi_get_memory_map()
returns a memory map buffer sized with extra headroom, allocate_e820()
now needs to explicitly factor that into the e820ext size calculation.

Signed-off-by: Lenny Szubowicz 
Suggested-by: Ard Biesheuvel 
Signed-off-by: Ard Biesheuvel 
---
 drivers/firmware/efi/libstub/efistub.h  | 13 +
 drivers/firmware/efi/libstub/mem.c  |  2 --
 drivers/firmware/efi/libstub/x86-stub.c | 24 +---
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/drivers/firmware/efi/libstub/efistub.h 
b/drivers/firmware/efi/libstub/efistub.h
index 67d26949fd26..62943992f02f 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -92,6 +92,19 @@ extern __pure efi_system_table_t  *efi_system_table(void);
 #define EFI_LOCATE_BY_REGISTER_NOTIFY  1
 #define EFI_LOCATE_BY_PROTOCOL 2
 
+/*
+ * An efi_boot_memmap is used by efi_get_memory_map() to return the
+ * EFI memory map in a dynamically allocated buffer.
+ *
+ * The buffer allocated for the EFI memory map includes extra room for
+ * a minimum of EFI_MMAP_NR_SLACK_SLOTS additional EFI memory descriptors.
+ * This facilitates the reuse of the EFI memory map buffer when a second
+ * call to ExitBootServices() is needed because of intervening changes to
+ * the EFI memory map. Other related structures, e.g. x86 e820ext, need
+ * to factor in this headroom requirement as well.
+ */
+#define EFI_MMAP_NR_SLACK_SLOTS8
+
 struct efi_boot_memmap {
efi_memory_desc_t   **map;
unsigned long   *map_size;
diff --git a/drivers/firmware/efi/libstub/mem.c 
b/drivers/firmware/efi/libstub/mem.c
index 869a79c8946f..09f4fa01914e 100644
--- a/drivers/firmware/efi/libstub/mem.c
+++ b/drivers/firmware/efi/libstub/mem.c
@@ -5,8 +5,6 @@
 
 #include "efistub.h"
 
-#define EFI_MMAP_NR_SLACK_SLOTS8
-
 static inline bool mmap_has_headroom(unsigned long buff_size,
 unsigned long map_size,
 unsigned long desc_size)
diff --git a/drivers/firmware/efi/libstub/x86-stub.c 
b/drivers/firmware/efi/libstub/x86-stub.c
index 05ccb229fb45..f0339b5d3658 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -606,24 +606,18 @@ static efi_status_t allocate_e820(struct boot_params 
*params,
  struct setup_data **e820ext,
  u32 *e820ext_size)
 {
-   unsigned long map_size, desc_size, buff_size;
-   struct efi_boot_memmap boot_map;
-   efi_memory_desc_t *map;
+   unsigned long map_size, desc_size, map_key;
efi_status_t status;
-   __u32 nr_desc;
+   __u32 nr_desc, desc_version;
 
-   boot_map.map= 
-   boot_map.map_size   = _size;
-   boot_map.desc_size  = _size;
-   boot_map.desc_ver   = NULL;
-   boot_map.key_ptr= NULL;
-   boot_map.buff_size  = _size;
+   /* Only need the size of the mem map and size of each mem descriptor */
+   map_size = 0;
+   status = efi_bs_call(get_memory_map, _size, NULL, _key,
+_size, _version);
+   if (status != EFI_BUFFER_TOO_SMALL)
+   return (status != EFI_SUCCESS) ? status : EFI_UNSUPPORTED;
 
-   status = efi_get_memory_map(_map);
-   if (status != EFI_SUCCESS)
-   return status;
-
-   nr_desc = buff_size / desc_size;
+   nr_desc = map_size / desc_size + EFI_MMAP_NR_SLACK_SLOTS;
 
if (nr_desc > ARRAY_SIZE(params->e820_table)) {
u32 nr_e820ext = nr_desc - ARRAY_SIZE(params->e820_table);
-- 
2.17.1



[GIT PULL 0/7] EFI fixes for v5.7

2020-05-17 Thread Ard Biesheuvel
The following changes since commit a088b858f16af85e3db359b6c6aaa92dd3bc0921:

  efi/x86: Revert struct layout change to fix kexec boot regression (2020-04-14 
08:32:17 +0200)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-urgent

for you to fetch changes up to b4f1874c62168159fdb419ced4afc77c1b51c475:

  tpm: check event log version before reading final events (2020-05-17 11:46:50 
+0200)


EFI fixes for v5.7-rcX:
- fix EFI framebuffer earlycon for wide fonts
- avoid filling screen_info with garbage if the EFI framebuffer is not
  available
- fix a potential host tool build error due to a symbol clash on x86
- work around a EFI firmware bug regarding the binary format of the TPM
  final events table
- fix a missing memory free by reworking the E820 table sizing routine to
  not do the allocation in the first place
- add CPER parsing for firmware errors


Arvind Sankar (1):
  x86/boot: Mark global variables as static

Benjamin Thiel (1):
  efi: Pull up arch-specific prototype efi_systab_show_arch()

Dave Young (1):
  efi/earlycon: Fix early printk for wider fonts

Heinrich Schuchardt (1):
  efi/libstub: Avoid returning uninitialized data from setup_graphics()

Lenny Szubowicz (1):
  efi/libstub/x86: Avoid EFI map buffer alloc in allocate_e820()

Loïc Yhuel (1):
  tpm: check event log version before reading final events

Punit Agrawal (1):
  efi: cper: Add support for printing Firmware Error Record Reference

 arch/x86/boot/tools/build.c | 16 -
 drivers/firmware/efi/cper.c | 62 +
 drivers/firmware/efi/earlycon.c | 14 
 drivers/firmware/efi/efi.c  |  5 +--
 drivers/firmware/efi/libstub/arm-stub.c |  6 +++-
 drivers/firmware/efi/libstub/efistub.h  | 13 +++
 drivers/firmware/efi/libstub/mem.c  |  2 --
 drivers/firmware/efi/libstub/tpm.c  |  5 +--
 drivers/firmware/efi/libstub/x86-stub.c | 24 +
 drivers/firmware/efi/tpm.c  |  5 ++-
 include/linux/cper.h|  9 +
 include/linux/efi.h |  2 ++
 12 files changed, 124 insertions(+), 39 deletions(-)


[PATCH 6/7] efi: Pull up arch-specific prototype efi_systab_show_arch()

2020-05-17 Thread Ard Biesheuvel
From: Benjamin Thiel 

Pull up arch-specific prototype efi_systab_show_arch() in order to
fix a -Wmissing-prototypes warning:

arch/x86/platform/efi/efi.c:957:7: warning: no previous prototype for
‘efi_systab_show_arch’ [-Wmissing-prototypes]
char *efi_systab_show_arch(char *str)

Signed-off-by: Benjamin Thiel 
Link: https://lore.kernel.org/r/20200516132647.14568-1-b.th...@posteo.de
Signed-off-by: Ard Biesheuvel 
---
 drivers/firmware/efi/efi.c | 5 +
 include/linux/efi.h| 2 ++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 911a2bd0f6b7..4e3055238f31 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -130,11 +130,8 @@ static ssize_t systab_show(struct kobject *kobj,
if (efi.smbios != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "SMBIOS=0x%lx\n", efi.smbios);
 
-   if (IS_ENABLED(CONFIG_IA64) || IS_ENABLED(CONFIG_X86)) {
-   extern char *efi_systab_show_arch(char *str);
-
+   if (IS_ENABLED(CONFIG_IA64) || IS_ENABLED(CONFIG_X86))
str = efi_systab_show_arch(str);
-   }
 
return str - buf;
 }
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 251f1f783cdf..9430d01c0c3d 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1245,4 +1245,6 @@ struct linux_efi_memreserve {
 
 void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size);
 
+char *efi_systab_show_arch(char *str);
+
 #endif /* _LINUX_EFI_H */
-- 
2.17.1



[PATCH 7/7] tpm: check event log version before reading final events

2020-05-17 Thread Ard Biesheuvel
From: Loic Yhuel 

This fixes the boot issues since 5.3 on several Dell models when the TPM
is enabled. Depending on the exact grub binary, booting the kernel would
freeze early, or just report an error parsing the final events log.

We get an event log in the SHA-1 format, which doesn't have a
tcg_efi_specid_event_head in the first event, and there is a final events
table which doesn't match the crypto agile format.
__calc_tpm2_event_size reads bad "count" and "efispecid->num_algs", and
either fails, or loops long enough for the machine to be appear frozen.

So we now only parse the final events table, which is per the spec always
supposed to be in the crypto agile format, when we got a event log in this
format.

Fixes: c46f3405692de ("tpm: Reserve the TPM final events table")
Fixes: 166a2809d65b2 ("tpm: Don't duplicate events from the final event log in 
the TCG2 log")
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1779611
Signed-off-by: Loïc Yhuel 
Link: https://lore.kernel.org/r/20200512040113.277768-1-loic.yh...@gmail.com
Reviewed-by: Javier Martinez Canillas 
Reviewed-by: Jerry Snitselaar 
Reviewed-by: Matthew Garrett 
[ardb: warn when final events table is missing or in the wrong format]
Signed-off-by: Ard Biesheuvel 
---
 drivers/firmware/efi/libstub/tpm.c | 5 +++--
 drivers/firmware/efi/tpm.c | 5 -
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/efi/libstub/tpm.c 
b/drivers/firmware/efi/libstub/tpm.c
index 1d59e103a2e3..e9a684637b70 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -54,7 +54,7 @@ void efi_retrieve_tpm2_eventlog(void)
efi_status_t status;
efi_physical_addr_t log_location = 0, log_last_entry = 0;
struct linux_efi_tpm_eventlog *log_tbl = NULL;
-   struct efi_tcg2_final_events_table *final_events_table;
+   struct efi_tcg2_final_events_table *final_events_table = NULL;
unsigned long first_entry_addr, last_entry_addr;
size_t log_size, last_entry_size;
efi_bool_t truncated;
@@ -127,7 +127,8 @@ void efi_retrieve_tpm2_eventlog(void)
 * Figure out whether any events have already been logged to the
 * final events structure, and if so how much space they take up
 */
-   final_events_table = get_efi_config_table(LINUX_EFI_TPM_FINAL_LOG_GUID);
+   if (version == EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)
+   final_events_table = 
get_efi_config_table(LINUX_EFI_TPM_FINAL_LOG_GUID);
if (final_events_table && final_events_table->nr_events) {
struct tcg_pcr_event2_head *header;
int offset;
diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
index 31f9f0e369b9..0543fbf60222 100644
--- a/drivers/firmware/efi/tpm.c
+++ b/drivers/firmware/efi/tpm.c
@@ -62,8 +62,11 @@ int __init efi_tpm_eventlog_init(void)
tbl_size = sizeof(*log_tbl) + log_tbl->size;
memblock_reserve(efi.tpm_log, tbl_size);
 
-   if (efi.tpm_final_log == EFI_INVALID_TABLE_ADDR)
+   if (efi.tpm_final_log == EFI_INVALID_TABLE_ADDR ||
+   log_tbl->version != EFI_TCG2_EVENT_LOG_FORMAT_TCG_2) {
+   pr_warn(FW_BUG "TPM Final Events table missing or invalid\n");
goto out;
+   }
 
final_tbl = early_memremap(efi.tpm_final_log, sizeof(*final_tbl));
 
-- 
2.17.1



[PATCH 2/7] efi/earlycon: Fix early printk for wider fonts

2020-05-17 Thread Ard Biesheuvel
From: Dave Young 

When I play with terminus fonts I noticed the efi early printk does
not work because the earlycon code assumes font width is 8.

Here add the code to adapt with larger fonts.  Tested with all kinds
of kernel built-in fonts on my laptop. Also tested with a local draft
patch for 14x28 !bold terminus font.

Signed-off-by: Dave Young 
Link: https://lore.kernel.org/r/20200412024927.ga6...@dhcp-128-65.nay.redhat.com
Signed-off-by: Ard Biesheuvel 
---
 drivers/firmware/efi/earlycon.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c
index 5d4f84781aa0..a52236e11e5f 100644
--- a/drivers/firmware/efi/earlycon.c
+++ b/drivers/firmware/efi/earlycon.c
@@ -114,14 +114,16 @@ static void efi_earlycon_write_char(u32 *dst, unsigned 
char c, unsigned int h)
const u32 color_black = 0x;
const u32 color_white = 0x00ff;
const u8 *src;
-   u8 s8;
-   int m;
+   int m, n, bytes;
+   u8 x;
 
-   src = font->data + c * font->height;
-   s8 = *(src + h);
+   bytes = BITS_TO_BYTES(font->width);
+   src = font->data + c * font->height * bytes + h * bytes;
 
-   for (m = 0; m < 8; m++) {
-   if ((s8 >> (7 - m)) & 1)
+   for (m = 0; m < font->width; m++) {
+   n = m % 8;
+   x = *(src + m / 8);
+   if ((x >> (7 - n)) & 1)
*dst = color_white;
else
*dst = color_black;
-- 
2.17.1



Re: [PATCH 2/3] sdhci: sparx5: Add Sparx5 SoC eMMC driver

2020-05-17 Thread Adrian Hunter
On 13/05/20 4:31 pm, Lars Povlsen wrote:
> This adds the eMMC driver for the Sparx5 SoC. It is based upon the
> designware IP, but requires some extra initialization and quirks.
> 
> Reviewed-by: Alexandre Belloni 
> Signed-off-by: Lars Povlsen 
> ---
>  drivers/mmc/host/Kconfig   |  13 ++
>  drivers/mmc/host/Makefile  |   1 +
>  drivers/mmc/host/sdhci-of-sparx5.c | 348 +
>  3 files changed, 362 insertions(+)
>  create mode 100644 drivers/mmc/host/sdhci-of-sparx5.c
> 
> diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
> index 462b5352fea75..1e8396d09df75 100644
> --- a/drivers/mmc/host/Kconfig
> +++ b/drivers/mmc/host/Kconfig
> @@ -213,6 +213,19 @@ config MMC_SDHCI_OF_DWCMSHC
> If you have a controller with this interface, say Y or M here.
> If unsure, say N.
> 
> +config MMC_SDHCI_OF_SPARX5
> + tristate "SDHCI OF support for the MCHP Sparx5 SoC"
> + depends on MMC_SDHCI_PLTFM
> + depends on ARCH_SPARX5
> + select MMC_SDHCI_IO_ACCESSORS
> + help
> +   This selects the Secure Digital Host Controller Interface (SDHCI)
> +   found in the MCHP Sparx5 SoC.
> +
> +   If you have a Sparx5 SoC with this interface, say Y or M here.
> +
> +   If unsure, say N.
> +
>  config MMC_SDHCI_CADENCE
>   tristate "SDHCI support for the Cadence SD/SDIO/eMMC controller"
>   depends on MMC_SDHCI_PLTFM
> diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
> index b929ef9412083..9f09b7ffaaa16 100644
> --- a/drivers/mmc/host/Makefile
> +++ b/drivers/mmc/host/Makefile
> @@ -89,6 +89,7 @@ obj-$(CONFIG_MMC_SDHCI_OF_ARASAN)   += sdhci-of-arasan.o
>  obj-$(CONFIG_MMC_SDHCI_OF_ASPEED)+= sdhci-of-aspeed.o
>  obj-$(CONFIG_MMC_SDHCI_OF_AT91)  += sdhci-of-at91.o
>  obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o
> +obj-$(CONFIG_MMC_SDHCI_OF_SPARX5)+= sdhci-of-sparx5.o
>  obj-$(CONFIG_MMC_SDHCI_OF_HLWD)  += sdhci-of-hlwd.o
>  obj-$(CONFIG_MMC_SDHCI_OF_DWCMSHC)   += sdhci-of-dwcmshc.o
>  obj-$(CONFIG_MMC_SDHCI_BCM_KONA) += sdhci-bcm-kona.o
> diff --git a/drivers/mmc/host/sdhci-of-sparx5.c 
> b/drivers/mmc/host/sdhci-of-sparx5.c
> new file mode 100644
> index 0..8253bf80e175a
> --- /dev/null
> +++ b/drivers/mmc/host/sdhci-of-sparx5.c
> @@ -0,0 +1,348 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * drivers/mmc/host/sdhci-of-sparx5.c
> + *
> + * MCHP Sparx5 SoC Secure Digital Host Controller Interface.
> + *
> + * Copyright (c) 2019 Microchip Inc.
> + *
> + * Author: Lars Povlsen 
> + */
> +
> +//#define DEBUG
> +//#define TRACE_REGISTER

No commented out code please.

> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "sdhci-pltfm.h"
> +
> +#define CPU_REGS_GENERAL_CTRL(0x22 * 4)
> +#define  MSHC_DLY_CC_MASKGENMASK(16, 13)
> +#define  MSHC_DLY_CC_SHIFT   13
> +#define  MSHC_DLY_CC_MAX 15
> +
> +#define CPU_REGS_PROC_CTRL   (0x2C * 4)
> +#define  ACP_CACHE_FORCE_ENA BIT(4)
> +#define  ACP_AWCACHE BIT(3)
> +#define  ACP_ARCACHE BIT(2)
> +#define  ACP_CACHE_MASK  
> (ACP_CACHE_FORCE_ENA|ACP_AWCACHE|ACP_ARCACHE)
> +
> +#define MSHC2_VERSION0x500   /* Off 0x140, reg 0x0 */
> +#define MSHC2_TYPE   0x504   /* Off 0x140, reg 0x1 */
> +#define MSHC2_EMMC_CTRL  0x52c   /* Off 0x140, reg 0xB */
> +#define  MSHC2_EMMC_CTRL_EMMC_RST_N  BIT(2)
> +#define  MSHC2_EMMC_CTRL_IS_EMMC BIT(0)
> +
> +struct sdhci_sparx5_data {
> + struct sdhci_host *host;
> + struct regmap *cpu_ctrl;
> + int delay_clock;
> + struct device_attribute dev_delay_clock;
> +};
> +
> +#define BOUNDARY_OK(addr, len) \
> + ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1)))
> +
> +#if defined(TRACE_REGISTER)

If you want this then add a Kconfig entry for it

> +static void sdhci_sparx5_writel(struct sdhci_host *host, u32 val, int reg)
> +{
> + pr_debug("$$$ writel(0x%08x, 0x%02x)\n", val, reg);
> + writel(val, host->ioaddr + reg);
> +}
> +
> +static void sdhci_sparx5_writew(struct sdhci_host *host, u16 val, int reg)
> +{
> + pr_debug("$$$ writew(0x%04x, 0x%02x)\n", val, reg);
> + writew(val, host->ioaddr + reg);
> +}
> +
> +static void sdhci_sparx5_writeb(struct sdhci_host *host, u8 val, int reg)
> +{
> + pr_debug("$$$ writeb(0x%02x, 0x%02x)\n", val, reg);
> + writeb(val, host->ioaddr + reg);
> +}
> +#endif
> +
> +/*
> + * If DMA addr spans 128MB boundary, we split the DMA transfer into two
> + * so that each DMA transfer doesn't exceed the boundary.
> + */
> +static void sdhci_sparx5_adma_write_desc(struct sdhci_host *host, void 
> **desc,
> +   dma_addr_t addr, int len,
> +   unsigned int cmd)
> +{
> + int tmplen, offset;
> +
> + pr_debug("write_desc: cmd %02x: len %d, offset 0x%0llx\n",

RE: [PATCH 09/29] kbuild: disallow multi-word in M= or KBUILD_EXTMOD

2020-05-17 Thread David Laight
From: Masahiro Yamada
> Sent: 17 May 2020 10:49
> $(firstword ...) in scripts/Makefile.modpost was added by commit
> 3f3fd3c05585 ("[PATCH] kbuild: allow multi-word $M in Makefile.modpost")
> to build multiple external module directories.
> 
> This feature has been broken for a while. Remove the bitrotten code, and
> stop parsing if M or KBUILD_EXTMOD contains multiple words.

ISTR that one of the kernel documentation files says that it is possible
to build multiple modules together in order to avoid 'faffing' with
exported symbol lists.

So the docs need updating to match.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)



Re: [PATCH 05/12] gpu/drm: Ingenic: Fix opaque pointer casted to wrong type

2020-05-17 Thread Paul Cercueil

Hi Sam,

Le dim. 17 mai 2020 à 8:21, Sam Ravnborg  a écrit :

On Sat, May 16, 2020 at 11:50:50PM +0200, Paul Cercueil wrote:

 The opaque pointer passed to the IRQ handler is a pointer to the
 drm_device, not a pointer to our ingenic_drm structure.

 It still worked, because our ingenic_drm structure contains the
 drm_device as its first field, so the pointer received had the same
 value, but this was not semantically correct.

 Cc: sta...@vger.kernel.org # v5.3
 Fixes: 90b86fcc47b4 ("DRM: Add KMS driver for the Ingenic JZ47xx 
SoCs")

 Signed-off-by: Paul Cercueil 

Acked-by: Sam Ravnborg 


Pushed to drm-misc-fixes, thanks for the review.

-Paul


 ---
  drivers/gpu/drm/ingenic/ingenic-drm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c 
b/drivers/gpu/drm/ingenic/ingenic-drm.c

 index 0c472382a08b..97244462599b 100644
 --- a/drivers/gpu/drm/ingenic/ingenic-drm.c
 +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
 @@ -476,7 +476,7 @@ static int 
ingenic_drm_encoder_atomic_check(struct drm_encoder *encoder,


  static irqreturn_t ingenic_drm_irq_handler(int irq, void *arg)
  {
 -  struct ingenic_drm *priv = arg;
 +  struct ingenic_drm *priv = drm_device_get_priv(arg);
unsigned int state;

regmap_read(priv->map, JZ_REG_LCD_STATE, );
 --
 2.26.2

 ___
 dri-devel mailing list
 dri-de...@lists.freedesktop.org
 https://lists.freedesktop.org/mailman/listinfo/dri-devel





Re: [PATCH 04/12] gpu/drm: ingenic: Fix bogus crtc_atomic_check callback

2020-05-17 Thread Paul Cercueil

Hi Sam,

Le dim. 17 mai 2020 à 8:17, Sam Ravnborg  a écrit :

On Sat, May 16, 2020 at 11:50:49PM +0200, Paul Cercueil wrote:
 The code was comparing the SoC's maximum height with the mode's 
width,

 and vice-versa. D'oh.

 Cc: sta...@vger.kernel.org # v5.6
 Fixes: a7c909b7c037 ("gpu/drm: ingenic: Check for display size in 
CRTC atomic check")

 Signed-off-by: Paul Cercueil 


Looks correct.
Acked-by: Sam Ravnborg 


Pushed to drm-misc-fixes, thanks for the review.

-Paul


 ---

 Notes:
 This patch was previously sent standalone.
 I marked it as superseded in patchwork.
 Nothing has been changed here.

  drivers/gpu/drm/ingenic/ingenic-drm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c 
b/drivers/gpu/drm/ingenic/ingenic-drm.c

 index 632d72177123..0c472382a08b 100644
 --- a/drivers/gpu/drm/ingenic/ingenic-drm.c
 +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
 @@ -330,8 +330,8 @@ static int ingenic_drm_crtc_atomic_check(struct 
drm_crtc *crtc,

if (!drm_atomic_crtc_needs_modeset(state))
return 0;

 -  if (state->mode.hdisplay > priv->soc_info->max_height ||
 -  state->mode.vdisplay > priv->soc_info->max_width)
 +  if (state->mode.hdisplay > priv->soc_info->max_width ||
 +  state->mode.vdisplay > priv->soc_info->max_height)
return -EINVAL;

rate = clk_round_rate(priv->pix_clk,
 --
 2.26.2

 ___
 dri-devel mailing list
 dri-de...@lists.freedesktop.org
 https://lists.freedesktop.org/mailman/listinfo/dri-devel





[PATCH 2/3] arm64: dts: qcom: Add initial sm6125 SoC support

2020-05-17 Thread Eli Riggs
Initial support for SM6125 SoC. CPUs, fixed clocks,
interrupt controller, and UART.

This DTSI is ported from the forked vendor version from
XiaoMi which can be found at [0]. It seems internally
this board is referred to as "Trinket".

Since GCC isn't upstreamed yet, we use dummy clocks for GENI.

[0]: 
https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/willow-p-oss/arch/arm64/boot/dts/qcom/trinket.dtsi

Signed-off-by: Eli Riggs 
---
 arch/arm64/boot/dts/qcom/sm6125.dtsi | 201 +++
 1 file changed, 201 insertions(+)
 create mode 100644 arch/arm64/boot/dts/qcom/sm6125.dtsi

diff --git a/arch/arm64/boot/dts/qcom/sm6125.dtsi 
b/arch/arm64/boot/dts/qcom/sm6125.dtsi
new file mode 100644
index 0..4931402d20c9d
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sm6125.dtsi
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+// Copyright (C) 2019 XiaoMi, Inc.
+// Copyright (C) 2020 Eli Riggs 
+
+#include 
+
+/ {
+   interrupt-parent = <>;
+
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   chosen { };
+
+   clocks {
+   xo_board: xo-board {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <1920>;
+   clock-output-names = "xo_board";
+   };
+   sleep-clk {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <32000>;
+   clock-output-names = "sleep_clk";
+   };
+   };
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+   CPU0: cpu@100 {
+   device_type = "cpu";
+   compatible = "qcom,kryo260";
+   reg = <0x0 0x100>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1638>;
+   d-cache-size = <0x1>;
+   i-cache-size = <0x1>;
+   };
+   CPU1: cpu@101 {
+   device_type = "cpu";
+   compatible = "qcom,kryo260";
+   reg = <0x0 0x101>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1638>;
+   d-cache-size = <0x1>;
+   i-cache-size = <0x1>;
+   };
+   CPU2: cpu@102 {
+   device_type = "cpu";
+   compatible = "qcom,kryo260";
+   reg = <0x0 0x102>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1638>;
+   d-cache-size = <0x1>;
+   i-cache-size = <0x1>;
+   };
+   CPU3: cpu@103 {
+   device_type = "cpu";
+   compatible = "qcom,kryo260";
+   reg = <0x0 0x103>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1638>;
+   d-cache-size = <0x1>;
+   i-cache-size = <0x1>;
+   };
+   CPU4: cpu@0 {
+   device_type = "cpu";
+   compatible = "qcom,kryo260";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1024>;
+   d-cache-size = <0x8000>;
+   i-cache-size = <0x8000>;
+   };
+   CPU5: cpu@1 {
+   device_type = "cpu";
+   compatible = "qcom,kryo260";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1024>;
+   d-cache-size = <0x8000>;
+   i-cache-size = <0x8000>;
+   };
+   CPU6: cpu@2 {
+   device_type = "cpu";
+   compatible = "qcom,kryo260";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1024>;
+   d-cache-size = <0x8000>;
+   i-cache-size = <0x8000>;
+   };
+   CPU7: cpu@3 {
+   device_type = "cpu";
+   compatible = "qcom,kryo260";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1024>;
+   d-cache-size = <0x8000>;
+   i-cache-size = <0x8000>;
+   };
+   cpu-map {
+   cluster0 {
+   core0 

[PATCH 1/3] dt-bindings: arm: qcom: Add sm6125 SoC and xiaomi,willow

2020-05-17 Thread Eli Riggs
Add compatibles for SM6125 aka SDM665 aka Snapdragon 665, as well
as xiaomi,willow aka Xiaomi Redmi Note 8T, the international
edition of the Note 8.

Signed-off-by: Eli Riggs 
---
 Documentation/devicetree/bindings/arm/qcom.yaml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/qcom.yaml 
b/Documentation/devicetree/bindings/arm/qcom.yaml
index 64ddae3bd39fd..4142e38a353ef 100644
--- a/Documentation/devicetree/bindings/arm/qcom.yaml
+++ b/Documentation/devicetree/bindings/arm/qcom.yaml
@@ -38,6 +38,7 @@ description: |
 msm8996
 sc7180
 sdm845
+sm6125
 
   The 'board' element must be one of the following strings:
 
@@ -158,4 +159,9 @@ properties:
   - qcom,ipq6018-cp01-c1
   - const: qcom,ipq6018
 
+  - items:
+  - enum:
+  - xiaomi,willow
+  - const: qcom,sm6125
+
 ...
-- 
2.20.1



[PATCH 3/3] arm64: dts: qcom: Add initial support for Xiaomi Redmi Note 8T

2020-05-17 Thread Eli Riggs
Adds initial device tree for Xiaomi Redmi Note 8T, codename xiaomi-willow.
It uses the sm6125 SoC. Currently only boots into initrd shell over UART.
Requires appended DTB with qcom,board-id = <0x22 0x0> and
qcom,msm-id = <0x18a 0x1> to actually boot.

Signed-off-by: Eli Riggs 
---
 arch/arm64/boot/dts/qcom/Makefile |  1 +
 .../boot/dts/qcom/sm6125-xiaomi-willow.dts| 19 +++
 2 files changed, 20 insertions(+)
 create mode 100644 arch/arm64/boot/dts/qcom/sm6125-xiaomi-willow.dts

diff --git a/arch/arm64/boot/dts/qcom/Makefile 
b/arch/arm64/boot/dts/qcom/Makefile
index cc103f7020fd6..060aa98200e47 100644
--- a/arch/arm64/boot/dts/qcom/Makefile
+++ b/arch/arm64/boot/dts/qcom/Makefile
@@ -22,6 +22,7 @@ dtb-$(CONFIG_ARCH_QCOM)   += sdm845-cheza-r3.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= sdm845-db845c.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= sdm845-mtp.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= sdm850-lenovo-yoga-c630.dtb
+dtb-$(CONFIG_ARCH_QCOM)+= sm6125-xiaomi-willow.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= sm8150-mtp.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= sm8250-mtp.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= qcs404-evb-1000.dtb
diff --git a/arch/arm64/boot/dts/qcom/sm6125-xiaomi-willow.dts 
b/arch/arm64/boot/dts/qcom/sm6125-xiaomi-willow.dts
new file mode 100644
index 0..444b32ccb9d48
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sm6125-xiaomi-willow.dts
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright (c) 2020, Eli Riggs 
+
+/dts-v1/;
+
+#include "sm6125.dtsi"
+
+/ {
+   model = "Xiaomi Redmi Note 8T";
+   compatible = "xiaomi,willow", "qcom,sm6125";
+
+   aliases {
+   serial0 = _se4_2uart;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+};
-- 
2.20.1



Re: [PATCH] drm/etnaviv: fix perfmon domain interation

2020-05-17 Thread Lucas Stach
Hi Christian,

Am Montag, den 11.05.2020, 14:37 +0200 schrieb Christian Gmeiner:
> The GC860 has one GPU device which has a 2d and 3d core. In this case
> we want to expose perfmon information for both cores.
> 
> The driver has one array which contains all possible perfmon domains
> with some meta data - doms_meta. Here we can see that for the GC860
> two elements of that array are relevant:
> 
>   doms_3d: is at index 0 in the doms_meta array with 8 perfmon domains
>   doms_2d: is at index 1 in the doms_meta array with 1 perfmon domain
> 
> The userspace driver wants to get a list of all perfmon domains and
> their perfmon signals. This is done by iterating over all domains and
> their signals. If the userspace driver wants to access the domain with
> id 8 the kernel driver fails and returns invalid data from doms_3d with
> and invalid offset.
> 
> This results in:
>   Unable to handle kernel paging request at virtual address 
> 
> On such a device it is not possible to use the userspace driver at all.
> 
> The fix for this off-by-one error is quite simple.
> 
> Reported-by: Paul Cercueil 
> Tested-by: Paul Cercueil 
> Fixes: ed1dd899baa3 ("drm/etnaviv: rework perfmon query infrastructure")
> Cc: sta...@vger.kernel.or

Missing last letter of the TLD.

> Signed-off-by: Christian Gmeiner 
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
> index e6795bafcbb9..35f7171e779a 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
> @@ -453,7 +453,7 @@ static const struct etnaviv_pm_domain *pm_domain(const 
> struct etnaviv_gpu *gpu,
>   if (!(gpu->identity.features & meta->feature))
>   continue;
>  
> - if (meta->nr_domains < (index - offset)) {
> + if ((meta->nr_domains - 1) < (index - offset)) {

While the logic is correct, I find this quite hard to read. A more
idiomatic way to write this (which is much easier to grok when reading
the code IMHO) would be:

if (index - offset >= meta->nr_domains)

If you agree, please send a v2 of this patch.

Regards,
Lucas
>   offset += meta->nr_domains;
>   continue;
>   }



[PATCH] block: Remove unused flush_queue_delayed in struct blk_flush_queue

2020-05-17 Thread Baolin Wang
The flush_queue_delayed was introdued to hold queue if flush is
running for non-queueable flush drive by commit 3ac0cc450870
("hold queue if flush is running for non-queueable flush drive"),
but the non mq parts of the flush code had been removed by
commit 7e992f847a08 ("block: remove non mq parts from the flush code"),
as well as removing the usage of the flush_queue_delayed flag.
Thus remove the unused flush_queue_delayed flag.

Signed-off-by: Baolin Wang 
---
 block/blk-flush.c | 1 -
 block/blk.h   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index c7f396e3d5e2..b733f7ac75c7 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -258,7 +258,6 @@ static void flush_end_io(struct request *flush_rq, 
blk_status_t error)
blk_flush_complete_seq(rq, fq, seq, error);
}
 
-   fq->flush_queue_delayed = 0;
spin_unlock_irqrestore(>mq_flush_lock, flags);
 }
 
diff --git a/block/blk.h b/block/blk.h
index fc00537026a0..6cab33a11f90 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -19,7 +19,6 @@ extern struct dentry *blk_debugfs_root;
 #endif
 
 struct blk_flush_queue {
-   unsigned intflush_queue_delayed:1;
unsigned intflush_pending_idx:1;
unsigned intflush_running_idx:1;
blk_status_trq_status;
-- 
2.17.1



[rcu:tglx.2020.05.05a 105/140] arch/x86/kernel/traps.c:819:24: error: 'tsk' undeclared

2020-05-17 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git 
tglx.2020.05.05a
head:   e6d36eed49b863bbe393e3c07cae737cd9c475e3
commit: ca303aa341bab5cdb3a3b41391ff262e252cd3f3 [105/140] x86/traps: 
Restructure #DB handling
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
git checkout ca303aa341bab5cdb3a3b41391ff262e252cd3f3
# save the attached .config to linux build tree
make ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot 

Note: the rcu/tglx.2020.05.05a HEAD e6d36eed49b863bbe393e3c07cae737cd9c475e3 
builds fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>, old ones prefixed by <<):

arch/x86/kernel/traps.c: In function 'exc_debug_kernel':
>> arch/x86/kernel/traps.c:819:24: error: 'tsk' undeclared (first use in this 
>> function)
clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP);
^~~
arch/x86/kernel/traps.c:819:24: note: each undeclared identifier is reported 
only once for each function it appears in
arch/x86/kernel/traps.c: In function 'exc_debug_user':
arch/x86/kernel/traps.c:842:24: error: 'tsk' undeclared (first use in this 
function)
clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP);
^~~

vim +/tsk +819 arch/x86/kernel/traps.c

   809  
   810  static __always_inline void exc_debug_kernel(struct pt_regs *regs,
   811   unsigned long dr6)
   812  {
   813  nmi_enter();
   814  /*
   815   * The SDM says "The processor clears the BTF flag when it
   816   * generates a debug exception."  Clear TIF_BLOCKSTEP to keep
   817   * TIF_BLOCKSTEP in sync with the hardware BTF flag.
   818   */
 > 819  clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP);
   820  
   821  /*
   822   * Catch SYSENTER with TF set and clear DR_STEP. If this hit a
   823   * watchpoint at the same time then that will still be handled.
   824   */
   825  if ((dr6 & DR_STEP) && is_sysenter_singlestep(regs))
   826  dr6 &= ~DR_STEP;
   827  
   828  /*
   829   * If DR6 is zero, no point in trying to handle it. The kernel 
is
   830   * not using INT1.
   831   */
   832  if (dr6)
   833  handle_debug(regs, dr6, false);
   834  
   835  nmi_exit();
   836  }
   837  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[PATCH liburing 4/4] splice/tee/tests: test len=0 splice/tee

2020-05-17 Thread Pavel Begunkov
Check zero-length splice() and tee().

Signed-off-by: Pavel Begunkov 
---
 test/splice.c | 38 --
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/test/splice.c b/test/splice.c
index 119c493..b81aa4b 100644
--- a/test/splice.c
+++ b/test/splice.c
@@ -144,7 +144,7 @@ static int do_splice_op(struct io_uring *ring,
struct io_uring_sqe *sqe;
int ret = -1;
 
-   while (len) {
+   do {
sqe = io_uring_get_sqe(ring);
if (!sqe) {
fprintf(stderr, "get sqe failed\n");
@@ -179,7 +179,7 @@ static int do_splice_op(struct io_uring *ring,
if (off_out != -1)
off_out += cqe->res;
io_uring_cqe_seen(ring, cqe);
-   }
+   } while (len);
 
return 0;
 }
@@ -215,6 +215,21 @@ static void check_tee_support(struct io_uring *ring, 
struct test_ctx *ctx)
has_tee = (ret == -EBADF);
 }
 
+static int check_zero_splice(struct io_uring *ring, struct test_ctx *ctx)
+{
+   int ret;
+
+   ret = do_splice(ring, ctx->fd_in, -1, ctx->pipe1[1], -1, 0);
+   if (ret)
+   return ret;
+
+   ret = do_splice(ring, ctx->pipe2[0], -1, ctx->pipe1[1], -1, 0);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
 static int splice_to_pipe(struct io_uring *ring, struct test_ctx *ctx)
 {
int ret;
@@ -349,11 +364,23 @@ static int check_tee(struct io_uring *ring, struct 
test_ctx *ctx)
return 0;
 }
 
+static int check_zero_tee(struct io_uring *ring, struct test_ctx *ctx)
+{
+   return do_tee(ring, ctx->pipe2[0], ctx->pipe1[1], 0);
+}
+
 static int test_splice(struct io_uring *ring, struct test_ctx *ctx)
 {
int ret;
 
if (has_splice) {
+   ret = check_zero_splice(ring, ctx);
+   if (ret) {
+   fprintf(stderr, "check_zero_splice failed %i %i\n",
+   ret, errno);
+   return ret;
+   }
+
ret = splice_to_pipe(ring, ctx);
if (ret) {
fprintf(stderr, "splice_to_pipe failed %i %i\n",
@@ -384,6 +411,13 @@ static int test_splice(struct io_uring *ring, struct 
test_ctx *ctx)
}
 
if (has_tee) {
+   ret = check_zero_tee(ring, ctx);
+   if (ret) {
+   fprintf(stderr, "check_zero_tee() failed %i %i\n",
+   ret, errno);
+   return ret;
+   }
+
ret = fail_tee_nonpipe(ring, ctx);
if (ret) {
fprintf(stderr, "fail_tee_nonpipe() failed %i %i\n",
-- 
2.24.0



[PATCH liburing 3/4] tee/test: add test for tee(2)

2020-05-17 Thread Pavel Begunkov
Add tee() tests with pipe data validation

Signed-off-by: Pavel Begunkov 
---
 test/splice.c | 157 ++
 1 file changed, 133 insertions(+), 24 deletions(-)

diff --git a/test/splice.c b/test/splice.c
index 1c27c8e..119c493 100644
--- a/test/splice.c
+++ b/test/splice.c
@@ -29,6 +29,7 @@ struct test_ctx {
 static unsigned int splice_flags = 0;
 static unsigned int sqe_flags = 0;
 static int has_splice = 0;
+static int has_tee = 0;
 
 static int read_buf(int fd, void *buf, int len)
 {
@@ -133,10 +134,11 @@ static int init_splice_ctx(struct test_ctx *ctx)
return 0;
 }
 
-static int do_splice(struct io_uring *ring,
-  int fd_in, loff_t off_in,
-  int fd_out, loff_t off_out,
-  unsigned int len)
+static int do_splice_op(struct io_uring *ring,
+   int fd_in, loff_t off_in,
+   int fd_out, loff_t off_out,
+   unsigned int len,
+   __u8 opcode)
 {
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
@@ -152,6 +154,7 @@ static int do_splice(struct io_uring *ring,
 len, splice_flags);
sqe->flags |= sqe_flags;
sqe->user_data = 42;
+   sqe->opcode = opcode;
 
ret = io_uring_submit(ring);
if (ret != 1) {
@@ -181,6 +184,21 @@ static int do_splice(struct io_uring *ring,
return 0;
 }
 
+static int do_splice(struct io_uring *ring,
+   int fd_in, loff_t off_in,
+   int fd_out, loff_t off_out,
+   unsigned int len)
+{
+   return do_splice_op(ring, fd_in, off_in, fd_out, off_out, len,
+   IORING_OP_SPLICE);
+}
+
+static int do_tee(struct io_uring *ring, int fd_in, int fd_out, 
+ unsigned int len)
+{
+   return do_splice_op(ring, fd_in, 0, fd_out, 0, len, IORING_OP_TEE);
+}
+
 static void check_splice_support(struct io_uring *ring, struct test_ctx *ctx)
 {
int ret;
@@ -189,6 +207,14 @@ static void check_splice_support(struct io_uring *ring, 
struct test_ctx *ctx)
has_splice = (ret == -EBADF);
 }
 
+static void check_tee_support(struct io_uring *ring, struct test_ctx *ctx)
+{
+   int ret;
+
+   ret = do_tee(ring, -1, -1, BUF_SIZE);
+   has_tee = (ret == -EBADF);
+}
+
 static int splice_to_pipe(struct io_uring *ring, struct test_ctx *ctx)
 {
int ret;
@@ -267,37 +293,119 @@ static int fail_splice_pipe_offset(struct io_uring 
*ring, struct test_ctx *ctx)
return 0;
 }
 
-static int test_splice(struct io_uring *ring, struct test_ctx *ctx)
+static int fail_tee_nonpipe(struct io_uring *ring, struct test_ctx *ctx)
 {
int ret;
 
-   ret = splice_to_pipe(ring, ctx);
-   if (ret) {
-   fprintf(stderr, "splice_to_pipe failed %i %i\n",
-   ret, errno);
+   ret = do_tee(ring, ctx->fd_in, ctx->pipe1[1], BUF_SIZE);
+   if (ret != -ESPIPE && ret != -EINVAL)
return ret;
-   }
 
-   ret = splice_from_pipe(ring, ctx);
-   if (ret) {
-   fprintf(stderr, "splice_from_pipe failed %i %i\n",
-   ret, errno);
+   return 0;
+}
+
+static int fail_tee_offset(struct io_uring *ring, struct test_ctx *ctx)
+{
+   int ret;
+
+   ret = do_splice_op(ring, ctx->pipe2[0], -1, ctx->pipe1[1], 0,
+  BUF_SIZE, IORING_OP_TEE);
+   if (ret != -ESPIPE && ret != -EINVAL)
+   return ret;
+
+   ret = do_splice_op(ring, ctx->pipe2[0], 0, ctx->pipe1[1], -1,
+  BUF_SIZE, IORING_OP_TEE);
+   if (ret != -ESPIPE && ret != -EINVAL)
+   return ret;
+
+   return 0;
+}
+
+static int check_tee(struct io_uring *ring, struct test_ctx *ctx)
+{
+   int ret;
+
+   ret = write_buf(ctx->real_pipe1[1], ctx->buf_in, BUF_SIZE);
+   if (ret)
+   return ret;
+   ret = do_tee(ring, ctx->pipe1[0], ctx->pipe2[1], BUF_SIZE);
+   if (ret)
return ret;
-   }
 
-   ret = splice_pipe_to_pipe(ring, ctx);
+   ret = check_content(ctx->real_pipe1[0], ctx->buf_out, BUF_SIZE,
+   ctx->buf_in);
if (ret) {
-   fprintf(stderr, "splice_pipe_to_pipe failed %i %i\n",
-   ret, errno);
+   fprintf(stderr, "tee(), invalid src data\n");
return ret;
}
 
-   ret = fail_splice_pipe_offset(ring, ctx);
+   ret = check_content(ctx->real_pipe2[0], ctx->buf_out, BUF_SIZE,
+   ctx->buf_in);
if (ret) {
-   fprintf(stderr, "fail_splice_pipe_offset failed %i %i\n",
-   ret, errno);
+   fprintf(stderr, "tee(), invalid dst data\n");
return ret;
}
+
+   return 0;
+}

[PATCH liburing 2/4] update io_uring.h with tee()

2020-05-17 Thread Pavel Begunkov
Signed-off-by: Pavel Begunkov 
---
 src/include/liburing/io_uring.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index e48d746..a279151 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -129,6 +129,7 @@ enum {
IORING_OP_SPLICE,
IORING_OP_PROVIDE_BUFFERS,
IORING_OP_REMOVE_BUFFERS,
+   IORING_OP_TEE,
 
/* this goes last, obviously */
IORING_OP_LAST,
-- 
2.24.0



[PATCH liburing 0/4] splice/tee testing

2020-05-17 Thread Pavel Begunkov
Add tee and improve splice tests

Pavel Begunkov (4):
  splice/test: improve splice tests
  update io_uring.h with tee()
  tee/test: add test for tee(2)
  splice/tee/tests: test len=0 splice/tee

 src/include/liburing/io_uring.h |   1 +
 test/splice.c   | 538 ++--
 2 files changed, 445 insertions(+), 94 deletions(-)

-- 
2.24.0



[PATCH liburing 1/4] splice/test: improve splice tests

2020-05-17 Thread Pavel Begunkov
Split and test functionality separately, better cover registered files
cases, and validate file\pipe actual data.

Signed-off-by: Pavel Begunkov 
---
 test/splice.c | 393 ++
 1 file changed, 300 insertions(+), 93 deletions(-)

diff --git a/test/splice.c b/test/splice.c
index b7ef537..1c27c8e 100644
--- a/test/splice.c
+++ b/test/splice.c
@@ -8,133 +8,305 @@
 
 #include "liburing.h"
 
-static int no_splice = 0;
-
-static int copy_single(struct io_uring *ring,
-   int fd_in, loff_t off_in,
-   int fd_out, loff_t off_out,
-   int pipe_fds[2],
-   unsigned int len,
-   unsigned flags1, unsigned flags2)
+#define BUF_SIZE (16 * 4096)
+
+struct test_ctx {
+   int real_pipe1[2];
+   int real_pipe2[2];
+   int real_fd_in;
+   int real_fd_out;
+
+   /* fds or for registered files */
+   int pipe1[2];
+   int pipe2[2];
+   int fd_in;
+   int fd_out;
+
+   void *buf_in;
+   void *buf_out;
+};
+
+static unsigned int splice_flags = 0;
+static unsigned int sqe_flags = 0;
+static int has_splice = 0;
+
+static int read_buf(int fd, void *buf, int len)
 {
-   struct io_uring_cqe *cqe;
-   struct io_uring_sqe *sqe;
-   int i, ret = -1;
+   int ret;
+
+   while (len) {
+   ret = read(fd, buf, len);
+   if (ret < 0)
+   return ret;
+   len -= ret;
+   buf += ret;
+   }
+   return 0;
+}
+
+static int write_buf(int fd, const void *buf, int len)
+{
+   int ret;
+
+   while (len) {
+   ret = write(fd, buf, len);
+   if (ret < 0)
+   return ret;
+   len -= ret;
+   buf += ret;
+   }
+   return 0;
+}
+
+static int check_content(int fd, void *buf, int len, const void *src)
+{
+   int ret;
+
+   ret = read_buf(fd, buf, len);
+   if (ret)
+   return ret;
+
+   ret = memcmp(buf, src, len);
+   return (ret != 0) ? -1 : 0;
+}
+
+static int create_file(const char *filename)
+{
+   int fd, save_errno;
+
+   fd = open(filename, O_RDWR | O_CREAT, 0644);
+   save_errno = errno;
+   unlink(filename);
+   errno = save_errno;
+   return fd;
+}
+
+static int init_splice_ctx(struct test_ctx *ctx)
+{
+   int ret, rnd_fd;
 
-   sqe = io_uring_get_sqe(ring);
-   if (!sqe) {
-   fprintf(stderr, "get sqe failed\n");
-   return -1;
+   ctx->buf_in = calloc(BUF_SIZE, 1);
+   if (!ctx->buf_in)
+   return 1;
+   ctx->buf_out = calloc(BUF_SIZE, 1);
+   if (!ctx->buf_out)
+   return 1;
+
+   ctx->fd_in = create_file(".splice-test-in");
+   if (ctx->fd_in < 0) {
+   perror("file open");
+   return 1;
}
-   io_uring_prep_splice(sqe, fd_in, off_in, pipe_fds[1], -1,
-len, flags1);
-   sqe->flags = IOSQE_IO_LINK;
-
-   sqe = io_uring_get_sqe(ring);
-   if (!sqe) {
-   fprintf(stderr, "get sqe failed\n");
-   return -1;
+
+   ctx->fd_out = create_file(".splice-test-out");
+   if (ctx->fd_out < 0) {
+   perror("file open");
+   return 1;
}
-   io_uring_prep_splice(sqe, pipe_fds[0], -1, fd_out, off_out,
-len, flags2);
-
-   ret = io_uring_submit(ring);
-   if (ret < 2) {
-   /* submitted just one, kernel likely doesn't support splice */
-   if (!io_uring_peek_cqe(ring, ) &&
-   cqe->res == -EINVAL) {
-   no_splice = 1;
+
+   /* get random data */
+   rnd_fd = open("/dev/urandom", O_RDONLY);
+   if (rnd_fd < 0)
+   return 1;
+
+   ret = read_buf(rnd_fd, ctx->buf_in, BUF_SIZE);
+   if (ret != 0)
+   return 1;
+   close(rnd_fd);
+
+   /* populate file */
+   ret = write_buf(ctx->fd_in, ctx->buf_in, BUF_SIZE);
+   if (ret)
+   return ret;
+
+   if (pipe(ctx->pipe1) < 0)
+   return 1;
+   if (pipe(ctx->pipe2) < 0)
+   return 1;
+
+   ctx->real_pipe1[0] = ctx->pipe1[0];
+   ctx->real_pipe1[1] = ctx->pipe1[1];
+   ctx->real_pipe2[0] = ctx->pipe2[0];
+   ctx->real_pipe2[1] = ctx->pipe2[1];
+   ctx->real_fd_in = ctx->fd_in;
+   ctx->real_fd_out = ctx->fd_out;
+   return 0;
+}
+
+static int do_splice(struct io_uring *ring,
+  int fd_in, loff_t off_in,
+  int fd_out, loff_t off_out,
+  unsigned int len)
+{
+   struct io_uring_cqe *cqe;
+   struct io_uring_sqe *sqe;
+   int ret = -1;
+
+   while (len) {
+   sqe = io_uring_get_sqe(ring);
+   if (!sqe) {
+   fprintf(stderr, "get sqe 

Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-17 Thread Aleksa Sarai
On 2020-05-17, Christian Brauner  wrote:
> Or... And that's more invasive but ultimately cleaner we v2 the whole
> thing so e.g. SECCOMP_IOCTL_NOTIF_RECV2, SECCOMP_IOCTL_NOTIF_SEND2, and
> embedd the size argument in the structs. Userspace sets the size
> argument, we use get_user() to get the size first and then
> copy_struct_from_user() to handle it cleanly based on that. A similar
> model as with sched (has other unrelated quirks because they messed up
> something too):
> 
> static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr 
> *attr)
> {
>   u32 size;
>   int ret;
> 
>   /* Zero the full structure, so that a short copy will be nice: */
>   memset(attr, 0, sizeof(*attr));
> 
>   ret = get_user(size, >size);
>   if (ret)
>   return ret;
> 
>   /* ABI compatibility quirk: */
>   if (!size)
>   size = SCHED_ATTR_SIZE_VER0;
>   if (size < SCHED_ATTR_SIZE_VER0 || size > PAGE_SIZE)
>   goto err_size;
> 
>   ret = copy_struct_from_user(attr, sizeof(*attr), uattr, size);
>   if (ret) {
>   if (ret == -E2BIG)
>   goto err_size;
>   return ret;
>   }
> 
> We're probably the biggest user of this right now and I'd be ok with
> that change. If it's a v2 than whatever. :)

I'm :+1: on a new version and switch to copy_struct_from_user(). I was a
little surprised when I found out that user_notif doesn't do it this
way a while ago (and although in theory it is userspace's fault, ideally
we could have an API that doesn't have built-in footguns).

-- 
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH



signature.asc
Description: PGP signature


[PATCH v2 0/2] io_uring tee support

2020-05-17 Thread Pavel Begunkov
Add tee support.

v2: handle zero-len tee

Pavel Begunkov (2):
  splice: export do_tee()
  io_uring: add tee(2) support

 fs/io_uring.c | 62 +--
 fs/splice.c   |  3 +-
 include/linux/splice.h|  3 ++
 include/uapi/linux/io_uring.h |  1 +
 4 files changed, 64 insertions(+), 5 deletions(-)

-- 
2.24.0



[PATCH v2 2/2] io_uring: add tee(2) support

2020-05-17 Thread Pavel Begunkov
Add IORING_OP_TEE implementing tee(2) support. Almost identical to
splice bits, but without offsets.

Signed-off-by: Pavel Begunkov 
---
 fs/io_uring.c | 62 +--
 include/uapi/linux/io_uring.h |  1 +
 2 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 83b599815cf0..7f25e145a60a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -853,6 +853,11 @@ static const struct io_op_def io_op_defs[] = {
},
[IORING_OP_PROVIDE_BUFFERS] = {},
[IORING_OP_REMOVE_BUFFERS] = {},
+   [IORING_OP_TEE] = {
+   .needs_file = 1,
+   .hash_reg_file  = 1,
+   .unbound_nonreg_file= 1,
+   },
 };
 
 static void io_wq_submit_work(struct io_wq_work **workptr);
@@ -2748,7 +2753,8 @@ static int io_write(struct io_kiocb *req, bool 
force_nonblock)
return ret;
 }
 
-static int io_splice_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+static int __io_splice_prep(struct io_kiocb *req,
+   const struct io_uring_sqe *sqe)
 {
struct io_splice* sp = >splice;
unsigned int valid_flags = SPLICE_F_FD_IN_FIXED | SPLICE_F_ALL;
@@ -2758,8 +2764,6 @@ static int io_splice_prep(struct io_kiocb *req, const 
struct io_uring_sqe *sqe)
return 0;
 
sp->file_in = NULL;
-   sp->off_in = READ_ONCE(sqe->splice_off_in);
-   sp->off_out = READ_ONCE(sqe->off);
sp->len = READ_ONCE(sqe->len);
sp->flags = READ_ONCE(sqe->splice_flags);
 
@@ -2778,6 +2782,46 @@ static int io_splice_prep(struct io_kiocb *req, const 
struct io_uring_sqe *sqe)
return 0;
 }
 
+static int io_tee_prep(struct io_kiocb *req,
+  const struct io_uring_sqe *sqe)
+{
+   if (READ_ONCE(sqe->splice_off_in) || READ_ONCE(sqe->off))
+   return -EINVAL;
+   return __io_splice_prep(req, sqe);
+}
+
+static int io_tee(struct io_kiocb *req, bool force_nonblock)
+{
+   struct io_splice *sp = >splice;
+   struct file *in = sp->file_in;
+   struct file *out = sp->file_out;
+   unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
+   long ret = 0;
+
+   if (force_nonblock)
+   return -EAGAIN;
+   if (sp->len)
+   ret = do_tee(in, out, sp->len, flags);
+
+   io_put_file(req, in, (sp->flags & SPLICE_F_FD_IN_FIXED));
+   req->flags &= ~REQ_F_NEED_CLEANUP;
+
+   io_cqring_add_event(req, ret);
+   if (ret != sp->len)
+   req_set_fail_links(req);
+   io_put_req(req);
+   return 0;
+}
+
+static int io_splice_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+{
+   struct io_splice* sp = >splice;
+
+   sp->off_in = READ_ONCE(sqe->splice_off_in);
+   sp->off_out = READ_ONCE(sqe->off);
+   return __io_splice_prep(req, sqe);
+}
+
 static int io_splice(struct io_kiocb *req, bool force_nonblock)
 {
struct io_splice *sp = >splice;
@@ -5087,6 +5131,9 @@ static int io_req_defer_prep(struct io_kiocb *req,
case IORING_OP_REMOVE_BUFFERS:
ret = io_remove_buffers_prep(req, sqe);
break;
+   case IORING_OP_TEE:
+   ret = io_tee_prep(req, sqe);
+   break;
default:
printk_once(KERN_WARNING "io_uring: unhandled opcode %d\n",
req->opcode);
@@ -5161,6 +5208,7 @@ static void io_cleanup_req(struct io_kiocb *req)
putname(req->open.filename);
break;
case IORING_OP_SPLICE:
+   case IORING_OP_TEE:
io_put_file(req, req->splice.file_in,
(req->splice.flags & SPLICE_F_FD_IN_FIXED));
break;
@@ -5391,6 +5439,14 @@ static int io_issue_sqe(struct io_kiocb *req, const 
struct io_uring_sqe *sqe,
}
ret = io_remove_buffers(req, force_nonblock);
break;
+   case IORING_OP_TEE:
+   if (sqe) {
+   ret = io_tee_prep(req, sqe);
+   if (ret < 0)
+   break;
+   }
+   ret = io_tee(req, force_nonblock);
+   break;
default:
ret = -EINVAL;
break;
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 8c5775df08b8..92c22699a5a7 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -129,6 +129,7 @@ enum {
IORING_OP_SPLICE,
IORING_OP_PROVIDE_BUFFERS,
IORING_OP_REMOVE_BUFFERS,
+   IORING_OP_TEE,
 
/* this goes last, obviously */
IORING_OP_LAST,
-- 
2.24.0



[PATCH v2 1/2] splice: export do_tee()

2020-05-17 Thread Pavel Begunkov
export do_tee() for use in io_uring

Signed-off-by: Pavel Begunkov 
---
 fs/splice.c| 3 +--
 include/linux/splice.h | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/splice.c b/fs/splice.c
index fd0a1e7e5959..a1dd54de24d8 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1754,8 +1754,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
  * The 'flags' used are the SPLICE_F_* variants, currently the only
  * applicable one is SPLICE_F_NONBLOCK.
  */
-static long do_tee(struct file *in, struct file *out, size_t len,
-  unsigned int flags)
+long do_tee(struct file *in, struct file *out, size_t len, unsigned int flags)
 {
struct pipe_inode_info *ipipe = get_pipe_info(in);
struct pipe_inode_info *opipe = get_pipe_info(out);
diff --git a/include/linux/splice.h b/include/linux/splice.h
index ebbbfea48aa0..5c47013f708e 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -82,6 +82,9 @@ extern long do_splice(struct file *in, loff_t __user *off_in,
  struct file *out, loff_t __user *off_out,
  size_t len, unsigned int flags);
 
+extern long do_tee(struct file *in, struct file *out, size_t len,
+  unsigned int flags);
+
 /*
  * for dynamic pipe sizing
  */
-- 
2.24.0



Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-17 Thread Sargun Dhillon
On Sun, May 17, 2020 at 12:17 AM Kees Cook  wrote:
>
> On Fri, May 15, 2020 at 04:40:05PM -0700, Sargun Dhillon wrote:
> > This includes the thread group leader ID in the seccomp_notif. This is
> > immediately useful for opening up a pidfd for the group leader, as
> > pidfds only work on group leaders.
> >
> > Previously, it was considered to include an actual pidfd in the
> > seccomp_notif structure[1], but it was suggested to avoid proliferating
> > mechanisms to create pidfds[2].
> >
> > [1]: https://lkml.org/lkml/2020/1/24/133
> > [2]: https://lkml.org/lkml/2020/5/15/481
>
> nit: please use lore.kernel.org/lkml/ URLs
>
> > Suggested-by: Christian Brauner 
> > Signed-off-by: Sargun Dhillon 
> > ---
> >  include/uapi/linux/seccomp.h  |  2 +
> >  kernel/seccomp.c  |  1 +
> >  tools/testing/selftests/seccomp/seccomp_bpf.c | 50 +++
> >  3 files changed, 53 insertions(+)
> >
> > diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h
> > index c1735455bc53..f0c272ef0f1e 100644
> > --- a/include/uapi/linux/seccomp.h
> > +++ b/include/uapi/linux/seccomp.h
> > @@ -75,6 +75,8 @@ struct seccomp_notif {
> >   __u32 pid;
> >   __u32 flags;
> >   struct seccomp_data data;
> > + __u32 tgid;
> > + __u8 pad0[4];
> >  };
>
> I think we need to leave off padding and instead use __packed. If we
> don't then userspace can't tell when "pad0" changes its "meaning" (i.e.
> the size of seccomp_notif becomes 88 bytes with above -- either via
> explicit padding like you've got or via implicit by the compiler. If
> some other u32 gets added in the future, user space will still see "88"
> as the size.
>
I've had previous feedback about using "packed". See:
https://lore.kernel.org/lkml/87o8w9bcaf@mid.deneb.enyo.de/
https://lore.kernel.org/lkml/a328b91d-fd8f-4f27-b3c2-91a9c45f1...@rasmusvillemoes.dk/
> So I *think* the right change here is:
>
> -};
> +   __u32 tgid;
> +} __packed;
>
> Though tgid may need to go above seccomp_data... for when it grows.
> Agh...
(How) can seccomp_data grow safely, even with this extensibility mechanism?
>
> _However_, unfortunately, I appear to have no thought this through very
> well, and there is actually no sanity-checking in the kernel for dealing
> with an old userspace when sizes change. :( For example, if a userspace
> doesn't check sizes and calls an ioctl, etc, the kernel will clobber the
> user buffer if it's too small.
>
> Even the SECCOMP_GET_NOTIF_SIZES command lacks a buffer size argument.
> :(
>
> So:
>
> - should we just declare such userspace as "wrong"? I don't think
>   that'll work, especially since what if we ever change the size of
>   seccomp_data...  that predated the ..._SIZES command.
>
> - should we add a SECCOMP_SET_SIZES command to tell the kernel what
>   we're expecting? There's no "state" associated across seccomp(2)
>   calls, but maybe that doesn't matter because only user_notif writes
>   back to userspace. For the ioctl, the state could be part of the
>   private file data? Sending seccomp_data back to userspace only
>   happens here, and any changes in seccomp_data size will just be seen
>   as allowing a filter to query further into it.
Will we ever grow seccomp_data?

I suggest we throw away the _SIZES api, and just introduce RECV2, which sends
back a known, fixed format, and deprecate these dynamically sized uapi
shenanigans.

(Queue RECV3, etc..)

Maybe we do something like perf_event_open, where there's a read_format,
and that's used by the user to determine how big of a response / fields they
want to get?

>
> - should GET_SIZES report "useful" size? (i.e. exclude padding?)
>
> > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c 
> > b/tools/testing/selftests/seccomp/seccomp_bpf.c
>
> Yay test updates! :)
>
> > +TEST(user_notification_groupleader)
>
> In my first pass of review I was going to say "can you please also check
> the sizes used by the ioctl?" But that triggered the above size checking
> mess in my mind.
>
> Let me look at this more closely on Monday, and I'll proposed something.
> :P
To summarize my set of ideas:
1. We take the ptrace-style API, where we have a request to get the tgid of
a given request ID (or any new / extensible field)
2. We add a perf_event_open style API, where you have to tell it what fields
to include in the response
3. We introduce RECV2 [through N]
4. We never extend seccomp_data, and just continue to append things to the API
5. We rev the API _once_ and unroll seccomp_data, and make it so that
new members have to be *asked for*, rather than are implicitly
included.
>
> Thanks!
>
> -Kees
>
> --
> Kees Cook


[PATCH 1/3] io_uring: remove req->needs_fixed_files

2020-05-17 Thread Pavel Begunkov
A submission is "async" IIF it's done by SQPOLL thread. Instead of
passing @async flag into io_submit_sqes(), deduce it from ctx->flags.

Signed-off-by: Pavel Begunkov 
---
 fs/io_uring.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 3d0a08560689..739aae7070c1 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -626,7 +626,6 @@ struct io_kiocb {
 
struct io_async_ctx *io;
int cflags;
-   boolneeds_fixed_file;
u8  opcode;
 
struct io_ring_ctx  *ctx;
@@ -891,6 +890,11 @@ EXPORT_SYMBOL(io_uring_get_socket);
 
 static void io_file_put_work(struct work_struct *work);
 
+static inline bool io_async_submit(struct io_ring_ctx *ctx)
+{
+   return ctx->flags & IORING_SETUP_SQPOLL;
+}
+
 static void io_ring_ctx_ref_free(struct percpu_ref *ref)
 {
struct io_ring_ctx *ctx = container_of(ref, struct io_ring_ctx, refs);
@@ -5487,7 +5491,7 @@ static int io_req_set_file(struct io_submit_state *state, 
struct io_kiocb *req,
bool fixed;
 
fixed = (req->flags & REQ_F_FIXED_FILE) != 0;
-   if (unlikely(!fixed && req->needs_fixed_file))
+   if (unlikely(!fixed && io_async_submit(req->ctx)))
return -EBADF;
 
return io_file_get(state, req, fd, >file, fixed);
@@ -5866,7 +5870,7 @@ static inline void io_consume_sqe(struct io_ring_ctx *ctx)
 
 static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
   const struct io_uring_sqe *sqe,
-  struct io_submit_state *state, bool async)
+  struct io_submit_state *state)
 {
unsigned int sqe_flags;
int id;
@@ -5887,7 +5891,6 @@ static int io_init_req(struct io_ring_ctx *ctx, struct 
io_kiocb *req,
refcount_set(>refs, 2);
req->task = NULL;
req->result = 0;
-   req->needs_fixed_file = async;
INIT_IO_WORK(>work, io_wq_submit_work);
 
if (unlikely(req->opcode >= IORING_OP_LAST))
@@ -5928,7 +5931,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct 
io_kiocb *req,
 }
 
 static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
- struct file *ring_file, int ring_fd, bool async)
+ struct file *ring_file, int ring_fd)
 {
struct io_submit_state state, *statep = NULL;
struct io_kiocb *link = NULL;
@@ -5972,7 +5975,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, 
unsigned int nr,
break;
}
 
-   err = io_init_req(ctx, req, sqe, statep, async);
+   err = io_init_req(ctx, req, sqe, statep);
io_consume_sqe(ctx);
/* will complete beyond this point, count as submitted */
submitted++;
@@ -5985,7 +5988,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, 
unsigned int nr,
}
 
trace_io_uring_submit_sqe(ctx, req->opcode, req->user_data,
-   true, async);
+   true, io_async_submit(ctx));
err = io_submit_sqe(req, sqe, );
if (err)
goto fail_req;
@@ -6124,7 +6127,7 @@ static int io_sq_thread(void *data)
}
 
mutex_lock(>uring_lock);
-   ret = io_submit_sqes(ctx, to_submit, NULL, -1, true);
+   ret = io_submit_sqes(ctx, to_submit, NULL, -1);
mutex_unlock(>uring_lock);
timeout = jiffies + ctx->sq_thread_idle;
}
@@ -7635,7 +7638,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, 
to_submit,
submitted = to_submit;
} else if (to_submit) {
mutex_lock(>uring_lock);
-   submitted = io_submit_sqes(ctx, to_submit, f.file, fd, false);
+   submitted = io_submit_sqes(ctx, to_submit, f.file, fd);
mutex_unlock(>uring_lock);
 
if (submitted != to_submit)
-- 
2.24.0



[PATCH 2/3] io_uring: rename io_file_put()

2020-05-17 Thread Pavel Begunkov
io_file_put() deals with flushing state's file refs, adding "state" to
its name makes it a bit clearer. Also, avoid double check of
state->file in __io_file_get() in some cases.

Signed-off-by: Pavel Begunkov 
---
 fs/io_uring.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 739aae7070c1..9c5a95414cbd 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1999,15 +1999,19 @@ static void io_iopoll_req_issued(struct io_kiocb *req)
wake_up(>sqo_wait);
 }
 
-static void io_file_put(struct io_submit_state *state)
+static void __io_state_file_put(struct io_submit_state *state)
 {
-   if (state->file) {
-   int diff = state->has_refs - state->used_refs;
+   int diff = state->has_refs - state->used_refs;
 
-   if (diff)
-   fput_many(state->file, diff);
-   state->file = NULL;
-   }
+   if (diff)
+   fput_many(state->file, diff);
+   state->file = NULL;
+}
+
+static inline void io_state_file_put(struct io_submit_state *state)
+{
+   if (state->file)
+   __io_state_file_put(state);
 }
 
 /*
@@ -2026,7 +2030,7 @@ static struct file *__io_file_get(struct io_submit_state 
*state, int fd)
state->ios_left--;
return state->file;
}
-   io_file_put(state);
+   __io_state_file_put(state);
}
state->file = fget_many(fd, state->ios_left);
if (!state->file)
@@ -5799,7 +5803,7 @@ static int io_submit_sqe(struct io_kiocb *req, const 
struct io_uring_sqe *sqe,
 static void io_submit_state_end(struct io_submit_state *state)
 {
blk_finish_plug(>plug);
-   io_file_put(state);
+   io_state_file_put(state);
if (state->free_reqs)
kmem_cache_free_bulk(req_cachep, state->free_reqs, state->reqs);
 }
-- 
2.24.0



[PATCH 3/3] io_uring: don't repeat valid flag list

2020-05-17 Thread Pavel Begunkov
req->flags stores all sqe->flags. After checking that sqe->flags are
valid set if IOSQE* flags, no need to double check it, just forward them
all.

Signed-off-by: Pavel Begunkov 
---
 fs/io_uring.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9c5a95414cbd..83b599815cf0 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5924,9 +5924,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct 
io_kiocb *req,
}
 
/* same numerical values with corresponding REQ_F_*, safe to copy */
-   req->flags |= sqe_flags & (IOSQE_IO_DRAIN | IOSQE_IO_HARDLINK |
-   IOSQE_ASYNC | IOSQE_FIXED_FILE |
-   IOSQE_BUFFER_SELECT | IOSQE_IO_LINK);
+   req->flags |= sqe_flags;
 
if (!io_op_defs[req->opcode].needs_file)
return 0;
-- 
2.24.0



[PATCH for-next 0/3] unrelated cleanups for next

2020-05-17 Thread Pavel Begunkov
Independent cleanups, that's it.

Pavel Begunkov (3):
  io_uring: remove req->needs_fixed_files
  io_uring: rename io_file_put()
  io_uring: don't repeat valid flag list

 fs/io_uring.c | 47 ++-
 1 file changed, 26 insertions(+), 21 deletions(-)

-- 
2.24.0



Re: "BUG: MAX_LOCKDEP_ENTRIES too low" with 6979 ">s_umount_key"

2020-05-17 Thread Qian Cai



> On May 16, 2020, at 9:16 PM, Waiman Long  wrote:
> 
> The lock_list table entries are for tracking a lock's forward and backward 
> dependencies. The lockdep_chains isn't the right lockdep file to look at. 
> Instead, check the lockdep files for entries with the maximum BD (backward 
> dependency) + FD (forward dependency). That will give you a better view of 
> which locks are consuming most of the lock_list entries. Also take a look at 
> lockdep_stats for an overall view of how much various table entries are being 
> consumed.

Thanks for the hint. It seems something in vfs is the culprit because every 
single one of those triggering from path_openat() (vfs_open()) or vfs_get_tree()

When the system after boot, lock_list entries is around 1. After running 
LTP syscalls and mm tests, the number is around 2. Then, it will go all the 
way over the max (32700) while running LTP fs tests. Most of the time from a 
test that would read every single file in sysfs.

I’ll decode the lockdep file to see if there is any more clues.

Re: [PATCH 02/12] dt-bindings: display: Add ingenic,ipu.yaml

2020-05-17 Thread Paul Cercueil

Hi Sam,

Le dim. 17 mai 2020 à 8:17, Sam Ravnborg  a écrit :

Hi Paul.
On Sat, May 16, 2020 at 11:50:47PM +0200, Paul Cercueil wrote:
 Add documentation of the Device Tree bindings for the Image 
Processing

 Unit (IPU) found in most Ingenic SoCs.

 Signed-off-by: Paul Cercueil 


For me it fails like this:


Oops. I missed the 'const:' in the item list. Will fix when I send a 
V2, and verify it this time.


Cheers,
-Paul

/Documentation/devicetree/bindings/display/ingenic,ipu.yaml: 
ignoring, error in schema: properties: compatible: oneOf: 1: items
warning: no schema found in file: 
Documentation/devicetree/bindings/display/ingenic,ipu.yaml
make[2]: *** [Documentation/devicetree/bindings/Makefile:42: 
Documentation/devicetree/bindings/processed-schema.yaml] Error 255

make[2]: *** Waiting for unfinished jobs
Documentation/devicetree/bindings/display/ingenic,ipu.yaml: 
properties:compatible:oneOf:1:items: ['ingenic,jz4770-ipu', 
'ingenic,jz4760-ipu'] is not valid under any of the given schemas 
(Possible causes of the failure):
	Documentation/devicetree/bindings/display/ingenic,ipu.yaml: 
properties:compatible:oneOf:1:items: ['ingenic,jz4770-ipu', 
'ingenic,jz4760-ipu'] is not of type 'object', 'boolean'
	Documentation/devicetree/bindings/display/ingenic,ipu.yaml: 
properties:compatible:oneOf:1:items:0: 'ingenic,jz4770-ipu' is not of 
type 'object', 'boolean'
	Documentation/devicetree/bindings/display/ingenic,ipu.yaml: 
properties:compatible:oneOf:1:items:1: 'ingenic,jz4760-ipu' is not of 
type 'object', 'boolean'



Sam


 ---
  .../bindings/display/ingenic,ipu.yaml | 65 
+++

  1 file changed, 65 insertions(+)
  create mode 100644 
Documentation/devicetree/bindings/display/ingenic,ipu.yaml


 diff --git 
a/Documentation/devicetree/bindings/display/ingenic,ipu.yaml 
b/Documentation/devicetree/bindings/display/ingenic,ipu.yaml

 new file mode 100644
 index ..22fe02ca866d
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/display/ingenic,ipu.yaml
 @@ -0,0 +1,65 @@
 +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
 +%YAML 1.2
 +---
 +$id: http://devicetree.org/schemas/display/ingenic,ipu.yaml#
 +$schema: http://devicetree.org/meta-schemas/core.yaml#
 +
 +title: Ingenic SoCs Image Processing Unit (IPU) devicetree bindings
 +
 +maintainers:
 +  - Paul Cercueil 
 +
 +properties:
 +  compatible:
 +oneOf:
 +  - enum:
 +- ingenic,jz4725b-ipu
 +- ingenic,jz4760-ipu
 +  - items:
 +- ingenic,jz4770-ipu
 +- ingenic,jz4760-ipu
 +
 +  reg:
 +maxItems: 1
 +
 +  interrupts:
 +maxItems: 1
 +
 +  clocks:
 +maxItems: 1
 +
 +  clock-names:
 +const: ipu
 +
 +patternProperties:
 +  "^ports?$":
 +description: OF graph bindings (specified in 
bindings/graph.txt).

 +
 +required:
 +  - compatible
 +  - reg
 +  - interrupts
 +  - clocks
 +  - clock-names
 +
 +additionalProperties: false
 +
 +examples:
 +  - |
 +#include 
 +ipu@1308 {
 +  compatible = "ingenic,jz4770-ipu", "ingenic,jz4760-ipu";
 +  reg = <0x1308 0x800>;
 +
 +  interrupt-parent = <>;
 +  interrupts = <29>;
 +
 +  clocks = < JZ4770_CLK_IPU>;
 +  clock-names = "ipu";
 +
 +  port {
 +ipu_ep: endpoint {
 +  remote-endpoint = <_ep>;
 +};
 +  };
 +};
 --
 2.26.2

 ___
 dri-devel mailing list
 dri-de...@lists.freedesktop.org
 https://lists.freedesktop.org/mailman/listinfo/dri-devel





[PATCH 1/2] io_uring: don't prepare DRAIN reqs twice

2020-05-17 Thread Pavel Begunkov
If req->io is not NULL, it's already prepared. Don't do it again,
it's dangerous.

Signed-off-by: Pavel Begunkov 
---
 fs/io_uring.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5a19120345e4..9e81781d7632 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5098,12 +5098,13 @@ static int io_req_defer(struct io_kiocb *req, const 
struct io_uring_sqe *sqe)
if (!req_need_defer(req) && list_empty_careful(>defer_list))
return 0;
 
-   if (!req->io && io_alloc_async_ctx(req))
-   return -EAGAIN;
-
-   ret = io_req_defer_prep(req, sqe);
-   if (ret < 0)
-   return ret;
+   if (!req->io) {
+   if (io_alloc_async_ctx(req))
+   return -EAGAIN;
+   ret = io_req_defer_prep(req, sqe);
+   if (ret < 0)
+   return ret;
+   }
 
spin_lock_irq(>completion_lock);
if (!req_need_defer(req) && list_empty(>defer_list)) {
-- 
2.24.0



[PATCH for-5.7 0/2] fortify async punt preparation

2020-05-17 Thread Pavel Begunkov
[2] fixes FORCE_ASYNC. I don't want to go through every bit, so
not sure whether this is an actual issue with [1], but it's just
safer this way. Please, consider it for-5.7

IMHO, all preparation thing became a bit messy, definitely could use
some rethinking in the future.

Pavel Begunkov (2):
  io_uring: don't prepare DRAIN reqs twice
  io_uring: fix FORCE_ASYNC req preparation

 fs/io_uring.c | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

-- 
2.24.0



[PATCH 2/2] io_uring: fix FORCE_ASYNC req preparation

2020-05-17 Thread Pavel Begunkov
As for other not inlined requests, alloc req->io for FORCE_ASYNC reqs,
so they can be prepared properly.

Signed-off-by: Pavel Begunkov 
---
 fs/io_uring.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9e81781d7632..3d0a08560689 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5692,9 +5692,15 @@ static void io_queue_sqe(struct io_kiocb *req, const 
struct io_uring_sqe *sqe)
io_double_put_req(req);
}
} else if (req->flags & REQ_F_FORCE_ASYNC) {
-   ret = io_req_defer_prep(req, sqe);
-   if (unlikely(ret < 0))
-   goto fail_req;
+   if (!req->io) {
+   ret = -EAGAIN;
+   if (io_alloc_async_ctx(req))
+   goto fail_req;
+   ret = io_req_defer_prep(req, sqe);
+   if (unlikely(ret < 0))
+   goto fail_req;
+   }
+
/*
 * Never try inline submit of IOSQE_ASYNC is set, go straight
 * to async execution.
-- 
2.24.0



[PATCH v2 2/2] dt-bindings: thermal: tsens: Add zeroc interrupt support in yaml

2020-05-17 Thread Manaf Meethalavalappu Pallikunhi
Add zeroc interrupt support for tsens in yaml.

Signed-off-by: Manaf Meethalavalappu Pallikunhi 
---
 .../bindings/thermal/qcom-tsens.yaml  | 21 +++
 1 file changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml 
b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
index 2ddd39d96766..717b0dd967e2 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
@@ -52,12 +52,14 @@ properties:
 items:
   - description: Combined interrupt if upper or lower threshold crossed
   - description: Interrupt if critical threshold crossed
+  - description: Interrupt if zeroC threshold is crossed
 
   interrupt-names:
 minItems: 1
 items:
   - const: uplow
   - const: critical
+  - const: zeroc
 
   nvmem-cells:
 minItems: 1
@@ -109,8 +111,10 @@ allOf:
   properties:
 interrupts:
   minItems: 2
+  maxItems: 3
 interrupt-names:
   minItems: 2
+  maxItems: 3
 
 required:
   - compatible
@@ -174,4 +178,21 @@ examples:
#qcom,sensors = <13>;
#thermal-sensor-cells = <1>;
 };
+
+  - |
+#include 
+// Example 4 (for any platform containing v2.6+ of the TSENS IP):
+tsens4: thermal-sensor@c265000 {
+   compatible = "qcom,sc7180-tsens", "qcom,tsens-v2";
+   reg = <0xc265000 0x1ff>,
+ <0xc223000 0x1ff>;
+
+   interrupts = ,
+,
+;
+   interrupt-names = "uplow", "critical", "zeroc";
+
+   #qcom,sensors = <15>;
+   #thermal-sensor-cells = <1>;
+};
 ...
-- 
2.26.2


Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif

2020-05-17 Thread Christian Brauner
On Sun, May 17, 2020 at 12:17:14AM -0700, Kees Cook wrote:
> On Fri, May 15, 2020 at 04:40:05PM -0700, Sargun Dhillon wrote:
> > This includes the thread group leader ID in the seccomp_notif. This is
> > immediately useful for opening up a pidfd for the group leader, as
> > pidfds only work on group leaders.
> > 
> > Previously, it was considered to include an actual pidfd in the
> > seccomp_notif structure[1], but it was suggested to avoid proliferating
> > mechanisms to create pidfds[2].
> > 
> > [1]: https://lkml.org/lkml/2020/1/24/133
> > [2]: https://lkml.org/lkml/2020/5/15/481
> 
> nit: please use lore.kernel.org/lkml/ URLs
> 
> > Suggested-by: Christian Brauner 
> > Signed-off-by: Sargun Dhillon 
> > ---
> >  include/uapi/linux/seccomp.h  |  2 +
> >  kernel/seccomp.c  |  1 +
> >  tools/testing/selftests/seccomp/seccomp_bpf.c | 50 +++
> >  3 files changed, 53 insertions(+)
> > 
> > diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h
> > index c1735455bc53..f0c272ef0f1e 100644
> > --- a/include/uapi/linux/seccomp.h
> > +++ b/include/uapi/linux/seccomp.h
> > @@ -75,6 +75,8 @@ struct seccomp_notif {
> > __u32 pid;
> > __u32 flags;
> > struct seccomp_data data;
> > +   __u32 tgid;
> > +   __u8 pad0[4];
> >  };
> 
> I think we need to leave off padding and instead use __packed. If we
> don't then userspace can't tell when "pad0" changes its "meaning" (i.e.
> the size of seccomp_notif becomes 88 bytes with above -- either via
> explicit padding like you've got or via implicit by the compiler. If
> some other u32 gets added in the future, user space will still see "88"
> as the size.
> 
> So I *think* the right change here is:
> 
> -};
> + __u32 tgid;
> +} __packed;
> 
> Though tgid may need to go above seccomp_data... for when it grows.
> Agh...
> 
> _However_, unfortunately, I appear to have no thought this through very
> well, and there is actually no sanity-checking in the kernel for dealing
> with an old userspace when sizes change. :( For example, if a userspace
> doesn't check sizes and calls an ioctl, etc, the kernel will clobber the
> user buffer if it's too small.

I'd just argue that that's just userspace messing up.

> 
> Even the SECCOMP_GET_NOTIF_SIZES command lacks a buffer size argument.
> :(
> 
> So:
> 
> - should we just declare such userspace as "wrong"? I don't think
>   that'll work, especially since what if we ever change the size of
>   seccomp_data...  that predated the ..._SIZES command.

Yeah, that's nasty since the struct member in seccomp_notif would now
clobber each other.

> 
> - should we add a SECCOMP_SET_SIZES command to tell the kernel what
>   we're expecting? There's no "state" associated across seccomp(2)
>   calls, but maybe that doesn't matter because only user_notif writes
>   back to userspace. For the ioctl, the state could be part of the
>   private file data? Sending seccomp_data back to userspace only
>   happens here, and any changes in seccomp_data size will just be seen
>   as allowing a filter to query further into it.

Sounds ok-ish in my opinion.

> 
> - should GET_SIZES report "useful" size? (i.e. exclude padding?)

Or... And that's more invasive but ultimately cleaner we v2 the whole
thing so e.g. SECCOMP_IOCTL_NOTIF_RECV2, SECCOMP_IOCTL_NOTIF_SEND2, and
embedd the size argument in the structs. Userspace sets the size
argument, we use get_user() to get the size first and then
copy_struct_from_user() to handle it cleanly based on that. A similar
model as with sched (has other unrelated quirks because they messed up
something too):

static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr 
*attr)
{
u32 size;
int ret;

/* Zero the full structure, so that a short copy will be nice: */
memset(attr, 0, sizeof(*attr));

ret = get_user(size, >size);
if (ret)
return ret;

/* ABI compatibility quirk: */
if (!size)
size = SCHED_ATTR_SIZE_VER0;
if (size < SCHED_ATTR_SIZE_VER0 || size > PAGE_SIZE)
goto err_size;

ret = copy_struct_from_user(attr, sizeof(*attr), uattr, size);
if (ret) {
if (ret == -E2BIG)
goto err_size;
return ret;
}

We're probably the biggest user of this right now and I'd be ok with
that change. If it's a v2 than whatever. :)

Christian


[PATCH v9] arm64: dts: qcom: sc7180: Add WCN3990 WLAN module device node

2020-05-17 Thread Rakesh Pillai
Add device node for the ath10k SNOC platform driver probe
and add resources required for WCN3990 on sc7180 soc.

Signed-off-by: Rakesh Pillai 
---
Changes from v8:
- Removed the qcom,msa-fixed-perm
---
 arch/arm64/boot/dts/qcom/sc7180-idp.dts |  7 +++
 arch/arm64/boot/dts/qcom/sc7180.dtsi| 27 +++
 2 files changed, 34 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sc7180-idp.dts 
b/arch/arm64/boot/dts/qcom/sc7180-idp.dts
index 4e9149d..38b102e 100644
--- a/arch/arm64/boot/dts/qcom/sc7180-idp.dts
+++ b/arch/arm64/boot/dts/qcom/sc7180-idp.dts
@@ -389,6 +389,13 @@
};
 };
 
+ {
+   status = "okay";
+   wifi-firmware {
+   iommus = <_smmu 0xc2 0x1>;
+   };
+};
+
 /* PINCTRL - additions to nodes defined in sc7180.dtsi */
 
 _clk {
diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi 
b/arch/arm64/boot/dts/qcom/sc7180.dtsi
index f1280e0..dd4e095 100644
--- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
@@ -63,6 +63,11 @@
clock-frequency = <32764>;
#clock-cells = <0>;
};
+
+   wlan_fw_mem: memory@9410 {
+   reg = <0 0x9410 0 0x20>;
+   no-map;
+   };
};
 
reserved_memory: reserved-memory {
@@ -944,6 +949,28 @@
};
};
 
+   wifi: wifi@1880 {
+   compatible = "qcom,wcn3990-wifi";
+   reg = <0 0x1880 0 0x80>;
+   reg-names = "membase";
+   iommus = <_smmu 0xc0 0x1>;
+   interrupts =
+   ,
+   ,
+   ,
+   ,
+   ,
+   ,
+   ,
+   ,
+   ,
+   ,
+   ,
+   ;
+   memory-region = <_fw_mem>;
+   status = "disabled";
+   };
+
config_noc: interconnect@150 {
compatible = "qcom,sc7180-config-noc";
reg = <0 0x0150 0 0x28000>;
-- 
2.7.4


[PATCH v2 0/2] Add zeroc interrupt support to tsens driver

2020-05-17 Thread Manaf Meethalavalappu Pallikunhi
The changes have dependency on merging tsens-common.c into tsens.c [1]
to merge first.

Dependencies:
[1] https://lkml.org/lkml/2020/4/29/1028

Changes in v2:
* Add zeroc interrupt support to tsens driver
* Update zeroc interrupt support in yaml

Manaf Meethalavalappu Pallikunhi (2):
  drivers: thermal: tsens: Add zeroc interrupt support
  dt-bindings: thermal: tsens: Add zeroc interrupt support in yaml

 .../bindings/thermal/qcom-tsens.yaml  |  21 
 drivers/thermal/qcom/tsens-v2.c   |   5 +
 drivers/thermal/qcom/tsens.c  | 107 +-
 drivers/thermal/qcom/tsens.h  |  10 ++
 4 files changed, 141 insertions(+), 2 deletions(-)

-- 
2.26.2


[PATCH v2 1/2] drivers: thermal: tsens: Add zeroc interrupt support

2020-05-17 Thread Manaf Meethalavalappu Pallikunhi
TSENS IP v2.6+ adds zeroc interrupt support. It triggers set
interrupt when aggregated minimum temperature of all TSENS falls
below zeroc preset threshold and triggers reset interrupt when
aggregated minimum temperature of all TSENS crosses above reset
threshold. Add support for this interrupt in the driver.

It adds another sensor to the of-thermal along with all individual
TSENS. It enables to add any mitigation for zeroc interrupt.

Signed-off-by: Manaf Meethalavalappu Pallikunhi 
---
 drivers/thermal/qcom/tsens-v2.c |   5 ++
 drivers/thermal/qcom/tsens.c| 107 +++-
 drivers/thermal/qcom/tsens.h|  10 +++
 3 files changed, 120 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c
index b293ed32174b..8f30b859ab22 100644
--- a/drivers/thermal/qcom/tsens-v2.c
+++ b/drivers/thermal/qcom/tsens-v2.c
@@ -23,6 +23,7 @@
 #define TM_Sn_UPPER_LOWER_THRESHOLD_OFF 0x0020
 #define TM_Sn_CRITICAL_THRESHOLD_OFF   0x0060
 #define TM_Sn_STATUS_OFF   0x00a0
+#define TM_ZEROC_INT_STATUS_OFF0x00e0
 #define TM_TRDY_OFF0x00e4
 #define TM_WDOG_LOG_OFF0x013c
 
@@ -86,6 +87,9 @@ static const struct reg_field 
tsens_v2_regfields[MAX_REGFIELDS] = {
REG_FIELD_FOR_EACH_SENSOR16(CRITICAL_STATUS, TM_Sn_STATUS_OFF, 19,  19),
REG_FIELD_FOR_EACH_SENSOR16(MAX_STATUS,  TM_Sn_STATUS_OFF, 20,  20),
 
+   /* ZEROC INTERRUPT STATUS */
+   [ZEROC_STATUS] = REG_FIELD(TM_ZEROC_INT_STATUS_OFF, 0, 0),
+
/* TRDY: 1=ready, 0=in progress */
[TRDY] = REG_FIELD(TM_TRDY_OFF, 0, 0),
 };
@@ -93,6 +97,7 @@ static const struct reg_field 
tsens_v2_regfields[MAX_REGFIELDS] = {
 static const struct tsens_ops ops_generic_v2 = {
.init   = init_common,
.get_temp   = get_temp_tsens_valid,
+   .get_zeroc_status  = get_tsens_zeroc_status,
 };
 
 struct tsens_plat_data data_tsens_v2 = {
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 8d3e94d2a9ed..dd0172f05eb6 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -205,7 +205,8 @@ static void tsens_set_interrupt_v1(struct tsens_priv *priv, 
u32 hw_id,
index = LOW_INT_CLEAR_0 + hw_id;
break;
case CRITICAL:
-   /* No critical interrupts before v2 */
+   case ZEROC:
+   /* No critical and zeroc interrupts before v2 */
return;
}
regmap_field_write(priv->rf[index], enable ? 0 : 1);
@@ -236,6 +237,9 @@ static void tsens_set_interrupt_v2(struct tsens_priv *priv, 
u32 hw_id,
index_mask  = CRIT_INT_MASK_0 + hw_id;
index_clear = CRIT_INT_CLEAR_0 + hw_id;
break;
+   case ZEROC:
+   /* Nothing to handle for zeroc interrupt */
+   return;
}
 
if (enable) {
@@ -367,6 +371,35 @@ static inline u32 masked_irq(u32 hw_id, u32 mask, enum 
tsens_ver ver)
return 0;
 }
 
+/**
+ * tsens_zeroc_irq_thread - Threaded interrupt handler for zeroc interrupt
+ * @irq: irq number
+ * @data: tsens controller private data
+ *
+ * Whenever interrupt triggers notify thermal framework using
+ * thermal_zone_device_update().
+ *
+ * Return: IRQ_HANDLED
+ */
+
+irqreturn_t tsens_zeroc_irq_thread(int irq, void *data)
+{
+   struct tsens_priv *priv = data;
+   struct tsens_sensor *s = >sensor[priv->num_sensors];
+   int temp, ret;
+
+   ret = regmap_field_read(priv->rf[ZEROC_STATUS], );
+   if (ret)
+   return ret;
+
+   dev_dbg(priv->dev, "[%u] %s: zeroc interrupt is %s\n",
+   s->hw_id, __func__, temp ? "triggered" : "cleared");
+
+   thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED);
+
+   return IRQ_HANDLED;
+}
+
 /**
  * tsens_critical_irq_thread() - Threaded handler for critical interrupts
  * @irq: irq number
@@ -575,6 +608,20 @@ void tsens_disable_irq(struct tsens_priv *priv)
regmap_field_write(priv->rf[INT_EN], 0);
 }
 
+int get_tsens_zeroc_status(const struct tsens_sensor *s, int *temp)
+{
+   struct tsens_priv *priv = s->priv;
+   int last_temp = 0, ret;
+
+   ret = regmap_field_read(priv->rf[ZEROC_STATUS], _temp);
+   if (ret)
+   return ret;
+
+   *temp = last_temp;
+
+   return 0;
+}
+
 int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp)
 {
struct tsens_priv *priv = s->priv;
@@ -843,6 +890,19 @@ int __init init_common(struct tsens_priv *priv)
regmap_field_write(priv->rf[CC_MON_MASK], 1);
}
 
+   if (tsens_version(priv) > VER_1_X &&  ver_minor > 5) {
+   /* ZEROC interrupt is present only on v2.6+ */
+   priv->feat->zeroc_int = 1;
+   priv->rf[ZEROC_STATUS] = devm_regmap_field_alloc(
+   dev,
+  

Re: [PATCH 2/2] dt-bindings: thermal: tsens: Add zeroc interrupt support in yaml

2020-05-17 Thread manafm

On 2020-05-05 21:08, Rob Herring wrote:
On Tue,  5 May 2020 16:42:04 +0530, Manaf Meethalavalappu Pallikunhi 
wrote:

Add 0C (zeroc) interrupt support for tsens in yaml.

Signed-off-by: Manaf Meethalavalappu Pallikunhi 


---
 Documentation/devicetree/bindings/thermal/qcom-tsens.yaml | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)



My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/thermal/qcom-tsens.example.dt.yaml:
thermal-sensor@c263000: interrupt-names: ['uplow', 'critical',
'zeroc'] is too long
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/thermal/qcom-tsens.example.dt.yaml:
thermal-sensor@c263000: interrupts: [[0, 506, 4], [0, 508, 4], [0,
510, 1]] is too long

See https://patchwork.ozlabs.org/patch/1283470

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure dt-schema is up to date:

pip3 install
git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.
Addressed above errors for 
Documentation/devicetree/bindings/thermal/qcom-tsens.yaml in v2


Re: [PATCH 0/2] Add 0C (zeorC) interrupt support to tsens driver

2020-05-17 Thread manafm

On 2020-05-05 17:42, Amit Kucheria wrote:

Hi Manaf,

Thanks for sending this.

Typo: zeorc in subject line.

Done



On Tue, May 5, 2020 at 4:42 PM Manaf Meethalavalappu Pallikunhi
 wrote:


Changes:
* Add zeroc interrupt support to tsens driver
* Update zeroc interrupt support in yaml

Manaf Meethalavalappu Pallikunhi (2):
  drivers: thermal: tsens: Add 0C (zeorC) interrupt support
  dt-bindings: thermal: tsens: Add zeroc interrupt support in yaml

 .../bindings/thermal/qcom-tsens.yaml  |  7 +-
 drivers/thermal/qcom/tsens-common.c   | 72 
++-

 drivers/thermal/qcom/tsens-v2.c   |  7 ++
 drivers/thermal/qcom/tsens.c  | 51 +++--
 drivers/thermal/qcom/tsens.h  | 11 +++
 5 files changed, 140 insertions(+), 8 deletions(-)

--
2.26.2


Re: [PATCH 2/2] dt-bindings: thermal: tsens: Add zeroc interrupt support in yaml

2020-05-17 Thread manafm

On 2020-05-05 17:41, Amit Kucheria wrote:

On Tue, May 5, 2020 at 4:43 PM Manaf Meethalavalappu Pallikunhi
 wrote:


Add 0C (zeroc) interrupt support for tsens in yaml.

Signed-off-by: Manaf Meethalavalappu Pallikunhi 


---
 Documentation/devicetree/bindings/thermal/qcom-tsens.yaml | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml 
b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml

index 2ddd39d96766..8a0893f77d20 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
@@ -52,12 +52,14 @@ properties:
 items:
   - description: Combined interrupt if upper or lower threshold 
crossed

   - description: Interrupt if critical threshold crossed
+  - description: Interrupt if zeroC threshold is crossed

   interrupt-names:
 minItems: 1
 items:
   - const: uplow
   - const: critical
+  - const: zeroc

   nvmem-cells:
 minItems: 1
@@ -168,8 +170,9 @@ examples:
  <0xc222000 0x1ff>;

interrupts = ,
-;
-   interrupt-names = "uplow", "critical";
+,
+;
+   interrupt-names = "uplow", "critical", "zeroc";



Add a new example for v2 with 0C interrupt here instead of reusing the 
old one.

Done



#qcom,sensors = <13>;
#thermal-sensor-cells = <1>;
--
2.26.2


[PATCH] habanalabs: update patched_cb_size for Wreg32

2020-05-17 Thread Oded Gabbay
From: Rachel Stahl 

The patch_cb_size is not updated for Wreg32 in its validate function, so
updated in goya_validate_cb.

Signed-off-by: Rachel Stahl 
Reviewed-by: Oded Gabbay 
Signed-off-by: Oded Gabbay 
---
 drivers/misc/habanalabs/goya/goya.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/habanalabs/goya/goya.c 
b/drivers/misc/habanalabs/goya/goya.c
index 56f415f9120a..15b6c3228e37 100644
--- a/drivers/misc/habanalabs/goya/goya.c
+++ b/drivers/misc/habanalabs/goya/goya.c
@@ -3394,6 +3394,7 @@ static int goya_validate_cb(struct hl_device *hdev,
 */
rc = goya_validate_wreg32(hdev,
parser, (struct packet_wreg32 *) user_pkt);
+   parser->patched_cb_size += pkt_size;
break;
 
case PACKET_WREG_BULK:
-- 
2.17.1



Re: [PATCH 1/2] drivers: thermal: tsens: Add 0C (zeorC) interrupt support

2020-05-17 Thread manafm

On 2020-05-05 17:39, Amit Kucheria wrote:

Hi Manaf,

Typo: fix zeorC in subject line.

Done


Please rebase this patch[1] on top of my patch merging tsens-common.c
and tsens.c.

[1]
https://lore.kernel.org/linux-arm-msm/e30e2ba6fa5c007983afd4d7d4e0311c0b57917a.1588183879.git.amit.kuche...@linaro.org/

Done


On Tue, May 5, 2020 at 4:42 PM Manaf Meethalavalappu Pallikunhi
 wrote:


TSENS IP v2.6+ adds 0C interrupt support. It triggers set
interrupt when aggregated minimum temperature of all TSENS falls
below 0C preset threshold and triggers reset interrupt when aggregate
minimum temperature of all TSENS crosses above reset threshold.
Add support for this interrupt in the driver.

It adds another sensor to the of-thermal along with all individual
TSENS. It enables to add any mitigation for 0C interrupt.

Signed-off-by: Manaf Meethalavalappu Pallikunhi 


---
 drivers/thermal/qcom/tsens-common.c | 72 
-

 drivers/thermal/qcom/tsens-v2.c |  7 +++
 drivers/thermal/qcom/tsens.c| 51 ++--
 drivers/thermal/qcom/tsens.h| 11 +
 4 files changed, 135 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-common.c 
b/drivers/thermal/qcom/tsens-common.c

index 172545366636..44e7edeb9a90 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -198,7 +198,8 @@ static void tsens_set_interrupt_v1(struct 
tsens_priv *priv, u32 hw_id,

index = LOW_INT_CLEAR_0 + hw_id;
break;
case CRITICAL:
-   /* No critical interrupts before v2 */
+   case ZEROC:
+   /* No critical and 0c interrupts before v2 */
return;
}
regmap_field_write(priv->rf[index], enable ? 0 : 1);
@@ -229,6 +230,9 @@ static void tsens_set_interrupt_v2(struct 
tsens_priv *priv, u32 hw_id,

index_mask  = CRIT_INT_MASK_0 + hw_id;
index_clear = CRIT_INT_CLEAR_0 + hw_id;
break;
+   case ZEROC:
+   /* Nothing to handle for 0c interrupt */
+   return;
}

if (enable) {
@@ -360,6 +364,34 @@ static inline u32 masked_irq(u32 hw_id, u32 mask, 
enum tsens_ver ver)

return 0;
 }

+/**
+ * tsens_0c_irq_thread - Threaded interrupt handler for 0c interrupt


Let's use zeroc instead of 0c in the function and variable names and
comments everywhere. Easier to grep and better consistency too.

Done



+ * @irq: irq number
+ * @data: tsens controller private data
+ *
+ * Whenever interrupt triggers notify thermal framework using
+ * thermal_zone_device_update() to update cold temperature 
mitigation.


How is this mitigation updated?

Updated comment section

+ *
+ * Return: IRQ_HANDLED
+ */
+irqreturn_t tsens_0c_irq_thread(int irq, void *data)
+{
+   struct tsens_priv *priv = data;
+   struct tsens_sensor *s = >sensor[priv->num_sensors];
+   int temp, ret;
+
+   ret = regmap_field_read(priv->rf[TSENS_0C_STATUS], );
+   if (ret)
+   return ret;
+
+   dev_dbg(priv->dev, "[%u] %s: 0c interrupt is %s\n",
+   s->hw_id, __func__, temp ? "triggered" : "cleared");


So triggered is printed for non-zero (including negative) values?
This zeroc hardware generates each interrupt when any of the TSENS that 
it monitors goes below 5C or above 10c. These thresholds are not 
configurable. Hence we don't expect this to be changed from kernel side.
So this sensor (status register) will read 0 or 1.  1 means soc 
temperature is in cold condition and 0 means it is in normal 
temperature.



+
+   thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED);
+
+   return IRQ_HANDLED;
+}
+
 /**
  * tsens_critical_irq_thread() - Threaded handler for critical 
interrupts

  * @irq: irq number
@@ -566,6 +598,20 @@ void tsens_disable_irq(struct tsens_priv *priv)
regmap_field_write(priv->rf[INT_EN], 0);
 }

+int tsens_get_0c_int_status(const struct tsens_sensor *s, int *temp)
+{
+   struct tsens_priv *priv = s->priv;
+   int last_temp = 0, ret;
+
+   ret = regmap_field_read(priv->rf[TSENS_0C_STATUS], 
_temp);

+   if (ret)
+   return ret;
+
+   *temp = last_temp;
+
+   return 0;
+}
+
 int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp)
 {
struct tsens_priv *priv = s->priv;
@@ -833,6 +879,30 @@ int __init init_common(struct tsens_priv *priv)
regmap_field_write(priv->rf[CC_MON_MASK], 1);
}

+   if (tsens_version(priv) > VER_1_X &&  ver_minor > 5) {
+   /* 0C interrupt is present only on v2.6+ */
+   priv->rf[TSENS_0C_INT_EN] = 
devm_regmap_field_alloc(dev,

+   priv->srot_map,
+   
priv->fields[TSENS_0C_INT_EN]);

+   if (IS_ERR(priv->rf[TSENS_0C_INT_EN])) {
+   ret = PTR_ERR(priv->rf[TSENS_0C_INT_EN]);
+   

Re: [PATCH v3 0/5] RCU dyntick nesting counter cleanups for rcu -dev

2020-05-17 Thread Thomas Gleixner
Paul,

"Paul E. McKenney"  writes:
> And I have allegedly resolved the conflicts with Thomas's and Peter's
> series, or at least the noinstr-rcu-nmi-2020-05-15 branch of that series.
> At least one conflict was completely invisible to "git rebase" (but
> fortunately blindingly obvious to the compiler).  This naturally makes
> me suspect that additional adjustments might be needed.  Especially
> given that misplaced instrumentation_begin() and instrumentation_end()
> calls are invisible not only to the compiler, but also to rcutorture in
> my setup.  (For example, tracing before instrumentation_begin() or after
> instrumentation_end() is a bug.)

there is tooling to verify that. If you merge

  git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git entry-v7-full

into your dev branch (trivial conflict) and after building it, run:

 objtool check -fal $BUILDIR/vmlinux.o

Note: This only covers built-in code. So if you have code you want to
check make sure it's not built as module.

Just did that and it complains about:

../build/vmlinux.o: warning: objtool: rcu_eqs_enter.constprop.0()+0xa9: call to 
rcu_preempt_deferred_qs() leaves .noinstr.text section

But that's even the case on my branch without your changes.

The call to rcu_preempt_deferred_qs() is definitely before
instrumentation_end() so this needs to be investigated on the objtool
side. Peter?

Thanks,

tglx


[PATCH v2 1/3] clk: qcom: gcc: Add support for a new frequency for SC7180

2020-05-17 Thread Taniya Das
There is a requirement to support 51.2MHz from GPLL6 for qup clocks,
thus update the frequency table and parent data/map to use the GPLL6
source PLL.

Fixes: 17269568f7267 ("clk: qcom: Add Global Clock controller (GCC) driver for 
SC7180")
Signed-off-by: Taniya Das 
---
 drivers/clk/qcom/gcc-sc7180.c | 73 ++-
 1 file changed, 37 insertions(+), 36 deletions(-)

diff --git a/drivers/clk/qcom/gcc-sc7180.c b/drivers/clk/qcom/gcc-sc7180.c
index 6a51b5b..7338052 100644
--- a/drivers/clk/qcom/gcc-sc7180.c
+++ b/drivers/clk/qcom/gcc-sc7180.c
@@ -390,6 +390,7 @@ static const struct freq_tbl 
ftbl_gcc_qupv3_wrap0_s0_clk_src[] = {
F(29491200, P_GPLL0_OUT_EVEN, 1, 1536, 15625),
F(3200, P_GPLL0_OUT_EVEN, 1, 8, 75),
F(4800, P_GPLL0_OUT_EVEN, 1, 4, 25),
+   F(5120, P_GPLL6_OUT_MAIN, 7.5, 0, 0),
F(6400, P_GPLL0_OUT_EVEN, 1, 16, 75),
F(7500, P_GPLL0_OUT_EVEN, 4, 0, 0),
F(8000, P_GPLL0_OUT_EVEN, 1, 4, 15),
@@ -405,8 +406,8 @@ static const struct freq_tbl 
ftbl_gcc_qupv3_wrap0_s0_clk_src[] = {

 static struct clk_init_data gcc_qupv3_wrap0_s0_clk_src_init = {
.name = "gcc_qupv3_wrap0_s0_clk_src",
-   .parent_data = gcc_parent_data_0,
-   .num_parents = 4,
+   .parent_data = gcc_parent_data_1,
+   .num_parents = ARRAY_SIZE(gcc_parent_data_1),
.ops = _rcg2_ops,
 };

@@ -414,15 +415,15 @@ static struct clk_rcg2 gcc_qupv3_wrap0_s0_clk_src = {
.cmd_rcgr = 0x17034,
.mnd_width = 16,
.hid_width = 5,
-   .parent_map = gcc_parent_map_0,
+   .parent_map = gcc_parent_map_1,
.freq_tbl = ftbl_gcc_qupv3_wrap0_s0_clk_src,
.clkr.hw.init = _qupv3_wrap0_s0_clk_src_init,
 };

 static struct clk_init_data gcc_qupv3_wrap0_s1_clk_src_init = {
.name = "gcc_qupv3_wrap0_s1_clk_src",
-   .parent_data = gcc_parent_data_0,
-   .num_parents = 4,
+   .parent_data = gcc_parent_data_1,
+   .num_parents = ARRAY_SIZE(gcc_parent_data_1),
.ops = _rcg2_ops,
 };

@@ -430,15 +431,15 @@ static struct clk_rcg2 gcc_qupv3_wrap0_s1_clk_src = {
.cmd_rcgr = 0x17164,
.mnd_width = 16,
.hid_width = 5,
-   .parent_map = gcc_parent_map_0,
+   .parent_map = gcc_parent_map_1,
.freq_tbl = ftbl_gcc_qupv3_wrap0_s0_clk_src,
.clkr.hw.init = _qupv3_wrap0_s1_clk_src_init,
 };

 static struct clk_init_data gcc_qupv3_wrap0_s2_clk_src_init = {
.name = "gcc_qupv3_wrap0_s2_clk_src",
-   .parent_data = gcc_parent_data_0,
-   .num_parents = 4,
+   .parent_data = gcc_parent_data_1,
+   .num_parents = ARRAY_SIZE(gcc_parent_data_1),
.ops = _rcg2_ops,
 };

@@ -446,15 +447,15 @@ static struct clk_rcg2 gcc_qupv3_wrap0_s2_clk_src = {
.cmd_rcgr = 0x17294,
.mnd_width = 16,
.hid_width = 5,
-   .parent_map = gcc_parent_map_0,
+   .parent_map = gcc_parent_map_1,
.freq_tbl = ftbl_gcc_qupv3_wrap0_s0_clk_src,
.clkr.hw.init = _qupv3_wrap0_s2_clk_src_init,
 };

 static struct clk_init_data gcc_qupv3_wrap0_s3_clk_src_init = {
.name = "gcc_qupv3_wrap0_s3_clk_src",
-   .parent_data = gcc_parent_data_0,
-   .num_parents = 4,
+   .parent_data = gcc_parent_data_1,
+   .num_parents = ARRAY_SIZE(gcc_parent_data_1),
.ops = _rcg2_ops,
 };

@@ -462,15 +463,15 @@ static struct clk_rcg2 gcc_qupv3_wrap0_s3_clk_src = {
.cmd_rcgr = 0x173c4,
.mnd_width = 16,
.hid_width = 5,
-   .parent_map = gcc_parent_map_0,
+   .parent_map = gcc_parent_map_1,
.freq_tbl = ftbl_gcc_qupv3_wrap0_s0_clk_src,
.clkr.hw.init = _qupv3_wrap0_s3_clk_src_init,
 };

 static struct clk_init_data gcc_qupv3_wrap0_s4_clk_src_init = {
.name = "gcc_qupv3_wrap0_s4_clk_src",
-   .parent_data = gcc_parent_data_0,
-   .num_parents = 4,
+   .parent_data = gcc_parent_data_1,
+   .num_parents = ARRAY_SIZE(gcc_parent_data_1),
.ops = _rcg2_ops,
 };

@@ -478,15 +479,15 @@ static struct clk_rcg2 gcc_qupv3_wrap0_s4_clk_src = {
.cmd_rcgr = 0x174f4,
.mnd_width = 16,
.hid_width = 5,
-   .parent_map = gcc_parent_map_0,
+   .parent_map = gcc_parent_map_1,
.freq_tbl = ftbl_gcc_qupv3_wrap0_s0_clk_src,
.clkr.hw.init = _qupv3_wrap0_s4_clk_src_init,
 };

 static struct clk_init_data gcc_qupv3_wrap0_s5_clk_src_init = {
.name = "gcc_qupv3_wrap0_s5_clk_src",
-   .parent_data = gcc_parent_data_0,
-   .num_parents = 4,
+   .parent_data = gcc_parent_data_1,
+   .num_parents = ARRAY_SIZE(gcc_parent_data_1),
.ops = _rcg2_ops,
 };

@@ -494,15 +495,15 @@ static struct clk_rcg2 gcc_qupv3_wrap0_s5_clk_src = {
.cmd_rcgr = 0x17624,
.mnd_width = 16,
.hid_width = 5,
-   .parent_map = gcc_parent_map_0,
+   .parent_map = gcc_parent_map_1,
.freq_tbl = ftbl_gcc_qupv3_wrap0_s0_clk_src,
.clkr.hw.init = 

[PATCH v2 2/3] dt-bindings: clock: Add gcc_sec_ctrl_clk_src clock ID

2020-05-17 Thread Taniya Das
The gcc_sec_ctrl_clk_src clock is required to be controlled by the
secure controller driver.

Signed-off-by: Taniya Das 
---
 include/dt-bindings/clock/qcom,gcc-sc7180.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/dt-bindings/clock/qcom,gcc-sc7180.h 
b/include/dt-bindings/clock/qcom,gcc-sc7180.h
index 1258fd0..992b67b 100644
--- a/include/dt-bindings/clock/qcom,gcc-sc7180.h
+++ b/include/dt-bindings/clock/qcom,gcc-sc7180.h
@@ -137,6 +137,7 @@
 #define GCC_MSS_NAV_AXI_CLK127
 #define GCC_MSS_Q6_MEMNOC_AXI_CLK  128
 #define GCC_MSS_SNOC_AXI_CLK   129
+#define GCC_SEC_CTRL_CLK_SRC   130
 
 /* GCC resets */
 #define GCC_QUSB2PHY_PRIM_BCR  0
-- 
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the  Linux Foundation.


[GIT pull] objtool/urgent for v5.7-rc6

2020-05-17 Thread Thomas Gleixner
Linus,

please pull the latest objtool/urgent branch from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
objtool-urgent-2020-05-17

up to:  71c95825289f: x86/unwind/orc: Fix error handling in __unwind_start()


A single bugfix for the ORC unwinder to ensure that the error flag which
tells the unwinding code whether a stack trace can be trusted or not is
always set correctly. This was messed up by a couple of changes in the
recent past.

Thanks,

tglx

-->
Josh Poimboeuf (1):
  x86/unwind/orc: Fix error handling in __unwind_start()


 arch/x86/kernel/unwind_orc.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
index 5b0bd8581fe6..fa79e4227d3d 100644
--- a/arch/x86/kernel/unwind_orc.c
+++ b/arch/x86/kernel/unwind_orc.c
@@ -617,23 +617,23 @@ EXPORT_SYMBOL_GPL(unwind_next_frame);
 void __unwind_start(struct unwind_state *state, struct task_struct *task,
struct pt_regs *regs, unsigned long *first_frame)
 {
-   if (!orc_init)
-   goto done;
-
memset(state, 0, sizeof(*state));
state->task = task;
 
+   if (!orc_init)
+   goto err;
+
/*
 * Refuse to unwind the stack of a task while it's executing on another
 * CPU.  This check is racy, but that's ok: the unwinder has other
 * checks to prevent it from going off the rails.
 */
if (task_on_another_cpu(task))
-   goto done;
+   goto err;
 
if (regs) {
if (user_mode(regs))
-   goto done;
+   goto the_end;
 
state->ip = regs->ip;
state->sp = regs->sp;
@@ -666,6 +666,7 @@ void __unwind_start(struct unwind_state *state, struct 
task_struct *task,
 * generate some kind of backtrace if this happens.
 */
void *next_page = (void *)PAGE_ALIGN((unsigned long)state->sp);
+   state->error = true;
if (get_stack_info(next_page, state->task, >stack_info,
   >stack_mask))
return;
@@ -691,8 +692,9 @@ void __unwind_start(struct unwind_state *state, struct 
task_struct *task,
 
return;
 
-done:
+err:
+   state->error = true;
+the_end:
state->stack_info.type = STACK_TYPE_UNKNOWN;
-   return;
 }
 EXPORT_SYMBOL_GPL(__unwind_start);



[PATCH v2 3/3] clk: qcom: gcc: Add support for Secure control source clock

2020-05-17 Thread Taniya Das
The secure controller driver requires to request for various frequencies
on the source clock, thus add support for the same.

Signed-off-by: Taniya Das 
---
 drivers/clk/qcom/gcc-sc7180.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/drivers/clk/qcom/gcc-sc7180.c b/drivers/clk/qcom/gcc-sc7180.c
index 7338052..ca4383e 100644
--- a/drivers/clk/qcom/gcc-sc7180.c
+++ b/drivers/clk/qcom/gcc-sc7180.c
@@ -817,6 +817,26 @@ static struct clk_rcg2 gcc_usb3_prim_phy_aux_clk_src = {
},
 };
 
+static const struct freq_tbl ftbl_gcc_sec_ctrl_clk_src[] = {
+   F(480, P_BI_TCXO, 4, 0, 0),
+   F(1920, P_BI_TCXO, 1, 0, 0),
+   { }
+};
+
+static struct clk_rcg2 gcc_sec_ctrl_clk_src = {
+   .cmd_rcgr = 0x3d030,
+   .mnd_width = 0,
+   .hid_width = 5,
+   .parent_map = gcc_parent_map_3,
+   .freq_tbl = ftbl_gcc_sec_ctrl_clk_src,
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "gcc_sec_ctrl_clk_src",
+   .parent_data = gcc_parent_data_3,
+   .num_parents = ARRAY_SIZE(gcc_parent_data_3),
+   .ops = _rcg2_ops,
+   },
+};
+
 static struct clk_branch gcc_aggre_ufs_phy_axi_clk = {
.halt_reg = 0x82024,
.halt_check = BRANCH_HALT_DELAY,
@@ -2407,6 +2427,7 @@ static struct clk_regmap *gcc_sc7180_clocks[] = {
[GCC_MSS_NAV_AXI_CLK] = _mss_nav_axi_clk.clkr,
[GCC_MSS_Q6_MEMNOC_AXI_CLK] = _mss_q6_memnoc_axi_clk.clkr,
[GCC_MSS_SNOC_AXI_CLK] = _mss_snoc_axi_clk.clkr,
+   [GCC_SEC_CTRL_CLK_SRC] = _sec_ctrl_clk_src.clkr,
 };
 
 static const struct qcom_reset_map gcc_sc7180_resets[] = {
-- 
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the  Linux Foundation.


[PATCH v2 0/3] Add Misc GCC clock driver support for SC7180

2020-05-17 Thread Taniya Das
 [v2]
  * Update to use ARRAY_SIZE instead of hard-coded values for num_parents.
Also add the fixes tag.

 [v1]
  * Add a new frequency of 51.2MHz for QUP clock.
  * Add support for gcc_sec_ctrl_clk_src RCG for client to be able to request
   various frequencies.

Taniya Das (3):
  clk: qcom: gcc: Add support for a new frequency for SC7180
  dt-bindings: clock: Add gcc_sec_ctrl_clk_src clock ID
  clk: qcom: gcc: Add support for Secure control source clock

 drivers/clk/qcom/gcc-sc7180.c   | 94 ++---
 include/dt-bindings/clock/qcom,gcc-sc7180.h |  1 +
 2 files changed, 59 insertions(+), 36 deletions(-)

--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the  Linux Foundation.


Re: [PATCH v1 3/3] clk: qcom: gcc: Add support for Secure control source clock

2020-05-17 Thread Taniya Das

Hello Stephen,

Thanks for your review.

On 3/16/2020 11:19 PM, Stephen Boyd wrote:

Quoting Taniya Das (2020-03-16 03:54:42)

diff --git a/drivers/clk/qcom/gcc-sc7180.c b/drivers/clk/qcom/gcc-sc7180.c
index ad75847..3302f19 100644
--- a/drivers/clk/qcom/gcc-sc7180.c
+++ b/drivers/clk/qcom/gcc-sc7180.c
@@ -817,6 +817,26 @@ static struct clk_rcg2 gcc_usb3_prim_phy_aux_clk_src = {
 },
  };

+static const struct freq_tbl ftbl_gcc_sec_ctrl_clk_src[] = {
+   F(480, P_BI_TCXO, 4, 0, 0),
+   F(1920, P_BI_TCXO, 1, 0, 0),
+   { }
+};
+
+static struct clk_rcg2 gcc_sec_ctrl_clk_src = {
+   .cmd_rcgr = 0x3d030,
+   .mnd_width = 0,
+   .hid_width = 5,
+   .parent_map = gcc_parent_map_3,
+   .freq_tbl = ftbl_gcc_sec_ctrl_clk_src,
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "gcc_sec_ctrl_clk_src",
+   .parent_data = gcc_parent_data_3,
+   .num_parents = 3,


ARRAY_SIZE please.



Will take care of the same.


+   .ops = _rcg2_ops,
+   },
+};
+
  static struct clk_branch gcc_aggre_ufs_phy_axi_clk = {
 .halt_reg = 0x82024,
 .halt_check = BRANCH_HALT_DELAY,


--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.

--


Re: [PATCH v1 1/3] clk: qcom: gcc: Add support for a new frequency for SC7180

2020-05-17 Thread Taniya Das

Hello Stephen,

Thanks for your review.

On 3/16/2020 11:19 PM, Stephen Boyd wrote:

Quoting Taniya Das (2020-03-16 03:54:40)

There is a requirement to support 51.2MHz from GPLL6 for qup clocks,
thus update the frequency table and parent data/map to use the GPLL6
source PLL.

Signed-off-by: Taniya Das 
---


Any Fixes: tag for this? I guess the beginning of this driver being
introduced?



Sure, will add the same.


  drivers/clk/qcom/gcc-sc7180.c | 73 ++-
  1 file changed, 37 insertions(+), 36 deletions(-)

diff --git a/drivers/clk/qcom/gcc-sc7180.c b/drivers/clk/qcom/gcc-sc7180.c
index 7f59fb8..ad75847 100644
--- a/drivers/clk/qcom/gcc-sc7180.c
+++ b/drivers/clk/qcom/gcc-sc7180.c
@@ -405,8 +406,8 @@ static const struct freq_tbl 
ftbl_gcc_qupv3_wrap0_s0_clk_src[] = {

  static struct clk_init_data gcc_qupv3_wrap0_s0_clk_src_init = {
 .name = "gcc_qupv3_wrap0_s0_clk_src",
-   .parent_data = gcc_parent_data_0,
-   .num_parents = 4,
+   .parent_data = gcc_parent_data_1,


This should have been done initially. We shouldn't need to describe
"new" parents when they have always been there. Are there other clks in
this driver that actually have more parents than we've currently
described? If so, please fix them.



The auto generation script does not consider to define the parent unless 
it is used in the frequency table to derive a frequency. For now I 
didn't find any other sources missed.



+   .num_parents = 5,


Can you use ARRAY_SIZE(gcc_parent_data_1) instead? That way this isn't a
hard-coded value.



Yes will take care of it too.


 .ops = _rcg2_ops,
  };



--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.

--


[PATCH] iio: adc: ad7780: Fix a resource handling path in 'ad7780_probe()'

2020-05-17 Thread Christophe JAILLET
If 'ad7780_init_gpios()' fails, we must not release some resources that
have not been allocated yet. Return directly instead.

Fixes: 5bb30e7daf00 ("staging: iio: ad7780: move regulator to after GPIO init")
Fixes: 9085daa4abcc ("staging: iio: ad7780: add gain & filter gpio support")
Signed-off-by: Christophe JAILLET 
---
 drivers/iio/adc/ad7780.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c
index f47606ee..b33fe6c3907e 100644
--- a/drivers/iio/adc/ad7780.c
+++ b/drivers/iio/adc/ad7780.c
@@ -329,7 +329,7 @@ static int ad7780_probe(struct spi_device *spi)
 
ret = ad7780_init_gpios(>dev, st);
if (ret)
-   goto error_cleanup_buffer_and_trigger;
+   return ret;
 
st->reg = devm_regulator_get(>dev, "avdd");
if (IS_ERR(st->reg))
-- 
2.25.1



[PATCH 01/29] modpost: drop RCS/CVS $Revision handling in MODULE_VERSION()

2020-05-17 Thread Masahiro Yamada
As far as I understood, this code gets rid of '$Revision$' or '$Revision:'
of CVS, RCS or whatever in MODULE_VERSION() tags.

Remove the primeval code.

Signed-off-by: Masahiro Yamada 
---

 scripts/mod/modpost.c|  3 --
 scripts/mod/modpost.h|  4 ---
 scripts/mod/sumversion.c | 66 
 3 files changed, 73 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 4d4b979d76be..77e5425759e2 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2074,9 +2074,6 @@ static void read_symbols(const char *modname)
check_sec_ref(mod, modname, );
 
version = get_modinfo(, "version");
-   if (version)
-   maybe_frob_rcs_version(modname, version, info.modinfo,
-  version - (char *)info.hdr);
if (version || (all_versions && !is_vmlinux(modname)))
get_src_version(modname, mod->srcversion,
sizeof(mod->srcversion)-1);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 39f6c29fb568..bbaf5cc37bfb 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -187,10 +187,6 @@ void handle_moddevtable(struct module *mod, struct 
elf_info *info,
 void add_moddevtable(struct buffer *buf, struct module *mod);
 
 /* sumversion.c */
-void maybe_frob_rcs_version(const char *modfilename,
-   char *version,
-   void *modinfo,
-   unsigned long modinfo_offset);
 void get_src_version(const char *modname, char sum[], unsigned sumlen);
 
 /* from modpost.c */
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index 63062024ce0e..f27f22420cbc 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -429,69 +429,3 @@ void get_src_version(const char *modname, char sum[], 
unsigned sumlen)
 release:
release_file(file, len);
 }
-
-static void write_version(const char *filename, const char *sum,
- unsigned long offset)
-{
-   int fd;
-
-   fd = open(filename, O_RDWR);
-   if (fd < 0) {
-   warn("changing sum in %s failed: %s\n",
-   filename, strerror(errno));
-   return;
-   }
-
-   if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
-   warn("changing sum in %s:%lu failed: %s\n",
-   filename, offset, strerror(errno));
-   goto out;
-   }
-
-   if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
-   warn("writing sum in %s failed: %s\n",
-   filename, strerror(errno));
-   goto out;
-   }
-out:
-   close(fd);
-}
-
-static int strip_rcs_crap(char *version)
-{
-   unsigned int len, full_len;
-
-   if (strncmp(version, "$Revision", strlen("$Revision")) != 0)
-   return 0;
-
-   /* Space for version string follows. */
-   full_len = strlen(version) + strlen(version + strlen(version) + 1) + 2;
-
-   /* Move string to start with version number: prefix will be
-* $Revision$ or $Revision: */
-   len = strlen("$Revision");
-   if (version[len] == ':' || version[len] == '$')
-   len++;
-   while (isspace(version[len]))
-   len++;
-   memmove(version, version+len, full_len-len);
-   full_len -= len;
-
-   /* Preserve up to next whitespace. */
-   len = 0;
-   while (version[len] && !isspace(version[len]))
-   len++;
-   memmove(version + len, version + strlen(version),
-   full_len - strlen(version));
-   return 1;
-}
-
-/* Clean up RCS-style version numbers. */
-void maybe_frob_rcs_version(const char *modfilename,
-   char *version,
-   void *modinfo,
-   unsigned long version_offset)
-{
-   if (strip_rcs_crap(version))
-   write_version(modfilename, version, version_offset);
-}
-- 
2.25.1



[PATCH 10/29] modpost: move -T option close to the modpost command

2020-05-17 Thread Masahiro Yamada
The '-T -' option reads the file list from stdin.

It is clearer to put it close to the piped command.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.modpost | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index b79bf0e30d32..da7730a43819 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -66,7 +66,7 @@ __modpost:
 
 else
 
-MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \
+MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s \
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
 
 ifeq ($(KBUILD_EXTMOD),)
@@ -88,7 +88,7 @@ modules := $(sort $(shell cat $(MODORDER)))
 # Read out modules.order instead of expanding $(modules) to pass in modpost.
 # Otherwise, allmodconfig would fail with "Argument list too long".
 quiet_cmd_modpost = MODPOST $(words $(modules)) modules
-  cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST)
+  cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) -T -
 
 __modpost:
$(call cmd,modpost)
-- 
2.25.1



[PATCH 20/29] modpost: generate vmlinux.symvers and reuse it for the second modpost

2020-05-17 Thread Masahiro Yamada
The full build runs modpost twice, first for vmlinux.o and second for
modules.

The first pass dumps all the vmlinux symbols into Module.symvers, but
the second pass parses vmlinux again instead of reusing the dump file,
presumably because it needs to avoid accumulating stale symbols.

Loading symbol info from a dump file is faster than parsing an ELF object.
Besides, modpost deals with various issues to parse vmlinux in the second
pass.

A solution is to make the first pass dumps symbols into a separate file,
vmlinux.symvers. The second pass reads it, and parses module .o files.
The merged symbol information is dumped into Module.symvers as before.

This makes further modpost cleanups possible.

Also, it fixes the problem of 'make vmlinux', which previously overwrote
Module.symvers, throwing away module symbols.

I slightly touched scripts/link-vmlinux.sh so that vmlinux is re-linked
when you cross this commit. Otherwise, vmlinux.symvers would not be
generated.

Signed-off-by: Masahiro Yamada 
---

 .gitignore   |  1 +
 Makefile |  2 +-
 scripts/Makefile.modpost | 11 +++
 scripts/link-vmlinux.sh  |  2 --
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index 2258e906f01c..87b9dd8a163b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ modules.order
 /linux
 /vmlinux
 /vmlinux.32
+/vmlinux.symvers
 /vmlinux-gdb.py
 /vmlinuz
 /System.map
diff --git a/Makefile b/Makefile
index 27e8a0522a3c..43988ce4e17e 100644
--- a/Makefile
+++ b/Makefile
@@ -1405,7 +1405,7 @@ endif # CONFIG_MODULES
 # make distclean Remove editor backup files, patch leftover files and the like
 
 # Directories & files removed with 'make clean'
-CLEAN_FILES += include/ksym \
+CLEAN_FILES += include/ksym vmlinux.symvers \
   modules.builtin modules.builtin.modinfo modules.nsdeps
 
 # Directories & files removed with 'make mrproper'
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index d14143b30b7a..1c597999b6a0 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -43,17 +43,17 @@ __modpost:
 include include/config/auto.conf
 include scripts/Kbuild.include
 
-kernelsymfile := $(objtree)/Module.symvers
-
 MODPOST = scripts/mod/modpost  
\
$(if $(CONFIG_MODVERSIONS),-m)  
\
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a)
\
-   $(if $(KBUILD_EXTMOD),,-o $(kernelsymfile)) 
\
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E)  
\
$(if $(KBUILD_MODPOST_WARN),-w)
 
 ifdef MODPOST_VMLINUX
 
+# modpost options for vmlinux.o
+MODPOST += -o vmlinux.symvers
+
 quiet_cmd_modpost = MODPOST vmlinux.o
   cmd_modpost = $(MODPOST) vmlinux.o
 
@@ -68,7 +68,10 @@ MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s \
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
 
 ifeq ($(KBUILD_EXTMOD),)
-MODPOST += $(wildcard vmlinux)
+
+# modpost options for in-kernel modules
+MODPOST += -i vmlinux.symvers -o Module.symvers
+
 else
 
 # set src + obj - they may be used in the modules's Makefile
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index d09ab4afbda4..d5af6be50b50 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -218,8 +218,6 @@ on_signals()
 }
 trap on_signals HUP INT QUIT TERM
 
-#
-#
 # Use "make V=1" to debug this script
 case "${KBUILD_VERBOSE}" in
 *1*)
-- 
2.25.1



[PATCH 05/29] modpost: re-add warning about missing *.mod file

2020-05-17 Thread Masahiro Yamada
This reverts 4be40e22233c ("kbuild: do not emit src version warning for
non-modules").

I do not fully understand what that commit addressed, but commit
91341d4b2c19 ("kbuild: introduce new option to enhance section mismatch
analysis") introduced partial section checks by using modpost. built-in.o
was parsed by modpost. Even modules had a problem because *.mod files
were created after the modpost check.

Commit b7dca6dd1e59 ("kbuild: create *.mod with full directory path and
remove MODVERDIR") stopped doing that. Now that modpost is only invoked
after the directory descend, *.mod files should always exist at the
modpost stage. If not, something went wrong, which should be warned.

Signed-off-by: Masahiro Yamada 
---

 scripts/mod/sumversion.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index f9aa532d93cf..f9df0b1863f1 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -402,9 +402,11 @@ void get_src_version(const char *modname, char sum[], 
unsigned sumlen)
 (int)strlen(modname) - 1, modname);
 
buf = read_text_file(filelist);
-   if (!buf)
-   /* not a module or .mod file missing - ignore */
+   if (!buf) {
+   warn("failed to open %s. cannot calculate checksum\n",
+filelist);
return;
+   }
 
pos = buf;
firstline = get_line();
-- 
2.25.1



[PATCH 12/29] modpost: move external module options

2020-05-17 Thread Masahiro Yamada
Separate out the external-only code for readability.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.modpost | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index bc5561aedb24..8321068abb31 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -44,14 +44,11 @@ include include/config/auto.conf
 include scripts/Kbuild.include
 
 kernelsymfile := $(objtree)/Module.symvers
-modulesymfile := $(KBUILD_EXTMOD)/Module.symvers
 
 MODPOST = scripts/mod/modpost  
\
$(if $(CONFIG_MODVERSIONS),-m)  
\
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a)
\
-   $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile)   
\
-   $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) 
\
-   $(if $(KBUILD_EXTMOD),-o $(modulesymfile))  
\
+   $(if $(KBUILD_EXTMOD),,-o $(kernelsymfile)) 
\
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E)  
\
$(if $(KBUILD_MODPOST_WARN),-w)
 
@@ -81,6 +78,13 @@ src := $(obj)
 # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
 include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
  $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
+
+# modpost options for external modules
+MODPOST += \
+   -i Module.symvers \
+   $(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS)) \
+   -o $(KBUILD_EXTMOD)/Module.symvers
+
 endif
 
 # find all modules listed in modules.order
-- 
2.25.1



[PATCH 06/29] modpost: avoid false-positive file open error

2020-05-17 Thread Masahiro Yamada
One problem of grab_file() is that it cannot distinguish the following
two cases:

 - I cannot read the file (the file does not exist, or read permission
   is not set)

 - It can read the file, but the file size is zero

This is because grab_file() calls mmap(), which requires the mapped
length is greater than 0. Hence, grab_file() fails for both cases.

If an empty header file were included from a module that requires checksum
calculation, the following warning would be printed:

  WARNING: modpost: could not open ...: Invalid argument

An empty file is a valid source file, so it should not fail.

Use read_text_file() instead. It can read a zero-length file.
Then, parse_file() will succeed with doing nothing.

Signed-off-by: Masahiro Yamada 
---

 scripts/mod/sumversion.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index f9df0b1863f1..a1c7b0f4cd5a 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -258,10 +258,12 @@ static int parse_file(const char *fname, struct md4_ctx 
*md)
char *file;
unsigned long i, len;
 
-   file = grab_file(fname, );
+   file = read_text_file(fname);
if (!file)
return 0;
 
+   len = strlen(file);
+
for (i = 0; i < len; i++) {
/* Collapse and ignore \ and CR. */
if (file[i] == '\\' && (i+1 < len) && file[i+1] == '\n') {
@@ -287,7 +289,7 @@ static int parse_file(const char *fname, struct md4_ctx *md)
 
add_char(file[i], md);
}
-   release_file(file, len);
+   free(file);
return 1;
 }
 /* Check whether the file is a static library or not */
-- 
2.25.1



[PATCH 15/29] modpost: allow to pass -i option multiple times remove -e option

2020-05-17 Thread Masahiro Yamada
Now that there is no difference in the functionality of -i and -e,
they can be unified.

Make modpost accept the -i option multiple times, then remove -e.

I will reuse -e for a different purpose.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.modpost | 2 +-
 scripts/mod/modpost.c| 9 +
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 8321068abb31..a316095c843c 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -82,7 +82,7 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
 # modpost options for external modules
 MODPOST += \
-i Module.symvers \
-   $(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS)) \
+   $(addprefix -i ,$(KBUILD_EXTRA_SYMBOLS)) \
-o $(KBUILD_EXTMOD)/Module.symvers
 
 endif
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 340b88647e94..d3141b217b57 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2548,7 +2548,6 @@ int main(int argc, char **argv)
 {
struct module *mod;
struct buffer buf = { };
-   char *kernel_read = NULL;
char *missing_namespace_deps = NULL;
char *dump_write = NULL, *files_source = NULL;
int opt;
@@ -2557,13 +2556,9 @@ int main(int argc, char **argv)
struct ext_sym_list *extsym_start = NULL;
struct ext_sym_list **extsym_iter = _start;
 
-   while ((opt = getopt(argc, argv, "i:e:mnsT:o:awENd:")) != -1) {
+   while ((opt = getopt(argc, argv, "i:mnsT:o:awENd:")) != -1) {
switch (opt) {
case 'i':
-   kernel_read = optarg;
-   external_module = 1;
-   break;
-   case 'e':
external_module = 1;
*extsym_iter = NOFAIL(calloc(1, sizeof(**extsym_iter)));
(*extsym_iter)->file = optarg;
@@ -2604,8 +2599,6 @@ int main(int argc, char **argv)
}
}
 
-   if (kernel_read)
-   read_dump(kernel_read);
while (extsym_start) {
struct ext_sym_list *tmp;
 
-- 
2.25.1



[PATCH 14/29] modpost: track if the symbol origin is a dump file or ELF object

2020-05-17 Thread Masahiro Yamada
The meaning of sym->kernel is obscure; it is set for in-kernel symbols
loaded from Modules.symver. This happens only when we are building
external modules, and it is used to determine whether to dump symbols
to $(KBUILD_EXTMOD)/Modules.symver

It is clearer to remember whether the symbol or module came from a dump
file or ELF object.

This changes the KBUILD_EXTRA_SYMBOLS behavior. Previously, symbols
loaded from KBUILD_EXTRA_SYMBOLS are accumulated into the current
$(KBUILD_EXTMOD)/Modules.symver

Going forward, they will be only used to check symbol references, but
not dumped into the current $(KBUILD_EXTMOD)/Modules.symver. I believe
this makes more sense.

sym->vmlinux will have no user. Remove it too.

Signed-off-by: Masahiro Yamada 
---

 scripts/mod/modpost.c | 15 +--
 scripts/mod/modpost.h |  1 +
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index dc8f15f10da0..340b88647e94 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -197,9 +197,6 @@ struct symbol {
int crc_valid;
char *namespace;
unsigned int weak:1;
-   unsigned int vmlinux:1;/* 1 if symbol is defined in vmlinux */
-   unsigned int kernel:1; /* 1 if symbol is from kernel
-   *  (only for external modules) **/
unsigned int is_static:1;  /* 1 if symbol is not global */
enum export  export;   /* Type of export */
char name[];
@@ -431,8 +428,6 @@ static struct symbol *sym_add_exported(const char *name, 
struct module *mod,
}
 
s->module = mod;
-   s->vmlinux   = is_vmlinux(mod->name);
-   s->kernel= 0;
s->export= export;
return s;
 }
@@ -2430,7 +2425,7 @@ static void write_if_changed(struct buffer *b, const char 
*fname)
 /* parse Module.symvers file. line format:
  * 0x12345678symbolmoduleexportnamespace
  **/
-static void read_dump(const char *fname, unsigned int kernel)
+static void read_dump(const char *fname)
 {
char *buf, *pos, *line;
 
@@ -2469,9 +2464,9 @@ static void read_dump(const char *fname, unsigned int 
kernel)
have_vmlinux = 1;
mod = new_module(modname);
mod->skip = 1;
+   mod->from_dump = 1;
}
s = sym_add_exported(symname, mod, export_no(export));
-   s->kernel= kernel;
s->is_static = 0;
sym_set_crc(symname, crc);
sym_update_namespace(symname, namespace);
@@ -2491,7 +2486,7 @@ static int dump_sym(struct symbol *sym)
 {
if (!external_module)
return 1;
-   if (sym->vmlinux || sym->kernel)
+   if (sym->module->from_dump)
return 0;
return 1;
 }
@@ -2610,11 +2605,11 @@ int main(int argc, char **argv)
}
 
if (kernel_read)
-   read_dump(kernel_read, 1);
+   read_dump(kernel_read);
while (extsym_start) {
struct ext_sym_list *tmp;
 
-   read_dump(extsym_start->file, 0);
+   read_dump(extsym_start->file);
tmp = extsym_start->next;
free(extsym_start);
extsym_start = tmp;
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 232a0e11fcaa..aaf3c4ad5d60 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -119,6 +119,7 @@ struct module {
const char *name;
int gpl_compatible;
struct symbol *unres;
+   int from_dump;  /* 1 if module was loaded from *.symver */
int seen;
int skip;
int has_init;
-- 
2.25.1



[PATCH 07/29] modpost: use read_text_file() and get_line() for reading text files

2020-05-17 Thread Masahiro Yamada
grab_file() mmaps a file, but it is not so efficient here because
get_next_line() copies every line to the temporary buffer anyway.

read_text_file() and get_line() are simpler. get_line() exploits the
library function strchr().

Signed-off-by: Masahiro Yamada 
---

 scripts/mod/modpost.c| 15 ---
 scripts/mod/sumversion.c | 11 ++-
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 2c6319f0ce19..8021f7e93448 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2466,15 +2466,16 @@ static void write_if_changed(struct buffer *b, const 
char *fname)
  **/
 static void read_dump(const char *fname, unsigned int kernel)
 {
-   unsigned long size, pos = 0;
-   void *file = grab_file(fname, );
-   char *line;
+   char *buf, *pos, *line;
 
-   if (!file)
+   buf = read_text_file(fname);
+   if (!buf)
/* No symbol versions, silently ignore */
return;
 
-   while ((line = get_next_line(, file, size))) {
+   pos = buf;
+
+   while ((line = get_line())) {
char *symname, *namespace, *modname, *d, *export;
unsigned int crc;
struct module *mod;
@@ -2509,10 +2510,10 @@ static void read_dump(const char *fname, unsigned int 
kernel)
sym_set_crc(symname, crc);
sym_update_namespace(symname, namespace);
}
-   release_file(file, size);
+   free(buf);
return;
 fail:
-   release_file(file, size);
+   free(buf);
fatal("parse error in symbol dump file\n");
 }
 
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index a1c7b0f4cd5a..89c8baefde9d 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -306,9 +306,8 @@ static int is_static_library(const char *objfile)
  * to figure out source files. */
 static int parse_source_files(const char *objfile, struct md4_ctx *md)
 {
-   char *cmd, *file, *line, *dir;
+   char *cmd, *file, *line, *dir, *pos;
const char *base;
-   unsigned long flen, pos = 0;
int dirlen, ret = 0, check_files = 0;
 
cmd = NOFAIL(malloc(strlen(objfile) + sizeof("..cmd")));
@@ -326,14 +325,16 @@ static int parse_source_files(const char *objfile, struct 
md4_ctx *md)
strncpy(dir, objfile, dirlen);
dir[dirlen] = '\0';
 
-   file = grab_file(cmd, );
+   file = read_text_file(cmd);
if (!file) {
warn("could not find %s for %s\n", cmd, objfile);
goto out;
}
 
+   pos = file;
+
/* Sum all files in the same dir or subdirs. */
-   while ((line = get_next_line(, file, flen)) != NULL) {
+   while ((line = get_line())) {
char* p = line;
 
if (strncmp(line, "source_", sizeof("source_")-1) == 0) {
@@ -384,7 +385,7 @@ static int parse_source_files(const char *objfile, struct 
md4_ctx *md)
/* Everyone parsed OK */
ret = 1;
 out_file:
-   release_file(file, flen);
+   free(file);
 out:
free(dir);
free(cmd);
-- 
2.25.1



[PATCH 19/29] modpost: show warning if it fails to read symbol dump file

2020-05-17 Thread Masahiro Yamada
If modpost fails to load a symbol dump file, it cannot check unresolved
symbols, hence module dependency will not be added. Nor CRCs can be added.

Currently, external module builds check only $(objtree)/Module.symvers,
but it should check files specified by KBUILD_EXTRA_SYMBOLS as well.

Print the warnings in modpost. The warning in Makefile is unneeded.

Signed-off-by: Masahiro Yamada 
---

 Makefile  | 10 +-
 scripts/mod/modpost.c | 11 +--
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index aeb690c692ee..27e8a0522a3c 100644
--- a/Makefile
+++ b/Makefile
@@ -1638,17 +1638,9 @@ else # KBUILD_EXTMOD
 # We are always building modules
 KBUILD_MODULES := 1
 
-PHONY += $(objtree)/Module.symvers
-$(objtree)/Module.symvers:
-   @test -e $(objtree)/Module.symvers || ( \
-   echo; \
-   echo "  WARNING: Symbol version dump $(objtree)/Module.symvers"; \
-   echo "   is missing; modules will have no dependencies and 
modversions."; \
-   echo )
-
 build-dirs := $(KBUILD_EXTMOD)
 PHONY += modules
-modules: descend $(objtree)/Module.symvers
+modules: descend
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
 PHONY += modules_install
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 8150be00e3df..ff715623b37e 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -41,6 +41,8 @@ static int sec_mismatch_fatal = 0;
 static int ignore_missing_files;
 /* If set to 1, only warn (instead of error) about missing ns imports */
 static int allow_missing_ns_imports;
+/* Set when at list one dump file is missing */
+static int missing_dump_file;
 
 enum export {
export_plain,  export_unused, export_gpl,
@@ -2428,9 +2430,11 @@ static void read_dump(const char *fname)
char *buf, *pos, *line;
 
buf = read_text_file(fname);
-   if (!buf)
-   /* No symbol versions, silently ignore */
+   if (!buf) {
+   warn("failed to read '%s'\n", fname);
+   missing_dump_file = 1;
return;
+   }
 
pos = buf;
 
@@ -2615,6 +2619,9 @@ int main(int argc, char **argv)
if (files_source)
read_symbols_from_files(files_source);
 
+   if (missing_dump_file)
+   warn("Symbol dump file is missing. Modules may not have 
dependencies or movversions.\n");
+
/*
 * When there's no vmlinux, don't print warnings about
 * unresolved symbols (since there'll be too many ;)
-- 
2.25.1



<    1   2   3   4   5   >