]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Apr 2023 07:06:24 +0000 (09:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Apr 2023 07:06:24 +0000 (09:06 +0200)
added patches:
net-sfp-initialize-sfp-i2c_block_size-at-sfp-allocation.patch
riscv-add-icache-flush-for-nommu-sigreturn-trampoline.patch

queue-5.10/net-sfp-initialize-sfp-i2c_block_size-at-sfp-allocation.patch [new file with mode: 0644]
queue-5.10/riscv-add-icache-flush-for-nommu-sigreturn-trampoline.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/net-sfp-initialize-sfp-i2c_block_size-at-sfp-allocation.patch b/queue-5.10/net-sfp-initialize-sfp-i2c_block_size-at-sfp-allocation.patch
new file mode 100644 (file)
index 0000000..35be4e3
--- /dev/null
@@ -0,0 +1,78 @@
+From 813c2dd78618f108fdcf9cd726ea90f081ee2881 Mon Sep 17 00:00:00 2001
+From: Ivan Bornyakov <i.bornyakov@metrotek.ru>
+Date: Thu, 6 Apr 2023 16:08:32 +0300
+Subject: net: sfp: initialize sfp->i2c_block_size at sfp allocation
+
+From: Ivan Bornyakov <i.bornyakov@metrotek.ru>
+
+commit 813c2dd78618f108fdcf9cd726ea90f081ee2881 upstream.
+
+sfp->i2c_block_size is initialized at SFP module insertion in
+sfp_sm_mod_probe(). Because of that, if SFP module was never inserted
+since boot, sfp_read() call will lead to zero-length I2C read attempt,
+and not all I2C controllers are happy with zero-length reads.
+
+One way to issue sfp_read() on empty SFP cage is to execute ethtool -m.
+If SFP module was never plugged since boot, there will be a zero-length
+I2C read attempt.
+
+  # ethtool -m xge0
+  i2c i2c-3: adapter quirk: no zero length (addr 0x0050, size 0, read)
+  Cannot get Module EEPROM data: Operation not supported
+
+If SFP module was plugged then removed at least once,
+sfp->i2c_block_size will be initialized and ethtool -m will fail with
+different exit code and without I2C error
+
+  # ethtool -m xge0
+  Cannot get Module EEPROM data: Remote I/O error
+
+Fix this by initializing sfp->i2_block_size at struct sfp allocation
+stage so no wild sfp_read() could issue zero-length I2C read.
+
+Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>
+Fixes: 0d035bed2a4a ("net: sfp: VSOL V2801F / CarlitoxxPro CPGOS03-0490 v2.0 workaround")
+Cc: stable@vger.kernel.org
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/phy/sfp.c |   13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/phy/sfp.c
++++ b/drivers/net/phy/sfp.c
+@@ -207,6 +207,12 @@ static const enum gpiod_flags gpio_flags
+  */
+ #define SFP_PHY_ADDR  22
++/* SFP_EEPROM_BLOCK_SIZE is the size of data chunk to read the EEPROM
++ * at a time. Some SFP modules and also some Linux I2C drivers do not like
++ * reads longer than 16 bytes.
++ */
++#define SFP_EEPROM_BLOCK_SIZE 16
++
+ struct sff_data {
+       unsigned int gpios;
+       bool (*module_supported)(const struct sfp_eeprom_id *id);
+@@ -1754,11 +1760,7 @@ static int sfp_sm_mod_probe(struct sfp *
+       u8 check;
+       int ret;
+-      /* Some SFP modules and also some Linux I2C drivers do not like reads
+-       * longer than 16 bytes, so read the EEPROM in chunks of 16 bytes at
+-       * a time.
+-       */
+-      sfp->i2c_block_size = 16;
++      sfp->i2c_block_size = SFP_EEPROM_BLOCK_SIZE;
+       ret = sfp_read(sfp, false, 0, &id.base, sizeof(id.base));
+       if (ret < 0) {
+@@ -2385,6 +2387,7 @@ static struct sfp *sfp_alloc(struct devi
+               return ERR_PTR(-ENOMEM);
+       sfp->dev = dev;
++      sfp->i2c_block_size = SFP_EEPROM_BLOCK_SIZE;
+       mutex_init(&sfp->sm_mutex);
+       mutex_init(&sfp->st_mutex);
diff --git a/queue-5.10/riscv-add-icache-flush-for-nommu-sigreturn-trampoline.patch b/queue-5.10/riscv-add-icache-flush-for-nommu-sigreturn-trampoline.patch
new file mode 100644 (file)
index 0000000..7b34f57
--- /dev/null
@@ -0,0 +1,58 @@
+From 8d736482749f6d350892ef83a7a11d43cd49981e Mon Sep 17 00:00:00 2001
+From: Mathis Salmen <mathis.salmen@matsal.de>
+Date: Thu, 6 Apr 2023 12:11:31 +0200
+Subject: riscv: add icache flush for nommu sigreturn trampoline
+
+From: Mathis Salmen <mathis.salmen@matsal.de>
+
+commit 8d736482749f6d350892ef83a7a11d43cd49981e upstream.
+
+In a NOMMU kernel, sigreturn trampolines are generated on the user
+stack by setup_rt_frame. Currently, these trampolines are not instruction
+fenced, thus their visibility to ifetch is not guaranteed.
+
+This patch adds a flush_icache_range in setup_rt_frame to fix this
+problem.
+
+Signed-off-by: Mathis Salmen <mathis.salmen@matsal.de>
+Fixes: 6bd33e1ece52 ("riscv: add nommu support")
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20230406101130.82304-1-mathis.salmen@matsal.de
+Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/riscv/kernel/signal.c |    9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+--- a/arch/riscv/kernel/signal.c
++++ b/arch/riscv/kernel/signal.c
+@@ -16,6 +16,7 @@
+ #include <asm/vdso.h>
+ #include <asm/switch_to.h>
+ #include <asm/csr.h>
++#include <asm/cacheflush.h>
+ extern u32 __user_rt_sigreturn[2];
+@@ -178,6 +179,7 @@ static int setup_rt_frame(struct ksignal
+ {
+       struct rt_sigframe __user *frame;
+       long err = 0;
++      unsigned long __maybe_unused addr;
+       frame = get_sigframe(ksig, regs, sizeof(*frame));
+       if (!access_ok(frame, sizeof(*frame)))
+@@ -206,7 +208,12 @@ static int setup_rt_frame(struct ksignal
+       if (copy_to_user(&frame->sigreturn_code, __user_rt_sigreturn,
+                        sizeof(frame->sigreturn_code)))
+               return -EFAULT;
+-      regs->ra = (unsigned long)&frame->sigreturn_code;
++
++      addr = (unsigned long)&frame->sigreturn_code;
++      /* Make sure the two instructions are pushed to icache. */
++      flush_icache_range(addr, addr + sizeof(frame->sigreturn_code));
++
++      regs->ra = addr;
+ #endif /* CONFIG_MMU */
+       /*
index eafa2bf292adb012164fce2a0d2a4a0282491480..3addc46a84571cb0a3bc558b997ec218c2745b83 100644 (file)
@@ -90,3 +90,5 @@ efi-sysfb_efi-add-quirk-for-lenovo-yoga-book-x91f-l.patch
 drm-panel-orientation-quirks-add-quirk-for-lenovo-yo.patch
 verify_pefile-relax-wrapper-length-check.patch
 asymmetric_keys-log-on-fatal-failures-in-pe-pkcs7.patch
+riscv-add-icache-flush-for-nommu-sigreturn-trampoline.patch
+net-sfp-initialize-sfp-i2c_block_size-at-sfp-allocation.patch