From 6af6f9df6cd2a084b23db34a7716fd98e6c877bc Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 3 Jul 2017 13:32:39 +0200 Subject: [PATCH] 4.4-stable patches added patches: arm64-assembler-make-adr_l-work-in-modules-under-kaslr.patch hid-i2c-hid-add-sleep-between-power-on-and-reset.patch scsi-lpfc-avoid-double-free-of-resource-identifiers.patch spi-davinci-use-dma_mapping_error.patch --- ...ke-adr_l-work-in-modules-under-kaslr.patch | 103 ++++++++++++++++++ ...add-sleep-between-power-on-and-reset.patch | 51 +++++++++ ...-double-free-of-resource-identifiers.patch | 52 +++++++++ queue-4.4/series | 4 + .../spi-davinci-use-dma_mapping_error.patch | 41 +++++++ 5 files changed, 251 insertions(+) create mode 100644 queue-4.4/arm64-assembler-make-adr_l-work-in-modules-under-kaslr.patch create mode 100644 queue-4.4/hid-i2c-hid-add-sleep-between-power-on-and-reset.patch create mode 100644 queue-4.4/scsi-lpfc-avoid-double-free-of-resource-identifiers.patch create mode 100644 queue-4.4/spi-davinci-use-dma_mapping_error.patch diff --git a/queue-4.4/arm64-assembler-make-adr_l-work-in-modules-under-kaslr.patch b/queue-4.4/arm64-assembler-make-adr_l-work-in-modules-under-kaslr.patch new file mode 100644 index 00000000000..4f77f7c055c --- /dev/null +++ b/queue-4.4/arm64-assembler-make-adr_l-work-in-modules-under-kaslr.patch @@ -0,0 +1,103 @@ +From foo@baz Mon Jul 3 13:29:24 CEST 2017 +From: Ard Biesheuvel +Date: Wed, 11 Jan 2017 14:54:53 +0000 +Subject: arm64: assembler: make adr_l work in modules under KASLR + +From: Ard Biesheuvel + + +[ Upstream commit 41c066f2c4d436c535616fe182331766c57838f0 ] + +When CONFIG_RANDOMIZE_MODULE_REGION_FULL=y, the offset between loaded +modules and the core kernel may exceed 4 GB, putting symbols exported +by the core kernel out of the reach of the ordinary adrp/add instruction +pairs used to generate relative symbol references. So make the adr_l +macro emit a movz/movk sequence instead when executing in module context. + +While at it, remove the pointless special case for the stack pointer. + +Acked-by: Mark Rutland +Acked-by: Will Deacon +Signed-off-by: Ard Biesheuvel +Signed-off-by: Catalin Marinas +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm64/include/asm/assembler.h | 36 +++++++++++++++++++++++++++--------- + 1 file changed, 27 insertions(+), 9 deletions(-) + +--- a/arch/arm64/include/asm/assembler.h ++++ b/arch/arm64/include/asm/assembler.h +@@ -147,22 +147,25 @@ lr .req x30 // link register + + /* + * Pseudo-ops for PC-relative adr/ldr/str , where +- * is within the range +/- 4 GB of the PC. ++ * is within the range +/- 4 GB of the PC when running ++ * in core kernel context. In module context, a movz/movk sequence ++ * is used, since modules may be loaded far away from the kernel ++ * when KASLR is in effect. + */ + /* + * @dst: destination register (64 bit wide) + * @sym: name of the symbol +- * @tmp: optional scratch register to be used if == sp, which +- * is not allowed in an adrp instruction + */ +- .macro adr_l, dst, sym, tmp= +- .ifb \tmp ++ .macro adr_l, dst, sym ++#ifndef MODULE + adrp \dst, \sym + add \dst, \dst, :lo12:\sym +- .else +- adrp \tmp, \sym +- add \dst, \tmp, :lo12:\sym +- .endif ++#else ++ movz \dst, #:abs_g3:\sym ++ movk \dst, #:abs_g2_nc:\sym ++ movk \dst, #:abs_g1_nc:\sym ++ movk \dst, #:abs_g0_nc:\sym ++#endif + .endm + + /* +@@ -173,6 +176,7 @@ lr .req x30 // link register + * the address + */ + .macro ldr_l, dst, sym, tmp= ++#ifndef MODULE + .ifb \tmp + adrp \dst, \sym + ldr \dst, [\dst, :lo12:\sym] +@@ -180,6 +184,15 @@ lr .req x30 // link register + adrp \tmp, \sym + ldr \dst, [\tmp, :lo12:\sym] + .endif ++#else ++ .ifb \tmp ++ adr_l \dst, \sym ++ ldr \dst, [\dst] ++ .else ++ adr_l \tmp, \sym ++ ldr \dst, [\tmp] ++ .endif ++#endif + .endm + + /* +@@ -189,8 +202,13 @@ lr .req x30 // link register + * while needs to be preserved. + */ + .macro str_l, src, sym, tmp ++#ifndef MODULE + adrp \tmp, \sym + str \src, [\tmp, :lo12:\sym] ++#else ++ adr_l \tmp, \sym ++ str \src, [\tmp] ++#endif + .endm + + /* diff --git a/queue-4.4/hid-i2c-hid-add-sleep-between-power-on-and-reset.patch b/queue-4.4/hid-i2c-hid-add-sleep-between-power-on-and-reset.patch new file mode 100644 index 00000000000..56422543737 --- /dev/null +++ b/queue-4.4/hid-i2c-hid-add-sleep-between-power-on-and-reset.patch @@ -0,0 +1,51 @@ +From foo@baz Mon Jul 3 13:29:24 CEST 2017 +From: Brendan McGrath +Date: Sat, 7 Jan 2017 08:01:38 +1100 +Subject: HID: i2c-hid: Add sleep between POWER ON and RESET + +From: Brendan McGrath + + +[ Upstream commit a89af4abdf9b353cdd6f61afc0eaaac403304873 ] + +Support for the Asus Touchpad was recently added. It turns out this +device can fail initialisation (and become unusable) when the RESET +command is sent too soon after the POWER ON command. + +Unfortunately the i2c-hid specification does not specify the need for +a delay between these two commands. But it was discovered the Windows +driver has a 1ms delay. + +As a result, this patch modifies the i2c-hid module to add a sleep +inbetween the POWER ON and RESET commands which lasts between 1ms and 5ms. + +See https://github.com/vlasenko/hid-asus-dkms/issues/24 for further +details. + +Signed-off-by: Brendan McGrath +Reviewed-by: Benjamin Tissoires +Signed-off-by: Jiri Kosina +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hid/i2c-hid/i2c-hid.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/drivers/hid/i2c-hid/i2c-hid.c ++++ b/drivers/hid/i2c-hid/i2c-hid.c +@@ -364,6 +364,15 @@ static int i2c_hid_hwreset(struct i2c_cl + if (ret) + return ret; + ++ /* ++ * The HID over I2C specification states that if a DEVICE needs time ++ * after the PWR_ON request, it should utilise CLOCK stretching. ++ * However, it has been observered that the Windows driver provides a ++ * 1ms sleep between the PWR_ON and RESET requests and that some devices ++ * rely on this. ++ */ ++ usleep_range(1000, 5000); ++ + i2c_hid_dbg(ihid, "resetting...\n"); + + ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0); diff --git a/queue-4.4/scsi-lpfc-avoid-double-free-of-resource-identifiers.patch b/queue-4.4/scsi-lpfc-avoid-double-free-of-resource-identifiers.patch new file mode 100644 index 00000000000..f10e7b5626a --- /dev/null +++ b/queue-4.4/scsi-lpfc-avoid-double-free-of-resource-identifiers.patch @@ -0,0 +1,52 @@ +From foo@baz Mon Jul 3 13:29:24 CEST 2017 +From: Roberto Sassu +Date: Wed, 11 Jan 2017 11:06:42 +0100 +Subject: scsi: lpfc: avoid double free of resource identifiers + +From: Roberto Sassu + + +[ Upstream commit cd60be4916ae689387d04b86b6fc15931e4c95ae ] + +Set variables initialized in lpfc_sli4_alloc_resource_identifiers() to +NULL if an error occurred. Otherwise, lpfc_sli4_driver_resource_unset() +attempts to free the memory again. + +Signed-off-by: Roberto Sassu +Signed-off-by: Johannes Thumshirn +Acked-by: James Smart +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/lpfc/lpfc_sli.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/drivers/scsi/lpfc/lpfc_sli.c ++++ b/drivers/scsi/lpfc/lpfc_sli.c +@@ -5887,18 +5887,25 @@ lpfc_sli4_alloc_resource_identifiers(str + + free_vfi_bmask: + kfree(phba->sli4_hba.vfi_bmask); ++ phba->sli4_hba.vfi_bmask = NULL; + free_xri_ids: + kfree(phba->sli4_hba.xri_ids); ++ phba->sli4_hba.xri_ids = NULL; + free_xri_bmask: + kfree(phba->sli4_hba.xri_bmask); ++ phba->sli4_hba.xri_bmask = NULL; + free_vpi_ids: + kfree(phba->vpi_ids); ++ phba->vpi_ids = NULL; + free_vpi_bmask: + kfree(phba->vpi_bmask); ++ phba->vpi_bmask = NULL; + free_rpi_ids: + kfree(phba->sli4_hba.rpi_ids); ++ phba->sli4_hba.rpi_ids = NULL; + free_rpi_bmask: + kfree(phba->sli4_hba.rpi_bmask); ++ phba->sli4_hba.rpi_bmask = NULL; + err_exit: + return rc; + } diff --git a/queue-4.4/series b/queue-4.4/series index 19b7c958d14..e0449520354 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -66,3 +66,7 @@ virtio_net-fix-page_size-64k.patch vxlan-do-not-age-static-remote-mac-entries.patch ibmveth-add-a-proper-check-for-the-availability-of-the-checksum-features.patch kernel-panic.c-add-missing-n.patch +hid-i2c-hid-add-sleep-between-power-on-and-reset.patch +scsi-lpfc-avoid-double-free-of-resource-identifiers.patch +spi-davinci-use-dma_mapping_error.patch +arm64-assembler-make-adr_l-work-in-modules-under-kaslr.patch diff --git a/queue-4.4/spi-davinci-use-dma_mapping_error.patch b/queue-4.4/spi-davinci-use-dma_mapping_error.patch new file mode 100644 index 00000000000..48986ef43e9 --- /dev/null +++ b/queue-4.4/spi-davinci-use-dma_mapping_error.patch @@ -0,0 +1,41 @@ +From foo@baz Mon Jul 3 13:29:24 CEST 2017 +From: Kevin Hilman +Date: Wed, 11 Jan 2017 18:18:40 -0800 +Subject: spi: davinci: use dma_mapping_error() + +From: Kevin Hilman + + +[ Upstream commit c5a2a394835f473ae23931eda5066d3771d7b2f8 ] + +The correct error checking for dma_map_single() is to use +dma_mapping_error(). + +Signed-off-by: Kevin Hilman +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/spi/spi-davinci.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/spi/spi-davinci.c ++++ b/drivers/spi/spi-davinci.c +@@ -651,7 +651,7 @@ static int davinci_spi_bufs(struct spi_d + buf = t->rx_buf; + t->rx_dma = dma_map_single(&spi->dev, buf, + t->len, DMA_FROM_DEVICE); +- if (!t->rx_dma) { ++ if (dma_mapping_error(&spi->dev, !t->rx_dma)) { + ret = -EFAULT; + goto err_rx_map; + } +@@ -665,7 +665,7 @@ static int davinci_spi_bufs(struct spi_d + buf = (void *)t->tx_buf; + t->tx_dma = dma_map_single(&spi->dev, buf, + t->len, DMA_TO_DEVICE); +- if (!t->tx_dma) { ++ if (dma_mapping_error(&spi->dev, t->tx_dma)) { + ret = -EFAULT; + goto err_tx_map; + } -- 2.47.3