···735735Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de>736736Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com>737737Yanteng Si <si.yanteng@linux.dev> <siyanteng@loongson.cn>738738+Ying Huang <huang.ying.caritas@gmail.com> <ying.huang@intel.com>738739Yusuke Goda <goda.yusuke@renesas.com>739740Zack Rusin <zack.rusin@broadcom.com> <zackr@vmware.com>740741Zhu Yanjun <zyjzyj2000@gmail.com> <yanjunz@nvidia.com>
+1-3
Documentation/admin-guide/pm/amd-pstate.rst
···251251In some ASICs, the highest CPPC performance is not the one in the ``_CPC``252252table, so we need to expose it to sysfs. If boost is not active, but253253still supported, this maximum frequency will be larger than the one in254254-``cpuinfo``. On systems that support preferred core, the driver will have255255-different values for some cores than others and this will reflect the values256256-advertised by the platform at bootup.254254+``cpuinfo``.257255This attribute is read-only.258256259257``amd_pstate_lowest_nonlinear_freq``
···114114 table that specifies the PPID to LIODN mapping. Needed if the PAMU is115115 used. Value is a 12 bit value where value is a LIODN ID for this JR.116116 This property is normally set by boot firmware.117117- $ref: /schemas/types.yaml#/definitions/uint32118118- maximum: 0xfff117117+ $ref: /schemas/types.yaml#/definitions/uint32-array118118+ items:119119+ - maximum: 0xfff119120120121 '^rtic@[0-9a-f]+$':121122 type: object···187186 Needed if the PAMU is used. Value is a 12 bit value where value188187 is a LIODN ID for this JR. This property is normally set by boot189188 firmware.190190- $ref: /schemas/types.yaml#/definitions/uint32191191- maximum: 0xfff189189+ $ref: /schemas/types.yaml#/definitions/uint32-array190190+ items:191191+ - maximum: 0xfff192192193193 fsl,rtic-region:194194 description:
···35353636 fsl,liodn:3737 $ref: /schemas/types.yaml#/definitions/uint32-array3838+ maxItems: 23839 description: See pamu.txt. Two LIODN(s). DQRR LIODN (DLIODN) and Frame LIODN3940 (FLIODN)4041···7069 type: object7170 properties:7271 fsl,liodn:7272+ $ref: /schemas/types.yaml#/definitions/uint32-array7373 description: See pamu.txt, PAMU property used for static LIODN assignment74747575 fsl,iommu-parent:
+850
Documentation/mm/process_addrs.rst
···33=================44Process Addresses55=================66+77+.. toctree::88+ :maxdepth: 399+1010+1111+Userland memory ranges are tracked by the kernel via Virtual Memory Areas or1212+'VMA's of type :c:struct:`!struct vm_area_struct`.1313+1414+Each VMA describes a virtually contiguous memory range with identical1515+attributes, each described by a :c:struct:`!struct vm_area_struct`1616+object. Userland access outside of VMAs is invalid except in the case where an1717+adjacent stack VMA could be extended to contain the accessed address.1818+1919+All VMAs are contained within one and only one virtual address space, described2020+by a :c:struct:`!struct mm_struct` object which is referenced by all tasks (that is,2121+threads) which share the virtual address space. We refer to this as the2222+:c:struct:`!mm`.2323+2424+Each mm object contains a maple tree data structure which describes all VMAs2525+within the virtual address space.2626+2727+.. note:: An exception to this is the 'gate' VMA which is provided by2828+ architectures which use :c:struct:`!vsyscall` and is a global static2929+ object which does not belong to any specific mm.3030+3131+-------3232+Locking3333+-------3434+3535+The kernel is designed to be highly scalable against concurrent read operations3636+on VMA **metadata** so a complicated set of locks are required to ensure memory3737+corruption does not occur.3838+3939+.. note:: Locking VMAs for their metadata does not have any impact on the memory4040+ they describe nor the page tables that map them.4141+4242+Terminology4343+-----------4444+4545+* **mmap locks** - Each MM has a read/write semaphore :c:member:`!mmap_lock`4646+ which locks at a process address space granularity which can be acquired via4747+ :c:func:`!mmap_read_lock`, :c:func:`!mmap_write_lock` and variants.4848+* **VMA locks** - The VMA lock is at VMA granularity (of course) which behaves4949+ as a read/write semaphore in practice. A VMA read lock is obtained via5050+ :c:func:`!lock_vma_under_rcu` (and unlocked via :c:func:`!vma_end_read`) and a5151+ write lock via :c:func:`!vma_start_write` (all VMA write locks are unlocked5252+ automatically when the mmap write lock is released). To take a VMA write lock5353+ you **must** have already acquired an :c:func:`!mmap_write_lock`.5454+* **rmap locks** - When trying to access VMAs through the reverse mapping via a5555+ :c:struct:`!struct address_space` or :c:struct:`!struct anon_vma` object5656+ (reachable from a folio via :c:member:`!folio->mapping`). VMAs must be stabilised via5757+ :c:func:`!anon_vma_[try]lock_read` or :c:func:`!anon_vma_[try]lock_write` for5858+ anonymous memory and :c:func:`!i_mmap_[try]lock_read` or5959+ :c:func:`!i_mmap_[try]lock_write` for file-backed memory. We refer to these6060+ locks as the reverse mapping locks, or 'rmap locks' for brevity.6161+6262+We discuss page table locks separately in the dedicated section below.6363+6464+The first thing **any** of these locks achieve is to **stabilise** the VMA6565+within the MM tree. That is, guaranteeing that the VMA object will not be6666+deleted from under you nor modified (except for some specific fields6767+described below).6868+6969+Stabilising a VMA also keeps the address space described by it around.7070+7171+Lock usage7272+----------7373+7474+If you want to **read** VMA metadata fields or just keep the VMA stable, you7575+must do one of the following:7676+7777+* Obtain an mmap read lock at the MM granularity via :c:func:`!mmap_read_lock` (or a7878+ suitable variant), unlocking it with a matching :c:func:`!mmap_read_unlock` when7979+ you're done with the VMA, *or*8080+* Try to obtain a VMA read lock via :c:func:`!lock_vma_under_rcu`. This tries to8181+ acquire the lock atomically so might fail, in which case fall-back logic is8282+ required to instead obtain an mmap read lock if this returns :c:macro:`!NULL`,8383+ *or*8484+* Acquire an rmap lock before traversing the locked interval tree (whether8585+ anonymous or file-backed) to obtain the required VMA.8686+8787+If you want to **write** VMA metadata fields, then things vary depending on the8888+field (we explore each VMA field in detail below). For the majority you must:8989+9090+* Obtain an mmap write lock at the MM granularity via :c:func:`!mmap_write_lock` (or a9191+ suitable variant), unlocking it with a matching :c:func:`!mmap_write_unlock` when9292+ you're done with the VMA, *and*9393+* Obtain a VMA write lock via :c:func:`!vma_start_write` for each VMA you wish to9494+ modify, which will be released automatically when :c:func:`!mmap_write_unlock` is9595+ called.9696+* If you want to be able to write to **any** field, you must also hide the VMA9797+ from the reverse mapping by obtaining an **rmap write lock**.9898+9999+VMA locks are special in that you must obtain an mmap **write** lock **first**100100+in order to obtain a VMA **write** lock. A VMA **read** lock however can be101101+obtained without any other lock (:c:func:`!lock_vma_under_rcu` will acquire then102102+release an RCU lock to lookup the VMA for you).103103+104104+This constrains the impact of writers on readers, as a writer can interact with105105+one VMA while a reader interacts with another simultaneously.106106+107107+.. note:: The primary users of VMA read locks are page fault handlers, which108108+ means that without a VMA write lock, page faults will run concurrent with109109+ whatever you are doing.110110+111111+Examining all valid lock states:112112+113113+.. table::114114+115115+ ========= ======== ========= ======= ===== =========== ==========116116+ mmap lock VMA lock rmap lock Stable? Read? Write most? Write all?117117+ ========= ======== ========= ======= ===== =========== ==========118118+ \- \- \- N N N N119119+ \- R \- Y Y N N120120+ \- \- R/W Y Y N N121121+ R/W \-/R \-/R/W Y Y N N122122+ W W \-/R Y Y Y N123123+ W W W Y Y Y Y124124+ ========= ======== ========= ======= ===== =========== ==========125125+126126+.. warning:: While it's possible to obtain a VMA lock while holding an mmap read lock,127127+ attempting to do the reverse is invalid as it can result in deadlock - if128128+ another task already holds an mmap write lock and attempts to acquire a VMA129129+ write lock that will deadlock on the VMA read lock.130130+131131+All of these locks behave as read/write semaphores in practice, so you can132132+obtain either a read or a write lock for each of these.133133+134134+.. note:: Generally speaking, a read/write semaphore is a class of lock which135135+ permits concurrent readers. However a write lock can only be obtained136136+ once all readers have left the critical region (and pending readers137137+ made to wait).138138+139139+ This renders read locks on a read/write semaphore concurrent with other140140+ readers and write locks exclusive against all others holding the semaphore.141141+142142+VMA fields143143+^^^^^^^^^^144144+145145+We can subdivide :c:struct:`!struct vm_area_struct` fields by their purpose, which makes it146146+easier to explore their locking characteristics:147147+148148+.. note:: We exclude VMA lock-specific fields here to avoid confusion, as these149149+ are in effect an internal implementation detail.150150+151151+.. table:: Virtual layout fields152152+153153+ ===================== ======================================== ===========154154+ Field Description Write lock155155+ ===================== ======================================== ===========156156+ :c:member:`!vm_start` Inclusive start virtual address of range mmap write,157157+ VMA describes. VMA write,158158+ rmap write.159159+ :c:member:`!vm_end` Exclusive end virtual address of range mmap write,160160+ VMA describes. VMA write,161161+ rmap write.162162+ :c:member:`!vm_pgoff` Describes the page offset into the file, mmap write,163163+ the original page offset within the VMA write,164164+ virtual address space (prior to any rmap write.165165+ :c:func:`!mremap`), or PFN if a PFN map166166+ and the architecture does not support167167+ :c:macro:`!CONFIG_ARCH_HAS_PTE_SPECIAL`.168168+ ===================== ======================================== ===========169169+170170+These fields describes the size, start and end of the VMA, and as such cannot be171171+modified without first being hidden from the reverse mapping since these fields172172+are used to locate VMAs within the reverse mapping interval trees.173173+174174+.. table:: Core fields175175+176176+ ============================ ======================================== =========================177177+ Field Description Write lock178178+ ============================ ======================================== =========================179179+ :c:member:`!vm_mm` Containing mm_struct. None - written once on180180+ initial map.181181+ :c:member:`!vm_page_prot` Architecture-specific page table mmap write, VMA write.182182+ protection bits determined from VMA183183+ flags.184184+ :c:member:`!vm_flags` Read-only access to VMA flags describing N/A185185+ attributes of the VMA, in union with186186+ private writable187187+ :c:member:`!__vm_flags`.188188+ :c:member:`!__vm_flags` Private, writable access to VMA flags mmap write, VMA write.189189+ field, updated by190190+ :c:func:`!vm_flags_*` functions.191191+ :c:member:`!vm_file` If the VMA is file-backed, points to a None - written once on192192+ struct file object describing the initial map.193193+ underlying file, if anonymous then194194+ :c:macro:`!NULL`.195195+ :c:member:`!vm_ops` If the VMA is file-backed, then either None - Written once on196196+ the driver or file-system provides a initial map by197197+ :c:struct:`!struct vm_operations_struct` :c:func:`!f_ops->mmap()`.198198+ object describing callbacks to be199199+ invoked on VMA lifetime events.200200+ :c:member:`!vm_private_data` A :c:member:`!void *` field for Handled by driver.201201+ driver-specific metadata.202202+ ============================ ======================================== =========================203203+204204+These are the core fields which describe the MM the VMA belongs to and its attributes.205205+206206+.. table:: Config-specific fields207207+208208+ ================================= ===================== ======================================== ===============209209+ Field Configuration option Description Write lock210210+ ================================= ===================== ======================================== ===============211211+ :c:member:`!anon_name` CONFIG_ANON_VMA_NAME A field for storing a mmap write,212212+ :c:struct:`!struct anon_vma_name` VMA write.213213+ object providing a name for anonymous214214+ mappings, or :c:macro:`!NULL` if none215215+ is set or the VMA is file-backed. The216216+ underlying object is reference counted217217+ and can be shared across multiple VMAs218218+ for scalability.219219+ :c:member:`!swap_readahead_info` CONFIG_SWAP Metadata used by the swap mechanism mmap read,220220+ to perform readahead. This field is swap-specific221221+ accessed atomically. lock.222222+ :c:member:`!vm_policy` CONFIG_NUMA :c:type:`!mempolicy` object which mmap write,223223+ describes the NUMA behaviour of the VMA write.224224+ VMA. The underlying object is reference225225+ counted.226226+ :c:member:`!numab_state` CONFIG_NUMA_BALANCING :c:type:`!vma_numab_state` object which mmap read,227227+ describes the current state of numab-specific228228+ NUMA balancing in relation to this VMA. lock.229229+ Updated under mmap read lock by230230+ :c:func:`!task_numa_work`.231231+ :c:member:`!vm_userfaultfd_ctx` CONFIG_USERFAULTFD Userfaultfd context wrapper object of mmap write,232232+ type :c:type:`!vm_userfaultfd_ctx`, VMA write.233233+ either of zero size if userfaultfd is234234+ disabled, or containing a pointer235235+ to an underlying236236+ :c:type:`!userfaultfd_ctx` object which237237+ describes userfaultfd metadata.238238+ ================================= ===================== ======================================== ===============239239+240240+These fields are present or not depending on whether the relevant kernel241241+configuration option is set.242242+243243+.. table:: Reverse mapping fields244244+245245+ =================================== ========================================= ============================246246+ Field Description Write lock247247+ =================================== ========================================= ============================248248+ :c:member:`!shared.rb` A red/black tree node used, if the mmap write, VMA write,249249+ mapping is file-backed, to place the VMA i_mmap write.250250+ in the251251+ :c:member:`!struct address_space->i_mmap`252252+ red/black interval tree.253253+ :c:member:`!shared.rb_subtree_last` Metadata used for management of the mmap write, VMA write,254254+ interval tree if the VMA is file-backed. i_mmap write.255255+ :c:member:`!anon_vma_chain` List of pointers to both forked/CoW’d mmap read, anon_vma write.256256+ :c:type:`!anon_vma` objects and257257+ :c:member:`!vma->anon_vma` if it is258258+ non-:c:macro:`!NULL`.259259+ :c:member:`!anon_vma` :c:type:`!anon_vma` object used by When :c:macro:`NULL` and260260+ anonymous folios mapped exclusively to setting non-:c:macro:`NULL`:261261+ this VMA. Initially set by mmap read, page_table_lock.262262+ :c:func:`!anon_vma_prepare` serialised263263+ by the :c:macro:`!page_table_lock`. This When non-:c:macro:`NULL` and264264+ is set as soon as any page is faulted in. setting :c:macro:`NULL`:265265+ mmap write, VMA write,266266+ anon_vma write.267267+ =================================== ========================================= ============================268268+269269+These fields are used to both place the VMA within the reverse mapping, and for270270+anonymous mappings, to be able to access both related :c:struct:`!struct anon_vma` objects271271+and the :c:struct:`!struct anon_vma` in which folios mapped exclusively to this VMA should272272+reside.273273+274274+.. note:: If a file-backed mapping is mapped with :c:macro:`!MAP_PRIVATE` set275275+ then it can be in both the :c:type:`!anon_vma` and :c:type:`!i_mmap`276276+ trees at the same time, so all of these fields might be utilised at277277+ once.278278+279279+Page tables280280+-----------281281+282282+We won't speak exhaustively on the subject but broadly speaking, page tables map283283+virtual addresses to physical ones through a series of page tables, each of284284+which contain entries with physical addresses for the next page table level285285+(along with flags), and at the leaf level the physical addresses of the286286+underlying physical data pages or a special entry such as a swap entry,287287+migration entry or other special marker. Offsets into these pages are provided288288+by the virtual address itself.289289+290290+In Linux these are divided into five levels - PGD, P4D, PUD, PMD and PTE. Huge291291+pages might eliminate one or two of these levels, but when this is the case we292292+typically refer to the leaf level as the PTE level regardless.293293+294294+.. note:: In instances where the architecture supports fewer page tables than295295+ five the kernel cleverly 'folds' page table levels, that is stubbing296296+ out functions related to the skipped levels. This allows us to297297+ conceptually act as if there were always five levels, even if the298298+ compiler might, in practice, eliminate any code relating to missing299299+ ones.300300+301301+There are four key operations typically performed on page tables:302302+303303+1. **Traversing** page tables - Simply reading page tables in order to traverse304304+ them. This only requires that the VMA is kept stable, so a lock which305305+ establishes this suffices for traversal (there are also lockless variants306306+ which eliminate even this requirement, such as :c:func:`!gup_fast`).307307+2. **Installing** page table mappings - Whether creating a new mapping or308308+ modifying an existing one in such a way as to change its identity. This309309+ requires that the VMA is kept stable via an mmap or VMA lock (explicitly not310310+ rmap locks).311311+3. **Zapping/unmapping** page table entries - This is what the kernel calls312312+ clearing page table mappings at the leaf level only, whilst leaving all page313313+ tables in place. This is a very common operation in the kernel performed on314314+ file truncation, the :c:macro:`!MADV_DONTNEED` operation via315315+ :c:func:`!madvise`, and others. This is performed by a number of functions316316+ including :c:func:`!unmap_mapping_range` and :c:func:`!unmap_mapping_pages`.317317+ The VMA need only be kept stable for this operation.318318+4. **Freeing** page tables - When finally the kernel removes page tables from a319319+ userland process (typically via :c:func:`!free_pgtables`) extreme care must320320+ be taken to ensure this is done safely, as this logic finally frees all page321321+ tables in the specified range, ignoring existing leaf entries (it assumes the322322+ caller has both zapped the range and prevented any further faults or323323+ modifications within it).324324+325325+.. note:: Modifying mappings for reclaim or migration is performed under rmap326326+ lock as it, like zapping, does not fundamentally modify the identity327327+ of what is being mapped.328328+329329+**Traversing** and **zapping** ranges can be performed holding any one of the330330+locks described in the terminology section above - that is the mmap lock, the331331+VMA lock or either of the reverse mapping locks.332332+333333+That is - as long as you keep the relevant VMA **stable** - you are good to go334334+ahead and perform these operations on page tables (though internally, kernel335335+operations that perform writes also acquire internal page table locks to336336+serialise - see the page table implementation detail section for more details).337337+338338+When **installing** page table entries, the mmap or VMA lock must be held to339339+keep the VMA stable. We explore why this is in the page table locking details340340+section below.341341+342342+.. warning:: Page tables are normally only traversed in regions covered by VMAs.343343+ If you want to traverse page tables in areas that might not be344344+ covered by VMAs, heavier locking is required.345345+ See :c:func:`!walk_page_range_novma` for details.346346+347347+**Freeing** page tables is an entirely internal memory management operation and348348+has special requirements (see the page freeing section below for more details).349349+350350+.. warning:: When **freeing** page tables, it must not be possible for VMAs351351+ containing the ranges those page tables map to be accessible via352352+ the reverse mapping.353353+354354+ The :c:func:`!free_pgtables` function removes the relevant VMAs355355+ from the reverse mappings, but no other VMAs can be permitted to be356356+ accessible and span the specified range.357357+358358+Lock ordering359359+-------------360360+361361+As we have multiple locks across the kernel which may or may not be taken at the362362+same time as explicit mm or VMA locks, we have to be wary of lock inversion, and363363+the **order** in which locks are acquired and released becomes very important.364364+365365+.. note:: Lock inversion occurs when two threads need to acquire multiple locks,366366+ but in doing so inadvertently cause a mutual deadlock.367367+368368+ For example, consider thread 1 which holds lock A and tries to acquire lock B,369369+ while thread 2 holds lock B and tries to acquire lock A.370370+371371+ Both threads are now deadlocked on each other. However, had they attempted to372372+ acquire locks in the same order, one would have waited for the other to373373+ complete its work and no deadlock would have occurred.374374+375375+The opening comment in :c:macro:`!mm/rmap.c` describes in detail the required376376+ordering of locks within memory management code:377377+378378+.. code-block::379379+380380+ inode->i_rwsem (while writing or truncating, not reading or faulting)381381+ mm->mmap_lock382382+ mapping->invalidate_lock (in filemap_fault)383383+ folio_lock384384+ hugetlbfs_i_mmap_rwsem_key (in huge_pmd_share, see hugetlbfs below)385385+ vma_start_write386386+ mapping->i_mmap_rwsem387387+ anon_vma->rwsem388388+ mm->page_table_lock or pte_lock389389+ swap_lock (in swap_duplicate, swap_info_get)390390+ mmlist_lock (in mmput, drain_mmlist and others)391391+ mapping->private_lock (in block_dirty_folio)392392+ i_pages lock (widely used)393393+ lruvec->lru_lock (in folio_lruvec_lock_irq)394394+ inode->i_lock (in set_page_dirty's __mark_inode_dirty)395395+ bdi.wb->list_lock (in set_page_dirty's __mark_inode_dirty)396396+ sb_lock (within inode_lock in fs/fs-writeback.c)397397+ i_pages lock (widely used, in set_page_dirty,398398+ in arch-dependent flush_dcache_mmap_lock,399399+ within bdi.wb->list_lock in __sync_single_inode)400400+401401+There is also a file-system specific lock ordering comment located at the top of402402+:c:macro:`!mm/filemap.c`:403403+404404+.. code-block::405405+406406+ ->i_mmap_rwsem (truncate_pagecache)407407+ ->private_lock (__free_pte->block_dirty_folio)408408+ ->swap_lock (exclusive_swap_page, others)409409+ ->i_pages lock410410+411411+ ->i_rwsem412412+ ->invalidate_lock (acquired by fs in truncate path)413413+ ->i_mmap_rwsem (truncate->unmap_mapping_range)414414+415415+ ->mmap_lock416416+ ->i_mmap_rwsem417417+ ->page_table_lock or pte_lock (various, mainly in memory.c)418418+ ->i_pages lock (arch-dependent flush_dcache_mmap_lock)419419+420420+ ->mmap_lock421421+ ->invalidate_lock (filemap_fault)422422+ ->lock_page (filemap_fault, access_process_vm)423423+424424+ ->i_rwsem (generic_perform_write)425425+ ->mmap_lock (fault_in_readable->do_page_fault)426426+427427+ bdi->wb.list_lock428428+ sb_lock (fs/fs-writeback.c)429429+ ->i_pages lock (__sync_single_inode)430430+431431+ ->i_mmap_rwsem432432+ ->anon_vma.lock (vma_merge)433433+434434+ ->anon_vma.lock435435+ ->page_table_lock or pte_lock (anon_vma_prepare and various)436436+437437+ ->page_table_lock or pte_lock438438+ ->swap_lock (try_to_unmap_one)439439+ ->private_lock (try_to_unmap_one)440440+ ->i_pages lock (try_to_unmap_one)441441+ ->lruvec->lru_lock (follow_page_mask->mark_page_accessed)442442+ ->lruvec->lru_lock (check_pte_range->folio_isolate_lru)443443+ ->private_lock (folio_remove_rmap_pte->set_page_dirty)444444+ ->i_pages lock (folio_remove_rmap_pte->set_page_dirty)445445+ bdi.wb->list_lock (folio_remove_rmap_pte->set_page_dirty)446446+ ->inode->i_lock (folio_remove_rmap_pte->set_page_dirty)447447+ bdi.wb->list_lock (zap_pte_range->set_page_dirty)448448+ ->inode->i_lock (zap_pte_range->set_page_dirty)449449+ ->private_lock (zap_pte_range->block_dirty_folio)450450+451451+Please check the current state of these comments which may have changed since452452+the time of writing of this document.453453+454454+------------------------------455455+Locking Implementation Details456456+------------------------------457457+458458+.. warning:: Locking rules for PTE-level page tables are very different from459459+ locking rules for page tables at other levels.460460+461461+Page table locking details462462+--------------------------463463+464464+In addition to the locks described in the terminology section above, we have465465+additional locks dedicated to page tables:466466+467467+* **Higher level page table locks** - Higher level page tables, that is PGD, P4D468468+ and PUD each make use of the process address space granularity469469+ :c:member:`!mm->page_table_lock` lock when modified.470470+471471+* **Fine-grained page table locks** - PMDs and PTEs each have fine-grained locks472472+ either kept within the folios describing the page tables or allocated473473+ separated and pointed at by the folios if :c:macro:`!ALLOC_SPLIT_PTLOCKS` is474474+ set. The PMD spin lock is obtained via :c:func:`!pmd_lock`, however PTEs are475475+ mapped into higher memory (if a 32-bit system) and carefully locked via476476+ :c:func:`!pte_offset_map_lock`.477477+478478+These locks represent the minimum required to interact with each page table479479+level, but there are further requirements.480480+481481+Importantly, note that on a **traversal** of page tables, sometimes no such482482+locks are taken. However, at the PTE level, at least concurrent page table483483+deletion must be prevented (using RCU) and the page table must be mapped into484484+high memory, see below.485485+486486+Whether care is taken on reading the page table entries depends on the487487+architecture, see the section on atomicity below.488488+489489+Locking rules490490+^^^^^^^^^^^^^491491+492492+We establish basic locking rules when interacting with page tables:493493+494494+* When changing a page table entry the page table lock for that page table495495+ **must** be held, except if you can safely assume nobody can access the page496496+ tables concurrently (such as on invocation of :c:func:`!free_pgtables`).497497+* Reads from and writes to page table entries must be *appropriately*498498+ atomic. See the section on atomicity below for details.499499+* Populating previously empty entries requires that the mmap or VMA locks are500500+ held (read or write), doing so with only rmap locks would be dangerous (see501501+ the warning below).502502+* As mentioned previously, zapping can be performed while simply keeping the VMA503503+ stable, that is holding any one of the mmap, VMA or rmap locks.504504+505505+.. warning:: Populating previously empty entries is dangerous as, when unmapping506506+ VMAs, :c:func:`!vms_clear_ptes` has a window of time between507507+ zapping (via :c:func:`!unmap_vmas`) and freeing page tables (via508508+ :c:func:`!free_pgtables`), where the VMA is still visible in the509509+ rmap tree. :c:func:`!free_pgtables` assumes that the zap has510510+ already been performed and removes PTEs unconditionally (along with511511+ all other page tables in the freed range), so installing new PTE512512+ entries could leak memory and also cause other unexpected and513513+ dangerous behaviour.514514+515515+There are additional rules applicable when moving page tables, which we discuss516516+in the section on this topic below.517517+518518+PTE-level page tables are different from page tables at other levels, and there519519+are extra requirements for accessing them:520520+521521+* On 32-bit architectures, they may be in high memory (meaning they need to be522522+ mapped into kernel memory to be accessible).523523+* When empty, they can be unlinked and RCU-freed while holding an mmap lock or524524+ rmap lock for reading in combination with the PTE and PMD page table locks.525525+ In particular, this happens in :c:func:`!retract_page_tables` when handling526526+ :c:macro:`!MADV_COLLAPSE`.527527+ So accessing PTE-level page tables requires at least holding an RCU read lock;528528+ but that only suffices for readers that can tolerate racing with concurrent529529+ page table updates such that an empty PTE is observed (in a page table that530530+ has actually already been detached and marked for RCU freeing) while another531531+ new page table has been installed in the same location and filled with532532+ entries. Writers normally need to take the PTE lock and revalidate that the533533+ PMD entry still refers to the same PTE-level page table.534534+535535+To access PTE-level page tables, a helper like :c:func:`!pte_offset_map_lock` or536536+:c:func:`!pte_offset_map` can be used depending on stability requirements.537537+These map the page table into kernel memory if required, take the RCU lock, and538538+depending on variant, may also look up or acquire the PTE lock.539539+See the comment on :c:func:`!__pte_offset_map_lock`.540540+541541+Atomicity542542+^^^^^^^^^543543+544544+Regardless of page table locks, the MMU hardware concurrently updates accessed545545+and dirty bits (perhaps more, depending on architecture). Additionally, page546546+table traversal operations in parallel (though holding the VMA stable) and547547+functionality like GUP-fast locklessly traverses (that is reads) page tables,548548+without even keeping the VMA stable at all.549549+550550+When performing a page table traversal and keeping the VMA stable, whether a551551+read must be performed once and only once or not depends on the architecture552552+(for instance x86-64 does not require any special precautions).553553+554554+If a write is being performed, or if a read informs whether a write takes place555555+(on an installation of a page table entry say, for instance in556556+:c:func:`!__pud_install`), special care must always be taken. In these cases we557557+can never assume that page table locks give us entirely exclusive access, and558558+must retrieve page table entries once and only once.559559+560560+If we are reading page table entries, then we need only ensure that the compiler561561+does not rearrange our loads. This is achieved via :c:func:`!pXXp_get`562562+functions - :c:func:`!pgdp_get`, :c:func:`!p4dp_get`, :c:func:`!pudp_get`,563563+:c:func:`!pmdp_get`, and :c:func:`!ptep_get`.564564+565565+Each of these uses :c:func:`!READ_ONCE` to guarantee that the compiler reads566566+the page table entry only once.567567+568568+However, if we wish to manipulate an existing page table entry and care about569569+the previously stored data, we must go further and use an hardware atomic570570+operation as, for example, in :c:func:`!ptep_get_and_clear`.571571+572572+Equally, operations that do not rely on the VMA being held stable, such as573573+GUP-fast (see :c:func:`!gup_fast` and its various page table level handlers like574574+:c:func:`!gup_fast_pte_range`), must very carefully interact with page table575575+entries, using functions such as :c:func:`!ptep_get_lockless` and equivalent for576576+higher level page table levels.577577+578578+Writes to page table entries must also be appropriately atomic, as established579579+by :c:func:`!set_pXX` functions - :c:func:`!set_pgd`, :c:func:`!set_p4d`,580580+:c:func:`!set_pud`, :c:func:`!set_pmd`, and :c:func:`!set_pte`.581581+582582+Equally functions which clear page table entries must be appropriately atomic,583583+as in :c:func:`!pXX_clear` functions - :c:func:`!pgd_clear`,584584+:c:func:`!p4d_clear`, :c:func:`!pud_clear`, :c:func:`!pmd_clear`, and585585+:c:func:`!pte_clear`.586586+587587+Page table installation588588+^^^^^^^^^^^^^^^^^^^^^^^589589+590590+Page table installation is performed with the VMA held stable explicitly by an591591+mmap or VMA lock in read or write mode (see the warning in the locking rules592592+section for details as to why).593593+594594+When allocating a P4D, PUD or PMD and setting the relevant entry in the above595595+PGD, P4D or PUD, the :c:member:`!mm->page_table_lock` must be held. This is596596+acquired in :c:func:`!__p4d_alloc`, :c:func:`!__pud_alloc` and597597+:c:func:`!__pmd_alloc` respectively.598598+599599+.. note:: :c:func:`!__pmd_alloc` actually invokes :c:func:`!pud_lock` and600600+ :c:func:`!pud_lockptr` in turn, however at the time of writing it ultimately601601+ references the :c:member:`!mm->page_table_lock`.602602+603603+Allocating a PTE will either use the :c:member:`!mm->page_table_lock` or, if604604+:c:macro:`!USE_SPLIT_PMD_PTLOCKS` is defined, a lock embedded in the PMD605605+physical page metadata in the form of a :c:struct:`!struct ptdesc`, acquired by606606+:c:func:`!pmd_ptdesc` called from :c:func:`!pmd_lock` and ultimately607607+:c:func:`!__pte_alloc`.608608+609609+Finally, modifying the contents of the PTE requires special treatment, as the610610+PTE page table lock must be acquired whenever we want stable and exclusive611611+access to entries contained within a PTE, especially when we wish to modify612612+them.613613+614614+This is performed via :c:func:`!pte_offset_map_lock` which carefully checks to615615+ensure that the PTE hasn't changed from under us, ultimately invoking616616+:c:func:`!pte_lockptr` to obtain a spin lock at PTE granularity contained within617617+the :c:struct:`!struct ptdesc` associated with the physical PTE page. The lock618618+must be released via :c:func:`!pte_unmap_unlock`.619619+620620+.. note:: There are some variants on this, such as621621+ :c:func:`!pte_offset_map_rw_nolock` when we know we hold the PTE stable but622622+ for brevity we do not explore this. See the comment for623623+ :c:func:`!__pte_offset_map_lock` for more details.624624+625625+When modifying data in ranges we typically only wish to allocate higher page626626+tables as necessary, using these locks to avoid races or overwriting anything,627627+and set/clear data at the PTE level as required (for instance when page faulting628628+or zapping).629629+630630+A typical pattern taken when traversing page table entries to install a new631631+mapping is to optimistically determine whether the page table entry in the table632632+above is empty, if so, only then acquiring the page table lock and checking633633+again to see if it was allocated underneath us.634634+635635+This allows for a traversal with page table locks only being taken when636636+required. An example of this is :c:func:`!__pud_alloc`.637637+638638+At the leaf page table, that is the PTE, we can't entirely rely on this pattern639639+as we have separate PMD and PTE locks and a THP collapse for instance might have640640+eliminated the PMD entry as well as the PTE from under us.641641+642642+This is why :c:func:`!__pte_offset_map_lock` locklessly retrieves the PMD entry643643+for the PTE, carefully checking it is as expected, before acquiring the644644+PTE-specific lock, and then *again* checking that the PMD entry is as expected.645645+646646+If a THP collapse (or similar) were to occur then the lock on both pages would647647+be acquired, so we can ensure this is prevented while the PTE lock is held.648648+649649+Installing entries this way ensures mutual exclusion on write.650650+651651+Page table freeing652652+^^^^^^^^^^^^^^^^^^653653+654654+Tearing down page tables themselves is something that requires significant655655+care. There must be no way that page tables designated for removal can be656656+traversed or referenced by concurrent tasks.657657+658658+It is insufficient to simply hold an mmap write lock and VMA lock (which will659659+prevent racing faults, and rmap operations), as a file-backed mapping can be660660+truncated under the :c:struct:`!struct address_space->i_mmap_rwsem` alone.661661+662662+As a result, no VMA which can be accessed via the reverse mapping (either663663+through the :c:struct:`!struct anon_vma->rb_root` or the :c:member:`!struct664664+address_space->i_mmap` interval trees) can have its page tables torn down.665665+666666+The operation is typically performed via :c:func:`!free_pgtables`, which assumes667667+either the mmap write lock has been taken (as specified by its668668+:c:member:`!mm_wr_locked` parameter), or that the VMA is already unreachable.669669+670670+It carefully removes the VMA from all reverse mappings, however it's important671671+that no new ones overlap these or any route remain to permit access to addresses672672+within the range whose page tables are being torn down.673673+674674+Additionally, it assumes that a zap has already been performed and steps have675675+been taken to ensure that no further page table entries can be installed between676676+the zap and the invocation of :c:func:`!free_pgtables`.677677+678678+Since it is assumed that all such steps have been taken, page table entries are679679+cleared without page table locks (in the :c:func:`!pgd_clear`, :c:func:`!p4d_clear`,680680+:c:func:`!pud_clear`, and :c:func:`!pmd_clear` functions.681681+682682+.. note:: It is possible for leaf page tables to be torn down independent of683683+ the page tables above it as is done by684684+ :c:func:`!retract_page_tables`, which is performed under the i_mmap685685+ read lock, PMD, and PTE page table locks, without this level of care.686686+687687+Page table moving688688+^^^^^^^^^^^^^^^^^689689+690690+Some functions manipulate page table levels above PMD (that is PUD, P4D and PGD691691+page tables). Most notable of these is :c:func:`!mremap`, which is capable of692692+moving higher level page tables.693693+694694+In these instances, it is required that **all** locks are taken, that is695695+the mmap lock, the VMA lock and the relevant rmap locks.696696+697697+You can observe this in the :c:func:`!mremap` implementation in the functions698698+:c:func:`!take_rmap_locks` and :c:func:`!drop_rmap_locks` which perform the rmap699699+side of lock acquisition, invoked ultimately by :c:func:`!move_page_tables`.700700+701701+VMA lock internals702702+------------------703703+704704+Overview705705+^^^^^^^^706706+707707+VMA read locking is entirely optimistic - if the lock is contended or a competing708708+write has started, then we do not obtain a read lock.709709+710710+A VMA **read** lock is obtained by :c:func:`!lock_vma_under_rcu`, which first711711+calls :c:func:`!rcu_read_lock` to ensure that the VMA is looked up in an RCU712712+critical section, then attempts to VMA lock it via :c:func:`!vma_start_read`,713713+before releasing the RCU lock via :c:func:`!rcu_read_unlock`.714714+715715+VMA read locks hold the read lock on the :c:member:`!vma->vm_lock` semaphore for716716+their duration and the caller of :c:func:`!lock_vma_under_rcu` must release it717717+via :c:func:`!vma_end_read`.718718+719719+VMA **write** locks are acquired via :c:func:`!vma_start_write` in instances where a720720+VMA is about to be modified, unlike :c:func:`!vma_start_read` the lock is always721721+acquired. An mmap write lock **must** be held for the duration of the VMA write722722+lock, releasing or downgrading the mmap write lock also releases the VMA write723723+lock so there is no :c:func:`!vma_end_write` function.724724+725725+Note that a semaphore write lock is not held across a VMA lock. Rather, a726726+sequence number is used for serialisation, and the write semaphore is only727727+acquired at the point of write lock to update this.728728+729729+This ensures the semantics we require - VMA write locks provide exclusive write730730+access to the VMA.731731+732732+Implementation details733733+^^^^^^^^^^^^^^^^^^^^^^734734+735735+The VMA lock mechanism is designed to be a lightweight means of avoiding the use736736+of the heavily contended mmap lock. It is implemented using a combination of a737737+read/write semaphore and sequence numbers belonging to the containing738738+:c:struct:`!struct mm_struct` and the VMA.739739+740740+Read locks are acquired via :c:func:`!vma_start_read`, which is an optimistic741741+operation, i.e. it tries to acquire a read lock but returns false if it is742742+unable to do so. At the end of the read operation, :c:func:`!vma_end_read` is743743+called to release the VMA read lock.744744+745745+Invoking :c:func:`!vma_start_read` requires that :c:func:`!rcu_read_lock` has746746+been called first, establishing that we are in an RCU critical section upon VMA747747+read lock acquisition. Once acquired, the RCU lock can be released as it is only748748+required for lookup. This is abstracted by :c:func:`!lock_vma_under_rcu` which749749+is the interface a user should use.750750+751751+Writing requires the mmap to be write-locked and the VMA lock to be acquired via752752+:c:func:`!vma_start_write`, however the write lock is released by the termination or753753+downgrade of the mmap write lock so no :c:func:`!vma_end_write` is required.754754+755755+All this is achieved by the use of per-mm and per-VMA sequence counts, which are756756+used in order to reduce complexity, especially for operations which write-lock757757+multiple VMAs at once.758758+759759+If the mm sequence count, :c:member:`!mm->mm_lock_seq` is equal to the VMA760760+sequence count :c:member:`!vma->vm_lock_seq` then the VMA is write-locked. If761761+they differ, then it is not.762762+763763+Each time the mmap write lock is released in :c:func:`!mmap_write_unlock` or764764+:c:func:`!mmap_write_downgrade`, :c:func:`!vma_end_write_all` is invoked which765765+also increments :c:member:`!mm->mm_lock_seq` via766766+:c:func:`!mm_lock_seqcount_end`.767767+768768+This way, we ensure that, regardless of the VMA's sequence number, a write lock769769+is never incorrectly indicated and that when we release an mmap write lock we770770+efficiently release **all** VMA write locks contained within the mmap at the771771+same time.772772+773773+Since the mmap write lock is exclusive against others who hold it, the automatic774774+release of any VMA locks on its release makes sense, as you would never want to775775+keep VMAs locked across entirely separate write operations. It also maintains776776+correct lock ordering.777777+778778+Each time a VMA read lock is acquired, we acquire a read lock on the779779+:c:member:`!vma->vm_lock` read/write semaphore and hold it, while checking that780780+the sequence count of the VMA does not match that of the mm.781781+782782+If it does, the read lock fails. If it does not, we hold the lock, excluding783783+writers, but permitting other readers, who will also obtain this lock under RCU.784784+785785+Importantly, maple tree operations performed in :c:func:`!lock_vma_under_rcu`786786+are also RCU safe, so the whole read lock operation is guaranteed to function787787+correctly.788788+789789+On the write side, we acquire a write lock on the :c:member:`!vma->vm_lock`790790+read/write semaphore, before setting the VMA's sequence number under this lock,791791+also simultaneously holding the mmap write lock.792792+793793+This way, if any read locks are in effect, :c:func:`!vma_start_write` will sleep794794+until these are finished and mutual exclusion is achieved.795795+796796+After setting the VMA's sequence number, the lock is released, avoiding797797+complexity with a long-term held write lock.798798+799799+This clever combination of a read/write semaphore and sequence count allows for800800+fast RCU-based per-VMA lock acquisition (especially on page fault, though801801+utilised elsewhere) with minimal complexity around lock ordering.802802+803803+mmap write lock downgrading804804+---------------------------805805+806806+When an mmap write lock is held one has exclusive access to resources within the807807+mmap (with the usual caveats about requiring VMA write locks to avoid races with808808+tasks holding VMA read locks).809809+810810+It is then possible to **downgrade** from a write lock to a read lock via811811+:c:func:`!mmap_write_downgrade` which, similar to :c:func:`!mmap_write_unlock`,812812+implicitly terminates all VMA write locks via :c:func:`!vma_end_write_all`, but813813+importantly does not relinquish the mmap lock while downgrading, therefore814814+keeping the locked virtual address space stable.815815+816816+An interesting consequence of this is that downgraded locks are exclusive817817+against any other task possessing a downgraded lock (since a racing task would818818+have to acquire a write lock first to downgrade it, and the downgraded lock819819+prevents a new write lock from being obtained until the original lock is820820+released).821821+822822+For clarity, we map read (R)/downgraded write (D)/write (W) locks against one823823+another showing which locks exclude the others:824824+825825+.. list-table:: Lock exclusivity826826+ :widths: 5 5 5 5827827+ :header-rows: 1828828+ :stub-columns: 1829829+830830+ * -831831+ - R832832+ - D833833+ - W834834+ * - R835835+ - N836836+ - N837837+ - Y838838+ * - D839839+ - N840840+ - Y841841+ - Y842842+ * - W843843+ - Y844844+ - Y845845+ - Y846846+847847+Here a Y indicates the locks in the matching row/column are mutually exclusive,848848+and N indicates that they are not.849849+850850+Stack expansion851851+---------------852852+853853+Stack expansion throws up additional complexities in that we cannot permit there854854+to be racing page faults, as a result we invoke :c:func:`!vma_start_write` to855855+prevent this in :c:func:`!expand_downwards` or :c:func:`!expand_upwards`.
+3-3
MAINTAINERS
···73477347DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS73487348M: Karol Herbst <kherbst@redhat.com>73497349M: Lyude Paul <lyude@redhat.com>73507350-M: Danilo Krummrich <dakr@redhat.com>73507350+M: Danilo Krummrich <dakr@kernel.org>73517351L: dri-devel@lists.freedesktop.org73527352L: nouveau@lists.freedesktop.org73537353S: Supported···84538453EROFS FILE SYSTEM84548454M: Gao Xiang <xiang@kernel.org>84558455M: Chao Yu <chao@kernel.org>84568456-R: Yue Hu <huyue2@coolpad.com>84568456+R: Yue Hu <zbestahu@gmail.com>84578457R: Jeffle Xu <jefflexu@linux.alibaba.com>84588458R: Sandeep Dhavale <dhavale@google.com>84598459L: linux-erofs@lists.ozlabs.org···89248924FIRMWARE LOADER (request_firmware)89258925M: Luis Chamberlain <mcgrof@kernel.org>89268926M: Russ Weight <russ.weight@linux.dev>89278927-M: Danilo Krummrich <dakr@redhat.com>89278927+M: Danilo Krummrich <dakr@kernel.org>89288928L: linux-kernel@vger.kernel.org89298929S: Maintained89308930F: Documentation/firmware_class/
···3636#include <asm/traps.h>3737#include <asm/vdso.h>38383939-#ifdef CONFIG_ARM64_GCS4039#define GCS_SIGNAL_CAP(addr) (((unsigned long)addr) & GCS_CAP_ADDR_MASK)4141-4242-static bool gcs_signal_cap_valid(u64 addr, u64 val)4343-{4444- return val == GCS_SIGNAL_CAP(addr);4545-}4646-#endif47404841/*4942 * Do a signal return; undo the signal stack. These are aligned to 128-bit.···10551062#ifdef CONFIG_ARM64_GCS10561063static int gcs_restore_signal(void)10571064{10581058- unsigned long __user *gcspr_el0;10591059- u64 cap;10651065+ u64 gcspr_el0, cap;10601066 int ret;1061106710621068 if (!system_supports_gcs())···10641072 if (!(current->thread.gcs_el0_mode & PR_SHADOW_STACK_ENABLE))10651073 return 0;1066107410671067- gcspr_el0 = (unsigned long __user *)read_sysreg_s(SYS_GCSPR_EL0);10751075+ gcspr_el0 = read_sysreg_s(SYS_GCSPR_EL0);1068107610691077 /*10701078 * Ensure that any changes to the GCS done via GCS operations···10791087 * then faults will be generated on GCS operations - the main10801088 * concern is to protect GCS pages.10811089 */10821082- ret = copy_from_user(&cap, gcspr_el0, sizeof(cap));10901090+ ret = copy_from_user(&cap, (unsigned long __user *)gcspr_el0,10911091+ sizeof(cap));10831092 if (ret)10841093 return -EFAULT;1085109410861095 /*10871096 * Check that the cap is the actual GCS before replacing it.10881097 */10891089- if (!gcs_signal_cap_valid((u64)gcspr_el0, cap))10981098+ if (cap != GCS_SIGNAL_CAP(gcspr_el0))10901099 return -EINVAL;1091110010921101 /* Invalidate the token to prevent reuse */10931093- put_user_gcs(0, (__user void*)gcspr_el0, &ret);11021102+ put_user_gcs(0, (unsigned long __user *)gcspr_el0, &ret);10941103 if (ret != 0)10951104 return -EFAULT;1096110510971097- write_sysreg_s(gcspr_el0 + 1, SYS_GCSPR_EL0);11061106+ write_sysreg_s(gcspr_el0 + 8, SYS_GCSPR_EL0);1098110710991108 return 0;11001109}···1414142114151422static int gcs_signal_entry(__sigrestore_t sigtramp, struct ksignal *ksig)14161423{14171417- unsigned long __user *gcspr_el0;14241424+ u64 gcspr_el0;14181425 int ret = 0;1419142614201427 if (!system_supports_gcs())···14271434 * We are entering a signal handler, current register state is14281435 * active.14291436 */14301430- gcspr_el0 = (unsigned long __user *)read_sysreg_s(SYS_GCSPR_EL0);14371437+ gcspr_el0 = read_sysreg_s(SYS_GCSPR_EL0);1431143814321439 /*14331440 * Push a cap and the GCS entry for the trampoline onto the GCS.14341441 */14351435- put_user_gcs((unsigned long)sigtramp, gcspr_el0 - 2, &ret);14361436- put_user_gcs(GCS_SIGNAL_CAP(gcspr_el0 - 1), gcspr_el0 - 1, &ret);14421442+ put_user_gcs((unsigned long)sigtramp,14431443+ (unsigned long __user *)(gcspr_el0 - 16), &ret);14441444+ put_user_gcs(GCS_SIGNAL_CAP(gcspr_el0 - 8),14451445+ (unsigned long __user *)(gcspr_el0 - 8), &ret);14371446 if (ret != 0)14381447 return ret;1439144814401440- gcspr_el0 -= 2;14411441- write_sysreg_s((unsigned long)gcspr_el0, SYS_GCSPR_EL0);14491449+ gcspr_el0 -= 16;14501450+ write_sysreg_s(gcspr_el0, SYS_GCSPR_EL0);1442145114431452 return 0;14441453}
···208208CONFIG_FB_ATY_CT=y209209CONFIG_FB_ATY_GX=y210210CONFIG_FB_3DFX=y211211+CONFIG_BACKLIGHT_CLASS_DEVICE=y211212# CONFIG_VGA_CONSOLE is not set212213CONFIG_FRAMEBUFFER_CONSOLE=y213214CONFIG_LOGO=y
···88#include <asm/special_insns.h>991010#ifdef CONFIG_X86_321111-static inline void iret_to_self(void)1111+static __always_inline void iret_to_self(void)1212{1313 asm volatile (1414 "pushfl\n\t"···1919 : ASM_CALL_CONSTRAINT : : "memory");2020}2121#else2222-static inline void iret_to_self(void)2222+static __always_inline void iret_to_self(void)2323{2424 unsigned int tmp;2525···5555 * Like all of Linux's memory ordering operations, this is a5656 * compiler barrier as well.5757 */5858-static inline void sync_core(void)5858+static __always_inline void sync_core(void)5959{6060 /*6161 * The SERIALIZE instruction is the most straightforward way to
···143143 dest < (void*)relocate_kernel + KEXEC_CONTROL_CODE_MAX_SIZE)144144 return true;145145#endif146146-#ifdef CONFIG_XEN147147- if (dest >= (void *)hypercall_page &&148148- dest < (void*)hypercall_page + PAGE_SIZE)149149- return true;150150-#endif151146 return false;152147}153148
+22-16
arch/x86/kernel/cpu/common.c
···867867 tlb_lld_4m[ENTRIES], tlb_lld_1g[ENTRIES]);868868}869869870870-static void get_cpu_vendor(struct cpuinfo_x86 *c)870870+void get_cpu_vendor(struct cpuinfo_x86 *c)871871{872872 char *v = c->x86_vendor_id;873873 int i;···16491649 detect_nopl();16501650}1651165116521652-void __init early_cpu_init(void)16521652+void __init init_cpu_devs(void)16531653{16541654 const struct cpu_dev *const *cdev;16551655 int count = 0;16561656-16571657-#ifdef CONFIG_PROCESSOR_SELECT16581658- pr_info("KERNEL supported cpus:\n");16591659-#endif1660165616611657 for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {16621658 const struct cpu_dev *cpudev = *cdev;···16611665 break;16621666 cpu_devs[count] = cpudev;16631667 count++;16681668+ }16691669+}16701670+16711671+void __init early_cpu_init(void)16721672+{16731673+#ifdef CONFIG_PROCESSOR_SELECT16741674+ unsigned int i, j;16751675+16761676+ pr_info("KERNEL supported cpus:\n");16771677+#endif16781678+16791679+ init_cpu_devs();1664168016651681#ifdef CONFIG_PROCESSOR_SELECT16661666- {16671667- unsigned int j;16681668-16691669- for (j = 0; j < 2; j++) {16701670- if (!cpudev->c_ident[j])16711671- continue;16721672- pr_info(" %s %s\n", cpudev->c_vendor,16731673- cpudev->c_ident[j]);16741674- }16821682+ for (i = 0; i < X86_VENDOR_NUM && cpu_devs[i]; i++) {16831683+ for (j = 0; j < 2; j++) {16841684+ if (!cpu_devs[i]->c_ident[j])16851685+ continue;16861686+ pr_info(" %s %s\n", cpu_devs[i]->c_vendor,16871687+ cpu_devs[i]->c_ident[j]);16751688 }16761676-#endif16771689 }16901690+#endif16911691+16781692 early_identify_cpu(&boot_cpu_data);16791693}16801694
+58
arch/x86/kernel/cpu/mshyperv.c
···223223 hyperv_cleanup();224224}225225#endif /* CONFIG_CRASH_DUMP */226226+227227+static u64 hv_ref_counter_at_suspend;228228+static void (*old_save_sched_clock_state)(void);229229+static void (*old_restore_sched_clock_state)(void);230230+231231+/*232232+ * Hyper-V clock counter resets during hibernation. Save and restore clock233233+ * offset during suspend/resume, while also considering the time passed234234+ * before suspend. This is to make sure that sched_clock using hv tsc page235235+ * based clocksource, proceeds from where it left off during suspend and236236+ * it shows correct time for the timestamps of kernel messages after resume.237237+ */238238+static void save_hv_clock_tsc_state(void)239239+{240240+ hv_ref_counter_at_suspend = hv_read_reference_counter();241241+}242242+243243+static void restore_hv_clock_tsc_state(void)244244+{245245+ /*246246+ * Adjust the offsets used by hv tsc clocksource to247247+ * account for the time spent before hibernation.248248+ * adjusted value = reference counter (time) at suspend249249+ * - reference counter (time) now.250250+ */251251+ hv_adj_sched_clock_offset(hv_ref_counter_at_suspend - hv_read_reference_counter());252252+}253253+254254+/*255255+ * Functions to override save_sched_clock_state and restore_sched_clock_state256256+ * functions of x86_platform. The Hyper-V clock counter is reset during257257+ * suspend-resume and the offset used to measure time needs to be258258+ * corrected, post resume.259259+ */260260+static void hv_save_sched_clock_state(void)261261+{262262+ old_save_sched_clock_state();263263+ save_hv_clock_tsc_state();264264+}265265+266266+static void hv_restore_sched_clock_state(void)267267+{268268+ restore_hv_clock_tsc_state();269269+ old_restore_sched_clock_state();270270+}271271+272272+static void __init x86_setup_ops_for_tsc_pg_clock(void)273273+{274274+ if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))275275+ return;276276+277277+ old_save_sched_clock_state = x86_platform.save_sched_clock_state;278278+ x86_platform.save_sched_clock_state = hv_save_sched_clock_state;279279+280280+ old_restore_sched_clock_state = x86_platform.restore_sched_clock_state;281281+ x86_platform.restore_sched_clock_state = hv_restore_sched_clock_state;282282+}226283#endif /* CONFIG_HYPERV */227284228285static uint32_t __init ms_hyperv_platform(void)···636579637580 /* Register Hyper-V specific clocksource */638581 hv_init_clocksource();582582+ x86_setup_ops_for_tsc_pg_clock();639583 hv_vtl_init_platform();640584#endif641585 /*
+9
arch/x86/kernel/static_call.c
···172172}173173EXPORT_SYMBOL_GPL(arch_static_call_transform);174174175175+noinstr void __static_call_update_early(void *tramp, void *func)176176+{177177+ BUG_ON(system_state != SYSTEM_BOOTING);178178+ BUG_ON(!early_boot_irqs_disabled);179179+ BUG_ON(static_call_initialized);180180+ __text_gen_insn(tramp, JMP32_INSN_OPCODE, tramp, func, JMP32_INSN_SIZE);181181+ sync_core();182182+}183183+175184#ifdef CONFIG_MITIGATION_RETHUNK176185/*177186 * This is called by apply_returns() to fix up static call trampolines,
-4
arch/x86/kernel/vmlinux.lds.S
···519519 * linker will never mark as relocatable. (Using just ABSOLUTE() is not520520 * sufficient for that).521521 */522522-#ifdef CONFIG_XEN523522#ifdef CONFIG_XEN_PV524523xen_elfnote_entry_value =525524 ABSOLUTE(xen_elfnote_entry) + ABSOLUTE(startup_xen);526526-#endif527527-xen_elfnote_hypercall_page_value =528528- ABSOLUTE(xen_elfnote_hypercall_page) + ABSOLUTE(hypercall_page);529525#endif530526#ifdef CONFIG_PVH531527xen_elfnote_phys32_entry_value =
-12
arch/x86/kvm/mmu/mmu.c
···33643364 return true;33653365}3366336633673367-static bool is_access_allowed(struct kvm_page_fault *fault, u64 spte)33683368-{33693369- if (fault->exec)33703370- return is_executable_pte(spte);33713371-33723372- if (fault->write)33733373- return is_writable_pte(spte);33743374-33753375- /* Fault was on Read access */33763376- return spte & PT_PRESENT_MASK;33773377-}33783378-33793367/*33803368 * Returns the last level spte pointer of the shadow page walk for the given33813369 * gpa, and sets *spte to the spte value. This spte may be non-preset. If no
+17
arch/x86/kvm/mmu/spte.h
···462462}463463464464/*465465+ * Returns true if the access indicated by @fault is allowed by the existing466466+ * SPTE protections. Note, the caller is responsible for checking that the467467+ * SPTE is a shadow-present, leaf SPTE (either before or after).468468+ */469469+static inline bool is_access_allowed(struct kvm_page_fault *fault, u64 spte)470470+{471471+ if (fault->exec)472472+ return is_executable_pte(spte);473473+474474+ if (fault->write)475475+ return is_writable_pte(spte);476476+477477+ /* Fault was on Read access */478478+ return spte & PT_PRESENT_MASK;479479+}480480+481481+/*465482 * If the MMU-writable flag is cleared, i.e. the SPTE is write-protected for466483 * write-tracking, remote TLBs must be flushed, even if the SPTE was read-only,467484 * as KVM allows stale Writable TLB entries to exist. When dirty logging, KVM
+5
arch/x86/kvm/mmu/tdp_mmu.c
···985985 if (fault->prefetch && is_shadow_present_pte(iter->old_spte))986986 return RET_PF_SPURIOUS;987987988988+ if (is_shadow_present_pte(iter->old_spte) &&989989+ is_access_allowed(fault, iter->old_spte) &&990990+ is_last_spte(iter->old_spte, iter->level))991991+ return RET_PF_SPURIOUS;992992+988993 if (unlikely(!fault->slot))989994 new_spte = make_mmio_spte(vcpu, iter->gfn, ACC_ALL);990995 else
+6
arch/x86/kvm/svm/avic.c
···11991199 return false;12001200 }1201120112021202+ if (cc_platform_has(CC_ATTR_HOST_SEV_SNP) &&12031203+ !boot_cpu_has(X86_FEATURE_HV_INUSE_WR_ALLOWED)) {12041204+ pr_warn("AVIC disabled: missing HvInUseWrAllowed on SNP-enabled system\n");12051205+ return false;12061206+ }12071207+12021208 if (boot_cpu_has(X86_FEATURE_AVIC)) {12031209 pr_info("AVIC enabled\n");12041210 } else if (force_avic) {
-9
arch/x86/kvm/svm/svm.c
···32013201 if (data & ~supported_de_cfg)32023202 return 1;3203320332043204- /*32053205- * Don't let the guest change the host-programmed value. The32063206- * MSR is very model specific, i.e. contains multiple bits that32073207- * are completely unknown to KVM, and the one bit known to KVM32083208- * is simply a reflection of hardware capabilities.32093209- */32103210- if (!msr->host_initiated && data != svm->msr_decfg)32113211- return 1;32123212-32133204 svm->msr_decfg = data;32143205 break;32153206 }
···99769976{99779977 u64 ret = vcpu->run->hypercall.ret;9978997899799979- if (!is_64_bit_mode(vcpu))99799979+ if (!is_64_bit_hypercall(vcpu))99809980 ret = (u32)ret;99819981 kvm_rax_write(vcpu, ret);99829982 ++vcpu->stat.hypercalls;···1272312723 kvm_apicv_init(kvm);1272412724 kvm_hv_init_vm(kvm);1272512725 kvm_xen_init_vm(kvm);1272612726+1272712727+ if (ignore_msrs && !report_ignored_msrs) {1272812728+ pr_warn_once("Running KVM with ignore_msrs=1 and report_ignored_msrs=0 is not a\n"1272912729+ "a supported configuration. Lying to the guest about the existence of MSRs\n"1273012730+ "may cause the guest operating system to hang or produce errors. If a guest\n"1273112731+ "does not run without ignore_msrs=1, please report it to kvm@vger.kernel.org.\n");1273212732+ }12726127331272712734 return 0;1272812735
+64-1
arch/x86/xen/enlighten.c
···2233#include <linux/console.h>44#include <linux/cpu.h>55+#include <linux/instrumentation.h>56#include <linux/kexec.h>67#include <linux/memblock.h>78#include <linux/slab.h>···22212322#include "xen-ops.h"24232525-EXPORT_SYMBOL_GPL(hypercall_page);2424+DEFINE_STATIC_CALL(xen_hypercall, xen_hypercall_hvm);2525+EXPORT_STATIC_CALL_TRAMP(xen_hypercall);26262727/*2828 * Pointer to the xen_vcpu_info structure or···6967 * page as soon as fixmap is up and running.7068 */7169struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info;7070+7171+static __ref void xen_get_vendor(void)7272+{7373+ init_cpu_devs();7474+ cpu_detect(&boot_cpu_data);7575+ get_cpu_vendor(&boot_cpu_data);7676+}7777+7878+void xen_hypercall_setfunc(void)7979+{8080+ if (static_call_query(xen_hypercall) != xen_hypercall_hvm)8181+ return;8282+8383+ if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||8484+ boot_cpu_data.x86_vendor == X86_VENDOR_HYGON))8585+ static_call_update(xen_hypercall, xen_hypercall_amd);8686+ else8787+ static_call_update(xen_hypercall, xen_hypercall_intel);8888+}8989+9090+/*9191+ * Evaluate processor vendor in order to select the correct hypercall9292+ * function for HVM/PVH guests.9393+ * Might be called very early in boot before vendor has been set by9494+ * early_cpu_init().9595+ */9696+noinstr void *__xen_hypercall_setfunc(void)9797+{9898+ void (*func)(void);9999+100100+ /*101101+ * Xen is supported only on CPUs with CPUID, so testing for102102+ * X86_FEATURE_CPUID is a test for early_cpu_init() having been103103+ * run.104104+ *105105+ * Note that __xen_hypercall_setfunc() is noinstr only due to a nasty106106+ * dependency chain: it is being called via the xen_hypercall static107107+ * call when running as a PVH or HVM guest. Hypercalls need to be108108+ * noinstr due to PV guests using hypercalls in noinstr code. So we109109+ * can safely tag the function body as "instrumentation ok", since110110+ * the PV guest requirement is not of interest here (xen_get_vendor()111111+ * calls noinstr functions, and static_call_update_early() might do112112+ * so, too).113113+ */114114+ instrumentation_begin();115115+116116+ if (!boot_cpu_has(X86_FEATURE_CPUID))117117+ xen_get_vendor();118118+119119+ if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||120120+ boot_cpu_data.x86_vendor == X86_VENDOR_HYGON))121121+ func = xen_hypercall_amd;122122+ else123123+ func = xen_hypercall_intel;124124+125125+ static_call_update_early(xen_hypercall, func);126126+127127+ instrumentation_end();128128+129129+ return func;130130+}7213173132static int xen_cpu_up_online(unsigned int cpu)74133{
+5-8
arch/x86/xen/enlighten_hvm.c
···106106 /* PVH set up hypercall page in xen_prepare_pvh(). */107107 if (xen_pvh_domain())108108 pv_info.name = "Xen PVH";109109- else {110110- u64 pfn;111111- uint32_t msr;112112-109109+ else113110 pv_info.name = "Xen HVM";114114- msr = cpuid_ebx(base + 2);115115- pfn = __pa(hypercall_page);116116- wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));117117- }118111119112 xen_setup_features();120113···292299293300 if (xen_pv_domain())294301 return 0;302302+303303+ /* Set correct hypercall function. */304304+ if (xen_domain)305305+ xen_hypercall_setfunc();295306296307 if (xen_pvh_domain() && nopv) {297308 /* Guest booting via the Xen-PVH boot entry goes here */
+3-1
arch/x86/xen/enlighten_pv.c
···1341134113421342 xen_domain_type = XEN_PV_DOMAIN;13431343 xen_start_flags = xen_start_info->flags;13441344+ /* Interrupts are guaranteed to be off initially. */13451345+ early_boot_irqs_disabled = true;13461346+ static_call_update_early(xen_hypercall, xen_hypercall_pv);1344134713451348 xen_setup_features();13461349···14341431 WARN_ON(xen_cpuhp_setup(xen_cpu_up_prepare_pv, xen_cpu_dead_pv));1435143214361433 local_irq_disable();14371437- early_boot_irqs_disabled = true;1438143414391435 xen_raw_console_write("mapping kernel into physical memory\n");14401436 xen_setup_kernel_pagetable((pgd_t *)xen_start_info->pt_base,
···155155 struct inode *inode = file->f_mapping->host;156156 struct block_device *bdev = I_BDEV(inode);157157158158- /* Size must be a power of two, and between 512 and PAGE_SIZE */159159- if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size))158158+ if (blk_validate_block_size(size))160159 return -EINVAL;161160162161 /* Size cannot be smaller than the size supported by the device */
+10-6
block/blk-mq-sysfs.c
···275275 struct blk_mq_hw_ctx *hctx;276276 unsigned long i;277277278278- lockdep_assert_held(&q->sysfs_dir_lock);279279-278278+ mutex_lock(&q->sysfs_dir_lock);280279 if (!q->mq_sysfs_init_done)281281- return;280280+ goto unlock;282281283282 queue_for_each_hw_ctx(q, hctx, i)284283 blk_mq_unregister_hctx(hctx);284284+285285+unlock:286286+ mutex_unlock(&q->sysfs_dir_lock);285287}286288287289int blk_mq_sysfs_register_hctxs(struct request_queue *q)···292290 unsigned long i;293291 int ret = 0;294292295295- lockdep_assert_held(&q->sysfs_dir_lock);296296-293293+ mutex_lock(&q->sysfs_dir_lock);297294 if (!q->mq_sysfs_init_done)298298- return ret;295295+ goto unlock;299296300297 queue_for_each_hw_ctx(q, hctx, i) {301298 ret = blk_mq_register_hctx(hctx);302299 if (ret)303300 break;304301 }302302+303303+unlock:304304+ mutex_unlock(&q->sysfs_dir_lock);305305306306 return ret;307307}
+21-19
block/blk-mq.c
···44124412}44134413EXPORT_SYMBOL(blk_mq_alloc_disk_for_queue);4414441444154415+/*44164416+ * Only hctx removed from cpuhp list can be reused44174417+ */44184418+static bool blk_mq_hctx_is_reusable(struct blk_mq_hw_ctx *hctx)44194419+{44204420+ return hlist_unhashed(&hctx->cpuhp_online) &&44214421+ hlist_unhashed(&hctx->cpuhp_dead);44224422+}44234423+44154424static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(44164425 struct blk_mq_tag_set *set, struct request_queue *q,44174426 int hctx_idx, int node)···44304421 /* reuse dead hctx first */44314422 spin_lock(&q->unused_hctx_lock);44324423 list_for_each_entry(tmp, &q->unused_hctx_list, hctx_list) {44334433- if (tmp->numa_node == node) {44244424+ if (tmp->numa_node == node && blk_mq_hctx_is_reusable(tmp)) {44344425 hctx = tmp;44354426 break;44364427 }···44624453 unsigned long i, j;4463445444644455 /* protect against switching io scheduler */44654465- lockdep_assert_held(&q->sysfs_lock);44664466-44564456+ mutex_lock(&q->sysfs_lock);44674457 for (i = 0; i < set->nr_hw_queues; i++) {44684458 int old_node;44694459 int node = blk_mq_get_hctx_node(set, i);···4495448744964488 xa_for_each_start(&q->hctx_table, j, hctx, j)44974489 blk_mq_exit_hctx(q, set, hctx, j);44904490+ mutex_unlock(&q->sysfs_lock);4498449144994492 /* unregister cpuhp callbacks for exited hctxs */45004493 blk_mq_remove_hw_queues_cpuhp(q);···4527451845284519 xa_init(&q->hctx_table);4529452045304530- mutex_lock(&q->sysfs_lock);45314531-45324521 blk_mq_realloc_hw_ctxs(set, q);45334522 if (!q->nr_hw_queues)45344523 goto err_hctxs;45354535-45364536- mutex_unlock(&q->sysfs_lock);4537452445384525 INIT_WORK(&q->timeout_work, blk_mq_timeout_work);45394526 blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30 * HZ);···45494544 return 0;4550454545514546err_hctxs:45524552- mutex_unlock(&q->sysfs_lock);45534547 blk_mq_release(q);45544548err_exit:45554549 q->mq_ops = NULL;···49294925 return false;4930492649314927 /* q->elevator needs protection from ->sysfs_lock */49324932- lockdep_assert_held(&q->sysfs_lock);49284928+ mutex_lock(&q->sysfs_lock);4933492949344930 /* the check has to be done with holding sysfs_lock */49354931 if (!q->elevator) {49364932 kfree(qe);49374937- goto out;49334933+ goto unlock;49384934 }4939493549404936 INIT_LIST_HEAD(&qe->node);···49444940 __elevator_get(qe->type);49454941 list_add(&qe->node, head);49464942 elevator_disable(q);49474947-out:49434943+unlock:49444944+ mutex_unlock(&q->sysfs_lock);49454945+49484946 return true;49494947}49504948···49754969 list_del(&qe->node);49764970 kfree(qe);4977497149724972+ mutex_lock(&q->sysfs_lock);49784973 elevator_switch(q, t);49794974 /* drop the reference acquired in blk_mq_elv_switch_none */49804975 elevator_put(t);49764976+ mutex_unlock(&q->sysfs_lock);49814977}4982497849834979static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,···49994991 if (set->nr_maps == 1 && nr_hw_queues == set->nr_hw_queues)50004992 return;5001499350025002- list_for_each_entry(q, &set->tag_list, tag_set_list) {50035003- mutex_lock(&q->sysfs_dir_lock);50045004- mutex_lock(&q->sysfs_lock);49944994+ list_for_each_entry(q, &set->tag_list, tag_set_list)50054995 blk_mq_freeze_queue(q);50065006- }50074996 /*50084997 * Switch IO scheduler to 'none', cleaning up the data associated50094998 * with the previous scheduler. We will switch back once we are done···50565051 list_for_each_entry(q, &set->tag_list, tag_set_list)50575052 blk_mq_elv_switch_back(&head, q);5058505350595059- list_for_each_entry(q, &set->tag_list, tag_set_list) {50545054+ list_for_each_entry(q, &set->tag_list, tag_set_list)50605055 blk_mq_unfreeze_queue(q);50615061- mutex_unlock(&q->sysfs_lock);50625062- mutex_unlock(&q->sysfs_dir_lock);50635063- }5064505650655057 /* Free the excess tags when nr_hw_queues shrink. */50665058 for (i = set->nr_hw_queues; i < prev_nr_hw_queues; i++)
+2-2
block/blk-sysfs.c
···706706 if (entry->load_module)707707 entry->load_module(disk, page, length);708708709709- mutex_lock(&q->sysfs_lock);710709 blk_mq_freeze_queue(q);710710+ mutex_lock(&q->sysfs_lock);711711 res = entry->store(disk, page, length);712712- blk_mq_unfreeze_queue(q);713712 mutex_unlock(&q->sysfs_lock);713713+ blk_mq_unfreeze_queue(q);714714 return res;715715}716716
···135135config ACPI_EC136136 bool "Embedded Controller"137137 depends on HAS_IOPORT138138- default X86138138+ default X86 || LOONGARCH139139 help140140 This driver handles communication with the microcontroller141141- on many x86 laptops and other machines.141141+ on many x86/LoongArch laptops and other machines.142142143143config ACPI_EC_DEBUGFS144144 tristate "EC read/write access through /sys/kernel/debug/ec"
+1-1
drivers/auxdisplay/Kconfig
···489489490490config HT16K33491491 tristate "Holtek Ht16K33 LED controller with keyscan"492492- depends on FB && I2C && INPUT492492+ depends on FB && I2C && INPUT && BACKLIGHT_CLASS_DEVICE493493 select FB_SYSMEM_HELPERS494494 select INPUT_MATRIXKMAP495495 select FB_BACKLIGHT
+10-5
drivers/block/zram/zram_drv.c
···614614 }615615616616 nr_pages = i_size_read(inode) >> PAGE_SHIFT;617617+ /* Refuse to use zero sized device (also prevents self reference) */618618+ if (!nr_pages) {619619+ err = -EINVAL;620620+ goto out;621621+ }622622+617623 bitmap_sz = BITS_TO_LONGS(nr_pages) * sizeof(long);618624 bitmap = kvzalloc(bitmap_sz, GFP_KERNEL);619625 if (!bitmap) {···14441438 size_t num_pages = disksize >> PAGE_SHIFT;14451439 size_t index;1446144014411441+ if (!zram->table)14421442+ return;14431443+14471444 /* Free all pages that are still in this zram device */14481445 for (index = 0; index < num_pages; index++)14491446 zram_free_page(zram, index);1450144714511448 zs_destroy_pool(zram->mem_pool);14521449 vfree(zram->table);14501450+ zram->table = NULL;14531451}1454145214551453static bool zram_meta_alloc(struct zram *zram, u64 disksize)···23292319 down_write(&zram->init_lock);2330232023312321 zram->limit_pages = 0;23322332-23332333- if (!init_done(zram)) {23342334- up_write(&zram->init_lock);23352335- return;23362336- }2337232223382323 set_capacity_and_notify(zram->disk, 0);23392324 part_stat_set_all(zram->disk->part0, 0);
+13-1
drivers/clocksource/hyperv_timer.c
···2727#include <asm/mshyperv.h>28282929static struct clock_event_device __percpu *hv_clock_event;3030-static u64 hv_sched_clock_offset __ro_after_init;3030+/* Note: offset can hold negative values after hibernation. */3131+static u64 hv_sched_clock_offset __read_mostly;31323233/*3334 * If false, we're using the old mechanism for stimer0 interrupts···469468 tsc_msr.enable = 1;470469 tsc_msr.pfn = tsc_pfn;471470 hv_set_msr(HV_MSR_REFERENCE_TSC, tsc_msr.as_uint64);471471+}472472+473473+/*474474+ * Called during resume from hibernation, from overridden475475+ * x86_platform.restore_sched_clock_state routine. This is to adjust offsets476476+ * used to calculate time for hv tsc page based sched_clock, to account for477477+ * time spent before hibernation.478478+ */479479+void hv_adj_sched_clock_offset(u64 offset)480480+{481481+ hv_sched_clock_offset -= offset;472482}473483474484#ifdef HAVE_VDSO_CLOCKMODE_HVCLOCK
+26-24
drivers/cpufreq/amd-pstate.c
···374374375375static int msr_init_perf(struct amd_cpudata *cpudata)376376{377377- u64 cap1;377377+ u64 cap1, numerator;378378379379 int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1,380380 &cap1);381381 if (ret)382382 return ret;383383384384- WRITE_ONCE(cpudata->highest_perf, AMD_CPPC_HIGHEST_PERF(cap1));385385- WRITE_ONCE(cpudata->max_limit_perf, AMD_CPPC_HIGHEST_PERF(cap1));384384+ ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);385385+ if (ret)386386+ return ret;387387+388388+ WRITE_ONCE(cpudata->highest_perf, numerator);389389+ WRITE_ONCE(cpudata->max_limit_perf, numerator);386390 WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1));387391 WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1));388392 WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1));···398394static int shmem_init_perf(struct amd_cpudata *cpudata)399395{400396 struct cppc_perf_caps cppc_perf;397397+ u64 numerator;401398402399 int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);403400 if (ret)404401 return ret;405402406406- WRITE_ONCE(cpudata->highest_perf, cppc_perf.highest_perf);407407- WRITE_ONCE(cpudata->max_limit_perf, cppc_perf.highest_perf);403403+ ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);404404+ if (ret)405405+ return ret;406406+407407+ WRITE_ONCE(cpudata->highest_perf, numerator);408408+ WRITE_ONCE(cpudata->max_limit_perf, numerator);408409 WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf);409410 WRITE_ONCE(cpudata->lowest_nonlinear_perf,410411 cppc_perf.lowest_nonlinear_perf);···570561571562static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)572563{573573- u32 max_limit_perf, min_limit_perf, lowest_perf, max_perf;564564+ u32 max_limit_perf, min_limit_perf, lowest_perf, max_perf, max_freq;574565 struct amd_cpudata *cpudata = policy->driver_data;575566576576- if (cpudata->boost_supported && !policy->boost_enabled)577577- max_perf = READ_ONCE(cpudata->nominal_perf);578578- else579579- max_perf = READ_ONCE(cpudata->highest_perf);580580-581581- max_limit_perf = div_u64(policy->max * max_perf, policy->cpuinfo.max_freq);582582- min_limit_perf = div_u64(policy->min * max_perf, policy->cpuinfo.max_freq);567567+ max_perf = READ_ONCE(cpudata->highest_perf);568568+ max_freq = READ_ONCE(cpudata->max_freq);569569+ max_limit_perf = div_u64(policy->max * max_perf, max_freq);570570+ min_limit_perf = div_u64(policy->min * max_perf, max_freq);583571584572 lowest_perf = READ_ONCE(cpudata->lowest_perf);585573 if (min_limit_perf < lowest_perf)···895889{896890 int ret;897891 u32 min_freq, max_freq;898898- u64 numerator;899892 u32 nominal_perf, nominal_freq;900893 u32 lowest_nonlinear_perf, lowest_nonlinear_freq;901894 u32 boost_ratio, lowest_nonlinear_ratio;···916911917912 nominal_perf = READ_ONCE(cpudata->nominal_perf);918913919919- ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);920920- if (ret)921921- return ret;922922- boost_ratio = div_u64(numerator << SCHED_CAPACITY_SHIFT, nominal_perf);914914+ boost_ratio = div_u64(cpudata->highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf);923915 max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT) * 1000;924916925917 lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);···18711869 static_call_update(amd_pstate_update_perf, shmem_update_perf);18721870 }1873187118741874- ret = amd_pstate_register_driver(cppc_state);18751875- if (ret) {18761876- pr_err("failed to register with return %d\n", ret);18771877- return ret;18781878- }18791879-18801872 if (amd_pstate_prefcore) {18811873 ret = amd_detect_prefcore(&amd_pstate_prefcore);18821874 if (ret)18831875 return ret;18761876+ }18771877+18781878+ ret = amd_pstate_register_driver(cppc_state);18791879+ if (ret) {18801880+ pr_err("failed to register with return %d\n", ret);18811881+ return ret;18841882 }1885188318861884 dev_root = bus_get_dev_root(&cpu_subsys);
+18-7
drivers/cxl/core/region.c
···12951295 struct cxl_region_params *p = &cxlr->params;12961296 struct cxl_decoder *cxld = cxl_rr->decoder;12971297 struct cxl_switch_decoder *cxlsd;12981298+ struct cxl_port *iter = port;12981299 u16 eig, peig;12991300 u8 eiw, peiw;13001301···1312131113131312 cxlsd = to_cxl_switch_decoder(&cxld->dev);13141313 if (cxl_rr->nr_targets_set) {13151315- int i, distance;13141314+ int i, distance = 1;13151315+ struct cxl_region_ref *cxl_rr_iter;1316131613171317 /*13181318- * Passthrough decoders impose no distance requirements between13191319- * peers13181318+ * The "distance" between peer downstream ports represents which13191319+ * endpoint positions in the region interleave a given port can13201320+ * host.13211321+ *13221322+ * For example, at the root of a hierarchy the distance is13231323+ * always 1 as every index targets a different host-bridge. At13241324+ * each subsequent switch level those ports map every Nth region13251325+ * position where N is the width of the switch == distance.13201326 */13211321- if (cxl_rr->nr_targets == 1)13221322- distance = 0;13231323- else13241324- distance = p->nr_targets / cxl_rr->nr_targets;13271327+ do {13281328+ cxl_rr_iter = cxl_rr_load(iter, cxlr);13291329+ distance *= cxl_rr_iter->nr_targets;13301330+ iter = to_cxl_port(iter->dev.parent);13311331+ } while (!is_cxl_root(iter));13321332+ distance *= cxlrd->cxlsd.cxld.interleave_ways;13331333+13251334 for (i = 0; i < cxl_rr->nr_targets_set; i++)13261335 if (ep->dport == cxlsd->target[i]) {13271336 rc = check_last_peer(cxled, ep, cxl_rr,
+4-2
drivers/cxl/pci.c
···836836 if (!root_dev)837837 return -ENXIO;838838839839+ if (!dport->regs.rcd_pcie_cap)840840+ return -ENXIO;841841+839842 guard(device)(root_dev);840843 if (!root_dev->driver)841844 return -ENXIO;···10351032 if (rc)10361033 return rc;1037103410381038- rc = cxl_pci_ras_unmask(pdev);10391039- if (rc)10351035+ if (cxl_pci_ras_unmask(pdev))10401036 dev_dbg(&pdev->dev, "No RAS reporting unmasked\n");1041103710421038 pci_save_state(pdev);
···297297};298298299299#define SEALS_WANTED (F_SEAL_SHRINK)300300-#define SEALS_DENIED (F_SEAL_WRITE)300300+#define SEALS_DENIED (F_SEAL_WRITE|F_SEAL_FUTURE_WRITE)301301302302static int check_memfd_seals(struct file *memfd)303303{···317317 return 0;318318}319319320320-static int export_udmabuf(struct udmabuf *ubuf,321321- struct miscdevice *device,322322- u32 flags)320320+static struct dma_buf *export_udmabuf(struct udmabuf *ubuf,321321+ struct miscdevice *device)323322{324323 DEFINE_DMA_BUF_EXPORT_INFO(exp_info);325325- struct dma_buf *buf;326324327325 ubuf->device = device;328326 exp_info.ops = &udmabuf_ops;···328330 exp_info.priv = ubuf;329331 exp_info.flags = O_RDWR;330332331331- buf = dma_buf_export(&exp_info);332332- if (IS_ERR(buf))333333- return PTR_ERR(buf);334334-335335- return dma_buf_fd(buf, flags);333333+ return dma_buf_export(&exp_info);336334}337335338336static long udmabuf_pin_folios(struct udmabuf *ubuf, struct file *memfd,···385391 struct folio **folios = NULL;386392 pgoff_t pgcnt = 0, pglimit;387393 struct udmabuf *ubuf;394394+ struct dma_buf *dmabuf;388395 long ret = -EINVAL;389396 u32 i, flags;390397···431436 goto err;432437 }433438439439+ /*440440+ * Take the inode lock to protect against concurrent441441+ * memfd_add_seals(), which takes this lock in write mode.442442+ */443443+ inode_lock_shared(file_inode(memfd));434444 ret = check_memfd_seals(memfd);435435- if (ret < 0) {436436- fput(memfd);437437- goto err;438438- }445445+ if (ret)446446+ goto out_unlock;439447440448 ret = udmabuf_pin_folios(ubuf, memfd, list[i].offset,441449 list[i].size, folios);450450+out_unlock:451451+ inode_unlock_shared(file_inode(memfd));442452 fput(memfd);443453 if (ret)444454 goto err;445455 }446456447457 flags = head->flags & UDMABUF_FLAGS_CLOEXEC ? O_CLOEXEC : 0;448448- ret = export_udmabuf(ubuf, device, flags);449449- if (ret < 0)458458+ dmabuf = export_udmabuf(ubuf, device);459459+ if (IS_ERR(dmabuf)) {460460+ ret = PTR_ERR(dmabuf);450461 goto err;462462+ }463463+ /*464464+ * Ownership of ubuf is held by the dmabuf from here.465465+ * If the following dma_buf_fd() fails, dma_buf_put() cleans up both the466466+ * dmabuf and the ubuf (through udmabuf_ops.release).467467+ */468468+469469+ ret = dma_buf_fd(dmabuf, flags);470470+ if (ret < 0)471471+ dma_buf_put(dmabuf);451472452473 kvfree(folios);453474 return ret;
+11-4
drivers/firmware/arm_ffa/bus.c
···187187 return valid;188188}189189190190-struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,191191- const struct ffa_ops *ops)190190+struct ffa_device *191191+ffa_device_register(const struct ffa_partition_info *part_info,192192+ const struct ffa_ops *ops)192193{193194 int id, ret;195195+ uuid_t uuid;194196 struct device *dev;195197 struct ffa_device *ffa_dev;198198+199199+ if (!part_info)200200+ return NULL;196201197202 id = ida_alloc_min(&ffa_bus_id, 1, GFP_KERNEL);198203 if (id < 0)···215210 dev_set_name(&ffa_dev->dev, "arm-ffa-%d", id);216211217212 ffa_dev->id = id;218218- ffa_dev->vm_id = vm_id;213213+ ffa_dev->vm_id = part_info->id;214214+ ffa_dev->properties = part_info->properties;219215 ffa_dev->ops = ops;220220- uuid_copy(&ffa_dev->uuid, uuid);216216+ import_uuid(&uuid, (u8 *)part_info->uuid);217217+ uuid_copy(&ffa_dev->uuid, &uuid);221218222219 ret = device_register(&ffa_dev->dev);223220 if (ret) {
+1-6
drivers/firmware/arm_ffa/driver.c
···13871387static int ffa_setup_partitions(void)13881388{13891389 int count, idx, ret;13901390- uuid_t uuid;13911390 struct ffa_device *ffa_dev;13921391 struct ffa_dev_part_info *info;13931392 struct ffa_partition_info *pbuf, *tpbuf;···1405140614061407 xa_init(&drv_info->partition_info);14071408 for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {14081408- import_uuid(&uuid, (u8 *)tpbuf->uuid);14091409-14101409 /* Note that if the UUID will be uuid_null, that will require14111410 * ffa_bus_notifier() to find the UUID of this partition id14121411 * with help of ffa_device_match_uuid(). FF-A v1.1 and above14131412 * provides UUID here for each partition as part of the14141413 * discovery API and the same is passed.14151414 */14161416- ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops);14151415+ ffa_dev = ffa_device_register(tpbuf, &ffa_drv_ops);14171416 if (!ffa_dev) {14181417 pr_err("%s: failed to register partition ID 0x%x\n",14191418 __func__, tpbuf->id);14201419 continue;14211420 }14221422-14231423- ffa_dev->properties = tpbuf->properties;1424142114251422 if (drv_info->version > FFA_VERSION_1_0 &&14261423 !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC))
+1
drivers/firmware/arm_scmi/vendors/imx/Kconfig
···1515config IMX_SCMI_MISC_EXT1616 tristate "i.MX SCMI MISC EXTENSION"1717 depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF)1818+ depends on IMX_SCMI_MISC_DRV1819 default y if ARCH_MXC1920 help2021 This enables i.MX System MISC control logic such as gpio expander
-1
drivers/firmware/imx/Kconfig
···25252626config IMX_SCMI_MISC_DRV2727 tristate "IMX SCMI MISC Protocol driver"2828- depends on IMX_SCMI_MISC_EXT || COMPILE_TEST2928 default y if ARCH_MXC3029 help3130 The System Controller Management Interface firmware (SCMI FW) is
+2-2
drivers/firmware/microchip/mpfs-auto-update.c
···402402 return -EIO;403403404404 /*405405- * Bit 5 of byte 1 is "UL_Auto Update" & if it is set, Auto Update is405405+ * Bit 5 of byte 1 is "UL_IAP" & if it is set, Auto Update is406406 * not possible.407407 */408408- if (response_msg[1] & AUTO_UPDATE_FEATURE_ENABLED)408408+ if ((((u8 *)response_msg)[1] & AUTO_UPDATE_FEATURE_ENABLED))409409 return -EPERM;410410411411 return 0;
+4
drivers/gpu/drm/Kconfig
···9999config DRM_KMS_HELPER100100 tristate101101 depends on DRM102102+ select FB_CORE if DRM_FBDEV_EMULATION102103 help103104 CRTC helpers for KMS drivers.104105···359358 tristate360359 depends on DRM361360 select DRM_TTM361361+ select FB_CORE if DRM_FBDEV_EMULATION362362 select FB_SYSMEM_HELPERS_DEFERRED if DRM_FBDEV_EMULATION363363 help364364 Helpers for ttm-based gem objects···367365config DRM_GEM_DMA_HELPER368366 tristate369367 depends on DRM368368+ select FB_CORE if DRM_FBDEV_EMULATION370369 select FB_DMAMEM_HELPERS_DEFERRED if DRM_FBDEV_EMULATION371370 help372371 Choose this if you need the GEM DMA helper functions···375372config DRM_GEM_SHMEM_HELPER376373 tristate377374 depends on DRM && MMU375375+ select FB_CORE if DRM_FBDEV_EMULATION378376 select FB_SYSMEM_HELPERS_DEFERRED if DRM_FBDEV_EMULATION379377 help380378 Choose this if you need the GEM shmem helper functions
+2-3
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
···343343 coredump->skip_vram_check = skip_vram_check;344344 coredump->reset_vram_lost = vram_lost;345345346346- if (job && job->vm) {347347- struct amdgpu_vm *vm = job->vm;346346+ if (job && job->pasid) {348347 struct amdgpu_task_info *ti;349348350350- ti = amdgpu_vm_get_task_info_vm(vm);349349+ ti = amdgpu_vm_get_task_info_pasid(adev, job->pasid);351350 if (ti) {352351 coredump->reset_task_info = *ti;353352 amdgpu_vm_put_task_info(ti);
+3
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
···417417{418418 struct amdgpu_device *adev = drm_to_adev(dev);419419420420+ if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))421421+ return false;422422+420423 if (adev->has_pr3 ||421424 ((adev->flags & AMD_IS_PX) && amdgpu_is_atpx_hybrid()))422425 return true;
+1-2
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
···255255256256void amdgpu_job_free_resources(struct amdgpu_job *job)257257{258258- struct amdgpu_ring *ring = to_amdgpu_ring(job->base.sched);259258 struct dma_fence *f;260259 unsigned i;261260···267268 f = NULL;268269269270 for (i = 0; i < job->num_ibs; ++i)270270- amdgpu_ib_free(ring->adev, &job->ibs[i], f);271271+ amdgpu_ib_free(NULL, &job->ibs[i], f);271272}272273273274static void amdgpu_job_free_cb(struct drm_sched_job *s_job)
+3-4
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
···12661266 * next command submission.12671267 */12681268 if (amdgpu_vm_is_bo_always_valid(vm, bo)) {12691269- uint32_t mem_type = bo->tbo.resource->mem_type;12701270-12711271- if (!(bo->preferred_domains &12721272- amdgpu_mem_type_to_domain(mem_type)))12691269+ if (bo->tbo.resource &&12701270+ !(bo->preferred_domains &12711271+ amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type)))12731272 amdgpu_vm_bo_evicted(&bo_va->base);12741273 else12751274 amdgpu_vm_bo_idle(&bo_va->base);
+1-1
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
···41234123 if (amdgpu_sriov_vf(adev))41244124 return 0;4125412541264126- switch (adev->ip_versions[GC_HWIP][0]) {41264126+ switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {41274127 case IP_VERSION(12, 0, 0):41284128 case IP_VERSION(12, 0, 1):41294129 gfx_v12_0_update_gfx_clock_gating(adev,
···18961896 *18971897 * Creates a DP tunnel manager for @dev.18981898 *18991899- * Returns a pointer to the tunnel manager if created successfully or NULL in19001900- * case of an error.18991899+ * Returns a pointer to the tunnel manager if created successfully or error19001900+ * pointer in case of failure.19011901 */19021902struct drm_dp_tunnel_mgr *19031903drm_dp_tunnel_mgr_create(struct drm_device *dev, int max_group_count)···1907190719081908 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);19091909 if (!mgr)19101910- return NULL;19101910+ return ERR_PTR(-ENOMEM);1911191119121912 mgr->dev = dev;19131913 init_waitqueue_head(&mgr->bw_req_queue);···19161916 if (!mgr->groups) {19171917 kfree(mgr);1918191819191919- return NULL;19191919+ return ERR_PTR(-ENOMEM);19201920 }1921192119221922#ifdef CONFIG_DRM_DISPLAY_DP_TUNNEL_STATE_DEBUG···19271927 if (!init_group(mgr, &mgr->groups[i])) {19281928 destroy_mgr(mgr);1929192919301930- return NULL;19301930+ return ERR_PTR(-ENOMEM);19311931 }1932193219331933 mgr->group_count++;
+7-4
drivers/gpu/drm/drm_modes.c
···12871287 */12881288int drm_mode_vrefresh(const struct drm_display_mode *mode)12891289{12901290- unsigned int num, den;12901290+ unsigned int num = 1, den = 1;1291129112921292 if (mode->htotal == 0 || mode->vtotal == 0)12931293 return 0;12941294-12951295- num = mode->clock;12961296- den = mode->htotal * mode->vtotal;1297129412981295 if (mode->flags & DRM_MODE_FLAG_INTERLACE)12991296 num *= 2;···12981301 den *= 2;12991302 if (mode->vscan > 1)13001303 den *= mode->vscan;13041304+13051305+ if (check_mul_overflow(mode->clock, num, &num))13061306+ return 0;13071307+13081308+ if (check_mul_overflow(mode->htotal * mode->vtotal, den, &den))13091309+ return 0;1301131013021311 return DIV_ROUND_CLOSEST_ULL(mul_u32_u32(num, 1000), den);13031312}
+5
drivers/gpu/drm/i915/gt/intel_engine_types.h
···343343 * @start_gt_clk: GT clock time of last idle to active transition.344344 */345345 u64 start_gt_clk;346346+347347+ /**348348+ * @total: The last value of total returned349349+ */350350+ u64 total;346351};347352348353union intel_engine_tlb_inv_reg {
···481481 return dev_err_probe(dev, -EPROBE_DEFER, "Cannot get secondary DSI host\n");482482483483 nt->dsi[1] = mipi_dsi_device_register_full(dsi_r_host, info);484484- if (!nt->dsi[1]) {484484+ if (IS_ERR(nt->dsi[1])) {485485 dev_err(dev, "Cannot get secondary DSI node\n");486486- return -ENODEV;486486+ return PTR_ERR(nt->dsi[1]);487487 }488488 num_dsis++;489489 }
+1
drivers/gpu/drm/panel/panel-sitronix-st7701.c
···11771177 return dev_err_probe(dev, ret, "Failed to get orientation\n");1178117811791179 drm_panel_init(&st7701->panel, dev, &st7701_funcs, connector_type);11801180+ st7701->panel.prepare_prev_first = true;1180118111811182 /**11821183 * Once sleep out has been issued, ST7701 IC required to wait 120ms
···13551355 * drm_sched_backend_ops.run_job(). Consequently, drm_sched_backend_ops.free_job()13561356 * will not be called for all jobs still in drm_gpu_scheduler.pending_list.13571357 * There is no solution for this currently. Thus, it is up to the driver to make13581358- * sure that13581358+ * sure that:13591359+ *13591360 * a) drm_sched_fini() is only called after for all submitted jobs13601361 * drm_sched_backend_ops.free_job() has been called or that13611362 * b) the jobs for which drm_sched_backend_ops.free_job() has not been called
+5-4
drivers/hv/hv_balloon.c
···756756 * adding succeeded, it is ok to proceed even if the memory was757757 * not onlined in time.758758 */759759- wait_for_completion_timeout(&dm_device.ol_waitevent, 5 * HZ);759759+ wait_for_completion_timeout(&dm_device.ol_waitevent, secs_to_jiffies(5));760760 post_status(&dm_device);761761 }762762}···13731373 struct hv_dynmem_device *dm = dm_dev;1374137413751375 while (!kthread_should_stop()) {13761376- wait_for_completion_interruptible_timeout(&dm_device.config_event, 1 * HZ);13761376+ wait_for_completion_interruptible_timeout(&dm_device.config_event,13771377+ secs_to_jiffies(1));13771378 /*13781379 * The host expects us to post information on the memory13791380 * pressure every second.···17491748 if (ret)17501749 goto out;1751175017521752- t = wait_for_completion_timeout(&dm_device.host_event, 5 * HZ);17511751+ t = wait_for_completion_timeout(&dm_device.host_event, secs_to_jiffies(5));17531752 if (t == 0) {17541753 ret = -ETIMEDOUT;17551754 goto out;···18071806 if (ret)18081807 goto out;1809180818101810- t = wait_for_completion_timeout(&dm_device.host_event, 5 * HZ);18091809+ t = wait_for_completion_timeout(&dm_device.host_event, secs_to_jiffies(5));18111810 if (t == 0) {18121811 ret = -ETIMEDOUT;18131812 goto out;
···25072507 vmbus_request_offers();2508250825092509 if (wait_for_completion_timeout(25102510- &vmbus_connection.ready_for_resume_event, 10 * HZ) == 0)25102510+ &vmbus_connection.ready_for_resume_event, secs_to_jiffies(10)) == 0)25112511 pr_err("Some vmbus device is missing after suspending?\n");2512251225132513 /* Reset the event for the next suspend. */
+6-4
drivers/hwmon/tmp513.c
···182182 struct regmap *regmap;183183};184184185185-// Set the shift based on the gain 8=4, 4=3, 2=2, 1=1185185+// Set the shift based on the gain: 8 -> 1, 4 -> 2, 2 -> 3, 1 -> 4186186static inline u8 tmp51x_get_pga_shift(struct tmp51x_data *data)187187{188188 return 5 - ffs(data->pga_gain);···204204 * 2's complement number shifted by one to four depending205205 * on the pga gain setting. 1lsb = 10uV206206 */207207- *val = sign_extend32(regval, 17 - tmp51x_get_pga_shift(data));207207+ *val = sign_extend32(regval,208208+ reg == TMP51X_SHUNT_CURRENT_RESULT ?209209+ 16 - tmp51x_get_pga_shift(data) : 15);208210 *val = DIV_ROUND_CLOSEST(*val * 10 * MILLI, data->shunt_uohms);209211 break;210212 case TMP51X_BUS_VOLTAGE_RESULT:···222220 break;223221 case TMP51X_BUS_CURRENT_RESULT:224222 // Current = (ShuntVoltage * CalibrationRegister) / 4096225225- *val = sign_extend32(regval, 16) * data->curr_lsb_ua;223223+ *val = sign_extend32(regval, 15) * (long)data->curr_lsb_ua;226224 *val = DIV_ROUND_CLOSEST(*val, MILLI);227225 break;228226 case TMP51X_LOCAL_TEMP_RESULT:···234232 case TMP51X_REMOTE_TEMP_LIMIT_2:235233 case TMP513_REMOTE_TEMP_LIMIT_3:236234 // 1lsb = 0.0625 degrees centigrade237237- *val = sign_extend32(regval, 16) >> TMP51X_TEMP_SHIFT;235235+ *val = sign_extend32(regval, 15) >> TMP51X_TEMP_SHIFT;238236 *val = DIV_ROUND_CLOSEST(*val * 625, 10);239237 break;240238 case TMP51X_N_FACTOR_AND_HYST_1:
+1
drivers/macintosh/Kconfig
···120120config PMAC_BACKLIGHT121121 bool "Backlight control for LCD screens"122122 depends on PPC_PMAC && ADB_PMU && FB = y && (BROKEN || !PPC64)123123+ depends on BACKLIGHT_CLASS_DEVICE=y123124 select FB_BACKLIGHT124125 help125126 Say Y here to enable Macintosh specific extensions of the generic
···11881188 return ret;11891189}1190119011911191-static11911191+/* clang stack usage explodes if this is inlined */11921192+static noinline_for_stack11921193void vdec_vp9_slice_map_counts_eob_coef(unsigned int i, unsigned int j, unsigned int k,11931194 struct vdec_vp9_slice_frame_counts *counts,11941195 struct v4l2_vp9_frame_symbol_counts *counts_helper)
···12201220static int m_can_interrupt_handler(struct m_can_classdev *cdev)12211221{12221222 struct net_device *dev = cdev->net;12231223- u32 ir;12231223+ u32 ir = 0, ir_read;12241224 int ret;1225122512261226 if (pm_runtime_suspended(cdev->dev))12271227 return IRQ_NONE;1228122812291229- ir = m_can_read(cdev, M_CAN_IR);12291229+ /* The m_can controller signals its interrupt status as a level, but12301230+ * depending in the integration the CPU may interpret the signal as12311231+ * edge-triggered (for example with m_can_pci). For these12321232+ * edge-triggered integrations, we must observe that IR is 0 at least12331233+ * once to be sure that the next interrupt will generate an edge.12341234+ */12351235+ while ((ir_read = m_can_read(cdev, M_CAN_IR)) != 0) {12361236+ ir |= ir_read;12371237+12381238+ /* ACK all irqs */12391239+ m_can_write(cdev, M_CAN_IR, ir);12401240+12411241+ if (!cdev->irq_edge_triggered)12421242+ break;12431243+ }12441244+12301245 m_can_coalescing_update(cdev, ir);12311246 if (!ir)12321247 return IRQ_NONE;12331233-12341234- /* ACK all irqs */12351235- m_can_write(cdev, M_CAN_IR, ir);1236124812371249 if (cdev->ops->clear_interrupts)12381250 cdev->ops->clear_interrupts(cdev);···17071695 return -EINVAL;17081696 }1709169716981698+ /* Write the INIT bit, in case no hardware reset has happened before16991699+ * the probe (for example, it was observed that the Intel Elkhart Lake17001700+ * SoCs do not properly reset the CAN controllers on reboot)17011701+ */17021702+ err = m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT);17031703+ if (err)17041704+ return err;17051705+17101706 if (!cdev->is_peripheral)17111707 netif_napi_add(dev, &cdev->napi, m_can_poll);17121708···17661746 return -EINVAL;17671747 }1768174817691769- /* Forcing standby mode should be redundant, as the chip should be in17701770- * standby after a reset. Write the INIT bit anyways, should the chip17711771- * be configured by previous stage.17721772- */17731773- return m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT);17491749+ return 0;17741750}1775175117761752static void m_can_stop(struct net_device *dev)
+1
drivers/net/can/m_can/m_can.h
···9999 int pm_clock_support;100100 int pm_wake_source;101101 int is_peripheral;102102+ bool irq_edge_triggered;102103103104 // Cached M_CAN_IE register content104105 u32 active_interrupts;
···867867static int xennet_close(struct net_device *dev)868868{869869 struct netfront_info *np = netdev_priv(dev);870870- unsigned int num_queues = dev->real_num_tx_queues;870870+ unsigned int num_queues = np->queues ? dev->real_num_tx_queues : 0;871871 unsigned int i;872872 struct netfront_queue *queue;873873 netif_tx_stop_all_queues(np->netdev);···881881static void xennet_destroy_queues(struct netfront_info *info)882882{883883 unsigned int i;884884+885885+ if (!info->queues)886886+ return;884887885888 for (i = 0; i < info->netdev->real_num_tx_queues; i++) {886889 struct netfront_queue *queue = &info->queues[i];
+1-1
drivers/nvme/host/core.c
···20342034 * or smaller than a sector size yet, so catch this early and don't20352035 * allow block I/O.20362036 */20372037- if (head->lba_shift > PAGE_SHIFT || head->lba_shift < SECTOR_SHIFT) {20372037+ if (blk_validate_block_size(bs)) {20382038 bs = (1 << 9);20392039 valid = false;20402040 }
···8888}89899090#define EXCLUDED_DEFAULT_CELLS_PLATFORMS ( \9191- IS_ENABLED(CONFIG_SPARC) \9191+ IS_ENABLED(CONFIG_SPARC) || \9292+ of_find_compatible_node(NULL, NULL, "coreboot") \9293)93949495int of_bus_n_addr_cells(struct device_node *np)···15081507 map_len--;1509150815101509 /* Check if not found */15111511- if (!new)15101510+ if (!new) {15111511+ ret = -EINVAL;15121512 goto put;15131513+ }1513151415141515 if (!of_device_is_available(new))15151516 match = 0;···15211518 goto put;1522151915231520 /* Check for malformed properties */15241524- if (WARN_ON(new_size > MAX_PHANDLE_ARGS))15211521+ if (WARN_ON(new_size > MAX_PHANDLE_ARGS) ||15221522+ map_len < new_size) {15231523+ ret = -EINVAL;15251524 goto put;15261526- if (map_len < new_size)15271527- goto put;15251525+ }1528152615291527 /* Move forward by new node's #<list>-cells amount */15301528 map += new_size;15311529 map_len -= new_size;15321530 }15331533- if (!match)15311531+ if (!match) {15321532+ ret = -ENOENT;15341533 goto put;15341534+ }1535153515361536 /* Get the <list>-map-pass-thru property (optional) */15371537 pass = of_get_property(cur, pass_name, NULL);
+8-1
drivers/of/empty_root.dts
···22/dts-v1/;3344/ {55-55+ /*66+ * #address-cells/#size-cells are required properties at root node.77+ * Use 2 cells for both address cells and size cells in order to fully88+ * support 64-bit addresses and sizes on systems using this empty root99+ * node.1010+ */1111+ #address-cells = <0x02>;1212+ #size-cells = <0x02>;613};
+2
drivers/of/irq.c
···111111 else112112 np = of_find_node_by_phandle(be32_to_cpup(imap));113113 imap++;114114+ len--;114115115116 /* Check if not found */116117 if (!np) {···355354 return of_irq_parse_oldworld(device, index, out_irq);356355357356 /* Get the reg property (if any) */357357+ addr_len = 0;358358 addr = of_get_property(device, "reg", &addr_len);359359360360 /* Prevent out-of-bounds read in case of longer interrupt parent address size */
···12131213 of_node_put(np);12141214}1215121512161216+static void __init of_unittest_pci_empty_dma_ranges(void)12171217+{12181218+ struct device_node *np;12191219+ struct of_pci_range range;12201220+ struct of_pci_range_parser parser;12211221+12221222+ if (!IS_ENABLED(CONFIG_PCI))12231223+ return;12241224+12251225+ np = of_find_node_by_path("/testcase-data/address-tests2/pcie@d1070000/pci@0,0/dev@0,0/local-bus@0");12261226+ if (!np) {12271227+ pr_err("missing testcase data\n");12281228+ return;12291229+ }12301230+12311231+ if (of_pci_dma_range_parser_init(&parser, np)) {12321232+ pr_err("missing dma-ranges property\n");12331233+ return;12341234+ }12351235+12361236+ /*12371237+ * Get the dma-ranges from the device tree12381238+ */12391239+ for_each_of_pci_range(&parser, &range) {12401240+ unittest(range.size == 0x10000000,12411241+ "for_each_of_pci_range wrong size on node %pOF size=%llx\n",12421242+ np, range.size);12431243+ unittest(range.cpu_addr == 0x00000000,12441244+ "for_each_of_pci_range wrong CPU addr (%llx) on node %pOF",12451245+ range.cpu_addr, np);12461246+ unittest(range.pci_addr == 0xc0000000,12471247+ "for_each_of_pci_range wrong DMA addr (%llx) on node %pOF",12481248+ range.pci_addr, np);12491249+ }12501250+12511251+ of_node_put(np);12521252+}12531253+12161254static void __init of_unittest_bus_ranges(void)12171255{12181256 struct device_node *np;···43104272 of_unittest_dma_get_max_cpu_address();43114273 of_unittest_parse_dma_ranges();43124274 of_unittest_pci_dma_ranges();42754275+ of_unittest_pci_empty_dma_ranges();43134276 of_unittest_bus_ranges();43144277 of_unittest_bus_3cell_ranges();43154278 of_unittest_reg();
+4-2
drivers/pci/pci.c
···62326232 pcie_capability_read_dword(dev, PCI_EXP_LNKCAP2, &lnkcap2);62336233 speeds = lnkcap2 & PCI_EXP_LNKCAP2_SLS;6234623462356235+ /* Ignore speeds higher than Max Link Speed */62366236+ pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &lnkcap);62376237+ speeds &= GENMASK(lnkcap & PCI_EXP_LNKCAP_SLS, 0);62386238+62356239 /* PCIe r3.0-compliant */62366240 if (speeds)62376241 return speeds;62386238-62396239- pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &lnkcap);6240624262416243 /* Synthesize from the Max Link Speed field */62426244 if ((lnkcap & PCI_EXP_LNKCAP_SLS) == PCI_EXP_LNKCAP_SLS_5_0GB)
+3-1
drivers/pci/pcie/portdrv.c
···265265 (pcie_ports_dpc_native || (services & PCIE_PORT_SERVICE_AER)))266266 services |= PCIE_PORT_SERVICE_DPC;267267268268+ /* Enable bandwidth control if more than one speed is supported. */268269 if (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM ||269270 pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {270271 u32 linkcap;271272272273 pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &linkcap);273273- if (linkcap & PCI_EXP_LNKCAP_LBNC)274274+ if (linkcap & PCI_EXP_LNKCAP_LBNC &&275275+ hweight8(dev->supported_speeds) > 1)274276 services |= PCIE_PORT_SERVICE_BWCTRL;275277 }276278
+1-1
drivers/platform/loongarch/Kconfig
···18181919config LOONGSON_LAPTOP2020 tristate "Generic Loongson-3 Laptop Driver"2121- depends on ACPI2121+ depends on ACPI_EC2222 depends on BACKLIGHT_CLASS_DEVICE2323 depends on INPUT2424 depends on MACH_LOONGSON64
···4343};44444545static struct p2sb_res_cache p2sb_resources[NR_P2SB_RES_CACHE];4646+static bool p2sb_hidden_by_bios;46474748static void p2sb_get_devfn(unsigned int *devfn)4849{···98979998static int p2sb_scan_and_cache(struct pci_bus *bus, unsigned int devfn)10099{100100+ /*101101+ * The BIOS prevents the P2SB device from being enumerated by the PCI102102+ * subsystem, so we need to unhide and hide it back to lookup the BAR.103103+ */104104+ pci_bus_write_config_dword(bus, devfn, P2SBC, 0);105105+101106 /* Scan the P2SB device and cache its BAR0 */102107 p2sb_scan_and_cache_devfn(bus, devfn);103108104109 /* On Goldmont p2sb_bar() also gets called for the SPI controller */105110 if (devfn == P2SB_DEVFN_GOLDMONT)106111 p2sb_scan_and_cache_devfn(bus, SPI_DEVFN_GOLDMONT);112112+113113+ pci_bus_write_config_dword(bus, devfn, P2SBC, P2SBC_HIDE);107114108115 if (!p2sb_valid_resource(&p2sb_resources[PCI_FUNC(devfn)].res))109116 return -ENOENT;···138129 u32 value = P2SBC_HIDE;139130 struct pci_bus *bus;140131 u16 class;141141- int ret;132132+ int ret = 0;142133143134 /* Get devfn for P2SB device itself */144135 p2sb_get_devfn(&devfn_p2sb);···161152 */162153 pci_lock_rescan_remove();163154164164- /*165165- * The BIOS prevents the P2SB device from being enumerated by the PCI166166- * subsystem, so we need to unhide and hide it back to lookup the BAR.167167- * Unhide the P2SB device here, if needed.168168- */169155 pci_bus_read_config_dword(bus, devfn_p2sb, P2SBC, &value);170170- if (value & P2SBC_HIDE)171171- pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, 0);156156+ p2sb_hidden_by_bios = value & P2SBC_HIDE;172157173173- ret = p2sb_scan_and_cache(bus, devfn_p2sb);174174-175175- /* Hide the P2SB device, if it was hidden */176176- if (value & P2SBC_HIDE)177177- pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, P2SBC_HIDE);158158+ /*159159+ * If the BIOS does not hide the P2SB device then its resources160160+ * are accesilble. Cache them only if the P2SB device is hidden.161161+ */162162+ if (p2sb_hidden_by_bios)163163+ ret = p2sb_scan_and_cache(bus, devfn_p2sb);178164179165 pci_unlock_rescan_remove();166166+167167+ return ret;168168+}169169+170170+static int p2sb_read_from_cache(struct pci_bus *bus, unsigned int devfn,171171+ struct resource *mem)172172+{173173+ struct p2sb_res_cache *cache = &p2sb_resources[PCI_FUNC(devfn)];174174+175175+ if (cache->bus_dev_id != bus->dev.id)176176+ return -ENODEV;177177+178178+ if (!p2sb_valid_resource(&cache->res))179179+ return -ENOENT;180180+181181+ memcpy(mem, &cache->res, sizeof(*mem));182182+183183+ return 0;184184+}185185+186186+static int p2sb_read_from_dev(struct pci_bus *bus, unsigned int devfn,187187+ struct resource *mem)188188+{189189+ struct pci_dev *pdev;190190+ int ret = 0;191191+192192+ pdev = pci_get_slot(bus, devfn);193193+ if (!pdev)194194+ return -ENODEV;195195+196196+ if (p2sb_valid_resource(pci_resource_n(pdev, 0)))197197+ p2sb_read_bar0(pdev, mem);198198+ else199199+ ret = -ENOENT;200200+201201+ pci_dev_put(pdev);180202181203 return ret;182204}···228188 */229189int p2sb_bar(struct pci_bus *bus, unsigned int devfn, struct resource *mem)230190{231231- struct p2sb_res_cache *cache;232232-233191 bus = p2sb_get_bus(bus);234192 if (!bus)235193 return -ENODEV;···235197 if (!devfn)236198 p2sb_get_devfn(&devfn);237199238238- cache = &p2sb_resources[PCI_FUNC(devfn)];239239- if (cache->bus_dev_id != bus->dev.id)240240- return -ENODEV;200200+ if (p2sb_hidden_by_bios)201201+ return p2sb_read_from_cache(bus, devfn, mem);241202242242- if (!p2sb_valid_resource(&cache->res))243243- return -ENOENT;244244-245245- memcpy(mem, &cache->res, sizeof(*mem));246246- return 0;203203+ return p2sb_read_from_dev(bus, devfn, mem);247204}248205EXPORT_SYMBOL_GPL(p2sb_bar);249206
···33 tristate "Support for small TFT LCD display modules"44 depends on FB && SPI55 depends on FB_DEVICE66+ depends on BACKLIGHT_CLASS_DEVICE67 depends on GPIOLIB || COMPILE_TEST78 select FB_BACKLIGHT89 select FB_SYSMEM_HELPERS_DEFERRED
···103103104104err_nvm:105105 dev_dbg(&rt->dev, "NVM upgrade disabled\n");106106+ rt->no_nvm_upgrade = true;106107 if (!IS_ERR(nvm))107108 tb_nvm_free(nvm);108109···183182184183 if (!rt->nvm)185184 ret = -EAGAIN;186186- else if (rt->no_nvm_upgrade)187187- ret = -EOPNOTSUPP;188185 else189186 ret = sysfs_emit(buf, "%#x\n", rt->auth_status);190187···322323323324 if (!rt->nvm)324325 ret = -EAGAIN;325325- else if (rt->no_nvm_upgrade)326326- ret = -EOPNOTSUPP;327326 else328327 ret = sysfs_emit(buf, "%x.%x\n", rt->nvm->major, rt->nvm->minor);329328···339342}340343static DEVICE_ATTR_RO(vendor);341344345345+static umode_t retimer_is_visible(struct kobject *kobj, struct attribute *attr,346346+ int n)347347+{348348+ struct device *dev = kobj_to_dev(kobj);349349+ struct tb_retimer *rt = tb_to_retimer(dev);350350+351351+ if (attr == &dev_attr_nvm_authenticate.attr ||352352+ attr == &dev_attr_nvm_version.attr)353353+ return rt->no_nvm_upgrade ? 0 : attr->mode;354354+355355+ return attr->mode;356356+}357357+342358static struct attribute *retimer_attrs[] = {343359 &dev_attr_device.attr,344360 &dev_attr_nvm_authenticate.attr,···361351};362352363353static const struct attribute_group retimer_group = {354354+ .is_visible = retimer_is_visible,364355 .attrs = retimer_attrs,365356};366357
+41
drivers/thunderbolt/tb.c
···20592059 }20602060}2061206120622062+static void tb_switch_enter_redrive(struct tb_switch *sw)20632063+{20642064+ struct tb_port *port;20652065+20662066+ tb_switch_for_each_port(sw, port)20672067+ tb_enter_redrive(port);20682068+}20692069+20702070+/*20712071+ * Called during system and runtime suspend to forcefully exit redrive20722072+ * mode without querying whether the resource is available.20732073+ */20742074+static void tb_switch_exit_redrive(struct tb_switch *sw)20752075+{20762076+ struct tb_port *port;20772077+20782078+ if (!(sw->quirks & QUIRK_KEEP_POWER_IN_DP_REDRIVE))20792079+ return;20802080+20812081+ tb_switch_for_each_port(sw, port) {20822082+ if (!tb_port_is_dpin(port))20832083+ continue;20842084+20852085+ if (port->redrive) {20862086+ port->redrive = false;20872087+ pm_runtime_put(&sw->dev);20882088+ tb_port_dbg(port, "exit redrive mode\n");20892089+ }20902090+ }20912091+}20922092+20622093static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port)20632094{20642095 struct tb_port *in, *out;···29402909 tb_create_usb3_tunnels(tb->root_switch);29412910 /* Add DP IN resources for the root switch */29422911 tb_add_dp_resources(tb->root_switch);29122912+ tb_switch_enter_redrive(tb->root_switch);29432913 /* Make the discovered switches available to the userspace */29442914 device_for_each_child(&tb->root_switch->dev, NULL,29452915 tb_scan_finalize_switch);···2956292429572925 tb_dbg(tb, "suspending...\n");29582926 tb_disconnect_and_release_dp(tb);29272927+ tb_switch_exit_redrive(tb->root_switch);29592928 tb_switch_suspend(tb->root_switch, false);29602929 tcm->hotplug_active = false; /* signal tb_handle_hotplug to quit */29612930 tb_dbg(tb, "suspend finished\n");···30493016 tb_dbg(tb, "tunnels restarted, sleeping for 100ms\n");30503017 msleep(100);30513018 }30193019+ tb_switch_enter_redrive(tb->root_switch);30523020 /* Allow tb_handle_hotplug to progress events */30533021 tcm->hotplug_active = true;30543022 tb_dbg(tb, "resume finished\n");···31133079 struct tb_cm *tcm = tb_priv(tb);3114308031153081 mutex_lock(&tb->lock);30823082+ /*30833083+ * The below call only releases DP resources to allow exiting and30843084+ * re-entering redrive mode.30853085+ */30863086+ tb_disconnect_and_release_dp(tb);30873087+ tb_switch_exit_redrive(tb->root_switch);31163088 tb_switch_suspend(tb->root_switch, true);31173089 tcm->hotplug_active = false;31183090 mutex_unlock(&tb->lock);···31503110 tb_restore_children(tb->root_switch);31513111 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list)31523112 tb_tunnel_restart(tunnel);31133113+ tb_switch_enter_redrive(tb->root_switch);31533114 tcm->hotplug_active = true;31543115 mutex_unlock(&tb->lock);31553116
+1-1
drivers/usb/host/xhci-mem.c
···436436 goto free_segments;437437 }438438439439- xhci_link_rings(xhci, ring, &new_ring);439439+ xhci_link_rings(xhci, &new_ring, ring);440440 trace_xhci_ring_expansion(ring);441441 xhci_dbg_trace(xhci, trace_xhci_dbg_ring_expansion,442442 "ring expansion succeed, now has %d segments",
-2
drivers/usb/host/xhci-ring.c
···11991199 * Keep retrying until the EP starts and stops again, on12001200 * chips where this is known to help. Wait for 100ms.12011201 */12021202- if (!(xhci->quirks & XHCI_NEC_HOST))12031203- break;12041202 if (time_is_before_jiffies(ep->stop_time + msecs_to_jiffies(100)))12051203 break;12061204 fallthrough;
···649649config FB_ATMEL650650 tristate "AT91 LCD Controller support"651651 depends on FB && OF && HAVE_CLK && HAS_IOMEM652652+ depends on BACKLIGHT_CLASS_DEVICE652653 depends on HAVE_FB_ATMEL || COMPILE_TEST653654 select FB_BACKLIGHT654655 select FB_IOMEM_HELPERS···661660config FB_NVIDIA662661 tristate "nVidia Framebuffer Support"663662 depends on FB && PCI664664- select FB_BACKLIGHT if FB_NVIDIA_BACKLIGHT665663 select FB_CFB_FILLRECT666664 select FB_CFB_COPYAREA667665 select FB_CFB_IMAGEBLIT···700700config FB_NVIDIA_BACKLIGHT701701 bool "Support for backlight control"702702 depends on FB_NVIDIA703703+ depends on BACKLIGHT_CLASS_DEVICE=y || BACKLIGHT_CLASS_DEVICE=FB_NVIDIA704704+ select FB_BACKLIGHT703705 default y704706 help705707 Say Y here if you want to control the backlight of your display.···709707config FB_RIVA710708 tristate "nVidia Riva support"711709 depends on FB && PCI712712- select FB_BACKLIGHT if FB_RIVA_BACKLIGHT713710 select FB_CFB_FILLRECT714711 select FB_CFB_COPYAREA715712 select FB_CFB_IMAGEBLIT···748747config FB_RIVA_BACKLIGHT749748 bool "Support for backlight control"750749 depends on FB_RIVA750750+ depends on BACKLIGHT_CLASS_DEVICE=y || BACKLIGHT_CLASS_DEVICE=FB_RIVA751751+ select FB_BACKLIGHT751752 default y752753 help753754 Say Y here if you want to control the backlight of your display.···937934config FB_RADEON938935 tristate "ATI Radeon display support"939936 depends on FB && PCI940940- select FB_BACKLIGHT if FB_RADEON_BACKLIGHT941937 select FB_CFB_FILLRECT942938 select FB_CFB_COPYAREA943939 select FB_CFB_IMAGEBLIT···962960config FB_RADEON_BACKLIGHT963961 bool "Support for backlight control"964962 depends on FB_RADEON963963+ depends on BACKLIGHT_CLASS_DEVICE=y || BACKLIGHT_CLASS_DEVICE=FB_RADEON964964+ select FB_BACKLIGHT965965 default y966966 help967967 Say Y here if you want to control the backlight of your display.···979975config FB_ATY128980976 tristate "ATI Rage128 display support"981977 depends on FB && PCI982982- select FB_BACKLIGHT if FB_ATY128_BACKLIGHT983978 select FB_IOMEM_HELPERS984979 select FB_MACMODES if PPC_PMAC985980 help···992989config FB_ATY128_BACKLIGHT993990 bool "Support for backlight control"994991 depends on FB_ATY128992992+ depends on BACKLIGHT_CLASS_DEVICE=y || BACKLIGHT_CLASS_DEVICE=FB_ATY128993993+ select FB_BACKLIGHT995994 default y996995 help997996 Say Y here if you want to control the backlight of your display.···1004999 select FB_CFB_FILLRECT10051000 select FB_CFB_COPYAREA10061001 select FB_CFB_IMAGEBLIT10071007- select FB_BACKLIGHT if FB_ATY_BACKLIGHT10081002 select FB_IOMEM_FOPS10091003 select FB_MACMODES if PPC10101004 select FB_ATY_CT if SPARC64 && PCI···10441040config FB_ATY_BACKLIGHT10451041 bool "Support for backlight control"10461042 depends on FB_ATY10431043+ depends on BACKLIGHT_CLASS_DEVICE=y || BACKLIGHT_CLASS_DEVICE=FB_ATY10441044+ select FB_BACKLIGHT10471045 default y10481046 help10491047 Say Y here if you want to control the backlight of your display.···15341528 depends on FB && HAVE_CLK && HAS_IOMEM15351529 depends on SUPERH || COMPILE_TEST15361530 depends on FB_DEVICE15311531+ depends on BACKLIGHT_CLASS_DEVICE15371532 select FB_BACKLIGHT15381533 select FB_DEFERRED_IO15391534 select FB_DMAMEM_HELPERS···18001793 tristate "Solomon SSD1307 framebuffer support"18011794 depends on FB && I2C18021795 depends on GPIOLIB || COMPILE_TEST17961796+ depends on BACKLIGHT_CLASS_DEVICE18031797 select FB_BACKLIGHT18041798 select FB_SYSMEM_HELPERS_DEFERRED18051799 help
+1-2
drivers/video/fbdev/core/Kconfig
···183183 select FB_SYSMEM_HELPERS184184185185config FB_BACKLIGHT186186- tristate186186+ bool187187 depends on FB188188- select BACKLIGHT_CLASS_DEVICE189188190189config FB_MODE_HELPERS191190 bool "Enable Video Mode Handling Helpers"
+11-5
fs/btrfs/bio.c
···358358 INIT_WORK(&bbio->end_io_work, btrfs_end_bio_work);359359 queue_work(btrfs_end_io_wq(fs_info, bio), &bbio->end_io_work);360360 } else {361361- if (bio_op(bio) == REQ_OP_ZONE_APPEND && !bio->bi_status)361361+ if (bio_is_zone_append(bio) && !bio->bi_status)362362 btrfs_record_physical_zoned(bbio);363363 btrfs_bio_end_io(bbio, bbio->bio.bi_status);364364 }···401401 else402402 bio->bi_status = BLK_STS_OK;403403404404- if (bio_op(bio) == REQ_OP_ZONE_APPEND && !bio->bi_status)404404+ if (bio_is_zone_append(bio) && !bio->bi_status)405405 stripe->physical = bio->bi_iter.bi_sector << SECTOR_SHIFT;406406407407 btrfs_bio_end_io(bbio, bbio->bio.bi_status);···415415 if (bio->bi_status) {416416 atomic_inc(&stripe->bioc->error);417417 btrfs_log_dev_io_error(bio, stripe->dev);418418- } else if (bio_op(bio) == REQ_OP_ZONE_APPEND) {418418+ } else if (bio_is_zone_append(bio)) {419419 stripe->physical = bio->bi_iter.bi_sector << SECTOR_SHIFT;420420 }421421···652652 map_length = min(map_length, bbio->fs_info->max_zone_append_size);653653 sector_offset = bio_split_rw_at(&bbio->bio, &bbio->fs_info->limits,654654 &nr_segs, map_length);655655- if (sector_offset)656656- return sector_offset << SECTOR_SHIFT;655655+ if (sector_offset) {656656+ /*657657+ * bio_split_rw_at() could split at a size smaller than our658658+ * sectorsize and thus cause unaligned I/Os. Fix that by659659+ * always rounding down to the nearest boundary.660660+ */661661+ return ALIGN_DOWN(sector_offset << SECTOR_SHIFT, bbio->fs_info->sectorsize);662662+ }657663 return map_length;658664}659665
+19
fs/btrfs/ctree.h
···371371}372372373373/*374374+ * Return the generation this root started with.375375+ *376376+ * Every normal root that is created with root->root_key.offset set to it's377377+ * originating generation. If it is a snapshot it is the generation when the378378+ * snapshot was created.379379+ *380380+ * However for TREE_RELOC roots root_key.offset is the objectid of the owning381381+ * tree root. Thankfully we copy the root item of the owning tree root, which382382+ * has it's last_snapshot set to what we would have root_key.offset set to, so383383+ * return that if this is a TREE_RELOC root.384384+ */385385+static inline u64 btrfs_root_origin_generation(const struct btrfs_root *root)386386+{387387+ if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID)388388+ return btrfs_root_last_snapshot(&root->root_item);389389+ return root->root_key.offset;390390+}391391+392392+/*374393 * Structure that conveys information about an extent that is going to replace375394 * all the extents in a file range.376395 */
+3-3
fs/btrfs/extent-tree.c
···52855285 * reference to it.52865286 */52875287 generation = btrfs_node_ptr_generation(eb, slot);52885288- if (!wc->update_ref || generation <= root->root_key.offset)52885288+ if (!wc->update_ref || generation <= btrfs_root_origin_generation(root))52895289 return false;5290529052915291 /*···53405340 goto reada;5341534153425342 if (wc->stage == UPDATE_BACKREF &&53435343- generation <= root->root_key.offset)53435343+ generation <= btrfs_root_origin_generation(root))53445344 continue;5345534553465346 /* We don't lock the tree block, it's OK to be racy here */···56835683 * for the subtree56845684 */56855685 if (wc->stage == UPDATE_BACKREF &&56865686- generation <= root->root_key.offset) {56865686+ generation <= btrfs_root_origin_generation(root)) {56875687 wc->lookup_info = 1;56885688 return 1;56895689 }
+26-1
fs/btrfs/tree-checker.c
···15271527 dref_offset, fs_info->sectorsize);15281528 return -EUCLEAN;15291529 }15301530+ if (unlikely(btrfs_extent_data_ref_count(leaf, dref) == 0)) {15311531+ extent_err(leaf, slot,15321532+ "invalid data ref count, should have non-zero value");15331533+ return -EUCLEAN;15341534+ }15301535 inline_refs += btrfs_extent_data_ref_count(leaf, dref);15311536 break;15321537 /* Contains parent bytenr and ref count */···15421537 extent_err(leaf, slot,15431538 "invalid data parent bytenr, have %llu expect aligned to %u",15441539 inline_offset, fs_info->sectorsize);15401540+ return -EUCLEAN;15411541+ }15421542+ if (unlikely(btrfs_shared_data_ref_count(leaf, sref) == 0)) {15431543+ extent_err(leaf, slot,15441544+ "invalid shared data ref count, should have non-zero value");15451545 return -EUCLEAN;15461546 }15471547 inline_refs += btrfs_shared_data_ref_count(leaf, sref);···16211611{16221612 u32 expect_item_size = 0;1623161316241624- if (key->type == BTRFS_SHARED_DATA_REF_KEY)16141614+ if (key->type == BTRFS_SHARED_DATA_REF_KEY) {16151615+ struct btrfs_shared_data_ref *sref;16161616+16171617+ sref = btrfs_item_ptr(leaf, slot, struct btrfs_shared_data_ref);16181618+ if (unlikely(btrfs_shared_data_ref_count(leaf, sref) == 0)) {16191619+ extent_err(leaf, slot,16201620+ "invalid shared data backref count, should have non-zero value");16211621+ return -EUCLEAN;16221622+ }16231623+16251624 expect_item_size = sizeof(struct btrfs_shared_data_ref);16251625+ }1626162616271627 if (unlikely(btrfs_item_size(leaf, slot) != expect_item_size)) {16281628 generic_err(leaf, slot,···17071687 extent_err(leaf, slot,17081688 "invalid extent data backref offset, have %llu expect aligned to %u",17091689 offset, leaf->fs_info->sectorsize);16901690+ return -EUCLEAN;16911691+ }16921692+ if (unlikely(btrfs_extent_data_ref_count(leaf, dref) == 0)) {16931693+ extent_err(leaf, slot,16941694+ "invalid extent data backref count, should have non-zero value");17101695 return -EUCLEAN;17111696 }17121697 }
+38-39
fs/ceph/file.c
···10661066 if (ceph_inode_is_shutdown(inode))10671067 return -EIO;1068106810691069- if (!len)10691069+ if (!len || !i_size)10701070 return 0;10711071 /*10721072 * flush any page cache pages in this range. this···10861086 int num_pages;10871087 size_t page_off;10881088 bool more;10891089- int idx;10891089+ int idx = 0;10901090 size_t left;10911091 struct ceph_osd_req_op *op;10921092 u64 read_off = off;···11161116 len = read_off + read_len - off;11171117 more = len < iov_iter_count(to);1118111811191119+ op = &req->r_ops[0];11201120+ if (sparse) {11211121+ extent_cnt = __ceph_sparse_read_ext_count(inode, read_len);11221122+ ret = ceph_alloc_sparse_ext_map(op, extent_cnt);11231123+ if (ret) {11241124+ ceph_osdc_put_request(req);11251125+ break;11261126+ }11271127+ }11281128+11191129 num_pages = calc_pages_for(read_off, read_len);11201130 page_off = offset_in_page(off);11211131 pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL);···1137112711381128 osd_req_op_extent_osd_data_pages(req, 0, pages, read_len,11391129 offset_in_page(read_off),11401140- false, false);11411141-11421142- op = &req->r_ops[0];11431143- if (sparse) {11441144- extent_cnt = __ceph_sparse_read_ext_count(inode, read_len);11451145- ret = ceph_alloc_sparse_ext_map(op, extent_cnt);11461146- if (ret) {11471147- ceph_osdc_put_request(req);11481148- break;11491149- }11501150- }11301130+ false, true);1151113111521132 ceph_osdc_start_request(osdc, req);11531133 ret = ceph_osdc_wait_request(osdc, req);···11601160 else if (ret == -ENOENT)11611161 ret = 0;1162116211631163- if (ret > 0 && IS_ENCRYPTED(inode)) {11631163+ if (ret < 0) {11641164+ ceph_osdc_put_request(req);11651165+ if (ret == -EBLOCKLISTED)11661166+ fsc->blocklisted = true;11671167+ break;11681168+ }11691169+11701170+ if (IS_ENCRYPTED(inode)) {11641171 int fret;1165117211661173 fret = ceph_fscrypt_decrypt_extents(inode, pages,···11931186 ret = min_t(ssize_t, fret, len);11941187 }1195118811961196- ceph_osdc_put_request(req);11971197-11981189 /* Short read but not EOF? Zero out the remainder. */11991199- if (ret >= 0 && ret < len && (off + ret < i_size)) {11901190+ if (ret < len && (off + ret < i_size)) {12001191 int zlen = min(len - ret, i_size - off - ret);12011192 int zoff = page_off + ret;12021193···12041199 ret += zlen;12051200 }1206120112071207- idx = 0;12081208- if (ret <= 0)12091209- left = 0;12101210- else if (off + ret > i_size)12111211- left = i_size - off;12021202+ if (off + ret > i_size)12031203+ left = (i_size > off) ? i_size - off : 0;12121204 else12131205 left = ret;12061206+12141207 while (left > 0) {12151208 size_t plen, copied;12161209···12241221 break;12251222 }12261223 }12271227- ceph_release_page_vector(pages, num_pages);1228122412291229- if (ret < 0) {12301230- if (ret == -EBLOCKLISTED)12311231- fsc->blocklisted = true;12321232- break;12331233- }12251225+ ceph_osdc_put_request(req);1234122612351227 if (off >= i_size || !more)12361228 break;···15511553 break;15521554 }1553155515561556+ op = &req->r_ops[0];15571557+ if (!write && sparse) {15581558+ extent_cnt = __ceph_sparse_read_ext_count(inode, size);15591559+ ret = ceph_alloc_sparse_ext_map(op, extent_cnt);15601560+ if (ret) {15611561+ ceph_osdc_put_request(req);15621562+ break;15631563+ }15641564+ }15651565+15541566 len = iter_get_bvecs_alloc(iter, size, &bvecs, &num_pages);15551567 if (len < 0) {15561568 ceph_osdc_put_request(req);···15691561 }15701562 if (len != size)15711563 osd_req_op_extent_update(req, 0, len);15641564+15651565+ osd_req_op_extent_osd_data_bvecs(req, 0, bvecs, num_pages, len);1572156615731567 /*15741568 * To simplify error handling, allow AIO when IO within i_size···16011591 PAGE_ALIGN(pos + len) - 1);1602159216031593 req->r_mtime = mtime;16041604- }16051605-16061606- osd_req_op_extent_osd_data_bvecs(req, 0, bvecs, num_pages, len);16071607- op = &req->r_ops[0];16081608- if (sparse) {16091609- extent_cnt = __ceph_sparse_read_ext_count(inode, size);16101610- ret = ceph_alloc_sparse_ext_map(op, extent_cnt);16111611- if (ret) {16121612- ceph_osdc_put_request(req);16131613- break;16141614- }16151594 }1616159516171596 if (aio_req) {
+4-5
fs/ceph/mds_client.c
···2800280028012801 if (pos < 0) {28022802 /*28032803- * A rename didn't occur, but somehow we didn't end up where28042804- * we thought we would. Throw a warning and try again.28032803+ * The path is longer than PATH_MAX and this function28042804+ * cannot ever succeed. Creating paths that long is28052805+ * possible with Ceph, but Linux cannot use them.28052806 */28062806- pr_warn_client(cl, "did not end path lookup where expected (pos = %d)\n",28072807- pos);28082808- goto retry;28072807+ return ERR_PTR(-ENAMETOOLONG);28092808 }2810280928112810 *pbase = base;
+2
fs/ceph/super.c
···431431432432 switch (token) {433433 case Opt_snapdirname:434434+ if (strlen(param->string) > NAME_MAX)435435+ return invalfc(fc, "snapdirname too long");434436 kfree(fsopt->snapdir_name);435437 fsopt->snapdir_name = param->string;436438 param->string = NULL;
···203203 struct erofs_device_info *dif;204204 int id, err = 0;205205206206- sbi->total_blocks = sbi->primarydevice_blocks;206206+ sbi->total_blocks = sbi->dif0.blocks;207207 if (!erofs_sb_has_device_table(sbi))208208 ondisk_extradevs = 0;209209 else···307307 sbi->sb_size);308308 goto out;309309 }310310- sbi->primarydevice_blocks = le32_to_cpu(dsb->blocks);310310+ sbi->dif0.blocks = le32_to_cpu(dsb->blocks);311311 sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);312312#ifdef CONFIG_EROFS_FS_XATTR313313 sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);···364364}365365366366enum {367367- Opt_user_xattr,368368- Opt_acl,369369- Opt_cache_strategy,370370- Opt_dax,371371- Opt_dax_enum,372372- Opt_device,373373- Opt_fsid,374374- Opt_domain_id,367367+ Opt_user_xattr, Opt_acl, Opt_cache_strategy, Opt_dax, Opt_dax_enum,368368+ Opt_device, Opt_fsid, Opt_domain_id, Opt_directio,375369 Opt_err376370};377371···392398 fsparam_string("device", Opt_device),393399 fsparam_string("fsid", Opt_fsid),394400 fsparam_string("domain_id", Opt_domain_id),401401+ fsparam_flag_no("directio", Opt_directio),395402 {}396403};397404···506511 errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name);507512 break;508513#endif514514+ case Opt_directio:515515+#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE516516+ if (result.boolean)517517+ set_opt(&sbi->opt, DIRECT_IO);518518+ else519519+ clear_opt(&sbi->opt, DIRECT_IO);520520+#else521521+ errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name);522522+#endif523523+ break;509524 default:510525 return -ENOPARAM;511526 }···607602 return -EINVAL;608603 }609604610610- sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev,611611- &sbi->dax_part_off,612612- NULL, NULL);605605+ sbi->dif0.dax_dev = fs_dax_get_by_bdev(sb->s_bdev,606606+ &sbi->dif0.dax_part_off, NULL, NULL);613607 }614608615609 err = erofs_read_superblock(sb);···631627 }632628633629 if (test_opt(&sbi->opt, DAX_ALWAYS)) {634634- if (!sbi->dax_dev) {630630+ if (!sbi->dif0.dax_dev) {635631 errorfc(fc, "DAX unsupported by block device. Turning off DAX.");636632 clear_opt(&sbi->opt, DAX_ALWAYS);637633 } else if (sbi->blkszbits != PAGE_SHIFT) {···707703 GET_TREE_BDEV_QUIET_LOOKUP : 0);708704#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE709705 if (ret == -ENOTBLK) {706706+ struct file *file;707707+710708 if (!fc->source)711709 return invalf(fc, "No source specified");712712- sbi->fdev = filp_open(fc->source, O_RDONLY | O_LARGEFILE, 0);713713- if (IS_ERR(sbi->fdev))714714- return PTR_ERR(sbi->fdev);710710+ file = filp_open(fc->source, O_RDONLY | O_LARGEFILE, 0);711711+ if (IS_ERR(file))712712+ return PTR_ERR(file);713713+ sbi->dif0.file = file;715714716716- if (S_ISREG(file_inode(sbi->fdev)->i_mode) &&717717- sbi->fdev->f_mapping->a_ops->read_folio)715715+ if (S_ISREG(file_inode(sbi->dif0.file)->i_mode) &&716716+ sbi->dif0.file->f_mapping->a_ops->read_folio)718717 return get_tree_nodev(fc, erofs_fc_fill_super);719719- fput(sbi->fdev);720718 }721719#endif722720 return ret;···769763 kfree(devs);770764}771765766766+static void erofs_sb_free(struct erofs_sb_info *sbi)767767+{768768+ erofs_free_dev_context(sbi->devs);769769+ kfree(sbi->fsid);770770+ kfree(sbi->domain_id);771771+ if (sbi->dif0.file)772772+ fput(sbi->dif0.file);773773+ kfree(sbi);774774+}775775+772776static void erofs_fc_free(struct fs_context *fc)773777{774778 struct erofs_sb_info *sbi = fc->s_fs_info;775779776776- if (!sbi)777777- return;778778-779779- erofs_free_dev_context(sbi->devs);780780- kfree(sbi->fsid);781781- kfree(sbi->domain_id);782782- kfree(sbi);780780+ if (sbi) /* free here if an error occurs before transferring to sb */781781+ erofs_sb_free(sbi);783782}784783785784static const struct fs_context_operations erofs_context_ops = {···820809{821810 struct erofs_sb_info *sbi = EROFS_SB(sb);822811823823- if ((IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && sbi->fsid) || sbi->fdev)812812+ if ((IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && sbi->fsid) ||813813+ sbi->dif0.file)824814 kill_anon_super(sb);825815 else826816 kill_block_super(sb);827827-828828- erofs_free_dev_context(sbi->devs);829829- fs_put_dax(sbi->dax_dev, NULL);817817+ fs_put_dax(sbi->dif0.dax_dev, NULL);830818 erofs_fscache_unregister_fs(sb);831831- kfree(sbi->fsid);832832- kfree(sbi->domain_id);833833- if (sbi->fdev)834834- fput(sbi->fdev);835835- kfree(sbi);819819+ erofs_sb_free(sbi);836820 sb->s_fs_info = NULL;837821}838822···953947 seq_puts(seq, ",dax=always");954948 if (test_opt(opt, DAX_NEVER))955949 seq_puts(seq, ",dax=never");950950+ if (erofs_is_fileio_mode(sbi) && test_opt(opt, DIRECT_IO))951951+ seq_puts(seq, ",directio");956952#ifdef CONFIG_EROFS_FS_ONDEMAND957953 if (sbi->fsid)958954 seq_printf(seq, ",fsid=%s", sbi->fsid);
+2-2
fs/erofs/zdata.c
···17921792 erofs_fscache_submit_bio(bio);17931793 else17941794 submit_bio(bio);17951795- if (memstall)17961796- psi_memstall_leave(&pflags);17971795 }17961796+ if (memstall)17971797+ psi_memstall_leave(&pflags);1798179817991799 /*18001800 * although background is preferred, no one is pending for submission.
+4-3
fs/erofs/zutil.c
···230230 struct erofs_sb_info *const sbi = EROFS_SB(sb);231231232232 mutex_lock(&sbi->umount_mutex);233233- /* clean up all remaining pclusters in memory */234234- z_erofs_shrink_scan(sbi, ~0UL);235235-233233+ while (!xa_empty(&sbi->managed_pslots)) {234234+ z_erofs_shrink_scan(sbi, ~0UL);235235+ cond_resched();236236+ }236237 spin_lock(&erofs_sb_list_lock);237238 list_del(&sbi->list);238239 spin_unlock(&erofs_sb_list_lock);
···971971 start = count = 0;972972 left = le32_to_cpu(alloc->id1.bitmap1.i_total);973973974974- while ((bit_off = ocfs2_find_next_zero_bit(bitmap, left, start)) <975975- left) {976976- if (bit_off == start) {974974+ while (1) {975975+ bit_off = ocfs2_find_next_zero_bit(bitmap, left, start);976976+ if ((bit_off < left) && (bit_off == start)) {977977 count++;978978 start++;979979 continue;···998998 }999999 }1000100010011001+ if (bit_off >= left)10021002+ break;10011003 count = 1;10021004 start = bit_off + 1;10031003- }10041004-10051005- /* clear the contiguous bits until the end boundary */10061006- if (count) {10071007- blkno = la_start_blk +10081008- ocfs2_clusters_to_blocks(osb->sb,10091009- start - count);10101010-10111011- trace_ocfs2_sync_local_to_main_free(10121012- count, start - count,10131013- (unsigned long long)la_start_blk,10141014- (unsigned long long)blkno);10151015-10161016- status = ocfs2_release_clusters(handle,10171017- main_bm_inode,10181018- main_bm_bh, blkno,10191019- count);10201020- if (status < 0)10211021- mlog_errno(status);10221005 }1023100610241007bail:
-1
fs/smb/client/Kconfig
···22config CIFS33 tristate "SMB3 and CIFS support (advanced network filesystem)"44 depends on INET55- select NETFS_SUPPORT65 select NLS76 select NLS_UCS2_UTILS87 select CRYPTO
+1-1
fs/smb/client/cifsfs.c
···398398 cifs_inode = alloc_inode_sb(sb, cifs_inode_cachep, GFP_KERNEL);399399 if (!cifs_inode)400400 return NULL;401401- cifs_inode->cifsAttrs = 0x20; /* default */401401+ cifs_inode->cifsAttrs = ATTR_ARCHIVE; /* default */402402 cifs_inode->time = 0;403403 /*404404 * Until the file is open and we have gotten oplock info back from the
+26-10
fs/smb/client/connect.c
···987987 msleep(125);988988 if (cifs_rdma_enabled(server))989989 smbd_destroy(server);990990+990991 if (server->ssocket) {991992 sock_release(server->ssocket);992993 server->ssocket = NULL;994994+995995+ /* Release netns reference for the socket. */996996+ put_net(cifs_net_ns(server));993997 }994998995999 if (!list_empty(&server->pending_mid_q)) {···10411037 */10421038 }1043103910401040+ /* Release netns reference for this server. */10441041 put_net(cifs_net_ns(server));10451042 kfree(server->leaf_fullpath);10461043 kfree(server);···1718171317191714 tcp_ses->ops = ctx->ops;17201715 tcp_ses->vals = ctx->vals;17161716+17171717+ /* Grab netns reference for this server. */17211718 cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns));1722171917231720 tcp_ses->conn_id = atomic_inc_return(&tcpSesNextId);···18511844out_err_crypto_release:18521845 cifs_crypto_secmech_release(tcp_ses);1853184618471847+ /* Release netns reference for this server. */18541848 put_net(cifs_net_ns(tcp_ses));1855184918561850out_err:···18601852 cifs_put_tcp_session(tcp_ses->primary_server, false);18611853 kfree(tcp_ses->hostname);18621854 kfree(tcp_ses->leaf_fullpath);18631863- if (tcp_ses->ssocket)18551855+ if (tcp_ses->ssocket) {18641856 sock_release(tcp_ses->ssocket);18571857+ put_net(cifs_net_ns(tcp_ses));18581858+ }18651859 kfree(tcp_ses);18661860 }18671861 return ERR_PTR(rc);···31413131 socket = server->ssocket;31423132 } else {31433133 struct net *net = cifs_net_ns(server);31443144- struct sock *sk;3145313431463146- rc = __sock_create(net, sfamily, SOCK_STREAM,31473147- IPPROTO_TCP, &server->ssocket, 1);31353135+ rc = sock_create_kern(net, sfamily, SOCK_STREAM, IPPROTO_TCP, &server->ssocket);31483136 if (rc < 0) {31493137 cifs_server_dbg(VFS, "Error %d creating socket\n", rc);31503138 return rc;31513139 }3152314031533153- sk = server->ssocket->sk;31543154- __netns_tracker_free(net, &sk->ns_tracker, false);31553155- sk->sk_net_refcnt = 1;31563156- get_net_track(net, &sk->ns_tracker, GFP_KERNEL);31573157- sock_inuse_add(net, 1);31413141+ /*31423142+ * Grab netns reference for the socket.31433143+ *31443144+ * It'll be released here, on error, or in clean_demultiplex_info() upon server31453145+ * teardown.31463146+ */31473147+ get_net(net);3158314831593149 /* BB other socket options to set KEEPALIVE, NODELAY? */31603150 cifs_dbg(FYI, "Socket created\n");···31683158 }3169315931703160 rc = bind_socket(server);31713171- if (rc < 0)31613161+ if (rc < 0) {31623162+ put_net(cifs_net_ns(server));31723163 return rc;31643164+ }3173316531743166 /*31753167 * Eventually check for other socket options to change from···32083196 if (rc < 0) {32093197 cifs_dbg(FYI, "Error %d connecting to server\n", rc);32103198 trace_smb3_connect_err(server->hostname, server->conn_id, &server->dstaddr, rc);31993199+ put_net(cifs_net_ns(server));32113200 sock_release(socket);32123201 server->ssocket = NULL;32133202 return rc;···32163203 trace_smb3_connect_done(server->hostname, server->conn_id, &server->dstaddr);32173204 if (sport == htons(RFC1001_PORT))32183205 rc = ip_rfc1001_connect(server);32063206+32073207+ if (rc < 0)32083208+ put_net(cifs_net_ns(server));3219320932203210 return rc;32213211}
···319319 init_smb2_max_write_size(req->smb2_max_write);320320 if (req->smb2_max_trans)321321 init_smb2_max_trans_size(req->smb2_max_trans);322322- if (req->smb2_max_credits)322322+ if (req->smb2_max_credits) {323323 init_smb2_max_credits(req->smb2_max_credits);324324+ server_conf.max_inflight_req =325325+ req->smb2_max_credits;326326+ }324327 if (req->smbd_max_io_size)325328 init_smbd_max_io_size(req->smbd_max_io_size);326329
···216216217217#endif /* __KERNEL__ */218218219219-/*220220- * Force the compiler to emit 'sym' as a symbol, so that we can reference221221- * it from inline assembler. Necessary in case 'sym' could be inlined222222- * otherwise, or eliminated entirely due to lack of references that are223223- * visible to the compiler.224224- */225225-#define ___ADDRESSABLE(sym, __attrs) \226226- static void * __used __attrs \227227- __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym;228228-#define __ADDRESSABLE(sym) \229229- ___ADDRESSABLE(sym, __section(".discard.addressable"))230230-231219/**232220 * offset_to_ptr - convert a relative memory offset to an absolute pointer233221 * @off: the address of the 32-bit offset value···226238}227239228240#endif /* __ASSEMBLY__ */241241+242242+#ifdef CONFIG_64BIT243243+#define ARCH_SEL(a,b) a244244+#else245245+#define ARCH_SEL(a,b) b246246+#endif247247+248248+/*249249+ * Force the compiler to emit 'sym' as a symbol, so that we can reference250250+ * it from inline assembler. Necessary in case 'sym' could be inlined251251+ * otherwise, or eliminated entirely due to lack of references that are252252+ * visible to the compiler.253253+ */254254+#define ___ADDRESSABLE(sym, __attrs) \255255+ static void * __used __attrs \256256+ __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym;257257+258258+#define __ADDRESSABLE(sym) \259259+ ___ADDRESSABLE(sym, __section(".discard.addressable"))260260+261261+#define __ADDRESSABLE_ASM(sym) \262262+ .pushsection .discard.addressable,"aw"; \263263+ .align ARCH_SEL(8,4); \264264+ ARCH_SEL(.quad, .long) __stringify(sym); \265265+ .popsection;266266+267267+#define __ADDRESSABLE_ASM_STR(sym) __stringify(__ADDRESSABLE_ASM(sym))229268230269#ifdef __CHECKER__231270#define __BUILD_BUG_ON_ZERO_MSG(e, msg) (0)
+13-1
include/linux/fortify-string.h
···616616 return false;617617}618618619619+/*620620+ * To work around what seems to be an optimizer bug, the macro arguments621621+ * need to have const copies or the values end up changed by the time they622622+ * reach fortify_warn_once(). See commit 6f7630b1b5bc ("fortify: Capture623623+ * __bos() results in const temp vars") for more details.624624+ */619625#define __fortify_memcpy_chk(p, q, size, p_size, q_size, \620626 p_size_field, q_size_field, op) ({ \621627 const size_t __fortify_size = (size_t)(size); \···629623 const size_t __q_size = (q_size); \630624 const size_t __p_size_field = (p_size_field); \631625 const size_t __q_size_field = (q_size_field); \626626+ /* Keep a mutable version of the size for the final copy. */ \627627+ size_t __copy_size = __fortify_size; \632628 fortify_warn_once(fortify_memcpy_chk(__fortify_size, __p_size, \633629 __q_size, __p_size_field, \634630 __q_size_field, FORTIFY_FUNC_ ##op), \···638630 __fortify_size, \639631 "field \"" #p "\" at " FILE_LINE, \640632 __p_size_field); \641641- __underlying_##op(p, q, __fortify_size); \633633+ /* Hide only the run-time size from value range tracking to */ \634634+ /* silence compile-time false positive bounds warnings. */ \635635+ if (!__builtin_constant_p(__copy_size)) \636636+ OPTIMIZER_HIDE_VAR(__copy_size); \637637+ __underlying_##op(p, q, __copy_size); \642638})643639644640/*
···15591559 void *channel;15601560 void (*util_cb)(void *);15611561 int (*util_init)(struct hv_util_service *);15621562+ int (*util_init_transport)(void);15621563 void (*util_deinit)(void);15631564 int (*util_pre_suspend)(void);15641565 int (*util_pre_resume)(void);
+1-3
include/linux/io_uring.h
···15151616static inline void io_uring_files_cancel(void)1717{1818- if (current->io_uring) {1919- io_uring_unreg_ringfd();1818+ if (current->io_uring)2019 __io_uring_cancel(false);2121- }2220}2321static inline void io_uring_task_cancel(void)2422{
···3131#include <linux/kasan.h>3232#include <linux/memremap.h>3333#include <linux/slab.h>3434+#include <linux/cacheinfo.h>34353536struct mempolicy;3637struct anon_vma;···30113010 lruvec_stat_sub_folio(folio, NR_PAGETABLE);30123011}3013301230143014-pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp);30133013+pte_t *___pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp);30143014+static inline pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr,30153015+ pmd_t *pmdvalp)30163016+{30173017+ pte_t *pte;30183018+30193019+ __cond_lock(RCU, pte = ___pte_offset_map(pmd, addr, pmdvalp));30203020+ return pte;30213021+}30153022static inline pte_t *pte_offset_map(pmd_t *pmd, unsigned long addr)30163023{30173024 return __pte_offset_map(pmd, addr, NULL);···30323023{30333024 pte_t *pte;3034302530353035- __cond_lock(*ptlp, pte = __pte_offset_map_lock(mm, pmd, addr, ptlp));30263026+ __cond_lock(RCU, __cond_lock(*ptlp,30273027+ pte = __pte_offset_map_lock(mm, pmd, addr, ptlp)));30363028 return pte;30373029}30383030···41844174 return 0;41854175}41864176#endif41774177+41784178+/*41794179+ * user_alloc_needs_zeroing checks if a user folio from page allocator needs to41804180+ * be zeroed or not.41814181+ */41824182+static inline bool user_alloc_needs_zeroing(void)41834183+{41844184+ /*41854185+ * for user folios, arch with cache aliasing requires cache flush and41864186+ * arc changes folio->flags to make icache coherent with dcache, so41874187+ * always return false to make caller use41884188+ * clear_user_page()/clear_user_highpage().41894189+ */41904190+ return cpu_dcache_is_aliasing() || cpu_icache_is_aliasing() ||41914191+ !static_branch_maybe(CONFIG_INIT_ON_ALLOC_DEFAULT_ON,41924192+ &init_on_alloc);41934193+}4187419441884195int arch_get_shadow_stack_status(struct task_struct *t, unsigned long __user *status);41894196int arch_set_shadow_stack_status(struct task_struct *t, unsigned long status);
+2-10
include/linux/page-flags.h
···862862 ClearPageHead(page);863863}864864FOLIO_FLAG(large_rmappable, FOLIO_SECOND_PAGE)865865-FOLIO_TEST_FLAG(partially_mapped, FOLIO_SECOND_PAGE)866866-/*867867- * PG_partially_mapped is protected by deferred_split split_queue_lock,868868- * so its safe to use non-atomic set/clear.869869- */870870-__FOLIO_SET_FLAG(partially_mapped, FOLIO_SECOND_PAGE)871871-__FOLIO_CLEAR_FLAG(partially_mapped, FOLIO_SECOND_PAGE)865865+FOLIO_FLAG(partially_mapped, FOLIO_SECOND_PAGE)872866#else873867FOLIO_FLAG_FALSE(large_rmappable)874874-FOLIO_TEST_FLAG_FALSE(partially_mapped)875875-__FOLIO_SET_FLAG_NOOP(partially_mapped)876876-__FOLIO_CLEAR_FLAG_NOOP(partially_mapped)868868+FOLIO_FLAG_FALSE(partially_mapped)877869#endif878870879871#define PG_head_mask ((1UL << PG_head))
···160160161161#ifdef CONFIG_HAVE_STATIC_CALL_INLINE162162163163+extern int static_call_initialized;164164+163165extern int __init static_call_init(void);164166165167extern void static_call_force_reinit(void);···227225228226#elif defined(CONFIG_HAVE_STATIC_CALL)229227228228+#define static_call_initialized 0229229+230230static inline int static_call_init(void) { return 0; }231231232232#define DEFINE_STATIC_CALL(name, _func) \···284280 EXPORT_SYMBOL_GPL(STATIC_CALL_TRAMP(name))285281286282#else /* Generic implementation */283283+284284+#define static_call_initialized 0287285288286static inline int static_call_init(void) { return 0; }289287
+5-1
include/linux/trace_events.h
···273273 const char *name;274274 const int size;275275 const int align;276276- const int is_signed;276276+ const unsigned int is_signed:1;277277+ unsigned int needs_test:1;277278 const int filter_type;278279 const int len;279280 };···325324 TRACE_EVENT_FL_EPROBE_BIT,326325 TRACE_EVENT_FL_FPROBE_BIT,327326 TRACE_EVENT_FL_CUSTOM_BIT,327327+ TRACE_EVENT_FL_TEST_STR_BIT,328328};329329330330/*···342340 * CUSTOM - Event is a custom event (to be attached to an exsiting tracepoint)343341 * This is set when the custom event has not been attached344342 * to a tracepoint yet, then it is cleared when it is.343343+ * TEST_STR - The event has a "%s" that points to a string outside the event345344 */346345enum {347346 TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT),···355352 TRACE_EVENT_FL_EPROBE = (1 << TRACE_EVENT_FL_EPROBE_BIT),356353 TRACE_EVENT_FL_FPROBE = (1 << TRACE_EVENT_FL_FPROBE_BIT),357354 TRACE_EVENT_FL_CUSTOM = (1 << TRACE_EVENT_FL_CUSTOM_BIT),355355+ TRACE_EVENT_FL_TEST_STR = (1 << TRACE_EVENT_FL_TEST_STR_BIT),358356};359357360358#define TRACE_EVENT_FL_UKPROBE (TRACE_EVENT_FL_KPROBE | TRACE_EVENT_FL_UPROBE)
···414414 if (ctx->flags & IORING_SETUP_SINGLE_ISSUER &&415415 current != ctx->submitter_task)416416 return -EEXIST;417417+ /* limited to DEFER_TASKRUN for now */418418+ if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN))419419+ return -EINVAL;417420 if (copy_from_user(&p, arg, sizeof(p)))418421 return -EFAULT;419422 if (p.flags & ~RESIZE_FLAGS)
+20-20
io_uring/timeout.c
···7474 if (!io_timeout_finish(timeout, data)) {7575 if (io_req_post_cqe(req, -ETIME, IORING_CQE_F_MORE)) {7676 /* re-arm timer */7777- spin_lock_irq(&ctx->timeout_lock);7777+ raw_spin_lock_irq(&ctx->timeout_lock);7878 list_add(&timeout->list, ctx->timeout_list.prev);7979 hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), data->mode);8080- spin_unlock_irq(&ctx->timeout_lock);8080+ raw_spin_unlock_irq(&ctx->timeout_lock);8181 return;8282 }8383 }···109109 u32 seq;110110 struct io_timeout *timeout, *tmp;111111112112- spin_lock_irq(&ctx->timeout_lock);112112+ raw_spin_lock_irq(&ctx->timeout_lock);113113 seq = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts);114114115115 list_for_each_entry_safe(timeout, tmp, &ctx->timeout_list, list) {···134134 io_kill_timeout(req, 0);135135 }136136 ctx->cq_last_tm_flush = seq;137137- spin_unlock_irq(&ctx->timeout_lock);137137+ raw_spin_unlock_irq(&ctx->timeout_lock);138138}139139140140static void io_req_tw_fail_links(struct io_kiocb *link, struct io_tw_state *ts)···200200 } else if (req->flags & REQ_F_LINK_TIMEOUT) {201201 struct io_ring_ctx *ctx = req->ctx;202202203203- spin_lock_irq(&ctx->timeout_lock);203203+ raw_spin_lock_irq(&ctx->timeout_lock);204204 link = io_disarm_linked_timeout(req);205205- spin_unlock_irq(&ctx->timeout_lock);205205+ raw_spin_unlock_irq(&ctx->timeout_lock);206206 if (link)207207 io_req_queue_tw_complete(link, -ECANCELED);208208 }···238238 struct io_ring_ctx *ctx = req->ctx;239239 unsigned long flags;240240241241- spin_lock_irqsave(&ctx->timeout_lock, flags);241241+ raw_spin_lock_irqsave(&ctx->timeout_lock, flags);242242 list_del_init(&timeout->list);243243 atomic_set(&req->ctx->cq_timeouts,244244 atomic_read(&req->ctx->cq_timeouts) + 1);245245- spin_unlock_irqrestore(&ctx->timeout_lock, flags);245245+ raw_spin_unlock_irqrestore(&ctx->timeout_lock, flags);246246247247 if (!(data->flags & IORING_TIMEOUT_ETIME_SUCCESS))248248 req_set_fail(req);···285285{286286 struct io_kiocb *req;287287288288- spin_lock_irq(&ctx->timeout_lock);288288+ raw_spin_lock_irq(&ctx->timeout_lock);289289 req = io_timeout_extract(ctx, cd);290290- spin_unlock_irq(&ctx->timeout_lock);290290+ raw_spin_unlock_irq(&ctx->timeout_lock);291291292292 if (IS_ERR(req))293293 return PTR_ERR(req);···330330 struct io_ring_ctx *ctx = req->ctx;331331 unsigned long flags;332332333333- spin_lock_irqsave(&ctx->timeout_lock, flags);333333+ raw_spin_lock_irqsave(&ctx->timeout_lock, flags);334334 prev = timeout->head;335335 timeout->head = NULL;336336···345345 }346346 list_del(&timeout->list);347347 timeout->prev = prev;348348- spin_unlock_irqrestore(&ctx->timeout_lock, flags);348348+ raw_spin_unlock_irqrestore(&ctx->timeout_lock, flags);349349350350 req->io_task_work.func = io_req_task_link_timeout;351351 io_req_task_work_add(req);···472472 } else {473473 enum hrtimer_mode mode = io_translate_timeout_mode(tr->flags);474474475475- spin_lock_irq(&ctx->timeout_lock);475475+ raw_spin_lock_irq(&ctx->timeout_lock);476476 if (tr->ltimeout)477477 ret = io_linked_timeout_update(ctx, tr->addr, &tr->ts, mode);478478 else479479 ret = io_timeout_update(ctx, tr->addr, &tr->ts, mode);480480- spin_unlock_irq(&ctx->timeout_lock);480480+ raw_spin_unlock_irq(&ctx->timeout_lock);481481 }482482483483 if (ret < 0)···572572 struct list_head *entry;573573 u32 tail, off = timeout->off;574574575575- spin_lock_irq(&ctx->timeout_lock);575575+ raw_spin_lock_irq(&ctx->timeout_lock);576576577577 /*578578 * sqe->off holds how many events that need to occur for this···611611 list_add(&timeout->list, entry);612612 data->timer.function = io_timeout_fn;613613 hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), data->mode);614614- spin_unlock_irq(&ctx->timeout_lock);614614+ raw_spin_unlock_irq(&ctx->timeout_lock);615615 return IOU_ISSUE_SKIP_COMPLETE;616616}617617···620620 struct io_timeout *timeout = io_kiocb_to_cmd(req, struct io_timeout);621621 struct io_ring_ctx *ctx = req->ctx;622622623623- spin_lock_irq(&ctx->timeout_lock);623623+ raw_spin_lock_irq(&ctx->timeout_lock);624624 /*625625 * If the back reference is NULL, then our linked request finished626626 * before we got a chance to setup the timer···633633 data->mode);634634 list_add_tail(&timeout->list, &ctx->ltimeout_list);635635 }636636- spin_unlock_irq(&ctx->timeout_lock);636636+ raw_spin_unlock_irq(&ctx->timeout_lock);637637 /* drop submission reference */638638 io_put_req(req);639639}···668668 * timeout_lockfirst to keep locking ordering.669669 */670670 spin_lock(&ctx->completion_lock);671671- spin_lock_irq(&ctx->timeout_lock);671671+ raw_spin_lock_irq(&ctx->timeout_lock);672672 list_for_each_entry_safe(timeout, tmp, &ctx->timeout_list, list) {673673 struct io_kiocb *req = cmd_to_io_kiocb(timeout);674674···676676 io_kill_timeout(req, -ECANCELED))677677 canceled++;678678 }679679- spin_unlock_irq(&ctx->timeout_lock);679679+ raw_spin_unlock_irq(&ctx->timeout_lock);680680 spin_unlock(&ctx->completion_lock);681681 return canceled != 0;682682}
+5-1
kernel/bpf/verifier.c
···2128121281 * changed in some incompatible and hard to support2128221282 * way, it's fine to back out this inlining logic2128321283 */2128421284+#ifdef CONFIG_SMP2128421285 insn_buf[0] = BPF_MOV32_IMM(BPF_REG_0, (u32)(unsigned long)&pcpu_hot.cpu_number);2128521286 insn_buf[1] = BPF_MOV64_PERCPU_REG(BPF_REG_0, BPF_REG_0);2128621287 insn_buf[2] = BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, 0);2128721288 cnt = 3;2128821288-2128921289+#else2129021290+ insn_buf[0] = BPF_ALU32_REG(BPF_XOR, BPF_REG_0, BPF_REG_0);2129121291+ cnt = 1;2129221292+#endif2128921293 new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);2129021294 if (!new_prog)2129121295 return -ENOMEM;
···1515extern struct static_call_tramp_key __start_static_call_tramp_key[],1616 __stop_static_call_tramp_key[];17171818-static int static_call_initialized;1818+int static_call_initialized;19192020/*2121 * Must be called before early_initcall() to be effective.
+7-1
kernel/trace/fgraph.c
···12151215static int start_graph_tracing(void)12161216{12171217 unsigned long **ret_stack_list;12181218- int ret;12181218+ int ret, cpu;1219121912201220 ret_stack_list = kcalloc(FTRACE_RETSTACK_ALLOC_SIZE,12211221 sizeof(*ret_stack_list), GFP_KERNEL);1222122212231223 if (!ret_stack_list)12241224 return -ENOMEM;12251225+12261226+ /* The cpu_boot init_task->ret_stack will never be freed */12271227+ for_each_online_cpu(cpu) {12281228+ if (!idle_task(cpu)->ret_stack)12291229+ ftrace_graph_init_idle_task(idle_task(cpu), cpu);12301230+ }1225123112261232 do {12271233 ret = alloc_retstack_tasklist(ret_stack_list);
···36113611}3612361236133613/* Returns true if the string is safe to dereference from an event */36143614-static bool trace_safe_str(struct trace_iterator *iter, const char *str,36153615- bool star, int len)36143614+static bool trace_safe_str(struct trace_iterator *iter, const char *str)36163615{36173616 unsigned long addr = (unsigned long)str;36183617 struct trace_event *trace_event;36193618 struct trace_event_call *event;36203620-36213621- /* Ignore strings with no length */36223622- if (star && !len)36233623- return true;3624361936253620 /* OK if part of the event data */36263621 if ((addr >= (unsigned long)iter->ent) &&···36563661 return false;36573662}3658366336593659-static DEFINE_STATIC_KEY_FALSE(trace_no_verify);36603660-36613661-static int test_can_verify_check(const char *fmt, ...)36623662-{36633663- char buf[16];36643664- va_list ap;36653665- int ret;36663666-36673667- /*36683668- * The verifier is dependent on vsnprintf() modifies the va_list36693669- * passed to it, where it is sent as a reference. Some architectures36703670- * (like x86_32) passes it by value, which means that vsnprintf()36713671- * does not modify the va_list passed to it, and the verifier36723672- * would then need to be able to understand all the values that36733673- * vsnprintf can use. If it is passed by value, then the verifier36743674- * is disabled.36753675- */36763676- va_start(ap, fmt);36773677- vsnprintf(buf, 16, "%d", ap);36783678- ret = va_arg(ap, int);36793679- va_end(ap);36803680-36813681- return ret;36823682-}36833683-36843684-static void test_can_verify(void)36853685-{36863686- if (!test_can_verify_check("%d %d", 0, 1)) {36873687- pr_info("trace event string verifier disabled\n");36883688- static_branch_inc(&trace_no_verify);36893689- }36903690-}36913691-36923664/**36933693- * trace_check_vprintf - Check dereferenced strings while writing to the seq buffer36653665+ * ignore_event - Check dereferenced fields while writing to the seq buffer36943666 * @iter: The iterator that holds the seq buffer and the event being printed36953695- * @fmt: The format used to print the event36963696- * @ap: The va_list holding the data to print from @fmt.36973667 *36983698- * This writes the data into the @iter->seq buffer using the data from36993699- * @fmt and @ap. If the format has a %s, then the source of the string37003700- * is examined to make sure it is safe to print, otherwise it will37013701- * warn and print "[UNSAFE MEMORY]" in place of the dereferenced string37023702- * pointer.36683668+ * At boot up, test_event_printk() will flag any event that dereferences36693669+ * a string with "%s" that does exist in the ring buffer. It may still36703670+ * be valid, as the string may point to a static string in the kernel36713671+ * rodata that never gets freed. But if the string pointer is pointing36723672+ * to something that was allocated, there's a chance that it can be freed36733673+ * by the time the user reads the trace. This would cause a bad memory36743674+ * access by the kernel and possibly crash the system.36753675+ *36763676+ * This function will check if the event has any fields flagged as needing36773677+ * to be checked at runtime and perform those checks.36783678+ *36793679+ * If it is found that a field is unsafe, it will write into the @iter->seq36803680+ * a message stating what was found to be unsafe.36813681+ *36823682+ * @return: true if the event is unsafe and should be ignored,36833683+ * false otherwise.37033684 */37043704-void trace_check_vprintf(struct trace_iterator *iter, const char *fmt,37053705- va_list ap)36853685+bool ignore_event(struct trace_iterator *iter)37063686{37073707- long text_delta = 0;37083708- long data_delta = 0;37093709- const char *p = fmt;37103710- const char *str;37113711- bool good;37123712- int i, j;36873687+ struct ftrace_event_field *field;36883688+ struct trace_event *trace_event;36893689+ struct trace_event_call *event;36903690+ struct list_head *head;36913691+ struct trace_seq *seq;36923692+ const void *ptr;3713369337143714- if (WARN_ON_ONCE(!fmt))37153715- return;36943694+ trace_event = ftrace_find_event(iter->ent->type);3716369537173717- if (static_branch_unlikely(&trace_no_verify))37183718- goto print;36963696+ seq = &iter->seq;3719369737203720- /*37213721- * When the kernel is booted with the tp_printk command line37223722- * parameter, trace events go directly through to printk().37233723- * It also is checked by this function, but it does not37243724- * have an associated trace_array (tr) for it.37253725- */37263726- if (iter->tr) {37273727- text_delta = iter->tr->text_delta;37283728- data_delta = iter->tr->data_delta;36983698+ if (!trace_event) {36993699+ trace_seq_printf(seq, "EVENT ID %d NOT FOUND?\n", iter->ent->type);37003700+ return true;37293701 }3730370237313731- /* Don't bother checking when doing a ftrace_dump() */37323732- if (iter->fmt == static_fmt_buf)37333733- goto print;37033703+ event = container_of(trace_event, struct trace_event_call, event);37043704+ if (!(event->flags & TRACE_EVENT_FL_TEST_STR))37053705+ return false;3734370637353735- while (*p) {37363736- bool star = false;37373737- int len = 0;37073707+ head = trace_get_fields(event);37083708+ if (!head) {37093709+ trace_seq_printf(seq, "FIELDS FOR EVENT '%s' NOT FOUND?\n",37103710+ trace_event_name(event));37113711+ return true;37123712+ }3738371337393739- j = 0;37143714+ /* Offsets are from the iter->ent that points to the raw event */37153715+ ptr = iter->ent;3740371637413741- /*37423742- * We only care about %s and variants37433743- * as well as %p[sS] if delta is non-zero37443744- */37453745- for (i = 0; p[i]; i++) {37463746- if (i + 1 >= iter->fmt_size) {37473747- /*37483748- * If we can't expand the copy buffer,37493749- * just print it.37503750- */37513751- if (!trace_iter_expand_format(iter))37523752- goto print;37533753- }37173717+ list_for_each_entry(field, head, link) {37183718+ const char *str;37193719+ bool good;3754372037553755- if (p[i] == '\\' && p[i+1]) {37563756- i++;37573757- continue;37583758- }37593759- if (p[i] == '%') {37603760- /* Need to test cases like %08.*s */37613761- for (j = 1; p[i+j]; j++) {37623762- if (isdigit(p[i+j]) ||37633763- p[i+j] == '.')37643764- continue;37653765- if (p[i+j] == '*') {37663766- star = true;37673767- continue;37683768- }37693769- break;37703770- }37713771- if (p[i+j] == 's')37723772- break;37733773-37743774- if (text_delta && p[i+1] == 'p' &&37753775- ((p[i+2] == 's' || p[i+2] == 'S')))37763776- break;37773777-37783778- star = false;37793779- }37803780- j = 0;37813781- }37823782- /* If no %s found then just print normally */37833783- if (!p[i])37843784- break;37853785-37863786- /* Copy up to the %s, and print that */37873787- strncpy(iter->fmt, p, i);37883788- iter->fmt[i] = '\0';37893789- trace_seq_vprintf(&iter->seq, iter->fmt, ap);37903790-37913791- /* Add delta to %pS pointers */37923792- if (p[i+1] == 'p') {37933793- unsigned long addr;37943794- char fmt[4];37953795-37963796- fmt[0] = '%';37973797- fmt[1] = 'p';37983798- fmt[2] = p[i+2]; /* Either %ps or %pS */37993799- fmt[3] = '\0';38003800-38013801- addr = va_arg(ap, unsigned long);38023802- addr += text_delta;38033803- trace_seq_printf(&iter->seq, fmt, (void *)addr);38043804-38053805- p += i + 3;37213721+ if (!field->needs_test)38063722 continue;38073807- }3808372338093809- /*38103810- * If iter->seq is full, the above call no longer guarantees38113811- * that ap is in sync with fmt processing, and further calls38123812- * to va_arg() can return wrong positional arguments.38133813- *38143814- * Ensure that ap is no longer used in this case.38153815- */38163816- if (iter->seq.full) {38173817- p = "";38183818- break;38193819- }37243724+ str = *(const char **)(ptr + field->offset);3820372538213821- if (star)38223822- len = va_arg(ap, int);38233823-38243824- /* The ap now points to the string data of the %s */38253825- str = va_arg(ap, const char *);38263826-38273827- good = trace_safe_str(iter, str, star, len);38283828-38293829- /* Could be from the last boot */38303830- if (data_delta && !good) {38313831- str += data_delta;38323832- good = trace_safe_str(iter, str, star, len);38333833- }37263726+ good = trace_safe_str(iter, str);3834372738353728 /*38363729 * If you hit this warning, it is likely that the···37293846 * instead. See samples/trace_events/trace-events-sample.h37303847 * for reference.37313848 */37323732- if (WARN_ONCE(!good, "fmt: '%s' current_buffer: '%s'",37333733- fmt, seq_buf_str(&iter->seq.seq))) {37343734- int ret;37353735-37363736- /* Try to safely read the string */37373737- if (star) {37383738- if (len + 1 > iter->fmt_size)37393739- len = iter->fmt_size - 1;37403740- if (len < 0)37413741- len = 0;37423742- ret = copy_from_kernel_nofault(iter->fmt, str, len);37433743- iter->fmt[len] = 0;37443744- star = false;37453745- } else {37463746- ret = strncpy_from_kernel_nofault(iter->fmt, str,37473747- iter->fmt_size);37483748- }37493749- if (ret < 0)37503750- trace_seq_printf(&iter->seq, "(0x%px)", str);37513751- else37523752- trace_seq_printf(&iter->seq, "(0x%px:%s)",37533753- str, iter->fmt);37543754- str = "[UNSAFE-MEMORY]";37553755- strcpy(iter->fmt, "%s");37563756- } else {37573757- strncpy(iter->fmt, p + i, j + 1);37583758- iter->fmt[j+1] = '\0';38493849+ if (WARN_ONCE(!good, "event '%s' has unsafe pointer field '%s'",38503850+ trace_event_name(event), field->name)) {38513851+ trace_seq_printf(seq, "EVENT %s: HAS UNSAFE POINTER FIELD '%s'\n",38523852+ trace_event_name(event), field->name);38533853+ return true;37593854 }37603760- if (star)37613761- trace_seq_printf(&iter->seq, iter->fmt, len, str);37623762- else37633763- trace_seq_printf(&iter->seq, iter->fmt, str);37643764-37653765- p += i + j + 1;37663855 }37673767- print:37683768- if (*p)37693769- trace_seq_vprintf(&iter->seq, p, ap);38563856+ return false;37703857}3771385837723859const char *trace_event_format(struct trace_iterator *iter, const char *fmt)···42064353 if (event) {42074354 if (tr->trace_flags & TRACE_ITER_FIELDS)42084355 return print_event_fields(iter, event);43564356+ /*43574357+ * For TRACE_EVENT() events, the print_fmt is not43584358+ * safe to use if the array has delta offsets43594359+ * Force printing via the fields.43604360+ */43614361+ if ((tr->text_delta || tr->data_delta) &&43624362+ event->type > __TRACE_LAST_TYPE)43634363+ return print_event_fields(iter, event);43644364+42094365 return event->funcs->trace(iter, sym_flags, event);42104366 }42114367···1063810776 apply_trace_boot_options();10639107771064010778 register_snapshot_cmd();1064110641-1064210642- test_can_verify();10643107791064410780 return 0;1064510781
+3-3
kernel/trace/trace.h
···667667668668bool trace_is_tracepoint_string(const char *str);669669const char *trace_event_format(struct trace_iterator *iter, const char *fmt);670670-void trace_check_vprintf(struct trace_iterator *iter, const char *fmt,671671- va_list ap) __printf(2, 0);672670char *trace_iter_expand_format(struct trace_iterator *iter);671671+bool ignore_event(struct trace_iterator *iter);673672674673int trace_empty(struct trace_iterator *iter);675674···14121413 int filter_type;14131414 int offset;14141415 int size;14151415- int is_signed;14161416+ unsigned int is_signed:1;14171417+ unsigned int needs_test:1;14161418 int len;14171419};14181420
+177-50
kernel/trace/trace_events.c
···8282 }83838484static struct ftrace_event_field *8585-__find_event_field(struct list_head *head, char *name)8585+__find_event_field(struct list_head *head, const char *name)8686{8787 struct ftrace_event_field *field;8888···114114115115static int __trace_define_field(struct list_head *head, const char *type,116116 const char *name, int offset, int size,117117- int is_signed, int filter_type, int len)117117+ int is_signed, int filter_type, int len,118118+ int need_test)118119{119120 struct ftrace_event_field *field;120121···134133 field->offset = offset;135134 field->size = size;136135 field->is_signed = is_signed;136136+ field->needs_test = need_test;137137 field->len = len;138138139139 list_add(&field->link, head);···153151154152 head = trace_get_fields(call);155153 return __trace_define_field(head, type, name, offset, size,156156- is_signed, filter_type, 0);154154+ is_signed, filter_type, 0, 0);157155}158156EXPORT_SYMBOL_GPL(trace_define_field);159157160158static int trace_define_field_ext(struct trace_event_call *call, const char *type,161159 const char *name, int offset, int size, int is_signed,162162- int filter_type, int len)160160+ int filter_type, int len, int need_test)163161{164162 struct list_head *head;165163···168166169167 head = trace_get_fields(call);170168 return __trace_define_field(head, type, name, offset, size,171171- is_signed, filter_type, len);169169+ is_signed, filter_type, len, need_test);172170}173171174172#define __generic_field(type, item, filter_type) \175173 ret = __trace_define_field(&ftrace_generic_fields, #type, \176174 #item, 0, 0, is_signed_type(type), \177177- filter_type, 0); \175175+ filter_type, 0, 0); \178176 if (ret) \179177 return ret;180178···183181 "common_" #item, \184182 offsetof(typeof(ent), item), \185183 sizeof(ent.item), \186186- is_signed_type(type), FILTER_OTHER, 0); \184184+ is_signed_type(type), FILTER_OTHER, \185185+ 0, 0); \187186 if (ret) \188187 return ret;189188···247244 return tail->offset + tail->size;248245}249246250250-/*251251- * Check if the referenced field is an array and return true,252252- * as arrays are OK to dereference.253253- */254254-static bool test_field(const char *fmt, struct trace_event_call *call)247247+248248+static struct trace_event_fields *find_event_field(const char *fmt,249249+ struct trace_event_call *call)255250{256251 struct trace_event_fields *field = call->class->fields_array;257257- const char *array_descriptor;258252 const char *p = fmt;259253 int len;260254261255 if (!(len = str_has_prefix(fmt, "REC->")))262262- return false;256256+ return NULL;263257 fmt += len;264258 for (p = fmt; *p; p++) {265259 if (!isalnum(*p) && *p != '_')···265265 len = p - fmt;266266267267 for (; field->type; field++) {268268- if (strncmp(field->name, fmt, len) ||269269- field->name[len])268268+ if (strncmp(field->name, fmt, len) || field->name[len])270269 continue;271271- array_descriptor = strchr(field->type, '[');272272- /* This is an array and is OK to dereference. */273273- return array_descriptor != NULL;270270+271271+ return field;272272+ }273273+ return NULL;274274+}275275+276276+/*277277+ * Check if the referenced field is an array and return true,278278+ * as arrays are OK to dereference.279279+ */280280+static bool test_field(const char *fmt, struct trace_event_call *call)281281+{282282+ struct trace_event_fields *field;283283+284284+ field = find_event_field(fmt, call);285285+ if (!field)286286+ return false;287287+288288+ /* This is an array and is OK to dereference. */289289+ return strchr(field->type, '[') != NULL;290290+}291291+292292+/* Look for a string within an argument */293293+static bool find_print_string(const char *arg, const char *str, const char *end)294294+{295295+ const char *r;296296+297297+ r = strstr(arg, str);298298+ return r && r < end;299299+}300300+301301+/* Return true if the argument pointer is safe */302302+static bool process_pointer(const char *fmt, int len, struct trace_event_call *call)303303+{304304+ const char *r, *e, *a;305305+306306+ e = fmt + len;307307+308308+ /* Find the REC-> in the argument */309309+ r = strstr(fmt, "REC->");310310+ if (r && r < e) {311311+ /*312312+ * Addresses of events on the buffer, or an array on the buffer is313313+ * OK to dereference. There's ways to fool this, but314314+ * this is to catch common mistakes, not malicious code.315315+ */316316+ a = strchr(fmt, '&');317317+ if ((a && (a < r)) || test_field(r, call))318318+ return true;319319+ } else if (find_print_string(fmt, "__get_dynamic_array(", e)) {320320+ return true;321321+ } else if (find_print_string(fmt, "__get_rel_dynamic_array(", e)) {322322+ return true;323323+ } else if (find_print_string(fmt, "__get_dynamic_array_len(", e)) {324324+ return true;325325+ } else if (find_print_string(fmt, "__get_rel_dynamic_array_len(", e)) {326326+ return true;327327+ } else if (find_print_string(fmt, "__get_sockaddr(", e)) {328328+ return true;329329+ } else if (find_print_string(fmt, "__get_rel_sockaddr(", e)) {330330+ return true;274331 }275332 return false;333333+}334334+335335+/* Return true if the string is safe */336336+static bool process_string(const char *fmt, int len, struct trace_event_call *call)337337+{338338+ struct trace_event_fields *field;339339+ const char *r, *e, *s;340340+341341+ e = fmt + len;342342+343343+ /*344344+ * There are several helper functions that return strings.345345+ * If the argument contains a function, then assume its field is valid.346346+ * It is considered that the argument has a function if it has:347347+ * alphanumeric or '_' before a parenthesis.348348+ */349349+ s = fmt;350350+ do {351351+ r = strstr(s, "(");352352+ if (!r || r >= e)353353+ break;354354+ for (int i = 1; r - i >= s; i++) {355355+ char ch = *(r - i);356356+ if (isspace(ch))357357+ continue;358358+ if (isalnum(ch) || ch == '_')359359+ return true;360360+ /* Anything else, this isn't a function */361361+ break;362362+ }363363+ /* A function could be wrapped in parethesis, try the next one */364364+ s = r + 1;365365+ } while (s < e);366366+367367+ /*368368+ * If there's any strings in the argument consider this arg OK as it369369+ * could be: REC->field ? "foo" : "bar" and we don't want to get into370370+ * verifying that logic here.371371+ */372372+ if (find_print_string(fmt, "\"", e))373373+ return true;374374+375375+ /* Dereferenced strings are also valid like any other pointer */376376+ if (process_pointer(fmt, len, call))377377+ return true;378378+379379+ /* Make sure the field is found */380380+ field = find_event_field(fmt, call);381381+ if (!field)382382+ return false;383383+384384+ /* Test this field's string before printing the event */385385+ call->flags |= TRACE_EVENT_FL_TEST_STR;386386+ field->needs_test = 1;387387+388388+ return true;276389}277390278391/*···397284static void test_event_printk(struct trace_event_call *call)398285{399286 u64 dereference_flags = 0;287287+ u64 string_flags = 0;400288 bool first = true;401401- const char *fmt, *c, *r, *a;289289+ const char *fmt;402290 int parens = 0;403291 char in_quote = 0;404292 int start_arg = 0;405293 int arg = 0;406406- int i;294294+ int i, e;407295408296 fmt = call->print_fmt;409297···488374 star = true;489375 continue;490376 }491491- if ((fmt[i + j] == 's') && star)492492- arg++;377377+ if ((fmt[i + j] == 's')) {378378+ if (star)379379+ arg++;380380+ if (WARN_ONCE(arg == 63,381381+ "Too many args for event: %s",382382+ trace_event_name(call)))383383+ return;384384+ dereference_flags |= 1ULL << arg;385385+ string_flags |= 1ULL << arg;386386+ }493387 break;494388 }495389 break;···525403 case ',':526404 if (in_quote || parens)527405 continue;406406+ e = i;528407 i++;529408 while (isspace(fmt[i]))530409 i++;531531- start_arg = i;532532- if (!(dereference_flags & (1ULL << arg)))533533- goto next_arg;534410535535- /* Find the REC-> in the argument */536536- c = strchr(fmt + i, ',');537537- r = strstr(fmt + i, "REC->");538538- if (r && (!c || r < c)) {539539- /*540540- * Addresses of events on the buffer,541541- * or an array on the buffer is542542- * OK to dereference.543543- * There's ways to fool this, but544544- * this is to catch common mistakes,545545- * not malicious code.546546- */547547- a = strchr(fmt + i, '&');548548- if ((a && (a < r)) || test_field(r, call))549549- dereference_flags &= ~(1ULL << arg);550550- } else if ((r = strstr(fmt + i, "__get_dynamic_array(")) &&551551- (!c || r < c)) {552552- dereference_flags &= ~(1ULL << arg);553553- } else if ((r = strstr(fmt + i, "__get_sockaddr(")) &&554554- (!c || r < c)) {555555- dereference_flags &= ~(1ULL << arg);411411+ /*412412+ * If start_arg is zero, then this is the start of the413413+ * first argument. The processing of the argument happens414414+ * when the end of the argument is found, as it needs to415415+ * handle paranthesis and such.416416+ */417417+ if (!start_arg) {418418+ start_arg = i;419419+ /* Balance out the i++ in the for loop */420420+ i--;421421+ continue;556422 }557423558558- next_arg:559559- i--;424424+ if (dereference_flags & (1ULL << arg)) {425425+ if (string_flags & (1ULL << arg)) {426426+ if (process_string(fmt + start_arg, e - start_arg, call))427427+ dereference_flags &= ~(1ULL << arg);428428+ } else if (process_pointer(fmt + start_arg, e - start_arg, call))429429+ dereference_flags &= ~(1ULL << arg);430430+ }431431+432432+ start_arg = i;560433 arg++;434434+ /* Balance out the i++ in the for loop */435435+ i--;561436 }437437+ }438438+439439+ if (dereference_flags & (1ULL << arg)) {440440+ if (string_flags & (1ULL << arg)) {441441+ if (process_string(fmt + start_arg, i - start_arg, call))442442+ dereference_flags &= ~(1ULL << arg);443443+ } else if (process_pointer(fmt + start_arg, i - start_arg, call))444444+ dereference_flags &= ~(1ULL << arg);562445 }563446564447 /*···25982471 ret = trace_define_field_ext(call, field->type, field->name,25992472 offset, field->size,26002473 field->is_signed, field->filter_type,26012601- field->len);24742474+ field->len, field->needs_test);26022475 if (WARN_ON_ONCE(ret)) {26032476 pr_err("error code is %d\n", ret);26042477 break;
+2-1
kernel/trace/trace_functions.c
···176176 tracing_reset_online_cpus(&tr->array_buffer);177177}178178179179-#ifdef CONFIG_FUNCTION_GRAPH_TRACER179179+/* fregs are guaranteed not to be NULL if HAVE_DYNAMIC_FTRACE_WITH_ARGS is set */180180+#if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS)180181static __always_inline unsigned long181182function_get_true_parent_ip(unsigned long parent_ip, struct ftrace_regs *fregs)182183{
···209209 return;210210 }211211212212+ /*213213+ * Clear tag references to avoid debug warning when using214214+ * __alloc_tag_ref_set() with non-empty reference.215215+ */216216+ set_codetag_empty(&ref_old);217217+ set_codetag_empty(&ref_new);218218+212219 /* swap tags */213220 __alloc_tag_ref_set(&ref_old, tag_new);214221 update_page_tag_ref(handle_old, &ref_old);···408401409402static int vm_module_tags_populate(void)410403{411411- unsigned long phys_size = vm_module_tags->nr_pages << PAGE_SHIFT;404404+ unsigned long phys_end = ALIGN_DOWN(module_tags.start_addr, PAGE_SIZE) +405405+ (vm_module_tags->nr_pages << PAGE_SHIFT);406406+ unsigned long new_end = module_tags.start_addr + module_tags.size;412407413413- if (phys_size < module_tags.size) {408408+ if (phys_end < new_end) {414409 struct page **next_page = vm_module_tags->pages + vm_module_tags->nr_pages;415415- unsigned long addr = module_tags.start_addr + phys_size;410410+ unsigned long old_shadow_end = ALIGN(phys_end, MODULE_ALIGN);411411+ unsigned long new_shadow_end = ALIGN(new_end, MODULE_ALIGN);416412 unsigned long more_pages;417413 unsigned long nr;418414419419- more_pages = ALIGN(module_tags.size - phys_size, PAGE_SIZE) >> PAGE_SHIFT;415415+ more_pages = ALIGN(new_end - phys_end, PAGE_SIZE) >> PAGE_SHIFT;420416 nr = alloc_pages_bulk_array_node(GFP_KERNEL | __GFP_NOWARN,421417 NUMA_NO_NODE, more_pages, next_page);422418 if (nr < more_pages ||423423- vmap_pages_range(addr, addr + (nr << PAGE_SHIFT), PAGE_KERNEL,419419+ vmap_pages_range(phys_end, phys_end + (nr << PAGE_SHIFT), PAGE_KERNEL,424420 next_page, PAGE_SHIFT) < 0) {425421 /* Clean up and error out */426422 for (int i = 0; i < nr; i++)427423 __free_page(next_page[i]);428424 return -ENOMEM;429425 }426426+430427 vm_module_tags->nr_pages += nr;428428+429429+ /*430430+ * Kasan allocates 1 byte of shadow for every 8 bytes of data.431431+ * When kasan_alloc_module_shadow allocates shadow memory,432432+ * its unit of allocation is a page.433433+ * Therefore, here we need to align to MODULE_ALIGN.434434+ */435435+ if (old_shadow_end < new_shadow_end)436436+ kasan_alloc_module_shadow((void *)old_shadow_end,437437+ new_shadow_end - old_shadow_end,438438+ GFP_KERNEL);431439 }440440+441441+ /*442442+ * Mark the pages as accessible, now that they are mapped.443443+ * With hardware tag-based KASAN, marking is skipped for444444+ * non-VM_ALLOC mappings, see __kasan_unpoison_vmalloc().445445+ */446446+ kasan_unpoison_vmalloc((void *)module_tags.start_addr,447447+ new_end - module_tags.start_addr,448448+ KASAN_VMALLOC_PROT_NORMAL);432449433450 return 0;434451}
+10-9
mm/huge_memory.c
···11761176 folio_throttle_swaprate(folio, gfp);1177117711781178 /*11791179- * When a folio is not zeroed during allocation (__GFP_ZERO not used),11801180- * folio_zero_user() is used to make sure that the page corresponding11811181- * to the faulting address will be hot in the cache after zeroing.11791179+ * When a folio is not zeroed during allocation (__GFP_ZERO not used)11801180+ * or user folios require special handling, folio_zero_user() is used to11811181+ * make sure that the page corresponding to the faulting address will be11821182+ * hot in the cache after zeroing.11821183 */11831183- if (!alloc_zeroed())11841184+ if (user_alloc_needs_zeroing())11841185 folio_zero_user(folio, addr);11851186 /*11861187 * The memory barrier inside __folio_mark_uptodate makes sure that···35773576 !list_empty(&folio->_deferred_list)) {35783577 ds_queue->split_queue_len--;35793578 if (folio_test_partially_mapped(folio)) {35803580- __folio_clear_partially_mapped(folio);35793579+ folio_clear_partially_mapped(folio);35813580 mod_mthp_stat(folio_order(folio),35823581 MTHP_STAT_NR_ANON_PARTIALLY_MAPPED, -1);35833582 }···36893688 if (!list_empty(&folio->_deferred_list)) {36903689 ds_queue->split_queue_len--;36913690 if (folio_test_partially_mapped(folio)) {36923692- __folio_clear_partially_mapped(folio);36913691+ folio_clear_partially_mapped(folio);36933692 mod_mthp_stat(folio_order(folio),36943693 MTHP_STAT_NR_ANON_PARTIALLY_MAPPED, -1);36953694 }···37333732 spin_lock_irqsave(&ds_queue->split_queue_lock, flags);37343733 if (partially_mapped) {37353734 if (!folio_test_partially_mapped(folio)) {37363736- __folio_set_partially_mapped(folio);37353735+ folio_set_partially_mapped(folio);37373736 if (folio_test_pmd_mappable(folio))37383737 count_vm_event(THP_DEFERRED_SPLIT_PAGE);37393738 count_mthp_stat(folio_order(folio), MTHP_STAT_SPLIT_DEFERRED);···38263825 } else {38273826 /* We lost race with folio_put() */38283827 if (folio_test_partially_mapped(folio)) {38293829- __folio_clear_partially_mapped(folio);38283828+ folio_clear_partially_mapped(folio);38303829 mod_mthp_stat(folio_order(folio),38313830 MTHP_STAT_NR_ANON_PARTIALLY_MAPPED, -1);38323831 }···41694168 size_t input_len = strlen(input_buf);4170416941714170 tok = strsep(&buf, ",");41724172- if (tok) {41714171+ if (tok && buf) {41734172 strscpy(file_path, tok);41744173 } else {41754174 ret = -EINVAL;
+2-3
mm/hugetlb.c
···53405340 break;53415341 }53425342 ret = copy_user_large_folio(new_folio, pte_folio,53435343- ALIGN_DOWN(addr, sz), dst_vma);53435343+ addr, dst_vma);53445344 folio_put(pte_folio);53455345 if (ret) {53465346 folio_put(new_folio);···66436643 *foliop = NULL;66446644 goto out;66456645 }66466646- ret = copy_user_large_folio(folio, *foliop,66476647- ALIGN_DOWN(dst_addr, size), dst_vma);66466646+ ret = copy_user_large_folio(folio, *foliop, dst_addr, dst_vma);66486647 folio_put(*foliop);66496648 *foliop = NULL;66506649 if (ret) {
-6
mm/internal.h
···12851285void touch_pmd(struct vm_area_struct *vma, unsigned long addr,12861286 pmd_t *pmd, bool write);1287128712881288-static inline bool alloc_zeroed(void)12891289-{12901290- return static_branch_maybe(CONFIG_INIT_ON_ALLOC_DEFAULT_ON,12911291- &init_on_alloc);12921292-}12931293-12941288/*12951289 * Parses a string with mem suffixes into its order. Useful to parse kernel12961290 * parameters.
+10-8
mm/memory.c
···47334733 folio_throttle_swaprate(folio, gfp);47344734 /*47354735 * When a folio is not zeroed during allocation47364736- * (__GFP_ZERO not used), folio_zero_user() is used47374737- * to make sure that the page corresponding to the47384738- * faulting address will be hot in the cache after47394739- * zeroing.47364736+ * (__GFP_ZERO not used) or user folios require special47374737+ * handling, folio_zero_user() is used to make sure47384738+ * that the page corresponding to the faulting address47394739+ * will be hot in the cache after zeroing.47404740 */47414741- if (!alloc_zeroed())47414741+ if (user_alloc_needs_zeroing())47424742 folio_zero_user(folio, vmf->address);47434743 return folio;47444744 }···68156815 return 0;68166816}6817681768186818-static void clear_gigantic_page(struct folio *folio, unsigned long addr,68186818+static void clear_gigantic_page(struct folio *folio, unsigned long addr_hint,68196819 unsigned int nr_pages)68206820{68216821+ unsigned long addr = ALIGN_DOWN(addr_hint, folio_size(folio));68216822 int i;6822682368236824 might_sleep();···68526851}6853685268546853static int copy_user_gigantic_page(struct folio *dst, struct folio *src,68556855- unsigned long addr,68546854+ unsigned long addr_hint,68566855 struct vm_area_struct *vma,68576856 unsigned int nr_pages)68586857{68596859- int i;68586858+ unsigned long addr = ALIGN_DOWN(addr_hint, folio_size(dst));68606859 struct page *dst_page;68616860 struct page *src_page;68616861+ int i;6862686268636863 for (i = 0; i < nr_pages; i++) {68646864 dst_page = folio_page(dst, i);
+4-2
mm/page_alloc.c
···12381238 if (order > pageblock_order)12391239 order = pageblock_order;1240124012411241- while (pfn != end) {12411241+ do {12421242 int mt = get_pfnblock_migratetype(page, pfn);1243124312441244 __free_one_page(page, pfn, zone, order, mt, fpi);12451245 pfn += 1 << order;12461246+ if (pfn == end)12471247+ break;12461248 page = pfn_to_page(pfn);12471247- }12491249+ } while (1);12481250}1249125112501252static void free_one_page(struct zone *zone, struct page *page,
+1-1
mm/pgtable-generic.c
···279279static void pmdp_get_lockless_end(unsigned long irqflags) { }280280#endif281281282282-pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp)282282+pte_t *___pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp)283283{284284 unsigned long irqflags;285285 pmd_t pmdval;
···2460246024612461 /* If flags changed, we might be able to merge, so try again. */24622462 if (map.retry_merge) {24632463+ struct vm_area_struct *merged;24632464 VMG_MMAP_STATE(vmg, &map, vma);2464246524652466 vma_iter_config(map.vmi, map.addr, map.end);24662466- vma_merge_existing_range(&vmg);24672467+ merged = vma_merge_existing_range(&vmg);24682468+ if (merged)24692469+ vma = merged;24672470 }2468247124692472 __mmap_complete(&map, vma);
+4-2
mm/vmalloc.c
···33743374 struct page *page = vm->pages[i];3375337533763376 BUG_ON(!page);33773377- mod_memcg_page_state(page, MEMCG_VMALLOC, -1);33773377+ if (!(vm->flags & VM_MAP_PUT_PAGES))33783378+ mod_memcg_page_state(page, MEMCG_VMALLOC, -1);33783379 /*33793380 * High-order allocs for huge vmallocs are split, so33803381 * can be freed as an array of order-0 allocations···33833382 __free_page(page);33843383 cond_resched();33853384 }33863386- atomic_long_sub(vm->nr_pages, &nr_vmalloc_pages);33853385+ if (!(vm->flags & VM_MAP_PUT_PAGES))33863386+ atomic_long_sub(vm->nr_pages, &nr_vmalloc_pages);33873387 kvfree(vm->pages);33883388 kfree(vm);33893389}
···3734373437353735static u32 __bpf_skb_min_len(const struct sk_buff *skb)37363736{37373737- u32 min_len = skb_network_offset(skb);37373737+ int offset = skb_network_offset(skb);37383738+ u32 min_len = 0;3738373937393739- if (skb_transport_header_was_set(skb))37403740- min_len = skb_transport_offset(skb);37413741- if (skb->ip_summed == CHECKSUM_PARTIAL)37423742- min_len = skb_checksum_start_offset(skb) +37433743- skb->csum_offset + sizeof(__sum16);37403740+ if (offset > 0)37413741+ min_len = offset;37423742+ if (skb_transport_header_was_set(skb)) {37433743+ offset = skb_transport_offset(skb);37443744+ if (offset > 0)37453745+ min_len = offset;37463746+ }37473747+ if (skb->ip_summed == CHECKSUM_PARTIAL) {37483748+ offset = skb_checksum_start_offset(skb) +37493749+ skb->csum_offset + sizeof(__sum16);37503750+ if (offset > 0)37513751+ min_len = offset;37523752+ }37443753 return min_len;37453754}37463755
+8-11
net/core/netdev-genl.c
···430430netdev_nl_queue_fill(struct sk_buff *rsp, struct net_device *netdev, u32 q_idx,431431 u32 q_type, const struct genl_info *info)432432{433433- int err = 0;433433+ int err;434434435435 if (!(netdev->flags & IFF_UP))436436- return err;436436+ return -ENOENT;437437438438 err = netdev_nl_queue_validate(netdev, q_idx, q_type);439439 if (err)···488488 struct netdev_nl_dump_ctx *ctx)489489{490490 int err = 0;491491- int i;492491493492 if (!(netdev->flags & IFF_UP))494493 return err;495494496496- for (i = ctx->rxq_idx; i < netdev->real_num_rx_queues;) {497497- err = netdev_nl_queue_fill_one(rsp, netdev, i,495495+ for (; ctx->rxq_idx < netdev->real_num_rx_queues; ctx->rxq_idx++) {496496+ err = netdev_nl_queue_fill_one(rsp, netdev, ctx->rxq_idx,498497 NETDEV_QUEUE_TYPE_RX, info);499498 if (err)500499 return err;501501- ctx->rxq_idx = i++;502500 }503503- for (i = ctx->txq_idx; i < netdev->real_num_tx_queues;) {504504- err = netdev_nl_queue_fill_one(rsp, netdev, i,501501+ for (; ctx->txq_idx < netdev->real_num_tx_queues; ctx->txq_idx++) {502502+ err = netdev_nl_queue_fill_one(rsp, netdev, ctx->txq_idx,505503 NETDEV_QUEUE_TYPE_TX, info);506504 if (err)507505 return err;508508- ctx->txq_idx = i++;509506 }510507511508 return err;···668671 i, info);669672 if (err)670673 return err;671671- ctx->rxq_idx = i++;674674+ ctx->rxq_idx = ++i;672675 }673676 i = ctx->txq_idx;674677 while (ops->get_queue_stats_tx && i < netdev->real_num_tx_queues) {···676679 i, info);677680 if (err)678681 return err;679679- ctx->txq_idx = i++;682682+ ctx->txq_idx = ++i;680683 }681684682685 ctx->rxq_idx = 0;
+3-2
net/core/rtnetlink.c
···38193819}3820382038213821static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,38223822+ struct nlattr *tbp[],38223823 struct nlattr *data[],38233824 struct netlink_ext_ack *extack)38243825{···38273826 int err;3828382738293828 if (!data || !data[ops->peer_type])38303830- return NULL;38293829+ return rtnl_link_get_net_ifla(tbp);3831383038323831 err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);38333832 if (err < 0)···39723971 }3973397239743973 if (ops->peer_type) {39753975- peer_net = rtnl_get_peer_net(ops, data, extack);39743974+ peer_net = rtnl_get_peer_net(ops, tb, data, extack);39763975 if (IS_ERR(peer_net)) {39773976 ret = PTR_ERR(peer_net);39783977 goto put_ops;
+8-3
net/core/skmsg.c
···369369 struct sk_msg *msg, u32 bytes)370370{371371 int ret = -ENOSPC, i = msg->sg.curr;372372+ u32 copy, buf_size, copied = 0;372373 struct scatterlist *sge;373373- u32 copy, buf_size;374374 void *to;375375376376 do {···397397 goto out;398398 }399399 bytes -= copy;400400+ copied += copy;400401 if (!bytes)401402 break;402403 msg->sg.copybreak = 0;···405404 } while (i != msg->sg.end);406405out:407406 msg->sg.curr = i;408408- return ret;407407+ return (ret < 0) ? ret : copied;409408}410409EXPORT_SYMBOL_GPL(sk_msg_memcopy_from_iter);411410···446445 if (likely(!peek)) {447446 sge->offset += copy;448447 sge->length -= copy;449449- if (!msg_rx->skb)448448+ if (!msg_rx->skb) {450449 sk_mem_uncharge(sk, copy);450450+ atomic_sub(copy, &sk->sk_rmem_alloc);451451+ }451452 msg_rx->sg.size -= copy;452453453454 if (!sge->length) {···775772776773 list_for_each_entry_safe(msg, tmp, &psock->ingress_msg, list) {777774 list_del(&msg->list);775775+ if (!msg->skb)776776+ atomic_sub(msg->sg.size, &psock->sk->sk_rmem_alloc);778777 sk_msg_free(psock->sk, msg);779778 kfree(msg);780779 }
+11-5
net/dsa/tag.h
···138138 * dsa_software_vlan_untag: Software VLAN untagging in DSA receive path139139 * @skb: Pointer to socket buffer (packet)140140 *141141- * Receive path method for switches which cannot avoid tagging all packets142142- * towards the CPU port. Called when ds->untag_bridge_pvid (legacy) or143143- * ds->untag_vlan_aware_bridge_pvid is set to true.141141+ * Receive path method for switches which send some packets as VLAN-tagged142142+ * towards the CPU port (generally from VLAN-aware bridge ports) even when the143143+ * packet was not tagged on the wire. Called when ds->untag_bridge_pvid144144+ * (legacy) or ds->untag_vlan_aware_bridge_pvid is set to true.144145 *145146 * As a side effect of this method, any VLAN tag from the skb head is moved146147 * to hwaccel.···150149{151150 struct dsa_port *dp = dsa_user_to_port(skb->dev);152151 struct net_device *br = dsa_port_bridge_dev_get(dp);153153- u16 vid;152152+ u16 vid, proto;153153+ int err;154154155155 /* software untagging for standalone ports not yet necessary */156156 if (!br)157157 return skb;158158159159+ err = br_vlan_get_proto(br, &proto);160160+ if (err)161161+ return skb;162162+159163 /* Move VLAN tag from data to hwaccel */160160- if (!skb_vlan_tag_present(skb)) {164164+ if (!skb_vlan_tag_present(skb) && skb->protocol == htons(proto)) {161165 skb = skb_vlan_untag(skb);162166 if (!skb)163167 return NULL;
+8-6
net/ipv4/tcp_bpf.c
···4949 sge = sk_msg_elem(msg, i);5050 size = (apply && apply_bytes < sge->length) ?5151 apply_bytes : sge->length;5252- if (!sk_wmem_schedule(sk, size)) {5252+ if (!__sk_rmem_schedule(sk, size, false)) {5353 if (!copied)5454 ret = -ENOMEM;5555 break;5656 }57575858 sk_mem_charge(sk, size);5959+ atomic_add(size, &sk->sk_rmem_alloc);5960 sk_msg_xfer(tmp, msg, i, size);6061 copied += size;6162 if (sge->length)···75747675 if (!ret) {7776 msg->sg.start = i;7878- sk_psock_queue_msg(psock, tmp);7777+ if (!sk_psock_queue_msg(psock, tmp))7878+ atomic_sub(copied, &sk->sk_rmem_alloc);7979 sk_psock_data_ready(sk, psock);8080 } else {8181 sk_msg_free(sk, tmp);···495493static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)496494{497495 struct sk_msg tmp, *msg_tx = NULL;498498- int copied = 0, err = 0;496496+ int copied = 0, err = 0, ret = 0;499497 struct sk_psock *psock;500498 long timeo;501499 int flags;···538536 copy = msg_tx->sg.size - osize;539537 }540538541541- err = sk_msg_memcopy_from_iter(sk, &msg->msg_iter, msg_tx,539539+ ret = sk_msg_memcopy_from_iter(sk, &msg->msg_iter, msg_tx,542540 copy);543543- if (err < 0) {541541+ if (ret < 0) {544542 sk_msg_trim(sk, msg_tx, osize);545543 goto out_err;546544 }547545548548- copied += copy;546546+ copied += ret;549547 if (psock->cork_bytes) {550548 if (size > psock->cork_bytes)551549 psock->cork_bytes = 0;
+26-10
net/mctp/route.c
···374374 msk = NULL;375375 rc = -EINVAL;376376377377- /* we may be receiving a locally-routed packet; drop source sk378378- * accounting377377+ /* We may be receiving a locally-routed packet; drop source sk378378+ * accounting.379379+ *380380+ * From here, we will either queue the skb - either to a frag_queue, or381381+ * to a receiving socket. When that succeeds, we clear the skb pointer;382382+ * a non-NULL skb on exit will be otherwise unowned, and hence383383+ * kfree_skb()-ed.379384 */380385 skb_orphan(skb);381386···439434 * pending key.440435 */441436 if (flags & MCTP_HDR_FLAG_EOM) {442442- sock_queue_rcv_skb(&msk->sk, skb);437437+ rc = sock_queue_rcv_skb(&msk->sk, skb);438438+ if (!rc)439439+ skb = NULL;443440 if (key) {444441 /* we've hit a pending reassembly; not much we445442 * can do but drop it···450443 MCTP_TRACE_KEY_REPLIED);451444 key = NULL;452445 }453453- rc = 0;454446 goto out_unlock;455447 }456448···476470 * this function.477471 */478472 rc = mctp_key_add(key, msk);479479- if (!rc)473473+ if (!rc) {480474 trace_mctp_key_acquire(key);475475+ skb = NULL;476476+ }481477482478 /* we don't need to release key->lock on exit, so483479 * clean up here and suppress the unlock via···497489 key = NULL;498490 } else {499491 rc = mctp_frag_queue(key, skb);492492+ if (!rc)493493+ skb = NULL;500494 }501495 }502496···513503 else514504 rc = mctp_frag_queue(key, skb);515505506506+ if (rc)507507+ goto out_unlock;508508+509509+ /* we've queued; the queue owns the skb now */510510+ skb = NULL;511511+516512 /* end of message? deliver to socket, and we're done with517513 * the reassembly/response key518514 */519519- if (!rc && flags & MCTP_HDR_FLAG_EOM) {520520- sock_queue_rcv_skb(key->sk, key->reasm_head);521521- key->reasm_head = NULL;515515+ if (flags & MCTP_HDR_FLAG_EOM) {516516+ rc = sock_queue_rcv_skb(key->sk, key->reasm_head);517517+ if (!rc)518518+ key->reasm_head = NULL;522519 __mctp_key_done_in(key, net, f, MCTP_TRACE_KEY_REPLIED);523520 key = NULL;524521 }···544527 if (any_key)545528 mctp_key_unref(any_key);546529out:547547- if (rc)548548- kfree_skb(skb);530530+ kfree_skb(skb);549531 return rc;550532}551533
+86
net/mctp/test/route-test.c
···837837 mctp_test_route_input_multiple_nets_key_fini(test, &t2);838838}839839840840+/* Input route to socket, using a single-packet message, where sock delivery841841+ * fails. Ensure we're handling the failure appropriately.842842+ */843843+static void mctp_test_route_input_sk_fail_single(struct kunit *test)844844+{845845+ const struct mctp_hdr hdr = RX_HDR(1, 10, 8, FL_S | FL_E | FL_TO);846846+ struct mctp_test_route *rt;847847+ struct mctp_test_dev *dev;848848+ struct socket *sock;849849+ struct sk_buff *skb;850850+ int rc;851851+852852+ __mctp_route_test_init(test, &dev, &rt, &sock, MCTP_NET_ANY);853853+854854+ /* No rcvbuf space, so delivery should fail. __sock_set_rcvbuf will855855+ * clamp the minimum to SOCK_MIN_RCVBUF, so we open-code this.856856+ */857857+ lock_sock(sock->sk);858858+ WRITE_ONCE(sock->sk->sk_rcvbuf, 0);859859+ release_sock(sock->sk);860860+861861+ skb = mctp_test_create_skb(&hdr, 10);862862+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, skb);863863+ skb_get(skb);864864+865865+ mctp_test_skb_set_dev(skb, dev);866866+867867+ /* do route input, which should fail */868868+ rc = mctp_route_input(&rt->rt, skb);869869+ KUNIT_EXPECT_NE(test, rc, 0);870870+871871+ /* we should hold the only reference to skb */872872+ KUNIT_EXPECT_EQ(test, refcount_read(&skb->users), 1);873873+ kfree_skb(skb);874874+875875+ __mctp_route_test_fini(test, dev, rt, sock);876876+}877877+878878+/* Input route to socket, using a fragmented message, where sock delivery fails.879879+ */880880+static void mctp_test_route_input_sk_fail_frag(struct kunit *test)881881+{882882+ const struct mctp_hdr hdrs[2] = { RX_FRAG(FL_S, 0), RX_FRAG(FL_E, 1) };883883+ struct mctp_test_route *rt;884884+ struct mctp_test_dev *dev;885885+ struct sk_buff *skbs[2];886886+ struct socket *sock;887887+ unsigned int i;888888+ int rc;889889+890890+ __mctp_route_test_init(test, &dev, &rt, &sock, MCTP_NET_ANY);891891+892892+ lock_sock(sock->sk);893893+ WRITE_ONCE(sock->sk->sk_rcvbuf, 0);894894+ release_sock(sock->sk);895895+896896+ for (i = 0; i < ARRAY_SIZE(skbs); i++) {897897+ skbs[i] = mctp_test_create_skb(&hdrs[i], 10);898898+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, skbs[i]);899899+ skb_get(skbs[i]);900900+901901+ mctp_test_skb_set_dev(skbs[i], dev);902902+ }903903+904904+ /* first route input should succeed, we're only queueing to the905905+ * frag list906906+ */907907+ rc = mctp_route_input(&rt->rt, skbs[0]);908908+ KUNIT_EXPECT_EQ(test, rc, 0);909909+910910+ /* final route input should fail to deliver to the socket */911911+ rc = mctp_route_input(&rt->rt, skbs[1]);912912+ KUNIT_EXPECT_NE(test, rc, 0);913913+914914+ /* we should hold the only reference to both skbs */915915+ KUNIT_EXPECT_EQ(test, refcount_read(&skbs[0]->users), 1);916916+ kfree_skb(skbs[0]);917917+918918+ KUNIT_EXPECT_EQ(test, refcount_read(&skbs[1]->users), 1);919919+ kfree_skb(skbs[1]);920920+921921+ __mctp_route_test_fini(test, dev, rt, sock);922922+}923923+840924#if IS_ENABLED(CONFIG_MCTP_FLOWS)841925842926static void mctp_test_flow_init(struct kunit *test,···11371053 mctp_route_input_sk_reasm_gen_params),11381054 KUNIT_CASE_PARAM(mctp_test_route_input_sk_keys,11391055 mctp_route_input_sk_keys_gen_params),10561056+ KUNIT_CASE(mctp_test_route_input_sk_fail_single),10571057+ KUNIT_CASE(mctp_test_route_input_sk_fail_frag),11401058 KUNIT_CASE(mctp_test_route_input_multiple_nets_bind),11411059 KUNIT_CASE(mctp_test_route_input_multiple_nets_key),11421060 KUNIT_CASE(mctp_test_packet_flow),
···155155/* A list of all modules we processed */156156LIST_HEAD(modules);157157158158-static struct module *find_module(const char *modname)158158+static struct module *find_module(const char *filename, const char *modname)159159{160160 struct module *mod;161161162162 list_for_each_entry(mod, &modules, list) {163163- if (strcmp(mod->name, modname) == 0)163163+ if (!strcmp(mod->dump_file, filename) &&164164+ !strcmp(mod->name, modname))164165 return mod;165166 }166167 return NULL;···20312030 continue;20322031 }2033203220342034- mod = find_module(modname);20332033+ mod = find_module(fname, modname);20352034 if (!mod) {20362035 mod = new_module(modname, strlen(modname));20372037- mod->from_dump = true;20362036+ mod->dump_file = fname;20382037 }20392038 s = sym_add_exported(symname, mod, gpl_only, namespace);20402039 sym_set_crc(s, crc);···20532052 struct symbol *sym;2054205320552054 list_for_each_entry(mod, &modules, list) {20562056- if (mod->from_dump)20552055+ if (mod->dump_file)20572056 continue;20582057 list_for_each_entry(sym, &mod->exported_symbols, list) {20592058 if (trim_unused_exports && !sym->used)···2077207620782077 list_for_each_entry(mod, &modules, list) {2079207820802080- if (mod->from_dump || list_empty(&mod->missing_namespaces))20792079+ if (mod->dump_file || list_empty(&mod->missing_namespaces))20812080 continue;2082208120832082 buf_printf(&ns_deps_buf, "%s.ko:", mod->name);···21952194 read_symbols_from_files(files_source);2196219521972196 list_for_each_entry(mod, &modules, list) {21982198- if (mod->from_dump || mod->is_vmlinux)21972197+ if (mod->dump_file || mod->is_vmlinux)21992198 continue;2200219922012200 check_modname_len(mod);···22062205 handle_white_list_exports(unused_exports_white_list);2207220622082207 list_for_each_entry(mod, &modules, list) {22092209- if (mod->from_dump)22082208+ if (mod->dump_file)22102209 continue;2211221022122211 if (mod->is_vmlinux)
+2-1
scripts/mod/modpost.h
···9595/**9696 * struct module - represent a module (vmlinux or *.ko)9797 *9898+ * @dump_file: path to the .symvers file if loaded from a file9899 * @aliases: list head for module_aliases99100 */100101struct module {101102 struct list_head list;102103 struct list_head exported_symbols;103104 struct list_head unresolved_symbols;105105+ const char *dump_file;104106 bool is_gpl_compatible;105105- bool from_dump; /* true if module was loaded from *.symvers */106107 bool is_vmlinux;107108 bool seen;108109 bool has_init;
+6
scripts/package/builddeb
···6363 esac6464 cp "$(${MAKE} -s -f ${srctree}/Makefile image_name)" "${pdir}/${installed_image_path}"65656666+ if [ "${ARCH}" != um ]; then6767+ install_maint_scripts "${pdir}"6868+ fi6969+}7070+7171+install_maint_scripts () {6672 # Install the maintainer scripts6773 # Note: hook scripts under /etc/kernel are also executed by official Debian6874 # kernel packages, as well as kernel packages built using make-kpkg.
···2929config SND_SOC_FSL_MQS3030 tristate "Medium Quality Sound (MQS) module support"3131 depends on SND_SOC_FSL_SAI3232+ depends on IMX_SCMI_MISC_DRV || !IMX_SCMI_MISC_DRV3233 select REGMAP_MMIO3333- select IMX_SCMI_MISC_DRV if IMX_SCMI_MISC_EXT !=n3434 help3535 Say Y if you want to add Medium Quality Sound (MQS)3636 support for the Freescale CPUs.
···11-#!/bin/bash11+#!/bin/sh2233# This example script parses /etc/resolv.conf to retrive DNS information.44# In the interest of keeping the KVP daemon code free of distro specific···1010# this script can be based on the Network Manager APIs for retrieving DNS1111# entries.12121313-cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }'1313+exec awk '/^nameserver/ { print $2 }' /etc/resolv.conf 2>/dev/null
+5-4
tools/hv/hv_kvp_daemon.c
···725725 * .726726 */727727728728- sprintf(cmd, KVP_SCRIPTS_PATH "%s", "hv_get_dns_info");728728+ sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dns_info", if_name);729729730730 /*731731 * Execute the command to gather DNS info.···742742 * Enabled: DHCP enabled.743743 */744744745745- sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dhcp_info", if_name);745745+ sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dhcp_info", if_name);746746747747 file = popen(cmd, "r");748748 if (file == NULL)···16061606 * invoke the external script to do its magic.16071607 */1608160816091609- str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s %s",16101610- "hv_set_ifconfig", if_filename, nm_filename);16091609+ str_len = snprintf(cmd, sizeof(cmd), "exec %s %s %s",16101610+ KVP_SCRIPTS_PATH "hv_set_ifconfig",16111611+ if_filename, nm_filename);16111612 /*16121613 * This is a little overcautious, but it's necessary to suppress some16131614 * false warnings from gcc 8.0.1.
···33#44# headers_check.pl execute a number of trivial consistency checks55#66-# Usage: headers_check.pl dir arch [files...]66+# Usage: headers_check.pl dir [files...]77# dir: dir to look for included files88-# arch: architecture98# files: list of files to check109#1110# The script reads the supplied files line by line and:···2223use strict;2324use File::Basename;24252525-my ($dir, $arch, @files) = @ARGV;2626+my ($dir, @files) = @ARGV;26272728my $ret = 0;2829my $line;···5354 my $inc = $1;5455 my $found;5556 $found = stat($dir . "/" . $inc);5656- if (!$found) {5757- $inc =~ s#asm/#asm-$arch/#;5858- $found = stat($dir . "/" . $inc);5959- }6057 if (!$found) {6158 printf STDERR "$filename:$lineno: included file '$inc' is not exported\n";6259 $ret = 1;