From a426cc6d4de887e68abda235a457454d2f125383 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 18 Oct 2021 12:55:56 +0200 Subject: [PATCH] 4.19-stable patches added patches: iio-adc-aspeed-set-driver-data-when-adc-probe.patch iio-adc128s052-fix-the-error-handling-path-of-adc128_probe.patch iio-dac-ti-dac5571-fix-an-error-code-in-probe.patch iio-light-opt3001-fixed-timeout-error-when-0-lux.patch iio-ssp_sensors-add-more-range-checking-in-ssp_parse_dataframe.patch iio-ssp_sensors-fix-error-code-in-ssp_print_mcu_debug.patch x86-kconfig-do-not-enable-amd_mem_encrypt_active_by_default-automatically.patch --- ...speed-set-driver-data-when-adc-probe.patch | 31 +++++++++ ...-error-handling-path-of-adc128_probe.patch | 42 ++++++++++++ ...i-dac5571-fix-an-error-code-in-probe.patch | 31 +++++++++ ...t3001-fixed-timeout-error-when-0-lux.patch | 44 ++++++++++++ ...ange-checking-in-ssp_parse_dataframe.patch | 57 ++++++++++++++++ ...ix-error-code-in-ssp_print_mcu_debug.patch | 35 ++++++++++ queue-4.19/series | 7 ++ ...rypt_active_by_default-automatically.patch | 68 +++++++++++++++++++ 8 files changed, 315 insertions(+) create mode 100644 queue-4.19/iio-adc-aspeed-set-driver-data-when-adc-probe.patch create mode 100644 queue-4.19/iio-adc128s052-fix-the-error-handling-path-of-adc128_probe.patch create mode 100644 queue-4.19/iio-dac-ti-dac5571-fix-an-error-code-in-probe.patch create mode 100644 queue-4.19/iio-light-opt3001-fixed-timeout-error-when-0-lux.patch create mode 100644 queue-4.19/iio-ssp_sensors-add-more-range-checking-in-ssp_parse_dataframe.patch create mode 100644 queue-4.19/iio-ssp_sensors-fix-error-code-in-ssp_print_mcu_debug.patch create mode 100644 queue-4.19/x86-kconfig-do-not-enable-amd_mem_encrypt_active_by_default-automatically.patch diff --git a/queue-4.19/iio-adc-aspeed-set-driver-data-when-adc-probe.patch b/queue-4.19/iio-adc-aspeed-set-driver-data-when-adc-probe.patch new file mode 100644 index 00000000000..3f46f409aff --- /dev/null +++ b/queue-4.19/iio-adc-aspeed-set-driver-data-when-adc-probe.patch @@ -0,0 +1,31 @@ +From eb795cd97365a3d3d9da3926d234a7bc32a3bb15 Mon Sep 17 00:00:00 2001 +From: Billy Tsai +Date: Tue, 31 Aug 2021 15:14:44 +0800 +Subject: iio: adc: aspeed: set driver data when adc probe. + +From: Billy Tsai + +commit eb795cd97365a3d3d9da3926d234a7bc32a3bb15 upstream. + +Fix the issue when adc remove will get the null driver data. + +Fixed: commit 573803234e72 ("iio: Aspeed ADC") +Signed-off-by: Billy Tsai +Link: https://lore.kernel.org/r/20210831071458.2334-2-billy_tsai@aspeedtech.com +Cc: +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/adc/aspeed_adc.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/iio/adc/aspeed_adc.c ++++ b/drivers/iio/adc/aspeed_adc.c +@@ -188,6 +188,7 @@ static int aspeed_adc_probe(struct platf + + data = iio_priv(indio_dev); + data->dev = &pdev->dev; ++ platform_set_drvdata(pdev, indio_dev); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + data->base = devm_ioremap_resource(&pdev->dev, res); diff --git a/queue-4.19/iio-adc128s052-fix-the-error-handling-path-of-adc128_probe.patch b/queue-4.19/iio-adc128s052-fix-the-error-handling-path-of-adc128_probe.patch new file mode 100644 index 00000000000..af947d48fa2 --- /dev/null +++ b/queue-4.19/iio-adc128s052-fix-the-error-handling-path-of-adc128_probe.patch @@ -0,0 +1,42 @@ +From bbcf40816b547b3c37af49168950491d20d81ce1 Mon Sep 17 00:00:00 2001 +From: Christophe JAILLET +Date: Sat, 21 Aug 2021 12:37:24 +0200 +Subject: iio: adc128s052: Fix the error handling path of 'adc128_probe()' + +From: Christophe JAILLET + +commit bbcf40816b547b3c37af49168950491d20d81ce1 upstream. + +A successful 'regulator_enable()' call should be balanced by a +corresponding 'regulator_disable()' call in the error handling path of the +probe, as already done in the remove function. + +Update the error handling path accordingly. + +Fixes: 913b86468674 ("iio: adc: Add TI ADC128S052") +Signed-off-by: Christophe JAILLET +Reviewed-by: Alexandru Ardelean +Link: https://lore.kernel.org/r/85189f1cfcf6f5f7b42d8730966f2a074b07b5f5.1629542160.git.christophe.jaillet@wanadoo.fr +Cc: +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/adc/ti-adc128s052.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/iio/adc/ti-adc128s052.c ++++ b/drivers/iio/adc/ti-adc128s052.c +@@ -168,7 +168,13 @@ static int adc128_probe(struct spi_devic + mutex_init(&adc->lock); + + ret = iio_device_register(indio_dev); ++ if (ret) ++ goto err_disable_regulator; + ++ return 0; ++ ++err_disable_regulator: ++ regulator_disable(adc->reg); + return ret; + } + diff --git a/queue-4.19/iio-dac-ti-dac5571-fix-an-error-code-in-probe.patch b/queue-4.19/iio-dac-ti-dac5571-fix-an-error-code-in-probe.patch new file mode 100644 index 00000000000..4f2e98cb65e --- /dev/null +++ b/queue-4.19/iio-dac-ti-dac5571-fix-an-error-code-in-probe.patch @@ -0,0 +1,31 @@ +From f7a28df7db84eb3410e9eca37832efa5aed93338 Mon Sep 17 00:00:00 2001 +From: Dan Carpenter +Date: Mon, 16 Aug 2021 21:39:54 +0300 +Subject: iio: dac: ti-dac5571: fix an error code in probe() + +From: Dan Carpenter + +commit f7a28df7db84eb3410e9eca37832efa5aed93338 upstream. + +If we have an unexpected number of channels then return -EINVAL instead +of returning success. + +Fixes: df38a4a72a3b ("iio: dac: add TI DAC5571 family support") +Signed-off-by: Dan Carpenter +Link: https://lore.kernel.org/r/20210816183954.GB2068@kili +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/dac/ti-dac5571.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/iio/dac/ti-dac5571.c ++++ b/drivers/iio/dac/ti-dac5571.c +@@ -355,6 +355,7 @@ static int dac5571_probe(struct i2c_clie + data->dac5571_pwrdwn = dac5571_pwrdwn_quad; + break; + default: ++ ret = -EINVAL; + goto err; + } + diff --git a/queue-4.19/iio-light-opt3001-fixed-timeout-error-when-0-lux.patch b/queue-4.19/iio-light-opt3001-fixed-timeout-error-when-0-lux.patch new file mode 100644 index 00000000000..d997788d62f --- /dev/null +++ b/queue-4.19/iio-light-opt3001-fixed-timeout-error-when-0-lux.patch @@ -0,0 +1,44 @@ +From 26d90b5590579def54382a2fc34cfbe8518a9851 Mon Sep 17 00:00:00 2001 +From: Jiri Valek - 2N +Date: Mon, 20 Sep 2021 14:53:48 +0200 +Subject: iio: light: opt3001: Fixed timeout error when 0 lux + +From: Jiri Valek - 2N + +commit 26d90b5590579def54382a2fc34cfbe8518a9851 upstream. + +Reading from sensor returned timeout error under +zero light conditions. + +Signed-off-by: Jiri Valek - 2N +Fixes: ac663db3678a ("iio: light: opt3001: enable operation w/o IRQ") +Link: https://lore.kernel.org/r/20210920125351.6569-1-valek@2n.cz +Cc: +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/light/opt3001.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/iio/light/opt3001.c ++++ b/drivers/iio/light/opt3001.c +@@ -283,6 +283,8 @@ static int opt3001_get_lux(struct opt300 + ret = wait_event_timeout(opt->result_ready_queue, + opt->result_ready, + msecs_to_jiffies(OPT3001_RESULT_READY_LONG)); ++ if (ret == 0) ++ return -ETIMEDOUT; + } else { + /* Sleep for result ready time */ + timeout = (opt->int_time == OPT3001_INT_TIME_SHORT) ? +@@ -319,9 +321,7 @@ err: + /* Disallow IRQ to access the device while lock is active */ + opt->ok_to_ignore_lock = false; + +- if (ret == 0) +- return -ETIMEDOUT; +- else if (ret < 0) ++ if (ret < 0) + return ret; + + if (opt->use_irq) { diff --git a/queue-4.19/iio-ssp_sensors-add-more-range-checking-in-ssp_parse_dataframe.patch b/queue-4.19/iio-ssp_sensors-add-more-range-checking-in-ssp_parse_dataframe.patch new file mode 100644 index 00000000000..cf46f73a1c4 --- /dev/null +++ b/queue-4.19/iio-ssp_sensors-add-more-range-checking-in-ssp_parse_dataframe.patch @@ -0,0 +1,57 @@ +From 8167c9a375ccceed19048ad9d68cb2d02ed276e0 Mon Sep 17 00:00:00 2001 +From: Dan Carpenter +Date: Thu, 9 Sep 2021 12:13:36 +0300 +Subject: iio: ssp_sensors: add more range checking in ssp_parse_dataframe() + +From: Dan Carpenter + +commit 8167c9a375ccceed19048ad9d68cb2d02ed276e0 upstream. + +The "idx" is validated at the start of the loop but it gets incremented +during the iteration so it needs to be checked again. + +Fixes: 50dd64d57eee ("iio: common: ssp_sensors: Add sensorhub driver") +Signed-off-by: Dan Carpenter +Link: https://lore.kernel.org/r/20210909091336.GA26312@kili +Cc: +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/common/ssp_sensors/ssp_spi.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +--- a/drivers/iio/common/ssp_sensors/ssp_spi.c ++++ b/drivers/iio/common/ssp_sensors/ssp_spi.c +@@ -283,6 +283,8 @@ static int ssp_parse_dataframe(struct ss + for (idx = 0; idx < len;) { + switch (dataframe[idx++]) { + case SSP_MSG2AP_INST_BYPASS_DATA: ++ if (idx >= len) ++ return -EPROTO; + sd = dataframe[idx++]; + if (sd < 0 || sd >= SSP_SENSOR_MAX) { + dev_err(SSP_DEV, +@@ -292,10 +294,13 @@ static int ssp_parse_dataframe(struct ss + + if (indio_devs[sd]) { + spd = iio_priv(indio_devs[sd]); +- if (spd->process_data) ++ if (spd->process_data) { ++ if (idx >= len) ++ return -EPROTO; + spd->process_data(indio_devs[sd], + &dataframe[idx], + data->timestamp); ++ } + } else { + dev_err(SSP_DEV, "no client for frame\n"); + } +@@ -303,6 +308,8 @@ static int ssp_parse_dataframe(struct ss + idx += ssp_offset_map[sd]; + break; + case SSP_MSG2AP_INST_DEBUG_DATA: ++ if (idx >= len) ++ return -EPROTO; + sd = ssp_print_mcu_debug(dataframe, &idx, len); + if (sd) { + dev_err(SSP_DEV, diff --git a/queue-4.19/iio-ssp_sensors-fix-error-code-in-ssp_print_mcu_debug.patch b/queue-4.19/iio-ssp_sensors-fix-error-code-in-ssp_print_mcu_debug.patch new file mode 100644 index 00000000000..f3cadf900cd --- /dev/null +++ b/queue-4.19/iio-ssp_sensors-fix-error-code-in-ssp_print_mcu_debug.patch @@ -0,0 +1,35 @@ +From 4170d3dd1467e9d78cb9af374b19357dc324b328 Mon Sep 17 00:00:00 2001 +From: Dan Carpenter +Date: Tue, 14 Sep 2021 13:53:33 +0300 +Subject: iio: ssp_sensors: fix error code in ssp_print_mcu_debug() + +From: Dan Carpenter + +commit 4170d3dd1467e9d78cb9af374b19357dc324b328 upstream. + +The ssp_print_mcu_debug() function should return negative error codes on +error. Returning "length" is meaningless. This change does not affect +runtime because the callers only care about zero/non-zero. + +Reported-by: Jonathan Cameron +Fixes: 50dd64d57eee ("iio: common: ssp_sensors: Add sensorhub driver") +Signed-off-by: Dan Carpenter +Link: https://lore.kernel.org/r/20210914105333.GA11657@kili +Cc: +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/common/ssp_sensors/ssp_spi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/iio/common/ssp_sensors/ssp_spi.c ++++ b/drivers/iio/common/ssp_sensors/ssp_spi.c +@@ -147,7 +147,7 @@ static int ssp_print_mcu_debug(char *dat + if (length > received_len - *data_index || length <= 0) { + ssp_dbg("[SSP]: MSG From MCU-invalid debug length(%d/%d)\n", + length, received_len); +- return length ? length : -EPROTO; ++ return -EPROTO; + } + + ssp_dbg("[SSP]: MSG From MCU - %s\n", &data_frame[*data_index]); diff --git a/queue-4.19/series b/queue-4.19/series index 1672129bbdd..75168220ef2 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -23,3 +23,10 @@ usb-serial-option-add-telit-le910cx-composition-0x1204.patch usb-serial-option-add-prod.-id-for-quectel-eg91.patch virtio-write-back-f_version_1-before-validate.patch nvmem-fix-shift-out-of-bound-ubsan-with-byte-size-cells.patch +x86-kconfig-do-not-enable-amd_mem_encrypt_active_by_default-automatically.patch +iio-adc-aspeed-set-driver-data-when-adc-probe.patch +iio-adc128s052-fix-the-error-handling-path-of-adc128_probe.patch +iio-light-opt3001-fixed-timeout-error-when-0-lux.patch +iio-ssp_sensors-add-more-range-checking-in-ssp_parse_dataframe.patch +iio-ssp_sensors-fix-error-code-in-ssp_print_mcu_debug.patch +iio-dac-ti-dac5571-fix-an-error-code-in-probe.patch diff --git a/queue-4.19/x86-kconfig-do-not-enable-amd_mem_encrypt_active_by_default-automatically.patch b/queue-4.19/x86-kconfig-do-not-enable-amd_mem_encrypt_active_by_default-automatically.patch new file mode 100644 index 00000000000..84e0c4d730d --- /dev/null +++ b/queue-4.19/x86-kconfig-do-not-enable-amd_mem_encrypt_active_by_default-automatically.patch @@ -0,0 +1,68 @@ +From 711885906b5c2df90746a51f4cd674f1ab9fbb1d Mon Sep 17 00:00:00 2001 +From: Borislav Petkov +Date: Wed, 6 Oct 2021 19:34:55 +0200 +Subject: x86/Kconfig: Do not enable AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT automatically + +From: Borislav Petkov + +commit 711885906b5c2df90746a51f4cd674f1ab9fbb1d upstream. + +This Kconfig option was added initially so that memory encryption is +enabled by default on machines which support it. + +However, devices which have DMA masks that are less than the bit +position of the encryption bit, aka C-bit, require the use of an IOMMU +or the use of SWIOTLB. + +If the IOMMU is disabled or in passthrough mode, the kernel would switch +to SWIOTLB bounce-buffering for those transfers. + +In order to avoid that, + + 2cc13bb4f59f ("iommu: Disable passthrough mode when SME is active") + +disables the default IOMMU passthrough mode so that devices for which the +default 256K DMA is insufficient, can use the IOMMU instead. + +However 2, there are cases where the IOMMU is disabled in the BIOS, etc. +(think the usual hardware folk "oops, I dropped the ball there" cases) or a +driver doesn't properly use the DMA APIs or a device has a firmware or +hardware bug, e.g.: + + ea68573d408f ("drm/amdgpu: Fail to load on RAVEN if SME is active") + +However 3, in the above GPU use case, there are APIs like Vulkan and +some OpenGL/OpenCL extensions which are under the assumption that +user-allocated memory can be passed in to the kernel driver and both the +GPU and CPU can do coherent and concurrent access to the same memory. +That cannot work with SWIOTLB bounce buffers, of course. + +So, in order for those devices to function, drop the "default y" for the +SME by default active option so that users who want to have SME enabled, +will need to either enable it in their config or use "mem_encrypt=on" on +the kernel command line. + + [ tlendacky: Generalize commit message. ] + +Fixes: 7744ccdbc16f ("x86/mm: Add Secure Memory Encryption (SME) support") +Reported-by: Paul Menzel +Signed-off-by: Borislav Petkov +Acked-by: Alex Deucher +Acked-by: Tom Lendacky +Cc: +Link: https://lkml.kernel.org/r/8bbacd0e-4580-3194-19d2-a0ecad7df09c@molgen.mpg.de +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/Kconfig | 1 - + 1 file changed, 1 deletion(-) + +--- a/arch/x86/Kconfig ++++ b/arch/x86/Kconfig +@@ -1496,7 +1496,6 @@ config AMD_MEM_ENCRYPT + + config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT + bool "Activate AMD Secure Memory Encryption (SME) by default" +- default y + depends on AMD_MEM_ENCRYPT + ---help--- + Say yes to have system memory encrypted by default if running on -- 2.47.3