mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH AUTOSEL for 4.9 02/24] s390/pci: do not require AIS facility
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 06/24] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl() alexander.levin
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Christian Borntraeger, Heiko Carstens, alexander.levin

From: Christian Borntraeger <borntraeger@de.ibm.com>

[ Upstream commit 48070c73058be6de9c0d754d441ed7092dfc8f12 ]

As of today QEMU does not provide the AIS facility to its guest.  This
prevents Linux guests from using PCI devices as the ais facility is
checked during init. As this is just a performance optimization, we can
move the ais check into the code where we need it (calling the SIC
instruction). This is used at initialization and on interrupt. Both
places do not require any serialization, so we can simply skip the
instruction.

Since we will now get all interrupts, we can also avoid the 2nd scan.
As we can have multiple interrupts in parallel we might trigger spurious
irqs more often for the non-AIS case but the core code can handle that.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Acked-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/s390/include/asm/pci_insn.h | 2 +-
 arch/s390/pci/pci.c              | 5 +++--
 arch/s390/pci/pci_insn.c         | 6 +++++-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/s390/include/asm/pci_insn.h b/arch/s390/include/asm/pci_insn.h
index 649eb62c52b3..9e02cb7955c1 100644
--- a/arch/s390/include/asm/pci_insn.h
+++ b/arch/s390/include/asm/pci_insn.h
@@ -81,6 +81,6 @@ int zpci_refresh_trans(u64 fn, u64 addr, u64 range);
 int zpci_load(u64 *data, u64 req, u64 offset);
 int zpci_store(u64 data, u64 req, u64 offset);
 int zpci_store_block(const u64 *data, u64 req, u64 offset);
-void zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc);
+int zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc);
 
 #endif
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 15ffc19c8c0c..03a1d5976ff5 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -354,7 +354,8 @@ static void zpci_irq_handler(struct airq_struct *airq)
 				/* End of second scan with interrupts on. */
 				break;
 			/* First scan complete, reenable interrupts. */
-			zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
+			if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC))
+				break;
 			si = 0;
 			continue;
 		}
@@ -928,7 +929,7 @@ static int __init pci_base_init(void)
 	if (!s390_pci_probe)
 		return 0;
 
-	if (!test_facility(69) || !test_facility(71) || !test_facility(72))
+	if (!test_facility(69) || !test_facility(71))
 		return 0;
 
 	rc = zpci_debug_init();
diff --git a/arch/s390/pci/pci_insn.c b/arch/s390/pci/pci_insn.c
index fa8d7d4b9751..248146dcfce3 100644
--- a/arch/s390/pci/pci_insn.c
+++ b/arch/s390/pci/pci_insn.c
@@ -7,6 +7,7 @@
 #include <linux/export.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
+#include <asm/facility.h>
 #include <asm/pci_insn.h>
 #include <asm/pci_debug.h>
 #include <asm/processor.h>
@@ -91,11 +92,14 @@ int zpci_refresh_trans(u64 fn, u64 addr, u64 range)
 }
 
 /* Set Interruption Controls */
-void zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc)
+int zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc)
 {
+	if (!test_facility(72))
+		return -EIO;
 	asm volatile (
 		"	.insn	rsy,0xeb00000000d1,%[ctl],%[isc],%[u]\n"
 		: : [ctl] "d" (ctl), [isc] "d" (isc << 27), [u] "Q" (*unused));
+	return 0;
 }
 
 /* PCI Load */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization
@ 2017-11-22 22:26 alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 02/24] s390/pci: do not require AIS facility alexander.levin
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Boshi Wang, Mimi Zohar, alexander.levin

From: Boshi Wang <wangboshi@huawei.com>

[ Upstream commit ebe7c0a7be92bbd34c6ff5b55810546a0ee05bee ]

The hash_setup function always sets the hash_setup_done flag, even
when the hash algorithm is invalid.  This prevents the default hash
algorithm defined as CONFIG_IMA_DEFAULT_HASH from being used.

This patch sets hash_setup_done flag only for valid hash algorithms.

Fixes: e7a2ad7eb6f4 "ima: enable support for larger default filedata hash
	algorithms"
Signed-off-by: Boshi Wang <wangboshi@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>

Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 security/integrity/ima/ima_main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 0e8762945e79..2b3def14b4fb 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -51,6 +51,8 @@ static int __init hash_setup(char *str)
 			ima_hash_algo = HASH_ALGO_SHA1;
 		else if (strncmp(str, "md5", 3) == 0)
 			ima_hash_algo = HASH_ALGO_MD5;
+		else
+			return 1;
 		goto out;
 	}
 
@@ -60,6 +62,8 @@ static int __init hash_setup(char *str)
 			break;
 		}
 	}
+	if (i == HASH_ALGO__LAST)
+		return 1;
 out:
 	hash_setup_done = 1;
 	return 1;
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 06/24] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl()
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 02/24] s390/pci: do not require AIS facility alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 03/24] selftests/x86/ldt_get: Add a few additional tests for limits alexander.levin
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Lukas Wunner, Ricardo Ribalda Delgado, Ji-Ze Hong (Peter Hong),
	Greg Kroah-Hartman, alexander.levin

From: Lukas Wunner <lukas@wunner.de>

[ Upstream commit 3236a965486ba0c6043cf2c7b51943d8b382ae29 ]

This driver's ->rs485_config callback checks if SER_RS485_RTS_ON_SEND
and SER_RS485_RTS_AFTER_SEND have the same value.  If they do, it means
the user has passed in invalid data with the TIOCSRS485 ioctl()
since RTS must have a different polarity when sending and when not
sending.  In this case, rs485 mode is not enabled (the RS485_URA bit
is not set in the RS485 Enable Register) and this is supposed to be
signaled back to the user by clearing the SER_RS485_ENABLED bit in
struct serial_rs485 ... except a missing tilde character is preventing
that from happening.

Fixes: 28e3fb6c4dce ("serial: Add support for Fintek F81216A LPC to 4 UART")
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/tty/serial/8250/8250_fintek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index 0facc789fe7d..9fc782642a36 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -118,7 +118,7 @@ static int fintek_8250_rs485_config(struct uart_port *port,
 
 	if ((!!(rs485->flags & SER_RS485_RTS_ON_SEND)) ==
 			(!!(rs485->flags & SER_RS485_RTS_AFTER_SEND)))
-		rs485->flags &= SER_RS485_ENABLED;
+		rs485->flags &= ~SER_RS485_ENABLED;
 	else
 		config |= RS485_URA;
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 04/24] staging: greybus: loopback: Fix iteration count on async path
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (2 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 03/24] selftests/x86/ldt_get: Add a few additional tests for limits alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 05/24] m68k: fix ColdFire node shift size calculation alexander.levin
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Bryan O'Donoghue, Alex Elder, Mitch Tasman, greybus-dev,
	devel, Greg Kroah-Hartman, alexander.levin

From: Bryan O'Donoghue <pure.logic@nexus-software.ie>

[ Upstream commit 44b02da39210e6dd67e39ff1f48d30c56d384240 ]

Commit 12927835d211 ("greybus: loopback: Add asynchronous bi-directional
support") does what it says on the tin - namely, adds support for
asynchronous bi-directional loopback operations.

What it neglects to do though is increment the per-connection
gb->iteration_count on an asynchronous operation error. This patch fixes
that omission.

Fixes: 12927835d211 ("greybus: loopback: Add asynchronous bi-directional support")

Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Reported-by: Mitch Tasman <tasman@leaflabs.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Mitch Tasman <tasman@leaflabs.com>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/staging/greybus/loopback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 29dc249b0c74..3c2c233c2e49 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -1034,8 +1034,10 @@ static int gb_loopback_fn(void *data)
 				error = gb_loopback_async_sink(gb, size);
 			}
 
-			if (error)
+			if (error) {
 				gb->error++;
+				gb->iteration_count++;
+			}
 		} else {
 			/* We are effectively single threaded here */
 			if (type == GB_LOOPBACK_TYPE_PING)
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 05/24] m68k: fix ColdFire node shift size calculation
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (3 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 04/24] staging: greybus: loopback: Fix iteration count on async path alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 09/24] spi: spi-axi: fix potential use-after-free after deregistration alexander.levin
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Greg Ungerer, alexander.levin

From: Greg Ungerer <gerg@linux-m68k.org>

[ Upstream commit f55ab8f27548ff3431a6567d400c6757c49fd520 ]

The m68k pg_data_table is a fix size array defined in arch/m68k/mm/init.c.
Index numbers within it are defined based on memory size. But for Coldfire
these don't take into account a non-zero physical RAM base address, and this
causes us to access past the end of this array at system start time.

Change the node shift calculation so that we keep the index inside its range.

Reported-by: Angelo Dureghello <angelo@sysam.it>
Tested-by: Angelo Dureghello <angelo@sysam.it>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/m68k/mm/mcfmmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
index 87131cd3bc8f..6d3a50446b21 100644
--- a/arch/m68k/mm/mcfmmu.c
+++ b/arch/m68k/mm/mcfmmu.c
@@ -169,7 +169,7 @@ void __init cf_bootmem_alloc(void)
 	max_pfn = max_low_pfn = PFN_DOWN(_ramend);
 	high_memory = (void *)_ramend;
 
-	m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
+	m68k_virt_to_node_shift = fls(_ramend - 1) - 6;
 	module_fixup(NULL, __start_fixup, __stop_fixup);
 
 	/* setup bootmem data */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 03/24] selftests/x86/ldt_get: Add a few additional tests for limits
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 02/24] s390/pci: do not require AIS facility alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 06/24] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl() alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 04/24] staging: greybus: loopback: Fix iteration count on async path alexander.levin
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Andy Lutomirski, Borislav Petkov, Linus Torvalds, Peter Zijlstra,
	Thomas Gleixner, Ingo Molnar, alexander.levin

From: Andy Lutomirski <luto@kernel.org>

[ Upstream commit fec8f5ae1715a01c72ad52cb2ecd8aacaf142302 ]

We weren't testing the .limit and .limit_in_pages fields very well.
Add more tests.

This addition seems to trigger the "bits 16:19 are undefined" issue
that was fixed in an earlier patch.  I think that, at least on my
CPU, the high nibble of the limit ends in LAR bits 16:19.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/5601c15ea9b3113d288953fd2838b18bedf6bc67.1509794321.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 tools/testing/selftests/x86/ldt_gdt.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
index e717fed80219..f936a3cd3e35 100644
--- a/tools/testing/selftests/x86/ldt_gdt.c
+++ b/tools/testing/selftests/x86/ldt_gdt.c
@@ -360,9 +360,24 @@ static void do_simple_tests(void)
 	install_invalid(&desc, false);
 
 	desc.seg_not_present = 0;
-	desc.read_exec_only = 0;
 	desc.seg_32bit = 1;
+	desc.read_exec_only = 0;
+	desc.limit = 0xfffff;
+
 	install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA | AR_S | AR_P | AR_DB);
+
+	desc.limit_in_pages = 1;
+
+	install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA | AR_S | AR_P | AR_DB | AR_G);
+	desc.read_exec_only = 1;
+	install_valid(&desc, AR_DPL3 | AR_TYPE_RODATA | AR_S | AR_P | AR_DB | AR_G);
+	desc.contents = 1;
+	desc.read_exec_only = 0;
+	install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA_EXPDOWN | AR_S | AR_P | AR_DB | AR_G);
+	desc.read_exec_only = 1;
+	install_valid(&desc, AR_DPL3 | AR_TYPE_RODATA_EXPDOWN | AR_S | AR_P | AR_DB | AR_G);
+
+	desc.limit = 0;
 	install_invalid(&desc, true);
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 09/24] spi: spi-axi: fix potential use-after-free after deregistration
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (4 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 05/24] m68k: fix ColdFire node shift size calculation alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 08/24] spi: sh-msiof: Fix DMA transfer size check alexander.levin
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Johan Hovold, Mark Brown, alexander.levin

From: Johan Hovold <johan@kernel.org>

[ Upstream commit 4d5e0689dc9d5640ad46cdfbe1896b74d8df1661 ]

Take an extra reference to the controller before deregistering it to
prevent use-after-free in the interrupt handler in case an interrupt
fires before the line is disabled.

Fixes: b1353d1c1d45 ("spi: Add Analog Devices AXI SPI Engine controller support")
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/spi/spi-axi-spi-engine.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
index c1eafbd7610a..da51fed143cd 100644
--- a/drivers/spi/spi-axi-spi-engine.c
+++ b/drivers/spi/spi-axi-spi-engine.c
@@ -553,7 +553,7 @@ static int spi_engine_probe(struct platform_device *pdev)
 
 static int spi_engine_remove(struct platform_device *pdev)
 {
-	struct spi_master *master = platform_get_drvdata(pdev);
+	struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
 	struct spi_engine *spi_engine = spi_master_get_devdata(master);
 	int irq = platform_get_irq(pdev, 0);
 
@@ -561,6 +561,8 @@ static int spi_engine_remove(struct platform_device *pdev)
 
 	free_irq(irq, master);
 
+	spi_master_put(master);
+
 	writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
 	writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
 	writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 08/24] spi: sh-msiof: Fix DMA transfer size check
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (5 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 09/24] spi: spi-axi: fix potential use-after-free after deregistration alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 07/24] staging: rtl8188eu: avoid a null dereference on pmlmepriv alexander.levin
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Hiromitsu Yamasaki, Simon Horman, Mark Brown, alexander.levin

From: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>

[ Upstream commit 36735783fdb599c94b9c86824583df367c65900b ]

DMA supports 32-bit words only,
even if BITLEN1 of SITMDR2 register is 16bit.

Fixes: b0d0ce8b6b91 ("spi: sh-msiof: Add DMA support")
Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/spi/spi-sh-msiof.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 1de3a772eb7d..cbf02ebb30a2 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -862,7 +862,7 @@ static int sh_msiof_transfer_one(struct spi_master *master,
 				break;
 			copy32 = copy_bswap32;
 		} else if (bits <= 16) {
-			if (l & 1)
+			if (l & 3)
 				break;
 			copy32 = copy_wswap32;
 		} else {
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 07/24] staging: rtl8188eu: avoid a null dereference on pmlmepriv
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (6 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 08/24] spi: sh-msiof: Fix DMA transfer size check alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 10/24] mmc: sdhci-msm: fix issue with power irq alexander.levin
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Colin Ian King, Greg Kroah-Hartman, alexander.levin

From: Colin Ian King <colin.king@canonical.com>

[ Upstream commit 123c0aab0050cd0e07ce18e453389fbbb0a5a425 ]

There is a check on pmlmepriv before dereferencing it when
vfree'ing pmlmepriv->free_bss_buf however the previous call
to rtw_free_mlme_priv_ie_data deferences pmlmepriv causing
a null pointer deference if it is null.  Avoid this by also
calling rtw_free_mlme_priv_ie_data if the pointer is non-null.

Detected by CoverityScan, CID#1230262 ("Dereference before null check")
Fixes: 7b464c9fa5cc ("staging: r8188eu: Add files for new driver - part 4")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index ee2dcd05010f..0b60d1e0333e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -107,10 +107,10 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
 
 void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 {
-	rtw_free_mlme_priv_ie_data(pmlmepriv);
-
-	if (pmlmepriv)
+	if (pmlmepriv) {
+		rtw_free_mlme_priv_ie_data(pmlmepriv);
 		vfree(pmlmepriv->free_bss_buf);
+	}
 }
 
 struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 10/24] mmc: sdhci-msm: fix issue with power irq
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (7 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 07/24] staging: rtl8188eu: avoid a null dereference on pmlmepriv alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 11/24] usb: dwc2: Fix UDC state tracking alexander.levin
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Subhash Jadavani, Vijay Viswanath, Ulf Hansson, alexander.levin

From: Subhash Jadavani <subhashj@codeaurora.org>

[ Upstream commit c7ccee224d2d551f712752c4a16947f6529d6506 ]

SDCC controller reset (SW_RST) during probe may trigger power irq if
previous status of PWRCTL was either BUS_ON or IO_HIGH_V. So before we
enable the power irq interrupt in GIC (by registering the interrupt
handler), we need to ensure that any pending power irq interrupt status
is acknowledged otherwise power irq interrupt handler would be fired
prematurely.

Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Vijay Viswanath <vviswana@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/mmc/host/sdhci-msm.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 90ed2e12d345..80c89a31d790 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -642,6 +642,21 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 			       CORE_VENDOR_SPEC_CAPABILITIES0);
 	}
 
+	/*
+	 * Power on reset state may trigger power irq if previous status of
+	 * PWRCTL was either BUS_ON or IO_HIGH_V. So before enabling pwr irq
+	 * interrupt in GIC, any pending power irq interrupt should be
+	 * acknowledged. Otherwise power irq interrupt handler would be
+	 * fired prematurely.
+	 */
+	sdhci_msm_voltage_switch(host);
+
+	/*
+	 * Ensure that above writes are propogated before interrupt enablement
+	 * in GIC.
+	 */
+	mb();
+
 	/* Setup IRQ for handling power/voltage tasks with PMIC */
 	msm_host->pwr_irq = platform_get_irq_byname(pdev, "pwr_irq");
 	if (msm_host->pwr_irq < 0) {
@@ -651,6 +666,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 		goto clk_disable;
 	}
 
+	/* Enable pwr irq interrupts */
+	writel_relaxed(INT_MASK, msm_host->core_mem + CORE_PWRCTL_MASK);
+
 	ret = devm_request_threaded_irq(&pdev->dev, msm_host->pwr_irq, NULL,
 					sdhci_msm_pwr_irq, IRQF_ONESHOT,
 					dev_name(&pdev->dev), host);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 14/24] serial: 8250: Preserve DLD[7:4] for PORT_XR17V35X
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (10 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 12/24] usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're in host mode alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 13/24] usb: phy: tahvo: fix error handling in tahvo_usb_probe() alexander.levin
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Aaron Sierra, Greg Kroah-Hartman, alexander.levin

From: Aaron Sierra <asierra@xes-inc.com>

[ Upstream commit 0ab84da2e076948c49d36197ee7d254125c53eab ]

The upper four bits of the XR17V35x fractional divisor register (DLD)
control general chip function (RS-485 direction pin polarity, multidrop
mode, XON/XOFF parity check, and fast IR mode). Don't allow these bits
to be clobbered when setting the baudrate.

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/tty/serial/8250/8250_port.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 1ef31e3ee4a1..f6e4373a8850 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2526,8 +2526,11 @@ static void serial8250_set_divisor(struct uart_port *port, unsigned int baud,
 	serial_dl_write(up, quot);
 
 	/* XR17V35x UARTs have an extra fractional divisor register (DLD) */
-	if (up->port.type == PORT_XR17V35X)
+	if (up->port.type == PORT_XR17V35X) {
+		/* Preserve bits not related to baudrate; DLD[7:4]. */
+		quot_frac |= serial_port_in(port, 0x2) & 0xf0;
 		serial_port_out(port, 0x2, quot_frac);
+	}
 }
 
 static unsigned int serial8250_get_baud_rate(struct uart_port *port,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 12/24] usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're in host mode
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (9 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 11/24] usb: dwc2: Fix UDC state tracking alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 14/24] serial: 8250: Preserve DLD[7:4] for PORT_XR17V35X alexander.levin
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: John Stultz, Wei Xu, Guodong Xu, Amit Pundir, YongQin Liu,
	John Youn, Minas Harutyunyan, Douglas Anderson, Chen Yu,
	Felipe Balbi, Greg Kroah-Hartman, linux-usb, alexander.levin

From: John Stultz <john.stultz@linaro.org>

[ Upstream commit 9b481092c2a31a6b630aff9c28f0145bf6683787 ]

We've found that while in host mode, using Android, if one runs
the command:
  stop adbd

The existing usb devices being utilized in host mode are disconnected.
This is most visible with usb networking devices.

This seems to be due to adbd closing the file:
  /dev/usb-ffs/adb/ep0
Which calls ffs_ep0_release() and the following backtrace:

[<ffffff800875a430>] dwc2_hsotg_ep_disable+0x148/0x150
[<ffffff800875a498>] dwc2_hsotg_udc_stop+0x60/0x110
[<ffffff8008787950>] usb_gadget_remove_driver+0x58/0x78
[<ffffff80087879e4>] usb_gadget_unregister_driver+0x74/0xe8
[<ffffff80087850c0>] unregister_gadget+0x28/0x58
[<ffffff800878511c>] unregister_gadget_item+0x2c/0x40
[<ffffff8008790ea8>] ffs_data_clear+0xe8/0xf8
[<ffffff8008790ed8>] ffs_data_reset+0x20/0x58
[<ffffff8008793218>] ffs_data_closed+0x98/0xe8
[<ffffff80087932d8>] ffs_ep0_release+0x20/0x30

Then when dwc2_hsotg_ep_disable() is called, we call
kill_all_requests() which causes a bunch of the following
messages:

dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode
dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode
dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode
dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode
dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode
dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode
dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode
dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode
init: Service 'adbd' (pid 1915) killed by signal 9
init: Sending signal 9 to service 'adbd' (pid 1915) process group...
init: Successfully killed process cgroup uid 0 pid 1915 in 0ms
init: processing action (init.svc.adbd=stopped) from (/init.usb.configfs.rc:15)
dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 8 - ChHltd set, but reason is unknown
dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029
dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 12 - ChHltd set, but reason is unknown
dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029
dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 15 - ChHltd set, but reason is unknown
dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029
dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 3 - ChHltd set, but reason is unknown
dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029
dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 4 - ChHltd set, but reason is unknown
dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029
dwc2 f72c0000.usb: dwc2_update_urb_state_abn(): trimming xfer length

And the usb devices connected are basically hung at this point.

It seems like if we're in host mode, we probably shouldn't run
the dwc2_hostg_ep_disable logic, so this patch returns an error
in that case.

With this patch (along with the previous patch in this set), we avoid
the mismatched interrupts and connected usb devices continue to function.

I'm not sure if some other solution would be better here, but this seems
to work, so I wanted to send it out for input on what the right approach
should be.

Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: YongQin Liu <yongqin.liu@linaro.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Tested-by: Minas Harutyunyan <hminas@synopsys.com>
Reported-by: YongQin Liu <yongqin.liu@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/usb/dwc2/gadget.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index dbbc4cdad707..4d01d77a12c6 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3117,6 +3117,11 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)
 		return -EINVAL;
 	}
 
+	if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) {
+		dev_err(hsotg->dev, "%s: called in host mode?\n", __func__);
+		return -EINVAL;
+	}
+
 	epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index);
 
 	spin_lock_irqsave(&hsotg->lock, flags);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 13/24] usb: phy: tahvo: fix error handling in tahvo_usb_probe()
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (11 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 14/24] serial: 8250: Preserve DLD[7:4] for PORT_XR17V35X alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 16/24] x86/entry: Use SYSCALL_DEFINE() macros for sys_modify_ldt() alexander.levin
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Alexey Khoroshilov, Felipe Balbi, alexander.levin

From: Alexey Khoroshilov <khoroshilov@ispras.ru>

[ Upstream commit ce035409bfa892a2fabb89720b542e1b335c3426 ]

If devm_extcon_dev_allocate() fails, we should disable clk before return.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Fixes: 860d2686fda7 ("usb: phy: tahvo: Use devm_extcon_dev_[allocate|register]() and replace deprecated API")
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/usb/phy/phy-tahvo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index ab5d364f6e8c..335a1ef35224 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -368,7 +368,8 @@ static int tahvo_usb_probe(struct platform_device *pdev)
 	tu->extcon = devm_extcon_dev_allocate(&pdev->dev, tahvo_cable);
 	if (IS_ERR(tu->extcon)) {
 		dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
-		return -ENOMEM;
+		ret = PTR_ERR(tu->extcon);
+		goto err_disable_clk;
 	}
 
 	ret = devm_extcon_dev_register(&pdev->dev, tu->extcon);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 11/24] usb: dwc2: Fix UDC state tracking
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (8 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 10/24] mmc: sdhci-msm: fix issue with power irq alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 12/24] usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're in host mode alexander.levin
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: John Stultz, Wei Xu, Guodong Xu, Amit Pundir, YongQin Liu,
	John Youn, Minas Harutyunyan, Douglas Anderson, Chen Yu,
	Felipe Balbi, Greg Kroah-Hartman, linux-usb, alexander.levin

From: John Stultz <john.stultz@linaro.org>

[ Upstream commit ce2b21a4e5ce042c0a42c9db8fa9e0f849427d5e ]

It has been noticed that the dwc2 udc state reporting doesn't
seem to work (at least on HiKey boards). Where after the initial
setup, the sysfs /sys/class/udc/f72c0000.usb/state file would
report "configured" no matter the state of the OTG port.

This patch adds a call so that we report to the UDC layer when
the gadget device is disconnected.

This patch does depend on the previous patch ("usb: dwc2:
Improve gadget state disconnection handling") in this patch set
in order to properly work.

Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: YongQin Liu <yongqin.liu@linaro.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Tested-by: Minas Harutyunyan <hminas@synopsys.com>
Reported-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/usb/dwc2/gadget.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index cfdd5c3da236..dbbc4cdad707 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2467,6 +2467,8 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg)
 
 	call_gadget(hsotg, disconnect);
 	hsotg->lx_state = DWC2_L3;
+
+	usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED);
 }
 
 /**
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 18/24] EDAC, sb_edac: Fix missing break in switch
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (15 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 17/24] irqchip/gic: Make quirks matching conditional on init return value alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 20/24] usbip: tools: Install all headers needed for libusbip development alexander.levin
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Gustavo A. R. Silva, Qiuxu Zhuo, linux-edac, Borislav Petkov,
	alexander.levin

From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>

[ Upstream commit a8e9b186f153a44690ad0363a56716e7077ad28c ]

Add missing break statement in order to prevent the code from falling
through.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Cc: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/20171016174029.GA19757@embeddedor.com
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/edac/sb_edac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 54775221a01f..3c47e6361d81 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -2510,6 +2510,7 @@ static int ibridge_mci_bind_devs(struct mem_ctl_info *mci,
 			break;
 		case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TA:
 			pvt->pci_ta = pdev;
+			break;
 		case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_RAS:
 			pvt->pci_ras = pdev;
 			break;
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 15/24] kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (13 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 16/24] x86/entry: Use SYSCALL_DEFINE() macros for sys_modify_ldt() alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 17/24] irqchip/gic: Make quirks matching conditional on init return value alexander.levin
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Masami Hiramatsu, Ananth N Mavinakayanahalli, Linus Torvalds,
	Naveen N . Rao, Paul E . McKenney, Peter Zijlstra,
	Steven Rostedt, Thomas Gleixner, Ingo Molnar, alexander.levin

From: Masami Hiramatsu <mhiramat@kernel.org>

[ Upstream commit a30b85df7d599f626973e9cd3056fe755bd778e0 ]

We want to wait for all potentially preempted kprobes trampoline
execution to have completed. This guarantees that any freed
trampoline memory is not in use by any task in the system anymore.
synchronize_rcu_tasks() gives such a guarantee, so use it.

Also, this guarantees to wait for all potentially preempted tasks
on the instructions which will be replaced with a jump.

Since this becomes a problem only when CONFIG_PREEMPT=y, enable
CONFIG_TASKS_RCU=y for synchronize_rcu_tasks() in that case.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Naveen N . Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/150845661962.5443.17724352636247312231.stgit@devbox
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/Kconfig     |  2 +-
 kernel/kprobes.c | 14 ++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 659bdd079277..ab57cb0153ef 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -83,7 +83,7 @@ config STATIC_KEYS_SELFTEST
 config OPTPROBES
 	def_bool y
 	depends on KPROBES && HAVE_OPTPROBES
-	depends on !PREEMPT
+	select TASKS_RCU if PREEMPT
 
 config KPROBES_ON_FTRACE
 	def_bool y
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a1a07cf1101f..a78b2cb98707 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -540,13 +540,15 @@ static void kprobe_optimizer(struct work_struct *work)
 	do_unoptimize_kprobes();
 
 	/*
-	 * Step 2: Wait for quiesence period to ensure all running interrupts
-	 * are done. Because optprobe may modify multiple instructions
-	 * there is a chance that Nth instruction is interrupted. In that
-	 * case, running interrupt can return to 2nd-Nth byte of jump
-	 * instruction. This wait is for avoiding it.
+	 * Step 2: Wait for quiesence period to ensure all potentially
+	 * preempted tasks to have normally scheduled. Because optprobe
+	 * may modify multiple instructions, there is a chance that Nth
+	 * instruction is preempted. In that case, such tasks can return
+	 * to 2nd-Nth byte of jump instruction. This wait is for avoiding it.
+	 * Note that on non-preemptive kernel, this is transparently converted
+	 * to synchronoze_sched() to wait for all interrupts to have completed.
 	 */
-	synchronize_sched();
+	synchronize_rcu_tasks();
 
 	/* Step 3: Optimize kprobes after quiesence period */
 	do_optimize_kprobes();
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 16/24] x86/entry: Use SYSCALL_DEFINE() macros for sys_modify_ldt()
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (12 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 13/24] usb: phy: tahvo: fix error handling in tahvo_usb_probe() alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 15/24] kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y alexander.levin
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Dave Hansen, Linus Torvalds, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, alexander.levin

From: Dave Hansen <dave.hansen@linux.intel.com>

[ Upstream commit da20ab35180780e4a6eadc804544f1fa967f3567 ]

We do not have tracepoints for sys_modify_ldt() because we define
it directly instead of using the normal SYSCALL_DEFINEx() macros.

However, there is a reason sys_modify_ldt() does not use the macros:
it has an 'int' return type instead of 'unsigned long'.  This is
a bug, but it's a bug cemented in the ABI.

What does this mean?  If we return -EINVAL from a function that
returns 'int', we have 0x00000000ffffffea in %rax.  But, if we
return -EINVAL from a function returning 'unsigned long', we end
up with 0xffffffffffffffea in %rax, which is wrong.

To work around this and maintain the 'int' behavior while using
the SYSCALL_DEFINEx() macros, so we add a cast to 'unsigned int'
in both implementations of sys_modify_ldt().

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Brian Gerst <brgerst@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20171018172107.1A79C532@viggo.jf.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/x86/include/asm/syscalls.h |  2 +-
 arch/x86/kernel/ldt.c           | 16 +++++++++++++---
 arch/x86/um/ldt.c               |  7 +++++--
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h
index 91dfcafe27a6..bad25bb80679 100644
--- a/arch/x86/include/asm/syscalls.h
+++ b/arch/x86/include/asm/syscalls.h
@@ -21,7 +21,7 @@ asmlinkage long sys_ioperm(unsigned long, unsigned long, int);
 asmlinkage long sys_iopl(unsigned int);
 
 /* kernel/ldt.c */
-asmlinkage int sys_modify_ldt(int, void __user *, unsigned long);
+asmlinkage long sys_modify_ldt(int, void __user *, unsigned long);
 
 /* kernel/signal.c */
 asmlinkage long sys_rt_sigreturn(void);
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 6707039b9032..5f70014ca602 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -12,6 +12,7 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/smp.h>
+#include <linux/syscalls.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/uaccess.h>
@@ -271,8 +272,8 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
 	return error;
 }
 
-asmlinkage int sys_modify_ldt(int func, void __user *ptr,
-			      unsigned long bytecount)
+SYSCALL_DEFINE3(modify_ldt, int , func , void __user * , ptr ,
+		unsigned long , bytecount)
 {
 	int ret = -ENOSYS;
 
@@ -290,5 +291,14 @@ asmlinkage int sys_modify_ldt(int func, void __user *ptr,
 		ret = write_ldt(ptr, bytecount, 0);
 		break;
 	}
-	return ret;
+	/*
+	 * The SYSCALL_DEFINE() macros give us an 'unsigned long'
+	 * return type, but tht ABI for sys_modify_ldt() expects
+	 * 'int'.  This cast gives us an int-sized value in %rax
+	 * for the return code.  The 'unsigned' is necessary so
+	 * the compiler does not try to sign-extend the negative
+	 * return codes into the high half of the register when
+	 * taking the value from int->long.
+	 */
+	return (unsigned int)ret;
 }
diff --git a/arch/x86/um/ldt.c b/arch/x86/um/ldt.c
index 836a1eb5df43..3ee234b6234d 100644
--- a/arch/x86/um/ldt.c
+++ b/arch/x86/um/ldt.c
@@ -6,6 +6,7 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/syscalls.h>
 #include <linux/uaccess.h>
 #include <asm/unistd.h>
 #include <os.h>
@@ -369,7 +370,9 @@ void free_ldt(struct mm_context *mm)
 	mm->arch.ldt.entry_count = 0;
 }
 
-int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
+SYSCALL_DEFINE3(modify_ldt, int , func , void __user * , ptr ,
+		unsigned long , bytecount)
 {
-	return do_modify_ldt_skas(func, ptr, bytecount);
+	/* See non-um modify_ldt() for why we do this cast */
+	return (unsigned int)do_modify_ldt_skas(func, ptr, bytecount);
 }
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 17/24] irqchip/gic: Make quirks matching conditional on init return value
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (14 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 15/24] kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 18/24] EDAC, sb_edac: Fix missing break in switch alexander.levin
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Ard Biesheuvel, Marc Zyngier, alexander.levin

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

[ Upstream commit 9d111d49106b61f5a652d5418e85d8741b1a0427 ]

As it turns out, the IIDR is not sufficient to distinguish between GICv3
implementations when it comes to enabling quirks. So update the prototype
of the init() hook to return a bool, and interpret a 'false' return value
as no match, in which case the 'enabling workaround' log message should
not be printed.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/irqchip/irq-gic-common.c |  5 +++--
 drivers/irqchip/irq-gic-common.h |  2 +-
 drivers/irqchip/irq-gic-v3-its.c | 12 +++++++++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/irqchip/irq-gic-common.c b/drivers/irqchip/irq-gic-common.c
index 9ae71804b5dd..30017df5b54c 100644
--- a/drivers/irqchip/irq-gic-common.c
+++ b/drivers/irqchip/irq-gic-common.c
@@ -40,8 +40,9 @@ void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks,
 	for (; quirks->desc; quirks++) {
 		if (quirks->iidr != (quirks->mask & iidr))
 			continue;
-		quirks->init(data);
-		pr_info("GIC: enabling workaround for %s\n", quirks->desc);
+		if (quirks->init(data))
+			pr_info("GIC: enabling workaround for %s\n",
+				quirks->desc);
 	}
 }
 
diff --git a/drivers/irqchip/irq-gic-common.h b/drivers/irqchip/irq-gic-common.h
index 205e5fddf6da..3919cd7c5285 100644
--- a/drivers/irqchip/irq-gic-common.h
+++ b/drivers/irqchip/irq-gic-common.h
@@ -23,7 +23,7 @@
 
 struct gic_quirk {
 	const char *desc;
-	void (*init)(void *data);
+	bool (*init)(void *data);
 	u32 iidr;
 	u32 mask;
 };
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index acb9d250a905..41996ed1b003 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -1584,26 +1584,32 @@ static int its_force_quiescent(void __iomem *base)
 	}
 }
 
-static void __maybe_unused its_enable_quirk_cavium_22375(void *data)
+static bool __maybe_unused its_enable_quirk_cavium_22375(void *data)
 {
 	struct its_node *its = data;
 
 	its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_22375;
+
+	return true;
 }
 
-static void __maybe_unused its_enable_quirk_cavium_23144(void *data)
+static bool __maybe_unused its_enable_quirk_cavium_23144(void *data)
 {
 	struct its_node *its = data;
 
 	its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_23144;
+
+	return true;
 }
 
-static void __maybe_unused its_enable_quirk_qdf2400_e0065(void *data)
+static bool __maybe_unused its_enable_quirk_qdf2400_e0065(void *data)
 {
 	struct its_node *its = data;
 
 	/* On QDF2400, the size of the ITE is 16Bytes */
 	its->ite_size = 16;
+
+	return true;
 }
 
 static const struct gic_quirk its_quirks[] = {
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 19/24] sysrq : fix Show Regs call trace on ARM
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (17 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 20/24] usbip: tools: Install all headers needed for libusbip development alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 21/24] perf test attr: Fix ignored test case result alexander.levin
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Jibin Xu, Greg Kroah-Hartman, alexander.levin

From: Jibin Xu <jibin.xu@windriver.com>

[ Upstream commit b00bebbc301c8e1f74f230dc82282e56b7e7a6db ]

When kernel configuration SMP,PREEMPT and DEBUG_PREEMPT are enabled,
echo 1 >/proc/sys/kernel/sysrq
echo p >/proc/sysrq-trigger
kernel will print call trace as below:

sysrq: SysRq : Show Regs
BUG: using __this_cpu_read() in preemptible [00000000] code: sh/435
caller is __this_cpu_preempt_check+0x18/0x20
Call trace:
[<ffffff8008088e80>] dump_backtrace+0x0/0x1d0
[<ffffff8008089074>] show_stack+0x24/0x30
[<ffffff8008447970>] dump_stack+0x90/0xb0
[<ffffff8008463950>] check_preemption_disabled+0x100/0x108
[<ffffff8008463998>] __this_cpu_preempt_check+0x18/0x20
[<ffffff80084c9194>] sysrq_handle_showregs+0x1c/0x40
[<ffffff80084c9c7c>] __handle_sysrq+0x12c/0x1a0
[<ffffff80084ca140>] write_sysrq_trigger+0x60/0x70
[<ffffff8008251e00>] proc_reg_write+0x90/0xd0
[<ffffff80081f1788>] __vfs_write+0x48/0x90
[<ffffff80081f241c>] vfs_write+0xa4/0x190
[<ffffff80081f3354>] SyS_write+0x54/0xb0
[<ffffff80080833f0>] el0_svc_naked+0x24/0x28

This can be seen on a common board like an r-pi3.
This happens because when echo p >/proc/sysrq-trigger,
get_irq_regs() is called outside of IRQ context,
if preemption is enabled in this situation,kernel will
print the call trace. Since many prior discussions on
the mailing lists have made it clear that get_irq_regs
either just returns NULL or stale data when used outside
of IRQ context,we simply avoid calling it outside of
IRQ context.

Signed-off-by: Jibin Xu <jibin.xu@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/tty/sysrq.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 701c085bb19b..53cbf4ebef10 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -243,8 +243,10 @@ static void sysrq_handle_showallcpus(int key)
 	 * architecture has no support for it:
 	 */
 	if (!trigger_all_cpu_backtrace()) {
-		struct pt_regs *regs = get_irq_regs();
+		struct pt_regs *regs = NULL;
 
+		if (in_irq())
+			regs = get_irq_regs();
 		if (regs) {
 			pr_info("CPU%d:\n", smp_processor_id());
 			show_regs(regs);
@@ -263,7 +265,10 @@ static struct sysrq_key_op sysrq_showallcpus_op = {
 
 static void sysrq_handle_showregs(int key)
 {
-	struct pt_regs *regs = get_irq_regs();
+	struct pt_regs *regs = NULL;
+
+	if (in_irq())
+		regs = get_irq_regs();
 	if (regs)
 		show_regs(regs);
 	perf_event_print_debug();
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 21/24] perf test attr: Fix ignored test case result
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (18 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 19/24] sysrq : fix Show Regs call trace on ARM alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 22/24] kprobes/x86: Disable preemption in ftrace-based jprobes alexander.levin
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Thomas Richter, Heiko Carstens, Hendrik Brueckner,
	Martin Schwidefsky, Arnaldo Carvalho de Melo, alexander.levin

From: Thomas Richter <tmricht@linux.vnet.ibm.com>

[ Upstream commit 22905582f6dd4bbd0c370fe5732c607452010c04 ]

Command perf test -v 16 (Setup struct perf_event_attr test) always
reports success even if the test case fails.  It works correctly if you
also specify -F (for don't fork).

   root@s35lp76 perf]# ./perf test -v 16
   15: Setup struct perf_event_attr               :
   --- start ---
   running './tests/attr/test-record-no-delay'
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.002 MB /tmp/tmp4E1h7R/perf.data
     (1 samples) ]
   expected task=0, got 1
   expected precise_ip=0, got 3
   expected wakeup_events=1, got 0
   FAILED './tests/attr/test-record-no-delay' - match failure
   test child finished with 0
   ---- end ----
   Setup struct perf_event_attr: Ok

The reason for the wrong error reporting is the return value of the
system() library call. It is called in run_dir() file tests/attr.c and
returns the exit status, in above case 0xff00.

This value is given as parameter to the exit() function which can only
handle values 0-0xff.

The child process terminates with exit value of 0 and the parent does
not detect any error.

This patch corrects the error reporting and prints the correct test
result.

Signed-off-by: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
LPU-Reference: 20170913081209.39570-2-tmricht@linux.vnet.ibm.com
Link: http://lkml.kernel.org/n/tip-rdube6rfcjsr1nzue72c7lqn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 tools/perf/tests/attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 28d1605b0338..b60a6fd66517 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -150,7 +150,7 @@ static int run_dir(const char *d, const char *perf)
 	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
 		 d, d, perf, vcnt, v);
 
-	return system(cmd);
+	return system(cmd) ? TEST_FAIL : TEST_OK;
 }
 
 int test__attr(int subtest __maybe_unused)
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 22/24] kprobes/x86: Disable preemption in ftrace-based jprobes
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (19 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 21/24] perf test attr: Fix ignored test case result alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 23/24] tools include: Do not use poison with C++ alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 24/24] iio: adc: ti-ads1015: add 10% to conversion wait time alexander.levin
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Masami Hiramatsu, Alexei Starovoitov, Alexei Starovoitov,
	Ananth N Mavinakayanahalli, Linus Torvalds, Paul E . McKenney,
	Peter Zijlstra, Steven Rostedt, Thomas Gleixner, Ingo Molnar,
	alexander.levin

From: Masami Hiramatsu <mhiramat@kernel.org>

[ Upstream commit 5bb4fc2d8641219732eb2bb654206775a4219aca ]

Disable preemption in ftrace-based jprobe handlers as
described in Documentation/kprobes.txt:

  "Probe handlers are run with preemption disabled."

This will fix jprobes behavior when CONFIG_PREEMPT=y.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/150581530024.32348.9863783558598926771.stgit@devbox
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/x86/kernel/kprobes/ftrace.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c
index 5f8f0b3cc674..2c0b0b645a74 100644
--- a/arch/x86/kernel/kprobes/ftrace.c
+++ b/arch/x86/kernel/kprobes/ftrace.c
@@ -26,7 +26,7 @@
 #include "common.h"
 
 static nokprobe_inline
-int __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
+void __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
 		      struct kprobe_ctlblk *kcb, unsigned long orig_ip)
 {
 	/*
@@ -41,20 +41,21 @@ int __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
 	__this_cpu_write(current_kprobe, NULL);
 	if (orig_ip)
 		regs->ip = orig_ip;
-	return 1;
 }
 
 int skip_singlestep(struct kprobe *p, struct pt_regs *regs,
 		    struct kprobe_ctlblk *kcb)
 {
-	if (kprobe_ftrace(p))
-		return __skip_singlestep(p, regs, kcb, 0);
-	else
-		return 0;
+	if (kprobe_ftrace(p)) {
+		__skip_singlestep(p, regs, kcb, 0);
+		preempt_enable_no_resched();
+		return 1;
+	}
+	return 0;
 }
 NOKPROBE_SYMBOL(skip_singlestep);
 
-/* Ftrace callback handler for kprobes */
+/* Ftrace callback handler for kprobes -- called under preepmt disabed */
 void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 			   struct ftrace_ops *ops, struct pt_regs *regs)
 {
@@ -77,13 +78,17 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 		/* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */
 		regs->ip = ip + sizeof(kprobe_opcode_t);
 
+		/* To emulate trap based kprobes, preempt_disable here */
+		preempt_disable();
 		__this_cpu_write(current_kprobe, p);
 		kcb->kprobe_status = KPROBE_HIT_ACTIVE;
-		if (!p->pre_handler || !p->pre_handler(p, regs))
+		if (!p->pre_handler || !p->pre_handler(p, regs)) {
 			__skip_singlestep(p, regs, kcb, orig_ip);
+			preempt_enable_no_resched();
+		}
 		/*
 		 * If pre_handler returns !0, it sets regs->ip and
-		 * resets current kprobe.
+		 * resets current kprobe, and keep preempt count +1.
 		 */
 	}
 end:
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 20/24] usbip: tools: Install all headers needed for libusbip development
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (16 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 18/24] EDAC, sb_edac: Fix missing break in switch alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 19/24] sysrq : fix Show Regs call trace on ARM alexander.levin
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Ben Hutchings, Greg Kroah-Hartman, alexander.levin

From: Ben Hutchings <ben@decadent.org.uk>

[ Upstream commit c15562c0dcb2c7f26e891923b784cf1926b8c833 ]

usbip_host_driver.h now depends on several additional headers, which
need to be installed along with it.

Fixes: 021aed845303 ("staging: usbip: userspace: migrate usbip_host_driver ...")
Fixes: 3391ba0e2792 ("usbip: tools: Extract generic code to be shared with ...")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 tools/usb/usbip/Makefile.am | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/usb/usbip/Makefile.am b/tools/usb/usbip/Makefile.am
index 66f8bf038c9f..45eaa70a71e0 100644
--- a/tools/usb/usbip/Makefile.am
+++ b/tools/usb/usbip/Makefile.am
@@ -1,6 +1,7 @@
 SUBDIRS := libsrc src
 includedir = @includedir@/usbip
 include_HEADERS := $(addprefix libsrc/, \
-		     usbip_common.h vhci_driver.h usbip_host_driver.h)
+		     usbip_common.h vhci_driver.h usbip_host_driver.h \
+		     list.h sysfs_utils.h usbip_host_common.h)
 
 dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8)
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 24/24] iio: adc: ti-ads1015: add 10% to conversion wait time
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (21 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 23/24] tools include: Do not use poison with C++ alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Ladislav Michl, Daniel Baluta, Jonathan Cameron,
	Jonathan Cameron, alexander.levin

From: Ladislav Michl <ladis@linux-mips.org>

[ Upstream commit fe895ac88b9fbdf2026f0bfd56c82747bb9d7c48 ]

As user's guide "ADS1015EVM, ADS1115EVM, ADS1015EVM-PDK, ADS1115EVM-PDK
User Guide (Rev. B)" (http://www.ti.com/lit/ug/sbau157b/sbau157b.pdf)
states at page 16:
"Note that both the ADS1115 and ADS1015 have internal clocks with a ±10%
accuracy. If performing FFT tests, frequencies may appear to be incorrect
as a result of this tolerance range.", add those 10% to converion wait
time.

Cc: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/iio/adc/ti-ads1015.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 472641fc890c..af05e20c986b 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -269,6 +269,7 @@ int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
 
 		conv_time = DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr_old]);
 		conv_time += DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr]);
+		conv_time += conv_time / 10; /* 10% internal clock inaccuracy */
 		usleep_range(conv_time, conv_time + 1);
 		data->conv_invalid = false;
 	}
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH AUTOSEL for 4.9 23/24] tools include: Do not use poison with C++
  2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
                   ` (20 preceding siblings ...)
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 22/24] kprobes/x86: Disable preemption in ftrace-based jprobes alexander.levin
@ 2017-11-22 22:26 ` alexander.levin
  2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 24/24] iio: adc: ti-ads1015: add 10% to conversion wait time alexander.levin
  22 siblings, 0 replies; 24+ messages in thread
From: alexander.levin @ 2017-11-22 22:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Arnaldo Carvalho de Melo, Adrian Hunter, Alexander Shishkin,
	David Ahern, Jiri Olsa, Namhyung Kim, Philip Li, Wang Nan,
	alexander.levin

From: Arnaldo Carvalho de Melo <acme@redhat.com>

[ Upstream commit 6ae8eefc6c8fe050f057781b70a83262eb0a61ee ]

LIST_POISON[12] are used to initialize list_head and hlist_node
pointers, and do void pointer arithmetic, which C++ doesn't like, so, to
avoid drifting from the kernel by introducing some HLIST_POISON to do
away with void pointer math, just make those poisoned pointers be NULL
when building it with a C++ compiler.

Noticed with:

  $ make LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
    CXX      util/c++/clang.o
    CXX	   util/c++/clang-test.o
  In file included from /home/lizj/linux/tools/include/linux/list.h:5:0,
                   from /home/lizj/linux/tools/perf/util/namespaces.h:13,
                   from /home/lizj/linux/tools/perf/util/util.h:15,
                   from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
                   from util/c++/clang-c.h:5,
                   from util/c++/clang-test.cpp:2:
  /home/lizj/linux/tools/include/linux/list.h: In function ‘void list_del(list_head*)’:
  /home/lizj/linux/tools/include/linux/poison.h:14:31: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]
   # define POISON_POINTER_DELTA 0
                                 ^
  /home/lizj/linux/tools/include/linux/poison.h:22:41: note: in expansion of macro ‘POISON_POINTER_DELTA’
   #define LIST_POISON1  ((void *) 0x100 + POISON_POINTER_DELTA)
                                           ^
  /home/lizj/linux/tools/include/linux/list.h:107:16: note: in expansion of macro ‘LIST_POISON1’
    entry->next = LIST_POISON1;
                  ^
  In file included from /home/lizj/linux/tools/perf/util/namespaces.h:13:0,
                   from /home/lizj/linux/tools/perf/util/util.h:15,
                   from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
                   from util/c++/clang-c.h:5,
                   from util/c++/clang-test.cpp:2:
  /home/lizj/linux/tools/include/linux/list.h:107:14: error: invalid conversion from ‘void*’ to ‘list_head*’ [-fpermissive]

Reported-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Philip Li <philip.li@intel.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-m5ei2o0mjshucbr28baf5lqz@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 tools/include/linux/poison.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/poison.h b/tools/include/linux/poison.h
index 51334edec506..f306a7642509 100644
--- a/tools/include/linux/poison.h
+++ b/tools/include/linux/poison.h
@@ -14,6 +14,10 @@
 # define POISON_POINTER_DELTA 0
 #endif
 
+#ifdef __cplusplus
+#define LIST_POISON1  NULL
+#define LIST_POISON2  NULL
+#else
 /*
  * These are non-NULL pointers that will result in page faults
  * under normal circumstances, used to verify that nobody uses
@@ -21,6 +25,7 @@
  */
 #define LIST_POISON1  ((void *) 0x100 + POISON_POINTER_DELTA)
 #define LIST_POISON2  ((void *) 0x200 + POISON_POINTER_DELTA)
+#endif
 
 /********** include/linux/timer.h **********/
 /*
-- 
2.11.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2017-11-22 22:41 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22 22:26 [PATCH AUTOSEL for 4.9 01/24] ima: fix hash algorithm initialization alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 02/24] s390/pci: do not require AIS facility alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 06/24] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl() alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 03/24] selftests/x86/ldt_get: Add a few additional tests for limits alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 04/24] staging: greybus: loopback: Fix iteration count on async path alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 05/24] m68k: fix ColdFire node shift size calculation alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 09/24] spi: spi-axi: fix potential use-after-free after deregistration alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 08/24] spi: sh-msiof: Fix DMA transfer size check alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 07/24] staging: rtl8188eu: avoid a null dereference on pmlmepriv alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 10/24] mmc: sdhci-msm: fix issue with power irq alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 11/24] usb: dwc2: Fix UDC state tracking alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 12/24] usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're in host mode alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 14/24] serial: 8250: Preserve DLD[7:4] for PORT_XR17V35X alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 13/24] usb: phy: tahvo: fix error handling in tahvo_usb_probe() alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 16/24] x86/entry: Use SYSCALL_DEFINE() macros for sys_modify_ldt() alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 15/24] kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 17/24] irqchip/gic: Make quirks matching conditional on init return value alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 18/24] EDAC, sb_edac: Fix missing break in switch alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 20/24] usbip: tools: Install all headers needed for libusbip development alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 19/24] sysrq : fix Show Regs call trace on ARM alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 21/24] perf test attr: Fix ignored test case result alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 22/24] kprobes/x86: Disable preemption in ftrace-based jprobes alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 23/24] tools include: Do not use poison with C++ alexander.levin
2017-11-22 22:26 ` [PATCH AUTOSEL for 4.9 24/24] iio: adc: ti-ads1015: add 10% to conversion wait time alexander.levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®