From: Sasha Levin Date: Tue, 16 Jul 2024 14:21:02 +0000 (-0400) Subject: Fixes for 6.6 X-Git-Tag: v4.19.318~18^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a5e3f138219e44c639ac65c40fea8bf8bbb86d6;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.6 Signed-off-by: Sasha Levin --- diff --git a/queue-6.6/i2c-mark-hostnotify-target-address-as-used.patch b/queue-6.6/i2c-mark-hostnotify-target-address-as-used.patch new file mode 100644 index 00000000000..392311a479e --- /dev/null +++ b/queue-6.6/i2c-mark-hostnotify-target-address-as-used.patch @@ -0,0 +1,39 @@ +From 8dfcc191be6f0044aab50a7623aab438b01a3d3b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 Jul 2024 10:55:07 +0200 +Subject: i2c: mark HostNotify target address as used + +From: Wolfram Sang + +[ Upstream commit bd9f5348089b65612e5ca976e2ae22f005340331 ] + +I2C core handles the local target for receiving HostNotify alerts. There +is no separate driver bound to that address. That means userspace can +access it if desired, leading to further complications if controllers +are not capable of reading their own local target. Bind the local target +to the dummy driver so it will be marked as "handled by the kernel" if +the HostNotify feature is used. That protects aginst userspace access +and prevents other drivers binding to it. + +Fixes: 2a71593da34d ("i2c: smbus: add core function handling SMBus host-notify") +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/i2c-core-base.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c +index 3642d42463209..1e873ff0a624d 100644 +--- a/drivers/i2c/i2c-core-base.c ++++ b/drivers/i2c/i2c-core-base.c +@@ -1064,6 +1064,7 @@ EXPORT_SYMBOL(i2c_find_device_by_fwnode); + + static const struct i2c_device_id dummy_id[] = { + { "dummy", 0 }, ++ { "smbus_host_notify", 0 }, + { }, + }; + +-- +2.43.0 + diff --git a/queue-6.6/i2c-rcar-bring-hardware-to-known-state-when-probing.patch b/queue-6.6/i2c-rcar-bring-hardware-to-known-state-when-probing.patch new file mode 100644 index 00000000000..e7bbb22bac5 --- /dev/null +++ b/queue-6.6/i2c-rcar-bring-hardware-to-known-state-when-probing.patch @@ -0,0 +1,71 @@ +From 2f812cabfd9819bace63e5b833786c0f713f0d1f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 7 Jul 2024 10:28:46 +0200 +Subject: i2c: rcar: bring hardware to known state when probing + +From: Wolfram Sang + +[ Upstream commit 4e36c0f20cb1c74c7bd7ea31ba432c1c4a989031 ] + +When probing, the hardware is not brought into a known state. This may +be a problem when a hypervisor restarts Linux without resetting the +hardware, leaving an old state running. Make sure the hardware gets +initialized, especially interrupts should be cleared and disabled. + +Reported-by: Dirk Behme +Reported-by: Geert Uytterhoeven +Closes: https://lore.kernel.org/r/20240702045535.2000393-1-dirk.behme@de.bosch.com +Fixes: 6ccbe607132b ("i2c: add Renesas R-Car I2C driver") +Signed-off-by: Wolfram Sang +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-rcar.c | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index a32a93f9a60d0..2fec6cb09757a 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -223,6 +223,14 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv) + + } + ++static void rcar_i2c_reset_slave(struct rcar_i2c_priv *priv) ++{ ++ rcar_i2c_write(priv, ICSIER, 0); ++ rcar_i2c_write(priv, ICSSR, 0); ++ rcar_i2c_write(priv, ICSCR, SDBS); ++ rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ ++} ++ + static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) + { + int ret; +@@ -975,11 +983,8 @@ static int rcar_unreg_slave(struct i2c_client *slave) + + /* ensure no irq is running before clearing ptr */ + disable_irq(priv->irq); +- rcar_i2c_write(priv, ICSIER, 0); +- rcar_i2c_write(priv, ICSSR, 0); ++ rcar_i2c_reset_slave(priv); + enable_irq(priv->irq); +- rcar_i2c_write(priv, ICSCR, SDBS); +- rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ + + priv->slave = NULL; + +@@ -1092,7 +1097,9 @@ static int rcar_i2c_probe(struct platform_device *pdev) + goto out_pm_disable; + } + +- rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ ++ /* Bring hardware to known state */ ++ rcar_i2c_init(priv); ++ rcar_i2c_reset_slave(priv); + + if (priv->devtype < I2C_RCAR_GEN3) { + irqflags |= IRQF_NO_THREAD; +-- +2.43.0 + diff --git a/queue-6.6/i2c-rcar-clear-no_rxdma-flag-after-resetting.patch b/queue-6.6/i2c-rcar-clear-no_rxdma-flag-after-resetting.patch new file mode 100644 index 00000000000..14b259bcf69 --- /dev/null +++ b/queue-6.6/i2c-rcar-clear-no_rxdma-flag-after-resetting.patch @@ -0,0 +1,39 @@ +From 54deb5162daabab11cedc2442e507eb07576f3c9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 Jul 2024 13:03:00 +0200 +Subject: i2c: rcar: clear NO_RXDMA flag after resetting + +From: Wolfram Sang + +[ Upstream commit fea6b5ebb71a2830b042e42de7ae255017ac3ce8 ] + +We should allow RXDMA only if the reset was really successful, so clear +the flag after the reset call. + +Fixes: 0e864b552b23 ("i2c: rcar: reset controller is mandatory for Gen3+") +Signed-off-by: Wolfram Sang +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-rcar.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index 0ba88d44a7dbe..1d341bd2b4b96 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -856,10 +856,10 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, + + /* Gen3+ needs a reset. That also allows RXDMA once */ + if (priv->devtype >= I2C_RCAR_GEN3) { +- priv->flags &= ~ID_P_NO_RXDMA; + ret = rcar_i2c_do_reset(priv); + if (ret) + goto out; ++ priv->flags &= ~ID_P_NO_RXDMA; + } + + rcar_i2c_init(priv); +-- +2.43.0 + diff --git a/queue-6.6/i2c-rcar-ensure-gen3-reset-does-not-disturb-local-ta.patch b/queue-6.6/i2c-rcar-ensure-gen3-reset-does-not-disturb-local-ta.patch new file mode 100644 index 00000000000..437c0d853fb --- /dev/null +++ b/queue-6.6/i2c-rcar-ensure-gen3-reset-does-not-disturb-local-ta.patch @@ -0,0 +1,59 @@ +From 2a722b468ad288ee6ea5689d0aa7c5b6b775c64d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Jul 2024 10:30:44 +0200 +Subject: i2c: rcar: ensure Gen3+ reset does not disturb local targets + +From: Wolfram Sang + +[ Upstream commit ea5ea84c9d3570dc06e8fc5ee2273eaa584aa3ac ] + +R-Car Gen3+ needs a reset before every controller transfer. That erases +configuration of a potentially in parallel running local target +instance. To avoid this disruption, avoid controller transfers if a +local target is running. Also, disable SMBusHostNotify because it +requires being a controller and local target at the same time. + +Fixes: 3b770017b03a ("i2c: rcar: handle RXDMA HW behaviour on Gen3") +Signed-off-by: Wolfram Sang +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-rcar.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index 2719bc5a1a771..0ba88d44a7dbe 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -824,6 +824,10 @@ static int rcar_i2c_do_reset(struct rcar_i2c_priv *priv) + { + int ret; + ++ /* Don't reset if a slave instance is currently running */ ++ if (priv->slave) ++ return -EISCONN; ++ + ret = reset_control_reset(priv->rstc); + if (ret) + return ret; +@@ -1114,6 +1118,7 @@ static int rcar_i2c_probe(struct platform_device *pdev) + if (of_property_read_bool(dev->of_node, "smbus")) + priv->flags |= ID_P_HOST_NOTIFY; + ++ /* R-Car Gen3+ needs a reset before every transfer */ + if (priv->devtype >= I2C_RCAR_GEN3) { + priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); + if (IS_ERR(priv->rstc)) +@@ -1122,6 +1127,9 @@ static int rcar_i2c_probe(struct platform_device *pdev) + ret = reset_control_status(priv->rstc); + if (ret < 0) + goto out_pm_put; ++ ++ /* hard reset disturbs HostNotify local target, so disable it */ ++ priv->flags &= ~ID_P_HOST_NOTIFY; + } + + ret = platform_get_irq(pdev, 0); +-- +2.43.0 + diff --git a/queue-6.6/i2c-rcar-introduce-gen4-devices.patch b/queue-6.6/i2c-rcar-introduce-gen4-devices.patch new file mode 100644 index 00000000000..cf99d83dc9f --- /dev/null +++ b/queue-6.6/i2c-rcar-introduce-gen4-devices.patch @@ -0,0 +1,77 @@ +From 86756256af0a280099ff4dd4413bc9e58bffe7ff Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 14 Dec 2023 08:43:57 +0100 +Subject: i2c: rcar: introduce Gen4 devices + +From: Wolfram Sang + +[ Upstream commit 2b523c46e81ebd621515ab47117f95de197dfcbf ] + +So far, we treated Gen4 as Gen3. But we are soon adding FM+ as a Gen4 +specific feature, so prepare the code for the new devtype. + +Signed-off-by: Wolfram Sang +Reviewed-by: Geert Uytterhoeven +Reviewed-by: Andi Shyti +Signed-off-by: Wolfram Sang +Stable-dep-of: ea5ea84c9d35 ("i2c: rcar: ensure Gen3+ reset does not disturb local targets") +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-rcar.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index 3fda82159e54d..2719bc5a1a771 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -114,6 +114,7 @@ enum rcar_i2c_type { + I2C_RCAR_GEN1, + I2C_RCAR_GEN2, + I2C_RCAR_GEN3, ++ I2C_RCAR_GEN4, + }; + + struct rcar_i2c_priv { +@@ -394,8 +395,8 @@ static void rcar_i2c_cleanup_dma(struct rcar_i2c_priv *priv, bool terminate) + dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg), + sg_dma_len(&priv->sg), priv->dma_direction); + +- /* Gen3 can only do one RXDMA per transfer and we just completed it */ +- if (priv->devtype == I2C_RCAR_GEN3 && ++ /* Gen3+ can only do one RXDMA per transfer and we just completed it */ ++ if (priv->devtype >= I2C_RCAR_GEN3 && + priv->dma_direction == DMA_FROM_DEVICE) + priv->flags |= ID_P_NO_RXDMA; + +@@ -849,8 +850,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, + if (ret < 0) + goto out; + +- /* Gen3 needs a reset before allowing RXDMA once */ +- if (priv->devtype == I2C_RCAR_GEN3) { ++ /* Gen3+ needs a reset. That also allows RXDMA once */ ++ if (priv->devtype >= I2C_RCAR_GEN3) { + priv->flags &= ~ID_P_NO_RXDMA; + ret = rcar_i2c_do_reset(priv); + if (ret) +@@ -1035,7 +1036,7 @@ static const struct of_device_id rcar_i2c_dt_ids[] = { + { .compatible = "renesas,rcar-gen1-i2c", .data = (void *)I2C_RCAR_GEN1 }, + { .compatible = "renesas,rcar-gen2-i2c", .data = (void *)I2C_RCAR_GEN2 }, + { .compatible = "renesas,rcar-gen3-i2c", .data = (void *)I2C_RCAR_GEN3 }, +- { .compatible = "renesas,rcar-gen4-i2c", .data = (void *)I2C_RCAR_GEN3 }, ++ { .compatible = "renesas,rcar-gen4-i2c", .data = (void *)I2C_RCAR_GEN4 }, + {}, + }; + MODULE_DEVICE_TABLE(of, rcar_i2c_dt_ids); +@@ -1113,7 +1114,7 @@ static int rcar_i2c_probe(struct platform_device *pdev) + if (of_property_read_bool(dev->of_node, "smbus")) + priv->flags |= ID_P_HOST_NOTIFY; + +- if (priv->devtype == I2C_RCAR_GEN3) { ++ if (priv->devtype >= I2C_RCAR_GEN3) { + priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); + if (IS_ERR(priv->rstc)) + goto out_pm_put; +-- +2.43.0 + diff --git a/queue-6.6/i2c-rcar-reset-controller-is-mandatory-for-gen3.patch b/queue-6.6/i2c-rcar-reset-controller-is-mandatory-for-gen3.patch new file mode 100644 index 00000000000..ec358dbb33f --- /dev/null +++ b/queue-6.6/i2c-rcar-reset-controller-is-mandatory-for-gen3.patch @@ -0,0 +1,81 @@ +From d8f3831ba37d73e305b9b9272210a46aa6269049 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 21 Sep 2023 14:53:49 +0200 +Subject: i2c: rcar: reset controller is mandatory for Gen3+ + +From: Wolfram Sang + +[ Upstream commit 0e864b552b2302e40b2277629ebac79544a5c433 ] + +Initially, we only needed a reset controller to make sure RXDMA works at +least once per transfer. Meanwhile, documentation has been updated. It +now says that a reset has to be performed prior every transaction, even +if it is non-DMA. So, make the reset controller a requirement instead of +being optional. And bail out if resetting fails. + +Signed-off-by: Wolfram Sang +Reviewed-by: Geert Uytterhoeven +Signed-off-by: Wolfram Sang +Stable-dep-of: ea5ea84c9d35 ("i2c: rcar: ensure Gen3+ reset does not disturb local targets") +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-rcar.c | 29 ++++++++++++++--------------- + 1 file changed, 14 insertions(+), 15 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index 2fec6cb09757a..3fda82159e54d 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -851,12 +851,10 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, + + /* Gen3 needs a reset before allowing RXDMA once */ + if (priv->devtype == I2C_RCAR_GEN3) { +- priv->flags |= ID_P_NO_RXDMA; +- if (!IS_ERR(priv->rstc)) { +- ret = rcar_i2c_do_reset(priv); +- if (ret == 0) +- priv->flags &= ~ID_P_NO_RXDMA; +- } ++ priv->flags &= ~ID_P_NO_RXDMA; ++ ret = rcar_i2c_do_reset(priv); ++ if (ret) ++ goto out; + } + + rcar_i2c_init(priv); +@@ -1106,15 +1104,6 @@ static int rcar_i2c_probe(struct platform_device *pdev) + irqhandler = rcar_i2c_gen2_irq; + } + +- if (priv->devtype == I2C_RCAR_GEN3) { +- priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); +- if (!IS_ERR(priv->rstc)) { +- ret = reset_control_status(priv->rstc); +- if (ret < 0) +- priv->rstc = ERR_PTR(-ENOTSUPP); +- } +- } +- + /* Stay always active when multi-master to keep arbitration working */ + if (of_property_read_bool(dev->of_node, "multi-master")) + priv->flags |= ID_P_PM_BLOCKED; +@@ -1124,6 +1113,16 @@ static int rcar_i2c_probe(struct platform_device *pdev) + if (of_property_read_bool(dev->of_node, "smbus")) + priv->flags |= ID_P_HOST_NOTIFY; + ++ if (priv->devtype == I2C_RCAR_GEN3) { ++ priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); ++ if (IS_ERR(priv->rstc)) ++ goto out_pm_put; ++ ++ ret = reset_control_status(priv->rstc); ++ if (ret < 0) ++ goto out_pm_put; ++ } ++ + ret = platform_get_irq(pdev, 0); + if (ret < 0) + goto out_pm_put; +-- +2.43.0 + diff --git a/queue-6.6/i2c-testunit-avoid-re-issued-work-after-read-message.patch b/queue-6.6/i2c-testunit-avoid-re-issued-work-after-read-message.patch new file mode 100644 index 00000000000..3d2c7f26d4c --- /dev/null +++ b/queue-6.6/i2c-testunit-avoid-re-issued-work-after-read-message.patch @@ -0,0 +1,44 @@ +From f10e30bf756b17a9a9887261e54f818f2b0e765e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Jul 2024 14:08:19 +0200 +Subject: i2c: testunit: avoid re-issued work after read message + +From: Wolfram Sang + +[ Upstream commit 119736c7af442ab398dbb806865988c98ef60d46 ] + +The to-be-fixed commit rightfully prevented that the registers will be +cleared. However, the index must be cleared. Otherwise a read message +will re-issue the last work. Fix it and add a comment describing the +situation. + +Fixes: c422b6a63024 ("i2c: testunit: don't erase registers after STOP") +Signed-off-by: Wolfram Sang +Reviewed-by: Andi Shyti +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/i2c-slave-testunit.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/drivers/i2c/i2c-slave-testunit.c b/drivers/i2c/i2c-slave-testunit.c +index ca43e98cae1b2..23a11e4e92567 100644 +--- a/drivers/i2c/i2c-slave-testunit.c ++++ b/drivers/i2c/i2c-slave-testunit.c +@@ -118,6 +118,13 @@ static int i2c_slave_testunit_slave_cb(struct i2c_client *client, + queue_delayed_work(system_long_wq, &tu->worker, + msecs_to_jiffies(10 * tu->regs[TU_REG_DELAY])); + } ++ ++ /* ++ * Reset reg_idx to avoid that work gets queued again in case of ++ * STOP after a following read message. But do not clear TU regs ++ * here because we still need them in the workqueue! ++ */ ++ tu->reg_idx = 0; + break; + + case I2C_SLAVE_WRITE_REQUESTED: +-- +2.43.0 + diff --git a/queue-6.6/kbuild-make-ld-version.sh-more-robust-against-versio.patch b/queue-6.6/kbuild-make-ld-version.sh-more-robust-against-versio.patch new file mode 100644 index 00000000000..9c156c8a266 --- /dev/null +++ b/queue-6.6/kbuild-make-ld-version.sh-more-robust-against-versio.patch @@ -0,0 +1,73 @@ +From 4ff7ba1653afb1a8233bab0687acb07487fed7ea Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 7 Jul 2024 22:06:47 -0700 +Subject: kbuild: Make ld-version.sh more robust against version string changes + +From: Nathan Chancellor + +[ Upstream commit 9852f47ac7c993990317570ff125e30ad901e213 ] + +After [1] in upstream LLVM, ld.lld's version output became slightly +different when the cmake configuration option LLVM_APPEND_VC_REV is +disabled. + +Before: + + Debian LLD 19.0.0 (compatible with GNU linkers) + +After: + + Debian LLD 19.0.0, compatible with GNU linkers + +This results in ld-version.sh failing with + + scripts/ld-version.sh: 18: arithmetic expression: expecting EOF: "10000 * 19 + 100 * 0 + 0," + +because the trailing comma is included in the patch level part of the +expression. While [1] has been partially reverted in [2] to avoid this +breakage (as it impacts the configuration stage and it is present in all +LTS branches), it would be good to make ld-version.sh more robust +against such miniscule changes like this one. + +Use POSIX shell parameter expansion [3] to remove the largest suffix +after just numbers and periods, replacing of the current removal of +everything after a hyphen. ld-version.sh continues to work for a number +of distributions (Arch Linux, Debian, and Fedora) and the kernel.org +toolchains and no longer errors on a version of ld.lld with [1]. + +Fixes: 02aff8592204 ("kbuild: check the minimum linker version in Kconfig") +Link: https://github.com/llvm/llvm-project/commit/0f9fbbb63cfcd2069441aa2ebef622c9716f8dbb [1] +Link: https://github.com/llvm/llvm-project/commit/649cdfc4b6781a350dfc87d9b2a4b5a4c3395909 [2] +Link: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html [3] +Suggested-by: Fangrui Song +Reviewed-by: Fangrui Song +Signed-off-by: Nathan Chancellor +Reviewed-by: Nicolas Schier +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + scripts/ld-version.sh | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh +index a78b804b680cf..b9513d224476f 100755 +--- a/scripts/ld-version.sh ++++ b/scripts/ld-version.sh +@@ -57,9 +57,11 @@ else + fi + fi + +-# Some distributions append a package release number, as in 2.34-4.fc32 +-# Trim the hyphen and any characters that follow. +-version=${version%-*} ++# There may be something after the version, such as a distribution's package ++# release number (like Fedora's "2.34-4.fc32") or punctuation (like LLD briefly ++# added before the "compatible with GNU linkers" string), so remove everything ++# after just numbers and periods. ++version=${version%%[!0-9.]*} + + cversion=$(get_canonical_version $version) + min_cversion=$(get_canonical_version $min_version) +-- +2.43.0 + diff --git a/queue-6.6/series b/queue-6.6/series index bbf186e4a32..208a3f79fa0 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -106,3 +106,14 @@ selftests-net-fix-gro.c-compilation-failure-due-to-non-existent-opt_ipproto_off. nilfs2-fix-kernel-bug-on-rename-operation-of-broken-directory.patch ext4-avoid-ptr-null-pointer-dereference.patch sched-move-psi_account_irqtime-out-of-update_rq_clock_task-hotpath.patch +i2c-rcar-bring-hardware-to-known-state-when-probing.patch +i2c-mark-hostnotify-target-address-as-used.patch +i2c-rcar-reset-controller-is-mandatory-for-gen3.patch +i2c-rcar-introduce-gen4-devices.patch +i2c-rcar-ensure-gen3-reset-does-not-disturb-local-ta.patch +i2c-testunit-avoid-re-issued-work-after-read-message.patch +i2c-rcar-clear-no_rxdma-flag-after-resetting.patch +x86-entry-rename-ignore_sysret.patch +x86-entry-64-remove-obsolete-comment-on-tracing-vs.-.patch +x86-bhi-avoid-warning-in-db-handler-due-to-bhi-mitig.patch +kbuild-make-ld-version.sh-more-robust-against-versio.patch diff --git a/queue-6.6/x86-bhi-avoid-warning-in-db-handler-due-to-bhi-mitig.patch b/queue-6.6/x86-bhi-avoid-warning-in-db-handler-due-to-bhi-mitig.patch new file mode 100644 index 00000000000..7e9176237a7 --- /dev/null +++ b/queue-6.6/x86-bhi-avoid-warning-in-db-handler-due-to-bhi-mitig.patch @@ -0,0 +1,106 @@ +From 0fb43e036b2c97caeec4da28848c7a61949142da Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 24 May 2024 09:04:59 +0200 +Subject: x86/bhi: Avoid warning in #DB handler due to BHI mitigation + +From: Alexandre Chartre + +[ Upstream commit ac8b270b61d48fcc61f052097777e3b5e11591e0 ] + +When BHI mitigation is enabled, if SYSENTER is invoked with the TF flag set +then entry_SYSENTER_compat() uses CLEAR_BRANCH_HISTORY and calls the +clear_bhb_loop() before the TF flag is cleared. This causes the #DB handler +(exc_debug_kernel()) to issue a warning because single-step is used outside the +entry_SYSENTER_compat() function. + +To address this issue, entry_SYSENTER_compat() should use CLEAR_BRANCH_HISTORY +after making sure the TF flag is cleared. + +The problem can be reproduced with the following sequence: + + $ cat sysenter_step.c + int main() + { asm("pushf; pop %ax; bts $8,%ax; push %ax; popf; sysenter"); } + + $ gcc -o sysenter_step sysenter_step.c + + $ ./sysenter_step + Segmentation fault (core dumped) + +The program is expected to crash, and the #DB handler will issue a warning. + +Kernel log: + + WARNING: CPU: 27 PID: 7000 at arch/x86/kernel/traps.c:1009 exc_debug_kernel+0xd2/0x160 + ... + RIP: 0010:exc_debug_kernel+0xd2/0x160 + ... + Call Trace: + <#DB> + ? show_regs+0x68/0x80 + ? __warn+0x8c/0x140 + ? exc_debug_kernel+0xd2/0x160 + ? report_bug+0x175/0x1a0 + ? handle_bug+0x44/0x90 + ? exc_invalid_op+0x1c/0x70 + ? asm_exc_invalid_op+0x1f/0x30 + ? exc_debug_kernel+0xd2/0x160 + exc_debug+0x43/0x50 + asm_exc_debug+0x1e/0x40 + RIP: 0010:clear_bhb_loop+0x0/0xb0 + ... + + + ? entry_SYSENTER_compat_after_hwframe+0x6e/0x8d + + + [ bp: Massage commit message. ] + +Fixes: 7390db8aea0d ("x86/bhi: Add support for clearing branch history at syscall entry") +Reported-by: Suman Maity +Signed-off-by: Alexandre Chartre +Signed-off-by: Borislav Petkov (AMD) +Reviewed-by: Andrew Cooper +Reviewed-by: Pawan Gupta +Reviewed-by: Josh Poimboeuf +Link: https://lore.kernel.org/r/20240524070459.3674025-1-alexandre.chartre@oracle.com +Signed-off-by: Sasha Levin +--- + arch/x86/entry/entry_64_compat.S | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S +index 4c1dfc51c56e4..ebfccadf918cb 100644 +--- a/arch/x86/entry/entry_64_compat.S ++++ b/arch/x86/entry/entry_64_compat.S +@@ -90,10 +90,6 @@ SYM_INNER_LABEL(entry_SYSENTER_compat_after_hwframe, SYM_L_GLOBAL) + + cld + +- IBRS_ENTER +- UNTRAIN_RET +- CLEAR_BRANCH_HISTORY +- + /* + * SYSENTER doesn't filter flags, so we need to clear NT and AC + * ourselves. To save a few cycles, we can check whether +@@ -117,6 +113,16 @@ SYM_INNER_LABEL(entry_SYSENTER_compat_after_hwframe, SYM_L_GLOBAL) + jnz .Lsysenter_fix_flags + .Lsysenter_flags_fixed: + ++ /* ++ * CPU bugs mitigations mechanisms can call other functions. They ++ * should be invoked after making sure TF is cleared because ++ * single-step is ignored only for instructions inside the ++ * entry_SYSENTER_compat function. ++ */ ++ IBRS_ENTER ++ UNTRAIN_RET ++ CLEAR_BRANCH_HISTORY ++ + movq %rsp, %rdi + call do_SYSENTER_32 + /* XEN PV guests always use IRET path */ +-- +2.43.0 + diff --git a/queue-6.6/x86-entry-64-remove-obsolete-comment-on-tracing-vs.-.patch b/queue-6.6/x86-entry-64-remove-obsolete-comment-on-tracing-vs.-.patch new file mode 100644 index 00000000000..be8d9a3d479 --- /dev/null +++ b/queue-6.6/x86-entry-64-remove-obsolete-comment-on-tracing-vs.-.patch @@ -0,0 +1,65 @@ +From 45825ebb3151a3384ac2fc408fc66b1b57f5325b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 21 Jul 2023 12:10:12 -0400 +Subject: x86/entry/64: Remove obsolete comment on tracing vs. SYSRET + +From: Brian Gerst + +[ Upstream commit eb43c9b1517b48e2ff0d3a584aca197338987d7b ] + +This comment comes from a time when the kernel attempted to use SYSRET +on all returns to userspace, including interrupts and exceptions. Ever +since commit fffbb5dc ("Move opportunistic sysret code to syscall code +path"), SYSRET is only used for returning from system calls. The +specific tracing issue listed in this comment is not possible anymore. + +Signed-off-by: Brian Gerst +Signed-off-by: Ingo Molnar +Cc: Andy Lutomirski +Cc: Brian Gerst +Cc: Denys Vlasenko +Cc: H. Peter Anvin +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Cc: Josh Poimboeuf +Link: https://lore.kernel.org/r/20230721161018.50214-2-brgerst@gmail.com +Stable-dep-of: ac8b270b61d4 ("x86/bhi: Avoid warning in #DB handler due to BHI mitigation") +Signed-off-by: Sasha Levin +--- + arch/x86/entry/entry_64.S | 19 +++---------------- + 1 file changed, 3 insertions(+), 16 deletions(-) + +diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S +index 1edb8e1b9e018..2192b6c33ea00 100644 +--- a/arch/x86/entry/entry_64.S ++++ b/arch/x86/entry/entry_64.S +@@ -167,22 +167,9 @@ SYM_INNER_LABEL(entry_SYSCALL_64_after_hwframe, SYM_L_GLOBAL) + jne swapgs_restore_regs_and_return_to_usermode + + /* +- * SYSCALL clears RF when it saves RFLAGS in R11 and SYSRET cannot +- * restore RF properly. If the slowpath sets it for whatever reason, we +- * need to restore it correctly. +- * +- * SYSRET can restore TF, but unlike IRET, restoring TF results in a +- * trap from userspace immediately after SYSRET. This would cause an +- * infinite loop whenever #DB happens with register state that satisfies +- * the opportunistic SYSRET conditions. For example, single-stepping +- * this user code: +- * +- * movq $stuck_here, %rcx +- * pushfq +- * popq %r11 +- * stuck_here: +- * +- * would never get past 'stuck_here'. ++ * SYSRET cannot restore RF. It can restore TF, but unlike IRET, ++ * restoring TF results in a trap from userspace immediately after ++ * SYSRET. + */ + testq $(X86_EFLAGS_RF|X86_EFLAGS_TF), %r11 + jnz swapgs_restore_regs_and_return_to_usermode +-- +2.43.0 + diff --git a/queue-6.6/x86-entry-rename-ignore_sysret.patch b/queue-6.6/x86-entry-rename-ignore_sysret.patch new file mode 100644 index 00000000000..b5c0e478a0b --- /dev/null +++ b/queue-6.6/x86-entry-rename-ignore_sysret.patch @@ -0,0 +1,76 @@ +From 4e3e44c814f8b51231553e96ba2600f27c27b254 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 23 Jun 2023 14:14:05 +0300 +Subject: x86/entry: Rename ignore_sysret() + +From: Nikolay Borisov + +[ Upstream commit f71e1d2ff8e6a183bd4004bc97c453ba527b7dc6 ] + +The SYSCALL instruction cannot really be disabled in compatibility mode. +The best that can be done is to configure the CSTAR msr to point to a +minimal handler. Currently this handler has a rather misleading name - +ignore_sysret() as it's not really doing anything with sysret. + +Give it a more descriptive name. + +Signed-off-by: Nikolay Borisov +Signed-off-by: Thomas Gleixner +Link: https://lore.kernel.org/r/20230623111409.3047467-3-nik.borisov@suse.com +Stable-dep-of: ac8b270b61d4 ("x86/bhi: Avoid warning in #DB handler due to BHI mitigation") +Signed-off-by: Sasha Levin +--- + arch/x86/entry/entry_64.S | 4 ++-- + arch/x86/include/asm/processor.h | 2 +- + arch/x86/kernel/cpu/common.c | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S +index 5d96561c0d6ad..1edb8e1b9e018 100644 +--- a/arch/x86/entry/entry_64.S ++++ b/arch/x86/entry/entry_64.S +@@ -1527,13 +1527,13 @@ SYM_CODE_END(asm_exc_nmi) + * This handles SYSCALL from 32-bit code. There is no way to program + * MSRs to fully disable 32-bit SYSCALL. + */ +-SYM_CODE_START(ignore_sysret) ++SYM_CODE_START(entry_SYSCALL32_ignore) + UNWIND_HINT_END_OF_STACK + ENDBR + mov $-ENOSYS, %eax + CLEAR_CPU_BUFFERS + sysretl +-SYM_CODE_END(ignore_sysret) ++SYM_CODE_END(entry_SYSCALL32_ignore) + #endif + + .pushsection .text, "ax" +diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h +index 6e19d0f226000..67ad64efa9263 100644 +--- a/arch/x86/include/asm/processor.h ++++ b/arch/x86/include/asm/processor.h +@@ -399,7 +399,7 @@ static inline unsigned long cpu_kernelmode_gs_base(int cpu) + return (unsigned long)per_cpu(fixed_percpu_data.gs_base, cpu); + } + +-extern asmlinkage void ignore_sysret(void); ++extern asmlinkage void entry_SYSCALL32_ignore(void); + + /* Save actual FS/GS selectors and bases to current->thread */ + void current_save_fsgs(void); +diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c +index 340dd6cc11af4..74d566263467e 100644 +--- a/arch/x86/kernel/cpu/common.c ++++ b/arch/x86/kernel/cpu/common.c +@@ -2134,7 +2134,7 @@ void syscall_init(void) + (unsigned long)(cpu_entry_stack(smp_processor_id()) + 1)); + wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat); + #else +- wrmsrl_cstar((unsigned long)ignore_sysret); ++ wrmsrl_cstar((unsigned long)entry_SYSCALL32_ignore); + wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)GDT_ENTRY_INVALID_SEG); + wrmsrl_safe(MSR_IA32_SYSENTER_ESP, 0ULL); + wrmsrl_safe(MSR_IA32_SYSENTER_EIP, 0ULL); +-- +2.43.0 +