6.6.24-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 276/396 xfs: remove conditional building of rt geometry validator functions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Darrick J. Wong" <[email protected]>
commit 881f78f472556ed05588172d5b5676b48dc48240 upstream.
[backport: resolve merge conflicts due to refactoring rtbitmap/summary macros and accessors]
I mistakenly turned off CONFIG_XFS_RT in the Kconfig file for arm64 variant of the djwong-wtf git branch. Unfortunately, it took me a good hour to figure out that RT wasn't built because this is what got printed to dmesg:
XFS (sda2): realtime geometry sanity check failed
XFS (sda2): Metadata corruption detected at xfs_sb_read_verify+0x170/0x190 [xfs], xfs_sb block 0x0
Whereas I would have expected:
XFS (sda2): Not built with CONFIG_XFS_RT
XFS (sda2): RT mount failed
The root cause of these problems is the conditional compilation of the new functions xfs_validate_rtextents and xfs_compute_rextslog that I introduced in the two commits listed below. The !RT versions of these functions return false and 0, respectively, which causes primary superblock validation to fail, which explains the first message.
Move the two functions to other parts of libxfs that are not conditionally defined by CONFIG_XFS_RT and remove the broken stubs so that validation works again.
--- fs/xfs/libxfs/xfs_rtbitmap.c | 14 -------------- fs/xfs/libxfs/xfs_rtbitmap.h | 16 ---------------- fs/xfs/libxfs/xfs_sb.c | 14 ++++++++++++++ fs/xfs/libxfs/xfs_sb.h | 2 ++ fs/xfs/libxfs/xfs_types.h | 12 ++++++++++++ fs/xfs/scrub/rtbitmap.c | 1 + fs/xfs/scrub/rtsummary.c | 1 + 7 files changed, 30 insertions(+), 30 deletions(-)
fs/xfs/libxfs/xfs_rtbitmap.c +0 -14
@@ -1131,17 +1131,3 @@ xfs_rtalloc_extent_is_free(return 0 ; } -/* -* Compute the maximum level number of the realtime summary file, as defined by -* mkfs. The historic use of highbit32 on a 64-bit quantity prohibited correct -* use of rt volumes with more than 2^32 extents. -*/ -uint8_t -xfs_compute_rextslog ( -xfs_rtbxlen_t rtextents) -{ -if (!rtextents) -return 0 ; -return xfs_highbit64 (rtextents); -} -
fs/xfs/libxfs/xfs_rtbitmap.h +0 -16
@@ -71,20 +71,6 @@ xfs_rtfree_extent(int xfs_rtfree_blocks (struct xfs_trans *tp,xfs_fsblock_t rtbno,xfs_filblks_t rtlen); -uint8_t xfs_compute_rextslog (xfs_rtbxlen_t rtextents); - -/* Do we support an rt volume having this number of rtextents? */ -static inline bool -xfs_validate_rtextents ( -xfs_rtbxlen_t rtextents) -{ -/* No runt rt volumes */ -if (rtextents ==0 ) -return false; - -return true; -} -#else /* CONFIG_XFS_RT */ # define xfs_rtfree_extent (t,b,l) (-ENOSYS)# define xfs_rtfree_blocks (t,rb,rl) (-ENOSYS)
@@ -92,8 +78,6 @@ xfs_validate_rtextents(# define xfs_rtalloc_query_all (m,t,f,p) (-ENOSYS)# define xfs_rtbuf_get (m,t,b,i,p) (-ENOSYS)# define xfs_rtalloc_extent_is_free (m,t,s,l,i) (-ENOSYS) -# define xfs_compute_rextslog (rtx) (0) -# define xfs_validate_rtextents (rtx) (false)#endif /* CONFIG_XFS_RT */ #endif /* __XFS_RTBITMAP_H__ */
fs/xfs/libxfs/xfs_sb.c +14 -0
@@ -1375,3 +1375,17 @@ xfs_validate_stripe_geometry( }return true; } + +/* +* Compute the maximum level number of the realtime summary file, as defined by +* mkfs. The historic use of highbit32 on a 64-bit quantity prohibited correct +* use of rt volumes with more than 2^32 extents. +*/ +uint8_t +xfs_compute_rextslog ( +xfs_rtbxlen_t rtextents) +{ +if (!rtextents) +return 0 ; +return xfs_highbit64 (rtextents); +}
fs/xfs/libxfs/xfs_sb.h +2 -0
@@ -38,4 +38,6 @@ extern int xfs_sb_get_secondary(struct xextern bool xfs_validate_stripe_geometry (struct xfs_mount *mp,__s64 sunit,__s64 swidth,int sectorsize,bool silent); +uint8_t xfs_compute_rextslog (xfs_rtbxlen_t rtextents); +#endif /* __XFS_SB_H__ */
fs/xfs/libxfs/xfs_types.h +12 -0
@@ -240,4 +240,16 @@ bool xfs_verify_fileoff(struct xfs_mountbool xfs_verify_fileext (struct xfs_mount *mp,xfs_fileoff_t off,xfs_fileoff_t len); +/* Do we support an rt volume having this number of rtextents? */ +static inline bool +xfs_validate_rtextents ( +xfs_rtbxlen_t rtextents) +{ +/* No runt rt volumes */ +if (rtextents ==0 ) +return false; + +return true; +} +#endif /* __XFS_TYPES_H__ */
fs/xfs/scrub/rtbitmap.c +1 -0
@@ -14,6 +14,7 @@#include "xfs_rtbitmap.h" #include "xfs_inode.h" #include "xfs_bmap.h" +#include "xfs_sb.h" #include "scrub/scrub.h" #include "scrub/common.h"
fs/xfs/scrub/rtsummary.c +1 -0
@@ -16,6 +16,7 @@#include "xfs_rtbitmap.h" #include "xfs_bit.h" #include "xfs_bmap.h" +#include "xfs_sb.h" #include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/trace.h"
Greg Kroah-Hartman
maintainerPATCH 277/396 btrfs: fix deadlock with fiemap and extent locking
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit b0ad381fa7690244802aed119b478b4bdafc31dd upstream.
While working on the patchset to remove extent locking I got a lockdep splat with fiemap and pagefaulting with my new extent lock replacement lock.
This deadlock exists with our normal code, we just don't have lockdep annotations with the extent locking so we've never noticed it.
Since we're copying the fiemap extent to user space on every iteration we have the chance of pagefaulting. Because we hold the extent lock for the entire range we could mkwrite into a range in the file that we have mmap'ed. This would deadlock with the following stack trace
[<0>] lock_extent+0x28d/0x2f0 [<0>] btrfs_page_mkwrite+0x273/0x8a0 [<0>] do_page_mkwrite+0x50/0xb0 [<0>] do_fault+0xc1/0x7b0 [<0>] __handle_mm_fault+0x2fa/0x460 [<0>] handle_mm_fault+0xa4/0x330 [<0>] do_user_addr_fault+0x1f4/0x800 [<0>] exc_page_fault+0x7c/0x1e0 [<0>] asm_exc_page_fault+0x26/0x30 [<0>] rep_movs_alternative+0x33/0x70 [<0>] _copy_to_user+0x49/0x70 [<0>] fiemap_fill_next_extent+0xc8/0x120 [<0>] emit_fiemap_extent+0x4d/0xa0 [<0>] extent_fiemap+0x7f8/0xad0 [<0>] btrfs_fiemap+0x49/0x80 [<0>] __x64_sys_ioctl+0x3e1/0xb50 [<0>] do_syscall_64+0x94/0x1a0 [<0>] entry_SYSCALL_64_after_hwframe+0x6e/0x76
I wrote an fstest to reproduce this deadlock without my replacement lock and verified that the deadlock exists with our existing locking.
To fix this simply don't take the extent lock for the entire duration of the fiemap. This is safe in general because we keep track of where we are when we're searching the tree, so if an ordered extent updates in the middle of our fiemap call we'll still emit the correct extents because we know what offset we were on before.
The only place we maintain the lock is searching delalloc. Since the delalloc stuff can change during writeback we want to lock the extent range so we have a consistent view of delalloc at the time we're checking to see if we need to set the delalloc flag.
With this patch applied we no longer deadlock with my testcase.
--- fs/btrfs/extent_io.c | 62 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 17 deletions(-)
fs/btrfs/extent_io.c +45 -17
@@ -2735,16 +2735,34 @@ static int fiemap_process_hole(struct bt* it beyond i_size. */ while (cur_offset < end && cur_offset < i_size) { +struct extent_state *cached_state =NULL ;u64 delalloc_start;u64 delalloc_end;u64 prealloc_start; +u64 lockstart; +u64 lockend;u64 prealloc_len =0 ;bool delalloc; + lockstart =round_down (cur_offset, inode->root->fs_info->sectorsize); + lockend =round_up (end, inode->root->fs_info->sectorsize); + +/* +* We are only locking for the delalloc range because that's the +* only thing that can change here. With fiemap we have a lock +* on the inode, so no buffered or direct writes can happen. +* +* However mmaps and normal page writeback will cause this to +* change arbitrarily. We have to lock the extent lock here to +* make sure that nobody messes with the tree while we're doing +* btrfs_find_delalloc_in_range. +*/ +lock_extent (&inode->io_tree, lockstart, lockend, &cached_state); delalloc =btrfs_find_delalloc_in_range (inode, cur_offset, end, delalloc_cached_state, &delalloc_start, &delalloc_end); +unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);if (!delalloc)break ;
@@ -2912,15 +2930,15 @@ int extent_fiemap(struct btrfs_inode *in u64 start, u64 len) {const u64 ino =btrfs_ino (inode); -struct extent_state *cached_state =NULL ;struct extent_state *delalloc_cached_state =NULL ;struct btrfs_path *path;struct fiemap_cache cache = {0 };struct btrfs_backref_share_check_ctx *backref_ctx;u64 last_extent_end;u64 prev_extent_end; -u64 lockstart; -u64 lockend; +u64 range_start; +u64 range_end; +const u64 sectorsize = inode->root->fs_info->sectorsize;bool stopped = false;int ret;
@@ -2931,12 +2949,11 @@ int extent_fiemap(struct btrfs_inode *in goto out; } - lockstart =round_down (start, inode->root->fs_info->sectorsize); - lockend =round_up (start + len, inode->root->fs_info->sectorsize); - prev_extent_end = lockstart; + range_start =round_down (start, sectorsize); + range_end =round_up (start + len, sectorsize); + prev_extent_end = range_start;btrfs_inode_lock (inode,BTRFS_ILOCK_SHARED ); -lock_extent (&inode->io_tree, lockstart, lockend, &cached_state); ret =fiemap_find_last_extent_offset (inode, path, &last_extent_end);if (ret <0 )
@@ -2944,7 +2961,7 @@ int extent_fiemap(struct btrfs_inode *inbtrfs_release_path (path); path->reada =READA_FORWARD ; - ret =fiemap_search_slot (inode, path, lockstart); + ret =fiemap_search_slot (inode, path, range_start);if (ret <0 ) { goto out_unlock; }else if (ret >0 ) {
@@ -2956,7 +2973,7 @@ int extent_fiemap(struct btrfs_inode *in goto check_eof_delalloc; } -while (prev_extent_end < lockend) { +while (prev_extent_end < range_end) {struct extent_buffer *leaf = path->nodes[0 ];struct btrfs_file_extent_item *ei;struct btrfs_key key;
@@ -2979,19 +2996,19 @@ int extent_fiemap(struct btrfs_inode *in* The first iteration can leave us at an extent item that ends * before our range's start. Move to the next item. */ -if (extent_end <= lockstart) +if (extent_end <= range_start) goto next_item; backref_ctx->curr_leaf_bytenr = leaf->start;/* We have in implicit hole (NO_HOLES feature enabled). */ if (prev_extent_end < key.offset) { -const u64 range_end =min (key.offset, lockend) -1 ; +const u64 hole_end =min (key.offset, range_end) -1 ; ret =fiemap_process_hole (inode, fieinfo, &cache, &delalloc_cached_state, backref_ctx,0 ,0 ,0 , - prev_extent_end, range_end); + prev_extent_end, hole_end);if (ret <0 ) { goto out_unlock; }else if (ret >0 ) {
@@ -3001,7 +3018,7 @@ int extent_fiemap(struct btrfs_inode *in }/* We've reached the end of the fiemap range, stop. */ -if (key.offset >= lockend) { +if (key.offset >= range_end) { stopped = true;break ; }
@@ -3095,29 +3112,41 @@ check_eof_delalloc:btrfs_free_path (path); path =NULL ; -if (!stopped && prev_extent_end < lockend) { +if (!stopped && prev_extent_end < range_end) { ret =fiemap_process_hole (inode, fieinfo, &cache, &delalloc_cached_state, backref_ctx, -0 ,0 ,0 , prev_extent_end, lockend -1 ); +0 ,0 ,0 , prev_extent_end, range_end -1 );if (ret <0 ) goto out_unlock; - prev_extent_end = lockend; + prev_extent_end = range_end; }if (cache.cached && cache.offset + cache.len >= last_extent_end) {const u64 i_size =i_size_read (&inode->vfs_inode);if (prev_extent_end < i_size) { +struct extent_state *cached_state =NULL ;u64 delalloc_start;u64 delalloc_end; +u64 lockstart; +u64 lockend;bool delalloc; + lockstart =round_down (prev_extent_end, sectorsize); + lockend =round_up (i_size, sectorsize); + +/* +* See the comment in fiemap_process_hole as to why +* we're doing the locking here. +*/ +lock_extent (&inode->io_tree, lockstart, lockend, &cached_state); delalloc =btrfs_find_delalloc_in_range (inode, prev_extent_end, i_size -1 , &delalloc_cached_state, &delalloc_start, &delalloc_end); +unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);if (!delalloc) cache.flags |=FIEMAP_EXTENT_LAST ; }else {
@@ -3128,7 +3157,6 @@ check_eof_delalloc: ret =emit_last_fiemap_cache (fieinfo, &cache); out_unlock: -unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);btrfs_inode_unlock (inode,BTRFS_ILOCK_SHARED ); out:free_extent_state (delalloc_cached_state);
Greg Kroah-Hartman
maintainerPATCH 278/396 vfio: Introduce interface to flush virqfd inject workqueue
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit b620ecbd17a03cacd06f014a5d3f3a11285ce053 upstream.
In order to synchronize changes that can affect the thread callback, introduce an interface to force a flush of the inject workqueue. The irqfd pointer is only valid under spinlock, but the workqueue cannot be flushed under spinlock. Therefore the flush work for the irqfd is queued under spinlock. The vfio_irqfd_cleanup_wq workqueue is re-used for queuing this work such that flushing the workqueue is also ordered relative to shutdown.
Stable-dep-of: 18c198c96a81 ("vfio/pci: Create persistent INTx handler")
--- drivers/vfio/virqfd.c | 21 +++++++++++++++++++++ include/linux/vfio.h | 2 ++ 2 files changed, 23 insertions(+)
drivers/vfio/virqfd.c +21 -0
@@ -101,6 +101,13 @@ static void virqfd_inject(struct work_st virqfd->thread (virqfd->opaque, virqfd->data); } +static void virqfd_flush_inject (struct work_struct *work) +{ + struct virqfd *virqfd = container_of(work, struct virqfd, flush_inject); + +flush_work (&virqfd->inject); +} + int vfio_virqfd_enable(void *opaque, int (*handler)(void *, void *), void (*thread)(void *, void *),
@@ -124,6 +131,7 @@ int vfio_virqfd_enable(void *opaque,INIT_WORK (&virqfd->shutdown, virqfd_shutdown);INIT_WORK (&virqfd->inject, virqfd_inject); +INIT_WORK (&virqfd->flush_inject, virqfd_flush_inject); irqfd =fdget (fd);if (!irqfd.file) {
@@ -213,3 +221,16 @@ void vfio_virqfd_disable(struct virqfd *flush_workqueue (vfio_irqfd_cleanup_wq); }EXPORT_SYMBOL_GPL (vfio_virqfd_disable); + +void vfio_virqfd_flush_thread (struct virqfd **pvirqfd) +{ +unsigned long flags; + +spin_lock_irqsave (&virqfd_lock, flags); +if (*pvirqfd && (*pvirqfd)->thread) +queue_work (vfio_irqfd_cleanup_wq, &(*pvirqfd)->flush_inject); +spin_unlock_irqrestore (&virqfd_lock, flags); + +flush_workqueue (vfio_irqfd_cleanup_wq); +} +EXPORT_SYMBOL_GPL (vfio_virqfd_flush_thread);
include/linux/vfio.h +2 -0
@@ -349,6 +349,7 @@ struct virqfd {wait_queue_entry_t wait;poll_table pt;struct work_struct shutdown; +struct work_struct flush_inject;struct virqfd **pvirqfd; };
@@ -356,5 +357,6 @@ int vfio_virqfd_enable(void *opaque, int void (*thread)(void *, void *), void *data, struct virqfd **pvirqfd, int fd);void vfio_virqfd_disable (struct virqfd **pvirqfd); +void vfio_virqfd_flush_thread (struct virqfd **pvirqfd);#endif /* VFIO_H */
Greg Kroah-Hartman
maintainerPATCH 279/396 vfio/pci: Create persistent INTx handler
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit 18c198c96a815c962adc2b9b77909eec0be7df4d upstream.
A vulnerability exists where the eventfd for INTx signaling can be deconfigured, which unregisters the IRQ handler but still allows eventfds to be signaled with a NULL context through the SET_IRQS ioctl or through unmask irqfd if the device interrupt is pending.
Ideally this could be solved with some additional locking; the igate mutex serializes the ioctl and config space accesses, and the interrupt handler is unregistered relative to the trigger, but the irqfd path runs asynchronous to those. The igate mutex cannot be acquired from the atomic context of the eventfd wake function. Disabling the irqfd relative to the eventfd registration is potentially incompatible with existing userspace.
As a result, the solution implemented here moves configuration of the INTx interrupt handler to track the lifetime of the INTx context object and irq_type configuration, rather than registration of a particular trigger eventfd. Synchronization is added between the ioctl path and eventfd_signal() wrapper such that the eventfd trigger can be dynamically updated relative to in-flight interrupts or irqfd callbacks.
--- drivers/vfio/pci/vfio_pci_intrs.c | 145 ++++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 67 deletions(-)
drivers/vfio/pci/vfio_pci_intrs.c +78 -67
@@ -90,11 +90,15 @@ static void vfio_send_intx_eventfd(voidif (likely (is_intx (vdev) && !vdev->virq_disabled)) {struct vfio_pci_irq_ctx *ctx; +struct eventfd_ctx *trigger; ctx =vfio_irq_ctx_get (vdev,0 );if (WARN_ON_ONCE (!ctx))return ; -eventfd_signal (ctx->trigger,1 ); + + trigger =READ_ONCE (ctx->trigger); +if (likely (trigger)) +eventfd_signal (trigger,1 ); } }
@@ -253,100 +257,100 @@ static irqreturn_t vfio_intx_handler(intreturn ret; } -static int vfio_intx_enable (struct vfio_pci_core_device *vdev) +static int vfio_intx_enable (struct vfio_pci_core_device *vdev, +struct eventfd_ctx *trigger) { +struct pci_dev *pdev = vdev->pdev;struct vfio_pci_irq_ctx *ctx; +unsigned long irqflags; +char *name; +int ret;if (!is_irq_none (vdev))return -EINVAL ; -if (!vdev->pdev->irq) +if (!pdev->irq)return -ENODEV ; + name =kasprintf (GFP_KERNEL_ACCOUNT ,"vfio-intx(%s)" ,pci_name (pdev)); +if (!name) +return -ENOMEM ; + ctx =vfio_irq_ctx_alloc (vdev,0 );if (!ctx)return -ENOMEM ; + ctx->name = name; + ctx->trigger = trigger; +/* -* If the virtual interrupt is masked, restore it. Devices -* supporting DisINTx can be masked at the hardware level -* here, non-PCI-2.3 devices will have to wait until the -* interrupt is enabled. +* Fill the initial masked state based on virq_disabled. After +* enable, changing the DisINTx bit in vconfig directly changes INTx +* masking. igate prevents races during setup, once running masked +* is protected via irqlock. +* +* Devices supporting DisINTx also reflect the current mask state in +* the physical DisINTx bit, which is not affected during IRQ setup. +* +* Devices without DisINTx support require an exclusive interrupt. +* IRQ masking is performed at the IRQ chip. Again, igate protects +* against races during setup and IRQ handlers and irqfds are not +* yet active, therefore masked is stable and can be used to +* conditionally auto-enable the IRQ. +* +* irq_type must be stable while the IRQ handler is registered, +* therefore it must be set before request_irq(). */ ctx->masked = vdev->virq_disabled; -if (vdev->pci_2_3) -pci_intx (vdev->pdev, !ctx->masked); +if (vdev->pci_2_3) { +pci_intx (pdev, !ctx->masked); + irqflags =IRQF_SHARED ; + }else { + irqflags = ctx->masked ?IRQF_NO_AUTOEN :0 ; + } vdev->irq_type =VFIO_PCI_INTX_IRQ_INDEX ; + ret =request_irq (pdev->irq, vfio_intx_handler, + irqflags, ctx->name, vdev); +if (ret) { + vdev->irq_type =VFIO_PCI_NUM_IRQS ; +kfree (name); +vfio_irq_ctx_free (vdev, ctx,0 ); +return ret; + } +return 0 ; } -static int vfio_intx_set_signal (struct vfio_pci_core_device *vdev,int fd) +static int vfio_intx_set_signal (struct vfio_pci_core_device *vdev, +struct eventfd_ctx *trigger) {struct pci_dev *pdev = vdev->pdev; -unsigned long irqflags =IRQF_SHARED ;struct vfio_pci_irq_ctx *ctx; -struct eventfd_ctx *trigger; -unsigned long flags; -int ret; +struct eventfd_ctx *old; ctx =vfio_irq_ctx_get (vdev,0 );if (WARN_ON_ONCE (!ctx))return -EINVAL ; -if (ctx->trigger) { -free_irq (pdev->irq, vdev); -kfree (ctx->name); -eventfd_ctx_put (ctx->trigger); - ctx->trigger =NULL ; - } - -if (fd <0 )/* Disable only */ -return 0 ; + old = ctx->trigger; - ctx->name =kasprintf (GFP_KERNEL_ACCOUNT ,"vfio-intx(%s)" , -pci_name (pdev)); -if (!ctx->name) -return -ENOMEM ; +WRITE_ONCE (ctx->trigger, trigger); - trigger =eventfd_ctx_fdget (fd); -if (IS_ERR (trigger)) { -kfree (ctx->name); -return PTR_ERR (trigger); +/* Releasing an old ctx requires synchronizing in-flight users */ +if (old) { +synchronize_irq (pdev->irq); +vfio_virqfd_flush_thread (&ctx->unmask); +eventfd_ctx_put (old); } - ctx->trigger = trigger; - -/* -* Devices without DisINTx support require an exclusive interrupt, -* IRQ masking is performed at the IRQ chip. The masked status is -* protected by vdev->irqlock. Setup the IRQ without auto-enable and -* unmask as necessary below under lock. DisINTx is unmodified by -* the IRQ configuration and may therefore use auto-enable. -*/ -if (!vdev->pci_2_3) - irqflags =IRQF_NO_AUTOEN ; - - ret =request_irq (pdev->irq, vfio_intx_handler, - irqflags, ctx->name, vdev); -if (ret) { - ctx->trigger =NULL ; -kfree (ctx->name); -eventfd_ctx_put (trigger); -return ret; - } - -spin_lock_irqsave (&vdev->irqlock, flags); -if (!vdev->pci_2_3 && !ctx->masked) -enable_irq (pdev->irq); -spin_unlock_irqrestore (&vdev->irqlock, flags); -return 0 ; }static void vfio_intx_disable (struct vfio_pci_core_device *vdev) { +struct pci_dev *pdev = vdev->pdev;struct vfio_pci_irq_ctx *ctx; ctx =vfio_irq_ctx_get (vdev,0 );
@@ -354,10 +358,13 @@ static void vfio_intx_disable(struct vfiif (ctx) {vfio_virqfd_disable (&ctx->unmask);vfio_virqfd_disable (&ctx->mask); +free_irq (pdev->irq, vdev); +if (ctx->trigger) +eventfd_ctx_put (ctx->trigger); +kfree (ctx->name); +vfio_irq_ctx_free (vdev, ctx,0 ); } -vfio_intx_set_signal (vdev,-1 ); vdev->irq_type =VFIO_PCI_NUM_IRQS ; -vfio_irq_ctx_free (vdev, ctx,0 ); }/*
@@ -641,19 +648,23 @@ static int vfio_pci_set_intx_trigger(strreturn -EINVAL ;if (flags &VFIO_IRQ_SET_DATA_EVENTFD ) { +struct eventfd_ctx *trigger =NULL ;int32_t fd = *(int32_t *)data;int ret; +if (fd >=0 ) { + trigger =eventfd_ctx_fdget (fd); +if (IS_ERR (trigger)) +return PTR_ERR (trigger); + } +if (is_intx (vdev)) -return vfio_intx_set_signal (vdev, fd); + ret =vfio_intx_set_signal (vdev, trigger); +else + ret =vfio_intx_enable (vdev, trigger); - ret =vfio_intx_enable (vdev); -if (ret) -return ret; - - ret =vfio_intx_set_signal (vdev, fd); -if (ret) -vfio_intx_disable (vdev); +if (ret && trigger) +eventfd_ctx_put (trigger);return ret; }
Greg Kroah-Hartman
maintainerPATCH 280/396 vfio/platform: Create persistent IRQ handlers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit 675daf435e9f8e5a5eab140a9864dfad6668b375 upstream.
The vfio-platform SET_IRQS ioctl currently allows loopback triggering of an interrupt before a signaling eventfd has been configured by the user, which thereby allows a NULL pointer dereference.
Rather than register the IRQ relative to a valid trigger, register all IRQs in a disabled state in the device open path. This allows mask operations on the IRQ to nest within the overall enable state governed by a valid eventfd signal. This decouples @masked, protected by the @locked spinlock from @trigger, protected via the @igate mutex.
In doing so, it's guaranteed that changes to @trigger cannot race the IRQ handlers because the IRQ handler is synchronously disabled before modifying the trigger, and loopback triggering of the IRQ via ioctl is safe due to serialization with trigger changes via igate.
For compatibility, request_irq() failures are maintained to be local to the SET_IRQS ioctl rather than a fatal error in the open device path. This allows, for example, a userspace driver with polling mode support to continue to work regardless of moving the request_irq() call site. This necessarily blocks all SET_IRQS access to the failed index.
--- drivers/vfio/platform/vfio_platform_irq.c | 100 ++++++++++++++++++++---------- 1 file changed, 68 insertions(+), 32 deletions(-)
drivers/vfio/platform/vfio_platform_irq.c +68 -32
@@ -136,6 +136,16 @@ static int vfio_platform_set_irq_unmask(return 0 ; } +/* +* The trigger eventfd is guaranteed valid in the interrupt path +* and protected by the igate mutex when triggered via ioctl. +*/ +static void vfio_send_eventfd (struct vfio_platform_irq *irq_ctx) +{ +if (likely (irq_ctx->trigger)) +eventfd_signal (irq_ctx->trigger,1 ); +} +static irqreturn_t vfio_automasked_irq_handler (int irq,void *dev_id) {struct vfio_platform_irq *irq_ctx = dev_id;
@@ -155,7 +165,7 @@ static irqreturn_t vfio_automasked_irq_hspin_unlock_irqrestore (&irq_ctx->lock, flags);if (ret ==IRQ_HANDLED ) -eventfd_signal (irq_ctx->trigger,1 ); +vfio_send_eventfd (irq_ctx);return ret; }
@@ -164,52 +174,40 @@ static irqreturn_t vfio_irq_handler(int {struct vfio_platform_irq *irq_ctx = dev_id; -eventfd_signal (irq_ctx->trigger,1 ); +vfio_send_eventfd (irq_ctx);return IRQ_HANDLED ; }static int vfio_set_trigger (struct vfio_platform_device *vdev,int index, -int fd,irq_handler_t handler) +int fd) {struct vfio_platform_irq *irq = &vdev->irqs[index];struct eventfd_ctx *trigger; -int ret;if (irq->trigger) { -irq_clear_status_flags (irq->hwirq,IRQ_NOAUTOEN ); -free_irq (irq->hwirq, irq); -kfree (irq->name); +disable_irq (irq->hwirq);eventfd_ctx_put (irq->trigger); irq->trigger =NULL ; }if (fd <0 )/* Disable only */ return 0 ; - irq->name =kasprintf (GFP_KERNEL_ACCOUNT ,"vfio-irq[%d](%s)" , - irq->hwirq, vdev->name); -if (!irq->name) -return -ENOMEM ; trigger =eventfd_ctx_fdget (fd); -if (IS_ERR (trigger)) { -kfree (irq->name); +if (IS_ERR (trigger))return PTR_ERR (trigger); - } irq->trigger = trigger; -irq_set_status_flags (irq->hwirq,IRQ_NOAUTOEN ); - ret =request_irq (irq->hwirq, handler,0 , irq->name, irq); -if (ret) { -kfree (irq->name); -eventfd_ctx_put (trigger); - irq->trigger =NULL ; -return ret; - } - -if (!irq->masked) -enable_irq (irq->hwirq); +/* +* irq->masked effectively provides nested disables within the overall +* enable relative to trigger. Specifically request_irq() is called +* with NO_AUTOEN, therefore the IRQ is initially disabled. The user +* may only further disable the IRQ with a MASK operations because +* irq->masked is initially false. +*/ +enable_irq (irq->hwirq);return 0 ; }
@@ -228,7 +226,7 @@ static int vfio_platform_set_irq_trigger handler = vfio_irq_handler;if (!count && (flags &VFIO_IRQ_SET_DATA_NONE )) -return vfio_set_trigger (vdev, index,-1 , handler); +return vfio_set_trigger (vdev, index,-1 );if (start !=0 || count !=1 )return -EINVAL ;
@@ -236,7 +234,7 @@ static int vfio_platform_set_irq_triggerif (flags &VFIO_IRQ_SET_DATA_EVENTFD ) {int32_t fd = *(int32_t *)data; -return vfio_set_trigger (vdev, index, fd, handler); +return vfio_set_trigger (vdev, index, fd); }if (flags &VFIO_IRQ_SET_DATA_NONE ) {
@@ -260,6 +258,14 @@ int vfio_platform_set_irqs_ioctl(struct unsigned start, unsigned count, uint32_t flags, void *data) = NULL; +/* +* For compatibility, errors from request_irq() are local to the +* SET_IRQS path and reflected in the name pointer. This allows, +* for example, polling mode fallback for an exclusive IRQ failure. +*/ +if (IS_ERR (vdev->irqs[index].name)) +return PTR_ERR (vdev->irqs[index].name); +switch (flags &VFIO_IRQ_SET_ACTION_TYPE_MASK ) {case VFIO_IRQ_SET_ACTION_MASK : func = vfio_platform_set_irq_mask;
@@ -280,7 +286,7 @@ int vfio_platform_set_irqs_ioctl(structint vfio_platform_irq_init (struct vfio_platform_device *vdev) { -int cnt =0 , i; +int cnt =0 , i, ret =0 ;while (vdev->get_irq (vdev, cnt) >=0 ) cnt++;
@@ -292,29 +298,54 @@ int vfio_platform_irq_init(struct vfio_pfor (i =0 ; i < cnt; i++) {int hwirq = vdev->get_irq (vdev, i); +irq_handler_t handler = vfio_irq_handler; -if (hwirq <0 ) +if (hwirq <0 ) { + ret = -EINVAL ; goto err; + }spin_lock_init (&vdev->irqs[i].lock); vdev->irqs[i].flags =VFIO_IRQ_INFO_EVENTFD ; -if (irq_get_trigger_type (hwirq) &IRQ_TYPE_LEVEL_MASK ) +if (irq_get_trigger_type (hwirq) &IRQ_TYPE_LEVEL_MASK ) { vdev->irqs[i].flags |=VFIO_IRQ_INFO_MASKABLE |VFIO_IRQ_INFO_AUTOMASKED ; + handler = vfio_automasked_irq_handler; + } vdev->irqs[i].count =1 ; vdev->irqs[i].hwirq = hwirq; vdev->irqs[i].masked = false; + vdev->irqs[i].name =kasprintf (GFP_KERNEL_ACCOUNT , +"vfio-irq[%d](%s)" , hwirq, + vdev->name); +if (!vdev->irqs[i].name) { + ret = -ENOMEM ; + goto err; + } + + ret =request_irq (hwirq, handler,IRQF_NO_AUTOEN , + vdev->irqs[i].name, &vdev->irqs[i]); +if (ret) { +kfree (vdev->irqs[i].name); + vdev->irqs[i].name =ERR_PTR (ret); + } } vdev->num_irqs = cnt;return 0 ; err: +for (--i; i >=0 ; i--) { +if (!IS_ERR (vdev->irqs[i].name)) { +free_irq (vdev->irqs[i].hwirq, &vdev->irqs[i]); +kfree (vdev->irqs[i].name); + } + }kfree (vdev->irqs); -return -EINVAL ; +return ret; }void vfio_platform_irq_cleanup (struct vfio_platform_device *vdev)
@@ -324,7 +355,12 @@ void vfio_platform_irq_cleanup(struct vffor (i =0 ; i < vdev->num_irqs; i++) {vfio_virqfd_disable (&vdev->irqs[i].mask);vfio_virqfd_disable (&vdev->irqs[i].unmask); -vfio_set_trigger (vdev, i,-1 ,NULL ); +if (!IS_ERR (vdev->irqs[i].name)) { +free_irq (vdev->irqs[i].hwirq, &vdev->irqs[i]); +if (vdev->irqs[i].trigger) +eventfd_ctx_put (vdev->irqs[i].trigger); +kfree (vdev->irqs[i].name); + } } vdev->num_irqs =0 ;
Greg Kroah-Hartman
maintainerPATCH 281/396 vfio/fsl-mc: Block calling interrupt handler without trigger
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit 7447d911af699a15f8d050dfcb7c680a86f87012 upstream.
The eventfd_ctx trigger pointer of the vfio_fsl_mc_irq object is initially NULL and may become NULL if the user sets the trigger eventfd to -1. The interrupt handler itself is guaranteed that trigger is always valid between request_irq() and free_irq(), but the loopback testing mechanisms to invoke the handler function need to test the trigger. The triggering and setting ioctl paths both make use of igate and are therefore mutually exclusive.
The vfio-fsl-mc driver does not make use of irqfds, nor does it support any sort of masking operations, therefore unlike vfio-pci and vfio-platform, the flow can remain essentially unchanged.
--- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c +4 -3
@@ -141,13 +141,14 @@ static int vfio_fsl_mc_set_irq_trigger(s irq = &vdev->mc_irqs[index];if (flags &VFIO_IRQ_SET_DATA_NONE ) { -vfio_fsl_mc_irq_handler (hwirq, irq); +if (irq->trigger) +eventfd_signal (irq->trigger,1 ); }else if (flags &VFIO_IRQ_SET_DATA_BOOL ) {u8 trigger = *(u8 *)data; -if (trigger) -vfio_fsl_mc_irq_handler (hwirq, irq); +if (trigger && irq->trigger) +eventfd_signal (irq->trigger,1 ); }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 282/396 x86/Kconfig: Remove CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
commit 29956748339aa8757a7e2f927a8679dd08f24bb6 upstream.
It was meant well at the time but nothing's using it so get rid of it.
--- Documentation/admin-guide/kernel-parameters.txt | 4 +--- Documentation/arch/x86/amd-memory-encryption.rst | 16 ++++++++-------- arch/x86/Kconfig | 13 ------------- arch/x86/mm/mem_encrypt_identity.c | 11 +---------- 4 files changed, 10 insertions(+), 34 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -3
@@ -3269,9 +3269,7 @@ mem_encrypt= [X86-64] AMD Secure Memory Encryption (SME) control Valid arguments: on, off - Default (depends on kernel configuration option): - on (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) - off (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=n) + Default: off mem_encrypt=on: Activate SME mem_encrypt=off: Do not activate SME
Documentation/arch/x86/amd-memory-encryption.rst +8 -8
@@ -87,14 +87,14 @@ The state of SME in the Linux kernel can kernel is non-zero). SME can also be enabled and activated in the BIOS. If SME is enabled and -activated in the BIOS, then all memory accesses will be encrypted and it will -not be necessary to activate the Linux memory encryption support. If the BIOS -merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), then Linux can activate -memory encryption by default (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) or -by supplying mem_encrypt=on on the kernel command line. However, if BIOS does -not enable SME, then Linux will not be able to activate memory encryption, even -if configured to do so by default or the mem_encrypt=on command line parameter -is specified. +activated in the BIOS, then all memory accesses will be encrypted and it +will not be necessary to activate the Linux memory encryption support. + +If the BIOS merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), +then memory encryption can be enabled by supplying mem_encrypt=on on the +kernel command line. However, if BIOS does not enable SME, then Linux +will not be able to activate memory encryption, even if configured to do +so by default or the mem_encrypt=on command line parameter is specified. Secure Nested Paging (SNP) ==========================
arch/x86/Kconfig +0 -13
@@ -1514,19 +1514,6 @@ config AMD_MEM_ENCRYPT This requires an AMD processor that supports Secure Memory Encryption (SME). -config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT - bool "Activate AMD Secure Memory Encryption (SME) by default" - depends on AMD_MEM_ENCRYPT - help - Say yes to have system memory encrypted by default if running on - an AMD processor that supports Secure Memory Encryption (SME). - - If set to Y, then the encryption of system memory can be - deactivated with the mem_encrypt=off command line option. - - If set to N, then the encryption of system memory can be - activated with the mem_encrypt=on command line option. - # Common NUMA Features config NUMA bool "NUMA Memory Allocation and Scheduler Support"
arch/x86/mm/mem_encrypt_identity.c +1 -10
@@ -97,7 +97,6 @@ static char sme_workarea[2 * PMD_SIZE] _static char sme_cmdline_arg[]__initdata ="mem_encrypt" ;static char sme_cmdline_on[]__initdata ="on" ; -static char sme_cmdline_off[]__initdata ="off" ;static void __init sme_clear_pgd (struct sme_populate_pgd_data *ppd) {
@@ -504,7 +503,7 @@ void __init sme_encrypt_kernel(struct bovoid __init sme_enable (struct boot_params *bp) { -const char *cmdline_ptr, *cmdline_arg, *cmdline_on, *cmdline_off; +const char *cmdline_ptr, *cmdline_arg, *cmdline_on;unsigned int eax, ebx, ecx, edx;unsigned long feature_mask;unsigned long me_mask;
@@ -587,12 +586,6 @@ void __init sme_enable(struct boot_param asm ("lea sme_cmdline_on(%%rip), %0" :"=r" (cmdline_on) :"p" (sme_cmdline_on)); - asm ("lea sme_cmdline_off(%%rip), %0" - :"=r" (cmdline_off) - :"p" (sme_cmdline_off)); - -if (IS_ENABLED (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT )) - sme_me_mask = me_mask; cmdline_ptr = (const char *)((u64 )bp->hdr.cmd_line_ptr | ((u64 )bp->ext_cmd_line_ptr <<32 ));
@@ -602,8 +595,6 @@ void __init sme_enable(struct boot_paramif (!strncmp (buffer, cmdline_on,sizeof (buffer))) sme_me_mask = me_mask; -else if (!strncmp (buffer, cmdline_off,sizeof (buffer))) - sme_me_mask =0 ; out:if (sme_me_mask) {
Greg Kroah-Hartman
maintainerPATCH 283/396 x86/sev: Fix position dependent variable references in startup code
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 1c811d403afd73f04bde82b83b24c754011bd0e8 upstream.
The early startup code executes from a 1:1 mapping of memory, which differs from the mapping that the code was linked and/or relocated to run at. The latter mapping is not active yet at this point, and so symbol references that rely on it will fault.
Given that the core kernel is built without -fPIC, symbol references are typically emitted as absolute, and so any such references occuring in the early startup code will therefore crash the kernel.
While an attempt was made to work around this for the early SEV/SME startup code, by forcing RIP-relative addressing for certain global SEV/SME variables via inline assembly (see snp_cpuid_get_table() for example), RIP-relative addressing must be pervasively enforced for SEV/SME global variables when accessed prior to page table fixups.
__startup_64() already handles this issue for select non-SEV/SME global variables using fixup_pointer(), which adjusts the pointer relative to a physaddr argument. To avoid having to pass around this physaddr argument across all functions needing to apply pointer fixups, introduce a macro RIP_RELATIVE_REF() which generates a RIP-relative reference to a given global variable. It is used where necessary to force RIP-relative accesses to global variables.
For backporting purposes, this patch makes no attempt at cleaning up other occurrences of this pattern, involving either inline asm or fixup_pointer(). Those will be addressed later.
[ bp: Call it "rip_rel_ref" everywhere like other code shortens
"rIP-relative reference" and make the asm wrapper __always_inline. ]
--- arch/x86/coco/core.c | 7 +------ arch/x86/include/asm/asm.h | 14 ++++++++++++++ arch/x86/include/asm/coco.h | 8 +++++++- arch/x86/include/asm/mem_encrypt.h | 15 +++++++++------ arch/x86/kernel/sev-shared.c | 12 ++++++------ arch/x86/kernel/sev.c | 4 ++-- arch/x86/mm/mem_encrypt_identity.c | 27 ++++++++++++--------------- 7 files changed, 51 insertions(+), 36 deletions(-)
arch/x86/coco/core.c +1 -6
@@ -14,7 +14,7 @@#include <asm/processor.h> enum cc_vendor cc_vendor__ro_after_init =CC_VENDOR_NONE ; -static u64 cc_mask__ro_after_init ; +u64 cc_mask__ro_after_init ; static bool noinstr intel_cc_platform_has(enum cc_attr attr) {
@@ -148,8 +148,3 @@ u64 cc_mkdec(u64 val) } }EXPORT_SYMBOL_GPL (cc_mkdec); - -__init void cc_set_mask (u64 mask) -{ - cc_mask = mask; -}
arch/x86/include/asm/asm.h +14 -0
@@ -113,6 +113,20 @@#endif +#ifndef __ASSEMBLY__ +#ifndef __pic__ +static __always_inline __pure void *rip_rel_ptr(void *p) +{ + asm("leaq %c1(%%rip), %0" :"=r" (p) :"i" (p)); + +return p; +} +#define RIP_REL_REF (var) (*(typeof(&(var)))rip_rel_ptr(&(var))) +#else +#define RIP_REL_REF (var) (var) +#endif +#endif +/* * Macros to generate condition code outputs from inline assembly, * The output operand must be type "bool".
arch/x86/include/asm/coco.h +7 -1
@@ -2,6 +2,7 @@#ifndef _ASM_X86_COCO_H#define _ASM_X86_COCO_H +#include <asm/asm.h> #include <asm/types.h> enum cc_vendor {
@@ -11,9 +12,14 @@ enum cc_vendor { };extern enum cc_vendor cc_vendor; +extern u64 cc_mask;#ifdef CONFIG_ARCH_HAS_CC_PLATFORM -void cc_set_mask (u64 mask); +static inline void cc_set_mask (u64 mask) +{ +RIP_REL_REF (cc_mask) = mask; +} +u64 cc_mkenc (u64 val);u64 cc_mkdec (u64 val);#else
arch/x86/include/asm/mem_encrypt.h +9 -6
@@ -15,7 +15,8 @@#include <linux/init.h> #include <linux/cc_platform.h> -#include <asm/bootparam.h> +#include <asm/asm.h> +struct boot_params ;#ifdef CONFIG_X86_MEM_ENCRYPT void __init mem_encrypt_init (void );
@@ -57,6 +58,11 @@ void __init mem_encrypt_free_decrypted_mvoid __init sev_es_init_vc_handling (void ); +static inline u64 sme_get_me_mask (void ) +{ +return RIP_REL_REF (sme_me_mask); +} +#define __bss_decrypted __section(".bss..decrypted")#else /* !CONFIG_AMD_MEM_ENCRYPT */
@@ -89,6 +95,8 @@ early_set_mem_enc_dec_hypercall(unsignedstatic inline void mem_encrypt_free_decrypted_mem (void ) { } +static inline u64 sme_get_me_mask (void ) {return 0 ; } +#define __bss_decrypted#endif /* CONFIG_AMD_MEM_ENCRYPT */
@@ -106,11 +114,6 @@ void add_encrypt_protection_map(void);extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[]; -static inline u64 sme_get_me_mask (void ) -{ -return sme_me_mask; -} -#endif /* __ASSEMBLY__ */ #endif /* __X86_MEM_ENCRYPT_H__ */
arch/x86/kernel/sev-shared.c +6 -6
@@ -556,9 +556,9 @@ static int snp_cpuid(struct ghcb *ghcb, leaf->eax = leaf->ebx = leaf->ecx = leaf->edx =0 ;/* Skip post-processing for out-of-range zero leafs. */ -if (!(leaf->fn <= cpuid_std_range_max || - (leaf->fn >=0x40000000 && leaf->fn <= cpuid_hyp_range_max) || - (leaf->fn >=0x80000000 && leaf->fn <= cpuid_ext_range_max))) +if (!(leaf->fn <=RIP_REL_REF (cpuid_std_range_max) || + (leaf->fn >=0x40000000 && leaf->fn <=RIP_REL_REF (cpuid_hyp_range_max)) || + (leaf->fn >=0x80000000 && leaf->fn <=RIP_REL_REF (cpuid_ext_range_max))))return 0 ; }
@@ -1063,11 +1063,11 @@ static void __init setup_cpuid_table(conconst struct snp_cpuid_fn *fn = &cpuid_table->fn[i];if (fn->eax_in ==0x0 ) - cpuid_std_range_max = fn->eax; +RIP_REL_REF (cpuid_std_range_max) = fn->eax;else if (fn->eax_in ==0x40000000 ) - cpuid_hyp_range_max = fn->eax; +RIP_REL_REF (cpuid_hyp_range_max) = fn->eax;else if (fn->eax_in ==0x80000000 ) - cpuid_ext_range_max = fn->eax; +RIP_REL_REF (cpuid_ext_range_max) = fn->eax; } }
arch/x86/kernel/sev.c +2 -2
@@ -748,7 +748,7 @@ void __init early_snp_set_memory_private* This eliminates worries about jump tables or checking boot_cpu_data * in the cc_platform_has() function. */ -if (!(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (!(RIP_REL_REF (sev_status) &MSR_AMD64_SEV_SNP_ENABLED ))return ;/*
@@ -767,7 +767,7 @@ void __init early_snp_set_memory_shared(* This eliminates worries about jump tables or checking boot_cpu_data * in the cc_platform_has() function. */ -if (!(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (!(RIP_REL_REF (sev_status) &MSR_AMD64_SEV_SNP_ENABLED ))return ;/* Ask hypervisor to mark the memory pages shared in the RMP table. */
arch/x86/mm/mem_encrypt_identity.c +12 -15
@@ -304,7 +304,8 @@ void __init sme_encrypt_kernel(struct bo* instrumentation or checking boot_cpu_data in the cc_platform_has() * function. */ -if (!sme_get_me_mask () || sev_status &MSR_AMD64_SEV_ENABLED ) +if (!sme_get_me_mask () || +RIP_REL_REF (sev_status) &MSR_AMD64_SEV_ENABLED )return ;/*
@@ -541,11 +542,11 @@ void __init sme_enable(struct boot_param me_mask =1UL << (ebx &0x3f );/* Check the SEV MSR whether SEV or SME is enabled */ - sev_status =__rdmsr (MSR_AMD64_SEV ); - feature_mask = (sev_status &MSR_AMD64_SEV_ENABLED ) ?AMD_SEV_BIT :AMD_SME_BIT ; +RIP_REL_REF (sev_status) = msr =__rdmsr (MSR_AMD64_SEV ); + feature_mask = (msr &MSR_AMD64_SEV_ENABLED ) ?AMD_SEV_BIT :AMD_SME_BIT ;/* The SEV-SNP CC blob should never be present unless SEV-SNP is enabled. */ -if (snp && !(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (snp && !(msr &MSR_AMD64_SEV_SNP_ENABLED ))snp_abort ();/* Check if memory encryption is enabled */
@@ -571,7 +572,6 @@ void __init sme_enable(struct boot_paramreturn ; }else {/* SEV state cannot be controlled by a command line option */ - sme_me_mask = me_mask; goto out; }
@@ -590,16 +590,13 @@ void __init sme_enable(struct boot_param cmdline_ptr = (const char *)((u64 )bp->hdr.cmd_line_ptr | ((u64 )bp->ext_cmd_line_ptr <<32 )); -if (cmdline_find_option (cmdline_ptr, cmdline_arg, buffer,sizeof (buffer)) <0 ) - goto out; - -if (!strncmp (buffer, cmdline_on,sizeof (buffer))) - sme_me_mask = me_mask; +if (cmdline_find_option (cmdline_ptr, cmdline_arg, buffer,sizeof (buffer)) <0 || +strncmp (buffer, cmdline_on,sizeof (buffer))) +return ; out: -if (sme_me_mask) { - physical_mask &= ~sme_me_mask; - cc_vendor =CC_VENDOR_AMD ; -cc_set_mask (sme_me_mask); - } +RIP_REL_REF (sme_me_mask) = me_mask; + physical_mask &= ~me_mask; + cc_vendor =CC_VENDOR_AMD ; +cc_set_mask (me_mask); }
Greg Kroah-Hartman
maintainerPATCH 284/396 clocksource/drivers/arm_global_timer: Fix maximum prescaler value
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit b34b9547cee41575a4fddf390f615570759dc999 ]
The prescaler in the "Global Timer Control Register bit assignments" is documented to use bits [15:8], which means that the maximum prescaler register value is 0xff.
--- drivers/clocksource/arm_global_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_global_timer.c +1 -1
@@ -32,7 +32,7 @@#define GT_CONTROL_IRQ_ENABLE BIT(2)/* banked */ #define GT_CONTROL_AUTO_INC BIT(3)/* banked */ #define GT_CONTROL_PRESCALER_SHIFT 8 -#define GT_CONTROL_PRESCALER_MAX 0xF +#define GT_CONTROL_PRESCALER_MAX 0xFF#define GT_CONTROL_PRESCALER_MASK (GT_CONTROL_PRESCALER_MAX << \ GT_CONTROL_PRESCALER_SHIFT)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 285/396 ARM: 9352/1: iwmmxt: Remove support for PJ4/PJ4B cores
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
[ Upstream commit b9920fdd5a751df129808e7fa512e9928223ee05 ]
PJ4 is a v7 core that incorporates a iWMMXt coprocessor. However, GCC does not support this combination (its iWMMXt configuration always implies v5te), and so there is no v6/v7 user space that actually makes use of this, beyond generic support for things like setjmp() that preserve/restore the iWMMXt register file using generic LDC/STC instructions emitted in assembler. As [0] appears to imply, this logic is triggered for the init process at boot, and so most user threads will have a iWMMXt register context associated with it, even though it is never used.
At this point, it is highly unlikely that such GCC support will ever materialize (and Clang does not implement support for iWMMXt to begin with).
This means that advertising iWMMXt support on these cores results in context switch overhead without any associated benefit, and so it is better to simply ignore the iWMMXt unit on these systems. So rip out the support. Doing so also fixes the issue reported in [0] related to UNDEF handling of co-processor #0/#1 instructions issued from user space running in Thumb2 mode.
The PJ4 cores are used in four platforms: Armada 370/xp, Dove (Cubox, d2plug), MMP2 (xo-1.75) and Berlin (Google TV). Out of these, only the first is still widely used, but that one actually doesn't have iWMMXt but instead has only VFPV3-D16, and so it is not impacted by this change.
--- arch/arm/Kconfig | 4 +- arch/arm/kernel/Makefile | 2 - arch/arm/kernel/iwmmxt.S | 51 ++++---------- arch/arm/kernel/pj4-cp0.c | 135 -------------------------------------- 4 files changed, 15 insertions(+), 177 deletions(-) delete mode 100644 arch/arm/kernel/pj4-cp0.c
arch/arm/Kconfig +2 -2
@@ -589,8 +589,8 @@ source "arch/arm/mm/Kconfig" config IWMMXT bool "Enable iWMMXt support" - depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_PJ4 || CPU_PJ4B - default y if PXA27x || PXA3xx || ARCH_MMP || CPU_PJ4 || CPU_PJ4B + depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK + default y if PXA27x || PXA3xx || ARCH_MMP help Enable support for iWMMXt context switching at run time if running on a CPU that supports it.
arch/arm/kernel/Makefile +0 -2
@@ -75,8 +75,6 @@ obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_CPU_XSCALE) += xscale-cp0.o obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o -obj-$(CONFIG_CPU_PJ4) += pj4-cp0.o -obj-$(CONFIG_CPU_PJ4B) += pj4-cp0.o obj-$(CONFIG_IWMMXT) += iwmmxt.o obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o obj-$(CONFIG_HW_PERF_EVENTS) += perf_event_xscale.o perf_event_v6.o \
arch/arm/kernel/iwmmxt.S +13 -38
91 lines not on this page · raw message
arch/arm/kernel/pj4-cp0.c deleted +0 -135
135 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 286/396 ARM: 9359/1: flush: check if the folio is reserved for no-mapping addresses
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongqiang Liu <[email protected]>
[ Upstream commit 0c66c6f4e21cb22220cbd8821c5c73fc157d20dc ]
Since commit a4d5613c4dc6 ("arm: extend pfn_valid to take into account freed memory map alignment") changes the semantics of pfn_valid() to check presence of the memory map for a PFN. A valid page for an address which is reserved but not mapped by the kernel[1], the system crashed during some uio test with the following memory layout:
node 0: [mem 0x00000000c0a00000-0x00000000cc8fffff]
node 0: [mem 0x00000000d0000000-0x00000000da1fffff]
the uio layout is:0xc0900000, 0x100000
the crash backtrace like:
Unable to handle kernel paging request at virtual address bff00000 [...] CPU: 1 PID: 465 Comm: startapp.bin Tainted: G O 5.10.0 #1 Hardware name: Generic DT based system PC is at b15_flush_kern_dcache_area+0x24/0x3c LR is at __sync_icache_dcache+0x6c/0x98 [...] (b15_flush_kern_dcache_area) from (__sync_icache_dcache+0x6c/0x98) (__sync_icache_dcache) from (set_pte_at+0x28/0x54) (set_pte_at) from (remap_pfn_range+0x1a0/0x274) (remap_pfn_range) from (uio_mmap+0x184/0x1b8 [uio]) (uio_mmap [uio]) from (__mmap_region+0x264/0x5f4) (__mmap_region) from (__do_mmap_mm+0x3ec/0x440) (__do_mmap_mm) from (do_mmap+0x50/0x58) (do_mmap) from (vm_mmap_pgoff+0xfc/0x188) (vm_mmap_pgoff) from (ksys_mmap_pgoff+0xac/0xc4) (ksys_mmap_pgoff) from (ret_fast_syscall+0x0/0x5c) Code: e0801001 e2423001 e1c00003 f57ff04f (ee070f3e) ---[ end trace 09cf0734c3805d52 ]--- Kernel panic - not syncing: Fatal exception
So check if PG_reserved was set to solve this issue.
[1]: https://lore.kernel.org/lkml/[email protected]/
--- arch/arm/mm/flush.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mm/flush.c +3 -0
@@ -296,6 +296,9 @@ void __sync_icache_dcache(pte_t pteval)return ; folio =page_folio (pfn_to_page (pfn)); +if (folio_test_reserved (folio)) +return ; +if (cache_is_vipt_aliasing ()) mapping =folio_flush_mapping (folio);else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 287/396 entry: Respect changes to system call number by trace_sys_enter()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Rösti <[email protected]>
[ Upstream commit fb13b11d53875e28e7fbf0c26b288e4ea676aa9f ]
When a probe is registered at the trace_sys_enter() tracepoint, and that probe changes the system call number, the old system call still gets executed. This worked correctly until commit b6ec41346103 ("core/entry:
Report syscall correctly for trace and audit"), which removed the re-evaluation of the syscall number after the trace point.
Restore the original semantics by re-evaluating the system call number after trace_sys_enter().
The performance impact of this re-evaluation is minimal because it only takes place when a trace point is active, and compared to the actual trace point overhead the read from a cache hot variable is negligible.
--- kernel/entry/common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/entry/common.c +7 -1
@@ -77,8 +77,14 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,/* Either of the above might have changed the syscall number */ syscall =syscall_get_nr (current, regs); -if (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT )) +if (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT )) {trace_sys_enter (regs, syscall); +/* +* Probes or BPF hooks in the tracepoint may have changed the +* system call number as well. +*/ + syscall =syscall_get_nr (current, regs); + }syscall_enter_audit (regs, syscall);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 288/396 swiotlb: Fix double-allocation of slots due to broken alignment handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit 04867a7a33324c9c562ee7949dbcaab7aaad1fb4 ]
Commit bbb73a103fbb ("swiotlb: fix a braino in the alignment check fix"), which was a fix for commit 0eee5ae10256 ("swiotlb: fix slot alignment checks"), causes a functional regression with vsock in a virtual machine using bouncing via a restricted DMA SWIOTLB pool.
When virtio allocates the virtqueues for the vsock device using dma_alloc_coherent(), the SWIOTLB search can return page-unaligned allocations if 'area->index' was left unaligned by a previous allocation from the buffer:
# Final address in brackets is the SWIOTLB address returned to the caller
| virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1645-1649/7168 (0x98326800) | virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1649-1653/7168 (0x98328800) | virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1653-1657/7168 (0x9832a800)
This ends badly (typically buffer corruption and/or a hang) because swiotlb_alloc() is expecting a page-aligned allocation and so blindly returns a pointer to the 'struct page' corresponding to the allocation, therefore double-allocating the first half (2KiB slot) of the 4KiB page.
Fix the problem by treating the allocation alignment separately to any additional alignment requirements from the device, using the maximum of the two as the stride to search the buffer slots and taking care to ensure a minimum of page-alignment for buffers larger than a page.
This also resolves swiotlb allocation failures occuring due to the inclusion of ~PAGE_MASK in 'iotlb_align_mask' for large allocations and resulting in alignment requirements exceeding swiotlb_max_mapping_size().
--- kernel/dma/swiotlb.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
kernel/dma/swiotlb.c +14 -12
@@ -982,7 +982,7 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool,phys_to_dma_unencrypted (dev, pool->start) & boundary_mask;unsigned long max_slots =get_max_slots (boundary_mask);unsigned int iotlb_align_mask = -dma_get_min_align_mask (dev) | alloc_align_mask; +dma_get_min_align_mask (dev) & ~(IO_TLB_SIZE -1 );unsigned int nslots =nr_slots (alloc_size), stride;unsigned int offset =swiotlb_align_offset (dev, orig_addr);unsigned int index, slots_checked, count =0 , i;
@@ -994,18 +994,17 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool,BUG_ON (area_index >= pool->nareas);/* -* For allocations of PAGE_SIZE or larger only look for page aligned -* allocations. +* For mappings with an alignment requirement don't bother looping to +* unaligned slots once we found an aligned one. */ -if (alloc_size >=PAGE_SIZE ) - iotlb_align_mask |= ~PAGE_MASK ; - iotlb_align_mask &= ~(IO_TLB_SIZE -1 ); + stride =get_max_slots (max (alloc_align_mask, iotlb_align_mask));/* -* For mappings with an alignment requirement don't bother looping to -* unaligned slots once we found an aligned one. +* For allocations of PAGE_SIZE or larger only look for page aligned +* allocations. */ - stride = (iotlb_align_mask >>IO_TLB_SHIFT ) +1 ; +if (alloc_size >=PAGE_SIZE ) + stride =umax (stride,PAGE_SHIFT -IO_TLB_SHIFT +1 );spin_lock_irqsave (&area->lock, flags);if (unlikely (nslots > pool->area_nslabs - area->used))
@@ -1015,11 +1014,14 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool, index = area->index;for (slots_checked =0 ; slots_checked < pool->area_nslabs; ) { +phys_addr_t tlb_addr; + slot_index = slot_base + index; + tlb_addr =slot_addr (tbl_dma_addr, slot_index); -if (orig_addr && - (slot_addr (tbl_dma_addr, slot_index) & - iotlb_align_mask) != (orig_addr & iotlb_align_mask)) { +if ((tlb_addr & alloc_align_mask) || + (orig_addr && (tlb_addr & iotlb_align_mask) != + (orig_addr & iotlb_align_mask))) { index =wrap_area_index (pool, index +1 ); slots_checked++;continue ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 289/396 swiotlb: Honour dma_alloc_coherent() alignment in swiotlb_alloc()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit cbf53074a528191df82b4dba1e3d21191102255e ]
core-api/dma-api-howto.rst states the following properties of dma_alloc_coherent():
| The CPU virtual address and the DMA address are both guaranteed to | be aligned to the smallest PAGE_SIZE order which is greater than or | equal to the requested size.
However, swiotlb_alloc() passes zero for the 'alloc_align_mask' parameter of swiotlb_find_slots() and so this property is not upheld. Instead, allocations larger than a page are aligned to PAGE_SIZE,
Calculate the mask corresponding to the page order suitable for holding the allocation and pass that to swiotlb_find_slots().
--- kernel/dma/swiotlb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/dma/swiotlb.c +3 -1
@@ -1608,12 +1608,14 @@ struct page *swiotlb_alloc(struct device *dev, size_t size)struct io_tlb_mem *mem = dev->dma_io_tlb_mem;struct io_tlb_pool *pool;phys_addr_t tlb_addr; +unsigned int align;int index;if (!mem)return NULL ; - index =swiotlb_find_slots (dev,0 , size,0 , &pool); + align = (1 << (get_order (size) +PAGE_SHIFT )) -1 ; + index =swiotlb_find_slots (dev,0 , size, align, &pool);if (index ==-1 )return NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 290/396 swiotlb: Fix alignment checks when both allocation and DMA masks are present
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit 51b30ecb73b481d5fac6ccf2ecb4a309c9ee3310 ]
Nicolin reports that swiotlb buffer allocations fail for an NVME device behind an IOMMU using 64KiB pages. This is because we end up with a minimum allocation alignment of 64KiB (for the IOMMU to map the buffer safely) but a minimum DMA alignment mask corresponding to a 4KiB NVME page (i.e. preserving the 4KiB page offset from the original allocation). If the original address is not 4KiB-aligned, the allocation will fail because swiotlb_search_pool_area() erroneously compares these unmasked bits with the 64KiB-aligned candidate allocation.
Tweak swiotlb_search_pool_area() so that the DMA alignment mask is reduced based on the required alignment of the allocation.
--- kernel/dma/swiotlb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/dma/swiotlb.c +9 -2
@@ -981,8 +981,7 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool,dma_addr_t tbl_dma_addr =phys_to_dma_unencrypted (dev, pool->start) & boundary_mask;unsigned long max_slots =get_max_slots (boundary_mask); -unsigned int iotlb_align_mask = -dma_get_min_align_mask (dev) & ~(IO_TLB_SIZE -1 ); +unsigned int iotlb_align_mask =dma_get_min_align_mask (dev);unsigned int nslots =nr_slots (alloc_size), stride;unsigned int offset =swiotlb_align_offset (dev, orig_addr);unsigned int index, slots_checked, count =0 , i;
@@ -993,6 +992,14 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool,BUG_ON (!nslots);BUG_ON (area_index >= pool->nareas); +/* +* Ensure that the allocation is at least slot-aligned and update +* 'iotlb_align_mask' to ignore bits that will be preserved when +* offsetting into the allocation. +*/ + alloc_align_mask |= (IO_TLB_SIZE -1 ); + iotlb_align_mask &= ~alloc_align_mask; +/* * For mappings with an alignment requirement don't bother looping to * unaligned slots once we found an aligned one.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 291/396 iommu/dma: Force swiotlb_max_mapping_size on an untrusted device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit afc5aa46ed560f01ceda897c053c6a40c77ce5c4 ]
The swiotlb does not support a mapping size > swiotlb_max_mapping_size().
On the other hand, with a 64KB PAGE_SIZE configuration, it's observed that
an NVME device can map a size between 300KB~512KB, which certainly failed
the swiotlb mappings, though the default pool of swiotlb has many slots:
systemd[1]: Started Journal Service.
=> nvme 0000:00:01.0: swiotlb buffer is full (sz: 327680 bytes), total 32768 (slots), used 32 (slots)
note: journal-offline[392] exited with irqs disabled
note: journal-offline[392] exited with preempt_count 1
Call trace: [ 3.099918] swiotlb_tbl_map_single+0x214/0x240 [ 3.099921] iommu_dma_map_page+0x218/0x328 [ 3.099928] dma_map_page_attrs+0x2e8/0x3a0 [ 3.101985] nvme_prep_rq.part.0+0x408/0x878 [nvme] [ 3.102308] nvme_queue_rqs+0xc0/0x300 [nvme] [ 3.102313] blk_mq_flush_plug_list.part.0+0x57c/0x600 [ 3.102321] blk_add_rq_to_plug+0x180/0x2a0 [ 3.102323] blk_mq_submit_bio+0x4c8/0x6b8 [ 3.103463] __submit_bio+0x44/0x220 [ 3.103468] submit_bio_noacct_nocheck+0x2b8/0x360 [ 3.103470] submit_bio_noacct+0x180/0x6c8 [ 3.103471] submit_bio+0x34/0x130 [ 3.103473] ext4_bio_write_folio+0x5a4/0x8c8 [ 3.104766] mpage_submit_folio+0xa0/0x100 [ 3.104769] mpage_map_and_submit_buffers+0x1a4/0x400 [ 3.104771] ext4_do_writepages+0x6a0/0xd78 [ 3.105615] ext4_writepages+0x80/0x118 [ 3.105616] do_writepages+0x90/0x1e8 [ 3.105619] filemap_fdatawrite_wbc+0x94/0xe0 [ 3.105622] __filemap_fdatawrite_range+0x68/0xb8 [ 3.106656] file_write_and_wait_range+0x84/0x120 [ 3.106658] ext4_sync_file+0x7c/0x4c0 [ 3.106660] vfs_fsync_range+0x3c/0xa8 [ 3.106663] do_fsync+0x44/0xc0
Since untrusted devices might go down the swiotlb pathway with dma-iommu, these devices should not map a size larger than swiotlb_max_mapping_size.
To fix this bug, add iommu_dma_max_mapping_size() for untrusted devices to take into account swiotlb_max_mapping_size() v.s. iova_rcache_range() from the iommu_dma_opt_mapping_size().
--- drivers/iommu/dma-iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iommu/dma-iommu.c +9 -0
@@ -1602,6 +1602,14 @@ static size_t iommu_dma_opt_mapping_size(void)return iova_rcache_range (); } +static size_t iommu_dma_max_mapping_size (struct device *dev) +{ +if (dev_is_untrusted (dev)) +return swiotlb_max_mapping_size (dev); + +return SIZE_MAX ; +} +static const struct dma_map_ops iommu_dma_ops = { .flags =DMA_F_PCI_P2PDMA_SUPPORTED , .alloc = iommu_dma_alloc,
@@ -1624,6 +1632,7 @@ static const struct dma_map_ops iommu_dma_ops = { .unmap_resource = iommu_dma_unmap_resource, .get_merge_boundary = iommu_dma_get_merge_boundary, .opt_mapping_size = iommu_dma_opt_mapping_size, + .max_mapping_size = iommu_dma_max_mapping_size, };/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 292/396 printk: Update @console_may_schedule in console_trylock_spinning()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 8076972468584d4a21dab9aa50e388b3ea9ad8c7 ]
console_trylock_spinning() may takeover the console lock from a schedulable context. Update @console_may_schedule to make sure it reflects a trylock acquire.
--- kernel/printk/printk.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/printk/printk.c +6 -0
@@ -2007,6 +2007,12 @@ static int console_trylock_spinning(void)*/ mutex_acquire (&console_lock_dep_map,0 ,1 , _THIS_IP_); +/* +* Update @console_may_schedule for trylock because the previous +* owner may have been schedulable. +*/ + console_may_schedule =0 ; +return 1 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 293/396 irqchip/renesas-rzg2l: Implement restriction when writing ISCR register
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit ef88eefb1a81a8701eabb7d5ced761a66a465a49 ]
The RZ/G2L manual (chapter "IRQ Status Control Register (ISCR)") describes the operation to clear interrupts through the ISCR register as follows:
[Write operation]
When "Falling-edge detection", "Rising-edge detection" or "Falling/Rising-edge detection" is set in IITSR:
- In case ISTAT is 1
0: IRQn interrupt detection status is cleared. 1: Invalid to write.
- In case ISTAT is 0
Invalid to write.
When "Low-level detection" is set in IITSR.:
Invalid to write.
Take the interrupt type into account when clearing interrupts through the ISCR register to avoid writing the ISCR when the interrupt type is level.
Stable-dep-of: 9eec61df55c5 ("irqchip/renesas-rzg2l: Flush posted write in irq_eoi()")
--- drivers/irqchip/irq-renesas-rzg2l.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +10 -4
@@ -72,11 +72,17 @@ static void rzg2l_irq_eoi(struct irq_data *d)unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ;struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);u32 bit =BIT (hw_irq); -u32 reg; +u32 iitsr, iscr; - reg =readl_relaxed (priv->base +ISCR ); -if (reg & bit) -writel_relaxed (reg & ~bit, priv->base +ISCR ); + iscr =readl_relaxed (priv->base +ISCR ); + iitsr =readl_relaxed (priv->base +IITSR ); + +/* +* ISCR can only be cleared if the type is falling-edge, rising-edge or +* falling/rising-edge. +*/ +if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) +writel_relaxed (iscr & ~bit, priv->base +ISCR ); }static void rzg2l_tint_eoi (struct irq_data *d)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 294/396 irqchip/renesas-rzg2l: Flush posted write in irq_eoi()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 9eec61df55c51415409c7cc47e9a1c8de94a0522 ]
The irq_eoi() callback of the RZ/G2L interrupt chip clears the relevant interrupt cause bit in the TSCR register by writing to it.
This write is not sufficient because the write is posted and therefore not guaranteed to immediately clear the bit. Due to that delay the CPU can raise the just handled interrupt again.
Prevent this by reading the register back which causes the posted write to be flushed to the hardware before the read completes.
--- drivers/irqchip/irq-renesas-rzg2l.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +14 -2
@@ -81,8 +81,14 @@ static void rzg2l_irq_eoi(struct irq_data *d)* ISCR can only be cleared if the type is falling-edge, rising-edge or * falling/rising-edge. */ -if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) +if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) {writel_relaxed (iscr & ~bit, priv->base +ISCR ); +/* +* Enforce that the posted write is flushed to prevent that the +* just handled interrupt is raised again. +*/ +readl_relaxed (priv->base +ISCR ); + } }static void rzg2l_tint_eoi (struct irq_data *d)
@@ -93,8 +99,14 @@ static void rzg2l_tint_eoi(struct irq_data *d)u32 reg; reg =readl_relaxed (priv->base +TSCR ); -if (reg & bit) +if (reg & bit) {writel_relaxed (reg & ~bit, priv->base +TSCR ); +/* +* Enforce that the posted write is flushed to prevent that the +* just handled interrupt is raised again. +*/ +readl_relaxed (priv->base +TSCR ); + } }static void rzg2l_irqc_eoi (struct irq_data *d)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 295/396 irqchip/renesas-rzg2l: Add macro to retrieve TITSR register offset based on registers index
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 2eca4731cc66563b3919d8753dbd74d18c39f662 ]
There are 2 TITSR registers available on the IA55 interrupt controller.
Add a macro that retrieves the TITSR register offset based on it's index. This macro is useful in when adding suspend/resume support so both TITSR registers can be accessed in a for loop.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +6 -8
@@ -28,8 +28,7 @@#define ISCR 0x10#define IITSR 0x14#define TSCR 0x20 -#define TITSR0 0x24 -#define TITSR1 0x28 +#define TITSR (n) (0x24 + (n) * 4)#define TITSR0_MAX_INT 16#define TITSEL_WIDTH 0x2#define TSSR (n) (0x30 + ((n) * 4))
@@ -206,8 +205,7 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type)struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);unsigned int hwirq =irqd_to_hwirq (d);u32 titseln = hwirq -IRQC_TINT_START ; -u32 offset; -u8 sense; +u8 index, sense;u32 reg;switch (type &IRQ_TYPE_SENSE_MASK ) {
@@ -223,17 +221,17 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type)return -EINVAL ; } - offset =TITSR0 ; + index =0 ;if (titseln >=TITSR0_MAX_INT ) { titseln -=TITSR0_MAX_INT ; - offset =TITSR1 ; + index =1 ; }raw_spin_lock (&priv->lock); - reg =readl_relaxed (priv->base + offset); + reg =readl_relaxed (priv->base +TITSR (index)); reg &= ~(IRQ_MASK << (titseln *TITSEL_WIDTH )); reg |= sense << (titseln *TITSEL_WIDTH ); -writel_relaxed (reg, priv->base + offset); +writel_relaxed (reg, priv->base +TITSR (index));raw_spin_unlock (&priv->lock);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 296/396 irqchip/renesas-rzg2l: Rename rzg2l_tint_eoi()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 7cb6362c63df233172eaecddaf9ce2ce2f769112 ]
Rename rzg2l_tint_eoi()->rzg2l_clear_tint_int() and simplify the code by removing redundant priv and hw_irq local variables.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -5
@@ -90,11 +90,9 @@ static void rzg2l_irq_eoi(struct irq_data *d) } } -static void rzg2l_tint_eoi (struct irq_data *d) +static void rzg2l_clear_tint_int (struct rzg2l_irqc_priv *priv,unsigned int hwirq) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_TINT_START ; -struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); -u32 bit =BIT (hw_irq); +u32 bit =BIT (hwirq -IRQC_TINT_START );u32 reg; reg =readl_relaxed (priv->base +TSCR );
@@ -117,7 +115,7 @@ static void rzg2l_irqc_eoi(struct irq_data *d)if (hw_irq >=IRQC_IRQ_START && hw_irq <=IRQC_IRQ_COUNT )rzg2l_irq_eoi (d);else if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ ) -rzg2l_tint_eoi (d); +rzg2l_clear_tint_int (priv, hw_irq);raw_spin_unlock (&priv->lock);irq_chip_eoi_parent (d); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 297/396 irqchip/renesas-rzg2l: Rename rzg2l_irq_eoi()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit b4b5cd61a6fdd92ede0dc39f0850a182affd1323 ]
Rename rzg2l_irq_eoi()->rzg2l_clear_irq_int() and simplify the code by removing redundant priv local variable.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -4
@@ -66,10 +66,9 @@ static struct rzg2l_irqc_priv *irq_data_to_priv(struct irq_data *data)return data->domain->host_data; } -static void rzg2l_irq_eoi (struct irq_data *d) +static void rzg2l_clear_irq_int (struct rzg2l_irqc_priv *priv,unsigned int hwirq) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ; -struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); +unsigned int hw_irq = hwirq -IRQC_IRQ_START ;u32 bit =BIT (hw_irq);u32 iitsr, iscr;
@@ -113,7 +112,7 @@ static void rzg2l_irqc_eoi(struct irq_data *d)raw_spin_lock (&priv->lock);if (hw_irq >=IRQC_IRQ_START && hw_irq <=IRQC_IRQ_COUNT ) -rzg2l_irq_eoi (d); +rzg2l_clear_irq_int (priv, hw_irq);else if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ )rzg2l_clear_tint_int (priv, hw_irq);raw_spin_unlock (&priv->lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 298/396 irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 853a6030303f8a8fa54929b68e5665d9b21aa405 ]
RZ/G2L interrupt chips require that the interrupt is masked before changing the NMI, IRQ, TINT interrupt settings. Aside of that, after setting an edge trigger type it is required to clear the interrupt status register in order to avoid spurious interrupts.
The current implementation fails to do either of that and therefore is prone to generate spurious interrupts when setting the trigger type.
Address this by:
- Ensuring that the interrupt is masked at the chip level across the update for the TINT chip
- Clearing the interrupt status register after updating the trigger mode for edge type interrupts
[ tglx: Massaged changelog and reverted the spin_lock_irqsave() change as
the set_type() callback is always called with interrupts disabled. ]
--- drivers/irqchip/irq-renesas-rzg2l.c | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +32 -4
@@ -162,8 +162,10 @@ static void rzg2l_irqc_irq_enable(struct irq_data *d)static int rzg2l_irq_set_type (struct irq_data *d,unsigned int type) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ;struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); +unsigned int hwirq =irqd_to_hwirq (d); +u32 iitseln = hwirq -IRQC_IRQ_START ; +bool clear_irq_int = false;u16 sense, tmp;switch (type &IRQ_TYPE_SENSE_MASK ) {
@@ -173,14 +175,17 @@ static int rzg2l_irq_set_type(struct irq_data *d, unsigned int type)case IRQ_TYPE_EDGE_FALLING : sense =IITSR_IITSEL_EDGE_FALLING ; + clear_irq_int = true;break ;case IRQ_TYPE_EDGE_RISING : sense =IITSR_IITSEL_EDGE_RISING ; + clear_irq_int = true;break ;case IRQ_TYPE_EDGE_BOTH : sense =IITSR_IITSEL_EDGE_BOTH ; + clear_irq_int = true;break ;default :
@@ -189,21 +194,40 @@ static int rzg2l_irq_set_type(struct irq_data *d, unsigned int type)raw_spin_lock (&priv->lock); tmp =readl_relaxed (priv->base +IITSR ); - tmp &= ~IITSR_IITSEL_MASK (hw_irq); - tmp |=IITSR_IITSEL (hw_irq, sense); + tmp &= ~IITSR_IITSEL_MASK (iitseln); + tmp |=IITSR_IITSEL (iitseln, sense); +if (clear_irq_int) +rzg2l_clear_irq_int (priv, hwirq);writel_relaxed (tmp, priv->base +IITSR );raw_spin_unlock (&priv->lock);return 0 ; } +static u32 rzg2l_disable_tint_and_set_tint_source (struct irq_data *d,struct rzg2l_irqc_priv *priv, +u32 reg,u32 tssr_offset,u8 tssr_index) +{ +u32 tint = (u32 )(uintptr_t )irq_data_get_irq_chip_data (d); +u32 tien = reg & (TIEN <<TSSEL_SHIFT (tssr_offset)); + +/* Clear the relevant byte in reg */ + reg &= ~(TSSEL_MASK <<TSSEL_SHIFT (tssr_offset)); +/* Set TINT and leave TIEN clear */ + reg |= tint <<TSSEL_SHIFT (tssr_offset); +writel_relaxed (reg, priv->base +TSSR (tssr_index)); + +return reg | tien; +} +static int rzg2l_tint_set_edge (struct irq_data *d,unsigned int type) {struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);unsigned int hwirq =irqd_to_hwirq (d);u32 titseln = hwirq -IRQC_TINT_START ; +u32 tssr_offset =TSSR_OFFSET (titseln); +u8 tssr_index =TSSR_INDEX (titseln);u8 index, sense; -u32 reg; +u32 reg, tssr;switch (type &IRQ_TYPE_SENSE_MASK ) {case IRQ_TYPE_EDGE_RISING :
@@ -225,10 +249,14 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type) }raw_spin_lock (&priv->lock); + tssr =readl_relaxed (priv->base +TSSR (tssr_index)); + tssr =rzg2l_disable_tint_and_set_tint_source (d, priv, tssr, tssr_offset, tssr_index); reg =readl_relaxed (priv->base +TITSR (index)); reg &= ~(IRQ_MASK << (titseln *TITSEL_WIDTH )); reg |= sense << (titseln *TITSEL_WIDTH );writel_relaxed (reg, priv->base +TITSR (index)); +rzg2l_clear_tint_int (priv, hwirq); +writel_relaxed (tssr, priv->base +TSSR (tssr_index));raw_spin_unlock (&priv->lock);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 299/396 kprobes/x86: Use copy_from_kernel_nofault() to read from unsafe address
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 4e51653d5d871f40f1bd5cf95cc7f2d8b33d063b ]
Read from an unsafe address with copy_from_kernel_nofault() in arch_adjust_kprobe_addr() because this function is used before checking the address is in text or not. Syzcaller bot found a bug and reported the case if user specifies inaccessible data area, arch_adjust_kprobe_addr() will cause a kernel panic.
[ mingo: Clarified the comment. ]
--- arch/x86/kernel/kprobes/core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/x86/kernel/kprobes/core.c +10 -1
@@ -335,7 +335,16 @@ static int can_probe(unsigned long paddr)kprobe_opcode_t *arch_adjust_kprobe_addr (unsigned long addr,unsigned long offset,bool *on_func_entry) { -if (is_endbr (*(u32 *)addr)) { +u32 insn; + +/* +* Since 'addr' is not guaranteed to be safe to access, use +* copy_from_kernel_nofault() to read the instruction: +*/ +if (copy_from_kernel_nofault (&insn, (void *)addr,sizeof (u32))) +return NULL ; + +if (is_endbr (insn)) { *on_func_entry = !offset || offset ==4 ;if (*on_func_entry) offset =4 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 300/396 efi/libstub: fix efi_random_alloc() to allocate memory at alloc_min or higher address
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: KONDO KAZUMA(近藤 和真) <[email protected]>
[ Upstream commit 3cb4a4827596abc82e55b80364f509d0fefc3051 ]
Following warning is sometimes observed while booting my servers:
[ 3.594838] DMA: preallocated 4096 KiB GFP_KERNEL pool for atomic allocations [ 3.602918] swapper/0: page allocation failure: order:10, mode:0xcc1(GFP_KERNEL|GFP_DMA), nodemask=(null),cpuset=/,mems_allowed=0-1 ... [ 3.851862] DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA pool for atomic allocation
If 'nokaslr' boot option is set, the warning always happens.
On x86, ZONE_DMA is small zone at the first 16MB of physical address space. When this problem happens, most of that space seems to be used by decompressed kernel. Thereby, there is not enough space at DMA_ZONE to meet the request of DMA pool allocation.
The commit 2f77465b05b1 ("x86/efistub: Avoid placing the kernel below LOAD_PHYSICAL_ADDR") tried to fix this problem by introducing lower bound of allocation.
But the fix is not complete.
efi_random_alloc() allocates pages by following steps.
1. Count total available slots ('total_slots')
2. Select a slot ('target_slot') to allocate randomly
3. Calculate a starting address ('target') to be included target_slot
4. Allocate pages, which starting address is 'target'
In step 1, 'alloc_min' is used to offset the starting address of memory chunk. But in step 3 'alloc_min' is not considered at all. As the result, 'target' can be miscalculated and become lower than 'alloc_min'.
When KASLR is disabled, 'target_slot' is always 0 and the problem happens everytime if the EFI memory map of the system meets the condition.
Fix this problem by calculating 'target' considering 'alloc_min'.
--- drivers/firmware/efi/libstub/randomalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/randomalloc.c +1 -1
@@ -120,7 +120,7 @@ efi_status_t efi_random_alloc(unsigned long size,continue ; } - target =round_up (md->phys_addr, align) + target_slot * align; + target =round_up (max (md->phys_addr, alloc_min), align) + target_slot * align; pages = size /EFI_PAGE_SIZE ; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 301/396 x86/mpparse: Register APIC address only once
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
[ Upstream commit f2208aa12c27bfada3c15c550c03ca81d42dcac2 ]
The APIC address is registered twice. First during the early detection and afterwards when actually scanning the table for APIC IDs. The APIC and topology core warn about the second attempt.
Restrict it to the early detection call.
--- arch/x86/kernel/mpparse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/mpparse.c +5 -5
@@ -196,12 +196,12 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early)if (!smp_check_mpc (mpc, oem, str))return 0 ; -/* Initialize the lapic mapping */ -if (!acpi_lapic) -register_lapic_address (mpc->lapic); - -if (early) +if (early) { +/* Initialize the lapic mapping */ +if (!acpi_lapic) +register_lapic_address (mpc->lapic);return 1 ; + }/* Now process the configuration blocks. */ while (count < mpc->length) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 302/396 x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adamos Ttofari <[email protected]>
[ Upstream commit 10e4b5166df9ff7a2d5316138ca668b42d004422 ]
Commit 672365477ae8 ("x86/fpu: Update XFD state where required") and commit 8bf26758ca96 ("x86/fpu: Add XFD state to fpstate") introduced a per CPU variable xfd_state to keep the MSR_IA32_XFD value cached, in order to avoid unnecessary writes to the MSR.
On CPU hotplug MSR_IA32_XFD is reset to the init_fpstate.xfd, which wipes out any stale state. But the per CPU cached xfd value is not reset, which brings them out of sync.
As a consequence a subsequent xfd_update_state() might fail to update the MSR which in turn can result in XRSTOR raising a #NM in kernel space, which crashes the kernel.
To fix this, introduce xfd_set_state() to write xfd_state together with MSR_IA32_XFD, and use it in all places that set MSR_IA32_XFD.
--- arch/x86/kernel/fpu/xstate.c | 5 +++-- arch/x86/kernel/fpu/xstate.h | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-)
arch/x86/kernel/fpu/xstate.c +3 -2
@@ -178,10 +178,11 @@ void fpu__init_cpu_xstate(void)* Must happen after CR4 setup and before xsetbv() to allow KVM * lazy passthrough. Write independent of the dynamic state static * key as that does not work on the boot CPU. This also ensures -* that any stale state is wiped out from XFD. +* that any stale state is wiped out from XFD. Reset the per CPU +* xfd cache too. */ if (cpu_feature_enabled (X86_FEATURE_XFD )) -wrmsrl (MSR_IA32_XFD , init_fpstate.xfd); +xfd_set_state (init_fpstate.xfd);/* * XCR_XFEATURE_ENABLED_MASK (aka. XCR0) sets user features
arch/x86/kernel/fpu/xstate.h +10 -4
@@ -148,20 +148,26 @@ static inline void xfd_validate_state(struct fpstate *fpstate, u64 mask, bool rs#endif #ifdef CONFIG_X86_64 +static inline void xfd_set_state (u64 xfd) +{ +wrmsrl (MSR_IA32_XFD , xfd); +__this_cpu_write (xfd_state, xfd); +} +static inline void xfd_update_state (struct fpstate *fpstate) {if (fpu_state_size_dynamic ()) {u64 xfd = fpstate->xfd; -if (__this_cpu_read (xfd_state) != xfd) { -wrmsrl (MSR_IA32_XFD , xfd); -__this_cpu_write (xfd_state, xfd); - } +if (__this_cpu_read (xfd_state) != xfd) +xfd_set_state (xfd); } }extern int __xfd_enable_feature (u64 which,struct fpu_guest *guest_fpu);#else +static inline void xfd_set_state (u64 xfd) { } +static inline void xfd_update_state (struct fpstate *fpstate) { }static inline int __xfd_enable_feature (u64 which,struct fpu_guest *guest_fpu) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 303/396 efi: fix panic in kdump kernel
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksandr Tymoshenko <[email protected]>
[ Upstream commit 62b71cd73d41ddac6b1760402bbe8c4932e23531 ]
Check if get_next_variable() is actually valid pointer before calling it. In kdump kernel this method is set to NULL that causes panic during the kexec-ed kernel boot.
Tested with QEMU and OVMF firmware.
--- drivers/firmware/efi/efi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firmware/efi/efi.c +2 -0
@@ -199,6 +199,8 @@ static bool generic_ops_supported(void) name_size =sizeof (name); +if (!efi.get_next_variable) +return false; status = efi.get_next_variable (&name_size, &name, &guid);if (status ==EFI_UNSUPPORTED )return false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 304/396 pwm: img: fix pwm clock lookup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zoltan HERPAI <[email protected]>
[ Upstream commit 9eb05877dbee03064d3d3483cd6702f610d5a358 ]
22e8e19 has introduced a regression in the imgchip->pwm_clk lookup, whereas the clock name has also been renamed to "imgchip". This causes the driver failing to load:
[ 0.546905] img-pwm 18101300.pwm: failed to get imgchip clock [ 0.553418] img-pwm: probe of 18101300.pwm failed with error -2
Fix this lookup by reverting the clock name back to "pwm".
--- drivers/pwm/pwm-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-img.c +2 -2
@@ -289,9 +289,9 @@ static int img_pwm_probe(struct platform_device *pdev)return PTR_ERR (imgchip->sys_clk); } - imgchip->pwm_clk =devm_clk_get (&pdev->dev,"imgchip" ); + imgchip->pwm_clk =devm_clk_get (&pdev->dev,"pwm" );if (IS_ERR (imgchip->pwm_clk)) { -dev_err (&pdev->dev,"failed to get imgchip clock\n" ); +dev_err (&pdev->dev,"failed to get pwm clock\n" );return PTR_ERR (imgchip->pwm_clk); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 305/396 selftests/mm: gup_test: conform test to TAP format output
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit cb6e7cae18868422a23d62670110c61fd1b15029 ]
Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages.
Stable-dep-of: 8b65ef5ad486 ("selftests/mm: Fix build with _FORTIFY_SOURCE")
--- tools/testing/selftests/mm/gup_test.c | 65 ++++++++++++++------------- 1 file changed, 33 insertions(+), 32 deletions(-)
tools/testing/selftests/mm/gup_test.c +33 -32
@@ -50,39 +50,41 @@ static char *cmd_to_str(unsigned long cmd)void *gup_thread (void *data) {struct gup_test gup = *(struct gup_test *)data; -int i; +int i, status;/* Only report timing information on the *_BENCHMARK commands: */ if ((cmd ==PIN_FAST_BENCHMARK ) || (cmd ==GUP_FAST_BENCHMARK ) || (cmd ==PIN_LONGTERM_BENCHMARK )) {for (i =0 ; i < repeats; i++) { gup.size = size; -if (ioctl (gup_fd, cmd, &gup)) -perror ("ioctl" ),exit (1 ); + status =ioctl (gup_fd, cmd, &gup); +if (status) +break ;pthread_mutex_lock (&print_mutex); -printf ("%s: Time: get:%lld put:%lld us" , -cmd_to_str (cmd), gup.get_delta_usec, - gup.put_delta_usec); +ksft_print_msg ("%s: Time: get:%lld put:%lld us" , +cmd_to_str (cmd), gup.get_delta_usec, + gup.put_delta_usec);if (gup.size != size) -printf (", truncated (size: %lld)" , gup.size); -printf ("\n" ); +ksft_print_msg (", truncated (size: %lld)" , gup.size); +ksft_print_msg ("\n" );pthread_mutex_unlock (&print_mutex); } }else { gup.size = size; -if (ioctl (gup_fd, cmd, &gup)) { -perror ("ioctl" ); -exit (1 ); - } + status =ioctl (gup_fd, cmd, &gup); +if (status) + goto return_;pthread_mutex_lock (&print_mutex); -printf ("%s: done\n" ,cmd_to_str (cmd)); +ksft_print_msg ("%s: done\n" ,cmd_to_str (cmd));if (gup.size != size) -printf ("Truncated (size: %lld)\n" , gup.size); +ksft_print_msg ("Truncated (size: %lld)\n" , gup.size);pthread_mutex_unlock (&print_mutex); } +return_: +ksft_test_result (!status,"ioctl status %d\n" , status);return NULL ; }
@@ -170,7 +172,7 @@ int main(int argc, char **argv) touch =1 ;break ;default : -return -1 ; +ksft_exit_fail_msg ("Wrong argument\n" ); } }
@@ -198,11 +200,12 @@ int main(int argc, char **argv) } } +ksft_print_header (); +ksft_set_plan (nthreads); + filed =open (file,O_RDWR |O_CREAT ); -if (filed <0 ) { -perror ("open" ); -exit (filed); - } +if (filed <0 ) +ksft_exit_fail_msg ("Unable to open %s: %s\n" , file,strerror (errno)); gup.nr_pages_per_call = nr_pages;if (write)
@@ -213,27 +216,24 @@ int main(int argc, char **argv)switch (errno) {case EACCES :if (getuid ()) -printf ("Please run this test as root\n" ); +ksft_print_msg ("Please run this test as root\n" );break ;case ENOENT : -if (opendir ("/sys/kernel/debug" ) ==NULL ) { -printf ("mount debugfs at /sys/kernel/debug\n" ); -break ; - } -printf ("check if CONFIG_GUP_TEST is enabled in kernel config\n" ); +if (opendir ("/sys/kernel/debug" ) ==NULL ) +ksft_print_msg ("mount debugfs at /sys/kernel/debug\n" ); +ksft_print_msg ("check if CONFIG_GUP_TEST is enabled in kernel config\n" );break ;default : -perror ("failed to open " GUP_TEST_FILE ); +ksft_print_msg ("failed to open %s: %s\n" ,GUP_TEST_FILE ,strerror (errno));break ; } -exit (KSFT_SKIP ); +ksft_test_result_skip ("Please run this test as root\n" ); +return ksft_exit_pass (); } p =mmap (NULL , size,PROT_READ |PROT_WRITE , flags, filed,0 ); -if (p ==MAP_FAILED ) { -perror ("mmap" ); -exit (1 ); - } +if (p ==MAP_FAILED ) +ksft_exit_fail_msg ("mmap: %s\n" ,strerror (errno)); gup.addr = (unsigned long )p;if (thp ==1 )
@@ -264,7 +264,8 @@ int main(int argc, char **argv) ret =pthread_join (tid[i],NULL );assert (ret ==0 ); } +free (tid); -return 0 ; +return ksft_exit_pass (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 306/396 selftests/mm: Fix build with _FORTIFY_SOURCE
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Chikunov <[email protected]>
[ Upstream commit 8b65ef5ad4862904e476a8f3d4e4418c950ddb90 ]
Add missing flags argument to open(2) call with O_CREAT.
Some tests fail to compile if _FORTIFY_SOURCE is defined (to any valid value) (together with -O), resulting in similar error messages such as:
In file included from /usr/include/fcntl.h:342,
from gup_test.c:1:
In function 'open',
inlined from 'main' at gup_test.c:206:10:
/usr/include/bits/fcntl2.h:50:11: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
50 | __open_missing_mode ();
| ^~~~~~~~~~~~~~~~~~~~~~_FORTIFY_SOURCE is enabled by default in some distributions, so the tests are not built by default and are skipped.
open(2) man-page warns about missing flags argument: "if it is not supplied, some arbitrary bytes from the stack will be applied as the file mode."
--- tools/testing/selftests/mm/gup_test.c | 2 +- tools/testing/selftests/mm/soft-dirty.c | 2 +- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/gup_test.c +1 -1
@@ -203,7 +203,7 @@ int main(int argc, char **argv)ksft_print_header ();ksft_set_plan (nthreads); - filed =open (file,O_RDWR |O_CREAT ); + filed =open (file,O_RDWR |O_CREAT ,0664 );if (filed <0 )ksft_exit_fail_msg ("Unable to open %s: %s\n" , file,strerror (errno));
tools/testing/selftests/mm/soft-dirty.c +1 -1
@@ -137,7 +137,7 @@ static void test_mprotect(int pagemap_fd, int pagesize, bool anon)if (!map)ksft_exit_fail_msg ("anon mmap failed\n" ); }else { - test_fd =open (fname,O_RDWR |O_CREAT ); + test_fd =open (fname,O_RDWR |O_CREAT ,0664 );if (test_fd <0 ) {ksft_test_result_skip ("Test %s open() file failed\n" , __func__);return ;
tools/testing/selftests/mm/split_huge_page_test.c +1 -1
@@ -253,7 +253,7 @@ void split_file_backed_thp(void) goto cleanup; } - fd =open (testfile,O_CREAT |O_WRONLY ); + fd =open (testfile,O_CREAT |O_WRONLY ,0664 );if (fd ==-1 ) {perror ("Cannot open testing file\n" ); goto cleanup;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 307/396 perf top: Use evsels cpus to replace user_requested_cpus
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 5fa695e7da4975e8d21ce49f3718d6cf00ecb75e upstream.
perf top errors out on a hybrid machine
$perf top
Error:
The cycles:P event is not supported.
The perf top expects that the "cycles" is collected on all CPUs in the system. But for hybrid there is no single "cycles" event which can cover all CPUs. Perf has to split it into two cycles events, e.g., cpu_core/cycles/ and cpu_atom/cycles/. Each event has its own CPU mask. If a event is opened on the unsupported CPU. The open fails. That's the reason of the above error out.
Perf should only open the cycles event on the corresponding CPU. The commit ef91871c960e ("perf evlist: Propagate user CPU maps intersecting core PMU maps") intersect the requested CPU map with the CPU map of the PMU. Use the evsel's cpus to replace user_requested_cpus.
The evlist's threads are also propagated to the evsel's threads in __perf_evlist__propagate_maps(). For a system-wide event, perf appends a dummy event and assign it to the evsel's threads. For a per-thread event, the evlist's thread_map is assigned to the evsel's threads. The same as the other tools, e.g., perf record, using the evsel's threads when opening an event.
--- tools/perf/builtin-top.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-top.c +2 -2
@@ -1027,8 +1027,8 @@ static int perf_top__start_counters(struevlist__for_each_entry (evlist, counter) { try_again: -if (evsel__open (counter, top->evlist->core.user_requested_cpus, - top->evlist->core.threads) <0 ) { +if (evsel__open (counter, counter->core.cpus, + counter->core.threads) <0 ) {/* * Specially handle overwrite fall back.
Greg Kroah-Hartman
maintainerPATCH 308/396 ALSA: hda/tas2781: remove digital gain kcontrol
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit ae065d0ce9e36ca4efdfb9b96ce3395bd1c19372 upstream.
The "Speaker Digital Gain" kcontrol controls the TAS2781_DVC_LVL (0x1A) register. Unfortunately the tas2563 does not have DVC_LVL, but has INT_MASK0 in 0x1A, which has been misused so far.
Since commit c1947ce61ff4 ("ALSA: hda/realtek: tas2781: enable subwoofer volume control") the volume of the tas2781 amplifiers can be controlled by the master volume, so this digital gain kcontrol is not needed.
Remove it.
Message-ID: <741fc21db994efd58f83e7aef38931204961e5b2.1711469583.git.soyer@irl.hu>
--- sound/pci/hda/tas2781_hda_i2c.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +1 -36
@@ -71,7 +71,7 @@ struct tas2781_hda {struct snd_kcontrol *dsp_prog_ctl;struct snd_kcontrol *dsp_conf_ctl;struct snd_kcontrol *prof_ctl; -struct snd_kcontrol *snd_ctls[3 ]; +struct snd_kcontrol *snd_ctls[2 ]; };static int tas2781_get_i2c_res (struct acpi_resource *ares,void *data)
@@ -288,27 +288,6 @@ static int tasdevice_config_put(struct sreturn ret; } -/* -* tas2781_digital_getvol - get the volum control -* @kcontrol: control pointer -* @ucontrol: User data -* Customer Kcontrol for tas2781 is primarily for regmap booking, paging -* depends on internal regmap mechanism. -* tas2781 contains book and page two-level register map, especially -* book switching will set the register BXXP00R7F, after switching to the -* correct book, then leverage the mechanism for paging to access the -* register. -*/ -static int tas2781_digital_getvol (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) -{ -struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); -struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - -return tasdevice_digital_getvol (tas_priv, ucontrol, mc); -} -static int tas2781_amp_getvol (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -319,17 +298,6 @@ static int tas2781_amp_getvol(struct sndreturn tasdevice_amp_getvol (tas_priv, ucontrol, mc); } -static int tas2781_digital_putvol (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) -{ -struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); -struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - -/* The check of the given value is in tasdevice_digital_putvol. */ -return tasdevice_digital_putvol (tas_priv, ucontrol, mc); -} -static int tas2781_amp_putvol (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -375,9 +343,6 @@ static const struct snd_kcontrol_new tasACARD_SINGLE_RANGE_EXT_TLV ("Speaker Analog Gain" ,TAS2781_AMP_LEVEL ,1 ,0 ,20 ,0 , tas2781_amp_getvol, tas2781_amp_putvol, amp_vol_tlv), -ACARD_SINGLE_RANGE_EXT_TLV ("Speaker Digital Gain" ,TAS2781_DVC_LVL , -0 ,0 ,200 ,1 , tas2781_digital_getvol, - tas2781_digital_putvol, dvc_tlv),ACARD_SINGLE_BOOL_EXT ("Speaker Force Firmware Load" ,0 , tas2781_force_fwload_get, tas2781_force_fwload_put), };
Greg Kroah-Hartman
maintainerPATCH 309/396 ALSA: hda/tas2781: add locks to kcontrols
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit 15bc3066d2378eef1b45254be9df23b0dd7f1667 upstream.
The rcabin.profile_cfg_id, cur_prog, cur_conf, force_fwload_status variables are acccessible from multiple threads and therefore require locking.
Message-ID: <e35b867f6fe5fa1f869dd658a0a1f2118b737f57.1711469583.git.soyer@irl.hu>
--- sound/pci/hda/tas2781_hda_i2c.c | 50 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +48 -2
@@ -179,8 +179,12 @@ static int tasdevice_get_profile_id(stru {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->rcabin.profile_cfg_id; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -194,11 +198,15 @@ static int tasdevice_set_profile_id(stru val =clamp (nr_profile,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->rcabin.profile_cfg_id != val) { tas_priv->rcabin.profile_cfg_id = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -235,8 +243,12 @@ static int tasdevice_program_get(struct {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->cur_prog; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -251,11 +263,15 @@ static int tasdevice_program_put(struct val =clamp (nr_program,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->cur_prog != val) { tas_priv->cur_prog = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -264,8 +280,12 @@ static int tasdevice_config_get(struct s {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->cur_conf; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -280,11 +300,15 @@ static int tasdevice_config_put(struct s val =clamp (nr_config,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->cur_conf != val) { tas_priv->cur_conf = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -294,8 +318,15 @@ static int tas2781_amp_getvol(struct sndstruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; +int ret; -return tasdevice_amp_getvol (tas_priv, ucontrol, mc); +mutex_lock (&tas_priv->codec_lock); + + ret =tasdevice_amp_getvol (tas_priv, ucontrol, mc); + +mutex_unlock (&tas_priv->codec_lock); + +return ret; } static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
@@ -304,9 +335,16 @@ static int tas2781_amp_putvol(struct sndstruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; +int ret; + +mutex_lock (&tas_priv->codec_lock);/* The check of the given value is in tasdevice_amp_putvol. */ -return tasdevice_amp_putvol (tas_priv, ucontrol, mc); + ret =tasdevice_amp_putvol (tas_priv, ucontrol, mc); + +mutex_unlock (&tas_priv->codec_lock); + +return ret; } static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
@@ -314,10 +352,14 @@ static int tas2781_force_fwload_get(stru {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = (int )tas_priv->force_fwload_status;dev_dbg (tas_priv->dev,"%s : Force FWload %s\n" , __func__, tas_priv->force_fwload_status ?"ON" :"OFF" ); +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -327,6 +369,8 @@ static int tas2781_force_fwload_put(strustruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);bool change, val = (bool )ucontrol->value.integer.value[0 ]; +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->force_fwload_status == val) change = false;else {
@@ -336,6 +380,8 @@ static int tas2781_force_fwload_put(strudev_dbg (tas_priv->dev,"%s : Force FWload %s\n" , __func__, tas_priv->force_fwload_status ?"ON" :"OFF" ); +mutex_unlock (&tas_priv->codec_lock); +return change; }
Greg Kroah-Hartman
maintainerPATCH 310/396 init: open /initrd.image with O_LARGEFILE
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Sperbeck <[email protected]>
commit 4624b346cf67400ef46a31771011fb798dd2f999 upstream.
If initrd data is larger than 2Gb, we'll eventually fail to write to the /initrd.image file when we hit that limit, unless O_LARGEFILE is set.
--- init/initramfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
init/initramfs.c +1 -1
@@ -673,7 +673,7 @@ static void __init populate_initrd_imageprintk (KERN_INFO "rootfs image is not initramfs (%s); looks like an initrd\n" , err); - file =filp_open ("/initrd.image" ,O_WRONLY |O_CREAT ,0700 ); + file =filp_open ("/initrd.image" ,O_WRONLY |O_CREAT |O_LARGEFILE ,0700 );if (IS_ERR (file))return ;
Greg Kroah-Hartman
maintainerPATCH 311/396 x86/efistub: Add missing boot_params for mixed mode compat entry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit d21f5a59ea773826cc489acb287811d690b703cc upstream.
The pure EFI stub entry point does not take a struct boot_params from the boot loader, but creates it from scratch, and populates only the fields that still have meaning in this context (command line, initrd base and size, etc)
The original mixed mode implementation used the EFI handover protocol instead, where the boot loader (i.e., GRUB) populates a boot_params struct and passes it to a special Linux specific EFI entry point that takes the boot_params pointer as its third argument.
When the new mixed mode implementation was introduced, using a special 32-bit PE entrypoint in the 64-bit kernel, it adopted the pure approach, and relied on the EFI stub to create the struct boot_params. This is preferred because it makes the bootloader side much easier to implement, as it does not need any x86-specific knowledge on how struct boot_params and struct setup_header are put together. This mixed mode implementation was adopted by systemd-boot version 252 and later.
When commit
e2ab9eab324c ("x86/boot/compressed: Move 32-bit entrypoint code into .text section")
refactored this code and moved it out of head_64.S, the fact that ESI was populated with the address of the base of the image was overlooked, and to simplify the code flow, ESI is now zeroed and stored to memory unconditionally in shared code, so that the NULL-ness of that variable can still be used later to determine which mixed mode boot protocol is in use.
With ESI pointing to the base of the image, it can serve as a struct boot_params pointer for startup_32(), which only accesses the init_data and kernel_alignment fields (and the scratch field as a temporary stack). Zeroing ESI means that those accesses produce garbage now, even though things appear to work if the first page of memory happens to be zeroed, and the region right before LOAD_PHYSICAL_ADDR (== 16 MiB) happens to be free.
The solution is to pass a special, temporary struct boot_params to startup_32() via ESI, one that is sufficient for getting it to create the page tables correctly and is discarded right after. This involves setting a minimal alignment of 4k, only to get the statically allocated page tables line up correctly, and setting init_size to the executable image size (_end - startup_32). This ensures that the page tables are covered by the static footprint of the PE image.
Given that EFI boot no longer calls the decompressor and no longer pads the image to permit the decompressor to execute in place, the same temporary struct boot_params should be used in the EFI handover protocol based mixed mode implementation as well, to prevent the page tables from being placed outside of allocated memory.
--- arch/x86/boot/compressed/efi_mixed.S | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
arch/x86/boot/compressed/efi_mixed.S +15 -5
@@ -15,10 +15,12 @@ */ #include <linux/linkage.h> +#include <asm/asm-offsets.h> #include <asm/msr.h> #include <asm/page_types.h> #include <asm/processor-flags.h> #include <asm/segment.h> +#include <asm/setup.h> .code64 .text
@@ -149,6 +151,7 @@ SYM_FUNC_END(__efi64_thunk) SYM_FUNC_START(efi32_stub_entry) call 1f 1: popl %ecx + leal (efi32_boot_args - 1b)(%ecx), %ebx /* Clear BSS */ xorl %eax, %eax
@@ -163,6 +166,7 @@ SYM_FUNC_START(efi32_stub_entry) popl %ecx popl %edx popl %esi + movl %esi, 8(%ebx) jmp efi32_entry SYM_FUNC_END(efi32_stub_entry) #endif
@@ -239,8 +243,6 @@ SYM_FUNC_END(efi_enter32) * * Arguments: %ecx image handle * %edx EFI system table pointer - * %esi struct bootparams pointer (or NULL when not using - * the EFI handover protocol) * * Since this is the point of no return for ordinary execution, no registers * are considered live except for the function parameters. [Note that the EFI
@@ -266,9 +268,18 @@ SYM_FUNC_START_LOCAL(efi32_entry) leal (efi32_boot_args - 1b)(%ebx), %ebx movl %ecx, 0(%ebx) movl %edx, 4(%ebx) - movl %esi, 8(%ebx) movb $0x0, 12(%ebx) // efi_is64 + /* + * Allocate some memory for a temporary struct boot_params, which only + * needs the minimal pieces that startup_32() relies on. + */ + subl $PARAM_SIZE, %esp + movl %esp, %esi + movl $PAGE_SIZE, BP_kernel_alignment(%esi) + movl $_end - 1b, BP_init_size(%esi) + subl $startup_32 - 1b, BP_init_size(%esi) + /* Disable paging */ movl %cr0, %eax btrl $X86_CR0_PG_BIT, %eax
@@ -294,8 +305,7 @@ SYM_FUNC_START(efi32_pe_entry) movl 8(%ebp), %ecx // image_handle movl 12(%ebp), %edx // sys_table - xorl %esi, %esi - jmp efi32_entry // pass %ecx, %edx, %esi + jmp efi32_entry // pass %ecx, %edx // no other registers remain live 2: popl %edi // restore callee-save registers
Greg Kroah-Hartman
maintainerPATCH 312/396 efi/libstub: Cast away type warning in use of max()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 61d130f261a3c15ae2c4b6f3ac3517d5d5b78855 upstream.
Avoid a type mismatch warning in max() by switching to max_t() and providing the type explicitly.
--- drivers/firmware/efi/libstub/randomalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/randomalloc.c +1 -1
@@ -120,7 +120,7 @@ efi_status_t efi_random_alloc(unsigned lcontinue ; } - target =round_up (max (md->phys_addr, alloc_min), align) + target_slot * align; + target =round_up (max_t (u64, md->phys_addr, alloc_min), align) + target_slot * align; pages = size /EFI_PAGE_SIZE ; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
Greg Kroah-Hartman
maintainerPATCH 313/396 x86/efistub: Reinstate soft limit for initrd loading
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit decd347c2a75d32984beb8807d470b763a53b542 upstream.
Commit
8117961d98fb2 ("x86/efi: Disregard setup header of loaded image")
dropped the memcopy of the image's setup header into the boot_params struct provided to the core kernel, on the basis that EFI boot does not need it and should rely only on a single protocol to interface with the boot chain. It is also a prerequisite for being able to increase the section alignment to 4k, which is needed to enable memory protections when running in the boot services.
So only the setup_header fields that matter to the core kernel are populated explicitly, and everything else is ignored. One thing was overlooked, though: the initrd_addr_max field in the setup_header is not used by the core kernel, but it is used by the EFI stub itself when it loads the initrd, where its default value of INT_MAX is used as the soft limit for memory allocation.
This means that, in the old situation, the initrd was virtually always loaded in the lower 2G of memory, but now, due to initrd_addr_max being 0x0, the initrd may end up anywhere in memory. This should not be an issue principle, as most systems can deal with this fine. However, it does appear to tickle some problems in older UEFI implementations, where the memory ends up being corrupted, resulting in errors when unpacking the initramfs.
So set the initrd_addr_max field to INT_MAX like it was before.
--- drivers/firmware/efi/libstub/x86-stub.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/efi/libstub/x86-stub.c +1 -0
@@ -487,6 +487,7 @@ efi_status_t __efiapi efi_pe_entry(efi_h hdr->vid_mode =0xffff ; hdr->type_of_loader =0x21 ; + hdr->initrd_addr_max =INT_MAX ;/* Convert unicode cmdline to ascii */ cmdline_ptr =efi_convert_cmdline (image, &options_size);
Greg Kroah-Hartman
maintainerPATCH 314/396 prctl: generalize PR_SET_MDWE support check to be per-arch
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zev Weiss <[email protected]>
commit d5aad4c2ca057e760a92a9a7d65bd38d72963f27 upstream.
Patch series "ARM: prctl: Reject PR_SET_MDWE where not supported".
I noticed after a recent kernel update that my ARM926 system started segfaulting on any execve() after calling prctl(PR_SET_MDWE). After some investigation it appears that ARMv5 is incapable of providing the appropriate protections for MDWE, since any readable memory is also implicitly executable.
The prctl_set_mdwe() function already had some special-case logic added disabling it on PARISC (commit 793838138c15, "prctl: Disable prctl(PR_SET_MDWE) on parisc"); this patch series (1) generalizes that check to use an arch_*() function, and (2) adds a corresponding override for ARM to disable MDWE on pre-ARMv6 CPUs.
With the series applied, prctl(PR_SET_MDWE) is rejected on ARMv5 and subsequent execve() calls (as well as mmap(PROT_READ|PROT_WRITE)) can succeed instead of unconditionally failing; on ARMv6 the prctl works as it did previously.
[0] https://lore.kernel.org/all/2023112456-linked-nape-bf19@gregkh/
This patch (of 2):
There exist systems other than PARISC where MDWE may not be feasible to support; rather than cluttering up the generic code with additional arch-specific logic let's add a generic function for checking MDWE support and allow each arch to override it as needed.
--- arch/parisc/include/asm/mman.h | 14 ++++++++++++++ include/linux/mman.h | 8 ++++++++ kernel/sys.c | 7 +++++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 arch/parisc/include/asm/mman.h
arch/parisc/include/asm/mman.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MMAN_H__ +#define __ASM_MMAN_H__ + +#include <uapi/asm/mman.h> + +/* PARISC cannot allow mdwe as it needs writable stacks */ +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return false; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported + +#endif /* __ASM_MMAN_H__ */
include/linux/mman.h +8 -0
@@ -161,6 +161,14 @@ calc_vm_flag_bits(unsigned long flags)unsigned long vm_commit_limit (void ); +#ifndef arch_memory_deny_write_exec_supported +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return true; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported +#endif +/* * Denies creating a writable executable mapping or gaining executable permissions. *
kernel/sys.c +5 -2
@@ -2395,8 +2395,11 @@ static inline int prctl_set_mdwe(unsigneif (bits &PR_MDWE_NO_INHERIT && !(bits &PR_MDWE_REFUSE_EXEC_GAIN ))return -EINVAL ; -/* PARISC cannot allow mdwe as it needs writable stacks */ -if (IS_ENABLED (CONFIG_PARISC )) +/* +* EOPNOTSUPP might be more appropriate here in principle, but +* existing userspace depends on EINVAL specifically. +*/ +if (!arch_memory_deny_write_exec_supported ())return -EINVAL ; current_bits =get_current_mdwe ();
Greg Kroah-Hartman
maintainerPATCH 315/396 ARM: prctl: reject PR_SET_MDWE on pre-ARMv6
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zev Weiss <[email protected]>
commit 166ce846dc5974a266f6c2a2896dbef5425a6f21 upstream.
On v5 and lower CPUs we can't provide MDWE protection, so ensure we fail any attempt to enable it via prctl(PR_SET_MDWE).
Previously such an attempt would misleadingly succeed, leading to any subsequent mmap(PROT_READ|PROT_WRITE) or execve() failing unconditionally (the latter somewhat violently via force_fatal_sig(SIGSEGV) due to READ_IMPLIES_EXEC).
--- arch/arm/include/asm/mman.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 arch/arm/include/asm/mman.h
arch/arm/include/asm/mman.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MMAN_H__ +#define __ASM_MMAN_H__ + +#include <asm/system_info.h> +#include <uapi/asm/mman.h> + +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return cpu_architecture () >= CPU_ARCH_ARMv6; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported + +#endif /* __ASM_MMAN_H__ */
Greg Kroah-Hartman
maintainerPATCH 316/396 tmpfs: fix race on handling dquot rbtree
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Maiolino <[email protected]>
commit 0a69b6b3a026543bc215ccc866d0aea5579e6ce2 upstream.
A syzkaller reproducer found a race while attempting to remove dquot information from the rb tree.
Fetching the rb_tree root node must also be protected by the dqopt->dqio_sem, otherwise, giving the right timing, shmem_release_dquot() will trigger a warning because it couldn't find a node in the tree, when the real reason was the root node changing before the search starts:
Thread 1 Thread 2
- shmem_release_dquot() - shmem_{acquire,release}_dquot()
- fetch ROOT - Fetch ROOT
- acquire dqio_sem
- wait dqio_sem
- do something, triger a tree rebalance
- release dqio_sem
- acquire dqio_sem
- start searching for the node, but
from the wrong location, missing
the node, and triggering a warning.
--- mm/shmem_quota.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
mm/shmem_quota.c +7 -3
@@ -116,7 +116,7 @@ static int shmem_free_file_info(struct super_block *sb, int type)static int shmem_get_next_id (struct super_block *sb,struct kqid *qid) {struct mem_dqinfo *info =sb_dqinfo (sb, qid->type); -struct rb_node *node = ((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node *node;qid_t id =from_kqid (&init_user_ns, *qid);struct quota_info *dqopt =sb_dqopt (sb);struct quota_id *entry =NULL ;
@@ -126,6 +126,7 @@ static int shmem_get_next_id(struct super_block *sb, struct kqid *qid)return -ESRCH ;down_read (&dqopt->dqio_sem); + node = ((struct rb_root *)info->dqi_priv)->rb_node;while (node) { entry = rb_entry(node, struct quota_id, node);
@@ -165,7 +166,7 @@ static int shmem_get_next_id(struct super_block *sb, struct kqid *qid)static int shmem_acquire_dquot (struct dquot *dquot) {struct mem_dqinfo *info =sb_dqinfo (dquot->dq_sb, dquot->dq_id.type); -struct rb_node **n = &((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node **n;struct shmem_sb_info *sbinfo = dquot->dq_sb->s_fs_info;struct rb_node *parent =NULL , *new_node =NULL ;struct quota_id *new_entry, *entry;
@@ -176,6 +177,8 @@ static int shmem_acquire_dquot(struct dquot *dquot)mutex_lock (&dquot->dq_lock);down_write (&dqopt->dqio_sem); + n = &((struct rb_root *)info->dqi_priv)->rb_node; +while (*n) { parent = *n; entry = rb_entry(parent, struct quota_id, node);
@@ -264,7 +267,7 @@ static bool shmem_is_empty_dquot(struct dquot *dquot)static int shmem_release_dquot (struct dquot *dquot) {struct mem_dqinfo *info =sb_dqinfo (dquot->dq_sb, dquot->dq_id.type); -struct rb_node *node = ((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node *node;qid_t id =from_kqid (&init_user_ns, dquot->dq_id);struct quota_info *dqopt =sb_dqopt (dquot->dq_sb);struct quota_id *entry =NULL ;
@@ -275,6 +278,7 @@ static int shmem_release_dquot(struct dquot *dquot) goto out_dqlock;down_write (&dqopt->dqio_sem); + node = ((struct rb_root *)info->dqi_priv)->rb_node;while (node) { entry = rb_entry(node, struct quota_id, node);
Signature · 1 line
2.44.0
Greg Kroah-Hartman
maintainerPATCH 317/396 btrfs: fix race in read_extent_buffer_pages()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tavian Barnes <[email protected]>
commit ef1e68236b9153c27cb7cf29ead0c532870d4215 upstream.
There are reports from tree-checker that detects corrupted nodes, without any obvious pattern so possibly an overwrite in memory. After some debugging it turns out there's a race when reading an extent buffer the uptodate status can be missed.
To prevent concurrent reads for the same extent buffer, read_extent_buffer_pages() performs these checks:
/* (1) */
if (test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
return 0;
/* (2) */
if (test_and_set_bit(EXTENT_BUFFER_READING, &eb->bflags))
goto done;At this point, it seems safe to start the actual read operation. Once that completes, end_bbio_meta_read() does
/* (3) */
set_extent_buffer_uptodate(eb);
/* (4) */
clear_bit(EXTENT_BUFFER_READING, &eb->bflags);Normally, this is enough to ensure only one read happens, and all other callers wait for it to finish before returning. Unfortunately, there is a racey interleaving:
Thread A | Thread B | Thread C
---------+----------+---------
(1) | |
| (1) |
(2) | |
(3) | |
(4) | |
| (2) |
| | (1)When this happens, thread B kicks of an unnecessary read. Worse, thread C will see UPTODATE set and return immediately, while the read from thread B is still in progress. This race could result in tree-checker errors like this as the extent buffer is concurrently modified:
BTRFS critical (device dm-0): corrupted node, root=256
block=8550954455682405139 owner mismatch, have 11858205567642294356
expect [256, 18446744073709551360]Fix it by testing UPTODATE again after setting the READING bit, and if it's been set, skip the unnecessary read.
--- fs/btrfs/extent_io.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/btrfs/extent_io.c +13 -0
@@ -4047,6 +4047,19 @@ int read_extent_buffer_pages(struct exteif (test_and_set_bit (EXTENT_BUFFER_READING , &eb->bflags)) goto done; +/* +* Between the initial test_bit(EXTENT_BUFFER_UPTODATE) and the above +* test_and_set_bit(EXTENT_BUFFER_READING), someone else could have +* started and finished reading the same eb. In this case, UPTODATE +* will now be set, and we shouldn't read it in again. +*/ +if (unlikely (test_bit (EXTENT_BUFFER_UPTODATE , &eb->bflags))) { +clear_bit (EXTENT_BUFFER_READING , &eb->bflags); +smp_mb__after_atomic (); +wake_up_bit (&eb->bflags,EXTENT_BUFFER_READING ); +return 0 ; + } +clear_bit (EXTENT_BUFFER_READ_ERR , &eb->bflags); eb->read_mirror =0 ;check_buffer_tree_ref (eb);
Greg Kroah-Hartman
maintainerPATCH 318/396 btrfs: zoned: dont skip block groups with 100% zone unusable
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit a8b70c7f8600bc77d03c0b032c0662259b9e615e upstream.
Commit f4a9f219411f ("btrfs: do not delete unused block group if it may be used soon") changed the behaviour of deleting unused block-groups on zoned filesystems. Starting with this commit, we're using btrfs_space_info_used() to calculate the number of used bytes in a space_info. But btrfs_space_info_used() also accounts btrfs_space_info::bytes_zone_unusable as used bytes.
So if a block group is 100% zone_unusable it is skipped from the deletion step.
In order not to skip fully zone_unusable block-groups, also check if the block-group has bytes left that can be used on a zoned filesystem.
--- fs/btrfs/block-group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +2 -1
@@ -1562,7 +1562,8 @@ void btrfs_delete_unused_bgs(struct btrf* needing to allocate extents from the block group. */ used =btrfs_space_info_used (space_info, true); -if (space_info->total_bytes - block_group->length < used) { +if (space_info->total_bytes - block_group->length < used && + block_group->zone_unusable < block_group->length) {/* * Add a reference for the list, compensate for the ref * drop under the "next" label for the
Greg Kroah-Hartman
maintainerPATCH 319/396 btrfs: zoned: use zone aware sb location for scrub
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit 74098a989b9c3370f768140b7783a7aaec2759b3 upstream.
At the moment scrub_supers() doesn't grab the super block's location via the zoned device aware btrfs_sb_log_location() but via btrfs_sb_offset().
This leads to checksum errors on 'scrub' as we're not accessing the correct location of the super block.
So use btrfs_sb_log_location() for getting the super blocks location on scrub.
--- fs/btrfs/scrub.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/btrfs/scrub.c +11 -1
@@ -2739,7 +2739,17 @@ static noinline_for_stack int scrub_supe gen = fs_info->last_trans_committed;for (i =0 ; i <BTRFS_SUPER_MIRROR_MAX ; i++) { - bytenr =btrfs_sb_offset (i); + ret =btrfs_sb_log_location (scrub_dev, i,0 , &bytenr); +if (ret == -ENOENT ) +break ; + +if (ret) { +spin_lock (&sctx->stat_lock); + sctx->stat.super_errors++; +spin_unlock (&sctx->stat_lock); +continue ; + } +if (bytenr +BTRFS_SUPER_INFO_SIZE > scrub_dev->commit_total_bytes)break ;
Greg Kroah-Hartman
maintainerPATCH 320/396 wifi: mac80211: check/clear fast rx for non-4addr sta VLAN changes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 4f2bdb3c5e3189297e156b3ff84b140423d64685 upstream.
When moving a station out of a VLAN and deleting the VLAN afterwards, the fast_rx entry still holds a pointer to the VLAN's netdev, which can cause use-after-free bugs. Fix this by immediately calling ieee80211_check_fast_rx after the VLAN change.
--- net/mac80211/cfg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/mac80211/cfg.c +2 -3
@@ -2187,15 +2187,14 @@ static int ieee80211_change_station(stru }if (sta->sdata->vif.type ==NL80211_IFTYPE_AP_VLAN && - sta->sdata->u.vlan.sta) { -ieee80211_clear_fast_rx (sta); + sta->sdata->u.vlan.sta)RCU_INIT_POINTER (sta->sdata->u.vlan.sta,NULL ); - }if (test_sta_flag (sta,WLAN_STA_AUTHORIZED ))ieee80211_vif_dec_num_mcast (sta->sdata); sta->sdata = vlansdata; +ieee80211_check_fast_rx (sta);ieee80211_check_fast_xmit (sta);if (test_sta_flag (sta,WLAN_STA_AUTHORIZED )) {
Greg Kroah-Hartman
maintainerPATCH 321/396 wifi: cfg80211: add a flag to disable wireless extensions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit be23b2d7c3b7c8bf57b1cf0bf890bd65df9d0186 upstream.
Wireless extensions are already disabled if MLO is enabled, given that we cannot support MLO there with all the hard- coded assumptions about BSSID etc.
However, the WiFi7 ecosystem is still stabilizing, and some devices may need MLO disabled while that happens. In that case, we might end up with a device that supports wext (but not MLO) in one kernel, and then breaks wext in the future (by enabling MLO), which is not desirable.
Add a flag to let such drivers/devices disable wext even if MLO isn't yet enabled.
--- include/net/cfg80211.h | 2 ++ net/wireless/wext-core.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
include/net/cfg80211.h +2 -0
@@ -4816,6 +4816,7 @@ struct cfg80211_ops {* @WIPHY_FLAG_SUPPORTS_EXT_KCK_32: The device supports 32-byte KCK keys. * @WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER: The device could handle reg notify for * NL80211_REGDOM_SET_BY_DRIVER. +* @WIPHY_FLAG_DISABLE_WEXT: disable wireless extensions for this device */ enum wiphy_flags {WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK =BIT (0 ),
@@ -4827,6 +4828,7 @@ enum wiphy_flags {WIPHY_FLAG_4ADDR_STATION =BIT (6 ),WIPHY_FLAG_CONTROL_PORT_PROTOCOL =BIT (7 ),WIPHY_FLAG_IBSS_RSN =BIT (8 ), +WIPHY_FLAG_DISABLE_WEXT =BIT (9 ),WIPHY_FLAG_MESH_AUTH =BIT (10 ), WIPHY_FLAG_SUPPORTS_EXT_KCK_32 = BIT(11),/* use hole at 12 */
net/wireless/wext-core.c +5 -2
@@ -4,6 +4,7 @@* Authors : Jean Tourrilhes - HPL - <[email protected]> * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved. * Copyright 2009 Johannes Berg <[email protected]> +* Copyright (C) 2024 Intel Corporation * * (As all part of the Linux kernel, this file is GPL) */
@@ -662,7 +663,8 @@ struct iw_statistics *get_wireless_stats dev->ieee80211_ptr->wiphy->wext && dev->ieee80211_ptr->wiphy->wext->get_wireless_stats) {wireless_warn_cfg80211_wext (); -if (dev->ieee80211_ptr->wiphy->flags &WIPHY_FLAG_SUPPORTS_MLO ) +if (dev->ieee80211_ptr->wiphy->flags & (WIPHY_FLAG_SUPPORTS_MLO | +WIPHY_FLAG_DISABLE_WEXT ))return NULL ;return dev->ieee80211_ptr->wiphy->wext->get_wireless_stats (dev); }
@@ -704,7 +706,8 @@ static iw_handler get_handler(struct net#ifdef CONFIG_CFG80211_WEXT if (dev->ieee80211_ptr && dev->ieee80211_ptr->wiphy) {wireless_warn_cfg80211_wext (); -if (dev->ieee80211_ptr->wiphy->flags &WIPHY_FLAG_SUPPORTS_MLO ) +if (dev->ieee80211_ptr->wiphy->flags & (WIPHY_FLAG_SUPPORTS_MLO | +WIPHY_FLAG_DISABLE_WEXT ))return NULL ; handlers = dev->ieee80211_ptr->wiphy->wext; }
Greg Kroah-Hartman
maintainerPATCH 322/396 wifi: iwlwifi: mvm: disable MLO for the time being
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 5f404005055304830bbbee0d66af2964fc48f29e upstream.
MLO ended up not really fully stable yet, we want to make sure it works well with the ecosystem before enabling it. Thus, remove the flag, but set WIPHY_FLAG_DISABLE_WEXT so we don't get wireless extensions back until we enable MLO for this hardware.
--- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +1 -1
@@ -318,7 +318,7 @@ int iwl_mvm_mac_setup_register(struct iwif (mvm->mld_api_is_used && mvm->nvm_data->sku_cap_11be_enable && !iwlwifi_mod_params.disable_11ax && !iwlwifi_mod_params.disable_11be) - hw->wiphy->flags |=WIPHY_FLAG_SUPPORTS_MLO ; + hw->wiphy->flags |=WIPHY_FLAG_DISABLE_WEXT ;/* With MLD FW API, it tracks timing by itself, * no need for any timing from the host
Greg Kroah-Hartman
maintainerPATCH 323/396 wifi: iwlwifi: fw: dont always use FW dump trig
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 045a5b645dd59929b0e05375f493cde3a0318271 upstream.
Since the dump_data (struct iwl_fwrt_dump_data) is a union, it's not safe to unconditionally access and use the 'trig' member, it might be 'desc' instead. Access it only if it's known to be 'trig' rather than 'desc', i.e. if ini-debug is present.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +9 -8
@@ -2933,8 +2933,6 @@ static void iwl_fw_dbg_collect_sync(strustruct iwl_fw_dbg_params params = {0 };struct iwl_fwrt_dump_data *dump_data = &fwrt->dump.wks[wk_idx].dump_data; -u32 policy; -u32 time_point;if (!test_bit (wk_idx, &fwrt->dump.active_wks))return ;
@@ -2965,13 +2963,16 @@ static void iwl_fw_dbg_collect_sync(struiwl_fw_dbg_stop_restart_recording (fwrt, ¶ms, false); - policy =le32_to_cpu (dump_data->trig->apply_policy); - time_point =le32_to_cpu (dump_data->trig->time_point); - -if (policy &IWL_FW_INI_APPLY_POLICY_DUMP_COMPLETE_CMD ) { -IWL_DEBUG_FW_INFO (fwrt,"WRT: sending dump complete\n" ); -iwl_send_dbg_dump_complete_cmd (fwrt, time_point,0 ); +if (iwl_trans_dbg_ini_valid (fwrt->trans)) { +u32 policy =le32_to_cpu (dump_data->trig->apply_policy); +u32 time_point =le32_to_cpu (dump_data->trig->time_point); + +if (policy &IWL_FW_INI_APPLY_POLICY_DUMP_COMPLETE_CMD ) { +IWL_DEBUG_FW_INFO (fwrt,"WRT: sending dump complete\n" ); +iwl_send_dbg_dump_complete_cmd (fwrt, time_point,0 ); + } } +if (fwrt->trans->dbg.last_tp_resetfw ==IWL_FW_INI_RESET_FW_MODE_STOP_FW_ONLY )iwl_force_nmi (fwrt->trans);
Greg Kroah-Hartman
maintainerPATCH 324/396 Revert "drm/amd/display: Fix sending VSC (+ colorimetry) packets for DP/eDP displays without PSR"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
commit 78aca9ee5e012e130dbfbd7191bc2302b0cf3b37 upstream.
This causes flicker on a bunch of eDP panels. The info_packet code also caused regressions on other OSes that we haven't' seen on Linux yet, but that is likely due to the fact that we haven't had a chance to test those environments on Linux.
We'll need to revisit this.
This reverts commit 202260f64519e591b5cd99626e441b6559f571a3.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++---- drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c | 13 +++------- 2 files changed, 8 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -5
@@ -6121,9 +6121,8 @@ create_stream_for_sink(struct amdgpu_dm_if (stream->signal ==SIGNAL_TYPE_HDMI_TYPE_A )mod_build_hf_vsif_infopacket (stream, &stream->vsp_infopacket); -else if (stream->signal ==SIGNAL_TYPE_DISPLAY_PORT || - stream->signal ==SIGNAL_TYPE_DISPLAY_PORT_MST || - stream->signal ==SIGNAL_TYPE_EDP ) { + +if (stream->link->psr_settings.psr_feature_enabled || stream->link->replay_settings.replay_feature_enabled) {// // should decide stream support vsc sdp colorimetry capability // before building vsc info packet
@@ -6139,9 +6138,8 @@ create_stream_for_sink(struct amdgpu_dm_if (stream->out_transfer_func->tf ==TRANSFER_FUNCTION_GAMMA22 ) tf =TRANSFER_FUNC_GAMMA_22 ;mod_build_vsc_infopacket (stream, &stream->vsc_infopacket, stream->output_color_space, tf); + aconnector->psr_skip_count =AMDGPU_DM_PSR_ENTRY_DELAY ; -if (stream->link->psr_settings.psr_feature_enabled) - aconnector->psr_skip_count =AMDGPU_DM_PSR_ENTRY_DELAY ; } finish:dc_sink_release (sink);
drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c +5 -8
@@ -147,15 +147,12 @@ void mod_build_vsc_infopacket(const stru }/* VSC packet set to 4 for PSR-SU, or 2 for PSR1 */ -if (stream->link->psr_settings.psr_feature_enabled) { -if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_SU_1 ) - vsc_packet_revision = vsc_packet_rev4; -else if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_1 ) - vsc_packet_revision = vsc_packet_rev2; - } - -if (stream->link->replay_settings.config.replay_supported) +if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_SU_1 ) + vsc_packet_revision = vsc_packet_rev4; +else if (stream->link->replay_settings.config.replay_supported) vsc_packet_revision = vsc_packet_rev4; +else if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_1 ) + vsc_packet_revision = vsc_packet_rev2;/* Update to revision 5 for extended colorimetry support */ if (stream->use_vsc_sdp_for_colorimetry)
Greg Kroah-Hartman
maintainerPATCH 325/396 gpio: cdev: sanitize the label before requesting the interrupt
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
commit b34490879baa847d16fc529c8ea6e6d34f004b38 upstream.
When an interrupt is requested, a procfs directory is created under "/proc/irq/<irqnum>/<label>" where <label> is the string passed to one of the request_irq() variants.
What follows is that the string must not contain the "/" character or the procfs mkdir operation will fail. We don't have such constraints for GPIO consumer labels which are used verbatim as interrupt labels for GPIO irqs. We must therefore sanitize the consumer string before requesting the interrupt.
Let's replace all "/" with ":".
--- drivers/gpio/gpiolib-cdev.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)
drivers/gpio/gpiolib-cdev.c +32 -6
@@ -1010,10 +1010,20 @@ static u32 gpio_v2_line_config_debounce_return 0 ; } +static inline char *make_irq_label (const char *orig) +{ +return kstrdup_and_replace (orig,'/' ,':' ,GFP_KERNEL ); +} + +static inline void free_irq_label (const char *label) +{ +kfree (label); +} +static void edge_detector_stop (struct line *line) {if (line->irq) { -free_irq (line->irq, line); +free_irq_label (free_irq (line->irq, line)); line->irq =0 ; }
@@ -1038,6 +1048,7 @@ static int edge_detector_setup(struct liunsigned long irqflags =0 ;u64 eflags;int irq, ret; +char *label; eflags = edflags &GPIO_V2_LINE_EDGE_FLAGS ;if (eflags && !kfifo_initialized (&line->req->events)) {
@@ -1074,11 +1085,17 @@ static int edge_detector_setup(struct li IRQF_TRIGGER_RISING :IRQF_TRIGGER_FALLING ; irqflags |=IRQF_ONESHOT ; + label =make_irq_label (line->req->label); +if (!label) +return -ENOMEM ; +/* Request a thread to read the events */ ret =request_threaded_irq (irq, edge_irq_handler, edge_irq_thread, - irqflags, line->req->label, line); -if (ret) + irqflags, label, line); +if (ret) { +free_irq_label (label);return ret; + } line->irq = irq;return 0 ;
@@ -1943,7 +1960,7 @@ static void lineevent_free(struct lineevblocking_notifier_chain_unregister (&le->gdev->device_notifier, &le->device_unregistered_nb);if (le->irq) -free_irq (le->irq, le); +free_irq_label (free_irq (le->irq, le));if (le->desc)gpiod_free (le->desc);kfree (le->label);
@@ -2091,6 +2108,7 @@ static int lineevent_create(struct gpio_int fd;int ret;int irq, irqflags =0 ; +char *label;if (copy_from_user (&eventreq, ip,sizeof (eventreq)))return -EFAULT ;
@@ -2175,15 +2193,23 @@ static int lineevent_create(struct gpio_if (ret) goto out_free_le; + label =make_irq_label (le->label); +if (!label) { + ret = -ENOMEM ; + goto out_free_le; + } +/* Request a thread to read the events */ ret =request_threaded_irq (irq, lineevent_irq_handler, lineevent_irq_thread, irqflags, - le->label, + label, le); -if (ret) +if (ret) { +free_irq_label (label); goto out_free_le; + } le->irq = irq;
Greg Kroah-Hartman
maintainerPATCH 326/396 exec: Fix NOMMU linux_binprm::exec in transfer_args_to_stack()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Filippov <[email protected]>
commit 2aea94ac14d1e0a8ae9e34febebe208213ba72f7 upstream.
In NOMMU kernel the value of linux_binprm::p is the offset inside the temporary program arguments array maintained in separate pages in the linux_binprm::page. linux_binprm::exec being a copy of linux_binprm::p thus must be adjusted when that array is copied to the user stack. Without that adjustment the value passed by the NOMMU kernel to the ELF program in the AT_EXECFN entry of the aux array doesn't make any sense and it may break programs that try to access memory pointed to by that entry.
Adjust linux_binprm::exec before the successful return from the transfer_args_to_stack().
--- fs/exec.c | 1 + 1 file changed, 1 insertion(+)
fs/exec.c +1 -0
@@ -894,6 +894,7 @@ int transfer_args_to_stack(struct linux_ goto out; } + bprm->exec += *sp_location -MAX_ARG_PAGES *PAGE_SIZE ; *sp_location = sp; out:
Greg Kroah-Hartman
maintainerPATCH 327/396 hexagon: vmlinux.lds.S: handle attributes section
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 549aa9678a0b3981d4821bf244579d9937650562 upstream.
After the linked LLVM change, the build fails with CONFIG_LD_ORPHAN_WARN_LEVEL="error", which happens with allmodconfig:
ld.lld: error: vmlinux.a(init/main.o):(.hexagon.attributes) is being placed in '.hexagon.attributes'
Handle the attributes section in a similar manner as arm and riscv by adding it after the primary ELF_DETAILS grouping in vmlinux.lds.S, which fixes the error.
--- arch/hexagon/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+)
arch/hexagon/kernel/vmlinux.lds.S +1 -0
@@ -63,6 +63,7 @@ SECTIONS STABS_DEBUG DWARF_DEBUG ELF_DETAILS + .hexagon.attributes 0 : { *(.hexagon.attributes) } DISCARDS }
Greg Kroah-Hartman
maintainerPATCH 328/396 mm: cachestat: fix two shmem bugs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit d5d39c707a4cf0bcc84680178677b97aa2cb2627 upstream.
When cachestat on shmem races with swapping and invalidation, there are two possible bugs:
1) A swapin error can have resulted in a poisoned swap entry in the shmem inode's xarray. Calling get_shadow_from_swap_cache() on it will result in an out-of-bounds access to swapper_spaces[].
Validate the entry with non_swap_entry() before going further.
2) When we find a valid swap entry in the shmem's inode, the shadow entry in the swapcache might not exist yet: swap IO is still in progress and we're before __remove_mapping; swapin, invalidation, or swapoff have removed the shadow from swapcache after we saw the shmem swap entry.
This will send a NULL to workingset_test_recent(). The latter purely operates on pointer bits, so it won't crash - node 0, memcg ID 0, eviction timestamp 0, etc. are all valid inputs - but it's a bogus test. In theory that could result in a false "recently evicted" count.
Such a false positive wouldn't be the end of the world. But for code clarity and (future) robustness, be explicit about this case.
Bail on get_shadow_from_swap_cache() returning NULL.
--- mm/filemap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
mm/filemap.c +16 -0
@@ -4201,7 +4201,23 @@ static void filemap_cachestat(struct add/* shmem file - in swap cache */ swp_entry_t swp =radix_to_swp_entry (folio); +/* swapin error results in poisoned entry */ +if (non_swap_entry (swp)) + goto resched; + +/* +* Getting a swap entry from the shmem +* inode means we beat +* shmem_unuse(). rcu_read_lock() +* ensures swapoff waits for us before +* freeing the swapper space. However, +* we can race with swapping and +* invalidation, so there might not be +* a shadow in the swapcache (yet). +*/ shadow =get_shadow_from_swap_cache (swp); +if (!shadow) + goto resched; }#endif if (workingset_test_recent (shadow, true, &workingset))
Greg Kroah-Hartman
maintainerPATCH 329/396 selftests/mm: sigbus-wp test requires UFFD_FEATURE_WP_HUGETLBFS_SHMEM
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Liaw <[email protected]>
commit 105840ebd76d8dbc1a7d734748ae320076f3201e upstream.
The sigbus-wp test requires the UFFD_FEATURE_WP_HUGETLBFS_SHMEM flag for shmem and hugetlb targets. Otherwise it is not backwards compatible with kernels <5.19 and fails with EINVAL.
--- tools/testing/selftests/mm/uffd-unit-tests.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/mm/uffd-unit-tests.c +2 -1
@@ -1219,7 +1219,8 @@ uffd_test_case_t uffd_tests[] = { .uffd_fn = uffd_sigbus_wp_test, .mem_targets = MEM_ALL, .uffd_feature_required = UFFD_FEATURE_SIGBUS | - UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_PAGEFAULT_FLAG_WP, + UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_PAGEFAULT_FLAG_WP | + UFFD_FEATURE_WP_HUGETLBFS_SHMEM, }, { .name = "events",
Greg Kroah-Hartman
maintainerPATCH 330/396 selftests/mm: fix ARM related issue with fork after pthread_create
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Liaw <[email protected]>
commit 8c864371b2a15a23ce35aa7e2bd241baaad6fbe8 upstream.
Following issue was observed while running the uffd-unit-tests selftest on ARM devices. On x86_64 no issues were detected:
pthread_create followed by fork caused deadlock in certain cases wherein fork required some work to be completed by the created thread. Used synchronization to ensure that created thread's start function has started before invoking fork.
--- tools/testing/selftests/mm/uffd-common.c | 3 +++ tools/testing/selftests/mm/uffd-common.h | 2 ++ tools/testing/selftests/mm/uffd-unit-tests.c | 10 ++++++++++ 3 files changed, 15 insertions(+)
tools/testing/selftests/mm/uffd-common.c +3 -0
@@ -17,6 +17,7 @@ bool map_shared;bool test_uffdio_wp = true;unsigned long long *count_verify;uffd_test_ops_t *uffd_test_ops; +atomic_bool ready_for_fork;static int uffd_mem_fd_create (off_t mem_size,bool hugetlb) {
@@ -507,6 +508,8 @@ void *uffd_poll_thread(void *arg) pollfd[1 ].fd = pipefd[cpu*2 ]; pollfd[1 ].events =POLLIN ; + ready_for_fork = true; +for (;;) { ret =poll (pollfd,2 ,-1 );if (ret <=0 ) {
tools/testing/selftests/mm/uffd-common.h +2 -0
@@ -32,6 +32,7 @@#include <inttypes.h> #include <stdint.h> #include <sys/random.h> +#include <stdatomic.h> #include "../kselftest.h" #include "vm_util.h"
@@ -97,6 +98,7 @@ extern bool map_shared;extern bool test_uffdio_wp;extern unsigned long long *count_verify;extern volatile bool test_uffdio_copy_eexist; +extern atomic_bool ready_for_fork;extern uffd_test_ops_t anon_uffd_test_ops;extern uffd_test_ops_t shmem_uffd_test_ops;
tools/testing/selftests/mm/uffd-unit-tests.c +10 -0
@@ -770,6 +770,8 @@ static void uffd_sigbus_test_common(boolchar c;struct uffd_args args = {0 }; + ready_for_fork = false; +fcntl (uffd,F_SETFL , uffd_flags |O_NONBLOCK ); if (uffd_register(uffd, area_dst, nr_pages * page_size,
@@ -785,6 +787,9 @@ static void uffd_sigbus_test_common(boolif (pthread_create (&uffd_mon,NULL , uffd_poll_thread, &args))err ("uffd_poll_thread create" ); +while (!ready_for_fork) + ;/* Wait for the poll_thread to start executing before forking */ + pid =fork ();if (pid <0 )err ("fork" );
@@ -824,6 +829,8 @@ static void uffd_events_test_common(boolchar c;struct uffd_args args = {0 }; + ready_for_fork = false; +fcntl (uffd,F_SETFL , uffd_flags |O_NONBLOCK );if (uffd_register (uffd, area_dst, nr_pages * page_size, true, wp, false))
@@ -833,6 +840,9 @@ static void uffd_events_test_common(boolif (pthread_create (&uffd_mon,NULL , uffd_poll_thread, &args))err ("uffd_poll_thread create" ); +while (!ready_for_fork) + ;/* Wait for the poll_thread to start executing before forking */ + pid =fork ();if (pid <0 )err ("fork" );
Greg Kroah-Hartman
maintainerPATCH 331/396 mmc: sdhci-omap: re-tuning is needed after a pm transition to support emmc HS200 mode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Romain Naour <[email protected]>
commit f9e2a5b00a35f2c064dc679808bc8db5cc779ed6 upstream.
"PM runtime functions" was been added in sdhci-omap driver in commit f433e8aac6b9 ("mmc: sdhci-omap: Implement PM runtime functions") along with "card power off and enable aggressive PM" in commit 3edf588e7fe0 ("mmc: sdhci-omap: Allow SDIO card power off and enable aggressive PM").
Since then, the sdhci-omap driver doesn't work using mmc-hs200 mode due to the tuning values being lost during a pm transition.
As for the sdhci_am654 driver, request a new tuning sequence before suspend (sdhci_omap_runtime_suspend()), otherwise the device will trigger cache flush error:
mmc1: cache flush error -110 (ETIMEDOUT)
mmc1: error -110 doing aggressive suspend
followed by I/O errors produced by fdisk -l /dev/mmcblk1boot1:
I/O error, dev mmcblk1boot0, sector 64384 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
I/O error, dev mmcblk1boot1, sector 64384 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
I/O error, dev mmcblk1boot1, sector 64384 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1boot1, logical block 8048, async page read I/O error, dev mmcblk1boot0, sector 64384 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1boot0, logical block 8048, async page read
Don't re-tune if auto retuning is supported in HW (when SDHCI_TUNING_MODE_3 is available).
--- drivers/mmc/host/sdhci-omap.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci-omap.c +3 -0
@@ -1439,6 +1439,9 @@ static int __maybe_unused sdhci_omap_runstruct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); +if (host->tuning_mode !=SDHCI_TUNING_MODE_3 ) +mmc_retune_needed (host->mmc); +if (omap_host->con != -EINVAL )sdhci_runtime_suspend_host (host);
Greg Kroah-Hartman
maintainerPATCH 332/396 mmc: core: Initialize mmc_blk_ioc_data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Rapeli <[email protected]>
commit 0cdfe5b0bf295c0dee97436a8ed13336933a0211 upstream.
Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") adds flags uint to struct mmc_blk_ioc_data, but it does not get initialized for RPMB ioctls which now fails.
Let's fix this by always initializing the struct and flags to zero.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -413,7 +413,7 @@ static struct mmc_blk_ioc_data *mmc_blk_struct mmc_blk_ioc_data *idata;int err; - idata =kmalloc (sizeof (*idata),GFP_KERNEL ); + idata =kzalloc (sizeof (*idata),GFP_KERNEL );if (!idata) { err = -ENOMEM ; goto out;
Greg Kroah-Hartman
maintainerPATCH 333/396 mmc: core: Avoid negative index with array access
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Rapeli <[email protected]>
commit cf55a7acd1ed38afe43bba1c8a0935b51d1dc014 upstream.
Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") assigns prev_idata = idatas[i - 1], but doesn't check that the iterator i is greater than zero. Let's fix this by adding a check.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -488,7 +488,7 @@ static int __mmc_blk_ioctl_cmd(struct mmif (idata->flags &MMC_BLK_IOC_DROP )return 0 ; -if (idata->flags &MMC_BLK_IOC_SBC ) +if (idata->flags &MMC_BLK_IOC_SBC && i >0 ) prev_idata = idatas[i -1 ];/*
Greg Kroah-Hartman
maintainerPATCH 334/396 sdhci-of-dwcmshc: disable PM runtime in dwcmshc_remove()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liming Sun <[email protected]>
commit 03749309909935070253accab314288d332a204d upstream.
This commit disables PM runtime in dwcmshc_remove() to avoid the error message below when reloading the sdhci-of-dwcmshc.ko
sdhci-dwcmshc MLNXBF30:00: Unbalanced pm_runtime_enable!
--- drivers/mmc/host/sdhci-of-dwcmshc.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/mmc/host/sdhci-of-dwcmshc.c +17 -11
@@ -584,6 +584,17 @@ free_pltfm:return err; } +static void dwcmshc_disable_card_clk (struct sdhci_host *host) +{ +u16 ctrl; + + ctrl =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); +if (ctrl &SDHCI_CLOCK_CARD_EN ) { + ctrl &= ~SDHCI_CLOCK_CARD_EN ; +sdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); + } +} +static void dwcmshc_remove (struct platform_device *pdev) {struct sdhci_host *host =platform_get_drvdata (pdev);
@@ -591,8 +602,14 @@ static void dwcmshc_remove(struct platfostruct dwcmshc_priv *priv =sdhci_pltfm_priv (pltfm_host);struct rk35xx_priv *rk_priv = priv->priv; +pm_runtime_get_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +sdhci_remove_host (host,0 ); +dwcmshc_disable_card_clk (host); +clk_disable_unprepare (pltfm_host->clk);clk_disable_unprepare (priv->bus_clk);if (rk_priv)
@@ -683,17 +700,6 @@ static void dwcmshc_enable_card_clk(strusdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); } } - -static void dwcmshc_disable_card_clk (struct sdhci_host *host) -{ -u16 ctrl; - - ctrl =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); -if (ctrl &SDHCI_CLOCK_CARD_EN ) { - ctrl &= ~SDHCI_CLOCK_CARD_EN ; -sdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); - } -}static int dwcmshc_runtime_suspend (struct device *dev) {
Greg Kroah-Hartman
maintainerPATCH 335/396 block: Do not force full zone append completion in req_bio_endio()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 55251fbdf0146c252ceff146a1bb145546f3e034 upstream.
This reverts commit 748dc0b65ec2b4b7b3dbd7befcc4a54fdcac7988.
Partial zone append completions cannot be supported as there is no guarantees that the fragmented data will be written sequentially in the same manner as with a full command. Commit 748dc0b65ec2 ("block: fix partial zone append completion handling in req_bio_endio()") changed req_bio_endio() to always advance a partially failed BIO by its full length, but this can lead to incorrect accounting. So revert this change and let low level device drivers handle this case by always failing completely zone append operations. With this revert, users will still see an IO error for a partially completed zone append BIO.
--- block/blk-mq.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
block/blk-mq.c +2 -7
@@ -767,16 +767,11 @@ static void req_bio_endio(struct request/* * Partial zone append completions cannot be supported as the * BIO fragments may end up not being written sequentially. -* For such case, force the completed nbytes to be equal to -* the BIO size so that bio_advance() sets the BIO remaining -* size to 0 and we end up calling bio_endio() before returning. */ -if (bio->bi_iter.bi_size != nbytes) { +if (bio->bi_iter.bi_size != nbytes) bio->bi_status =BLK_STS_IOERR ; - nbytes = bio->bi_iter.bi_size; - }else { +else bio->bi_iter.bi_sector = rq->__sector; - } }bio_advance (bio, nbytes);
Greg Kroah-Hartman
maintainerPATCH 336/396 thermal: devfreq_cooling: Fix perf state when calculate dfc res_util
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Zhang <[email protected]>
commit a26de34b3c77ae3a969654d94be49e433c947e3b upstream.
The issue occurs when the devfreq cooling device uses the EM power model and the get_real_power() callback is provided by the driver.
The EM power table is sorted ascending,can't index the table by cooling device state,so convert cooling state to performance state by dfc->max_state - dfc->capped_state.
--- drivers/thermal/devfreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/devfreq_cooling.c +1 -1
@@ -201,7 +201,7 @@ static int devfreq_cooling_get_requested res = dfc->power_ops->get_real_power (df, power, freq, voltage);if (!res) { - state = dfc->capped_state; + state = dfc->max_state - dfc->capped_state;/* Convert EM power into milli-Watts first */ dfc->res_util = dfc->em_pd->table[state].power;
Greg Kroah-Hartman
maintainerPATCH 337/396 nouveau/dmem: handle kcalloc() allocation failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 16e87fe23d4af6df920406494ced5c0f4354567b upstream.
The kcalloc() in nouveau_dmem_evict_chunk() will return null if the physical memory has run out. As a result, if we dereference src_pfns, dst_pfns or dma_addrs, the null pointer dereference bugs will happen.
Moreover, the GPU is going away. If the kcalloc() fails, we could not evict all pages mapping a chunk. So this patch adds a __GFP_NOFAIL flag in kcalloc().
Finally, as there is no need to have physically contiguous memory, this patch switches kcalloc() to kvcalloc() in order to avoid failing allocations.
--- drivers/gpu/drm/nouveau/nouveau_dmem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dmem.c +6 -6
@@ -378,9 +378,9 @@ nouveau_dmem_evict_chunk(struct nouveau_dma_addr_t *dma_addrs;struct nouveau_fence *fence; - src_pfns =kcalloc (npages,sizeof (*src_pfns),GFP_KERNEL ); - dst_pfns =kcalloc (npages,sizeof (*dst_pfns),GFP_KERNEL ); - dma_addrs =kcalloc (npages,sizeof (*dma_addrs),GFP_KERNEL ); + src_pfns =kvcalloc (npages,sizeof (*src_pfns),GFP_KERNEL | __GFP_NOFAIL); + dst_pfns =kvcalloc (npages,sizeof (*dst_pfns),GFP_KERNEL | __GFP_NOFAIL); + dma_addrs =kvcalloc (npages,sizeof (*dma_addrs),GFP_KERNEL | __GFP_NOFAIL);migrate_device_range (src_pfns, chunk->pagemap.range.start >>PAGE_SHIFT , npages);
@@ -406,11 +406,11 @@ nouveau_dmem_evict_chunk(struct nouveau_migrate_device_pages (src_pfns, dst_pfns, npages);nouveau_dmem_fence_done (&fence);migrate_device_finalize (src_pfns, dst_pfns, npages); -kfree (src_pfns); -kfree (dst_pfns); +kvfree (src_pfns); +kvfree (dst_pfns);for (i =0 ; i < npages; i++)dma_unmap_page (chunk->drm->dev->dev, dma_addrs[i],PAGE_SIZE ,DMA_BIDIRECTIONAL ); -kfree (dma_addrs); +kvfree (dma_addrs); }void
Greg Kroah-Hartman
maintainerPATCH 338/396 net: ll_temac: platform_get_resource replaced by wrong function
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claus Hansen Ries <[email protected]>
commit 3a38a829c8bc27d78552c28e582eb1d885d07d11 upstream.
The function platform_get_resource was replaced with devm_platform_ioremap_resource_byname and is called using 0 as name.
This eventually ends up in platform_get_resource_byname in the call stack, where it causes a null pointer in strcmp.
if (type == resource_type(r) && !strcmp(r->name, name))
It should have been replaced with devm_platform_ioremap_resource.
--- drivers/net/ethernet/xilinx/ll_temac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +1 -1
@@ -1443,7 +1443,7 @@ static int temac_probe(struct platform_d }/* map device registers */ - lp->regs =devm_platform_ioremap_resource_byname (pdev,0 ); + lp->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (lp->regs)) {dev_err (&pdev->dev,"could not map TEMAC registers\n" );return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 339/396 drm/vmwgfx: Create debugfs ttm_resource_manager entry only if needed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jocelyn Falempe <[email protected]>
commit 4be9075fec0a639384ed19975634b662bfab938f upstream.
The driver creates /sys/kernel/debug/dri/0/mob_ttm even when the corresponding ttm_resource_manager is not allocated. This leads to a crash when trying to read from this file.
Add a check to create mob_ttm, system_mob_ttm, and gmr_ttm debug file only when the corresponding ttm_resource_manager is allocated.
crash> bt
PID: 3133409 TASK: ffff8fe4834a5000 CPU: 3 COMMAND: "grep"
#0 [ffffb954506b3b20] machine_kexec at ffffffffb2a6bec3 #1 [ffffb954506b3b78] __crash_kexec at ffffffffb2bb598a #2 [ffffb954506b3c38] crash_kexec at ffffffffb2bb68c1 #3 [ffffb954506b3c50] oops_end at ffffffffb2a2a9b1
#4 [ffffb954506b3c70] no_context at ffffffffb2a7e913 #5 [ffffb954506b3cc8] __bad_area_nosemaphore at ffffffffb2a7ec8c #6 [ffffb954506b3d10] do_page_fault at ffffffffb2a7f887 #7 [ffffb954506b3d40] page_fault at ffffffffb360116e
[exception RIP: ttm_resource_manager_debug+0x11]
RIP: ffffffffc04afd11 RSP: ffffb954506b3df0 RFLAGS: 00010246
RAX: ffff8fe41a6d1200 RBX: 0000000000000000 RCX: 0000000000000940
RDX: 0000000000000000 RSI: ffffffffc04b4338 RDI: 0000000000000000
RBP: ffffb954506b3e08 R8: ffff8fee3ffad000 R9: 0000000000000000
R10: ffff8fe41a76a000 R11: 0000000000000001 R12: 00000000ffffffff
R13: 0000000000000001 R14: ffff8fe5bb6f3900 R15: ffff8fe41a6d1200
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#8 [ffffb954506b3e00] ttm_resource_manager_show at ffffffffc04afde7 [ttm]
#9 [ffffb954506b3e30] seq_read at ffffffffb2d8f9f3
RIP: 00007f4c4eda8985 RSP: 00007ffdbba9e9f8 RFLAGS: 00000246
RAX: ffffffffffffffda RBX: 000000000037e000 RCX: 00007f4c4eda8985
RDX: 000000000037e000 RSI: 00007f4c41573000 RDI: 0000000000000003
RBP: 000000000037e000 R8: 0000000000000000 R9: 000000000037fe30
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f4c41573000
R13: 0000000000000003 R14: 00007f4c41572010 R15: 0000000000000003
ORIG_RAX: 0000000000000000 CS: 0033 SS: 002b--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +9 -6
@@ -1444,12 +1444,15 @@ static void vmw_debugfs_resource_manager root, "system_ttm");ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,TTM_PL_VRAM ), root,"vram_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_GMR ), - root,"gmr_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_MOB ), - root,"mob_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_SYSTEM ), - root,"system_mob_ttm" ); +if (vmw->has_gmr) +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_GMR ), + root,"gmr_ttm" ); +if (vmw->has_mob) { +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_MOB ), + root,"mob_ttm" ); +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_SYSTEM ), + root,"system_mob_ttm" ); + } } static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
Greg Kroah-Hartman
maintainerPATCH 340/396 drm/amdkfd: fix TLB flush after unmap for GFX9.4.2
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Huang <[email protected]>
commit 1210e2f1033dc56b666c9f6dfb761a2d3f9f5d6c upstream.
TLB flush after unmap accidentially was removed on gfx9.4.2. It is to add it back.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -1
@@ -1466,7 +1466,7 @@ void kfd_flush_tlb(struct kfd_process_destatic inline bool kfd_flush_tlb_after_unmap (struct kfd_dev *dev) { -return KFD_GC_VERSION (dev) >IP_VERSION (9 ,4 ,2 ) || +return KFD_GC_VERSION (dev) >=IP_VERSION (9 ,4 ,2 ) || (KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,1 ) && dev->sdma_fw_version >=18 ) ||KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,0 ); }
Greg Kroah-Hartman
maintainerPATCH 341/396 drm/amdgpu: fix deadlock while reading mqd from debugfs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit 8678b1060ae2b75feb60b87e5b75e17374e3c1c5 upstream.
An errant disk backup on my desktop got into debugfs and triggered the following deadlock scenario in the amdgpu debugfs files. The machine also hard-resets immediately after those lines are printed (although I wasn't able to reproduce that part when reading by hand):
[ 1318.016074][ T1082] ======================================================
[ 1318.016607][ T1082] WARNING: possible circular locking dependency detected
[ 1318.017107][ T1082] 6.8.0-rc7-00015-ge0c8221b72c0 #17 Not tainted
[ 1318.017598][ T1082] ------------------------------------------------------
[ 1318.018096][ T1082] tar/1082 is trying to acquire lock:
[ 1318.018585][ T1082] ffff98c44175d6a0 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0x40/0x80
[ 1318.019084][ T1082]
[ 1318.019084][ T1082] but task is already holding lock:
[ 1318.020052][ T1082] ffff98c4c13f55f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: amdgpu_debugfs_mqd_read+0x6a/0x250 [amdgpu]
[ 1318.020607][ T1082]
[ 1318.020607][ T1082] which lock already depends on the new lock.
[ 1318.020607][ T1082]
[ 1318.022081][ T1082]
[ 1318.022081][ T1082] the existing dependency chain (in reverse order) is:
[ 1318.023083][ T1082]
[ 1318.023083][ T1082] -> #2 (reservation_ww_class_mutex){+.+.}-{3:3}:
[ 1318.024114][ T1082] __ww_mutex_lock.constprop.0+0xe0/0x12f0
[ 1318.024639][ T1082] ww_mutex_lock+0x32/0x90
[ 1318.025161][ T1082] dma_resv_lockdep+0x18a/0x330
[ 1318.025683][ T1082] do_one_initcall+0x6a/0x350
[ 1318.026210][ T1082] kernel_init_freeable+0x1a3/0x310
[ 1318.026728][ T1082] kernel_init+0x15/0x1a0
[ 1318.027242][ T1082] ret_from_fork+0x2c/0x40
[ 1318.027759][ T1082] ret_from_fork_asm+0x11/0x20
[ 1318.028281][ T1082]
[ 1318.028281][ T1082] -> #1 (reservation_ww_class_acquire){+.+.}-{0:0}:
[ 1318.029297][ T1082] dma_resv_lockdep+0x16c/0x330
[ 1318.029790][ T1082] do_one_initcall+0x6a/0x350
[ 1318.030263][ T1082] kernel_init_freeable+0x1a3/0x310
[ 1318.030722][ T1082] kernel_init+0x15/0x1a0
[ 1318.031168][ T1082] ret_from_fork+0x2c/0x40
[ 1318.031598][ T1082] ret_from_fork_asm+0x11/0x20
[ 1318.032011][ T1082]
[ 1318.032011][ T1082] -> #0 (&mm->mmap_lock){++++}-{3:3}:
[ 1318.032778][ T1082] __lock_acquire+0x14bf/0x2680
[ 1318.033141][ T1082] lock_acquire+0xcd/0x2c0
[ 1318.033487][ T1082] __might_fault+0x58/0x80
[ 1318.033814][ T1082] amdgpu_debugfs_mqd_read+0x103/0x250 [amdgpu]
[ 1318.034181][ T1082] full_proxy_read+0x55/0x80
[ 1318.034487][ T1082] vfs_read+0xa7/0x360
[ 1318.034788][ T1082] ksys_read+0x70/0xf0
[ 1318.035085][ T1082] do_syscall_64+0x94/0x180
[ 1318.035375][ T1082] entry_SYSCALL_64_after_hwframe+0x46/0x4e
[ 1318.035664][ T1082]
[ 1318.035664][ T1082] other info that might help us debug this:
[ 1318.035664][ T1082]
[ 1318.036487][ T1082] Chain exists of:
[ 1318.036487][ T1082] &mm->mmap_lock --> reservation_ww_class_acquire --> reservation_ww_class_mutex
[ 1318.036487][ T1082]
[ 1318.037310][ T1082] Possible unsafe locking scenario:
[ 1318.037310][ T1082]
[ 1318.037838][ T1082] CPU0 CPU1
[ 1318.038101][ T1082] ---- ----
[ 1318.038350][ T1082] lock(reservation_ww_class_mutex);
[ 1318.038590][ T1082] lock(reservation_ww_class_acquire);
[ 1318.038839][ T1082] lock(reservation_ww_class_mutex);
[ 1318.039083][ T1082] rlock(&mm->mmap_lock);
[ 1318.039328][ T1082]
[ 1318.039328][ T1082] *** DEADLOCK ***
[ 1318.039328][ T1082]
[ 1318.040029][ T1082] 1 lock held by tar/1082:
[ 1318.040259][ T1082] #0: ffff98c4c13f55f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: amdgpu_debugfs_mqd_read+0x6a/0x250 [amdgpu]
[ 1318.040560][ T1082]
[ 1318.040560][ T1082] stack backtrace:
[ 1318.041053][ T1082] CPU: 22 PID: 1082 Comm: tar Not tainted 6.8.0-rc7-00015-ge0c8221b72c0 #17 3316c85d50e282c5643b075d1f01a4f6365e39c2
[ 1318.041329][ T1082] Hardware name: Gigabyte Technology Co., Ltd. B650 AORUS PRO AX/B650 AORUS PRO AX, BIOS F20 12/14/2023
[ 1318.041614][ T1082] Call Trace:
[ 1318.041895][ T1082] <TASK>
[ 1318.042175][ T1082] dump_stack_lvl+0x4a/0x80
[ 1318.042460][ T1082] check_noncircular+0x145/0x160
[ 1318.042743][ T1082] __lock_acquire+0x14bf/0x2680
[ 1318.043022][ T1082] lock_acquire+0xcd/0x2c0
[ 1318.043301][ T1082] ? __might_fault+0x40/0x80
[ 1318.043580][ T1082] ? __might_fault+0x40/0x80
[ 1318.043856][ T1082] __might_fault+0x58/0x80
[ 1318.044131][ T1082] ? __might_fault+0x40/0x80
[ 1318.044408][ T1082] amdgpu_debugfs_mqd_read+0x103/0x250 [amdgpu 8fe2afaa910cbd7654c8cab23563a94d6caebaab]
[ 1318.044749][ T1082] full_proxy_read+0x55/0x80
[ 1318.045042][ T1082] vfs_read+0xa7/0x360
[ 1318.045333][ T1082] ksys_read+0x70/0xf0
[ 1318.045623][ T1082] do_syscall_64+0x94/0x180
[ 1318.045913][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.046201][ T1082] ? lockdep_hardirqs_on+0x7d/0x100
[ 1318.046487][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.046773][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047057][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047337][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047611][ T1082] entry_SYSCALL_64_after_hwframe+0x46/0x4e
[ 1318.047887][ T1082] RIP: 0033:0x7f480b70a39d
[ 1318.048162][ T1082] Code: 91 ba 0d 00 f7 d8 64 89 02 b8 ff ff ff ff eb b2 e8 18 a3 01 00 0f 1f 84 00 00 00 00 00 80 3d a9 3c 0e 00 00 74 17 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 5b c3 66 2e 0f 1f 84 00 00 00 00 00 53 48 83
[ 1318.048769][ T1082] RSP: 002b:00007ffde77f5c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 1318.049083][ T1082] RAX: ffffffffffffffda RBX: 0000000000000800 RCX: 00007f480b70a39d
[ 1318.049392][ T1082] RDX: 0000000000000800 RSI: 000055c9f2120c00 RDI: 0000000000000008
[ 1318.049703][ T1082] RBP: 0000000000000800 R08: 000055c9f2120a94 R09: 0000000000000007
[ 1318.050011][ T1082] R10: 0000000000000000 R11: 0000000000000246 R12: 000055c9f2120c00
[ 1318.050324][ T1082] R13: 0000000000000008 R14: 0000000000000008 R15: 0000000000000800
[ 1318.050638][ T1082] </TASK>amdgpu_debugfs_mqd_read() holds a reservation when it calls put_user(), which may fault and acquire the mmap_sem. This violates the established locking order.
Bounce the mqd data through a kernel buffer to get put_user() out of the illegal section.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 46 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +29 -17
@@ -520,46 +520,58 @@ static ssize_t amdgpu_debugfs_mqd_read(s {struct amdgpu_ring *ring =file_inode (f)->i_private;volatile u32 *mqd; -int r; +u32 *kbuf; +int r, i;uint32_t value, result;if (*pos &3 || size &3 )return -EINVAL ; - result =0 ; + kbuf =kmalloc (ring->mqd_size,GFP_KERNEL ); +if (!kbuf) +return -ENOMEM ; r =amdgpu_bo_reserve (ring->mqd_obj, false);if (unlikely (r !=0 )) -return r; + goto err_free; r =amdgpu_bo_kmap (ring->mqd_obj, (void **)&mqd); -if (r) { -amdgpu_bo_unreserve (ring->mqd_obj); -return r; - } +if (r) + goto err_unreserve; + +/* +* Copy to local buffer to avoid put_user(), which might fault +* and acquire mmap_sem, under reservation_ww_class_mutex. +*/ +for (i =0 ; i < ring->mqd_size/sizeof (u32); i++) + kbuf[i] = mqd[i]; + +amdgpu_bo_kunmap (ring->mqd_obj); +amdgpu_bo_unreserve (ring->mqd_obj); + result =0 ;while (size) {if (*pos >= ring->mqd_size) - goto done; +break ; - value = mqd[*pos/4 ]; + value = kbuf[*pos/4 ]; r =put_user (value, (uint32_t *)buf);if (r) - goto done; + goto err_free; buf +=4 ; result +=4 ; size -=4 ; *pos +=4 ; } -done: -amdgpu_bo_kunmap (ring->mqd_obj); - mqd =NULL ; -amdgpu_bo_unreserve (ring->mqd_obj); -if (r) -return r; - +kfree (kbuf);return result; + +err_unreserve: +amdgpu_bo_unreserve (ring->mqd_obj); +err_free: +kfree (kbuf); +return r; }static const struct file_operations amdgpu_debugfs_mqd_fops = {
Greg Kroah-Hartman
maintainerPATCH 342/396 drm/i915/hwmon: Fix locking inversion in sysfs getter
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janusz Krzysztofik <[email protected]>
commit b212b79768ccde74429f872c37618c543fa11333 upstream.
In i915 hwmon sysfs getter path we now take a hwmon_lock, then acquire an rpm wakeref. That results in lock inversion:
<4> [197.079335] ======================================================
<4> [197.085473] WARNING: possible circular locking dependency detected
<4> [197.091611] 6.8.0-rc7-Patchwork_129026v7-gc4dc92fb1152+ #1 Not tainted
<4> [197.098096] ------------------------------------------------------
<4> [197.104231] prometheus-node/839 is trying to acquire lock:
<4> [197.109680] ffffffff82764d80 (fs_reclaim){+.+.}-{0:0}, at: __kmalloc+0x9a/0x350 <4> [197.116939]
but task is already holding lock:
<4> [197.122730] ffff88811b772a40 (&hwmon->hwmon_lock){+.+.}-{3:3}, at: hwm_energy+0x4b/0x100 [i915] <4> [197.131543]
which lock already depends on the new lock.
...
<4> [197.507922] Chain exists of:
fs_reclaim --> >->reset.mutex --> &hwmon->hwmon_lock
<4> [197.518528] Possible unsafe locking scenario:
<4> [197.524411] CPU0 CPU1 <4> [197.528916] ---- ----
<4> [197.533418] lock(&hwmon->hwmon_lock);
<4> [197.537237] lock(>->reset.mutex);
<4> [197.543376] lock(&hwmon->hwmon_lock);
<4> [197.549682] lock(fs_reclaim);
...
<4> [197.632548] Call Trace:
<4> [197.634990] <TASK> <4> [197.637088] dump_stack_lvl+0x64/0xb0 <4> [197.640738] check_noncircular+0x15e/0x180 <4> [197.652968] check_prev_add+0xe9/0xce0 <4> [197.656705] __lock_acquire+0x179f/0x2300 <4> [197.660694] lock_acquire+0xd8/0x2d0 <4> [197.673009] fs_reclaim_acquire+0xa1/0xd0 <4> [197.680478] __kmalloc+0x9a/0x350 <4> [197.689063] acpi_ns_internalize_name.part.0+0x4a/0xb0 <4> [197.694170] acpi_ns_get_node_unlocked+0x60/0xf0 <4> [197.720608] acpi_ns_get_node+0x3b/0x60 <4> [197.724428] acpi_get_handle+0x57/0xb0 <4> [197.728164] acpi_has_method+0x20/0x50 <4> [197.731896] acpi_pci_set_power_state+0x43/0x120 <4> [197.736485] pci_power_up+0x24/0x1c0 <4> [197.740047] pci_pm_default_resume_early+0x9/0x30 <4> [197.744725] pci_pm_runtime_resume+0x2d/0x90 <4> [197.753911] __rpm_callback+0x3c/0x110 <4> [197.762586] rpm_callback+0x58/0x70 <4> [197.766064] rpm_resume+0x51e/0x730 <4> [197.769542] rpm_resume+0x267/0x730 <4> [197.773020] rpm_resume+0x267/0x730 <4> [197.776498] rpm_resume+0x267/0x730 <4> [197.779974] __pm_runtime_resume+0x49/0x90 <4> [197.784055] __intel_runtime_pm_get+0x19/0xa0 [i915] <4> [197.789070] hwm_energy+0x55/0x100 [i915] <4> [197.793183] hwm_read+0x9a/0x310 [i915] <4> [197.797124] hwmon_attr_show+0x36/0x120 <4> [197.800946] dev_attr_show+0x15/0x60 <4> [197.804509] sysfs_kf_seq_show+0xb5/0x100
Acquire the wakeref before the lock and hold it as long as the lock is also held. Follow that pattern across the whole source file where similar lock inversion can happen.
v2: Keep hardware read under the lock so the whole operation of updating
energy from hardware is still atomic (Guenter),
- instead, acquire the rpm wakeref before the lock and hold it as long as the lock is held,
- use the same aproach for other similar places across the i915_hwmon.c source file (Rodrigo).
--- drivers/gpu/drm/i915/i915_hwmon.c | 37 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_hwmon.c +19 -18
@@ -72,12 +72,13 @@ hwm_locked_with_pm_intel_uncore_rmw(struct hwm_drvdata *ddat,struct intel_uncore *uncore = ddat->uncore;intel_wakeref_t wakeref; -mutex_lock (&hwmon->hwmon_lock); + with_intel_runtime_pm(uncore->rpm, wakeref) { +mutex_lock (&hwmon->hwmon_lock); - with_intel_runtime_pm(uncore->rpm, wakeref)intel_uncore_rmw (uncore, reg, clear, set); -mutex_unlock (&hwmon->hwmon_lock); +mutex_unlock (&hwmon->hwmon_lock); + } }/*
@@ -136,20 +137,21 @@ hwm_energy(struct hwm_drvdata *ddat, long *energy)else rgaddr = hwmon->rg.energy_status_all; -mutex_lock (&hwmon->hwmon_lock); + with_intel_runtime_pm(uncore->rpm, wakeref) { +mutex_lock (&hwmon->hwmon_lock); -with_intel_runtime_pm (uncore->rpm, wakeref) reg_val =intel_uncore_read (uncore, rgaddr); -if (reg_val >= ei->reg_val_prev) - ei->accum_energy += reg_val - ei->reg_val_prev; -else - ei->accum_energy +=UINT_MAX - ei->reg_val_prev + reg_val; - ei->reg_val_prev = reg_val; +if (reg_val >= ei->reg_val_prev) + ei->accum_energy += reg_val - ei->reg_val_prev; +else + ei->accum_energy +=UINT_MAX - ei->reg_val_prev + reg_val; + ei->reg_val_prev = reg_val; - *energy =mul_u64_u32_shr (ei->accum_energy,SF_ENERGY , - hwmon->scl_shift_energy); -mutex_unlock (&hwmon->hwmon_lock); + *energy =mul_u64_u32_shr (ei->accum_energy,SF_ENERGY , + hwmon->scl_shift_energy); +mutex_unlock (&hwmon->hwmon_lock); + } } static ssize_t
@@ -404,6 +406,7 @@ hwm_power_max_write(struct hwm_drvdata *ddat, long val)/* Block waiting for GuC reset to complete when needed */ for (;;) { + wakeref =intel_runtime_pm_get (ddat->uncore->rpm);mutex_lock (&hwmon->hwmon_lock);prepare_to_wait (&ddat->waitq, &wait,TASK_INTERRUPTIBLE );
@@ -417,14 +420,13 @@ hwm_power_max_write(struct hwm_drvdata *ddat, long val) }mutex_unlock (&hwmon->hwmon_lock); +intel_runtime_pm_put (ddat->uncore->rpm, wakeref);schedule (); }finish_wait (&ddat->waitq, &wait);if (ret) - goto unlock; - - wakeref =intel_runtime_pm_get (ddat->uncore->rpm); + goto exit;/* Disable PL1 limit and verify, because the limit cannot be disabled on all platforms */ if (val ==PL1_DISABLE ) {
@@ -444,9 +446,8 @@ hwm_power_max_write(struct hwm_drvdata *ddat, long val)intel_uncore_rmw (ddat->uncore, hwmon->rg.pkg_rapl_limit,PKG_PWR_LIM_1_EN |PKG_PWR_LIM_1 , nval); exit: -intel_runtime_pm_put (ddat->uncore->rpm, wakeref); -unlock:mutex_unlock (&hwmon->hwmon_lock); +intel_runtime_pm_put (ddat->uncore->rpm, wakeref);return ret; }
Signature · 1 line
2.44.0
Greg Kroah-Hartman
maintainerPATCH 343/396 drm/i915/bios: Tolerate devdata==NULL in intel_bios_encoder_supports_dp_dual_mode()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 32e39bab59934bfd3f37097d4dd85ac5eb0fd549 upstream.
If we have no VBT, or the VBT didn't declare the encoder in question, we won't have the 'devdata' for the encoder. Instead of oopsing just bail early.
We won't be able to tell whether the port is DP++ or not, but so be it.
--- drivers/gpu/drm/i915/display/intel_bios.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/display/intel_bios.c +3 -0
@@ -3313,6 +3313,9 @@ bool intel_bios_encoder_supports_dp_dual {const struct child_device_config *child = &devdata->child; +if (!devdata) +return false; +if (!intel_bios_encoder_supports_dp (devdata) || !intel_bios_encoder_supports_hdmi (devdata))return false;
Greg Kroah-Hartman
maintainerPATCH 344/396 drm/i915/dsi: Go back to the previous INIT_OTP/DISPLAY_ON order, mostly
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 18846627ef1210dcd55d65342b055ea97a46ffff upstream.
Reinstate commit 88b065943cb5 ("drm/i915/dsi: Do display on sequence later on icl+"), for the most part. Turns out some machines (eg. Chuwi Minibook X) really do need that updated order. It is also the order the Windows driver uses.
However we can't just undo the revert since that would again break Lenovo 82TQ. After staring at the VBT sequences for both machines I've concluded that the Lenovo 82TQ sequences look somewhat broken:
- INIT_OTP is not present at all
- what should be in INIT_OTP is found in DISPLAY_ON
- what should be in DISPLAY_ON is found in BACKLIGHT_ON (along with the actual backlight stuff)
The Chuwi Minibook X on the other hand has a full complement of sequences in its VBT.
So let's try to deal with the broken sequences in the Lenovo 82TQ VBT by simply swapping the (non-existent) INIT_OTP sequence with the DISPLAY_ON sequence. Thus we execute DISPLAY_ON when intending to execute INIT_OTP, and execute nothing at all when intending to execute DISPLAY_ON. That should be 100% equivalent to the revert, for such broken VBTs.
References: https://gitlab.freedesktop.org/drm/intel/-/issues/10071
--- drivers/gpu/drm/i915/display/icl_dsi.c | 3 +- drivers/gpu/drm/i915/display/intel_bios.c | 43 +++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/display/icl_dsi.c +2 -1
@@ -1155,7 +1155,6 @@ static void gen11_dsi_powerup_panel(stru }intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_INIT_OTP ); -intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_DISPLAY_ON );/* ensure all panel commands dispatched before enabling transcoder */ wait_for_cmds_dispatched_to_panel (encoder);
@@ -1256,6 +1255,8 @@ static void gen11_dsi_enable(struct inte/* step6d: enable dsi transcoder */ gen11_dsi_enable_transcoder (encoder); +intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_DISPLAY_ON ); +/* step7: enable backlight */ intel_backlight_enable (crtc_state, conn_state);intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_BACKLIGHT_ON );
drivers/gpu/drm/i915/display/intel_bios.c +37 -6
59 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 345/396 drm/i915: Do not match JSL in ehl_combo_pll_div_frac_wa_needed()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathon Hall <[email protected]>
commit e41d769f1a7a1dc533c35ef7b366be3dbf432a1c upstream.
Since commit 0c65dc062611 ("drm/i915/jsl: s/JSL/JASPERLAKE for platform/subplatform defines"), boot freezes on a Jasper Lake tablet (Librem 11), usually with graphical corruption on the eDP display, but sometimes just a black screen. This commit was included in 6.6 and later.
That commit was intended to refactor EHL and JSL macros, but the change to ehl_combo_pll_div_frac_wa_needed() started matching JSL incorrectly when it was only intended to match EHL.
It replaced:
return ((IS_PLATFORM(i915, INTEL_ELKHARTLAKE) && IS_JSL_EHL_DISPLAY_STEP(i915, STEP_B0, STEP_FOREVER)) || with: return (((IS_ELKHARTLAKE(i915) || IS_JASPERLAKE(i915)) && IS_DISPLAY_STEP(i915, STEP_B0, STEP_FOREVER)) ||
Remove IS_JASPERLAKE() to fix the regression.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +1 -1
@@ -2462,7 +2462,7 @@ static void icl_wrpll_params_populate(ststatic bool ehl_combo_pll_div_frac_wa_needed (struct drm_i915_private *i915) { -return (((IS_ELKHARTLAKE (i915) ||IS_JASPERLAKE (i915)) && +return ((IS_ELKHARTLAKE (i915) &&IS_DISPLAY_STEP (i915,STEP_B0 ,STEP_FOREVER )) ||IS_TIGERLAKE (i915) ||IS_ALDERLAKE_S (i915) ||IS_ALDERLAKE_P (i915)) && i915->display.dpll.ref_clks.nssc ==38400 ;
Greg Kroah-Hartman
maintainerPATCH 346/396 drm/i915/gt: Reset queue_priority_hint on parking
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit 4a3859ea5240365d21f6053ee219bb240d520895 upstream.
Originally, with strict in order execution, we could complete execution only when the queue was empty. Preempt-to-busy allows replacement of an active request that may complete before the preemption is processed by HW. If that happens, the request is retired from the queue, but the queue_priority_hint remains set, preventing direct submission until after the next CS interrupt is processed.
This preempt-to-busy race can be triggered by the heartbeat, which will also act as the power-management barrier and upon completion allow us to idle the HW. We may process the completion of the heartbeat, and begin parking the engine before the CS event that restores the queue_priority_hint, causing us to fail the assertion that it is MIN.
<3>[ 166.210729] __engine_park:283 GEM_BUG_ON(engine->sched_engine->queue_priority_hint != (-((int)(~0U >> 1)) - 1))
<0>[ 166.210781] Dumping ftrace buffer:
<0>[ 166.210795] ---------------------------------
...
<0>[ 167.302811] drm_fdin-1097 2..s1. 165741070us : trace_ports: 0000:00:02.0 rcs0: promote { ccid:20 1217:2 prio 0 }
<0>[ 167.302861] drm_fdin-1097 2d.s2. 165741072us : execlists_submission_tasklet: 0000:00:02.0 rcs0: preempting last=1217:2, prio=0, hint=2147483646
<0>[ 167.302928] drm_fdin-1097 2d.s2. 165741072us : __i915_request_unsubmit: 0000:00:02.0 rcs0: fence 1217:2, current 0
<0>[ 167.302992] drm_fdin-1097 2d.s2. 165741073us : __i915_request_submit: 0000:00:02.0 rcs0: fence 3:4660, current 4659
<0>[ 167.303044] drm_fdin-1097 2d.s1. 165741076us : execlists_submission_tasklet: 0000:00:02.0 rcs0: context:3 schedule-in, ccid:40
<0>[ 167.303095] drm_fdin-1097 2d.s1. 165741077us : trace_ports: 0000:00:02.0 rcs0: submit { ccid:40 3:4660* prio 2147483646 }
<0>[ 167.303159] kworker/-89 11..... 165741139us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence c90:2, current 2
<0>[ 167.303208] kworker/-89 11..... 165741148us : __intel_context_do_unpin: 0000:00:02.0 rcs0: context:c90 unpin
<0>[ 167.303272] kworker/-89 11..... 165741159us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence 1217:2, current 2
<0>[ 167.303321] kworker/-89 11..... 165741166us : __intel_context_do_unpin: 0000:00:02.0 rcs0: context:1217 unpin
<0>[ 167.303384] kworker/-89 11..... 165741170us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence 3:4660, current 4660
<0>[ 167.303434] kworker/-89 11d..1. 165741172us : __intel_context_retire: 0000:00:02.0 rcs0: context:1216 retire runtime: { total:56028ns, avg:56028ns }
<0>[ 167.303484] kworker/-89 11..... 165741198us : __engine_park: 0000:00:02.0 rcs0: parked
<0>[ 167.303534] <idle>-0 5d.H3. 165741207us : execlists_irq_handler: 0000:00:02.0 rcs0: semaphore yield: 00000040
<0>[ 167.303583] kworker/-89 11..... 165741397us : __intel_context_retire: 0000:00:02.0 rcs0: context:1217 retire runtime: { total:325575ns, avg:0ns }
<0>[ 167.303756] kworker/-89 11..... 165741777us : __intel_context_retire: 0000:00:02.0 rcs0: context:c90 retire runtime: { total:0ns, avg:0ns }
<0>[ 167.303806] kworker/-89 11..... 165742017us : __engine_park: __engine_park:283 GEM_BUG_ON(engine->sched_engine->queue_priority_hint != (-((int)(~0U >> 1)) - 1))
<0>[ 167.303811] ---------------------------------
<4>[ 167.304722] ------------[ cut here ]------------
<2>[ 167.304725] kernel BUG at drivers/gpu/drm/i915/gt/intel_engine_pm.c:283!
<4>[ 167.304731] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
<4>[ 167.304734] CPU: 11 PID: 89 Comm: kworker/11:1 Tainted: G W 6.8.0-rc2-CI_DRM_14193-gc655e0fd2804+ #1
<4>[ 167.304736] Hardware name: Intel Corporation Rocket Lake Client Platform/RocketLake S UDIMM 6L RVP, BIOS RKLSFWI1.R00.3173.A03.2204210138 04/21/2022
<4>[ 167.304738] Workqueue: i915-unordered retire_work_handler [i915]
<4>[ 167.304839] RIP: 0010:__engine_park+0x3fd/0x680 [i915]
<4>[ 167.304937] Code: 00 48 c7 c2 b0 e5 86 a0 48 8d 3d 00 00 00 00 e8 79 48 d4 e0 bf 01 00 00 00 e8 ef 0a d4 e0 31 f6 bf 09 00 00 00 e8 03 49 c0 e0 <0f> 0b 0f 0b be 01 00 00 00 e8 f5 61 fd ff 31 c0 e9 34 fd ff ff 48
<4>[ 167.304940] RSP: 0018:ffffc9000059fce0 EFLAGS: 00010246
<4>[ 167.304942] RAX: 0000000000000200 RBX: 0000000000000000 RCX: 0000000000000006
<4>[ 167.304944] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000009
<4>[ 167.304946] RBP: ffff8881330ca1b0 R08: 0000000000000001 R09: 0000000000000001
<4>[ 167.304947] R10: 0000000000000001 R11: 0000000000000001 R12: ffff8881330ca000
<4>[ 167.304948] R13: ffff888110f02aa0 R14: ffff88812d1d0205 R15: ffff88811277d4f0
<4>[ 167.304950] FS: 0000000000000000(0000) GS:ffff88844f780000(0000) knlGS:0000000000000000
<4>[ 167.304952] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4>[ 167.304953] CR2: 00007fc362200c40 CR3: 000000013306e003 CR4: 0000000000770ef0
<4>[ 167.304955] PKRU: 55555554
<4>[ 167.304957] Call Trace:
<4>[ 167.304958] <TASK>
<4>[ 167.305573] ____intel_wakeref_put_last+0x1d/0x80 [i915]
<4>[ 167.305685] i915_request_retire.part.0+0x34f/0x600 [i915]
<4>[ 167.305800] retire_requests+0x51/0x80 [i915]
<4>[ 167.305892] intel_gt_retire_requests_timeout+0x27f/0x700 [i915]
<4>[ 167.305985] process_scheduled_works+0x2db/0x530
<4>[ 167.305990] worker_thread+0x18c/0x350
<4>[ 167.305993] kthread+0xfe/0x130
<4>[ 167.305997] ret_from_fork+0x2c/0x50
<4>[ 167.306001] ret_from_fork_asm+0x1b/0x30
<4>[ 167.306004] </TASK>It is necessary for the queue_priority_hint to be lower than the next request submission upon waking up, as we rely on the hint to decide when to kick the tasklet to submit that first request.
--- drivers/gpu/drm/i915/gt/intel_engine_pm.c | 3 --- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_pm.c +0 -3
@@ -278,9 +278,6 @@ static int __engine_park(struct intel_waintel_engine_park_heartbeat (engine);intel_breadcrumbs_park (engine->breadcrumbs); -/* Must be reset upon idling, or we may miss the busy wakeup. */ -GEM_BUG_ON (engine->sched_engine->queue_priority_hint !=INT_MIN ); -if (engine->park) engine->park (engine);
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +3 -0
@@ -3274,6 +3274,9 @@ static void execlists_park(struct intel_ {cancel_timer (&engine->execlists.timer);cancel_timer (&engine->execlists.preempt); + +/* Reset upon idling, or we may delay the busy wakeup. */ +WRITE_ONCE (engine->sched_engine->queue_priority_hint,INT_MIN ); }static void add_to_engine (struct i915_request *rq)
Greg Kroah-Hartman
maintainerPATCH 347/396 Bluetooth: hci_sync: Fix not checking error on hci_cmd_sync_cancel_sync
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit 1c3366abdbe884be62e5a7502b4db758aa3974c6 upstream.
hci_cmd_sync_cancel_sync shall check the error passed to it since it will be propagated using req_result which is __u32 it needs to be properly set to a positive value if it was passed as negative othertise IS_ERR will not trigger as -(errno) would be converted to a positive value.
--- net/bluetooth/hci_core.c | 6 +++--- net/bluetooth/hci_sync.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-)
net/bluetooth/hci_core.c +3 -3
@@ -2842,7 +2842,7 @@ static void hci_cancel_cmd_sync(struct hcancel_delayed_work_sync (&hdev->ncmd_timer);atomic_set (&hdev->cmd_cnt,1 ); -hci_cmd_sync_cancel_sync (hdev, -err); +hci_cmd_sync_cancel_sync (hdev, err); }/* Suspend HCI device */
@@ -2862,7 +2862,7 @@ int hci_suspend_dev(struct hci_dev *hdevreturn 0 ;/* Cancel potentially blocking sync operation before suspend */ -hci_cancel_cmd_sync (hdev, -EHOSTDOWN ); +hci_cancel_cmd_sync (hdev,EHOSTDOWN );hci_req_sync_lock (hdev); ret =hci_suspend_sync (hdev);
@@ -4178,7 +4178,7 @@ static void hci_send_cmd_sync(struct hci err =hci_send_frame (hdev, skb);if (err <0 ) { -hci_cmd_sync_cancel_sync (hdev, err); +hci_cmd_sync_cancel_sync (hdev, -err);return ; }
net/bluetooth/hci_sync.c +4 -1
@@ -679,7 +679,10 @@ void hci_cmd_sync_cancel_sync(struct hcibt_dev_dbg (hdev,"err 0x%2.2x" , err);if (hdev->req_status ==HCI_REQ_PEND ) { - hdev->req_result = err; +/* req_result is __u32 so error must be positive to be properly +* propagated. +*/ + hdev->req_result = err <0 ? -err : err; hdev->req_status =HCI_REQ_CANCELED ;wake_up_interruptible (&hdev->req_wait_q);
Greg Kroah-Hartman
maintainerPATCH 348/396 mtd: spinand: Add support for 5-byte IDs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ezra Buehler <[email protected]>
commit 34a956739d295de6010cdaafeed698ccbba87ea4 upstream.
E.g. ESMT chips will return an identification code with a length of 5 bytes. In order to prevent ambiguity, flash chips would actually need to return IDs that are up to 17 or more bytes long due to JEDEC's continuation scheme. I understand that if a manufacturer ID is located in bank N of JEDEC's database (there are currently 16 banks), N - 1 continuation codes (7Fh) need to be added to the identification code (comprising of manufacturer ID and device ID). However, most flash chip manufacturers don't seem to implement this (correctly).
--- include/linux/mtd/spinand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
@@ -169,7 +169,7 @@struct spinand_op ;struct spinand_device ; -#define SPINAND_MAX_ID_LEN 4 +#define SPINAND_MAX_ID_LEN 5/* * For erase, write and read operation, we got the following timings : * tBERS (erase) 1ms to 4ms
Greg Kroah-Hartman
maintainerPATCH 349/396 Revert "usb: phy: generic: Get the vbus supply"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
commit fdada0db0b2ae2addef4ccafe50937874dbeeebe upstream.
This reverts commit 75fd6485cccef269ac9eb3b71cf56753341195ef. This patch was applied twice by accident, causing probe failures. Revert the accident.
--- drivers/usb/phy/phy-generic.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/usb/phy/phy-generic.c +0 -7
@@ -268,13 +268,6 @@ int usb_phy_gen_create_phy(struct devicereturn dev_err_probe (dev,PTR_ERR (nop->vbus_draw),"could not get vbus regulator\n" ); - nop->vbus_draw =devm_regulator_get_exclusive (dev,"vbus" ); -if (PTR_ERR (nop->vbus_draw) == -ENODEV ) - nop->vbus_draw =NULL ; -if (IS_ERR (nop->vbus_draw)) -return dev_err_probe (dev,PTR_ERR (nop->vbus_draw), -"could not get vbus regulator\n" ); - nop->dev = dev; nop->phy.dev = nop->dev; nop->phy.label ="nop-xceiv" ;
Greg Kroah-Hartman
maintainerPATCH 350/396 usb: cdc-wdm: close race between read and workqueue
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 339f83612f3a569b194680768b22bf113c26a29d upstream.
wdm_read() cannot race with itself. However, in service_outstanding_interrupt() it can race with the workqueue, which can be triggered by error handling.
Hence we need to make sure that the WDM_RESPONDING flag is not just only set but tested.
--- drivers/usb/class/cdc-wdm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-wdm.c +5 -1
@@ -485,6 +485,7 @@ out_free_mem:static int service_outstanding_interrupt (struct wdm_device *desc) {int rv =0 ; +int used;/* submit read urb only if the device is waiting for it */ if (!desc->resp_count || !--desc->resp_count)
@@ -499,7 +500,10 @@ static int service_outstanding_interrupt goto out; } -set_bit (WDM_RESPONDING , &desc->flags); + used =test_and_set_bit (WDM_RESPONDING , &desc->flags); +if (used) + goto out; +spin_unlock_irq (&desc->iuspin); rv =usb_submit_urb (desc->response,GFP_KERNEL );spin_lock_irq (&desc->iuspin);
Greg Kroah-Hartman
maintainerPATCH 351/396 USB: UAS: return ENODEV when submit urbs fail with device not attached
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weitao Wang <[email protected]>
commit cd5432c712351a3d5f82512908f5febfca946ca6 upstream.
In the scenario of entering hibernation with udisk in the system, if the udisk was gone or resume fail in the thaw phase of hibernation. Its state will be set to NOTATTACHED. At this point, usb_hub_wq was already freezed and can't not handle disconnect event. Next, in the poweroff phase of hibernation, SYNCHRONIZE_CACHE SCSI command will be sent to this udisk when poweroff this scsi device, which will cause uas_submit_urbs to be called to submit URB for sense/data/cmd pipe. However, these URBs will submit fail as device was set to NOTATTACHED state. Then, uas_submit_urbs will return a value SCSI_MLQUEUE_DEVICE_BUSY to the caller. That will lead the SCSI layer go into an ugly loop and system fail to go into hibernation.
On the other hand, when we specially check for -ENODEV in function uas_queuecommand_lck, returning DID_ERROR to SCSI layer will cause device poweroff fail and system shutdown instead of entering hibernation.
To fix this issue, let uas_submit_urbs to return original generic error when submitting URB failed. At the same time, we need to translate -ENODEV to DID_NOT_CONNECT for the SCSI layer.
--- drivers/usb/storage/uas.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/usb/storage/uas.c +13 -15
@@ -533,7 +533,7 @@ static struct urb *uas_alloc_cmd_urb(str* daft to me. */ -static struct urb *uas_submit_sense_urb (struct scsi_cmnd *cmnd,gfp_t gfp) +static int uas_submit_sense_urb (struct scsi_cmnd *cmnd,gfp_t gfp) {struct uas_dev_info *devinfo = cmnd->device->hostdata;struct urb *urb;
@@ -541,30 +541,28 @@ static struct urb *uas_submit_sense_urb( urb =uas_alloc_sense_urb (devinfo, gfp, cmnd);if (!urb) -return NULL ; +return -ENOMEM ;usb_anchor_urb (urb, &devinfo->sense_urbs); err =usb_submit_urb (urb, gfp);if (err) {usb_unanchor_urb (urb);uas_log_cmd_state (cmnd,"sense submit err" , err);usb_free_urb (urb); -return NULL ; } -return urb; +return err; }static int uas_submit_urbs (struct scsi_cmnd *cmnd,struct uas_dev_info *devinfo) {struct uas_cmd_info *cmdinfo =scsi_cmd_priv (cmnd); -struct urb *urb;int err;lockdep_assert_held (&devinfo->lock);if (cmdinfo->state &SUBMIT_STATUS_URB ) { - urb =uas_submit_sense_urb (cmnd,GFP_ATOMIC ); -if (!urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; + err =uas_submit_sense_urb (cmnd,GFP_ATOMIC ); +if (err) +return err; cmdinfo->state &= ~SUBMIT_STATUS_URB ; }
@@ -572,7 +570,7 @@ static int uas_submit_urbs(struct scsi_c cmdinfo->data_in_urb =uas_alloc_data_urb (devinfo,GFP_ATOMIC , cmnd,DMA_FROM_DEVICE );if (!cmdinfo->data_in_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_DATA_IN_URB ; }
@@ -582,7 +580,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->data_in_urb);uas_log_cmd_state (cmnd,"data in submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->state &= ~SUBMIT_DATA_IN_URB ; cmdinfo->state |=DATA_IN_URB_INFLIGHT ;
@@ -592,7 +590,7 @@ static int uas_submit_urbs(struct scsi_c cmdinfo->data_out_urb =uas_alloc_data_urb (devinfo,GFP_ATOMIC , cmnd,DMA_TO_DEVICE );if (!cmdinfo->data_out_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_DATA_OUT_URB ; }
@@ -602,7 +600,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->data_out_urb);uas_log_cmd_state (cmnd,"data out submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->state &= ~SUBMIT_DATA_OUT_URB ; cmdinfo->state |=DATA_OUT_URB_INFLIGHT ;
@@ -611,7 +609,7 @@ static int uas_submit_urbs(struct scsi_cif (cmdinfo->state &ALLOC_CMD_URB ) { cmdinfo->cmd_urb =uas_alloc_cmd_urb (devinfo,GFP_ATOMIC , cmnd);if (!cmdinfo->cmd_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_CMD_URB ; }
@@ -621,7 +619,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->cmd_urb);uas_log_cmd_state (cmnd,"cmd submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->cmd_urb =NULL ; cmdinfo->state &= ~SUBMIT_CMD_URB ;
@@ -698,7 +696,7 @@ static int uas_queuecommand_lck(struct s* of queueing, no matter how fatal the error */ if (err == -ENODEV ) { -set_host_byte (cmnd,DID_ERROR ); +set_host_byte (cmnd,DID_NO_CONNECT );scsi_done (cmnd); goto zombie; }
Greg Kroah-Hartman
maintainerPATCH 352/396 drm/amd/display: Fix hang/underflow when transitioning to ODM4:1
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Bakoulin <[email protected]>
[ Upstream commit e7b2b108cdeab76a7e7324459e50b0c1214c0386 ]
[Why]
Under some circumstances, disabling an OPTC and attempting to reclaim its OPP(s) for a different OPTC could cause a hang/underflow due to OPPs not being properly disconnected from the disabled OPTC.
[How]
Ensure that all OPPs are unassigned from an OPTC when it gets disabled.
Stable-dep-of: b4e05bb1dec5 ("drm/amd/display: Clear OPTC mem select on disable")
--- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_optc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_optc.c +7 -0
@@ -148,6 +148,13 @@ static bool optc32_disable_crtc(struct timing_generator *optc)REG_UPDATE (OTG_CONTROL ,OTG_MASTER_EN ,0 ); +REG_UPDATE_5 (OPTC_DATA_SOURCE_SELECT , +OPTC_SEG0_SRC_SEL ,0xf , +OPTC_SEG1_SRC_SEL ,0xf , +OPTC_SEG2_SRC_SEL ,0xf , +OPTC_SEG3_SRC_SEL ,0xf , +OPTC_NUM_OF_INPUT_SEGMENT ,0 ); +REG_UPDATE (CONTROL ,VTG0_ENABLE ,0 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 353/396 drm/amd/display: Disconnect phantom pipe OPP from OPTC being disabled
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Shen <[email protected]>
[ Upstream commit 7bdbfb4e36e34eb788e44f27666bf0a2b3b90803 ]
[Why]
If an OPP is used for a different OPTC without first being disconnected from the previous OPTC, unexpected behaviour can occur. This also applies to phantom pipes, which is what the current logic missed.
[How]
Disconnect OPPs from OPTC for phantom pipes before disabling OTG master.
Also move the disconnection to before the OTG master disable, since the register is double buffered.
Stable-dep-of: b4e05bb1dec5 ("drm/amd/display: Clear OPTC mem select on disable")
--- .../gpu/drm/amd/display/dc/dcn32/dcn32_optc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_optc.c +13 -6
@@ -142,12 +142,6 @@ static bool optc32_disable_crtc(struct timing_generator *optc) {struct optc *optc1 =DCN10TG_FROM_TG (optc); -/* disable otg request until end of the first line -* in the vertical blank region -*/ -REG_UPDATE (OTG_CONTROL , -OTG_MASTER_EN ,0 ); - REG_UPDATE_5(OPTC_DATA_SOURCE_SELECT, OPTC_SEG0_SRC_SEL, 0xf, OPTC_SEG1_SRC_SEL, 0xf,
@@ -155,6 +149,12 @@ static bool optc32_disable_crtc(struct timing_generator *optc)OPTC_SEG3_SRC_SEL ,0xf , OPTC_NUM_OF_INPUT_SEGMENT, 0); +/* disable otg request until end of the first line +* in the vertical blank region +*/ +REG_UPDATE (OTG_CONTROL , +OTG_MASTER_EN ,0 ); +REG_UPDATE (CONTROL ,VTG0_ENABLE ,0 );
@@ -181,6 +181,13 @@ static void optc32_disable_phantom_otg(struct timing_generator *optc) {struct optc *optc1 =DCN10TG_FROM_TG (optc); +REG_UPDATE_5 (OPTC_DATA_SOURCE_SELECT , +OPTC_SEG0_SRC_SEL ,0xf , +OPTC_SEG1_SRC_SEL ,0xf , +OPTC_SEG2_SRC_SEL ,0xf , +OPTC_SEG3_SRC_SEL ,0xf , +OPTC_NUM_OF_INPUT_SEGMENT ,0 ); +REG_UPDATE (OTG_CONTROL ,OTG_MASTER_EN ,0 ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 354/396 drm/amd/display: Clear OPTC mem select on disable
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Bakoulin <[email protected]>
[ Upstream commit b4e05bb1dec53fe28c3c88425aded824498666e5 ]
[Why]
Not clearing the memory select bits prior to OPTC disable can cause DSC corruption issues when attempting to reuse a memory instance for another OPTC that enables ODM.
[How]
Clear the memory select bits prior to disabling an OPTC.
--- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_optc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_optc.c +3 -0
@@ -149,6 +149,9 @@ static bool optc32_disable_crtc(struct timing_generator *optc)OPTC_SEG3_SRC_SEL ,0xf , OPTC_NUM_OF_INPUT_SEGMENT, 0); +REG_UPDATE (OPTC_MEMORY_CONFIG , +OPTC_MEM_SEL ,0 ); +/* disable otg request until end of the first line * in the vertical blank region */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 355/396 vfio/pds: Make sure migration file isnt accessed after reset
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brett Creeley <[email protected]>
[ Upstream commit 457f7308254756b6e4b8fc3876cb770dcf0e7cc7 ]
It's possible the migration file is accessed after reset when it has been cleaned up, especially when it's initiated by the device. This is because the driver doesn't rip out the filep when cleaning up it only frees the related page structures and sets its local struct pds_vfio_lm_file pointer to NULL. This can cause a NULL pointer dereference, which is shown in the example below during a restore after a device initiated reset:
BUG: kernel NULL pointer dereference, address: 000000000000000c PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:pds_vfio_get_file_page+0x5d/0xf0 [pds_vfio_pci] [...] Call Trace: <TASK> pds_vfio_restore_write+0xf6/0x160 [pds_vfio_pci] vfs_write+0xc9/0x3f0 ? __fget_light+0xc9/0x110 ksys_write+0xb5/0xf0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
Add a disabled flag to the driver's struct pds_vfio_lm_file that gets set during cleanup. Then make sure to check the flag when the migration file is accessed via its file_operations. By default this flag will be false as the memory for struct pds_vfio_lm_file is kzalloc'd, which means the struct pds_vfio_lm_file is enabled and accessible. Also, since the file_operations and driver's migration file cleanup happen under the protection of the same pds_vfio_lm_file.lock, using this flag is thread safe.
--- drivers/vfio/pci/pds/lm.c | 13 +++++++++++++ drivers/vfio/pci/pds/lm.h | 1 + 2 files changed, 14 insertions(+)
drivers/vfio/pci/pds/lm.c +13 -0
@@ -92,8 +92,10 @@ static void pds_vfio_put_lm_file(struct pds_vfio_lm_file *lm_file) {mutex_lock (&lm_file->lock); + lm_file->disabled = true; lm_file->size =0 ; lm_file->alloc_size =0 ; + lm_file->filep->f_pos =0 ;/* Free scatter list of file pages */ sg_free_table (&lm_file->sg_table);
@@ -183,6 +185,12 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf, pos = &filp->f_pos;mutex_lock (&lm_file->lock); + +if (lm_file->disabled) { + done = -ENODEV ; + goto out_unlock; + } +if (*pos > lm_file->size) { done = -EINVAL ; goto out_unlock;
@@ -283,6 +291,11 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf,mutex_lock (&lm_file->lock); +if (lm_file->disabled) { + done = -ENODEV ; + goto out_unlock; + } +while (len) {size_t page_offset;struct page *page;
drivers/vfio/pci/pds/lm.h +1 -0
@@ -27,6 +27,7 @@ struct pds_vfio_lm_file {struct scatterlist *last_offset_sg;/* Iterator */ unsigned int sg_last_entry;unsigned long last_offset; +bool disabled; };struct pds_vfio_pci_device ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 356/396 ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 051e0840ffa8ab25554d6b14b62c9ab9e4901457 upstream.
The dreamcastcard->timer could schedule the spu_dma_work and the spu_dma_work could also arm the dreamcastcard->timer.
When the snd_pcm_substream is closing, the aica_channel will be deallocated. But it could still be dereferenced in the worker thread. The reason is that del_timer() will return directly regardless of whether the timer handler is running or not and the worker could be rescheduled in the timer handler. As a result, the UAF bug will happen. The racy situation is shown below:
(Thread 1) | (Thread 2)
snd_aicapcm_pcm_close() |
... | run_spu_dma() //worker
| mod_timer()
flush_work() |
del_timer() | aica_period_elapsed() //timer
kfree(dreamcastcard->channel) | schedule_work()
| run_spu_dma() //worker
... | dreamcastcard->channel-> //USEIn order to mitigate this bug and other possible corner cases, call mod_timer() conditionally in run_spu_dma(), then implement PCM sync_stop op to cancel both the timer and worker. The sync_stop op will be called from PCM core appropriately when needed.
Message-ID: <[email protected]>
--- sound/sh/aica.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
sound/sh/aica.c +14 -3
@@ -278,7 +278,8 @@ static void run_spu_dma(struct work_stru dreamcastcard->clicks++;if (unlikely (dreamcastcard->clicks >=AICA_PERIOD_NUMBER )) dreamcastcard->clicks %=AICA_PERIOD_NUMBER ; -mod_timer (&dreamcastcard->timer, jiffies +1 ); +if (snd_pcm_running (dreamcastcard->substream)) +mod_timer (&dreamcastcard->timer, jiffies +1 ); } }
@@ -290,6 +291,8 @@ static void aica_period_elapsed(struct t/*timer function - so cannot sleep */ int play_period;struct snd_pcm_runtime *runtime; +if (!snd_pcm_running (substream)) +return ; runtime = substream->runtime; dreamcastcard = substream->pcm->private_data;/* Have we played out an additional period? */
@@ -350,12 +353,19 @@ static int snd_aicapcm_pcm_open(struct sreturn 0 ; } +static int snd_aicapcm_pcm_sync_stop (struct snd_pcm_substream *substream) +{ +struct snd_card_aica *dreamcastcard = substream->pcm->private_data; + +del_timer_sync (&dreamcastcard->timer); +cancel_work_sync (&dreamcastcard->spu_dma_work); +return 0 ; +} +static int snd_aicapcm_pcm_close (struct snd_pcm_substream *substream) {struct snd_card_aica *dreamcastcard = substream->pcm->private_data; -flush_work (&(dreamcastcard->spu_dma_work)); -del_timer (&dreamcastcard->timer); dreamcastcard->substream =NULL ;kfree (dreamcastcard->channel);spu_disable ();
@@ -401,6 +411,7 @@ static const struct snd_pcm_ops snd_aica .prepare = snd_aicapcm_pcm_prepare, .trigger = snd_aicapcm_pcm_trigger, .pointer = snd_aicapcm_pcm_pointer, + .sync_stop = snd_aicapcm_pcm_sync_stop, };/* TO DO: set up to handle more than one pcm instance */
Greg Kroah-Hartman
maintainerPATCH 357/396 scsi: sd: Fix TCG OPAL unlock on system resume
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 0c76106cb97548810214def8ee22700bbbb90543 upstream.
Commit 3cc2ffe5c16d ("scsi: sd: Differentiate system and runtime start/stop management") introduced the manage_system_start_stop scsi_device flag to allow libata to indicate to the SCSI disk driver that nothing should be done when resuming a disk on system resume. This change turned the execution of sd_resume() into a no-op for ATA devices on system resume. While this solved deadlock issues during device resume, this change also wrongly removed the execution of opal_unlock_from_suspend(). As a result, devices with TCG OPAL locking enabled remain locked and inaccessible after a system resume from sleep.
To fix this issue, introduce the SCSI driver resume method and implement it with the sd_resume() function calling opal_unlock_from_suspend(). The former sd_resume() function is renamed to sd_resume_common() and modified to call the new sd_resume() function. For non-ATA devices, this result in no functional changes.
In order for libata to explicitly execute sd_resume() when a device is resumed during system restart, the function scsi_resume_device() is introduced. libata calls this function from the revalidation work executed on devie resume, a state that is indicated with the new device flag ATA_DFLAG_RESUMING. Doing so, locked TCG OPAL enabled devices are unlocked on resume, allowing normal operation.
--- drivers/ata/libata-eh.c | 5 ++++- drivers/ata/libata-scsi.c | 9 +++++++++ drivers/scsi/scsi_scan.c | 34 ++++++++++++++++++++++++++++++++++ drivers/scsi/sd.c | 23 +++++++++++++++++++---- include/linux/libata.h | 1 + include/scsi/scsi_driver.h | 1 + include/scsi/scsi_host.h | 1 + 7 files changed, 69 insertions(+), 5 deletions(-)
drivers/ata/libata-eh.c +4 -1
@@ -700,8 +700,10 @@ void ata_scsi_port_error_handler(struct ehc->saved_ncq_enabled |=1 << devno;/* If we are resuming, wake up the device */ -if (ap->pflags &ATA_PFLAG_RESUMING ) +if (ap->pflags &ATA_PFLAG_RESUMING ) { + dev->flags |=ATA_DFLAG_RESUMING ; ehc->i.dev_action[devno] |=ATA_EH_SET_ACTIVE ; + } } }
@@ -3170,6 +3172,7 @@ static int ata_eh_revalidate_and_attach(return 0 ; err: + dev->flags &= ~ATA_DFLAG_RESUMING ; *r_failed_dev = dev;return rc; }
drivers/ata/libata-scsi.c +9 -0
@@ -4765,6 +4765,7 @@ void ata_scsi_dev_rescan(struct work_strstruct ata_link *link;struct ata_device *dev;unsigned long flags; +bool do_resume;int ret =0 ;mutex_lock (&ap->scsi_scan_mutex);
@@ -4786,7 +4787,15 @@ void ata_scsi_dev_rescan(struct work_strif (scsi_device_get (sdev))continue ; + do_resume = dev->flags &ATA_DFLAG_RESUMING ; +spin_unlock_irqrestore (ap->lock, flags); +if (do_resume) { + ret =scsi_resume_device (sdev); +if (ret == -EWOULDBLOCK ) + goto unlock; + dev->flags &= ~ATA_DFLAG_RESUMING ; + } ret =scsi_rescan_device (sdev);scsi_device_put (sdev);spin_lock_irqsave (ap->lock, flags);
drivers/scsi/scsi_scan.c +34 -0
@@ -1619,6 +1619,40 @@ int scsi_add_device(struct Scsi_Host *ho }EXPORT_SYMBOL (scsi_add_device); +int scsi_resume_device (struct scsi_device *sdev) +{ +struct device *dev = &sdev->sdev_gendev; +int ret =0 ; + +device_lock (dev); + +/* +* Bail out if the device or its queue are not running. Otherwise, +* the rescan may block waiting for commands to be executed, with us +* holding the device lock. This can result in a potential deadlock +* in the power management core code when system resume is on-going. +*/ +if (sdev->sdev_state !=SDEV_RUNNING || +blk_queue_pm_only (sdev->request_queue)) { + ret = -EWOULDBLOCK ; + goto unlock; + } + +if (dev->driver &&try_module_get (dev->driver->owner)) { +struct scsi_driver *drv =to_scsi_driver (dev->driver); + +if (drv->resume) + ret = drv->resume (dev); +module_put (dev->driver->owner); + } + +unlock: +device_unlock (dev); + +return ret; +} +EXPORT_SYMBOL (scsi_resume_device); +int scsi_rescan_device (struct scsi_device *sdev) {struct device *dev = &sdev->sdev_gendev;
drivers/scsi/sd.c +19 -4
@@ -3942,7 +3942,21 @@ static int sd_suspend_runtime(struct devreturn sd_suspend_common (dev, true); } -static int sd_resume (struct device *dev,bool runtime) +static int sd_resume (struct device *dev) +{ +struct scsi_disk *sdkp =dev_get_drvdata (dev); + +sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); + +if (opal_unlock_from_suspend (sdkp->opal_dev)) { +sd_printk (KERN_NOTICE , sdkp,"OPAL unlock failed\n" ); +return -EIO ; + } + +return 0 ; +} + +static int sd_resume_common (struct device *dev,bool runtime) {struct scsi_disk *sdkp =dev_get_drvdata (dev);int ret =0 ;
@@ -3961,7 +3975,7 @@ static int sd_resume(struct device *dev, }if (!ret) { -opal_unlock_from_suspend (sdkp->opal_dev); +sd_resume (dev); sdkp->suspended = false; }
@@ -3980,7 +3994,7 @@ static int sd_resume_system(struct devicreturn 0 ; } -return sd_resume (dev, false); +return sd_resume_common (dev, false); }static int sd_resume_runtime (struct device *dev)
@@ -4007,7 +4021,7 @@ static int sd_resume_runtime(struct devi "Failed to clear sense data\n"); } -return sd_resume (dev, true); +return sd_resume_common (dev, true); }static const struct dev_pm_ops sd_pm_ops = {
@@ -4030,6 +4044,7 @@ static struct scsi_driver sd_template = .pm = &sd_pm_ops, }, .rescan = sd_rescan, + .resume = sd_resume, .init_command = sd_init_command, .uninit_command = sd_uninit_command, .done = sd_done,
include/linux/libata.h +1 -0
@@ -107,6 +107,7 @@ enum {ATA_DFLAG_NCQ_PRIO_ENABLED = (1 <<20 ),/* Priority cmds sent to dev */ ATA_DFLAG_CDL_ENABLED = (1 <<21 ),/* cmd duration limits is enabled */ +ATA_DFLAG_RESUMING = (1 <<22 ),/* Device is resuming */ ATA_DFLAG_DETACH = (1 <<24 ),ATA_DFLAG_DETACHED = (1 <<25 ), ATA_DFLAG_DA = (1 << 26), /* device supports Device Attention */
include/scsi/scsi_driver.h +1 -0
@@ -12,6 +12,7 @@ struct request;struct scsi_driver {struct device_driver gendrv; +int (*resume)(struct device *);void (*rescan)(struct device *);blk_status_t (*init_command)(struct scsi_cmnd *);void (*uninit_command)(struct scsi_cmnd *);
include/scsi/scsi_host.h +1 -0
@@ -764,6 +764,7 @@ scsi_template_proc_dir(const struct scsi#define scsi_template_proc_dir (sht) NULL#endif extern void scsi_scan_host (struct Scsi_Host *); +extern int scsi_resume_device (struct scsi_device *sdev);extern int scsi_rescan_device (struct scsi_device *sdev);extern void scsi_remove_host (struct Scsi_Host *);extern struct Scsi_Host *scsi_host_get (struct Scsi_Host *);
Greg Kroah-Hartman
maintainerPATCH 358/396 scsi: sg: Avoid sg device teardown race
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Wetzel <[email protected]>
commit 27f58c04a8f438078583041468ec60597841284d upstream.
sg_remove_sfp_usercontext() must not use sg_device_destroy() after calling scsi_device_put().
sg_device_destroy() is accessing the parent scsi_device request_queue which will already be set to NULL when the preceding call to scsi_device_put() removed the last reference to the parent scsi_device.
The resulting NULL pointer exception will then crash the kernel.
--- drivers/scsi/sg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sg.c +3 -1
@@ -2208,6 +2208,7 @@ sg_remove_sfp_usercontext(struct work_st { struct sg_fd *sfp = container_of(work, struct sg_fd, ew.work);struct sg_device *sdp = sfp->parentdp; +struct scsi_device *device = sdp->device;Sg_request *srp;unsigned long iflags;
@@ -2233,8 +2234,9 @@ sg_remove_sfp_usercontext(struct work_st "sg_remove_sfp: sfp=0x%p\n", sfp));kfree (sfp); -scsi_device_put (sdp->device); +WARN_ON_ONCE (kref_read (&sdp->d_ref) !=1 );kref_put (&sdp->d_ref, sg_device_destroy); +scsi_device_put (device);module_put (THIS_MODULE ); }
Greg Kroah-Hartman
maintainerPATCH 359/396 scsi: core: Fix unremoved procfs host directory regression
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guilherme G. Piccoli <[email protected]>
commit f23a4d6e07570826fe95023ca1aa96a011fa9f84 upstream.
Commit fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier") fixed a bug related to modules loading/unloading, by adding a call to scsi_proc_hostdir_rm() on scsi_remove_host(). But that led to a potential duplicate call to the hostdir_rm() routine, since it's also called from scsi_host_dev_release(). That triggered a regression report, which was then fixed by commit be03df3d4bfe ("scsi: core: Fix a procfs host directory removal regression"). The fix just dropped the hostdir_rm() call from dev_release().
But it happens that this proc directory is created on scsi_host_alloc(), and that function "pairs" with scsi_host_dev_release(), while scsi_remove_host() pairs with scsi_add_host(). In other words, it seems the reason for removing the proc directory on dev_release() was meant to cover cases in which a SCSI host structure was allocated, but the call to scsi_add_host() didn't happen. And that pattern happens to exist in some error paths, for example.
Syzkaller causes that by using USB raw gadget device, error'ing on usb-storage driver, at usb_stor_probe2(). By checking that path, we can see that the BadDevice label leads to a scsi_host_put() after a SCSI host allocation, but there's no call to scsi_add_host() in such path. That leads to messages like this in dmesg (and a leak of the SCSI host proc structure):
usb-storage 4-1:87.51: USB Mass Storage device detected proc_dir_entry 'scsi/usb-storage' already registered
WARNING: CPU: 1 PID: 3519 at fs/proc/generic.c:377 proc_register+0x347/0x4e0 fs/proc/generic.c:376
The proper fix seems to still call scsi_proc_hostdir_rm() on dev_release(), but guard that with the state check for SHOST_CREATED; there is even a comment in scsi_host_dev_release() detailing that: such conditional is meant for cases where the SCSI host was allocated but there was no calls to {add,remove}_host(), like the usb-storage case.
This is what we propose here and with that, the error path of usb-storage does not trigger the warning anymore.
--- drivers/scsi/hosts.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/hosts.c +4 -3
@@ -353,12 +353,13 @@ static void scsi_host_dev_release(structif (shost->shost_state ==SHOST_CREATED ) {/* -* Free the shost_dev device name here if scsi_host_alloc() -* and scsi_host_put() have been called but neither +* Free the shost_dev device name and remove the proc host dir +* here if scsi_host_{alloc,put}() have been called but neither * scsi_host_add() nor scsi_remove_host() has been called. * This avoids that the memory allocated for the shost_dev -* name is leaked. +* name as well as the proc dir structure are leaked. */ +scsi_proc_hostdir_rm (shost->hostt);kfree (dev_name (&shost->shost_dev)); }
Greg Kroah-Hartman
maintainerPATCH 360/396 staging: vc04_services: changen strncpy() to strscpy_pad()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit ef25725b7f8aaffd7756974d3246ec44fae0a5cf upstream.
gcc-14 warns about this strncpy() that results in a non-terminated string for an overflow:
In file included from include/linux/string.h:369,
from drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:20:
In function 'strncpy',
inlined from 'create_component' at drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:940:2:include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' specified bound 128 equals destination size [-Werror=stringop-truncation]
Change it to strscpy_pad(), which produces a properly terminated and zero-padded string.
--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +2 -2
@@ -937,8 +937,8 @@ static int create_component(struct vchiq/* build component create message */ m.h.type =MMAL_MSG_TYPE_COMPONENT_CREATE ; m.u.component_create.client_component = component->client_component; -strncpy (m.u.component_create.name, name, -sizeof (m.u.component_create.name)); +strscpy_pad (m.u.component_create.name, name, +sizeof (m.u.component_create.name)); ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),
Greg Kroah-Hartman
maintainerPATCH 361/396 staging: vc04_services: fix information leak in create_component()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit f37e76abd614b68987abc8e5c22d986013349771 upstream.
The m.u.component_create.pid field is for debugging and in the mainline kernel it's not used anything. However, it still needs to be set to something to prevent disclosing uninitialized stack data. Set it to zero.
--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +1 -0
@@ -939,6 +939,7 @@ static int create_component(struct vchiq m.u.component_create.client_component = component->client_component;strscpy_pad (m.u.component_create.name, name,sizeof (m.u.component_create.name)); + m.u.component_create.pid =0 ; ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),
Greg Kroah-Hartman
maintainerPATCH 362/396 usb: dwc3: Properly set system wakeup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thinh Nguyen <[email protected]>
commit f9aa41130ac69d13a53ce2a153ca79c70d43f39c upstream.
If the device is configured for system wakeup, then make sure that the xHCI driver knows about it and make sure to permit wakeup only at the appropriate time.
For host mode, if the controller goes through the dwc3 code path, then a child xHCI platform device is created. Make sure the platform device also inherits the wakeup setting for xHCI to enable remote wakeup.
For device mode, make sure to disable system wakeup if no gadget driver is bound. We may experience unwanted system wakeup due to the wakeup signal from the controller PMU detecting connection/disconnection when in low power (D3). E.g. In the case of Steam Deck, the PCI PME prevents the system staying in suspend.
--- drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/gadget.c | 10 ++++++++++ drivers/usb/dwc3/host.c | 11 +++++++++++ 4 files changed, 25 insertions(+)
drivers/usb/dwc3/core.c +2 -0
@@ -1493,6 +1493,8 @@ static void dwc3_get_properties(struct delse dwc->sysdev = dwc->dev; + dwc->sys_wakeup =device_may_wakeup (dwc->sysdev); + ret =device_property_read_string (dev,"usb-psy-name" , &usb_psy_name);if (ret >=0 ) { dwc->usb_psy =power_supply_get_by_name (usb_psy_name);
drivers/usb/dwc3/core.h +2 -0
@@ -1123,6 +1123,7 @@ struct dwc3_scratchpad_array {* 3 - Reserved * @dis_metastability_quirk: set to disable metastability quirk. * @dis_split_quirk: set to disable split boundary. +* @sys_wakeup: set if the device may do system wakeup. * @wakeup_configured: set if the device is configured for remote wakeup. * @suspended: set to track suspend event due to U3/L2. * @imod_interval: set the interrupt moderation interval in 250ns
@@ -1344,6 +1345,7 @@ struct dwc3 { unsigned dis_split_quirk:1; unsigned async_callbacks:1; + unsigned sys_wakeup:1; unsigned wakeup_configured:1; unsigned suspended:1;
drivers/usb/dwc3/gadget.c +10 -0
@@ -2968,6 +2968,9 @@ static int dwc3_gadget_start(struct usb_ dwc->gadget_driver = driver;spin_unlock_irqrestore (&dwc->lock, flags); +if (dwc->sys_wakeup) +device_wakeup_enable (dwc->sysdev); +return 0 ; }
@@ -2983,6 +2986,9 @@ static int dwc3_gadget_stop(struct usb_gstruct dwc3 *dwc =gadget_to_dwc (g);unsigned long flags; +if (dwc->sys_wakeup) +device_wakeup_disable (dwc->sysdev); +spin_lock_irqsave (&dwc->lock, flags); dwc->gadget_driver =NULL ; dwc->max_cfg_eps =0 ;
@@ -4664,6 +4670,10 @@ int dwc3_gadget_init(struct dwc3 *dwc)else dwc3_gadget_set_speed (dwc->gadget, dwc->maximum_speed); +/* No system wakeup if no gadget driver bound */ +if (dwc->sys_wakeup) +device_wakeup_disable (dwc->sysdev); +return 0 ; err5:
drivers/usb/dwc3/host.c +11 -0
@@ -123,6 +123,14 @@ int dwc3_host_init(struct dwc3 *dwc) goto err; } +if (dwc->sys_wakeup) { +/* Restore wakeup setting if switched from device */ +device_wakeup_enable (dwc->sysdev); + +/* Pass on wakeup setting to the new xhci platform device */ +device_init_wakeup (&xhci->dev, true); + } +return 0 ; err:platform_device_put (xhci);
@@ -131,6 +139,9 @@ err:void dwc3_host_exit (struct dwc3 *dwc) { +if (dwc->sys_wakeup) +device_init_wakeup (&dwc->xhci->dev, false); +platform_device_unregister (dwc->xhci); dwc->xhci =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 363/396 USB: core: Fix deadlock in usb_deauthorize_interface()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 80ba43e9f799cbdd83842fc27db667289b3150f5 upstream.
Among the attribute file callback routines in drivers/usb/core/sysfs.c, the interface_authorized_store() function is the only one which acquires a device lock on an ancestor device: It calls usb_deauthorize_interface(), which locks the interface's parent USB device.
The will lead to deadlock if another process already owns that lock and tries to remove the interface, whether through a configuration change or because the device has been disconnected. As part of the removal procedure, device_del() waits for all ongoing sysfs attribute callbacks to complete. But usb_deauthorize_interface() can't complete until the device lock has been released, and the lock won't be released until the removal has finished.
The mechanism provided by sysfs to prevent this kind of deadlock is to use the sysfs_break_active_protection() function, which tells sysfs not to wait for the attribute callback.
Reported-and-tested by: Yue Sun <[email protected]> Reported by: xingwei lee <[email protected]>
--- drivers/usb/core/sysfs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/usb/core/sysfs.c +13 -3
@@ -1168,14 +1168,24 @@ static ssize_t interface_authorized_stor {struct usb_interface *intf =to_usb_interface (dev);bool val; +struct kernfs_node *kn;if (kstrtobool (buf, &val) !=0 )return -EINVAL ; -if (val) +if (val) {usb_authorize_interface (intf); -else -usb_deauthorize_interface (intf); + }else { +/* +* Prevent deadlock if another process is concurrently +* trying to unregister intf. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (kn) { +usb_deauthorize_interface (intf); +sysfs_unbreak_active_protection (kn); + } + }return count; }
Greg Kroah-Hartman
maintainerPATCH 364/396 USB: core: Add hub_get() and hub_put() routines
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit ee113b860aa169e9a4d2c167c95d0f1961c6e1b8 upstream.
Create hub_get() and hub_put() routines to encapsulate the kref_get() and kref_put() calls in hub.c. The new routines will be used by the next patch in this series.
--- drivers/usb/core/hub.c | 23 ++++++++++++++++------- drivers/usb/core/hub.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-)
drivers/usb/core/hub.c +16 -7
@@ -123,7 +123,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rws#define HUB_DEBOUNCE_STEP 25#define HUB_DEBOUNCE_STABLE 100 -static void hub_release (struct kref *kref);static int usb_reset_and_verify_device (struct usb_device *udev);static int hub_port_disable (struct usb_hub *hub,int port1,int set_state); static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
@@ -685,14 +684,14 @@ static void kick_hub_wq(struct usb_hub **/ intf =to_usb_interface (hub->intfdev);usb_autopm_get_interface_no_resume (intf); -kref_get (&hub->kref); +hub_get (hub);if (queue_work (hub_wq, &hub->events))return ;/* the work has already been scheduled */ usb_autopm_put_interface_async (intf); -kref_put (&hub->kref, hub_release); +hub_put (hub); }void usb_kick_hub_wq (struct usb_device *hdev)
@@ -1060,7 +1059,7 @@ static void hub_activate(struct usb_hub goto init2; goto init3; } -kref_get (&hub->kref); +hub_get (hub);/* The superspeed hub except for root hub has to use Hub Depth * value as an offset into the route string to locate the bits
@@ -1308,7 +1307,7 @@ static void hub_activate(struct usb_hubdevice_unlock (&hdev->dev); } -kref_put (&hub->kref, hub_release); +hub_put (hub); }/* Implement the continuations for the delays above */
@@ -1724,6 +1723,16 @@ static void hub_release(struct kref *krekfree (hub); } +void hub_get (struct usb_hub *hub) +{ +kref_get (&hub->kref); +} + +void hub_put (struct usb_hub *hub) +{ +kref_put (&hub->kref, hub_release); +} +static unsigned highspeed_hubs;static void hub_disconnect (struct usb_interface *intf)
@@ -1772,7 +1781,7 @@ static void hub_disconnect(struct usb_inonboard_hub_destroy_pdevs (&hub->onboard_hub_devs); -kref_put (&hub->kref, hub_release); +hub_put (hub); }static bool hub_descriptor_is_sane (struct usb_host_interface *desc)
@@ -5890,7 +5899,7 @@ out_hdev_lock:/* Balance the stuff in kick_hub_wq() and allow autosuspend */ usb_autopm_put_interface (intf); -kref_put (&hub->kref, hub_release); +hub_put (hub);kcov_remote_stop (); }
drivers/usb/core/hub.h +2 -0
@@ -126,6 +126,8 @@ extern void usb_hub_remove_port_device(sextern int usb_hub_set_port_power (struct usb_device *hdev,struct usb_hub *hub,int port1,bool set);extern struct usb_hub *usb_hub_to_struct_hub (struct usb_device *hdev); +extern void hub_get (struct usb_hub *hub); +extern void hub_put (struct usb_hub *hub);extern int hub_port_debounce (struct usb_hub *hub,int port1,bool must_be_connected); extern int usb_clear_port_feature(struct usb_device *hdev,
Greg Kroah-Hartman
maintainerPATCH 365/396 USB: core: Fix deadlock in port "disable" sysfs attribute
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit f4d1960764d8a70318b02f15203a1be2b2554ca1 upstream.
The show and store callback routines for the "disable" sysfs attribute file in port.c acquire the device lock for the port's parent hub device. This can cause problems if another process has locked the hub to remove it or change its configuration:
Removing the hub or changing its configuration requires the hub interface to be removed, which requires the port device to be removed, and device_del() waits until all outstanding sysfs attribute callbacks for the ports have returned. The lock can't be released until then.
But the disable_show() or disable_store() routine can't return until after it has acquired the lock.
The resulting deadlock can be avoided by calling sysfs_break_active_protection(). This will cause the sysfs core not to wait for the attribute's callback routine to return, allowing the removal to proceed. The disadvantage is that after making this call, there is no guarantee that the hub structure won't be deallocated at any moment. To prevent this, we have to acquire a reference to it first by calling hub_get().
--- drivers/usb/core/port.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-)
drivers/usb/core/port.c +34 -4
@@ -55,11 +55,22 @@ static ssize_t disable_show(struct devicu16 portstatus, unused;bool disabled;int rc; +struct kernfs_node *kn; +hub_get (hub); rc =usb_autopm_get_interface (intf);if (rc <0 ) -return rc; + goto out_hub_get; +/* +* Prevent deadlock if another process is concurrently +* trying to unregister hdev. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) { + rc = -ENODEV ; + goto out_autopm; + }usb_lock_device (hdev);if (hub->disconnected) { rc = -ENODEV ;
@@ -69,9 +80,13 @@ static ssize_t disable_show(struct devicusb_hub_port_status (hub, port1, &portstatus, &unused); disabled = !usb_port_is_power_on (hub, portstatus); -out_hdev_lock: + out_hdev_lock:usb_unlock_device (hdev); +sysfs_unbreak_active_protection (kn); + out_autopm:usb_autopm_put_interface (intf); + out_hub_get: +hub_put (hub);if (rc)return rc;
@@ -89,15 +104,26 @@ static ssize_t disable_store(struct deviint port1 = port_dev->portnum;bool disabled;int rc; +struct kernfs_node *kn; rc =kstrtobool (buf, &disabled);if (rc)return rc; +hub_get (hub); rc =usb_autopm_get_interface (intf);if (rc <0 ) -return rc; + goto out_hub_get; +/* +* Prevent deadlock if another process is concurrently +* trying to unregister hdev. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) { + rc = -ENODEV ; + goto out_autopm; + }usb_lock_device (hdev);if (hub->disconnected) { rc = -ENODEV ;
@@ -118,9 +144,13 @@ static ssize_t disable_store(struct deviif (!rc) rc = count; -out_hdev_lock: + out_hdev_lock:usb_unlock_device (hdev); +sysfs_unbreak_active_protection (kn); + out_autopm:usb_autopm_put_interface (intf); + out_hub_get: +hub_put (hub);return rc; }
Greg Kroah-Hartman
maintainerPATCH 366/396 usb: dwc2: host: Fix remote wakeup from hibernation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit bae2bc73a59c200db53b6c15fb26bb758e2c6108 upstream.
Starting from core v4.30a changed order of programming GPWRDN_PMUACTV to 0 in case of exit from hibernation on remote wakeup signaling from device.
--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/hcd.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/usb/dwc2/core.h +1 -0
@@ -1086,6 +1086,7 @@ struct dwc2_hsotg {bool needs_byte_swap;/* DWC OTG HW Release versions */ +#define DWC2_CORE_REV_4_30a 0x4f54430a#define DWC2_CORE_REV_2_71a 0x4f54271a#define DWC2_CORE_REV_2_72a 0x4f54272a#define DWC2_CORE_REV_2_80a 0x4f54280a
drivers/usb/dwc2/hcd.c +13 -4
@@ -5610,10 +5610,12 @@ int dwc2_host_exit_hibernation(struct dwdwc2_writel (hsotg, hr->hcfg,HCFG );/* De-assert Wakeup Logic */ - gpwrdn =dwc2_readl (hsotg,GPWRDN ); - gpwrdn &= ~GPWRDN_PMUACTV ; -dwc2_writel (hsotg, gpwrdn,GPWRDN ); -udelay (10 ); +if (!(rem_wakeup && hsotg->hw_params.snpsid >= DWC2_CORE_REV_4_30a)) { + gpwrdn =dwc2_readl (hsotg,GPWRDN ); + gpwrdn &= ~GPWRDN_PMUACTV ; +dwc2_writel (hsotg, gpwrdn,GPWRDN ); +udelay (10 ); + } hprt0 = hr->hprt0; hprt0 |=HPRT0_PWR ;
@@ -5638,6 +5640,13 @@ int dwc2_host_exit_hibernation(struct dw hprt0 |=HPRT0_RES ;dwc2_writel (hsotg, hprt0,HPRT0 ); +/* De-assert Wakeup Logic */ +if ((rem_wakeup && hsotg->hw_params.snpsid >= DWC2_CORE_REV_4_30a)) { + gpwrdn =dwc2_readl (hsotg,GPWRDN ); + gpwrdn &= ~GPWRDN_PMUACTV ; +dwc2_writel (hsotg, gpwrdn,GPWRDN ); +udelay (10 ); + }/* Wait for Resume time and then program HPRT again */ mdelay (100 ); hprt0 &= ~HPRT0_RES ;
Greg Kroah-Hartman
maintainerPATCH 367/396 usb: dwc2: host: Fix hibernation flow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 3c7b9856a82227db01a20171d2e24c7ce305d59b upstream.
Added to backup/restore registers HFLBADDR, HCCHARi, HCSPLTi, HCTSIZi, HCDMAi and HCDMABi.
--- drivers/usb/dwc2/core.h | 12 ++++++++++++ drivers/usb/dwc2/hcd.c | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
drivers/usb/dwc2/core.h +12 -0
@@ -729,8 +729,14 @@ struct dwc2_dregs_backup {* struct dwc2_hregs_backup - Holds host registers state before * entering partial power down * @hcfg: Backup of HCFG register +* @hflbaddr: Backup of HFLBADDR register * @haintmsk: Backup of HAINTMSK register +* @hcchar: Backup of HCCHAR register +* @hcsplt: Backup of HCSPLT register * @hcintmsk: Backup of HCINTMSK register +* @hctsiz: Backup of HCTSIZ register +* @hdma: Backup of HCDMA register +* @hcdmab: Backup of HCDMAB register * @hprt0: Backup of HPTR0 register * @hfir: Backup of HFIR register * @hptxfsiz: Backup of HPTXFSIZ register
@@ -738,8 +744,14 @@ struct dwc2_dregs_backup {*/ struct dwc2_hregs_backup {u32 hcfg; +u32 hflbaddr;u32 haintmsk; +u32 hcchar[MAX_EPS_CHANNELS ]; +u32 hcsplt[MAX_EPS_CHANNELS ];u32 hcintmsk[MAX_EPS_CHANNELS ]; +u32 hctsiz[MAX_EPS_CHANNELS ]; +u32 hcidma[MAX_EPS_CHANNELS ]; +u32 hcidmab[MAX_EPS_CHANNELS ];u32 hprt0;u32 hfir;u32 hptxfsiz;
drivers/usb/dwc2/hcd.c +16 -2
@@ -5406,9 +5406,16 @@ int dwc2_backup_host_registers(struct dw/* Backup Host regs */ hr = &hsotg->hr_backup; hr->hcfg =dwc2_readl (hsotg,HCFG ); + hr->hflbaddr =dwc2_readl (hsotg,HFLBADDR ); hr->haintmsk =dwc2_readl (hsotg,HAINTMSK ); -for (i =0 ; i < hsotg->params.host_channels; ++i) +for (i =0 ; i < hsotg->params.host_channels; ++i) { + hr->hcchar[i] =dwc2_readl (hsotg,HCCHAR (i)); + hr->hcsplt[i] =dwc2_readl (hsotg,HCSPLT (i)); hr->hcintmsk[i] =dwc2_readl (hsotg,HCINTMSK (i)); + hr->hctsiz[i] =dwc2_readl (hsotg,HCTSIZ (i)); + hr->hcidma[i] =dwc2_readl (hsotg,HCDMA (i)); + hr->hcidmab[i] =dwc2_readl (hsotg,HCDMAB (i)); + } hr->hprt0 =dwc2_read_hprt0 (hsotg); hr->hfir =dwc2_readl (hsotg,HFIR );
@@ -5442,10 +5449,17 @@ int dwc2_restore_host_registers(struct d hr->valid = false;dwc2_writel (hsotg, hr->hcfg,HCFG ); +dwc2_writel (hsotg, hr->hflbaddr,HFLBADDR );dwc2_writel (hsotg, hr->haintmsk,HAINTMSK ); -for (i =0 ; i < hsotg->params.host_channels; ++i) +for (i =0 ; i < hsotg->params.host_channels; ++i) { +dwc2_writel (hsotg, hr->hcchar[i],HCCHAR (i)); +dwc2_writel (hsotg, hr->hcsplt[i],HCSPLT (i));dwc2_writel (hsotg, hr->hcintmsk[i],HCINTMSK (i)); +dwc2_writel (hsotg, hr->hctsiz[i],HCTSIZ (i)); +dwc2_writel (hsotg, hr->hcidma[i],HCDMA (i)); +dwc2_writel (hsotg, hr->hcidmab[i],HCDMAB (i)); + }dwc2_writel (hsotg, hr->hprt0,HPRT0 );dwc2_writel (hsotg, hr->hfir,HFIR );
Greg Kroah-Hartman
maintainerPATCH 368/396 usb: dwc2: host: Fix ISOC flow in DDMA mode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit b258e42688501cadb1a6dd658d6f015df9f32d8f upstream.
Fixed ISOC completion flow in DDMA mode. Added isoc descriptor actual length value and update urb's start_frame value.
Fixed initialization of ISOC DMA descriptors flow.
--- drivers/usb/dwc2/hcd.c | 12 ++++++++++-- drivers/usb/dwc2/hcd_ddma.c | 17 +++++++++++------ drivers/usb/dwc2/hw.h | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-)
drivers/usb/dwc2/hcd.c +10 -2
@@ -2701,8 +2701,11 @@ enum dwc2_transaction_type dwc2_hcd_sele hsotg->available_host_channels--; } qh = list_entry(qh_ptr, struct dwc2_qh, qh_list_entry); -if (dwc2_assign_and_init_hc (hsotg, qh)) +if (dwc2_assign_and_init_hc (hsotg, qh)) { +if (hsotg->params.uframe_sched) + hsotg->available_host_channels++;break ; + }/* * Move the QH from the periodic ready schedule to the
@@ -2735,8 +2738,11 @@ enum dwc2_transaction_type dwc2_hcd_sele hsotg->available_host_channels--; } -if (dwc2_assign_and_init_hc (hsotg, qh)) +if (dwc2_assign_and_init_hc (hsotg, qh)) { +if (hsotg->params.uframe_sched) + hsotg->available_host_channels++;break ; + }/* * Move the QH from the non-periodic inactive schedule to the
@@ -4143,6 +4149,8 @@ void dwc2_host_complete(struct dwc2_hsot urb->actual_length);if (usb_pipetype (urb->pipe) ==PIPE_ISOCHRONOUS ) { +if (!hsotg->params.dma_desc_enable) + urb->start_frame = qtd->qh->start_active_frame; urb->error_count =dwc2_hcd_urb_get_error_count (qtd->urb);for (i =0 ; i < urb->number_of_packets; ++i) { urb->iso_frame_desc[i].actual_length =
drivers/usb/dwc2/hcd_ddma.c +11 -6
@@ -559,7 +559,7 @@ static void dwc2_init_isoc_dma_desc(stru idx = qh->td_last; inc = qh->host_interval; hsotg->frame_number =dwc2_hcd_get_frame_number (hsotg); - cur_idx =dwc2_frame_list_idx (hsotg->frame_number); + cur_idx = idx; next_idx =dwc2_desclist_idx_inc (qh->td_last, inc, qh->dev_speed);/*
@@ -866,6 +866,8 @@ static int dwc2_cmpl_host_isoc_dma_desc( {struct dwc2_dma_desc *dma_desc;struct dwc2_hcd_iso_packet_desc *frame_desc; +u16 frame_desc_idx; +struct urb *usb_urb = qtd->urb->priv;u16 remain =0 ;int rc =0 ;
@@ -878,8 +880,11 @@ static int dwc2_cmpl_host_isoc_dma_desc( DMA_FROM_DEVICE); dma_desc = &qh->desc_list[idx]; + frame_desc_idx = (idx - qtd->isoc_td_first) & (usb_urb->number_of_packets -1 ); - frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index_last]; + frame_desc = &qtd->urb->iso_descs[frame_desc_idx]; +if (idx == qtd->isoc_td_first) + usb_urb->start_frame =dwc2_hcd_get_frame_number (hsotg); dma_desc->buf = (u32)(qtd->urb->dma + frame_desc->offset);if (chan->ep_is_in) remain = (dma_desc->status & HOST_DMA_ISOC_NBYTES_MASK) >>
@@ -900,7 +905,7 @@ static int dwc2_cmpl_host_isoc_dma_desc( frame_desc->status =0 ; } -if (++qtd->isoc_frame_index == qtd->urb->packet_count) { +if (++qtd->isoc_frame_index == usb_urb->number_of_packets) {/* * urb->status is not used for isoc transfers here. The * individual frame_desc status are used instead.
@@ -1005,11 +1010,11 @@ static void dwc2_complete_isoc_xfer_ddmareturn ; idx =dwc2_desclist_idx_inc (idx, qh->host_interval, chan->speed); -if (!rc) +if (rc ==0 )continue ; -if (rc ==DWC2_CMPL_DONE ) -break ; +if (rc ==DWC2_CMPL_DONE || rc ==DWC2_CMPL_STOP ) + goto stop_scan;/* rc == DWC2_CMPL_STOP */
drivers/usb/dwc2/hw.h +1 -1
@@ -698,7 +698,7 @@#define TXSTS_QTOP_TOKEN_MASK (0x3 << 25)#define TXSTS_QTOP_TOKEN_SHIFT 25#define TXSTS_QTOP_TERMINATE BIT(24) -#define TXSTS_QSPCAVAIL_MASK (0xff << 16) +#define TXSTS_QSPCAVAIL_MASK (0x7f << 16)#define TXSTS_QSPCAVAIL_SHIFT 16#define TXSTS_FSPCAVAIL_MASK (0xffff << 0)#define TXSTS_FSPCAVAIL_SHIFT 0
Greg Kroah-Hartman
maintainerPATCH 369/396 usb: dwc2: gadget: Fix exiting from clock gating
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 31f42da31417bec88158f3cf62d19db836217f1e upstream.
Added exiting from the clock gating mode on USB Reset Detect interrupt if core in the clock gating mode.
Added new condition to check core in clock gating mode or no.
--- drivers/usb/dwc2/core_intr.c | 9 ++++++--- drivers/usb/dwc2/gadget.c | 6 ++++++ drivers/usb/dwc2/hcd.c | 2 +- drivers/usb/dwc2/platform.c | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-)
drivers/usb/dwc2/core_intr.c +6 -3
@@ -297,7 +297,8 @@ static void dwc2_handle_session_req_intr/* Exit gadget mode clock gating. */ if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_gadget_exit_clock_gating (hsotg,0 ); }
@@ -408,7 +409,8 @@ static void dwc2_handle_wakeup_detected_/* Exit gadget mode clock gating. */ if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_gadget_exit_clock_gating (hsotg,0 ); }else {/* Change to L0 state */
@@ -425,7 +427,8 @@ static void dwc2_handle_wakeup_detected_ }if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_host_exit_clock_gating (hsotg,1 );/*
drivers/usb/dwc2/gadget.c +6 -0
@@ -3727,6 +3727,12 @@ irq_retry:if (hsotg->in_ppd && hsotg->lx_state ==DWC2_L2 )dwc2_exit_partial_power_down (hsotg,0 , true); +/* Exit gadget mode clock gating. */ +if (hsotg->params.power_down == +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating) +dwc2_gadget_exit_clock_gating (hsotg,0 ); + hsotg->lx_state =DWC2_L0 ; }
drivers/usb/dwc2/hcd.c +1 -1
@@ -4657,7 +4657,7 @@ static int _dwc2_hcd_urb_enqueue(struct }if (hsotg->params.power_down ==DWC2_POWER_DOWN_PARAM_NONE && - hsotg->bus_suspended) { + hsotg->bus_suspended && !hsotg->params.no_clock_gating) {if (dwc2_is_device_mode (hsotg))dwc2_gadget_exit_clock_gating (hsotg,0 );else
drivers/usb/dwc2/platform.c +1 -1
@@ -331,7 +331,7 @@ static void dwc2_driver_remove(struct pl/* Exit clock gating when driver is removed. */ if (hsotg->params.power_down ==DWC2_POWER_DOWN_PARAM_NONE && - hsotg->bus_suspended) { + hsotg->bus_suspended && !hsotg->params.no_clock_gating) {if (dwc2_is_device_mode (hsotg))dwc2_gadget_exit_clock_gating (hsotg,0 );else
Greg Kroah-Hartman
maintainerPATCH 370/396 usb: dwc2: gadget: LPM flow fix
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 5d69a3b54e5a630c90d82a4c2bdce3d53dc78710 upstream.
Added functionality to exit from L1 state by device initiation using remote wakeup signaling, in case when function driver queuing request while core in L1 state.
--- drivers/usb/dwc2/core.h | 1 drivers/usb/dwc2/core_intr.c | 65 ++++++++++++++++++++++++++++--------------- drivers/usb/dwc2/gadget.c | 4 ++ 3 files changed, 48 insertions(+), 22 deletions(-)
drivers/usb/dwc2/core.h +1 -0
@@ -1336,6 +1336,7 @@ int dwc2_backup_global_registers(structint dwc2_restore_global_registers (struct dwc2_hsotg *hsotg);void dwc2_enable_acg (struct dwc2_hsotg *hsotg); +void dwc2_wakeup_from_lpm_l1 (struct dwc2_hsotg *hsotg,bool remotewakeup);/* This function should be called on every hardware interrupt. */ irqreturn_t dwc2_handle_common_intr (int irq,void *dev);
drivers/usb/dwc2/core_intr.c +43 -22
97 lines not on this page · raw message
drivers/usb/dwc2/gadget.c +4 -0
@@ -1415,6 +1415,10 @@ static int dwc2_hsotg_ep_queue(struct us ep->name, req, req->length, req->buf, req->no_interrupt, req->zero, req->short_not_ok); +if (hs->lx_state ==DWC2_L1 ) { +dwc2_wakeup_from_lpm_l1 (hs, true); + } +/* Prevent new request submission when controller is suspended */ if (hs->lx_state !=DWC2_L0 ) { dev_dbg(hs->dev, "%s: submit request only in active state\n",
Greg Kroah-Hartman
maintainerPATCH 371/396 usb: udc: remove warning when queue disabled ep
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: yuan linyu <[email protected]>
commit 2a587a035214fa1b5ef598aea0b81848c5b72e5e upstream.
It is possible trigger below warning message from mass storage function,
WARNING: CPU: 6 PID: 3839 at drivers/usb/gadget/udc/core.c:294 usb_ep_queue+0x7c/0x104 pc : usb_ep_queue+0x7c/0x104 lr : fsg_main_thread+0x494/0x1b3c
Root cause is mass storage function try to queue request from main thread, but other thread may already disable ep when function disable.
As there is no function failure in the driver, in order to avoid effort to fix warning, change WARN_ON_ONCE() in usb_ep_queue() to pr_debug().
--- drivers/usb/gadget/udc/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/core.c +3 -1
@@ -292,7 +292,9 @@ int usb_ep_queue(struct usb_ep *ep, {int ret =0 ; -if (WARN_ON_ONCE (!ep->enabled && ep->address)) { +if (!ep->enabled && ep->address) { +pr_debug ("USB gadget: queue request to disabled ep 0x%x (%s)\n" , + ep->address, ep->name); ret = -ESHUTDOWN ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 372/396 usb: typec: Return size of buffer if pd_set operation succeeds
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Tso <[email protected]>
commit 53f5094fdf5deacd99b8655df692e9278506724d upstream.
The attribute writing should return the number of bytes used from the buffer on success.
--- drivers/usb/typec/class.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/typec/class.c +6 -1
@@ -1264,6 +1264,7 @@ static ssize_t select_usb_power_delivery {struct typec_port *port =to_typec_port (dev);struct usb_power_delivery *pd; +int ret;if (!port->ops || !port->ops->pd_set)return -EOPNOTSUPP ;
@@ -1272,7 +1273,11 @@ static ssize_t select_usb_power_deliveryif (!pd)return -EINVAL ; -return port->ops->pd_set (port, pd); + ret = port->ops->pd_set (port, pd); +if (ret) +return ret; + +return size; } static ssize_t select_usb_power_delivery_show(struct device *dev,
Greg Kroah-Hartman
maintainerPATCH 373/396 usb: typec: ucsi: Clear EVENT_PENDING under PPM lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 15b2e71b4653b3e13df34695a29ebeee237c5af2 upstream.
Suppose we sleep on the PPM lock after clearing the EVENT_PENDING bit because the thread for another connector is executing a command. In this case the command completion of the other command will still report the connector change for our connector.
Clear the EVENT_PENDING bit under the PPM lock to avoid another useless call to ucsi_handle_connector_change() in this case.
--- drivers/usb/typec/ucsi/ucsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +2 -2
@@ -933,11 +933,11 @@ static void ucsi_handle_connector_changeif (con->status.change &UCSI_CONSTAT_CAM_CHANGE )ucsi_partner_task (con, ucsi_check_altmodes,1 ,0 ); -clear_bit (EVENT_PENDING , &con->ucsi->flags); -mutex_lock (&ucsi->ppm_lock); +clear_bit (EVENT_PENDING , &con->ucsi->flags); ret =ucsi_acknowledge_connector_change (ucsi);mutex_unlock (&ucsi->ppm_lock); +if (ret)dev_err (ucsi->dev,"%s: ACK failed (%d)" , __func__, ret);
Greg Kroah-Hartman
maintainerPATCH 374/396 usb: typec: ucsi: Check for notifications after init
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56 upstream.
The completion notification for the final SET_NOTIFICATION_ENABLE command during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.
Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +9 -1
@@ -955,7 +955,7 @@ void ucsi_connector_change(struct ucsi *struct ucsi_connector *con = &ucsi->connector[num -1 ];if (!(ucsi->ntfy &UCSI_ENABLE_NTFY_CONNECTOR_CHANGE )) { -dev_dbg (ucsi->dev,"Bogus connector change event\n" ); +dev_dbg (ucsi->dev,"Early connector change event\n" );return ; }
@@ -1352,6 +1352,7 @@ static int ucsi_init(struct ucsi *ucsi) {struct ucsi_connector *con, *connector;u64 command, ntfy; +u32 cci;int ret;int i;
@@ -1404,6 +1405,13 @@ static int ucsi_init(struct ucsi *ucsi) ucsi->connector = connector; ucsi->ntfy = ntfy; + + ret = ucsi->ops->read (ucsi,UCSI_CCI , &cci,sizeof (cci)); +if (ret) +return ret; +if (UCSI_CCI_CONNECTOR (READ_ONCE (cci))) +ucsi_connector_change (ucsi, cci); +return 0 ; err_unregister:
Greg Kroah-Hartman
maintainerPATCH 375/396 usb: typec: ucsi: Ack unsupported commands
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 6b5c85ddeea77d18c4b69e3bda60e9374a20c304 upstream.
If a command completes the OPM must send an ack. This applies to unsupported commands, too.
Send the required ACK for unsupported commands.
--- drivers/usb/typec/ucsi/ucsi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +5 -1
@@ -138,8 +138,12 @@ static int ucsi_exec_command(struct ucsiif (!(cci &UCSI_CCI_COMMAND_COMPLETE ))return -EIO ; -if (cci &UCSI_CCI_NOT_SUPPORTED ) +if (cci &UCSI_CCI_NOT_SUPPORTED ) { +if (ucsi_acknowledge_command (ucsi) <0 ) +dev_err (ucsi->dev, +"ACK of unsupported command failed\n" );return -EOPNOTSUPP ; + }if (cci &UCSI_CCI_ERROR ) {if (cmd ==UCSI_GET_ERROR_STATUS )
Greg Kroah-Hartman
maintainerPATCH 376/396 usb: typec: ucsi_acpi: Refactor and fix DELL quirk
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 6aaceb7d9cd00f3e065dc4b054ecfe52c5253b03 upstream.
Some DELL systems don't like UCSI_ACK_CC_CI commands with the UCSI_ACK_CONNECTOR_CHANGE but not the UCSI_ACK_COMMAND_COMPLETE bit set. The current quirk still leaves room for races because it requires two consecutive ACK commands to be sent.
Refactor and significantly simplify the quirk to fix this:
Send a dummy command and bundle the connector change ack with the command completion ack in a single UCSI_ACK_CC_CI command. This removes the need to probe for the quirk.
While there define flag bits for struct ucsi_acpi->flags in ucsi_acpi.c and don't re-use definitions from ucsi.h for struct ucsi->flags.
--- drivers/usb/typec/ucsi/ucsi_acpi.c | 71 ++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 40 deletions(-)
drivers/usb/typec/ucsi/ucsi_acpi.c +31 -40
@@ -23,10 +23,11 @@ struct ucsi_acpi {void *base;struct completion complete;unsigned long flags; +#define UCSI_ACPI_SUPPRESS_EVENT 0 +#define UCSI_ACPI_COMMAND_PENDING 1 +#define UCSI_ACPI_ACK_PENDING 2guid_t guid;u64 cmd; -bool dell_quirk_probed; -bool dell_quirk_active; };static int ucsi_acpi_dsm (struct ucsi_acpi *ua,int func)
@@ -79,9 +80,9 @@ static int ucsi_acpi_sync_write(struct uint ret;if (ack) -set_bit (ACK_PENDING , &ua->flags); +set_bit (UCSI_ACPI_ACK_PENDING , &ua->flags);else -set_bit (COMMAND_PENDING , &ua->flags); +set_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags); ret =ucsi_acpi_async_write (ucsi, offset, val, val_len);if (ret)
@@ -92,9 +93,9 @@ static int ucsi_acpi_sync_write(struct u out_clear_bit:if (ack) -clear_bit (ACK_PENDING , &ua->flags); +clear_bit (UCSI_ACPI_ACK_PENDING , &ua->flags);else -clear_bit (COMMAND_PENDING , &ua->flags); +clear_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags);return ret; }
@@ -129,51 +130,40 @@ static const struct ucsi_operations ucsi };/* -* Some Dell laptops expect that an ACK command with the -* UCSI_ACK_CONNECTOR_CHANGE bit set is followed by a (separate) -* ACK command that only has the UCSI_ACK_COMMAND_COMPLETE bit set. -* If this is not done events are not delivered to OSPM and -* subsequent commands will timeout. +* Some Dell laptops don't like ACK commands with the +* UCSI_ACK_CONNECTOR_CHANGE but not the UCSI_ACK_COMMAND_COMPLETE +* bit set. To work around this send a dummy command and bundle the +* UCSI_ACK_CONNECTOR_CHANGE with the UCSI_ACK_COMMAND_COMPLETE +* for the dummy command. */ static int ucsi_dell_sync_write (struct ucsi *ucsi,unsigned int offset,const void *val,size_t val_len) {struct ucsi_acpi *ua =ucsi_get_drvdata (ucsi); -u64 cmd = *(u64 *)val, ack =0 ; +u64 cmd = *(u64 *)val; +u64 dummycmd =UCSI_GET_CAPABILITY ;int ret; -if (UCSI_COMMAND (cmd) ==UCSI_ACK_CC_CI && - cmd &UCSI_ACK_CONNECTOR_CHANGE ) - ack =UCSI_ACK_CC_CI |UCSI_ACK_COMMAND_COMPLETE ; +if (cmd == (UCSI_ACK_CC_CI |UCSI_ACK_CONNECTOR_CHANGE )) { + cmd |=UCSI_ACK_COMMAND_COMPLETE ; - ret =ucsi_acpi_sync_write (ucsi, offset, val, val_len); -if (ret !=0 ) -return ret; -if (ack ==0 ) -return ret; - -if (!ua->dell_quirk_probed) { - ua->dell_quirk_probed = true; +/* +* The UCSI core thinks it is sending a connector change ack +* and will accept new connector change events. We don't want +* this to happen for the dummy command as its response will +* still report the very event that the core is trying to clear. +*/ +set_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags); + ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &dummycmd, +sizeof (dummycmd)); +clear_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags); - cmd =UCSI_GET_CAPABILITY ; - ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &cmd, -sizeof (cmd)); -if (ret ==0 ) -return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , - &ack,sizeof (ack)); -if (ret != -ETIMEDOUT ) +if (ret <0 )return ret; - - ua->dell_quirk_active = true; -dev_err (ua->dev,"Firmware bug: Additional ACK required after ACKing a connector change.\n" ); -dev_err (ua->dev,"Firmware bug: Enabling workaround\n" ); } -if (!ua->dell_quirk_active) -return ret; - -return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &ack,sizeof (ack)); +return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &cmd,sizeof (cmd)); }static const struct ucsi_operations ucsi_dell_ops = {
@@ -209,13 +199,14 @@ static void ucsi_acpi_notify(acpi_handleif (ret)return ; -if (UCSI_CCI_CONNECTOR (cci)) +if (UCSI_CCI_CONNECTOR (cci) && + !test_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags))ucsi_connector_change (ua->ucsi,UCSI_CCI_CONNECTOR (cci));if (cci &UCSI_CCI_ACK_COMPLETE &&test_bit (ACK_PENDING , &ua->flags))complete (&ua->complete);if (cci &UCSI_CCI_COMMAND_COMPLETE && -test_bit (COMMAND_PENDING , &ua->flags)) +test_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags))complete (&ua->complete); }
Greg Kroah-Hartman
maintainerPATCH 377/396 usb: typec: ucsi: Clear UCSI_CCI_RESET_COMPLETE before reset
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 3de4f996a0b5412aa451729008130a488f71563e upstream.
Check the UCSI_CCI_RESET_COMPLETE complete flag before starting another reset. Use a UCSI_SET_NOTIFICATION_ENABLE command to clear the flag if it is set.
--- drivers/usb/typec/ucsi/ucsi.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +35 -1
@@ -982,13 +982,47 @@ static int ucsi_reset_connector(struct ustatic int ucsi_reset_ppm (struct ucsi *ucsi) { -u64 command =UCSI_PPM_RESET ; +u64 command;unsigned long tmo;u32 cci;int ret;mutex_lock (&ucsi->ppm_lock); + ret = ucsi->ops->read (ucsi,UCSI_CCI , &cci,sizeof (cci)); +if (ret <0 ) + goto out; + +/* +* If UCSI_CCI_RESET_COMPLETE is already set we must clear +* the flag before we start another reset. Send a +* UCSI_SET_NOTIFICATION_ENABLE command to achieve this. +* Ignore a timeout and try the reset anyway if this fails. +*/ +if (cci &UCSI_CCI_RESET_COMPLETE ) { + command =UCSI_SET_NOTIFICATION_ENABLE ; + ret = ucsi->ops->async_write (ucsi,UCSI_CONTROL , &command, +sizeof (command)); +if (ret <0 ) + goto out; + + tmo = jiffies +msecs_to_jiffies (UCSI_TIMEOUT_MS ); +do { + ret = ucsi->ops->read (ucsi,UCSI_CCI , + &cci,sizeof (cci)); +if (ret <0 ) + goto out; +if (cci &UCSI_CCI_COMMAND_COMPLETE ) +break ; +if (time_is_before_jiffies (tmo)) +break ; +msleep (20 ); + }while (1 ); + +WARN_ON (cci &UCSI_CCI_RESET_COMPLETE ); + } + + command =UCSI_PPM_RESET ; ret = ucsi->ops->async_write (ucsi,UCSI_CONTROL , &command,sizeof (command));if (ret <0 )
Greg Kroah-Hartman
maintainerPATCH 378/396 scsi: qla2xxx: Prevent command send on chip reset
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 4895009c4bb72f71f2e682f1e7d2c2d96e482087 upstream.
Currently IOCBs are allowed to push through while chip reset could be in progress. During chip reset the outstanding_cmds array is cleared twice. Once when any command on this array is returned as failed and secondly when the array is initialize to zero. If a command is inserted on to the array between these intervals, then the command will be lost. Check for chip reset before sending IOCB.
--- drivers/scsi/qla2xxx/qla_init.c | 8 ++++++-- drivers/scsi/qla2xxx/qla_iocb.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +6 -2
@@ -1193,8 +1193,12 @@ int qla24xx_async_gnl(struct scsi_qla_horeturn rval; done_free_sp: -/* ref: INIT */ -kref_put (&sp->cmd_kref, qla2x00_sp_release); +/* +* use qla24xx_async_gnl_sp_done to purge all pending gnl request. +* kref_put is call behind the scene. +*/ + sp->u.iocb_cmd.u.mbx.in_mb[0 ] =MBS_COMMAND_ERROR ; +qla24xx_async_gnl_sp_done (sp,QLA_COMMAND_ERROR ); fcport->flags &= ~(FCF_ASYNC_SENT ); done: fcport->flags &= ~(FCF_ASYNC_ACTIVE );
drivers/scsi/qla2xxx/qla_iocb.c +31 -2
@@ -2587,6 +2587,33 @@ void qla2x00_sp_release(struct kref *kref) { struct srb *sp = container_of(kref, struct srb, cmd_kref); +struct scsi_qla_host *vha = sp->vha; + +switch (sp->type) { +case SRB_CT_PTHRU_CMD : +/* GPSC & GFPNID use fcport->ct_desc.ct_sns for both req & rsp */ +if (sp->u.iocb_cmd.u.ctarg.req && + (!sp->fcport || + sp->u.iocb_cmd.u.ctarg.req != sp->fcport->ct_desc.ct_sns)) { +dma_free_coherent (&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.req_allocated_size, + sp->u.iocb_cmd.u.ctarg.req, + sp->u.iocb_cmd.u.ctarg.req_dma); + sp->u.iocb_cmd.u.ctarg.req =NULL ; + } +if (sp->u.iocb_cmd.u.ctarg.rsp && + (!sp->fcport || + sp->u.iocb_cmd.u.ctarg.rsp != sp->fcport->ct_desc.ct_sns)) { +dma_free_coherent (&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.rsp_allocated_size, + sp->u.iocb_cmd.u.ctarg.rsp, + sp->u.iocb_cmd.u.ctarg.rsp_dma); + sp->u.iocb_cmd.u.ctarg.rsp =NULL ; + } +break ; +default : +break ; + } sp->free (sp); }
@@ -2692,7 +2719,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v*/ sp =qla2x00_get_sp (vha, fcport,GFP_KERNEL );if (!sp) { -kfree (fcport); +qla2x00_free_fcport (fcport);ql_log (ql_log_info, vha,0x70e6 ,"SRB allocation failed\n" );return -ENOMEM ;
@@ -2747,6 +2774,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vif (rval !=QLA_SUCCESS ) {/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release); +qla2x00_free_fcport (fcport);return QLA_FUNCTION_FAILED ; }
@@ -2756,6 +2784,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v fcport->d_id.b.area, fcport->d_id.b.al_pa);wait_for_completion (&elsio->u.els_logo.comp); +qla2x00_free_fcport (fcport);/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release);
@@ -3918,7 +3947,7 @@ qla2x00_start_sp(srb_t *sp)return -EAGAIN ; } - pkt =__qla2x00_alloc_iocbs (sp->qpair, sp); + pkt =qla2x00_alloc_iocbs_ready (sp->qpair, sp);if (!pkt) { rval = -EAGAIN ; ql_log(ql_log_warn, vha, 0x700c,
Greg Kroah-Hartman
maintainerPATCH 379/396 scsi: qla2xxx: Fix N2N stuck connection
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 881eb861ca3877300570db10abbf11494e48548d upstream.
Disk failed to rediscover after chip reset error injection. The chip reset happens at the time when a PLOGI is being sent. This causes a flag to be left on which blocks the retry. Clear the blocking flag.
--- drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_iocb.c | 32 +++++++++++--------------------- drivers/scsi/qla2xxx/qla_os.c | 2 +- 3 files changed, 13 insertions(+), 23 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +1 -1
@@ -44,7 +44,7 @@ extern int qla2x00_fabric_login(scsi_qlaextern int qla2x00_local_device_login (scsi_qla_host_t *,fc_port_t *);extern int qla24xx_els_dcmd_iocb (scsi_qla_host_t *,int ,port_id_t ); -extern int qla24xx_els_dcmd2_iocb (scsi_qla_host_t *,int ,fc_port_t *,bool ); +extern int qla24xx_els_dcmd2_iocb (scsi_qla_host_t *,int ,fc_port_t *);extern void qla2x00_els_dcmd2_free (scsi_qla_host_t *vha,struct els_plogi *els_plogi);
drivers/scsi/qla2xxx/qla_iocb.c +11 -21
@@ -3041,7 +3041,7 @@ static void qla2x00_els_dcmd2_sp_done(srint qla24xx_els_dcmd2_iocb (scsi_qla_host_t *vha,int els_opcode, -fc_port_t *fcport,bool wait) +fc_port_t *fcport) {srb_t *sp;struct srb_iocb *elsio =NULL ;
@@ -3056,8 +3056,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!sp) {ql_log (ql_log_info, vha,0x70e6 ,"SRB allocation failed\n" ); - fcport->flags &= ~FCF_ASYNC_ACTIVE ; -return -ENOMEM ; + goto done; } fcport->flags |=FCF_ASYNC_SENT ;
@@ -3066,9 +3065,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *ql_dbg (ql_dbg_io, vha,0x3073 ,"%s Enter: PLOGI portid=%06x\n" , __func__, fcport->d_id.b24); -if (wait) - sp->flags =SRB_WAKEUP_ON_COMP ; - sp->type =SRB_ELS_DCMD ; sp->name ="ELS_DCMD" ; sp->fcport = fcport;
@@ -3084,7 +3080,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!elsio->u.els_plogi.els_plogi_pyld) { rval =QLA_FUNCTION_FAILED ; - goto out; + goto done_free_sp; } resp_ptr = elsio->u.els_plogi.els_resp_pyld =
@@ -3093,7 +3089,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!elsio->u.els_plogi.els_resp_pyld) { rval =QLA_FUNCTION_FAILED ; - goto out; + goto done_free_sp; }ql_dbg (ql_dbg_io, vha,0x3073 ,"PLOGI %p %p\n" , ptr, resp_ptr);
@@ -3109,7 +3105,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (els_opcode ==ELS_DCMD_PLOGI &&DBELL_ACTIVE (vha)) {struct fc_els_flogi *p = ptr; - p->fl_csp.sp_features |=cpu_to_be16 (FC_SP_FT_SEC ); }
@@ -3118,10 +3113,11 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t * (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, sizeof(*elsio->u.els_plogi.els_plogi_pyld)); -init_completion (&elsio->u.els_plogi.comp); rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS ) { - rval =QLA_FUNCTION_FAILED ; + fcport->flags |=FCF_LOGIN_NEEDED ; +set_bit (RELOGIN_NEEDED , &vha->dpc_flags); + goto done_free_sp; }else { ql_dbg(ql_dbg_disc, vha, 0x3074, "%s PLOGI sent, hdl=%x, loopid=%x, to port_id %06x from port_id %06x\n",
@@ -3129,21 +3125,15 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t * fcport->d_id.b24, vha->d_id.b24); } -if (wait) { -wait_for_completion (&elsio->u.els_plogi.comp); - -if (elsio->u.els_plogi.comp_status !=CS_COMPLETE ) - rval =QLA_FUNCTION_FAILED ; - }else { - goto done; - } +return rval; -out: - fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE ); +done_free_sp:qla2x00_els_dcmd2_free (vha, &elsio->u.els_plogi);/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release); done: + fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE ); +qla2x00_set_fcport_disc_state (fcport,DSC_DELETED );return rval; }
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -5582,7 +5582,7 @@ qla2x00_do_work(struct scsi_qla_host *vhbreak ;case QLA_EVT_ELS_PLOGI :qla24xx_els_dcmd2_iocb (vha,ELS_DCMD_PLOGI , - e->u.fcport.fcport, false); + e->u.fcport.fcport);break ;case QLA_EVT_SA_REPLACE : rc =qla24xx_issue_sa_replace_iocb (vha, e);
Greg Kroah-Hartman
maintainerPATCH 380/396 scsi: qla2xxx: Split FCE|EFT trace control
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 76a192e1a566e15365704b9f8fb3b70825f85064 upstream.
Current code combines the allocation of FCE|EFT trace buffers and enables the features all in 1 step.
Split this step into separate steps in preparation for follow-on patch to allow user to have a choice to enable / disable FCE trace feature.
--- drivers/scsi/qla2xxx/qla_init.c | 102 ++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 61 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +41 -61
@@ -2669,6 +2669,40 @@ exit:return rval; } +static void qla_enable_fce_trace (scsi_qla_host_t *vha) +{ +int rval; +struct qla_hw_data *ha = vha->hw; + +if (ha->fce) { + ha->flags.fce_enabled =1 ; +memset (ha->fce,0 ,fce_calc_size (ha->fce_bufs)); + rval =qla2x00_enable_fce_trace (vha, + ha->fce_dma, ha->fce_bufs, ha->fce_mb, &ha->fce_bufs); + +if (rval) { +ql_log (ql_log_warn, vha,0x8033 , +"Unable to reinitialize FCE (%d).\n" , rval); + ha->flags.fce_enabled =0 ; + } + } +} + +static void qla_enable_eft_trace (scsi_qla_host_t *vha) +{ +int rval; +struct qla_hw_data *ha = vha->hw; + +if (ha->eft) { +memset (ha->eft,0 ,EFT_SIZE ); + rval =qla2x00_enable_eft_trace (vha, ha->eft_dma,EFT_NUM_BUFFERS ); + +if (rval) { +ql_log (ql_log_warn, vha,0x8034 , +"Unable to reinitialize EFT (%d).\n" , rval); + } + } +}/* * qla2x00_initialize_adapter * Initialize board.
@@ -3672,9 +3706,8 @@ qla24xx_chip_diag(scsi_qla_host_t *vha) }static void -qla2x00_init_fce_trace (scsi_qla_host_t *vha) +qla2x00_alloc_fce_trace (scsi_qla_host_t *vha) { -int rval;dma_addr_t tc_dma;void *tc;struct qla_hw_data *ha = vha->hw;
@@ -3703,27 +3736,17 @@ qla2x00_init_fce_trace(scsi_qla_host_t *return ; } - rval =qla2x00_enable_fce_trace (vha, tc_dma,FCE_NUM_BUFFERS , - ha->fce_mb, &ha->fce_bufs); -if (rval) { -ql_log (ql_log_warn, vha,0x00bf , -"Unable to initialize FCE (%d).\n" , rval); -dma_free_coherent (&ha->pdev->dev,FCE_SIZE , tc, tc_dma); -return ; - } -ql_dbg (ql_dbg_init, vha,0x00c0 ,"Allocated (%d KB) for FCE...\n" ,FCE_SIZE /1024 ); - ha->flags.fce_enabled =1 ; ha->fce_dma = tc_dma; ha->fce = tc; + ha->fce_bufs =FCE_NUM_BUFFERS ; }static void -qla2x00_init_eft_trace (scsi_qla_host_t *vha) +qla2x00_alloc_eft_trace (scsi_qla_host_t *vha) { -int rval;dma_addr_t tc_dma;void *tc;struct qla_hw_data *ha = vha->hw;
@@ -3748,14 +3771,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t *return ; } - rval =qla2x00_enable_eft_trace (vha, tc_dma,EFT_NUM_BUFFERS ); -if (rval) { -ql_log (ql_log_warn, vha,0x00c2 , -"Unable to initialize EFT (%d).\n" , rval); -dma_free_coherent (&ha->pdev->dev,EFT_SIZE , tc, tc_dma); -return ; - } -ql_dbg (ql_dbg_init, vha,0x00c3 ,"Allocated (%d KB) EFT ...\n" ,EFT_SIZE /1024 );
@@ -3763,13 +3778,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t * ha->eft = tc; } -static void -qla2x00_alloc_offload_mem (scsi_qla_host_t *vha) -{ -qla2x00_init_fce_trace (vha); -qla2x00_init_eft_trace (vha); -} -void qla2x00_alloc_fw_dump (scsi_qla_host_t *vha) {
@@ -3824,10 +3832,10 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vif (ha->tgt.atio_ring) mq_size += ha->tgt.atio_q_length *sizeof (request_t); -qla2x00_init_fce_trace (vha); +qla2x00_alloc_fce_trace (vha);if (ha->fce) fce_size =sizeof (struct qla2xxx_fce_chain ) +FCE_SIZE ; -qla2x00_init_eft_trace (vha); +qla2x00_alloc_eft_trace (vha);if (ha->eft) eft_size =EFT_SIZE ; }
@@ -4257,7 +4265,6 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)struct qla_hw_data *ha = vha->hw;struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;unsigned long flags; -uint16_t fw_major_version;int done_once =0 ;if (IS_P3P_TYPE (ha)) {
@@ -4324,7 +4331,6 @@ execute_fw_with_lr: goto failed; enable_82xx_npiv: - fw_major_version = ha->fw_major_version;if (IS_P3P_TYPE (ha))qla82xx_check_md_needed (vha);else
@@ -4353,12 +4359,11 @@ enable_82xx_npiv:if (rval !=QLA_SUCCESS ) goto failed; -if (!fw_major_version && !(IS_P3P_TYPE (ha))) -qla2x00_alloc_offload_mem (vha); -if (ql2xallocfwdump && !(IS_P3P_TYPE (ha)))qla2x00_alloc_fw_dump (vha); +qla_enable_fce_trace (vha); +qla_enable_eft_trace (vha); }else { goto failed; }
@@ -7491,7 +7496,6 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_int qla2x00_abort_isp (scsi_qla_host_t *vha) { -int rval;uint8_t status =0 ;struct qla_hw_data *ha = vha->hw;struct scsi_qla_host *vp, *tvp;
@@ -7585,31 +7589,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)if (IS_QLA81XX (ha) ||IS_QLA8031 (ha))qla2x00_get_fw_version (vha); -if (ha->fce) { - ha->flags.fce_enabled =1 ; -memset (ha->fce,0 , -fce_calc_size (ha->fce_bufs)); - rval =qla2x00_enable_fce_trace (vha, - ha->fce_dma, ha->fce_bufs, ha->fce_mb, - &ha->fce_bufs); -if (rval) { -ql_log (ql_log_warn, vha,0x8033 , -"Unable to reinitialize FCE " -"(%d).\n" , rval); - ha->flags.fce_enabled =0 ; - } - } -if (ha->eft) { -memset (ha->eft,0 ,EFT_SIZE ); - rval =qla2x00_enable_eft_trace (vha, - ha->eft_dma,EFT_NUM_BUFFERS ); -if (rval) { -ql_log (ql_log_warn, vha,0x8034 , -"Unable to reinitialize EFT " -"(%d).\n" , rval); - } - } }else {/* failed the ISP abort */ vha->flags.online =1 ;if (test_bit (ISP_ABORT_RETRY , &vha->dpc_flags)) {
Greg Kroah-Hartman
maintainerPATCH 381/396 scsi: qla2xxx: Update manufacturer detail
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bikash Hazarika <[email protected]>
commit 688fa069fda6fce24d243cddfe0c7024428acb74 upstream.
Update manufacturer detail from "Marvell Semiconductor, Inc." to "Marvell".
--- drivers/scsi/qla2xxx/qla_def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_def.h +1 -1
@@ -82,7 +82,7 @@ typedef union {#include "qla_nvme.h" #define QLA2XXX_DRIVER_NAME "qla2xxx"#define QLA2XXX_APIDEV "ql2xapidev" -#define QLA2XXX_MANUFACTURER "Marvell Semiconductor, Inc." +#define QLA2XXX_MANUFACTURER "Marvell"/* * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
Greg Kroah-Hartman
maintainerPATCH 382/396 scsi: qla2xxx: NVME|FCP prefer flag not being honored
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 69aecdd410106dc3a8f543a4f7ec6379b995b8d0 upstream.
Changing of [FCP|NVME] prefer flag in flash has no effect on driver. For device that supports both FCP + NVMe over the same connection, driver continues to connect to this device using the previous successful login mode.
On completion of flash update, adapter will be reset. Driver will reset the prefer flag based on setting from flash.
--- drivers/scsi/qla2xxx/qla_init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/scsi/qla2xxx/qla_init.c +18 -0
@@ -7501,6 +7501,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)struct scsi_qla_host *vp, *tvp;struct req_que *req = ha->req_q_map[0 ];unsigned long flags; +fc_port_t *fcport;if (vha->flags.online) {qla2x00_abort_isp_cleanup (vha);
@@ -7569,6 +7570,15 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) "ISP Abort - ISP reg disconnect post nvmram config, exiting.\n");return status; } + +/* User may have updated [fcp|nvme] prefer in flash */ +list_for_each_entry (fcport, &vha->vp_fcports, list) { +if (NVME_PRIORITY (ha, fcport)) + fcport->do_prli_nvme =1 ; +else + fcport->do_prli_nvme =0 ; + } +if (!qla2x00_restart_isp (vha)) {clear_bit (RESET_MARKER_NEEDED , &vha->dpc_flags);
@@ -7639,6 +7649,14 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)atomic_inc (&vp->vref_count);spin_unlock_irqrestore (&ha->vport_slock, flags); +/* User may have updated [fcp|nvme] prefer in flash */ +list_for_each_entry (fcport, &vp->vp_fcports, list) { +if (NVME_PRIORITY (ha, fcport)) + fcport->do_prli_nvme =1 ; +else + fcport->do_prli_nvme =0 ; + } +qla2x00_vp_abort_isp (vp);spin_lock_irqsave (&ha->vport_slock, flags);
Greg Kroah-Hartman
maintainerPATCH 383/396 scsi: qla2xxx: Fix command flush on cable pull
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit a27d4d0e7de305def8a5098a614053be208d1aa1 upstream.
System crash due to command failed to flush back to SCSI layer.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 PGD 0 P4D 0 Oops: 0000 [#1] SMP NOPTI CPU: 27 PID: 793455 Comm: kworker/u130:6 Kdump: loaded Tainted: G OE --------- - - 4.18.0-372.9.1.el8.x86_64 #1 Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 09/03/2021 Workqueue: nvme-wq nvme_fc_connect_ctrl_work [nvme_fc] RIP: 0010:__wake_up_common+0x4c/0x190 Code: 24 10 4d 85 c9 74 0a 41 f6 01 04 0f 85 9d 00 00 00 48 8b 43 08 48 83 c3 08 4c 8d 48 e8 49 8d 41 18 48 39 c3 0f 84 f0 00 00 00 <49> 8b 41 18 89 54 24 08 31 ed 4c 8d 70 e8 45 8b 29 41 f6 c5 04 75 RSP: 0018:ffff95f3e0cb7cd0 EFLAGS: 00010086 RAX: 0000000000000000 RBX: ffff8b08d3b26328 RCX: 0000000000000000 RDX: 0000000000000001 RSI: 0000000000000003 RDI: ffff8b08d3b26320 RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffffffffffe8 R10: 0000000000000000 R11: ffff95f3e0cb7a60 R12: ffff95f3e0cb7d20 R13: 0000000000000003 R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff8b2fdf6c0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000002f1e410002 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: __wake_up_common_lock+0x7c/0xc0 qla_nvme_ls_req+0x355/0x4c0 [qla2xxx] qla2xxx [0000:12:00.1]-f084:3: qlt_free_session_done: se_sess 0000000000000000 / sess ffff8ae1407ca000 from port 21:32:00:02:ac:07:ee:b8 loop_id 0x02 s_id 01:02:00 logout 1 keep 0 els_logo 0 ? __nvme_fc_send_ls_req+0x260/0x380 [nvme_fc] qla2xxx [0000:12:00.1]-207d:3: FCPort 21:32:00:02:ac:07:ee:b8 state transitioned from ONLINE to LOST - portid=010200. ? nvme_fc_send_ls_req.constprop.42+0x1a/0x45 [nvme_fc] qla2xxx [0000:12:00.1]-2109:3: qla2x00_schedule_rport_del 21320002ac07eeb8. rport ffff8ae598122000 roles 1 ? nvme_fc_connect_ctrl_work.cold.63+0x1e3/0xa7d [nvme_fc] qla2xxx [0000:12:00.1]-f084:3: qlt_free_session_done: se_sess 0000000000000000 / sess ffff8ae14801e000 from port 21:32:01:02:ad:f7:ee:b8 loop_id 0x04 s_id 01:02:01 logout 1 keep 0 els_logo 0 ? __switch_to+0x10c/0x450 ? process_one_work+0x1a7/0x360 qla2xxx [0000:12:00.1]-207d:3: FCPort 21:32:01:02:ad:f7:ee:b8 state transitioned from ONLINE to LOST - portid=010201. ? worker_thread+0x1ce/0x390 ? create_worker+0x1a0/0x1a0 qla2xxx [0000:12:00.1]-2109:3: qla2x00_schedule_rport_del 21320102adf7eeb8. rport ffff8ae3b2312800 roles 70 ? kthread+0x10a/0x120 qla2xxx [0000:12:00.1]-2112:3: qla_nvme_unregister_remote_port: unregister remoteport on ffff8ae14801e000 21320102adf7eeb8 ? set_kthread_struct+0x40/0x40 qla2xxx [0000:12:00.1]-2110:3: remoteport_delete of ffff8ae14801e000 21320102adf7eeb8 completed. ? ret_from_fork+0x1f/0x40 qla2xxx [0000:12:00.1]-f086:3: qlt_free_session_done: waiting for sess ffff8ae14801e000 logout
The system was under memory stress where driver was not able to allocate an SRB to carry out error recovery of cable pull. The failure to flush causes upper layer to start modifying scsi_cmnd. When the system frees up some memory, the subsequent cable pull trigger another command flush. At this point the driver access a null pointer when attempting to DMA unmap the SGL.
Add a check to make sure commands are flush back on session tear down to prevent the null pointer access.
--- drivers/scsi/qla2xxx/qla_target.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/qla2xxx/qla_target.c +10 -0
@@ -1062,6 +1062,16 @@ void qlt_free_session_done(struct work_s "%s: sess %p logout completed\n", __func__, sess); } +/* check for any straggling io left behind */ +if (!(sess->flags &FCF_FCP2_DEVICE ) && +qla2x00_eh_wait_for_pending_commands (sess->vha, sess->d_id.b24,0 ,WAIT_TARGET )) { +ql_log (ql_log_warn, vha,0x3027 , +"IO not return. Resetting.\n" ); +set_bit (ISP_ABORT_NEEDED , &vha->dpc_flags); +qla2xxx_wake_dpc (vha); +qla2x00_wait_for_chip_reset (vha); + } +if (sess->logo_ack_needed) { sess->logo_ack_needed =0 ; qla24xx_async_notify_ack(vha, sess,
Greg Kroah-Hartman
maintainerPATCH 384/396 scsi: qla2xxx: Fix double free of the ha->vp_map pointer
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurav Kashyap <[email protected]>
commit e288285d47784fdcf7c81be56df7d65c6f10c58b upstream.
Coverity scan reported potential risk of double free of the pointer ha->vp_map. ha->vp_map was freed in qla2x00_mem_alloc(), and again freed in function qla2x00_mem_free(ha).
Assign NULL to vp_map and kfree take care of NULL.
--- drivers/scsi/qla2xxx/qla_os.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_os.c +1 -0
@@ -4601,6 +4601,7 @@ fail_free_init_cb: ha->init_cb_dma =0 ; fail_free_vp_map:kfree (ha->vp_map); + ha->vp_map =NULL ; fail:ql_log (ql_log_fatal,NULL ,0x0030 ,"Memory allocation failure.\n" );
Greg Kroah-Hartman
maintainerPATCH 385/396 scsi: qla2xxx: Fix double free of fcport
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurav Kashyap <[email protected]>
commit 82f522ae0d97119a43da53e0f729275691b9c525 upstream.
The server was crashing after LOGO because fcport was getting freed twice.
-----------[ cut here ]-----------
kernel BUG at mm/slub.c:371!
invalid opcode: 0000 1 SMP PTI
CPU: 35 PID: 4610 Comm: bash Kdump: loaded Tainted: G OE --------- - - 4.18.0-425.3.1.el8.x86_64 #1 Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 09/03/2021 RIP: 0010:set_freepointer.part.57+0x0/0x10 RSP: 0018:ffffb07107027d90 EFLAGS: 00010246 RAX: ffff9cb7e3150000 RBX: ffff9cb7e332b9c0 RCX: ffff9cb7e3150400 RDX: 0000000000001f37 RSI: 0000000000000000 RDI: ffff9cb7c0005500 RBP: fffff693448c5400 R08: 0000000080000000 R09: 0000000000000009 R10: 0000000000000000 R11: 0000000000132af0 R12: ffff9cb7c0005500 R13: ffff9cb7e3150000 R14: ffffffffc06990e0 R15: ffff9cb7ea85ea58 FS: 00007ff6b79c2740(0000) GS:ffff9cb8f7ec0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055b426b7d700 CR3: 0000000169c18002 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: kfree+0x238/0x250 qla2x00_els_dcmd_sp_free+0x20/0x230 [qla2xxx] ? qla24xx_els_dcmd_iocb+0x607/0x690 [qla2xxx] qla2x00_issue_logo+0x28c/0x2a0 [qla2xxx] ? qla2x00_issue_logo+0x28c/0x2a0 [qla2xxx] ? kernfs_fop_write+0x11e/0x1a0
Remove one of the free calls and add check for valid fcport. Also use function qla2x00_free_fcport() instead of kfree().
--- drivers/scsi/qla2xxx/qla_iocb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_iocb.c +3 -2
@@ -2637,7 +2637,8 @@ static void qla2x00_els_dcmd_sp_free(srb {struct srb_iocb *elsio = &sp->u.iocb_cmd; -kfree (sp->fcport); +if (sp->fcport) +qla2x00_free_fcport (sp->fcport);if (elsio->u.els_logo.els_logo_pyld) dma_free_coherent(&sp->vha->hw->pdev->dev, DMA_POOL_SIZE,
@@ -2750,6 +2751,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vif (!elsio->u.els_logo.els_logo_pyld) {/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release); +qla2x00_free_fcport (fcport);return QLA_FUNCTION_FAILED ; }
@@ -2784,7 +2786,6 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v fcport->d_id.b.area, fcport->d_id.b.al_pa);wait_for_completion (&elsio->u.els_logo.comp); -qla2x00_free_fcport (fcport);/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release);
Greg Kroah-Hartman
maintainerPATCH 386/396 scsi: qla2xxx: Change debug message during driver unload
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurav Kashyap <[email protected]>
commit b5a30840727a3e41d12a336d19f6c0716b299161 upstream.
Upon driver unload, purge_mbox flag is set and the heartbeat monitor thread detects this flag and does not send the mailbox command down to FW with a debug message "Error detected: purge[1] eeh[0] cmd=0x0, Exiting". This being not a real error, change the debug message.
--- drivers/scsi/qla2xxx/qla_mbx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_mbx.c +1 -1
@@ -194,7 +194,7 @@ qla2x00_mailbox_command(scsi_qla_host_tif (ha->flags.purge_mbox || chip_reset != ha->chip_reset || ha->flags.eeh_busy) {ql_log (ql_log_warn, vha,0xd035 , -"Error detected: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n" , +"Purge mbox: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n" , ha->flags.purge_mbox, ha->flags.eeh_busy, mcp->mb[0 ]); rval =QLA_ABORTED ; goto premature_exit;
Greg Kroah-Hartman
maintainerPATCH 387/396 scsi: qla2xxx: Delay I/O Abort on PCI error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 591c1fdf2016d118b8fbde427b796fac13f3f070 upstream.
Currently when PCI error is detected, I/O is aborted manually through the ABORT IOCB mechanism which is not guaranteed to succeed.
Instead, wait for the OS or system to notify driver to wind down I/O through the pci_error_handlers api. Set eeh_busy flag to pause all traffic and wait for I/O to drain.
--- drivers/scsi/qla2xxx/qla_attr.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +12 -2
@@ -2741,7 +2741,13 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rpreturn ;if (unlikely (pci_channel_offline (fcport->vha->hw->pdev))) { -qla2x00_abort_all_cmds (fcport->vha,DID_NO_CONNECT <<16 ); +/* Will wait for wind down of adapter */ +ql_dbg (ql_dbg_aer, fcport->vha,0x900c , +"%s pci offline detected (id %06x)\n" , __func__, + fcport->d_id.b24); +qla_pci_set_eeh_busy (fcport->vha); +qla2x00_eh_wait_for_pending_commands (fcport->vha, fcport->d_id.b24, +0 ,WAIT_TARGET );return ; } }
@@ -2763,7 +2769,11 @@ qla2x00_terminate_rport_io(struct fc_rpo vha = fcport->vha;if (unlikely (pci_channel_offline (fcport->vha->hw->pdev))) { -qla2x00_abort_all_cmds (fcport->vha,DID_NO_CONNECT <<16 ); +/* Will wait for wind down of adapter */ +ql_dbg (ql_dbg_aer, fcport->vha,0x900b , +"%s pci offline detected (id %06x)\n" , __func__, + fcport->d_id.b24); +qla_pci_set_eeh_busy (vha);qla2x00_eh_wait_for_pending_commands (fcport->vha, fcport->d_id.b24,0 ,WAIT_TARGET );return ;
Greg Kroah-Hartman
maintainerPATCH 388/396 x86/bugs: Use fixed addressing for VERW operand
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawan Gupta <[email protected]>
commit 8009479ee919b9a91674f48050ccbff64eafedaa upstream.
The macro used for MDS mitigation executes VERW with relative addressing for the operand. This was necessary in earlier versions of the series. Now it is unnecessary and creates a problem for backports on older kernels that don't support relocations in alternatives. Relocation support was added by commit 270a69c4485d ("x86/alternative:
Support relocations in alternatives"). Also asm for fixed addressing is much cleaner than relative RIP addressing.
Simplify the asm by using fixed addressing for VERW operand.
[ dhansen: tweak changelog ]
--- arch/x86/include/asm/nospec-branch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/nospec-branch.h +1 -1
@@ -337,7 +337,7 @@* Note: Only the memory operand variant of VERW clears the CPU buffers. */ .macro CLEAR_CPU_BUFFERS - ALTERNATIVE "", __stringify(verw _ASM_RIP(mds_verw_sel)), X86_FEATURE_CLEAR_CPU_BUF + ALTERNATIVE "", __stringify(verw mds_verw_sel), X86_FEATURE_CLEAR_CPU_BUF .endm#else /* __ASSEMBLY__ */
Greg Kroah-Hartman
maintainerPATCH 389/396 Revert "x86/bugs: Use fixed addressing for VERW operand"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit 532a0c57d7ff75e8f07d4e25cba4184989e2a241 upstream.
This was reverts commit 8009479ee919b9a91674f48050ccbff64eafedaa.
It was originally in x86/urgent, but was deemed wrong so got zapped. But in the meantime, x86/urgent had been merged into x86/apic to resolve a conflict. I didn't notice the merge so didn't zap it from x86/apic and it managed to make it up with the x86/apic material.
The reverted commit is known to cause some KASAN problems.
--- arch/x86/include/asm/nospec-branch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/nospec-branch.h +1 -1
@@ -337,7 +337,7 @@* Note: Only the memory operand variant of VERW clears the CPU buffers. */ .macro CLEAR_CPU_BUFFERS - ALTERNATIVE "", __stringify(verw mds_verw_sel), X86_FEATURE_CLEAR_CPU_BUF + ALTERNATIVE "", __stringify(verw _ASM_RIP(mds_verw_sel)), X86_FEATURE_CLEAR_CPU_BUF .endm#else /* __ASSEMBLY__ */
Greg Kroah-Hartman
maintainerPATCH 390/396 usb: dwc3: pci: Drop duplicate ID
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heikki Krogerus <[email protected]>
commit f121531703ae442edc1dde4b56803680628bc5b7 upstream.
Intel Arrow Lake CPU uses the Meteor Lake ID with this controller (the controller that's part of the Intel Arrow Lake chipset (PCH) does still have unique PCI ID).
--- drivers/usb/dwc3/dwc3-pci.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/dwc3/dwc3-pci.c +0 -2
@@ -51,7 +51,6 @@#define PCI_DEVICE_ID_INTEL_MTLP 0x7ec1#define PCI_DEVICE_ID_INTEL_MTLS 0x7f6f#define PCI_DEVICE_ID_INTEL_MTL 0x7e7e -#define PCI_DEVICE_ID_INTEL_ARLH 0x7ec1#define PCI_DEVICE_ID_INTEL_ARLH_PCH 0x777e#define PCI_DEVICE_ID_INTEL_TGL 0x9a15#define PCI_DEVICE_ID_AMD_MR 0x163a
@@ -423,7 +422,6 @@ static const struct pci_device_id dwc3_p { PCI_DEVICE_DATA(INTEL, MTLP, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, MTL, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, MTLS, &dwc3_pci_intel_swnode) }, - { PCI_DEVICE_DATA(INTEL, ARLH, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, ARLH_PCH, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, TGL, &dwc3_pci_intel_swnode) },
Greg Kroah-Hartman
maintainerPATCH 391/396 scsi: lpfc: Correct size for cmdwqe/rspwqe for memset()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
commit 16cc2ba71b9f6440805aef7f92ba0f031f79b765 upstream.
The cmdwqe and rspwqe are of type lpfc_wqe128. They should be memset() with the same type.
--- drivers/scsi/lpfc/lpfc_bsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_bsg.c +2 -2
@@ -3169,10 +3169,10 @@ lpfc_bsg_diag_loopback_run(struct bsg_jo } cmdwqe = &cmdiocbq->wqe; -memset (cmdwqe,0 ,sizeof (union lpfc_wqe )); +memset (cmdwqe,0 ,sizeof (*cmdwqe));if (phba->sli_rev <LPFC_SLI_REV4 ) { rspwqe = &rspiocbq->wqe; -memset (rspwqe,0 ,sizeof (union lpfc_wqe )); +memset (rspwqe,0 ,sizeof (*rspwqe)); }INIT_LIST_HEAD (&head);
Greg Kroah-Hartman
maintainerPATCH 392/396 scsi: lpfc: Correct size for wqe for memset()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
commit 28d41991182c210ec1654f8af2e140ef4cc73f20 upstream.
The wqe is of type lpfc_wqe128. It should be memset with the same type.
--- drivers/scsi/lpfc/lpfc_nvmet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_nvmet.c +1 -1
@@ -1586,7 +1586,7 @@ lpfc_nvmet_setup_io_context(struct lpfc_ wqe = &nvmewqe->wqe;/* Initialize WQE */ -memset (wqe,0 ,sizeof (union lpfc_wqe )); +memset (wqe,0 ,sizeof (*wqe)); ctx_buf->iocbq->cmd_dmabuf =NULL ;spin_lock (&phba->sli4_hba.sgl_list_lock);
Greg Kroah-Hartman
maintainerPATCH 393/396 scsi: libsas: Add a helper sas_get_sas_addr_and_dev_type()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
commit a57345279fd311ba679b8083feb0eec5272c7729 upstream.
Add a helper to get attached_sas_addr and device type from disc_resp.
--- drivers/scsi/libsas/sas_expander.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/scsi/libsas/sas_expander.c +12 -7
@@ -1621,6 +1621,16 @@ out_err:/* ---------- Domain revalidation ---------- */ +static void sas_get_sas_addr_and_dev_type (struct smp_disc_resp *disc_resp, +u8 *sas_addr, +enum sas_device_type *type) +{ +memcpy (sas_addr, disc_resp->disc.attached_sas_addr,SAS_ADDR_SIZE ); + *type =to_dev_type (&disc_resp->disc); +if (*type ==SAS_PHY_UNUSED ) +memset (sas_addr,0 ,SAS_ADDR_SIZE ); +} +static int sas_get_phy_discover (struct domain_device *dev,int phy_id,struct smp_disc_resp *disc_resp) {
@@ -1674,13 +1684,8 @@ int sas_get_phy_attached_dev(struct domareturn -ENOMEM ; res =sas_get_phy_discover (dev, phy_id, disc_resp); -if (res ==0 ) { -memcpy (sas_addr, disc_resp->disc.attached_sas_addr, -SAS_ADDR_SIZE ); - *type =to_dev_type (&disc_resp->disc); -if (*type ==0 ) -memset (sas_addr,0 ,SAS_ADDR_SIZE ); - } +if (res ==0 ) +sas_get_sas_addr_and_dev_type (disc_resp, sas_addr, type);kfree (disc_resp);return res; }
Greg Kroah-Hartman
maintainerPATCH 394/396 scsi: libsas: Fix disk not being scanned in after being removed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
commit 8e68a458bcf5b5cb9c3624598bae28f08251601f upstream.
As of commit d8649fc1c5e4 ("scsi: libsas: Do discovery on empty PHY to update PHY info"), do discovery will send a new SMP_DISCOVER and update phy->phy_change_count. We found that if the disk is reconnected and phy change_count changes at this time, the disk scanning process will not be triggered.
Therefore, call sas_set_ex_phy() to update the PHY info with the results of the last query. And because the previous phy info will be used when calling sas_unregister_devs_sas_addr(), sas_unregister_devs_sas_addr() should be called before sas_set_ex_phy().
--- drivers/scsi/libsas/sas_expander.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/scsi/libsas/sas_expander.c +22 -10
@@ -1945,6 +1945,7 @@ static int sas_rediscover_dev(struct domstruct expander_device *ex = &dev->ex_dev;struct ex_phy *phy = &ex->ex_phy[phy_id];enum sas_device_type type =SAS_PHY_UNUSED ; +struct smp_disc_resp *disc_resp;u8 sas_addr[SAS_ADDR_SIZE ];char msg[80 ] ="" ;int res;
@@ -1956,33 +1957,41 @@ static int sas_rediscover_dev(struct dom SAS_ADDR(dev->sas_addr), phy_id, msg);memset (sas_addr,0 ,SAS_ADDR_SIZE ); - res =sas_get_phy_attached_dev (dev, phy_id, sas_addr, &type); + disc_resp =alloc_smp_resp (DISCOVER_RESP_SIZE ); +if (!disc_resp) +return -ENOMEM ; + + res =sas_get_phy_discover (dev, phy_id, disc_resp);switch (res) {case SMP_RESP_NO_PHY : phy->phy_state =PHY_NOT_PRESENT ;sas_unregister_devs_sas_addr (dev, phy_id, last); -return res; + goto out_free_resp;case SMP_RESP_PHY_VACANT : phy->phy_state =PHY_VACANT ;sas_unregister_devs_sas_addr (dev, phy_id, last); -return res; + goto out_free_resp;case SMP_RESP_FUNC_ACC :break ;case -ECOMM :break ;default : -return res; + goto out_free_resp; } +if (res ==0 ) +sas_get_sas_addr_and_dev_type (disc_resp, sas_addr, &type); +if ((SAS_ADDR (sas_addr) ==0 ) || (res == -ECOMM )) { phy->phy_state =PHY_EMPTY ;sas_unregister_devs_sas_addr (dev, phy_id, last);/* -* Even though the PHY is empty, for convenience we discover -* the PHY to update the PHY info, like negotiated linkrate. +* Even though the PHY is empty, for convenience we update +* the PHY info, like negotiated linkrate. */ -sas_ex_phy_discover (dev, phy_id); -return res; +if (res ==0 ) +sas_set_ex_phy (dev, phy_id, disc_resp); + goto out_free_resp; }else if (SAS_ADDR (sas_addr) ==SAS_ADDR (phy->attached_sas_addr) &&dev_type_flutter (type, phy->attached_dev_type)) {struct domain_device *ata_dev =sas_ex_to_ata (dev, phy_id);
@@ -1994,7 +2003,7 @@ static int sas_rediscover_dev(struct dom action =", needs recovery" ;pr_debug ("ex %016llx phy%02d broadcast flutter%s\n" ,SAS_ADDR (dev->sas_addr), phy_id, action); -return res; + goto out_free_resp; }/* we always have to delete the old device when we went here */
@@ -2003,7 +2012,10 @@ static int sas_rediscover_dev(struct dom SAS_ADDR(phy->attached_sas_addr));sas_unregister_devs_sas_addr (dev, phy_id, last); -return sas_discover_new (dev, phy_id); + res =sas_discover_new (dev, phy_id); +out_free_resp: +kfree (disc_resp); +return res; }/**
Greg Kroah-Hartman
maintainerPATCH 395/396 x86/sev: Skip ROM range scans and validation for SEV-SNP guests
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kevin Loughlin <[email protected]>
commit 0f4a1e80989aca185d955fcd791d7750082044a2 upstream.
SEV-SNP requires encrypted memory to be validated before access. Because the ROM memory range is not part of the e820 table, it is not pre-validated by the BIOS. Therefore, if a SEV-SNP guest kernel wishes to access this range, the guest must first validate the range.
The current SEV-SNP code does indeed scan the ROM range during early boot and thus attempts to validate the ROM range in probe_roms(). However, this behavior is neither sufficient nor necessary for the following reasons:
* With regards to sufficiency, if EFI_CONFIG_TABLES are not enabled and CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK is set, the kernel will attempt to access the memory at SMBIOS_ENTRY_POINT_SCAN_START (which falls in the ROM range) prior to validation.
For example, Project Oak Stage 0 provides a minimal guest firmware that currently meets these configuration conditions, meaning guests booting atop Oak Stage 0 firmware encounter a problematic call chain during dmi_setup() -> dmi_scan_machine() that results in a crash during boot if SEV-SNP is enabled.
* With regards to necessity, SEV-SNP guests generally read garbage (which changes across boots) from the ROM range, meaning these scans are unnecessary. The guest reads garbage because the legacy ROM range is unencrypted data but is accessed via an encrypted PMD during early boot (where the PMD is marked as encrypted due to potentially mapping actually-encrypted data in other PMD-contained ranges).
In one exceptional case, EISA probing treats the ROM range as unencrypted data, which is inconsistent with other probing.
Continuing to allow SEV-SNP guests to use garbage and to inconsistently classify ROM range encryption status can trigger undesirable behavior. For instance, if garbage bytes appear to be a valid signature, memory may be unnecessarily reserved for the ROM range. Future code or other use cases may result in more problematic (arbitrary) behavior that should be avoided.
While one solution would be to overhaul the early PMD mapping to always treat the ROM region of the PMD as unencrypted, SEV-SNP guests do not currently rely on data from the ROM region during early boot (and even if they did, they would be mostly relying on garbage data anyways).
As a simpler solution, skip the ROM range scans (and the otherwise- necessary range validation) during SEV-SNP guest early boot. The potential SEV-SNP guest crash due to lack of ROM range validation is thus avoided by simply not accessing the ROM range.
In most cases, skip the scans by overriding problematic x86_init functions during sme_early_init() to SNP-safe variants, which can be likened to x86_init overrides done for other platforms (ex: Xen); such overrides also avoid the spread of cc_platform_has() checks throughout the tree.
In the exceptional EISA case, still use cc_platform_has() for the simplest change, given (1) checks for guest type (ex: Xen domain status) are already performed here, and (2) these checks occur in a subsys initcall instead of an x86_init function.
[ bp: Massage commit message, remove "we"s. ]
--- arch/x86/include/asm/sev.h | 4 ++-- arch/x86/include/asm/x86_init.h | 3 ++- arch/x86/kernel/eisa.c | 3 ++- arch/x86/kernel/probe_roms.c | 10 ---------- arch/x86/kernel/setup.c | 3 +-- arch/x86/kernel/sev.c | 27 ++++++++++++--------------- arch/x86/kernel/x86_init.c | 2 ++ arch/x86/mm/mem_encrypt_amd.c | 18 ++++++++++++++++++ 8 files changed, 39 insertions(+), 31 deletions(-)
arch/x86/include/asm/sev.h +2 -2
@@ -203,12 +203,12 @@ void __init early_snp_set_memory_private unsigned long npages);void __init early_snp_set_memory_shared (unsigned long vaddr,unsigned long paddr,unsigned long npages); -void __init snp_prep_memory (unsigned long paddr,unsigned int sz,enum psc_op op);void snp_set_memory_shared (unsigned long vaddr,unsigned long npages);void snp_set_memory_private (unsigned long vaddr,unsigned long npages);void snp_set_wakeup_secondary_cpu (void );bool snp_init (struct boot_params *bp);void __init __noreturn snp_abort (void ); +void snp_dmi_setup (void );int snp_issue_guest_request (u64 exit_code,struct snp_req_data *input,struct snp_guest_request_ioctl *rio);void snp_accept_memory (phys_addr_t start,phys_addr_t end);u64 snp_get_unsupported_features (u64 status);
@@ -227,12 +227,12 @@ static inline void __init early_snp_set_memory_private(unsigned long vaddr, unsigned long paddr, unsigned long npages) { }static inline void __init early_snp_set_memory_shared (unsigned long vaddr,unsigned long paddr,unsigned long npages) { } -static inline void __init snp_prep_memory (unsigned long paddr,unsigned int sz,enum psc_op op) { }static inline void snp_set_memory_shared (unsigned long vaddr,unsigned long npages) { }static inline void snp_set_memory_private (unsigned long vaddr,unsigned long npages) { }static inline void snp_set_wakeup_secondary_cpu (void ) { }static inline bool snp_init (struct boot_params *bp) {return false; }static inline void snp_abort (void ) { } +static inline void snp_dmi_setup (void ) { }static inline int snp_issue_guest_request (u64 exit_code,struct snp_req_data *input,struct snp_guest_request_ioctl *rio) {return -ENOTTY ;
arch/x86/include/asm/x86_init.h +2 -1
@@ -30,12 +30,13 @@ struct x86_init_mpparse {* @reserve_resources: reserve the standard resources for the * platform * @memory_setup: platform specific memory setup -* +* @dmi_setup: platform specific DMI setup */ struct x86_init_resources {void (*probe_roms)(void );void (*reserve_resources)(void );char *(*memory_setup)(void ); +void (*dmi_setup)(void ); };/**
arch/x86/kernel/eisa.c +2 -1
@@ -2,6 +2,7 @@/* * EISA specific code */ +#include <linux/cc_platform.h> #include <linux/ioport.h> #include <linux/eisa.h> #include <linux/io.h>
@@ -12,7 +13,7 @@ static __init int eisa_bus_probe(void) {void __iomem *p; -if (xen_pv_domain () && !xen_initial_domain ()) +if ((xen_pv_domain () && !xen_initial_domain ()) ||cc_platform_has (CC_ATTR_GUEST_SEV_SNP ))return 0 ; p =ioremap (0x0FFFD9 ,4 );
arch/x86/kernel/probe_roms.c +0 -10
@@ -203,16 +203,6 @@ void __init probe_roms(void)unsigned char c;int i; -/* -* The ROM memory range is not part of the e820 table and is therefore not -* pre-validated by BIOS. The kernel page table maps the ROM region as encrypted -* memory, and SNP requires encrypted memory to be validated before access. -* Do that here. -*/ -snp_prep_memory (video_rom_resource.start, - ((system_rom_resource.end +1 ) - video_rom_resource.start), -SNP_PAGE_STATE_PRIVATE ); -/* video rom */ upper = adapter_rom_resources[0 ].start;for (start = video_rom_resource.start; start < upper; start +=2048 ) {
arch/x86/kernel/setup.c +1 -2
@@ -9,7 +9,6 @@#include <linux/console.h> #include <linux/crash_dump.h> #include <linux/dma-map-ops.h> -#include <linux/dmi.h> #include <linux/efi.h> #include <linux/ima.h> #include <linux/init_ohci1394_dma.h>
@@ -1029,7 +1028,7 @@ void __init setup_arch(char **cmdline_p)efi_init ();reserve_ibft_region (); -dmi_setup (); + x86_init.resources.dmi_setup ();/* * VMware detection requires dmi to be available, so this
arch/x86/kernel/sev.c +12 -15
@@ -23,6 +23,7 @@#include <linux/platform_device.h> #include <linux/io.h> #include <linux/psp-sev.h> +#include <linux/dmi.h> #include <uapi/linux/sev-guest.h> #include <asm/cpu_entry_area.h>
@@ -774,21 +775,6 @@ void __init early_snp_set_memory_shared(early_set_pages_state (vaddr, paddr, npages,SNP_PAGE_STATE_SHARED ); } -void __init snp_prep_memory (unsigned long paddr,unsigned int sz,enum psc_op op) -{ -unsigned long vaddr, npages; - - vaddr = (unsigned long )__va (paddr); - npages =PAGE_ALIGN (sz) >>PAGE_SHIFT ; - -if (op ==SNP_PAGE_STATE_PRIVATE ) -early_snp_set_memory_private (vaddr, paddr, npages); -else if (op ==SNP_PAGE_STATE_SHARED ) -early_snp_set_memory_shared (vaddr, paddr, npages); -else -WARN (1 ,"invalid memory op %d\n" , op); -} -static unsigned long __set_pages_state (struct snp_psc_desc *data,unsigned long vaddr,unsigned long vaddr_end,int op) {
@@ -2112,6 +2098,17 @@ void __init __noreturn snp_abort(void)sev_es_terminate (SEV_TERM_SET_GEN ,GHCB_SNP_UNSUPPORTED ); } +/* +* SEV-SNP guests should only execute dmi_setup() if EFI_CONFIG_TABLES are +* enabled, as the alternative (fallback) logic for DMI probing in the legacy +* ROM region can cause a crash since this region is not pre-validated. +*/ +void __init snp_dmi_setup (void ) +{ +if (efi_enabled (EFI_CONFIG_TABLES )) +dmi_setup (); +} +static void dump_cpuid_table (void ) {const struct snp_cpuid_table *cpuid_table =snp_cpuid_get_table ();
arch/x86/kernel/x86_init.c +2 -0
@@ -3,6 +3,7 @@* * For licencing details see kernel-base/COPYING */ +#include <linux/dmi.h> #include <linux/init.h> #include <linux/ioport.h> #include <linux/export.h>
@@ -66,6 +67,7 @@ struct x86_init_ops x86_init __initdata .probe_roms = probe_roms, .reserve_resources = reserve_standard_io_resources, .memory_setup = e820__memory_setup_default, + .dmi_setup = dmi_setup, }, .mpparse = {
arch/x86/mm/mem_encrypt_amd.c +18 -0
@@ -528,6 +528,24 @@ void __init sme_early_init(void)*/ if (sev_status &MSR_AMD64_SEV_ENABLED )ia32_disable (); + +/* +* Override init functions that scan the ROM region in SEV-SNP guests, +* as this memory is not pre-validated and would thus cause a crash. +*/ +if (sev_status &MSR_AMD64_SEV_SNP_ENABLED ) { + x86_init.mpparse.find_smp_config = x86_init_noop; + x86_init.pci.init_irq = x86_init_noop; + x86_init.resources.probe_roms = x86_init_noop; + +/* +* DMI setup behavior for SEV-SNP guests depends on +* efi_enabled(EFI_CONFIG_TABLES), which hasn't been +* parsed yet. snp_dmi_setup() will run after that +* parsing has happened. +*/ + x86_init.resources.dmi_setup = snp_dmi_setup; + } }void __init mem_encrypt_free_decrypted_mem (void )
Greg Kroah-Hartman
maintainerPATCH 396/396 tools/resolve_btfids: fix build with musl libc
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Natanael Copa <[email protected]>
commit 62248b22d01e96a4d669cde0d7005bd51ebf9e76 upstream.
Include the header that defines u32.
This fixes build of 6.6.23 and 6.1.83 kernels for Alpine Linux, which uses musl libc. I assume that GNU libc indirecly pulls in linux/types.h.
--- tools/include/linux/btf_ids.h | 2 ++ 1 file changed, 2 insertions(+)
tools/include/linux/btf_ids.h +2 -0
@@ -3,6 +3,8 @@ #ifndef _LINUX_BTF_IDS_H #define _LINUX_BTF_IDS_H +#include <linux/types.h> /* for u32 */ + struct btf_id_set { u32 cnt; u32 ids[];
Hello,
Quoted 5 lines · On Mon, 1 Apr 2024 17:40:49 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 8 lines
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.
This rc kernel passes DAMON functionality test[1] on my test machine. Attaching the test results summary below. Please note that I retrieved the kernel from linux-stable-rc tree[2].
[1] https://github.com/awslabs/damon-tests/tree/next/corr
[2] 75a2533b74d0 ("Linux 6.6.24-rc1")
Thanks,
SJ
[...]
---
ok 1 selftests: damon: debugfs_attrs.sh
ok 2 selftests: damon: debugfs_schemes.sh
ok 3 selftests: damon: debugfs_target_ids.sh
ok 4 selftests: damon: debugfs_empty_targets.sh
ok 5 selftests: damon: debugfs_huge_count_read_write.sh
ok 6 selftests: damon: debugfs_duplicate_context_creation.sh
ok 7 selftests: damon: debugfs_rm_non_contexts.sh
ok 8 selftests: damon: sysfs.sh
ok 9 selftests: damon: sysfs_update_removed_scheme_dir.sh
ok 10 selftests: damon: reclaim.sh
ok 11 selftests: damon: lru_sort.sh
ok 1 selftests: damon-tests: kunit.sh
ok 2 selftests: damon-tests: huge_count_read_write.sh
ok 3 selftests: damon-tests: buffer_overflow.sh
ok 4 selftests: damon-tests: rm_contexts.sh
ok 5 selftests: damon-tests: record_null_deref.sh
ok 6 selftests: damon-tests: dbgfs_target_ids_read_before_terminate_race.sh ok 7 selftests: damon-tests: dbgfs_target_ids_pid_leak.sh
ok 8 selftests: damon-tests: damo_tests.sh
ok 9 selftests: damon-tests: masim-record.sh
ok 10 selftests: damon-tests: build_i386.sh
ok 11 selftests: damon-tests: build_arm64.sh
ok 12 selftests: damon-tests: build_m68k.sh
ok 13 selftests: damon-tests: build_i386_idle_flag.sh
ok 14 selftests: damon-tests: build_i386_highpte.sh
ok 15 selftests: damon-tests: build_nomemcg.sh
[33m
[92mPASS [39m
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
Following kernel warnings have been noticed on qemu-x86_64 while running LTP cve ioctl_sg01 tests the kernel with stable-rc 6.6.24-rc1, 6.7.12-rc1 and 6.8.3-rc1.
We have started bi-secting this issue.
Always reproduced.
ioctl_sg01.c:81: TINFO: Found SCSI device /dev/sg0
------------[ cut here ]------------ [ 36.606841] WARNING: CPU: 0 PID: 8 at drivers/scsi/sg.c:2237 sg_remove_sfp_usercontext+0x145/0x150 [ 36.609445] Modules linked in: [ 36.610793] CPU: 0 PID: 8 Comm: kworker/0:0 Not tainted 6.6.24-rc1 #1 [ 36.611568] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 [ 36.612872] Workqueue: events sg_remove_sfp_usercontext [ 36.613691] RIP: 0010:sg_remove_sfp_usercontext+0x145/0x150
<trim>
[ 36.621539] Call Trace: [ 36.621953] <TASK> [ 36.622444] ? show_regs+0x69/0x80 [ 36.622819] ? __warn+0x8d/0x150 [ 36.623078] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.623558] ? report_bug+0x171/0x1a0 [ 36.623881] ? handle_bug+0x42/0x80 [ 36.624070] ? exc_invalid_op+0x1c/0x70 [ 36.624491] ? asm_exc_invalid_op+0x1f/0x30 [ 36.624897] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.625408] process_one_work+0x141/0x300 [ 36.625769] worker_thread+0x2f6/0x430 [ 36.626073] ? __pfx_worker_thread+0x10/0x10 [ 36.626529] kthread+0x105/0x140 [ 36.626778] ? __pfx_kthread+0x10/0x10 [ 36.627059] ret_from_fork+0x41/0x60 [ 36.627441] ? __pfx_kthread+0x10/0x10 [ 36.627735] ret_from_fork_asm+0x1b/0x30 [ 36.628293] </TASK> [ 36.628604] ---[ end trace 0000000000000000 ]---
ioctl_sg01.c:122: TPASS: Output buffer is empty, no data leaked
Suspecting commit:
-----
scsi: sg: Avoid sg device teardown race
commit 27f58c04a8f438078583041468ec60597841284d upstream.
+ WARN_ON_ONCE(kref_read(&sdp->d_ref) != 1);
Steps to reproduce:
- https://tuxapi.tuxsuite.com/v1/groups/linaro/projects/lkft/tests/2eVWFlAeOUepfeFVkrOXFYNNAqI/reproducer
Links:
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.6.y/build/v6.6.23-397-g75a2533b74d0/testrun/23255318/suite/log-parser-test/tests/
- https://tuxapi.tuxsuite.com/v1/groups/linaro/projects/lkft/tests/2eVTitwVMagaiWhs5T2iKH390D5
--
Linaro LKFT
https://lkft.linaro.org
Quoted 43 lines
Following kernel warnings have been noticed on qemu-x86_64 while running LTP cve
ioctl_sg01tests the kernel with stable-rc 6.6.24-rc1, 6.7.12-rc1 and 6.8.3-rc1.We have started bi-secting this issue.
Always reproduced.ioctl_sg01.c:81: TINFO: Found SCSI device
/dev/sg0------------[ cut here ]------------ [ 36.606841] WARNING: CPU: 0 PID: 8 at drivers/scsi/sg.c:2237 sg_remove_sfp_usercontext+0x145/0x150 [ 36.609445] Modules linked in: [ 36.610793] CPU: 0 PID: 8 Comm: kworker/0:0 Not tainted 6.6.24-rc1 #1 [ 36.611568] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 [ 36.612872] Workqueue: events sg_remove_sfp_usercontext [ 36.613691] RIP: 0010:sg_remove_sfp_usercontext+0x145/0x150<trim>
[ 36.621539] Call Trace: [ 36.621953] <TASK> [ 36.622444] ? show_regs+0x69/0x80 [ 36.622819] ? __warn+0x8d/0x150 [ 36.623078] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.623558] ? report_bug+0x171/0x1a0 [ 36.623881] ? handle_bug+0x42/0x80 [ 36.624070] ? exc_invalid_op+0x1c/0x70 [ 36.624491] ? asm_exc_invalid_op+0x1f/0x30 [ 36.624897] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.625408] process_one_work+0x141/0x300 [ 36.625769] worker_thread+0x2f6/0x430 [ 36.626073] ? __pfx_worker_thread+0x10/0x10 [ 36.626529] kthread+0x105/0x140 [ 36.626778] ? __pfx_kthread+0x10/0x10 [ 36.627059] ret_from_fork+0x41/0x60 [ 36.627441] ? __pfx_kthread+0x10/0x10 [ 36.627735] ret_from_fork_asm+0x1b/0x30 [ 36.628293] </TASK> [ 36.628604] ---[ end trace 0000000000000000 ]---
Quoted 7 lines
ioctl_sg01.c:122: TPASS: Output buffer is empty, no data leaked
Suspecting commit:
-----
scsi: sg: Avoid sg device teardown race
commit27f58c04a8f438078583041468ec60597841284dupstream.
Correct. The issue is already been worked on.
commit 27f58c04a8f4 ("scsi: sg: Avoid sg device teardown race") fixed a real issue. But also added an incorrect WARN_ON_ONCE(). Thus the scary - but otherwise harmless - error message.
Current patch fixing the broken commit is proposed here:
https://lore.kernel.org/all/[email protected]/
Sorry for the trouble,
Alexander
Greg Kroah-Hartman
maintainerQuoted 51 lines · Alexander Wetzel
Quoted 43 lines
Following kernel warnings have been noticed on qemu-x86_64 while running LTP cve
ioctl_sg01tests the kernel with stable-rc 6.6.24-rc1, 6.7.12-rc1 and 6.8.3-rc1.We have started bi-secting this issue.
Always reproduced.ioctl_sg01.c:81: TINFO: Found SCSI device
/dev/sg0------------[ cut here ]------------ [ 36.606841] WARNING: CPU: 0 PID: 8 at drivers/scsi/sg.c:2237 sg_remove_sfp_usercontext+0x145/0x150 [ 36.609445] Modules linked in: [ 36.610793] CPU: 0 PID: 8 Comm: kworker/0:0 Not tainted 6.6.24-rc1 #1 [ 36.611568] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 [ 36.612872] Workqueue: events sg_remove_sfp_usercontext [ 36.613691] RIP: 0010:sg_remove_sfp_usercontext+0x145/0x150<trim>
[ 36.621539] Call Trace: [ 36.621953] <TASK> [ 36.622444] ? show_regs+0x69/0x80 [ 36.622819] ? __warn+0x8d/0x150 [ 36.623078] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.623558] ? report_bug+0x171/0x1a0 [ 36.623881] ? handle_bug+0x42/0x80 [ 36.624070] ? exc_invalid_op+0x1c/0x70 [ 36.624491] ? asm_exc_invalid_op+0x1f/0x30 [ 36.624897] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.625408] process_one_work+0x141/0x300 [ 36.625769] worker_thread+0x2f6/0x430 [ 36.626073] ? __pfx_worker_thread+0x10/0x10 [ 36.626529] kthread+0x105/0x140 [ 36.626778] ? __pfx_kthread+0x10/0x10 [ 36.627059] ret_from_fork+0x41/0x60 [ 36.627441] ? __pfx_kthread+0x10/0x10 [ 36.627735] ret_from_fork_asm+0x1b/0x30 [ 36.628293] </TASK> [ 36.628604] ---[ end trace 0000000000000000 ]---Quoted 7 lines
ioctl_sg01.c:122: TPASS: Output buffer is empty, no data leaked
Suspecting commit:
-----
scsi: sg: Avoid sg device teardown race
commit27f58c04a8f438078583041468ec60597841284dupstream.
Quoted 8 lines
Correct. The issue is already been worked on.
commit
27f58c04a8f4("scsi: sg: Avoid sg device teardown race") fixed a real issue. But also added an incorrectWARN_ON_ONCE(). Thus the scary - but otherwise harmless - error message.Current patch fixing the broken commit is proposed here:
https://lore.kernel.org/all/[email protected]/
I will drop the offending commit from all queues now, thanks.
greg k-h
Quoted 51 lines · Alexander Wetzel
Quoted 43 lines
Following kernel warnings have been noticed on qemu-x86_64 while running LTP cve
ioctl_sg01tests the kernel with stable-rc 6.6.24-rc1, 6.7.12-rc1 and 6.8.3-rc1.We have started bi-secting this issue.
Always reproduced.ioctl_sg01.c:81: TINFO: Found SCSI device
/dev/sg0------------[ cut here ]------------ [ 36.606841] WARNING: CPU: 0 PID: 8 at drivers/scsi/sg.c:2237 sg_remove_sfp_usercontext+0x145/0x150 [ 36.609445] Modules linked in: [ 36.610793] CPU: 0 PID: 8 Comm: kworker/0:0 Not tainted 6.6.24-rc1 #1 [ 36.611568] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 [ 36.612872] Workqueue: events sg_remove_sfp_usercontext [ 36.613691] RIP: 0010:sg_remove_sfp_usercontext+0x145/0x150<trim>
[ 36.621539] Call Trace: [ 36.621953] <TASK> [ 36.622444] ? show_regs+0x69/0x80 [ 36.622819] ? __warn+0x8d/0x150 [ 36.623078] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.623558] ? report_bug+0x171/0x1a0 [ 36.623881] ? handle_bug+0x42/0x80 [ 36.624070] ? exc_invalid_op+0x1c/0x70 [ 36.624491] ? asm_exc_invalid_op+0x1f/0x30 [ 36.624897] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.625408] process_one_work+0x141/0x300 [ 36.625769] worker_thread+0x2f6/0x430 [ 36.626073] ? __pfx_worker_thread+0x10/0x10 [ 36.626529] kthread+0x105/0x140 [ 36.626778] ? __pfx_kthread+0x10/0x10 [ 36.627059] ret_from_fork+0x41/0x60 [ 36.627441] ? __pfx_kthread+0x10/0x10 [ 36.627735] ret_from_fork_asm+0x1b/0x30 [ 36.628293] </TASK> [ 36.628604] ---[ end trace 0000000000000000 ]---Quoted 7 lines
ioctl_sg01.c:122: TPASS: Output buffer is empty, no data leaked
Suspecting commit:
-----
scsi: sg: Avoid sg device teardown race
commit27f58c04a8f438078583041468ec60597841284dupstream.
Quoted 5 lines
Correct. The issue is already been worked on.
commit
27f58c04a8f4("scsi: sg: Avoid sg device teardown race") fixed a real issue. But also added an incorrectWARN_ON_ONCE(). Thus the scary - but otherwise harmless - error message.
If you have Reboot on Oops turned on (apparently Android enables this) then WARN() will reboot the system so it can be pretty annoying.
regards,
dan carpenter
Greg Kroah-Hartman
maintainerQuoted 52 lines · Dan Carpenter
Quoted 51 lines · Alexander Wetzel
Quoted 50 lines
Following kernel warnings have been noticed on qemu-x86_64 while running LTP cve
ioctl_sg01tests the kernel with stable-rc 6.6.24-rc1, 6.7.12-rc1 and 6.8.3-rc1.We have started bi-secting this issue.
Always reproduced.ioctl_sg01.c:81: TINFO: Found SCSI device
/dev/sg0------------[ cut here ]------------ [ 36.606841] WARNING: CPU: 0 PID: 8 at drivers/scsi/sg.c:2237 sg_remove_sfp_usercontext+0x145/0x150 [ 36.609445] Modules linked in: [ 36.610793] CPU: 0 PID: 8 Comm: kworker/0:0 Not tainted 6.6.24-rc1 #1 [ 36.611568] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 [ 36.612872] Workqueue: events sg_remove_sfp_usercontext [ 36.613691] RIP: 0010:sg_remove_sfp_usercontext+0x145/0x150<trim>
[ 36.621539] Call Trace: [ 36.621953] <TASK> [ 36.622444] ? show_regs+0x69/0x80 [ 36.622819] ? __warn+0x8d/0x150 [ 36.623078] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.623558] ? report_bug+0x171/0x1a0 [ 36.623881] ? handle_bug+0x42/0x80 [ 36.624070] ? exc_invalid_op+0x1c/0x70 [ 36.624491] ? asm_exc_invalid_op+0x1f/0x30 [ 36.624897] ? sg_remove_sfp_usercontext+0x145/0x150 [ 36.625408] process_one_work+0x141/0x300 [ 36.625769] worker_thread+0x2f6/0x430 [ 36.626073] ? __pfx_worker_thread+0x10/0x10 [ 36.626529] kthread+0x105/0x140 [ 36.626778] ? __pfx_kthread+0x10/0x10 [ 36.627059] ret_from_fork+0x41/0x60 [ 36.627441] ? __pfx_kthread+0x10/0x10 [ 36.627735] ret_from_fork_asm+0x1b/0x30 [ 36.628293] </TASK> [ 36.628604] ---[ end trace 0000000000000000 ]---ioctl_sg01.c:122: TPASS: Output buffer is empty, no data leaked
Suspecting commit:
-----
scsi: sg: Avoid sg device teardown race
commit27f58c04a8f438078583041468ec60597841284dupstream.
Quoted 8 lines
Quoted 5 lines
Correct. The issue is already been worked on.
commit
27f58c04a8f4("scsi: sg: Avoid sg device teardown race") fixed a real issue. But also added an incorrectWARN_ON_ONCE(). Thus the scary - but otherwise harmless - error message.If you have Reboot on Oops turned on (apparently Android enables this) then
WARN()will reboot the system so it can be pretty annoying.
Agreed, I've dropped this stable change for now because of this.
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
No regressions found on WSL (x86 and arm64).
Built, booted, and reviewed dmesg.
Thank you. :)
Hi Greg,
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
No problems seen on x86_64 and aarch64 with our testing.
Thanks,
Harshit
Quoted 11 lines
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
----
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
Regressions on arm64, arm, x86_64, and i386 with libgpiod tests.
libgpiod test regressions noticed on Linux stable-rc 6.8, 6.7 and 6.6 and Linux next and mainline master.
Anders bisected and found this first bad commit,
gpio: cdev: sanitize the label before requesting the interrupt commit b34490879baa847d16fc529c8ea6e6d34f004b38 upstream.
LKFT is running libgpiod test suite version
v2.0.1-0-gae275c3 (and also tested v2.1)
libgpiod
- _gpiod_edge-event_edge_event_wait_timeout
- _gpiod_edge-event_event_copy
- _gpiod_edge-event_null_buffer
- _gpiod_edge-event_read_both_events
- _gpiod_edge-event_read_both_events_blocking
- _gpiod_edge-event_read_falling_edge_event
- _gpiod_edge-event_read_rising_edge_event
- _gpiod_edge-event_read_rising_edge_event_polled
- _gpiod_edge-event_reading_more_events_than_the_queue_contains_doesnt_block
- _gpiod_edge-event_seqno
- _gpiod_line-info_edge_detection_settings
Test log:
-------
ok 16 /gpiod/edge-event/edge_event_buffer_max_capacity
** gpiod-test:ERROR:tests-edge-event.c:52:_gpiod_test_func_edge_event_wait_timeout:
'_request' should not be NULL
# gpiod-test:ERROR:tests-edge-event.c:52:_gpiod_test_func_edge_event_wait_timeout:
'_request' should not be NULL
not ok 17 /gpiod/edge-event/edge_event_wait_timeout
ok 18 /gpiod/edge-event/cannot_request_lines_in_output_mode_with_edge_detection ** gpiod-test:ERROR:tests-edge-event.c:125:_gpiod_test_func_read_both_events:
'_request' should not be NULL
# gpiod-test:ERROR:tests-edge-event.c:125:_gpiod_test_func_read_both_events:
'_request' should not be NULL
not ok 19 /gpiod/edge-event/read_both_events
--
Linaro LKFT
https://lkft.linaro.org
Hi Greg
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
6.6.24-rc1 tested.
Build successfully completed.
Boot successfully completed.
No dmesg regressions.
Video output normal.
Sound output normal.
Lenovo ThinkPad X1 Carbon Gen10(Intel i7-1260P(x86_64) arch linux)
[ 0.000000] Linux version 6.6.24-rc1rv
(takeshi@ThinkPadX1Gen10J0764) (gcc (GCC) 13.2.1 20230801, GNU ld (GNU Binutils) 2.42.0) #1 SMP PREEMPT_DYNAMIC Tue Apr 2 19:48:41 JST 2024
Thanks
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 03 Apr 2024 15:24:46 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.24-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.6.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v6.6:
10 builds: 10 pass, 0 fail
26 boots: 26 pass, 0 fail
116 tests: 116 pass, 0 failLinux version: 6.6.24-rc1-g75a2533b74d0
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.6.24 release. There are 396 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.