From 3fcd8c262336fbf2e311b78436f20bb7580222e6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 15 Aug 2022 13:00:41 +0200 Subject: [PATCH] 5.15-stable patches added patches: powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.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 --- ...eh-field-when-calling-lwarx-on-ppc32.patch | 101 ++++++++++++++++++ queue-5.15/series | 4 + ...re_persistent-parameter-when-connect.patch | 77 +++++++++++++ ...ck-fix-persistent-grants-negotiation.patch | 90 ++++++++++++++++ ...re_persistent-parameter-when-connect.patch | 73 +++++++++++++ 5 files changed, 345 insertions(+) create mode 100644 queue-5.15/powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.patch create mode 100644 queue-5.15/xen-blkback-apply-feature_persistent-parameter-when-connect.patch create mode 100644 queue-5.15/xen-blkback-fix-persistent-grants-negotiation.patch create mode 100644 queue-5.15/xen-blkfront-apply-feature_persistent-parameter-when-connect.patch diff --git a/queue-5.15/powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.patch b/queue-5.15/powerpc-fix-eh-field-when-calling-lwarx-on-ppc32.patch new file mode 100644 index 00000000000..800b0ac9822 --- /dev/null +++ b/queue-5.15/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; +@@ -177,9 +178,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" +@@ -187,7 +189,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; +@@ -200,17 +202,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.15/series b/queue-5.15/series index 4e3d6f628cc..3a85d470671 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -755,3 +755,7 @@ ext4-unindent-codeblock-in-ext4_xattr_block_set.patch 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 +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 diff --git a/queue-5.15/xen-blkback-apply-feature_persistent-parameter-when-connect.patch b/queue-5.15/xen-blkback-apply-feature_persistent-parameter-when-connect.patch new file mode 100644 index 00000000000..ac1f0f9e26e --- /dev/null +++ b/queue-5.15/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: SeongJae Park + 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 +@@ -185,8 +185,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; + } + +@@ -1089,10 +1087,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.15/xen-blkback-fix-persistent-grants-negotiation.patch b/queue-5.15/xen-blkback-fix-persistent-grants-negotiation.patch new file mode 100644 index 00000000000..e09b5cf90a5 --- /dev/null +++ b/queue-5.15/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 +@@ -156,6 +156,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; +@@ -180,6 +185,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; + } + +@@ -471,12 +478,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) +@@ -522,8 +523,6 @@ static int xen_vbd_create(struct xen_blk + if (q && blk_queue_secure_erase(q)) + 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.15/xen-blkfront-apply-feature_persistent-parameter-when-connect.patch b/queue-5.15/xen-blkfront-apply-feature_persistent-parameter-when-connect.patch new file mode 100644 index 00000000000..6fa114fc6d6 --- /dev/null +++ b/queue-5.15/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: SeongJae Park + 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 +@@ -2014,8 +2014,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); +@@ -2309,7 +2307,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); -- 2.47.3