From: Greg Kroah-Hartman Date: Mon, 17 Apr 2023 07:06:24 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.14.313~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07787c53dc2c1c57934733c92079426ecef31b42;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: net-sfp-initialize-sfp-i2c_block_size-at-sfp-allocation.patch riscv-add-icache-flush-for-nommu-sigreturn-trampoline.patch --- 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 index 00000000000..35be4e3660e --- /dev/null +++ b/queue-5.10/net-sfp-initialize-sfp-i2c_block_size-at-sfp-allocation.patch @@ -0,0 +1,78 @@ +From 813c2dd78618f108fdcf9cd726ea90f081ee2881 Mon Sep 17 00:00:00 2001 +From: Ivan Bornyakov +Date: Thu, 6 Apr 2023 16:08:32 +0300 +Subject: net: sfp: initialize sfp->i2c_block_size at sfp allocation + +From: Ivan Bornyakov + +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 +Fixes: 0d035bed2a4a ("net: sfp: VSOL V2801F / CarlitoxxPro CPGOS03-0490 v2.0 workaround") +Cc: stable@vger.kernel.org +Reviewed-by: Andrew Lunn +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..7b34f570410 --- /dev/null +++ b/queue-5.10/riscv-add-icache-flush-for-nommu-sigreturn-trampoline.patch @@ -0,0 +1,58 @@ +From 8d736482749f6d350892ef83a7a11d43cd49981e Mon Sep 17 00:00:00 2001 +From: Mathis Salmen +Date: Thu, 6 Apr 2023 12:11:31 +0200 +Subject: riscv: add icache flush for nommu sigreturn trampoline + +From: Mathis Salmen + +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 +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 +Signed-off-by: Greg Kroah-Hartman +--- + 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 + #include + #include ++#include + + 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 */ + + /* diff --git a/queue-5.10/series b/queue-5.10/series index eafa2bf292a..3addc46a845 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -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