Re: [PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread kbuild test robot
Hi Venkat,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.9 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Venkat-Prashanth-B-U/rtc-add-support-for-rtc-NXP-pca21125-and-pca8565/20161225-150140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
rtc-next
config: i386-randconfig-x016-201652 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   drivers/rtc/rtc-pcf8563.c: In function 'pca21125_probe':
>> drivers/rtc/rtc-pcf8563.c:666:32: warning: passing argument 1 of 
>> '__devm_regmap_init_spi' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 regmap = devm_regmap_init_spi(spi, );
   ^
   include/linux/regmap.h:505:6: note: in definition of macro 
'__regmap_lockdep_wrapper'
  fn(__VA_ARGS__, &_key, \
 ^~~
>> drivers/rtc/rtc-pcf8563.c:666:11: note: in expansion of macro 
>> 'devm_regmap_init_spi'
 regmap = devm_regmap_init_spi(spi, );
  ^~~~
   include/linux/regmap.h:470:16: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
   ^~
>> drivers/rtc/rtc-pcf8563.c:674:12: error: assignment of member 'mode' in 
>> read-only object
 spi->mode = SPI_MODE_3;
   ^
>> drivers/rtc/rtc-pcf8563.c:675:21: error: assignment of member 
>> 'bits_per_word' in read-only object
 spi->bits_per_word = 8;
^
>> drivers/rtc/rtc-pcf8563.c:676:12: warning: passing argument 1 of 'spi_setup' 
>> discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 spi_setup(spi);
   ^~~
   In file included from drivers/rtc/rtc-pcf8563.c:25:0:
   include/linux/spi/spi.h:905:12: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
extern int spi_setup(struct spi_device *spi);
   ^
>> drivers/rtc/rtc-pcf8563.c:678:20: warning: passing argument 1 of 
>> 'regmap_read' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_SC, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
   drivers/rtc/rtc-pcf8563.c:682:20: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
>> drivers/rtc/rtc-pcf8563.c:687:21: warning: passing argument 1 of 
>> 'regmap_write' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^~~~
   drivers/rtc/rtc-pcf8563.c:692:20: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_SR, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
   drivers/rtc/rtc-pcf8563.c:697:21: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_wr

Re: [PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread kbuild test robot
Hi Venkat,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.9 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Venkat-Prashanth-B-U/rtc-add-support-for-rtc-NXP-pca21125-and-pca8565/20161225-150140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
rtc-next
config: i386-randconfig-x016-201652 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   drivers/rtc/rtc-pcf8563.c: In function 'pca21125_probe':
>> drivers/rtc/rtc-pcf8563.c:666:32: warning: passing argument 1 of 
>> '__devm_regmap_init_spi' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 regmap = devm_regmap_init_spi(spi, );
   ^
   include/linux/regmap.h:505:6: note: in definition of macro 
'__regmap_lockdep_wrapper'
  fn(__VA_ARGS__, &_key, \
 ^~~
>> drivers/rtc/rtc-pcf8563.c:666:11: note: in expansion of macro 
>> 'devm_regmap_init_spi'
 regmap = devm_regmap_init_spi(spi, );
  ^~~~
   include/linux/regmap.h:470:16: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
   ^~
>> drivers/rtc/rtc-pcf8563.c:674:12: error: assignment of member 'mode' in 
>> read-only object
 spi->mode = SPI_MODE_3;
   ^
>> drivers/rtc/rtc-pcf8563.c:675:21: error: assignment of member 
>> 'bits_per_word' in read-only object
 spi->bits_per_word = 8;
^
>> drivers/rtc/rtc-pcf8563.c:676:12: warning: passing argument 1 of 'spi_setup' 
>> discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 spi_setup(spi);
   ^~~
   In file included from drivers/rtc/rtc-pcf8563.c:25:0:
   include/linux/spi/spi.h:905:12: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
extern int spi_setup(struct spi_device *spi);
   ^
>> drivers/rtc/rtc-pcf8563.c:678:20: warning: passing argument 1 of 
>> 'regmap_read' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_SC, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
   drivers/rtc/rtc-pcf8563.c:682:20: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
>> drivers/rtc/rtc-pcf8563.c:687:21: warning: passing argument 1 of 
>> 'regmap_write' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^~~~
   drivers/rtc/rtc-pcf8563.c:692:20: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_read(regmap, PCF8563_REG_SR, );
   ^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^~~
   drivers/rtc/rtc-pcf8563.c:697:21: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
^~
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_wr

[kvm-unit-tests PATCH] Makefile: Disable PIE as GCC enables it by default from 6.2.0-7

2016-12-24 Thread Gavin Guo
Build fail can be observed while the kvm-unit-tests builds on Ubuntu
Yakkety/Zesty release:

/usr/bin/ld: x86/cstart64.o: relocation R_X86_64_32 against `.data'
can not be used when making a shared object; recompile with -fPIC

and can be fixed by adding "-fno-pic" and "-no-pie" option.

There are other discussions:
- gcc-6 6.2.0-7 breaks kernel build if stack protection is enabled
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841368
- [yakkety,RFC,v1] disable -pie when gcc has it enabled by default
https://patchwork.ozlabs.org/patch/616621/
- https://wiki.ubuntu.com/YakketyYak/ReleaseNotes#GCC

Signed-off-by: Gavin Guo 
Signed-off-by: Hsiangkai Wang 
Signed-off-by: Cole Wang 
Tested-by: Po-Hsu Lin 
---
 Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index a32333b0928e..4c9fbfbb6714 100644
--- a/Makefile
+++ b/Makefile
@@ -51,10 +51,14 @@ fomit_frame_pointer := $(call cc-option, 
$(frame-pointer-flag), "")
 fnostack_protector := $(call cc-option, -fno-stack-protector, "")
 fnostack_protector_all := $(call cc-option, -fno-stack-protector-all, "")
 wno_frame_address := $(call cc-option, -Wno-frame-address, "")
+fno_pic := $(call cc-option, -fno-pic, "")
+no_pie := $(call cc-option, -no-pie, "")
 CFLAGS += $(fomit_frame_pointer)
 CFLAGS += $(fno_stack_protector)
 CFLAGS += $(fno_stack_protector_all)
 CFLAGS += $(wno_frame_address)
+CFLAGS += $(fno_pic)
+CFLAGS += $(no_pie)
 
 CXXFLAGS += $(CFLAGS)
 
-- 
2.7.4



[kvm-unit-tests PATCH] Makefile: Disable PIE as GCC enables it by default from 6.2.0-7

2016-12-24 Thread Gavin Guo
Build fail can be observed while the kvm-unit-tests builds on Ubuntu
Yakkety/Zesty release:

/usr/bin/ld: x86/cstart64.o: relocation R_X86_64_32 against `.data'
can not be used when making a shared object; recompile with -fPIC

and can be fixed by adding "-fno-pic" and "-no-pie" option.

There are other discussions:
- gcc-6 6.2.0-7 breaks kernel build if stack protection is enabled
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841368
- [yakkety,RFC,v1] disable -pie when gcc has it enabled by default
https://patchwork.ozlabs.org/patch/616621/
- https://wiki.ubuntu.com/YakketyYak/ReleaseNotes#GCC

Signed-off-by: Gavin Guo 
Signed-off-by: Hsiangkai Wang 
Signed-off-by: Cole Wang 
Tested-by: Po-Hsu Lin 
---
 Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index a32333b0928e..4c9fbfbb6714 100644
--- a/Makefile
+++ b/Makefile
@@ -51,10 +51,14 @@ fomit_frame_pointer := $(call cc-option, 
$(frame-pointer-flag), "")
 fnostack_protector := $(call cc-option, -fno-stack-protector, "")
 fnostack_protector_all := $(call cc-option, -fno-stack-protector-all, "")
 wno_frame_address := $(call cc-option, -Wno-frame-address, "")
+fno_pic := $(call cc-option, -fno-pic, "")
+no_pie := $(call cc-option, -no-pie, "")
 CFLAGS += $(fomit_frame_pointer)
 CFLAGS += $(fno_stack_protector)
 CFLAGS += $(fno_stack_protector_all)
 CFLAGS += $(wno_frame_address)
+CFLAGS += $(fno_pic)
+CFLAGS += $(no_pie)
 
 CXXFLAGS += $(CFLAGS)
 
-- 
2.7.4



Re: [PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread kbuild test robot
Hi Venkat,

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v4.9 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Venkat-Prashanth-B-U/rtc-add-support-for-rtc-NXP-pca21125-and-pca8565/20161225-150140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
rtc-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   drivers/rtc/rtc-pcf8563.c: In function 'pca21125_probe':
>> include/linux/regmap.h:667:27: warning: passing argument 1 of 
>> '__devm_regmap_init_spi' discards 'const' qualifier from pointer target type
 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \
  ^
   include/linux/regmap.h:505:3: note: in definition of macro 
'__regmap_lockdep_wrapper'
  fn(__VA_ARGS__, &_key, \
  ^
   drivers/rtc/rtc-pcf8563.c:666:11: note: in expansion of macro 
'devm_regmap_init_spi'
 regmap = devm_regmap_init_spi(spi, );
  ^
   include/linux/regmap.h:470:16: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
   ^
   drivers/rtc/rtc-pcf8563.c:674:12: error: assignment of member 'mode' in 
read-only object
 spi->mode = SPI_MODE_3;
   ^
   drivers/rtc/rtc-pcf8563.c:675:21: error: assignment of member 
'bits_per_word' in read-only object
 spi->bits_per_word = 8;
^
   drivers/rtc/rtc-pcf8563.c:676:2: warning: passing argument 1 of 'spi_setup' 
discards 'const' qualifier from pointer target type
 spi_setup(spi);
 ^
   In file included from drivers/rtc/rtc-pcf8563.c:25:0:
   include/linux/spi/spi.h:905:12: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
extern int spi_setup(struct spi_device *spi);
   ^
   drivers/rtc/rtc-pcf8563.c:678:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_SC, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:682:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:687:8: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type
 res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^
   drivers/rtc/rtc-pcf8563.c:692:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_SR, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:697:8: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type
 res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^
   drivers/rtc/rtc-pcf8563.c:703:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/re

Re: [PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread kbuild test robot
Hi Venkat,

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v4.9 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Venkat-Prashanth-B-U/rtc-add-support-for-rtc-NXP-pca21125-and-pca8565/20161225-150140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
rtc-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   drivers/rtc/rtc-pcf8563.c: In function 'pca21125_probe':
>> include/linux/regmap.h:667:27: warning: passing argument 1 of 
>> '__devm_regmap_init_spi' discards 'const' qualifier from pointer target type
 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \
  ^
   include/linux/regmap.h:505:3: note: in definition of macro 
'__regmap_lockdep_wrapper'
  fn(__VA_ARGS__, &_key, \
  ^
   drivers/rtc/rtc-pcf8563.c:666:11: note: in expansion of macro 
'devm_regmap_init_spi'
 regmap = devm_regmap_init_spi(spi, );
  ^
   include/linux/regmap.h:470:16: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
   ^
   drivers/rtc/rtc-pcf8563.c:674:12: error: assignment of member 'mode' in 
read-only object
 spi->mode = SPI_MODE_3;
   ^
   drivers/rtc/rtc-pcf8563.c:675:21: error: assignment of member 
'bits_per_word' in read-only object
 spi->bits_per_word = 8;
^
   drivers/rtc/rtc-pcf8563.c:676:2: warning: passing argument 1 of 'spi_setup' 
discards 'const' qualifier from pointer target type
 spi_setup(spi);
 ^
   In file included from drivers/rtc/rtc-pcf8563.c:25:0:
   include/linux/spi/spi.h:905:12: note: expected 'struct spi_device *' but 
argument is of type 'const struct spi_device *'
extern int spi_setup(struct spi_device *spi);
   ^
   drivers/rtc/rtc-pcf8563.c:678:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_SC, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:682:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:687:8: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type
 res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^
   drivers/rtc/rtc-pcf8563.c:692:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_SR, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:758:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
^
   drivers/rtc/rtc-pcf8563.c:697:8: warning: passing argument 1 of 
'regmap_write' discards 'const' qualifier from pointer target type
 res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/regmap.h:745:5: note: expected 'struct regmap *' but argument 
is of type 'const struct regmap *'
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
^
   drivers/rtc/rtc-pcf8563.c:703:8: warning: passing argument 1 of 
'regmap_read' discards 'const' qualifier from pointer target type
 res = regmap_read(regmap, PCF8563_REG_CLKO, );
   ^
   In file included from drivers/rtc/rtc-pcf8563.c:26:0:
   include/linux/re

undefined reference to `_text'

2016-12-24 Thread kbuild test robot
Hi Randy,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 7c7808ce107d63e158dbbc3af085980985a0c3c4 openrisc: prevent VGA console, 
fix builds
date:   13 days ago
config: openrisc-alldefconfig (attached as .config)
compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 7c7808ce107d63e158dbbc3af085980985a0c3c4
# save the attached .config to linux build tree
make.cross ARCH=openrisc 

All errors (new ones prefixed by >>):

   .tmp_kallsyms1.o: In function `kallsyms_relative_base':
>> (.rodata+0x8a18): undefined reference to `_text'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


undefined reference to `_text'

2016-12-24 Thread kbuild test robot
Hi Randy,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 7c7808ce107d63e158dbbc3af085980985a0c3c4 openrisc: prevent VGA console, 
fix builds
date:   13 days ago
config: openrisc-alldefconfig (attached as .config)
compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 7c7808ce107d63e158dbbc3af085980985a0c3c4
# save the attached .config to linux build tree
make.cross ARCH=openrisc 

All errors (new ones prefixed by >>):

   .tmp_kallsyms1.o: In function `kallsyms_relative_base':
>> (.rodata+0x8a18): undefined reference to `_text'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread Venkat Prashanth B U
This is a patch to support the SPI compatible PCA21125 device
with the I2C based rtc-pcf8563 driver using regmap layer.
Further this patch adds "pca8565" to the set of i2c ids.

Signed-off-by: Venkat Prashanth B U 
---
change log v3:
1. Add a regmap layer to I2C PCF8563 to support SPI PCA21125.
2. Add pca8565 to the set of i2c ids of rtc-pcf8563.
---
---
 drivers/rtc/rtc-pcf8563.c | 82 +++
 1 file changed, 82 insertions(+)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 1227cea..26c8b9b 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -22,6 +22,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -59,6 +61,7 @@
 
 #define PCF8563_SC_LV  0x80 /* low voltage */
 #define PCF8563_MO_C   0x80 /* century */
+#define PCF8563_REG_SR 0x01 /*control-status register*/
 
 static struct i2c_driver pcf8563_driver;
 
@@ -84,6 +87,9 @@ struct pcf8563 {
struct i2c_client *client;
 #ifdef CONFIG_COMMON_CLK
struct clk_hw   clkout_hw;
+const  struct device *dev;
+const  struct regmap *regmap;
+   bool suspended;
 #endif
 };
 
@@ -629,6 +635,7 @@ static int pcf8563_probe(struct i2c_client *client,
 static const struct i2c_device_id pcf8563_id[] = {
{ "pcf8563", 0 },
{ "rtc8564", 0 },
+   { "pca8565", 0 },
{ }
 };
 MODULE_DEVICE_TABLE(i2c, pcf8563_id);
@@ -636,11 +643,86 @@ MODULE_DEVICE_TABLE(i2c, pcf8563_id);
 #ifdef CONFIG_OF
 static const struct of_device_id pcf8563_of_match[] = {
{ .compatible = "nxp,pcf8563" },
+   { .compatible = "nxp,pca8565" },
{}
 };
 MODULE_DEVICE_TABLE(of, pcf8563_of_match);
 #endif
 
+#if IS_ENABLED(CONFIG_SPI_MASTER)
+
+static int pca21125_probe(const struct spi_device *spi)
+{
+   int res;
+   unsigned int tmp;
+   static const struct regmap_config config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .write_flag_mask = 0x80,
+   };
+const struct regmap *regmap;
+const struct pcf8563 *pcf8563;
+
+   regmap = devm_regmap_init_spi(spi, );
+
+   if (IS_ERR(regmap)) {
+   dev_err(>dev, "%s: regmap allocation 
failed: %ld\n",
+   __func__, PTR_ERR(regmap));
+   return PTR_ERR(regmap);
+   }
+
+   spi->mode = SPI_MODE_3;
+   spi->bits_per_word = 8;
+   spi_setup(spi);
+
+   res = regmap_read(regmap, PCF8563_REG_SC, );
+
+   if (res)
+   return res;
+   res = regmap_read(regmap, PCF8563_REG_CLKO, );
+
+   if (res)
+   return res;
+
+   res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
+
+   if (res)
+   return res;
+
+   res = regmap_read(regmap, PCF8563_REG_SR, );
+
+   if (res)
+   return res;
+
+   res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
+
+   if (res)
+   return res;
+
+   /* Print our settings */
+   res = regmap_read(regmap, PCF8563_REG_CLKO, );
+
+   if (res)
+   return res;
+
+   dev_info(>dev, "Control Reg: 0x%02x\n", tmp);
+   res = regmap_read(regmap, PCF8563_REG_SR, );
+
+   if (res)
+   return res;
+
+   dev_info(>dev, "Ctrl/Stat Reg: 0x%02x\n", tmp);
+
+   pcf8563->rtc = devm_rtc_device_register(>dev,
+   "pcf8563",
+   _rtc_ops, THIS_MODULE);
+}
+
+const struct spi_driver pca21125_driver = {
+   .driver = {
+   .name= "pca21125",
+   },
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
.name   = "rtc-pcf8563",
-- 
1.9.2



[PATCH] rtc: add support for rtc NXP pca21125 and pca8565

2016-12-24 Thread Venkat Prashanth B U
This is a patch to support the SPI compatible PCA21125 device
with the I2C based rtc-pcf8563 driver using regmap layer.
Further this patch adds "pca8565" to the set of i2c ids.

Signed-off-by: Venkat Prashanth B U 
---
change log v3:
1. Add a regmap layer to I2C PCF8563 to support SPI PCA21125.
2. Add pca8565 to the set of i2c ids of rtc-pcf8563.
---
---
 drivers/rtc/rtc-pcf8563.c | 82 +++
 1 file changed, 82 insertions(+)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 1227cea..26c8b9b 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -22,6 +22,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define PCF8563_REG_ST10x00 /* status */
 #define PCF8563_REG_ST20x01
@@ -59,6 +61,7 @@
 
 #define PCF8563_SC_LV  0x80 /* low voltage */
 #define PCF8563_MO_C   0x80 /* century */
+#define PCF8563_REG_SR 0x01 /*control-status register*/
 
 static struct i2c_driver pcf8563_driver;
 
@@ -84,6 +87,9 @@ struct pcf8563 {
struct i2c_client *client;
 #ifdef CONFIG_COMMON_CLK
struct clk_hw   clkout_hw;
+const  struct device *dev;
+const  struct regmap *regmap;
+   bool suspended;
 #endif
 };
 
@@ -629,6 +635,7 @@ static int pcf8563_probe(struct i2c_client *client,
 static const struct i2c_device_id pcf8563_id[] = {
{ "pcf8563", 0 },
{ "rtc8564", 0 },
+   { "pca8565", 0 },
{ }
 };
 MODULE_DEVICE_TABLE(i2c, pcf8563_id);
@@ -636,11 +643,86 @@ MODULE_DEVICE_TABLE(i2c, pcf8563_id);
 #ifdef CONFIG_OF
 static const struct of_device_id pcf8563_of_match[] = {
{ .compatible = "nxp,pcf8563" },
+   { .compatible = "nxp,pca8565" },
{}
 };
 MODULE_DEVICE_TABLE(of, pcf8563_of_match);
 #endif
 
+#if IS_ENABLED(CONFIG_SPI_MASTER)
+
+static int pca21125_probe(const struct spi_device *spi)
+{
+   int res;
+   unsigned int tmp;
+   static const struct regmap_config config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .write_flag_mask = 0x80,
+   };
+const struct regmap *regmap;
+const struct pcf8563 *pcf8563;
+
+   regmap = devm_regmap_init_spi(spi, );
+
+   if (IS_ERR(regmap)) {
+   dev_err(>dev, "%s: regmap allocation 
failed: %ld\n",
+   __func__, PTR_ERR(regmap));
+   return PTR_ERR(regmap);
+   }
+
+   spi->mode = SPI_MODE_3;
+   spi->bits_per_word = 8;
+   spi_setup(spi);
+
+   res = regmap_read(regmap, PCF8563_REG_SC, );
+
+   if (res)
+   return res;
+   res = regmap_read(regmap, PCF8563_REG_CLKO, );
+
+   if (res)
+   return res;
+
+   res = regmap_write(regmap, PCF8563_REG_CLKO, tmp & 0x1c);
+
+   if (res)
+   return res;
+
+   res = regmap_read(regmap, PCF8563_REG_SR, );
+
+   if (res)
+   return res;
+
+   res = regmap_write(regmap, PCF8563_REG_SR, tmp & 0x88);
+
+   if (res)
+   return res;
+
+   /* Print our settings */
+   res = regmap_read(regmap, PCF8563_REG_CLKO, );
+
+   if (res)
+   return res;
+
+   dev_info(>dev, "Control Reg: 0x%02x\n", tmp);
+   res = regmap_read(regmap, PCF8563_REG_SR, );
+
+   if (res)
+   return res;
+
+   dev_info(>dev, "Ctrl/Stat Reg: 0x%02x\n", tmp);
+
+   pcf8563->rtc = devm_rtc_device_register(>dev,
+   "pcf8563",
+   _rtc_ops, THIS_MODULE);
+}
+
+const struct spi_driver pca21125_driver = {
+   .driver = {
+   .name= "pca21125",
+   },
+
 static struct i2c_driver pcf8563_driver = {
.driver = {
.name   = "rtc-pcf8563",
-- 
1.9.2



[PATCH v2] ipv4: Namespaceify tcp_tw_reuse knob

2016-12-24 Thread Haishuang Yan
Different namespaces might have different requirements to reuse
TIME-WAIT sockets for new connections. This might be required in
cases where different namespace applications are in place which
require TIME_WAIT socket connections to be reduced independently
of the host.

Signed-off-by: Haishuang Yan 

---
Changes in v2:
  - Make the commit message more clearer.
---
 include/net/netns/ipv4.h   |  1 +
 include/net/tcp.h  |  1 -
 net/ipv4/sysctl_net_ipv4.c | 14 +++---
 net/ipv4/tcp_ipv4.c|  4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index f0cf5a1..0378e88 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -110,6 +110,7 @@ struct netns_ipv4 {
int sysctl_tcp_orphan_retries;
int sysctl_tcp_fin_timeout;
unsigned int sysctl_tcp_notsent_lowat;
+   int sysctl_tcp_tw_reuse;
 
int sysctl_igmp_max_memberships;
int sysctl_igmp_max_msf;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 207147b..6061963 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -252,7 +252,6 @@
 extern int sysctl_tcp_rmem[3];
 extern int sysctl_tcp_app_win;
 extern int sysctl_tcp_adv_win_scale;
-extern int sysctl_tcp_tw_reuse;
 extern int sysctl_tcp_frto;
 extern int sysctl_tcp_low_latency;
 extern int sysctl_tcp_nometrics_save;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 80bc36b..22cbd61 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -433,13 +433,6 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, 
int write,
.extra2 = _adv_win_scale_max,
},
{
-   .procname   = "tcp_tw_reuse",
-   .data   = _tcp_tw_reuse,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec
-   },
-   {
.procname   = "tcp_frto",
.data   = _tcp_frto,
.maxlen = sizeof(int),
@@ -960,6 +953,13 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, 
int write,
.mode   = 0644,
.proc_handler   = proc_dointvec,
},
+   {
+   .procname   = "tcp_tw_reuse",
+   .data   = _net.ipv4.sysctl_tcp_tw_reuse,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec
+   },
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
{
.procname   = "fib_multipath_use_neigh",
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 30d81f5..fe9da4f 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -84,7 +84,6 @@
 #include 
 #include 
 
-int sysctl_tcp_tw_reuse __read_mostly;
 int sysctl_tcp_low_latency __read_mostly;
 
 #ifdef CONFIG_TCP_MD5SIG
@@ -120,7 +119,7 @@ int tcp_twsk_unique(struct sock *sk, struct sock *sktw, 
void *twp)
   and use initial timestamp retrieved from peer table.
 */
if (tcptw->tw_ts_recent_stamp &&
-   (!twp || (sysctl_tcp_tw_reuse &&
+   (!twp || (sock_net(sk)->ipv4.sysctl_tcp_tw_reuse &&
 get_seconds() - tcptw->tw_ts_recent_stamp > 1))) {
tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2;
if (tp->write_seq == 0)
@@ -2456,6 +2455,7 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_orphan_retries = 0;
net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
net->ipv4.sysctl_tcp_notsent_lowat = UINT_MAX;
+   net->ipv4.sysctl_tcp_tw_reuse = 0;
 
return 0;
 fail:
-- 
1.8.3.1





[PATCH v2] ipv4: Namespaceify tcp_tw_reuse knob

2016-12-24 Thread Haishuang Yan
Different namespaces might have different requirements to reuse
TIME-WAIT sockets for new connections. This might be required in
cases where different namespace applications are in place which
require TIME_WAIT socket connections to be reduced independently
of the host.

Signed-off-by: Haishuang Yan 

---
Changes in v2:
  - Make the commit message more clearer.
---
 include/net/netns/ipv4.h   |  1 +
 include/net/tcp.h  |  1 -
 net/ipv4/sysctl_net_ipv4.c | 14 +++---
 net/ipv4/tcp_ipv4.c|  4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index f0cf5a1..0378e88 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -110,6 +110,7 @@ struct netns_ipv4 {
int sysctl_tcp_orphan_retries;
int sysctl_tcp_fin_timeout;
unsigned int sysctl_tcp_notsent_lowat;
+   int sysctl_tcp_tw_reuse;
 
int sysctl_igmp_max_memberships;
int sysctl_igmp_max_msf;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 207147b..6061963 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -252,7 +252,6 @@
 extern int sysctl_tcp_rmem[3];
 extern int sysctl_tcp_app_win;
 extern int sysctl_tcp_adv_win_scale;
-extern int sysctl_tcp_tw_reuse;
 extern int sysctl_tcp_frto;
 extern int sysctl_tcp_low_latency;
 extern int sysctl_tcp_nometrics_save;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 80bc36b..22cbd61 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -433,13 +433,6 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, 
int write,
.extra2 = _adv_win_scale_max,
},
{
-   .procname   = "tcp_tw_reuse",
-   .data   = _tcp_tw_reuse,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec
-   },
-   {
.procname   = "tcp_frto",
.data   = _tcp_frto,
.maxlen = sizeof(int),
@@ -960,6 +953,13 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, 
int write,
.mode   = 0644,
.proc_handler   = proc_dointvec,
},
+   {
+   .procname   = "tcp_tw_reuse",
+   .data   = _net.ipv4.sysctl_tcp_tw_reuse,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec
+   },
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
{
.procname   = "fib_multipath_use_neigh",
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 30d81f5..fe9da4f 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -84,7 +84,6 @@
 #include 
 #include 
 
-int sysctl_tcp_tw_reuse __read_mostly;
 int sysctl_tcp_low_latency __read_mostly;
 
 #ifdef CONFIG_TCP_MD5SIG
@@ -120,7 +119,7 @@ int tcp_twsk_unique(struct sock *sk, struct sock *sktw, 
void *twp)
   and use initial timestamp retrieved from peer table.
 */
if (tcptw->tw_ts_recent_stamp &&
-   (!twp || (sysctl_tcp_tw_reuse &&
+   (!twp || (sock_net(sk)->ipv4.sysctl_tcp_tw_reuse &&
 get_seconds() - tcptw->tw_ts_recent_stamp > 1))) {
tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2;
if (tp->write_seq == 0)
@@ -2456,6 +2455,7 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_orphan_retries = 0;
net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
net->ipv4.sysctl_tcp_notsent_lowat = UINT_MAX;
+   net->ipv4.sysctl_tcp_tw_reuse = 0;
 
return 0;
 fail:
-- 
1.8.3.1





Re: [v2 3/7] x86/mpx, x86/insn: Relocate insn util functions to a new insn-utils

2016-12-24 Thread Masami Hiramatsu
Hi Ricado,

On Fri, 23 Dec 2016 17:37:41 -0800
Ricardo Neri  wrote:

> Other kernel submodules can benefit from using the utility functions
> defined in mpx.c to obtain the addresses and values of operands contained
> in the general purpose registers. An instance of this is the emulation code
> used for instructions protected by the Intel User-Mode Instruction
> Prevention feature.
> 
> Thus, these functions are relocated to a new insn-utils.c file. The reason
> to not relocate these utilities for insn.c is that the latter solely
> analyses instructions given by a struct insn. The file insn-utils.c intends
> to be used when, for instance, determining addresses from the contents
> of the general purpose registers.
> 
> To avoid creating a new insn-utils.h, insn.h is used. One caveat, however,
> is that several #include's were needed by the utility functions.
> 
> Functions are simply relocated. There are not functional or indentation
> changes.

Thank you for your great work! :)

> ---
>  arch/x86/include/asm/insn.h |   6 ++
>  arch/x86/lib/Makefile   |   2 +-
>  arch/x86/lib/insn-utils.c   | 148 
> 
>  arch/x86/mm/mpx.c   | 136 +---
>  4 files changed, 156 insertions(+), 136 deletions(-)
>  create mode 100644 arch/x86/lib/insn-utils.c
> 
> diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h
> index b3e32b0..9dc9d42 100644
> --- a/arch/x86/include/asm/insn.h
> +++ b/arch/x86/include/asm/insn.h
> @@ -22,6 +22,10 @@
>  
>  /* insn_attr_t is defined in inat.h */
>  #include 
> +#include 
> +#include 
> +#include 
> +#include 
>  
>  struct insn_field {
>   union {
> @@ -106,6 +110,8 @@ extern void insn_get_sib(struct insn *insn);
>  extern void insn_get_displacement(struct insn *insn);
>  extern void insn_get_immediate(struct insn *insn);
>  extern void insn_get_length(struct insn *insn);
> +extern void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs 
> *regs);
> +extern int get_reg_offset_rm(struct insn *insn, struct pt_regs *regs);

Could you also rename this to add "insn_" prefix?

Other part looks good to me :)
(btw, I saw a kbuild bot warning, would you also test it with
 CONFIG_X86_DECODER_SELFTEST=y?)

Thanks again!

>  
>  /* Attribute will be determined after getting ModRM (for opcode groups) */
>  static inline void insn_get_attribute(struct insn *insn)
> diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
> index 34a7413..0d01d82 100644
> --- a/arch/x86/lib/Makefile
> +++ b/arch/x86/lib/Makefile
> @@ -23,7 +23,7 @@ lib-y := delay.o misc.o cmdline.o cpu.o
>  lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
>  lib-y += memcpy_$(BITS).o
>  lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
> -lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o
> +lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o insn-utils.o
>  lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
>  
>  obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
> diff --git a/arch/x86/lib/insn-utils.c b/arch/x86/lib/insn-utils.c
> new file mode 100644
> index 000..598bbd6
> --- /dev/null
> +++ b/arch/x86/lib/insn-utils.c
> @@ -0,0 +1,148 @@
> +/*
> + * Utility functions for x86 operand and address decoding
> + *
> + * Copyright (C) Intel Corporation 2016
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +enum reg_type {
> + REG_TYPE_RM = 0,
> + REG_TYPE_INDEX,
> + REG_TYPE_BASE,
> +};
> +
> +static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
> +   enum reg_type type)
> +{
> + int regno = 0;
> +
> + static const int regoff[] = {
> + offsetof(struct pt_regs, ax),
> + offsetof(struct pt_regs, cx),
> + offsetof(struct pt_regs, dx),
> + offsetof(struct pt_regs, bx),
> + offsetof(struct pt_regs, sp),
> + offsetof(struct pt_regs, bp),
> + offsetof(struct pt_regs, si),
> + offsetof(struct pt_regs, di),
> +#ifdef CONFIG_X86_64
> + offsetof(struct pt_regs, r8),
> + offsetof(struct pt_regs, r9),
> + offsetof(struct pt_regs, r10),
> + offsetof(struct pt_regs, r11),
> + offsetof(struct pt_regs, r12),
> + offsetof(struct pt_regs, r13),
> + offsetof(struct pt_regs, r14),
> + offsetof(struct pt_regs, r15),
> +#endif
> + };
> + int nr_registers = ARRAY_SIZE(regoff);
> + /*
> +  * Don't possibly decode a 32-bit instructions as
> +  * reading a 64-bit-only register.
> +  */
> + if (IS_ENABLED(CONFIG_X86_64) && !insn->x86_64)
> + nr_registers -= 8;
> +
> + switch (type) {
> + case REG_TYPE_RM:
> + regno = X86_MODRM_RM(insn->modrm.value);
> + if (X86_REX_B(insn->rex_prefix.value))
> + regno += 8;
> + break;
> +
> + case 

Re: [v2 3/7] x86/mpx, x86/insn: Relocate insn util functions to a new insn-utils

2016-12-24 Thread Masami Hiramatsu
Hi Ricado,

On Fri, 23 Dec 2016 17:37:41 -0800
Ricardo Neri  wrote:

> Other kernel submodules can benefit from using the utility functions
> defined in mpx.c to obtain the addresses and values of operands contained
> in the general purpose registers. An instance of this is the emulation code
> used for instructions protected by the Intel User-Mode Instruction
> Prevention feature.
> 
> Thus, these functions are relocated to a new insn-utils.c file. The reason
> to not relocate these utilities for insn.c is that the latter solely
> analyses instructions given by a struct insn. The file insn-utils.c intends
> to be used when, for instance, determining addresses from the contents
> of the general purpose registers.
> 
> To avoid creating a new insn-utils.h, insn.h is used. One caveat, however,
> is that several #include's were needed by the utility functions.
> 
> Functions are simply relocated. There are not functional or indentation
> changes.

Thank you for your great work! :)

> ---
>  arch/x86/include/asm/insn.h |   6 ++
>  arch/x86/lib/Makefile   |   2 +-
>  arch/x86/lib/insn-utils.c   | 148 
> 
>  arch/x86/mm/mpx.c   | 136 +---
>  4 files changed, 156 insertions(+), 136 deletions(-)
>  create mode 100644 arch/x86/lib/insn-utils.c
> 
> diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h
> index b3e32b0..9dc9d42 100644
> --- a/arch/x86/include/asm/insn.h
> +++ b/arch/x86/include/asm/insn.h
> @@ -22,6 +22,10 @@
>  
>  /* insn_attr_t is defined in inat.h */
>  #include 
> +#include 
> +#include 
> +#include 
> +#include 
>  
>  struct insn_field {
>   union {
> @@ -106,6 +110,8 @@ extern void insn_get_sib(struct insn *insn);
>  extern void insn_get_displacement(struct insn *insn);
>  extern void insn_get_immediate(struct insn *insn);
>  extern void insn_get_length(struct insn *insn);
> +extern void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs 
> *regs);
> +extern int get_reg_offset_rm(struct insn *insn, struct pt_regs *regs);

Could you also rename this to add "insn_" prefix?

Other part looks good to me :)
(btw, I saw a kbuild bot warning, would you also test it with
 CONFIG_X86_DECODER_SELFTEST=y?)

Thanks again!

>  
>  /* Attribute will be determined after getting ModRM (for opcode groups) */
>  static inline void insn_get_attribute(struct insn *insn)
> diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
> index 34a7413..0d01d82 100644
> --- a/arch/x86/lib/Makefile
> +++ b/arch/x86/lib/Makefile
> @@ -23,7 +23,7 @@ lib-y := delay.o misc.o cmdline.o cpu.o
>  lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
>  lib-y += memcpy_$(BITS).o
>  lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
> -lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o
> +lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o insn-utils.o
>  lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
>  
>  obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
> diff --git a/arch/x86/lib/insn-utils.c b/arch/x86/lib/insn-utils.c
> new file mode 100644
> index 000..598bbd6
> --- /dev/null
> +++ b/arch/x86/lib/insn-utils.c
> @@ -0,0 +1,148 @@
> +/*
> + * Utility functions for x86 operand and address decoding
> + *
> + * Copyright (C) Intel Corporation 2016
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +enum reg_type {
> + REG_TYPE_RM = 0,
> + REG_TYPE_INDEX,
> + REG_TYPE_BASE,
> +};
> +
> +static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
> +   enum reg_type type)
> +{
> + int regno = 0;
> +
> + static const int regoff[] = {
> + offsetof(struct pt_regs, ax),
> + offsetof(struct pt_regs, cx),
> + offsetof(struct pt_regs, dx),
> + offsetof(struct pt_regs, bx),
> + offsetof(struct pt_regs, sp),
> + offsetof(struct pt_regs, bp),
> + offsetof(struct pt_regs, si),
> + offsetof(struct pt_regs, di),
> +#ifdef CONFIG_X86_64
> + offsetof(struct pt_regs, r8),
> + offsetof(struct pt_regs, r9),
> + offsetof(struct pt_regs, r10),
> + offsetof(struct pt_regs, r11),
> + offsetof(struct pt_regs, r12),
> + offsetof(struct pt_regs, r13),
> + offsetof(struct pt_regs, r14),
> + offsetof(struct pt_regs, r15),
> +#endif
> + };
> + int nr_registers = ARRAY_SIZE(regoff);
> + /*
> +  * Don't possibly decode a 32-bit instructions as
> +  * reading a 64-bit-only register.
> +  */
> + if (IS_ENABLED(CONFIG_X86_64) && !insn->x86_64)
> + nr_registers -= 8;
> +
> + switch (type) {
> + case REG_TYPE_RM:
> + regno = X86_MODRM_RM(insn->modrm.value);
> + if (X86_REX_B(insn->rex_prefix.value))
> + regno += 8;
> + break;
> +
> + case REG_TYPE_INDEX:
> + regno = 

Re: Detecting kprobes generated code addresses

2016-12-24 Thread Masami Hiramatsu
On Sun, 25 Dec 2016 12:13:20 +0900
Masami Hiramatsu  wrote:

> On Thu, 22 Dec 2016 00:42:19 -0600
> Josh Poimboeuf  wrote:
> 
> > Hi Masami,
> > 
> > I would like to make __kernel_text_address() be able to detect whether
> > an address belongs to code which was generated by kprobes.  As far as I
> > can tell, that information seems to be in the 'pages' lists of
> > kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
> > protected by mutexes.
> 
> Right. It is currently under mutex because it may kick
> page allocation. But I think it is easy to fix that :)

Hmm, IMHO, it seems that we should add a dummy (auto-generated)
symbol for optprobe trampoline code to kallsyms so that
__kernel_text_address() automatically returns true on it.

Thank you,

-- 
Masami Hiramatsu 


Re: Detecting kprobes generated code addresses

2016-12-24 Thread Masami Hiramatsu
On Sun, 25 Dec 2016 12:13:20 +0900
Masami Hiramatsu  wrote:

> On Thu, 22 Dec 2016 00:42:19 -0600
> Josh Poimboeuf  wrote:
> 
> > Hi Masami,
> > 
> > I would like to make __kernel_text_address() be able to detect whether
> > an address belongs to code which was generated by kprobes.  As far as I
> > can tell, that information seems to be in the 'pages' lists of
> > kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
> > protected by mutexes.
> 
> Right. It is currently under mutex because it may kick
> page allocation. But I think it is easy to fix that :)

Hmm, IMHO, it seems that we should add a dummy (auto-generated)
symbol for optprobe trampoline code to kallsyms so that
__kernel_text_address() automatically returns true on it.

Thank you,

-- 
Masami Hiramatsu 


core.c:undefined reference to `fpu_save'

2016-12-24 Thread kbuild test robot
Hi Andrew,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: c60f169202c7643991a8b4bfeea60e06843d5b5a 
arch/mn10300/kernel/fpu-nofpu.c: needs asm/elf.h
date:   9 months ago
config: mn10300-allnoconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout c60f169202c7643991a8b4bfeea60e06843d5b5a
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

All errors (new ones prefixed by >>):

   kernel/built-in.o: In function `.L410':
>> core.c:(.sched.text+0x28a): undefined reference to `fpu_save'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


core.c:undefined reference to `fpu_save'

2016-12-24 Thread kbuild test robot
Hi Andrew,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: c60f169202c7643991a8b4bfeea60e06843d5b5a 
arch/mn10300/kernel/fpu-nofpu.c: needs asm/elf.h
date:   9 months ago
config: mn10300-allnoconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout c60f169202c7643991a8b4bfeea60e06843d5b5a
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

All errors (new ones prefixed by >>):

   kernel/built-in.o: In function `.L410':
>> core.c:(.sched.text+0x28a): undefined reference to `fpu_save'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

2016-12-24 Thread Hugh Dickins
On Sun, 25 Dec 2016, Nicholas Piggin wrote:

> A page is not added to the swap cache without being swap backed,
> so PageSwapBacked mappings can use PG_owner_priv_1 for PageSwapCache.
> 
> Acked-by: Hugh Dickins 

Yes, confirmed, Acked-by: Hugh Dickins 
I checked through your migrate and memory-failure additions,
and both look correct to me.  I still think that more should
be done for KPF_SWAPCACHE, to exclude the new false positives;
but as I said before, no urgency, that can be a later followup.

> Signed-off-by: Nicholas Piggin 
> ---
>  include/linux/page-flags.h | 24 
>  include/trace/events/mmflags.h |  1 -
>  mm/memory-failure.c|  4 +---
>  mm/migrate.c   | 14 --
>  4 files changed, 25 insertions(+), 18 deletions(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 74e4dda91238..a57c909a15e4 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -87,7 +87,6 @@ enum pageflags {
>   PG_private_2,   /* If pagecache, has fs aux data */
>   PG_writeback,   /* Page is under writeback */
>   PG_head,/* A head page */
> - PG_swapcache,   /* Swap page: swp_entry_t in private */
>   PG_mappedtodisk,/* Has blocks allocated on-disk */
>   PG_reclaim, /* To be reclaimed asap */
>   PG_swapbacked,  /* Page is backed by RAM/swap */
> @@ -110,6 +109,9 @@ enum pageflags {
>   /* Filesystems */
>   PG_checked = PG_owner_priv_1,
>  
> + /* SwapBacked */
> + PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private */
> +
>   /* Two page bits are conscripted by FS-Cache to maintain local caching
>* state.  These bits are set on pages belonging to the netfs's inodes
>* when those inodes are being locally cached.
> @@ -314,7 +316,13 @@ PAGEFLAG_FALSE(HighMem)
>  #endif
>  
>  #ifdef CONFIG_SWAP
> -PAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
> +static __always_inline int PageSwapCache(struct page *page)
> +{
> + return PageSwapBacked(page) && test_bit(PG_swapcache, >flags);
> +
> +}
> +SETPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
> +CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
>  #else
>  PAGEFLAG_FALSE(SwapCache)
>  #endif
> @@ -701,12 +709,12 @@ static inline void ClearPageSlabPfmemalloc(struct page 
> *page)
>   * Flags checked when a page is freed.  Pages being freed should not have
>   * these flags set.  It they are, there is a problem.
>   */
> -#define PAGE_FLAGS_CHECK_AT_FREE \
> - (1UL << PG_lru   | 1UL << PG_locked| \
> -  1UL << PG_private | 1UL << PG_private_2 | \
> -  1UL << PG_writeback | 1UL << PG_reserved | \
> -  1UL << PG_slab  | 1UL << PG_swapcache | 1UL << PG_active | \
> -  1UL << PG_unevictable | __PG_MLOCKED)
> +#define PAGE_FLAGS_CHECK_AT_FREE \
> + (1UL << PG_lru  | 1UL << PG_locked  |   \
> +  1UL << PG_private  | 1UL << PG_private_2   |   \
> +  1UL << PG_writeback| 1UL << PG_reserved|   \
> +  1UL << PG_slab | 1UL << PG_active  |   \
> +  1UL << PG_unevictable  | __PG_MLOCKED)
>  
>  /*
>   * Flags checked when a page is prepped for return by the page allocator.
> diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
> index 5a81ab48a2fb..30c2adbdebe8 100644
> --- a/include/trace/events/mmflags.h
> +++ b/include/trace/events/mmflags.h
> @@ -95,7 +95,6 @@
>   {1UL << PG_private_2,   "private_2" },  \
>   {1UL << PG_writeback,   "writeback" },  \
>   {1UL << PG_head,"head"  },  \
> - {1UL << PG_swapcache,   "swapcache" },  \
>   {1UL << PG_mappedtodisk,"mappedtodisk"  },  \
>   {1UL << PG_reclaim, "reclaim"   },  \
>   {1UL << PG_swapbacked,  "swapbacked"},  \
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 19e796d36a62..f283c7e0a2a3 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -764,12 +764,11 @@ static int me_huge_page(struct page *p, unsigned long 
> pfn)
>   */
>  
>  #define dirty(1UL << PG_dirty)
> -#define sc   (1UL << PG_swapcache)
> +#define sc   ((1UL << PG_swapcache) | (1UL << PG_swapbacked))
>  #define unevict  (1UL << PG_unevictable)
>  #define mlock(1UL << PG_mlocked)
>  #define writeback(1UL << PG_writeback)
>  #define lru  (1UL << PG_lru)
> -#define swapbacked   (1UL << PG_swapbacked)
>  #define head (1UL << PG_head)
>  #define slab (1UL << PG_slab)
>  #define reserved (1UL << PG_reserved)
> @@ -819,7 +818,6 @@ static struct page_state {
>  #undef mlock
>  #undef 

Re: [PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

2016-12-24 Thread Hugh Dickins
On Sun, 25 Dec 2016, Nicholas Piggin wrote:

> A page is not added to the swap cache without being swap backed,
> so PageSwapBacked mappings can use PG_owner_priv_1 for PageSwapCache.
> 
> Acked-by: Hugh Dickins 

Yes, confirmed, Acked-by: Hugh Dickins 
I checked through your migrate and memory-failure additions,
and both look correct to me.  I still think that more should
be done for KPF_SWAPCACHE, to exclude the new false positives;
but as I said before, no urgency, that can be a later followup.

> Signed-off-by: Nicholas Piggin 
> ---
>  include/linux/page-flags.h | 24 
>  include/trace/events/mmflags.h |  1 -
>  mm/memory-failure.c|  4 +---
>  mm/migrate.c   | 14 --
>  4 files changed, 25 insertions(+), 18 deletions(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 74e4dda91238..a57c909a15e4 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -87,7 +87,6 @@ enum pageflags {
>   PG_private_2,   /* If pagecache, has fs aux data */
>   PG_writeback,   /* Page is under writeback */
>   PG_head,/* A head page */
> - PG_swapcache,   /* Swap page: swp_entry_t in private */
>   PG_mappedtodisk,/* Has blocks allocated on-disk */
>   PG_reclaim, /* To be reclaimed asap */
>   PG_swapbacked,  /* Page is backed by RAM/swap */
> @@ -110,6 +109,9 @@ enum pageflags {
>   /* Filesystems */
>   PG_checked = PG_owner_priv_1,
>  
> + /* SwapBacked */
> + PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private */
> +
>   /* Two page bits are conscripted by FS-Cache to maintain local caching
>* state.  These bits are set on pages belonging to the netfs's inodes
>* when those inodes are being locally cached.
> @@ -314,7 +316,13 @@ PAGEFLAG_FALSE(HighMem)
>  #endif
>  
>  #ifdef CONFIG_SWAP
> -PAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
> +static __always_inline int PageSwapCache(struct page *page)
> +{
> + return PageSwapBacked(page) && test_bit(PG_swapcache, >flags);
> +
> +}
> +SETPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
> +CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
>  #else
>  PAGEFLAG_FALSE(SwapCache)
>  #endif
> @@ -701,12 +709,12 @@ static inline void ClearPageSlabPfmemalloc(struct page 
> *page)
>   * Flags checked when a page is freed.  Pages being freed should not have
>   * these flags set.  It they are, there is a problem.
>   */
> -#define PAGE_FLAGS_CHECK_AT_FREE \
> - (1UL << PG_lru   | 1UL << PG_locked| \
> -  1UL << PG_private | 1UL << PG_private_2 | \
> -  1UL << PG_writeback | 1UL << PG_reserved | \
> -  1UL << PG_slab  | 1UL << PG_swapcache | 1UL << PG_active | \
> -  1UL << PG_unevictable | __PG_MLOCKED)
> +#define PAGE_FLAGS_CHECK_AT_FREE \
> + (1UL << PG_lru  | 1UL << PG_locked  |   \
> +  1UL << PG_private  | 1UL << PG_private_2   |   \
> +  1UL << PG_writeback| 1UL << PG_reserved|   \
> +  1UL << PG_slab | 1UL << PG_active  |   \
> +  1UL << PG_unevictable  | __PG_MLOCKED)
>  
>  /*
>   * Flags checked when a page is prepped for return by the page allocator.
> diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
> index 5a81ab48a2fb..30c2adbdebe8 100644
> --- a/include/trace/events/mmflags.h
> +++ b/include/trace/events/mmflags.h
> @@ -95,7 +95,6 @@
>   {1UL << PG_private_2,   "private_2" },  \
>   {1UL << PG_writeback,   "writeback" },  \
>   {1UL << PG_head,"head"  },  \
> - {1UL << PG_swapcache,   "swapcache" },  \
>   {1UL << PG_mappedtodisk,"mappedtodisk"  },  \
>   {1UL << PG_reclaim, "reclaim"   },  \
>   {1UL << PG_swapbacked,  "swapbacked"},  \
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 19e796d36a62..f283c7e0a2a3 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -764,12 +764,11 @@ static int me_huge_page(struct page *p, unsigned long 
> pfn)
>   */
>  
>  #define dirty(1UL << PG_dirty)
> -#define sc   (1UL << PG_swapcache)
> +#define sc   ((1UL << PG_swapcache) | (1UL << PG_swapbacked))
>  #define unevict  (1UL << PG_unevictable)
>  #define mlock(1UL << PG_mlocked)
>  #define writeback(1UL << PG_writeback)
>  #define lru  (1UL << PG_lru)
> -#define swapbacked   (1UL << PG_swapbacked)
>  #define head (1UL << PG_head)
>  #define slab (1UL << PG_slab)
>  #define reserved (1UL << PG_reserved)
> @@ -819,7 +818,6 @@ static struct page_state {
>  #undef mlock
>  #undef writeback
>  #undef lru
> -#undef swapbacked
>  #undef 

arch/xtensa/include/asm/initialize_mmu.h:41: Error: invalid register 'atomctl' for 'wsr' instruction

2016-12-24 Thread kbuild test robot
Hi Pete,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: d0b73b488c55df905ea8faaad079f8535629ed26 xtensa: Add config files for 
Diamond 233L - Rev C processor variant
date:   3 years, 10 months ago
config: xtensa-generic_kc705_defconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout d0b73b488c55df905ea8faaad079f8535629ed26
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All errors (new ones prefixed by >>):

   arch/xtensa/include/asm/initialize_mmu.h: Assembler messages:
>> arch/xtensa/include/asm/initialize_mmu.h:41: Error: invalid register 
>> 'atomctl' for 'wsr' instruction

vim +41 arch/xtensa/include/asm/initialize_mmu.h

c622b29d Max Filippov 2012-11-19  25  
c622b29d Max Filippov 2012-11-19  26  #ifdef __ASSEMBLY__
c622b29d Max Filippov 2012-11-19  27  
c622b29d Max Filippov 2012-11-19  28  #define XTENSA_HWVERSION_RC_2009_0 23
c622b29d Max Filippov 2012-11-19  29  
c622b29d Max Filippov 2012-11-19  30.macro  initialize_mmu
c622b29d Max Filippov 2012-11-19  31  
c622b29d Max Filippov 2012-11-19  32  #if XCHAL_HAVE_S32C1I && 
(XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RC_2009_0)
c622b29d Max Filippov 2012-11-19  33  /*
c622b29d Max Filippov 2012-11-19  34   * We Have Atomic Operation Control 
(ATOMCTL) Register; Initialize it.
c622b29d Max Filippov 2012-11-19  35   * For details see 
Documentation/xtensa/atomctl.txt
c622b29d Max Filippov 2012-11-19  36   */
c622b29d Max Filippov 2012-11-19  37  #if XCHAL_DCACHE_IS_COHERENT
c622b29d Max Filippov 2012-11-19  38movia3, 0x25/* For SMP/MX 
-- internal for writeback,
c622b29d Max Filippov 2012-11-19  39 * RCW otherwise
c622b29d Max Filippov 2012-11-19  40 */
c622b29d Max Filippov 2012-11-19 @41  #else
c622b29d Max Filippov 2012-11-19  42movia3, 0x29/* non-MX -- 
Most cores use Std Memory
c622b29d Max Filippov 2012-11-19  43 * Controlers 
which usually can't use RCW
c622b29d Max Filippov 2012-11-19  44 */
c622b29d Max Filippov 2012-11-19  45  #endif
c622b29d Max Filippov 2012-11-19  46wsr a3, atomctl
c622b29d Max Filippov 2012-11-19  47  #endif  /* XCHAL_HAVE_S32C1I &&
c622b29d Max Filippov 2012-11-19  48 * (XCHAL_HW_MIN_VERSION >= 
XTENSA_HWVERSION_RC_2009_0)
c622b29d Max Filippov 2012-11-19  49 */

:: The code at line 41 was first introduced by commit
:: c622b29d1f38021411965b7e0170ab01b257 xtensa: initialize atomctl SR

:: TO: Max Filippov 
:: CC: Chris Zankel 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


arch/xtensa/include/asm/initialize_mmu.h:41: Error: invalid register 'atomctl' for 'wsr' instruction

2016-12-24 Thread kbuild test robot
Hi Pete,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: d0b73b488c55df905ea8faaad079f8535629ed26 xtensa: Add config files for 
Diamond 233L - Rev C processor variant
date:   3 years, 10 months ago
config: xtensa-generic_kc705_defconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout d0b73b488c55df905ea8faaad079f8535629ed26
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All errors (new ones prefixed by >>):

   arch/xtensa/include/asm/initialize_mmu.h: Assembler messages:
>> arch/xtensa/include/asm/initialize_mmu.h:41: Error: invalid register 
>> 'atomctl' for 'wsr' instruction

vim +41 arch/xtensa/include/asm/initialize_mmu.h

c622b29d Max Filippov 2012-11-19  25  
c622b29d Max Filippov 2012-11-19  26  #ifdef __ASSEMBLY__
c622b29d Max Filippov 2012-11-19  27  
c622b29d Max Filippov 2012-11-19  28  #define XTENSA_HWVERSION_RC_2009_0 23
c622b29d Max Filippov 2012-11-19  29  
c622b29d Max Filippov 2012-11-19  30.macro  initialize_mmu
c622b29d Max Filippov 2012-11-19  31  
c622b29d Max Filippov 2012-11-19  32  #if XCHAL_HAVE_S32C1I && 
(XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RC_2009_0)
c622b29d Max Filippov 2012-11-19  33  /*
c622b29d Max Filippov 2012-11-19  34   * We Have Atomic Operation Control 
(ATOMCTL) Register; Initialize it.
c622b29d Max Filippov 2012-11-19  35   * For details see 
Documentation/xtensa/atomctl.txt
c622b29d Max Filippov 2012-11-19  36   */
c622b29d Max Filippov 2012-11-19  37  #if XCHAL_DCACHE_IS_COHERENT
c622b29d Max Filippov 2012-11-19  38movia3, 0x25/* For SMP/MX 
-- internal for writeback,
c622b29d Max Filippov 2012-11-19  39 * RCW otherwise
c622b29d Max Filippov 2012-11-19  40 */
c622b29d Max Filippov 2012-11-19 @41  #else
c622b29d Max Filippov 2012-11-19  42movia3, 0x29/* non-MX -- 
Most cores use Std Memory
c622b29d Max Filippov 2012-11-19  43 * Controlers 
which usually can't use RCW
c622b29d Max Filippov 2012-11-19  44 */
c622b29d Max Filippov 2012-11-19  45  #endif
c622b29d Max Filippov 2012-11-19  46wsr a3, atomctl
c622b29d Max Filippov 2012-11-19  47  #endif  /* XCHAL_HAVE_S32C1I &&
c622b29d Max Filippov 2012-11-19  48 * (XCHAL_HW_MIN_VERSION >= 
XTENSA_HWVERSION_RC_2009_0)
c622b29d Max Filippov 2012-11-19  49 */

:: The code at line 41 was first introduced by commit
:: c622b29d1f38021411965b7e0170ab01b257 xtensa: initialize atomctl SR

:: TO: Max Filippov 
:: CC: Chris Zankel 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


drivers/net/ethernet/intel/igb/igb_ptp.c:397: warning: array subscript is below array bounds

2016-12-24 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: d1cbfd771ce8297fa11e89f315392de6056a2181 ptp_clock: Allow for it to be 
optional
date:   6 weeks ago
config: x86_64-randconfig-s1-12251102 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout d1cbfd771ce8297fa11e89f315392de6056a2181
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/intel/igb/igb_ptp.c: In function 
'igb_ptp_feature_enable_i210':
>> drivers/net/ethernet/intel/igb/igb_ptp.c:397: warning: array subscript is 
>> below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:400: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:452: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:455: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:458: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:460: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:463: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:465: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:467: warning: array subscript is 
below array bounds

vim +397 drivers/net/ethernet/intel/igb/igb_ptp.c

720db4ff Richard Cochran 2014-11-21  381TS_SDP0_EN, TS_SDP1_EN, 
TS_SDP2_EN, TS_SDP3_EN,
720db4ff Richard Cochran 2014-11-21  382};
b23c0cc5 Alexander Duyck 2015-03-06  383struct e1000_hw *hw = >hw;
720db4ff Richard Cochran 2014-11-21  384u32 ctrl, ctrl_ext, tssdp = 0;
720db4ff Richard Cochran 2014-11-21  385  
720db4ff Richard Cochran 2014-11-21  386ctrl = rd32(E1000_CTRL);
720db4ff Richard Cochran 2014-11-21  387ctrl_ext = rd32(E1000_CTRL_EXT);
720db4ff Richard Cochran 2014-11-21  388tssdp = rd32(E1000_TSSDP);
720db4ff Richard Cochran 2014-11-21  389  
720db4ff Richard Cochran 2014-11-21  390igb_pin_direction(pin, 1, 
, _ext);
720db4ff Richard Cochran 2014-11-21  391  
720db4ff Richard Cochran 2014-11-21  392/* Make sure this pin is not 
enabled as an output. */
720db4ff Richard Cochran 2014-11-21  393tssdp &= ~ts_sdp_en[pin];
720db4ff Richard Cochran 2014-11-21  394  
720db4ff Richard Cochran 2014-11-21  395if (chan == 1) {
720db4ff Richard Cochran 2014-11-21  396tssdp &= ~AUX1_SEL_SDP3;
720db4ff Richard Cochran 2014-11-21 @397tssdp |= 
aux1_sel_sdp[pin] | AUX1_TS_SDP_EN;
720db4ff Richard Cochran 2014-11-21  398} else {
720db4ff Richard Cochran 2014-11-21  399tssdp &= ~AUX0_SEL_SDP3;
720db4ff Richard Cochran 2014-11-21  400tssdp |= 
aux0_sel_sdp[pin] | AUX0_TS_SDP_EN;
720db4ff Richard Cochran 2014-11-21  401}
720db4ff Richard Cochran 2014-11-21  402  
720db4ff Richard Cochran 2014-11-21  403wr32(E1000_TSSDP, tssdp);
720db4ff Richard Cochran 2014-11-21  404wr32(E1000_CTRL, ctrl);
720db4ff Richard Cochran 2014-11-21  405wr32(E1000_CTRL_EXT, ctrl_ext);

:: The code at line 397 was first introduced by commit
:: 720db4ffd0846570c1ddc82e7bb661ab0a676fad igb: enable auxiliary PHC 
functions for the i210

:: TO: Richard Cochran 
:: CC: Jeff Kirsher 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


drivers/net/ethernet/intel/igb/igb_ptp.c:397: warning: array subscript is below array bounds

2016-12-24 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: d1cbfd771ce8297fa11e89f315392de6056a2181 ptp_clock: Allow for it to be 
optional
date:   6 weeks ago
config: x86_64-randconfig-s1-12251102 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout d1cbfd771ce8297fa11e89f315392de6056a2181
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/intel/igb/igb_ptp.c: In function 
'igb_ptp_feature_enable_i210':
>> drivers/net/ethernet/intel/igb/igb_ptp.c:397: warning: array subscript is 
>> below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:400: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:452: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:455: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:458: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:460: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:463: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:465: warning: array subscript is 
below array bounds
   drivers/net/ethernet/intel/igb/igb_ptp.c:467: warning: array subscript is 
below array bounds

vim +397 drivers/net/ethernet/intel/igb/igb_ptp.c

720db4ff Richard Cochran 2014-11-21  381TS_SDP0_EN, TS_SDP1_EN, 
TS_SDP2_EN, TS_SDP3_EN,
720db4ff Richard Cochran 2014-11-21  382};
b23c0cc5 Alexander Duyck 2015-03-06  383struct e1000_hw *hw = >hw;
720db4ff Richard Cochran 2014-11-21  384u32 ctrl, ctrl_ext, tssdp = 0;
720db4ff Richard Cochran 2014-11-21  385  
720db4ff Richard Cochran 2014-11-21  386ctrl = rd32(E1000_CTRL);
720db4ff Richard Cochran 2014-11-21  387ctrl_ext = rd32(E1000_CTRL_EXT);
720db4ff Richard Cochran 2014-11-21  388tssdp = rd32(E1000_TSSDP);
720db4ff Richard Cochran 2014-11-21  389  
720db4ff Richard Cochran 2014-11-21  390igb_pin_direction(pin, 1, 
, _ext);
720db4ff Richard Cochran 2014-11-21  391  
720db4ff Richard Cochran 2014-11-21  392/* Make sure this pin is not 
enabled as an output. */
720db4ff Richard Cochran 2014-11-21  393tssdp &= ~ts_sdp_en[pin];
720db4ff Richard Cochran 2014-11-21  394  
720db4ff Richard Cochran 2014-11-21  395if (chan == 1) {
720db4ff Richard Cochran 2014-11-21  396tssdp &= ~AUX1_SEL_SDP3;
720db4ff Richard Cochran 2014-11-21 @397tssdp |= 
aux1_sel_sdp[pin] | AUX1_TS_SDP_EN;
720db4ff Richard Cochran 2014-11-21  398} else {
720db4ff Richard Cochran 2014-11-21  399tssdp &= ~AUX0_SEL_SDP3;
720db4ff Richard Cochran 2014-11-21  400tssdp |= 
aux0_sel_sdp[pin] | AUX0_TS_SDP_EN;
720db4ff Richard Cochran 2014-11-21  401}
720db4ff Richard Cochran 2014-11-21  402  
720db4ff Richard Cochran 2014-11-21  403wr32(E1000_TSSDP, tssdp);
720db4ff Richard Cochran 2014-11-21  404wr32(E1000_CTRL, ctrl);
720db4ff Richard Cochran 2014-11-21  405wr32(E1000_CTRL_EXT, ctrl_ext);

:: The code at line 397 was first introduced by commit
:: 720db4ffd0846570c1ddc82e7bb661ab0a676fad igb: enable auxiliary PHC 
functions for the i210

:: TO: Richard Cochran 
:: CC: Jeff Kirsher 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: Detecting kprobes generated code addresses

2016-12-24 Thread Masami Hiramatsu
On Thu, 22 Dec 2016 00:42:19 -0600
Josh Poimboeuf  wrote:

> Hi Masami,
> 
> I would like to make __kernel_text_address() be able to detect whether
> an address belongs to code which was generated by kprobes.  As far as I
> can tell, that information seems to be in the 'pages' lists of
> kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
> protected by mutexes.

Right. It is currently under mutex because it may kick
page allocation. But I think it is easy to fix that :)

>  Do you know if there's a sleep-free way to access
> that information?

Hmm, no, I couldn't find that yet.

Thanks,

-- 
Masami Hiramatsu 


Re: Detecting kprobes generated code addresses

2016-12-24 Thread Masami Hiramatsu
On Thu, 22 Dec 2016 00:42:19 -0600
Josh Poimboeuf  wrote:

> Hi Masami,
> 
> I would like to make __kernel_text_address() be able to detect whether
> an address belongs to code which was generated by kprobes.  As far as I
> can tell, that information seems to be in the 'pages' lists of
> kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
> protected by mutexes.

Right. It is currently under mutex because it may kick
page allocation. But I think it is easy to fix that :)

>  Do you know if there's a sleep-free way to access
> that information?

Hmm, no, I couldn't find that yet.

Thanks,

-- 
Masami Hiramatsu 


[PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for a page bit

2016-12-24 Thread Nicholas Piggin
Add a new page flag, PageWaiters, to indicate the page waitqueue has
tasks waiting. This can be tested rather than testing waitqueue_active
which requires another cacheline load.

This bit is always set when the page has tasks on page_waitqueue(page),
and is set and cleared under the waitqueue lock. It may be set when
there are no tasks on the waitqueue, which will cause a harmless extra
wakeup check that will clears the bit.

The generic bit-waitqueue infrastructure is no longer used for pages.
Instead, waitqueues are used directly with a custom key type. The
generic code was not flexible enough to have PageWaiters manipulation
under the waitqueue lock (which simplifies concurrency).

This improves the performance of page lock intensive microbenchmarks by
2-3%.

Putting two bits in the same word opens the opportunity to remove the
memory barrier between clearing the lock bit and testing the waiters
bit, after some work on the arch primitives (e.g., ensuring memory
operand widths match and cover both bits).

Signed-off-by: Nicholas Piggin 
---
 include/linux/mm.h |   2 +
 include/linux/page-flags.h |   9 ++
 include/linux/pagemap.h|  23 +++---
 include/linux/writeback.h  |   1 -
 include/trace/events/mmflags.h |   1 +
 init/main.c|   3 +-
 mm/filemap.c   | 181 +
 mm/internal.h  |   2 +
 mm/swap.c  |   2 +
 9 files changed, 174 insertions(+), 50 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4424784ac374..fe6b4036664a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1758,6 +1758,8 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, 
pmd_t *pmd)
return ptl;
 }
 
+extern void __init pagecache_init(void);
+
 extern void free_area_init(unsigned long * zones_size);
 extern void free_area_init_node(int nid, unsigned long * zones_size,
unsigned long zone_start_pfn, unsigned long *zholes_size);
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index a57c909a15e4..c56b39890a41 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -73,6 +73,7 @@
  */
 enum pageflags {
PG_locked,  /* Page is locked. Don't touch. */
+   PG_waiters, /* Page has waiters, check its waitqueue */
PG_error,
PG_referenced,
PG_uptodate,
@@ -169,6 +170,9 @@ static __always_inline int PageCompound(struct page *page)
  * for compound page all operations related to the page flag applied to
  * head page.
  *
+ * PF_ONLY_HEAD:
+ * for compound page, callers only ever operate on the head page.
+ *
  * PF_NO_TAIL:
  * modifications of the page flag must be done on small or head pages,
  * checks can be done on tail pages too.
@@ -178,6 +182,9 @@ static __always_inline int PageCompound(struct page *page)
  */
 #define PF_ANY(page, enforce)  page
 #define PF_HEAD(page, enforce) compound_head(page)
+#define PF_ONLY_HEAD(page, enforce) ({ \
+   VM_BUG_ON_PGFLAGS(PageTail(page), page);\
+   page;})
 #define PF_NO_TAIL(page, enforce) ({   \
VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \
compound_head(page);})
@@ -255,6 +262,7 @@ static inline int TestClearPage##uname(struct page *page) { 
return 0; }
TESTSETFLAG_FALSE(uname) TESTCLEARFLAG_FALSE(uname)
 
 __PAGEFLAG(Locked, locked, PF_NO_TAIL)
+PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, 
PF_ONLY_HEAD)
 PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, 
PF_NO_COMPOUND)
 PAGEFLAG(Referenced, referenced, PF_HEAD)
TESTCLEARFLAG(Referenced, referenced, PF_HEAD)
@@ -743,6 +751,7 @@ static inline int page_has_private(struct page *page)
 
 #undef PF_ANY
 #undef PF_HEAD
+#undef PF_ONLY_HEAD
 #undef PF_NO_TAIL
 #undef PF_NO_COMPOUND
 #endif /* !__GENERATING_BOUNDS_H */
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 7dbe9148b2f8..d7f25f754d60 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -486,22 +486,14 @@ static inline int lock_page_or_retry(struct page *page, 
struct mm_struct *mm,
  * and for filesystems which need to wait on PG_private.
  */
 extern void wait_on_page_bit(struct page *page, int bit_nr);
-
 extern int wait_on_page_bit_killable(struct page *page, int bit_nr);
-extern int wait_on_page_bit_killable_timeout(struct page *page,
-int bit_nr, unsigned long timeout);
-
-static inline int wait_on_page_locked_killable(struct page *page)
-{
-   if (!PageLocked(page))
-   return 0;
-   return wait_on_page_bit_killable(compound_head(page), PG_locked);
-}
+extern void wake_up_page_bit(struct page *page, int bit_nr);
 
-extern wait_queue_head_t 

[PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for a page bit

2016-12-24 Thread Nicholas Piggin
Add a new page flag, PageWaiters, to indicate the page waitqueue has
tasks waiting. This can be tested rather than testing waitqueue_active
which requires another cacheline load.

This bit is always set when the page has tasks on page_waitqueue(page),
and is set and cleared under the waitqueue lock. It may be set when
there are no tasks on the waitqueue, which will cause a harmless extra
wakeup check that will clears the bit.

The generic bit-waitqueue infrastructure is no longer used for pages.
Instead, waitqueues are used directly with a custom key type. The
generic code was not flexible enough to have PageWaiters manipulation
under the waitqueue lock (which simplifies concurrency).

This improves the performance of page lock intensive microbenchmarks by
2-3%.

Putting two bits in the same word opens the opportunity to remove the
memory barrier between clearing the lock bit and testing the waiters
bit, after some work on the arch primitives (e.g., ensuring memory
operand widths match and cover both bits).

Signed-off-by: Nicholas Piggin 
---
 include/linux/mm.h |   2 +
 include/linux/page-flags.h |   9 ++
 include/linux/pagemap.h|  23 +++---
 include/linux/writeback.h  |   1 -
 include/trace/events/mmflags.h |   1 +
 init/main.c|   3 +-
 mm/filemap.c   | 181 +
 mm/internal.h  |   2 +
 mm/swap.c  |   2 +
 9 files changed, 174 insertions(+), 50 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4424784ac374..fe6b4036664a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1758,6 +1758,8 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, 
pmd_t *pmd)
return ptl;
 }
 
+extern void __init pagecache_init(void);
+
 extern void free_area_init(unsigned long * zones_size);
 extern void free_area_init_node(int nid, unsigned long * zones_size,
unsigned long zone_start_pfn, unsigned long *zholes_size);
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index a57c909a15e4..c56b39890a41 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -73,6 +73,7 @@
  */
 enum pageflags {
PG_locked,  /* Page is locked. Don't touch. */
+   PG_waiters, /* Page has waiters, check its waitqueue */
PG_error,
PG_referenced,
PG_uptodate,
@@ -169,6 +170,9 @@ static __always_inline int PageCompound(struct page *page)
  * for compound page all operations related to the page flag applied to
  * head page.
  *
+ * PF_ONLY_HEAD:
+ * for compound page, callers only ever operate on the head page.
+ *
  * PF_NO_TAIL:
  * modifications of the page flag must be done on small or head pages,
  * checks can be done on tail pages too.
@@ -178,6 +182,9 @@ static __always_inline int PageCompound(struct page *page)
  */
 #define PF_ANY(page, enforce)  page
 #define PF_HEAD(page, enforce) compound_head(page)
+#define PF_ONLY_HEAD(page, enforce) ({ \
+   VM_BUG_ON_PGFLAGS(PageTail(page), page);\
+   page;})
 #define PF_NO_TAIL(page, enforce) ({   \
VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \
compound_head(page);})
@@ -255,6 +262,7 @@ static inline int TestClearPage##uname(struct page *page) { 
return 0; }
TESTSETFLAG_FALSE(uname) TESTCLEARFLAG_FALSE(uname)
 
 __PAGEFLAG(Locked, locked, PF_NO_TAIL)
+PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, 
PF_ONLY_HEAD)
 PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, 
PF_NO_COMPOUND)
 PAGEFLAG(Referenced, referenced, PF_HEAD)
TESTCLEARFLAG(Referenced, referenced, PF_HEAD)
@@ -743,6 +751,7 @@ static inline int page_has_private(struct page *page)
 
 #undef PF_ANY
 #undef PF_HEAD
+#undef PF_ONLY_HEAD
 #undef PF_NO_TAIL
 #undef PF_NO_COMPOUND
 #endif /* !__GENERATING_BOUNDS_H */
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 7dbe9148b2f8..d7f25f754d60 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -486,22 +486,14 @@ static inline int lock_page_or_retry(struct page *page, 
struct mm_struct *mm,
  * and for filesystems which need to wait on PG_private.
  */
 extern void wait_on_page_bit(struct page *page, int bit_nr);
-
 extern int wait_on_page_bit_killable(struct page *page, int bit_nr);
-extern int wait_on_page_bit_killable_timeout(struct page *page,
-int bit_nr, unsigned long timeout);
-
-static inline int wait_on_page_locked_killable(struct page *page)
-{
-   if (!PageLocked(page))
-   return 0;
-   return wait_on_page_bit_killable(compound_head(page), PG_locked);
-}
+extern void wake_up_page_bit(struct page *page, int bit_nr);
 
-extern wait_queue_head_t *page_waitqueue(struct page 

[PATCH 0/2] PageWaiters again

2016-12-24 Thread Nicholas Piggin
I cleaned up the changelog a bit and made a few tweaks to patch 1 as
described in my reply to Hugh. Resending with SOBs.

Thanks,
Nick

Nicholas Piggin (2):
  mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked
  mm: add PageWaiters indicating tasks are waiting for a page bit

 include/linux/mm.h |   2 +
 include/linux/page-flags.h |  33 ++--
 include/linux/pagemap.h|  23 +++---
 include/linux/writeback.h  |   1 -
 include/trace/events/mmflags.h |   2 +-
 init/main.c|   3 +-
 mm/filemap.c   | 181 +
 mm/internal.h  |   2 +
 mm/memory-failure.c|   4 +-
 mm/migrate.c   |  14 ++--
 mm/swap.c  |   2 +
 11 files changed, 199 insertions(+), 68 deletions(-)

-- 
2.11.0



[PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

2016-12-24 Thread Nicholas Piggin
A page is not added to the swap cache without being swap backed,
so PageSwapBacked mappings can use PG_owner_priv_1 for PageSwapCache.

Acked-by: Hugh Dickins 
Signed-off-by: Nicholas Piggin 
---
 include/linux/page-flags.h | 24 
 include/trace/events/mmflags.h |  1 -
 mm/memory-failure.c|  4 +---
 mm/migrate.c   | 14 --
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 74e4dda91238..a57c909a15e4 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -87,7 +87,6 @@ enum pageflags {
PG_private_2,   /* If pagecache, has fs aux data */
PG_writeback,   /* Page is under writeback */
PG_head,/* A head page */
-   PG_swapcache,   /* Swap page: swp_entry_t in private */
PG_mappedtodisk,/* Has blocks allocated on-disk */
PG_reclaim, /* To be reclaimed asap */
PG_swapbacked,  /* Page is backed by RAM/swap */
@@ -110,6 +109,9 @@ enum pageflags {
/* Filesystems */
PG_checked = PG_owner_priv_1,
 
+   /* SwapBacked */
+   PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private */
+
/* Two page bits are conscripted by FS-Cache to maintain local caching
 * state.  These bits are set on pages belonging to the netfs's inodes
 * when those inodes are being locally cached.
@@ -314,7 +316,13 @@ PAGEFLAG_FALSE(HighMem)
 #endif
 
 #ifdef CONFIG_SWAP
-PAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
+static __always_inline int PageSwapCache(struct page *page)
+{
+   return PageSwapBacked(page) && test_bit(PG_swapcache, >flags);
+
+}
+SETPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
+CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
 #else
 PAGEFLAG_FALSE(SwapCache)
 #endif
@@ -701,12 +709,12 @@ static inline void ClearPageSlabPfmemalloc(struct page 
*page)
  * Flags checked when a page is freed.  Pages being freed should not have
  * these flags set.  It they are, there is a problem.
  */
-#define PAGE_FLAGS_CHECK_AT_FREE \
-   (1UL << PG_lru   | 1UL << PG_locked| \
-1UL << PG_private | 1UL << PG_private_2 | \
-1UL << PG_writeback | 1UL << PG_reserved | \
-1UL << PG_slab  | 1UL << PG_swapcache | 1UL << PG_active | \
-1UL << PG_unevictable | __PG_MLOCKED)
+#define PAGE_FLAGS_CHECK_AT_FREE   \
+   (1UL << PG_lru  | 1UL << PG_locked  |   \
+1UL << PG_private  | 1UL << PG_private_2   |   \
+1UL << PG_writeback| 1UL << PG_reserved|   \
+1UL << PG_slab | 1UL << PG_active  |   \
+1UL << PG_unevictable  | __PG_MLOCKED)
 
 /*
  * Flags checked when a page is prepped for return by the page allocator.
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 5a81ab48a2fb..30c2adbdebe8 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -95,7 +95,6 @@
{1UL << PG_private_2,   "private_2" },  \
{1UL << PG_writeback,   "writeback" },  \
{1UL << PG_head,"head"  },  \
-   {1UL << PG_swapcache,   "swapcache" },  \
{1UL << PG_mappedtodisk,"mappedtodisk"  },  \
{1UL << PG_reclaim, "reclaim"   },  \
{1UL << PG_swapbacked,  "swapbacked"},  \
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 19e796d36a62..f283c7e0a2a3 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -764,12 +764,11 @@ static int me_huge_page(struct page *p, unsigned long pfn)
  */
 
 #define dirty  (1UL << PG_dirty)
-#define sc (1UL << PG_swapcache)
+#define sc ((1UL << PG_swapcache) | (1UL << PG_swapbacked))
 #define unevict(1UL << PG_unevictable)
 #define mlock  (1UL << PG_mlocked)
 #define writeback  (1UL << PG_writeback)
 #define lru(1UL << PG_lru)
-#define swapbacked (1UL << PG_swapbacked)
 #define head   (1UL << PG_head)
 #define slab   (1UL << PG_slab)
 #define reserved   (1UL << PG_reserved)
@@ -819,7 +818,6 @@ static struct page_state {
 #undef mlock
 #undef writeback
 #undef lru
-#undef swapbacked
 #undef head
 #undef slab
 #undef reserved
diff --git a/mm/migrate.c b/mm/migrate.c
index 0ed24b1fa77b..87f4d0f81819 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -466,13 +466,15 @@ int migrate_page_move_mapping(struct address_space 
*mapping,
 */
newpage->index = page->index;
newpage->mapping = page->mapping;
-   if (PageSwapBacked(page))
-   __SetPageSwapBacked(newpage);
-
get_page(newpage);

[PATCH 0/2] PageWaiters again

2016-12-24 Thread Nicholas Piggin
I cleaned up the changelog a bit and made a few tweaks to patch 1 as
described in my reply to Hugh. Resending with SOBs.

Thanks,
Nick

Nicholas Piggin (2):
  mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked
  mm: add PageWaiters indicating tasks are waiting for a page bit

 include/linux/mm.h |   2 +
 include/linux/page-flags.h |  33 ++--
 include/linux/pagemap.h|  23 +++---
 include/linux/writeback.h  |   1 -
 include/trace/events/mmflags.h |   2 +-
 init/main.c|   3 +-
 mm/filemap.c   | 181 +
 mm/internal.h  |   2 +
 mm/memory-failure.c|   4 +-
 mm/migrate.c   |  14 ++--
 mm/swap.c  |   2 +
 11 files changed, 199 insertions(+), 68 deletions(-)

-- 
2.11.0



[PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

2016-12-24 Thread Nicholas Piggin
A page is not added to the swap cache without being swap backed,
so PageSwapBacked mappings can use PG_owner_priv_1 for PageSwapCache.

Acked-by: Hugh Dickins 
Signed-off-by: Nicholas Piggin 
---
 include/linux/page-flags.h | 24 
 include/trace/events/mmflags.h |  1 -
 mm/memory-failure.c|  4 +---
 mm/migrate.c   | 14 --
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 74e4dda91238..a57c909a15e4 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -87,7 +87,6 @@ enum pageflags {
PG_private_2,   /* If pagecache, has fs aux data */
PG_writeback,   /* Page is under writeback */
PG_head,/* A head page */
-   PG_swapcache,   /* Swap page: swp_entry_t in private */
PG_mappedtodisk,/* Has blocks allocated on-disk */
PG_reclaim, /* To be reclaimed asap */
PG_swapbacked,  /* Page is backed by RAM/swap */
@@ -110,6 +109,9 @@ enum pageflags {
/* Filesystems */
PG_checked = PG_owner_priv_1,
 
+   /* SwapBacked */
+   PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private */
+
/* Two page bits are conscripted by FS-Cache to maintain local caching
 * state.  These bits are set on pages belonging to the netfs's inodes
 * when those inodes are being locally cached.
@@ -314,7 +316,13 @@ PAGEFLAG_FALSE(HighMem)
 #endif
 
 #ifdef CONFIG_SWAP
-PAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
+static __always_inline int PageSwapCache(struct page *page)
+{
+   return PageSwapBacked(page) && test_bit(PG_swapcache, >flags);
+
+}
+SETPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
+CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
 #else
 PAGEFLAG_FALSE(SwapCache)
 #endif
@@ -701,12 +709,12 @@ static inline void ClearPageSlabPfmemalloc(struct page 
*page)
  * Flags checked when a page is freed.  Pages being freed should not have
  * these flags set.  It they are, there is a problem.
  */
-#define PAGE_FLAGS_CHECK_AT_FREE \
-   (1UL << PG_lru   | 1UL << PG_locked| \
-1UL << PG_private | 1UL << PG_private_2 | \
-1UL << PG_writeback | 1UL << PG_reserved | \
-1UL << PG_slab  | 1UL << PG_swapcache | 1UL << PG_active | \
-1UL << PG_unevictable | __PG_MLOCKED)
+#define PAGE_FLAGS_CHECK_AT_FREE   \
+   (1UL << PG_lru  | 1UL << PG_locked  |   \
+1UL << PG_private  | 1UL << PG_private_2   |   \
+1UL << PG_writeback| 1UL << PG_reserved|   \
+1UL << PG_slab | 1UL << PG_active  |   \
+1UL << PG_unevictable  | __PG_MLOCKED)
 
 /*
  * Flags checked when a page is prepped for return by the page allocator.
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 5a81ab48a2fb..30c2adbdebe8 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -95,7 +95,6 @@
{1UL << PG_private_2,   "private_2" },  \
{1UL << PG_writeback,   "writeback" },  \
{1UL << PG_head,"head"  },  \
-   {1UL << PG_swapcache,   "swapcache" },  \
{1UL << PG_mappedtodisk,"mappedtodisk"  },  \
{1UL << PG_reclaim, "reclaim"   },  \
{1UL << PG_swapbacked,  "swapbacked"},  \
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 19e796d36a62..f283c7e0a2a3 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -764,12 +764,11 @@ static int me_huge_page(struct page *p, unsigned long pfn)
  */
 
 #define dirty  (1UL << PG_dirty)
-#define sc (1UL << PG_swapcache)
+#define sc ((1UL << PG_swapcache) | (1UL << PG_swapbacked))
 #define unevict(1UL << PG_unevictable)
 #define mlock  (1UL << PG_mlocked)
 #define writeback  (1UL << PG_writeback)
 #define lru(1UL << PG_lru)
-#define swapbacked (1UL << PG_swapbacked)
 #define head   (1UL << PG_head)
 #define slab   (1UL << PG_slab)
 #define reserved   (1UL << PG_reserved)
@@ -819,7 +818,6 @@ static struct page_state {
 #undef mlock
 #undef writeback
 #undef lru
-#undef swapbacked
 #undef head
 #undef slab
 #undef reserved
diff --git a/mm/migrate.c b/mm/migrate.c
index 0ed24b1fa77b..87f4d0f81819 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -466,13 +466,15 @@ int migrate_page_move_mapping(struct address_space 
*mapping,
 */
newpage->index = page->index;
newpage->mapping = page->mapping;
-   if (PageSwapBacked(page))
-   __SetPageSwapBacked(newpage);
-
get_page(newpage);  /* add cache reference */
-   

Re: [PATCH V3 3/4] arch/powerpc: Implement Optprobes

2016-12-24 Thread Masami Hiramatsu
On Mon, 19 Dec 2016 18:48:24 +0530
Anju T Sudhakar  wrote:

> Detour buffer contains instructions to create an in memory pt_regs.
> After the execution of the pre-handler, a call is made for instruction 
> emulation.
> The NIP is determined in advanced through dummy instruction emulation and a 
> branch
> instruction is created to the NIP at the end of the trampoline.
> 
> Instruction slot for detour buffer is allocated from the reserved area.
> For the time being, 64KB is reserved in memory for this purpose.
> 
> Instructions which can be emulated using analyse_instr() are suppliants
> for optimization. Before optimization ensure that the address range
> between the detour buffer allocated and the instruction being probed
> is within ± 32MB.
> 
> Signed-off-by: Anju T Sudhakar 
> Signed-off-by: Naveen N. Rao 

Looks good to me :)

Acked-by: Masami Hiramatsu 

Thanks!

> ---
>  .../features/debug/optprobes/arch-support.txt  |   2 +-
>  arch/powerpc/Kconfig   |   1 +
>  arch/powerpc/include/asm/kprobes.h |  24 +-
>  arch/powerpc/include/asm/sstep.h   |   1 +
>  arch/powerpc/kernel/Makefile   |   1 +
>  arch/powerpc/kernel/optprobes.c| 331 
> +
>  arch/powerpc/kernel/optprobes_head.S   | 135 +
>  arch/powerpc/lib/sstep.c   |  21 ++
>  8 files changed, 514 insertions(+), 2 deletions(-)
>  create mode 100644 arch/powerpc/kernel/optprobes.c
>  create mode 100644 arch/powerpc/kernel/optprobes_head.S
> 
> diff --git a/Documentation/features/debug/optprobes/arch-support.txt 
> b/Documentation/features/debug/optprobes/arch-support.txt
> index b8999d8..45bc99d 100644
> --- a/Documentation/features/debug/optprobes/arch-support.txt
> +++ b/Documentation/features/debug/optprobes/arch-support.txt
> @@ -27,7 +27,7 @@
>  |   nios2: | TODO |
>  |openrisc: | TODO |
>  |  parisc: | TODO |
> -| powerpc: | TODO |
> +| powerpc: |  ok  |
>  |s390: | TODO |
>  |   score: | TODO |
>  |  sh: | TODO |
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 65fba4c..f7e9296 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -98,6 +98,7 @@ config PPC
>   select HAVE_IOREMAP_PROT
>   select HAVE_EFFICIENT_UNALIGNED_ACCESS if !(CPU_LITTLE_ENDIAN && 
> POWER7_CPU)
>   select HAVE_KPROBES
> + select HAVE_OPTPROBES if PPC64
>   select HAVE_ARCH_KGDB
>   select HAVE_KRETPROBES
>   select HAVE_ARCH_TRACEHOOK
> diff --git a/arch/powerpc/include/asm/kprobes.h 
> b/arch/powerpc/include/asm/kprobes.h
> index 2c9759bd..0cf640b 100644
> --- a/arch/powerpc/include/asm/kprobes.h
> +++ b/arch/powerpc/include/asm/kprobes.h
> @@ -38,7 +38,23 @@ struct pt_regs;
>  struct kprobe;
>  
>  typedef ppc_opcode_t kprobe_opcode_t;
> -#define MAX_INSN_SIZE 1
> +
> +extern kprobe_opcode_t optinsn_slot;
> +
> +/* Optinsn template address */
> +extern kprobe_opcode_t optprobe_template_entry[];
> +extern kprobe_opcode_t optprobe_template_op_address[];
> +extern kprobe_opcode_t optprobe_template_call_handler[];
> +extern kprobe_opcode_t optprobe_template_insn[];
> +extern kprobe_opcode_t optprobe_template_call_emulate[];
> +extern kprobe_opcode_t optprobe_template_ret[];
> +extern kprobe_opcode_t optprobe_template_end[];
> +
> +/* Fixed instruction size for powerpc */
> +#define MAX_INSN_SIZE1
> +#define MAX_OPTIMIZED_LENGTH sizeof(kprobe_opcode_t) /* 4 bytes */
> +#define MAX_OPTINSN_SIZE (optprobe_template_end - 
> optprobe_template_entry)
> +#define RELATIVEJUMP_SIZEsizeof(kprobe_opcode_t) /* 4 bytes */
>  
>  #ifdef PPC64_ELF_ABI_v2
>  /* PPC64 ABIv2 needs local entry point */
> @@ -124,6 +140,12 @@ struct kprobe_ctlblk {
>   struct prev_kprobe prev_kprobe;
>  };
>  
> +struct arch_optimized_insn {
> + kprobe_opcode_t copied_insn[1];
> + /* detour buffer */
> + kprobe_opcode_t *insn;
> +};
> +
>  extern int kprobe_exceptions_notify(struct notifier_block *self,
>   unsigned long val, void *data);
>  extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
> diff --git a/arch/powerpc/include/asm/sstep.h 
> b/arch/powerpc/include/asm/sstep.h
> index d3a42cc..f7ad425 100644
> --- a/arch/powerpc/include/asm/sstep.h
> +++ b/arch/powerpc/include/asm/sstep.h
> @@ -87,3 +87,4 @@ struct instruction_op {
>  
>  extern int analyse_instr(struct instruction_op *op, struct pt_regs *regs,
>unsigned int instr);
> +extern bool is_conditional_branch(unsigned int instr);
> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> index 1925341..54f0f47 100644
> --- a/arch/powerpc/kernel/Makefile
> +++ b/arch/powerpc/kernel/Makefile
> @@ -98,6 +98,7 @@ 

Re: [PATCH V3 3/4] arch/powerpc: Implement Optprobes

2016-12-24 Thread Masami Hiramatsu
On Mon, 19 Dec 2016 18:48:24 +0530
Anju T Sudhakar  wrote:

> Detour buffer contains instructions to create an in memory pt_regs.
> After the execution of the pre-handler, a call is made for instruction 
> emulation.
> The NIP is determined in advanced through dummy instruction emulation and a 
> branch
> instruction is created to the NIP at the end of the trampoline.
> 
> Instruction slot for detour buffer is allocated from the reserved area.
> For the time being, 64KB is reserved in memory for this purpose.
> 
> Instructions which can be emulated using analyse_instr() are suppliants
> for optimization. Before optimization ensure that the address range
> between the detour buffer allocated and the instruction being probed
> is within ± 32MB.
> 
> Signed-off-by: Anju T Sudhakar 
> Signed-off-by: Naveen N. Rao 

Looks good to me :)

Acked-by: Masami Hiramatsu 

Thanks!

> ---
>  .../features/debug/optprobes/arch-support.txt  |   2 +-
>  arch/powerpc/Kconfig   |   1 +
>  arch/powerpc/include/asm/kprobes.h |  24 +-
>  arch/powerpc/include/asm/sstep.h   |   1 +
>  arch/powerpc/kernel/Makefile   |   1 +
>  arch/powerpc/kernel/optprobes.c| 331 
> +
>  arch/powerpc/kernel/optprobes_head.S   | 135 +
>  arch/powerpc/lib/sstep.c   |  21 ++
>  8 files changed, 514 insertions(+), 2 deletions(-)
>  create mode 100644 arch/powerpc/kernel/optprobes.c
>  create mode 100644 arch/powerpc/kernel/optprobes_head.S
> 
> diff --git a/Documentation/features/debug/optprobes/arch-support.txt 
> b/Documentation/features/debug/optprobes/arch-support.txt
> index b8999d8..45bc99d 100644
> --- a/Documentation/features/debug/optprobes/arch-support.txt
> +++ b/Documentation/features/debug/optprobes/arch-support.txt
> @@ -27,7 +27,7 @@
>  |   nios2: | TODO |
>  |openrisc: | TODO |
>  |  parisc: | TODO |
> -| powerpc: | TODO |
> +| powerpc: |  ok  |
>  |s390: | TODO |
>  |   score: | TODO |
>  |  sh: | TODO |
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 65fba4c..f7e9296 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -98,6 +98,7 @@ config PPC
>   select HAVE_IOREMAP_PROT
>   select HAVE_EFFICIENT_UNALIGNED_ACCESS if !(CPU_LITTLE_ENDIAN && 
> POWER7_CPU)
>   select HAVE_KPROBES
> + select HAVE_OPTPROBES if PPC64
>   select HAVE_ARCH_KGDB
>   select HAVE_KRETPROBES
>   select HAVE_ARCH_TRACEHOOK
> diff --git a/arch/powerpc/include/asm/kprobes.h 
> b/arch/powerpc/include/asm/kprobes.h
> index 2c9759bd..0cf640b 100644
> --- a/arch/powerpc/include/asm/kprobes.h
> +++ b/arch/powerpc/include/asm/kprobes.h
> @@ -38,7 +38,23 @@ struct pt_regs;
>  struct kprobe;
>  
>  typedef ppc_opcode_t kprobe_opcode_t;
> -#define MAX_INSN_SIZE 1
> +
> +extern kprobe_opcode_t optinsn_slot;
> +
> +/* Optinsn template address */
> +extern kprobe_opcode_t optprobe_template_entry[];
> +extern kprobe_opcode_t optprobe_template_op_address[];
> +extern kprobe_opcode_t optprobe_template_call_handler[];
> +extern kprobe_opcode_t optprobe_template_insn[];
> +extern kprobe_opcode_t optprobe_template_call_emulate[];
> +extern kprobe_opcode_t optprobe_template_ret[];
> +extern kprobe_opcode_t optprobe_template_end[];
> +
> +/* Fixed instruction size for powerpc */
> +#define MAX_INSN_SIZE1
> +#define MAX_OPTIMIZED_LENGTH sizeof(kprobe_opcode_t) /* 4 bytes */
> +#define MAX_OPTINSN_SIZE (optprobe_template_end - 
> optprobe_template_entry)
> +#define RELATIVEJUMP_SIZEsizeof(kprobe_opcode_t) /* 4 bytes */
>  
>  #ifdef PPC64_ELF_ABI_v2
>  /* PPC64 ABIv2 needs local entry point */
> @@ -124,6 +140,12 @@ struct kprobe_ctlblk {
>   struct prev_kprobe prev_kprobe;
>  };
>  
> +struct arch_optimized_insn {
> + kprobe_opcode_t copied_insn[1];
> + /* detour buffer */
> + kprobe_opcode_t *insn;
> +};
> +
>  extern int kprobe_exceptions_notify(struct notifier_block *self,
>   unsigned long val, void *data);
>  extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
> diff --git a/arch/powerpc/include/asm/sstep.h 
> b/arch/powerpc/include/asm/sstep.h
> index d3a42cc..f7ad425 100644
> --- a/arch/powerpc/include/asm/sstep.h
> +++ b/arch/powerpc/include/asm/sstep.h
> @@ -87,3 +87,4 @@ struct instruction_op {
>  
>  extern int analyse_instr(struct instruction_op *op, struct pt_regs *regs,
>unsigned int instr);
> +extern bool is_conditional_branch(unsigned int instr);
> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> index 1925341..54f0f47 100644
> --- a/arch/powerpc/kernel/Makefile
> +++ b/arch/powerpc/kernel/Makefile
> @@ -98,6 +98,7 @@ obj-$(CONFIG_KGDB)  += kgdb.o
>  obj-$(CONFIG_BOOTX_TEXT) += btext.o
>  obj-$(CONFIG_SMP)+= 

arch/ia64/kernel/entry.S:621: Error: Operand 2 of `adds' should be a 14-bit integer (-8192-8191)

2016-12-24 Thread kbuild test robot
Hi Will,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: da48d094ce5d7c7dcdad9011648a81c42fd1c2ef Kconfig: remove 
HAVE_LATENCYTOP_SUPPORT
date:   11 months ago
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout da48d094ce5d7c7dcdad9011648a81c42fd1c2ef
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   arch/ia64/kernel/entry.S: Assembler messages:
>> arch/ia64/kernel/entry.S:621: Error: Operand 2 of `adds' should be a 14-bit 
>> integer (-8192-8191)
   arch/ia64/kernel/entry.S:728: Error: Operand 2 of `adds' should be a 14-bit 
integer (-8192-8191)
   arch/ia64/kernel/entry.S:859: Error: Operand 2 of `adds' should be a 14-bit 
integer (-8192-8191)
--
   arch/ia64/kernel/fsys.S: Assembler messages:
>> arch/ia64/kernel/fsys.S:67: Error: Operand 3 of `add' should be a general 
>> register r0-r3
   arch/ia64/kernel/fsys.S:97: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:193: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:336: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:338: Error: Operand 3 of `add' should be a general 
register r0-r3
--
   arch/ia64/kernel/ivt.S: Assembler messages:
>> arch/ia64/kernel/ivt.S:759: Error: Operand 3 of `add' should be a general 
>> register r0-r3

vim +621 arch/ia64/kernel/entry.S

^1da177e Linus Torvalds 2005-04-16  605 PT_REGS_UNWIND_INFO(0)
^1da177e Linus Torvalds 2005-04-16  606  {  /*
^1da177e Linus Torvalds 2005-04-16  607  * Some versions of gas 
generate bad unwind info if the first instruction of a
^1da177e Linus Torvalds 2005-04-16  608  * procedure doesn't go into 
the first slot of a bundle.  This is a workaround.
^1da177e Linus Torvalds 2005-04-16  609  */
^1da177e Linus Torvalds 2005-04-16  610 nop.m 0
^1da177e Linus Torvalds 2005-04-16  611 nop.i 0
^1da177e Linus Torvalds 2005-04-16  612 /*
^1da177e Linus Torvalds 2005-04-16  613  * We need to call 
schedule_tail() to complete the scheduling process.
^1da177e Linus Torvalds 2005-04-16  614  * Called by ia64_switch_to() 
after do_fork()->copy_thread().  r8 contains the
^1da177e Linus Torvalds 2005-04-16  615  * address of the previously 
executing task.
^1da177e Linus Torvalds 2005-04-16  616  */
^1da177e Linus Torvalds 2005-04-16  617 br.call.sptk.many 
rp=ia64_invoke_schedule_tail
^1da177e Linus Torvalds 2005-04-16  618  }
^1da177e Linus Torvalds 2005-04-16  619  .ret8:
54d496c3 Al Viro2012-10-14  620  (pKStk)br.call.sptk.many 
rp=call_payload
^1da177e Linus Torvalds 2005-04-16 @621 adds 
r2=TI_FLAGS+IA64_TASK_SIZE,r13
^1da177e Linus Torvalds 2005-04-16  622 ;;
^1da177e Linus Torvalds 2005-04-16  623 ld4 r2=[r2]
^1da177e Linus Torvalds 2005-04-16  624 ;;
^1da177e Linus Torvalds 2005-04-16  625 mov r8=0
^1da177e Linus Torvalds 2005-04-16  626 and 
r2=_TIF_SYSCALL_TRACEAUDIT,r2
^1da177e Linus Torvalds 2005-04-16  627 ;;
^1da177e Linus Torvalds 2005-04-16  628 cmp.ne p6,p0=r2,r0
^1da177e Linus Torvalds 2005-04-16  629  (p6)   br.cond.spnt 
.strace_check_retval

:: The code at line 621 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


arch/ia64/kernel/entry.S:621: Error: Operand 2 of `adds' should be a 14-bit integer (-8192-8191)

2016-12-24 Thread kbuild test robot
Hi Will,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: da48d094ce5d7c7dcdad9011648a81c42fd1c2ef Kconfig: remove 
HAVE_LATENCYTOP_SUPPORT
date:   11 months ago
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout da48d094ce5d7c7dcdad9011648a81c42fd1c2ef
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   arch/ia64/kernel/entry.S: Assembler messages:
>> arch/ia64/kernel/entry.S:621: Error: Operand 2 of `adds' should be a 14-bit 
>> integer (-8192-8191)
   arch/ia64/kernel/entry.S:728: Error: Operand 2 of `adds' should be a 14-bit 
integer (-8192-8191)
   arch/ia64/kernel/entry.S:859: Error: Operand 2 of `adds' should be a 14-bit 
integer (-8192-8191)
--
   arch/ia64/kernel/fsys.S: Assembler messages:
>> arch/ia64/kernel/fsys.S:67: Error: Operand 3 of `add' should be a general 
>> register r0-r3
   arch/ia64/kernel/fsys.S:97: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:193: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:336: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:338: Error: Operand 3 of `add' should be a general 
register r0-r3
--
   arch/ia64/kernel/ivt.S: Assembler messages:
>> arch/ia64/kernel/ivt.S:759: Error: Operand 3 of `add' should be a general 
>> register r0-r3

vim +621 arch/ia64/kernel/entry.S

^1da177e Linus Torvalds 2005-04-16  605 PT_REGS_UNWIND_INFO(0)
^1da177e Linus Torvalds 2005-04-16  606  {  /*
^1da177e Linus Torvalds 2005-04-16  607  * Some versions of gas 
generate bad unwind info if the first instruction of a
^1da177e Linus Torvalds 2005-04-16  608  * procedure doesn't go into 
the first slot of a bundle.  This is a workaround.
^1da177e Linus Torvalds 2005-04-16  609  */
^1da177e Linus Torvalds 2005-04-16  610 nop.m 0
^1da177e Linus Torvalds 2005-04-16  611 nop.i 0
^1da177e Linus Torvalds 2005-04-16  612 /*
^1da177e Linus Torvalds 2005-04-16  613  * We need to call 
schedule_tail() to complete the scheduling process.
^1da177e Linus Torvalds 2005-04-16  614  * Called by ia64_switch_to() 
after do_fork()->copy_thread().  r8 contains the
^1da177e Linus Torvalds 2005-04-16  615  * address of the previously 
executing task.
^1da177e Linus Torvalds 2005-04-16  616  */
^1da177e Linus Torvalds 2005-04-16  617 br.call.sptk.many 
rp=ia64_invoke_schedule_tail
^1da177e Linus Torvalds 2005-04-16  618  }
^1da177e Linus Torvalds 2005-04-16  619  .ret8:
54d496c3 Al Viro2012-10-14  620  (pKStk)br.call.sptk.many 
rp=call_payload
^1da177e Linus Torvalds 2005-04-16 @621 adds 
r2=TI_FLAGS+IA64_TASK_SIZE,r13
^1da177e Linus Torvalds 2005-04-16  622 ;;
^1da177e Linus Torvalds 2005-04-16  623 ld4 r2=[r2]
^1da177e Linus Torvalds 2005-04-16  624 ;;
^1da177e Linus Torvalds 2005-04-16  625 mov r8=0
^1da177e Linus Torvalds 2005-04-16  626 and 
r2=_TIF_SYSCALL_TRACEAUDIT,r2
^1da177e Linus Torvalds 2005-04-16  627 ;;
^1da177e Linus Torvalds 2005-04-16  628 cmp.ne p6,p0=r2,r0
^1da177e Linus Torvalds 2005-04-16  629  (p6)   br.cond.spnt 
.strace_check_retval

:: The code at line 621 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


RE: A small window for a race condition in mm/rmap.c:page_lock_anon_vma_read

2016-12-24 Thread Dashi DS1 Cao
It's a CentOS 7.2, so there is point in asking RHT. I'll try to persuade the 
customer to have a try with kernel version 4.9, if only I can get it work with 
CentOS 7.2.

Dashi Cao

-Original Message-
From: Peter Zijlstra [mailto:pet...@infradead.org] 
Sent: Friday, December 23, 2016 10:20 PM
To: Dashi DS1 Cao 
Cc: Hugh Dickins ; Michal Hocko ; 
linux...@kvack.org; linux-kernel@vger.kernel.org
Subject: Re: A small window for a race condition in 
mm/rmap.c:page_lock_anon_vma_read

On Fri, Dec 23, 2016 at 02:02:14AM +, Dashi DS1 Cao wrote:
> The kernel version is "RELEASE: 3.10.0-327.36.3.el7.x86_64". It was the 
> latest kernel release of CentOS 7.2 at that time, or maybe still now.

This would be the point where we ask you to run a recent upstream kernel and 
try and reproduce the problem with that, or contact RHT for support on their 
franken-kernel ;-)


RE: A small window for a race condition in mm/rmap.c:page_lock_anon_vma_read

2016-12-24 Thread Dashi DS1 Cao
It's a CentOS 7.2, so there is point in asking RHT. I'll try to persuade the 
customer to have a try with kernel version 4.9, if only I can get it work with 
CentOS 7.2.

Dashi Cao

-Original Message-
From: Peter Zijlstra [mailto:pet...@infradead.org] 
Sent: Friday, December 23, 2016 10:20 PM
To: Dashi DS1 Cao 
Cc: Hugh Dickins ; Michal Hocko ; 
linux...@kvack.org; linux-kernel@vger.kernel.org
Subject: Re: A small window for a race condition in 
mm/rmap.c:page_lock_anon_vma_read

On Fri, Dec 23, 2016 at 02:02:14AM +, Dashi DS1 Cao wrote:
> The kernel version is "RELEASE: 3.10.0-327.36.3.el7.x86_64". It was the 
> latest kernel release of CentOS 7.2 at that time, or maybe still now.

This would be the point where we ask you to run a recent upstream kernel and 
try and reproduce the problem with that, or contact RHT for support on their 
franken-kernel ;-)


cc1: error: '-march=r3000' requires '-mfp32'

2016-12-24 Thread kbuild test robot
Hi James,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 034827c727f7f3946a18355b63995b402c226c82 MIPS: Fix -mabi=64 build of 
vdso.lds
date:   3 months ago
config: mips-decstation_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 034827c727f7f3946a18355b63995b402c226c82
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> cc1: error: '-march=r3000' requires '-mfp32'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


cc1: error: '-march=r3000' requires '-mfp32'

2016-12-24 Thread kbuild test robot
Hi James,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 034827c727f7f3946a18355b63995b402c226c82 MIPS: Fix -mabi=64 build of 
vdso.lds
date:   3 months ago
config: mips-decstation_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 034827c727f7f3946a18355b63995b402c226c82
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> cc1: error: '-march=r3000' requires '-mfp32'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH] ipv4: Namespaceify tcp_tw_reuse knob

2016-12-24 Thread David Miller
From: Haishuang Yan 
Date: Sat, 24 Dec 2016 20:43:07 +0800

> Signed-off-by: Haishuang Yan 

You need to provide something more than an empty commit message.

Instead, the commit message must explain why this particular
sysctl should be considered for namespacification and what
the implications, both good and bad, are for such a change.


Re: [PATCH] ipv4: Namespaceify tcp_tw_reuse knob

2016-12-24 Thread David Miller
From: Haishuang Yan 
Date: Sat, 24 Dec 2016 20:43:07 +0800

> Signed-off-by: Haishuang Yan 

You need to provide something more than an empty commit message.

Instead, the commit message must explain why this particular
sysctl should be considered for namespacification and what
the implications, both good and bad, are for such a change.


Re: [PATCH 01/14] x86/cqm: Intel Resource Monitoring Documentation

2016-12-24 Thread Shivappa Vikas



On Fri, 23 Dec 2016, Peter Zijlstra wrote:


On Fri, Dec 23, 2016 at 11:35:03AM -0800, Shivappa Vikas wrote:


Hello Peterz,

On Fri, 23 Dec 2016, Peter Zijlstra wrote:


On Fri, Dec 16, 2016 at 03:12:55PM -0800, Vikas Shivappa wrote:

+Continuous monitoring
+-
+A new file cont_monitoring is added to perf_cgroup which helps to enable
+cqm continuous monitoring. Enabling this field would start monitoring of
+the cgroup without perf being launched. This can be used for long term
+light weight monitoring of tasks/cgroups.
+
+To enable continuous monitoring of cgroup p1.
+#echo 1 > /sys/fs/cgroup/perf_event/p1/perf_event.cqm_cont_monitoring
+
+To disable continuous monitoring of cgroup p1.
+#echo 0 > /sys/fs/cgroup/perf_event/p1/perf_event.cqm_cont_monitoring
+
+To read the counters at the end of monitoring perf can be used.
+
+LAZY and NOLAZY Monitoring
+--
+LAZY:
+By default when monitoring is enabled, the RMIDs are not allocated
+immediately and allocated lazily only at the first sched_in.
+There are 2-4 RMIDs per logical processor on each package. So if a dual
+package has 48 logical processors, there would be upto 192 RMIDs on each
+package = total of 192x2 RMIDs.
+There is a possibility that RMIDs can runout and in that case the read
+reports an error since there was no RMID available to monitor for an
+event.
+
+NOLAZY:
+When user wants guaranteed monitoring, he can enable the 'monitoring
+mask' which is basically used to specify the packages he wants to
+monitor. The RMIDs are statically allocated at open and failure is
+indicated if RMIDs are not available.
+
+To specify monitoring on package 0 and package 1:
+#echo 0-1 > /sys/fs/cgroup/perf_event/p1/perf_event.cqm_mon_mask
+
+An error is thrown if packages not online are specified.


I very much dislike both those for adding files to the perf cgroup.
Drivers should really not do that.


Is the continuous monitoring the issue or the interface (adding a file in
perf_cgroup) ? I have not mentioned in the documentaion but this continuous
monitoring/ monitoring mask applies only to cgroup in this patch and hence
we thought a good place for that is in the cgroup itself because its per
cgroup.

For task events , this wont apply and we are thinking of providing a prctl
based interface for user to toggle the continous monitoring ..


More fail..



I absolutely hate the second because events already have affinity.


This applies to continuous monitoring as well when there are no events
associated. Meaning if the monitoring mask is chosen and user tries to
enable continuous monitoring using the cgrp->cont_mon - all RMIDs are
allocated immediately. the mon_mask provides a way for the user to have
guarenteed RMIDs for both that have events and for continoous monitoring(no
perf event associated) (assuming user uses it when user knows he would
definitely use it.. or else there is LAZY mode)

Again this is cgroup specific and wont apply to task events and is needed
when there are no events associated.


So no, the problem is that a driver introduces special ABI and behaviour
that radically departs from the regular behaviour.


Ok , looks like the interface  is the problem. Will try to 
fix this. We are just trying to have a light weight monitoring

option so that its reasonable to monitor for a
very long time (like lifetime of process etc). Mainly to not have all the perf 
scheduling overhead.
May be a perf event attr option is a more reasonable approach for the user to 
choose the option ? (rather than some new interface like prctl / cgroup file..)


Thanks,
Vikas


Re: [PATCH 01/14] x86/cqm: Intel Resource Monitoring Documentation

2016-12-24 Thread Shivappa Vikas



On Fri, 23 Dec 2016, Peter Zijlstra wrote:


On Fri, Dec 23, 2016 at 11:35:03AM -0800, Shivappa Vikas wrote:


Hello Peterz,

On Fri, 23 Dec 2016, Peter Zijlstra wrote:


On Fri, Dec 16, 2016 at 03:12:55PM -0800, Vikas Shivappa wrote:

+Continuous monitoring
+-
+A new file cont_monitoring is added to perf_cgroup which helps to enable
+cqm continuous monitoring. Enabling this field would start monitoring of
+the cgroup without perf being launched. This can be used for long term
+light weight monitoring of tasks/cgroups.
+
+To enable continuous monitoring of cgroup p1.
+#echo 1 > /sys/fs/cgroup/perf_event/p1/perf_event.cqm_cont_monitoring
+
+To disable continuous monitoring of cgroup p1.
+#echo 0 > /sys/fs/cgroup/perf_event/p1/perf_event.cqm_cont_monitoring
+
+To read the counters at the end of monitoring perf can be used.
+
+LAZY and NOLAZY Monitoring
+--
+LAZY:
+By default when monitoring is enabled, the RMIDs are not allocated
+immediately and allocated lazily only at the first sched_in.
+There are 2-4 RMIDs per logical processor on each package. So if a dual
+package has 48 logical processors, there would be upto 192 RMIDs on each
+package = total of 192x2 RMIDs.
+There is a possibility that RMIDs can runout and in that case the read
+reports an error since there was no RMID available to monitor for an
+event.
+
+NOLAZY:
+When user wants guaranteed monitoring, he can enable the 'monitoring
+mask' which is basically used to specify the packages he wants to
+monitor. The RMIDs are statically allocated at open and failure is
+indicated if RMIDs are not available.
+
+To specify monitoring on package 0 and package 1:
+#echo 0-1 > /sys/fs/cgroup/perf_event/p1/perf_event.cqm_mon_mask
+
+An error is thrown if packages not online are specified.


I very much dislike both those for adding files to the perf cgroup.
Drivers should really not do that.


Is the continuous monitoring the issue or the interface (adding a file in
perf_cgroup) ? I have not mentioned in the documentaion but this continuous
monitoring/ monitoring mask applies only to cgroup in this patch and hence
we thought a good place for that is in the cgroup itself because its per
cgroup.

For task events , this wont apply and we are thinking of providing a prctl
based interface for user to toggle the continous monitoring ..


More fail..



I absolutely hate the second because events already have affinity.


This applies to continuous monitoring as well when there are no events
associated. Meaning if the monitoring mask is chosen and user tries to
enable continuous monitoring using the cgrp->cont_mon - all RMIDs are
allocated immediately. the mon_mask provides a way for the user to have
guarenteed RMIDs for both that have events and for continoous monitoring(no
perf event associated) (assuming user uses it when user knows he would
definitely use it.. or else there is LAZY mode)

Again this is cgroup specific and wont apply to task events and is needed
when there are no events associated.


So no, the problem is that a driver introduces special ABI and behaviour
that radically departs from the regular behaviour.


Ok , looks like the interface  is the problem. Will try to 
fix this. We are just trying to have a light weight monitoring

option so that its reasonable to monitor for a
very long time (like lifetime of process etc). Mainly to not have all the perf 
scheduling overhead.
May be a perf event attr option is a more reasonable approach for the user to 
choose the option ? (rather than some new interface like prctl / cgroup file..)


Thanks,
Vikas


arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3000' requires '-mfp32'

2016-12-24 Thread kbuild test robot
Hi Guenter,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e MIPS: VDSO: Fix build error 
with binutils 2.24 and earlier
date:   12 months ago
config: mips-decstation_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3000' requires '-mfp32'
/*


vim +1 arch/mips/vdso/gettimeofday.c

a7f4df4e Alex Smith 2015-10-21 @1  /*
a7f4df4e Alex Smith 2015-10-21  2   * Copyright (C) 2015 Imagination 
Technologies
a7f4df4e Alex Smith 2015-10-21  3   * Author: Alex Smith 
a7f4df4e Alex Smith 2015-10-21  4   *
a7f4df4e Alex Smith 2015-10-21  5   * This program is free software; you can 
redistribute it and/or modify it
a7f4df4e Alex Smith 2015-10-21  6   * under the terms of the GNU General Public 
License as published by the
a7f4df4e Alex Smith 2015-10-21  7   * Free Software Foundation;  either version 
2 of the  License, or (at your
a7f4df4e Alex Smith 2015-10-21  8   * option) any later version.
a7f4df4e Alex Smith 2015-10-21  9   */

:: The code at line 1 was first introduced by commit
:: a7f4df4e21dd8a8dab96e88acd2c9c5017b83fc6 MIPS: VDSO: Add implementations 
of gettimeofday() and clock_gettime()

:: TO: Alex Smith 
:: CC: Ralf Baechle 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3000' requires '-mfp32'

2016-12-24 Thread kbuild test robot
Hi Guenter,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e MIPS: VDSO: Fix build error 
with binutils 2.24 and earlier
date:   12 months ago
config: mips-decstation_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3000' requires '-mfp32'
/*


vim +1 arch/mips/vdso/gettimeofday.c

a7f4df4e Alex Smith 2015-10-21 @1  /*
a7f4df4e Alex Smith 2015-10-21  2   * Copyright (C) 2015 Imagination 
Technologies
a7f4df4e Alex Smith 2015-10-21  3   * Author: Alex Smith 
a7f4df4e Alex Smith 2015-10-21  4   *
a7f4df4e Alex Smith 2015-10-21  5   * This program is free software; you can 
redistribute it and/or modify it
a7f4df4e Alex Smith 2015-10-21  6   * under the terms of the GNU General Public 
License as published by the
a7f4df4e Alex Smith 2015-10-21  7   * Free Software Foundation;  either version 
2 of the  License, or (at your
a7f4df4e Alex Smith 2015-10-21  8   * option) any later version.
a7f4df4e Alex Smith 2015-10-21  9   */

:: The code at line 1 was first introduced by commit
:: a7f4df4e21dd8a8dab96e88acd2c9c5017b83fc6 MIPS: VDSO: Add implementations 
of gettimeofday() and clock_gettime()

:: TO: Alex Smith 
:: CC: Ralf Baechle 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used uninitialized in this function

2016-12-24 Thread kbuild test robot
Hi Dave,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91 drm/i915: Introduce & use new 
lightweight SGL iterators
date:   7 months ago
config: x86_64-randconfig-s0-12250734 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All errors (new ones prefixed by >>):

   cc1: warnings being treated as errors
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen8_ggtt_insert_entries':
>> drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used 
>> uninitialized in this function
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen6_ggtt_insert_entries':
   drivers/gpu/drm/i915/i915_gem_gtt.c:2442: error: 'gtt_entry' may be used 
uninitialized in this function

vim +/gtt_entry +2367 drivers/gpu/drm/i915/i915_gem_gtt.c

  2361   enum i915_cache_level level, u32 
unused)
  2362  {
  2363  struct drm_i915_private *dev_priv = to_i915(vm->dev);
  2364  struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
  2365  struct sgt_iter sgt_iter;
  2366  gen8_pte_t __iomem *gtt_entries;
> 2367  gen8_pte_t gtt_entry;
  2368  dma_addr_t addr;
  2369  int rpm_atomic_seq;
  2370  int i = 0;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


arch/mips/vdso/elf.S:1:0: error: '-march=r3000' requires '-mfp32'

2016-12-24 Thread kbuild test robot
Hi Alex,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: ebb5e78cc63417a35254a791de66e1cc84f963cc MIPS: Initial implementation 
of a VDSO
date:   1 year, 1 month ago
config: mips-decstation_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout ebb5e78cc63417a35254a791de66e1cc84f963cc
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/elf.S:1:0: error: '-march=r3000' requires '-mfp32'
/*

--
>> arch/mips/vdso/sigreturn.S:1:0: error: '-march=r3000' requires '-mfp32'
/*


vim +1 arch/mips/vdso/elf.S

   > 1  /*
 2   * Copyright (C) 2015 Imagination Technologies
 3   * Author: Alex Smith 
 4   *

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used uninitialized in this function

2016-12-24 Thread kbuild test robot
Hi Dave,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91 drm/i915: Introduce & use new 
lightweight SGL iterators
date:   7 months ago
config: x86_64-randconfig-s0-12250734 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All errors (new ones prefixed by >>):

   cc1: warnings being treated as errors
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen8_ggtt_insert_entries':
>> drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used 
>> uninitialized in this function
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen6_ggtt_insert_entries':
   drivers/gpu/drm/i915/i915_gem_gtt.c:2442: error: 'gtt_entry' may be used 
uninitialized in this function

vim +/gtt_entry +2367 drivers/gpu/drm/i915/i915_gem_gtt.c

  2361   enum i915_cache_level level, u32 
unused)
  2362  {
  2363  struct drm_i915_private *dev_priv = to_i915(vm->dev);
  2364  struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
  2365  struct sgt_iter sgt_iter;
  2366  gen8_pte_t __iomem *gtt_entries;
> 2367  gen8_pte_t gtt_entry;
  2368  dma_addr_t addr;
  2369  int rpm_atomic_seq;
  2370  int i = 0;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


arch/mips/vdso/elf.S:1:0: error: '-march=r3000' requires '-mfp32'

2016-12-24 Thread kbuild test robot
Hi Alex,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: ebb5e78cc63417a35254a791de66e1cc84f963cc MIPS: Initial implementation 
of a VDSO
date:   1 year, 1 month ago
config: mips-decstation_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout ebb5e78cc63417a35254a791de66e1cc84f963cc
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/elf.S:1:0: error: '-march=r3000' requires '-mfp32'
/*

--
>> arch/mips/vdso/sigreturn.S:1:0: error: '-march=r3000' requires '-mfp32'
/*


vim +1 arch/mips/vdso/elf.S

   > 1  /*
 2   * Copyright (C) 2015 Imagination Technologies
 3   * Author: Alex Smith 
 4   *

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

2016-12-24 Thread Nicholas Piggin
On Thu, 22 Dec 2016 11:55:28 -0800 (PST)
Hugh Dickins  wrote:

> On Thu, 22 Dec 2016, Nicholas Piggin wrote:
> 
> I agree with every word of that changelog ;)
> 
> And I'll stamp this with
> Acked-by: Hugh Dickins 

Thanks Hugh.
 
> The thing that Peter remembers I commented on (which 0day caught too),
> was to remove PG_swapcache from PAGE_FLAGS_CHECK_AT_FREE: you've done
> that now, so this is good.  (Note in passing: wouldn't it be good to
> add PG_waiters to PAGE_FLAGS_CHECK_AT_FREE in the 2/2?)
> 
> Though I did yesterday notice a few more problematic uses of
> PG_swapcache, which you'll probably need to refine to exclude
> other uses of PG_owner_priv_1; though no great hurry for those,
> so not necessarily in this same patch.  Do your own grep, but
> 
> fs/proc/page.c derives its KPF_SWAPCACHE from PG_swapcache,
> needs refining.
> 
> kernel/kexec_core.c says VMCOREINFO_NUMBER(PG_swapcache):
> I haven't looked into what that's about, it will probably just
> have to be commented as now including other uses of the same bit.
> 
> mm/memory-failure.c has an error_states[] table that involves
> testing PG_swapcache as "sc", but looks as if it can be changed
> to factor in "swapbacked" too.

I've added the swapbacked check to mm/memory-failure.c, the others look
like they're just dealing with bit number, so not much to do about it
really. I also just made the migration case more explicit, seeing as the
others are.

Hopefully that doesn't negate your ack because I'm adding that too.

Thanks,
Nick


Re: [PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

2016-12-24 Thread Nicholas Piggin
On Thu, 22 Dec 2016 11:55:28 -0800 (PST)
Hugh Dickins  wrote:

> On Thu, 22 Dec 2016, Nicholas Piggin wrote:
> 
> I agree with every word of that changelog ;)
> 
> And I'll stamp this with
> Acked-by: Hugh Dickins 

Thanks Hugh.
 
> The thing that Peter remembers I commented on (which 0day caught too),
> was to remove PG_swapcache from PAGE_FLAGS_CHECK_AT_FREE: you've done
> that now, so this is good.  (Note in passing: wouldn't it be good to
> add PG_waiters to PAGE_FLAGS_CHECK_AT_FREE in the 2/2?)
> 
> Though I did yesterday notice a few more problematic uses of
> PG_swapcache, which you'll probably need to refine to exclude
> other uses of PG_owner_priv_1; though no great hurry for those,
> so not necessarily in this same patch.  Do your own grep, but
> 
> fs/proc/page.c derives its KPF_SWAPCACHE from PG_swapcache,
> needs refining.
> 
> kernel/kexec_core.c says VMCOREINFO_NUMBER(PG_swapcache):
> I haven't looked into what that's about, it will probably just
> have to be commented as now including other uses of the same bit.
> 
> mm/memory-failure.c has an error_states[] table that involves
> testing PG_swapcache as "sc", but looks as if it can be changed
> to factor in "swapbacked" too.

I've added the swapbacked check to mm/memory-failure.c, the others look
like they're just dealing with bit number, so not much to do about it
really. I also just made the migration case more explicit, seeing as the
others are.

Hopefully that doesn't negate your ack because I'm adding that too.

Thanks,
Nick


Re: [PATCH v3 1/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread David Miller

It is never, ever, appropriate to use the same exact Subject: line
text for two different changes.

Someone looking at "git shortlog" has no way to know what is different
between the two changes.

You must put care and time into constructing Subject: lines because
this text is critical for data mining and analysis done by both humans
and machines.



Re: [PATCH v3 1/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread David Miller

It is never, ever, appropriate to use the same exact Subject: line
text for two different changes.

Someone looking at "git shortlog" has no way to know what is different
between the two changes.

You must put care and time into constructing Subject: lines because
this text is critical for data mining and analysis done by both humans
and machines.



Re: Re: [PATCH v2 1/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread Thomas Preisner
Hello.

On Sat, 2016-12-24 at 20:06 +0100, Sergei Shtylyov wrote:
>Hello!
>
>On 12/24/2016 03:02 PM, Thomas Preisner wrote:
>
>> In a few cases the err-variable is not set to a negative error code if a
>> function call fails and thus 0 is returned instead.
>> It may be better to set err to the appropriate negative error code
>> before returning.
>>
>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841
>>
>> Reported-by: Pan Bian 
>> Signed-off-by: Thomas Preisner 
>> Signed-off-by: Milan Stephan 
>> ---
>>  drivers/net/ethernet/3com/typhoon.c | 7 +--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/3com/typhoon.c 
>> b/drivers/net/ethernet/3com/typhoon.c
>> index a0cacbe..c88b88a 100644
>> --- a/drivers/net/ethernet/3com/typhoon.c
>> +++ b/drivers/net/ethernet/3com/typhoon.c
>[...]
>> @@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
>> pci_device_id *ent)
>>   * later when we print out the version reported.
>>   */
>>  INIT_COMMAND_WITH_RESPONSE(_cmd, TYPHOON_CMD_READ_VERSIONS);
>> -if(typhoon_issue_command(tp, 1, _cmd, 3, xp_resp) < 0) {
>> +err = typhoon_issue_command(tp, 1, _cmd, 3, xp_resp);
>> +if(err < 0) {
>
>Need a space between *if* and (. Run your patches thru 
>scripts/checkpatch.pl before posting, please.

Those spaces were actually left out purposely: The file in question (typhoon.c)
is missing those spaces between the statements (if, for, while) and the
following opening bracket pretty much always (except 2-3 times) and we figured
that it might be better to keep the coding style consistent since this might
aswell have been intended by the original author.

>
>>  err_msg = "Could not get Sleep Image version";
>>  goto error_out_reset;
>>  }
>> @@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
>> pci_device_id *ent)
>>  dev->features = dev->hw_features |
>>  NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
>>
>> -if(register_netdev(dev) < 0) {
>> +err = register_netdev(dev);
>> +if(err < 0) {
>
>Same here.
>
>[...]
>
>MBR, Sergei

But of course we can provide you with a patchset including those spaces.

With Regards,
Milan and Thomas



Re: Re: [PATCH v2 1/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread Thomas Preisner
Hello.

On Sat, 2016-12-24 at 20:06 +0100, Sergei Shtylyov wrote:
>Hello!
>
>On 12/24/2016 03:02 PM, Thomas Preisner wrote:
>
>> In a few cases the err-variable is not set to a negative error code if a
>> function call fails and thus 0 is returned instead.
>> It may be better to set err to the appropriate negative error code
>> before returning.
>>
>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841
>>
>> Reported-by: Pan Bian 
>> Signed-off-by: Thomas Preisner 
>> Signed-off-by: Milan Stephan 
>> ---
>>  drivers/net/ethernet/3com/typhoon.c | 7 +--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/3com/typhoon.c 
>> b/drivers/net/ethernet/3com/typhoon.c
>> index a0cacbe..c88b88a 100644
>> --- a/drivers/net/ethernet/3com/typhoon.c
>> +++ b/drivers/net/ethernet/3com/typhoon.c
>[...]
>> @@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
>> pci_device_id *ent)
>>   * later when we print out the version reported.
>>   */
>>  INIT_COMMAND_WITH_RESPONSE(_cmd, TYPHOON_CMD_READ_VERSIONS);
>> -if(typhoon_issue_command(tp, 1, _cmd, 3, xp_resp) < 0) {
>> +err = typhoon_issue_command(tp, 1, _cmd, 3, xp_resp);
>> +if(err < 0) {
>
>Need a space between *if* and (. Run your patches thru 
>scripts/checkpatch.pl before posting, please.

Those spaces were actually left out purposely: The file in question (typhoon.c)
is missing those spaces between the statements (if, for, while) and the
following opening bracket pretty much always (except 2-3 times) and we figured
that it might be better to keep the coding style consistent since this might
aswell have been intended by the original author.

>
>>  err_msg = "Could not get Sleep Image version";
>>  goto error_out_reset;
>>  }
>> @@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
>> pci_device_id *ent)
>>  dev->features = dev->hw_features |
>>  NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
>>
>> -if(register_netdev(dev) < 0) {
>> +err = register_netdev(dev);
>> +if(err < 0) {
>
>Same here.
>
>[...]
>
>MBR, Sergei

But of course we can provide you with a patchset including those spaces.

With Regards,
Milan and Thomas



[PATCH v3 2/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread Thomas Preisner
In some cases the return value of a failing function is not being used
and the function typhoon_init_one() returns another negative error
code instead.

Signed-off-by: Thomas Preisner 
Signed-off-by: Milan Stephan 
---
 drivers/net/ethernet/3com/typhoon.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c 
b/drivers/net/ethernet/3com/typhoon.c
index c88b88a..8821a24 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -2370,9 +2370,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 * 4) Get the hardware address.
 * 5) Put the card to sleep.
 */
-   if (typhoon_reset(ioaddr, WaitSleep) < 0) {
+   err = typhoon_reset(ioaddr, WaitSleep);
+   if (err < 0) {
err_msg = "could not reset 3XP";
-   err = -EIO;
goto error_out_dma;
}
 
@@ -2386,16 +2386,16 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
typhoon_init_interface(tp);
typhoon_init_rings(tp);
 
-   if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) {
+   err = typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST);
+   if (err < 0) {
err_msg = "cannot boot 3XP sleep image";
-   err = -EIO;
goto error_out_reset;
}
 
INIT_COMMAND_WITH_RESPONSE(_cmd, TYPHOON_CMD_READ_MAC_ADDRESS);
-   if(typhoon_issue_command(tp, 1, _cmd, 1, xp_resp) < 0) {
+   err = typhoon_issue_command(tp, 1, _cmd, 1, xp_resp);
+   if (err < 0) {
err_msg = "cannot read MAC address";
-   err = -EIO;
goto error_out_reset;
}
 
@@ -2430,9 +2430,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if(xp_resp[0].numDesc != 0)
tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET;
 
-   if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) {
+   err = typhoon_sleep(tp, PCI_D3hot, 0);
+   if (err < 0) {
err_msg = "cannot put adapter to sleep";
-   err = -EIO;
goto error_out_reset;
}
 
-- 
2.7.4



[PATCH v3 1/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread Thomas Preisner
In a few cases the err-variable is not set to a negative error code if a
function call fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code
before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

Reported-by: Pan Bian 
Signed-off-by: Thomas Preisner 
Signed-off-by: Milan Stephan 
---
 drivers/net/ethernet/3com/typhoon.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c 
b/drivers/net/ethernet/3com/typhoon.c
index a0cacbe..c88b88a 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -2404,6 +2404,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
-   if(!is_valid_ether_addr(dev->dev_addr)) {
+   if (!is_valid_ether_addr(dev->dev_addr)) {
err_msg = "Could not obtain valid ethernet address, aborting";
+   err = -EIO;
goto error_out_reset;
}
 
@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 * later when we print out the version reported.
 */
INIT_COMMAND_WITH_RESPONSE(_cmd, TYPHOON_CMD_READ_VERSIONS);
-   if(typhoon_issue_command(tp, 1, _cmd, 3, xp_resp) < 0) {
+   err = typhoon_issue_command(tp, 1, _cmd, 3, xp_resp);
+   if (err < 0) {
err_msg = "Could not get Sleep Image version";
goto error_out_reset;
}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
dev->features = dev->hw_features |
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
 
-   if(register_netdev(dev) < 0) {
+   err = register_netdev(dev);
+   if (err < 0) {
err_msg = "unable to register netdev";
goto error_out_reset;
}
-- 
2.7.4



[PATCH v3 2/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread Thomas Preisner
In some cases the return value of a failing function is not being used
and the function typhoon_init_one() returns another negative error
code instead.

Signed-off-by: Thomas Preisner 
Signed-off-by: Milan Stephan 
---
 drivers/net/ethernet/3com/typhoon.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c 
b/drivers/net/ethernet/3com/typhoon.c
index c88b88a..8821a24 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -2370,9 +2370,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 * 4) Get the hardware address.
 * 5) Put the card to sleep.
 */
-   if (typhoon_reset(ioaddr, WaitSleep) < 0) {
+   err = typhoon_reset(ioaddr, WaitSleep);
+   if (err < 0) {
err_msg = "could not reset 3XP";
-   err = -EIO;
goto error_out_dma;
}
 
@@ -2386,16 +2386,16 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
typhoon_init_interface(tp);
typhoon_init_rings(tp);
 
-   if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) {
+   err = typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST);
+   if (err < 0) {
err_msg = "cannot boot 3XP sleep image";
-   err = -EIO;
goto error_out_reset;
}
 
INIT_COMMAND_WITH_RESPONSE(_cmd, TYPHOON_CMD_READ_MAC_ADDRESS);
-   if(typhoon_issue_command(tp, 1, _cmd, 1, xp_resp) < 0) {
+   err = typhoon_issue_command(tp, 1, _cmd, 1, xp_resp);
+   if (err < 0) {
err_msg = "cannot read MAC address";
-   err = -EIO;
goto error_out_reset;
}
 
@@ -2430,9 +2430,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if(xp_resp[0].numDesc != 0)
tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET;
 
-   if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) {
+   err = typhoon_sleep(tp, PCI_D3hot, 0);
+   if (err < 0) {
err_msg = "cannot put adapter to sleep";
-   err = -EIO;
goto error_out_reset;
}
 
-- 
2.7.4



[PATCH v3 1/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread Thomas Preisner
In a few cases the err-variable is not set to a negative error code if a
function call fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code
before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

Reported-by: Pan Bian 
Signed-off-by: Thomas Preisner 
Signed-off-by: Milan Stephan 
---
 drivers/net/ethernet/3com/typhoon.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c 
b/drivers/net/ethernet/3com/typhoon.c
index a0cacbe..c88b88a 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -2404,6 +2404,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
-   if(!is_valid_ether_addr(dev->dev_addr)) {
+   if (!is_valid_ether_addr(dev->dev_addr)) {
err_msg = "Could not obtain valid ethernet address, aborting";
+   err = -EIO;
goto error_out_reset;
}
 
@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 * later when we print out the version reported.
 */
INIT_COMMAND_WITH_RESPONSE(_cmd, TYPHOON_CMD_READ_VERSIONS);
-   if(typhoon_issue_command(tp, 1, _cmd, 3, xp_resp) < 0) {
+   err = typhoon_issue_command(tp, 1, _cmd, 3, xp_resp);
+   if (err < 0) {
err_msg = "Could not get Sleep Image version";
goto error_out_reset;
}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
dev->features = dev->hw_features |
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
 
-   if(register_netdev(dev) < 0) {
+   err = register_netdev(dev);
+   if (err < 0) {
err_msg = "unable to register netdev";
goto error_out_reset;
}
-- 
2.7.4



{standard input}:199: Error: unknown opcode

2016-12-24 Thread kbuild test robot
Hi Rich,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: b4214e41b7152b1964a3421a40251d202ae2d2c0 sh: add SMP support for J2
date:   5 months ago
config: sh-j2_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout b4214e41b7152b1964a3421a40251d202ae2d2c0
# save the attached .config to linux build tree
make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   {standard input}: Assembler messages:
>> {standard input}:199: Error: unknown opcode
   {standard input}:1229: Error: unknown opcode
--
   {standard input}: Assembler messages:
   {standard input}:162: Error: unknown opcode
>> {standard input}:199: Error: unknown opcode
   {standard input}:324: Error: unknown opcode
   {standard input}:520: Error: unknown opcode
   {standard input}:619: Error: unknown opcode

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


{standard input}:199: Error: unknown opcode

2016-12-24 Thread kbuild test robot
Hi Rich,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: b4214e41b7152b1964a3421a40251d202ae2d2c0 sh: add SMP support for J2
date:   5 months ago
config: sh-j2_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout b4214e41b7152b1964a3421a40251d202ae2d2c0
# save the attached .config to linux build tree
make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   {standard input}: Assembler messages:
>> {standard input}:199: Error: unknown opcode
   {standard input}:1229: Error: unknown opcode
--
   {standard input}: Assembler messages:
   {standard input}:162: Error: unknown opcode
>> {standard input}:199: Error: unknown opcode
   {standard input}:324: Error: unknown opcode
   {standard input}:520: Error: unknown opcode
   {standard input}:619: Error: unknown opcode

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


include/linux/unaligned/access_ok.h:7:19: error: redefinition of 'get_unaligned_le16'

2016-12-24 Thread kbuild test robot
Hi Vincent,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 3194c6870158e305dac2af52f83681e9cb67280f NFC: nfcmrvl: add firmware 
download support
date:   1 year, 2 months ago
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 3194c6870158e305dac2af52f83681e9cb67280f
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:7:19: error: redefinition of 
>> 'get_unaligned_le16'
static inline u16 get_unaligned_le16(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:4:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/nfc/nfcmrvl/fw_dnld.c:19:
   include/linux/unaligned/le_struct.h:6:19: note: previous definition of 
'get_unaligned_le16' was here
static inline u16 get_unaligned_le16(const void *p)
  ^~
   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:12:19: error: redefinition of 
>> 'get_unaligned_le32'
static inline u32 get_unaligned_le32(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:4:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/nfc/nfcmrvl/fw_dnld.c:19:
   include/linux/unaligned/le_struct.h:11:19: note: previous definition of 
'get_unaligned_le32' was here
static inline u32 get_unaligned_le32(const void *p)
  ^~
   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:17:19: error: redefinition of 
>> 'get_unaligned_le64'
static inline u64 get_unaligned_le64(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:4:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/nfc/nfcmrvl/fw_dnld.c:19:
   include/linux/unaligned/le_struct.h:16:19: note: previous definition of 
'get_unaligned_le64' was here
static inline u64 get_unaligned_le64(const void *p)
  ^~
   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:22:19: error: redefinition of 
>> 'get_unaligned_be16'
static inline u16 get_unaligned_be16(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:5:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/nfc/nfcmrvl/fw_dnld.c:19:
   include/linux/unaligned/be_byteshift.h:40:19: note: previous definition of 
'get_unaligned_be16' was here
static inline u16 get_unaligned_be16(const void *p)
  ^~
   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:27:19: error: redefinition of 
>> 'get_unaligned_be32'
static inline u32 get_unaligned_be32(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:5:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from 

include/linux/unaligned/access_ok.h:7:19: error: redefinition of 'get_unaligned_le16'

2016-12-24 Thread kbuild test robot
Hi Vincent,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7c0f6ba682b9c7632072ffbedf8d328c8f3c42ba
commit: 3194c6870158e305dac2af52f83681e9cb67280f NFC: nfcmrvl: add firmware 
download support
date:   1 year, 2 months ago
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 3194c6870158e305dac2af52f83681e9cb67280f
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:7:19: error: redefinition of 
>> 'get_unaligned_le16'
static inline u16 get_unaligned_le16(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:4:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/nfc/nfcmrvl/fw_dnld.c:19:
   include/linux/unaligned/le_struct.h:6:19: note: previous definition of 
'get_unaligned_le16' was here
static inline u16 get_unaligned_le16(const void *p)
  ^~
   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:12:19: error: redefinition of 
>> 'get_unaligned_le32'
static inline u32 get_unaligned_le32(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:4:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/nfc/nfcmrvl/fw_dnld.c:19:
   include/linux/unaligned/le_struct.h:11:19: note: previous definition of 
'get_unaligned_le32' was here
static inline u32 get_unaligned_le32(const void *p)
  ^~
   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:17:19: error: redefinition of 
>> 'get_unaligned_le64'
static inline u64 get_unaligned_le64(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:4:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/nfc/nfcmrvl/fw_dnld.c:19:
   include/linux/unaligned/le_struct.h:16:19: note: previous definition of 
'get_unaligned_le64' was here
static inline u64 get_unaligned_le64(const void *p)
  ^~
   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:22:19: error: redefinition of 
>> 'get_unaligned_be16'
static inline u16 get_unaligned_be16(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:5:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/nfc/nfcmrvl/fw_dnld.c:19:
   include/linux/unaligned/be_byteshift.h:40:19: note: previous definition of 
'get_unaligned_be16' was here
static inline u16 get_unaligned_be16(const void *p)
  ^~
   In file included from drivers/nfc/nfcmrvl/fw_dnld.c:20:0:
>> include/linux/unaligned/access_ok.h:27:19: error: redefinition of 
>> 'get_unaligned_be32'
static inline u32 get_unaligned_be32(const void *p)
  ^~
   In file included from arch/ia64/include/asm/unaligned.h:5:0,
from arch/ia64/include/asm/io.h:22,
from arch/ia64/include/asm/smp.h:20,
from 

[GIT PULL] turbostat patches for 4.10 merge

2016-12-24 Thread Len Brown
Hi Linus,

Please pull these turbostat patches.

thanks!
Len Brown, Intel Open Source Technology Center

The following changes since commit 43c4f67c966deb1478dc9acbf66ab547287d530f:
Merge branch 'akpm' (patches from Andrew) (2016-11-30 16:33:41 -0800)
are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git turbostat

for you to fetch changes up to 6886fee4d7a3afaf905a8e0bec62dc8fdc39878d:
tools/power turbostat: remove obsolete -M, -m, -C, -c options
(2016-12-24 15:38:09 -0500)



Colin Ian King (1):
tools/power turbostat: fix error case overflow read of slm_freq_table[]

Jacob Pan (3):
tools/power/turbostat: split core MSR support into status + limit
tools/power/turbostat: Add Denverton support
tools/power/turbostat: Add Denverton RAPL support


Len Brown (10):
tools/power turbostat: tidy up output on Joule counter overflow
tools/power turbostat: Gracefully handle ACPI S3
tools/power turbostat: switch to tab delimited output
tools/power turbostat: use intel-family.h model strings
tools/power turbostat: Support Knights Mill (KNM)
tools/power turbostat: fix SKX PKG_CSTATE_LIMIT decoding
tools/power turbostat: line up headers when -M is used
tools/power turbostat: Denverton uses a 25 MHz crystal, not 19.2 MHz
tools/power turbostat: Make extensible via the --add parameter
tools/power turbostat: remove obsolete -M, -m, -C, -c options

Mika Westerberg (1):
tools/power turbostat: Allocate correct amount of fd and irq entries

Srinivas Pandruvada (1):
tools/power turbostat: Display HWP OOB status

Xiaolong Wang (1):
tools/power turbostat: fix Denverton BCLK


tools/power/x86/turbostat/Makefile | 1 +
tools/power/x86/turbostat/turbostat.8 | 26 +-
tools/power/x86/turbostat/turbostat.c | 1017 +

3 files changed, 673 insertions(+), 371 deletions(-)


[GIT PULL] turbostat patches for 4.10 merge

2016-12-24 Thread Len Brown
Hi Linus,

Please pull these turbostat patches.

thanks!
Len Brown, Intel Open Source Technology Center

The following changes since commit 43c4f67c966deb1478dc9acbf66ab547287d530f:
Merge branch 'akpm' (patches from Andrew) (2016-11-30 16:33:41 -0800)
are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git turbostat

for you to fetch changes up to 6886fee4d7a3afaf905a8e0bec62dc8fdc39878d:
tools/power turbostat: remove obsolete -M, -m, -C, -c options
(2016-12-24 15:38:09 -0500)



Colin Ian King (1):
tools/power turbostat: fix error case overflow read of slm_freq_table[]

Jacob Pan (3):
tools/power/turbostat: split core MSR support into status + limit
tools/power/turbostat: Add Denverton support
tools/power/turbostat: Add Denverton RAPL support


Len Brown (10):
tools/power turbostat: tidy up output on Joule counter overflow
tools/power turbostat: Gracefully handle ACPI S3
tools/power turbostat: switch to tab delimited output
tools/power turbostat: use intel-family.h model strings
tools/power turbostat: Support Knights Mill (KNM)
tools/power turbostat: fix SKX PKG_CSTATE_LIMIT decoding
tools/power turbostat: line up headers when -M is used
tools/power turbostat: Denverton uses a 25 MHz crystal, not 19.2 MHz
tools/power turbostat: Make extensible via the --add parameter
tools/power turbostat: remove obsolete -M, -m, -C, -c options

Mika Westerberg (1):
tools/power turbostat: Allocate correct amount of fd and irq entries

Srinivas Pandruvada (1):
tools/power turbostat: Display HWP OOB status

Xiaolong Wang (1):
tools/power turbostat: fix Denverton BCLK


tools/power/x86/turbostat/Makefile | 1 +
tools/power/x86/turbostat/turbostat.8 | 26 +-
tools/power/x86/turbostat/turbostat.c | 1017 +

3 files changed, 673 insertions(+), 371 deletions(-)


Re: [RFC PATCH 4.10 3/6] bpf: Use SHA256 instead of SHA1 for bpf digests

2016-12-24 Thread Daniel Borkmann

On 12/24/2016 03:22 AM, Andy Lutomirski wrote:

BPF digests are intended to be used to avoid reloading programs that
are already loaded.  For use cases (CRIU?) where untrusted programs
are involved, intentional hash collisions could cause the wrong BPF
program to execute.  Additionally, if BPF digests are ever used
in-kernel to skip verification, a hash collision could give privilege
escalation directly.


Just for the record, digests will never ever be used to skip the
verification step, so I don't know why this idea even comes up
here (?) or is part of the changelog? As this will never be done
anyway, rather drop that part so we can avoid confusion on this?

Wrt untrusted programs, I don't see much of a use on this facility
in general for them. Something like a tail call map would quite
likely only be private to the application. And again, I really doubt
we'll have something like user namespace support in the foreseeable
future. Anyway, that said, I don't really have a big issue if you
want to switch to sha256, though.


SHA1 is no longer considered adequately collision-resistant (see, for
example, all the major browsers dropping support for SHA1
certificates).  Use SHA256 instead.

I moved the digest field to keep all of the bpf program metadata in
the same cache line.

Cc: Daniel Borkmann 
Cc: Alexei Starovoitov 
Signed-off-by: Andy Lutomirski 




Re: [RFC PATCH 4.10 3/6] bpf: Use SHA256 instead of SHA1 for bpf digests

2016-12-24 Thread Daniel Borkmann

On 12/24/2016 03:22 AM, Andy Lutomirski wrote:

BPF digests are intended to be used to avoid reloading programs that
are already loaded.  For use cases (CRIU?) where untrusted programs
are involved, intentional hash collisions could cause the wrong BPF
program to execute.  Additionally, if BPF digests are ever used
in-kernel to skip verification, a hash collision could give privilege
escalation directly.


Just for the record, digests will never ever be used to skip the
verification step, so I don't know why this idea even comes up
here (?) or is part of the changelog? As this will never be done
anyway, rather drop that part so we can avoid confusion on this?

Wrt untrusted programs, I don't see much of a use on this facility
in general for them. Something like a tail call map would quite
likely only be private to the application. And again, I really doubt
we'll have something like user namespace support in the foreseeable
future. Anyway, that said, I don't really have a big issue if you
want to switch to sha256, though.


SHA1 is no longer considered adequately collision-resistant (see, for
example, all the major browsers dropping support for SHA1
certificates).  Use SHA256 instead.

I moved the digest field to keep all of the bpf program metadata in
the same cache line.

Cc: Daniel Borkmann 
Cc: Alexei Starovoitov 
Signed-off-by: Andy Lutomirski 




[RFC] taint/module: Fix problems when out-of-kernel driver defines true or false

2016-12-24 Thread Larry Finger
Commit 7fd8329ba502 ("taint/module: Clean up global and module taint
flags handling") used the key words true and false as character members
of a new struct. These names cause problems when out-of-kernel modules
such as VirtualBox include their own definitions of true and false.

Fixes: 7fd8329ba502 ("taint/module: Clean up global and module taint flags 
handling")
Signed-off-by: Larry Finger 
Cc: Petr Mladek 
Cc: Jessica Yu 
Cc: Rusty Russell 
---
 include/linux/kernel.h | 4 ++--
 kernel/module.c| 2 +-
 kernel/panic.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 56aec84..cb09238 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -514,8 +514,8 @@ extern enum system_states {
 #define TAINT_FLAGS_COUNT  16
 
 struct taint_flag {
-   char true;  /* character printed when tainted */
-   char false; /* character printed when not tainted */
+   char c_true;/* character printed when tainted */
+   char c_false;   /* character printed when not tainted */
bool module;/* also show as a per-module taint flag */
 };
 
diff --git a/kernel/module.c b/kernel/module.c
index f7482db..5f7d482 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1145,7 +1145,7 @@ static size_t module_flags_taint(struct module *mod, char 
*buf)
 
for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
if (taint_flags[i].module && test_bit(i, >taints))
-   buf[l++] = taint_flags[i].true;
+   buf[l++] = taint_flags[i].c_true;
}
 
return l;
diff --git a/kernel/panic.c b/kernel/panic.c
index c51edaa..901c4fb 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -355,7 +355,7 @@ const char *print_tainted(void)
for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
const struct taint_flag *t = _flags[i];
*s++ = test_bit(i, _mask) ?
-   t->true : t->false;
+   t->c_true : t->c_false;
}
*s = 0;
} else
-- 
2.10.2



[RFC] taint/module: Fix problems when out-of-kernel driver defines true or false

2016-12-24 Thread Larry Finger
Commit 7fd8329ba502 ("taint/module: Clean up global and module taint
flags handling") used the key words true and false as character members
of a new struct. These names cause problems when out-of-kernel modules
such as VirtualBox include their own definitions of true and false.

Fixes: 7fd8329ba502 ("taint/module: Clean up global and module taint flags 
handling")
Signed-off-by: Larry Finger 
Cc: Petr Mladek 
Cc: Jessica Yu 
Cc: Rusty Russell 
---
 include/linux/kernel.h | 4 ++--
 kernel/module.c| 2 +-
 kernel/panic.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 56aec84..cb09238 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -514,8 +514,8 @@ extern enum system_states {
 #define TAINT_FLAGS_COUNT  16
 
 struct taint_flag {
-   char true;  /* character printed when tainted */
-   char false; /* character printed when not tainted */
+   char c_true;/* character printed when tainted */
+   char c_false;   /* character printed when not tainted */
bool module;/* also show as a per-module taint flag */
 };
 
diff --git a/kernel/module.c b/kernel/module.c
index f7482db..5f7d482 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1145,7 +1145,7 @@ static size_t module_flags_taint(struct module *mod, char 
*buf)
 
for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
if (taint_flags[i].module && test_bit(i, >taints))
-   buf[l++] = taint_flags[i].true;
+   buf[l++] = taint_flags[i].c_true;
}
 
return l;
diff --git a/kernel/panic.c b/kernel/panic.c
index c51edaa..901c4fb 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -355,7 +355,7 @@ const char *print_tainted(void)
for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
const struct taint_flag *t = _flags[i];
*s++ = test_bit(i, _mask) ?
-   t->true : t->false;
+   t->c_true : t->c_false;
}
*s = 0;
} else
-- 
2.10.2



Re: [PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

2016-12-24 Thread Linus Torvalds
Nick,
mind adding a changelog and a sign-off for these two patches?

I'd like to apply at least the first one asap, just to get as much
verification of the page flag bits as possible.

 Linus

On Wed, Dec 21, 2016 at 7:19 AM, Nicholas Piggin  wrote:
> ---
>  include/linux/page-flags.h | 24 
>  include/trace/events/mmflags.h |  1 -
>  2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 74e4dda91238..a57c909a15e4 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -87,7 +87,6 @@ enum pageflags {
> PG_private_2,   /* If pagecache, has fs aux data */
> PG_writeback,   /* Page is under writeback */
> PG_head,/* A head page */
> -   PG_swapcache,   /* Swap page: swp_entry_t in private */
> PG_mappedtodisk,/* Has blocks allocated on-disk */
> PG_reclaim, /* To be reclaimed asap */
> PG_swapbacked,  /* Page is backed by RAM/swap */
> @@ -110,6 +109,9 @@ enum pageflags {
> /* Filesystems */
> PG_checked = PG_owner_priv_1,
>
> +   /* SwapBacked */
> +   PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private 
> */
> +
> /* Two page bits are conscripted by FS-Cache to maintain local caching
>  * state.  These bits are set on pages belonging to the netfs's inodes
>  * when those inodes are being locally cached.
> @@ -314,7 +316,13 @@ PAGEFLAG_FALSE(HighMem)
>  #endif
>
>  #ifdef CONFIG_SWAP
> -PAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
> +static __always_inline int PageSwapCache(struct page *page)
> +{
> +   return PageSwapBacked(page) && test_bit(PG_swapcache, >flags);
> +
> +}
> +SETPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
> +CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
>  #else
>  PAGEFLAG_FALSE(SwapCache)
>  #endif
> @@ -701,12 +709,12 @@ static inline void ClearPageSlabPfmemalloc(struct page 
> *page)
>   * Flags checked when a page is freed.  Pages being freed should not have
>   * these flags set.  It they are, there is a problem.
>   */
> -#define PAGE_FLAGS_CHECK_AT_FREE \
> -   (1UL << PG_lru   | 1UL << PG_locked| \
> -1UL << PG_private | 1UL << PG_private_2 | \
> -1UL << PG_writeback | 1UL << PG_reserved | \
> -1UL << PG_slab  | 1UL << PG_swapcache | 1UL << PG_active | \
> -1UL << PG_unevictable | __PG_MLOCKED)
> +#define PAGE_FLAGS_CHECK_AT_FREE   \
> +   (1UL << PG_lru  | 1UL << PG_locked  |   \
> +1UL << PG_private  | 1UL << PG_private_2   |   \
> +1UL << PG_writeback| 1UL << PG_reserved|   \
> +1UL << PG_slab | 1UL << PG_active  |   \
> +1UL << PG_unevictable  | __PG_MLOCKED)
>
>  /*
>   * Flags checked when a page is prepped for return by the page allocator.
> diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
> index 5a81ab48a2fb..30c2adbdebe8 100644
> --- a/include/trace/events/mmflags.h
> +++ b/include/trace/events/mmflags.h
> @@ -95,7 +95,6 @@
> {1UL << PG_private_2,   "private_2" },  \
> {1UL << PG_writeback,   "writeback" },  \
> {1UL << PG_head,"head"  },  \
> -   {1UL << PG_swapcache,   "swapcache" },  \
> {1UL << PG_mappedtodisk,"mappedtodisk"  },  \
> {1UL << PG_reclaim, "reclaim"   },  \
> {1UL << PG_swapbacked,  "swapbacked"},  \
> --
> 2.11.0
>


Re: [PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

2016-12-24 Thread Linus Torvalds
Nick,
mind adding a changelog and a sign-off for these two patches?

I'd like to apply at least the first one asap, just to get as much
verification of the page flag bits as possible.

 Linus

On Wed, Dec 21, 2016 at 7:19 AM, Nicholas Piggin  wrote:
> ---
>  include/linux/page-flags.h | 24 
>  include/trace/events/mmflags.h |  1 -
>  2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 74e4dda91238..a57c909a15e4 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -87,7 +87,6 @@ enum pageflags {
> PG_private_2,   /* If pagecache, has fs aux data */
> PG_writeback,   /* Page is under writeback */
> PG_head,/* A head page */
> -   PG_swapcache,   /* Swap page: swp_entry_t in private */
> PG_mappedtodisk,/* Has blocks allocated on-disk */
> PG_reclaim, /* To be reclaimed asap */
> PG_swapbacked,  /* Page is backed by RAM/swap */
> @@ -110,6 +109,9 @@ enum pageflags {
> /* Filesystems */
> PG_checked = PG_owner_priv_1,
>
> +   /* SwapBacked */
> +   PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private 
> */
> +
> /* Two page bits are conscripted by FS-Cache to maintain local caching
>  * state.  These bits are set on pages belonging to the netfs's inodes
>  * when those inodes are being locally cached.
> @@ -314,7 +316,13 @@ PAGEFLAG_FALSE(HighMem)
>  #endif
>
>  #ifdef CONFIG_SWAP
> -PAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
> +static __always_inline int PageSwapCache(struct page *page)
> +{
> +   return PageSwapBacked(page) && test_bit(PG_swapcache, >flags);
> +
> +}
> +SETPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
> +CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND)
>  #else
>  PAGEFLAG_FALSE(SwapCache)
>  #endif
> @@ -701,12 +709,12 @@ static inline void ClearPageSlabPfmemalloc(struct page 
> *page)
>   * Flags checked when a page is freed.  Pages being freed should not have
>   * these flags set.  It they are, there is a problem.
>   */
> -#define PAGE_FLAGS_CHECK_AT_FREE \
> -   (1UL << PG_lru   | 1UL << PG_locked| \
> -1UL << PG_private | 1UL << PG_private_2 | \
> -1UL << PG_writeback | 1UL << PG_reserved | \
> -1UL << PG_slab  | 1UL << PG_swapcache | 1UL << PG_active | \
> -1UL << PG_unevictable | __PG_MLOCKED)
> +#define PAGE_FLAGS_CHECK_AT_FREE   \
> +   (1UL << PG_lru  | 1UL << PG_locked  |   \
> +1UL << PG_private  | 1UL << PG_private_2   |   \
> +1UL << PG_writeback| 1UL << PG_reserved|   \
> +1UL << PG_slab | 1UL << PG_active  |   \
> +1UL << PG_unevictable  | __PG_MLOCKED)
>
>  /*
>   * Flags checked when a page is prepped for return by the page allocator.
> diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
> index 5a81ab48a2fb..30c2adbdebe8 100644
> --- a/include/trace/events/mmflags.h
> +++ b/include/trace/events/mmflags.h
> @@ -95,7 +95,6 @@
> {1UL << PG_private_2,   "private_2" },  \
> {1UL << PG_writeback,   "writeback" },  \
> {1UL << PG_head,"head"  },  \
> -   {1UL << PG_swapcache,   "swapcache" },  \
> {1UL << PG_mappedtodisk,"mappedtodisk"  },  \
> {1UL << PG_reclaim, "reclaim"   },  \
> {1UL << PG_swapbacked,  "swapbacked"},  \
> --
> 2.11.0
>


Re: [PATCH v2 1/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread Sergei Shtylyov

Hello!

On 12/24/2016 03:02 PM, Thomas Preisner wrote:


In a few cases the err-variable is not set to a negative error code if a
function call fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code
before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

Reported-by: Pan Bian 
Signed-off-by: Thomas Preisner 
Signed-off-by: Milan Stephan 
---
 drivers/net/ethernet/3com/typhoon.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c 
b/drivers/net/ethernet/3com/typhoon.c
index a0cacbe..c88b88a 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c

[...]

@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 * later when we print out the version reported.
 */
INIT_COMMAND_WITH_RESPONSE(_cmd, TYPHOON_CMD_READ_VERSIONS);
-   if(typhoon_issue_command(tp, 1, _cmd, 3, xp_resp) < 0) {
+   err = typhoon_issue_command(tp, 1, _cmd, 3, xp_resp);
+   if(err < 0) {


   Need a space between *if* and (. Run your patches thru 
scripts/checkpatch.pl before posting, please.



err_msg = "Could not get Sleep Image version";
goto error_out_reset;
}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
dev->features = dev->hw_features |
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;

-   if(register_netdev(dev) < 0) {
+   err = register_netdev(dev);
+   if(err < 0) {


   Same here.

[...]

MBR, Sergei



Re: [PATCH v2 1/2] drivers: net: ethernet: 3com: fix return value

2016-12-24 Thread Sergei Shtylyov

Hello!

On 12/24/2016 03:02 PM, Thomas Preisner wrote:


In a few cases the err-variable is not set to a negative error code if a
function call fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code
before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

Reported-by: Pan Bian 
Signed-off-by: Thomas Preisner 
Signed-off-by: Milan Stephan 
---
 drivers/net/ethernet/3com/typhoon.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c 
b/drivers/net/ethernet/3com/typhoon.c
index a0cacbe..c88b88a 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c

[...]

@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 * later when we print out the version reported.
 */
INIT_COMMAND_WITH_RESPONSE(_cmd, TYPHOON_CMD_READ_VERSIONS);
-   if(typhoon_issue_command(tp, 1, _cmd, 3, xp_resp) < 0) {
+   err = typhoon_issue_command(tp, 1, _cmd, 3, xp_resp);
+   if(err < 0) {


   Need a space between *if* and (. Run your patches thru 
scripts/checkpatch.pl before posting, please.



err_msg = "Could not get Sleep Image version";
goto error_out_reset;
}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
dev->features = dev->hw_features |
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;

-   if(register_netdev(dev) < 0) {
+   err = register_netdev(dev);
+   if(err < 0) {


   Same here.

[...]

MBR, Sergei



Re: linux-next: Tree for Dec 24 (ijnput/rmi4)

2016-12-24 Thread Randy Dunlap
On 12/23/16 19:53, Stephen Rothwell wrote:
> Hi all,
> 
> Please do not add any material for v4.11 to your linux-next included
> branches until after v4.10-rc1 has been released.
> 
> There will be no linux-next releases from me between Dec 25 and Jan 2
> inclusive (unless I get really bored with my new toys :-)).
> 
> Changes since 20161223:
> 

on x86_64:

when CONFIG_SERIO=m and CONFIG_RMI4_F03=y:

drivers/built-in.o: In function `rmi_f03_attention':
rmi_f03.c:(.text+0xf8ef8): undefined reference to `serio_interrupt'
rmi_f03.c:(.text+0xf8fbd): undefined reference to `serio_interrupt'
drivers/built-in.o: In function `rmi_f03_remove':
rmi_f03.c:(.text+0xf9082): undefined reference to `serio_unregister_port'
drivers/built-in.o: In function `rmi_f03_probe':
rmi_f03.c:(.text+0xf9260): undefined reference to `__serio_register_port'




-- 
~Randy


Re: linux-next: Tree for Dec 24 (ijnput/rmi4)

2016-12-24 Thread Randy Dunlap
On 12/23/16 19:53, Stephen Rothwell wrote:
> Hi all,
> 
> Please do not add any material for v4.11 to your linux-next included
> branches until after v4.10-rc1 has been released.
> 
> There will be no linux-next releases from me between Dec 25 and Jan 2
> inclusive (unless I get really bored with my new toys :-)).
> 
> Changes since 20161223:
> 

on x86_64:

when CONFIG_SERIO=m and CONFIG_RMI4_F03=y:

drivers/built-in.o: In function `rmi_f03_attention':
rmi_f03.c:(.text+0xf8ef8): undefined reference to `serio_interrupt'
rmi_f03.c:(.text+0xf8fbd): undefined reference to `serio_interrupt'
drivers/built-in.o: In function `rmi_f03_remove':
rmi_f03.c:(.text+0xf9082): undefined reference to `serio_unregister_port'
drivers/built-in.o: In function `rmi_f03_probe':
rmi_f03.c:(.text+0xf9260): undefined reference to `__serio_register_port'




-- 
~Randy


[PATCH 2/2] ALSA: hda - Fix click noises on Samsung Ativ Book 8

2016-12-24 Thread Gabriele Mazzotta
The Samsung Ativ Book 8 makes a loud click noise on boot, shutdown
and when the audio card enters or exits power saving states. All
these noises disappear applying ALC269_FIXUP_NO_SHUTUP.

In addition to that, fix the loud click noise that the laptop
makes when inserting or removing the headphone jack by automuting
via amp instead of pinctl.

Signed-off-by: Gabriele Mazzotta 
---
 sound/pci/hda/patch_realtek.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d30cc49512e4..00df12b6695a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4856,6 +4856,7 @@ enum {
ALC292_FIXUP_TPT460,
ALC298_FIXUP_SPK_VOLUME,
ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
+   ALC269_FIXUP_ATIV_BOOK_8,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -5528,6 +5529,12 @@ static const struct hda_fixup alc269_fixups[] = {
.chained = true,
.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
},
+   [ALC269_FIXUP_ATIV_BOOK_8] = {
+   .type = HDA_FIXUP_FUNC,
+   .v.func = alc_fixup_auto_mute_via_amp,
+   .chained = true,
+   .chain_id = ALC269_FIXUP_NO_SHUTUP
+   },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5664,6 +5671,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", 
ALC269_FIXUP_LIFEBOOK_HP_PIN),
SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", 
ALC269_FIXUP_LIFEBOOK_EXTMIC),
SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", 
ALC269_FIXUP_INV_DMIC),
+   SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", 
ALC269_FIXUP_ATIV_BOOK_8),
SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", 
ALC283_FIXUP_HEADSET_MIC),
SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", 
ALC283_FIXUP_HEADSET_MIC),
SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", 
ALC269_FIXUP_SKU_IGNORE),
-- 
2.11.0



[PATCH 1/2] ALSA: hda - Apply ALC269_FIXUP_NO_SHUTUP on HDA_FIXUP_ACT_PROBE

2016-12-24 Thread Gabriele Mazzotta
Setting shutup when the action is HDA_FIXUP_ACT_PRE_PROBE might
not have the desired effect since it could be overridden by
another more generic shutup function. Prevent this by setting
the more specific shutup function on HDA_FIXUP_ACT_PROBE.

Signed-off-by: Gabriele Mazzotta 
---
 sound/pci/hda/patch_realtek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index ea81c08ddc7a..d30cc49512e4 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4400,7 +4400,7 @@ static void alc_no_shutup(struct hda_codec *codec)
 static void alc_fixup_no_shutup(struct hda_codec *codec,
const struct hda_fixup *fix, int action)
 {
-   if (action == HDA_FIXUP_ACT_PRE_PROBE) {
+   if (action == HDA_FIXUP_ACT_PROBE) {
struct alc_spec *spec = codec->spec;
spec->shutup = alc_no_shutup;
}
-- 
2.11.0



[PATCH 2/2] ALSA: hda - Fix click noises on Samsung Ativ Book 8

2016-12-24 Thread Gabriele Mazzotta
The Samsung Ativ Book 8 makes a loud click noise on boot, shutdown
and when the audio card enters or exits power saving states. All
these noises disappear applying ALC269_FIXUP_NO_SHUTUP.

In addition to that, fix the loud click noise that the laptop
makes when inserting or removing the headphone jack by automuting
via amp instead of pinctl.

Signed-off-by: Gabriele Mazzotta 
---
 sound/pci/hda/patch_realtek.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d30cc49512e4..00df12b6695a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4856,6 +4856,7 @@ enum {
ALC292_FIXUP_TPT460,
ALC298_FIXUP_SPK_VOLUME,
ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
+   ALC269_FIXUP_ATIV_BOOK_8,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -5528,6 +5529,12 @@ static const struct hda_fixup alc269_fixups[] = {
.chained = true,
.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
},
+   [ALC269_FIXUP_ATIV_BOOK_8] = {
+   .type = HDA_FIXUP_FUNC,
+   .v.func = alc_fixup_auto_mute_via_amp,
+   .chained = true,
+   .chain_id = ALC269_FIXUP_NO_SHUTUP
+   },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5664,6 +5671,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", 
ALC269_FIXUP_LIFEBOOK_HP_PIN),
SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", 
ALC269_FIXUP_LIFEBOOK_EXTMIC),
SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", 
ALC269_FIXUP_INV_DMIC),
+   SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", 
ALC269_FIXUP_ATIV_BOOK_8),
SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", 
ALC283_FIXUP_HEADSET_MIC),
SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", 
ALC283_FIXUP_HEADSET_MIC),
SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", 
ALC269_FIXUP_SKU_IGNORE),
-- 
2.11.0



[PATCH 1/2] ALSA: hda - Apply ALC269_FIXUP_NO_SHUTUP on HDA_FIXUP_ACT_PROBE

2016-12-24 Thread Gabriele Mazzotta
Setting shutup when the action is HDA_FIXUP_ACT_PRE_PROBE might
not have the desired effect since it could be overridden by
another more generic shutup function. Prevent this by setting
the more specific shutup function on HDA_FIXUP_ACT_PROBE.

Signed-off-by: Gabriele Mazzotta 
---
 sound/pci/hda/patch_realtek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index ea81c08ddc7a..d30cc49512e4 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4400,7 +4400,7 @@ static void alc_no_shutup(struct hda_codec *codec)
 static void alc_fixup_no_shutup(struct hda_codec *codec,
const struct hda_fixup *fix, int action)
 {
-   if (action == HDA_FIXUP_ACT_PRE_PROBE) {
+   if (action == HDA_FIXUP_ACT_PROBE) {
struct alc_spec *spec = codec->spec;
spec->shutup = alc_no_shutup;
}
-- 
2.11.0



Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

2016-12-24 Thread Pali Rohár
On Saturday 24 December 2016 19:17:30 Pavel Machek wrote:
> Hi!
> 
> > In case there is no valid MAC address kernel generates random one.
> > This patch propagate this generated MAC address back to NVS data
> > which will be uploaded to wl1251 chip. So HW would have same MAC
> > address as linux kernel uses.
> > 
> > return 0;
> >  
> >  }
> > 
> > +static int wl1251_write_nvs_mac(struct wl1251 *wl)
> > +{
> 
> The name is quite confusing, this sounds like writing into
> non-volatile storage.
> 
> > +   int i;
> > +
> > +   if (wl->nvs_len < 0x24)
> > +   return -ENODATA;
> > +
> > +   /* length is 2 and data address is 0x546c (mask is 0xfffe) */
> 
> You don't actually check for the mask.

It is quite complicated. { 0x6d, 0x54 } (= 0x546d) in data represent 
address 0x546c and content are data. You need to apply mask 0xfffe for 
0x546d and you get address where data will be written (so 0x546c).

> > +   if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b]
> > != 0x54) +  return -EINVAL;
> 
> You have two copies of these. Does it make sense to move it to helper
> function?

I'm thinking if checks is really needed. But probably moving it to 
separate function is good idea.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

2016-12-24 Thread Pali Rohár
On Saturday 24 December 2016 19:17:30 Pavel Machek wrote:
> Hi!
> 
> > In case there is no valid MAC address kernel generates random one.
> > This patch propagate this generated MAC address back to NVS data
> > which will be uploaded to wl1251 chip. So HW would have same MAC
> > address as linux kernel uses.
> > 
> > return 0;
> >  
> >  }
> > 
> > +static int wl1251_write_nvs_mac(struct wl1251 *wl)
> > +{
> 
> The name is quite confusing, this sounds like writing into
> non-volatile storage.
> 
> > +   int i;
> > +
> > +   if (wl->nvs_len < 0x24)
> > +   return -ENODATA;
> > +
> > +   /* length is 2 and data address is 0x546c (mask is 0xfffe) */
> 
> You don't actually check for the mask.

It is quite complicated. { 0x6d, 0x54 } (= 0x546d) in data represent 
address 0x546c and content are data. You need to apply mask 0xfffe for 
0x546d and you get address where data will be written (so 0x546c).

> > +   if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b]
> > != 0x54) +  return -EINVAL;
> 
> You have two copies of these. Does it make sense to move it to helper
> function?

I'm thinking if checks is really needed. But probably moving it to 
separate function is good idea.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH 5/6] wl1251: Parse and use MAC address from supplied NVS data

2016-12-24 Thread Pali Rohár
On Saturday 24 December 2016 19:14:21 Pavel Machek wrote:
> On Sat 2016-12-24 17:53:00, Pali Rohár wrote:
> > @@ -1581,10 +1598,16 @@ int wl1251_init_ieee80211(struct wl1251
> > *wl)
> > 
> > wl->hw->queues = 4;
> > 
> > +   if (wl->nvs == NULL && !wl->use_eeprom) {
> > +   ret = wl1251_fetch_nvs(wl);
> > +   if (ret < 0)
> > +   goto out;
> > +   }
> 
> Is goto out here good idea? IMNSHO it is copy bug, it should
> just proceed with generating random address.

No, goto is correct here. wl1251 cannot be initialized without NVS data. 
And when fetching (from userspace) fails it is fatal error.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH 5/6] wl1251: Parse and use MAC address from supplied NVS data

2016-12-24 Thread Pali Rohár
On Saturday 24 December 2016 19:14:21 Pavel Machek wrote:
> On Sat 2016-12-24 17:53:00, Pali Rohár wrote:
> > @@ -1581,10 +1598,16 @@ int wl1251_init_ieee80211(struct wl1251
> > *wl)
> > 
> > wl->hw->queues = 4;
> > 
> > +   if (wl->nvs == NULL && !wl->use_eeprom) {
> > +   ret = wl1251_fetch_nvs(wl);
> > +   if (ret < 0)
> > +   goto out;
> > +   }
> 
> Is goto out here good idea? IMNSHO it is copy bug, it should
> just proceed with generating random address.

No, goto is correct here. wl1251 cannot be initialized without NVS data. 
And when fetching (from userspace) fails it is fatal error.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH 4/6] wl1251: Generate random MAC address only if driver does not have valid

2016-12-24 Thread Pali Rohár
On Saturday 24 December 2016 19:08:54 Pavel Machek wrote:
> On Sat 2016-12-24 17:52:59, Pali Rohár wrote:
> > Before this patch driver generated random MAC address every time
> > when was doing initialization. And after that random MAC address
> > could be overwritten with fixed one if provided.
> 
> Before this patch, driver generated random MAC address every time it
> was initialized. After that random MAC address could be overwritten
> with fixed one, if provided.
> 
> > This patch changes order. First it tries to read fixed MAC address
> > and if it fails then driver generates random MAC address.
> 
> I don't quite get where the advantage is supposed to be. Is it that
> "use_eeprom" is set, but reading fails?

Random bytes are read from kernel only if random MAC address is needed. 
And in wl->mac_addr is always either invalid address or permanenent mac 
address which will be used. Without patch in wl->mac_addr can be random 
temporary address for some time...

> The only case where this helps is if wl1251_read_eeprom_mac()
> succeeds but reads invalid address.
> 
> > Signed-off-by: Pali Rohár 
> 
> Acked-by: Pavel Machek 

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH 4/6] wl1251: Generate random MAC address only if driver does not have valid

2016-12-24 Thread Pali Rohár
On Saturday 24 December 2016 19:08:54 Pavel Machek wrote:
> On Sat 2016-12-24 17:52:59, Pali Rohár wrote:
> > Before this patch driver generated random MAC address every time
> > when was doing initialization. And after that random MAC address
> > could be overwritten with fixed one if provided.
> 
> Before this patch, driver generated random MAC address every time it
> was initialized. After that random MAC address could be overwritten
> with fixed one, if provided.
> 
> > This patch changes order. First it tries to read fixed MAC address
> > and if it fails then driver generates random MAC address.
> 
> I don't quite get where the advantage is supposed to be. Is it that
> "use_eeprom" is set, but reading fails?

Random bytes are read from kernel only if random MAC address is needed. 
And in wl->mac_addr is always either invalid address or permanenent mac 
address which will be used. Without patch in wl->mac_addr can be random 
temporary address for some time...

> The only case where this helps is if wl1251_read_eeprom_mac()
> succeeds but reads invalid address.
> 
> > Signed-off-by: Pali Rohár 
> 
> Acked-by: Pavel Machek 

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH] media: Add video bus switch

2016-12-24 Thread kbuild test robot
Hi Pavel,

[auto build test WARNING on v4.9-rc8]
[also build test WARNING on next-20161224]
[cannot apply to linuxtv-media/master]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Pavel-Machek/media-Add-video-bus-switch/20161225-003239
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
   include/linux/init.h:1: warning: no structured comments found
   include/linux/workqueue.h:392: warning: No description found for parameter 
'...'
   include/linux/workqueue.h:392: warning: Excess function parameter 'args' 
description in 'alloc_workqueue'
   include/linux/workqueue.h:413: warning: No description found for parameter 
'...'
   include/linux/workqueue.h:413: warning: Excess function parameter 'args' 
description in 'alloc_ordered_workqueue'
   include/linux/kthread.h:26: warning: No description found for parameter '...'
   kernel/sys.c:1: warning: no structured comments found
   drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found
   include/linux/fence-array.h:61: warning: No description found for parameter 
'fence'
   include/sound/core.h:324: warning: No description found for parameter '...'
   include/sound/core.h:335: warning: No description found for parameter '...'
   include/sound/core.h:388: warning: No description found for parameter '...'
   include/media/media-entity.h:1054: warning: No description found for 
parameter '...'
>> include/media/v4l2-subdev.h:421: warning: No description found for parameter 
>> 'g_endpoint_config'
   include/net/mac80211.h:3207: ERROR: Unexpected indentation.
   include/net/mac80211.h:3210: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:3212: ERROR: Unexpected indentation.
   include/net/mac80211.h:3213: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:1772: ERROR: Unexpected indentation.
   include/net/mac80211.h:1776: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/sched/fair.c:7259: WARNING: Inline emphasis start-string without 
end-string.
   kernel/time/timer.c:1240: ERROR: Unexpected indentation.
   kernel/time/timer.c:1242: ERROR: Unexpected indentation.
   kernel/time/timer.c:1243: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/linux/wait.h:121: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/linux/wait.h:124: ERROR: Unexpected indentation.
   include/linux/wait.h:126: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/time/hrtimer.c:1021: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/signal.c:317: WARNING: Inline literal start-string without end-string.
   drivers/base/firmware_class.c:1348: WARNING: Bullet list ends without a 
blank line; unexpected unindent.
   drivers/message/fusion/mptbase.c:5054: WARNING: Definition list ends without 
a blank line; unexpected unindent.
   drivers/tty/serial/serial_core.c:1893: WARNING: Definition list ends without 
a blank line; unexpected unindent.
   include/linux/spi/spi.h:369: ERROR: Unexpected indentation.
   WARNING: dvipng command 'dvipng' cannot be run (needed for math display), 
check the imgmath_dvipng setting
   Documentation/output/media.h.rst:6: WARNING: undefined label: 
media-ent-f-switch (if the link has no caption the label must precede a section 
header)

vim +/g_endpoint_config +421 include/media/v4l2-subdev.h

35c3017a Laurent Pinchart   2010-05-05  405 int 
(*s_frame_interval)(struct v4l2_subdev *sd,
35c3017a Laurent Pinchart   2010-05-05  406 
struct v4l2_subdev_frame_interval *interval);
b6456c0c Muralidharan Karicheri 2009-11-19  407 int 
(*s_dv_timings)(struct v4l2_subdev *sd,
b6456c0c Muralidharan Karicheri 2009-11-19  408 struct 
v4l2_dv_timings *timings);
b6456c0c Muralidharan Karicheri 2009-11-19  409 int 
(*g_dv_timings)(struct v4l2_subdev *sd,
b6456c0c Muralidharan Karicheri 2009-11-19  410 struct 
v4l2_dv_timings *timings);
5d7758ee Hans Verkuil   2012-05-15  411 int 
(*query_dv_timings)(struct v4l2_subdev *sd,
5d7758ee Hans Verkuil   2012-05-15  412 struct 
v4l2_dv_timings *timings);
91c79530 Guennadi Liakhovetski  2011-07-01  413 int 
(*g_mbus_config)(struct v4l2_subdev *sd,
91c79530 Guennadi Liakhovetski  2011-07-01  414  
struct v4l2_mbus_config *cfg);
91c79530 Guennadi Liakhovetski  2011-07-01  415 int 
(*s_mbus_config)(struct v4l2_subdev *sd,
91c79530 Guennadi Liakhovetski  2011-07-01  416  
const struct v4l2_mbus_config *cfg);
a375e1df Sylwester Nawrocki  

Re: [PATCH] media: Add video bus switch

2016-12-24 Thread kbuild test robot
Hi Pavel,

[auto build test WARNING on v4.9-rc8]
[also build test WARNING on next-20161224]
[cannot apply to linuxtv-media/master]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Pavel-Machek/media-Add-video-bus-switch/20161225-003239
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
   include/linux/init.h:1: warning: no structured comments found
   include/linux/workqueue.h:392: warning: No description found for parameter 
'...'
   include/linux/workqueue.h:392: warning: Excess function parameter 'args' 
description in 'alloc_workqueue'
   include/linux/workqueue.h:413: warning: No description found for parameter 
'...'
   include/linux/workqueue.h:413: warning: Excess function parameter 'args' 
description in 'alloc_ordered_workqueue'
   include/linux/kthread.h:26: warning: No description found for parameter '...'
   kernel/sys.c:1: warning: no structured comments found
   drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found
   include/linux/fence-array.h:61: warning: No description found for parameter 
'fence'
   include/sound/core.h:324: warning: No description found for parameter '...'
   include/sound/core.h:335: warning: No description found for parameter '...'
   include/sound/core.h:388: warning: No description found for parameter '...'
   include/media/media-entity.h:1054: warning: No description found for 
parameter '...'
>> include/media/v4l2-subdev.h:421: warning: No description found for parameter 
>> 'g_endpoint_config'
   include/net/mac80211.h:3207: ERROR: Unexpected indentation.
   include/net/mac80211.h:3210: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:3212: ERROR: Unexpected indentation.
   include/net/mac80211.h:3213: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:1772: ERROR: Unexpected indentation.
   include/net/mac80211.h:1776: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/sched/fair.c:7259: WARNING: Inline emphasis start-string without 
end-string.
   kernel/time/timer.c:1240: ERROR: Unexpected indentation.
   kernel/time/timer.c:1242: ERROR: Unexpected indentation.
   kernel/time/timer.c:1243: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/linux/wait.h:121: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/linux/wait.h:124: ERROR: Unexpected indentation.
   include/linux/wait.h:126: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/time/hrtimer.c:1021: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/signal.c:317: WARNING: Inline literal start-string without end-string.
   drivers/base/firmware_class.c:1348: WARNING: Bullet list ends without a 
blank line; unexpected unindent.
   drivers/message/fusion/mptbase.c:5054: WARNING: Definition list ends without 
a blank line; unexpected unindent.
   drivers/tty/serial/serial_core.c:1893: WARNING: Definition list ends without 
a blank line; unexpected unindent.
   include/linux/spi/spi.h:369: ERROR: Unexpected indentation.
   WARNING: dvipng command 'dvipng' cannot be run (needed for math display), 
check the imgmath_dvipng setting
   Documentation/output/media.h.rst:6: WARNING: undefined label: 
media-ent-f-switch (if the link has no caption the label must precede a section 
header)

vim +/g_endpoint_config +421 include/media/v4l2-subdev.h

35c3017a Laurent Pinchart   2010-05-05  405 int 
(*s_frame_interval)(struct v4l2_subdev *sd,
35c3017a Laurent Pinchart   2010-05-05  406 
struct v4l2_subdev_frame_interval *interval);
b6456c0c Muralidharan Karicheri 2009-11-19  407 int 
(*s_dv_timings)(struct v4l2_subdev *sd,
b6456c0c Muralidharan Karicheri 2009-11-19  408 struct 
v4l2_dv_timings *timings);
b6456c0c Muralidharan Karicheri 2009-11-19  409 int 
(*g_dv_timings)(struct v4l2_subdev *sd,
b6456c0c Muralidharan Karicheri 2009-11-19  410 struct 
v4l2_dv_timings *timings);
5d7758ee Hans Verkuil   2012-05-15  411 int 
(*query_dv_timings)(struct v4l2_subdev *sd,
5d7758ee Hans Verkuil   2012-05-15  412 struct 
v4l2_dv_timings *timings);
91c79530 Guennadi Liakhovetski  2011-07-01  413 int 
(*g_mbus_config)(struct v4l2_subdev *sd,
91c79530 Guennadi Liakhovetski  2011-07-01  414  
struct v4l2_mbus_config *cfg);
91c79530 Guennadi Liakhovetski  2011-07-01  415 int 
(*s_mbus_config)(struct v4l2_subdev *sd,
91c79530 Guennadi Liakhovetski  2011-07-01  416  
const struct v4l2_mbus_config *cfg);
a375e1df Sylwester Nawrocki  

Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

2016-12-24 Thread Pavel Machek
Hi!

> In case there is no valid MAC address kernel generates random one. This
> patch propagate this generated MAC address back to NVS data which will be
> uploaded to wl1251 chip. So HW would have same MAC address as linux kernel
> uses.

>   return 0;
>  }
>  
> +static int wl1251_write_nvs_mac(struct wl1251 *wl)
> +{

The name is quite confusing, this sounds like writing into
non-volatile storage.

> + int i;
> +
> + if (wl->nvs_len < 0x24)
> + return -ENODATA;
> +
> + /* length is 2 and data address is 0x546c (mask is 0xfffe) */

You don't actually check for the mask.

> + if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 
> 0x54)
> + return -EINVAL;

You have two copies of these. Does it make sense to move it to helper
function?

Thanks,
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

2016-12-24 Thread Pavel Machek
Hi!

> In case there is no valid MAC address kernel generates random one. This
> patch propagate this generated MAC address back to NVS data which will be
> uploaded to wl1251 chip. So HW would have same MAC address as linux kernel
> uses.

>   return 0;
>  }
>  
> +static int wl1251_write_nvs_mac(struct wl1251 *wl)
> +{

The name is quite confusing, this sounds like writing into
non-volatile storage.

> + int i;
> +
> + if (wl->nvs_len < 0x24)
> + return -ENODATA;
> +
> + /* length is 2 and data address is 0x546c (mask is 0xfffe) */

You don't actually check for the mask.

> + if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 
> 0x54)
> + return -EINVAL;

You have two copies of these. Does it make sense to move it to helper
function?

Thanks,
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 5/6] wl1251: Parse and use MAC address from supplied NVS data

2016-12-24 Thread Pavel Machek
On Sat 2016-12-24 17:53:00, Pali Rohár wrote:
> This patch implements parsing MAC address from NVS data which are sent to
> wl1251 chip. Calibration NVS data could contain valid MAC address and it
> will be used instead randomly generated.

will be used instead of randomly generated one.

> This patch also move code for requesting NVS data from userspace to driver

"moves"

> initialization code to make sure that NVS data will be there at time when
> permanent MAC address is needed.

"at a time"

> Calibration NVS data for wl1251 are model specific. Every one device with

"device specific"? "Every device".

> wl1251 chip should have been calibrated in factory and needs to provide own
> calibration data.
> 
> Default example wl1251-nvs.bin data found in linux-firmware repository and

"are found"

> contains MAC address 00:00:20:07:03:09. So this MAC address is marked as

"contain"

> invalid as it is not real device specific address, just example one.
> 
> Format of calibration NVS data can be found at:
> http://notaz.gp2x.de/misc/pnd/wl1251/nvs_map.txt
> 
> Signed-off-by: Pali Rohár 
> ---
>  drivers/net/wireless/ti/wl1251/main.c |   39 
> ++---
>  1 file changed, 31 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/ti/wl1251/main.c 
> b/drivers/net/wireless/ti/wl1251/main.c
> index c3fa0b6..1454ba2 100644
> --- a/drivers/net/wireless/ti/wl1251/main.c
> +++ b/drivers/net/wireless/ti/wl1251/main.c
> @@ -205,13 +205,6 @@ static int wl1251_chip_wakeup(struct wl1251 *wl)
>   goto out;
>   }
>  
> - if (wl->nvs == NULL && !wl->use_eeprom) {
> - /* No NVS from netlink, try to get it from the filesystem */
> - ret = wl1251_fetch_nvs(wl);
> - if (ret < 0)
> - goto out;
> - }
> -
>  out:
>   return ret;
>  }
> @@ -1538,6 +1531,30 @@ static int wl1251_read_eeprom_mac(struct wl1251 *wl)
>   return 0;
>  }
>  
> +static int wl1251_read_nvs_mac(struct wl1251 *wl)
> +{
> + u8 mac[ETH_ALEN];
> + int i;
> +
> + if (wl->nvs_len < 0x24)
> + return -ENODATA;
> +
> + /* length is 2 and data address is 0x546c (mask is 0xfffe) */
> + if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 
> 0x54)
> + return -EINVAL;
> +
> + /* MAC is stored in reverse order */
> + for (i = 0; i < ETH_ALEN; i++)
> + mac[i] = wl->nvs[0x1c + ETH_ALEN - i - 1];
> +
> + /* 00:00:20:07:03:09 is in default example wl1251-nvs.bin, so invalid */

remove "default".

> + if (ether_addr_equal_unaligned(mac, "\x00\x00\x20\x07\x03\x09"))
> + return -EINVAL;
> +
> + memcpy(wl->mac_addr, mac, ETH_ALEN);
> + return 0;
> +}
> +
>  static int wl1251_register_hw(struct wl1251 *wl)
>  {
>   int ret;
> @@ -1581,10 +1598,16 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
>  
>   wl->hw->queues = 4;
>  
> + if (wl->nvs == NULL && !wl->use_eeprom) {
> + ret = wl1251_fetch_nvs(wl);
> + if (ret < 0)
> + goto out;
> + }

Is goto out here good idea? IMNSHO it is copy bug, it should
just proceed with generating random address.

>   if (wl->use_eeprom)
>   ret = wl1251_read_eeprom_mac(wl);
>   else
> - ret = -EINVAL;
> + ret = wl1251_read_nvs_mac(wl);
>  
>   if (ret == 0 && !is_valid_ether_addr(wl->mac_addr))
>   ret = -EINVAL;

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 5/6] wl1251: Parse and use MAC address from supplied NVS data

2016-12-24 Thread Pavel Machek
On Sat 2016-12-24 17:53:00, Pali Rohár wrote:
> This patch implements parsing MAC address from NVS data which are sent to
> wl1251 chip. Calibration NVS data could contain valid MAC address and it
> will be used instead randomly generated.

will be used instead of randomly generated one.

> This patch also move code for requesting NVS data from userspace to driver

"moves"

> initialization code to make sure that NVS data will be there at time when
> permanent MAC address is needed.

"at a time"

> Calibration NVS data for wl1251 are model specific. Every one device with

"device specific"? "Every device".

> wl1251 chip should have been calibrated in factory and needs to provide own
> calibration data.
> 
> Default example wl1251-nvs.bin data found in linux-firmware repository and

"are found"

> contains MAC address 00:00:20:07:03:09. So this MAC address is marked as

"contain"

> invalid as it is not real device specific address, just example one.
> 
> Format of calibration NVS data can be found at:
> http://notaz.gp2x.de/misc/pnd/wl1251/nvs_map.txt
> 
> Signed-off-by: Pali Rohár 
> ---
>  drivers/net/wireless/ti/wl1251/main.c |   39 
> ++---
>  1 file changed, 31 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/ti/wl1251/main.c 
> b/drivers/net/wireless/ti/wl1251/main.c
> index c3fa0b6..1454ba2 100644
> --- a/drivers/net/wireless/ti/wl1251/main.c
> +++ b/drivers/net/wireless/ti/wl1251/main.c
> @@ -205,13 +205,6 @@ static int wl1251_chip_wakeup(struct wl1251 *wl)
>   goto out;
>   }
>  
> - if (wl->nvs == NULL && !wl->use_eeprom) {
> - /* No NVS from netlink, try to get it from the filesystem */
> - ret = wl1251_fetch_nvs(wl);
> - if (ret < 0)
> - goto out;
> - }
> -
>  out:
>   return ret;
>  }
> @@ -1538,6 +1531,30 @@ static int wl1251_read_eeprom_mac(struct wl1251 *wl)
>   return 0;
>  }
>  
> +static int wl1251_read_nvs_mac(struct wl1251 *wl)
> +{
> + u8 mac[ETH_ALEN];
> + int i;
> +
> + if (wl->nvs_len < 0x24)
> + return -ENODATA;
> +
> + /* length is 2 and data address is 0x546c (mask is 0xfffe) */
> + if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 
> 0x54)
> + return -EINVAL;
> +
> + /* MAC is stored in reverse order */
> + for (i = 0; i < ETH_ALEN; i++)
> + mac[i] = wl->nvs[0x1c + ETH_ALEN - i - 1];
> +
> + /* 00:00:20:07:03:09 is in default example wl1251-nvs.bin, so invalid */

remove "default".

> + if (ether_addr_equal_unaligned(mac, "\x00\x00\x20\x07\x03\x09"))
> + return -EINVAL;
> +
> + memcpy(wl->mac_addr, mac, ETH_ALEN);
> + return 0;
> +}
> +
>  static int wl1251_register_hw(struct wl1251 *wl)
>  {
>   int ret;
> @@ -1581,10 +1598,16 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
>  
>   wl->hw->queues = 4;
>  
> + if (wl->nvs == NULL && !wl->use_eeprom) {
> + ret = wl1251_fetch_nvs(wl);
> + if (ret < 0)
> + goto out;
> + }

Is goto out here good idea? IMNSHO it is copy bug, it should
just proceed with generating random address.

>   if (wl->use_eeprom)
>   ret = wl1251_read_eeprom_mac(wl);
>   else
> - ret = -EINVAL;
> + ret = wl1251_read_nvs_mac(wl);
>  
>   if (ret == 0 && !is_valid_ether_addr(wl->mac_addr))
>   ret = -EINVAL;

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 4/6] wl1251: Generate random MAC address only if driver does not have valid

2016-12-24 Thread Pavel Machek
On Sat 2016-12-24 17:52:59, Pali Rohár wrote:

> Before this patch driver generated random MAC address every time when was
> doing initialization. And after that random MAC address could be
> overwritten with fixed one if provided.

Before this patch, driver generated random MAC address every time it
was initialized. After that random MAC address could be overwritten
with fixed one, if provided.

> This patch changes order. First it tries to read fixed MAC address and if
> it fails then driver generates random MAC address.

I don't quite get where the advantage is supposed to be. Is it that
"use_eeprom" is set, but reading fails?

The only case where this helps is if wl1251_read_eeprom_mac() succeeds
but reads invalid address.

> Signed-off-by: Pali Rohár 

Acked-by: Pavel Machek 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 4/6] wl1251: Generate random MAC address only if driver does not have valid

2016-12-24 Thread Pavel Machek
On Sat 2016-12-24 17:52:59, Pali Rohár wrote:

> Before this patch driver generated random MAC address every time when was
> doing initialization. And after that random MAC address could be
> overwritten with fixed one if provided.

Before this patch, driver generated random MAC address every time it
was initialized. After that random MAC address could be overwritten
with fixed one, if provided.

> This patch changes order. First it tries to read fixed MAC address and if
> it fails then driver generates random MAC address.

I don't quite get where the advantage is supposed to be. Is it that
"use_eeprom" is set, but reading fails?

The only case where this helps is if wl1251_read_eeprom_mac() succeeds
but reads invalid address.

> Signed-off-by: Pali Rohár 

Acked-by: Pavel Machek 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 3/6] wl1251: Update wl->nvs_len after wl->nvs is valid

2016-12-24 Thread Pavel Machek
On Sat 2016-12-24 17:52:58, Pali Rohár wrote:
> In case kmemdup fails thne wl->nvs_len will contains invalid non-zero size.
> This patch fixes it.

If kmemdup fails, then wl->nvs_len will contain invalid non-zero size.

?

This probably should go as first in series, as it is bugfix?

Pavel
Acked-by: Pavel Machek 


> Signed-off-by: Pali Rohár 
> ---
>  drivers/net/wireless/ti/wl1251/main.c |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ti/wl1251/main.c 
> b/drivers/net/wireless/ti/wl1251/main.c
> index 24f8866..8971b64 100644
> --- a/drivers/net/wireless/ti/wl1251/main.c
> +++ b/drivers/net/wireless/ti/wl1251/main.c
> @@ -124,8 +124,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
>   goto out;
>   }
>  
> - wl->nvs_len = fw->size;
> - wl->nvs = kmemdup(fw->data, wl->nvs_len, GFP_KERNEL);
> + wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL);
>  
>   if (!wl->nvs) {
>   wl1251_error("could not allocate memory for the nvs file");
> @@ -133,6 +132,8 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
>   goto out;
>   }
>  
> + wl->nvs_len = fw->size;
> +
>   ret = 0;
>  
>  out:

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 3/6] wl1251: Update wl->nvs_len after wl->nvs is valid

2016-12-24 Thread Pavel Machek
On Sat 2016-12-24 17:52:58, Pali Rohár wrote:
> In case kmemdup fails thne wl->nvs_len will contains invalid non-zero size.
> This patch fixes it.

If kmemdup fails, then wl->nvs_len will contain invalid non-zero size.

?

This probably should go as first in series, as it is bugfix?

Pavel
Acked-by: Pavel Machek 


> Signed-off-by: Pali Rohár 
> ---
>  drivers/net/wireless/ti/wl1251/main.c |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ti/wl1251/main.c 
> b/drivers/net/wireless/ti/wl1251/main.c
> index 24f8866..8971b64 100644
> --- a/drivers/net/wireless/ti/wl1251/main.c
> +++ b/drivers/net/wireless/ti/wl1251/main.c
> @@ -124,8 +124,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
>   goto out;
>   }
>  
> - wl->nvs_len = fw->size;
> - wl->nvs = kmemdup(fw->data, wl->nvs_len, GFP_KERNEL);
> + wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL);
>  
>   if (!wl->nvs) {
>   wl1251_error("could not allocate memory for the nvs file");
> @@ -133,6 +132,8 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
>   goto out;
>   }
>  
> + wl->nvs_len = fw->size;
> +
>   ret = 0;
>  
>  out:

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [RFC PATCH 4.10 1/6] crypto/sha256: Refactor the API so it can be used without shash

2016-12-24 Thread Andy Lutomirski
On Sat, Dec 24, 2016 at 2:33 AM, Ard Biesheuvel
 wrote:
> Hi Andy,
>
> On 24 December 2016 at 02:22, Andy Lutomirski  wrote:
>> There are some pieecs of kernel code that want to compute SHA256
>> directly without going through the crypto core.  Adjust the exported
>> API to decouple it from the crypto core.
>>
>
> There are a bunch of things happening at the same time in this patch,
> i.e., unnecessary renames of functions with static linkage, return
> type changes to the base prototypes (int (*)(...) to void (*)(...))
> and the change for the base functions to take a struct sha256_state
> ctx rather than a shash_desc. I suppose you are mainly after the
> latter, so could we please drop the other changes?
>
> For the name clashes, could we simply use the crypto_ prefix for the
> globally visible functions rather than using names that are already in
> use? (and having to go around clean up the conflicts)
> As for the return type changes, the base functions intentionally
> return int to allow tail calls from the functions exposed by the
> crypto API (whose prototypes cannot be changed). Unlikely to matter in
> the grand scheme of things (especially now that the base layer
> consists of static inline functions primarily), but it is equally
> pointless to go around and change them to return void IMO.
>
> So what remains is the struct shash_desc to struct sha256_state
> change, which makes sense given that you are after a sha256_digest()
> function that does not require the crypto API. But it seems your use
> case does not rely on incremental hashing, and so there is no reason
> for the state to be exposed outside of the implementation, and we
> could simply expose a crypto_sha256_digest() routine from the
> sha256_generic.c implementation instead.

I actually do use incremental hashing later on.   BPF currently
vmallocs() a big temporary buffer just so it can fill it and hash it.
I change it to hash as it goes.

I painted the bike shed the other way because I thought that crypto_
names should indicate that they're the versions compatible with the
crypto API, but I take your point about churn.  Part of the reason I
didn't want to use crypto_sha256_update is because that function is
currently like this:

int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
  unsigned int len)

and I wanted to avoid churn.  The sha256_update() functions scattered
all over were static, so I didn't worry about them.

I'm going to give this another try as a split-up series that tries to
avoid making any changes beyond simple function renames to the
drivers.

>
> Also, I strongly feel that crypto and other security related patches
> should be tested before being posted, even if they are only RFC,
> especially when they are posted by high profile kernel devs like
> yourself. (Your code incorrectly calls crypto_sha2_final() in a couple
> of places, resulting in the finalization being performed twice, once
> with the accelerated block transform and again with the generic
> transform)
>

I tested it, albeit poorly.  I wanted feedback on the API (thanks!)
and I figured I could more carefully check the implementation once the
API survives a bit of review.  Since it looks like I have to rework
this, I'd need to re-test anyway.

>> I suspect this will very slightly speed up the SHA256 shash operations
>> as well by reducing the amount of indirection involved.
>>
>
> I think you have a valid point when it comes to the complexity of the
> crypto API in general. But the struct sha256_state is embedded in the
> shash_desc rather than referred to via a pointer, so the level of
> indirection does not appear to change. And given how 99.9% of the
> SHA256 execution time is spent in the block transform routine anyway,
> I expect the performance delta to be in the noise tbh.

s/very slightly/negligibly?  There's an extra speedup from avoiding a
variable-length stack allocation, but that probably doesn't matter
much either.

>
> Finally, another thing to keep in mind is that the base layers of
> SHA-1, SHA-256 and SHA-512 are intentionally structured in the same
> way. If there is a need for a digest() entry point, I'd prefer to add
> them for all flavours.

I want to get sha256 right first.  Once it's in good shape, making the
same changes to the other variants should be easy.

>
> Whether this still belongs under crypto or under lib/sha256.c as a
> library function (allowing archs to override it) is open for debate.
> If hashing BPF programs becomes a hot spot, we probably have bigger
> problems.
>
> Regards,
> Ard.
>
> P.S. I do take your point regarding the arch_sha256_block_transform()
> proposed in your follow up email, but there are some details (SIMD,
> availability of the instructions etc) that would make it only suitable
> for the generic implementation anyway, and the base layer was already
> a huge improvement compared to the open coded implementations of the

Re: [RFC PATCH 4.10 1/6] crypto/sha256: Refactor the API so it can be used without shash

2016-12-24 Thread Andy Lutomirski
On Sat, Dec 24, 2016 at 2:33 AM, Ard Biesheuvel
 wrote:
> Hi Andy,
>
> On 24 December 2016 at 02:22, Andy Lutomirski  wrote:
>> There are some pieecs of kernel code that want to compute SHA256
>> directly without going through the crypto core.  Adjust the exported
>> API to decouple it from the crypto core.
>>
>
> There are a bunch of things happening at the same time in this patch,
> i.e., unnecessary renames of functions with static linkage, return
> type changes to the base prototypes (int (*)(...) to void (*)(...))
> and the change for the base functions to take a struct sha256_state
> ctx rather than a shash_desc. I suppose you are mainly after the
> latter, so could we please drop the other changes?
>
> For the name clashes, could we simply use the crypto_ prefix for the
> globally visible functions rather than using names that are already in
> use? (and having to go around clean up the conflicts)
> As for the return type changes, the base functions intentionally
> return int to allow tail calls from the functions exposed by the
> crypto API (whose prototypes cannot be changed). Unlikely to matter in
> the grand scheme of things (especially now that the base layer
> consists of static inline functions primarily), but it is equally
> pointless to go around and change them to return void IMO.
>
> So what remains is the struct shash_desc to struct sha256_state
> change, which makes sense given that you are after a sha256_digest()
> function that does not require the crypto API. But it seems your use
> case does not rely on incremental hashing, and so there is no reason
> for the state to be exposed outside of the implementation, and we
> could simply expose a crypto_sha256_digest() routine from the
> sha256_generic.c implementation instead.

I actually do use incremental hashing later on.   BPF currently
vmallocs() a big temporary buffer just so it can fill it and hash it.
I change it to hash as it goes.

I painted the bike shed the other way because I thought that crypto_
names should indicate that they're the versions compatible with the
crypto API, but I take your point about churn.  Part of the reason I
didn't want to use crypto_sha256_update is because that function is
currently like this:

int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
  unsigned int len)

and I wanted to avoid churn.  The sha256_update() functions scattered
all over were static, so I didn't worry about them.

I'm going to give this another try as a split-up series that tries to
avoid making any changes beyond simple function renames to the
drivers.

>
> Also, I strongly feel that crypto and other security related patches
> should be tested before being posted, even if they are only RFC,
> especially when they are posted by high profile kernel devs like
> yourself. (Your code incorrectly calls crypto_sha2_final() in a couple
> of places, resulting in the finalization being performed twice, once
> with the accelerated block transform and again with the generic
> transform)
>

I tested it, albeit poorly.  I wanted feedback on the API (thanks!)
and I figured I could more carefully check the implementation once the
API survives a bit of review.  Since it looks like I have to rework
this, I'd need to re-test anyway.

>> I suspect this will very slightly speed up the SHA256 shash operations
>> as well by reducing the amount of indirection involved.
>>
>
> I think you have a valid point when it comes to the complexity of the
> crypto API in general. But the struct sha256_state is embedded in the
> shash_desc rather than referred to via a pointer, so the level of
> indirection does not appear to change. And given how 99.9% of the
> SHA256 execution time is spent in the block transform routine anyway,
> I expect the performance delta to be in the noise tbh.

s/very slightly/negligibly?  There's an extra speedup from avoiding a
variable-length stack allocation, but that probably doesn't matter
much either.

>
> Finally, another thing to keep in mind is that the base layers of
> SHA-1, SHA-256 and SHA-512 are intentionally structured in the same
> way. If there is a need for a digest() entry point, I'd prefer to add
> them for all flavours.

I want to get sha256 right first.  Once it's in good shape, making the
same changes to the other variants should be easy.

>
> Whether this still belongs under crypto or under lib/sha256.c as a
> library function (allowing archs to override it) is open for debate.
> If hashing BPF programs becomes a hot spot, we probably have bigger
> problems.
>
> Regards,
> Ard.
>
> P.S. I do take your point regarding the arch_sha256_block_transform()
> proposed in your follow up email, but there are some details (SIMD,
> availability of the instructions etc) that would make it only suitable
> for the generic implementation anyway, and the base layer was already
> a huge improvement compared to the open coded implementations of the
> SHA boilerplate.

Agreed, and my model may 

Re: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel

2016-12-24 Thread Mark Greer
On Sat, Dec 24, 2016 at 11:17:18AM -0500, Geoff Lansberry wrote:
> Mark - I'm sorry, but I did not write this code, and therefore was not
> able to accurately describe it.   It is fixing a different issue, not
> the neard segfault that we are still chasing. Last week Jaret Cantu
> sent a separate email explaining the purpose of the code, which had
> you copied, did you see that?

Hm, no, I didn't.  I received an email from Justin Bronder but not from
Jaret Cantu.  Justin's email did help but is still pretty high-level.
We need a clear understanding as to what is happening in the digital
layer and the driver to know how execution is getting into a block of
error handling code that should never be executed.  Once we understand
that we can start thinking about what the best fix is.

> Does it explain why it was done to
> your satisfaction?   I've asked him to join in on the effort to push
> the change upstream, however he will not be available until the new
> year.

I expect that it would help if he joins.  After the holidays is fine -
I think many people are taking it easy for the next week or so, anyway.

> I know you did suggest that we split off that change from the others,
> and if now is the time to do that, let me know.   If you don't have
> the email from Jaret, also please let me know and I will forward it to
> you.

I think it would help you if you split it off because the first two patches
have a good chance of being accepted but this one doesn't (yet).  If you
separate the them, it will make it easier for Samuel to take the first two
(or he may take the first two anyway but its always good to make it as
easy maintainers as you can).

Mark
--


Re: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel

2016-12-24 Thread Mark Greer
On Sat, Dec 24, 2016 at 11:17:18AM -0500, Geoff Lansberry wrote:
> Mark - I'm sorry, but I did not write this code, and therefore was not
> able to accurately describe it.   It is fixing a different issue, not
> the neard segfault that we are still chasing. Last week Jaret Cantu
> sent a separate email explaining the purpose of the code, which had
> you copied, did you see that?

Hm, no, I didn't.  I received an email from Justin Bronder but not from
Jaret Cantu.  Justin's email did help but is still pretty high-level.
We need a clear understanding as to what is happening in the digital
layer and the driver to know how execution is getting into a block of
error handling code that should never be executed.  Once we understand
that we can start thinking about what the best fix is.

> Does it explain why it was done to
> your satisfaction?   I've asked him to join in on the effort to push
> the change upstream, however he will not be available until the new
> year.

I expect that it would help if he joins.  After the holidays is fine -
I think many people are taking it easy for the next week or so, anyway.

> I know you did suggest that we split off that change from the others,
> and if now is the time to do that, let me know.   If you don't have
> the email from Jaret, also please let me know and I will forward it to
> you.

I think it would help you if you split it off because the first two patches
have a good chance of being accepted but this one doesn't (yet).  If you
separate the them, it will make it easier for Samuel to take the first two
(or he may take the first two anyway but its always good to make it as
easy maintainers as you can).

Mark
--


  1   2   3   >