6.12.19-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 109/269 drm/xe: Add staging tree for VM binds
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Brost <[email protected]>
commit ae482ec8cd1a85bde3307f71921a7780086fbec0 upstream.
Concurrent VM bind staging and zapping of PTEs from a userptr notifier do not work because the view of PTEs is not stable. VM binds cannot acquire the notifier lock during staging, as memory allocations are required. To resolve this race condition, use a staging tree for VM binds that is committed only under the userptr notifier lock during the final step of the bind. This ensures a consistent view of the PTEs in the userptr notifier.
A follow up may only use staging for VM in fault mode as this is the only mode in which the above race exists.
v3:
- Drop zap PTE change (Thomas)
- s/xe_pt_entry/xe_pt_entry_staging (Thomas)
--- drivers/gpu/drm/xe/xe_pt.c | 58 +++++++++++++++++++++++++++------------- drivers/gpu/drm/xe/xe_pt_walk.c | 3 +- drivers/gpu/drm/xe/xe_pt_walk.h | 4 ++ 3 files changed, 46 insertions(+), 19 deletions(-)
drivers/gpu/drm/xe/xe_pt.c +40 -18
@@ -28,6 +28,8 @@ struct xe_pt_dir {struct xe_pt pt;/** @children: Array of page-table child nodes */ struct xe_ptw *children[XE_PDES ]; +/** @staging: Array of page-table staging nodes */ +struct xe_ptw *staging[XE_PDES ]; };#if IS_ENABLED (CONFIG_DRM_XE_DEBUG_VM )
@@ -48,9 +50,10 @@ static struct xe_pt_dir *as_xe_pt_dir(st return container_of(pt, struct xe_pt_dir, pt); } -static struct xe_pt *xe_pt_entry (struct xe_pt_dir *pt_dir,unsigned int index) +static struct xe_pt * +xe_pt_entry_staging (struct xe_pt_dir *pt_dir,unsigned int index) { - return container_of(pt_dir->children[index], struct xe_pt, base); + return container_of(pt_dir->staging[index], struct xe_pt, base); } static u64 __xe_pt_empty_pte(struct xe_tile *tile, struct xe_vm *vm,
@@ -125,6 +128,7 @@ struct xe_pt *xe_pt_create(struct xe_vm } pt->bo = bo; pt->base.children = level ?as_xe_pt_dir (pt)->children :NULL ; + pt->base.staging = level ?as_xe_pt_dir (pt)->staging :NULL ;if (vm->xef)xe_drm_client_add_bo (vm->xef->client, pt->bo);
@@ -205,8 +209,8 @@ void xe_pt_destroy(struct xe_pt *pt, u32struct xe_pt_dir *pt_dir =as_xe_pt_dir (pt);for (i =0 ; i <XE_PDES ; i++) { -if (xe_pt_entry (pt_dir, i)) -xe_pt_destroy (xe_pt_entry (pt_dir, i), flags, +if (xe_pt_entry_staging (pt_dir, i)) +xe_pt_destroy (xe_pt_entry_staging (pt_dir, i), flags, deferred); } }
@@ -375,8 +379,10 @@ xe_pt_insert_entry(struct xe_pt_stage_bi/* Continue building a non-connected subtree. */ struct iosys_map *map = &parent->bo->vmap; -if (unlikely (xe_child)) +if (unlikely (xe_child)) { parent->base.children[offset] = &xe_child->base; + parent->base.staging[offset] = &xe_child->base; + }xe_pt_write (xe_walk->vm->xe, map, offset, pte); parent->num_live++;
@@ -613,6 +619,7 @@ xe_pt_stage_bind(struct xe_tile *tile, s .ops = &xe_pt_stage_bind_ops, .shifts = xe_normal_pt_shifts, .max_level = XE_PT_HIGHEST_LEVEL, + .staging = true, }, .vm = xe_vma_vm(vma), .tile = tile,
@@ -872,7 +879,7 @@ static void xe_pt_cancel_bind(struct xe_ } } -static void xe_pt_commit_locks_assert (struct xe_vma *vma) +static void xe_pt_commit_prepare_locks_assert (struct xe_vma *vma) {struct xe_vm *vm =xe_vma_vm (vma);
@@ -884,6 +891,16 @@ static void xe_pt_commit_locks_assert(stxe_vm_assert_held (vm); } +static void xe_pt_commit_locks_assert (struct xe_vma *vma) +{ +struct xe_vm *vm =xe_vma_vm (vma); + +xe_pt_commit_prepare_locks_assert (vma); + +if (xe_vma_is_userptr (vma)) +lockdep_assert_held_read (&vm->userptr.notifier_lock); +} +static void xe_pt_commit (struct xe_vma *vma,struct xe_vm_pgtable_update *entries,u32 num_entries,struct llist_head *deferred)
@@ -894,13 +911,17 @@ static void xe_pt_commit(struct xe_vma *for (i =0 ; i < num_entries; i++) {struct xe_pt *pt = entries[i].pt; +struct xe_pt_dir *pt_dir;if (!pt->level)continue ; + pt_dir =as_xe_pt_dir (pt);for (j =0 ; j < entries[i].qwords; j++) {struct xe_pt *oldpte = entries[i].pt_entries[j].pt; +int j_ = j + entries[i].ofs; + pt_dir->children[j_] = pt_dir->staging[j_];xe_pt_destroy (oldpte,xe_vma_vm (vma)->flags, deferred); } }
@@ -912,7 +933,7 @@ static void xe_pt_abort_bind(struct xe_v {int i, j; -xe_pt_commit_locks_assert (vma); +xe_pt_commit_prepare_locks_assert (vma);for (i = num_entries -1 ; i >=0 ; --i) {struct xe_pt *pt = entries[i].pt;
@@ -927,10 +948,10 @@ static void xe_pt_abort_bind(struct xe_v pt_dir =as_xe_pt_dir (pt);for (j =0 ; j < entries[i].qwords; j++) {u32 j_ = j + entries[i].ofs; -struct xe_pt *newpte =xe_pt_entry (pt_dir, j_); +struct xe_pt *newpte =xe_pt_entry_staging (pt_dir, j_);struct xe_pt *oldpte = entries[i].pt_entries[j].pt; - pt_dir->children[j_] = oldpte ? &oldpte->base :0 ; + pt_dir->staging[j_] = oldpte ? &oldpte->base :0 ;xe_pt_destroy (newpte,xe_vma_vm (vma)->flags,NULL ); } }
@@ -942,7 +963,7 @@ static void xe_pt_commit_prepare_bind(st {u32 i, j; -xe_pt_commit_locks_assert (vma); +xe_pt_commit_prepare_locks_assert (vma);for (i =0 ; i < num_entries; i++) {struct xe_pt *pt = entries[i].pt;
@@ -960,10 +981,10 @@ static void xe_pt_commit_prepare_bind(ststruct xe_pt *newpte = entries[i].pt_entries[j].pt;struct xe_pt *oldpte =NULL ; -if (xe_pt_entry (pt_dir, j_)) - oldpte =xe_pt_entry (pt_dir, j_); +if (xe_pt_entry_staging (pt_dir, j_)) + oldpte =xe_pt_entry_staging (pt_dir, j_); - pt_dir->children[j_] = &newpte->base; + pt_dir->staging[j_] = &newpte->base; entries[i].pt_entries[j].pt = oldpte; } }
@@ -1513,6 +1534,7 @@ static unsigned int xe_pt_stage_unbind(s .ops = &xe_pt_stage_unbind_ops, .shifts = xe_normal_pt_shifts, .max_level = XE_PT_HIGHEST_LEVEL, + .staging = true, }, .tile = tile, .modified_start = xe_vma_start(vma),
@@ -1554,7 +1576,7 @@ static void xe_pt_abort_unbind(struct xe {int i, j; -xe_pt_commit_locks_assert (vma); +xe_pt_commit_prepare_locks_assert (vma);for (i = num_entries -1 ; i >=0 ; --i) {struct xe_vm_pgtable_update *entry = &entries[i];
@@ -1567,7 +1589,7 @@ static void xe_pt_abort_unbind(struct xecontinue ;for (j = entry->ofs; j < entry->ofs + entry->qwords; j++) - pt_dir->children[j] = + pt_dir->staging[j] = entries[i].pt_entries[j - entry->ofs].pt ? &entries[i].pt_entries[j - entry->ofs].pt->base :NULL ; }
@@ -1580,7 +1602,7 @@ xe_pt_commit_prepare_unbind(struct xe_vm {int i, j; -xe_pt_commit_locks_assert (vma); +xe_pt_commit_prepare_locks_assert (vma);for (i =0 ; i < num_entries; ++i) {struct xe_vm_pgtable_update *entry = &entries[i];
@@ -1594,8 +1616,8 @@ xe_pt_commit_prepare_unbind(struct xe_vm pt_dir =as_xe_pt_dir (pt);for (j = entry->ofs; j < entry->ofs + entry->qwords; j++) { entry->pt_entries[j - entry->ofs].pt = -xe_pt_entry (pt_dir, j); - pt_dir->children[j] =NULL ; +xe_pt_entry_staging (pt_dir, j); + pt_dir->staging[j] =NULL ; } } }
drivers/gpu/drm/xe/xe_pt_walk.c +2 -1
@@ -74,7 +74,8 @@ int xe_pt_walk_range(struct xe_ptw *pare u64 addr, u64 end, struct xe_pt_walk *walk) { pgoff_t offset = xe_pt_offset(addr, level, walk); -struct xe_ptw **entries = parent->children ? parent->children :NULL ; +struct xe_ptw **entries = walk->staging ? (parent->staging ?:NULL ) : + (parent->children ?:NULL );const struct xe_pt_walk_ops *ops = walk->ops;enum page_walk_action action;struct xe_ptw *child;
drivers/gpu/drm/xe/xe_pt_walk.h +4 -0
@@ -11,12 +11,14 @@/** * struct xe_ptw - base class for driver pagetable subclassing. * @children: Pointer to an array of children if any. +* @staging: Pointer to an array of staging if any. * * Drivers could subclass this, and if it's a page-directory, typically * embed an array of xe_ptw pointers. */ struct xe_ptw {struct xe_ptw **children; +struct xe_ptw **staging; };/**
@@ -41,6 +43,8 @@ struct xe_pt_walk {* as shared pagetables. */ bool shared_pt_mode; +/** @staging: Walk staging PT structure */ +bool staging; };/**
Greg Kroah-Hartman
maintainerPATCH 110/269 drm/xe/hmm: Style- and include fixes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <[email protected]>
commit e3e2e7fc4cd8414c9a966ef1b344db543f8614f4 upstream.
Add proper #ifndef around the xe_hmm.h header, proper spacing and since the documentation mostly follows kerneldoc format, make it kerneldoc. Also prepare for upcoming -stable fixes.
--- drivers/gpu/drm/xe/xe_hmm.c | 9 +++------ drivers/gpu/drm/xe/xe_hmm.h | 5 +++++ 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_hmm.c +3 -6
@@ -19,11 +19,10 @@ static u64 xe_npages_in_range(unsigned long start, unsigned long end)return (end - start) >>PAGE_SHIFT ; } -/* +/** * xe_mark_range_accessed() - mark a range is accessed, so core mm * have such information for memory eviction or write back to * hard disk -* * @range: the range to mark * @write: if write to this range, we mark pages in this range * as dirty
@@ -43,11 +42,10 @@ static void xe_mark_range_accessed(struct hmm_range *range, bool write) } } -/* +/** * xe_build_sg() - build a scatter gather table for all the physical pages/pfn * in a hmm_range. dma-map pages if necessary. dma-address is save in sg table * and will be used to program GPU page table later. -* * @xe: the xe device who will access the dma-address in sg table * @range: the hmm range that we build the sg table from. range->hmm_pfns[] * has the pfn numbers of pages that back up this hmm address range.
@@ -112,9 +110,8 @@ static int xe_build_sg(struct xe_device *xe, struct hmm_range *range,return ret; } -/* +/** * xe_hmm_userptr_free_sg() - Free the scatter gather table of userptr -* * @uvma: the userptr vma which hold the scatter gather table * * With function xe_userptr_populate_range, we allocate storage of
drivers/gpu/drm/xe/xe_hmm.h +5 -0
@@ -3,9 +3,14 @@* Copyright © 2024 Intel Corporation */ +#ifndef _XE_HMM_H_ +#define _XE_HMM_H_ +#include <linux/types.h> struct xe_userptr_vma ;int xe_hmm_userptr_populate_range (struct xe_userptr_vma *uvma,bool is_mm_mmap_locked); +void xe_hmm_userptr_free_sg (struct xe_userptr_vma *uvma); +#endif
Signature · 1 line
2.48.1
Greg Kroah-Hartman
maintainerPATCH 111/269 drm/xe/hmm: Dont dereference struct page pointers without notifier lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <[email protected]>
commit 0a98219bcc961edd3388960576e4353e123b4a51 upstream.
The pnfs that we obtain from hmm_range_fault() point to pages that we don't have a reference on, and the guarantee that they are still in the cpu page-tables is that the notifier lock must be held and the notifier seqno is still valid.
So while building the sg table and marking the pages accesses / dirty we need to hold this lock with a validated seqno.
However, the lock is reclaim tainted which makes sg_alloc_table_from_pages_segment() unusable, since it internally allocates memory.
Instead build the sg-table manually. For the non-iommu case this might lead to fewer coalesces, but if that's a problem it can be fixed up later in the resource cursor code. For the iommu case, the whole sg-table may still be coalesced to a single contigous device va region.
This avoids marking pages that we don't own dirty and accessed, and it also avoid dereferencing struct pages that we don't own.
v2:
- Use assert to check whether hmm pfns are valid (Matthew Auld)
- Take into account that large pages may cross range boundaries (Matthew Auld)
v3:
- Don't unnecessarily check for a non-freed sg-table. (Matthew Auld)
- Add a missing up_read() in an error path. (Matthew Auld)
--- drivers/gpu/drm/xe/xe_hmm.c | 120 +++++++++++++++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 30 deletions(-)
drivers/gpu/drm/xe/xe_hmm.c +90 -30
@@ -42,6 +42,42 @@ static void xe_mark_range_accessed(struc } } +static int xe_alloc_sg (struct xe_device *xe,struct sg_table *st, +struct hmm_range *range,struct rw_semaphore *notifier_sem) +{ +unsigned long i, npages, hmm_pfn; +unsigned long num_chunks =0 ; +int ret; + +/* HMM docs says this is needed. */ + ret =down_read_interruptible (notifier_sem); +if (ret) +return ret; + +if (mmu_interval_read_retry (range->notifier, range->notifier_seq)) { +up_read (notifier_sem); +return -EAGAIN ; + } + + npages =xe_npages_in_range (range->start, range->end); +for (i =0 ; i < npages;) { +unsigned long len; + + hmm_pfn = range->hmm_pfns[i]; +xe_assert (xe, hmm_pfn &HMM_PFN_VALID ); + + len =1UL <<hmm_pfn_to_map_order (hmm_pfn); + +/* If order > 0 the page may extend beyond range->start */ + len -= (hmm_pfn & ~HMM_PFN_FLAGS ) & (len -1 ); + i += len; + num_chunks++; + } +up_read (notifier_sem); + +return sg_alloc_table (st, num_chunks,GFP_KERNEL ); +} +/** * xe_build_sg() - build a scatter gather table for all the physical pages/pfn * in a hmm_range. dma-map pages if necessary. dma-address is save in sg table
@@ -50,6 +86,7 @@ static void xe_mark_range_accessed(struc* @range: the hmm range that we build the sg table from. range->hmm_pfns[] * has the pfn numbers of pages that back up this hmm address range. * @st: pointer to the sg table. +* @notifier_sem: The xe notifier lock. * @write: whether we write to this range. This decides dma map direction * for system pages. If write we map it bi-diretional; otherwise * DMA_TO_DEVICE
@@ -76,38 +113,41 @@ static void xe_mark_range_accessed(struc* Returns 0 if successful; -ENOMEM if fails to allocate memory */ static int xe_build_sg (struct xe_device *xe,struct hmm_range *range, -struct sg_table *st,bool write) +struct sg_table *st, +struct rw_semaphore *notifier_sem, +bool write) { +unsigned long npages =xe_npages_in_range (range->start, range->end);struct device *dev = xe->drm.dev; -struct page **pages; -u64 i, npages; -int ret; - - npages =xe_npages_in_range (range->start, range->end); - pages =kvmalloc_array (npages,sizeof (*pages),GFP_KERNEL ); -if (!pages) -return -ENOMEM ; - -for (i =0 ; i < npages; i++) { - pages[i] =hmm_pfn_to_page (range->hmm_pfns[i]); -xe_assert (xe, !is_device_private_page (pages[i])); - } - - ret =sg_alloc_table_from_pages_segment (st, pages, npages,0 , npages <<PAGE_SHIFT , -xe_sg_segment_size (dev),GFP_KERNEL ); -if (ret) - goto free_pages; - - ret =dma_map_sgtable (dev, st, write ?DMA_BIDIRECTIONAL :DMA_TO_DEVICE , -DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_NO_KERNEL_MAPPING ); -if (ret) { -sg_free_table (st); - st =NULL ; +struct scatterlist *sgl; +struct page *page; +unsigned long i, j; + +lockdep_assert_held (notifier_sem); + + i =0 ; +for_each_sg (st->sgl, sgl, st->nents, j) { +unsigned long hmm_pfn, size; + + hmm_pfn = range->hmm_pfns[i]; + page =hmm_pfn_to_page (hmm_pfn); +xe_assert (xe, !is_device_private_page (page)); + + size =1UL <<hmm_pfn_to_map_order (hmm_pfn); + size -=page_to_pfn (page) & (size -1 ); + i += size; + +if (unlikely (j == st->nents -1 )) { +if (i > npages) + size -= (i - npages); +sg_mark_end (sgl); + } +sg_set_page (sgl, page, size <<PAGE_SHIFT ,0 ); } +xe_assert (xe, i == npages); -free_pages: -kvfree (pages); -return ret; +return dma_map_sgtable (dev, st, write ?DMA_BIDIRECTIONAL :DMA_TO_DEVICE , +DMA_ATTR_SKIP_CPU_SYNC |DMA_ATTR_NO_KERNEL_MAPPING ); }/**
@@ -235,16 +275,36 @@ int xe_hmm_userptr_populate_range(structif (ret) goto free_pfns; - ret =xe_build_sg (vm->xe, &hmm_range, &userptr->sgt, write); + ret =xe_alloc_sg (vm->xe, &userptr->sgt, &hmm_range, &vm->userptr.notifier_lock);if (ret) goto free_pfns; + ret =down_read_interruptible (&vm->userptr.notifier_lock); +if (ret) + goto free_st; + +if (mmu_interval_read_retry (hmm_range.notifier, hmm_range.notifier_seq)) { + ret = -EAGAIN ; + goto out_unlock; + } + + ret =xe_build_sg (vm->xe, &hmm_range, &userptr->sgt, + &vm->userptr.notifier_lock, write); +if (ret) + goto out_unlock; +xe_mark_range_accessed (&hmm_range, write); userptr->sg = &userptr->sgt; userptr->notifier_seq = hmm_range.notifier_seq; +up_read (&vm->userptr.notifier_lock); +kvfree (pfns); +return 0 ; +out_unlock: +up_read (&vm->userptr.notifier_lock); +free_st: +sg_free_table (&userptr->sgt); free_pfns:kvfree (pfns);return ret; } -
Greg Kroah-Hartman
maintainerPATCH 112/269 drm/xe/vm: Fix a misplaced #endif
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <[email protected]>
commit 1414d95d5805b1dc221d22db9b8dc5287ef083bc upstream.
Fix a (harmless) misplaced #endif leading to declarations appearing multiple times.
--- drivers/gpu/drm/xe/xe_vm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_vm.h +1 -1
@@ -275,9 +275,9 @@ static inline void vm_dbg(const struct d const char *format, ...) {/* noop */ }#endif -#endif struct xe_vm_snapshot *xe_vm_snapshot_capture (struct xe_vm *vm);void xe_vm_snapshot_capture_delayed (struct xe_vm_snapshot *snap);void xe_vm_snapshot_print (struct xe_vm_snapshot *snap,struct drm_printer *p);void xe_vm_snapshot_free (struct xe_vm_snapshot *snap); +#endif
Greg Kroah-Hartman
maintainerPATCH 113/269 drm/xe/vm: Validate userptr during gpu vma prefetching
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <[email protected]>
commit e775e2a060d99180edc5366fb9f4299d0f07b66c upstream.
If a userptr vma subject to prefetching was already invalidated or invalidated during the prefetch operation, the operation would repeatedly return -EAGAIN which would typically cause an infinite loop.
Validate the userptr to ensure this doesn't happen.
v2:
- Don't fallthrough from UNMAP to PREFETCH (Matthew Brost)
--- drivers/gpu/drm/xe/xe_vm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_vm.c +10 -1
@@ -2284,8 +2284,17 @@ static int vm_bind_ioctl_ops_parse(strucbreak ; }case DRM_GPUVA_OP_UNMAP : +xe_vma_ops_incr_pt_update_ops (vops, op->tile_mask); +break ;case DRM_GPUVA_OP_PREFETCH : -/* FIXME: Need to skip some prefetch ops */ + vma =gpuva_to_vma (op->base.prefetch.va); + +if (xe_vma_is_userptr (vma)) { + err =xe_vma_userptr_pin_pages (to_userptr_vma (vma)); +if (err) +return err; + } +xe_vma_ops_incr_pt_update_ops (vops, op->tile_mask);break ;default :
Greg Kroah-Hartman
maintainerPATCH 114/269 mptcp: fix scheduling while atomic in mptcp_pm_nl_append_new_local_addr
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krister Johansen <[email protected]>
commit 022bfe24aad8937705704ff2e414b100cf0f2e1a upstream.
If multiple connection requests attempt to create an implicit mptcp endpoint in parallel, more than one caller may end up in mptcp_pm_nl_append_new_local_addr because none found the address in local_addr_list during their call to mptcp_pm_nl_get_local_id. In this case, the concurrent new_local_addr calls may delete the address entry created by the previous caller. These deletes use synchronize_rcu, but this is not permitted in some of the contexts where this function may be called. During packet recv, the caller may be in a rcu read critical section and have preemption disabled.
An example stack:
BUG: scheduling while atomic: swapper/2/0/0x00000302 Call Trace: <IRQ> dump_stack_lvl (lib/dump_stack.c:117 (discriminator 1)) dump_stack (lib/dump_stack.c:124) __schedule_bug (kernel/sched/core.c:5943) schedule_debug.constprop.0 (arch/x86/include/asm/preempt.h:33 kernel/sched/core.c:5970) __schedule (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:207 kernel/sched/features.h:29 kernel/sched/core.c:6621) schedule (arch/x86/include/asm/preempt.h:84 kernel/sched/core.c:6804 kernel/sched/core.c:6818) schedule_timeout (kernel/time/timer.c:2160) wait_for_completion (kernel/sched/completion.c:96 kernel/sched/completion.c:116 kernel/sched/completion.c:127 kernel/sched/completion.c:148) __wait_rcu_gp (include/linux/rcupdate.h:311 kernel/rcu/update.c:444) synchronize_rcu (kernel/rcu/tree.c:3609) mptcp_pm_nl_append_new_local_addr (net/mptcp/pm_netlink.c:966 net/mptcp/pm_netlink.c:1061) mptcp_pm_nl_get_local_id (net/mptcp/pm_netlink.c:1164) mptcp_pm_get_local_id (net/mptcp/pm.c:420) subflow_check_req (net/mptcp/subflow.c:98 net/mptcp/subflow.c:213) subflow_v4_route_req (net/mptcp/subflow.c:305) tcp_conn_request (net/ipv4/tcp_input.c:7216) subflow_v4_conn_request (net/mptcp/subflow.c:651) tcp_rcv_state_process (net/ipv4/tcp_input.c:6709) tcp_v4_do_rcv (net/ipv4/tcp_ipv4.c:1934) tcp_v4_rcv (net/ipv4/tcp_ipv4.c:2334) ip_protocol_deliver_rcu (net/ipv4/ip_input.c:205 (discriminator 1)) ip_local_deliver_finish (include/linux/rcupdate.h:813 net/ipv4/ip_input.c:234) ip_local_deliver (include/linux/netfilter.h:314 include/linux/netfilter.h:308 net/ipv4/ip_input.c:254) ip_sublist_rcv_finish (include/net/dst.h:461 net/ipv4/ip_input.c:580) ip_sublist_rcv (net/ipv4/ip_input.c:640) ip_list_rcv (net/ipv4/ip_input.c:675) __netif_receive_skb_list_core (net/core/dev.c:5583 net/core/dev.c:5631) netif_receive_skb_list_internal (net/core/dev.c:5685 net/core/dev.c:5774) napi_complete_done (include/linux/list.h:37 include/net/gro.h:449 include/net/gro.h:444 net/core/dev.c:6114) igb_poll (drivers/net/ethernet/intel/igb/igb_main.c:8244) igb __napi_poll (net/core/dev.c:6582) net_rx_action (net/core/dev.c:6653 net/core/dev.c:6787) handle_softirqs (kernel/softirq.c:553) __irq_exit_rcu (kernel/softirq.c:588 kernel/softirq.c:427 kernel/softirq.c:636) irq_exit_rcu (kernel/softirq.c:651) common_interrupt (arch/x86/kernel/irq.c:247 (discriminator 14)) </IRQ>
This problem seems particularly prevalent if the user advertises an endpoint that has a different external vs internal address. In the case where the external address is advertised and multiple connections already exist, multiple subflow SYNs arrive in parallel which tends to trigger the race during creation of the first local_addr_list entries which have the internal address instead.
Fix by skipping the replacement of an existing implicit local address if called via mptcp_pm_nl_get_local_id.
--- net/mptcp/pm_netlink.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
net/mptcp/pm_netlink.c +15 -3
@@ -968,7 +968,7 @@ static void __mptcp_pm_release_addr_entrstatic int mptcp_pm_nl_append_new_local_addr (struct pm_nl_pernet *pernet,struct mptcp_pm_addr_entry *entry, -bool needs_id) +bool needs_id,bool replace) {struct mptcp_pm_addr_entry *cur, *del_entry =NULL ;unsigned int addr_max;
@@ -1008,6 +1008,17 @@ static int mptcp_pm_nl_append_new_local_if (entry->addr.id) goto out; +/* allow callers that only need to look up the local +* addr's id to skip replacement. This allows them to +* avoid calling synchronize_rcu in the packet recv +* path. +*/ +if (!replace) { +kfree (entry); + ret = cur->addr.id; + goto out; + } + pernet->addrs--; entry->addr.id = cur->addr.id;list_del_rcu (&cur->list);
@@ -1160,7 +1171,7 @@ int mptcp_pm_nl_get_local_id(struct mptc entry->ifindex =0 ; entry->flags =MPTCP_PM_ADDR_FLAG_IMPLICIT ; entry->lsk =NULL ; - ret =mptcp_pm_nl_append_new_local_addr (pernet, entry, true); + ret =mptcp_pm_nl_append_new_local_addr (pernet, entry, true, false);if (ret <0 )kfree (entry);
@@ -1432,7 +1443,8 @@ int mptcp_pm_nl_add_addr_doit(struct sk_ } } ret =mptcp_pm_nl_append_new_local_addr (pernet, entry, - !mptcp_pm_has_addr_attr_id (attr, info)); + !mptcp_pm_has_addr_attr_id (attr, info), + true);if (ret <0 ) {GENL_SET_ERR_MSG_FMT (info,"too many addresses or duplicate one: %d" , ret); goto out_free;
Greg Kroah-Hartman
maintainerPATCH 115/269 drm/xe: Fix GT "for each engine" workarounds
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
commit 54f94dc7f6b4db45dbc23b4db3d20c7194e2c54f upstream.
Any rules using engine matching are currently broken due RTP processing happening too in early init, before the list of hardware engines has been initialised.
Fix this by moving workaround processing to later in the driver probe sequence, to just before the processed list is used for the first time.
Looking at the debugfs gt0/workarounds on ADL-P we notice 14011060649 should be present while we see, before:
GT Workarounds
14011059788
14015795083And with the patch:
GT Workarounds
14011060649
14011059788
14015795083--- drivers/gpu/drm/xe/xe_gt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_gt.c +2 -2
@@ -379,9 +379,7 @@ int xe_gt_init_early(struct xe_gt *gt)if (err)return err; -xe_wa_process_gt (gt);xe_wa_process_oob (gt); -xe_tuning_process_gt (gt);xe_force_wake_init_gt (gt,gt_to_fw (gt));spin_lock_init (>->global_invl_lock);
@@ -469,6 +467,8 @@ static int all_fw_domain_init(struct xe_ goto err_hw_fence_irq;xe_gt_mcr_set_implicit_defaults (gt); +xe_wa_process_gt (gt); +xe_tuning_process_gt (gt);xe_reg_sr_apply_mmio (>->reg_sr, gt); err =xe_gt_clock_init (gt);
Greg Kroah-Hartman
maintainerPATCH 116/269 drm/xe: Fix fault mode invalidation with unbind
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <[email protected]>
commit 84211b1c0db6b9dbe0020fa97192fb9661617f24 upstream.
Fix fault mode invalidation racing with unbind leading to the PTE zapping potentially traversing an invalid page-table tree. Do this by holding the notifier lock across PTE zapping. This might transfer any contention waiting on the notifier seqlock read side to the notifier lock read side, but that shouldn't be a major problem.
At the same time get rid of the open-coded invalidation in the bind code by relying on the notifier even when the vma bind is not yet committed.
Finally let userptr invalidation call a dedicated xe_vm function performing a full invalidation.
--- drivers/gpu/drm/xe/xe_pt.c | 38 ++++------------- drivers/gpu/drm/xe/xe_vm.c | 85 +++++++++++++++++++++++++-------------- drivers/gpu/drm/xe/xe_vm.h | 8 +++ drivers/gpu/drm/xe/xe_vm_types.h | 4 - 4 files changed, 75 insertions(+), 60 deletions(-)
drivers/gpu/drm/xe/xe_pt.c +9 -29
@@ -1233,42 +1233,22 @@ static int vma_check_userptr(struct xe_vreturn 0 ; uvma =to_userptr_vma (vma); - notifier_seq = uvma->userptr.notifier_seq; +if (xe_pt_userptr_inject_eagain (uvma)) +xe_vma_userptr_force_invalidate (uvma); -if (uvma->userptr.initial_bind && !xe_vm_in_fault_mode (vm)) -return 0 ; + notifier_seq = uvma->userptr.notifier_seq;if (!mmu_interval_read_retry (&uvma->userptr.notifier, - notifier_seq) && - !xe_pt_userptr_inject_eagain (uvma)) + notifier_seq))return 0 ; -if (xe_vm_in_fault_mode (vm)) { +if (xe_vm_in_fault_mode (vm))return -EAGAIN ; - }else { -spin_lock (&vm->userptr.invalidated_lock); -list_move_tail (&uvma->userptr.invalidate_link, - &vm->userptr.invalidated); -spin_unlock (&vm->userptr.invalidated_lock); - -if (xe_vm_in_preempt_fence_mode (vm)) { -struct dma_resv_iter cursor; -struct dma_fence *fence; -long err; - -dma_resv_iter_begin (&cursor,xe_vm_resv (vm), -DMA_RESV_USAGE_BOOKKEEP ); -dma_resv_for_each_fence_unlocked (&cursor, fence) -dma_fence_enable_sw_signaling (fence); -dma_resv_iter_end (&cursor); - - err =dma_resv_wait_timeout (xe_vm_resv (vm), -DMA_RESV_USAGE_BOOKKEEP , - false,MAX_SCHEDULE_TIMEOUT ); -XE_WARN_ON (err <=0 ); - } - } +/* +* Just continue the operation since exec or rebind worker +* will take care of rebinding. +*/ return 0 ; }
drivers/gpu/drm/xe/xe_vm.c +56 -29
124 lines not on this page · raw message
drivers/gpu/drm/xe/xe_vm.h +8 -0
@@ -280,4 +280,12 @@ struct xe_vm_snapshot *xe_vm_snapshot_cavoid xe_vm_snapshot_capture_delayed (struct xe_vm_snapshot *snap);void xe_vm_snapshot_print (struct xe_vm_snapshot *snap,struct drm_printer *p);void xe_vm_snapshot_free (struct xe_vm_snapshot *snap); + +#if IS_ENABLED (CONFIG_DRM_XE_USERPTR_INVAL_INJECT ) +void xe_vma_userptr_force_invalidate (struct xe_userptr_vma *uvma); +#else +static inline void xe_vma_userptr_force_invalidate (struct xe_userptr_vma *uvma) +{ +} +#endif #endif
drivers/gpu/drm/xe/xe_vm_types.h +2 -2
@@ -227,8 +227,8 @@ struct xe_vm {* up for revalidation. Protected from access with the * @invalidated_lock. Removing items from the list * additionally requires @lock in write mode, and adding -* items to the list requires the @userptr.notifer_lock in -* write mode. +* items to the list requires either the @userptr.notifer_lock in +* write mode, OR @lock in write mode. */ struct list_head invalidated; } userptr;
Greg Kroah-Hartman
maintainerPATCH 117/269 drm/xe/userptr: properly setup pfn_flags_mask
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
commit 475d06e00b7496c7915d87f7ae67af26738e4649 upstream.
Currently we just leave it uninitialised, which at first looks harmless, however we also don't zero out the pfn array, and with pfn_flags_mask the idea is to be able set individual flags for a given range of pfn or completely ignore them, outside of default_flags. So here we end up with pfn[i] & pfn_flags_mask, and if both are uninitialised we might get back an unexpected flags value, like asking for read only with default_flags, but getting back write on top, leading to potentially bogus behaviour.
To fix this ensure we zero the pfn_flags_mask, such that hmm only considers the default_flags and not also the initial pfn[i] value.
v2 (Thomas):
- Prefer proper initializer.
--- drivers/gpu/drm/xe/xe_hmm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_hmm.c +10 -8
@@ -203,13 +203,20 @@ int xe_hmm_userptr_populate_range(struct {unsigned long timeout = jiffies +msecs_to_jiffies (HMM_RANGE_DEFAULT_TIMEOUT ); -unsigned long *pfns, flags =HMM_PFN_REQ_FAULT ; +unsigned long *pfns;struct xe_userptr *userptr;struct xe_vma *vma = &uvma->vma;u64 userptr_start =xe_vma_userptr (vma);u64 userptr_end = userptr_start +xe_vma_size (vma);struct xe_vm *vm =xe_vma_vm (vma); -struct hmm_range hmm_range; +struct hmm_range hmm_range = { + .pfn_flags_mask =0 ,/* ignore pfns */ + .default_flags =HMM_PFN_REQ_FAULT , + .start = userptr_start, + .end = userptr_end, + .notifier = &uvma->userptr.notifier, + .dev_private_owner = vm->xe, + };bool write = !xe_vma_read_only (vma);unsigned long notifier_seq;u64 npages;
@@ -236,19 +243,14 @@ int xe_hmm_userptr_populate_range(structreturn -ENOMEM ;if (write) - flags |=HMM_PFN_REQ_WRITE ; + hmm_range.default_flags |=HMM_PFN_REQ_WRITE ;if (!mmget_not_zero (userptr->notifier.mm)) { ret = -EFAULT ; goto free_pfns; } - hmm_range.default_flags = flags; hmm_range.hmm_pfns = pfns; - hmm_range.notifier = &userptr->notifier; - hmm_range.start = userptr_start; - hmm_range.end = userptr_end; - hmm_range.dev_private_owner = vm->xe;while (true) { hmm_range.notifier_seq =mmu_interval_read_begin (&userptr->notifier);
Greg Kroah-Hartman
maintainerPATCH 118/269 drm/xe/userptr: Unmap userptrs in the mmu notifier
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <[email protected]>
commit 333b8906336174478efbbfc1e24a89e3397ffe65 upstream.
If userptr pages are freed after a call to the xe mmu notifier, the device will not be blocked out from theoretically accessing these pages unless they are also unmapped from the iommu, and this violates some aspects of the iommu-imposed security.
Ensure that userptrs are unmapped in the mmu notifier to mitigate this. A naive attempt would try to free the sg table, but the sg table itself may be accessed by a concurrent bind operation, so settle for only unmapping.
v3:
- Update lockdep asserts.
- Fix a typo (Matthew Auld)
--- drivers/gpu/drm/xe/xe_hmm.c | 51 ++++++++++++++++++++++++++++++++------- drivers/gpu/drm/xe/xe_hmm.h | 2 + drivers/gpu/drm/xe/xe_vm.c | 4 +++ drivers/gpu/drm/xe/xe_vm_types.h | 4 +++ 4 files changed, 52 insertions(+), 9 deletions(-)
drivers/gpu/drm/xe/xe_hmm.c +42 -9
@@ -150,6 +150,45 @@ static int xe_build_sg(struct xe_device DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_NO_KERNEL_MAPPING); } +static void xe_hmm_userptr_set_mapped (struct xe_userptr_vma *uvma) +{ +struct xe_userptr *userptr = &uvma->userptr; +struct xe_vm *vm =xe_vma_vm (&uvma->vma); + +lockdep_assert_held_write (&vm->lock); +lockdep_assert_held (&vm->userptr.notifier_lock); + +mutex_lock (&userptr->unmap_mutex); +xe_assert (vm->xe, !userptr->mapped); + userptr->mapped = true; +mutex_unlock (&userptr->unmap_mutex); +} + +void xe_hmm_userptr_unmap (struct xe_userptr_vma *uvma) +{ +struct xe_userptr *userptr = &uvma->userptr; +struct xe_vma *vma = &uvma->vma; +bool write = !xe_vma_read_only (vma); +struct xe_vm *vm =xe_vma_vm (vma); +struct xe_device *xe = vm->xe; + +if (!lockdep_is_held_type (&vm->userptr.notifier_lock,0 ) && + !lockdep_is_held_type (&vm->lock,0 ) && + !(vma->gpuva.flags &XE_VMA_DESTROYED )) { +/* Don't unmap in exec critical section. */ +xe_vm_assert_held (vm); +/* Don't unmap while mapping the sg. */ +lockdep_assert_held (&vm->lock); + } + +mutex_lock (&userptr->unmap_mutex); +if (userptr->sg && userptr->mapped) +dma_unmap_sgtable (xe->drm.dev, userptr->sg, + write ?DMA_BIDIRECTIONAL :DMA_TO_DEVICE ,0 ); + userptr->mapped = false; +mutex_unlock (&userptr->unmap_mutex); +} +/** * xe_hmm_userptr_free_sg() - Free the scatter gather table of userptr * @uvma: the userptr vma which hold the scatter gather table
@@ -161,16 +200,9 @@ static int xe_build_sg(struct xe_devicevoid xe_hmm_userptr_free_sg (struct xe_userptr_vma *uvma) {struct xe_userptr *userptr = &uvma->userptr; -struct xe_vma *vma = &uvma->vma; -bool write = !xe_vma_read_only (vma); -struct xe_vm *vm =xe_vma_vm (vma); -struct xe_device *xe = vm->xe; -struct device *dev = xe->drm.dev; - -xe_assert (xe, userptr->sg); -dma_unmap_sgtable (dev, userptr->sg, - write ?DMA_BIDIRECTIONAL :DMA_TO_DEVICE ,0 ); +xe_assert (xe_vma_vm (&uvma->vma)->xe, userptr->sg); +xe_hmm_userptr_unmap (uvma);sg_free_table (userptr->sg); userptr->sg =NULL ; }
@@ -297,6 +329,7 @@ int xe_hmm_userptr_populate_range(structxe_mark_range_accessed (&hmm_range, write); userptr->sg = &userptr->sgt; +xe_hmm_userptr_set_mapped (uvma); userptr->notifier_seq = hmm_range.notifier_seq;up_read (&vm->userptr.notifier_lock);kvfree (pfns);
drivers/gpu/drm/xe/xe_hmm.h +2 -0
@@ -13,4 +13,6 @@ struct xe_userptr_vma;int xe_hmm_userptr_populate_range (struct xe_userptr_vma *uvma,bool is_mm_mmap_locked);void xe_hmm_userptr_free_sg (struct xe_userptr_vma *uvma); + +void xe_hmm_userptr_unmap (struct xe_userptr_vma *uvma);#endif
drivers/gpu/drm/xe/xe_vm.c +4 -0
@@ -621,6 +621,8 @@ static void __vma_userptr_invalidate(str err =xe_vm_invalidate_vma (vma);XE_WARN_ON (err); } + +xe_hmm_userptr_unmap (uvma); } static bool vma_userptr_invalidate(struct mmu_interval_notifier *mni,
@@ -1039,6 +1041,7 @@ static struct xe_vma *xe_vma_create(struINIT_LIST_HEAD (&userptr->invalidate_link);INIT_LIST_HEAD (&userptr->repin_link); vma->gpuva.gem.offset = bo_offset_or_userptr; +mutex_init (&userptr->unmap_mutex); err = mmu_interval_notifier_insert(&userptr->notifier, current->mm,
@@ -1080,6 +1083,7 @@ static void xe_vma_destroy_late(struct x* them anymore */ mmu_interval_notifier_remove (&userptr->notifier); +mutex_destroy (&userptr->unmap_mutex);xe_vm_put (vm); }else if (xe_vma_is_null (vma)) {xe_vm_put (vm);
drivers/gpu/drm/xe/xe_vm_types.h +4 -0
@@ -59,12 +59,16 @@ struct xe_userptr {struct sg_table *sg;/** @notifier_seq: notifier sequence number */ unsigned long notifier_seq; +/** @unmap_mutex: Mutex protecting dma-unmapping */ +struct mutex unmap_mutex;/** * @initial_bind: user pointer has been bound at least once. * write: vm->userptr.notifier_lock in read mode and vm->resv held. * read: vm->userptr.notifier_lock in write mode or vm->resv held. */ bool initial_bind; +/** @mapped: Whether the @sgt sg-table is dma-mapped. Protected by @unmap_mutex. */ +bool mapped;#if IS_ENABLED (CONFIG_DRM_XE_USERPTR_INVAL_INJECT )u32 divisor;#endif
Greg Kroah-Hartman
maintainerPATCH 119/269 Bluetooth: Add check for mgmt_alloc_skb() in mgmt_remote_name()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit f2176a07e7b19f73e05c805cf3d130a2999154cb upstream.
Add check for the return value of mgmt_alloc_skb() in mgmt_remote_name() to prevent null pointer dereference.
--- net/bluetooth/mgmt.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/mgmt.c +2 -0
@@ -10484,6 +10484,8 @@ void mgmt_remote_name(struct hci_dev *hd skb =mgmt_alloc_skb (hdev,MGMT_EV_DEVICE_FOUND ,sizeof (*ev) + (name ?eir_precalc_len (name_len) :0 )); +if (!skb) +return ; ev =skb_put (skb,sizeof (*ev));bacpy (&ev->addr.bdaddr, bdaddr);
Greg Kroah-Hartman
maintainerPATCH 120/269 Bluetooth: Add check for mgmt_alloc_skb() in mgmt_device_connected()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit d8df010f72b8a32aaea393e36121738bb53ed905 upstream.
Add check for the return value of mgmt_alloc_skb() in mgmt_device_connected() to prevent null pointer dereference.
--- net/bluetooth/mgmt.c | 3 +++ 1 file changed, 3 insertions(+)
net/bluetooth/mgmt.c +3 -0
@@ -9731,6 +9731,9 @@ void mgmt_device_connected(struct hci_desizeof (*ev) + (name ?eir_precalc_len (name_len) :0 ) + eir_precalc_len(sizeof(conn->dev_class))); +if (!skb) +return ; + ev =skb_put (skb,sizeof (*ev));bacpy (&ev->addr.bdaddr, &conn->dst); ev->addr.type =link_to_bdaddr (conn->type, conn->dst_type);
Greg Kroah-Hartman
maintainerPATCH 121/269 wifi: cfg80211: regulatory: improve invalid hints checking
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
commit 59b348be7597c4a9903cb003c69e37df20c04a30 upstream.
Syzbot keeps reporting an issue [1] that occurs when erroneous symbols sent from userspace get through into user_alpha2[] via regulatory_hint_user() call. Such invalid regulatory hints should be rejected.
While a sanity check from commit 47caf685a685 ("cfg80211: regulatory:
reject invalid hints") looks to be enough to deter these very cases, there is a way to get around it due to 2 reasons.
1) The way isalpha() works, symbols other than latin lower and upper letters may be used to determine a country/domain. For instance, greek letters will also be considered upper/lower letters and for such characters isalpha() will return true as well. However, ISO-3166-1 alpha2 codes should only hold latin characters.
2) While processing a user regulatory request, between reg_process_hint_user() and regulatory_hint_user() there happens to be a call to queue_regulatory_request() which modifies letters in request->alpha2[] with toupper(). This works fine for latin symbols, less so for weird letter characters from the second part of _ctype[].
Syzbot triggers a warning in is_user_regdom_saved() by first sending over an unexpected non-latin letter that gets malformed by toupper() into a character that ends up failing isalpha() check.
Prevent this by enhancing is_an_alpha2() to ensure that incoming symbols are latin letters and nothing else.
[1] Syzbot report:
------------[ cut here ]------------ Unexpected user alpha2: A� WARNING: CPU: 1 PID: 964 at net/wireless/reg.c:442 is_user_regdom_saved net/wireless/reg.c:440 [inline] WARNING: CPU: 1 PID: 964 at net/wireless/reg.c:442 restore_alpha2 net/wireless/reg.c:3424 [inline] WARNING: CPU: 1 PID: 964 at net/wireless/reg.c:442 restore_regulatory_settings+0x3c0/0x1e50 net/wireless/reg.c:3516 Modules linked in: CPU: 1 UID: 0 PID: 964 Comm: kworker/1:2 Not tainted 6.12.0-rc5-syzkaller-00044-gc1e939a21eb1 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Workqueue: events_power_efficient crda_timeout_work RIP: 0010:is_user_regdom_saved net/wireless/reg.c:440 [inline] RIP: 0010:restore_alpha2 net/wireless/reg.c:3424 [inline] RIP: 0010:restore_regulatory_settings+0x3c0/0x1e50 net/wireless/reg.c:3516 ... Call Trace: <TASK> crda_timeout_work+0x27/0x50 net/wireless/reg.c:542 process_one_work kernel/workqueue.c:3229 [inline] process_scheduled_works+0xa65/0x1850 kernel/workqueue.c:3310 worker_thread+0x870/0xd30 kernel/workqueue.c:3391 kthread+0x2f2/0x390 kernel/kthread.c:389 ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK>
--- net/wireless/reg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/wireless/reg.c +2 -1
@@ -407,7 +407,8 @@ static bool is_an_alpha2(const char *alp {if (!alpha2)return false; -return isalpha (alpha2[0 ]) &&isalpha (alpha2[1 ]); +return isascii (alpha2[0 ]) &&isalpha (alpha2[0 ]) && +isascii (alpha2[1 ]) &&isalpha (alpha2[1 ]); }static bool alpha2_equal (const char *alpha2_x,const char *alpha2_y)
Greg Kroah-Hartman
maintainerPATCH 122/269 wifi: nl80211: reject cooked mode if it is set along with other flags
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaliy Shevtsov <[email protected]>
commit 49f27f29446a5bfe633dd2cc0cfebd48a1a5e77f upstream.
It is possible to set both MONITOR_FLAG_COOK_FRAMES and MONITOR_FLAG_ACTIVE flags simultaneously on the same monitor interface from the userspace. This causes a sub-interface to be created with no IEEE80211_SDATA_IN_DRIVER bit set because the monitor interface is in the cooked state and it takes precedence over all other states. When the interface is then being deleted the kernel calls WARN_ONCE() from check_sdata_in_driver() because of missing that bit.
Fix this by rejecting MONITOR_FLAG_COOK_FRAMES if it is set along with other flags.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- net/wireless/nl80211.c | 5 +++++ 1 file changed, 5 insertions(+)
net/wireless/nl80211.c +5 -0
@@ -4218,6 +4218,11 @@ static int parse_monitor_flags(struct nlif (flags[flag]) *mntrflags |= (1 <<flag); +/* cooked monitor mode is incompatible with other modes */ +if (*mntrflags &MONITOR_FLAG_COOK_FRAMES && + *mntrflags !=MONITOR_FLAG_COOK_FRAMES ) +return -EOPNOTSUPP ; + *mntrflags |=MONITOR_FLAG_CHANGED ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 123/269 selftests/damon/damos_quota_goal: handle minimum quota that cannot be further reduced
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 349db086a66051bc6114b64b4446787c20ac3f00 upstream.
damos_quota_goal.py selftest see if DAMOS quota goals tuning feature increases or reduces the effective size quota for given score as expected. The tuning feature sets the minimum quota size as one byte, so if the effective size quota is already one, we cannot expect it further be reduced. However the test is not aware of the edge case, and fails since it shown no expected change of the effective quota. Handle the case by updating the failure logic for no change to see if it was the case, and simply skips to next test input.
--- tools/testing/selftests/damon/damos_quota_goal.py | 3 +++ 1 file changed, 3 insertions(+)
tools/testing/selftests/damon/damos_quota_goal.py +3 -0
@@ -63,6 +63,9 @@ def main(): if last_effective_bytes != 0 else -1.0)) if last_effective_bytes == goal.effective_bytes: + # effective quota was already minimum that cannot be more reduced + if expect_increase is False and last_effective_bytes == 1: + continue print('efective bytes not changed: %d' % goal.effective_bytes) exit(1)
Greg Kroah-Hartman
maintainerPATCH 124/269 selftests/damon/damos_quota: make real expectation of quota exceeds
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 1c684d77dfbcf926e0dd28f6d260e8fdd8a58e85 upstream.
Patch series "selftests/damon: three fixes for false results".
Fix three DAMON selftest bugs that cause two and one false positive failures and successes.
This patch (of 3):
damos_quota.py assumes the quota will always exceeded. But whether quota will be exceeded or not depend on the monitoring results. Actually the monitored workload has chaning access pattern and hence sometimes the quota may not really be exceeded. As a result, false positive test failures happen. Expect how much time the quota will be exceeded by checking the monitoring results, and use it instead of the naive assumption.
--- tools/testing/selftests/damon/damos_quota.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/damon/damos_quota.py +6 -3
@@ -51,16 +51,19 @@ def main(): nr_quota_exceeds = scheme.stats.qt_exceeds wss_collected.sort() + nr_expected_quota_exceeds = 0 for wss in wss_collected: if wss > sz_quota: print('quota is not kept: %s > %s' % (wss, sz_quota)) print('collected samples are as below') print('\n'.join(['%d' % wss for wss in wss_collected])) exit(1) + if wss == sz_quota: + nr_expected_quota_exceeds += 1 - if nr_quota_exceeds < len(wss_collected): - print('quota is not always exceeded: %d > %d' % - (len(wss_collected), nr_quota_exceeds)) + if nr_quota_exceeds < nr_expected_quota_exceeds: + print('quota is exceeded less than expected: %d < %d' % + (nr_quota_exceeds, nr_expected_quota_exceeds)) exit(1) if __name__ == '__main__':
Greg Kroah-Hartman
maintainerPATCH 125/269 selftests/damon/damon_nr_regions: set ops update for merge results check to 100ms
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 695469c07a65547acb6e229b3fdf6aaa881817e3 upstream.
damon_nr_regions.py updates max_nr_regions to a number smaller than expected number of real regions and confirms DAMON respect the harsh limit. To give time for DAMON to make changes for the regions, 3 aggregation intervals (300 milliseconds) are given.
The internal mechanism works with not only the max_nr_regions, but also sz_limit, though. It avoids merging region if that casn make region of size larger than sz_limit. In the test, sz_limit is set too small to achive the new max_nr_regions, unless it is updated for the new min_nr_regions. But the update is done only once per operations set update interval, which is one second by default.
Hence, the test randomly incurs false positive failures. Fix it by setting the ops interval same to aggregation interval, to make sure sz_limit is updated by the time of the check.
--- tools/testing/selftests/damon/damon_nr_regions.py | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/damon/damon_nr_regions.py +1 -0
@@ -109,6 +109,7 @@ def main(): attrs = kdamonds.kdamonds[0].contexts[0].monitoring_attrs attrs.min_nr_regions = 3 attrs.max_nr_regions = 7 + attrs.update_us = 100000 err = kdamonds.kdamonds[0].commit() if err is not None: proc.terminate()
Greg Kroah-Hartman
maintainerPATCH 126/269 selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 582ccf78f6090d88b1c7066b1e90b3d9ec952d08 upstream.
damon_nr_regions.py starts DAMON, periodically collect number of regions in snapshots, and see if it is in the requested range. The check code assumes the numbers are sorted on the collection list, but there is no such guarantee. Hence this can result in false positive test success. Sort the list before doing the check.
--- tools/testing/selftests/damon/damon_nr_regions.py | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/damon/damon_nr_regions.py +1 -0
@@ -65,6 +65,7 @@ def test_nr_regions(real_nr_regions, min test_name = 'nr_regions test with %d/%d/%d real/min/max nr_regions' % ( real_nr_regions, min_nr_regions, max_nr_regions) + collected_nr_regions.sort() if (collected_nr_regions[0] < min_nr_regions or collected_nr_regions[-1] > max_nr_regions): print('fail %s' % test_name)
Greg Kroah-Hartman
maintainerPATCH 127/269 rapidio: add check for rio_add_net() in rio_scan_alloc_net()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit e842f9a1edf306bf36fe2a4d847a0b0d458770de upstream.
The return value of rio_add_net() should be checked. If it fails, put_device() should be called to free the memory and give up the reference initialized in rio_add_net().
--- drivers/rapidio/rio-scan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rapidio/rio-scan.c +4 -1
@@ -871,7 +871,10 @@ static struct rio_net *rio_scan_alloc_nedev_set_name (&net->dev,"rnet_%d" , net->id); net->dev.parent = &mport->dev; net->dev.release = rio_scan_release_dev; -rio_add_net (net); +if (rio_add_net (net)) { +put_device (&net->dev); + net =NULL ; + } }return net;
Greg Kroah-Hartman
maintainerPATCH 128/269 rapidio: fix an API misues when rio_add_net() fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit b2ef51c74b0171fde7eb69b6152d3d2f743ef269 upstream.
rio_add_net() calls device_register() and fails when device_register() fails. Thus, put_device() should be used rather than kfree(). Add "mport->net = NULL;" to avoid a use after free issue.
--- drivers/rapidio/devices/rio_mport_cdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rapidio/devices/rio_mport_cdev.c +2 -1
@@ -1742,7 +1742,8 @@ static int rio_mport_add_riodev(struct m err =rio_add_net (net);if (err) {rmcd_debug (RDEV ,"failed to register net, err=%d" , err); -kfree (net); +put_device (&net->dev); + mport->net =NULL ; goto cleanup; } }
Greg Kroah-Hartman
maintainerPATCH 129/269 dma: kmsan: export kmsan_handle_dma() for modules
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 19fac3c93991502a22c5132824c40b6a2e64b136 upstream.
kmsan_handle_dma() is used by virtio_ring() which can be built as a module. kmsan_handle_dma() needs to be exported otherwise building the virtio_ring fails.
Export kmsan_handle_dma for modules.
--- mm/kmsan/hooks.c | 1 + 1 file changed, 1 insertion(+)
mm/kmsan/hooks.c +1 -0
@@ -357,6 +357,7 @@ void kmsan_handle_dma(struct page *page, size -= to_go; } } +EXPORT_SYMBOL_GPL (kmsan_handle_dma);void kmsan_handle_dma_sg (struct scatterlist *sg,int nents,enum dma_data_direction dir)
Greg Kroah-Hartman
maintainerPATCH 130/269 s390/traps: Fix test_monitor_call() inline assembly
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 5623bc23a1cb9f9a9470fa73b3a20321dc4c4870 upstream.
The test_monitor_call() inline assembly uses the xgr instruction, which also modifies the condition code, to clear a register. However the clobber list of the inline assembly does not specify that the condition code is modified, which may lead to incorrect code generation.
Use the lhi instruction instead to clear the register without that the condition code is modified. Furthermore this limits clearing to the lower 32 bits of val, since its type is int.
--- arch/s390/kernel/traps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kernel/traps.c +3 -3
@@ -284,10 +284,10 @@ static void __init test_monitor_call(voireturn ; asmvolatile (" mc 0,0\n" -"0: xgr %0,%0\n" +"0: lhi %[val],0\n" "1:\n" - EX_TABLE(0b,1b) - : "+d" (val)); + EX_TABLE(0b, 1b) + : [val] "+d" (val)); if (!val)panic ("Monitor call doesn't work!\n" ); }
Greg Kroah-Hartman
maintainerPATCH 131/269 NFS: fix nfs_release_folio() to not deadlock via kcompactd writeback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Snitzer <[email protected]>
commit ce6d9c1c2b5cc785016faa11b48b6cd317eb367e upstream.
Add PF_KCOMPACTD flag and current_is_kcompactd() helper to check for it so nfs_release_folio() can skip calling nfs_wb_folio() from kcompactd.
Otherwise NFS can deadlock waiting for kcompactd enduced writeback which recurses back to NFS (which triggers writeback to NFSD via NFS loopback mount on the same host, NFSD blocks waiting for XFS's call to __filemap_get_folio):
6070.550357] INFO: task kcompactd0:58 blocked for more than 4435 seconds.
{---
[58] "kcompactd0"
[<0>] folio_wait_bit+0xe8/0x200 [<0>] folio_wait_writeback+0x2b/0x80 [<0>] nfs_wb_folio+0x80/0x1b0 [nfs] [<0>] nfs_release_folio+0x68/0x130 [nfs] [<0>] split_huge_page_to_list_to_order+0x362/0x840 [<0>] migrate_pages_batch+0x43d/0xb90 [<0>] migrate_pages_sync+0x9a/0x240 [<0>] migrate_pages+0x93c/0x9f0 [<0>] compact_zone+0x8e2/0x1030 [<0>] compact_node+0xdb/0x120 [<0>] kcompactd+0x121/0x2e0 [<0>] kthread+0xcf/0x100 [<0>] ret_from_fork+0x31/0x40 [<0>] ret_from_fork_asm+0x1a/0x30
---}
--- fs/nfs/file.c | 3 ++- include/linux/compaction.h | 5 +++++ include/linux/sched.h | 2 +- mm/compaction.c | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-)
fs/nfs/file.c +2 -1
@@ -29,6 +29,7 @@#include <linux/pagemap.h> #include <linux/gfp.h> #include <linux/swap.h> +#include <linux/compaction.h> #include <linux/uaccess.h> #include <linux/filelock.h>
@@ -451,7 +452,7 @@ static bool nfs_release_folio(struct fol/* If the private flag is set, then the folio is not freeable */ if (folio_test_private (folio)) {if ((current_gfp_context (gfp) &GFP_KERNEL ) !=GFP_KERNEL || -current_is_kswapd ()) +current_is_kswapd () ||current_is_kcompactd ())return false;if (nfs_wb_folio (folio->mapping->host, folio) <0 )return false;
include/linux/compaction.h +5 -0
@@ -80,6 +80,11 @@ static inline unsigned long compact_gap(return 2UL << order; } +static inline int current_is_kcompactd (void ) +{ +return current->flags &PF_KCOMPACTD ; +} +#ifdef CONFIG_COMPACTION extern unsigned int extfrag_for_order (struct zone *zone,unsigned int order);
include/linux/sched.h +1 -1
@@ -1682,7 +1682,7 @@ extern struct pid *cad_pid;#define PF_USED_MATH 0x00002000/* If unset the fpu must be initialized before use */ #define PF_USER_WORKER 0x00004000/* Kernel thread cloned from userspace thread */ #define PF_NOFREEZE 0x00008000/* This thread should not be frozen */ -#define PF__HOLE__00010000 0x00010000 +#define PF_KCOMPACTD 0x00010000/* I am kcompactd */ #define PF_KSWAPD 0x00020000/* I am kswapd */ #define PF_MEMALLOC_NOFS 0x00040000/* All allocations inherit GFP_NOFS. See memalloc_nfs_save() */ #define PF_MEMALLOC_NOIO 0x00080000/* All allocations inherit GFP_NOIO. See memalloc_noio_save() */
mm/compaction.c +3 -0
@@ -3164,6 +3164,7 @@ static int kcompactd(void *p)if (!cpumask_empty (cpumask))set_cpus_allowed_ptr (tsk, cpumask); + current->flags |=PF_KCOMPACTD ;set_freezable (); pgdat->kcompactd_max_order =0 ;
@@ -3220,6 +3221,8 @@ static int kcompactd(void *p) pgdat->proactive_compact_trigger = false; } + current->flags &= ~PF_KCOMPACTD ; +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 132/269 userfaultfd: do not block on locking a large folio with raised refcount
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
commit 37b338eed10581784e854d4262da05c8d960c748 upstream.
Lokesh recently raised an issue about UFFDIO_MOVE getting into a deadlock state when it goes into split_folio() with raised folio refcount. split_folio() expects the reference count to be exactly mapcount + num_pages_in_folio + 1 (see can_split_folio()) and fails with EAGAIN otherwise.
If multiple processes are trying to move the same large folio, they raise the refcount (all tasks succeed in that) then one of them succeeds in locking the folio, while others will block in folio_lock() while keeping the refcount raised. The winner of this race will proceed with calling split_folio() and will fail returning EAGAIN to the caller and unlocking the folio. The next competing process will get the folio locked and will go through the same flow. In the meantime the original winner will be retried and will block in folio_lock(), getting into the queue of waiting processes only to repeat the same path. All this results in a livelock.
An easy fix would be to avoid waiting for the folio lock while holding folio refcount, similar to madvise_free_huge_pmd() where folio lock is acquired before raising the folio refcount. Since we lock and take a refcount of the folio while holding the PTE lock, changing the order of these operations should not break anything.
Modify move_pages_pte() to try locking the folio first and if that fails and the folio is large then return EAGAIN without touching the folio refcount. If the folio is single-page then split_folio() is not called, so we don't have this issue. Lokesh has a reproducer [1] and I verified that this change fixes the issue.
[1] https://github.com/lokeshgidra/uffd_move_ioctl_deadlock
--- mm/userfaultfd.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
mm/userfaultfd.c +16 -1
@@ -1215,6 +1215,7 @@ retry:*/ if (!src_folio) {struct folio *folio; +bool locked;/* * Pin the page while holding the lock to be sure the
@@ -1234,12 +1235,26 @@ retry: goto out; } + locked =folio_trylock (folio); +/* +* We avoid waiting for folio lock with a raised +* refcount for large folios because extra refcounts +* will result in split_folio() failing later and +* retrying. If multiple tasks are trying to move a +* large folio we can end up livelocking. +*/ +if (!locked &&folio_test_large (folio)) { +spin_unlock (src_ptl); + err = -EAGAIN ; + goto out; + } +folio_get (folio); src_folio = folio; src_folio_pte = orig_src_pte;spin_unlock (src_ptl); -if (!folio_trylock (src_folio)) { +if (!locked) {pte_unmap (&orig_src_pte);pte_unmap (&orig_dst_pte); src_pte = dst_pte =NULL ;
Greg Kroah-Hartman
maintainerPATCH 133/269 block: fix conversion of GPT partition name to 7-bit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olivier Gayot <[email protected]>
commit e06472bab2a5393430cc2fbc3211cd3602422c1e upstream.
The utf16_le_to_7bit function claims to, naively, convert a UTF-16 string to a 7-bit ASCII string. By naively, we mean that it:
* drops the first byte of every character in the original UTF-16 string
* checks if all characters are printable, and otherwise replaces them by exclamation mark "!".
This means that theoretically, all characters outside the 7-bit ASCII range should be replaced by another character. Examples:
* lower-case alpha (ɒ) 0x0252 becomes 0x52 (R)
* ligature OE (œ) 0x0153 becomes 0x53 (S)
* hangul letter pieup (ㅂ) 0x3142 becomes 0x42 (B)
* upper-case gamma (Ɣ) 0x0194 becomes 0x94 (not printable) so gets replaced by "!"
The result of this conversion for the GPT partition name is passed to user-space as PARTNAME via udev, which is confusing and feels questionable.
However, there is a flaw in the conversion function itself. By dropping one byte of each character and using isprint() to check if the remaining byte corresponds to a printable character, we do not actually guarantee that the resulting character is 7-bit ASCII.
This happens because we pass 8-bit characters to isprint(), which in the kernel returns 1 for many values > 0x7f - as defined in ctype.c.
This results in many values which should be replaced by "!" to be kept as-is, despite not being valid 7-bit ASCII. Examples:
* e with acute accent (é) 0x00E9 becomes 0xE9 - kept as-is because isprint(0xE9) returns 1.
* euro sign (€) 0x20AC becomes 0xAC - kept as-is because isprint(0xAC) returns 1.
This way has broken pyudev utility[1], fixes it by using a mask of 7 bits instead of 8 bits before calling isprint.
--- block/partitions/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/partitions/efi.c +1 -1
@@ -682,7 +682,7 @@ static void utf16_le_to_7bit(const __le1 out[size] =0 ;while (i < size) { -u8 c =le16_to_cpu (in[i]) &0xff ; +u8 c =le16_to_cpu (in[i]) &0x7f ;if (c && !isprint (c)) c ='!' ;
Greg Kroah-Hartman
maintainerPATCH 134/269 mm/page_alloc: fix uninitialized variable
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hao Zhang <[email protected]>
commit 8fe9ed44dc29fba0786b7e956d2e87179e407582 upstream.
The variable "compact_result" is not initialized in function __alloc_pages_slowpath(). It causes should_compact_retry() to use an uninitialized value.
Initialize variable "compact_result" with the value COMPACT_SKIPPED.
BUG: KMSAN: uninit-value in __alloc_pages_slowpath+0xee8/0x16c0 mm/page_alloc.c:4416 __alloc_pages_slowpath+0xee8/0x16c0 mm/page_alloc.c:4416 __alloc_frozen_pages_noprof+0xa4c/0xe00 mm/page_alloc.c:4752 alloc_pages_mpol+0x4cd/0x890 mm/mempolicy.c:2270 alloc_frozen_pages_noprof mm/mempolicy.c:2341 [inline] alloc_pages_noprof mm/mempolicy.c:2361 [inline] folio_alloc_noprof+0x1dc/0x350 mm/mempolicy.c:2371 filemap_alloc_folio_noprof+0xa6/0x440 mm/filemap.c:1019 __filemap_get_folio+0xb9a/0x1840 mm/filemap.c:1970 grow_dev_folio fs/buffer.c:1039 [inline] grow_buffers fs/buffer.c:1105 [inline] __getblk_slow fs/buffer.c:1131 [inline] bdev_getblk+0x2c9/0xab0 fs/buffer.c:1431 getblk_unmovable include/linux/buffer_head.h:369 [inline] ext4_getblk+0x3b7/0xe50 fs/ext4/inode.c:864 ext4_bread_batch+0x9f/0x7d0 fs/ext4/inode.c:933 __ext4_find_entry+0x1ebb/0x36c0 fs/ext4/namei.c:1627 ext4_lookup_entry fs/ext4/namei.c:1729 [inline] ext4_lookup+0x189/0xb40 fs/ext4/namei.c:1797 __lookup_slow+0x538/0x710 fs/namei.c:1793 lookup_slow+0x6a/0xd0 fs/namei.c:1810 walk_component fs/namei.c:2114 [inline] link_path_walk+0xf29/0x1420 fs/namei.c:2479 path_openat+0x30f/0x6250 fs/namei.c:3985 do_filp_open+0x268/0x600 fs/namei.c:4016 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1428 do_sys_open fs/open.c:1443 [inline] __do_sys_openat fs/open.c:1459 [inline] __se_sys_openat fs/open.c:1454 [inline] __x64_sys_openat+0x2a1/0x310 fs/open.c:1454 x64_sys_call+0x36f5/0x3c30 arch/x86/include/generated/asm/syscalls_64.h:258 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable compact_result created at:
__alloc_pages_slowpath+0x66/0x16c0 mm/page_alloc.c:4218 __alloc_frozen_pages_noprof+0xa4c/0xe00 mm/page_alloc.c:4752
--- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+)
mm/page_alloc.c +1 -0
@@ -4243,6 +4243,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, u restart: compaction_retries =0 ; no_progress_loops =0 ; + compact_result =COMPACT_SKIPPED ; compact_priority =DEF_COMPACT_PRIORITY ; cpuset_mems_cookie =read_mems_allowed_begin (); zonelist_iter_cookie =zonelist_iter_begin ();
Greg Kroah-Hartman
maintainerPATCH 135/269 mm: abort vma_modify() on merge out of memory failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Stoakes <[email protected]>
commit 47b16d0462a460000b8f05dfb1292377ac48f3ca upstream.
The remainder of vma_modify() relies upon the vmg state remaining pristine after a merge attempt.
Usually this is the case, however in the one edge case scenario of a merge attempt failing not due to the specified range being unmergeable, but rather due to an out of memory error arising when attempting to commit the merge, this assumption becomes untrue.
This results in vmg->start, end being modified, and thus the proceeding attempts to split the VMA will be done with invalid start/end values.
Thankfully, it is likely practically impossible for us to hit this in reality, as it would require a maple tree node pre-allocation failure that would likely never happen due to it being 'too small to fail', i.e. the kernel would simply keep retrying reclaim until it succeeded.
However, this scenario remains theoretically possible, and what we are doing here is wrong so we must correct it.
The safest option is, when this scenario occurs, to simply give up the operation. If we cannot allocate memory to merge, then we cannot allocate memory to split either (perhaps moreso!).
Any scenario where this would be happening would be under very extreme (likely fatal) memory pressure, so it's best we give up early.
So there is no doubt it is appropriate to simply bail out in this scenario.
However, in general we must if at all possible never assume VMG state is stable after a merge attempt, since merge operations update VMG fields. As a result, additionally also make this clear by storing start, end in local variables.
The issue was reported originally by syzkaller, and by Brad Spengler (via an off-list discussion), and in both instances it manifested as a triggering of the assert:
VM_WARN_ON_VMG(start >= end, vmg);
In vma_merge_existing_range().
It seems at least one scenario in which this is occurring is one in which the merge being attempted is due to an madvise() across multiple VMAs which looks like this:
start end
|<------>|
|----------|------|
| vma | next |
|----------|------|When madvise_walk_vmas() is invoked, we first find vma in the above (determining prev to be equal to vma as we are offset into vma), and then enter the loop.
We determine the end of vma that forms part of the range we are madvise()'ing by setting 'tmp' to this value:
/* Here vma->vm_start <= start < (end|vma->vm_end) */ tmp = vma->vm_end;
We then invoke the madvise() operation via visit(), letting prev get updated to point to vma as part of the operation:
/* Here vma->vm_start <= start < tmp <= (end|vma->vm_end). */ error = visit(vma, &prev, start, tmp, arg);
Where the visit() function pointer in this instance is madvise_vma_behavior().
As observed in syzkaller reports, it is ultimately madvise_update_vma() that is invoked, calling vma_modify_flags_name() and vma_modify() in turn.
Then, in vma_modify(), we attempt the merge:
merged = vma_merge_existing_range(vmg); if (merged) return merged;
We invoke this with vmg->start, end set to start, tmp as such:
start tmp
|<--->|
|----------|------|
| vma | next |
|----------|------|We find ourselves in the merge right scenario, but the one in which we cannot remove the middle (we are offset into vma).
Here we have a special case where vmg->start, end get set to perhaps unintuitive values - we intended to shrink the middle VMA and expand the next.
This means vmg->start, end are set to... vma->vm_start, start.
Now the commit_merge() fails, and vmg->start, end are left like this. This means we return to the rest of vma_modify() with vmg->start, end (here denoted as start', end') set as:
start' end'
|<-->|
|----------|------|
| vma | next |
|----------|------|So we now erroneously try to split accordingly. This is where the unfortunate stuff begins.
We start with:
/* Split any preceding portion of the VMA. */
if (vma->vm_start < vmg->start) {
...
}This doesn't trigger as we are no longer offset into vma at the start.
But then we invoke:
/* Split any trailing portion of the VMA. */
if (vma->vm_end > vmg->end) {
...
}Which does get invoked. This leaves us with:
start' end'
|<-->|
|----|-----|------|
| vma| new | next |
|----|-----|------|We then return ultimately to madvise_walk_vmas(). Here 'new' is unknown, and putting back the values known in this function we are faced with:
start tmp end
| | |
|----|-----|------|
| vma| new | next |
|----|-----|------|
prevThen:
start = tmp;
So:
start end
| |
|----|-----|------|
| vma| new | next |
|----|-----|------|
prevThe following code does not cause anything to happen:
if (prev && start < prev->vm_end) start = prev->vm_end; if (start >= end) break;
And then we invoke:
if (prev) vma = find_vma(mm, prev->vm_end);
Which is where a problem occurs - we don't know about 'new' so we essentially look for the vma after prev, which is new, whereas we actually intended to discover next!
So we end up with:
start end
| |
|----|-----|------|
|prev| vma | next |
|----|-----|------|And we have successfully bypassed all of the checks madvise_walk_vmas() has to ensure early exit should we end up moving out of range.
We loop around, and hit:
/* Here vma->vm_start <= start < (end|vma->vm_end) */ tmp = vma->vm_end;
Oh dear. Now we have:
tmp
start end
| |
|----|-----|------|
|prev| vma | next |
|----|-----|------|We then invoke:
/* Here vma->vm_start <= start < tmp <= (end|vma->vm_end). */ error = visit(vma, &prev, start, tmp, arg);
Where start == tmp. That is, a zero range. This is not good.
We invoke visit() which is madvise_vma_behavior() which does not check the range (for good reason, it assumes all checks have been done before it was called), which in turn finally calls madvise_update_vma().
The madvise_update_vma() function calls vma_modify_flags_name() in turn, which ultimately invokes vma_modify() with... start == end.
vma_modify() calls vma_merge_existing_range() and finally we hit:
VM_WARN_ON_VMG(start >= end, vmg);
Which triggers, as start == end.
While it might be useful to add some CONFIG_DEBUG_VM asserts in these instances to catch this kind of error, since we have just eliminated any possibility of that happening, we will add such asserts separately as to reduce churn and aid backporting.
--- mm/vma.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
mm/vma.c +8 -4
@@ -1417,24 +1417,28 @@ int do_vmi_munmap(struct vma_iterator *vstatic struct vm_area_struct *vma_modify (struct vma_merge_struct *vmg) {struct vm_area_struct *vma = vmg->vma; +unsigned long start = vmg->start; +unsigned long end = vmg->end;struct vm_area_struct *merged;/* First, try to merge. */ merged =vma_merge_existing_range (vmg);if (merged)return merged; +if (vmg_nomem (vmg)) +return ERR_PTR (-ENOMEM );/* Split any preceding portion of the VMA. */ -if (vma->vm_start < vmg->start) { -int err =split_vma (vmg->vmi, vma, vmg->start,1 ); +if (vma->vm_start < start) { +int err =split_vma (vmg->vmi, vma, start,1 );if (err)return ERR_PTR (err); }/* Split any trailing portion of the VMA. */ -if (vma->vm_end > vmg->end) { -int err =split_vma (vmg->vmi, vma, vmg->end,0 ); +if (vma->vm_end > end) { +int err =split_vma (vmg->vmi, vma, end,0 );if (err)return ERR_PTR (err);
Greg Kroah-Hartman
maintainerPATCH 136/269 mm: memory-failure: update ttu flag inside unmap_poisoned_folio
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Wupeng <[email protected]>
commit b81679b1633aa43c0d973adfa816d78c1ed0d032 upstream.
Patch series "mm: memory_failure: unmap poisoned folio during migrate properly", v3.
Fix two bugs during folio migration if the folio is poisoned.
This patch (of 3):
Commit 6da6b1d4a7df ("mm/hwpoison: convert TTU_IGNORE_HWPOISON to TTU_HWPOISON") introduce TTU_HWPOISON to replace TTU_IGNORE_HWPOISON in order to stop send SIGBUS signal when accessing an error page after a memory error on a clean folio. However during page migration, anon folio must be set with TTU_HWPOISON during unmap_*(). For pagecache we need some policy just like the one in hwpoison_user_mappings to set this flag. So move this policy from hwpoison_user_mappings to unmap_poisoned_folio to handle this warning properly.
Warning will be produced during unamp poison folio with the following log:
------------[ cut here ]------------ WARNING: CPU: 1 PID: 365 at mm/rmap.c:1847 try_to_unmap_one+0x8fc/0xd3c Modules linked in: CPU: 1 UID: 0 PID: 365 Comm: bash Tainted: G W 6.13.0-rc1-00018-gacdb4bbda7ab #42 Tainted: [W]=WARN Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015 pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : try_to_unmap_one+0x8fc/0xd3c lr : try_to_unmap_one+0x3dc/0xd3c Call trace: try_to_unmap_one+0x8fc/0xd3c (P) try_to_unmap_one+0x3dc/0xd3c (L) rmap_walk_anon+0xdc/0x1f8 rmap_walk+0x3c/0x58 try_to_unmap+0x88/0x90 unmap_poisoned_folio+0x30/0xa8 do_migrate_range+0x4a0/0x568 offline_pages+0x5a4/0x670 memory_block_action+0x17c/0x374 memory_subsys_offline+0x3c/0x78 device_offline+0xa4/0xd0 state_store+0x8c/0xf0 dev_attr_store+0x18/0x2c sysfs_kf_write+0x44/0x54 kernfs_fop_write_iter+0x118/0x1a8 vfs_write+0x3a8/0x4bc ksys_write+0x6c/0xf8 __arm64_sys_write+0x1c/0x28 invoke_syscall+0x44/0x100 el0_svc_common.constprop.0+0x40/0xe0 do_el0_svc+0x1c/0x28 el0_svc+0x30/0xd0 el0t_64_sync_handler+0xc8/0xcc el0t_64_sync+0x198/0x19c ---[ end trace 0000000000000000 ]---
--- mm/internal.h | 5 ++-- mm/memory-failure.c | 63 +++++++++++++++++++++++++--------------------------- mm/memory_hotplug.c | 3 +- 3 files changed, 36 insertions(+), 35 deletions(-)
mm/internal.h +3 -2
@@ -1101,7 +1101,7 @@ static inline int find_next_best_node(in* mm/memory-failure.c */ #ifdef CONFIG_MEMORY_FAILURE -void unmap_poisoned_folio (struct folio *folio,enum ttu_flags ttu); +int unmap_poisoned_folio (struct folio *folio,unsigned long pfn,bool must_kill);void shake_folio (struct folio *folio);extern int hwpoison_filter (struct page *p);
@@ -1123,8 +1123,9 @@ void add_to_kill_ksm(struct task_structunsigned long page_mapped_in_vma (struct page *page,struct vm_area_struct *vma);#else -static inline void unmap_poisoned_folio (struct folio *folio,enum ttu_flags ttu) +static inline int unmap_poisoned_folio (struct folio *folio,unsigned long pfn,bool must_kill) { +return -EBUSY ; }#endif
mm/memory-failure.c +31 -32
101 lines not on this page · raw message
mm/memory_hotplug.c +2 -1
@@ -1806,7 +1806,8 @@ static void do_migrate_range(unsigned loif (WARN_ON (folio_test_lru (folio)))folio_isolate_lru (folio);if (folio_mapped (folio)) -unmap_poisoned_folio (folio,TTU_IGNORE_MLOCK ); +unmap_poisoned_folio (folio, pfn, false); +continue ; }
Greg Kroah-Hartman
maintainerPATCH 137/269 mm: dont skip arch_sync_kernel_mappings() in error paths
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Roberts <[email protected]>
commit 3685024edd270f7c791f993157d65d3c928f3d6e upstream.
Fix callers that previously skipped calling arch_sync_kernel_mappings() if an error occurred during a pgtable update. The call is still required to sync any pgtable updates that may have occurred prior to hitting the error condition.
These are theoretical bugs discovered during code review.
--- mm/memory.c | 6 ++++-- mm/vmalloc.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-)
mm/memory.c +4 -2
@@ -2957,8 +2957,10 @@ static int __apply_to_page_range(struct next =pgd_addr_end (addr, end);if (pgd_none (*pgd) && !create)continue ; -if (WARN_ON_ONCE (pgd_leaf (*pgd))) -return -EINVAL ; +if (WARN_ON_ONCE (pgd_leaf (*pgd))) { + err = -EINVAL ; +break ; + }if (!pgd_none (*pgd) &&WARN_ON_ONCE (pgd_bad (*pgd))) {if (!create)continue ;
mm/vmalloc.c +2 -2
@@ -586,13 +586,13 @@ static int vmap_small_pages_range_noflus mask |=PGTBL_PGD_MODIFIED ; err =vmap_pages_p4d_range (pgd, addr, next, prot, pages, &nr, &mask);if (err) -return err; +break ; }while (pgd++, addr = next, addr != end);if (mask &ARCH_PAGE_TABLE_SYNC_MASK )arch_sync_kernel_mappings (start, end); -return 0 ; +return err; }/*
Greg Kroah-Hartman
maintainerPATCH 138/269 mm: fix finish_fault() handling for large folios
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Geffon <[email protected]>
commit 34b82f33cf3f03bc39e9a205a913d790e1520ade upstream.
When handling faults for anon shmem finish_fault() will attempt to install ptes for the entire folio. Unfortunately if it encounters a single non-pte_none entry in that range it will bail, even if the pte that triggered the fault is still pte_none. When this situation happens the fault will be retried endlessly never making forward progress.
This patch fixes this behavior and if it detects that a pte in the range is not pte_none it will fall back to setting a single pte.
--- mm/memory.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
mm/memory.c +10 -5
@@ -5079,7 +5079,11 @@ vm_fault_t finish_fault(struct vm_faultbool is_cow = (vmf->flags &FAULT_FLAG_WRITE ) && !(vma->vm_flags &VM_SHARED );int type, nr_pages; -unsigned long addr = vmf->address; +unsigned long addr; +bool needs_fallback = false; + +fallback: + addr = vmf->address;/* Did we COW the page? */ if (is_cow)
@@ -5118,7 +5122,8 @@ vm_fault_t finish_fault(struct vm_fault* approach also applies to non-anonymous-shmem faults to avoid * inflating the RSS of the process. */ -if (!vma_is_anon_shmem (vma) ||unlikely (userfaultfd_armed (vma))) { +if (!vma_is_anon_shmem (vma) ||unlikely (userfaultfd_armed (vma)) || +unlikely (needs_fallback)) { nr_pages =1 ; }else if (nr_pages >1 ) {pgoff_t idx =folio_page_idx (folio, page);
@@ -5154,9 +5159,9 @@ vm_fault_t finish_fault(struct vm_fault ret =VM_FAULT_NOPAGE ; goto unlock; }else if (nr_pages >1 && !pte_range_none (vmf->pte, nr_pages)) { -update_mmu_tlb_range (vma, addr, vmf->pte, nr_pages); - ret =VM_FAULT_NOPAGE ; - goto unlock; + needs_fallback = true; +pte_unmap_unlock (vmf->pte, vmf->ptl); + goto fallback; }folio_ref_add (folio, nr_pages -1 );
Greg Kroah-Hartman
maintainerPATCH 139/269 hwpoison, memory_hotplug: lock folio before unmap hwpoisoned folio
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Wupeng <[email protected]>
commit af288a426c3e3552b62595c6138ec6371a17dbba upstream.
Commit b15c87263a69 ("hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined) add page poison checks in do_migrate_range in order to make offline hwpoisoned page possible by introducing isolate_lru_page and try_to_unmap for hwpoisoned page. However folio lock must be held before calling try_to_unmap. Add it to fix this problem.
Warning will be produced if folio is not locked during unmap:
------------[ cut here ]------------ kernel BUG at ./include/linux/swapops.h:400! Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP Modules linked in: CPU: 4 UID: 0 PID: 411 Comm: bash Tainted: G W 6.13.0-rc1-00016-g3c434c7ee82a-dirty #41 Tainted: [W]=WARN Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015 pstate: 40400005 (nZcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : try_to_unmap_one+0xb08/0xd3c lr : try_to_unmap_one+0x3dc/0xd3c Call trace: try_to_unmap_one+0xb08/0xd3c (P) try_to_unmap_one+0x3dc/0xd3c (L) rmap_walk_anon+0xdc/0x1f8 rmap_walk+0x3c/0x58 try_to_unmap+0x88/0x90 unmap_poisoned_folio+0x30/0xa8 do_migrate_range+0x4a0/0x568 offline_pages+0x5a4/0x670 memory_block_action+0x17c/0x374 memory_subsys_offline+0x3c/0x78 device_offline+0xa4/0xd0 state_store+0x8c/0xf0 dev_attr_store+0x18/0x2c sysfs_kf_write+0x44/0x54 kernfs_fop_write_iter+0x118/0x1a8 vfs_write+0x3a8/0x4bc ksys_write+0x6c/0xf8 __arm64_sys_write+0x1c/0x28 invoke_syscall+0x44/0x100 el0_svc_common.constprop.0+0x40/0xe0 do_el0_svc+0x1c/0x28 el0_svc+0x30/0xd0 el0t_64_sync_handler+0xc8/0xcc el0t_64_sync+0x198/0x19c Code: f9407be0 b5fff320 d4210000 17ffff97 (d4210000) ---[ end trace 0000000000000000 ]---
--- mm/memory_hotplug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
mm/memory_hotplug.c +4 -1
@@ -1805,8 +1805,11 @@ static void do_migrate_range(unsigned lo (folio_test_large(folio) && folio_test_has_hwpoisoned(folio))) {if (WARN_ON (folio_test_lru (folio)))folio_isolate_lru (folio); -if (folio_mapped (folio)) +if (folio_mapped (folio)) { +folio_lock (folio);unmap_poisoned_folio (folio, pfn, false); +folio_unlock (folio); + }continue ; }
Greg Kroah-Hartman
maintainerPATCH 140/269 mm: memory-hotplug: check folio ref count first in do_migrate_range
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Wupeng <[email protected]>
commit 773b9a6aa6d38894b95088e3ed6f8a701d9f50fd upstream.
If a folio has an increased reference count, folio_try_get() will acquire it, perform necessary operations, and then release it. In the case of a poisoned folio without an elevated reference count (which is unlikely for memory-failure), folio_try_get() will simply bypass it.
Therefore, relocate the folio_try_get() function, responsible for checking and acquiring this reference count at first.
--- mm/memory_hotplug.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
mm/memory_hotplug.c +7 -13
@@ -1795,12 +1795,12 @@ static void do_migrate_range(unsigned loif (folio_test_large (folio)) pfn =folio_pfn (folio) +folio_nr_pages (folio) -1 ; -/* -* HWPoison pages have elevated reference counts so the migration would -* fail on them. It also doesn't make any sense to migrate them in the -* first place. Still try to unmap such a page in case it is still mapped -* (keep the unmap as the catch all safety net). -*/ +if (!folio_try_get (folio)) +continue ; + +if (unlikely (page_folio (page) != folio)) + goto put_folio; +if (folio_test_hwpoison (folio) || (folio_test_large (folio) &&folio_test_has_hwpoisoned (folio))) {if (WARN_ON (folio_test_lru (folio)))
@@ -1811,14 +1811,8 @@ static void do_migrate_range(unsigned lofolio_unlock (folio); } -continue ; - } - -if (!folio_try_get (folio)) -continue ; - -if (unlikely (page_folio (page) != folio)) goto put_folio; + }if (!isolate_folio_to_list (folio, &source)) {if (__ratelimit (&migrate_rs)) {
Greg Kroah-Hartman
maintainerPATCH 141/269 wifi: iwlwifi: mvm: clean up ROC on failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit f9751163bffd3fe60794929829f810968c6de73d ]
If the firmware fails to start the session protection, then we do call iwl_mvm_roc_finished() here, but that won't do anything at all because IWL_MVM_STATUS_ROC_P2P_RUNNING was never set. Set IWL_MVM_STATUS_ROC_P2P_RUNNING in the failure/stop path. If it started successfully before, it's already set, so that doesn't matter, and if it didn't start it needs to be set to clean up.
Not doing so will lead to a WARN_ON() later on a fresh remain- on-channel, since the link is already active when activated as it was never deactivated.
--- drivers/net/wireless/intel/iwlwifi/mvm/time-event.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c +2 -0
@@ -1030,6 +1030,8 @@ void iwl_mvm_rx_session_protect_notif(struct iwl_mvm *mvm,/* End TE, notify mac80211 */ mvmvif->time_event_data.id =SESSION_PROTECT_CONF_MAX_ID ; mvmvif->time_event_data.link_id =-1 ; +/* set the bit so the ROC cleanup will actually clean up */ +set_bit (IWL_MVM_STATUS_ROC_P2P_RUNNING , &mvm->status);iwl_mvm_roc_finished (mvm);ieee80211_remain_on_channel_expired (mvm->hw); }else if (le32_to_cpu (notif->start)) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 142/269 wifi: iwlwifi: mvm: dont try to talk to a dead firmware
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit d73d2c6e3313f0ba60711ab4f4b9044eddca9ca5 ]
This fixes:
bad state = 0
WARNING: CPU: 10 PID: 702 at drivers/net/wireless/inel/iwlwifi/iwl-trans.c:178 iwl_trans_send_cmd+0xba/0xe0 [iwlwifi] Call Trace: <TASK> ? __warn+0xca/0x1c0 ? iwl_trans_send_cmd+0xba/0xe0 [iwlwifi 64fa9ad799a0e0d2ba53d4af93a53ad9a531f8d4] iwl_fw_dbg_clear_monitor_buf+0xd7/0x110 [iwlwifi 64fa9ad799a0e0d2ba53d4af93a53ad9a531f8d4] _iwl_dbgfs_fw_dbg_clear_write+0xe2/0x120 [iwlmvm 0e8adb18cea92d2c341766bcc10b18699290068a]
Ask whether the firmware is alive before sending a command.
--- drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +7 -0
@@ -1518,6 +1518,13 @@ static ssize_t iwl_dbgfs_fw_dbg_clear_write(struct iwl_mvm *mvm,if (mvm->trans->trans_cfg->device_family <IWL_DEVICE_FAMILY_9000 )return -EOPNOTSUPP ; +/* +* If the firmware is not running, silently succeed since there is +* no data to clear. +*/ +if (!iwl_mvm_firmware_running (mvm)) +return count; +mutex_lock (&mvm->mutex);iwl_fw_dbg_clear_monitor_buf (&mvm->fwrt);mutex_unlock (&mvm->mutex);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 143/269 wifi: iwlwifi: limit printed string from FW file
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit e0dc2c1bef722cbf16ae557690861e5f91208129 ]
There's no guarantee here that the file is always with a NUL-termination, so reading the string may read beyond the end of the TLV. If that's the last TLV in the file, it can perhaps even read beyond the end of the file buffer.
Fix that by limiting the print format to the size of the buffer we have.
--- drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/iwl-drv.c +1 -1
@@ -1197,7 +1197,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,if (tlv_len !=sizeof (*fseq_ver)) goto invalid_tlv_len; -IWL_INFO (drv,"TLV_FW_FSEQ_VERSION: %s\n" , +IWL_INFO (drv,"TLV_FW_FSEQ_VERSION: %.32s\n" , fseq_ver->version); }break ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 144/269 wifi: iwlwifi: Free pages allocated when failing to build A-MSDU
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilan Peer <[email protected]>
[ Upstream commit 3b08e608d50c44ca1135beed179f266aa0461da7 ]
When failing to prepare the data needed for A-MSDU transmission, the memory allocated for the TSO management was not freed. Fix it.
--- drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c +1 -0
@@ -347,6 +347,7 @@ iwl_tfh_tfd *iwl_txq_gen2_build_tx_amsdu(struct iwl_trans *trans,return tfd; out_err: +iwl_pcie_free_tso_pages (trans, skb, out_meta);iwl_txq_gen2_tfd_unmap (trans, out_meta, tfd);return NULL ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 145/269 wifi: iwlwifi: Fix A-MSDU TSO preparation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilan Peer <[email protected]>
[ Upstream commit 3640dbc1f75ce15d128ea4af44226960d894f3fd ]
The TSO preparation assumed that the skb head contained the headers while the rest of the data was in the fragments. Since this is not always true, e.g., it is possible that the data was linearised, modify the TSO preparation to start the data processing after the network headers.
--- .../wireless/intel/iwlwifi/pcie/internal.h | 5 +++-- .../net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 5 +++-- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 20 +++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/internal.h +3 -2
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* -* Copyright (C) 2003-2015, 2018-2024 Intel Corporation +* Copyright (C) 2003-2015, 2018-2025 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2016-2017 Intel Deutschland GmbH */
@@ -643,7 +643,8 @@ dma_addr_t iwl_pcie_get_sgt_tb_phys(struct sg_table *sgt, unsigned int offset, unsigned int len);struct sg_table *iwl_pcie_prep_tso (struct iwl_trans *trans,struct sk_buff *skb,struct iwl_cmd_meta *cmd_meta, -u8 **hdr,unsigned int hdr_room); +u8 **hdr,unsigned int hdr_room, +unsigned int offset);void iwl_pcie_free_tso_pages (struct iwl_trans *trans,struct sk_buff *skb,struct iwl_cmd_meta *cmd_meta);
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c +3 -2
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* * Copyright (C) 2017 Intel Deutschland GmbH -* Copyright (C) 2018-2020, 2023-2024 Intel Corporation +* Copyright (C) 2018-2020, 2023-2025 Intel Corporation */ #include <net/tso.h> #include <linux/tcp.h>
@@ -188,7 +188,8 @@ static int iwl_txq_gen2_build_amsdu(struct iwl_trans *trans, (3 + snap_ip_tcp_hdrlen +sizeof (struct ethhdr ));/* Our device supports 9 segments at most, it will fit in 1 page */ - sgt =iwl_pcie_prep_tso (trans, skb, out_meta, &start_hdr, hdr_room); + sgt =iwl_pcie_prep_tso (trans, skb, out_meta, &start_hdr, hdr_room, + snap_ip_tcp_hdrlen + hdr_len);if (!sgt)return -ENOMEM ;
drivers/net/wireless/intel/iwlwifi/pcie/tx.c +12 -8
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* -* Copyright (C) 2003-2014, 2018-2021, 2023-2024 Intel Corporation +* Copyright (C) 2003-2014, 2018-2021, 2023-2025 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2016-2017 Intel Deutschland GmbH */
@@ -1853,6 +1853,7 @@ dma_addr_t iwl_pcie_get_sgt_tb_phys(struct sg_table *sgt, unsigned int offset,* @cmd_meta: command meta to store the scatter list information for unmapping * @hdr: output argument for TSO headers * @hdr_room: requested length for TSO headers +* @offset: offset into the data from which mapping should start * * Allocate space for a scatter gather list and TSO headers and map the SKB * using the scatter gather list. The SKB is unmapped again when the page is
@@ -1862,18 +1863,20 @@ dma_addr_t iwl_pcie_get_sgt_tb_phys(struct sg_table *sgt, unsigned int offset,*/ struct sg_table *iwl_pcie_prep_tso (struct iwl_trans *trans,struct sk_buff *skb,struct iwl_cmd_meta *cmd_meta, -u8 **hdr,unsigned int hdr_room) +u8 **hdr,unsigned int hdr_room, +unsigned int offset) {struct sg_table *sgt; +unsigned int n_segments;if (WARN_ON_ONCE (skb_has_frag_list (skb)))return NULL ; + n_segments =DIV_ROUND_UP (skb->len - offset,skb_shinfo (skb)->gso_size); *hdr =iwl_pcie_get_page_hdr (trans, hdr_room + __alignof__(struct sg_table ) +sizeof (struct sg_table ) + - (skb_shinfo (skb)->nr_frags +1 ) * -sizeof (struct scatterlist ), + n_segments *sizeof (struct scatterlist ), skb);if (!*hdr)return NULL ;
@@ -1881,11 +1884,11 @@ struct sg_table *iwl_pcie_prep_tso(struct iwl_trans *trans, struct sk_buff *skb, sgt = (void *)PTR_ALIGN (*hdr + hdr_room, __alignof__(struct sg_table )); sgt->sgl = (void *)(sgt +1 ); -sg_init_table (sgt->sgl,skb_shinfo (skb)->nr_frags +1 ); +sg_init_table (sgt->sgl, n_segments);/* Only map the data, not the header (it is copied to the TSO page) */ - sgt->orig_nents =skb_to_sgvec (skb, sgt->sgl,skb_headlen (skb), - skb->data_len); + sgt->orig_nents =skb_to_sgvec (skb, sgt->sgl, offset, + skb->len - offset);if (WARN_ON_ONCE (sgt->orig_nents <=0 ))return NULL ;
@@ -1937,7 +1940,8 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb, (3 + snap_ip_tcp_hdrlen +sizeof (struct ethhdr )) + iv_len;/* Our device supports 9 segments at most, it will fit in 1 page */ - sgt =iwl_pcie_prep_tso (trans, skb, out_meta, &start_hdr, hdr_room); + sgt =iwl_pcie_prep_tso (trans, skb, out_meta, &start_hdr, hdr_room, + snap_ip_tcp_hdrlen + hdr_len + iv_len);if (!sgt)return -ENOMEM ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 146/269 HID: google: fix unused variable warning under !CONFIG_ACPI
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu-Chun Lin <[email protected]>
[ Upstream commit 4bd0725c09f377ffaf22b834241f6c050742e4fc ]
As reported by the kernel test robot, the following warning occurs:
Quoted 1 line
Quoted 1 line
drivers/hid/hid-google-hammer.c:261:36: warning: 'cbas_ec_acpi_ids' defined but not used [-Wunused-const-variable=]
261 | static const struct acpi_device_id cbas_ec_acpi_ids[] = {
| ^~~~~~~~~~~~~~~~The 'cbas_ec_acpi_ids' array is only used when CONFIG_ACPI is enabled. Wrapping its definition and 'MODULE_DEVICE_TABLE' in '#ifdef CONFIG_ACPI' prevents a compiler warning when ACPI is disabled.
--- drivers/hid/hid-google-hammer.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-google-hammer.c +2 -0
@@ -268,11 +268,13 @@ static void cbas_ec_remove(struct platform_device *pdev)mutex_unlock (&cbas_ec_reglock); } +#ifdef CONFIG_ACPI static const struct acpi_device_id cbas_ec_acpi_ids[] = { {"GOOG000B" ,0 }, { } };MODULE_DEVICE_TABLE (acpi, cbas_ec_acpi_ids); +#endif #ifdef CONFIG_OF static const struct of_device_id cbas_ec_of_match[] = {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 147/269 HID: intel-ish-hid: Fix use-after-free issue in hid_ishtp_cl_remove()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Lixu <[email protected]>
[ Upstream commit 823987841424289339fdb4ba90e6d2c3792836db ]
During the rmmod operation for the intel_ishtp_hid driver, a use-after-free issue can occur in the hid_ishtp_cl_remove() function. The function hid_ishtp_cl_deinit() is called before ishtp_hid_remove(), which can lead to accessing freed memory or resources during the removal process.
Call Trace: ? ishtp_cl_send+0x168/0x220 [intel_ishtp] ? hid_output_report+0xe3/0x150 [hid] hid_ishtp_set_feature+0xb5/0x120 [intel_ishtp_hid] ishtp_hid_request+0x7b/0xb0 [intel_ishtp_hid] hid_hw_request+0x1f/0x40 [hid] sensor_hub_set_feature+0x11f/0x190 [hid_sensor_hub] _hid_sensor_power_state+0x147/0x1e0 [hid_sensor_trigger] hid_sensor_runtime_resume+0x22/0x30 [hid_sensor_trigger] sensor_hub_remove+0xa8/0xe0 [hid_sensor_hub] hid_device_remove+0x49/0xb0 [hid] hid_destroy_device+0x6f/0x90 [hid] ishtp_hid_remove+0x42/0x70 [intel_ishtp_hid] hid_ishtp_cl_remove+0x6b/0xb0 [intel_ishtp_hid] ishtp_cl_device_remove+0x4a/0x60 [intel_ishtp] ...
Additionally, ishtp_hid_remove() is a HID level power off, which should occur before the ISHTP level disconnect.
This patch resolves the issue by reordering the calls in hid_ishtp_cl_remove(). The function ishtp_hid_remove() is now called before hid_ishtp_cl_deinit().
--- drivers/hid/intel-ish-hid/ishtp-hid-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/intel-ish-hid/ishtp-hid-client.c +1 -1
@@ -833,9 +833,9 @@ static void hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device) hid_ishtp_cl);dev_dbg (ishtp_device (cl_device),"%s\n" , __func__); -hid_ishtp_cl_deinit (hid_ishtp_cl);ishtp_put_device (cl_device);ishtp_hid_remove (client_data); +hid_ishtp_cl_deinit (hid_ishtp_cl); hid_ishtp_cl =NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 148/269 HID: intel-ish-hid: Fix use-after-free issue in ishtp_hid_remove()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Lixu <[email protected]>
[ Upstream commit 07583a0010696a17fb0942e0b499a62785c5fc9f ]
The system can experience a random crash a few minutes after the driver is removed. This issue occurs due to improper handling of memory freeing in the ishtp_hid_remove() function.
The function currently frees the driver_data directly within the loop that destroys the HID devices, which can lead to accessing freed memory. Specifically, hid_destroy_device() uses driver_data when it calls hid_ishtp_set_feature() to power off the sensor, so freeing driver_data beforehand can result in accessing invalid memory.
This patch resolves the issue by storing the driver_data in a temporary variable before calling hid_destroy_device(), and then freeing the driver_data after the device is destroyed.
--- drivers/hid/intel-ish-hid/ishtp-hid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hid/intel-ish-hid/ishtp-hid.c +3 -1
@@ -261,12 +261,14 @@ int ishtp_hid_probe(unsigned int cur_hid_dev,*/ void ishtp_hid_remove (struct ishtp_cl_data *client_data) { +void *data;int i;for (i =0 ; i < client_data->num_hid_devices; ++i) {if (client_data->hid_sensor_hubs[i]) { -kfree (client_data->hid_sensor_hubs[i]->driver_data); + data = client_data->hid_sensor_hubs[i]->driver_data;hid_destroy_device (client_data->hid_sensor_hubs[i]); +kfree (data); client_data->hid_sensor_hubs[i] =NULL ; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 149/269 coredump: Only sort VMAs when core_sort_vma sysctl is set
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 39ec9eaaa165d297d008d1fa385748430bd18e4d ]
The sorting of VMAs by size in commit 7d442a33bfe8 ("binfmt_elf: Dump smaller VMAs first in ELF cores") breaks elfutils[1]. Instead, sort based on the setting of the new sysctl, core_sort_vma, which defaults to 0, no sorting.
--- Documentation/admin-guide/sysctl/kernel.rst | 11 +++++++++++ fs/coredump.c | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-)
Documentation/admin-guide/sysctl/kernel.rst +11 -0
@@ -212,6 +212,17 @@ pid>/``). This value defaults to 0. +core_sort_vma +============= + +The default coredump writes VMAs in address order. By setting +``core_sort_vma`` to 1, VMAs will be written from smallest size +to largest size. This is known to break at least elfutils, but +can be handy when dealing with very large (and truncated) +coredumps where the more useful debugging details are included +in the smaller VMAs. + + core_uses_pid =============
fs/coredump.c +13 -2
@@ -63,6 +63,7 @@ static void free_vma_snapshot(struct coredump_params *cprm);static int core_uses_pid;static unsigned int core_pipe_limit; +static unsigned int core_sort_vma;static char core_pattern[CORENAME_MAX_SIZE ] ="core" ;static int core_name_size =CORENAME_MAX_SIZE ;unsigned int core_file_note_size_limit =CORE_FILE_NOTE_SIZE_DEFAULT ;
@@ -1025,6 +1026,15 @@ static struct ctl_table coredump_sysctls[] = { .extra1 = (unsigned int *)&core_file_note_size_min, .extra2 = (unsigned int *)&core_file_note_size_max, }, + { + .procname = "core_sort_vma", + .data = &core_sort_vma, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_douintvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, };static int __init init_fs_coredump_sysctls (void )
@@ -1255,8 +1265,9 @@ static bool dump_vma_snapshot(struct coredump_params *cprm) cprm->vma_data_size += m->dump_size; } -sort (cprm->vma_meta, cprm->vma_count,sizeof (*cprm->vma_meta), - cmp_vma_size,NULL ); +if (core_sort_vma) +sort (cprm->vma_meta, cprm->vma_count,sizeof (*cprm->vma_meta), + cmp_vma_size,NULL );return true; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 150/269 nvme-pci: add support for sgl metadata
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 979c6342f9c0a48696a6420f14f9dd409591657f ]
Supporting this mode allows creating and merging multi-segment metadata requests that wouldn't be possible otherwise. It also allows directly using user space requests that straddle physically discontiguous pages.
Stable-dep-of: 00817f0f1c45 ("nvme-ioctl: fix leaked requests on mapping error")
--- drivers/nvme/host/nvme.h | 7 ++ drivers/nvme/host/pci.c | 144 +++++++++++++++++++++++++++++++++++---- include/linux/nvme.h | 1 + 3 files changed, 137 insertions(+), 15 deletions(-)
drivers/nvme/host/nvme.h +7 -0
@@ -1130,6 +1130,13 @@ static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)return ctrl->sgls & ((1 <<0 ) | (1 <<1 )); } +static inline bool nvme_ctrl_meta_sgl_supported (struct nvme_ctrl *ctrl) +{ +if (ctrl->ops->flags &NVME_F_FABRICS ) +return true; +return ctrl->sgls &NVME_CTRL_SGLS_MSDS ; +} +#ifdef CONFIG_NVME_HOST_AUTH int __init nvme_init_auth (void ); void __exit nvme_exit_auth(void);
drivers/nvme/host/pci.c +129 -15
261 lines not on this page · raw message
include/linux/nvme.h +1 -0
@@ -388,6 +388,7 @@ enum {NVME_CTRL_CTRATT_PREDICTABLE_LAT =1 <<5 ,NVME_CTRL_CTRATT_NAMESPACE_GRANULARITY =1 <<7 ,NVME_CTRL_CTRATT_UUID_LIST =1 <<9 , + NVME_CTRL_SGLS_MSDS = 1 << 19, }; struct nvme_lbaf {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 151/269 nvme-pci: use sgls for all user requests if possible
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 6fad84a4d624c300d03ebba457cc641765050c43 ]
If the device supports SGLs, use these for all user requests. This format encodes the expected transfer length so it can catch short buffer errors in a user command, whether it occurred accidently or maliciously.
For controllers that support SGL data mode, this is a viable mitigation to CVE-2023-6238. For controllers that don't support SGLs, log a warning in the passthrough path since not having the capability can corrupt data if the interface is not used correctly.
Stable-dep-of: 00817f0f1c45 ("nvme-ioctl: fix leaked requests on mapping error")
--- drivers/nvme/host/ioctl.c | 12 ++++++++++-- drivers/nvme/host/pci.c | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/nvme/host/ioctl.c +10 -2
@@ -120,12 +120,20 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,struct nvme_ns *ns = q->queuedata;struct block_device *bdev = ns ? ns->disk->part0 :NULL ;bool supports_metadata = bdev &&blk_get_integrity (bdev->bd_disk); +struct nvme_ctrl *ctrl =nvme_req (req)->ctrl;bool has_metadata = meta_buffer && meta_len;struct bio *bio =NULL ;int ret; -if (has_metadata && !supports_metadata) -return -EINVAL ; +if (!nvme_ctrl_sgl_supported (ctrl)) +dev_warn_once (ctrl->device,"using unchecked data buffer\n" ); +if (has_metadata) { +if (!supports_metadata) +return -EINVAL ; +if (!nvme_ctrl_meta_sgl_supported (ctrl)) +dev_warn_once (ctrl->device, +"using unchecked metadata buffer\n" ); + }if (ioucmd && (ioucmd->flags &IORING_URING_CMD_FIXED )) {struct iov_iter iter;
drivers/nvme/host/pci.c +3 -2
@@ -514,7 +514,8 @@ static inline bool nvme_pci_metadata_use_sgls(struct nvme_dev *dev, {if (!nvme_ctrl_meta_sgl_supported (&dev->ctrl))return false; -return req->nr_integrity_segments >1 ; +return req->nr_integrity_segments >1 || +nvme_req (req)->flags &NVME_REQ_USERCMD ; } static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req,
@@ -532,7 +533,7 @@ static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req,if (nvme_pci_metadata_use_sgls (dev, req))return true;if (!sgl_threshold || avg_seg_size < sgl_threshold) -return false; +return nvme_req (req)->flags &NVME_REQ_USERCMD ;return true; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 152/269 nvme-ioctl: fix leaked requests on mapping error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 00817f0f1c45b007965f5676b9a2013bb39c7228 ]
All the callers assume nvme_map_user_request() frees the request on a failure. This wasn't happening on invalid metadata or io_uring command flags, so we've been leaking those requests.
--- drivers/nvme/host/ioctl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/nvme/host/ioctl.c +8 -4
@@ -128,8 +128,10 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,if (!nvme_ctrl_sgl_supported (ctrl))dev_warn_once (ctrl->device,"using unchecked data buffer\n" );if (has_metadata) { -if (!supports_metadata) -return -EINVAL ; +if (!supports_metadata) { + ret = -EINVAL ; + goto out; + }if (!nvme_ctrl_meta_sgl_supported (ctrl))dev_warn_once (ctrl->device,"using unchecked metadata buffer\n" );
@@ -139,8 +141,10 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,struct iov_iter iter;/* fixedbufs is only for non-vectored io */ -if (WARN_ON_ONCE (flags &NVME_IOCTL_VEC )) -return -EINVAL ; +if (WARN_ON_ONCE (flags &NVME_IOCTL_VEC )) { + ret = -EINVAL ; + goto out; + } ret =io_uring_cmd_import_fixed (ubuffer, bufflen,rq_data_dir (req), &iter, ioucmd);if (ret <0 )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 153/269 wifi: mac80211: Support parsing EPCS ML element
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilan Peer <[email protected]>
[ Upstream commit 24711d60f8492a30622e419cee643d59264ea939 ]
Add support for parsing an ML element of type EPCS priority access, which can optionally be included in EHT protected action frames used to configure EPCS.
Stable-dep-of: 99ca2c28e6b6 ("wifi: mac80211: fix MLE non-inheritance parsing")
--- net/mac80211/ieee80211_i.h | 2 ++ net/mac80211/parse.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
net/mac80211/ieee80211_i.h +2 -0
@@ -1751,6 +1751,7 @@ struct ieee802_11_elems {const struct ieee80211_eht_operation *eht_operation;const struct ieee80211_multi_link_elem *ml_basic;const struct ieee80211_multi_link_elem *ml_reconf; +const struct ieee80211_multi_link_elem *ml_epcs;const struct ieee80211_bandwidth_indication *bandwidth_indication;const struct ieee80211_ttlm_elem *ttlm[IEEE80211_TTLM_MAX_CNT ];
@@ -1781,6 +1782,7 @@ struct ieee802_11_elems {/* mult-link element can be de-fragmented and thus u8 is not sufficient */ size_t ml_basic_len;size_t ml_reconf_len; +size_t ml_epcs_len;u8 ttlm_num;
net/mac80211/parse.c +29 -0
@@ -44,6 +44,9 @@ struct ieee80211_elems_parse {/* The reconfiguration Multi-Link element in the original elements */ const struct element *ml_reconf_elem; +/* The EPCS Multi-Link element in the original elements */ +const struct element *ml_epcs_elem; +/* * scratch buffer that can be used for various element parsing related * tasks, e.g., element de-fragmentation etc.
@@ -159,6 +162,9 @@ ieee80211_parse_extension_element(u32 *crc,case IEEE80211_ML_CONTROL_TYPE_RECONF : elems_parse->ml_reconf_elem = elem;break ; +case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS : + elems_parse->ml_epcs_elem = elem; +break ;default :break ; }
@@ -943,6 +949,27 @@ ieee80211_mle_defrag_reconf(struct ieee80211_elems_parse *elems_parse) elems_parse->scratch_pos += ml_len; } +static void +ieee80211_mle_defrag_epcs (struct ieee80211_elems_parse *elems_parse) +{ +struct ieee802_11_elems *elems = &elems_parse->elems; +ssize_t ml_len; + + ml_len =cfg80211_defragment_element (elems_parse->ml_epcs_elem, + elems->ie_start, + elems->total_len, + elems_parse->scratch_pos, + elems_parse->scratch + + elems_parse->scratch_len - + elems_parse->scratch_pos, +WLAN_EID_FRAGMENT ); +if (ml_len <0 ) +return ; + elems->ml_epcs = (void *)elems_parse->scratch_pos; + elems->ml_epcs_len = ml_len; + elems_parse->scratch_pos += ml_len; +} +struct ieee802_11_elems *ieee802_11_parse_elems_full (struct ieee80211_elems_parse_params *params) {
@@ -1001,6 +1028,8 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params)ieee80211_mle_defrag_reconf (elems_parse); +ieee80211_mle_defrag_epcs (elems_parse); +if (elems->tim && !elems->parse_error) {const struct ieee80211_tim_ie *tim_ie = elems->tim;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 154/269 wifi: mac80211: fix MLE non-inheritance parsing
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 99ca2c28e6b68084a0fb65585df09b9e28c3ec16 ]
The code is erroneously applying the non-inheritance element to the inner elements rather than the outer, which is clearly completely wrong. Fix it by finding the MLE basic element at the beginning, and then applying the non-inheritance for the outer parsing.
While at it, do some general cleanups such as not allowing callers to try looking for a specific non-transmitted BSS and link at the same time.
--- net/mac80211/mlme.c | 1 + net/mac80211/parse.c | 127 ++++++++++++++++++++++++++++--------------- 2 files changed, 83 insertions(+), 45 deletions(-)
net/mac80211/mlme.c +1 -0
@@ -4733,6 +4733,7 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link, parse_params.start = bss_ies->data; parse_params.len = bss_ies->len; parse_params.bss = cbss; + parse_params.link_id =-1 ; bss_elems =ieee802_11_parse_elems_full (&parse_params);if (!bss_elems) { ret = false;
net/mac80211/parse.c +82 -45
209 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 155/269 wifi: mac80211: fix vendor-specific inheritance
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 130067e9c13bdc4820748ef16076a6972364745f ]
If there's any vendor-specific element in the subelements then the outer element parsing must not parse any vendor element at all. This isn't implemented correctly now due to parsing into the pointers and then overriding them, so explicitly skip vendor elements if any exist in the sub- elements (non-transmitted profile or per-STA profile).
--- net/mac80211/parse.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/mac80211/parse.c +8 -0
@@ -48,6 +48,7 @@ struct ieee80211_elems_parse {const struct element *ml_epcs_elem;bool multi_link_inner; +bool skip_vendor;/* * scratch buffer that can be used for various element parsing related
@@ -400,6 +401,9 @@ _ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params,IEEE80211_PARSE_ERR_BAD_ELEM_SIZE ;break ;case WLAN_EID_VENDOR_SPECIFIC : +if (elems_parse->skip_vendor) +break ; +if (elen >=4 && pos[0 ] ==0x00 && pos[1 ] ==0x50 && pos[2 ] ==0xf2 ) {/* Microsoft OUI (00:50:F2) */
@@ -1054,12 +1058,16 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params) multi_link_inner = true; } + elems_parse->skip_vendor = +cfg80211_find_elem (WLAN_EID_VENDOR_SPECIFIC , + sub.start, sub.len); elems->crc =_ieee802_11_parse_elems_full (params, elems_parse, non_inherit);/* Override with nontransmitted/per-STA profile if found */ if (sub.len) { elems_parse->multi_link_inner = multi_link_inner; + elems_parse->skip_vendor = false;_ieee802_11_parse_elems_full (&sub, elems_parse,NULL ); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 156/269 drm/fbdev-helper: Move color-mode lookup into 4CC format helper
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit eb1f4adf9101573fc2347978a60d71c4f1176cca ]
The color mode as specified on the kernel command line gives the user's preferred color depth and number of bits per pixel. Move the color-mode-to-format conversion from fbdev helpers into a 4CC helper, so that it can be shared among DRM clients.
v2:
- fix grammar in commit message (Laurent)
Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
--- drivers/gpu/drm/drm_fb_helper.c | 70 +++++++-------------------------- drivers/gpu/drm/drm_fourcc.c | 30 +++++++++++++- include/drm/drm_fourcc.h | 1 + 3 files changed, 45 insertions(+), 56 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +15 -55
@@ -1443,67 +1443,27 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,EXPORT_SYMBOL (drm_fb_helper_pan_display);static uint32_t drm_fb_helper_find_format (struct drm_fb_helper *fb_helper,const uint32_t *formats, -size_t format_count,uint32_t bpp,uint32_t depth) +size_t format_count,unsigned int color_mode) {struct drm_device *dev = fb_helper->dev;uint32_t format;size_t i; -/* -* Do not consider YUV or other complicated formats -* for framebuffers. This means only legacy formats -* are supported (fmt->depth is a legacy field), but -* the framebuffer emulation can only deal with such -* formats, specifically RGB/BGA formats. -*/ - format =drm_mode_legacy_fb_format (bpp, depth); -if (!format) - goto err; + format =drm_driver_color_mode_format (dev, color_mode); +if (!format) { +drm_info (dev,"unsupported color mode of %d\n" , color_mode); +return DRM_FORMAT_INVALID ; + }for (i =0 ; i < format_count; ++i) {if (formats[i] == format)return format; } - -err: -/* We found nothing. */ -drm_warn (dev,"bpp/depth value of %u/%u not supported\n" , bpp, depth); +drm_warn (dev,"format %p4cc not supported\n" , &format);return DRM_FORMAT_INVALID ; } -static uint32_t drm_fb_helper_find_color_mode_format (struct drm_fb_helper *fb_helper, -const uint32_t *formats,size_t format_count, -unsigned int color_mode) -{ -struct drm_device *dev = fb_helper->dev; -uint32_t bpp, depth; - -switch (color_mode) { -case 1 : -case 2 : -case 4 : -case 8 : -case 16 : -case 24 : - bpp = depth = color_mode; -break ; -case 15 : - bpp =16 ; - depth =15 ; -break ; -case 32 : - bpp =32 ; - depth =24 ; -break ; -default : -drm_info (dev,"unsupported color mode of %d\n" , color_mode); -return DRM_FORMAT_INVALID ; - } - -return drm_fb_helper_find_format (fb_helper, formats, format_count, bpp, depth); -} -static int __drm_fb_helper_find_sizes (struct drm_fb_helper *fb_helper,struct drm_fb_helper_surface_size *sizes) {
@@ -1533,10 +1493,10 @@ static int __drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper,if (!cmdline_mode->bpp_specified)continue ; - surface_format =drm_fb_helper_find_color_mode_format (fb_helper, - plane->format_types, - plane->format_count, - cmdline_mode->bpp); + surface_format =drm_fb_helper_find_format (fb_helper, + plane->format_types, + plane->format_count, + cmdline_mode->bpp);if (surface_format !=DRM_FORMAT_INVALID )break ;/* found supported format */ }
@@ -1546,10 +1506,10 @@ static int __drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper,break ;/* found supported format */ /* try preferred color mode */ - surface_format =drm_fb_helper_find_color_mode_format (fb_helper, - plane->format_types, - plane->format_count, - fb_helper->preferred_bpp); + surface_format =drm_fb_helper_find_format (fb_helper, + plane->format_types, + plane->format_count, + fb_helper->preferred_bpp);if (surface_format !=DRM_FORMAT_INVALID )break ;/* found supported format */ }
drivers/gpu/drm/drm_fourcc.c +29 -1
@@ -36,7 +36,6 @@* @depth: bit depth per pixel * * Computes a drm fourcc pixel format code for the given @bpp/@depth values. -* Useful in fbdev emulation code, since that deals in those values. */ uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth) {
@@ -140,6 +139,35 @@ uint32_t drm_driver_legacy_fb_format(struct drm_device *dev, }EXPORT_SYMBOL (drm_driver_legacy_fb_format); +/** +* drm_driver_color_mode_format - Compute DRM 4CC code from color mode +* @dev: DRM device +* @color_mode: command-line color mode +* +* Computes a DRM 4CC pixel format code for the given color mode using +* drm_driver_color_mode(). The color mode is in the format used and the +* kernel command line. It specifies the number of bits per pixel +* and color depth in a single value. +* +* Useful in fbdev emulation code, since that deals in those values. The +* helper does not consider YUV or other complicated formats. This means +* only legacy formats are supported (fmt->depth is a legacy field), but +* the framebuffer emulation can only deal with such formats, specifically +* RGB/BGA formats. +*/ +uint32_t drm_driver_color_mode_format (struct drm_device *dev,unsigned int color_mode) +{ +switch (color_mode) { +case 15 : +return drm_driver_legacy_fb_format (dev,16 ,15 ); +case 32 : +return drm_driver_legacy_fb_format (dev,32 ,24 ); +default : +return drm_driver_legacy_fb_format (dev, color_mode, color_mode); + } +} +EXPORT_SYMBOL (drm_driver_color_mode_format); +/* * Internal function to query information for a given format. See * drm_format_info() for the public API.
include/drm/drm_fourcc.h +1 -0
@@ -313,6 +313,7 @@ drm_get_format_info(struct drm_device *dev,uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);uint32_t drm_driver_legacy_fb_format (struct drm_device *dev,uint32_t bpp,uint32_t depth); +uint32_t drm_driver_color_mode_format (struct drm_device *dev,unsigned int color_mode);unsigned int drm_format_info_block_width (const struct drm_format_info *info,int plane); unsigned int drm_format_info_block_height(const struct drm_format_info *info,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 157/269 drm/fbdev: Add memory-agnostic fbdev client
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit 5d08c44e47b9d41366714552bdd374ac4b595591 ]
Add an fbdev client that can work with any memory manager. The client implementation is the same as existing code in fbdev-dma or fbdev-shmem.
Provide struct drm_driver.fbdev_probe for the new client to allocate the surface GEM buffer. The new callback replaces fb_probe of struct drm_fb_helper_funcs, which does the same.
To use the new client, DRM drivers set fbdev_probe in their struct drm_driver instance and call drm_fbdev_client_setup(). Probing and creating the fbdev surface buffer is now independent from the other operations in struct drm_fb_helper. For the pixel format, the fbdev client either uses a specified format, the value in preferred_depth or 32-bit RGB.
v2:
- test for struct drm_fb_helper.funcs for NULL (Sui)
- respect struct drm_mode_config.preferred_depth for default format
Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
--- drivers/gpu/drm/Makefile | 4 +- drivers/gpu/drm/drm_fb_helper.c | 15 +-- drivers/gpu/drm/drm_fbdev_client.c | 141 +++++++++++++++++++++++++++++ include/drm/drm_drv.h | 18 ++++ include/drm/drm_fbdev_client.h | 19 ++++ 5 files changed, 190 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/drm/drm_fbdev_client.c create mode 100644 include/drm/drm_fbdev_client.h
drivers/gpu/drm/Makefile +3 -1
@@ -145,7 +145,9 @@ drm_kms_helper-y := \ drm_self_refresh_helper.o \ drm_simple_kms_helper.o drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o -drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o +drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += \ + drm_fbdev_client.o \ + drm_fb_helper.o obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o #
drivers/gpu/drm/drm_fb_helper.c +9 -6
@@ -492,8 +492,8 @@ EXPORT_SYMBOL(drm_fb_helper_init);* @fb_helper: driver-allocated fbdev helper * * A helper to alloc fb_info and the member cmap. Called by the driver -* within the fb_probe fb_helper callback function. Drivers do not -* need to release the allocated fb_info structure themselves, this is +* within the struct &drm_driver.fbdev_probe callback function. Drivers do +* not need to release the allocated fb_info structure themselves, this is * automatically done when calling drm_fb_helper_fini(). * * RETURNS:
@@ -1610,7 +1610,7 @@ static int drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper,/* * Allocates the backing storage and sets up the fbdev info structure through -* the ->fb_probe callback. +* the ->fbdev_probe callback. */ static int drm_fb_helper_single_fb_probe (struct drm_fb_helper *fb_helper) {
@@ -1628,7 +1628,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper) }/* push down into drivers */ - ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes); +if (dev->driver->fbdev_probe) + ret = dev->driver->fbdev_probe (fb_helper, &sizes); +else if (fb_helper->funcs) + ret = fb_helper->funcs->fb_probe (fb_helper, &sizes);if (ret <0 )return ret;
@@ -1700,7 +1703,7 @@ static void drm_fb_helper_fill_var(struct fb_info *info,* instance and the drm framebuffer allocated in &drm_fb_helper.fb. * * Drivers should call this (or their equivalent setup code) from their -* &drm_fb_helper_funcs.fb_probe callback after having allocated the fbdev +* &drm_driver.fbdev_probe callback after having allocated the fbdev * backing storage framebuffer. */ void drm_fb_helper_fill_info(struct fb_info *info,
@@ -1856,7 +1859,7 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper)* Note that this also registers the fbdev and so allows userspace to call into * the driver through the fbdev interfaces. * -* This function will call down into the &drm_fb_helper_funcs.fb_probe callback +* This function will call down into the &drm_driver.fbdev_probe callback * to let the driver allocate and initialize the fbdev info structure and the * drm framebuffer used to back the fbdev. drm_fb_helper_fill_info() is provided * as a helper to setup simple default values for the fbdev info structure.
drivers/gpu/drm/drm_fbdev_client.c new file +141 -0
141 lines not on this page · raw message
include/drm/drm_drv.h +18 -0
@@ -34,6 +34,8 @@#include <drm/drm_device.h> +struct drm_fb_helper ; +struct drm_fb_helper_surface_size ;struct drm_file ;struct drm_gem_object ;struct drm_master ;
@@ -366,6 +368,22 @@ struct drm_driver { struct drm_device *dev, uint32_t handle, uint64_t *offset); +/** +* @fbdev_probe +* +* Allocates and initialize the fb_info structure for fbdev emulation. +* Furthermore it also needs to allocate the DRM framebuffer used to +* back the fbdev. +* +* This callback is mandatory for fbdev support. +* +* Returns: +* +* 0 on success ot a negative error code otherwise. +*/ +int (*fbdev_probe)(struct drm_fb_helper *fbdev_helper, +struct drm_fb_helper_surface_size *sizes); +/** * @show_fdinfo: *
include/drm/drm_fbdev_client.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef DRM_FBDEV_CLIENT_H +#define DRM_FBDEV_CLIENT_H + +struct drm_device ; +struct drm_format_info ; + +#ifdef CONFIG_DRM_FBDEV_EMULATION +int drm_fbdev_client_setup (struct drm_device *dev,const struct drm_format_info *format); +#else +static inline int drm_fbdev_client_setup (struct drm_device *dev, +const struct drm_format_info *format) +{ +return 0 ; +} +#endif + +#endif
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 158/269 drm: Add client-agnostic setup helper
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit d07fdf9225922d3e36ebd13ccab3df62b1ccdab3 ]
DRM may support multiple in-kernel clients that run as soon as a DRM driver has been registered. To select the client(s) in a single place, introduce drm_client_setup().
Drivers that call the new helper automatically instantiate the kernel's configured default clients. Only fbdev emulation is currently supported. Later versions can add support for DRM-based logging, a boot logo or even a console.
Some drivers handle the color mode for clients internally. Provide the helper drm_client_setup_with_color_mode() for them.
Using the new interface requires the driver to select DRM_CLIENT_SELECTION in its Kconfig. For now this only enables the client-setup helpers if the fbdev client has been configured by the user. A future patchset will further modularize client support and rework DRM_CLIENT_SELECTION to select the correct dependencies for all its clients.
v5:
- add CONFIG_DRM_CLIENT_SELECTION und DRM_CLIENT_SETUP v4:
- fix docs for drm_client_setup_with_fourcc() (Geert) v3:
- fix build error
v2:
- add drm_client_setup_with_fourcc() (Laurent)
- push default-format handling into actual clients
Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
--- drivers/gpu/drm/Kconfig | 12 ++++++ drivers/gpu/drm/Makefile | 2 + drivers/gpu/drm/drm_client_setup.c | 66 ++++++++++++++++++++++++++++++ include/drm/drm_client_setup.h | 26 ++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 drivers/gpu/drm/drm_client_setup.c create mode 100644 include/drm/drm_client_setup.h
drivers/gpu/drm/Kconfig +12 -0
@@ -211,6 +211,18 @@ config DRM_DEBUG_MODESET_LOCK If in doubt, say "N". +config DRM_CLIENT_SELECTION + bool + depends on DRM + select DRM_CLIENT_SETUP if DRM_FBDEV_EMULATION + help + Drivers that support in-kernel DRM clients have to select this + option. + +config DRM_CLIENT_SETUP + bool + depends on DRM_CLIENT_SELECTION + config DRM_FBDEV_EMULATION bool "Enable legacy fbdev support for your modesetting driver" depends on DRM
drivers/gpu/drm/Makefile +2 -0
@@ -144,6 +144,8 @@ drm_kms_helper-y := \ drm_rect.o \ drm_self_refresh_helper.o \ drm_simple_kms_helper.o +drm_kms_helper-$(CONFIG_DRM_CLIENT_SETUP) += \ + drm_client_setup.o drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += \ drm_fbdev_client.o \
drivers/gpu/drm/drm_client_setup.c new file +66 -0
66 lines not on this page · raw message
include/drm/drm_client_setup.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef DRM_CLIENT_SETUP_H +#define DRM_CLIENT_SETUP_H + +#include <linux/types.h> + +struct drm_device ; +struct drm_format_info ; + +#if defined(CONFIG_DRM_CLIENT_SETUP ) +void drm_client_setup (struct drm_device *dev,const struct drm_format_info *format); +void drm_client_setup_with_fourcc (struct drm_device *dev,u32 fourcc); +void drm_client_setup_with_color_mode (struct drm_device *dev,unsigned int color_mode); +#else +static inline void drm_client_setup (struct drm_device *dev, +const struct drm_format_info *format) +{ } +static inline void drm_client_setup_with_fourcc (struct drm_device *dev,u32 fourcc) +{ } +static inline void drm_client_setup_with_color_mode (struct drm_device *dev, +unsigned int color_mode) +{ } +#endif + +#endif
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 159/269 drm/fbdev-ttm: Support struct drm_driver.fbdev_probe
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit c7c1b9e1d52b0a0dbb0ee552efdc3360c0f5363c ]
Rework fbdev probing to support fbdev_probe in struct drm_driver and reimplement the old fb_probe callback on top of it. Provide an initializer macro for struct drm_driver that sets the callback according to the kernel configuration.
This change allows the common fbdev client to run on top of TTM- based DRM drivers.
Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
--- drivers/gpu/drm/drm_fbdev_ttm.c | 142 +++++++++++++++++--------------- include/drm/drm_fbdev_ttm.h | 13 +++ 2 files changed, 90 insertions(+), 65 deletions(-)
drivers/gpu/drm/drm_fbdev_ttm.c +77 -65
@@ -71,71 +71,7 @@ static const struct fb_ops drm_fbdev_ttm_fb_ops = {static int drm_fbdev_ttm_helper_fb_probe (struct drm_fb_helper *fb_helper,struct drm_fb_helper_surface_size *sizes) { -struct drm_client_dev *client = &fb_helper->client; -struct drm_device *dev = fb_helper->dev; -struct drm_client_buffer *buffer; -struct fb_info *info; -size_t screen_size; -void *screen_buffer; -u32 format; -int ret; - -drm_dbg_kms (dev,"surface width(%d), height(%d) and bpp(%d)\n" , - sizes->surface_width, sizes->surface_height, - sizes->surface_bpp); - - format =drm_driver_legacy_fb_format (dev, sizes->surface_bpp, - sizes->surface_depth); - buffer =drm_client_framebuffer_create (client, sizes->surface_width, - sizes->surface_height, format); -if (IS_ERR (buffer)) -return PTR_ERR (buffer); - - fb_helper->buffer = buffer; - fb_helper->fb = buffer->fb; - - screen_size = buffer->gem->size; - screen_buffer =vzalloc (screen_size); -if (!screen_buffer) { - ret = -ENOMEM ; - goto err_drm_client_framebuffer_delete; - } - - info =drm_fb_helper_alloc_info (fb_helper); -if (IS_ERR (info)) { - ret =PTR_ERR (info); - goto err_vfree; - } - -drm_fb_helper_fill_info (info, fb_helper, sizes); - - info->fbops = &drm_fbdev_ttm_fb_ops; - -/* screen */ - info->flags |=FBINFO_VIRTFB |FBINFO_READS_FAST ; - info->screen_buffer = screen_buffer; - info->fix.smem_len = screen_size; - -/* deferred I/O */ - fb_helper->fbdefio.delay =HZ /20 ; - fb_helper->fbdefio.deferred_io = drm_fb_helper_deferred_io; - - info->fbdefio = &fb_helper->fbdefio; - ret =fb_deferred_io_init (info); -if (ret) - goto err_drm_fb_helper_release_info; - -return 0 ; - -err_drm_fb_helper_release_info: -drm_fb_helper_release_info (fb_helper); -err_vfree: -vfree (screen_buffer); -err_drm_client_framebuffer_delete: - fb_helper->fb =NULL ; - fb_helper->buffer =NULL ; -drm_client_framebuffer_delete (buffer); -return ret; +return drm_fbdev_ttm_driver_fbdev_probe (fb_helper, sizes); } static void drm_fbdev_ttm_damage_blit_real(struct drm_fb_helper *fb_helper,
@@ -240,6 +176,82 @@ static const struct drm_fb_helper_funcs drm_fbdev_ttm_helper_funcs = { .fb_dirty = drm_fbdev_ttm_helper_fb_dirty, }; +/* +* struct drm_driver +*/ + +int drm_fbdev_ttm_driver_fbdev_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_client_dev *client = &fb_helper->client; +struct drm_device *dev = fb_helper->dev; +struct drm_client_buffer *buffer; +struct fb_info *info; +size_t screen_size; +void *screen_buffer; +u32 format; +int ret; + +drm_dbg_kms (dev,"surface width(%d), height(%d) and bpp(%d)\n" , + sizes->surface_width, sizes->surface_height, + sizes->surface_bpp); + + format =drm_driver_legacy_fb_format (dev, sizes->surface_bpp, + sizes->surface_depth); + buffer =drm_client_framebuffer_create (client, sizes->surface_width, + sizes->surface_height, format); +if (IS_ERR (buffer)) +return PTR_ERR (buffer); + + fb_helper->funcs = &drm_fbdev_ttm_helper_funcs; + fb_helper->buffer = buffer; + fb_helper->fb = buffer->fb; + + screen_size = buffer->gem->size; + screen_buffer =vzalloc (screen_size); +if (!screen_buffer) { + ret = -ENOMEM ; + goto err_drm_client_framebuffer_delete; + } + + info =drm_fb_helper_alloc_info (fb_helper); +if (IS_ERR (info)) { + ret =PTR_ERR (info); + goto err_vfree; + } + +drm_fb_helper_fill_info (info, fb_helper, sizes); + + info->fbops = &drm_fbdev_ttm_fb_ops; + +/* screen */ + info->flags |=FBINFO_VIRTFB |FBINFO_READS_FAST ; + info->screen_buffer = screen_buffer; + info->fix.smem_len = screen_size; + +/* deferred I/O */ + fb_helper->fbdefio.delay =HZ /20 ; + fb_helper->fbdefio.deferred_io = drm_fb_helper_deferred_io; + + info->fbdefio = &fb_helper->fbdefio; + ret =fb_deferred_io_init (info); +if (ret) + goto err_drm_fb_helper_release_info; + +return 0 ; + +err_drm_fb_helper_release_info: +drm_fb_helper_release_info (fb_helper); +err_vfree: +vfree (screen_buffer); +err_drm_client_framebuffer_delete: + fb_helper->fb =NULL ; + fb_helper->buffer =NULL ; +drm_client_framebuffer_delete (buffer); +return ret; +} +EXPORT_SYMBOL (drm_fbdev_ttm_driver_fbdev_probe); +static void drm_fbdev_ttm_client_unregister (struct drm_client_dev *client) {struct drm_fb_helper *fb_helper =drm_fb_helper_from_client (client);
include/drm/drm_fbdev_ttm.h +13 -0
@@ -3,11 +3,24 @@#ifndef DRM_FBDEV_TTM_H #define DRM_FBDEV_TTM_H +#include <linux/stddef.h> +struct drm_device ; +struct drm_fb_helper ; +struct drm_fb_helper_surface_size ;#ifdef CONFIG_DRM_FBDEV_EMULATION +int drm_fbdev_ttm_driver_fbdev_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes); + +#define DRM_FBDEV_TTM_DRIVER_OPS \ + .fbdev_probe = drm_fbdev_ttm_driver_fbdev_probe +void drm_fbdev_ttm_setup (struct drm_device *dev,unsigned int preferred_bpp);#else +#define DRM_FBDEV_TTM_DRIVER_OPS \ + .fbdev_probe = NULL +static inline void drm_fbdev_ttm_setup (struct drm_device *dev,unsigned int preferred_bpp) { }#endif
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 160/269 drm/nouveau: Run DRM default client setup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit ef350898ae22db832ada972476fa2999f8ea978c ]
Call drm_client_setup() to run the kernel's default client setup for DRM. Set fbdev_probe in struct drm_driver, so that the client setup can start the common fbdev client.
The nouveau driver specifies a preferred color mode depending on the available video memory, with a default of 32. Adapt this for the new client interface.
v5:
- select DRM_CLIENT_SELECTION
v2:
- style changes
Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
--- drivers/gpu/drm/nouveau/Kconfig | 1 + drivers/gpu/drm/nouveau/nouveau_drm.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/Kconfig +1 -0
@@ -4,6 +4,7 @@ config DRM_NOUVEAU depends on DRM && PCI && MMU select IOMMU_API select FW_LOADER + select DRM_CLIENT_SELECTION select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDMI_HELPER select DRM_DISPLAY_HELPER
drivers/gpu/drm/nouveau/nouveau_drm.c +8 -2
@@ -31,6 +31,7 @@#include <linux/dynamic_debug.h> #include <drm/drm_aperture.h> +#include <drm/drm_client_setup.h> #include <drm/drm_drv.h> #include <drm/drm_fbdev_ttm.h> #include <drm/drm_gem_ttm_helper.h>
@@ -836,6 +837,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev, {struct nvkm_device *device;struct nouveau_drm *drm; +const struct drm_format_info *format;int ret;if (vga_switcheroo_client_probe_defer (pdev))
@@ -873,9 +875,11 @@ static int nouveau_drm_probe(struct pci_dev *pdev, goto fail_pci;if (drm->client.device.info.ram_size <=32 *1024 *1024 ) -drm_fbdev_ttm_setup (drm->dev,8 ); + format =drm_format_info (DRM_FORMAT_C8 );else -drm_fbdev_ttm_setup (drm->dev,32 ); + format =NULL ; + +drm_client_setup (drm->dev, format);quirk_broken_nv_runpm (pdev);return 0 ;
@@ -1318,6 +1322,8 @@ driver_stub = { .dumb_create = nouveau_display_dumb_create, .dumb_map_offset = drm_gem_ttm_dumb_map_offset, +DRM_FBDEV_TTM_DRIVER_OPS , + .name = DRIVER_NAME, .desc = DRIVER_DESC, #ifdef GIT_REVISION
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 161/269 drm/nouveau: select FW caching
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Airlie <[email protected]>
[ Upstream commit 6b481ab0e6855fb30e2923c51f62f1662d1cda7e ]
nouveau tries to load some firmware during suspend that it loaded earlier, but with fw caching disabled it hangs suspend, so just rely on FW cache enabling instead of working around it in the driver.
--- drivers/gpu/drm/nouveau/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/Kconfig +1 -0
@@ -4,6 +4,7 @@ config DRM_NOUVEAU depends on DRM && PCI && MMU select IOMMU_API select FW_LOADER + select FW_CACHE if PM_SLEEP select DRM_CLIENT_SELECTION select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDMI_HELPER
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 162/269 bluetooth: btusb: Initialize .owner field of force_poll_sync_fops
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
[ Upstream commit cbf85b9cb80bec6345ffe0368dfff98386f4714f ]
Initialize .owner field of force_poll_sync_fops to THIS_MODULE in order to prevent btusb from being unloaded while its operations are in use.
--- drivers/bluetooth/btusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/btusb.c +1 -0
@@ -3644,6 +3644,7 @@ static ssize_t force_poll_sync_write(struct file *file, }static const struct file_operations force_poll_sync_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = force_poll_sync_read, .write = force_poll_sync_write,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 163/269 nvme-tcp: add basic support for the C2HTermReq PDU
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit 84e009042d0f3dfe91bec60bcd208ee3f866cbcd ]
Previously, the NVMe/TCP host driver did not handle the C2HTermReq PDU, instead printing "unsupported pdu type (3)" when received. This patch adds support for processing the C2HTermReq PDU, allowing the driver to print the Fatal Error Status field.
Example of output:
nvme nvme4: Received C2HTermReq (FES = Invalid PDU Header Field)
Stable-dep-of: ad95bab0cd28 ("nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu()")
--- drivers/nvme/host/tcp.c | 43 ++++++++++++++++++++++++++++++++++++++++ include/linux/nvme-tcp.h | 2 ++ 2 files changed, 45 insertions(+)
drivers/nvme/host/tcp.c +43 -0
@@ -763,6 +763,40 @@ static int nvme_tcp_handle_r2t(struct nvme_tcp_queue *queue,return 0 ; } +static void nvme_tcp_handle_c2h_term (struct nvme_tcp_queue *queue, +struct nvme_tcp_term_pdu *pdu) +{ +u16 fes; +const char *msg; +u32 plen =le32_to_cpu (pdu->hdr.plen); + +static const char *const msg_table[] = { + [NVME_TCP_FES_INVALID_PDU_HDR ] ="Invalid PDU Header Field" , + [NVME_TCP_FES_PDU_SEQ_ERR ] ="PDU Sequence Error" , + [NVME_TCP_FES_HDR_DIGEST_ERR ] ="Header Digest Error" , + [NVME_TCP_FES_DATA_OUT_OF_RANGE ] ="Data Transfer Out Of Range" , + [NVME_TCP_FES_R2T_LIMIT_EXCEEDED ] ="R2T Limit Exceeded" , + [NVME_TCP_FES_UNSUPPORTED_PARAM ] ="Unsupported Parameter" , + }; + +if (plen <NVME_TCP_MIN_C2HTERM_PLEN || + plen >NVME_TCP_MAX_C2HTERM_PLEN ) { +dev_err (queue->ctrl->ctrl.device, +"Received a malformed C2HTermReq PDU (plen = %u)\n" , + plen); +return ; + } + + fes =le16_to_cpu (pdu->fes); +if (fes && fes <ARRAY_SIZE (msg_table)) + msg = msg_table[fes]; +else + msg ="Unknown" ; + +dev_err (queue->ctrl->ctrl.device, +"Received C2HTermReq (FES = %s)\n" , msg); +} +static int nvme_tcp_recv_pdu (struct nvme_tcp_queue *queue,struct sk_buff *skb,unsigned int *offset,size_t *len) {
@@ -784,6 +818,15 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,return 0 ; hdr = queue->pdu; +if (unlikely (hdr->type == nvme_tcp_c2h_term)) { +/* +* C2HTermReq never includes Header or Data digests. +* Skip the checks. +*/ +nvme_tcp_handle_c2h_term (queue, (void *)queue->pdu); +return -EINVAL ; + } +if (queue->hdr_digest) { ret =nvme_tcp_verify_hdgst (queue, queue->pdu, hdr->hlen);if (unlikely (ret))
include/linux/nvme-tcp.h +2 -0
@@ -13,6 +13,8 @@#define NVME_TCP_ADMIN_CCSZ SZ_8K#define NVME_TCP_DIGEST_LENGTH 4#define NVME_TCP_MIN_MAXH2CDATA 4096 +#define NVME_TCP_MIN_C2HTERM_PLEN 24 +#define NVME_TCP_MAX_C2HTERM_PLEN 152enum nvme_tcp_pfv {NVME_TCP_PFV_1_0 =0x0 ,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 164/269 nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit ad95bab0cd28ed77c2c0d0b6e76e03e031391064 ]
nvme_tcp_recv_pdu() doesn't check the validity of the header length. When header digests are enabled, a target might send a packet with an invalid header length (e.g. 255), causing nvme_tcp_verify_hdgst() to access memory outside the allocated area and cause memory corruptions by overwriting it with the calculated digest.
Fix this by rejecting packets with an unexpected header length.
--- drivers/nvme/host/tcp.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
drivers/nvme/host/tcp.c +29 -3
@@ -217,6 +217,19 @@ static inline int nvme_tcp_queue_id(struct nvme_tcp_queue *queue)return queue - queue->ctrl->queues; } +static inline bool nvme_tcp_recv_pdu_supported (enum nvme_tcp_pdu_type type) +{ +switch (type) { +case nvme_tcp_c2h_term: +case nvme_tcp_c2h_data: +case nvme_tcp_r2t: +case nvme_tcp_rsp: +return true; +default : +return false; + } +} +/* * Check if the queue is TLS encrypted */
@@ -818,6 +831,16 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,return 0 ; hdr = queue->pdu; +if (unlikely (hdr->hlen !=sizeof (struct nvme_tcp_rsp_pdu ))) { +if (!nvme_tcp_recv_pdu_supported (hdr->type)) + goto unsupported_pdu; + +dev_err (queue->ctrl->ctrl.device, +"pdu type %d has unexpected header length (%d)\n" , + hdr->type, hdr->hlen); +return -EPROTO ; + } +if (unlikely (hdr->type == nvme_tcp_c2h_term)) {/* * C2HTermReq never includes Header or Data digests.
@@ -850,10 +873,13 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,nvme_tcp_init_recv_ctx (queue);return nvme_tcp_handle_r2t (queue, (void *)queue->pdu);default : -dev_err (queue->ctrl->ctrl.device, -"unsupported pdu type (%d)\n" , hdr->type); -return -EINVAL ; + goto unsupported_pdu; } + +unsupported_pdu: +dev_err (queue->ctrl->ctrl.device, +"unsupported pdu type (%d)\n" , hdr->type); +return -EINVAL ; }static inline void nvme_tcp_end_request (struct request *rq,u16 status)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 165/269 nvmet-tcp: Fix a possible sporadic response drops in weakly ordered arch
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meir Elisha <[email protected]>
[ Upstream commit a16f88964c647103dad7743a484b216d488a6352 ]
The order in which queue->cmd and rcv_state are updated is crucial. If these assignments are reordered by the compiler, the worker might not get queued in nvmet_tcp_queue_response(), hanging the IO. to enforce the the correct reordering, set rcv_state using smp_store_release().
--- drivers/nvme/target/tcp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/nvme/target/tcp.c +11 -4
@@ -571,10 +571,16 @@ static void nvmet_tcp_queue_response(struct nvmet_req *req)struct nvmet_tcp_cmd *cmd = container_of(req, struct nvmet_tcp_cmd, req);struct nvmet_tcp_queue *queue = cmd->queue; +enum nvmet_tcp_recv_state queue_state; +struct nvmet_tcp_cmd *queue_cmd;struct nvme_sgl_desc *sgl;u32 len; -if (unlikely (cmd == queue->cmd)) { +/* Pairs with store_release in nvmet_prepare_receive_pdu() */ + queue_state =smp_load_acquire (&queue->rcv_state); + queue_cmd =READ_ONCE (queue->cmd); + +if (unlikely (cmd == queue_cmd)) { sgl = &cmd->req.cmd->common.dptr.sgl; len =le32_to_cpu (sgl->length);
@@ -583,7 +589,7 @@ static void nvmet_tcp_queue_response(struct nvmet_req *req)* Avoid using helpers, this might happen before * nvmet_req_init is completed. */ -if (queue->rcv_state ==NVMET_TCP_RECV_PDU && +if (queue_state ==NVMET_TCP_RECV_PDU && len && len <= cmd->req.port->inline_data_size &&nvme_is_write (cmd->req.cmd))return ;
@@ -847,8 +853,9 @@ static void nvmet_prepare_receive_pdu(struct nvmet_tcp_queue *queue) { queue->offset =0 ; queue->left =sizeof (struct nvme_tcp_hdr ); - queue->cmd =NULL ; - queue->rcv_state =NVMET_TCP_RECV_PDU ; +WRITE_ONCE (queue->cmd,NULL ); +/* Ensure rcv_state is visible only after queue->cmd is set */ +smp_store_release (&queue->rcv_state,NVMET_TCP_RECV_PDU ); }static void nvmet_tcp_free_crypto (struct nvmet_tcp_queue *queue)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 166/269 ALSA: hda/realtek: Remove (revert) duplicate Ally X config
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antheas Kapenekakis <[email protected]>
[ Upstream commit 3414cda9d41f41703832d0abd01063dd8de82b89 ]
In commit 1e9c708dc3ae ("ALSA: hda/tas2781: Add new quirk for Lenovo, ASUS, Dell projects") Baojun adds a bunch of projects to the file, including for the Ally X. Turns out the initial Ally X was not sorted properly, so the kernel had 2 quirks for it.
The previous quirk overrode the new one due to being earlier and they are different. When AB testing, the normal pin fixup seems to work ok but causes a bit of a minor popping. Given the other config is more complicated and may cause undefined behavior, revert it.
--- sound/pci/hda/patch_realtek.c | 8 -------- 1 file changed, 8 deletions(-)
sound/pci/hda/patch_realtek.c +0 -8
@@ -7741,7 +7741,6 @@ enum {ALC285_FIXUP_THINKPAD_X1_GEN7 ,ALC285_FIXUP_THINKPAD_HEADSET_JACK ,ALC294_FIXUP_ASUS_ALLY , -ALC294_FIXUP_ASUS_ALLY_X ,ALC294_FIXUP_ASUS_ALLY_PINS ,ALC294_FIXUP_ASUS_ALLY_VERBS , ALC294_FIXUP_ASUS_ALLY_SPEAKER,
@@ -9184,12 +9183,6 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id =ALC294_FIXUP_ASUS_ALLY_PINS }, - [ALC294_FIXUP_ASUS_ALLY_X] = { - .type = HDA_FIXUP_FUNC, - .v.func = tas2781_fixup_i2c, - .chained = true, - .chain_id =ALC294_FIXUP_ASUS_ALLY_PINS - }, [ALC294_FIXUP_ASUS_ALLY_PINS] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl[]) {
@@ -10674,7 +10667,6 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1043 ,0x1740 ,"ASUS UX430UA" ,ALC295_FIXUP_ASUS_DACS ),SND_PCI_QUIRK (0x1043 ,0x17d1 ,"ASUS UX431FL" ,ALC294_FIXUP_ASUS_DUAL_SPK ),SND_PCI_QUIRK (0x1043 ,0x17f3 ,"ROG Ally NR2301L/X" ,ALC294_FIXUP_ASUS_ALLY ), -SND_PCI_QUIRK (0x1043 ,0x1eb3 ,"ROG Ally X RC72LA" ,ALC294_FIXUP_ASUS_ALLY_X ),SND_PCI_QUIRK (0x1043 ,0x1863 ,"ASUS UX6404VI/VV" ,ALC245_FIXUP_CS35L41_SPI_2 ),SND_PCI_QUIRK (0x1043 ,0x1881 ,"ASUS Zephyrus S/M" ,ALC294_FIXUP_ASUS_GX502_PINS ), SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 167/269 net: gso: fix ownership in __udp_gso_segment
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoine Tenart <[email protected]>
[ Upstream commit ee01b2f2d7d0010787c2343463965bbc283a497f ]
In __udp_gso_segment the skb destructor is removed before segmenting the skb but the socket reference is kept as-is. This is an issue if the original skb is later orphaned as we can hit the following bug:
kernel BUG at ./include/linux/skbuff.h:3312! (skb_orphan)
RIP: 0010:ip_rcv_core+0x8b2/0xca0 Call Trace: ip_rcv+0xab/0x6e0 __netif_receive_skb_one_core+0x168/0x1b0 process_backlog+0x384/0x1100 __napi_poll.constprop.0+0xa1/0x370 net_rx_action+0x925/0xe50
The above can happen following a sequence of events when using OpenVSwitch, when an OVS_ACTION_ATTR_USERSPACE action precedes an OVS_ACTION_ATTR_OUTPUT action:
1. OVS_ACTION_ATTR_USERSPACE is handled (in do_execute_actions): the skb goes through queue_gso_packets and then __udp_gso_segment, where its destructor is removed.
2. The segments' data are copied and sent to userspace.
3. OVS_ACTION_ATTR_OUTPUT is handled (in do_execute_actions) and the same original skb is sent to its path.
4. If it later hits skb_orphan, we hit the bug.
Fix this by also removing the reference to the socket in __udp_gso_segment.
--- net/ipv4/udp_offload.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv4/udp_offload.c +6 -2
@@ -321,13 +321,17 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,/* clear destructor to avoid skb_segment assigning it to tail */ copy_dtor = gso_skb->destructor == sock_wfree; -if (copy_dtor) +if (copy_dtor) { gso_skb->destructor =NULL ; + gso_skb->sk =NULL ; + } segs =skb_segment (gso_skb, features);if (IS_ERR_OR_NULL (segs)) { -if (copy_dtor) +if (copy_dtor) { gso_skb->destructor = sock_wfree; + gso_skb->sk = sk; + }return segs; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 168/269 caif_virtio: fix wrong pointer check in cfv_probe()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaliy Shevtsov <[email protected]>
[ Upstream commit a466fd7e9fafd975949e5945e2f70c33a94b1a70 ]
del_vqs() frees virtqueues, therefore cfv->vq_tx pointer should be checked for NULL before calling it, not cfv->vdev. Also the current implementation is redundant because the pointer cfv->vdev is dereferenced before it is checked for NULL.
Fix this by checking cfv->vq_tx for NULL instead of cfv->vdev before calling del_vqs().
--- drivers/net/caif/caif_virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/caif/caif_virtio.c +1 -1
@@ -745,7 +745,7 @@ static int cfv_probe(struct virtio_device *vdev)if (cfv->vr_rx) vdev->vringh_config->del_vrhs (cfv->vdev); -if (cfv->vdev) +if (cfv->vq_tx) vdev->config->del_vqs (cfv->vdev);free_netdev (netdev);return err;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 169/269 perf/core: Fix pmus_lock vs. pmus_srcu ordering
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
[ Upstream commit 2565e42539b120b81a68a58da961ce5d1e34eac8 ]
Commit a63fbed776c7 ("perf/tracing/cpuhotplug: Fix locking order") placed pmus_lock inside pmus_srcu, this makes perf_pmu_unregister() trip lockdep.
Move the locking about such that only pmu_idr and pmus (list) are modified while holding pmus_lock. This avoids doing synchronize_srcu() while holding pmus_lock and all is well again.
--- kernel/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/core.c +2 -2
@@ -11846,6 +11846,8 @@ void perf_pmu_unregister(struct pmu *pmu) {mutex_lock (&pmus_lock);list_del_rcu (&pmu->entry); +idr_remove (&pmu_idr, pmu->type); +mutex_unlock (&pmus_lock);/* * We dereference the pmu list under both SRCU and regular RCU, so
@@ -11855,7 +11857,6 @@ void perf_pmu_unregister(struct pmu *pmu)synchronize_rcu ();free_percpu (pmu->pmu_disable_count); -idr_remove (&pmu_idr, pmu->type);if (pmu_bus_running && pmu->dev && pmu->dev !=PMU_NULL_DEV ) {if (pmu->nr_addr_filters)device_remove_file (pmu->dev, &dev_attr_nr_addr_filters);
@@ -11863,7 +11864,6 @@ void perf_pmu_unregister(struct pmu *pmu)put_device (pmu->dev); }free_pmu_context (pmu); -mutex_unlock (&pmus_lock); }EXPORT_SYMBOL_GPL (perf_pmu_unregister);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 170/269 hwmon: (pmbus) Initialise page count in pmbus_identify()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Titus Rwantare <[email protected]>
[ Upstream commit 6b6e2e8fd0de3fa7c6f4f8fe6841b01770b2e7bc ]
The pmbus_identify() function fails to correctly determine the number of supported pages on PMBus devices. This occurs because info->pages is implicitly zero-initialised, and pmbus_set_page() does not perform writes to the page register if info->pages is not yet initialised. Without this patch, info->pages is always set to the maximum after scanning.
This patch initialises info->pages to PMBUS_PAGES before the probing loop, enabling pmbus_set_page() writes to make it out onto the bus correctly identifying the number of pages. PMBUS_PAGES seemed like a reasonable non-zero number because that's the current result of the identification process.
Testing was done with a PMBus device in QEMU.
--- drivers/hwmon/pmbus/pmbus.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwmon/pmbus/pmbus.c +2 -0
@@ -103,6 +103,8 @@ static int pmbus_identify(struct i2c_client *client,if (pmbus_check_byte_register (client,0 ,PMBUS_PAGE )) {int page; + info->pages =PMBUS_PAGES ; +for (page =1 ; page <PMBUS_PAGES ; page++) {if (pmbus_set_page (client, page,0xff ) <0 )break ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 171/269 hwmon: (ntc_thermistor) Fix the ncpXXxh103 sensor table
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maud Spierings <[email protected]>
[ Upstream commit 1c7932d5ae0f5c22fa52ac811b4c427bbca5aff5 ]
I could not find a single table that has the values currently present in the table, change it to the actual values that can be found in [1]/[2] and [3] (page 15 column 2)
[1]: https://www.murata.com/products/productdetail?partno=NCP15XH103F03RC
[2]: https://www.murata.com/products/productdata/8796836626462/NTHCG83.txt?1437969843000
[3]: https://nl.mouser.com/datasheet/2/281/r44e-522712.pdf
--- drivers/hwmon/ntc_thermistor.c | 66 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-)
drivers/hwmon/ntc_thermistor.c +33 -33
@@ -181,40 +181,40 @@ static const struct ntc_compensation ncpXXwf104[] = { };static const struct ntc_compensation ncpXXxh103[] = { - { .temp_c =-40 , .ohm =247565 }, - { .temp_c =-35 , .ohm =181742 }, - { .temp_c =-30 , .ohm =135128 }, - { .temp_c =-25 , .ohm =101678 }, - { .temp_c =-20 , .ohm =77373 }, - { .temp_c =-15 , .ohm =59504 }, - { .temp_c =-10 , .ohm =46222 }, - { .temp_c =-5 , .ohm =36244 }, - { .temp_c =0 , .ohm =28674 }, - { .temp_c =5 , .ohm =22878 }, - { .temp_c =10 , .ohm =18399 }, - { .temp_c =15 , .ohm =14910 }, - { .temp_c =20 , .ohm =12169 }, + { .temp_c =-40 , .ohm =195652 }, + { .temp_c =-35 , .ohm =148171 }, + { .temp_c =-30 , .ohm =113347 }, + { .temp_c =-25 , .ohm =87559 }, + { .temp_c =-20 , .ohm =68237 }, + { .temp_c =-15 , .ohm =53650 }, + { .temp_c =-10 , .ohm =42506 }, + { .temp_c =-5 , .ohm =33892 }, + { .temp_c =0 , .ohm =27219 }, + { .temp_c =5 , .ohm =22021 }, + { .temp_c =10 , .ohm =17926 }, + { .temp_c =15 , .ohm =14674 }, + { .temp_c =20 , .ohm =12081 }, { .temp_c =25 , .ohm =10000 }, - { .temp_c =30 , .ohm =8271 }, - { .temp_c =35 , .ohm =6883 }, - { .temp_c =40 , .ohm =5762 }, - { .temp_c =45 , .ohm =4851 }, - { .temp_c =50 , .ohm =4105 }, - { .temp_c =55 , .ohm =3492 }, - { .temp_c =60 , .ohm =2985 }, - { .temp_c =65 , .ohm =2563 }, - { .temp_c =70 , .ohm =2211 }, - { .temp_c =75 , .ohm =1915 }, - { .temp_c =80 , .ohm =1666 }, - { .temp_c =85 , .ohm =1454 }, - { .temp_c =90 , .ohm =1275 }, - { .temp_c =95 , .ohm =1121 }, - { .temp_c =100 , .ohm =990 }, - { .temp_c =105 , .ohm =876 }, - { .temp_c =110 , .ohm =779 }, - { .temp_c =115 , .ohm =694 }, - { .temp_c =120 , .ohm =620 }, - { .temp_c =125 , .ohm =556 }, + { .temp_c =30 , .ohm =8315 }, + { .temp_c =35 , .ohm =6948 }, + { .temp_c =40 , .ohm =5834 }, + { .temp_c =45 , .ohm =4917 }, + { .temp_c =50 , .ohm =4161 }, + { .temp_c =55 , .ohm =3535 }, + { .temp_c =60 , .ohm =3014 }, + { .temp_c =65 , .ohm =2586 }, + { .temp_c =70 , .ohm =2228 }, + { .temp_c =75 , .ohm =1925 }, + { .temp_c =80 , .ohm =1669 }, + { .temp_c =85 , .ohm =1452 }, + { .temp_c =90 , .ohm =1268 }, + { .temp_c =95 , .ohm =1110 }, + { .temp_c =100 , .ohm =974 }, + { .temp_c =105 , .ohm =858 }, + { .temp_c =110 , .ohm =758 }, + { .temp_c =115 , .ohm =672 }, + { .temp_c =120 , .ohm =596 }, + { .temp_c =125 , .ohm =531 }, };/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 172/269 hwmon: (ad7314) Validate leading zero bits and return error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Erik Schumacher <[email protected]>
[ Upstream commit e278d5e8aef4c0a1d9a9fa8b8910d713a89aa800 ]
Leading zero bits are sent on the bus before the temperature value is transmitted. If any of these bits are high, the connection might be unstable or there could be no AD7314 / ADT730x (or compatible) at all. Return -EIO in that case.
--- drivers/hwmon/ad7314.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/hwmon/ad7314.c +10 -0
@@ -22,11 +22,13 @@*/ #define AD7314_TEMP_MASK 0x7FE0#define AD7314_TEMP_SHIFT 5 +#define AD7314_LEADING_ZEROS_MASK BIT(15)/* * ADT7301 and ADT7302 temperature masks */ #define ADT7301_TEMP_MASK 0x3FFF +#define ADT7301_LEADING_ZEROS_MASK (BIT(15) | BIT(14))enum ad7314_variant { adt7301,
@@ -65,12 +67,20 @@ static ssize_t ad7314_temperature_show(struct device *dev,return ret;switch (spi_get_device_id (chip->spi_dev)->driver_data) {case ad7314: +if (ret &AD7314_LEADING_ZEROS_MASK ) { +/* Invalid read-out, leading zero part is missing */ +return -EIO ; + } data = (ret &AD7314_TEMP_MASK ) >>AD7314_TEMP_SHIFT ; data =sign_extend32 (data,9 );return sprintf (buf,"%d\n" ,250 * data);case adt7301:case adt7302: +if (ret &ADT7301_LEADING_ZEROS_MASK ) { +/* Invalid read-out, leading zero part is missing */ +return -EIO ; + }/* * Documented as a 13 bit twos complement register * with a sign bit - which is a 14 bit 2's complement
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 173/269 tracing: probe-events: Remove unused MAX_ARG_BUF_LEN macro
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit fd5ba38390c59e1c147480ae49b6133c4ac24001 ]
Commit 18b1e870a496 ("tracing/probes: Add $arg* meta argument for all function args") introduced MAX_ARG_BUF_LEN but it is not used. Remove it.
--- kernel/trace/trace_probe.h | 1 - 1 file changed, 1 deletion(-)
kernel/trace/trace_probe.h +0 -1
@@ -36,7 +36,6 @@#define MAX_BTF_ARGS_LEN 128#define MAX_DENTRY_ARGS_LEN 256#define MAX_STRING_SIZE PATH_MAX -#define MAX_ARG_BUF_LEN (MAX_TRACE_ARGS * MAX_ARG_NAME_LEN)/* Reserved field names */ #define FIELD_STRING_IP "__probe_ip"
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 174/269 drm/imagination: Fix timestamps in firmware traces
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alessio Belle <[email protected]>
[ Upstream commit 1d2eabb6616433ccaa13927811bdfa205e91ba60 ]
When firmware traces are enabled, the firmware dumps 48-bit timestamps for each trace as two 32-bit values, highest 32 bits (of which only 16 useful) first.
The driver was reassembling them the other way round i.e. interpreting the first value in memory as the lowest 32 bits, and the second value as the highest 32 bits (then truncated to 16 bits).
Due to this, firmware trace dumps showed very large timestamps even for traces recorded shortly after GPU boot. The timestamps in these dumps would also sometimes jump backwards because of the truncation.
Example trace dumped after loading the powervr module and enabling firmware traces, where each line is commented with the timestamp value in hexadecimal to better show both issues:
[93540092739584] : Host Sync Partition marker: 1 // 0x551300000000 [28419798597632] : GPU units deinit // 0x19d900000000 [28548647616512] : GPU deinit // 0x19f700000000
Update logic to reassemble the timestamps halves in the correct order.
--- drivers/gpu/drm/imagination/pvr_fw_trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/imagination/pvr_fw_trace.c +2 -2
@@ -333,8 +333,8 @@ static int fw_trace_seq_show(struct seq_file *s, void *v)if (sf_id ==ROGUE_FW_SF_LAST )return -EINVAL ; - timestamp =read_fw_trace (trace_seq_data,1 ) | - ((u64 )read_fw_trace (trace_seq_data,2 ) <<32 ); + timestamp = ((u64 )read_fw_trace (trace_seq_data,1 ) <<32 ) | +read_fw_trace (trace_seq_data,2 ); timestamp = (timestamp & ~ROGUE_FWT_TIMESTAMP_TIME_CLRMSK ) >>ROGUE_FWT_TIMESTAMP_TIME_SHIFT ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 175/269 ALSA: usx2y: validate nrpacks module parameter on probe
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murad Masimov <[email protected]>
[ Upstream commit 172a0f509723fe4741d4b8e9190cf434b18320d8 ]
The module parameter defines number of iso packets per one URB. User is allowed to set any value to the parameter of type int, which can lead to various kinds of weird and incorrect behavior like integer overflows, truncations, etc. Number of packets should be a small non-negative number.
Since this parameter is read-only, its value can be validated on driver probe.
--- sound/usb/usx2y/usbusx2y.c | 11 +++++++++++ sound/usb/usx2y/usbusx2y.h | 26 ++++++++++++++++++++++++++ sound/usb/usx2y/usbusx2yaudio.c | 27 --------------------------- 3 files changed, 37 insertions(+), 27 deletions(-)
sound/usb/usx2y/usbusx2y.c +11 -0
@@ -151,6 +151,12 @@ static int snd_usx2y_card_used[SNDRV_CARDS];static void snd_usx2y_card_private_free (struct snd_card *card);static void usx2y_unlinkseq (struct snd_usx2y_async_seq *s); +#ifdef USX2Y_NRPACKS_VARIABLE +int nrpacks =USX2Y_NRPACKS ;/* number of packets per urb */ +module_param (nrpacks, int,0444 ); +MODULE_PARM_DESC (nrpacks,"Number of packets per URB." ); +#endif +/* * pipe 4 is used for switching the lamps, setting samplerate, volumes .... */
@@ -432,6 +438,11 @@ static int snd_usx2y_probe(struct usb_interface *intf,struct snd_card *card;int err; +#ifdef USX2Y_NRPACKS_VARIABLE +if (nrpacks <0 || nrpacks >USX2Y_NRPACKS_MAX ) +return -EINVAL ; +#endif + if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 &&
sound/usb/usx2y/usbusx2y.h +26 -0
@@ -7,6 +7,32 @@#define NRURBS 2 +/* Default value used for nr of packs per urb. +* 1 to 4 have been tested ok on uhci. +* To use 3 on ohci, you'd need a patch: +* look for "0000425-linux-2.6.9-rc4-mm1_ohci-hcd.patch.gz" on +* "https://bugtrack.alsa-project.org/alsa-bug/bug_view_page.php?bug_id=0000425" +* +* 1, 2 and 4 work out of the box on ohci, if I recall correctly. +* Bigger is safer operation, smaller gives lower latencies. +*/ +#define USX2Y_NRPACKS 4 + +#define USX2Y_NRPACKS_MAX 1024 + +/* If your system works ok with this module's parameter +* nrpacks set to 1, you might as well comment +* this define out, and thereby produce smaller, faster code. +* You'd also set USX2Y_NRPACKS to 1 then. +*/ +#define USX2Y_NRPACKS_VARIABLE 1 + +#ifdef USX2Y_NRPACKS_VARIABLE +extern int nrpacks; +#define nr_of_packs () nrpacks +#else +#define nr_of_packs () USX2Y_NRPACKS +#endif #define URBS_ASYNC_SEQ 10#define URB_DATA_LEN_ASYNC_SEQ 32
sound/usb/usx2y/usbusx2yaudio.c +0 -27
@@ -28,33 +28,6 @@#include "usx2y.h" #include "usbusx2y.h" -/* Default value used for nr of packs per urb. -* 1 to 4 have been tested ok on uhci. -* To use 3 on ohci, you'd need a patch: -* look for "0000425-linux-2.6.9-rc4-mm1_ohci-hcd.patch.gz" on -* "https://bugtrack.alsa-project.org/alsa-bug/bug_view_page.php?bug_id=0000425" -* -* 1, 2 and 4 work out of the box on ohci, if I recall correctly. -* Bigger is safer operation, smaller gives lower latencies. -*/ -#define USX2Y_NRPACKS 4 - -/* If your system works ok with this module's parameter -* nrpacks set to 1, you might as well comment -* this define out, and thereby produce smaller, faster code. -* You'd also set USX2Y_NRPACKS to 1 then. -*/ -#define USX2Y_NRPACKS_VARIABLE 1 - -#ifdef USX2Y_NRPACKS_VARIABLE -static int nrpacks =USX2Y_NRPACKS ;/* number of packets per urb */ -#define nr_of_packs () nrpacks -module_param (nrpacks, int,0444 ); -MODULE_PARM_DESC (nrpacks,"Number of packets per URB." ); -#else -#define nr_of_packs () USX2Y_NRPACKS -#endif -static int usx2y_urb_capt_retire (struct snd_usx2y_substream *subs) {struct urb *urb = subs->completed_urb;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 176/269 llc: do not use skb_get() before dev_queue_xmit()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 64e6a754d33d31aa844b3ee66fb93ac84ca1565e ]
syzbot is able to crash hosts [1], using llc and devices not supporting IFF_TX_SKB_SHARING.
In this case, e1000 driver calls eth_skb_pad(), while the skb is shared.
Simply replace skb_get() by skb_clone() in net/llc/llc_s_ac.c
Note that e1000 driver might have an issue with pktgen, because it does not clear IFF_TX_SKB_SHARING, this is an orthogonal change.
We need to audit other skb_get() uses in net/llc.
[1]
kernel BUG at net/core/skbuff.c:2178 !
Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI CPU: 0 UID: 0 PID: 16371 Comm: syz.2.2764 Not tainted 6.14.0-rc4-syzkaller-00052-gac9c34d1e45a #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 RIP: 0010:pskb_expand_head+0x6ce/0x1240 net/core/skbuff.c:2178 Call Trace: <TASK> __skb_pad+0x18a/0x610 net/core/skbuff.c:2466 __skb_put_padto include/linux/skbuff.h:3843 [inline] skb_put_padto include/linux/skbuff.h:3862 [inline] eth_skb_pad include/linux/etherdevice.h:656 [inline] e1000_xmit_frame+0x2d99/0x5800 drivers/net/ethernet/intel/e1000/e1000_main.c:3128 __netdev_start_xmit include/linux/netdevice.h:5151 [inline] netdev_start_xmit include/linux/netdevice.h:5160 [inline] xmit_one net/core/dev.c:3806 [inline] dev_hard_start_xmit+0x9a/0x7b0 net/core/dev.c:3822 sch_direct_xmit+0x1ae/0xc30 net/sched/sch_generic.c:343 __dev_xmit_skb net/core/dev.c:4045 [inline] __dev_queue_xmit+0x13d4/0x43e0 net/core/dev.c:4621 dev_queue_xmit include/linux/netdevice.h:3313 [inline] llc_sap_action_send_test_c+0x268/0x320 net/llc/llc_s_ac.c:144 llc_exec_sap_trans_actions net/llc/llc_sap.c:153 [inline] llc_sap_next_state net/llc/llc_sap.c:182 [inline] llc_sap_state_process+0x239/0x510 net/llc/llc_sap.c:209 llc_ui_sendmsg+0xd0d/0x14e0 net/llc/af_llc.c:993 sock_sendmsg_nosec net/socket.c:718 [inline]
--- net/llc/llc_s_ac.c | 49 +++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 22 deletions(-)
net/llc/llc_s_ac.c +27 -22
@@ -24,7 +24,7 @@#include <net/llc_s_ac.h> #include <net/llc_s_ev.h> #include <net/llc_sap.h> - +#include <net/sock.h> /** * llc_sap_action_unitdata_ind - forward UI PDU to network layer
@@ -40,6 +40,26 @@ int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb)return 0 ; } +static int llc_prepare_and_xmit (struct sk_buff *skb) +{ +struct llc_sap_state_ev *ev =llc_sap_ev (skb); +struct sk_buff *nskb; +int rc; + + rc =llc_mac_hdr_init (skb, ev->saddr.mac, ev->daddr.mac); +if (rc) +return rc; + + nskb =skb_clone (skb,GFP_ATOMIC ); +if (!nskb) +return -ENOMEM ; + +if (skb->sk) +skb_set_owner_w (nskb, skb->sk); + +return dev_queue_xmit (nskb); +} +/** * llc_sap_action_send_ui - sends UI PDU resp to UNITDATA REQ to MAC layer * @sap: SAP
@@ -52,17 +72,12 @@ int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb)int llc_sap_action_send_ui (struct llc_sap *sap,struct sk_buff *skb) {struct llc_sap_state_ev *ev =llc_sap_ev (skb); -int rc;llc_pdu_header_init (skb,LLC_PDU_TYPE_U , ev->saddr.lsap, ev->daddr.lsap,LLC_PDU_CMD );llc_pdu_init_as_ui_cmd (skb); - rc =llc_mac_hdr_init (skb, ev->saddr.mac, ev->daddr.mac); -if (likely (!rc)) { -skb_get (skb); - rc =dev_queue_xmit (skb); - } -return rc; + +return llc_prepare_and_xmit (skb); }/**
@@ -77,17 +92,12 @@ int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb)int llc_sap_action_send_xid_c (struct llc_sap *sap,struct sk_buff *skb) {struct llc_sap_state_ev *ev =llc_sap_ev (skb); -int rc;llc_pdu_header_init (skb,LLC_PDU_TYPE_U_XID , ev->saddr.lsap, ev->daddr.lsap,LLC_PDU_CMD );llc_pdu_init_as_xid_cmd (skb,LLC_XID_NULL_CLASS_2 ,0 ); - rc =llc_mac_hdr_init (skb, ev->saddr.mac, ev->daddr.mac); -if (likely (!rc)) { -skb_get (skb); - rc =dev_queue_xmit (skb); - } -return rc; + +return llc_prepare_and_xmit (skb); }/**
@@ -133,17 +143,12 @@ int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb)int llc_sap_action_send_test_c (struct llc_sap *sap,struct sk_buff *skb) {struct llc_sap_state_ev *ev =llc_sap_ev (skb); -int rc;llc_pdu_header_init (skb,LLC_PDU_TYPE_U , ev->saddr.lsap, ev->daddr.lsap,LLC_PDU_CMD );llc_pdu_init_as_test_cmd (skb); - rc =llc_mac_hdr_init (skb, ev->saddr.mac, ev->daddr.mac); -if (likely (!rc)) { -skb_get (skb); - rc =dev_queue_xmit (skb); - } -return rc; + +return llc_prepare_and_xmit (skb); }int llc_sap_action_send_test_r (struct llc_sap *sap,struct sk_buff *skb)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 177/269 hwmon: fix a NULL vs IS_ERR_OR_NULL() check in xgene_hwmon_probe()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xinghuo Chen <[email protected]>
[ Upstream commit 10fce7ebe888fa8c97eee7e317a47e7603e5e78d ]
The devm_memremap() function returns error pointers on error, it doesn't return NULL.
--- drivers/hwmon/xgene-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/xgene-hwmon.c +1 -1
@@ -706,7 +706,7 @@ static int xgene_hwmon_probe(struct platform_device *pdev) goto out; } -if (!ctx->pcc_comm_addr) { +if (IS_ERR_OR_NULL (ctx->pcc_comm_addr)) {dev_err (&pdev->dev,"Failed to ioremap PCC comm region\n" ); rc = -ENOMEM ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 178/269 drm/sched: Fix preprocessor guard
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philipp Stanner <[email protected]>
[ Upstream commit 23e0832d6d7be2d3c713f9390c060b6f1c48bf36 ]
When writing the header guard for gpu_scheduler_trace.h, a typo, apparently, occurred.
Fix the typo and document the scope of the guard.
--- drivers/gpu/drm/scheduler/gpu_scheduler_trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +2 -2
@@ -21,7 +21,7 @@* */ -#if !defined(_GPU_SCHED_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) +#if !defined(_GPU_SCHED_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ )#define _GPU_SCHED_TRACE_H_#include <linux/stringify.h>
@@ -106,7 +106,7 @@ TRACE_EVENT(drm_sched_job_wait_dep, __entry->seqno) ); -#endif +#endif /* _GPU_SCHED_TRACE_H_ */ /* This part must be outside protection */ #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 179/269 be2net: fix sleeping while atomic bugs in be_ndo_bridge_getlink
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 1a82d19ca2d6835904ee71e2d40fd331098f94a0 ]
Partially revert commit b71724147e73 ("be2net: replace polling with sleeping in the FW completion path") w.r.t mcc mutex it introduces and the use of usleep_range. The be2net be_ndo_bridge_getlink() callback is called with rcu_read_lock, so this code has been broken for a long time. Both the mutex_lock and the usleep_range can cause the issue Ian Kumlien reported[1]. The call path is:be_ndo_bridge_getlink -> be_cmd_get_hsw_config -> be_mcc_notify_wait -> be_mcc_wait_compl -> usleep_range()
[1] https://lore.kernel.org/netdev/CAA85sZveppNgEVa_FD+qhOMtG_AavK9_mFiU+jWrMtXmwqefGA@mail.gmail.com/
--- drivers/net/ethernet/emulex/benet/be.h | 2 +- drivers/net/ethernet/emulex/benet/be_cmds.c | 197 ++++++++++---------- drivers/net/ethernet/emulex/benet/be_main.c | 2 +- 3 files changed, 100 insertions(+), 101 deletions(-)
drivers/net/ethernet/emulex/benet/be.h +1 -1
@@ -562,7 +562,7 @@ struct be_adapter {struct be_dma_mem mbox_mem_alloced;struct be_mcc_obj mcc_obj; -struct mutex mcc_lock;/* For serializing mcc cmds to BE card */ +spinlock_t mcc_lock;/* For serializing mcc cmds to BE card */ spinlock_t mcc_cq_lock;u16 cfg_num_rx_irqs;/* configured via set-channels */
drivers/net/ethernet/emulex/benet/be_cmds.c +98 -99
787 lines not on this page · raw message
drivers/net/ethernet/emulex/benet/be_main.c +1 -1
@@ -5667,8 +5667,8 @@ static int be_drv_init(struct be_adapter *adapter) }mutex_init (&adapter->mbox_lock); -mutex_init (&adapter->mcc_lock);mutex_init (&adapter->rx_filter_lock); +spin_lock_init (&adapter->mcc_lock);spin_lock_init (&adapter->mcc_cq_lock);init_completion (&adapter->et_cmd_compl);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 180/269 net: hns3: make sure ptp clock is unregister and freed if hclge_ptp_get_cycle returns an error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peiyang Wang <[email protected]>
[ Upstream commit b7365eab39831487a84e63a9638209b68dc54008 ]
During the initialization of ptp, hclge_ptp_get_cycle might return an error and returned directly without unregister clock and free it. To avoid that, call hclge_ptp_destroy_clock to unregist and free clock if hclge_ptp_get_cycle failed.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c +1 -1
@@ -483,7 +483,7 @@ int hclge_ptp_init(struct hclge_dev *hdev) ret =hclge_ptp_get_cycle (hdev);if (ret) -return ret; + goto out; } ret =hclge_ptp_int_en (hdev, true);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 181/269 drm/i915/color: Extract intel_color_modeset()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
[ Upstream commit 84d2d0430f0833cdf52a3d051906add051f20ef0 ]
We always perform the same steps to program color management stuff during a full modeset. Extract that code to a helper to avoid duplication.
Stable-dep-of: 30bfc151f0c1 ("drm/xe: Remove double pageflip")
--- drivers/gpu/drm/i915/display/intel_color.c | 17 ++++++++++ drivers/gpu/drm/i915/display/intel_color.h | 1 + drivers/gpu/drm/i915/display/intel_display.c | 33 +++----------------- 3 files changed, 22 insertions(+), 29 deletions(-)
drivers/gpu/drm/i915/display/intel_color.c +17 -0
@@ -1912,6 +1912,23 @@ void intel_color_post_update(const struct intel_crtc_state *crtc_state) i915->display.funcs.color->color_post_update (crtc_state); } +void intel_color_modeset (const struct intel_crtc_state *crtc_state) +{ +struct intel_display *display =to_intel_display (crtc_state); + +intel_color_load_luts (crtc_state); +intel_color_commit_noarm (crtc_state); +intel_color_commit_arm (crtc_state); + +if (DISPLAY_VER (display) <9 ) { +struct intel_crtc *crtc =to_intel_crtc (crtc_state->uapi.crtc); +struct intel_plane *plane =to_intel_plane (crtc->base.primary); + +/* update DSPCNTR to configure gamma/csc for pipe bottom color */ + plane->disable_arm (plane, crtc_state); + } +} +void intel_color_prepare_commit (struct intel_atomic_state *state,struct intel_crtc *crtc) {
drivers/gpu/drm/i915/display/intel_color.h +1 -0
@@ -28,6 +28,7 @@ void intel_color_commit_noarm(const struct intel_crtc_state *crtc_state);void intel_color_commit_arm (const struct intel_crtc_state *crtc_state);void intel_color_post_update (const struct intel_crtc_state *crtc_state);void intel_color_load_luts (const struct intel_crtc_state *crtc_state); +void intel_color_modeset (const struct intel_crtc_state *crtc_state);void intel_color_get_config (struct intel_crtc_state *crtc_state); bool intel_color_lut_equal(const struct intel_crtc_state *crtc_state, const struct drm_property_blob *blob1,
drivers/gpu/drm/i915/display/intel_display.c +4 -29
@@ -1502,14 +1502,6 @@ static void intel_encoders_update_pipe(struct intel_atomic_state *state, } } -static void intel_disable_primary_plane (const struct intel_crtc_state *crtc_state) -{ -struct intel_crtc *crtc =to_intel_crtc (crtc_state->uapi.crtc); -struct intel_plane *plane =to_intel_plane (crtc->base.primary); - - plane->disable_arm (plane, crtc_state); -} -static void ilk_configure_cpu_transcoder (const struct intel_crtc_state *crtc_state) {struct intel_crtc *crtc =to_intel_crtc (crtc_state->uapi.crtc);
@@ -1575,11 +1567,7 @@ static void ilk_crtc_enable(struct intel_atomic_state *state,* On ILK+ LUT must be loaded before the pipe is running but with * clocks enabled */ -intel_color_load_luts (new_crtc_state); -intel_color_commit_noarm (new_crtc_state); -intel_color_commit_arm (new_crtc_state); -/* update DSPCNTR to configure gamma for pipe bottom color */ -intel_disable_primary_plane (new_crtc_state); +intel_color_modeset (new_crtc_state);intel_initial_watermarks (state, crtc);intel_enable_transcoder (new_crtc_state);
@@ -1741,12 +1729,7 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,* On ILK+ LUT must be loaded before the pipe is running but with * clocks enabled */ -intel_color_load_luts (pipe_crtc_state); -intel_color_commit_noarm (pipe_crtc_state); -intel_color_commit_arm (pipe_crtc_state); -/* update DSPCNTR to configure gamma/csc for pipe bottom color */ -if (DISPLAY_VER (dev_priv) <9 ) -intel_disable_primary_plane (pipe_crtc_state); +intel_color_modeset (pipe_crtc_state);hsw_set_linetime_wm (pipe_crtc_state);
@@ -2147,11 +2130,7 @@ static void valleyview_crtc_enable(struct intel_atomic_state *state,i9xx_pfit_enable (new_crtc_state); -intel_color_load_luts (new_crtc_state); -intel_color_commit_noarm (new_crtc_state); -intel_color_commit_arm (new_crtc_state); -/* update DSPCNTR to configure gamma for pipe bottom color */ -intel_disable_primary_plane (new_crtc_state); +intel_color_modeset (new_crtc_state);intel_initial_watermarks (state, crtc);intel_enable_transcoder (new_crtc_state);
@@ -2187,11 +2166,7 @@ static void i9xx_crtc_enable(struct intel_atomic_state *state,i9xx_pfit_enable (new_crtc_state); -intel_color_load_luts (new_crtc_state); -intel_color_commit_noarm (new_crtc_state); -intel_color_commit_arm (new_crtc_state); -/* update DSPCNTR to configure gamma for pipe bottom color */ -intel_disable_primary_plane (new_crtc_state); +intel_color_modeset (new_crtc_state);if (!intel_initial_watermarks (state, crtc))intel_update_watermarks (dev_priv);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 182/269 drm/i915: Plumb dsb all way to the plane hooks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
[ Upstream commit 01389846f7d61d262cc92d42ad4d1a25730e3eff ]
We need to be able to do both MMIO and DSB based pipe/plane programming. To that end plumb the 'dsb' all way from the top into the plane commit hooks.
The compiler appears smart enough to combine the branches from all the back-to-back register writes into a single branch. So the generated asm ends up looking more or less like this:plane_hook()
{
if (dsb) {
intel_dsb_reg_write();
intel_dsb_reg_write();
...
} else {
intel_de_write_fw();
intel_de_write_fw();
...
}
}which seems like a reasonably efficient way to do this.
An alternative I was also considering is some kind of closure (register write function + display vs. dsb pointer passed to it). That does result is smaller code as there are no branches anymore, but having each register access go via function pointer sounds less efficient.
Not that I actually measured the overhead of either approach yet. Also the reg_rw tracepoint seems to be making a huge mess of the generated code for the mmio path. And additionally there's some kind of IS_GSI_REG() hack in __raw_uncore_read() which ends up generating a pointless branch for every mmio register access. So looks like there might be quite a bit of room for improvement in the mmio path still.
Stable-dep-of: 30bfc151f0c1 ("drm/xe: Remove double pageflip")
--- drivers/gpu/drm/i915/display/i9xx_plane.c | 22 +- .../gpu/drm/i915/display/intel_atomic_plane.c | 49 +-- .../gpu/drm/i915/display/intel_atomic_plane.h | 19 +- drivers/gpu/drm/i915/display/intel_color.c | 2 +- drivers/gpu/drm/i915/display/intel_cursor.c | 101 +++--- drivers/gpu/drm/i915/display/intel_de.h | 11 + drivers/gpu/drm/i915/display/intel_display.c | 25 +- .../drm/i915/display/intel_display_types.h | 16 +- drivers/gpu/drm/i915/display/intel_sprite.c | 27 +- .../drm/i915/display/skl_universal_plane.c | 307 ++++++++++-------- drivers/gpu/drm/xe/display/xe_plane_initial.c | 2 +- 11 files changed, 334 insertions(+), 247 deletions(-)
drivers/gpu/drm/i915/display/i9xx_plane.c +14 -8
@@ -416,7 +416,8 @@ static int i9xx_plane_min_cdclk(const struct intel_crtc_state *crtc_state,return DIV_ROUND_UP (pixel_rate * num, den); } -static void i9xx_plane_update_noarm (struct intel_plane *plane, +static void i9xx_plane_update_noarm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -444,7 +445,8 @@ static void i9xx_plane_update_noarm(struct intel_plane *plane, } } -static void i9xx_plane_update_arm (struct intel_plane *plane, +static void i9xx_plane_update_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -507,7 +509,8 @@ static void i9xx_plane_update_arm(struct intel_plane *plane, intel_plane_ggtt_offset(plane_state) + dspaddr_offset); } -static void i830_plane_update_arm (struct intel_plane *plane, +static void i830_plane_update_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -517,11 +520,12 @@ static void i830_plane_update_arm(struct intel_plane *plane,* Additional breakage on i830 causes register reads to return * the last latched value instead of the last written value [ALM026]. */ -i9xx_plane_update_noarm (plane, crtc_state, plane_state); -i9xx_plane_update_arm (plane, crtc_state, plane_state); +i9xx_plane_update_noarm (dsb, plane, crtc_state, plane_state); +i9xx_plane_update_arm (dsb, plane, crtc_state, plane_state); } -static void i9xx_plane_disable_arm (struct intel_plane *plane, +static void i9xx_plane_disable_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state) {struct drm_i915_private *dev_priv =to_i915 (plane->base.dev);
@@ -549,7 +553,8 @@ static void i9xx_plane_disable_arm(struct intel_plane *plane, }static void -g4x_primary_async_flip (struct intel_plane *plane, +g4x_primary_async_flip (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state,bool async_flip)
@@ -569,7 +574,8 @@ g4x_primary_async_flip(struct intel_plane *plane, }static void -vlv_primary_async_flip (struct intel_plane *plane, +vlv_primary_async_flip (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state,bool async_flip)
drivers/gpu/drm/i915/display/intel_atomic_plane.c +29 -20
125 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_atomic_plane.h +13 -6
@@ -14,6 +14,7 @@ struct drm_rect;struct intel_atomic_state ;struct intel_crtc ;struct intel_crtc_state ; +struct intel_dsb ;struct intel_plane ;struct intel_plane_state ;enum plane_id ;
@@ -32,26 +33,32 @@ void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state, struct intel_crtc *crtc);void intel_plane_copy_hw_state (struct intel_plane_state *plane_state,const struct intel_plane_state *from_plane_state); -void intel_plane_async_flip (struct intel_plane *plane, +void intel_plane_async_flip (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state,bool async_flip); -void intel_plane_update_noarm (struct intel_plane *plane, +void intel_plane_update_noarm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state); -void intel_plane_update_arm (struct intel_plane *plane, +void intel_plane_update_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state); -void intel_plane_disable_arm (struct intel_plane *plane, +void intel_plane_disable_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state);struct intel_plane *intel_plane_alloc (void );void intel_plane_free (struct intel_plane *plane);struct drm_plane_state *intel_plane_duplicate_state (struct drm_plane *plane);void intel_plane_destroy_state (struct drm_plane *plane,struct drm_plane_state *state); -void intel_crtc_planes_update_noarm (struct intel_atomic_state *state, +void intel_crtc_planes_update_noarm (struct intel_dsb *dsb, +struct intel_atomic_state *state,struct intel_crtc *crtc); -void intel_crtc_planes_update_arm (struct intel_atomic_state *state, +void intel_crtc_planes_update_arm (struct intel_dsb *dsbx, +struct intel_atomic_state *state,struct intel_crtc *crtc); int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_state, struct intel_crtc_state *crtc_state,
drivers/gpu/drm/i915/display/intel_color.c +1 -1
@@ -1925,7 +1925,7 @@ void intel_color_modeset(const struct intel_crtc_state *crtc_state)struct intel_plane *plane =to_intel_plane (crtc->base.primary);/* update DSPCNTR to configure gamma/csc for pipe bottom color */ - plane->disable_arm (plane, crtc_state); + plane->disable_arm (NULL , plane, crtc_state); } }
drivers/gpu/drm/i915/display/intel_cursor.c +54 -47
215 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_de.h +11 -0
@@ -8,6 +8,7 @@#include "i915_drv.h" #include "i915_trace.h" +#include "intel_dsb.h" #include "intel_uncore.h" static inline struct intel_uncore *__to_uncore (struct intel_display *display)
@@ -233,4 +234,14 @@ __intel_de_write_notrace(struct intel_display *display, i915_reg_t reg, }#define intel_de_write_notrace (p,...) __intel_de_write_notrace(__to_intel_display(p), __VA_ARGS__) +static __always_inline void +intel_de_write_dsb (struct intel_display *display,struct intel_dsb *dsb, +i915_reg_t reg,u32 val) +{ +if (dsb) +intel_dsb_reg_write (dsb, reg, val); +else +intel_de_write_fw (display, reg, val); +} +#endif /* __INTEL_DE_H__ */
drivers/gpu/drm/i915/display/intel_display.c +14 -11
@@ -135,7 +135,8 @@static void intel_set_transcoder_timings (const struct intel_crtc_state *crtc_state);static void intel_set_pipe_src_size (const struct intel_crtc_state *crtc_state);static void hsw_set_transconf (const struct intel_crtc_state *crtc_state); -static void bdw_set_pipe_misc (const struct intel_crtc_state *crtc_state); +static void bdw_set_pipe_misc (struct intel_dsb *dsb, +const struct intel_crtc_state *crtc_state);/* returns HPLL frequency in kHz */ int vlv_get_hpll_vco (struct drm_i915_private *dev_priv)
@@ -715,7 +716,7 @@ void intel_plane_disable_noatomic(struct intel_crtc *crtc,if (DISPLAY_VER (dev_priv) ==2 && !crtc_state->active_planes)intel_set_cpu_fifo_underrun_reporting (dev_priv, crtc->pipe, false); -intel_plane_disable_arm (plane, crtc_state); +intel_plane_disable_arm (NULL , plane, crtc_state);intel_crtc_wait_for_next_vblank (crtc); }
@@ -1172,8 +1173,8 @@ static void intel_crtc_async_flip_disable_wa(struct intel_atomic_state *state,* Apart from the async flip bit we want to * preserve the old state for the plane. */ -intel_plane_async_flip (plane, old_crtc_state, - old_plane_state, false); +intel_plane_async_flip (NULL , plane, + old_crtc_state, old_plane_state, false); need_vbl_wait = true; } }
@@ -1315,7 +1316,7 @@ static void intel_crtc_disable_planes(struct intel_atomic_state *state, !(update_mask & BIT(plane->id)))continue ; -intel_plane_disable_arm (plane, new_crtc_state); +intel_plane_disable_arm (NULL , plane, new_crtc_state);if (old_plane_state->uapi.visible) fb_bits |= plane->frontbuffer_bit;
@@ -1704,7 +1705,7 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,intel_set_pipe_src_size (pipe_crtc_state);if (DISPLAY_VER (dev_priv) >=9 ||IS_BROADWELL (dev_priv)) -bdw_set_pipe_misc (pipe_crtc_state); +bdw_set_pipe_misc (NULL , pipe_crtc_state); }if (!transcoder_is_dsi (cpu_transcoder))
@@ -3221,9 +3222,11 @@ static void hsw_set_transconf(const struct intel_crtc_state *crtc_state)intel_de_posting_read (dev_priv,TRANSCONF (dev_priv, cpu_transcoder)); } -static void bdw_set_pipe_misc (const struct intel_crtc_state *crtc_state) +static void bdw_set_pipe_misc (struct intel_dsb *dsb, +const struct intel_crtc_state *crtc_state) {struct intel_crtc *crtc =to_intel_crtc (crtc_state->uapi.crtc); +struct intel_display *display =to_intel_display (crtc->base.dev);struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev);u32 val =0 ;
@@ -3268,7 +3271,7 @@ static void bdw_set_pipe_misc(const struct intel_crtc_state *crtc_state)if (IS_BROADWELL (dev_priv)) val |=PIPE_MISC_PSR_MASK_SPRITE_ENABLE ; -intel_de_write (dev_priv,PIPE_MISC (crtc->pipe), val); +intel_de_write_dsb (display, dsb,PIPE_MISC (crtc->pipe), val); }int bdw_get_pipe_misc_bpp (struct intel_crtc *crtc)
@@ -6821,7 +6824,7 @@ static void commit_pipe_pre_planes(struct intel_atomic_state *state,intel_color_commit_arm (new_crtc_state);if (DISPLAY_VER (dev_priv) >=9 ||IS_BROADWELL (dev_priv)) -bdw_set_pipe_misc (new_crtc_state); +bdw_set_pipe_misc (NULL , new_crtc_state);if (intel_crtc_needs_fastset (new_crtc_state))intel_pipe_fastset (old_crtc_state, new_crtc_state);
@@ -6921,7 +6924,7 @@ static void intel_pre_update_crtc(struct intel_atomic_state *state, intel_crtc_needs_color_update(new_crtc_state))intel_color_commit_noarm (new_crtc_state); -intel_crtc_planes_update_noarm (state, crtc); +intel_crtc_planes_update_noarm (NULL , state, crtc); } static void intel_update_crtc(struct intel_atomic_state *state,
@@ -6937,7 +6940,7 @@ static void intel_update_crtc(struct intel_atomic_state *state,commit_pipe_pre_planes (state, crtc); -intel_crtc_planes_update_arm (state, crtc); +intel_crtc_planes_update_arm (NULL , state, crtc);commit_pipe_post_planes (state, crtc);
drivers/gpu/drm/i915/display/intel_display_types.h +12 -4
@@ -1036,6 +1036,10 @@ struct intel_csc_matrix {u16 postoff[3 ]; }; +void intel_io_mmio_fw_write (void *ctx,i915_reg_t reg,u32 val); + +typedef void (*intel_io_reg_write )(void *ctx,i915_reg_t reg,u32 val); +struct intel_crtc_state {/* * uapi (drm) state. This is the software state shown to userspace.
@@ -1578,22 +1582,26 @@ struct intel_plane { u32 pixel_format, u64 modifier, unsigned int rotation);/* Write all non-self arming plane registers */ -void (*update_noarm)(struct intel_plane *plane, +void (*update_noarm)(struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state);/* Write all self-arming plane registers */ -void (*update_arm)(struct intel_plane *plane, +void (*update_arm)(struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state);/* Disable the plane, must arm */ -void (*disable_arm)(struct intel_plane *plane, +void (*disable_arm)(struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state);bool (*get_hw_state)(struct intel_plane *plane,enum pipe *pipe);int (*check_plane)(struct intel_crtc_state *crtc_state,struct intel_plane_state *plane_state);int (*min_cdclk)(const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state); -void (*async_flip)(struct intel_plane *plane, +void (*async_flip)(struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state,bool async_flip);
drivers/gpu/drm/i915/display/intel_sprite.c +18 -9
@@ -378,7 +378,8 @@ static void vlv_sprite_update_gamma(const struct intel_plane_state *plane_state) }static void -vlv_sprite_update_noarm (struct intel_plane *plane, +vlv_sprite_update_noarm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -399,7 +400,8 @@ vlv_sprite_update_noarm(struct intel_plane *plane, }static void -vlv_sprite_update_arm (struct intel_plane *plane, +vlv_sprite_update_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -449,7 +451,8 @@ vlv_sprite_update_arm(struct intel_plane *plane, }static void -vlv_sprite_disable_arm (struct intel_plane *plane, +vlv_sprite_disable_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state) {struct intel_display *display =to_intel_display (plane->base.dev);
@@ -795,7 +798,8 @@ static void ivb_sprite_update_gamma(const struct intel_plane_state *plane_state) }static void -ivb_sprite_update_noarm (struct intel_plane *plane, +ivb_sprite_update_noarm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -826,7 +830,8 @@ ivb_sprite_update_noarm(struct intel_plane *plane, }static void -ivb_sprite_update_arm (struct intel_plane *plane, +ivb_sprite_update_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -874,7 +879,8 @@ ivb_sprite_update_arm(struct intel_plane *plane, }static void -ivb_sprite_disable_arm (struct intel_plane *plane, +ivb_sprite_disable_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state) {struct intel_display *display =to_intel_display (plane->base.dev);
@@ -1133,7 +1139,8 @@ static void ilk_sprite_update_gamma(const struct intel_plane_state *plane_state) }static void -g4x_sprite_update_noarm (struct intel_plane *plane, +g4x_sprite_update_noarm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -1162,7 +1169,8 @@ g4x_sprite_update_noarm(struct intel_plane *plane, }static void -g4x_sprite_update_arm (struct intel_plane *plane, +g4x_sprite_update_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -1206,7 +1214,8 @@ g4x_sprite_update_arm(struct intel_plane *plane, }static void -g4x_sprite_disable_arm (struct intel_plane *plane, +g4x_sprite_disable_arm (struct intel_dsb *dsb, +struct intel_plane *plane,const struct intel_crtc_state *crtc_state) {struct intel_display *display =to_intel_display (plane->base.dev);
drivers/gpu/drm/i915/display/skl_universal_plane.c +167 -140
525 lines not on this page · raw message
drivers/gpu/drm/xe/display/xe_plane_initial.c +1 -1
@@ -248,7 +248,7 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,* the lookup of sysmem scratch pages. */ plane->check_plane (crtc_state, plane_state); - plane->async_flip (plane, crtc_state, plane_state, true); + plane->async_flip (NULL , plane, crtc_state, plane_state, true);return ; nofb:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 183/269 drm/xe: Remove double pageflip
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maarten Lankhorst <[email protected]>
[ Upstream commit 30bfc151f0c1ec80c27a80a7651b2c15c648ad16 ]
This is already handled below in the code by fixup_initial_plane_config.
--- drivers/gpu/drm/xe/display/xe_plane_initial.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/gpu/drm/xe/display/xe_plane_initial.c +0 -10
@@ -194,8 +194,6 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,to_intel_plane (crtc->base.primary);struct intel_plane_state *plane_state =to_intel_plane_state (plane->base.state); -struct intel_crtc_state *crtc_state = -to_intel_crtc_state (crtc->base.state);struct drm_framebuffer *fb;struct i915_vma *vma;
@@ -241,14 +239,6 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,atomic_or (plane->frontbuffer_bit, &to_intel_frontbuffer (fb)->bits); plane_config->vma = vma; - -/* -* Flip to the newly created mapping ASAP, so we can re-use the -* first part of GGTT for WOPCM, prevent flickering, and prevent -* the lookup of sysmem scratch pages. -*/ - plane->check_plane (crtc_state, plane_state); - plane->async_flip (NULL , plane, crtc_state, plane_state, true);return ; nofb:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 184/269 HID: hid-steam: Fix use-after-free when detaching device
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vicki Pfau <[email protected]>
[ Upstream commit e53fc232a65f7488ab75d03a5b95f06aaada7262 ]
When a hid-steam device is removed it must clean up the client_hdev used for intercepting hidraw access. This can lead to scheduling deferred work to reattach the input device. Though the cleanup cancels the deferred work, this was done before the client_hdev itself is cleaned up, so it gets rescheduled. This patch fixes the ordering to make sure the deferred work is properly canceled.
--- drivers/hid/hid-steam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-steam.c +1 -1
@@ -1327,11 +1327,11 @@ static void steam_remove(struct hid_device *hdev)return ; } +hid_destroy_device (steam->client_hdev);cancel_delayed_work_sync (&steam->mode_switch);cancel_work_sync (&steam->work_connect);cancel_work_sync (&steam->rumble_work);cancel_work_sync (&steam->unregister_work); -hid_destroy_device (steam->client_hdev); steam->client_hdev =NULL ; steam->client_opened =0 ;if (steam->quirks &STEAM_QUIRK_WIRELESS ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 185/269 net: ipa: Fix v4.7 resource group names
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit 5eb3dc1396aa7e315486b24df80df782912334b7 ]
In the downstream IPA driver there's only one group defined for source and destination, and the destination group doesn't have a _DPL suffix.
--- drivers/net/ipa/data/ipa_data-v4.7.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/net/ipa/data/ipa_data-v4.7.c +5 -7
@@ -28,12 +28,10 @@ enum ipa_resource_type {enum ipa_rsrc_group_id {/* Source resource group identifiers */ IPA_RSRC_GROUP_SRC_UL_DL =0 , -IPA_RSRC_GROUP_SRC_UC_RX_Q ,IPA_RSRC_GROUP_SRC_COUNT ,/* Last in set; not a source group */ /* Destination resource group identifiers */ -IPA_RSRC_GROUP_DST_UL_DL_DPL =0 , -IPA_RSRC_GROUP_DST_UNUSED_1 , +IPA_RSRC_GROUP_DST_UL_DL =0 ,IPA_RSRC_GROUP_DST_COUNT ,/* Last; not a destination group */ };
@@ -81,7 +79,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { }, .endpoint = { .config = { - .resource_group = IPA_RSRC_GROUP_DST_UL_DL_DPL, + .resource_group = IPA_RSRC_GROUP_DST_UL_DL, .aggregation = true, .status_enable = true, .rx = {
@@ -128,7 +126,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { }, .endpoint = { .config = { - .resource_group = IPA_RSRC_GROUP_DST_UL_DL_DPL, + .resource_group = IPA_RSRC_GROUP_DST_UL_DL, .qmap = true, .aggregation = true, .rx = {
@@ -197,12 +195,12 @@ static const struct ipa_resource ipa_resource_src[] = {/* Destination resource configuration data for an SoC having IPA v4.7 */ static const struct ipa_resource ipa_resource_dst[] = { [IPA_RESOURCE_TYPE_DST_DATA_SECTORS ] = { - .limits[IPA_RSRC_GROUP_DST_UL_DL_DPL ] = { + .limits[IPA_RSRC_GROUP_DST_UL_DL ] = { .min =7 , .max =7 , }, }, [IPA_RESOURCE_TYPE_DST_DPS_DMARS ] = { - .limits[IPA_RSRC_GROUP_DST_UL_DL_DPL ] = { + .limits[IPA_RSRC_GROUP_DST_UL_DL ] = { .min =2 , .max =2 , }, },
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 186/269 net: ipa: Fix QSB data for v4.7
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit 6a2843aaf551d87beb92d774f7d5b8ae007fe774 ]
As per downstream reference, max_writes should be 12 and max_reads should be 13.
--- drivers/net/ipa/data/ipa_data-v4.7.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ipa/data/ipa_data-v4.7.c +2 -2
@@ -38,8 +38,8 @@ enum ipa_rsrc_group_id {/* QSB configuration data for an SoC having IPA v4.7 */ static const struct ipa_qsb_data ipa_qsb_data[] = { [IPA_QSB_MASTER_DDR ] = { - .max_writes =8 , - .max_reads =0 ,/* no limit (hardware max) */ + .max_writes =12 , + .max_reads =13 , .max_reads_beats =120 , }, };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 187/269 net: ipa: Enable checksum for IPA_ENDPOINT_AP_MODEM_{RX,TX} for v4.7
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit 934e69669e32eb653234898424ae007bae2f636e ]
Enable the checksum option for these two endpoints in order to allow mobile data to actually work. Without this, no packets seem to make it through the IPA.
--- drivers/net/ipa/data/ipa_data-v4.7.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ipa/data/ipa_data-v4.7.c +2 -0
@@ -104,6 +104,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .filter_support = true, .config = { .resource_group = IPA_RSRC_GROUP_SRC_UL_DL, + .checksum = true, .qmap = true, .status_enable = true, .tx = {
@@ -127,6 +128,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .endpoint = { .config = { .resource_group = IPA_RSRC_GROUP_DST_UL_DL, + .checksum = true, .qmap = true, .aggregation = true, .rx = {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 188/269 ppp: Fix KMSAN uninit-value warning with bpf
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 4c2d14c40a68678d885eab4008a0129646805bae ]
Syzbot caught an "KMSAN: uninit-value" warning [1], which is caused by the ppp driver not initializing a 2-byte header when using socket filter.
The following code can generate a PPP filter BPF program:
'''
struct bpf_program fp;pcap_t *handle;
handle = pcap_open_dead(DLT_PPP_PPPD, 65535); pcap_compile(handle, &fp, "ip and outbound", 0, 0); bpf_dump(&fp, 1);
'''
Its output is:
'''
(000) ldh [2]
(001) jeq #0x21 jt 2 jf 5
(002) ldb [0]
(003) jeq #0x1 jt 4 jf 5
(004) ret #65535
(005) ret #0
'''
Wen can find similar code at the following link:
https://github.com/ppp-project/ppp/blob/master/pppd/options.c#L1680
The maintainer of this code repository is also the original maintainer of the ppp driver.
As you can see the BPF program skips 2 bytes of data and then reads the 'Protocol' field to determine if it's an IP packet. Then it read the first byte of the first 2 bytes to determine the direction.
The issue is that only the first byte indicating direction is initialized in current ppp driver code while the second byte is not initialized.
For normal BPF programs generated by libpcap, uninitialized data won't be used, so it's not a problem. However, for carefully crafted BPF programs, such as those generated by syzkaller [2], which start reading from offset 0, the uninitialized data will be used and caught by KMSAN.
[1] https://syzkaller.appspot.com/bug?extid=853242d9c9917165d791
[2] https://syzkaller.appspot.com/text?tag=ReproC&x=11994913980000
--- drivers/net/ppp/ppp_generic.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/net/ppp/ppp_generic.c +19 -9
@@ -72,6 +72,17 @@#define PPP_PROTO_LEN 2#define PPP_LCP_HDRLEN 4 +/* The filter instructions generated by libpcap are constructed +* assuming a four-byte PPP header on each packet, where the last +* 2 bytes are the protocol field defined in the RFC and the first +* byte of the first 2 bytes indicates the direction. +* The second byte is currently unused, but we still need to initialize +* it to prevent crafted BPF programs from reading them which would +* cause reading of uninitialized data. +*/ +#define PPP_FILTER_OUTBOUND_TAG 0x0100 +#define PPP_FILTER_INBOUND_TAG 0x0000 +/* * An instance of /dev/ppp can be associated with either a ppp * interface unit or a ppp channel. In both cases, file->private_data
@@ -1762,10 +1773,10 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)if (proto <0x8000 ) {#ifdef CONFIG_PPP_FILTER -/* check if we should pass this packet */ -/* the filter instructions are constructed assuming -a four-byte PPP header on each packet */ - *(u8 *)skb_push (skb,2 ) =1 ; +/* check if the packet passes the pass and active filters. +* See comment for PPP_FILTER_OUTBOUND_TAG above. +*/ + *(__be16 *)skb_push (skb,2 ) =htons (PPP_FILTER_OUTBOUND_TAG );if (ppp->pass_filter &&bpf_prog_run (ppp->pass_filter, skb) ==0 ) {if (ppp->debug &1 )
@@ -2482,14 +2493,13 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)/* network protocol frame - give it to the kernel */ #ifdef CONFIG_PPP_FILTER -/* check if the packet passes the pass and active filters */ -/* the filter instructions are constructed assuming -a four-byte PPP header on each packet */ if (ppp->pass_filter || ppp->active_filter) {if (skb_unclone (skb,GFP_ATOMIC )) goto err; - - *(u8 *)skb_push (skb,2 ) =0 ; +/* Check if the packet passes the pass and active filters. +* See comment for PPP_FILTER_INBOUND_TAG above. +*/ + *(__be16 *)skb_push (skb,2 ) =htons (PPP_FILTER_INBOUND_TAG );if (ppp->pass_filter &&bpf_prog_run (ppp->pass_filter, skb) ==0 ) {if (ppp->debug &1 )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 189/269 ethtool: linkstate: migrate linkstate functions to support multi-PHY setups
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit fe55b1d401c697c2ef126fe3ebbcaa6885fced5a ]
Adapt linkstate_get_sqi() and linkstate_get_sqi_max() to take a phy_device argument directly, enabling support for setups with multiple PHYs. The previous assumption of a single PHY attached to a net_device no longer holds.
Use ethnl_req_get_phydev() to identify the appropriate PHY device for the operation. Update linkstate_prepare_data() and related logic to accommodate this change, ensuring compatibility with multi-PHY configurations.
Stable-dep-of: 637399bf7e77 ("net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device")
--- net/ethtool/linkstate.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
net/ethtool/linkstate.c +15 -8
@@ -26,9 +26,8 @@ const struct nla_policy ethnl_linkstate_get_policy[] = { NLA_POLICY_NESTED(ethnl_header_policy_stats), }; -static int linkstate_get_sqi (struct net_device *dev) +static int linkstate_get_sqi (struct phy_device *phydev) { -struct phy_device *phydev = dev->phydev;int ret;if (!phydev)
@@ -46,9 +45,8 @@ static int linkstate_get_sqi(struct net_device *dev)return ret; } -static int linkstate_get_sqi_max (struct net_device *dev) +static int linkstate_get_sqi_max (struct phy_device *phydev) { -struct phy_device *phydev = dev->phydev;int ret;if (!phydev)
@@ -100,19 +98,28 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base, {struct linkstate_reply_data *data =LINKSTATE_REPDATA (reply_base);struct net_device *dev = reply_base->dev; +struct nlattr **tb = info->attrs; +struct phy_device *phydev;int ret; + phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_LINKSTATE_HEADER ], + info->extack); +if (IS_ERR (phydev)) { + ret =PTR_ERR (phydev); + goto out; + } + ret =ethnl_ops_begin (dev);if (ret <0 )return ret; data->link =__ethtool_get_link (dev); - ret =linkstate_get_sqi (dev); + ret =linkstate_get_sqi (phydev);if (linkstate_sqi_critical_error (ret)) goto out; data->sqi = ret; - ret =linkstate_get_sqi_max (dev); + ret =linkstate_get_sqi_max (phydev);if (linkstate_sqi_critical_error (ret)) goto out; data->sqi_max = ret;
@@ -127,9 +134,9 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base, sizeof(data->link_stats) / 8);if (req_base->flags ÐTOOL_FLAG_STATS ) { -if (dev->phydev) +if (phydev) data->link_stats.link_down_events = -READ_ONCE (dev->phydev->link_down_events); +READ_ONCE (phydev->link_down_events);if (dev->ethtool_ops->get_link_ext_stats) dev->ethtool_ops->get_link_ext_stats(dev,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 190/269 net: ethtool: plumb PHY stats to PHY drivers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit b7a2c1fe6b55364e61b4b54b991eb43a47bb1104 ]
Introduce support for standardized PHY statistics reporting in ethtool by extending the PHYLIB framework. Add the functions phy_ethtool_get_phy_stats() and phy_ethtool_get_link_ext_stats() to provide a consistent interface for retrieving PHY-level and link-specific statistics. These functions are used within the ethtool implementation to avoid direct access to the phy_device structure outside of the PHYLIB framework.
A new structure, ethtool_phy_stats, is introduced to standardize PHY statistics such as packet counts, byte counts, and error counters. Drivers are updated to include callbacks for retrieving PHY and link-specific statistics, ensuring values are explicitly set only for supported fields, initialized with ETHTOOL_STAT_NOT_SET to avoid ambiguity.
Stable-dep-of: 637399bf7e77 ("net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device")
--- drivers/net/phy/phy.c | 43 ++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 2 ++ include/linux/ethtool.h | 23 +++++++++++++++++++ include/linux/phy.h | 36 ++++++++++++++++++++++++++++++ include/linux/phylib_stubs.h | 42 +++++++++++++++++++++++++++++++++++ net/ethtool/linkstate.c | 5 +++-- net/ethtool/stats.c | 18 +++++++++++++++ 7 files changed, 167 insertions(+), 2 deletions(-)
drivers/net/phy/phy.c +43 -0
@@ -615,6 +615,49 @@ int phy_ethtool_get_stats(struct phy_device *phydev, }EXPORT_SYMBOL (phy_ethtool_get_stats); +/** +* __phy_ethtool_get_phy_stats - Retrieve standardized PHY statistics +* @phydev: Pointer to the PHY device +* @phy_stats: Pointer to ethtool_eth_phy_stats structure +* @phydev_stats: Pointer to ethtool_phy_stats structure +* +* Fetches PHY statistics using a kernel-defined interface for consistent +* diagnostics. Unlike phy_ethtool_get_stats(), which allows custom stats, +* this function enforces a standardized format for better interoperability. +*/ +void __phy_ethtool_get_phy_stats (struct phy_device *phydev, +struct ethtool_eth_phy_stats *phy_stats, +struct ethtool_phy_stats *phydev_stats) +{ +if (!phydev->drv || !phydev->drv->get_phy_stats) +return ; + +mutex_lock (&phydev->lock); + phydev->drv->get_phy_stats (phydev, phy_stats, phydev_stats); +mutex_unlock (&phydev->lock); +} + +/** +* __phy_ethtool_get_link_ext_stats - Retrieve extended link statistics for a PHY +* @phydev: Pointer to the PHY device +* @link_stats: Pointer to the structure to store extended link statistics +* +* Populates the ethtool_link_ext_stats structure with link down event counts +* and additional driver-specific link statistics, if available. +*/ +void __phy_ethtool_get_link_ext_stats (struct phy_device *phydev, +struct ethtool_link_ext_stats *link_stats) +{ + link_stats->link_down_events =READ_ONCE (phydev->link_down_events); + +if (!phydev->drv || !phydev->drv->get_link_stats) +return ; + +mutex_lock (&phydev->lock); + phydev->drv->get_link_stats (phydev, link_stats); +mutex_unlock (&phydev->lock); +} +/** * phy_ethtool_get_plca_cfg - Get PLCA RS configuration * @phydev: the phy_device struct
drivers/net/phy/phy_device.c +2 -0
@@ -3776,6 +3776,8 @@ static const struct ethtool_phy_ops phy_ethtool_phy_ops = {static const struct phylib_stubs __phylib_stubs = { .hwtstamp_get = __phy_hwtstamp_get, .hwtstamp_set = __phy_hwtstamp_set, + .get_phy_stats = __phy_ethtool_get_phy_stats, + .get_link_ext_stats = __phy_ethtool_get_link_ext_stats, };static void phylib_register_stubs (void )
include/linux/ethtool.h +23 -0
@@ -412,6 +412,29 @@ struct ethtool_eth_phy_stats { ); }; +/** +* struct ethtool_phy_stats - PHY-level statistics counters +* @rx_packets: Total successfully received frames +* @rx_bytes: Total successfully received bytes +* @rx_errors: Total received frames with errors (e.g., CRC errors) +* @tx_packets: Total successfully transmitted frames +* @tx_bytes: Total successfully transmitted bytes +* @tx_errors: Total transmitted frames with errors +* +* This structure provides a standardized interface for reporting +* PHY-level statistics counters. It is designed to expose statistics +* commonly provided by PHYs but not explicitly defined in the IEEE +* 802.3 standard. +*/ +struct ethtool_phy_stats { +u64 rx_packets; +u64 rx_bytes; +u64 rx_errors; +u64 tx_packets; +u64 tx_bytes; +u64 tx_errors; +}; +/* Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*), not otherwise exposed * via a more targeted API. */
include/linux/phy.h +36 -0
@@ -1090,6 +1090,35 @@ struct phy_driver {int (*cable_test_get_status)(struct phy_device *dev,bool *finished);/* Get statistics from the PHY using ethtool */ +/** +* @get_phy_stats: Retrieve PHY statistics. +* @dev: The PHY device for which the statistics are retrieved. +* @eth_stats: structure where Ethernet PHY stats will be stored. +* @stats: structure where additional PHY-specific stats will be stored. +* +* Retrieves the supported PHY statistics and populates the provided +* structures. The input structures are pre-initialized with +* `ETHTOOL_STAT_NOT_SET`, and the driver must only modify members +* corresponding to supported statistics. Unmodified members will remain +* set to `ETHTOOL_STAT_NOT_SET` and will not be returned to userspace. +*/ +void (*get_phy_stats)(struct phy_device *dev, +struct ethtool_eth_phy_stats *eth_stats, +struct ethtool_phy_stats *stats); + +/** +* @get_link_stats: Retrieve link statistics. +* @dev: The PHY device for which the statistics are retrieved. +* @link_stats: structure where link-specific stats will be stored. +* +* Retrieves link-related statistics for the given PHY device. The input +* structure is pre-initialized with `ETHTOOL_STAT_NOT_SET`, and the +* driver must only modify members corresponding to supported +* statistics. Unmodified members will remain set to +* `ETHTOOL_STAT_NOT_SET` and will not be returned to userspace. +*/ +void (*get_link_stats)(struct phy_device *dev, +struct ethtool_link_ext_stats *link_stats);/** @get_sset_count: Number of statistic counters */ int (*get_sset_count)(struct phy_device *dev);/** @get_strings: Names of the statistic counters */
@@ -2055,6 +2084,13 @@ int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);int phy_ethtool_get_sset_count (struct phy_device *phydev);int phy_ethtool_get_stats (struct phy_device *phydev,struct ethtool_stats *stats,u64 *data); + +void __phy_ethtool_get_phy_stats (struct phy_device *phydev, +struct ethtool_eth_phy_stats *phy_stats, +struct ethtool_phy_stats *phydev_stats); +void __phy_ethtool_get_link_ext_stats (struct phy_device *phydev, +struct ethtool_link_ext_stats *link_stats); +int phy_ethtool_get_plca_cfg (struct phy_device *phydev,struct phy_plca_cfg *plca_cfg); int phy_ethtool_set_plca_cfg(struct phy_device *phydev,
include/linux/phylib_stubs.h +42 -0
64 lines not on this page · raw message
net/ethtool/linkstate.c +3 -2
@@ -3,6 +3,7 @@#include "netlink.h" #include "common.h" #include <linux/phy.h> +#include <linux/phylib_stubs.h> struct linkstate_req_info {struct ethnl_req_info base;
@@ -135,8 +136,8 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base,if (req_base->flags ÐTOOL_FLAG_STATS ) {if (phydev) - data->link_stats.link_down_events = -READ_ONCE (phydev->link_down_events); +phy_ethtool_get_link_ext_stats (phydev, + &data->link_stats);if (dev->ethtool_ops->get_link_ext_stats) dev->ethtool_ops->get_link_ext_stats(dev,
net/ethtool/stats.c +18 -0
@@ -1,5 +1,8 @@// SPDX-License-Identifier: GPL-2.0-only +#include <linux/phy.h> +#include <linux/phylib_stubs.h> +#include "netlink.h" #include "common.h" #include "bitset.h"
@@ -20,6 +23,7 @@ struct stats_reply_data {struct ethtool_eth_mac_stats mac_stats;struct ethtool_eth_ctrl_stats ctrl_stats;struct ethtool_rmon_stats rmon_stats; +struct ethtool_phy_stats phydev_stats; );const struct ethtool_rmon_hist_range *rmon_ranges; };
@@ -120,8 +124,15 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base,struct stats_reply_data *data =STATS_REPDATA (reply_base);enum ethtool_mac_stats_src src = req_info->src;struct net_device *dev = reply_base->dev; +struct nlattr **tb = info->attrs; +struct phy_device *phydev;int ret; + phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_STATS_HEADER ], + info->extack); +if (IS_ERR (phydev)) +return PTR_ERR (phydev); + ret =ethnl_ops_begin (dev);if (ret <0 )return ret;
@@ -145,6 +156,13 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, data->ctrl_stats.src = src; data->rmon_stats.src = src; +if (test_bit (ETHTOOL_STATS_ETH_PHY , req_info->stat_mask) && + src ==ETHTOOL_MAC_STATS_SRC_AGGREGATE ) { +if (phydev) +phy_ethtool_get_phy_stats (phydev, &data->phy_stats, + &data->phydev_stats); + } +if (test_bit (ETHTOOL_STATS_ETH_PHY , req_info->stat_mask) && dev->ethtool_ops->get_eth_phy_stats) dev->ethtool_ops->get_eth_phy_stats (dev, &data->phy_stats);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 191/269 net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 637399bf7e77797811adf340090b561a8f9d1213 ]
ethnl_req_get_phydev() is used to lookup a phy_device, in the case an ethtool netlink command targets a specific phydev within a netdev's topology.
It takes as a parameter a const struct nlattr *header that's used for error handling :
if (!phydev) {
NL_SET_ERR_MSG_ATTR(extack, header,
"no phy matching phyindex");
return ERR_PTR(-ENODEV);
}In the notify path after a ->set operation however, there's no request attributes available.
The typical callsite for the above function looks like:
phydev = ethnl_req_get_phydev(req_base, tb[ETHTOOL_A_XXX_HEADER], info->extack);
So, when tb is NULL (such as in the ethnl notify path), we have a nice crash.
It turns out that there's only the PLCA command that is in that case, as the other phydev-specific commands don't have a notification.
This commit fixes the crash by passing the cmd index and the nlattr array separately, allowing NULL-checking it directly inside the helper.
--- net/ethtool/cabletest.c | 8 ++++---- net/ethtool/linkstate.c | 2 +- net/ethtool/netlink.c | 6 +++--- net/ethtool/netlink.h | 5 +++-- net/ethtool/phy.c | 2 +- net/ethtool/plca.c | 6 +++--- net/ethtool/pse-pd.c | 4 ++-- net/ethtool/stats.c | 2 +- net/ethtool/strset.c | 2 +- 9 files changed, 19 insertions(+), 18 deletions(-)
net/ethtool/cabletest.c +4 -4
@@ -72,8 +72,8 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info) dev = req_info.dev;rtnl_lock (); - phydev =ethnl_req_get_phydev (&req_info, - tb[ETHTOOL_A_CABLE_TEST_HEADER ], + phydev =ethnl_req_get_phydev (&req_info, tb, +ETHTOOL_A_CABLE_TEST_HEADER , info->extack);if (IS_ERR_OR_NULL (phydev)) { ret = -EOPNOTSUPP ;
@@ -339,8 +339,8 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info) goto out_dev_put;rtnl_lock (); - phydev =ethnl_req_get_phydev (&req_info, - tb[ETHTOOL_A_CABLE_TEST_TDR_HEADER ], + phydev =ethnl_req_get_phydev (&req_info, tb, +ETHTOOL_A_CABLE_TEST_TDR_HEADER , info->extack);if (IS_ERR_OR_NULL (phydev)) { ret = -EOPNOTSUPP ;
net/ethtool/linkstate.c +1 -1
@@ -103,7 +103,7 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base,struct phy_device *phydev;int ret; - phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_LINKSTATE_HEADER ], + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_LINKSTATE_HEADER , info->extack);if (IS_ERR (phydev)) { ret =PTR_ERR (phydev);
net/ethtool/netlink.c +3 -3
@@ -210,7 +210,7 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, }struct phy_device *ethnl_req_get_phydev (const struct ethnl_req_info *req_info, -const struct nlattr *header, +struct nlattr **tb,unsigned int header,struct netlink_ext_ack *extack) {struct phy_device *phydev;
@@ -224,8 +224,8 @@ struct phy_device *ethnl_req_get_phydev(const struct ethnl_req_info *req_info,return req_info->dev->phydev; phydev =phy_link_topo_get_phy (req_info->dev, req_info->phy_index); -if (!phydev) { -NL_SET_ERR_MSG_ATTR (extack, header, +if (!phydev && tb) { +NL_SET_ERR_MSG_ATTR (extack, tb[header],"no phy matching phyindex" );return ERR_PTR (-ENODEV ); }
net/ethtool/netlink.h +3 -2
@@ -275,7 +275,8 @@ static inline void ethnl_parse_header_dev_put(struct ethnl_req_info *req_info)* ethnl_req_get_phydev() - Gets the phy_device targeted by this request, * if any. Must be called under rntl_lock(). * @req_info: The ethnl request to get the phy from. -* @header: The netlink header, used for error reporting. +* @tb: The netlink attributes array, for error reporting. +* @header: The netlink header index, used for error reporting. * @extack: The netlink extended ACK, for error reporting. * * The caller must hold RTNL, until it's done interacting with the returned
@@ -289,7 +290,7 @@ static inline void ethnl_parse_header_dev_put(struct ethnl_req_info *req_info)* is returned. */ struct phy_device *ethnl_req_get_phydev (const struct ethnl_req_info *req_info, -const struct nlattr *header, +struct nlattr **tb,unsigned int header,struct netlink_ext_ack *extack);/**
net/ethtool/phy.c +1 -1
@@ -125,7 +125,7 @@ static int ethnl_phy_parse_request(struct ethnl_req_info *req_base,struct phy_req_info *req_info =PHY_REQINFO (req_base);struct phy_device *phydev; - phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_PHY_HEADER ], + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_PHY_HEADER , extack);if (!phydev)return 0 ;
net/ethtool/plca.c +3 -3
@@ -62,7 +62,7 @@ static int plca_get_cfg_prepare_data(const struct ethnl_req_info *req_base,struct phy_device *phydev;int ret; - phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_PLCA_HEADER ], + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_PLCA_HEADER , info->extack);// check that the PHY device is available and connected if (IS_ERR_OR_NULL (phydev)) {
@@ -152,7 +152,7 @@ ethnl_set_plca(struct ethnl_req_info *req_info, struct genl_info *info)bool mod = false;int ret; - phydev =ethnl_req_get_phydev (req_info, tb[ETHTOOL_A_PLCA_HEADER ], + phydev =ethnl_req_get_phydev (req_info, tb,ETHTOOL_A_PLCA_HEADER , info->extack);// check that the PHY device is available and connected if (IS_ERR_OR_NULL (phydev))
@@ -211,7 +211,7 @@ static int plca_get_status_prepare_data(const struct ethnl_req_info *req_base,struct phy_device *phydev;int ret; - phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_PLCA_HEADER ], + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_PLCA_HEADER , info->extack);// check that the PHY device is available and connected if (IS_ERR_OR_NULL (phydev)) {
net/ethtool/pse-pd.c +2 -2
@@ -64,7 +64,7 @@ static int pse_prepare_data(const struct ethnl_req_info *req_base,if (ret <0 )return ret; - phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_PSE_HEADER ], + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_PSE_HEADER , info->extack);if (IS_ERR (phydev))return -ENODEV ;
@@ -261,7 +261,7 @@ ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info)struct phy_device *phydev;int ret; - phydev =ethnl_req_get_phydev (req_info, tb[ETHTOOL_A_PSE_HEADER ], + phydev =ethnl_req_get_phydev (req_info, tb,ETHTOOL_A_PSE_HEADER , info->extack); ret =ethnl_set_pse_validate (phydev, info);if (ret)
net/ethtool/stats.c +1 -1
@@ -128,7 +128,7 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base,struct phy_device *phydev;int ret; - phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_STATS_HEADER ], + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_STATS_HEADER , info->extack);if (IS_ERR (phydev))return PTR_ERR (phydev);
net/ethtool/strset.c +1 -1
@@ -299,7 +299,7 @@ static int strset_prepare_data(const struct ethnl_req_info *req_base,return 0 ; } - phydev =ethnl_req_get_phydev (req_base, tb[ETHTOOL_A_HEADER_FLAGS ], + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_HEADER_FLAGS , info->extack);/* phydev can be NULL, check for errors only */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 192/269 vlan: enforce underlying device type
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oscar Maes <[email protected]>
[ Upstream commit b33a534610067ade2bdaf2052900aaad99701353 ]
Currently, VLAN devices can be created on top of non-ethernet devices.
Besides the fact that it doesn't make much sense, this also causes a bug which leaks the address of a kernel function to usermode.
When creating a VLAN device, we initialize GARP (garp_init_applicant) and MRP (mrp_init_applicant) for the underlying device.
As part of the initialization process, we add the multicast address of each applicant to the underlying device, by calling dev_mc_add.
__dev_mc_add uses dev->addr_len to determine the length of the new multicast address.
This causes an out-of-bounds read if dev->addr_len is greater than 6, since the multicast addresses provided by GARP and MRP are only 6 bytes long.
This behaviour can be reproduced using the following commands:
ip tunnel add gretest mode ip6gre local ::1 remote ::2 dev lo ip l set up dev gretest
ip link add link gretest name vlantest type vlan id 100
Then, the following command will display the address of garp_pdu_rcv:
ip maddr show | grep 01:80:c2:00:00:21
Fix the bug by enforcing the type of the underlying device during VLAN device initialization.
--- net/8021q/vlan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/8021q/vlan.c +2 -1
@@ -131,7 +131,8 @@ int vlan_check_real_dev(struct net_device *real_dev, {const char *name = real_dev->name; -if (real_dev->features &NETIF_F_VLAN_CHALLENGED ) { +if (real_dev->features &NETIF_F_VLAN_CHALLENGED || + real_dev->type !=ARPHRD_ETHER ) {pr_info ("VLANs not supported on %s\n" , name);NL_SET_ERR_MSG_MOD (extack,"VLANs not supported on device" );return -EOPNOTSUPP ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 193/269 x86/sgx: Fix size overflows in sgx_encl_create()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
[ Upstream commit 0d3e0dfd68fb9e6b0ec865be9f3377cc3ff55733 ]
The total size calculated for EPC can overflow u64 given the added up page for SECS. Further, the total size calculated for shmem can overflow even when the EPC size stays within limits of u64, given that it adds the extra space for 128 byte PCMD structures (one for each page).
Address this by pre-evaluating the micro-architectural requirement of
SGX: the address space size must be power of two. This is eventually checked up by ECREATE but the pre-check has the additional benefit of making sure that there is some space for additional data.
--- arch/x86/kernel/cpu/sgx/ioctl.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/cpu/sgx/ioctl.c +7 -0
@@ -64,6 +64,13 @@ static int sgx_encl_create(struct sgx_encl *encl, struct sgx_secs *secs)struct file *backing;long ret; +/* +* ECREATE would detect this too, but checking here also ensures +* that the 'encl_size' calculations below can never overflow. +*/ +if (!is_power_of_2 (secs->size)) +return -EINVAL ; + va_page =sgx_encl_grow (encl, true);if (IS_ERR (va_page))return PTR_ERR (va_page);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 194/269 exfat: fix just enough dentries but allocate a new cluster to dir
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuezhang Mo <[email protected]>
[ Upstream commit 6697f819a10b238ccf01998c3f203d65d8374696 ]
This commit fixes the condition for allocating cluster to parent directory to avoid allocating new cluster to parent directory when there are just enough empty directory entries at the end of the parent directory.
--- fs/exfat/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exfat/namei.c +1 -1
@@ -237,7 +237,7 @@ static int exfat_search_empty_slot(struct super_block *sb, dentry =0 ; } -while (dentry + num_entries < total_entries && +while (dentry + num_entries <= total_entries && clu.dir !=EXFAT_EOF_CLUSTER ) { i = dentry & (dentries_per_clu -1 );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 195/269 exfat: fix soft lockup in exfat_clear_bitmap
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 9da33619e0ca53627641bc97d1b93ec741299111 ]
bitmap clear loop will take long time in __exfat_free_cluster() if data size of file/dir enty is invalid.
If cluster bit in bitmap is already clear, stop clearing bitmap go to out of loop.
--- fs/exfat/balloc.c | 10 ++++++++-- fs/exfat/exfat_fs.h | 2 +- fs/exfat/fatent.c | 11 +++++++---- 3 files changed, 16 insertions(+), 7 deletions(-)
fs/exfat/balloc.c +8 -2
@@ -141,7 +141,7 @@ int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync)return 0 ; } -void exfat_clear_bitmap (struct inode *inode,unsigned int clu,bool sync) +int exfat_clear_bitmap (struct inode *inode,unsigned int clu,bool sync) {int i, b;unsigned int ent_idx;
@@ -150,13 +150,17 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync)struct exfat_mount_options *opts = &sbi->options;if (!is_valid_cluster (sbi, clu)) -return ; +return -EIO ; ent_idx =CLUSTER_TO_BITMAP_ENT (clu); i =BITMAP_OFFSET_SECTOR_INDEX (sb, ent_idx); b =BITMAP_OFFSET_BIT_IN_SECTOR (sb, ent_idx); +if (!test_bit_le (b, sbi->vol_amap[i]->b_data)) +return -EIO ; +clear_bit_le (b, sbi->vol_amap[i]->b_data); +exfat_update_bh (sbi->vol_amap[i], sync);if (opts->discard) {
@@ -171,6 +175,8 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync) opts->discard =0 ; } } + +return 0 ; }/*
fs/exfat/exfat_fs.h +1 -1
@@ -452,7 +452,7 @@ int exfat_count_num_clusters(struct super_block *sb,int exfat_load_bitmap (struct super_block *sb);void exfat_free_bitmap (struct exfat_sb_info *sbi);int exfat_set_bitmap (struct inode *inode,unsigned int clu,bool sync); -void exfat_clear_bitmap (struct inode *inode,unsigned int clu,bool sync); +int exfat_clear_bitmap (struct inode *inode,unsigned int clu,bool sync);unsigned int exfat_find_free_bitmap (struct super_block *sb,unsigned int clu);int exfat_count_used_clusters (struct super_block *sb,unsigned int *ret_count);int exfat_trim_fs (struct inode *inode,struct fstrim_range *range);
fs/exfat/fatent.c +7 -4
@@ -175,6 +175,7 @@ static int __exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chainBITMAP_OFFSET_SECTOR_INDEX (sb,CLUSTER_TO_BITMAP_ENT (clu));if (p_chain->flags ==ALLOC_NO_FAT_CHAIN ) { +int err;unsigned int last_cluster = p_chain->dir + p_chain->size -1 ; do { bool sync = false;
@@ -189,7 +190,9 @@ static int __exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain cur_cmap_i = next_cmap_i; } -exfat_clear_bitmap (inode, clu, (sync &&IS_DIRSYNC (inode))); + err =exfat_clear_bitmap (inode, clu, (sync &&IS_DIRSYNC (inode))); +if (err) +break ; clu++; num_clusters++; }while (num_clusters < p_chain->size);
@@ -210,12 +213,13 @@ static int __exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain cur_cmap_i = next_cmap_i; } -exfat_clear_bitmap (inode, clu, (sync &&IS_DIRSYNC (inode))); +if (exfat_clear_bitmap (inode, clu, (sync &&IS_DIRSYNC (inode)))) +break ; clu = n_clu; num_clusters++;if (err) - goto dec_used_clus; +break ;if (num_clusters >= sbi->num_clusters -EXFAT_FIRST_CLUSTER ) {/*
@@ -229,7 +233,6 @@ static int __exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain }while (clu !=EXFAT_EOF_CLUSTER ); } -dec_used_clus: sbi->used_clusters -= num_clusters;return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 196/269 exfat: short-circuit zero-byte writes in exfat_file_write_iter
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Sandeen <[email protected]>
[ Upstream commit fda94a9919fd632033979ad7765a99ae3cab9289 ]
When generic_write_checks() returns zero, it means that iov_iter_count() is zero, and there is no work to do.
Simply return success like all other filesystems do, rather than proceeding down the write path, which today yields an -EFAULT in generic_perform_write() via the (fault_in_iov_iter_readable(i, bytes) == bytes) check when bytes == 0.
--- fs/exfat/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exfat/file.c +1 -1
@@ -587,7 +587,7 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) valid_size = ei->valid_size; ret =generic_write_checks (iocb, iter); -if (ret <0 ) +if (ret <=0 ) goto unlock;if (iocb->ki_flags &IOCB_DIRECT ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 197/269 net-timestamp: support TCP GSO case for a few missing flags
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Xing <[email protected]>
[ Upstream commit 3c9231ea6497dfc50ac0ef69fff484da27d0df66 ]
When I read through the TSO codes, I found out that we probably miss initializing the tx_flags of last seg when TSO is turned off, which means at the following points no more timestamp (for this last one) will be generated. There are three flags to be handled in this patch:
1. SKBTX_HW_TSTAMP
2. SKBTX_BPF
3. SKBTX_SCHED_TSTAMP
Note that SKBTX_BPF[1] was added in 6.14.0-rc2 by commit 6b98ec7e882af ("bpf: Add BPF_SOCK_OPS_TSTAMP_SCHED_CB callback") and only belongs to net-next branch material for now. The common issue of the above three flags can be fixed by this single patch.
This patch initializes the tx_flags to SKBTX_ANY_TSTAMP like what the UDP GSO does to make the newly segmented last skb inherit the tx_flags so that requested timestamp will be generated in each certain layer, or else that last one has zero value of tx_flags which leads to no timestamp at all.
--- net/ipv4/tcp_offload.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/ipv4/tcp_offload.c +7 -4
@@ -13,12 +13,15 @@#include <net/tcp.h> #include <net/protocol.h> -static void tcp_gso_tstamp (struct sk_buff *skb,unsigned int ts_seq, +static void tcp_gso_tstamp (struct sk_buff *skb,struct sk_buff *gso_skb,unsigned int seq,unsigned int mss) { +u32 flags =skb_shinfo (gso_skb)->tx_flags &SKBTX_ANY_TSTAMP ; +u32 ts_seq =skb_shinfo (gso_skb)->tskey; +while (skb) {if (before (ts_seq, seq + mss)) { -skb_shinfo (skb)->tx_flags |=SKBTX_SW_TSTAMP ; +skb_shinfo (skb)->tx_flags |= flags;skb_shinfo (skb)->tskey = ts_seq;return ; }
@@ -193,8 +196,8 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb, th =tcp_hdr (skb); seq =ntohl (th->seq); -if (unlikely (skb_shinfo (gso_skb)->tx_flags &SKBTX_SW_TSTAMP )) -tcp_gso_tstamp (segs,skb_shinfo (gso_skb)->tskey, seq, mss); +if (unlikely (skb_shinfo (gso_skb)->tx_flags &SKBTX_ANY_TSTAMP )) +tcp_gso_tstamp (segs, gso_skb, seq, mss); newcheck = ~csum_fold (csum_add (csum_unfold (th->check), delta));
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 198/269 ublk: set_params: properly check if parameters can be applied
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uday Shankar <[email protected]>
[ Upstream commit 5ac60242b0173be83709603ebaf27a473f16c4e4 ]
The parameters set by the set_params call are only applied to the block device in the start_dev call. So if a device has already been started, a subsequently issued set_params on that device will not have the desired effect, and should return an error. There is an existing check for this
- set_params fails on devices in the LIVE state. But this check is not sufficient to cover the recovery case. In this case, the device will be in the QUIESCED or FAIL_IO states, so set_params will succeed. But this success is misleading, because the parameters will not be applied, since the device has already been started (by a previous ublk server). The bit UB_STATE_USED is set on completion of the start_dev; use it to detect and fail set_params commands which arrive too late to be applied (after start_dev).
--- drivers/block/ublk_drv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/block/ublk_drv.c +5 -2
@@ -2665,9 +2665,12 @@ static int ublk_ctrl_set_params(struct ublk_device *ub,if (ph.len >sizeof (struct ublk_params )) ph.len =sizeof (struct ublk_params ); -/* parameters can only be changed when device isn't live */ mutex_lock (&ub->mutex); -if (ub->dev_info.state ==UBLK_S_DEV_LIVE ) { +if (test_bit (UB_STATE_USED , &ub->state)) { +/* +* Parameters can only be changed when device hasn't +* been started yet +*/ ret = -EACCES ; }else if (copy_from_user (&ub->params, argp, ph.len)) { ret = -EFAULT ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 199/269 sched/fair: Fix potential memory corruption in child_cfs_rq_on_list
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zecheng Li <[email protected]>
[ Upstream commit 3b4035ddbfc8e4521f85569998a7569668cccf51 ]
child_cfs_rq_on_list attempts to convert a 'prev' pointer to a cfs_rq. This 'prev' pointer can originate from struct rq's leaf_cfs_rq_list, making the conversion invalid and potentially leading to memory corruption. Depending on the relative positions of leaf_cfs_rq_list and the task group (tg) pointer within the struct, this can cause a memory fault or access garbage data.
The issue arises in list_add_leaf_cfs_rq, where both cfs_rq->leaf_cfs_rq_list and rq->leaf_cfs_rq_list are added to the same leaf list. Also, rq->tmp_alone_branch can be set to rq->leaf_cfs_rq_list.
This adds a check if (prev == &rq->leaf_cfs_rq_list) after the main conditional in child_cfs_rq_on_list. This ensures that the container_of operation will convert a correct cfs_rq struct.
This check is sufficient because only cfs_rqs on the same CPU are added to the list, so verifying the 'prev' pointer against the current rq's list head is enough.
Fixes a potential memory corruption issue that due to current struct layout might not be manifesting as a crash but could lead to unpredictable behavior when the layout changes.
--- kernel/sched/fair.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/sched/fair.c +4 -2
@@ -4155,15 +4155,17 @@ static inline bool child_cfs_rq_on_list(struct cfs_rq *cfs_rq) {struct cfs_rq *prev_cfs_rq;struct list_head *prev; +struct rq *rq =rq_of (cfs_rq);if (cfs_rq->on_list) { prev = cfs_rq->leaf_cfs_rq_list.prev; }else { -struct rq *rq =rq_of (cfs_rq); - prev = rq->tmp_alone_branch; } +if (prev == &rq->leaf_cfs_rq_list) +return false; + prev_cfs_rq = container_of(prev, struct cfs_rq, leaf_cfs_rq_list);return (prev_cfs_rq->tg->parent == cfs_rq->tg);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 200/269 nvme-tcp: fix signedness bug in nvme_tcp_init_connection()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 528361c49962708a60f51a1afafeb00987cebedf ]
The kernel_recvmsg() function returns an int which could be either negative error codes or the number of bytes received. The problem is that the condition:
if (ret < sizeof(*icresp)) {is type promoted to type unsigned long and negative values are treated as high positive values which is success, when they should be treated as failure. Handle invalid positive returns separately from negative error codes to avoid this problem.
--- drivers/nvme/host/tcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/nvme/host/tcp.c +3 -3
@@ -1521,11 +1521,11 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue) msg.msg_flags =MSG_WAITALL ; ret =kernel_recvmsg (queue->sock, &msg, &iov,1 , iov.iov_len, msg.msg_flags); -if (ret <sizeof (*icresp)) { +if (ret >=0 && ret <sizeof (*icresp)) + ret = -ECONNRESET ; +if (ret <0 ) {pr_warn ("queue %d: failed to receive icresp, error %d\n" ,nvme_tcp_queue_id (queue), ret); -if (ret >=0 ) - ret = -ECONNRESET ; goto free_icresp; } ret = -ENOTCONN ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 201/269 net: dsa: mt7530: Fix traffic flooding for MMIO devices
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit ccc2f5a436fbb0ae1fb598932a9b8e48423c1959 ]
On MMIO devices (e.g. MT7988 or EN7581) unicast traffic received on lanX port is flooded on all other user ports if the DSA switch is configured without VLAN support since PORT_MATRIX in PCR regs contains all user ports. Similar to MDIO devices (e.g. MT7530 and MT7531) fix the issue defining default VLAN-ID 0 for MT7530 MMIO devices.
--- drivers/net/dsa/mt7530.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/dsa/mt7530.c +2 -6
@@ -2590,7 +2590,8 @@ mt7531_setup_common(struct dsa_switch *ds)if (ret <0 )return ret; -return 0 ; +/* Setup VLAN ID 0 for VLAN-unaware bridges */ +return mt7530_setup_vlan0 (priv); } static int
@@ -2686,11 +2687,6 @@ mt7531_setup(struct dsa_switch *ds)if (ret)return ret; -/* Setup VLAN ID 0 for VLAN-unaware bridges */ - ret =mt7530_setup_vlan0 (priv); -if (ret) -return ret; - ds->assisted_learning_on_cpu_port = true; ds->mtu_enforcement_ingress = true;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 202/269 mctp i3c: handle NULL header address
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Johnston <[email protected]>
[ Upstream commit cf7ee25e70c6edfac4553d6b671e8b19db1d9573 ]
daddr can be NULL if there is no neighbour table entry present, in that case the tx packet should be dropped.
saddr will usually be set by MCTP core, but check for NULL in case a packet is transmitted by a different protocol.
--- drivers/net/mctp/mctp-i3c.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/mctp/mctp-i3c.c +3 -0
@@ -507,6 +507,9 @@ static int mctp_i3c_header_create(struct sk_buff *skb, struct net_device *dev, {struct mctp_i3c_internal_hdr *ihdr; +if (!daddr || !saddr) +return -EINVAL ; +skb_push (skb,sizeof (struct mctp_i3c_internal_hdr ));skb_reset_mac_header (skb); ihdr = (void *)skb_mac_header (skb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 203/269 net: ipv6: fix dst ref loop in ila lwtunnel
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Iurman <[email protected]>
[ Upstream commit 0e7633d7b95b67f1758aea19f8e85621c5f506a3 ]
This patch follows commit 92191dd10730 ("net: ipv6: fix dst ref loops in rpl, seg6 and ioam6 lwtunnels") and, on a second thought, the same patch is also needed for ila (even though the config that triggered the issue was pathological, but still, we don't want that to happen).
--- net/ipv6/ila/ila_lwt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/ila/ila_lwt.c +2 -1
@@ -88,7 +88,8 @@ static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb) goto drop; } -if (ilwt->connected) { +/* cache only if we don't create a dst reference loop */ +if (ilwt->connected && orig_dst->lwtstate != dst->lwtstate) {local_bh_disable ();dst_cache_set_ip6 (&ilwt->dst_cache, dst, &fl6.saddr);local_bh_enable ();
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 204/269 net: ipv6: fix missing dst ref drop in ila lwtunnel
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Iurman <[email protected]>
[ Upstream commit 5da15a9c11c1c47ef573e6805b60a7d8a1687a2a ]
Add missing skb_dst_drop() to drop reference to the old dst before adding the new dst to the skb.
--- net/ipv6/ila/ila_lwt.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/ila/ila_lwt.c +1 -0
@@ -96,6 +96,7 @@ static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb) } } +skb_dst_drop (skb);skb_dst_set (skb, dst);return dst_output (net, sk, skb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 205/269 gpio: rcar: Fix missing of_node_put() call
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrizio Castro <[email protected]>
[ Upstream commit 391b41f983bf7ff853de44704d8e14e7cc648a9b ]
of_parse_phandle_with_fixed_args() requires its caller to call into of_node_put() on the node pointer from the output structure, but such a call is currently missing.
Call into of_node_put() to rectify that.
--- drivers/gpio/gpio-rcar.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpio/gpio-rcar.c +6 -1
@@ -468,7 +468,12 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) p->info = *info; ret =of_parse_phandle_with_fixed_args (np,"gpio-ranges" ,3 ,0 , &args); - *npins = ret ==0 ? args.args[2 ] :RCAR_MAX_GPIO_PER_BANK ; +if (ret) { + *npins =RCAR_MAX_GPIO_PER_BANK ; + }else { + *npins = args.args[2 ]; +of_node_put (args.np); + }if (*npins ==0 || *npins >RCAR_MAX_GPIO_PER_BANK ) { dev_warn(p->dev, "Invalid number of gpio lines %u, using %u\n",
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 206/269 Revert "drivers/card_reader/rtsx_usb: Restore interrupt based detection"
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Heusel <[email protected]>
commit 2397d61ee45cddb8f3bd3a3a9840ef0f0b5aa843 upstream.
This reverts commit 235b630eda072d7e7b102ab346d6b8a2c028a772.
This commit was found responsible for issues with SD card recognition, as users had to re-insert their cards in the readers and wait for a while. As for some people the SD card was involved in the boot process it also caused boot failures.
--- drivers/misc/cardreader/rtsx_usb.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/misc/cardreader/rtsx_usb.c +0 -15
@@ -286,7 +286,6 @@ static int rtsx_usb_get_status_with_bulkint rtsx_usb_get_card_status (struct rtsx_ucr *ucr,u16 *status) {int ret; -u8 interrupt_val =0 ;u16 *buf;if (!status)
@@ -309,20 +308,6 @@ int rtsx_usb_get_card_status(struct rtsx ret =rtsx_usb_get_status_with_bulk (ucr, status); } -rtsx_usb_read_register (ucr,CARD_INT_PEND , &interrupt_val); -/* Cross check presence with interrupts */ -if (*status &XD_CD ) -if (!(interrupt_val &XD_INT )) - *status &= ~XD_CD ; - -if (*status &SD_CD ) -if (!(interrupt_val &SD_INT )) - *status &= ~SD_CD ; - -if (*status &MS_CD ) -if (!(interrupt_val &MS_INT )) - *status &= ~MS_CD ; -/* usb_control_msg may return positive when success */ if (ret <0 )return ret;
Greg Kroah-Hartman
maintainerPATCH 207/269 usb: renesas_usbhs: Call clk_put()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
commit b5ea08aa883da05106fcc683d12489a4292d1122 upstream.
Clocks acquired with of_clk_get() need to be freed with clk_put(). Call clk_put() on priv->clks[0] on error path.
--- drivers/usb/renesas_usbhs/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/renesas_usbhs/common.c +3 -1
@@ -312,8 +312,10 @@ static int usbhsc_clk_get(struct device priv->clks[1 ] =of_clk_get (dev_of_node (dev),1 );if (PTR_ERR (priv->clks[1 ]) == -ENOENT ) priv->clks[1 ] =NULL ; -else if (IS_ERR (priv->clks[1 ])) +else if (IS_ERR (priv->clks[1 ])) { +clk_put (priv->clks[0 ]);return PTR_ERR (priv->clks[1 ]); + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 208/269 xhci: Restrict USB4 tunnel detection for USB3 devices to Intel hosts
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 487cfd4a8e3dc42d34a759017978a4edaf85fce0 upstream.
When adding support for USB3-over-USB4 tunnelling detection, a check for an Intel-specific capability was added. This capability, which goes by ID 206, is used without any check that we are actually dealing with an Intel host.
As it turns out, the Cadence XHCI controller *also* exposes an extended capability numbered 206 (for unknown purposes), but of course doesn't have the Intel-specific registers that the tunnelling code is trying to access. Fun follows.
The core of the problems is that the tunnelling code blindly uses vendor-specific capabilities without any check (the Intel-provided documentation I have at hand indicates that 192-255 are indeed vendor-specific).
Restrict the detection code to Intel HW for real, preventing any further explosion on my (non-Intel) HW.
--- drivers/usb/host/xhci-hub.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/host/xhci-hub.c +8 -0
@@ -12,6 +12,7 @@#include <linux/slab.h> #include <linux/unaligned.h> #include <linux/bitfield.h> +#include <linux/pci.h> #include "xhci.h" #include "xhci-trace.h"
@@ -770,9 +771,16 @@ static int xhci_exit_test_mode(struct xhci_hcd *xhci)enum usb_link_tunnel_mode xhci_port_is_tunneled (struct xhci_hcd *xhci,struct xhci_port *port) { +struct usb_hcd *hcd;void __iomem *base;u32 offset; +/* Don't try and probe this capability for non-Intel hosts */ + hcd =xhci_to_hcd (xhci); +if (!dev_is_pci (hcd->self.controller) || +to_pci_dev (hcd->self.controller)->vendor !=PCI_VENDOR_ID_INTEL ) +return USB_LINK_UNKNOWN ; + base = &xhci->cap_regs->hc_capbase; offset =xhci_find_next_ext_cap (base,0 ,XHCI_EXT_CAPS_INTEL_SPR_SHADOW );
Signature · 1 line
2.48.1
Greg Kroah-Hartman
maintainerPATCH 209/269 usb: renesas_usbhs: Use devm_usb_get_phy()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
commit e0c92440938930e7fa7aa6362780d39cdea34449 upstream.
The gpriv->transceiver is retrieved in probe() through usb_get_phy() but never released. Use devm_usb_get_phy() to handle this scenario.
This issue was identified through code investigation. No issue was found without this change.
--- drivers/usb/renesas_usbhs/mod_gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/renesas_usbhs/mod_gadget.c +1 -1
@@ -1094,7 +1094,7 @@ int usbhs_mod_gadget_probe(struct usbhs_ goto usbhs_mod_gadget_probe_err_gpriv; } - gpriv->transceiver =usb_get_phy (USB_PHY_TYPE_UNDEFINED ); + gpriv->transceiver =devm_usb_get_phy (dev,USB_PHY_TYPE_UNDEFINED );dev_info (dev,"%stransceiver found\n" , !IS_ERR (gpriv->transceiver) ?"" :"no " );
Greg Kroah-Hartman
maintainerPATCH 210/269 usb: hub: lack of clearing xHC resources
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawel Laszczak <[email protected]>
commit 2b66ef84d0d2a0ea955b40bd306f5e3abbc5cf9c upstream.
The xHC resources allocated for USB devices are not released in correct order after resuming in case when while suspend device was reconnected.
This issue has been detected during the fallowing scenario:
- connect hub HS to root port
- connect LS/FS device to hub port
- wait for enumeration to finish
- force host to suspend
- reconnect hub attached to root port
- wake host
For this scenario during enumeration of USB LS/FS device the Cadence xHC reports completion error code for xHC commands because the xHC resources used for devices has not been properly released.
XHCI specification doesn't mention that device can be reset in any order so, we should not treat this issue as Cadence xHC controller bug. Similar as during disconnecting in this case the device resources should be cleared starting form the last usb device in tree toward the root hub. To fix this issue usbcore driver should call hcd->driver->reset_device for all USB devices connected to hub which was reconnected while suspending.
--- drivers/usb/core/hub.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/usb/core/hub.c +33 -0
@@ -6066,6 +6066,36 @@ void usb_hub_cleanup(void) }/* usb_hub_cleanup() */ /** +* hub_hc_release_resources - clear resources used by host controller +* @udev: pointer to device being released +* +* Context: task context, might sleep +* +* Function releases the host controller resources in correct order before +* making any operation on resuming usb device. The host controller resources +* allocated for devices in tree should be released starting from the last +* usb device in tree toward the root hub. This function is used only during +* resuming device when usb device require reinitialization – that is, when +* flag udev->reset_resume is set. +* +* This call is synchronous, and may not be used in an interrupt context. +*/ +static void hub_hc_release_resources (struct usb_device *udev) +{ +struct usb_hub *hub =usb_hub_to_struct_hub (udev); +struct usb_hcd *hcd =bus_to_hcd (udev->bus); +int i; + +/* Release up resources for all children before this device */ +for (i =0 ; i < udev->maxchild; i++) +if (hub->ports[i]->child) +hub_hc_release_resources (hub->ports[i]->child); + +if (hcd->driver->reset_device) + hcd->driver->reset_device (hcd, udev); +} + +/** * usb_reset_and_verify_device - perform a USB port reset to reinitialize a device * @udev: device to reset (not in SUSPENDED or NOTATTACHED state) *
@@ -6129,6 +6159,9 @@ static int usb_reset_and_verify_device(s bos = udev->bos; udev->bos =NULL ; +if (udev->reset_resume) +hub_hc_release_resources (udev); +mutex_lock (hcd->address0_mutex);for (i =0 ; i <PORT_INIT_TRIES ; ++i) {
Greg Kroah-Hartman
maintainerPATCH 211/269 usb: quirks: Add DELAY_INIT and NO_LPM for Prolific Mass Storage Card Reader
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miao Li <[email protected]>
commit ff712188daa3fe3ce7e11e530b4dca3826dae14a upstream.
When used on Huawei hisi platforms, Prolific Mass Storage Card Reader which the VID:PID is in 067b:2731 might fail to enumerate at boot time and doesn't work well with LPM enabled, combination quirks:
USB_QUIRK_DELAY_INIT + USB_QUIRK_NO_LPM
fixed the problems.
--- drivers/usb/core/quirks.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/core/quirks.c +4 -0
@@ -341,6 +341,10 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x0638, 0x0a13), .driver_info = USB_QUIRK_STRING_FETCH_255 }, + /* Prolific Single-LUN Mass Storage Card Reader */ + { USB_DEVICE(0x067b, 0x2731), .driver_info = USB_QUIRK_DELAY_INIT | + USB_QUIRK_NO_LPM }, + /* Saitek Cyborg Gold Joystick */ { USB_DEVICE(0x06a3, 0x0006), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
Greg Kroah-Hartman
maintainerPATCH 212/269 usb: typec: ucsi: Fix NULL pointer access
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrei Kuchynski <[email protected]>
commit b13abcb7ddd8d38de769486db5bd917537b32ab1 upstream.
Resources should be released only after all threads that utilize them have been destroyed.
This commit ensures that resources are not released prematurely by waiting for the associated workqueue to complete before deallocating them.
--- drivers/usb/typec/ucsi/ucsi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +7 -6
@@ -1809,11 +1809,11 @@ static int ucsi_init(struct ucsi *ucsi) err_unregister:for (con = connector; con->port; con++) { +if (con->wq) +destroy_workqueue (con->wq);ucsi_unregister_partner (con);ucsi_unregister_altmodes (con,UCSI_RECIPIENT_CON );ucsi_unregister_port_psy (con); -if (con->wq) -destroy_workqueue (con->wq);usb_power_delivery_unregister_capabilities (con->port_sink_caps); con->port_sink_caps =NULL ;
@@ -1997,10 +1997,6 @@ void ucsi_unregister(struct ucsi *ucsi)for (i =0 ; i < ucsi->cap.num_connectors; i++) {cancel_work_sync (&ucsi->connector[i].work); -ucsi_unregister_partner (&ucsi->connector[i]); -ucsi_unregister_altmodes (&ucsi->connector[i], -UCSI_RECIPIENT_CON ); -ucsi_unregister_port_psy (&ucsi->connector[i]);if (ucsi->connector[i].wq) {struct ucsi_work *uwork;
@@ -2016,6 +2012,11 @@ void ucsi_unregister(struct ucsi *ucsi)destroy_workqueue (ucsi->connector[i].wq); } +ucsi_unregister_partner (&ucsi->connector[i]); +ucsi_unregister_altmodes (&ucsi->connector[i], +UCSI_RECIPIENT_CON ); +ucsi_unregister_port_psy (&ucsi->connector[i]); +usb_power_delivery_unregister_capabilities (ucsi->connector[i].port_sink_caps); ucsi->connector[i].port_sink_caps =NULL ;usb_power_delivery_unregister_capabilities (ucsi->connector[i].port_source_caps);
Greg Kroah-Hartman
maintainerPATCH 213/269 usb: renesas_usbhs: Flush the notify_hotplug_work
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
commit 552ca6b87e3778f3dd5b87842f95138162e16c82 upstream.
When performing continuous unbind/bind operations on the USB drivers available on the Renesas RZ/G2L SoC, a kernel crash with the message "Unable to handle kernel NULL pointer dereference at virtual address" may occur. This issue points to the usbhsc_notify_hotplug() function.
Flush the delayed work to avoid its execution when driver resources are unavailable.
--- drivers/usb/renesas_usbhs/common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/renesas_usbhs/common.c +2 -0
@@ -781,6 +781,8 @@ static void usbhs_remove(struct platformdev_dbg (&pdev->dev,"usb remove\n" ); +flush_delayed_work (&priv->notify_hotplug_work); +/* power off */ if (!usbhs_get_dparam (priv, runtime_pwctrl))usbhsc_power_ctrl (priv,0 );
Greg Kroah-Hartman
maintainerPATCH 214/269 usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashanth K <[email protected]>
commit 17c2c87c37862c3e95b55f660681cc6e8d66660e upstream.
Currently while UDC suspends, u_ether attempts to remote wakeup the host if there are any pending transfers. However, if remote wakeup fails, the UDC remains suspended but the is_suspend flag is not set. And since is_suspend flag isn't set, the subsequent eth_start_xmit() would queue USB requests to suspended UDC.
To fix this, bail out from gether_suspend() only if remote wakeup operation is successful.
--- drivers/usb/gadget/function/u_ether.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/u_ether.c +2 -2
@@ -1052,8 +1052,8 @@ void gether_suspend(struct gether *link)* There is a transfer in progress. So we trigger a remote * wakeup to inform the host. */ -ether_wakeup_host (dev->port_usb); -return ; +if (!ether_wakeup_host (dev->port_usb)) +return ; }spin_lock_irqsave (&dev->lock, flags); link->is_suspend = true;
Greg Kroah-Hartman
maintainerPATCH 215/269 usb: atm: cxacru: fix a flaw in existing endpoint checks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
commit c90aad369899a607cfbc002bebeafd51e31900cd upstream.
Syzbot once again identified a flaw in usb endpoint checking, see [1]. This time the issue stems from a commit authored by me (2eabb655a968 ("usb: atm: cxacru: fix endpoint checking in cxacru_bind()")).
While using usb_find_common_endpoints() may usually be enough to discard devices with wrong endpoints, in this case one needs more than just finding and identifying the sufficient number of endpoints of correct types - one needs to check the endpoint's address as well.
Since cxacru_bind() fills URBs with CXACRU_EP_CMD address in mind, switch the endpoint verification approach to usb_check_XXX_endpoints() instead to fix incomplete ep testing.
[1] Syzbot report:
usb 5-1: BOGUS urb xfer, pipe 3 != type 1
WARNING: CPU: 0 PID: 1378 at drivers/usb/core/urb.c:504 usb_submit_urb+0xc4e/0x18c0 drivers/usb/core/urb.c:503 ... RIP: 0010:usb_submit_urb+0xc4e/0x18c0 drivers/usb/core/urb.c:503 ... Call Trace: <TASK> cxacru_cm+0x3c8/0xe50 drivers/usb/atm/cxacru.c:649 cxacru_card_status drivers/usb/atm/cxacru.c:760 [inline] cxacru_bind+0xcf9/0x1150 drivers/usb/atm/cxacru.c:1223 usbatm_usb_probe+0x314/0x1d30 drivers/usb/atm/usbatm.c:1058 cxacru_usb_probe+0x184/0x220 drivers/usb/atm/cxacru.c:1377 usb_probe_interface+0x641/0xbb0 drivers/usb/core/driver.c:396 really_probe+0x2b9/0xad0 drivers/base/dd.c:658 __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:800 driver_probe_device+0x50/0x430 drivers/base/dd.c:830
...
--- drivers/usb/atm/cxacru.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/atm/cxacru.c +7 -6
@@ -1131,7 +1131,10 @@ static int cxacru_bind(struct usbatm_datstruct cxacru_data *instance;struct usb_device *usb_dev =interface_to_usbdev (intf);struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD ]; -struct usb_endpoint_descriptor *in, *out; +static const u8 ep_addrs[] = { +CXACRU_EP_CMD +USB_DIR_IN , +CXACRU_EP_CMD +USB_DIR_OUT , +0 };int ret;/* instance init */
@@ -1179,13 +1182,11 @@ static int cxacru_bind(struct usbatm_dat }if (usb_endpoint_xfer_int (&cmd_ep->desc)) - ret =usb_find_common_endpoints (intf->cur_altsetting, -NULL ,NULL , &in, &out); + ret =usb_check_int_endpoints (intf, ep_addrs);else - ret =usb_find_common_endpoints (intf->cur_altsetting, - &in, &out,NULL ,NULL ); + ret =usb_check_bulk_endpoints (intf, ep_addrs); -if (ret) { +if (!ret) {usb_err (usbatm_instance,"cxacru_bind: interface has incorrect endpoints\n" ); ret = -ENODEV ; goto fail;
Greg Kroah-Hartman
maintainerPATCH 216/269 usb: dwc3: Set SUSPENDENABLE soon after phy init
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thinh Nguyen <[email protected]>
commit cc5bfc4e16fc1d1c520cd7bb28646e82b6e69217 upstream.
After phy initialization, some phy operations can only be executed while in lower P states. Ensure GUSB3PIPECTL.SUSPENDENABLE and GUSB2PHYCFG.SUSPHY are set soon after initialization to avoid blocking phy ops.
Previously the SUSPENDENABLE bits are only set after the controller initialization, which may not happen right away if there's no gadget driver or xhci driver bound. Revise this to clear SUSPENDENABLE bits only when there's mode switching (change in GCTL.PRTCAPDIR).
--- drivers/usb/dwc3/core.c | 69 +++++++++++++++++++++++++++++------------------- drivers/usb/dwc3/core.h | 2 - drivers/usb/dwc3/drd.c | 4 +- 3 files changed, 45 insertions(+), 30 deletions(-)
drivers/usb/dwc3/core.c +42 -27
@@ -131,11 +131,24 @@ void dwc3_enable_susphy(struct dwc3 *dwc } } -void dwc3_set_prtcap (struct dwc3 *dwc,u32 mode) +void dwc3_set_prtcap (struct dwc3 *dwc,u32 mode,bool ignore_susphy) { +unsigned int hw_mode;u32 reg; reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + +/* +* For DRD controllers, GUSB3PIPECTL.SUSPENDENABLE and +* GUSB2PHYCFG.SUSPHY should be cleared during mode switching, +* and they can be set after core initialization. +*/ + hw_mode =DWC3_GHWPARAMS0_MODE (dwc->hwparams.hwparams0); +if (hw_mode ==DWC3_GHWPARAMS0_MODE_DRD && !ignore_susphy) { +if (DWC3_GCTL_PRTCAP (reg) != mode) +dwc3_enable_susphy (dwc, false); + } + reg &= ~(DWC3_GCTL_PRTCAPDIR (DWC3_GCTL_PRTCAP_OTG )); reg |=DWC3_GCTL_PRTCAPDIR (mode);dwc3_writel (dwc->regs,DWC3_GCTL , reg);
@@ -216,7 +229,7 @@ static void __dwc3_set_mode(struct work_spin_lock_irqsave (&dwc->lock, flags); -dwc3_set_prtcap (dwc, desired_dr_role); +dwc3_set_prtcap (dwc, desired_dr_role, false);spin_unlock_irqrestore (&dwc->lock, flags);
@@ -658,16 +671,7 @@ static int dwc3_ss_phy_setup(struct dwc3*/ reg &= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX ; -/* -* Above DWC_usb3.0 1.94a, it is recommended to set -* DWC3_GUSB3PIPECTL_SUSPHY to '0' during coreConsultant configuration. -* So default value will be '0' when the core is reset. Application -* needs to set it to '1' after the core initialization is completed. -* -* Similarly for DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be -* cleared after power-on reset, and it can be set after core -* initialization. -*/ +/* Ensure the GUSB3PIPECTL.SUSPENDENABLE is cleared prior to phy init. */ reg &= ~DWC3_GUSB3PIPECTL_SUSPHY ;if (dwc->u2ss_inp3_quirk)
@@ -747,15 +751,7 @@ static int dwc3_hs_phy_setup(struct dwc3break ; } -/* -* Above DWC_usb3.0 1.94a, it is recommended to set -* DWC3_GUSB2PHYCFG_SUSPHY to '0' during coreConsultant configuration. -* So default value will be '0' when the core is reset. Application -* needs to set it to '1' after the core initialization is completed. -* -* Similarly for DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared -* after power-on reset, and it can be set after core initialization. -*/ +/* Ensure the GUSB2PHYCFG.SUSPHY is cleared prior to phy init. */ reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ;if (dwc->dis_enblslpm_quirk)
@@ -830,6 +826,25 @@ static int dwc3_phy_init(struct dwc3 *dw goto err_exit_usb3_phy; } +/* +* Above DWC_usb3.0 1.94a, it is recommended to set +* DWC3_GUSB3PIPECTL_SUSPHY and DWC3_GUSB2PHYCFG_SUSPHY to '0' during +* coreConsultant configuration. So default value will be '0' when the +* core is reset. Application needs to set it to '1' after the core +* initialization is completed. +* +* Certain phy requires to be in P0 power state during initialization. +* Make sure GUSB3PIPECTL.SUSPENDENABLE and GUSB2PHYCFG.SUSPHY are clear +* prior to phy init to maintain in the P0 state. +* +* After phy initialization, some phy operations can only be executed +* while in lower P states. Ensure GUSB3PIPECTL.SUSPENDENABLE and +* GUSB2PHYCFG.SUSPHY are set soon after initialization to avoid +* blocking phy ops. +*/ + if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) +dwc3_enable_susphy (dwc, true); +return 0 ; err_exit_usb3_phy:
@@ -1564,7 +1579,7 @@ static int dwc3_core_init_mode(struct dwswitch (dwc->dr_mode) {case USB_DR_MODE_PERIPHERAL : -dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE ); +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE , false);if (dwc->usb2_phy)otg_set_vbus (dwc->usb2_phy->otg, false);
@@ -1576,7 +1591,7 @@ static int dwc3_core_init_mode(struct dwreturn dev_err_probe (dev, ret,"failed to initialize gadget\n" );break ;case USB_DR_MODE_HOST : -dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST ); +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST , false);if (dwc->usb2_phy)otg_set_vbus (dwc->usb2_phy->otg, true);
@@ -1621,7 +1636,7 @@ static void dwc3_core_exit_mode(struct d }/* de-assert DRVVBUS for HOST and OTG mode */ -dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE ); +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE , true); }static void dwc3_get_software_properties (struct dwc3 *dwc)
@@ -2433,7 +2448,7 @@ static int dwc3_resume_common(struct dwcif (ret)return ret; -dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE ); +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE , true);dwc3_gadget_resume (dwc);break ;case DWC3_GCTL_PRTCAP_HOST :
@@ -2441,7 +2456,7 @@ static int dwc3_resume_common(struct dwc ret =dwc3_core_init_for_resume (dwc);if (ret)return ret; -dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST ); +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST , true);break ; }/* Restore GUSB2PHYCFG bits that were modified in suspend */
@@ -2470,7 +2485,7 @@ static int dwc3_resume_common(struct dwcif (ret)return ret; -dwc3_set_prtcap (dwc, dwc->current_dr_role); +dwc3_set_prtcap (dwc, dwc->current_dr_role, true);dwc3_otg_init (dwc);if (dwc->current_otg_role ==DWC3_OTG_ROLE_HOST ) {
drivers/usb/dwc3/core.h +1 -1
@@ -1562,7 +1562,7 @@ struct dwc3_gadget_ep_cmd_params {#define DWC3_HAS_OTG BIT(3)/* prototypes */ -void dwc3_set_prtcap (struct dwc3 *dwc,u32 mode); +void dwc3_set_prtcap (struct dwc3 *dwc,u32 mode,bool ignore_susphy);void dwc3_set_mode (struct dwc3 *dwc,u32 mode);u32 dwc3_core_fifo_space (struct dwc3_ep *dep,u8 type);
drivers/usb/dwc3/drd.c +2 -2
@@ -173,7 +173,7 @@ void dwc3_otg_init(struct dwc3 *dwc)* block "Initialize GCTL for OTG operation". */ /* GCTL.PrtCapDir=2'b11 */ -dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_OTG ); +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_OTG , true);/* GUSB2PHYCFG0.SusPHY=0 */ reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ;
@@ -556,7 +556,7 @@ int dwc3_drd_init(struct dwc3 *dwc)dwc3_drd_update (dwc); }else { -dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_OTG ); +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_OTG , true);/* use OTG block to get ID event */ irq =dwc3_otg_get_irq (dwc);
Greg Kroah-Hartman
maintainerPATCH 217/269 usb: dwc3: gadget: Prevent irq storm when TH re-executes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Badhri Jagan Sridharan <[email protected]>
commit 69c58deec19628c8a686030102176484eb94fed4 upstream.
While commit d325a1de49d6 ("usb: dwc3: gadget: Prevent losing events in event cache") makes sure that top half(TH) does not end up overwriting the cached events before processing them when the TH gets invoked more than one time, returning IRQ_HANDLED results in occasional irq storm where the TH hogs the CPU. The irq storm can be prevented by the flag before event handler busy is cleared. Default enable interrupt moderation in all versions which support them.
ftrace event stub during dwc3 irq storm:
irq/504_dwc3-1111 ( 1111) [000] .... 70.000866: irq_handler_exit: irq=14 ret=handled
irq/504_dwc3-1111 ( 1111) [000] .... 70.000872: irq_handler_entry: irq=504 name=dwc3
irq/504_dwc3-1111 ( 1111) [000] .... 70.000874: irq_handler_exit: irq=504 ret=handled
irq/504_dwc3-1111 ( 1111) [000] .... 70.000881: irq_handler_entry: irq=504 name=dwc3
irq/504_dwc3-1111 ( 1111) [000] .... 70.000883: irq_handler_exit: irq=504 ret=handled
irq/504_dwc3-1111 ( 1111) [000] .... 70.000889: irq_handler_entry: irq=504 name=dwc3
irq/504_dwc3-1111 ( 1111) [000] .... 70.000892: irq_handler_exit: irq=504 ret=handled
irq/504_dwc3-1111 ( 1111) [000] .... 70.000898: irq_handler_entry: irq=504 name=dwc3
irq/504_dwc3-1111 ( 1111) [000] .... 70.000901: irq_handler_exit: irq=504 ret=handled
irq/504_dwc3-1111 ( 1111) [000] .... 70.000907: irq_handler_entry: irq=504 name=dwc3
irq/504_dwc3-1111 ( 1111) [000] .... 70.000909: irq_handler_exit: irq=504 ret=handled
irq/504_dwc3-1111 ( 1111) [000] .... 70.000915: irq_handler_entry: irq=504 name=dwc3
irq/504_dwc3-1111 ( 1111) [000] .... 70.000918: irq_handler_exit: irq=504 ret=handled
irq/504_dwc3-1111 ( 1111) [000] .... 70.000924: irq_handler_entry: irq=504 name=dwc3
irq/504_dwc3-1111 ( 1111) [000] .... 70.000927: irq_handler_exit: irq=504 ret=handled
irq/504_dwc3-1111 ( 1111) [000] .... 70.000933: irq_handler_entry: irq=504 name=dwc3
irq/504_dwc3-1111 ( 1111) [000] .... 70.000935: irq_handler_exit: irq=504 ret=handled
....--- drivers/usb/dwc3/core.c | 16 ++++++---------- drivers/usb/dwc3/gadget.c | 10 +++++++--- 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/usb/dwc3/core.c +6 -10
@@ -1826,8 +1826,6 @@ static void dwc3_get_properties(struct d dwc->tx_thr_num_pkt_prd = tx_thr_num_pkt_prd; dwc->tx_max_burst_prd = tx_max_burst_prd; - dwc->imod_interval =0 ; - dwc->tx_fifo_resize_max_num = tx_fifo_resize_max_num; }
@@ -1845,21 +1843,19 @@ static void dwc3_check_params(struct dwcunsigned int hwparam_gen =DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3); -/* Check for proper value of imod_interval */ -if (dwc->imod_interval && !dwc3_has_imod (dwc)) { -dev_warn (dwc->dev,"Interrupt moderation not supported\n" ); - dwc->imod_interval =0 ; - } -/* +* Enable IMOD for all supporting controllers. +* +* Particularly, DWC_usb3 v3.00a must enable this feature for +* the following reason: +* * Workaround for STAR 9000961433 which affects only version * 3.00a of the DWC_usb3 core. This prevents the controller * interrupt from being masked while handling events. IMOD * allows us to work around this issue. Enable it for the * affected version. */ -if (!dwc->imod_interval && - DWC3_VER_IS(DWC3, 300A)) +if (dwc3_has_imod ((dwc))) dwc->imod_interval =1 ;/* Check the maximum_speed parameter */
drivers/usb/dwc3/gadget.c +7 -3
@@ -4507,14 +4507,18 @@ static irqreturn_t dwc3_process_event_budwc3_writel (dwc->regs,DWC3_GEVNTSIZ (0 ),DWC3_GEVNTSIZ_SIZE (evt->length)); + evt->flags &= ~DWC3_EVENT_PENDING ; +/* +* Add an explicit write memory barrier to make sure that the update of +* clearing DWC3_EVENT_PENDING is observed in dwc3_check_event_buf() +*/ +wmb (); +if (dwc->imod_interval) {dwc3_writel (dwc->regs,DWC3_GEVNTCOUNT (0 ),DWC3_GEVNTCOUNT_EHB );dwc3_writel (dwc->regs,DWC3_DEV_IMOD (0 ), dwc->imod_interval); } -/* Keep the clearing of DWC3_EVENT_PENDING at the end */ - evt->flags &= ~DWC3_EVENT_PENDING ; -return ret; }
Greg Kroah-Hartman
maintainerPATCH 218/269 usb: typec: ucsi: increase timeout for PPM reset operations
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit bf4f9ae1cb08ccaafbe6874be6c46f59b83ae778 upstream.
It is observed that on some systems an initial PPM reset during the boot phase can trigger a timeout:
[ 6.482546] ucsi_acpi USBC000:00: failed to reset PPM! [ 6.482551] ucsi_acpi USBC000:00: error -ETIMEDOUT: PPM init failed
Still, increasing the timeout value, albeit being the most straightforward solution, eliminates the problem: the initial PPM reset may take up to ~8000-10000ms on some Lenovo laptops. When it is reset after the above period of time (or even if ucsi_reset_ppm() is not called overall), UCSI works as expected.
Moreover, if the ucsi_acpi module is loaded/unloaded manually after the system has booted, reading the CCI values and resetting the PPM works perfectly, without any timeout. Thus it's only a boot-time issue.
The reason for this behavior is not clear but it may be the consequence of some tricks that the firmware performs or be an actual firmware bug. As a workaround, increase the timeout to avoid failing the UCSI initialization prematurely.
--- drivers/usb/typec/ucsi/ucsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +1 -1
@@ -25,7 +25,7 @@* difficult to estimate the time it takes for the system to process the command * before it is actually passed to the PPM. */ -#define UCSI_TIMEOUT_MS 5000 +#define UCSI_TIMEOUT_MS 10000/* * UCSI_SWAP_TIMEOUT_MS - Timeout for role swap requests
Greg Kroah-Hartman
maintainerPATCH 219/269 usb: typec: tcpci_rt1711h: Unmask alert interrupts to fix functionality
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: AngeloGioacchino Del Regno <[email protected]>
commit d6b82dafd17db0658f089b9cdec573982ca82bc5 upstream.
During probe, the TCPC alert interrupts are getting masked to avoid unwanted interrupts during chip setup: this is ok to do but there is no unmasking happening at any later time, which means that the chip will not raise any interrupt, essentially making it not functional as, while internally it does perform all of the intended functions, it won't signal anything to the outside.
Unmask the alert interrupts to fix functionality.
--- drivers/usb/typec/tcpm/tcpci_rt1711h.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/usb/typec/tcpm/tcpci_rt1711h.c +11 -0
@@ -334,6 +334,11 @@ static int rt1711h_probe(struct i2c_clie {int ret;struct rt1711h_chip *chip; +const u16 alert_mask =TCPC_ALERT_TX_SUCCESS |TCPC_ALERT_TX_DISCARDED | +TCPC_ALERT_TX_FAILED |TCPC_ALERT_RX_HARD_RST | +TCPC_ALERT_RX_STATUS |TCPC_ALERT_POWER_STATUS | +TCPC_ALERT_CC_STATUS |TCPC_ALERT_RX_BUF_OVF | +TCPC_ALERT_FAULT ; chip =devm_kzalloc (&client->dev,sizeof (*chip),GFP_KERNEL );if (!chip)
@@ -382,6 +387,12 @@ static int rt1711h_probe(struct i2c_clie dev_name(chip->dev), chip);if (ret <0 )return ret; + +/* Enable alert interrupts */ + ret =rt1711h_write16 (chip,TCPC_ALERT_MASK , alert_mask); +if (ret <0 ) +return ret; +enable_irq_wake (client->irq);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 220/269 usb: gadget: Set self-powered based on MaxPower and bmAttributes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashanth K <[email protected]>
commit 40e89ff5750fca2c1d6da93f98a2038716bba86c upstream.
Currently the USB gadget will be set as bus-powered based solely on whether its bMaxPower is greater than 100mA, but this may miss devices that may legitimately draw less than 100mA but still want to report as bus-powered. Similarly during suspend & resume, USB gadget is incorrectly marked as bus/self powered without checking the bmAttributes field. Fix these by configuring the USB gadget as self or bus powered based on bmAttributes, and explicitly set it as bus-powered if it draws more than 100mA.
--- drivers/usb/gadget/composite.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/usb/gadget/composite.c +11 -5
@@ -1050,10 +1050,11 @@ static int set_config(struct usb_composielse usb_gadget_set_remote_wakeup (gadget,0 ); done: -if (power <=USB_SELF_POWER_VBUS_MAX_DRAW ) -usb_gadget_set_selfpowered (gadget); -else +if (power >USB_SELF_POWER_VBUS_MAX_DRAW || + !(c->bmAttributes &USB_CONFIG_ATT_SELFPOWER ))usb_gadget_clear_selfpowered (gadget); +else +usb_gadget_set_selfpowered (gadget);usb_gadget_vbus_draw (gadget, power);if (result >=0 && cdev->delayed_status)
@@ -2615,7 +2616,9 @@ void composite_suspend(struct usb_gadget cdev->suspended =1 ; -usb_gadget_set_selfpowered (gadget); +if (cdev->config->bmAttributes &USB_CONFIG_ATT_SELFPOWER ) +usb_gadget_set_selfpowered (gadget); +usb_gadget_vbus_draw (gadget,2 ); }
@@ -2649,8 +2652,11 @@ void composite_resume(struct usb_gadgetelse maxpower =min (maxpower,900U ); -if (maxpower >USB_SELF_POWER_VBUS_MAX_DRAW ) +if (maxpower >USB_SELF_POWER_VBUS_MAX_DRAW || + !(cdev->config->bmAttributes &USB_CONFIG_ATT_SELFPOWER ))usb_gadget_clear_selfpowered (gadget); +else +usb_gadget_set_selfpowered (gadget);usb_gadget_vbus_draw (gadget, maxpower); }else {
Greg Kroah-Hartman
maintainerPATCH 221/269 usb: gadget: Fix setting self-powered state on suspend
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
commit c783e1258f29c5caac9eea0aea6b172870f1baf8 upstream.
cdev->config might be NULL, so check it before dereferencing.
--- drivers/usb/gadget/composite.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/composite.c +2 -1
@@ -2616,7 +2616,8 @@ void composite_suspend(struct usb_gadget cdev->suspended =1 ; -if (cdev->config->bmAttributes &USB_CONFIG_ATT_SELFPOWER ) +if (cdev->config && + cdev->config->bmAttributes &USB_CONFIG_ATT_SELFPOWER )usb_gadget_set_selfpowered (gadget);usb_gadget_vbus_draw (gadget,2 );
Greg Kroah-Hartman
maintainerPATCH 222/269 usb: gadget: Check bmAttributes only if configuration is valid
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashanth K <[email protected]>
commit 8e812e9355a6f14dffd54a33d951ca403b9732f5 upstream.
If the USB configuration is not valid, then avoid checking for bmAttributes to prevent null pointer deference.
--- drivers/usb/gadget/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/composite.c +1 -1
@@ -1051,7 +1051,7 @@ static int set_config(struct usb_composiusb_gadget_set_remote_wakeup (gadget,0 ); done:if (power >USB_SELF_POWER_VBUS_MAX_DRAW || - !(c->bmAttributes &USB_CONFIG_ATT_SELFPOWER )) + (c && !(c->bmAttributes &USB_CONFIG_ATT_SELFPOWER )))usb_gadget_clear_selfpowered (gadget);else usb_gadget_set_selfpowered (gadget);
Greg Kroah-Hartman
maintainerPATCH 223/269 kbuild: userprogs: use correct lld when linking through clang
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit dfc1b168a8c4b376fa222b27b97c2c4ad4b786e1 upstream.
The userprog infrastructure links objects files through $(CC). Either explicitly by manually calling $(CC) on multiple object files or implicitly by directly compiling a source file to an executable. The documentation at Documentation/kbuild/llvm.rst indicates that ld.lld would be used for linking if LLVM=1 is specified.
However clang instead will use either a globally installed cross linker from $PATH called ${target}-ld or fall back to the system linker, which probably does not support crosslinking.
For the normal kernel build this is not an issue because the linker is always executed directly, without the compiler being involved.
Explicitly pass --ld-path to clang so $(LD) is respected.
As clang 13.0.1 is required to build the kernel, this option is available.
--- Makefile | 5 +++++ 1 file changed, 5 insertions(+)
Makefile +5 -0
@@ -1067,6 +1067,11 @@ endif KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) +# userspace programs are linked via the compiler, use the correct linker +ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_LD_IS_LLD),yy) +KBUILD_USERLDFLAGS += --ld-path=$(LD) +endif + # make the checker run with the right architecture CHECKFLAGS += --arch=$(ARCH)
Greg Kroah-Hartman
maintainerPATCH 224/269 acpi: typec: ucsi: Introduce a ->poll_cci method
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 976e7e9bdc7719a023a4ecccd2e3daec9ab20a40 upstream.
For the ACPI backend of UCSI the UCSI "registers" are just a memory copy of the register values in an opregion. The ACPI implementation in the BIOS ensures that the opregion contents are synced to the embedded controller and it ensures that the registers (in particular CCI) are synced back to the opregion on notifications. While there is an ACPI call that syncs the actual registers to the opregion there is rarely a need to do this and on some ACPI implementations it actually breaks in various interesting ways.
The only reason to force a sync from the embedded controller is to poll CCI while notifications are disabled. Only the ucsi core knows if this is the case and guessing based on the current command is suboptimal, i.e. leading to the following spurious assertion splat:
WARNING: CPU: 3 PID: 76 at drivers/usb/typec/ucsi/ucsi.c:1388 ucsi_reset_ppm+0x1b4/0x1c0 [typec_ucsi] CPU: 3 UID: 0 PID: 76 Comm: kworker/3:0 Not tainted 6.12.11-200.fc41.x86_64 #1 Hardware name: LENOVO 21D0/LNVNB161216, BIOS J6CN45WW 03/17/2023 Workqueue: events_long ucsi_init_work [typec_ucsi] RIP: 0010:ucsi_reset_ppm+0x1b4/0x1c0 [typec_ucsi] Call Trace: <TASK> ucsi_init_work+0x3c/0xac0 [typec_ucsi] process_one_work+0x179/0x330 worker_thread+0x252/0x390 kthread+0xd2/0x100 ret_from_fork+0x34/0x50 ret_from_fork_asm+0x1a/0x30 </TASK>
Thus introduce a ->poll_cci() method that works like ->read_cci() with an additional forced sync and document that this should be used when polling with notifications disabled. For all other backends that presumably don't have this issue use the same implementation for both methods.
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++----- drivers/usb/typec/ucsi/ucsi.h | 2 ++ drivers/usb/typec/ucsi/ucsi_acpi.c | 21 ++++++++++++++------- drivers/usb/typec/ucsi/ucsi_ccg.c | 1 + drivers/usb/typec/ucsi/ucsi_glink.c | 1 + drivers/usb/typec/ucsi/ucsi_stm32g0.c | 1 + drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 1 + 7 files changed, 25 insertions(+), 12 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +5 -5
@@ -1330,7 +1330,7 @@ static int ucsi_reset_ppm(struct ucsi *umutex_lock (&ucsi->ppm_lock); - ret = ucsi->ops->read_cci (ucsi, &cci); + ret = ucsi->ops->poll_cci (ucsi, &cci);if (ret <0 ) goto out;
@@ -1348,7 +1348,7 @@ static int ucsi_reset_ppm(struct ucsi *u tmo = jiffies +msecs_to_jiffies (UCSI_TIMEOUT_MS ); do { - ret = ucsi->ops->read_cci(ucsi, &cci); + ret = ucsi->ops->poll_cci(ucsi, &cci); if (ret < 0) goto out; if (cci & UCSI_CCI_COMMAND_COMPLETE)
@@ -1377,7 +1377,7 @@ static int ucsi_reset_ppm(struct ucsi *u/* Give the PPM time to process a reset before reading CCI */ msleep (20 ); - ret = ucsi->ops->read_cci (ucsi, &cci); + ret = ucsi->ops->poll_cci (ucsi, &cci);if (ret) goto out;
@@ -1913,8 +1913,8 @@ struct ucsi *ucsi_create(struct device *struct ucsi *ucsi;if (!ops || - !ops->read_version || !ops->read_cci || !ops->read_message_in || - !ops->sync_control || !ops->async_control) + !ops->read_version || !ops->read_cci || !ops->poll_cci || + !ops->read_message_in || !ops->sync_control || !ops->async_control)return ERR_PTR (-EINVAL ); ucsi =kzalloc (sizeof (*ucsi),GFP_KERNEL );
drivers/usb/typec/ucsi/ucsi.h +2 -0
@@ -60,6 +60,7 @@ struct dentry;* struct ucsi_operations - UCSI I/O operations * @read_version: Read implemented UCSI version * @read_cci: Read CCI register +* @poll_cci: Read CCI register while polling with notifications disabled * @read_message_in: Read message data from UCSI * @sync_control: Blocking control operation * @async_control: Non-blocking control operation
@@ -74,6 +75,7 @@ struct dentry;struct ucsi_operations {int (*read_version)(struct ucsi *ucsi,u16 *version);int (*read_cci)(struct ucsi *ucsi,u32 *cci); +int (*poll_cci)(struct ucsi *ucsi,u32 *cci);int (*read_message_in)(struct ucsi *ucsi,void *val,size_t val_len);int (*sync_control)(struct ucsi *ucsi,u64 command);int (*async_control)(struct ucsi *ucsi,u64 command);
drivers/usb/typec/ucsi/ucsi_acpi.c +14 -7
@@ -59,19 +59,24 @@ static int ucsi_acpi_read_version(structstatic int ucsi_acpi_read_cci (struct ucsi *ucsi,u32 *cci) {struct ucsi_acpi *ua =ucsi_get_drvdata (ucsi); -int ret; - -if (UCSI_COMMAND (ua->cmd) ==UCSI_PPM_RESET ) { - ret =ucsi_acpi_dsm (ua,UCSI_DSM_FUNC_READ ); -if (ret) -return ret; - }memcpy (cci, ua->base +UCSI_CCI ,sizeof (*cci));return 0 ; } +static int ucsi_acpi_poll_cci (struct ucsi *ucsi,u32 *cci) +{ +struct ucsi_acpi *ua =ucsi_get_drvdata (ucsi); +int ret; + + ret =ucsi_acpi_dsm (ua,UCSI_DSM_FUNC_READ ); +if (ret) +return ret; + +return ucsi_acpi_read_cci (ucsi, cci); +} +static int ucsi_acpi_read_message_in (struct ucsi *ucsi,void *val,size_t val_len) {struct ucsi_acpi *ua =ucsi_get_drvdata (ucsi);
@@ -94,6 +99,7 @@ static int ucsi_acpi_async_control(strucstatic const struct ucsi_operations ucsi_acpi_ops = { .read_version = ucsi_acpi_read_version, .read_cci = ucsi_acpi_read_cci, + .poll_cci = ucsi_acpi_poll_cci, .read_message_in = ucsi_acpi_read_message_in, .sync_control = ucsi_sync_control_common, .async_control = ucsi_acpi_async_control
@@ -145,6 +151,7 @@ static int ucsi_gram_sync_control(structstatic const struct ucsi_operations ucsi_gram_ops = { .read_version = ucsi_acpi_read_version, .read_cci = ucsi_acpi_read_cci, + .poll_cci = ucsi_acpi_poll_cci, .read_message_in = ucsi_gram_read_message_in, .sync_control = ucsi_gram_sync_control, .async_control = ucsi_acpi_async_control
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
@@ -664,6 +664,7 @@ err_put:static const struct ucsi_operations ucsi_ccg_ops = { .read_version = ucsi_ccg_read_version, .read_cci = ucsi_ccg_read_cci, + .poll_cci = ucsi_ccg_read_cci, .read_message_in = ucsi_ccg_read_message_in, .sync_control = ucsi_ccg_sync_control, .async_control = ucsi_ccg_async_control,
drivers/usb/typec/ucsi/ucsi_glink.c +1 -0
@@ -201,6 +201,7 @@ static void pmic_glink_ucsi_connector_ststatic const struct ucsi_operations pmic_glink_ucsi_ops = { .read_version = pmic_glink_ucsi_read_version, .read_cci = pmic_glink_ucsi_read_cci, + .poll_cci = pmic_glink_ucsi_read_cci, .read_message_in = pmic_glink_ucsi_read_message_in, .sync_control = ucsi_sync_control_common, .async_control = pmic_glink_ucsi_async_control,
drivers/usb/typec/ucsi/ucsi_stm32g0.c +1 -0
@@ -424,6 +424,7 @@ static irqreturn_t ucsi_stm32g0_irq_handstatic const struct ucsi_operations ucsi_stm32g0_ops = { .read_version = ucsi_stm32g0_read_version, .read_cci = ucsi_stm32g0_read_cci, + .poll_cci = ucsi_stm32g0_read_cci, .read_message_in = ucsi_stm32g0_read_message_in, .sync_control = ucsi_sync_control_common, .async_control = ucsi_stm32g0_async_control,
drivers/usb/typec/ucsi/ucsi_yoga_c630.c +1 -0
@@ -74,6 +74,7 @@ static int yoga_c630_ucsi_async_control(const struct ucsi_operations yoga_c630_ucsi_ops = { .read_version = yoga_c630_ucsi_read_version, .read_cci = yoga_c630_ucsi_read_cci, + .poll_cci = yoga_c630_ucsi_read_cci, .read_message_in = yoga_c630_ucsi_read_message_in, .sync_control = ucsi_sync_control_common, .async_control = yoga_c630_ucsi_async_control,
Greg Kroah-Hartman
maintainerPATCH 225/269 rust: finish using custom FFI integer types
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miguel Ojeda <[email protected]>
commit 27c7518e7f1ccaaa43eb5f25dc362779d2dc2ccb upstream.
In the last kernel cycle we migrated most of the core::ffi cases in commit d072acda4862 ("rust: use custom FFI integer types"):
Currently FFI integer types are defined in libcore. This commit creates the ffi crate and asks bindgen to use that crate for FFI integer types instead of core::ffi.
This commit is preparatory and no type changes are made in this commit yet.
Finish now the few remaining/new cases so that we perform the actual remapping in the next commit as planned.
--- drivers/gpu/drm/drm_panic_qr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_panic_qr.rs +1 -1
@@ -931,7 +931,7 @@ impl QrImage<'_> {/// They must remain valid for the duration of the function call. #[no_mangle] pub unsafe extern "C" fn drm_panic_qr_generate ( - url: *const i8 , + url: *const kernel::ffi::c_char , data: *mut u8 , data_len:usize , data_size: usize,
Greg Kroah-Hartman
maintainerPATCH 226/269 rust: map `long` to `isize` and `char` to `u8`
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
commit 1bae8729e50a900f41e9a1c17ae81113e4cf62b8 upstream.
The following FFI types are replaced compared to core::ffi:
1. char type is now always mapped to u8, since kernel uses -funsigned-char on the C code. core::ffi maps it to platform default ABI, which can be either signed or unsigned.
2. long is now always mapped to isize. It's very common in the kernel to use long to represent a pointer-sized integer, and in fact intptr_t is a typedef of long in the kernel. Enforce this mapping rather than mapping to i32/i64 depending on platform can save us a lot of unnecessary casts.
[ Moved uaccess changes from the next commit, since they were
irrefutable patterns that Rust >= 1.82.0 warns about. Reworded slightly and reformatted a few documentation comments. Rebased on top of rust-next. Added the removal of two casts to avoid Clippy warnings. - Miguel ]
--- rust/ffi.rs | 37 ++++++++++++++++++++++++++++++++++++- rust/kernel/error.rs | 5 +---- rust/kernel/firmware.rs | 2 +- rust/kernel/uaccess.rs | 27 +++++++-------------------- 4 files changed, 45 insertions(+), 26 deletions(-)
rust/ffi.rs +36 -1
@@ -10,4 +10,39 @@#![no_std] -pub use core::ffi::*; +macro_rules! alias { + ($($name:ident = $ty:ty;)*) => {$( +#[allow(non_camel_case_types, missing_docs)] +pub type $name = $ty; + +// Check size compatibility with `core`. +const _: () =assert! ( + core::mem::size_of ::<$name>() == core::mem::size_of ::<core::ffi::$name>() + ); + )*} +} + +alias! { +// `core::ffi::c_char` is either `i8` or `u8` depending on architecture. In the kernel, we use +// `-funsigned-char` so it's always mapped to `u8`. + c_char =u8 ; + + c_schar =i8 ; + c_uchar =u8 ; + + c_short =i16 ; + c_ushort =u16 ; + + c_int =i32 ; + c_uint =u32 ; + +// In the kernel, `intptr_t` is defined to be `long` in all platforms, so we can map the type to +// `isize`. + c_long =isize ; + c_ulong =usize ; + + c_longlong =i64 ; + c_ulonglong =u64 ; +} + +pub use core::ffi::c_void;
rust/kernel/error.rs +1 -4
@@ -153,11 +153,8 @@ impl Error {/// Returns the error encoded as a pointer. pub fn to_ptr <T >(self) -> *mut T { -#[cfg_attr(target_pointer_width = "32" , allow(clippy::useless_conversion))] // SAFETY: `self.0` is a valid error due to its invariant. -unsafe { - bindings::ERR_PTR (self.0 .get ().into ())as *mut _ - } +unsafe { bindings::ERR_PTR (self.0 .get ()as _ )as *mut _ } }/// Returns a string representing the error, if one exists.
rust/kernel/firmware.rs +1 -1
@@ -12,7 +12,7 @@ use core::ptr::NonNull;/// One of the following: `bindings::request_firmware`, `bindings::firmware_request_nowarn`, /// `bindings::firmware_request_platform`, `bindings::request_firmware_direct`. struct FwFunc ( -unsafe extern "C" fn (*mut *const bindings::firmware , *const i8 , *mut bindings::device ) ->i32 , +unsafe extern "C" fn (*mut *const bindings::firmware , *const u8 , *mut bindings::device ) ->i32 , );impl FwFunc {
rust/kernel/uaccess.rs +7 -20
@@ -8,7 +8,7 @@ use crate::{ alloc::Flags, bindings, error::Result, - ffi::{c_ulong, c_void}, + ffi::c_void, prelude::*, types::{AsBytes, FromBytes}, };
@@ -224,13 +224,9 @@ impl UserSliceReader {if len > self.length {return Err (EFAULT ); } -let Ok (len_ulong) = c_ulong::try_from (len)else { -return Err (EFAULT ); - }; -// SAFETY: `out_ptr` points into a mutable slice of length `len_ulong`, so we may write +// SAFETY: `out_ptr` points into a mutable slice of length `len`, so we may write // that many bytes to it. -let res = -unsafe { bindings::copy_from_user (out_ptr, self.ptras *const c_void , len_ulong) }; +let res =unsafe { bindings::copy_from_user (out_ptr, self.ptras *const c_void , len) };if res !=0 {return Err (EFAULT ); }
@@ -259,9 +255,6 @@ impl UserSliceReader {if len > self.length {return Err (EFAULT ); } -let Ok (len_ulong) = c_ulong::try_from (len)else { -return Err (EFAULT ); - };let mut out:MaybeUninit <T > =MaybeUninit ::uninit ();// SAFETY: The local variable `out` is valid for writing `size_of::<T>()` bytes. //
@@ -272,7 +265,7 @@ impl UserSliceReader { bindings::_copy_from_user ( out.as_mut_ptr ().cast ::<c_void >(), self.ptras *const c_void , - len_ulong, + len, ) };if res !=0 {
@@ -335,12 +328,9 @@ impl UserSliceWriter {if len > self.length {return Err (EFAULT ); } -let Ok (len_ulong) = c_ulong::try_from (len)else { -return Err (EFAULT ); - }; -// SAFETY: `data_ptr` points into an immutable slice of length `len_ulong`, so we may read +// SAFETY: `data_ptr` points into an immutable slice of length `len`, so we may read // that many bytes from it. -let res =unsafe { bindings::copy_to_user (self.ptras *mut c_void , data_ptr, len_ulong) }; +let res =unsafe { bindings::copy_to_user (self.ptras *mut c_void , data_ptr, len) };if res !=0 {return Err (EFAULT ); }
@@ -359,9 +349,6 @@ impl UserSliceWriter {if len > self.length {return Err (EFAULT ); } -let Ok (len_ulong) = c_ulong::try_from (len)else { -return Err (EFAULT ); - };// SAFETY: The reference points to a value of type `T`, so it is valid for reading // `size_of::<T>()` bytes. //
@@ -372,7 +359,7 @@ impl UserSliceWriter { bindings::_copy_to_user ( self.ptras *mut c_void , (valueas *const T ).cast ::<c_void >(), - len_ulong, + len, ) };if res !=0 {
Greg Kroah-Hartman
maintainerPATCH 227/269 xhci: pci: Fix indentation in the PCI device ID definitions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 0309ed83791c079f239c13e0c605210425cd1a61 upstream.
Some of the definitions are missing the one TAB, add it to them.
--- drivers/usb/host/xhci-pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-pci.c +4 -4
@@ -28,8 +28,8 @@#define SPARSE_CNTL_ENABLE 0xC12C/* Device for a quirk */ -#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 -#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 +#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 +#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1009 0x1009#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1100 0x1100#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400
@@ -38,8 +38,8 @@#define PCI_DEVICE_ID_EJ168 0x7023#define PCI_DEVICE_ID_EJ188 0x7052 -#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31 -#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 +#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31 +#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
Greg Kroah-Hartman
maintainerPATCH 228/269 usb: xhci: Enable the TRB overfetch quirk on VIA VL805
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
commit c133ec0e5717868c9967fa3df92a55e537b1aead upstream.
Raspberry Pi is a major user of those chips and they discovered a bug - when the end of a transfer ring segment is reached, up to four TRBs can be prefetched from the next page even if the segment ends with link TRB and on page boundary (the chip claims to support standard 4KB pages).
It also appears that if the prefetched TRBs belong to a different ring whose doorbell is later rung, they may be used without refreshing from system RAM and the endpoint will stay idle if their cycle bit is stale.
Other users complain about IOMMU faults on x86 systems, unsurprisingly.
Deal with it by using existing quirk which allocates a dummy page after each transfer ring segment. This was seen to resolve both problems. RPi came up with a more efficient solution, shortening each segment by four TRBs, but it complicated the driver and they ditched it for this quirk.
Also rename the quirk and add VL805 device ID macro.
--- drivers/usb/host/xhci-mem.c | 3 ++- drivers/usb/host/xhci-pci.c | 10 +++++++--- drivers/usb/host/xhci.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-)
drivers/usb/host/xhci-mem.c +2 -1
@@ -2443,7 +2443,8 @@ int xhci_mem_init(struct xhci_hcd *xhci,* and our use of dma addresses in the trb_address_map radix tree needs * TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need. */ -if (xhci->quirks &XHCI_ZHAOXIN_TRB_FETCH ) +if (xhci->quirks &XHCI_TRB_OVERFETCH ) +/* Buggy HC prefetches beyond segment bounds - allocate dummy space at the end */ xhci->segment_pool =dma_pool_create ("xHCI ring segments" , dev,TRB_SEGMENT_SIZE *2 ,TRB_SEGMENT_SIZE *2 , xhci->page_size *2 );else
drivers/usb/host/xhci-pci.c +7 -3
@@ -38,6 +38,8 @@#define PCI_DEVICE_ID_EJ168 0x7023#define PCI_DEVICE_ID_EJ188 0x7052 +#define PCI_DEVICE_ID_VIA_VL805 0x3483 +#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1
@@ -424,8 +426,10 @@ static void xhci_pci_quirks(struct devic pdev->device == 0x3432) xhci->quirks |=XHCI_BROKEN_STREAMS ; -if (pdev->vendor ==PCI_VENDOR_ID_VIA && pdev->device ==0x3483 ) +if (pdev->vendor ==PCI_VENDOR_ID_VIA && pdev->device ==PCI_DEVICE_ID_VIA_VL805 ) { xhci->quirks |=XHCI_LPM_SUPPORT ; + xhci->quirks |=XHCI_TRB_OVERFETCH ; + }if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA && pdev->device ==PCI_DEVICE_ID_ASMEDIA_1042_XHCI ) {
@@ -473,11 +477,11 @@ static void xhci_pci_quirks(struct devicif (pdev->device ==0x9202 ) { xhci->quirks |=XHCI_RESET_ON_RESUME ; - xhci->quirks |=XHCI_ZHAOXIN_TRB_FETCH ; + xhci->quirks |=XHCI_TRB_OVERFETCH ; }if (pdev->device ==0x9203 ) - xhci->quirks |=XHCI_ZHAOXIN_TRB_FETCH ; + xhci->quirks |=XHCI_TRB_OVERFETCH ; } if (pdev->vendor == PCI_DEVICE_ID_CADENCE &&
drivers/usb/host/xhci.h +1 -1
@@ -1621,7 +1621,7 @@ struct xhci_hcd {#define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42)#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43)#define XHCI_RESET_TO_DEFAULT BIT_ULL(44) -#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45) +#define XHCI_TRB_OVERFETCH BIT_ULL(45)#define XHCI_ZHAOXIN_HOST BIT_ULL(46)#define XHCI_WRITE_64_HI_LO BIT_ULL(47)#define XHCI_CDNS_SCTX_QUIRK BIT_ULL(48)
Greg Kroah-Hartman
maintainerPATCH 229/269 KVM: SVM: Set RFLAGS.IF=1 in C code, to get VMRUN out of the STI shadow
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit be45bc4eff33d9a7dae84a2150f242a91a617402 upstream.
Enable/disable local IRQs, i.e. set/clear RFLAGS.IF, in the common svm_vcpu_enter_exit() just after/before guest_state_{enter,exit}_irqoff() so that VMRUN is not executed in an STI shadow. AMD CPUs have a quirk (some would say "bug"), where the STI shadow bleeds into the guest's intr_state field if a #VMEXIT occurs during injection of an event, i.e. if the VMRUN doesn't complete before the subsequent #VMEXIT.
The spurious "interrupts masked" state is relatively benign, as it only occurs during event injection and is transient. Because KVM is already injecting an event, the guest can't be in HLT, and if KVM is querying IRQ blocking for injection, then KVM would need to force an immediate exit anyways since injecting multiple events is impossible.
However, because KVM copies int_state verbatim from vmcb02 to vmcb12, the spurious STI shadow is visible to L1 when running a nested VM, which can trip sanity checks, e.g. in VMware's VMM.
Hoist the STI+CLI all the way to C code, as the aforementioned calls to guest_state_{enter,exit}_irqoff() already inform lockdep that IRQs are enabled/disabled, and taking a fault on VMRUN with RFLAGS.IF=1 is already possible. I.e. if there's kernel code that is confused by running with RFLAGS.IF=1, then it's already a problem. In practice, since GIF=0 also blocks NMIs, the only change in exposure to non-KVM code (relative to surrounding VMRUN with STI+CLI) is exception handling code, and except for the kvm_rebooting=1 case, all exception in the core VM-Enter/VM-Exit path are fatal.
Use the "raw" variants to enable/disable IRQs to avoid tracing in the "no instrumentation" code; the guest state helpers also take care of tracing IRQ state.
Oppurtunstically document why KVM needs to do STI in the first place.
--- arch/x86/kvm/svm/svm.c | 14 ++++++++++++++ arch/x86/kvm/svm/vmenter.S | 10 +--------- 2 files changed, 15 insertions(+), 9 deletions(-)
arch/x86/kvm/svm/svm.c +14 -0
@@ -4176,6 +4176,18 @@ static noinstr void svm_vcpu_enter_exit(guest_state_enter_irqoff (); +/* +* Set RFLAGS.IF prior to VMRUN, as the host's RFLAGS.IF at the time of +* VMRUN controls whether or not physical IRQs are masked (KVM always +* runs with V_INTR_MASKING_MASK). Toggle RFLAGS.IF here to avoid the +* temptation to do STI+VMRUN+CLI, as AMD CPUs bleed the STI shadow +* into guest state if delivery of an event during VMRUN triggers a +* #VMEXIT, and the guest_state transitions already tell lockdep that +* IRQs are being enabled/disabled. Note! GIF=0 for the entirety of +* this path, so IRQs aren't actually unmasked while running host code. +*/ +raw_local_irq_enable (); +amd_clear_divider ();if (sev_es_guest (vcpu->kvm))
@@ -4184,6 +4196,8 @@ static noinstr void svm_vcpu_enter_exit(else __svm_vcpu_run (svm, spec_ctrl_intercepted); +raw_local_irq_disable (); +guest_state_exit_irqoff (); }
arch/x86/kvm/svm/vmenter.S +1 -9
@@ -170,12 +170,8 @@ SYM_FUNC_START(__svm_vcpu_run) mov VCPU_RDI(%_ASM_DI), %_ASM_DI /* Enter guest mode */ - sti - 3: vmrun %_ASM_AX 4: - cli - /* Pop @svm to RAX while it's the only available register. */ pop %_ASM_AX
@@ -340,12 +336,8 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) mov KVM_VMCB_pa(%rax), %rax /* Enter guest mode */ - sti - 1: vmrun %rax - -2: cli - +2: /* IMPORTANT: Stuff the RSB immediately after VM-Exit, before RET! */ FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_VMEXIT
Greg Kroah-Hartman
maintainerPATCH 230/269 KVM: SVM: Save host DR masks on CPUs with DebugSwap
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit b2653cd3b75f62f29b72df4070e20357acb52bc4 upstream.
When running SEV-SNP guests on a CPU that supports DebugSwap, always save the host's DR0..DR3 mask MSR values irrespective of whether or not DebugSwap is enabled, to ensure the host values aren't clobbered by the CPU. And for now, also save DR0..DR3, even though doing so isn't necessary (see below).
SVM_VMGEXIT_AP_CREATE is deeply flawed in that it allows the *guest* to create a VMSA with guest-controlled SEV_FEATURES. A well behaved guest can inform the hypervisor, i.e. KVM, of its "requested" features, but on CPUs without ALLOWED_SEV_FEATURES support, nothing prevents the guest from lying about which SEV features are being enabled (or not!).
If a misbehaving guest enables DebugSwap in a secondary vCPU's VMSA, the CPU will load the DR0..DR3 mask MSRs on #VMEXIT, i.e. will clobber the MSRs with '0' if KVM doesn't save its desired value.
Note, DR0..DR3 themselves are "ok", as DR7 is reset on #VMEXIT, and KVM restores all DRs in common x86 code as needed via hw_breakpoint_restore(). I.e. there is no risk of host DR0..DR3 being clobbered (when it matters). However, there is a flaw in the opposite direction; because the guest can lie about enabling DebugSwap, i.e. can *disable* DebugSwap without KVM's knowledge, KVM must not rely on the CPU to restore DRs. Defer fixing that wart, as it's more of a documentation issue than a bug in the code.
Note, KVM added support for DebugSwap on commit d1f85fbe836e ("KVM: SEV:
Enable data breakpoints in SEV-ES"), but that is not an appropriate Fixes, as the underlying flaw exists in hardware, not in KVM. I.e. all kernels that support SEV-SNP need to be patched, not just kernels with KVM's full support for DebugSwap (ignoring that DebugSwap support landed first).
Opportunistically fix an incorrect statement in the comment; on CPUs without DebugSwap, the CPU does NOT save or load debug registers, i.e.
--- arch/x86/kvm/svm/sev.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/x86/kvm/svm/sev.c +10 -3
@@ -4579,6 +4579,8 @@ void sev_es_vcpu_reset(struct vcpu_svm *void sev_es_prepare_switch_to_guest (struct vcpu_svm *svm,struct sev_es_save_area *hostsa) { +struct kvm *kvm = svm->vcpu.kvm; +/* * All host state for SEV-ES guests is categorized into three swap types * based on how it is handled by hardware during a world switch:
@@ -4602,10 +4604,15 @@ void sev_es_prepare_switch_to_guest(stru/* * If DebugSwap is enabled, debug registers are loaded but NOT saved by -* the CPU (Type-B). If DebugSwap is disabled/unsupported, the CPU both -* saves and loads debug registers (Type-A). +* the CPU (Type-B). If DebugSwap is disabled/unsupported, the CPU does +* not save or load debug registers. Sadly, on CPUs without +* ALLOWED_SEV_FEATURES, KVM can't prevent SNP guests from enabling +* DebugSwap on secondary vCPUs without KVM's knowledge via "AP Create". +* Save all registers if DebugSwap is supported to prevent host state +* from being clobbered by a misbehaving guest. */ -if (sev_vcpu_has_debug_swap (svm)) { +if (sev_vcpu_has_debug_swap (svm) || + (sev_snp_guest (kvm) &&cpu_feature_enabled (X86_FEATURE_DEBUG_SWAP ))) { hostsa->dr0 =native_get_debugreg (0 ); hostsa->dr1 =native_get_debugreg (1 ); hostsa->dr2 =native_get_debugreg (2 );
Greg Kroah-Hartman
maintainerPATCH 231/269 KVM: SVM: Drop DEBUGCTL[5:2] from guests effective value
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit ee89e8013383d50a27ea9bf3c8a69eed6799856f upstream.
Drop bits 5:2 from the guest's effective DEBUGCTL value, as AMD changed the architectural behavior of the bits and broke backwards compatibility. On CPUs without BusLockTrap (or at least, in APMs from before ~2023), bits 5:2 controlled the behavior of external pins:
Performance-Monitoring/Breakpoint Pin-Control (PBi)—Bits 5:2, read/write. Software uses thesebits to control the type of information reported by the four external performance-monitoring/breakpoint pins on the processor. When a PBi bit is cleared to 0, the corresponding external pin (BPi) reports performance-monitor information. When a PBi bit is set to 1, the corresponding external pin (BPi) reports breakpoint information.
With the introduction of BusLockTrap, presumably to be compatible with Intel CPUs, AMD redefined bit 2 to be BLCKDB:
Bus Lock #DB Trap (BLCKDB)—Bit 2, read/write. Software sets this bit to enable generation of a #DB trap following successful execution of a bus lock when CPL is > 0.
and redefined bits 5:3 (and bit 6) as "6:3 Reserved MBZ".
Ideally, KVM would treat bits 5:2 as reserved. Defer that change to a feature cleanup to avoid breaking existing guest in LTS kernels. For now, drop the bits to retain backwards compatibility (of a sort).
Note, dropping bits 5:2 is still a guest-visible change, e.g. if the guest is enabling LBRs *and* the legacy PBi bits, then the state of the PBi bits is visible to the guest, whereas now the guest will always see '0'.
--- arch/x86/kvm/svm/svm.c | 12 ++++++++++++ arch/x86/kvm/svm/svm.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +12 -0
@@ -3167,6 +3167,18 @@ static int svm_set_msr(struct kvm_vcpu *kvm_pr_unimpl_wrmsr (vcpu, ecx, data);break ; } + +/* +* AMD changed the architectural behavior of bits 5:2. On CPUs +* without BusLockTrap, bits 5:2 control "external pins", but +* on CPUs that support BusLockDetect, bit 2 enables BusLockTrap +* and bits 5:3 are reserved-to-zero. Sadly, old KVM allowed +* the guest to set bits 5:2 despite not actually virtualizing +* Performance-Monitoring/Breakpoint external pins. Drop bits +* 5:2 for backwards compatibility. +*/ + data &= ~GENMASK (5 ,2 ); +if (data &DEBUGCTL_RESERVED_BITS )return 1 ;
arch/x86/kvm/svm/svm.h +1 -1
@@ -591,7 +591,7 @@ static inline bool is_vnmi_enabled(struc/* svm.c */ #define MSR_INVALID 0xffffffffU -#define DEBUGCTL_RESERVED_BITS (~(0x3fULL)) +#define DEBUGCTL_RESERVED_BITS (~(DEBUGCTLMSR_BTF | DEBUGCTLMSR_LBR))extern bool dump_invalid_vmcb;
Greg Kroah-Hartman
maintainerPATCH 232/269 KVM: SVM: Suppress DEBUGCTL.BTF on AMD
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit d0eac42f5cecce009d315655bee341304fbe075e upstream.
Mark BTF as reserved in DEBUGCTL on AMD, as KVM doesn't actually support BTF, and fully enabling BTF virtualization is non-trivial due to interactions with the emulator, guest_debug, #DB interception, nested SVM, etc.
Don't inject #GP if the guest attempts to set BTF, as there's no way to communicate lack of support to the guest, and instead suppress the flag and treat the WRMSR as (partially) unsupported.
In short, make KVM behave the same on AMD and Intel (VMX already squashes BTF).
Note, due to other bugs in KVM's handling of DEBUGCTL, the only way BTF has "worked" in any capacity is if the guest simultaneously enables LBRs.
--- arch/x86/kvm/svm/svm.c | 9 +++++++++ arch/x86/kvm/svm/svm.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +9 -0
@@ -3179,6 +3179,15 @@ static int svm_set_msr(struct kvm_vcpu **/ data &= ~GENMASK (5 ,2 ); +/* +* Suppress BTF as KVM doesn't virtualize BTF, but there's no +* way to communicate lack of support to the guest. +*/ +if (data &DEBUGCTLMSR_BTF ) { +kvm_pr_unimpl_wrmsr (vcpu,MSR_IA32_DEBUGCTLMSR , data); + data &= ~DEBUGCTLMSR_BTF ; + } +if (data &DEBUGCTL_RESERVED_BITS )return 1 ;
arch/x86/kvm/svm/svm.h +1 -1
@@ -591,7 +591,7 @@ static inline bool is_vnmi_enabled(struc/* svm.c */ #define MSR_INVALID 0xffffffffU -#define DEBUGCTL_RESERVED_BITS (~(DEBUGCTLMSR_BTF | DEBUGCTLMSR_LBR)) +#define DEBUGCTL_RESERVED_BITS (~DEBUGCTLMSR_LBR)extern bool dump_invalid_vmcb;
Greg Kroah-Hartman
maintainerPATCH 233/269 KVM: x86: Snapshot the hosts DEBUGCTL in common x86
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit fb71c795935652fa20eaf9517ca9547f5af99a76 upstream.
Move KVM's snapshot of DEBUGCTL to kvm_vcpu_arch and take the snapshot in common x86, so that SVM can also use the snapshot.
Opportunistically change the field to a u64. While bits 63:32 are reserved on AMD, not mentioned at all in Intel's SDM, and managed as an "unsigned long" by the kernel, DEBUGCTL is an MSR and therefore a 64-bit value.
--- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 8 ++------ arch/x86/kvm/vmx/vmx.h | 2 -- arch/x86/kvm/x86.c | 1 + 4 files changed, 4 insertions(+), 8 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -0
@@ -761,6 +761,7 @@ struct kvm_vcpu_arch {u32 pkru;u32 hflags;u64 efer; +u64 host_debugctl;u64 apic_base;struct kvm_lapic *apic;/* kernel irqchip context */ bool load_eoi_exitmap_pending;
arch/x86/kvm/vmx/vmx.c +2 -6
@@ -1515,16 +1515,12 @@ void vmx_vcpu_load_vmcs(struct kvm_vcpu*/ void vmx_vcpu_load (struct kvm_vcpu *vcpu,int cpu) { -struct vcpu_vmx *vmx =to_vmx (vcpu); -if (vcpu->scheduled_out && !kvm_pause_in_guest (vcpu->kvm))shrink_ple_window (vcpu);vmx_vcpu_load_vmcs (vcpu, cpu,NULL );vmx_vcpu_pi_load (vcpu, cpu); - - vmx->host_debugctlmsr =get_debugctlmsr (); }void vmx_vcpu_put (struct kvm_vcpu *vcpu)
@@ -7454,8 +7450,8 @@ fastpath_t vmx_vcpu_run(struct kvm_vcpu }/* MSR_IA32_DEBUGCTLMSR is zeroed on vmexit. Restore it if needed */ -if (vmx->host_debugctlmsr) -update_debugctlmsr (vmx->host_debugctlmsr); +if (vcpu->arch.host_debugctl) +update_debugctlmsr (vcpu->arch.host_debugctl);#ifndef CONFIG_X86_64 /*
arch/x86/kvm/vmx/vmx.h +0 -2
@@ -339,8 +339,6 @@ struct vcpu_vmx {/* apic deadline value in host tsc */ u64 hv_deadline_tsc; -unsigned long host_debugctlmsr; -/* * Only bits masked by msr_ia32_feature_control_valid_bits can be set in * msr_ia32_feature_control. FEAT_CTL_LOCKED is always included
arch/x86/kvm/x86.c +1 -0
@@ -4993,6 +4993,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu/* Save host pkru register if supported */ vcpu->arch.host_pkru =read_pkru (); + vcpu->arch.host_debugctl =get_debugctlmsr ();/* Apply any externally detected TSC adjustments (due to suspend) */ if (unlikely (vcpu->arch.tsc_offset_adjustment)) {
Greg Kroah-Hartman
maintainerPATCH 234/269 KVM: SVM: Manually context switch DEBUGCTL if LBR virtualization is disabled
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 433265870ab3455b418885bff48fa5fd02f7e448 upstream.
Manually load the guest's DEBUGCTL prior to VMRUN (and restore the host's value on #VMEXIT) if it diverges from the host's value and LBR virtualization is disabled, as hardware only context switches DEBUGCTL if LBR virtualization is fully enabled. Running the guest with the host's value has likely been mildly problematic for quite some time, e.g. it will result in undesirable behavior if BTF diverges (with the caveat that KVM now suppresses guest BTF due to lack of support).
But the bug became fatal with the introduction of Bus Lock Trap ("Detect" in kernel paralance) support for AMD (commit 408eb7417a92 ("x86/bus_lock: Add support for AMD")), as a bus lock in the guest will trigger an unexpected #DB.
Note, suppressing the bus lock #DB, i.e. simply resuming the guest without injecting a #DB, is not an option. It wouldn't address the general issue with DEBUGCTL, e.g. for things like BTF, and there are other guest-visible side effects if BusLockTrap is left enabled.
If BusLockTrap is disabled, then DR6.BLD is reserved-to-1; any attempts to clear it by software are ignored. But if BusLockTrap is enabled, software can clear DR6.BLD:
Software enables bus lock trap by setting DebugCtl MSR[BLCKDB] (bit 2) to 1. When bus lock trap is enabled, ... The processor indicates that this #DB was caused by a bus lock by clearing DR6[BLD] (bit 11). DR6[11] previously had been defined to be always 1.
and clearing DR6.BLD is "sticky" in that it's not set (i.e. lowered) by other #DBs:
All other #DB exceptions leave DR6[BLD] unmodified
E.g. leaving BusLockTrap enable can confuse a legacy guest that writes '0' to reset DR6.
--- arch/x86/kvm/svm/svm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/x86/kvm/svm/svm.c +14 -0
@@ -4275,6 +4275,16 @@ static __no_kcsan fastpath_t svm_vcpu_ruclgi ();kvm_load_guest_xsave_state (vcpu); +/* +* Hardware only context switches DEBUGCTL if LBR virtualization is +* enabled. Manually load DEBUGCTL if necessary (and restore it after +* VM-Exit), as running with the host's DEBUGCTL can negatively affect +* guest state and can even be fatal, e.g. due to Bus Lock Detect. +*/ +if (!(svm->vmcb->control.virt_ext &LBR_CTL_ENABLE_MASK ) && + vcpu->arch.host_debugctl != svm->vmcb->save.dbgctl) +update_debugctlmsr (svm->vmcb->save.dbgctl); +kvm_wait_lapic_expire (vcpu);/*
@@ -4302,6 +4312,10 @@ static __no_kcsan fastpath_t svm_vcpu_ruif (unlikely (svm->vmcb->control.exit_code ==SVM_EXIT_NMI ))kvm_before_interrupt (vcpu,KVM_HANDLING_NMI ); +if (!(svm->vmcb->control.virt_ext &LBR_CTL_ENABLE_MASK ) && + vcpu->arch.host_debugctl != svm->vmcb->save.dbgctl) +update_debugctlmsr (vcpu->arch.host_debugctl); +kvm_load_host_xsave_state (vcpu);stgi ();
Greg Kroah-Hartman
maintainerPATCH 235/269 KVM: x86: Snapshot the hosts DEBUGCTL after disabling IRQs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 189ecdb3e112da703ac0699f4ec76aa78122f911 upstream.
Snapshot the host's DEBUGCTL after disabling IRQs, as perf can toggle debugctl bits from IRQ context, e.g. when enabling/disabling events via smp_call_function_single(). Taking the snapshot (long) before IRQs are disabled could result in KVM effectively clobbering DEBUGCTL due to using a stale snapshot.
--- arch/x86/kvm/x86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/x86.c +2 -1
@@ -4993,7 +4993,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu/* Save host pkru register if supported */ vcpu->arch.host_pkru =read_pkru (); - vcpu->arch.host_debugctl =get_debugctlmsr ();/* Apply any externally detected TSC adjustments (due to suspend) */ if (unlikely (vcpu->arch.tsc_offset_adjustment)) {
@@ -10965,6 +10964,8 @@ static int vcpu_enter_guest(struct kvm_vset_debugreg (0 ,7 ); } + vcpu->arch.host_debugctl =get_debugctlmsr (); +guest_timing_enter_irqoff ();for (;;) {
Greg Kroah-Hartman
maintainerPATCH 236/269 KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isnt supported by KVM
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaoyao Li <[email protected]>
commit f9dc8fb3afc968042bdaf4b6e445a9272071c9f3 upstream.
Fix a goof where KVM sets CPUID.0x80000022.EAX to CPUID.0x80000022.EBX instead of zeroing both when PERFMON_V2 isn't supported by KVM. In practice, barring a buggy CPU (or vCPU model when running nested) only the !enable_pmu case is affected, as KVM always supports PERFMON_V2 if it's available in hardware, i.e. CPUID.0x80000022.EBX will be '0' if PERFMON_V2 is unsupported.
For the !enable_pmu case, the bug is relatively benign as KVM will refuse to enable PMU capabilities, but a VMM that reflects KVM's supported CPUID into the guest could inadvertently induce #GPs in the guest due to advertising support for MSRs that KVM refuses to emulate.
--- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +1 -1
@@ -1387,7 +1387,7 @@ static inline int __do_cpuid_func(struct entry->ecx = entry->edx =0 ;if (!enable_pmu || !kvm_cpu_cap_has (X86_FEATURE_PERFMON_V2 )) { - entry->eax = entry->ebx; + entry->eax = entry->ebx =0 ;break ; }
Greg Kroah-Hartman
maintainerPATCH 237/269 cdx: Fix possible UAF error in driver_override_show()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiu-ji Chen <[email protected]>
commit 91d44c1afc61a2fec37a9c7a3485368309391e0b upstream.
Fixed a possible UAF problem in driver_override_show() in drivers/cdx/cdx.c
This function driver_override_show() is part of DEVICE_ATTR_RW, which includes both driver_override_show() and driver_override_store(). These functions can be executed concurrently in sysfs.
The driver_override_store() function uses driver_set_override() to update the driver_override value, and driver_set_override() internally locks the device (device_lock(dev)). If driver_override_show() reads cdx_dev->driver_override without locking, it could potentially access a freed pointer if driver_override_store() frees the string concurrently. This could lead to printing a kernel address, which is a security risk since DEVICE_ATTR can be read by all users.
Additionally, a similar pattern is used in drivers/amba/bus.c, as well as many other bus drivers, where device_lock() is taken in the show function, and it has been working without issues.
This potential bug was detected by our experimental static analysis tool, which analyzes locking APIs and paired functions to identify data races and atomicity violations.
--- drivers/cdx/cdx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/cdx/cdx.c +5 -1
@@ -470,8 +470,12 @@ static ssize_t driver_override_show(stru struct device_attribute *attr, char *buf) { struct cdx_device *cdx_dev = to_cdx_device(dev); +ssize_t len; -return sysfs_emit (buf,"%s\n" , cdx_dev->driver_override); +device_lock (dev); + len =sysfs_emit (buf,"%s\n" , cdx_dev->driver_override); +device_unlock (dev); +return len; }static DEVICE_ATTR_RW (driver_override);
Greg Kroah-Hartman
maintainerPATCH 238/269 mei: me: add panther lake P DID
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit a8e8ffcc3afce2ee5fb70162aeaef3f03573ee1e upstream.
Add Panther Lake P device id.
--- drivers/misc/mei/hw-me-regs.h | 2 ++ drivers/misc/mei/pci-me.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/misc/mei/hw-me-regs.h +2 -0
@@ -117,6 +117,8 @@#define MEI_DEV_ID_LNL_M 0xA870/* Lunar Lake Point M */ +#define MEI_DEV_ID_PTL_P 0xE470/* Panther Lake P */ +/* * MEI HW Section */
drivers/misc/mei/pci-me.c +2 -0
@@ -124,6 +124,8 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_LNL_M, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_PTL_P, MEI_ME_PCH15_CFG)}, +/* required last entry */ {0, } };
Greg Kroah-Hartman
maintainerPATCH 239/269 mei: vsc: Use "wakeuphostint" when getting the host wakeup GPIO
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit fdb1ada57cf8b8752cdf54f08709d76d74999544 upstream.
The _CRS ACPI resources table has 2 entries for the host wakeup GPIO, the first one being a regular GpioIo () resource while the second one is a GpioInt () resource for the same pin.
The acpi_gpio_mapping table used by vsc-tp.c maps the first Gpio () resource to "wakeuphost-gpios" where as the second GpioInt () entry is mapped to "wakeuphostint-gpios".
Using "wakeuphost" to request the GPIO as was done until now, means that the gpiolib-acpi code does not know that the GPIO is active-low as that info is only available in the GpioInt () entry.
Things were still working before due to the following happening:
1. Since the 2 entries point to the same pin they share a struct gpio_desc
2. The SPI core creates the SPI device vsc-tp.c binds to and calls acpi_dev_gpio_irq_get(). This does use the second entry and sets FLAG_ACTIVE_LOW in gpio_desc.flags .
3. vsc_tp_probe() requests the "wakeuphost" GPIO and inherits the active-low flag set by acpi_dev_gpio_irq_get()
But there is a possible scenario where things do not work:
1. - 3. happen as above
4. After requesting the "wakeuphost" GPIO, the "resetfw" GPIO is requested next, but its USB GPIO controller is not available yet, so this call returns -EPROBE_DEFER.
5. The gpio_desc for "wakeuphost" is put() and during this the active-low flag is cleared from gpio_desc.flags .
6. Later on vsc_tp_probe() requests the "wakeuphost" GPIO again, but now it is not marked active-low.
The difference can also be seen in /sys/kernel/debug/gpio, which contains the following line for this GPIO:
gpio-535 ( |wakeuphost ) in hi IRQ ACTIVE LOW
If the second scenario is hit the "ACTIVE LOW" at the end disappears and things do not work.
Fix this by requesting the GPIO through the "wakeuphostint" mapping instead which provides active-low info without relying on acpi_dev_gpio_irq_get() pre-populating this info in the gpio_desc.
--- drivers/misc/mei/vsc-tp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/vsc-tp.c +1 -1
@@ -504,7 +504,7 @@ static int vsc_tp_probe(struct spi_devicif (ret)return ret; - tp->wakeuphost =devm_gpiod_get (dev,"wakeuphost" ,GPIOD_IN ); + tp->wakeuphost =devm_gpiod_get (dev,"wakeuphostint" ,GPIOD_IN );if (IS_ERR (tp->wakeuphost))return PTR_ERR (tp->wakeuphost);
Greg Kroah-Hartman
maintainerPATCH 240/269 intel_th: pci: Add Arrow Lake support
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawel Chmielewski <[email protected]>
commit b5edccae9f447a92d475267d94c33f4926963eec upstream.
Add support for the Trace Hub in Arrow Lake.
--- drivers/hwtracing/intel_th/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwtracing/intel_th/pci.c +5 -0
@@ -330,6 +330,11 @@ static const struct pci_device_id intel_ .driver_data = (kernel_ulong_t)&intel_th_2x, }, { +/* Arrow Lake */ + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x7724), + .driver_data = (kernel_ulong_t)&intel_th_2x, + }, + {/* Alder Lake CPU */ PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x466f ), .driver_data = (kernel_ulong_t)&intel_th_2x,
Greg Kroah-Hartman
maintainerPATCH 241/269 intel_th: pci: Add Panther Lake-H support
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Shishkin <[email protected]>
commit a70034d6c0d5f3cdee40bb00a578e17fd2ebe426 upstream.
Add support for the Trace Hub in Panther Lake-H.
--- drivers/hwtracing/intel_th/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwtracing/intel_th/pci.c +5 -0
@@ -335,6 +335,11 @@ static const struct pci_device_id intel_ .driver_data = (kernel_ulong_t)&intel_th_2x, }, { +/* Panther Lake-H */ + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe324), + .driver_data = (kernel_ulong_t)&intel_th_2x, + }, + {/* Alder Lake CPU */ PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x466f ), .driver_data = (kernel_ulong_t)&intel_th_2x,
Greg Kroah-Hartman
maintainerPATCH 242/269 intel_th: pci: Add Panther Lake-P/U support
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Shishkin <[email protected]>
commit 49114ff05770264ae233f50023fc64a719a9dcf9 upstream.
Add support for the Trace Hub in Panther Lake-P/U.
--- drivers/hwtracing/intel_th/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwtracing/intel_th/pci.c +5 -0
@@ -340,6 +340,11 @@ static const struct pci_device_id intel_ .driver_data = (kernel_ulong_t)&intel_th_2x, }, { +/* Panther Lake-P/U */ + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe424), + .driver_data = (kernel_ulong_t)&intel_th_2x, + }, + {/* Alder Lake CPU */ PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x466f ), .driver_data = (kernel_ulong_t)&intel_th_2x,
Greg Kroah-Hartman
maintainerPATCH 243/269 char: misc: deallocate static minor in error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
commit 6d991f569c5ef6eaeadf1238df2c36e3975233ad upstream.
When creating sysfs files fail, the allocated minor must be freed such that it can be later reused. That is specially harmful for static minor numbers, since those would always fail to register later on.
--- drivers/char/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/misc.c +1 -1
@@ -264,8 +264,8 @@ int misc_register(struct miscdevice *misdevice_create_with_groups (&misc_class, misc->parent, dev, misc, misc->groups,"%s" , misc->name);if (IS_ERR (misc->this_device)) { +misc_minor_free (misc->minor);if (is_dynamic) { -misc_minor_free (misc->minor); misc->minor =MISC_DYNAMIC_MINOR ; } err =PTR_ERR (misc->this_device);
Greg Kroah-Hartman
maintainerPATCH 244/269 drivers: core: fix device leak in __fw_devlink_relax_cycles()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
commit 78eb41f518f414378643ab022241df2a9dcd008b upstream.
Commit bac3b10b78e5 ("driver core: fw_devlink: Stop trying to optimize cycle detection logic") introduced a new struct device *con_dev and a get_dev_from_fwnode() call to get it, but without adding a corresponding put_device().
--- drivers/base/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/base/core.c +1 -0
@@ -2079,6 +2079,7 @@ static bool __fw_devlink_relax_cycles(st out: sup_handle->flags &= ~FWNODE_FLAG_VISITED ;put_device (sup_dev); +put_device (con_dev);put_device (par_dev);return ret; }
Greg Kroah-Hartman
maintainerPATCH 245/269 slimbus: messaging: Free transaction ID in delayed interrupt scenario
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Visweswara Tanuku <[email protected]>
commit dcb0d43ba8eb9517e70b1a0e4b0ae0ab657a0e5a upstream.
In case of interrupt delay for any reason, slim_do_transfer() returns timeout error but the transaction ID (TID) is not freed. This results into invalid memory access inside qcom_slim_ngd_rx_msgq_cb() due to invalid TID.
Fix the issue by freeing the TID in slim_do_transfer() before returning timeout error to avoid invalid memory access.
Call trace: __memcpy_fromio+0x20/0x190 qcom_slim_ngd_rx_msgq_cb+0x130/0x290 [slim_qcom_ngd_ctrl] vchan_complete+0x2a0/0x4a0 tasklet_action_common+0x274/0x700 tasklet_action+0x28/0x3c _stext+0x188/0x620 run_ksoftirqd+0x34/0x74 smpboot_thread_fn+0x1d8/0x464 kthread+0x178/0x238 ret_from_fork+0x10/0x20 Code: aa0003e8 91000429 f100044a 3940002b (3800150b) ---[ end trace 0fe00bec2b975c99 ]--- Kernel panic - not syncing: Oops: Fatal exception in interrupt.
--- drivers/slimbus/messaging.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/slimbus/messaging.c +3 -2
@@ -148,8 +148,9 @@ int slim_do_transfer(struct slim_control } ret = ctrl->xfer_msg (ctrl, txn); - -if (!ret && need_tid && !txn->msg->comp) { +if (ret == -ETIMEDOUT ) { +slim_free_txn_tid (ctrl, txn); + }else if (!ret && need_tid && !txn->msg->comp) {unsigned long ms = txn->rl +HZ ; time_left = wait_for_completion_timeout(txn->comp,
Greg Kroah-Hartman
maintainerPATCH 246/269 bus: mhi: host: pci_generic: Use pci_try_reset_function() to avoid deadlock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
commit a321d163de3d8aa38a6449ab2becf4b1581aed96 upstream.
There are multiple places from where the recovery work gets scheduled asynchronously. Also, there are multiple places where the caller waits synchronously for the recovery to be completed. One such place is during the PM shutdown() callback.
If the device is not alive during recovery_work, it will try to reset the device using pci_reset_function(). This function internally will take the device_lock() first before resetting the device. By this time, if the lock has already been acquired, then recovery_work will get stalled while waiting for the lock. And if the lock was already acquired by the caller which waits for the recovery_work to be completed, it will lead to deadlock.
This is what happened on the X1E80100 CRD device when the device died before shutdown() callback. Driver core calls the driver's shutdown() callback while holding the device_lock() leading to deadlock.
And this deadlock scenario can occur on other paths as well, like during the PM suspend() callback, where the driver core would hold the device_lock() before calling driver's suspend() callback. And if the recovery_work was already started, it could lead to deadlock. This is also observed on the X1E80100 CRD.
So to fix both issues, use pci_try_reset_function() in recovery_work. This function first checks for the availability of the device_lock() before trying to reset the device. If the lock is available, it will acquire it and reset the device. Otherwise, it will return -EAGAIN. If that happens, recovery_work will fail with the error message "Recovery failed" as not much could be done.
--- drivers/bus/mhi/host/pci_generic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/bus/mhi/host/pci_generic.c +3 -2
@@ -1040,8 +1040,9 @@ static void mhi_pci_recovery_work(struct err_unprepare:mhi_unprepare_after_power_down (mhi_cntrl); err_try_reset: -if (pci_reset_function (pdev)) -dev_err (&pdev->dev,"Recovery failed\n" ); + err =pci_try_reset_function (pdev); +if (err) +dev_err (&pdev->dev,"Recovery failed: %d\n" , err); }static void health_check (struct timer_list *t)
Greg Kroah-Hartman
maintainerPATCH 247/269 eeprom: digsy_mtc: Make GPIO lookup table match the device
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 038ef0754aae76f79b147b8867f9250e6a976872 upstream.
The dev_id value in the GPIO lookup table must match to the device instance name, which in this case is combined of name and platform device ID, i.e. "spi_gpio.1". But the table assumed that there was no platform device ID defined, which is wrong. Fix the dev_id value accordingly.
--- drivers/misc/eeprom/digsy_mtc_eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/eeprom/digsy_mtc_eeprom.c +1 -1
@@ -50,7 +50,7 @@ static struct platform_device digsy_mtc_ };static struct gpiod_lookup_table eeprom_spi_gpiod_table = { - .dev_id ="spi_gpio" , + .dev_id ="spi_gpio.1" , .table = {GPIO_LOOKUP ("gpio@b00" ,GPIO_EEPROM_CLK ,"sck" ,GPIO_ACTIVE_HIGH ),