From: Greg Kroah-Hartman Date: Mon, 15 Aug 2022 11:00:58 +0000 (+0200) Subject: 5.19-stable patches X-Git-Tag: v5.15.61~86 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c1e104de571fb824a855f623b8c0afc2010d717b;p=thirdparty%2Fkernel%2Fstable-queue.git 5.19-stable patches added patches: powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.patch powerpc64-ftrace-fix-ftrace-for-clang-builds.patch xen-blkback-apply-feature_persistent-parameter-when-connect.patch xen-blkback-fix-persistent-grants-negotiation.patch xen-blkfront-apply-feature_persistent-parameter-when-connect.patch --- diff --git a/queue-5.19/powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.patch b/queue-5.19/powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.patch new file mode 100644 index 00000000000..11ada289cb0 --- /dev/null +++ b/queue-5.19/powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.patch @@ -0,0 +1,101 @@ +From 18db466a9a306406dab3b134014d9f6ed642471c Mon Sep 17 00:00:00 2001 +From: Christophe Leroy +Date: Tue, 2 Aug 2022 11:02:36 +0200 +Subject: powerpc: Fix eh field when calling lwarx on PPC32 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Christophe Leroy + +commit 18db466a9a306406dab3b134014d9f6ed642471c upstream. + +Commit 9401f4e46cf6 ("powerpc: Use lwarx/ldarx directly instead of +PPC_LWARX/LDARX macros") properly handled the eh field of lwarx +in asm/bitops.h but failed to clear it for PPC32 in +asm/simple_spinlock.h + +So, do as in arch_atomic_try_cmpxchg_lock(), set it to 1 if PPC64 +but set it to 0 if PPC32. For that use IS_ENABLED(CONFIG_PPC64) which +returns 1 when CONFIG_PPC64 is set and 0 otherwise. + +Fixes: 9401f4e46cf6 ("powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX macros") +Cc: stable@vger.kernel.org # v5.15+ +Reported-by: Pali Rohár +Signed-off-by: Christophe Leroy +Tested-by: Pali Rohár +Reviewed-by: Segher Boessenkool +[mpe: Use symbolic names, use 'n' constraint per Segher] +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/a1176e19e627dd6a1b8d24c6c457a8ab874b7d12.1659430931.git.christophe.leroy@csgroup.eu +Signed-off-by: Greg Kroah-Hartman +--- + arch/powerpc/include/asm/simple_spinlock.h | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +--- a/arch/powerpc/include/asm/simple_spinlock.h ++++ b/arch/powerpc/include/asm/simple_spinlock.h +@@ -48,10 +48,11 @@ static inline int arch_spin_is_locked(ar + static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock) + { + unsigned long tmp, token; ++ unsigned int eh = IS_ENABLED(CONFIG_PPC64); + + token = LOCK_TOKEN; + __asm__ __volatile__( +-"1: lwarx %0,0,%2,1\n\ ++"1: lwarx %0,0,%2,%[eh]\n\ + cmpwi 0,%0,0\n\ + bne- 2f\n\ + stwcx. %1,0,%2\n\ +@@ -59,7 +60,7 @@ static inline unsigned long __arch_spin_ + PPC_ACQUIRE_BARRIER + "2:" + : "=&r" (tmp) +- : "r" (token), "r" (&lock->slock) ++ : "r" (token), "r" (&lock->slock), [eh] "n" (eh) + : "cr0", "memory"); + + return tmp; +@@ -156,9 +157,10 @@ static inline void arch_spin_unlock(arch + static inline long __arch_read_trylock(arch_rwlock_t *rw) + { + long tmp; ++ unsigned int eh = IS_ENABLED(CONFIG_PPC64); + + __asm__ __volatile__( +-"1: lwarx %0,0,%1,1\n" ++"1: lwarx %0,0,%1,%[eh]\n" + __DO_SIGN_EXTEND + " addic. %0,%0,1\n\ + ble- 2f\n" +@@ -166,7 +168,7 @@ static inline long __arch_read_trylock(a + bne- 1b\n" + PPC_ACQUIRE_BARRIER + "2:" : "=&r" (tmp) +- : "r" (&rw->lock) ++ : "r" (&rw->lock), [eh] "n" (eh) + : "cr0", "xer", "memory"); + + return tmp; +@@ -179,17 +181,18 @@ static inline long __arch_read_trylock(a + static inline long __arch_write_trylock(arch_rwlock_t *rw) + { + long tmp, token; ++ unsigned int eh = IS_ENABLED(CONFIG_PPC64); + + token = WRLOCK_TOKEN; + __asm__ __volatile__( +-"1: lwarx %0,0,%2,1\n\ ++"1: lwarx %0,0,%2,%[eh]\n\ + cmpwi 0,%0,0\n\ + bne- 2f\n" + " stwcx. %1,0,%2\n\ + bne- 1b\n" + PPC_ACQUIRE_BARRIER + "2:" : "=&r" (tmp) +- : "r" (token), "r" (&rw->lock) ++ : "r" (token), "r" (&rw->lock), [eh] "n" (eh) + : "cr0", "memory"); + + return tmp; diff --git a/queue-5.19/powerpc64-ftrace-fix-ftrace-for-clang-builds.patch b/queue-5.19/powerpc64-ftrace-fix-ftrace-for-clang-builds.patch new file mode 100644 index 00000000000..ae535ed45db --- /dev/null +++ b/queue-5.19/powerpc64-ftrace-fix-ftrace-for-clang-builds.patch @@ -0,0 +1,54 @@ +From cb928ac192128c842f4c1cfc8b6780b95719d65f Mon Sep 17 00:00:00 2001 +From: "Naveen N. Rao" +Date: Tue, 9 Aug 2022 15:29:07 +0530 +Subject: powerpc64/ftrace: Fix ftrace for clang builds + +From: Naveen N. Rao + +commit cb928ac192128c842f4c1cfc8b6780b95719d65f upstream. + +Clang doesn't support -mprofile-kernel ABI, so guard the checks against +CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version. + +Fixes: 23b44fc248f4 ("powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64") +Cc: stable@vger.kernel.org # v5.19+ +Reported-by: Nick Desaulniers +Reported-by: Ondrej Mosnacek +Signed-off-by: Naveen N. Rao +Tested-by: Ondrej Mosnacek +Acked-by: Nick Desaulniers +Signed-off-by: Michael Ellerman +Link: https://github.com/llvm/llvm-project/issues/57031 +Link: https://github.com/ClangBuiltLinux/linux/issues/1682 +Link: https://lore.kernel.org/r/20220809095907.418764-1-naveen.n.rao@linux.vnet.ibm.com +Signed-off-by: Greg Kroah-Hartman +--- + arch/powerpc/kernel/trace/ftrace.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/arch/powerpc/kernel/trace/ftrace.c ++++ b/arch/powerpc/kernel/trace/ftrace.c +@@ -392,11 +392,11 @@ int ftrace_make_nop(struct module *mod, + */ + static bool expected_nop_sequence(void *ip, ppc_inst_t op0, ppc_inst_t op1) + { +- if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1)) ++ if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS)) ++ return ppc_inst_equal(op0, ppc_inst(PPC_RAW_NOP())); ++ else + return ppc_inst_equal(op0, ppc_inst(PPC_RAW_BRANCH(8))) && + ppc_inst_equal(op1, ppc_inst(PPC_INST_LD_TOC)); +- else +- return ppc_inst_equal(op0, ppc_inst(PPC_RAW_NOP())); + } + + static int +@@ -411,7 +411,7 @@ __ftrace_make_call(struct dyn_ftrace *re + if (copy_inst_from_kernel_nofault(op, ip)) + return -EFAULT; + +- if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1) && ++ if (!IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS) && + copy_inst_from_kernel_nofault(op + 1, ip + 4)) + return -EFAULT; + diff --git a/queue-5.19/series b/queue-5.19/series index 7db3dcc5e62..aa7132176bc 100644 --- a/queue-5.19/series +++ b/queue-5.19/series @@ -1131,3 +1131,8 @@ ext4-fix-race-when-reusing-xattr-blocks.patch keys-asymmetric-enforce-sm2-signature-use-pkey-algo.patch tpm-eventlog-fix-section-mismatch-for-debug_section_.patch tpm-add-check-for-failure-mode-for-tpm2-modules.patch +xen-blkback-fix-persistent-grants-negotiation.patch +xen-blkback-apply-feature_persistent-parameter-when-connect.patch +xen-blkfront-apply-feature_persistent-parameter-when-connect.patch +powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.patch +powerpc64-ftrace-fix-ftrace-for-clang-builds.patch diff --git a/queue-5.19/xen-blkback-apply-feature_persistent-parameter-when-connect.patch b/queue-5.19/xen-blkback-apply-feature_persistent-parameter-when-connect.patch new file mode 100644 index 00000000000..3de9479df08 --- /dev/null +++ b/queue-5.19/xen-blkback-apply-feature_persistent-parameter-when-connect.patch @@ -0,0 +1,77 @@ +From e94c6101e151b019b8babc518ac2a6ada644a5a1 Mon Sep 17 00:00:00 2001 +From: Maximilian Heyne +Date: Fri, 15 Jul 2022 22:51:07 +0000 +Subject: xen-blkback: Apply 'feature_persistent' parameter when connect + +From: Maximilian Heyne + +commit e94c6101e151b019b8babc518ac2a6ada644a5a1 upstream. + +In some use cases[1], the backend is created while the frontend doesn't +support the persistent grants feature, but later the frontend can be +changed to support the feature and reconnect. In the past, 'blkback' +enabled the persistent grants feature since it unconditionally checked +if frontend supports the persistent grants feature for every connect +('connect_ring()') and decided whether it should use persistent grans or +not. + +However, commit aac8a70db24b ("xen-blkback: add a parameter for +disabling of persistent grants") has mistakenly changed the behavior. +It made the frontend feature support check to not be repeated once it +shown the 'feature_persistent' as 'false', or the frontend doesn't +support persistent grants. + +This commit changes the behavior of the parameter to make effect for +every connect, so that the previous workflow can work again as expected. + +[1] https://lore.kernel.org/xen-devel/CAJwUmVB6H3iTs-C+U=v-pwJB7-_ZRHPxHzKRJZ22xEPW7z8a=g@mail.gmail.com/ + +Reported-by: Andrii Chepurnyi +Fixes: aac8a70db24b ("xen-blkback: add a parameter for disabling of persistent grants") +Cc: # 5.10.x +Signed-off-by: Maximilian Heyne +Signed-off-by: SeongJae Park +Reviewed-by: Maximilian Heyne +Reviewed-by: Juergen Gross +Link: https://lore.kernel.org/r/20220715225108.193398-3-sj@kernel.org +Signed-off-by: Juergen Gross +Signed-off-by: Greg Kroah-Hartman +--- + Documentation/ABI/testing/sysfs-driver-xen-blkback | 2 +- + drivers/block/xen-blkback/xenbus.c | 9 +++------ + 2 files changed, 4 insertions(+), 7 deletions(-) + +--- a/Documentation/ABI/testing/sysfs-driver-xen-blkback ++++ b/Documentation/ABI/testing/sysfs-driver-xen-blkback +@@ -42,5 +42,5 @@ KernelVersion: 5.10 + Contact: Maximilian Heyne + Description: + Whether to enable the persistent grants feature or not. Note +- that this option only takes effect on newly created backends. ++ that this option only takes effect on newly connected backends. + The default is Y (enable). +--- a/drivers/block/xen-blkback/xenbus.c ++++ b/drivers/block/xen-blkback/xenbus.c +@@ -186,8 +186,6 @@ static struct xen_blkif *xen_blkif_alloc + __module_get(THIS_MODULE); + INIT_WORK(&blkif->free_work, xen_blkif_deferred_free); + +- blkif->vbd.feature_gnt_persistent = feature_persistent; +- + return blkif; + } + +@@ -1086,10 +1084,9 @@ static int connect_ring(struct backend_i + xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol); + return -ENOSYS; + } +- if (blkif->vbd.feature_gnt_persistent) +- blkif->vbd.feature_gnt_persistent = +- xenbus_read_unsigned(dev->otherend, +- "feature-persistent", 0); ++ ++ blkif->vbd.feature_gnt_persistent = feature_persistent && ++ xenbus_read_unsigned(dev->otherend, "feature-persistent", 0); + + blkif->vbd.overflow_max_grants = 0; + diff --git a/queue-5.19/xen-blkback-fix-persistent-grants-negotiation.patch b/queue-5.19/xen-blkback-fix-persistent-grants-negotiation.patch new file mode 100644 index 00000000000..3bc7b8f398c --- /dev/null +++ b/queue-5.19/xen-blkback-fix-persistent-grants-negotiation.patch @@ -0,0 +1,90 @@ +From fc9be616bb8f3ed9cf560308f86904f5c06be205 Mon Sep 17 00:00:00 2001 +From: SeongJae Park +Date: Fri, 15 Jul 2022 22:51:06 +0000 +Subject: xen-blkback: fix persistent grants negotiation + +From: SeongJae Park + +commit fc9be616bb8f3ed9cf560308f86904f5c06be205 upstream. + +Persistent grants feature can be used only when both backend and the +frontend supports the feature. The feature was always supported by +'blkback', but commit aac8a70db24b ("xen-blkback: add a parameter for +disabling of persistent grants") has introduced a parameter for +disabling it runtime. + +To avoid the parameter be updated while being used by 'blkback', the +commit caches the parameter into 'vbd->feature_gnt_persistent' in +'xen_vbd_create()', and then check if the guest also supports the +feature and finally updates the field in 'connect_ring()'. + +However, 'connect_ring()' could be called before 'xen_vbd_create()', so +later execution of 'xen_vbd_create()' can wrongly overwrite 'true' to +'vbd->feature_gnt_persistent'. As a result, 'blkback' could try to use +'persistent grants' feature even if the guest doesn't support the +feature. + +This commit fixes the issue by moving the parameter value caching to +'xen_blkif_alloc()', which allocates the 'blkif'. Because the struct +embeds 'vbd' object, which will be used by 'connect_ring()' later, this +should be called before 'connect_ring()' and therefore this should be +the right and safe place to do the caching. + +Fixes: aac8a70db24b ("xen-blkback: add a parameter for disabling of persistent grants") +Cc: # 5.10.x +Signed-off-by: Maximilian Heyne +Signed-off-by: SeongJae Park +Reviewed-by: Maximilian Heyne +Reviewed-by: Juergen Gross +Link: https://lore.kernel.org/r/20220715225108.193398-2-sj@kernel.org +Signed-off-by: Juergen Gross +Signed-off-by: Greg Kroah-Hartman +--- + drivers/block/xen-blkback/xenbus.c | 15 +++++++-------- + 1 file changed, 7 insertions(+), 8 deletions(-) + +--- a/drivers/block/xen-blkback/xenbus.c ++++ b/drivers/block/xen-blkback/xenbus.c +@@ -157,6 +157,11 @@ static int xen_blkif_alloc_rings(struct + return 0; + } + ++/* Enable the persistent grants feature. */ ++static bool feature_persistent = true; ++module_param(feature_persistent, bool, 0644); ++MODULE_PARM_DESC(feature_persistent, "Enables the persistent grants feature"); ++ + static struct xen_blkif *xen_blkif_alloc(domid_t domid) + { + struct xen_blkif *blkif; +@@ -181,6 +186,8 @@ static struct xen_blkif *xen_blkif_alloc + __module_get(THIS_MODULE); + INIT_WORK(&blkif->free_work, xen_blkif_deferred_free); + ++ blkif->vbd.feature_gnt_persistent = feature_persistent; ++ + return blkif; + } + +@@ -472,12 +479,6 @@ static void xen_vbd_free(struct xen_vbd + vbd->bdev = NULL; + } + +-/* Enable the persistent grants feature. */ +-static bool feature_persistent = true; +-module_param(feature_persistent, bool, 0644); +-MODULE_PARM_DESC(feature_persistent, +- "Enables the persistent grants feature"); +- + static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle, + unsigned major, unsigned minor, int readonly, + int cdrom) +@@ -520,8 +521,6 @@ static int xen_vbd_create(struct xen_blk + if (bdev_max_secure_erase_sectors(bdev)) + vbd->discard_secure = true; + +- vbd->feature_gnt_persistent = feature_persistent; +- + pr_debug("Successful creation of handle=%04x (dom=%u)\n", + handle, blkif->domid); + return 0; diff --git a/queue-5.19/xen-blkfront-apply-feature_persistent-parameter-when-connect.patch b/queue-5.19/xen-blkfront-apply-feature_persistent-parameter-when-connect.patch new file mode 100644 index 00000000000..ab24d826aff --- /dev/null +++ b/queue-5.19/xen-blkfront-apply-feature_persistent-parameter-when-connect.patch @@ -0,0 +1,73 @@ +From 402c43ea6b34a1b371ffeed9adf907402569eaf5 Mon Sep 17 00:00:00 2001 +From: SeongJae Park +Date: Fri, 15 Jul 2022 22:51:08 +0000 +Subject: xen-blkfront: Apply 'feature_persistent' parameter when connect + +From: SeongJae Park + +commit 402c43ea6b34a1b371ffeed9adf907402569eaf5 upstream. + +In some use cases[1], the backend is created while the frontend doesn't +support the persistent grants feature, but later the frontend can be +changed to support the feature and reconnect. In the past, 'blkback' +enabled the persistent grants feature since it unconditionally checked +if frontend supports the persistent grants feature for every connect +('connect_ring()') and decided whether it should use persistent grans or +not. + +However, commit aac8a70db24b ("xen-blkback: add a parameter for +disabling of persistent grants") has mistakenly changed the behavior. +It made the frontend feature support check to not be repeated once it +shown the 'feature_persistent' as 'false', or the frontend doesn't +support persistent grants. + +Similar behavioral change has made on 'blkfront' by commit 74a852479c68 +("xen-blkfront: add a parameter for disabling of persistent grants"). +This commit changes the behavior of the parameter to make effect for +every connect, so that the previous behavior of 'blkfront' can be +restored. + +[1] https://lore.kernel.org/xen-devel/CAJwUmVB6H3iTs-C+U=v-pwJB7-_ZRHPxHzKRJZ22xEPW7z8a=g@mail.gmail.com/ + +Fixes: 74a852479c68 ("xen-blkfront: add a parameter for disabling of persistent grants") +Cc: # 5.10.x +Signed-off-by: SeongJae Park +Reviewed-by: Maximilian Heyne +Reviewed-by: Juergen Gross +Link: https://lore.kernel.org/r/20220715225108.193398-4-sj@kernel.org +Signed-off-by: Juergen Gross +Signed-off-by: Greg Kroah-Hartman +--- + Documentation/ABI/testing/sysfs-driver-xen-blkfront | 2 +- + drivers/block/xen-blkfront.c | 4 +--- + 2 files changed, 2 insertions(+), 4 deletions(-) + +--- a/Documentation/ABI/testing/sysfs-driver-xen-blkfront ++++ b/Documentation/ABI/testing/sysfs-driver-xen-blkfront +@@ -15,5 +15,5 @@ KernelVersion: 5.10 + Contact: Maximilian Heyne + Description: + Whether to enable the persistent grants feature or not. Note +- that this option only takes effect on newly created frontends. ++ that this option only takes effect on newly connected frontends. + The default is Y (enable). +--- a/drivers/block/xen-blkfront.c ++++ b/drivers/block/xen-blkfront.c +@@ -1988,8 +1988,6 @@ static int blkfront_probe(struct xenbus_ + info->vdevice = vdevice; + info->connected = BLKIF_STATE_DISCONNECTED; + +- info->feature_persistent = feature_persistent; +- + /* Front end dir is a number, which is used as the id. */ + info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0); + dev_set_drvdata(&dev->dev, info); +@@ -2283,7 +2281,7 @@ static void blkfront_gather_backend_feat + if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0)) + blkfront_setup_discard(info); + +- if (info->feature_persistent) ++ if (feature_persistent) + info->feature_persistent = + !!xenbus_read_unsigned(info->xbdev->otherend, + "feature-persistent", 0);