Changelog in Linux kernel 6.12.19

 
acpi: typec: ucsi: Introduce a ->poll_cci method [+ + +]
Author: Christian A. Ehrhardt <lk@c--e.de>
Date:   Mon Feb 17 13:54:39 2025 +0300

    acpi: typec: ucsi: Introduce a ->poll_cci method
    
    commit 976e7e9bdc7719a023a4ecccd2e3daec9ab20a40 upstream.
    
    For the ACPI backend of UCSI the UCSI "registers" are just a memory copy
    of the register values in an opregion. The ACPI implementation in the
    BIOS ensures that the opregion contents are synced to the embedded
    controller and it ensures that the registers (in particular CCI) are
    synced back to the opregion on notifications. While there is an ACPI call
    that syncs the actual registers to the opregion there is rarely a need to
    do this and on some ACPI implementations it actually breaks in various
    interesting ways.
    
    The only reason to force a sync from the embedded controller is to poll
    CCI while notifications are disabled. Only the ucsi core knows if this
    is the case and guessing based on the current command is suboptimal, i.e.
    leading to the following spurious assertion splat:
    
    WARNING: CPU: 3 PID: 76 at drivers/usb/typec/ucsi/ucsi.c:1388 ucsi_reset_ppm+0x1b4/0x1c0 [typec_ucsi]
    CPU: 3 UID: 0 PID: 76 Comm: kworker/3:0 Not tainted 6.12.11-200.fc41.x86_64 #1
    Hardware name: LENOVO 21D0/LNVNB161216, BIOS J6CN45WW 03/17/2023
    Workqueue: events_long ucsi_init_work [typec_ucsi]
    RIP: 0010:ucsi_reset_ppm+0x1b4/0x1c0 [typec_ucsi]
    Call Trace:
     <TASK>
     ucsi_init_work+0x3c/0xac0 [typec_ucsi]
     process_one_work+0x179/0x330
     worker_thread+0x252/0x390
     kthread+0xd2/0x100
     ret_from_fork+0x34/0x50
     ret_from_fork_asm+0x1a/0x30
     </TASK>
    
    Thus introduce a ->poll_cci() method that works like ->read_cci() with an
    additional forced sync and document that this should be used when polling
    with notifications disabled. For all other backends that presumably don't
    have this issue use the same implementation for both methods.
    
    Fixes: fa48d7e81624 ("usb: typec: ucsi: Do not call ACPI _DSM method for UCSI read operations")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Christian A. Ehrhardt <lk@c--e.de>
    Tested-by: Fedor Pchelkin <boddah8794@gmail.com>
    Signed-off-by: Fedor Pchelkin <boddah8794@gmail.com>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Link: https://lore.kernel.org/r/20250217105442.113486-2-boddah8794@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ALSA: hda/realtek - add supported Mic Mute LED for Lenovo platform [+ + +]
Author: Kailang Yang <kailang@realtek.com>
Date:   Mon Mar 3 14:56:10 2025 +0800

    ALSA: hda/realtek - add supported Mic Mute LED for Lenovo platform
    
    commit f603b159231b0c58f0c27ab39348534063d38223 upstream.
    
    Support Mic Mute LED for ThinkCentre M series.
    
    Signed-off-by: Kailang Yang <kailang@realtek.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/c211a2702f1f411e86bd7420d7eebc03@realtek.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: hda/realtek: Remove (revert) duplicate Ally X config [+ + +]
Author: Antheas Kapenekakis <lkml@antheas.dev>
Date:   Thu Feb 27 18:51:06 2025 +0100

    ALSA: hda/realtek: Remove (revert) duplicate Ally X config
    
    [ Upstream commit 3414cda9d41f41703832d0abd01063dd8de82b89 ]
    
    In commit 1e9c708dc3ae ("ALSA: hda/tas2781: Add new quirk for Lenovo,
    ASUS, Dell projects") Baojun adds a bunch of projects to the file,
    including for the Ally X. Turns out the initial Ally X was not sorted
    properly, so the kernel had 2 quirks for it.
    
    The previous quirk overrode the new one due to being earlier and they
    are different. When AB testing, the normal pin fixup seems to work ok
    but causes a bit of a minor popping. Given the other config is more
    complicated and may cause undefined behavior, revert it.
    
    Fixes: 1e9c708dc3ae ("ALSA: hda/tas2781: Add new quirk for Lenovo, ASUS, Dell projects")
    Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
    Link: https://patch.msgid.link/20250227175107.33432-2-lkml@antheas.dev
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ALSA: hda/realtek: update ALC222 depop optimize [+ + +]
Author: Kailang Yang <kailang@realtek.com>
Date:   Wed Mar 5 13:54:34 2025 +0800

    ALSA: hda/realtek: update ALC222 depop optimize
    
    commit ca0dedaff92307591f66c9206933fbdfe87add10 upstream.
    
    Add ALC222 its own depop functions for alc_init and alc_shutup.
    
    [note: this fixes pop noise issues on the models with two headphone
     jacks -- tiwai ]
    
    Signed-off-by: Kailang Yang <kailang@realtek.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: hda: intel: Add Dell ALC3271 to power_save denylist [+ + +]
Author: Hoku Ishibe <me@hokuishi.be>
Date:   Sun Feb 23 21:05:17 2025 -0500

    ALSA: hda: intel: Add Dell ALC3271 to power_save denylist
    
    commit 1ee5aa765c22a0577ec552d460bf2035300b4b51 upstream.
    
    Dell XPS 13 7390 with the Realtek ALC3271 codec experiences
    persistent humming noise when the power_save mode is enabled.
    This issue occurs when the codec enters power saving mode,
    leading to unwanted noise from the speakers.
    
    This patch adds the affected model (PCI ID 0x1028:0x0962) to the
    power_save denylist to ensure power_save is disabled by default,
    preventing power-off related noise issues.
    
    Steps to Reproduce
    1. Boot the system with `snd_hda_intel` loaded.
    2. Verify that `power_save` mode is enabled:
    ```sh
    cat /sys/module/snd_hda_intel/parameters/power_save
    ````
    output: 10 (default power save timeout)
    3. Wait for the power save timeout
    4. Observe a persistent humming noise from the speakers
    5. Disable `power_save` manually:
    ```sh
    echo 0 | sudo tee /sys/module/snd_hda_intel/parameters/power_save
    ````
    6. Confirm that the noise disappears immediately.
    
    This issue has been observed on my system, and this patch
    successfully eliminates the unwanted noise. If other users
    experience similar issues, additional reports would be helpful.
    
    Signed-off-by: Hoku Ishibe <me@hokuishi.be>
    Cc: <stable@vger.kernel.org>
    Link: https://patch.msgid.link/20250224020517.51035-1-me@hokuishi.be
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: hda: realtek: fix incorrect IS_REACHABLE() usage [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue Mar 4 15:25:55 2025 +0100

    ALSA: hda: realtek: fix incorrect IS_REACHABLE() usage
    
    commit d0bbe332669c5db32c8c92bc967f8e7f8d460ddf upstream.
    
    The alternative path leads to a build error after a recent change:
    
    sound/pci/hda/patch_realtek.c: In function 'alc233_fixup_lenovo_low_en_micmute_led':
    include/linux/stddef.h:9:14: error: called object is not a function or function pointer
        9 | #define NULL ((void *)0)
          |              ^
    sound/pci/hda/patch_realtek.c:5041:49: note: in expansion of macro 'NULL'
     5041 | #define alc233_fixup_lenovo_line2_mic_hotkey    NULL
          |                                                 ^~~~
    sound/pci/hda/patch_realtek.c:5063:9: note: in expansion of macro 'alc233_fixup_lenovo_line2_mic_hotkey'
     5063 |         alc233_fixup_lenovo_line2_mic_hotkey(codec, fix, action);
    
    Using IS_REACHABLE() is somewhat questionable here anyway since it
    leads to the input code not working when the HDA driver is builtin
    but input is in a loadable module. Replace this with a hard compile-time
    dependency on CONFIG_INPUT. In practice this won't chance much
    other than solve the compiler error because it is rare to require
    sound output but no input support.
    
    Fixes: f603b159231b ("ALSA: hda/realtek - add supported Mic Mute LED for Lenovo platform")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Link: https://patch.msgid.link/20250304142620.582191-1-arnd@kernel.org
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: seq: Avoid module auto-load handling at event delivery [+ + +]
Author: Takashi Iwai <tiwai@suse.de>
Date:   Sat Mar 1 12:45:29 2025 +0100

    ALSA: seq: Avoid module auto-load handling at event delivery
    
    commit c9ce148ea753bef66686460fa3cec6641cdfbb9f upstream.
    
    snd_seq_client_use_ptr() is supposed to return the snd_seq_client
    object for the given client ID, and it tries to handle the module
    auto-loading when no matching object is found.  Although the module
    handling is performed only conditionally with "!in_interrupt()", this
    condition may be fragile, e.g. when the code is called from the ALSA
    timer callback where the spinlock is temporarily disabled while the
    irq is disabled.  Then his doesn't fit well and spews the error about
    sleep from invalid context, as complained recently by syzbot.
    
    Also, in general, handling the module-loading at each time if no
    matching object is found is really an overkill.  It can be still
    useful when performed at the top-level ioctl or proc reads, but it
    shouldn't be done at event delivery at all.
    
    For addressing the issues above, this patch disables the module
    handling in snd_seq_client_use_ptr() in normal cases like event
    deliveries, but allow only in limited and safe situations.
    A new function client_load_and_use_ptr() is used for the cases where
    the module loading can be done safely, instead.
    
    Reported-by: syzbot+4cb9fad083898f54c517@syzkaller.appspotmail.com
    Closes: https://lore.kernel.org/67c272e5.050a0220.dc10f.0159.GAE@google.com
    Cc: <stable@vger.kernel.org>
    Link: https://patch.msgid.link/20250301114530.8975-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: usx2y: validate nrpacks module parameter on probe [+ + +]
Author: Murad Masimov <m.masimov@mt-integration.ru>
Date:   Mon Mar 3 13:04:13 2025 +0300

    ALSA: usx2y: validate nrpacks module parameter on probe
    
    [ Upstream commit 172a0f509723fe4741d4b8e9190cf434b18320d8 ]
    
    The module parameter defines number of iso packets per one URB. User is
    allowed to set any value to the parameter of type int, which can lead to
    various kinds of weird and incorrect behavior like integer overflows,
    truncations, etc. Number of packets should be a small non-negative number.
    
    Since this parameter is read-only, its value can be validated on driver
    probe.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Murad Masimov <m.masimov@mt-integration.ru>
    Link: https://patch.msgid.link/20250303100413.835-1-m.masimov@mt-integration.ru
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
arm64: hugetlb: Fix huge_ptep_get_and_clear() for non-present ptes [+ + +]
Author: Ryan Roberts <ryan.roberts@arm.com>
Date:   Wed Feb 26 12:06:52 2025 +0000

    arm64: hugetlb: Fix huge_ptep_get_and_clear() for non-present ptes
    
    commit 49c87f7677746f3c5bd16c81b23700bb6b88bfd4 upstream.
    
    arm64 supports multiple huge_pte sizes. Some of the sizes are covered by
    a single pte entry at a particular level (PMD_SIZE, PUD_SIZE), and some
    are covered by multiple ptes at a particular level (CONT_PTE_SIZE,
    CONT_PMD_SIZE). So the function has to figure out the size from the
    huge_pte pointer. This was previously done by walking the pgtable to
    determine the level and by using the PTE_CONT bit to determine the
    number of ptes at the level.
    
    But the PTE_CONT bit is only valid when the pte is present. For
    non-present pte values (e.g. markers, migration entries), the previous
    implementation was therefore erroneously determining the size. There is
    at least one known caller in core-mm, move_huge_pte(), which may call
    huge_ptep_get_and_clear() for a non-present pte. So we must be robust to
    this case. Additionally the "regular" ptep_get_and_clear() is robust to
    being called for non-present ptes so it makes sense to follow the
    behavior.
    
    Fix this by using the new sz parameter which is now provided to the
    function. Additionally when clearing each pte in a contig range, don't
    gather the access and dirty bits if the pte is not present.
    
    An alternative approach that would not require API changes would be to
    store the PTE_CONT bit in a spare bit in the swap entry pte for the
    non-present case. But it felt cleaner to follow other APIs' lead and
    just pass in the size.
    
    As an aside, PTE_CONT is bit 52, which corresponds to bit 40 in the swap
    entry offset field (layout of non-present pte). Since hugetlb is never
    swapped to disk, this field will only be populated for markers, which
    always set this bit to 0 and hwpoison swap entries, which set the offset
    field to a PFN; So it would only ever be 1 for a 52-bit PVA system where
    memory in that high half was poisoned (I think!). So in practice, this
    bit would almost always be zero for non-present ptes and we would only
    clear the first entry if it was actually a contiguous block. That's
    probably a less severe symptom than if it was always interpreted as 1
    and cleared out potentially-present neighboring PTEs.
    
    Cc: stable@vger.kernel.org
    Fixes: 66b3923a1a0f ("arm64: hugetlb: add support for PTE contiguous bit")
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
    Link: https://lore.kernel.org/r/20250226120656.2400136-3-ryan.roberts@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
be2net: fix sleeping while atomic bugs in be_ndo_bridge_getlink [+ + +]
Author: Nikolay Aleksandrov <razor@blackwall.org>
Date:   Thu Feb 27 18:41:29 2025 +0200

    be2net: fix sleeping while atomic bugs in be_ndo_bridge_getlink
    
    [ Upstream commit 1a82d19ca2d6835904ee71e2d40fd331098f94a0 ]
    
    Partially revert commit b71724147e73 ("be2net: replace polling with
    sleeping in the FW completion path") w.r.t mcc mutex it introduces and the
    use of usleep_range. The be2net be_ndo_bridge_getlink() callback is
    called with rcu_read_lock, so this code has been broken for a long time.
    Both the mutex_lock and the usleep_range can cause the issue Ian Kumlien
    reported[1]. The call path is:
    be_ndo_bridge_getlink -> be_cmd_get_hsw_config -> be_mcc_notify_wait ->
    be_mcc_wait_compl -> usleep_range()
    
    [1] https://lore.kernel.org/netdev/CAA85sZveppNgEVa_FD+qhOMtG_AavK9_mFiU+jWrMtXmwqefGA@mail.gmail.com/
    
    Tested-by: Ian Kumlien <ian.kumlien@gmail.com>
    Fixes: b71724147e73 ("be2net: replace polling with sleeping in the FW completion path")
    Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
    Link: https://patch.msgid.link/20250227164129.1201164-1-razor@blackwall.org
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
block: fix conversion of GPT partition name to 7-bit [+ + +]
Author: Olivier Gayot <olivier.gayot@canonical.com>
Date:   Wed Mar 5 10:21:54 2025 +0800

    block: fix conversion of GPT partition name to 7-bit
    
    commit e06472bab2a5393430cc2fbc3211cd3602422c1e upstream.
    
    The utf16_le_to_7bit function claims to, naively, convert a UTF-16
    string to a 7-bit ASCII string. By naively, we mean that it:
     * drops the first byte of every character in the original UTF-16 string
     * checks if all characters are printable, and otherwise replaces them
       by exclamation mark "!".
    
    This means that theoretically, all characters outside the 7-bit ASCII
    range should be replaced by another character. Examples:
    
     * lower-case alpha (ɒ) 0x0252 becomes 0x52 (R)
     * ligature OE (œ) 0x0153 becomes 0x53 (S)
     * hangul letter pieup (ㅂ) 0x3142 becomes 0x42 (B)
     * upper-case gamma (Ɣ) 0x0194 becomes 0x94 (not printable) so gets
       replaced by "!"
    
    The result of this conversion for the GPT partition name is passed to
    user-space as PARTNAME via udev, which is confusing and feels questionable.
    
    However, there is a flaw in the conversion function itself. By dropping
    one byte of each character and using isprint() to check if the remaining
    byte corresponds to a printable character, we do not actually guarantee
    that the resulting character is 7-bit ASCII.
    
    This happens because we pass 8-bit characters to isprint(), which
    in the kernel returns 1 for many values > 0x7f - as defined in ctype.c.
    
    This results in many values which should be replaced by "!" to be kept
    as-is, despite not being valid 7-bit ASCII. Examples:
    
     * e with acute accent (é) 0x00E9 becomes 0xE9 - kept as-is because
       isprint(0xE9) returns 1.
     * euro sign (€) 0x20AC becomes 0xAC - kept as-is because isprint(0xAC)
       returns 1.
    
    This way has broken pyudev utility[1], fixes it by using a mask of 7 bits
    instead of 8 bits before calling isprint.
    
    Link: https://github.com/pyudev/pyudev/issues/490#issuecomment-2685794648 [1]
    Link: https://lore.kernel.org/linux-block/4cac90c2-e414-4ebb-ae62-2a4589d9dc6e@canonical.com/
    Cc: Mulhern <amulhern@redhat.com>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Cc: stable@vger.kernel.org
    Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
    Signed-off-by: Ming Lei <ming.lei@redhat.com>
    Link: https://lore.kernel.org/r/20250305022154.3903128-1-ming.lei@redhat.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Bluetooth: Add check for mgmt_alloc_skb() in mgmt_device_connected() [+ + +]
Author: Haoxiang Li <haoxiang_li2024@163.com>
Date:   Fri Feb 21 16:58:01 2025 +0800

    Bluetooth: Add check for mgmt_alloc_skb() in mgmt_device_connected()
    
    commit d8df010f72b8a32aaea393e36121738bb53ed905 upstream.
    
    Add check for the return value of mgmt_alloc_skb() in
    mgmt_device_connected() to prevent null pointer dereference.
    
    Fixes: e96741437ef0 ("Bluetooth: mgmt: Make use of mgmt_send_event_skb in MGMT_EV_DEVICE_CONNECTED")
    Cc: stable@vger.kernel.org
    Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bluetooth: Add check for mgmt_alloc_skb() in mgmt_remote_name() [+ + +]
Author: Haoxiang Li <haoxiang_li2024@163.com>
Date:   Fri Feb 21 16:49:47 2025 +0800

    Bluetooth: Add check for mgmt_alloc_skb() in mgmt_remote_name()
    
    commit f2176a07e7b19f73e05c805cf3d130a2999154cb upstream.
    
    Add check for the return value of mgmt_alloc_skb() in
    mgmt_remote_name() to prevent null pointer dereference.
    
    Fixes: ba17bb62ce41 ("Bluetooth: Fix skb allocation in mgmt_remote_name() & mgmt_device_connected()")
    Cc: stable@vger.kernel.org
    Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
bluetooth: btusb: Initialize .owner field of force_poll_sync_fops [+ + +]
Author: Salah Triki <salah.triki@gmail.com>
Date:   Fri Feb 21 22:32:59 2025 +0100

    bluetooth: btusb: Initialize .owner field of force_poll_sync_fops
    
    [ Upstream commit cbf85b9cb80bec6345ffe0368dfff98386f4714f ]
    
    Initialize .owner field of force_poll_sync_fops to THIS_MODULE in order to
    prevent btusb from being unloaded while its operations are in use.
    
    Fixes: 800fe5ec302e ("Bluetooth: btusb: Add support for queuing during polling interval")
    Signed-off-by: Salah Triki <salah.triki@gmail.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
btrfs: fix a leaked chunk map issue in read_one_chunk() [+ + +]
Author: Haoxiang Li <haoxiang_li2024@163.com>
Date:   Mon Mar 3 10:42:33 2025 +0800

    btrfs: fix a leaked chunk map issue in read_one_chunk()
    
    commit 35d99c68af40a8ca175babc5a89ef7e2226fb3ca upstream.
    
    Add btrfs_free_chunk_map() to free the memory allocated
    by btrfs_alloc_chunk_map() if btrfs_add_chunk_map() fails.
    
    Fixes: 7dc66abb5a47 ("btrfs: use a dedicated data structure for chunk maps")
    CC: stable@vger.kernel.org
    Reviewed-by: Qu Wenruo <wqu@suse.com>
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: fix data overwriting bug during buffered write when block size < page size [+ + +]
Author: Qu Wenruo <wqu@suse.com>
Date:   Wed Feb 19 09:06:33 2025 +1030

    btrfs: fix data overwriting bug during buffered write when block size < page size
    
    [ Upstream commit efa11fd269c139e29b71ec21bc9c9c0063fde40d ]
    
    [BUG]
    When running generic/418 with a btrfs whose block size < page size
    (subpage cases), it always fails.
    
    And the following minimal reproducer is more than enough to trigger it
    reliably:
    
    workload()
    {
            mkfs.btrfs -s 4k -f $dev > /dev/null
            dmesg -C
            mount $dev $mnt
            $fsstree_dir/src/dio-invalidate-cache -r -b 4096 -n 3 -i 1 -f $mnt/diotest
            ret=$?
            umount $mnt
            stop_trace
            if [ $ret -ne 0 ]; then
                    fail
            fi
    }
    
    for (( i = 0; i < 1024; i++)); do
            echo "=== $i/$runtime ==="
            workload
    done
    
    [CAUSE]
    With extra trace printk added to the following functions:
    - btrfs_buffered_write()
      * Which folio is touched
      * The file offset (start) where the buffered write is at
      * How many bytes are copied
      * The content of the write (the first 2 bytes)
    
    - submit_one_sector()
      * Which folio is touched
      * The position inside the folio
      * The content of the page cache (the first 2 bytes)
    
    - pagecache_isize_extended()
      * The parameters of the function itself
      * The parameters of the folio_zero_range()
    
    Which are enough to show the problem:
    
      22.158114: btrfs_buffered_write: folio pos=0 start=0 copied=4096 content=0x0101
      22.158161: submit_one_sector: r/i=5/257 folio=0 pos=0 content=0x0101
      22.158609: btrfs_buffered_write: folio pos=0 start=4096 copied=4096 content=0x0101
      22.158634: btrfs_buffered_write: folio pos=0 start=8192 copied=4096 content=0x0101
      22.158650: pagecache_isize_extended: folio=0 from=4096 to=8192 bsize=4096 zero off=4096 len=8192
      22.158682: submit_one_sector: r/i=5/257 folio=0 pos=4096 content=0x0000
      22.158686: submit_one_sector: r/i=5/257 folio=0 pos=8192 content=0x0101
    
    The tool dio-invalidate-cache will start 3 threads, each doing a buffered
    write with 0x01 at offset 0, 4096 and 8192, do a fsync, then do a direct read,
    and compare the read buffer with the write buffer.
    
    Note that all 3 btrfs_buffered_write() are writing the correct 0x01 into
    the page cache.
    
    But at submit_one_sector(), at file offset 4096, the content is zeroed
    out, by pagecache_isize_extended().
    
    The race happens like this:
     Thread A is writing into range [4K, 8K).
     Thread B is writing into range [8K, 12k).
    
                   Thread A              |         Thread B
    -------------------------------------+------------------------------------
    btrfs_buffered_write()               | btrfs_buffered_write()
    |- old_isize = 4K;                   | |- old_isize = 4096;
    |- btrfs_inode_lock()                | |
    |- write into folio range [4K, 8K)   | |
    |- pagecache_isize_extended()        | |
    |  extend isize from 4096 to 8192    | |
    |  no folio_zero_range() called      | |
    |- btrfs_inode_lock()                | |
                                         | |- btrfs_inode_lock()
                                         | |- write into folio range [8K, 12K)
                                         | |- pagecache_isize_extended()
                                         | |  calling folio_zero_range(4K, 8K)
                                         | |  This is caused by the old_isize is
                                         | |  grabbed too early, without any
                                         | |  inode lock.
                                         | |- btrfs_inode_unlock()
    
    The @old_isize is grabbed without inode lock, causing race between two
    buffered write threads and making pagecache_isize_extended() to zero
    range which is still containing cached data.
    
    And this is only affecting subpage btrfs, because for regular blocksize
    == page size case, the function pagecache_isize_extended() will do
    nothing if the block size >= page size.
    
    [FIX]
    Grab the old i_size while holding the inode lock.
    This means each buffered write thread will have a stable view of the
    old inode size, thus avoid the above race.
    
    CC: stable@vger.kernel.org # 5.15+
    Fixes: 5e8b9ef30392 ("btrfs: move pos increment and pagecache extension to btrfs_buffered_write")
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
bus: mhi: host: pci_generic: Use pci_try_reset_function() to avoid deadlock [+ + +]
Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Date:   Wed Jan 8 19:09:27 2025 +0530

    bus: mhi: host: pci_generic: Use pci_try_reset_function() to avoid deadlock
    
    commit a321d163de3d8aa38a6449ab2becf4b1581aed96 upstream.
    
    There are multiple places from where the recovery work gets scheduled
    asynchronously. Also, there are multiple places where the caller waits
    synchronously for the recovery to be completed. One such place is during
    the PM shutdown() callback.
    
    If the device is not alive during recovery_work, it will try to reset the
    device using pci_reset_function(). This function internally will take the
    device_lock() first before resetting the device. By this time, if the lock
    has already been acquired, then recovery_work will get stalled while
    waiting for the lock. And if the lock was already acquired by the caller
    which waits for the recovery_work to be completed, it will lead to
    deadlock.
    
    This is what happened on the X1E80100 CRD device when the device died
    before shutdown() callback. Driver core calls the driver's shutdown()
    callback while holding the device_lock() leading to deadlock.
    
    And this deadlock scenario can occur on other paths as well, like during
    the PM suspend() callback, where the driver core would hold the
    device_lock() before calling driver's suspend() callback. And if the
    recovery_work was already started, it could lead to deadlock. This is also
    observed on the X1E80100 CRD.
    
    So to fix both issues, use pci_try_reset_function() in recovery_work. This
    function first checks for the availability of the device_lock() before
    trying to reset the device. If the lock is available, it will acquire it
    and reset the device. Otherwise, it will return -EAGAIN. If that happens,
    recovery_work will fail with the error message "Recovery failed" as not
    much could be done.
    
    Cc: stable@vger.kernel.org # 5.12
    Reported-by: Johan Hovold <johan@kernel.org>
    Closes: https://lore.kernel.org/mhi/Z1me8iaK7cwgjL92@hovoldconsulting.com
    Fixes: 7389337f0a78 ("mhi: pci_generic: Add suspend/resume/recovery procedure")
    Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
    Tested-by: Johan Hovold <johan+linaro@kernel.org>
    Analyzed-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/mhi/Z2KKjWY2mPen6GPL@hovoldconsulting.com/
    Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
    Link: https://lore.kernel.org/r/20250108-mhi_recovery_fix-v1-1-a0a00a17da46@linaro.org
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
caif_virtio: fix wrong pointer check in cfv_probe() [+ + +]
Author: Vitaliy Shevtsov <v.shevtsov@mt-integration.ru>
Date:   Thu Feb 27 23:46:27 2025 +0500

    caif_virtio: fix wrong pointer check in cfv_probe()
    
    [ Upstream commit a466fd7e9fafd975949e5945e2f70c33a94b1a70 ]
    
    del_vqs() frees virtqueues, therefore cfv->vq_tx pointer should be checked
    for NULL before calling it, not cfv->vdev. Also the current implementation
    is redundant because the pointer cfv->vdev is dereferenced before it is
    checked for NULL.
    
    Fix this by checking cfv->vq_tx for NULL instead of cfv->vdev before
    calling del_vqs().
    
    Fixes: 0d2e1a2926b1 ("caif_virtio: Introduce caif over virtio")
    Signed-off-by: Vitaliy Shevtsov <v.shevtsov@mt-integration.ru>
    Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
    Link: https://patch.msgid.link/20250227184716.4715-1-v.shevtsov@mt-integration.ru
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
cdx: Fix possible UAF error in driver_override_show() [+ + +]
Author: Qiu-ji Chen <chenqiuji666@gmail.com>
Date:   Sat Jan 18 15:08:33 2025 +0800

    cdx: Fix possible UAF error in driver_override_show()
    
    commit 91d44c1afc61a2fec37a9c7a3485368309391e0b upstream.
    
    Fixed a possible UAF problem in driver_override_show() in drivers/cdx/cdx.c
    
    This function driver_override_show() is part of DEVICE_ATTR_RW, which
    includes both driver_override_show() and driver_override_store().
    These functions can be executed concurrently in sysfs.
    
    The driver_override_store() function uses driver_set_override() to
    update the driver_override value, and driver_set_override() internally
    locks the device (device_lock(dev)). If driver_override_show() reads
    cdx_dev->driver_override without locking, it could potentially access
    a freed pointer if driver_override_store() frees the string
    concurrently. This could lead to printing a kernel address, which is a
    security risk since DEVICE_ATTR can be read by all users.
    
    Additionally, a similar pattern is used in drivers/amba/bus.c, as well
    as many other bus drivers, where device_lock() is taken in the show
    function, and it has been working without issues.
    
    This potential bug was detected by our experimental static analysis
    tool, which analyzes locking APIs and paired functions to identify
    data races and atomicity violations.
    
    Fixes: 1f86a00c1159 ("bus/fsl-mc: add support for 'driver_override' in the mc-bus")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Qiu-ji Chen <chenqiuji666@gmail.com>
    Link: https://lore.kernel.org/r/20250118070833.27201-1-chenqiuji666@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
char: misc: deallocate static minor in error path [+ + +]
Author: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Date:   Thu Jan 23 09:32:49 2025 -0300

    char: misc: deallocate static minor in error path
    
    commit 6d991f569c5ef6eaeadf1238df2c36e3975233ad upstream.
    
    When creating sysfs files fail, the allocated minor must be freed such that
    it can be later reused. That is specially harmful for static minor numbers,
    since those would always fail to register later on.
    
    Fixes: 6d04d2b554b1 ("misc: misc_minor_alloc to use ida for all dynamic/misc dynamic minors")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
    Link: https://lore.kernel.org/r/20250123123249.4081674-5-cascardo@igalia.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
cifs: Remove symlink member from cifs_open_info_data union [+ + +]
Author: Pali Rohár <pali@kernel.org>
Date:   Thu Dec 26 14:50:38 2024 +0100

    cifs: Remove symlink member from cifs_open_info_data union
    
    [ Upstream commit 65c49767dd4fc058673f9259fda1772fd398eaa7 ]
    
    Member 'symlink' is part of the union in struct cifs_open_info_data. Its
    value is assigned on few places, but is always read through another union
    member 'reparse_point'. So to make code more readable, always use only
    'reparse_point' member and drop whole union structure. No function change.
    
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Stable-dep-of: 9df23801c83d ("smb311: failure to open files of length 1040 when mounting with SMB3.1.1 POSIX extensions")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
coredump: Only sort VMAs when core_sort_vma sysctl is set [+ + +]
Author: Kees Cook <kees@kernel.org>
Date:   Wed Feb 19 11:53:16 2025 -0800

    coredump: Only sort VMAs when core_sort_vma sysctl is set
    
    [ Upstream commit 39ec9eaaa165d297d008d1fa385748430bd18e4d ]
    
    The sorting of VMAs by size in commit 7d442a33bfe8 ("binfmt_elf: Dump
    smaller VMAs first in ELF cores") breaks elfutils[1]. Instead, sort
    based on the setting of the new sysctl, core_sort_vma, which defaults
    to 0, no sorting.
    
    Reported-by: Michael Stapelberg <michael@stapelberg.ch>
    Closes: https://lore.kernel.org/all/20250218085407.61126-1-michael@stapelberg.de/ [1]
    Fixes: 7d442a33bfe8 ("binfmt_elf: Dump smaller VMAs first in ELF cores")
    Signed-off-by: Kees Cook <kees@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dma: kmsan: export kmsan_handle_dma() for modules [+ + +]
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:   Tue Feb 18 10:14:11 2025 +0100

    dma: kmsan: export kmsan_handle_dma() for modules
    
    commit 19fac3c93991502a22c5132824c40b6a2e64b136 upstream.
    
    kmsan_handle_dma() is used by virtio_ring() which can be built as a
    module.  kmsan_handle_dma() needs to be exported otherwise building the
    virtio_ring fails.
    
    Export kmsan_handle_dma for modules.
    
    Link: https://lkml.kernel.org/r/20250218091411.MMS3wBN9@linutronix.de
    Reported-by: kernel test robot <lkp@intel.com>
    Closes: https://lore.kernel.org/oe-kbuild-all/202502150634.qjxwSeJR-lkp@intel.com/
    Fixes: 7ade4f10779c ("dma: kmsan: unpoison DMA mappings")
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Dmitriy Vyukov <dvyukov@google.com>
    Cc: Macro Elver <elver@google.com>
    Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
docs: rust: remove spurious item in `expect` list [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Sun Nov 17 14:31:27 2024 +0100

    docs: rust: remove spurious item in `expect` list
    
    commit b160dc46dd9af4001c802cc9c7d68b6ba58d27c4 upstream.
    
    This list started as a "when to prefer `expect`" list, but at some point
    during writing I changed it to a "prefer `expect` unless..." one. However,
    the first bullet remained, which does not make sense anymore.
    
    Thus remove it. In addition, fix nearby typo.
    
    Fixes: 04866494e936 ("Documentation: rust: discuss `#[expect(...)]` in the guidelines")
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
    Link: https://lore.kernel.org/r/20241117133127.473937-1-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Documentation: rust: add coding guidelines on lints [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:22 2025 +0100

    Documentation: rust: add coding guidelines on lints
    
    commit 139d396572ec4ba6e8cc5c02f5c8d5d1139be4b7 upstream.
    
    In the C side, disabling diagnostics locally, i.e. within the source code,
    is rare (at least in the kernel). Sometimes warnings are manipulated
    via the flags at the translation unit level, but that is about it.
    
    In Rust, it is easier to change locally the "level" of lints
    (e.g. allowing them locally). In turn, this means it is easier to
    globally enable more lints that may trigger a few false positives here
    and there that need to be allowed locally, but that generally can spot
    issues or bugs.
    
    Thus document this.
    
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-17-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Documentation: rust: discuss `#[expect(...)]` in the guidelines [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:24 2025 +0100

    Documentation: rust: discuss `#[expect(...)]` in the guidelines
    
    commit 04866494e936d041fd196d3a36aecd979e4ef078 upstream.
    
    Discuss `#[expect(...)]` in the Lints sections of the coding guidelines
    document, which is an upcoming feature in Rust 1.81.0, and explain that
    it is generally to be preferred over `allow` unless there is a reason
    not to use it (e.g. conditional compilation being involved).
    
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-19-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drivers: core: fix device leak in __fw_devlink_relax_cycles() [+ + +]
Author: Luca Ceresoli <luca.ceresoli@bootlin.com>
Date:   Thu Feb 13 15:05:13 2025 +0100

    drivers: core: fix device leak in __fw_devlink_relax_cycles()
    
    commit 78eb41f518f414378643ab022241df2a9dcd008b upstream.
    
    Commit bac3b10b78e5 ("driver core: fw_devlink: Stop trying to optimize
    cycle detection logic") introduced a new struct device *con_dev and a
    get_dev_from_fwnode() call to get it, but without adding a corresponding
    put_device().
    
    Closes: https://lore.kernel.org/all/20241204124826.2e055091@booty/
    Fixes: bac3b10b78e5 ("driver core: fw_devlink: Stop trying to optimize cycle detection logic")
    Cc: stable@vger.kernel.org
    Reviewed-by: Saravana Kannan <saravanak@google.com>
    Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
    Link: https://lore.kernel.org/r/20250213-fix__fw_devlink_relax_cycles_missing_device_put-v2-1-8cd3b03e6a3f@bootlin.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drivers: virt: acrn: hsm: Use kzalloc to avoid info leak in pmcmd_ioctl [+ + +]
Author: Haoyu Li <lihaoyu499@gmail.com>
Date:   Thu Jan 30 19:58:11 2025 +0800

    drivers: virt: acrn: hsm: Use kzalloc to avoid info leak in pmcmd_ioctl
    
    commit 819cec1dc47cdeac8f5dd6ba81c1dbee2a68c3bb upstream.
    
    In the "pmcmd_ioctl" function, three memory objects allocated by
    kmalloc are initialized by "hcall_get_cpu_state", which are then
    copied to user space. The initializer is indeed implemented in
    "acrn_hypercall2" (arch/x86/include/asm/acrn.h). There is a risk of
    information leakage due to uninitialized bytes.
    
    Fixes: 3d679d5aec64 ("virt: acrn: Introduce interfaces to query C-states and P-states allowed by hypervisor")
    Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
    Cc: stable <stable@kernel.org>
    Acked-by: Fei Li <fei1.li@intel.com>
    Link: https://lore.kernel.org/r/20250130115811.92424-1-lihaoyu499@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/amd/display: Fix null check for pipe_ctx->plane_state in resource_build_scaling_params [+ + +]
Author: Ma Ke <make24@iscas.ac.cn>
Date:   Wed Feb 26 16:37:31 2025 +0800

    drm/amd/display: Fix null check for pipe_ctx->plane_state in resource_build_scaling_params
    
    commit 374c9faac5a763a05bc3f68ad9f73dab3c6aec90 upstream.
    
    Null pointer dereference issue could occur when pipe_ctx->plane_state
    is null. The fix adds a check to ensure 'pipe_ctx->plane_state' is not
    null before accessing. This prevents a null pointer dereference.
    
    Found by code review.
    
    Fixes: 3be5262e353b ("drm/amd/display: Rename more dc_surface stuff to plane_state")
    Reviewed-by: Alex Hung <alex.hung@amd.com>
    Signed-off-by: Ma Ke <make24@iscas.ac.cn>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    (cherry picked from commit 63e6a77ccf239337baa9b1e7787cde9fa0462092)
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/amd/pm: always allow ih interrupt from fw [+ + +]
Author: Kenneth Feng <kenneth.feng@amd.com>
Date:   Fri Feb 28 17:02:11 2025 +0800

    drm/amd/pm: always allow ih interrupt from fw
    
    commit da552bda987420e877500fdd90bd0172e3bf412b upstream.
    
    always allow ih interrupt from fw on smu v14 based on
    the interface requirement
    
    Signed-off-by: Kenneth Feng <kenneth.feng@amd.com>
    Reviewed-by: Yang Wang <kevinyang.wang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    (cherry picked from commit a3199eba46c54324193607d9114a1e321292d7a1)
    Cc: stable@vger.kernel.org # 6.12.x
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/amdkfd: Fix NULL Pointer Dereference in KFD queue [+ + +]
Author: Andrew Martin <Andrew.Martin@amd.com>
Date:   Fri Feb 28 11:26:48 2025 -0500

    drm/amdkfd: Fix NULL Pointer Dereference in KFD queue
    
    commit fd617ea3b79d2116d53f76cdb5a3601c0ba6e42f upstream.
    
    Through KFD IOCTL Fuzzing we encountered a NULL pointer derefrence
    when calling kfd_queue_acquire_buffers.
    
    Fixes: 629568d25fea ("drm/amdkfd: Validate queue cwsr area and eop buffer size")
    Signed-off-by: Andrew Martin <Andrew.Martin@amd.com>
    Reviewed-by: Philip Yang <Philip.Yang@amd.com>
    Signed-off-by: Andrew Martin <Andrew.Martin@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    (cherry picked from commit 049e5bf3c8406f87c3d8e1958e0a16804fa1d530)
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/fbdev-helper: Move color-mode lookup into 4CC format helper [+ + +]
Author: Thomas Zimmermann <tzimmermann@suse.de>
Date:   Tue Sep 24 09:11:59 2024 +0200

    drm/fbdev-helper: Move color-mode lookup into 4CC format helper
    
    [ Upstream commit eb1f4adf9101573fc2347978a60d71c4f1176cca ]
    
    The color mode as specified on the kernel command line gives the user's
    preferred color depth and number of bits per pixel. Move the
    color-mode-to-format conversion from fbdev helpers into a 4CC helper,
    so that it can be shared among DRM clients.
    
    v2:
    - fix grammar in commit message (Laurent)
    
    Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
    Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240924071734.98201-2-tzimmermann@suse.de
    Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/fbdev-ttm: Support struct drm_driver.fbdev_probe [+ + +]
Author: Thomas Zimmermann <tzimmermann@suse.de>
Date:   Tue Sep 24 09:13:02 2024 +0200

    drm/fbdev-ttm: Support struct drm_driver.fbdev_probe
    
    [ Upstream commit c7c1b9e1d52b0a0dbb0ee552efdc3360c0f5363c ]
    
    Rework fbdev probing to support fbdev_probe in struct drm_driver
    and reimplement the old fb_probe callback on top of it. Provide an
    initializer macro for struct drm_driver that sets the callback
    according to the kernel configuration.
    
    This change allows the common fbdev client to run on top of TTM-
    based DRM drivers.
    
    Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
    Acked-by: Javier Martinez Canillas <javierm@redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240924071734.98201-65-tzimmermann@suse.de
    Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/fbdev: Add memory-agnostic fbdev client [+ + +]
Author: Thomas Zimmermann <tzimmermann@suse.de>
Date:   Tue Sep 24 09:12:01 2024 +0200

    drm/fbdev: Add memory-agnostic fbdev client
    
    [ Upstream commit 5d08c44e47b9d41366714552bdd374ac4b595591 ]
    
    Add an fbdev client that can work with any memory manager. The
    client implementation is the same as existing code in fbdev-dma or
    fbdev-shmem.
    
    Provide struct drm_driver.fbdev_probe for the new client to allocate
    the surface GEM buffer. The new callback replaces fb_probe of struct
    drm_fb_helper_funcs, which does the same.
    
    To use the new client, DRM drivers set fbdev_probe in their struct
    drm_driver instance and call drm_fbdev_client_setup(). Probing and
    creating the fbdev surface buffer is now independent from the other
    operations in struct drm_fb_helper. For the pixel format, the fbdev
    client either uses a specified format, the value in preferred_depth
    or 32-bit RGB.
    
    v2:
    - test for struct drm_fb_helper.funcs for NULL (Sui)
    - respect struct drm_mode_config.preferred_depth for default format
    
    Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
    Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240924071734.98201-4-tzimmermann@suse.de
    Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/i915/color: Extract intel_color_modeset() [+ + +]
Author: Ville Syrjälä <ville.syrjala@linux.intel.com>
Date:   Mon Sep 16 18:29:57 2024 +0300

    drm/i915/color: Extract intel_color_modeset()
    
    [ Upstream commit 84d2d0430f0833cdf52a3d051906add051f20ef0 ]
    
    We always perform the same steps to program color management
    stuff during a full modeset. Extract that code to a helper
    to avoid duplication.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240916152958.17332-2-ville.syrjala@linux.intel.com
    Reviewed-by: Luca Coelho <luciano.coelho@intel.com>
    Stable-dep-of: 30bfc151f0c1 ("drm/xe: Remove double pageflip")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/i915/dsi: convert to struct intel_display [+ + +]
Author: Jani Nikula <jani.nikula@intel.com>
Date:   Mon Oct 28 22:07:29 2024 +0200

    drm/i915/dsi: convert to struct intel_display
    
    [ Upstream commit 7c05c58c15d49b75eefaa24154cce771f1db955b ]
    
    struct intel_display will replace struct drm_i915_private as the main
    device pointer for display code. Switch ICL DSI code over to it.
    
    Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Jani Nikula <jani.nikula@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/f62a3616ef15e02cf19c5d041656fc6e09b37f6a.1730146000.git.jani.nikula@intel.com
    Stable-dep-of: 879f70382ff3 ("drm/i915/dsi: Use TRANS_DDI_FUNC_CTL's own port width macro")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/i915/dsi: Use TRANS_DDI_FUNC_CTL's own port width macro [+ + +]
Author: Imre Deak <imre.deak@intel.com>
Date:   Fri Feb 14 16:19:51 2025 +0200

    drm/i915/dsi: Use TRANS_DDI_FUNC_CTL's own port width macro
    
    [ Upstream commit 879f70382ff3e92fc854589ada3453e3f5f5b601 ]
    
    The format of the port width field in the DDI_BUF_CTL and the
    TRANS_DDI_FUNC_CTL registers are different starting with MTL, where the
    x3 lane mode for HDMI FRL has a different encoding in the two registers.
    To account for this use the TRANS_DDI_FUNC_CTL's own port width macro.
    
    Cc: <stable@vger.kernel.org> # v6.5+
    Fixes: b66a8abaa48a ("drm/i915/display/mtl: Fill port width in DDI_BUF_/TRANS_DDI_FUNC_/PORT_BUF_CTL for HDMI")
    Reviewed-by: Jani Nikula <jani.nikula@intel.com>
    Signed-off-by: Imre Deak <imre.deak@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250214142001.552916-2-imre.deak@intel.com
    (cherry picked from commit 76120b3a304aec28fef4910204b81a12db8974da)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/i915: Plumb 'dsb' all way to the plane hooks [+ + +]
Author: Ville Syrjälä <ville.syrjala@linux.intel.com>
Date:   Mon Sep 30 20:04:13 2024 +0300

    drm/i915: Plumb 'dsb' all way to the plane hooks
    
    [ Upstream commit 01389846f7d61d262cc92d42ad4d1a25730e3eff ]
    
    We need to be able to do both MMIO and DSB based pipe/plane
    programming. To that end plumb the 'dsb' all way from the top
    into the plane commit hooks.
    
    The compiler appears smart enough to combine the branches from
    all the back-to-back register writes into a single branch.
    So the generated asm ends up looking more or less like this:
    plane_hook()
    {
            if (dsb) {
                    intel_dsb_reg_write();
                    intel_dsb_reg_write();
                    ...
            } else {
                    intel_de_write_fw();
                    intel_de_write_fw();
                    ...
            }
    }
    which seems like a reasonably efficient way to do this.
    
    An alternative I was also considering is some kind of closure
    (register write function + display vs. dsb pointer passed to it).
    That does result is smaller code as there are no branches anymore,
    but having each register access go via function pointer sounds
    less efficient.
    
    Not that I actually measured the overhead of either approach yet.
    Also the reg_rw tracepoint seems to be making a huge mess of the
    generated code for the mmio path. And additionally there's some
    kind of IS_GSI_REG() hack in __raw_uncore_read() which ends up
    generating a pointless branch for every mmio register access.
    So looks like there might be quite a bit of room for improvement
    in the mmio path still.
    
    Reviewed-by: Animesh Manna <animesh.manna@intel.com>
    Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240930170415.23841-12-ville.syrjala@linux.intel.com
    Stable-dep-of: 30bfc151f0c1 ("drm/xe: Remove double pageflip")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/imagination: avoid deadlock on fence release [+ + +]
Author: Brendan King <Brendan.King@imgtec.com>
Date:   Wed Feb 26 15:42:19 2025 +0000

    drm/imagination: avoid deadlock on fence release
    
    commit df1a1ed5e1bdd9cc13148e0e5549f5ebcf76cf13 upstream.
    
    Do scheduler queue fence release processing on a workqueue, rather
    than in the release function itself.
    
    Fixes deadlock issues such as the following:
    
    [  607.400437] ============================================
    [  607.405755] WARNING: possible recursive locking detected
    [  607.415500] --------------------------------------------
    [  607.420817] weston:zfq0/24149 is trying to acquire lock:
    [  607.426131] ffff000017d041a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: pvr_gem_object_vunmap+0x40/0xc0 [powervr]
    [  607.436728]
                   but task is already holding lock:
    [  607.442554] ffff000017d105a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: dma_buf_ioctl+0x250/0x554
    [  607.451727]
                   other info that might help us debug this:
    [  607.458245]  Possible unsafe locking scenario:
    
    [  607.464155]        CPU0
    [  607.466601]        ----
    [  607.469044]   lock(reservation_ww_class_mutex);
    [  607.473584]   lock(reservation_ww_class_mutex);
    [  607.478114]
                    *** DEADLOCK ***
    
    Cc: stable@vger.kernel.org
    Fixes: eaf01ee5ba28 ("drm/imagination: Implement job submission and scheduling")
    Signed-off-by: Brendan King <brendan.king@imgtec.com>
    Reviewed-by: Matt Coster <matt.coster@imgtec.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250226-fence-release-deadlock-v2-1-6fed2fc1fe88@imgtec.com
    Signed-off-by: Matt Coster <matt.coster@imgtec.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/imagination: Fix timestamps in firmware traces [+ + +]
Author: Alessio Belle <alessio.belle@imgtec.com>
Date:   Fri Feb 21 10:49:35 2025 +0000

    drm/imagination: Fix timestamps in firmware traces
    
    [ Upstream commit 1d2eabb6616433ccaa13927811bdfa205e91ba60 ]
    
    When firmware traces are enabled, the firmware dumps 48-bit timestamps
    for each trace as two 32-bit values, highest 32 bits (of which only 16
    useful) first.
    
    The driver was reassembling them the other way round i.e. interpreting
    the first value in memory as the lowest 32 bits, and the second value
    as the highest 32 bits (then truncated to 16 bits).
    
    Due to this, firmware trace dumps showed very large timestamps even for
    traces recorded shortly after GPU boot. The timestamps in these dumps
    would also sometimes jump backwards because of the truncation.
    
    Example trace dumped after loading the powervr module and enabling
    firmware traces, where each line is commented with the timestamp value
    in hexadecimal to better show both issues:
    
    [93540092739584] : Host Sync Partition marker: 1    // 0x551300000000
    [28419798597632] : GPU units deinit                 // 0x19d900000000
    [28548647616512] : GPU deinit                       // 0x19f700000000
    
    Update logic to reassemble the timestamps halves in the correct order.
    
    Fixes: cb56cd610866 ("drm/imagination: Add firmware trace to debugfs")
    Signed-off-by: Alessio Belle <alessio.belle@imgtec.com>
    Reviewed-by: Matt Coster <matt.coster@imgtec.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250221-fix-fw-trace-timestamps-v1-1-dba4aeb030ca@imgtec.com
    Signed-off-by: Matt Coster <matt.coster@imgtec.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/imagination: Hold drm_gem_gpuva lock for unmap [+ + +]
Author: Brendan King <Brendan.King@imgtec.com>
Date:   Wed Feb 26 15:43:06 2025 +0000

    drm/imagination: Hold drm_gem_gpuva lock for unmap
    
    commit a5c4c3ba95a52d66315acdfbaba9bd82ed39c250 upstream.
    
    Avoid a warning from drm_gem_gpuva_assert_lock_held in drm_gpuva_unlink.
    
    The Imagination driver uses the GEM object reservation lock to protect
    the gpuva list, but the GEM object was not always known in the code
    paths that ended up calling drm_gpuva_unlink. When the GEM object isn't
    known, it is found by calling drm_gpuva_find to lookup the object
    associated with a given virtual address range, or by calling
    drm_gpuva_find_first when removing all mappings.
    
    Cc: stable@vger.kernel.org
    Fixes: 4bc736f890ce ("drm/imagination: vm: make use of GPUVM's drm_exec helper")
    Signed-off-by: Brendan King <brendan.king@imgtec.com>
    Reviewed-by: Matt Coster <matt.coster@imgtec.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250226-hold-drm_gem_gpuva-lock-for-unmap-v2-1-3fdacded227f@imgtec.com
    Signed-off-by: Matt Coster <matt.coster@imgtec.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/imagination: only init job done fences once [+ + +]
Author: Brendan King <Brendan.King@imgtec.com>
Date:   Wed Feb 26 15:43:54 2025 +0000

    drm/imagination: only init job done fences once
    
    commit 68c3de7f707e8a70e0a6d8087cf0fe4a3d5dbfb0 upstream.
    
    Ensure job done fences are only initialised once.
    
    This fixes a memory manager not clean warning from drm_mm_takedown
    on module unload.
    
    Cc: stable@vger.kernel.org
    Fixes: eaf01ee5ba28 ("drm/imagination: Implement job submission and scheduling")
    Signed-off-by: Brendan King <brendan.king@imgtec.com>
    Reviewed-by: Matt Coster <matt.coster@imgtec.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250226-init-done-fences-once-v2-1-c1b2f556b329@imgtec.com
    Signed-off-by: Matt Coster <matt.coster@imgtec.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/nouveau: Run DRM default client setup [+ + +]
Author: Thomas Zimmermann <tzimmermann@suse.de>
Date:   Tue Sep 24 09:13:06 2024 +0200

    drm/nouveau: Run DRM default client setup
    
    [ Upstream commit ef350898ae22db832ada972476fa2999f8ea978c ]
    
    Call drm_client_setup() to run the kernel's default client setup
    for DRM. Set fbdev_probe in struct drm_driver, so that the client
    setup can start the common fbdev client.
    
    The nouveau driver specifies a preferred color mode depending on
    the available video memory, with a default of 32. Adapt this for
    the new client interface.
    
    v5:
    - select DRM_CLIENT_SELECTION
    v2:
    - style changes
    
    Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: Karol Herbst <kherbst@redhat.com>
    Cc: Lyude Paul <lyude@redhat.com>
    Cc: Danilo Krummrich <dakr@redhat.com>
    Reviewed-by: Lyude Paul <lyude@redhat.com>
    Acked-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240924071734.98201-69-tzimmermann@suse.de
    Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/nouveau: select FW caching [+ + +]
Author: Dave Airlie <airlied@redhat.com>
Date:   Fri Feb 7 11:25:31 2025 +1000

    drm/nouveau: select FW caching
    
    [ Upstream commit 6b481ab0e6855fb30e2923c51f62f1662d1cda7e ]
    
    nouveau tries to load some firmware during suspend that it loaded
    earlier, but with fw caching disabled it hangs suspend, so just rely on
    FW cache enabling instead of working around it in the driver.
    
    Fixes: 176fdcbddfd2 ("drm/nouveau/gsp/r535: add support for booting GSP-RM")
    Signed-off-by: Dave Airlie <airlied@redhat.com>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250207012531.621369-1-airlied@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/panic: allow verbose boolean for clarity [+ + +]
Author: Thomas Böhler <witcher@wiredspace.de>
Date:   Fri Mar 7 23:50:01 2025 +0100

    drm/panic: allow verbose boolean for clarity
    
    commit 27aef8a52e4b7f120ce47cd638d9d83065b759d2 upstream.
    
    Clippy complains about a non-minimal boolean expression with
    `nonminimal_bool`:
    
        error: this boolean expression can be simplified
           --> drivers/gpu/drm/drm_panic_qr.rs:722:9
            |
        722 |         (x < 8 && y < 8) || (x < 8 && y >= end) || (x >= end && y < 8)
            |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
            = note: `-D clippy::nonminimal-bool` implied by `-D warnings`
            = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]`
        help: try
            |
        722 |         !(x >= 8 || y >= 8 && y < end) || (x >= end && y < 8)
            |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        722 |         (y >= end || y < 8) && x < 8 || (x >= end && y < 8)
            |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    While this can be useful in a lot of cases, it isn't here because the
    line expresses clearly what the intention is. Simplifying the expression
    means losing clarity, so opt-out of this lint for the offending line.
    
    Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
    Reported-by: Miguel Ojeda <ojeda@kernel.org>
    Link: https://github.com/Rust-for-Linux/linux/issues/1123
    Signed-off-by: Thomas Böhler <witcher@wiredspace.de>
    Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
    Link: https://lore.kernel.org/r/20241019084048.22336-7-witcher@wiredspace.de
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/panic: allow verbose version check [+ + +]
Author: Thomas Böhler <witcher@wiredspace.de>
Date:   Fri Mar 7 23:50:02 2025 +0100

    drm/panic: allow verbose version check
    
    commit 06b919e3fedf4798a1f0f60e0b67caa192f724a7 upstream.
    
    Clippy warns about a reimplementation of `RangeInclusive::contains`:
    
        error: manual `!RangeInclusive::contains` implementation
           --> drivers/gpu/drm/drm_panic_qr.rs:986:8
            |
        986 |     if version < 1 || version > 40 {
            |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `!(1..=40).contains(&version)`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
            = note: `-D clippy::manual-range-contains` implied by `-D warnings`
            = help: to override `-D warnings` add `#[allow(clippy::manual_range_contains)]`
    
    Ignore this and keep the current implementation as that makes it easier
    to read.
    
    Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
    Reported-by: Miguel Ojeda <ojeda@kernel.org>
    Link: https://github.com/Rust-for-Linux/linux/issues/1123
    Signed-off-by: Thomas Böhler <witcher@wiredspace.de>
    Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
    Link: https://lore.kernel.org/r/20241019084048.22336-8-witcher@wiredspace.de
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/panic: avoid reimplementing Iterator::find [+ + +]
Author: Thomas Böhler <witcher@wiredspace.de>
Date:   Fri Mar 7 23:49:56 2025 +0100

    drm/panic: avoid reimplementing Iterator::find
    
    commit c408dd81678bb0a957eae96962c913c242e069f7 upstream.
    
    Rust's standard library's `std::iter::Iterator` trait provides a function
    `find` that finds the first element that satisfies a predicate.
    The function `Version::from_segments` is doing the same thing but is
    implementing the same logic itself.
    
    Clippy complains about this in the `manual_find` lint:
    
        error: manual implementation of `Iterator::find`
           --> drivers/gpu/drm/drm_panic_qr.rs:212:9
            |
        212 | /         for v in (1..=40).map(|k| Version(k)) {
        213 | |             if v.max_data() * 8 >= segments.iter().map(|s| s.total_size_bits(v)).sum() {
        214 | |                 return Some(v);
        215 | |             }
        216 | |         }
        217 | |         None
            | |____________^ help: replace with an iterator: `(1..=40).map(|k| Version(k)).find(|&v| v.max_data() * 8 >= segments.iter().map(|s| s.total_size_bits(v)).sum())`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_find
            = note: `-D clippy::manual-find` implied by `-D warnings`
            = help: to override `-D warnings` add `#[allow(clippy::manual_find)]`
    
    Use `Iterator::find` instead to make the intention clearer.
    
    At the same time, clean up the redundant closure that Clippy warns
    about too:
    
        error: redundant closure
        --> drivers/gpu/drm/drm_panic_qr.rs:212:31
            |
        212 |         for v in (1..=40).map(|k| Version(k)) {
            |                               ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `Version`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
            = note: `-D clippy::redundant-closure` implied by `-D warnings`
            = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]`
    
    Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
    Reported-by: Miguel Ojeda <ojeda@kernel.org>
    Link: https://github.com/Rust-for-Linux/linux/issues/1123
    Signed-off-by: Thomas Böhler <witcher@wiredspace.de>
    Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
    Link: https://lore.kernel.org/r/20241019084048.22336-2-witcher@wiredspace.de
    [ Reworded to mention the redundant closure cleanup too. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/panic: correctly indent continuation of line in list item [+ + +]
Author: Thomas Böhler <witcher@wiredspace.de>
Date:   Fri Mar 7 23:50:00 2025 +0100

    drm/panic: correctly indent continuation of line in list item
    
    commit 5bb698e6fc514ddd9e23b6649b29a0934d8d8586 upstream.
    
    It is common practice in Rust to indent the next line the same amount of
    space as the previous one if both belong to the same list item. Clippy
    checks for this with the lint `doc_lazy_continuation`.
    
        error: doc list item without indentation
        --> drivers/gpu/drm/drm_panic_qr.rs:979:5
            |
        979 | /// conversion to numeric segments.
            |     ^
            |
            = help: if this is supposed to be its own paragraph, add a blank line
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
            = note: `-D clippy::doc-lazy-continuation` implied by `-D warnings`
            = help: to override `-D warnings` add `#[allow(clippy::doc_lazy_continuation)]`
        help: indent this line
            |
        979 | ///   conversion to numeric segments.
            |     ++
    
    Indent the offending line by 2 more spaces to remove this Clippy error.
    
    Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
    Reported-by: Miguel Ojeda <ojeda@kernel.org>
    Link: https://github.com/Rust-for-Linux/linux/issues/1123
    Signed-off-by: Thomas Böhler <witcher@wiredspace.de>
    Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
    Link: https://lore.kernel.org/r/20241019084048.22336-6-witcher@wiredspace.de
    [ Reworded to indent Clippy's message. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/panic: prefer eliding lifetimes [+ + +]
Author: Thomas Böhler <witcher@wiredspace.de>
Date:   Fri Mar 7 23:49:58 2025 +0100

    drm/panic: prefer eliding lifetimes
    
    commit ae75c40117b53ae3d91dfc9d0bf06984a079f044 upstream.
    
    Eliding lifetimes when possible instead of specifying them directly is
    both shorter and easier to read. Clippy notes this in the
    `needless_lifetimes` lint:
    
        error: the following explicit lifetimes could be elided: 'b
           --> drivers/gpu/drm/drm_panic_qr.rs:479:16
            |
        479 |     fn new<'a, 'b>(segments: &[&Segment<'b>], data: &'a mut [u8]) -> Option<EncodedMsg<'a>> {
            |                ^^                       ^^
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
            = note: `-D clippy::needless-lifetimes` implied by `-D warnings`
            = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]`
        help: elide the lifetimes
            |
        479 -     fn new<'a, 'b>(segments: &[&Segment<'b>], data: &'a mut [u8]) -> Option<EncodedMsg<'a>> {
        479 +     fn new<'a>(segments: &[&Segment<'_>], data: &'a mut [u8]) -> Option<EncodedMsg<'a>> {
            |
    
    Remove the explicit lifetime annotation in favour of an elided lifetime.
    
    Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
    Reported-by: Miguel Ojeda <ojeda@kernel.org>
    Link: https://github.com/Rust-for-Linux/linux/issues/1123
    Signed-off-by: Thomas Böhler <witcher@wiredspace.de>
    Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
    Link: https://lore.kernel.org/r/20241019084048.22336-4-witcher@wiredspace.de
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/panic: remove redundant field when assigning value [+ + +]
Author: Thomas Böhler <witcher@wiredspace.de>
Date:   Fri Mar 7 23:49:59 2025 +0100

    drm/panic: remove redundant field when assigning value
    
    commit da13129a3f2a75d49469e1d6f7dcefac2d11d205 upstream.
    
    Rust allows initializing fields of a struct without specifying the
    attribute that is assigned if the variable has the same name. In this
    instance this is done for all other attributes of the struct except for
    `data`. Clippy notes the redundant field name:
    
        error: redundant field names in struct initialization
        --> drivers/gpu/drm/drm_panic_qr.rs:495:13
            |
        495 |             data: data,
            |             ^^^^^^^^^^ help: replace it with: `data`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
            = note: `-D clippy::redundant-field-names` implied by `-D warnings`
            = help: to override `-D warnings` add `#[allow(clippy::redundant_field_names)]`
    
    Remove the redundant `data` in the assignment to be consistent.
    
    Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
    Reported-by: Miguel Ojeda <ojeda@kernel.org>
    Link: https://github.com/Rust-for-Linux/linux/issues/1123
    Signed-off-by: Thomas Böhler <witcher@wiredspace.de>
    Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
    Link: https://lore.kernel.org/r/20241019084048.22336-5-witcher@wiredspace.de
    [ Reworded to add Clippy warning like it is done in the rest of the
      series. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/panic: remove unnecessary borrow in alignment_pattern [+ + +]
Author: Thomas Böhler <witcher@wiredspace.de>
Date:   Fri Mar 7 23:49:57 2025 +0100

    drm/panic: remove unnecessary borrow in alignment_pattern
    
    commit 7b6de57e0b2d1e62becfa3aac063c4c58d2c2c42 upstream.
    
    The function `alignment_pattern` returns a static reference to a `u8`
    slice. The borrow of the returned element in `ALIGNMENT_PATTERNS` is
    already a reference as defined in the array definition above so this
    borrow is unnecessary and removed by the compiler. Clippy notes this in
    `needless_borrow`:
    
        error: this expression creates a reference which is immediately dereferenced by the compiler
           --> drivers/gpu/drm/drm_panic_qr.rs:245:9
            |
        245 |         &ALIGNMENT_PATTERNS[self.0 - 1]
            |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `ALIGNMENT_PATTERNS[self.0 - 1]`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
            = note: `-D clippy::needless-borrow` implied by `-D warnings`
            = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]`
    
    Remove the unnecessary borrow.
    
    Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
    Reported-by: Miguel Ojeda <ojeda@kernel.org>
    Link: https://github.com/Rust-for-Linux/linux/issues/1123
    Signed-off-by: Thomas Böhler <witcher@wiredspace.de>
    Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
    Link: https://lore.kernel.org/r/20241019084048.22336-3-witcher@wiredspace.de
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/radeon: Fix rs400_gpu_init for ATI mobility radeon Xpress 200M [+ + +]
Author: Richard Thier <u9vata@gmail.com>
Date:   Mon Jun 17 23:46:27 2019 +0200

    drm/radeon: Fix rs400_gpu_init for ATI mobility radeon Xpress 200M
    
    commit 29ffeb73b216ce3eff10229eb077cf9b7812119d upstream.
    
    num_gb_pipes was set to a wrong value using r420_pipe_config
    
    This have lead to HyperZ glitches on fast Z clearing.
    
    Closes: https://bugs.freedesktop.org/show_bug.cgi?id=110897
    Reviewed-by: Marek Olšák <marek.olsak@amd.com>
    Signed-off-by: Richard Thier <u9vata@gmail.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    (cherry picked from commit 044e59a85c4d84e3c8d004c486e5c479640563a6)
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/sched: Fix preprocessor guard [+ + +]
Author: Philipp Stanner <phasta@kernel.org>
Date:   Tue Feb 18 13:41:50 2025 +0100

    drm/sched: Fix preprocessor guard
    
    [ Upstream commit 23e0832d6d7be2d3c713f9390c060b6f1c48bf36 ]
    
    When writing the header guard for gpu_scheduler_trace.h, a typo,
    apparently, occurred.
    
    Fix the typo and document the scope of the guard.
    
    Fixes: 353da3c520b4 ("drm/amdgpu: add tracepoint for scheduler (v2)")
    Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
    Signed-off-by: Philipp Stanner <phasta@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250218124149.118002-2-phasta@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/xe/hmm: Don't dereference struct page pointers without notifier lock [+ + +]
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Date:   Tue Mar 4 18:33:41 2025 +0100

    drm/xe/hmm: Don't dereference struct page pointers without notifier lock
    
    commit 0a98219bcc961edd3388960576e4353e123b4a51 upstream.
    
    The pnfs that we obtain from hmm_range_fault() point to pages that
    we don't have a reference on, and the guarantee that they are still
    in the cpu page-tables is that the notifier lock must be held and the
    notifier seqno is still valid.
    
    So while building the sg table and marking the pages accesses / dirty
    we need to hold this lock with a validated seqno.
    
    However, the lock is reclaim tainted which makes
    sg_alloc_table_from_pages_segment() unusable, since it internally
    allocates memory.
    
    Instead build the sg-table manually. For the non-iommu case
    this might lead to fewer coalesces, but if that's a problem it can
    be fixed up later in the resource cursor code. For the iommu case,
    the whole sg-table may still be coalesced to a single contigous
    device va region.
    
    This avoids marking pages that we don't own dirty and accessed, and
    it also avoid dereferencing struct pages that we don't own.
    
    v2:
    - Use assert to check whether hmm pfns are valid (Matthew Auld)
    - Take into account that large pages may cross range boundaries
      (Matthew Auld)
    
    v3:
    - Don't unnecessarily check for a non-freed sg-table. (Matthew Auld)
    - Add a missing up_read() in an error path. (Matthew Auld)
    
    Fixes: 81e058a3e7fd ("drm/xe: Introduce helper to populate userptr")
    Cc: Oak Zeng <oak.zeng@intel.com>
    Cc: <stable@vger.kernel.org> # v6.10+
    Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Reviewed-by: Matthew Auld <matthew.auld@intel.com>
    Acked-by: Matthew Brost <matthew.brost@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250304173342.22009-3-thomas.hellstrom@linux.intel.com
    (cherry picked from commit ea3e66d280ce2576664a862693d1da8fd324c317)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/xe/hmm: Style- and include fixes [+ + +]
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Date:   Tue Mar 4 18:33:40 2025 +0100

    drm/xe/hmm: Style- and include fixes
    
    commit e3e2e7fc4cd8414c9a966ef1b344db543f8614f4 upstream.
    
    Add proper #ifndef around the xe_hmm.h header, proper spacing
    and since the documentation mostly follows kerneldoc format,
    make it kerneldoc. Also prepare for upcoming -stable fixes.
    
    Fixes: 81e058a3e7fd ("drm/xe: Introduce helper to populate userptr")
    Cc: Oak Zeng <oak.zeng@intel.com>
    Cc: <stable@vger.kernel.org> # v6.10+
    Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Reviewed-by: Matthew Auld <matthew.auld@intel.com>
    Acked-by: Matthew Brost <Matthew Brost <matthew.brost@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250304173342.22009-2-thomas.hellstrom@linux.intel.com
    (cherry picked from commit bbe2b06b55bc061c8fcec034ed26e88287f39143)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/xe/userptr: properly setup pfn_flags_mask [+ + +]
Author: Matthew Auld <matthew.auld@intel.com>
Date:   Wed Feb 26 17:47:49 2025 +0000

    drm/xe/userptr: properly setup pfn_flags_mask
    
    commit 475d06e00b7496c7915d87f7ae67af26738e4649 upstream.
    
    Currently we just leave it uninitialised, which at first looks harmless,
    however we also don't zero out the pfn array, and with pfn_flags_mask
    the idea is to be able set individual flags for a given range of pfn or
    completely ignore them, outside of default_flags. So here we end up with
    pfn[i] & pfn_flags_mask, and if both are uninitialised we might get back
    an unexpected flags value, like asking for read only with default_flags,
    but getting back write on top, leading to potentially bogus behaviour.
    
    To fix this ensure we zero the pfn_flags_mask, such that hmm only
    considers the default_flags and not also the initial pfn[i] value.
    
    v2 (Thomas):
     - Prefer proper initializer.
    
    Fixes: 81e058a3e7fd ("drm/xe: Introduce helper to populate userptr")
    Signed-off-by: Matthew Auld <matthew.auld@intel.com>
    Cc: Matthew Brost <matthew.brost@intel.com>
    Cc: Thomas Hellström <thomas.hellstrom@intel.com>
    Cc: <stable@vger.kernel.org> # v6.10+
    Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250226174748.294285-2-matthew.auld@intel.com
    (cherry picked from commit dd8c01e42f4c5c1eaf02f003d7d588ba6706aa71)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/xe/userptr: Unmap userptrs in the mmu notifier [+ + +]
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Date:   Tue Mar 4 18:33:42 2025 +0100

    drm/xe/userptr: Unmap userptrs in the mmu notifier
    
    commit 333b8906336174478efbbfc1e24a89e3397ffe65 upstream.
    
    If userptr pages are freed after a call to the xe mmu notifier,
    the device will not be blocked out from theoretically accessing
    these pages unless they are also unmapped from the iommu, and
    this violates some aspects of the iommu-imposed security.
    
    Ensure that userptrs are unmapped in the mmu notifier to
    mitigate this. A naive attempt would try to free the sg table, but
    the sg table itself may be accessed by a concurrent bind
    operation, so settle for only unmapping.
    
    v3:
    - Update lockdep asserts.
    - Fix a typo (Matthew Auld)
    
    Fixes: 81e058a3e7fd ("drm/xe: Introduce helper to populate userptr")
    Cc: Oak Zeng <oak.zeng@intel.com>
    Cc: Matthew Auld <matthew.auld@intel.com>
    Cc: <stable@vger.kernel.org> # v6.10+
    Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Reviewed-by: Matthew Auld <matthew.auld@intel.com>
    Acked-by: Matthew Brost <matthew.brost@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250304173342.22009-4-thomas.hellstrom@linux.intel.com
    (cherry picked from commit ba767b9d01a2c552d76cf6f46b125d50ec4147a6)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/xe/vm: Fix a misplaced #endif [+ + +]
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Date:   Fri Feb 28 08:30:56 2025 +0100

    drm/xe/vm: Fix a misplaced #endif
    
    commit 1414d95d5805b1dc221d22db9b8dc5287ef083bc upstream.
    
    Fix a (harmless) misplaced #endif leading to declarations
    appearing multiple times.
    
    Fixes: 0eb2a18a8fad ("drm/xe: Implement VM snapshot support for BO's and userptr")
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: José Roberto de Souza <jose.souza@intel.com>
    Cc: <stable@vger.kernel.org> # v6.12+
    Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
    Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250228073058.59510-3-thomas.hellstrom@linux.intel.com
    (cherry picked from commit fcc20a4c752214b3e25632021c57d7d1d71ee1dd)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/xe/vm: Validate userptr during gpu vma prefetching [+ + +]
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Date:   Fri Feb 28 08:30:55 2025 +0100

    drm/xe/vm: Validate userptr during gpu vma prefetching
    
    commit e775e2a060d99180edc5366fb9f4299d0f07b66c upstream.
    
    If a userptr vma subject to prefetching was already invalidated
    or invalidated during the prefetch operation, the operation would
    repeatedly return -EAGAIN which would typically cause an infinite
    loop.
    
    Validate the userptr to ensure this doesn't happen.
    
    v2:
    - Don't fallthrough from UNMAP to PREFETCH (Matthew Brost)
    
    Fixes: 5bd24e78829a ("drm/xe/vm: Subclass userptr vmas")
    Fixes: 617eebb9c480 ("drm/xe: Fix array of binds")
    Cc: Matthew Brost <matthew.brost@intel.com>
    Cc: <stable@vger.kernel.org> # v6.9+
    Suggested-by: Matthew Brost <matthew.brost@intel.com>
    Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Reviewed-by: Matthew Brost <matthew.brost@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250228073058.59510-2-thomas.hellstrom@linux.intel.com
    (cherry picked from commit 03c346d4d0d85d210d549d43c8cfb3dfb7f20e0a)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/xe: Add staging tree for VM binds [+ + +]
Author: Matthew Brost <matthew.brost@intel.com>
Date:   Fri Feb 28 08:30:58 2025 +0100

    drm/xe: Add staging tree for VM binds
    
    commit ae482ec8cd1a85bde3307f71921a7780086fbec0 upstream.
    
    Concurrent VM bind staging and zapping of PTEs from a userptr notifier
    do not work because the view of PTEs is not stable. VM binds cannot
    acquire the notifier lock during staging, as memory allocations are
    required. To resolve this race condition, use a staging tree for VM
    binds that is committed only under the userptr notifier lock during the
    final step of the bind. This ensures a consistent view of the PTEs in
    the userptr notifier.
    
    A follow up may only use staging for VM in fault mode as this is the
    only mode in which the above race exists.
    
    v3:
     - Drop zap PTE change (Thomas)
     - s/xe_pt_entry/xe_pt_entry_staging (Thomas)
    
    Suggested-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Cc: <stable@vger.kernel.org>
    Fixes: e8babb280b5e ("drm/xe: Convert multiple bind ops into single job")
    Fixes: a708f6501c69 ("drm/xe: Update PT layer with better error handling")
    Signed-off-by: Matthew Brost <matthew.brost@intel.com>
    Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250228073058.59510-5-thomas.hellstrom@linux.intel.com
    Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    (cherry picked from commit 6f39b0c5ef0385eae586760d10b9767168037aa5)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/xe: Fix fault mode invalidation with unbind [+ + +]
Author: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Date:   Fri Feb 28 08:30:57 2025 +0100

    drm/xe: Fix fault mode invalidation with unbind
    
    commit 84211b1c0db6b9dbe0020fa97192fb9661617f24 upstream.
    
    Fix fault mode invalidation racing with unbind leading to the
    PTE zapping potentially traversing an invalid page-table tree.
    Do this by holding the notifier lock across PTE zapping. This
    might transfer any contention waiting on the notifier seqlock
    read side to the notifier lock read side, but that shouldn't be
    a major problem.
    
    At the same time get rid of the open-coded invalidation in the bind
    code by relying on the notifier even when the vma bind is not
    yet committed.
    
    Finally let userptr invalidation call a dedicated xe_vm function
    performing a full invalidation.
    
    Fixes: e8babb280b5e ("drm/xe: Convert multiple bind ops into single job")
    Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Cc: Matthew Brost <matthew.brost@intel.com>
    Cc: Matthew Auld <matthew.auld@intel.com>
    Cc: <stable@vger.kernel.org> # v6.12+
    Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Reviewed-by: Matthew Brost <matthew.brost@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250228073058.59510-4-thomas.hellstrom@linux.intel.com
    (cherry picked from commit 100a5b8dadfca50d91d9a4c9fc01431b42a25cab)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/xe: Fix GT "for each engine" workarounds [+ + +]
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Date:   Thu Feb 27 10:13:00 2025 +0000

    drm/xe: Fix GT "for each engine" workarounds
    
    commit 54f94dc7f6b4db45dbc23b4db3d20c7194e2c54f upstream.
    
    Any rules using engine matching are currently broken due RTP processing
    happening too in early init, before the list of hardware engines has been
    initialised.
    
    Fix this by moving workaround processing to later in the driver probe
    sequence, to just before the processed list is used for the first time.
    
    Looking at the debugfs gt0/workarounds on ADL-P we notice 14011060649
    should be present while we see, before:
    
     GT Workarounds
         14011059788
         14015795083
    
    And with the patch:
    
     GT Workarounds
         14011060649
         14011059788
         14015795083
    
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
    Cc: Lucas De Marchi <lucas.demarchi@intel.com>
    Cc: Matt Roper <matthew.d.roper@intel.com>
    Cc: stable@vger.kernel.org # v6.11+
    Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20250227101304.46660-2-tvrtko.ursulin@igalia.com
    Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
    (cherry picked from commit 25d434cef791e03cf40680f5441b576c639bfa84)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/xe: Remove double pageflip [+ + +]
Author: Maarten Lankhorst <dev@lankhorst.se>
Date:   Tue Dec 10 09:31:02 2024 +0100

    drm/xe: Remove double pageflip
    
    [ Upstream commit 30bfc151f0c1ec80c27a80a7651b2c15c648ad16 ]
    
    This is already handled below in the code by fixup_initial_plane_config.
    
    Fixes: a8153627520a ("drm/i915: Try to relocate the BIOS fb to the start of ggtt")
    Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Reviewed-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
    Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20241210083111.230484-3-dev@lankhorst.se
    Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
    (cherry picked from commit 2218704997979fbf11765281ef752f07c5cf25bb)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm: Add client-agnostic setup helper [+ + +]
Author: Thomas Zimmermann <tzimmermann@suse.de>
Date:   Tue Sep 24 09:12:02 2024 +0200

    drm: Add client-agnostic setup helper
    
    [ Upstream commit d07fdf9225922d3e36ebd13ccab3df62b1ccdab3 ]
    
    DRM may support multiple in-kernel clients that run as soon as a DRM
    driver has been registered. To select the client(s) in a single place,
    introduce drm_client_setup().
    
    Drivers that call the new helper automatically instantiate the kernel's
    configured default clients. Only fbdev emulation is currently supported.
    Later versions can add support for DRM-based logging, a boot logo or even
    a console.
    
    Some drivers handle the color mode for clients internally. Provide the
    helper drm_client_setup_with_color_mode() for them.
    
    Using the new interface requires the driver to select
    DRM_CLIENT_SELECTION in its Kconfig. For now this only enables the
    client-setup helpers if the fbdev client has been configured by the
    user. A future patchset will further modularize client support and
    rework DRM_CLIENT_SELECTION to select the correct dependencies for
    all its clients.
    
    v5:
    - add CONFIG_DRM_CLIENT_SELECTION und DRM_CLIENT_SETUP
    v4:
    - fix docs for drm_client_setup_with_fourcc() (Geert)
    v3:
    - fix build error
    v2:
    - add drm_client_setup_with_fourcc() (Laurent)
    - push default-format handling into actual clients
    
    Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
    Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240924071734.98201-5-tzimmermann@suse.de
    Stable-dep-of: 6b481ab0e685 ("drm/nouveau: select FW caching")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
eeprom: digsy_mtc: Make GPIO lookup table match the device [+ + +]
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Fri Feb 7 00:03:11 2025 +0200

    eeprom: digsy_mtc: Make GPIO lookup table match the device
    
    commit 038ef0754aae76f79b147b8867f9250e6a976872 upstream.
    
    The dev_id value in the GPIO lookup table must match to
    the device instance name, which in this case is combined
    of name and platform device ID, i.e. "spi_gpio.1". But
    the table assumed that there was no platform device ID
    defined, which is wrong. Fix the dev_id value accordingly.
    
    Fixes: 9b00bc7b901f ("spi: spi-gpio: Rewrite to use GPIO descriptors")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20250206220311.1554075-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ethtool: linkstate: migrate linkstate functions to support multi-PHY setups [+ + +]
Author: Oleksij Rempel <o.rempel@pengutronix.de>
Date:   Fri Jan 10 07:05:11 2025 +0100

    ethtool: linkstate: migrate linkstate functions to support multi-PHY setups
    
    [ Upstream commit fe55b1d401c697c2ef126fe3ebbcaa6885fced5a ]
    
    Adapt linkstate_get_sqi() and linkstate_get_sqi_max() to take a
    phy_device argument directly, enabling support for setups with
    multiple PHYs. The previous assumption of a single PHY attached to
    a net_device no longer holds.
    
    Use ethnl_req_get_phydev() to identify the appropriate PHY device
    for the operation. Update linkstate_prepare_data() and related
    logic to accommodate this change, ensuring compatibility with
    multi-PHY configurations.
    
    Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Stable-dep-of: 637399bf7e77 ("net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
exfat: fix just enough dentries but allocate a new cluster to dir [+ + +]
Author: Yuezhang Mo <Yuezhang.Mo@sony.com>
Date:   Fri Nov 22 10:50:55 2024 +0800

    exfat: fix just enough dentries but allocate a new cluster to dir
    
    [ Upstream commit 6697f819a10b238ccf01998c3f203d65d8374696 ]
    
    This commit fixes the condition for allocating cluster to parent
    directory to avoid allocating new cluster to parent directory when
    there are just enough empty directory entries at the end of the
    parent directory.
    
    Fixes: af02c72d0b62 ("exfat: convert exfat_find_empty_entry() to use dentry cache")
    Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
    Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

exfat: fix soft lockup in exfat_clear_bitmap [+ + +]
Author: Namjae Jeon <linkinjeon@kernel.org>
Date:   Fri Jan 31 12:55:55 2025 +0900

    exfat: fix soft lockup in exfat_clear_bitmap
    
    [ Upstream commit 9da33619e0ca53627641bc97d1b93ec741299111 ]
    
    bitmap clear loop will take long time in __exfat_free_cluster()
    if data size of file/dir enty is invalid.
    If cluster bit in bitmap is already clear, stop clearing bitmap go to
    out of loop.
    
    Fixes: 31023864e67a ("exfat: add fat entry operations")
    Reported-by: Kun Hu <huk23@m.fudan.edu.cn>, Jiaji Qin <jjtan24@m.fudan.edu.cn>
    Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
    Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

exfat: short-circuit zero-byte writes in exfat_file_write_iter [+ + +]
Author: Eric Sandeen <sandeen@redhat.com>
Date:   Tue Feb 11 14:14:21 2025 -0600

    exfat: short-circuit zero-byte writes in exfat_file_write_iter
    
    [ Upstream commit fda94a9919fd632033979ad7765a99ae3cab9289 ]
    
    When generic_write_checks() returns zero, it means that
    iov_iter_count() is zero, and there is no work to do.
    
    Simply return success like all other filesystems do, rather than
    proceeding down the write path, which today yields an -EFAULT in
    generic_perform_write() via the
    (fault_in_iov_iter_readable(i, bytes) == bytes) check when bytes
    == 0.
    
    Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength")
    Reported-by: Noah <kernel-org-10@maxgrass.eu>
    Signed-off-by: Eric Sandeen <sandeen@redhat.com>
    Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
    Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
fs/netfs/read_collect: fix crash due to uninitialized `prev` variable [+ + +]
Author: Max Kellermann <max.kellermann@ionos.com>
Date:   Fri Feb 14 14:12:25 2025 +0100

    fs/netfs/read_collect: fix crash due to uninitialized `prev` variable
    
    [ Just like the other two netfs patches I sent yesterday, this one
      doesn't apply to v6.14 as it was obsoleted by commit e2d46f2ec332
      ("netfs: Change the read result collector to only use one work item").  ]
    
    When checking whether the edges of adjacent subrequests touch, the
    `prev` variable is deferenced, but it might not have been initialized.
    This causes crashes like this one:
    
     BUG: unable to handle page fault for address: 0000000181343843
     #PF: supervisor read access in kernel mode
     #PF: error_code(0x0000) - not-present page
     PGD 8000001c66db0067 P4D 8000001c66db0067 PUD 0
     Oops: Oops: 0000 [#1] SMP PTI
     CPU: 1 UID: 33333 PID: 24424 Comm: php-cgi8.2 Kdump: loaded Not tainted 6.13.2-cm4all0-hp+ #427
     Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 11/23/2021
     RIP: 0010:netfs_consume_read_data.isra.0+0x5ef/0xb00
     Code: fe ff ff 48 8b 83 88 00 00 00 48 8b 4c 24 30 4c 8b 43 78 48 85 c0 48 8d 51 70 75 20 48 8b 73 30 48 39 d6 74 17 48 8b 7c 24 40 <48> 8b 4f 78 48 03 4f 68 48 39 4b 68 0f 84 ab 02 00 00 49 29 c0 48
     RSP: 0000:ffffc90037adbd00 EFLAGS: 00010283
     RAX: 0000000000000000 RBX: ffff88811bda0600 RCX: ffff888620e7b980
     RDX: ffff888620e7b9f0 RSI: ffff88811bda0428 RDI: 00000001813437cb
     RBP: 0000000000000000 R08: 0000000000004000 R09: 0000000000000000
     R10: ffffffff82e070c0 R11: 0000000007ffffff R12: 0000000000004000
     R13: ffff888620e7bb68 R14: 0000000000008000 R15: ffff888620e7bb68
     FS:  00007ff2e0e7ddc0(0000) GS:ffff88981f840000(0000) knlGS:0000000000000000
     CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
     CR2: 0000000181343843 CR3: 0000001bc10ba006 CR4: 00000000001706f0
     Call Trace:
      <TASK>
      ? __die+0x1f/0x60
      ? page_fault_oops+0x15c/0x450
      ? search_extable+0x22/0x30
      ? netfs_consume_read_data.isra.0+0x5ef/0xb00
      ? search_module_extables+0xe/0x40
      ? exc_page_fault+0x5e/0x100
      ? asm_exc_page_fault+0x22/0x30
      ? netfs_consume_read_data.isra.0+0x5ef/0xb00
      ? intel_iommu_unmap_pages+0xaa/0x190
      ? __pfx_cachefiles_read_complete+0x10/0x10
      netfs_read_subreq_terminated+0x24f/0x390
      cachefiles_read_complete+0x48/0xf0
      iomap_dio_bio_end_io+0x125/0x160
      blk_update_request+0xea/0x3e0
      scsi_end_request+0x27/0x190
      scsi_io_completion+0x43/0x6c0
      blk_complete_reqs+0x40/0x50
      handle_softirqs+0xd1/0x280
      irq_exit_rcu+0x91/0xb0
      common_interrupt+0x3b/0xa0
      asm_common_interrupt+0x22/0x40
     RIP: 0033:0x55fe8470d2ab
     Code: 00 00 3c 7e 74 3b 3c b6 0f 84 dd 03 00 00 3c 1e 74 2f 83 c1 01 48 83 c2 38 48 83 c7 30 44 39 d1 74 3e 48 63 42 08 85 c0 79 a3 <49> 8b 46 48 8b 04 38 f6 c4 04 75 0b 0f b6 42 30 83 e0 0c 3c 04 75
     RSP: 002b:00007ffca5ef2720 EFLAGS: 00000216
     RAX: 0000000000000023 RBX: 0000000000000008 RCX: 000000000000001b
     RDX: 00007ff2e0cdb6f8 RSI: 0000000000000006 RDI: 0000000000000510
     RBP: 00007ffca5ef27a0 R08: 00007ffca5ef2720 R09: 0000000000000001
     R10: 000000000000001e R11: 00007ff2e0c10d08 R12: 0000000000000001
     R13: 0000000000000120 R14: 00007ff2e0cb1ed0 R15: 00000000000000b0
      </TASK>
    
    Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading")
    Cc: stable@vger.kernel.org
    Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
fs/netfs/read_pgpriv2: skip folio queues without `marks3` [+ + +]
Author: Max Kellermann <max.kellermann@ionos.com>
Date:   Mon Feb 10 23:31:44 2025 +0100

    fs/netfs/read_pgpriv2: skip folio queues without `marks3`
    
    [ Note this patch doesn't apply to v6.14 as it was obsoleted by commit
      e2d46f2ec332 ("netfs: Change the read result collector to only use one
      work item"). ]
    
    At the beginning of the function, folio queues with marks3==0 are
    skipped, but after that, the `marks3` field is ignored.  If one such
    queue is found, `slot` is set to 64 (because `__ffs(0)==64`), leading
    to a buffer overflow in the folioq_folio() call.  The resulting crash
    may look like this:
    
     BUG: kernel NULL pointer dereference, address: 0000000000000000
     #PF: supervisor read access in kernel mode
     #PF: error_code(0x0000) - not-present page
     PGD 0 P4D 0
     Oops: Oops: 0000 [#1] SMP PTI
     CPU: 11 UID: 0 PID: 2909 Comm: kworker/u262:1 Not tainted 6.13.1-cm4all2-vm #415
     Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
     Workqueue: events_unbound netfs_read_termination_worker
     RIP: 0010:netfs_pgpriv2_write_to_the_cache+0x15a/0x3f0
     Code: 48 85 c0 48 89 44 24 08 0f 84 24 01 00 00 48 8b 80 40 01 00 00 48 8b 7c 24 08 f3 48 0f bc c0 89 44 24 18 89 c0 48 8b 74 c7 08 <48> 8b 06 48 c7 04 24 00 10 00 00 a8 40 74 10 0f b6 4e 40 b8 00 10
     RSP: 0018:ffffbbc440effe18 EFLAGS: 00010203
     RAX: 0000000000000040 RBX: ffff96f8fc034000 RCX: 0000000000000000
     RDX: 0000000000000040 RSI: 0000000000000000 RDI: ffff96f8fc036400
     RBP: 0000000000001000 R08: ffff96f9132bb400 R09: 0000000000001000
     R10: ffff96f8c1263c80 R11: 0000000000000003 R12: 0000000000001000
     R13: ffff96f8fb75ade8 R14: fffffaaf5ca90000 R15: ffff96f8fb75ad00
     FS:  0000000000000000(0000) GS:ffff9703cf0c0000(0000) knlGS:0000000000000000
     CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
     CR2: 0000000000000000 CR3: 000000010c9ca003 CR4: 00000000001706b0
     DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
     DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
     Call Trace:
      <TASK>
      ? __die+0x1f/0x60
      ? page_fault_oops+0x158/0x450
      ? search_extable+0x22/0x30
      ? netfs_pgpriv2_write_to_the_cache+0x15a/0x3f0
      ? search_module_extables+0xe/0x40
      ? exc_page_fault+0x62/0x120
      ? asm_exc_page_fault+0x22/0x30
      ? netfs_pgpriv2_write_to_the_cache+0x15a/0x3f0
      ? netfs_pgpriv2_write_to_the_cache+0xf6/0x3f0
      netfs_read_termination_worker+0x1f/0x60
      process_one_work+0x138/0x2d0
      worker_thread+0x2a5/0x3b0
      ? __pfx_worker_thread+0x10/0x10
      kthread+0xba/0xe0
      ? __pfx_kthread+0x10/0x10
      ret_from_fork+0x30/0x50
      ? __pfx_kthread+0x10/0x10
      ret_from_fork_asm+0x1a/0x30
      </TASK>
    
    Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading")
    Cc: stable@vger.kernel.org
    Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
gpio: aggregator: protect driver attr handlers against module unload [+ + +]
Author: Koichiro Den <koichiro.den@canonical.com>
Date:   Mon Feb 24 23:31:26 2025 +0900

    gpio: aggregator: protect driver attr handlers against module unload
    
    commit 12f65d1203507f7db3ba59930fe29a3b8eee9945 upstream.
    
    Both new_device_store and delete_device_store touch module global
    resources (e.g. gpio_aggregator_lock). To prevent race conditions with
    module unload, a reference needs to be held.
    
    Add try_module_get() in these handlers.
    
    For new_device_store, this eliminates what appears to be the most dangerous
    scenario: if an id is allocated from gpio_aggregator_idr but
    platform_device_register has not yet been called or completed, a concurrent
    module unload could fail to unregister/delete the device, leaving behind a
    dangling platform device/GPIO forwarder. This can result in various issues.
    The following simple reproducer demonstrates these problems:
    
      #!/bin/bash
      while :; do
        # note: whether 'gpiochip0 0' exists or not does not matter.
        echo 'gpiochip0 0' > /sys/bus/platform/drivers/gpio-aggregator/new_device
      done &
      while :; do
        modprobe gpio-aggregator
        modprobe -r gpio-aggregator
      done &
      wait
    
      Starting with the following warning, several kinds of warnings will appear
      and the system may become unstable:
    
      ------------[ cut here ]------------
      list_del corruption, ffff888103e2e980->next is LIST_POISON1 (dead000000000100)
      WARNING: CPU: 1 PID: 1327 at lib/list_debug.c:56 __list_del_entry_valid_or_report+0xa3/0x120
      [...]
      RIP: 0010:__list_del_entry_valid_or_report+0xa3/0x120
      [...]
      Call Trace:
       <TASK>
       ? __list_del_entry_valid_or_report+0xa3/0x120
       ? __warn.cold+0x93/0xf2
       ? __list_del_entry_valid_or_report+0xa3/0x120
       ? report_bug+0xe6/0x170
       ? __irq_work_queue_local+0x39/0xe0
       ? handle_bug+0x58/0x90
       ? exc_invalid_op+0x13/0x60
       ? asm_exc_invalid_op+0x16/0x20
       ? __list_del_entry_valid_or_report+0xa3/0x120
       gpiod_remove_lookup_table+0x22/0x60
       new_device_store+0x315/0x350 [gpio_aggregator]
       kernfs_fop_write_iter+0x137/0x1f0
       vfs_write+0x262/0x430
       ksys_write+0x60/0xd0
       do_syscall_64+0x6c/0x180
       entry_SYSCALL_64_after_hwframe+0x76/0x7e
       [...]
       </TASK>
      ---[ end trace 0000000000000000 ]---
    
    Fixes: 828546e24280 ("gpio: Add GPIO Aggregator")
    Cc: stable@vger.kernel.org
    Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
    Link: https://lore.kernel.org/r/20250224143134.3024598-2-koichiro.den@canonical.com
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

gpio: rcar: Fix missing of_node_put() call [+ + +]
Author: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Date:   Wed Mar 5 16:37:50 2025 +0000

    gpio: rcar: Fix missing of_node_put() call
    
    [ Upstream commit 391b41f983bf7ff853de44704d8e14e7cc648a9b ]
    
    of_parse_phandle_with_fixed_args() requires its caller to
    call into of_node_put() on the node pointer from the output
    structure, but such a call is currently missing.
    
    Call into of_node_put() to rectify that.
    
    Fixes: 159f8a0209af ("gpio-rcar: Add DT support")
    Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
    Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Link: https://lore.kernel.org/r/20250305163753.34913-2-fabrizio.castro.jz@renesas.com
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

gpio: rcar: Use raw_spinlock to protect register access [+ + +]
Author: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Date:   Tue Jan 21 14:58:33 2025 +0100

    gpio: rcar: Use raw_spinlock to protect register access
    
    commit f02c41f87cfe61440c18bf77d1ef0a884b9ee2b5 upstream.
    
    Use raw_spinlock in order to fix spurious messages about invalid context
    when spinlock debugging is enabled. The lock is only used to serialize
    register access.
    
        [    4.239592] =============================
        [    4.239595] [ BUG: Invalid wait context ]
        [    4.239599] 6.13.0-rc7-arm64-renesas-05496-gd088502a519f #35 Not tainted
        [    4.239603] -----------------------------
        [    4.239606] kworker/u8:5/76 is trying to lock:
        [    4.239609] ffff0000091898a0 (&p->lock){....}-{3:3}, at: gpio_rcar_config_interrupt_input_mode+0x34/0x164
        [    4.239641] other info that might help us debug this:
        [    4.239643] context-{5:5}
        [    4.239646] 5 locks held by kworker/u8:5/76:
        [    4.239651]  #0: ffff0000080fb148 ((wq_completion)async){+.+.}-{0:0}, at: process_one_work+0x190/0x62c
        [    4.250180] OF: /soc/sound@ec500000/ports/port@0/endpoint: Read of boolean property 'frame-master' with a value.
        [    4.254094]  #1: ffff80008299bd80 ((work_completion)(&entry->work)){+.+.}-{0:0}, at: process_one_work+0x1b8/0x62c
        [    4.254109]  #2: ffff00000920c8f8
        [    4.258345] OF: /soc/sound@ec500000/ports/port@1/endpoint: Read of boolean property 'bitclock-master' with a value.
        [    4.264803]  (&dev->mutex){....}-{4:4}, at: __device_attach_async_helper+0x3c/0xdc
        [    4.264820]  #3: ffff00000a50ca40 (request_class#2){+.+.}-{4:4}, at: __setup_irq+0xa0/0x690
        [    4.264840]  #4:
        [    4.268872] OF: /soc/sound@ec500000/ports/port@1/endpoint: Read of boolean property 'frame-master' with a value.
        [    4.273275] ffff00000a50c8c8 (lock_class){....}-{2:2}, at: __setup_irq+0xc4/0x690
        [    4.296130] renesas_sdhi_internal_dmac ee100000.mmc: mmc1 base at 0x00000000ee100000, max clock rate 200 MHz
        [    4.304082] stack backtrace:
        [    4.304086] CPU: 1 UID: 0 PID: 76 Comm: kworker/u8:5 Not tainted 6.13.0-rc7-arm64-renesas-05496-gd088502a519f #35
        [    4.304092] Hardware name: Renesas Salvator-X 2nd version board based on r8a77965 (DT)
        [    4.304097] Workqueue: async async_run_entry_fn
        [    4.304106] Call trace:
        [    4.304110]  show_stack+0x14/0x20 (C)
        [    4.304122]  dump_stack_lvl+0x6c/0x90
        [    4.304131]  dump_stack+0x14/0x1c
        [    4.304138]  __lock_acquire+0xdfc/0x1584
        [    4.426274]  lock_acquire+0x1c4/0x33c
        [    4.429942]  _raw_spin_lock_irqsave+0x5c/0x80
        [    4.434307]  gpio_rcar_config_interrupt_input_mode+0x34/0x164
        [    4.440061]  gpio_rcar_irq_set_type+0xd4/0xd8
        [    4.444422]  __irq_set_trigger+0x5c/0x178
        [    4.448435]  __setup_irq+0x2e4/0x690
        [    4.452012]  request_threaded_irq+0xc4/0x190
        [    4.456285]  devm_request_threaded_irq+0x7c/0xf4
        [    4.459398] ata1: link resume succeeded after 1 retries
        [    4.460902]  mmc_gpiod_request_cd_irq+0x68/0xe0
        [    4.470660]  mmc_start_host+0x50/0xac
        [    4.474327]  mmc_add_host+0x80/0xe4
        [    4.477817]  tmio_mmc_host_probe+0x2b0/0x440
        [    4.482094]  renesas_sdhi_probe+0x488/0x6f4
        [    4.486281]  renesas_sdhi_internal_dmac_probe+0x60/0x78
        [    4.491509]  platform_probe+0x64/0xd8
        [    4.495178]  really_probe+0xb8/0x2a8
        [    4.498756]  __driver_probe_device+0x74/0x118
        [    4.503116]  driver_probe_device+0x3c/0x154
        [    4.507303]  __device_attach_driver+0xd4/0x160
        [    4.511750]  bus_for_each_drv+0x84/0xe0
        [    4.515588]  __device_attach_async_helper+0xb0/0xdc
        [    4.520470]  async_run_entry_fn+0x30/0xd8
        [    4.524481]  process_one_work+0x210/0x62c
        [    4.528494]  worker_thread+0x1ac/0x340
        [    4.532245]  kthread+0x10c/0x110
        [    4.535476]  ret_from_fork+0x10/0x20
    
    Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20250121135833.3769310-1-niklas.soderlund+renesas@ragnatech.se
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

gpio: vf610: add locking to gpio direction functions [+ + +]
Author: Johan Korsnes <johan.korsnes@remarkable.no>
Date:   Mon Feb 17 10:16:43 2025 +0100

    gpio: vf610: add locking to gpio direction functions
    
    [ Upstream commit 4e667a1968099c6deadee2313ecd648f8f0a8956 ]
    
    Add locking to `vf610_gpio_direction_input|output()` functions. Without
    this locking, a race condition exists between concurrent calls to these
    functions, potentially leading to incorrect GPIO direction settings.
    
    To verify the correctness of this fix, a `trylock` patch was applied,
    where after a couple of reboots the race was confirmed. I.e., one user
    had to wait before acquiring the lock. With this patch the race has not
    been encountered. It's worth mentioning that any type of debugging
    (printing, tracing, etc.) would "resolve"/hide the issue.
    
    Fixes: 659d8a62311f ("gpio: vf610: add imx7ulp support")
    Signed-off-by: Johan Korsnes <johan.korsnes@remarkable.no>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
    Cc: Bartosz Golaszewski <brgl@bgdev.pl>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20250217091643.679644-1-johan.korsnes@remarkable.no
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

gpio: vf610: use generic device_get_match_data() [+ + +]
Author: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Date:   Mon Oct 7 12:25:49 2024 +0200

    gpio: vf610: use generic device_get_match_data()
    
    [ Upstream commit 1b35c124f961b355dafb1906c591191bd0b37417 ]
    
    There's no need to use the OF-specific variant to get the match data.
    Switch to using device_get_match_data() and with that remove the of.h
    include. Also remove of_irq.h as none of its interfaces is used here and
    order the includes in alphabetical order.
    
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Link: https://lore.kernel.org/r/20241007102549.34926-1-brgl@bgdev.pl
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
    Stable-dep-of: 4e667a196809 ("gpio: vf610: add locking to gpio direction functions")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
HID: appleir: Fix potential NULL dereference at raw event handle [+ + +]
Author: Daniil Dulov <d.dulov@aladdin.ru>
Date:   Mon Feb 24 20:30:30 2025 +0300

    HID: appleir: Fix potential NULL dereference at raw event handle
    
    commit 2ff5baa9b5275e3acafdf7f2089f74cccb2f38d1 upstream.
    
    Syzkaller reports a NULL pointer dereference issue in input_event().
    
    BUG: KASAN: null-ptr-deref in instrument_atomic_read include/linux/instrumented.h:68 [inline]
    BUG: KASAN: null-ptr-deref in _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline]
    BUG: KASAN: null-ptr-deref in is_event_supported drivers/input/input.c:67 [inline]
    BUG: KASAN: null-ptr-deref in input_event+0x42/0xa0 drivers/input/input.c:395
    Read of size 8 at addr 0000000000000028 by task syz-executor199/2949
    
    CPU: 0 UID: 0 PID: 2949 Comm: syz-executor199 Not tainted 6.13.0-rc4-syzkaller-00076-gf097a36ef88d #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
    Call Trace:
     <IRQ>
     __dump_stack lib/dump_stack.c:94 [inline]
     dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
     kasan_report+0xd9/0x110 mm/kasan/report.c:602
     check_region_inline mm/kasan/generic.c:183 [inline]
     kasan_check_range+0xef/0x1a0 mm/kasan/generic.c:189
     instrument_atomic_read include/linux/instrumented.h:68 [inline]
     _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline]
     is_event_supported drivers/input/input.c:67 [inline]
     input_event+0x42/0xa0 drivers/input/input.c:395
     input_report_key include/linux/input.h:439 [inline]
     key_down drivers/hid/hid-appleir.c:159 [inline]
     appleir_raw_event+0x3e5/0x5e0 drivers/hid/hid-appleir.c:232
     __hid_input_report.constprop.0+0x312/0x440 drivers/hid/hid-core.c:2111
     hid_ctrl+0x49f/0x550 drivers/hid/usbhid/hid-core.c:484
     __usb_hcd_giveback_urb+0x389/0x6e0 drivers/usb/core/hcd.c:1650
     usb_hcd_giveback_urb+0x396/0x450 drivers/usb/core/hcd.c:1734
     dummy_timer+0x17f7/0x3960 drivers/usb/gadget/udc/dummy_hcd.c:1993
     __run_hrtimer kernel/time/hrtimer.c:1739 [inline]
     __hrtimer_run_queues+0x20a/0xae0 kernel/time/hrtimer.c:1803
     hrtimer_run_softirq+0x17d/0x350 kernel/time/hrtimer.c:1820
     handle_softirqs+0x206/0x8d0 kernel/softirq.c:561
     __do_softirq kernel/softirq.c:595 [inline]
     invoke_softirq kernel/softirq.c:435 [inline]
     __irq_exit_rcu+0xfa/0x160 kernel/softirq.c:662
     irq_exit_rcu+0x9/0x30 kernel/softirq.c:678
     instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1049 [inline]
     sysvec_apic_timer_interrupt+0x90/0xb0 arch/x86/kernel/apic/apic.c:1049
     </IRQ>
     <TASK>
     asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702
     __mod_timer+0x8f6/0xdc0 kernel/time/timer.c:1185
     add_timer+0x62/0x90 kernel/time/timer.c:1295
     schedule_timeout+0x11f/0x280 kernel/time/sleep_timeout.c:98
     usbhid_wait_io+0x1c7/0x380 drivers/hid/usbhid/hid-core.c:645
     usbhid_init_reports+0x19f/0x390 drivers/hid/usbhid/hid-core.c:784
     hiddev_ioctl+0x1133/0x15b0 drivers/hid/usbhid/hiddev.c:794
     vfs_ioctl fs/ioctl.c:51 [inline]
     __do_sys_ioctl fs/ioctl.c:906 [inline]
     __se_sys_ioctl fs/ioctl.c:892 [inline]
     __x64_sys_ioctl+0x190/0x200 fs/ioctl.c:892
     do_syscall_x64 arch/x86/entry/common.c:52 [inline]
     do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
     entry_SYSCALL_64_after_hwframe+0x77/0x7f
     </TASK>
    
    This happens due to the malformed report items sent by the emulated device
    which results in a report, that has no fields, being added to the report list.
    Due to this appleir_input_configured() is never called, hidinput_connect()
    fails which results in the HID_CLAIMED_INPUT flag is not being set. However,
    it  does not make appleir_probe() fail and lets the event callback to be
    called without the associated input device.
    
    Thus, add a check for the HID_CLAIMED_INPUT flag and leave the event hook
    early if the driver didn't claim any input_dev for some reason. Moreover,
    some other hid drivers accessing input_dev in their event callbacks do have
    similar checks, too.
    
    Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
    
    Fixes: 9a4a5574ce42 ("HID: appleir: add support for Apple ir devices")
    Cc: stable@vger.kernel.org
    Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
    Signed-off-by: Jiri Kosina <jkosina@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

HID: google: fix unused variable warning under !CONFIG_ACPI [+ + +]
Author: Yu-Chun Lin <eleanor15x@gmail.com>
Date:   Tue Feb 18 00:50:13 2025 +0800

    HID: google: fix unused variable warning under !CONFIG_ACPI
    
    [ Upstream commit 4bd0725c09f377ffaf22b834241f6c050742e4fc ]
    
    As reported by the kernel test robot, the following warning occurs:
    
    >> drivers/hid/hid-google-hammer.c:261:36: warning: 'cbas_ec_acpi_ids' defined but not used [-Wunused-const-variable=]
         261 | static const struct acpi_device_id cbas_ec_acpi_ids[] = {
             |                                    ^~~~~~~~~~~~~~~~
    
    The 'cbas_ec_acpi_ids' array is only used when CONFIG_ACPI is enabled.
    Wrapping its definition and 'MODULE_DEVICE_TABLE' in '#ifdef CONFIG_ACPI'
    prevents a compiler warning when ACPI is disabled.
    
    Fixes: eb1aac4c8744f75 ("HID: google: add support tablet mode switch for Whiskers")
    Reported-by: kernel test robot <lkp@intel.com>
    Closes: https://lore.kernel.org/oe-kbuild-all/202501201141.jctFH5eB-lkp@intel.com/
    Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

HID: hid-steam: Fix use-after-free when detaching device [+ + +]
Author: Vicki Pfau <vi@endrift.com>
Date:   Thu Feb 27 15:41:33 2025 -0800

    HID: hid-steam: Fix use-after-free when detaching device
    
    [ Upstream commit e53fc232a65f7488ab75d03a5b95f06aaada7262 ]
    
    When a hid-steam device is removed it must clean up the client_hdev used for
    intercepting hidraw access. This can lead to scheduling deferred work to
    reattach the input device. Though the cleanup cancels the deferred work, this
    was done before the client_hdev itself is cleaned up, so it gets rescheduled.
    This patch fixes the ordering to make sure the deferred work is properly
    canceled.
    
    Reported-by: syzbot+0154da2d403396b2bd59@syzkaller.appspotmail.com
    Fixes: 79504249d7e2 ("HID: hid-steam: Move hidraw input (un)registering to work")
    Signed-off-by: Vicki Pfau <vi@endrift.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

HID: intel-ish-hid: Fix use-after-free issue in hid_ishtp_cl_remove() [+ + +]
Author: Zhang Lixu <lixu.zhang@intel.com>
Date:   Tue Feb 18 14:37:29 2025 +0800

    HID: intel-ish-hid: Fix use-after-free issue in hid_ishtp_cl_remove()
    
    [ Upstream commit 823987841424289339fdb4ba90e6d2c3792836db ]
    
    During the `rmmod` operation for the `intel_ishtp_hid` driver, a
    use-after-free issue can occur in the hid_ishtp_cl_remove() function.
    The function hid_ishtp_cl_deinit() is called before ishtp_hid_remove(),
    which can lead to accessing freed memory or resources during the
    removal process.
    
    Call Trace:
     ? ishtp_cl_send+0x168/0x220 [intel_ishtp]
     ? hid_output_report+0xe3/0x150 [hid]
     hid_ishtp_set_feature+0xb5/0x120 [intel_ishtp_hid]
     ishtp_hid_request+0x7b/0xb0 [intel_ishtp_hid]
     hid_hw_request+0x1f/0x40 [hid]
     sensor_hub_set_feature+0x11f/0x190 [hid_sensor_hub]
     _hid_sensor_power_state+0x147/0x1e0 [hid_sensor_trigger]
     hid_sensor_runtime_resume+0x22/0x30 [hid_sensor_trigger]
     sensor_hub_remove+0xa8/0xe0 [hid_sensor_hub]
     hid_device_remove+0x49/0xb0 [hid]
     hid_destroy_device+0x6f/0x90 [hid]
     ishtp_hid_remove+0x42/0x70 [intel_ishtp_hid]
     hid_ishtp_cl_remove+0x6b/0xb0 [intel_ishtp_hid]
     ishtp_cl_device_remove+0x4a/0x60 [intel_ishtp]
     ...
    
    Additionally, ishtp_hid_remove() is a HID level power off, which should
    occur before the ISHTP level disconnect.
    
    This patch resolves the issue by reordering the calls in
    hid_ishtp_cl_remove(). The function ishtp_hid_remove() is now
    called before hid_ishtp_cl_deinit().
    
    Fixes: f645a90e8ff7 ("HID: intel-ish-hid: ishtp-hid-client: use helper functions for connection")
    Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
    Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

HID: intel-ish-hid: Fix use-after-free issue in ishtp_hid_remove() [+ + +]
Author: Zhang Lixu <lixu.zhang@intel.com>
Date:   Tue Feb 18 14:37:30 2025 +0800

    HID: intel-ish-hid: Fix use-after-free issue in ishtp_hid_remove()
    
    [ Upstream commit 07583a0010696a17fb0942e0b499a62785c5fc9f ]
    
    The system can experience a random crash a few minutes after the driver is
    removed. This issue occurs due to improper handling of memory freeing in
    the ishtp_hid_remove() function.
    
    The function currently frees the `driver_data` directly within the loop
    that destroys the HID devices, which can lead to accessing freed memory.
    Specifically, `hid_destroy_device()` uses `driver_data` when it calls
    `hid_ishtp_set_feature()` to power off the sensor, so freeing
    `driver_data` beforehand can result in accessing invalid memory.
    
    This patch resolves the issue by storing the `driver_data` in a temporary
    variable before calling `hid_destroy_device()`, and then freeing the
    `driver_data` after the device is destroyed.
    
    Fixes: 0b28cb4bcb17 ("HID: intel-ish-hid: ISH HID client driver")
    Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
    Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
hwmon: (ad7314) Validate leading zero bits and return error [+ + +]
Author: Erik Schumacher <erik.schumacher@iris-sensing.com>
Date:   Mon Feb 24 09:19:04 2025 +0000

    hwmon: (ad7314) Validate leading zero bits and return error
    
    [ Upstream commit e278d5e8aef4c0a1d9a9fa8b8910d713a89aa800 ]
    
    Leading zero bits are sent on the bus before the temperature value is
    transmitted. If any of these bits are high, the connection might be
    unstable or there could be no AD7314 / ADT730x (or compatible) at all.
    Return -EIO in that case.
    
    Signed-off-by: Erik Schumacher <erik.schumacher@iris-sensing.com>
    Fixes: 4f3a659581cab ("hwmon: AD7314 driver (ported from IIO)")
    Link: https://lore.kernel.org/r/24a50c2981a318580aca8f50d23be7987b69ea00.camel@iris-sensing.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

hwmon: (ntc_thermistor) Fix the ncpXXxh103 sensor table [+ + +]
Author: Maud Spierings <maudspierings@gocontroll.com>
Date:   Thu Feb 27 13:57:53 2025 +0100

    hwmon: (ntc_thermistor) Fix the ncpXXxh103 sensor table
    
    [ Upstream commit 1c7932d5ae0f5c22fa52ac811b4c427bbca5aff5 ]
    
    I could not find a single table that has the values currently present in
    the table, change it to the actual values that can be found in [1]/[2]
    and [3] (page 15 column 2)
    
    [1]: https://www.murata.com/products/productdetail?partno=NCP15XH103F03RC
    [2]: https://www.murata.com/products/productdata/8796836626462/NTHCG83.txt?1437969843000
    [3]: https://nl.mouser.com/datasheet/2/281/r44e-522712.pdf
    
    Fixes: 54ce3a0d8011 ("hwmon: (ntc_thermistor) Add support for ncpXXxh103")
    Signed-off-by: Maud Spierings <maudspierings@gocontroll.com>
    Link: https://lore.kernel.org/r/20250227-ntc_thermistor_fixes-v1-3-70fa73200b52@gocontroll.com
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

hwmon: (peci/dimmtemp) Do not provide fake thresholds data [+ + +]
Author: Paul Fertser <fercerpav@gmail.com>
Date:   Thu Jan 23 15:20:02 2025 +0300

    hwmon: (peci/dimmtemp) Do not provide fake thresholds data
    
    commit 5797c04400ee117bfe459ff1e468d0ea38054ab4 upstream.
    
    When an Icelake or Sapphire Rapids CPU isn't providing the maximum and
    critical thresholds for particular DIMM the driver should return an
    error to the userspace instead of giving it stale (best case) or wrong
    (the structure contains all zeros after kzalloc() call) data.
    
    The issue can be reproduced by binding the peci driver while the host is
    fully booted and idle, this makes PECI interaction unreliable enough.
    
    Fixes: 73bc1b885dae ("hwmon: peci: Add dimmtemp driver")
    Fixes: 621995b6d795 ("hwmon: (peci/dimmtemp) Add Sapphire Rapids support")
    Cc: stable@vger.kernel.org
    Signed-off-by: Paul Fertser <fercerpav@gmail.com>
    Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com>
    Link: https://lore.kernel.org/r/20250123122003.6010-1-fercerpav@gmail.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

hwmon: (pmbus) Initialise page count in pmbus_identify() [+ + +]
Author: Titus Rwantare <titusr@google.com>
Date:   Thu Feb 27 22:24:55 2025 +0000

    hwmon: (pmbus) Initialise page count in pmbus_identify()
    
    [ Upstream commit 6b6e2e8fd0de3fa7c6f4f8fe6841b01770b2e7bc ]
    
    The `pmbus_identify()` function fails to correctly determine the number
    of supported pages on PMBus devices. This occurs because `info->pages`
    is implicitly zero-initialised, and `pmbus_set_page()` does not perform
    writes to the page register if `info->pages` is not yet initialised.
    Without this patch, `info->pages` is always set to the maximum after
    scanning.
    
    This patch initialises `info->pages` to `PMBUS_PAGES` before the probing
    loop, enabling `pmbus_set_page()` writes to make it out onto the bus
    correctly identifying the number of pages. `PMBUS_PAGES` seemed like a
    reasonable non-zero number because that's the current result of the
    identification process.
    
    Testing was done with a PMBus device in QEMU.
    
    Signed-off-by: Titus Rwantare <titusr@google.com>
    Fixes: 442aba78728e7 ("hwmon: PMBus device driver")
    Link: https://lore.kernel.org/r/20250227222455.2583468-1-titusr@google.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

hwmon: fix a NULL vs IS_ERR_OR_NULL() check in xgene_hwmon_probe() [+ + +]
Author: Xinghuo Chen <xinghuo.chen@foxmail.com>
Date:   Mon Mar 3 07:57:33 2025 -0500

    hwmon: fix a NULL vs IS_ERR_OR_NULL() check in xgene_hwmon_probe()
    
    [ Upstream commit 10fce7ebe888fa8c97eee7e317a47e7603e5e78d ]
    
    The devm_memremap() function returns error pointers on error,
    it doesn't return NULL.
    
    Fixes: c7cefce03e69 ("hwmon: (xgene) access mailbox as RAM")
    Signed-off-by: Xinghuo Chen <xinghuo.chen@foxmail.com>
    Link: https://lore.kernel.org/r/tencent_9AD8E7683EC29CAC97496B44F3F865BA070A@qq.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
hwpoison, memory_hotplug: lock folio before unmap hwpoisoned folio [+ + +]
Author: Ma Wupeng <mawupeng1@huawei.com>
Date:   Mon Feb 17 09:43:29 2025 +0800

    hwpoison, memory_hotplug: lock folio before unmap hwpoisoned folio
    
    commit af288a426c3e3552b62595c6138ec6371a17dbba upstream.
    
    Commit b15c87263a69 ("hwpoison, memory_hotplug: allow hwpoisoned pages to
    be offlined) add page poison checks in do_migrate_range in order to make
    offline hwpoisoned page possible by introducing isolate_lru_page and
    try_to_unmap for hwpoisoned page.  However folio lock must be held before
    calling try_to_unmap.  Add it to fix this problem.
    
    Warning will be produced if folio is not locked during unmap:
    
      ------------[ cut here ]------------
      kernel BUG at ./include/linux/swapops.h:400!
      Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 4 UID: 0 PID: 411 Comm: bash Tainted: G        W          6.13.0-rc1-00016-g3c434c7ee82a-dirty #41
      Tainted: [W]=WARN
      Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
      pstate: 40400005 (nZcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      pc : try_to_unmap_one+0xb08/0xd3c
      lr : try_to_unmap_one+0x3dc/0xd3c
      Call trace:
       try_to_unmap_one+0xb08/0xd3c (P)
       try_to_unmap_one+0x3dc/0xd3c (L)
       rmap_walk_anon+0xdc/0x1f8
       rmap_walk+0x3c/0x58
       try_to_unmap+0x88/0x90
       unmap_poisoned_folio+0x30/0xa8
       do_migrate_range+0x4a0/0x568
       offline_pages+0x5a4/0x670
       memory_block_action+0x17c/0x374
       memory_subsys_offline+0x3c/0x78
       device_offline+0xa4/0xd0
       state_store+0x8c/0xf0
       dev_attr_store+0x18/0x2c
       sysfs_kf_write+0x44/0x54
       kernfs_fop_write_iter+0x118/0x1a8
       vfs_write+0x3a8/0x4bc
       ksys_write+0x6c/0xf8
       __arm64_sys_write+0x1c/0x28
       invoke_syscall+0x44/0x100
       el0_svc_common.constprop.0+0x40/0xe0
       do_el0_svc+0x1c/0x28
       el0_svc+0x30/0xd0
       el0t_64_sync_handler+0xc8/0xcc
       el0t_64_sync+0x198/0x19c
      Code: f9407be0 b5fff320 d4210000 17ffff97 (d4210000)
      ---[ end trace 0000000000000000 ]---
    
    Link: https://lkml.kernel.org/r/20250217014329.3610326-4-mawupeng1@huawei.com
    Fixes: b15c87263a69 ("hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined")
    Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Acked-by: Miaohe Lin <linmiaohe@huawei.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
    Cc: Oscar Salvador <osalvador@suse.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
iio: adc: ad7192: fix channel select [+ + +]
Author: Markus Burri <markus.burri@mt.com>
Date:   Fri Jan 24 16:07:03 2025 +0100

    iio: adc: ad7192: fix channel select
    
    commit 21d7241faf406e8aee3ce348451cc362d5db6a02 upstream.
    
    Channel configuration doesn't work as expected.
    For FIELD_PREP the bit mask is needed and not the bit number.
    
    Fixes: 874bbd1219c7 ("iio: adc: ad7192: Use bitfield access macros")
    Signed-off-by: Markus Burri <markus.burri@mt.com>
    Reviewed-by: Nuno Sá <nuno.sa@analog.com>
    Link: https://patch.msgid.link/20250124150703.97848-1-markus.burri@mt.com
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

iio: adc: at91-sama5d2_adc: fix sama7g5 realbits value [+ + +]
Author: Nayab Sayed <nayabbasha.sayed@microchip.com>
Date:   Wed Jan 15 11:37:04 2025 +0530

    iio: adc: at91-sama5d2_adc: fix sama7g5 realbits value
    
    commit aa5119c36d19639397d29ef305aa53a5ecd72b27 upstream.
    
    The number of valid bits in SAMA7G5 ADC channel data register are 16.
    Hence changing the realbits value to 16
    
    Fixes: 840bf6cb983f ("iio: adc: at91-sama5d2_adc: add support for sama7g5 device")
    Signed-off-by: Nayab Sayed <nayabbasha.sayed@microchip.com>
    Link: https://patch.msgid.link/20250115-fix-sama7g5-adc-realbits-v2-1-58a6e4087584@microchip.com
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

iio: dac: ad3552r: clear reset status flag [+ + +]
Author: Angelo Dureghello <adureghello@baylibre.com>
Date:   Sat Jan 25 17:24:32 2025 +0100

    iio: dac: ad3552r: clear reset status flag
    
    commit e17b9f20da7d2bc1f48878ab2230523b2512d965 upstream.
    
    Clear reset status flag, to keep error status register clean after reset
    (ad3552r manual, rev B table 38).
    
    Reset error flag was left to 1, so debugging registers, the "Error
    Status Register" was dirty (0x01). It is important to clear this bit, so
    if there is any reset event over normal working mode, it is possible to
    detect it.
    
    Fixes: 8f2b54824b28 ("drivers:iio:dac: Add AD3552R driver support")
    Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
    Link: https://patch.msgid.link/20250125-wip-bl-ad3552r-clear-reset-v2-1-aa3a27f3ff8c@baylibre.com
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

iio: filter: admv8818: Force initialization of SDO [+ + +]
Author: Sam Winchenbach <swinchenbach@arka.org>
Date:   Mon Feb 3 13:34:34 2025 +0000

    iio: filter: admv8818: Force initialization of SDO
    
    commit cc2c3540d9477a9931fb0fd851fcaeba524a5b35 upstream.
    
    When a weak pull-up is present on the SDO line, regmap_update_bits fails
    to write both the SOFTRESET and SDOACTIVE bits because it incorrectly
    reads them as already set.
    
    Since the soft reset disables the SDO line, performing a
    read-modify-write operation on ADI_SPI_CONFIG_A to enable the SDO line
    doesn't make sense. This change directly writes to the register instead
    of using regmap_update_bits.
    
    Fixes: f34fe888ad05 ("iio:filter:admv8818: add support for ADMV8818")
    Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
    Link: https://patch.msgid.link/SA1P110MB106904C961B0F3FAFFED74C0BCF5A@SA1P110MB1069.NAMP110.PROD.OUTLOOK.COM
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

iio: light: apds9306: fix max_scale_nano values [+ + +]
Author: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Date:   Sun Jan 12 01:08:11 2025 +0100

    iio: light: apds9306: fix max_scale_nano values
    
    commit a96d3e2beca0e51c8444d0a3b6b3ec484c4c5a8f upstream.
    
    The two provided max_scale_nano values must be multiplied by 100 and 10
    respectively to achieve nano units. According to the comments:
    
    Max scale for apds0306 is 16.326432 → the fractional part is 0.326432,
    which is 326432000 in NANO. The current value is 3264320.
    
    Max scale for apds0306-065 is 14.09721 → the fractional part is 0.09712,
    which is 97120000 in NANO. The current value is 9712000.
    
    Update max_scale_nano initialization to use the right NANO fractional
    parts.
    
    Cc: stable@vger.kernel.org
    Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
    Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
    Tested-by: subhajit.ghosh@tweaklogic.com
    Link: https://patch.msgid.link/20250112-apds9306_nano_vals-v1-1-82fb145d0b16@gmail.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
intel_th: pci: Add Arrow Lake support [+ + +]
Author: Pawel Chmielewski <pawel.chmielewski@intel.com>
Date:   Tue Feb 11 20:50:15 2025 +0200

    intel_th: pci: Add Arrow Lake support
    
    commit b5edccae9f447a92d475267d94c33f4926963eec upstream.
    
    Add support for the Trace Hub in Arrow Lake.
    
    Signed-off-by: Pawel Chmielewski <pawel.chmielewski@intel.com>
    Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Cc: stable@kernel.org
    Link: https://lore.kernel.org/r/20250211185017.1759193-4-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

intel_th: pci: Add Panther Lake-H support [+ + +]
Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Date:   Tue Feb 11 20:50:16 2025 +0200

    intel_th: pci: Add Panther Lake-H support
    
    commit a70034d6c0d5f3cdee40bb00a578e17fd2ebe426 upstream.
    
    Add support for the Trace Hub in Panther Lake-H.
    
    Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Cc: stable@kernel.org
    Link: https://lore.kernel.org/r/20250211185017.1759193-5-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

intel_th: pci: Add Panther Lake-P/U support [+ + +]
Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Date:   Tue Feb 11 20:50:17 2025 +0200

    intel_th: pci: Add Panther Lake-P/U support
    
    commit 49114ff05770264ae233f50023fc64a719a9dcf9 upstream.
    
    Add support for the Trace Hub in Panther Lake-P/U.
    
    Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Cc: stable@kernel.org
    Link: https://lore.kernel.org/r/20250211185017.1759193-6-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
kbuild: hdrcheck: fix cross build with clang [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue Feb 25 11:00:31 2025 +0100

    kbuild: hdrcheck: fix cross build with clang
    
    [ Upstream commit 02e9a22ceef0227175e391902d8760425fa072c6 ]
    
    The headercheck tries to call clang with a mix of compiler arguments
    that don't include the target architecture. When building e.g. x86
    headers on arm64, this produces a warning like
    
       clang: warning: unknown platform, assuming -mfloat-abi=soft
    
    Add in the KBUILD_CPPFLAGS, which contain the target, in order to make it
    build properly.
    
    See also 1b71c2fb04e7 ("kbuild: userprogs: fix bitsize and target
    detection on clang").
    
    Reviewed-by: Nathan Chancellor <nathan@kernel.org>
    Fixes: feb843a469fb ("kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

kbuild: rust: remove the `alloc` crate and `GlobalAlloc` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:54 2025 +0100

    kbuild: rust: remove the `alloc` crate and `GlobalAlloc`
    
    commit 392e34b6bc22077ef63abf62387ea3e9f39418c1 upstream.
    
    Now that we have our own `Allocator`, `Box` and `Vec` types we can remove
    Rust's `alloc` crate and the `new_uninit` unstable feature.
    
    Also remove `Kmalloc`'s `GlobalAlloc` implementation -- we can't remove
    this in a separate patch, since the `alloc` crate requires a
    `#[global_allocator]` to set, that implements `GlobalAlloc`.
    
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-29-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

kbuild: userprogs: use correct lld when linking through clang [+ + +]
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Date:   Mon Feb 17 08:27:54 2025 +0100

    kbuild: userprogs: use correct lld when linking through clang
    
    commit dfc1b168a8c4b376fa222b27b97c2c4ad4b786e1 upstream.
    
    The userprog infrastructure links objects files through $(CC).
    Either explicitly by manually calling $(CC) on multiple object files or
    implicitly by directly compiling a source file to an executable.
    The documentation at Documentation/kbuild/llvm.rst indicates that ld.lld
    would be used for linking if LLVM=1 is specified.
    However clang instead will use either a globally installed cross linker
    from $PATH called ${target}-ld or fall back to the system linker, which
    probably does not support crosslinking.
    For the normal kernel build this is not an issue because the linker is
    always executed directly, without the compiler being involved.
    
    Explicitly pass --ld-path to clang so $(LD) is respected.
    As clang 13.0.1 is required to build the kernel, this option is available.
    
    Fixes: 7f3a59db274c ("kbuild: add infrastructure to build userspace programs")
    Cc: stable@vger.kernel.org # needs wrapping in $(cc-option) for < 6.9
    Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
    Reviewed-by: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ksmbd: fix bug on trap in smb2_lock [+ + +]
Author: Namjae Jeon <linkinjeon@kernel.org>
Date:   Thu Feb 27 15:49:10 2025 +0900

    ksmbd: fix bug on trap in smb2_lock
    
    commit e26e2d2e15daf1ab33e0135caf2304a0cfa2744b upstream.
    
    If lock count is greater than 1, flags could be old value.
    It should be checked with flags of smb_lock, not flags.
    It will cause bug-on trap from locks_free_lock in error handling
    routine.
    
    Cc: stable@vger.kernel.org
    Reported-by: Norbert Szetei <norbert@doyensec.com>
    Tested-by: Norbert Szetei <norbert@doyensec.com>
    Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ksmbd: fix out-of-bounds in parse_sec_desc() [+ + +]
Author: Namjae Jeon <linkinjeon@kernel.org>
Date:   Tue Feb 18 22:49:50 2025 +0900

    ksmbd: fix out-of-bounds in parse_sec_desc()
    
    commit d6e13e19063db24f94b690159d0633aaf72a0f03 upstream.
    
    If osidoffset, gsidoffset and dacloffset could be greater than smb_ntsd
    struct size. If it is smaller, It could cause slab-out-of-bounds.
    And when validating sid, It need to check it included subauth array size.
    
    Cc: stable@vger.kernel.org
    Reported-by: Norbert Szetei <norbert@doyensec.com>
    Tested-by: Norbert Szetei <norbert@doyensec.com>
    Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ksmbd: fix type confusion via race condition when using ipc_msg_send_request [+ + +]
Author: Namjae Jeon <linkinjeon@kernel.org>
Date:   Fri Feb 21 14:16:23 2025 +0900

    ksmbd: fix type confusion via race condition when using ipc_msg_send_request
    
    commit e2ff19f0b7a30e03516e6eb73b948e27a55bc9d2 upstream.
    
    req->handle is allocated using ksmbd_acquire_id(&ipc_ida), based on
    ida_alloc. req->handle from ksmbd_ipc_login_request and
    FSCTL_PIPE_TRANSCEIVE ioctl can be same and it could lead to type confusion
    between messages, resulting in access to unexpected parts of memory after
    an incorrect delivery. ksmbd check type of ipc response but missing add
    continue to check next ipc reponse.
    
    Cc: stable@vger.kernel.org
    Reported-by: Norbert Szetei <norbert@doyensec.com>
    Tested-by: Norbert Szetei <norbert@doyensec.com>
    Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ksmbd: fix use-after-free in smb2_lock [+ + +]
Author: Namjae Jeon <linkinjeon@kernel.org>
Date:   Wed Feb 26 15:44:02 2025 +0900

    ksmbd: fix use-after-free in smb2_lock
    
    commit 84d2d1641b71dec326e8736a749b7ee76a9599fc upstream.
    
    If smb_lock->zero_len has value, ->llist of smb_lock is not delete and
    flock is old one. It will cause use-after-free on error handling
    routine.
    
    Cc: stable@vger.kernel.org
    Reported-by: Norbert Szetei <norbert@doyensec.com>
    Tested-by: Norbert Szetei <norbert@doyensec.com>
    Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
KVM: e500: always restore irqs [+ + +]
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Sun Jan 12 10:34:44 2025 +0100

    KVM: e500: always restore irqs
    
    commit 87ecfdbc699cc95fac73291b52650283ddcf929d upstream.
    
    If find_linux_pte fails, IRQs will not be restored.  This is unlikely
    to happen in practice since it would have been reported as hanging
    hosts, but it should of course be fixed anyway.
    
    Cc: stable@vger.kernel.org
    Reported-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

KVM: SVM: Drop DEBUGCTL[5:2] from guest's effective value [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Thu Feb 27 14:24:06 2025 -0800

    KVM: SVM: Drop DEBUGCTL[5:2] from guest's effective value
    
    commit ee89e8013383d50a27ea9bf3c8a69eed6799856f upstream.
    
    Drop bits 5:2 from the guest's effective DEBUGCTL value, as AMD changed
    the architectural behavior of the bits and broke backwards compatibility.
    On CPUs without BusLockTrap (or at least, in APMs from before ~2023),
    bits 5:2 controlled the behavior of external pins:
    
      Performance-Monitoring/Breakpoint Pin-Control (PBi)—Bits 5:2, read/write.
      Software uses thesebits to control the type of information reported by
      the four external performance-monitoring/breakpoint pins on the
      processor. When a PBi bit is cleared to 0, the corresponding external pin
      (BPi) reports performance-monitor information. When a PBi bit is set to
      1, the corresponding external pin (BPi) reports breakpoint information.
    
    With the introduction of BusLockTrap, presumably to be compatible with
    Intel CPUs, AMD redefined bit 2 to be BLCKDB:
    
      Bus Lock #DB Trap (BLCKDB)—Bit 2, read/write. Software sets this bit to
      enable generation of a #DB trap following successful execution of a bus
      lock when CPL is > 0.
    
    and redefined bits 5:3 (and bit 6) as "6:3 Reserved MBZ".
    
    Ideally, KVM would treat bits 5:2 as reserved.  Defer that change to a
    feature cleanup to avoid breaking existing guest in LTS kernels.  For now,
    drop the bits to retain backwards compatibility (of a sort).
    
    Note, dropping bits 5:2 is still a guest-visible change, e.g. if the guest
    is enabling LBRs *and* the legacy PBi bits, then the state of the PBi bits
    is visible to the guest, whereas now the guest will always see '0'.
    
    Reported-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Cc: stable@vger.kernel.org
    Reviewed-and-tested-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Link: https://lore.kernel.org/r/20250227222411.3490595-2-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

KVM: SVM: Manually context switch DEBUGCTL if LBR virtualization is disabled [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Thu Feb 27 14:24:09 2025 -0800

    KVM: SVM: Manually context switch DEBUGCTL if LBR virtualization is disabled
    
    commit 433265870ab3455b418885bff48fa5fd02f7e448 upstream.
    
    Manually load the guest's DEBUGCTL prior to VMRUN (and restore the host's
    value on #VMEXIT) if it diverges from the host's value and LBR
    virtualization is disabled, as hardware only context switches DEBUGCTL if
    LBR virtualization is fully enabled.  Running the guest with the host's
    value has likely been mildly problematic for quite some time, e.g. it will
    result in undesirable behavior if BTF diverges (with the caveat that KVM
    now suppresses guest BTF due to lack of support).
    
    But the bug became fatal with the introduction of Bus Lock Trap ("Detect"
    in kernel paralance) support for AMD (commit 408eb7417a92
    ("x86/bus_lock: Add support for AMD")), as a bus lock in the guest will
    trigger an unexpected #DB.
    
    Note, suppressing the bus lock #DB, i.e. simply resuming the guest without
    injecting a #DB, is not an option.  It wouldn't address the general issue
    with DEBUGCTL, e.g. for things like BTF, and there are other guest-visible
    side effects if BusLockTrap is left enabled.
    
    If BusLockTrap is disabled, then DR6.BLD is reserved-to-1; any attempts to
    clear it by software are ignored.  But if BusLockTrap is enabled, software
    can clear DR6.BLD:
    
      Software enables bus lock trap by setting DebugCtl MSR[BLCKDB] (bit 2)
      to 1.  When bus lock trap is enabled, ... The processor indicates that
      this #DB was caused by a bus lock by clearing DR6[BLD] (bit 11).  DR6[11]
      previously had been defined to be always 1.
    
    and clearing DR6.BLD is "sticky" in that it's not set (i.e. lowered) by
    other #DBs:
    
      All other #DB exceptions leave DR6[BLD] unmodified
    
    E.g. leaving BusLockTrap enable can confuse a legacy guest that writes '0'
    to reset DR6.
    
    Reported-by: rangemachine@gmail.com
    Reported-by: whanos@sergal.fun
    Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219787
    Closes: https://lore.kernel.org/all/bug-219787-28872@https.bugzilla.kernel.org%2F
    Cc: Ravi Bangoria <ravi.bangoria@amd.com>
    Cc: stable@vger.kernel.org
    Reviewed-and-tested-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Link: https://lore.kernel.org/r/20250227222411.3490595-5-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

KVM: SVM: Save host DR masks on CPUs with DebugSwap [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Wed Feb 26 17:25:32 2025 -0800

    KVM: SVM: Save host DR masks on CPUs with DebugSwap
    
    commit b2653cd3b75f62f29b72df4070e20357acb52bc4 upstream.
    
    When running SEV-SNP guests on a CPU that supports DebugSwap, always save
    the host's DR0..DR3 mask MSR values irrespective of whether or not
    DebugSwap is enabled, to ensure the host values aren't clobbered by the
    CPU.  And for now, also save DR0..DR3, even though doing so isn't
    necessary (see below).
    
    SVM_VMGEXIT_AP_CREATE is deeply flawed in that it allows the *guest* to
    create a VMSA with guest-controlled SEV_FEATURES.  A well behaved guest
    can inform the hypervisor, i.e. KVM, of its "requested" features, but on
    CPUs without ALLOWED_SEV_FEATURES support, nothing prevents the guest from
    lying about which SEV features are being enabled (or not!).
    
    If a misbehaving guest enables DebugSwap in a secondary vCPU's VMSA, the
    CPU will load the DR0..DR3 mask MSRs on #VMEXIT, i.e. will clobber the
    MSRs with '0' if KVM doesn't save its desired value.
    
    Note, DR0..DR3 themselves are "ok", as DR7 is reset on #VMEXIT, and KVM
    restores all DRs in common x86 code as needed via hw_breakpoint_restore().
    I.e. there is no risk of host DR0..DR3 being clobbered (when it matters).
    However, there is a flaw in the opposite direction; because the guest can
    lie about enabling DebugSwap, i.e. can *disable* DebugSwap without KVM's
    knowledge, KVM must not rely on the CPU to restore DRs.  Defer fixing
    that wart, as it's more of a documentation issue than a bug in the code.
    
    Note, KVM added support for DebugSwap on commit d1f85fbe836e ("KVM: SEV:
    Enable data breakpoints in SEV-ES"), but that is not an appropriate Fixes,
    as the underlying flaw exists in hardware, not in KVM.  I.e. all kernels
    that support SEV-SNP need to be patched, not just kernels with KVM's full
    support for DebugSwap (ignoring that DebugSwap support landed first).
    
    Opportunistically fix an incorrect statement in the comment; on CPUs
    without DebugSwap, the CPU does NOT save or load debug registers, i.e.
    
    Fixes: e366f92ea99e ("KVM: SEV: Support SEV-SNP AP Creation NAE event")
    Cc: stable@vger.kernel.org
    Cc: Naveen N Rao <naveen@kernel.org>
    Cc: Kim Phillips <kim.phillips@amd.com>
    Cc: Tom Lendacky <thomas.lendacky@amd.com>
    Cc: Alexey Kardashevskiy <aik@amd.com>
    Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
    Link: https://lore.kernel.org/r/20250227012541.3234589-2-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

KVM: SVM: Set RFLAGS.IF=1 in C code, to get VMRUN out of the STI shadow [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Mon Feb 24 08:54:41 2025 -0800

    KVM: SVM: Set RFLAGS.IF=1 in C code, to get VMRUN out of the STI shadow
    
    commit be45bc4eff33d9a7dae84a2150f242a91a617402 upstream.
    
    Enable/disable local IRQs, i.e. set/clear RFLAGS.IF, in the common
    svm_vcpu_enter_exit() just after/before guest_state_{enter,exit}_irqoff()
    so that VMRUN is not executed in an STI shadow.  AMD CPUs have a quirk
    (some would say "bug"), where the STI shadow bleeds into the guest's
    intr_state field if a #VMEXIT occurs during injection of an event, i.e. if
    the VMRUN doesn't complete before the subsequent #VMEXIT.
    
    The spurious "interrupts masked" state is relatively benign, as it only
    occurs during event injection and is transient.  Because KVM is already
    injecting an event, the guest can't be in HLT, and if KVM is querying IRQ
    blocking for injection, then KVM would need to force an immediate exit
    anyways since injecting multiple events is impossible.
    
    However, because KVM copies int_state verbatim from vmcb02 to vmcb12, the
    spurious STI shadow is visible to L1 when running a nested VM, which can
    trip sanity checks, e.g. in VMware's VMM.
    
    Hoist the STI+CLI all the way to C code, as the aforementioned calls to
    guest_state_{enter,exit}_irqoff() already inform lockdep that IRQs are
    enabled/disabled, and taking a fault on VMRUN with RFLAGS.IF=1 is already
    possible.  I.e. if there's kernel code that is confused by running with
    RFLAGS.IF=1, then it's already a problem.  In practice, since GIF=0 also
    blocks NMIs, the only change in exposure to non-KVM code (relative to
    surrounding VMRUN with STI+CLI) is exception handling code, and except for
    the kvm_rebooting=1 case, all exception in the core VM-Enter/VM-Exit path
    are fatal.
    
    Use the "raw" variants to enable/disable IRQs to avoid tracing in the
    "no instrumentation" code; the guest state helpers also take care of
    tracing IRQ state.
    
    Oppurtunstically document why KVM needs to do STI in the first place.
    
    Reported-by: Doug Covelli <doug.covelli@broadcom.com>
    Closes: https://lore.kernel.org/all/CADH9ctBs1YPmE4aCfGPNBwA10cA8RuAk2gO7542DjMZgs4uzJQ@mail.gmail.com
    Fixes: f14eec0a3203 ("KVM: SVM: move more vmentry code to assembly")
    Cc: stable@vger.kernel.org
    Reviewed-by: Jim Mattson <jmattson@google.com>
    Link: https://lore.kernel.org/r/20250224165442.2338294-2-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

KVM: SVM: Suppress DEBUGCTL.BTF on AMD [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Thu Feb 27 14:24:07 2025 -0800

    KVM: SVM: Suppress DEBUGCTL.BTF on AMD
    
    commit d0eac42f5cecce009d315655bee341304fbe075e upstream.
    
    Mark BTF as reserved in DEBUGCTL on AMD, as KVM doesn't actually support
    BTF, and fully enabling BTF virtualization is non-trivial due to
    interactions with the emulator, guest_debug, #DB interception, nested SVM,
    etc.
    
    Don't inject #GP if the guest attempts to set BTF, as there's no way to
    communicate lack of support to the guest, and instead suppress the flag
    and treat the WRMSR as (partially) unsupported.
    
    In short, make KVM behave the same on AMD and Intel (VMX already squashes
    BTF).
    
    Note, due to other bugs in KVM's handling of DEBUGCTL, the only way BTF
    has "worked" in any capacity is if the guest simultaneously enables LBRs.
    
    Reported-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Cc: stable@vger.kernel.org
    Reviewed-and-tested-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Link: https://lore.kernel.org/r/20250227222411.3490595-3-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isn't supported by KVM [+ + +]
Author: Xiaoyao Li <xiaoyao.li@intel.com>
Date:   Tue Mar 4 03:23:14 2025 -0500

    KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isn't supported by KVM
    
    commit f9dc8fb3afc968042bdaf4b6e445a9272071c9f3 upstream.
    
    Fix a goof where KVM sets CPUID.0x80000022.EAX to CPUID.0x80000022.EBX
    instead of zeroing both when PERFMON_V2 isn't supported by KVM.  In
    practice, barring a buggy CPU (or vCPU model when running nested) only the
    !enable_pmu case is affected, as KVM always supports PERFMON_V2 if it's
    available in hardware, i.e. CPUID.0x80000022.EBX will be '0' if PERFMON_V2
    is unsupported.
    
    For the !enable_pmu case, the bug is relatively benign as KVM will refuse
    to enable PMU capabilities, but a VMM that reflects KVM's supported CPUID
    into the guest could inadvertently induce #GPs in the guest due to
    advertising support for MSRs that KVM refuses to emulate.
    
    Fixes: 94cdeebd8211 ("KVM: x86/cpuid: Add AMD CPUID ExtPerfMonAndDbg leaf 0x80000022")
    Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
    Link: https://lore.kernel.org/r/20250304082314.472202-3-xiaoyao.li@intel.com
    [sean: massage shortlog and changelog, tag for stable]
    Cc: stable@vger.kernel.org
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

KVM: x86: Snapshot the host's DEBUGCTL after disabling IRQs [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Thu Feb 27 14:24:10 2025 -0800

    KVM: x86: Snapshot the host's DEBUGCTL after disabling IRQs
    
    commit 189ecdb3e112da703ac0699f4ec76aa78122f911 upstream.
    
    Snapshot the host's DEBUGCTL after disabling IRQs, as perf can toggle
    debugctl bits from IRQ context, e.g. when enabling/disabling events via
    smp_call_function_single().  Taking the snapshot (long) before IRQs are
    disabled could result in KVM effectively clobbering DEBUGCTL due to using
    a stale snapshot.
    
    Cc: stable@vger.kernel.org
    Reviewed-and-tested-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Link: https://lore.kernel.org/r/20250227222411.3490595-6-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

KVM: x86: Snapshot the host's DEBUGCTL in common x86 [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Thu Feb 27 14:24:08 2025 -0800

    KVM: x86: Snapshot the host's DEBUGCTL in common x86
    
    commit fb71c795935652fa20eaf9517ca9547f5af99a76 upstream.
    
    Move KVM's snapshot of DEBUGCTL to kvm_vcpu_arch and take the snapshot in
    common x86, so that SVM can also use the snapshot.
    
    Opportunistically change the field to a u64.  While bits 63:32 are reserved
    on AMD, not mentioned at all in Intel's SDM, and managed as an "unsigned
    long" by the kernel, DEBUGCTL is an MSR and therefore a 64-bit value.
    
    Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
    Cc: stable@vger.kernel.org
    Reviewed-and-tested-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Link: https://lore.kernel.org/r/20250227222411.3490595-4-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Linux: Linux 6.12.19 [+ + +]
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Mar 13 13:02:20 2025 +0100

    Linux 6.12.19
    
    Link: https://lore.kernel.org/r/20250310170457.700086763@linuxfoundation.org
    Tested-by: SeongJae Park <sj@kernel.org>
    Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Tested-by: Salvatore Bonaccorso <carnil@debian.org>
    Tested-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Ron Economos <re@w6rz.net>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Mark Brown <broonie@kernel.org>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Markus Reichelt <lkt+2023@mareichelt.com>
    Tested-by: Miguel Ojeda <ojeda@kernel.org>
    Tested-by: Peter Schneider <pschneider1968@googlemail.com>
    Tested-by: Hardik Garg <hargar@linux.microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
llc: do not use skb_get() before dev_queue_xmit() [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Feb 27 08:26:42 2025 +0000

    llc: do not use skb_get() before dev_queue_xmit()
    
    [ Upstream commit 64e6a754d33d31aa844b3ee66fb93ac84ca1565e ]
    
    syzbot is able to crash hosts [1], using llc and devices
    not supporting IFF_TX_SKB_SHARING.
    
    In this case, e1000 driver calls eth_skb_pad(), while
    the skb is shared.
    
    Simply replace skb_get() by skb_clone() in net/llc/llc_s_ac.c
    
    Note that e1000 driver might have an issue with pktgen,
    because it does not clear IFF_TX_SKB_SHARING, this is an
    orthogonal change.
    
    We need to audit other skb_get() uses in net/llc.
    
    [1]
    
    kernel BUG at net/core/skbuff.c:2178 !
    Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
    CPU: 0 UID: 0 PID: 16371 Comm: syz.2.2764 Not tainted 6.14.0-rc4-syzkaller-00052-gac9c34d1e45a #0
    Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
     RIP: 0010:pskb_expand_head+0x6ce/0x1240 net/core/skbuff.c:2178
    Call Trace:
     <TASK>
      __skb_pad+0x18a/0x610 net/core/skbuff.c:2466
      __skb_put_padto include/linux/skbuff.h:3843 [inline]
      skb_put_padto include/linux/skbuff.h:3862 [inline]
      eth_skb_pad include/linux/etherdevice.h:656 [inline]
      e1000_xmit_frame+0x2d99/0x5800 drivers/net/ethernet/intel/e1000/e1000_main.c:3128
      __netdev_start_xmit include/linux/netdevice.h:5151 [inline]
      netdev_start_xmit include/linux/netdevice.h:5160 [inline]
      xmit_one net/core/dev.c:3806 [inline]
      dev_hard_start_xmit+0x9a/0x7b0 net/core/dev.c:3822
      sch_direct_xmit+0x1ae/0xc30 net/sched/sch_generic.c:343
      __dev_xmit_skb net/core/dev.c:4045 [inline]
      __dev_queue_xmit+0x13d4/0x43e0 net/core/dev.c:4621
      dev_queue_xmit include/linux/netdevice.h:3313 [inline]
      llc_sap_action_send_test_c+0x268/0x320 net/llc/llc_s_ac.c:144
      llc_exec_sap_trans_actions net/llc/llc_sap.c:153 [inline]
      llc_sap_next_state net/llc/llc_sap.c:182 [inline]
      llc_sap_state_process+0x239/0x510 net/llc/llc_sap.c:209
      llc_ui_sendmsg+0xd0d/0x14e0 net/llc/af_llc.c:993
      sock_sendmsg_nosec net/socket.c:718 [inline]
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reported-by: syzbot+da65c993ae113742a25f@syzkaller.appspotmail.com
    Closes: https://lore.kernel.org/netdev/67c020c0.050a0220.222324.0011.GAE@google.com/T/#u
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
LoongArch: Convert unreachable() to BUG() [+ + +]
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date:   Sat Mar 8 13:50:45 2025 +0800

    LoongArch: Convert unreachable() to BUG()
    
    commit da64a2359092ceec4f9dea5b329d0aef20104217 upstream.
    
    When compiling on LoongArch, there exists the following objtool warning
    in arch/loongarch/kernel/machine_kexec.o:
    
      kexec_reboot() falls through to next function crash_shutdown_secondary()
    
    Avoid using unreachable() as it can (and will in the absence of UBSAN)
    generate fall-through code. Use BUG() so we get a "break BRK_BUG" trap
    (with unreachable annotation).
    
    Cc: stable@vger.kernel.org  # 6.12+
    Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
    Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

LoongArch: KVM: Add interrupt checking for AVEC [+ + +]
Author: Bibo Mao <maobibo@loongson.cn>
Date:   Sat Mar 8 13:51:59 2025 +0800

    LoongArch: KVM: Add interrupt checking for AVEC
    
    commit 6fb1867d5a44b0a061cf39d2492d23d314bcb8ce upstream.
    
    There is a newly added macro INT_AVEC with CSR ESTAT register, which is
    bit 14 used for LoongArch AVEC support. AVEC interrupt status bit 14 is
    supported with macro CSR_ESTAT_IS, so here replace the hard-coded value
    0x1fff with macro CSR_ESTAT_IS so that the AVEC interrupt status is also
    supported by KVM.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Bibo Mao <maobibo@loongson.cn>
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

LoongArch: KVM: Fix GPA size issue about VM [+ + +]
Author: Bibo Mao <maobibo@loongson.cn>
Date:   Sat Mar 8 13:52:04 2025 +0800

    LoongArch: KVM: Fix GPA size issue about VM
    
    commit 6bdbb73dc8d99fbb77f5db79dbb6f108708090b4 upstream.
    
    Physical address space is 48 bit on Loongson-3A5000 physical machine,
    however it is 47 bit for VM on Loongson-3A5000 system. Size of physical
    address space of VM is the same with the size of virtual user space (a
    half) of physical machine.
    
    Variable cpu_vabits represents user address space, kernel address space
    is not included (user space and kernel space are both a half of total).
    Here cpu_vabits, rather than cpu_vabits - 1, is to represent the size of
    guest physical address space.
    
    Also there is strict checking about page fault GPA address, inject error
    if it is larger than maximum GPA address of VM.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Bibo Mao <maobibo@loongson.cn>
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

LoongArch: KVM: Reload guest CSR registers after sleep [+ + +]
Author: Bibo Mao <maobibo@loongson.cn>
Date:   Sat Mar 8 13:52:01 2025 +0800

    LoongArch: KVM: Reload guest CSR registers after sleep
    
    commit 78d7bc5a02e1468df53896df354fa80727f35b7d upstream.
    
    On host, the HW guest CSR registers are lost after suspend and resume
    operation. Since last_vcpu of boot CPU still records latest vCPU pointer
    so that the guest CSR register skips to reload when boot CPU resumes and
    vCPU is scheduled.
    
    Here last_vcpu is cleared so that guest CSR registers will reload from
    scheduled vCPU context after suspend and resume.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Bibo Mao <maobibo@loongson.cn>
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

LoongArch: Set max_pfn with the PFN of the last page [+ + +]
Author: Bibo Mao <maobibo@loongson.cn>
Date:   Sat Mar 8 13:51:32 2025 +0800

    LoongArch: Set max_pfn with the PFN of the last page
    
    commit c8477bb0a8e7f6b2e47952b403c5cb67a6929e55 upstream.
    
    The current max_pfn equals to zero. In this case, it causes user cannot
    get some page information through /proc filesystem such as kpagecount.
    The following message is displayed by stress-ng test suite with command
    "stress-ng --verbose --physpage 1 -t 1".
    
     # stress-ng --verbose --physpage 1 -t 1
     stress-ng: error: [1691] physpage: cannot read page count for address 0x134ac000 in /proc/kpagecount, errno=22 (Invalid argument)
     stress-ng: error: [1691] physpage: cannot read page count for address 0x7ffff207c3a8 in /proc/kpagecount, errno=22 (Invalid argument)
     stress-ng: error: [1691] physpage: cannot read page count for address 0x134b0000 in /proc/kpagecount, errno=22 (Invalid argument)
     ...
    
    After applying this patch, the kernel can pass the test.
    
     # stress-ng --verbose --physpage 1 -t 1
     stress-ng: debug: [1701] physpage: [1701] started (instance 0 on CPU 3)
     stress-ng: debug: [1701] physpage: [1701] exited (instance 0 on CPU 3)
     stress-ng: debug: [1700] physpage: [1701] terminated (success)
    
    Cc: stable@vger.kernel.org  # 6.8+
    Fixes: ff6c3d81f2e8 ("NUMA: optimize detection of memory with no node id assigned by firmware")
    Signed-off-by: Bibo Mao <maobibo@loongson.cn>
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
loongarch: Use ASM_REACHABLE [+ + +]
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Thu Nov 28 10:39:03 2024 +0100

    loongarch: Use ASM_REACHABLE
    
    commit 624bde3465f660e54a7cd4c1efc3e536349fead5 upstream.
    
    annotate_reachable() is unreliable since the compiler is free to place
    random code inbetween two consecutive asm() statements.
    
    This removes the last and only annotate_reachable() user.
    
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
    Link: https://lore.kernel.org/r/20241128094312.133437051@infradead.org
    Closes: https://lore.kernel.org/loongarch/20250307214943.372210-1-ojeda@kernel.org/
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
LoongArch: Use polling play_dead() when resuming from hibernation [+ + +]
Author: Huacai Chen <chenhuacai@kernel.org>
Date:   Sat Mar 8 13:51:32 2025 +0800

    LoongArch: Use polling play_dead() when resuming from hibernation
    
    commit c9117434c8f7523f0b77db4c5766f5011cc94677 upstream.
    
    When CONFIG_RANDOM_KMALLOC_CACHES or other randomization infrastructrue
    enabled, the idle_task's stack may different between the booting kernel
    and target kernel. So when resuming from hibernation, an ACTION_BOOT_CPU
    IPI wakeup the idle instruction in arch_cpu_idle_dead() and jump to the
    interrupt handler. But since the stack pointer is changed, the interrupt
    handler cannot restore correct context.
    
    So rename the current arch_cpu_idle_dead() to idle_play_dead(), make it
    as the default version of play_dead(), and the new arch_cpu_idle_dead()
    call play_dead() directly. For hibernation, implement an arch-specific
    hibernate_resume_nonboot_cpu_disable() to use the polling version (idle
    instruction is replace by nop, and irq is disabled) of play_dead(), i.e.
    poll_play_dead(), to avoid IPI handler corrupting the idle_task's stack
    when resuming from hibernation.
    
    This solution is a little similar to commit 406f992e4a372dafbe3c ("x86 /
    hibernate: Use hlt_play_dead() when resuming from hibernation").
    
    Cc: stable@vger.kernel.org
    Tested-by: Erpeng Xu <xuerpeng@uniontech.com>
    Tested-by: Yuli Wang <wangyuli@uniontech.com>
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
MAINTAINERS: add entry for the Rust `alloc` module [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:55 2025 +0100

    MAINTAINERS: add entry for the Rust `alloc` module
    
    commit 6ce162a002657910104c7a07fb50017681bc476c upstream.
    
    Add maintainers entry for the Rust `alloc` module.
    
    Currently, this includes the `Allocator` API itself, `Allocator`
    implementations, such as `Kmalloc` or `Vmalloc`, as well as the kernel's
    implementation of the primary memory allocation data structures, `Box`
    and `Vec`.
    
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-30-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mctp i3c: handle NULL header address [+ + +]
Author: Matt Johnston <matt@codeconstruct.com.au>
Date:   Tue Mar 4 13:59:51 2025 +0800

    mctp i3c: handle NULL header address
    
    [ Upstream commit cf7ee25e70c6edfac4553d6b671e8b19db1d9573 ]
    
    daddr can be NULL if there is no neighbour table entry present,
    in that case the tx packet should be dropped.
    
    saddr will usually be set by MCTP core, but check for NULL in case a
    packet is transmitted by a different protocol.
    
    Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
    Fixes: c8755b29b58e ("mctp i3c: MCTP I3C driver")
    Link: https://patch.msgid.link/20250304-mctp-i3c-null-v1-1-4416bbd56540@codeconstruct.com.au
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mei: me: add panther lake P DID [+ + +]
Author: Alexander Usyskin <alexander.usyskin@intel.com>
Date:   Sun Feb 9 13:05:50 2025 +0200

    mei: me: add panther lake P DID
    
    commit a8e8ffcc3afce2ee5fb70162aeaef3f03573ee1e upstream.
    
    Add Panther Lake P device id.
    
    Cc: stable <stable@kernel.org>
    Co-developed-by: Tomas Winkler <tomasw@gmail.com>
    Signed-off-by: Tomas Winkler <tomasw@gmail.com>
    Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
    Link: https://lore.kernel.org/r/20250209110550.1582982-1-alexander.usyskin@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mei: vsc: Use "wakeuphostint" when getting the host wakeup GPIO [+ + +]
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Fri Feb 14 22:24:25 2025 +0100

    mei: vsc: Use "wakeuphostint" when getting the host wakeup GPIO
    
    commit fdb1ada57cf8b8752cdf54f08709d76d74999544 upstream.
    
    The _CRS ACPI resources table has 2 entries for the host wakeup GPIO,
    the first one being a regular GpioIo () resource while the second one
    is a GpioInt () resource for the same pin.
    
    The acpi_gpio_mapping table used by vsc-tp.c maps the first Gpio ()
    resource to "wakeuphost-gpios" where as the second GpioInt () entry
    is mapped to "wakeuphostint-gpios".
    
    Using "wakeuphost" to request the GPIO as was done until now, means
    that the gpiolib-acpi code does not know that the GPIO is active-low
    as that info is only available in the GpioInt () entry.
    
    Things were still working before due to the following happening:
    
    1. Since the 2 entries point to the same pin they share a struct gpio_desc
    2. The SPI core creates the SPI device vsc-tp.c binds to and calls
       acpi_dev_gpio_irq_get(). This does use the second entry and sets
       FLAG_ACTIVE_LOW in gpio_desc.flags .
    3. vsc_tp_probe() requests the "wakeuphost" GPIO and inherits the
       active-low flag set by acpi_dev_gpio_irq_get()
    
    But there is a possible scenario where things do not work:
    
    1. - 3. happen as above
    4. After requesting the "wakeuphost" GPIO, the "resetfw" GPIO is requested
       next, but its USB GPIO controller is not available yet, so this call
       returns -EPROBE_DEFER.
    5. The gpio_desc for "wakeuphost" is put() and during this the active-low
       flag is cleared from gpio_desc.flags .
    6. Later on vsc_tp_probe() requests the "wakeuphost" GPIO again, but now it
       is not marked active-low.
    
    The difference can also be seen in /sys/kernel/debug/gpio, which contains
    the following line for this GPIO:
    
     gpio-535 (                    |wakeuphost          ) in  hi IRQ ACTIVE LOW
    
    If the second scenario is hit the "ACTIVE LOW" at the end disappears and
    things do not work.
    
    Fix this by requesting the GPIO through the "wakeuphostint" mapping instead
    which provides active-low info without relying on acpi_dev_gpio_irq_get()
    pre-populating this info in the gpio_desc.
    
    Link: https://bugzilla.redhat.com/show_bug.cgi?id=2316918
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
    Tested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device")
    Cc: stable <stable@kernel.org>
    Link: https://lore.kernel.org/r/20250214212425.84021-1-hdegoede@redhat.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mm/page_alloc: fix uninitialized variable [+ + +]
Author: Hao Zhang <zhanghao1@kylinos.cn>
Date:   Thu Feb 27 11:41:29 2025 +0800

    mm/page_alloc: fix uninitialized variable
    
    commit 8fe9ed44dc29fba0786b7e956d2e87179e407582 upstream.
    
    The variable "compact_result" is not initialized in function
    __alloc_pages_slowpath().  It causes should_compact_retry() to use an
    uninitialized value.
    
    Initialize variable "compact_result" with the value COMPACT_SKIPPED.
    
    BUG: KMSAN: uninit-value in __alloc_pages_slowpath+0xee8/0x16c0 mm/page_alloc.c:4416
     __alloc_pages_slowpath+0xee8/0x16c0 mm/page_alloc.c:4416
     __alloc_frozen_pages_noprof+0xa4c/0xe00 mm/page_alloc.c:4752
     alloc_pages_mpol+0x4cd/0x890 mm/mempolicy.c:2270
     alloc_frozen_pages_noprof mm/mempolicy.c:2341 [inline]
     alloc_pages_noprof mm/mempolicy.c:2361 [inline]
     folio_alloc_noprof+0x1dc/0x350 mm/mempolicy.c:2371
     filemap_alloc_folio_noprof+0xa6/0x440 mm/filemap.c:1019
     __filemap_get_folio+0xb9a/0x1840 mm/filemap.c:1970
     grow_dev_folio fs/buffer.c:1039 [inline]
     grow_buffers fs/buffer.c:1105 [inline]
     __getblk_slow fs/buffer.c:1131 [inline]
     bdev_getblk+0x2c9/0xab0 fs/buffer.c:1431
     getblk_unmovable include/linux/buffer_head.h:369 [inline]
     ext4_getblk+0x3b7/0xe50 fs/ext4/inode.c:864
     ext4_bread_batch+0x9f/0x7d0 fs/ext4/inode.c:933
     __ext4_find_entry+0x1ebb/0x36c0 fs/ext4/namei.c:1627
     ext4_lookup_entry fs/ext4/namei.c:1729 [inline]
     ext4_lookup+0x189/0xb40 fs/ext4/namei.c:1797
     __lookup_slow+0x538/0x710 fs/namei.c:1793
     lookup_slow+0x6a/0xd0 fs/namei.c:1810
     walk_component fs/namei.c:2114 [inline]
     link_path_walk+0xf29/0x1420 fs/namei.c:2479
     path_openat+0x30f/0x6250 fs/namei.c:3985
     do_filp_open+0x268/0x600 fs/namei.c:4016
     do_sys_openat2+0x1bf/0x2f0 fs/open.c:1428
     do_sys_open fs/open.c:1443 [inline]
     __do_sys_openat fs/open.c:1459 [inline]
     __se_sys_openat fs/open.c:1454 [inline]
     __x64_sys_openat+0x2a1/0x310 fs/open.c:1454
     x64_sys_call+0x36f5/0x3c30 arch/x86/include/generated/asm/syscalls_64.h:258
     do_syscall_x64 arch/x86/entry/common.c:52 [inline]
     do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
     entry_SYSCALL_64_after_hwframe+0x77/0x7f
    
    Local variable compact_result created at:
     __alloc_pages_slowpath+0x66/0x16c0 mm/page_alloc.c:4218
     __alloc_frozen_pages_noprof+0xa4c/0xe00 mm/page_alloc.c:4752
    
    Link: https://lkml.kernel.org/r/tencent_ED1032321D6510B145CDBA8CBA0093178E09@qq.com
    Reported-by: syzbot+0cfd5e38e96a5596f2b6@syzkaller.appspotmail.com
    Closes: https://syzkaller.appspot.com/bug?extid=0cfd5e38e96a5596f2b6
    Signed-off-by: Hao Zhang <zhanghao1@kylinos.cn>
    Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mm: abort vma_modify() on merge out of memory failure [+ + +]
Author: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Date:   Sat Feb 22 16:19:52 2025 +0000

    mm: abort vma_modify() on merge out of memory failure
    
    commit 47b16d0462a460000b8f05dfb1292377ac48f3ca upstream.
    
    The remainder of vma_modify() relies upon the vmg state remaining pristine
    after a merge attempt.
    
    Usually this is the case, however in the one edge case scenario of a merge
    attempt failing not due to the specified range being unmergeable, but
    rather due to an out of memory error arising when attempting to commit the
    merge, this assumption becomes untrue.
    
    This results in vmg->start, end being modified, and thus the proceeding
    attempts to split the VMA will be done with invalid start/end values.
    
    Thankfully, it is likely practically impossible for us to hit this in
    reality, as it would require a maple tree node pre-allocation failure that
    would likely never happen due to it being 'too small to fail', i.e.  the
    kernel would simply keep retrying reclaim until it succeeded.
    
    However, this scenario remains theoretically possible, and what we are
    doing here is wrong so we must correct it.
    
    The safest option is, when this scenario occurs, to simply give up the
    operation.  If we cannot allocate memory to merge, then we cannot allocate
    memory to split either (perhaps moreso!).
    
    Any scenario where this would be happening would be under very extreme
    (likely fatal) memory pressure, so it's best we give up early.
    
    So there is no doubt it is appropriate to simply bail out in this
    scenario.
    
    However, in general we must if at all possible never assume VMG state is
    stable after a merge attempt, since merge operations update VMG fields.
    As a result, additionally also make this clear by storing start, end in
    local variables.
    
    The issue was reported originally by syzkaller, and by Brad Spengler (via
    an off-list discussion), and in both instances it manifested as a
    triggering of the assert:
    
            VM_WARN_ON_VMG(start >= end, vmg);
    
    In vma_merge_existing_range().
    
    It seems at least one scenario in which this is occurring is one in which
    the merge being attempted is due to an madvise() across multiple VMAs
    which looks like this:
    
            start     end
              |<------>|
         |----------|------|
         |   vma    | next |
         |----------|------|
    
    When madvise_walk_vmas() is invoked, we first find vma in the above
    (determining prev to be equal to vma as we are offset into vma), and then
    enter the loop.
    
    We determine the end of vma that forms part of the range we are
    madvise()'ing by setting 'tmp' to this value:
    
                    /* Here vma->vm_start <= start < (end|vma->vm_end) */
                    tmp = vma->vm_end;
    
    We then invoke the madvise() operation via visit(), letting prev get
    updated to point to vma as part of the operation:
    
                    /* Here vma->vm_start <= start < tmp <= (end|vma->vm_end). */
                    error = visit(vma, &prev, start, tmp, arg);
    
    Where the visit() function pointer in this instance is
    madvise_vma_behavior().
    
    As observed in syzkaller reports, it is ultimately madvise_update_vma()
    that is invoked, calling vma_modify_flags_name() and vma_modify() in turn.
    
    Then, in vma_modify(), we attempt the merge:
    
            merged = vma_merge_existing_range(vmg);
            if (merged)
                    return merged;
    
    We invoke this with vmg->start, end set to start, tmp as such:
    
            start  tmp
              |<--->|
         |----------|------|
         |   vma    | next |
         |----------|------|
    
    We find ourselves in the merge right scenario, but the one in which we
    cannot remove the middle (we are offset into vma).
    
    Here we have a special case where vmg->start, end get set to perhaps
    unintuitive values - we intended to shrink the middle VMA and expand the
    next.
    
    This means vmg->start, end are set to...  vma->vm_start, start.
    
    Now the commit_merge() fails, and vmg->start, end are left like this.
    This means we return to the rest of vma_modify() with vmg->start, end
    (here denoted as start', end') set as:
    
      start' end'
         |<-->|
         |----------|------|
         |   vma    | next |
         |----------|------|
    
    So we now erroneously try to split accordingly.  This is where the
    unfortunate stuff begins.
    
    We start with:
    
            /* Split any preceding portion of the VMA. */
            if (vma->vm_start < vmg->start) {
                    ...
            }
    
    This doesn't trigger as we are no longer offset into vma at the start.
    
    But then we invoke:
    
            /* Split any trailing portion of the VMA. */
            if (vma->vm_end > vmg->end) {
                    ...
            }
    
    Which does get invoked. This leaves us with:
    
      start' end'
         |<-->|
         |----|-----|------|
         | vma| new | next |
         |----|-----|------|
    
    We then return ultimately to madvise_walk_vmas().  Here 'new' is unknown,
    and putting back the values known in this function we are faced with:
    
            start tmp end
              |     |  |
         |----|-----|------|
         | vma| new | next |
         |----|-----|------|
          prev
    
    Then:
    
                    start = tmp;
    
    So:
    
                 start end
                    |  |
         |----|-----|------|
         | vma| new | next |
         |----|-----|------|
          prev
    
    The following code does not cause anything to happen:
    
                    if (prev && start < prev->vm_end)
                            start = prev->vm_end;
                    if (start >= end)
                            break;
    
    And then we invoke:
    
                    if (prev)
                            vma = find_vma(mm, prev->vm_end);
    
    Which is where a problem occurs - we don't know about 'new' so we
    essentially look for the vma after prev, which is new, whereas we actually
    intended to discover next!
    
    So we end up with:
    
                 start end
                    |  |
         |----|-----|------|
         |prev| vma | next |
         |----|-----|------|
    
    And we have successfully bypassed all of the checks madvise_walk_vmas()
    has to ensure early exit should we end up moving out of range.
    
    We loop around, and hit:
    
                    /* Here vma->vm_start <= start < (end|vma->vm_end) */
                    tmp = vma->vm_end;
    
    Oh dear. Now we have:
    
                  tmp
                 start end
                    |  |
         |----|-----|------|
         |prev| vma | next |
         |----|-----|------|
    
    We then invoke:
    
                    /* Here vma->vm_start <= start < tmp <= (end|vma->vm_end). */
                    error = visit(vma, &prev, start, tmp, arg);
    
    Where start == tmp. That is, a zero range. This is not good.
    
    We invoke visit() which is madvise_vma_behavior() which does not check the
    range (for good reason, it assumes all checks have been done before it was
    called), which in turn finally calls madvise_update_vma().
    
    The madvise_update_vma() function calls vma_modify_flags_name() in turn,
    which ultimately invokes vma_modify() with...  start == end.
    
    vma_modify() calls vma_merge_existing_range() and finally we hit:
    
            VM_WARN_ON_VMG(start >= end, vmg);
    
    Which triggers, as start == end.
    
    While it might be useful to add some CONFIG_DEBUG_VM asserts in these
    instances to catch this kind of error, since we have just eliminated any
    possibility of that happening, we will add such asserts separately as to
    reduce churn and aid backporting.
    
    Link: https://lkml.kernel.org/r/20250222161952.41957-1-lorenzo.stoakes@oracle.com
    Fixes: 2f1c6611b0a8 ("mm: introduce vma_merge_struct and abstract vma_merge(),vma_modify()")
    Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
    Tested-by: Brad Spengler <brad.spengler@opensrcsec.com>
    Reported-by: Brad Spengler <brad.spengler@opensrcsec.com>
    Reported-by: syzbot+46423ed8fa1f1148c6e4@syzkaller.appspotmail.com
    Closes: https://lore.kernel.org/linux-mm/6774c98f.050a0220.25abdd.0991.GAE@google.com/
    Cc: Jann Horn <jannh@google.com>
    Cc: Liam Howlett <liam.howlett@oracle.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mm: don't skip arch_sync_kernel_mappings() in error paths [+ + +]
Author: Ryan Roberts <ryan.roberts@arm.com>
Date:   Wed Feb 26 12:16:09 2025 +0000

    mm: don't skip arch_sync_kernel_mappings() in error paths
    
    commit 3685024edd270f7c791f993157d65d3c928f3d6e upstream.
    
    Fix callers that previously skipped calling arch_sync_kernel_mappings() if
    an error occurred during a pgtable update.  The call is still required to
    sync any pgtable updates that may have occurred prior to hitting the error
    condition.
    
    These are theoretical bugs discovered during code review.
    
    Link: https://lkml.kernel.org/r/20250226121610.2401743-1-ryan.roberts@arm.com
    Fixes: 2ba3e6947aed ("mm/vmalloc: track which page-table levels were modified")
    Fixes: 0c95cba49255 ("mm: apply_to_pte_range warn and fail if a large pte is encountered")
    Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
    Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Christop Hellwig <hch@infradead.org>
    Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mm: fix finish_fault() handling for large folios [+ + +]
Author: Brian Geffon <bgeffon@google.com>
Date:   Wed Feb 26 11:23:41 2025 -0500

    mm: fix finish_fault() handling for large folios
    
    commit 34b82f33cf3f03bc39e9a205a913d790e1520ade upstream.
    
    When handling faults for anon shmem finish_fault() will attempt to install
    ptes for the entire folio.  Unfortunately if it encounters a single
    non-pte_none entry in that range it will bail, even if the pte that
    triggered the fault is still pte_none.  When this situation happens the
    fault will be retried endlessly never making forward progress.
    
    This patch fixes this behavior and if it detects that a pte in the range
    is not pte_none it will fall back to setting a single pte.
    
    [bgeffon@google.com: tweak whitespace]
      Link: https://lkml.kernel.org/r/20250227133236.1296853-1-bgeffon@google.com
    Link: https://lkml.kernel.org/r/20250226162341.915535-1-bgeffon@google.com
    Fixes: 43e027e41423 ("mm: memory: extend finish_fault() to support large folio")
    Signed-off-by: Brian Geffon <bgeffon@google.com>
    Suggested-by: Baolin Wang <baolin.wang@linux.alibaba.com>
    Reported-by: Marek Maslanka <mmaslanka@google.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Hugh Dickens <hughd@google.com>
    Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
    Cc: Matthew Wilcow (Oracle) <willy@infradead.org>
    Cc: Suren Baghdasaryan <surenb@google.com>
    Cc: Zi Yan <ziy@nvidia.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mm: hugetlb: Add huge page size param to huge_ptep_get_and_clear() [+ + +]
Author: Ryan Roberts <ryan.roberts@arm.com>
Date:   Wed Feb 26 12:06:51 2025 +0000

    mm: hugetlb: Add huge page size param to huge_ptep_get_and_clear()
    
    commit 02410ac72ac3707936c07ede66e94360d0d65319 upstream.
    
    In order to fix a bug, arm64 needs to be told the size of the huge page
    for which the huge_pte is being cleared in huge_ptep_get_and_clear().
    Provide for this by adding an `unsigned long sz` parameter to the
    function. This follows the same pattern as huge_pte_clear() and
    set_huge_pte_at().
    
    This commit makes the required interface modifications to the core mm as
    well as all arches that implement this function (arm64, loongarch, mips,
    parisc, powerpc, riscv, s390, sparc). The actual arm64 bug will be fixed
    in a separate commit.
    
    Cc: stable@vger.kernel.org
    Fixes: 66b3923a1a0f ("arm64: hugetlb: add support for PTE contiguous bit")
    Acked-by: David Hildenbrand <david@redhat.com>
    Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> # riscv
    Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
    Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
    Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> # s390
    Link: https://lore.kernel.org/r/20250226120656.2400136-2-ryan.roberts@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mm: memory-failure: update ttu flag inside unmap_poisoned_folio [+ + +]
Author: Ma Wupeng <mawupeng1@huawei.com>
Date:   Mon Feb 17 09:43:27 2025 +0800

    mm: memory-failure: update ttu flag inside unmap_poisoned_folio
    
    commit b81679b1633aa43c0d973adfa816d78c1ed0d032 upstream.
    
    Patch series "mm: memory_failure: unmap poisoned folio during migrate
    properly", v3.
    
    Fix two bugs during folio migration if the folio is poisoned.
    
    
    This patch (of 3):
    
    Commit 6da6b1d4a7df ("mm/hwpoison: convert TTU_IGNORE_HWPOISON to
    TTU_HWPOISON") introduce TTU_HWPOISON to replace TTU_IGNORE_HWPOISON in
    order to stop send SIGBUS signal when accessing an error page after a
    memory error on a clean folio.  However during page migration, anon folio
    must be set with TTU_HWPOISON during unmap_*().  For pagecache we need
    some policy just like the one in hwpoison_user_mappings to set this flag.
    So move this policy from hwpoison_user_mappings to unmap_poisoned_folio to
    handle this warning properly.
    
    Warning will be produced during unamp poison folio with the following log:
    
      ------------[ cut here ]------------
      WARNING: CPU: 1 PID: 365 at mm/rmap.c:1847 try_to_unmap_one+0x8fc/0xd3c
      Modules linked in:
      CPU: 1 UID: 0 PID: 365 Comm: bash Tainted: G        W          6.13.0-rc1-00018-gacdb4bbda7ab #42
      Tainted: [W]=WARN
      Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
      pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      pc : try_to_unmap_one+0x8fc/0xd3c
      lr : try_to_unmap_one+0x3dc/0xd3c
      Call trace:
       try_to_unmap_one+0x8fc/0xd3c (P)
       try_to_unmap_one+0x3dc/0xd3c (L)
       rmap_walk_anon+0xdc/0x1f8
       rmap_walk+0x3c/0x58
       try_to_unmap+0x88/0x90
       unmap_poisoned_folio+0x30/0xa8
       do_migrate_range+0x4a0/0x568
       offline_pages+0x5a4/0x670
       memory_block_action+0x17c/0x374
       memory_subsys_offline+0x3c/0x78
       device_offline+0xa4/0xd0
       state_store+0x8c/0xf0
       dev_attr_store+0x18/0x2c
       sysfs_kf_write+0x44/0x54
       kernfs_fop_write_iter+0x118/0x1a8
       vfs_write+0x3a8/0x4bc
       ksys_write+0x6c/0xf8
       __arm64_sys_write+0x1c/0x28
       invoke_syscall+0x44/0x100
       el0_svc_common.constprop.0+0x40/0xe0
       do_el0_svc+0x1c/0x28
       el0_svc+0x30/0xd0
       el0t_64_sync_handler+0xc8/0xcc
       el0t_64_sync+0x198/0x19c
      ---[ end trace 0000000000000000 ]---
    
    [mawupeng1@huawei.com: unmap_poisoned_folio(): remove shadowed local `mapping', per Miaohe]
      Link: https://lkml.kernel.org/r/20250219060653.3849083-1-mawupeng1@huawei.com
    Link: https://lkml.kernel.org/r/20250217014329.3610326-1-mawupeng1@huawei.com
    Link: https://lkml.kernel.org/r/20250217014329.3610326-2-mawupeng1@huawei.com
    Fixes: 6da6b1d4a7df ("mm/hwpoison: convert TTU_IGNORE_HWPOISON to TTU_HWPOISON")
    Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
    Suggested-by: David Hildenbrand <david@redhat.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Acked-by: Miaohe Lin <linmiaohe@huawei.com>
    Cc: Ma Wupeng <mawupeng1@huawei.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
    Cc: Oscar Salvador <osalvador@suse.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mm: memory-hotplug: check folio ref count first in do_migrate_range [+ + +]
Author: Ma Wupeng <mawupeng1@huawei.com>
Date:   Mon Feb 17 09:43:28 2025 +0800

    mm: memory-hotplug: check folio ref count first in do_migrate_range
    
    commit 773b9a6aa6d38894b95088e3ed6f8a701d9f50fd upstream.
    
    If a folio has an increased reference count, folio_try_get() will acquire
    it, perform necessary operations, and then release it.  In the case of a
    poisoned folio without an elevated reference count (which is unlikely for
    memory-failure), folio_try_get() will simply bypass it.
    
    Therefore, relocate the folio_try_get() function, responsible for checking
    and acquiring this reference count at first.
    
    Link: https://lkml.kernel.org/r/20250217014329.3610326-3-mawupeng1@huawei.com
    Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Acked-by: Miaohe Lin <linmiaohe@huawei.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
    Cc: Oscar Salvador <osalvador@suse.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mptcp: fix 'scheduling while atomic' in mptcp_pm_nl_append_new_local_addr [+ + +]
Author: Krister Johansen <kjlx@templeofstupid.com>
Date:   Mon Mar 3 18:10:13 2025 +0100

    mptcp: fix 'scheduling while atomic' in mptcp_pm_nl_append_new_local_addr
    
    commit 022bfe24aad8937705704ff2e414b100cf0f2e1a upstream.
    
    If multiple connection requests attempt to create an implicit mptcp
    endpoint in parallel, more than one caller may end up in
    mptcp_pm_nl_append_new_local_addr because none found the address in
    local_addr_list during their call to mptcp_pm_nl_get_local_id.  In this
    case, the concurrent new_local_addr calls may delete the address entry
    created by the previous caller.  These deletes use synchronize_rcu, but
    this is not permitted in some of the contexts where this function may be
    called.  During packet recv, the caller may be in a rcu read critical
    section and have preemption disabled.
    
    An example stack:
    
       BUG: scheduling while atomic: swapper/2/0/0x00000302
    
       Call Trace:
       <IRQ>
       dump_stack_lvl (lib/dump_stack.c:117 (discriminator 1))
       dump_stack (lib/dump_stack.c:124)
       __schedule_bug (kernel/sched/core.c:5943)
       schedule_debug.constprop.0 (arch/x86/include/asm/preempt.h:33 kernel/sched/core.c:5970)
       __schedule (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:207 kernel/sched/features.h:29 kernel/sched/core.c:6621)
       schedule (arch/x86/include/asm/preempt.h:84 kernel/sched/core.c:6804 kernel/sched/core.c:6818)
       schedule_timeout (kernel/time/timer.c:2160)
       wait_for_completion (kernel/sched/completion.c:96 kernel/sched/completion.c:116 kernel/sched/completion.c:127 kernel/sched/completion.c:148)
       __wait_rcu_gp (include/linux/rcupdate.h:311 kernel/rcu/update.c:444)
       synchronize_rcu (kernel/rcu/tree.c:3609)
       mptcp_pm_nl_append_new_local_addr (net/mptcp/pm_netlink.c:966 net/mptcp/pm_netlink.c:1061)
       mptcp_pm_nl_get_local_id (net/mptcp/pm_netlink.c:1164)
       mptcp_pm_get_local_id (net/mptcp/pm.c:420)
       subflow_check_req (net/mptcp/subflow.c:98 net/mptcp/subflow.c:213)
       subflow_v4_route_req (net/mptcp/subflow.c:305)
       tcp_conn_request (net/ipv4/tcp_input.c:7216)
       subflow_v4_conn_request (net/mptcp/subflow.c:651)
       tcp_rcv_state_process (net/ipv4/tcp_input.c:6709)
       tcp_v4_do_rcv (net/ipv4/tcp_ipv4.c:1934)
       tcp_v4_rcv (net/ipv4/tcp_ipv4.c:2334)
       ip_protocol_deliver_rcu (net/ipv4/ip_input.c:205 (discriminator 1))
       ip_local_deliver_finish (include/linux/rcupdate.h:813 net/ipv4/ip_input.c:234)
       ip_local_deliver (include/linux/netfilter.h:314 include/linux/netfilter.h:308 net/ipv4/ip_input.c:254)
       ip_sublist_rcv_finish (include/net/dst.h:461 net/ipv4/ip_input.c:580)
       ip_sublist_rcv (net/ipv4/ip_input.c:640)
       ip_list_rcv (net/ipv4/ip_input.c:675)
       __netif_receive_skb_list_core (net/core/dev.c:5583 net/core/dev.c:5631)
       netif_receive_skb_list_internal (net/core/dev.c:5685 net/core/dev.c:5774)
       napi_complete_done (include/linux/list.h:37 include/net/gro.h:449 include/net/gro.h:444 net/core/dev.c:6114)
       igb_poll (drivers/net/ethernet/intel/igb/igb_main.c:8244) igb
       __napi_poll (net/core/dev.c:6582)
       net_rx_action (net/core/dev.c:6653 net/core/dev.c:6787)
       handle_softirqs (kernel/softirq.c:553)
       __irq_exit_rcu (kernel/softirq.c:588 kernel/softirq.c:427 kernel/softirq.c:636)
       irq_exit_rcu (kernel/softirq.c:651)
       common_interrupt (arch/x86/kernel/irq.c:247 (discriminator 14))
       </IRQ>
    
    This problem seems particularly prevalent if the user advertises an
    endpoint that has a different external vs internal address.  In the case
    where the external address is advertised and multiple connections
    already exist, multiple subflow SYNs arrive in parallel which tends to
    trigger the race during creation of the first local_addr_list entries
    which have the internal address instead.
    
    Fix by skipping the replacement of an existing implicit local address if
    called via mptcp_pm_nl_get_local_id.
    
    Fixes: d045b9eb95a9 ("mptcp: introduce implicit endpoints")
    Cc: stable@vger.kernel.org
    Suggested-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
    Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Link: https://patch.msgid.link/20250303-net-mptcp-fix-sched-while-atomic-v1-1-f6a216c5a74c@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
net-timestamp: support TCP GSO case for a few missing flags [+ + +]
Author: Jason Xing <kerneljasonxing@gmail.com>
Date:   Tue Mar 4 08:44:29 2025 +0800

    net-timestamp: support TCP GSO case for a few missing flags
    
    [ Upstream commit 3c9231ea6497dfc50ac0ef69fff484da27d0df66 ]
    
    When I read through the TSO codes, I found out that we probably
    miss initializing the tx_flags of last seg when TSO is turned
    off, which means at the following points no more timestamp
    (for this last one) will be generated. There are three flags
    to be handled in this patch:
    1. SKBTX_HW_TSTAMP
    2. SKBTX_BPF
    3. SKBTX_SCHED_TSTAMP
    Note that SKBTX_BPF[1] was added in 6.14.0-rc2 by commit
    6b98ec7e882af ("bpf: Add BPF_SOCK_OPS_TSTAMP_SCHED_CB callback")
    and only belongs to net-next branch material for now. The common
    issue of the above three flags can be fixed by this single patch.
    
    This patch initializes the tx_flags to SKBTX_ANY_TSTAMP like what
    the UDP GSO does to make the newly segmented last skb inherit the
    tx_flags so that requested timestamp will be generated in each
    certain layer, or else that last one has zero value of tx_flags
    which leads to no timestamp at all.
    
    Fixes: 4ed2d765dfacc ("net-timestamp: TCP timestamping")
    Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>
    Reviewed-by: Willem de Bruijn <willemb@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
net: dsa: mt7530: Fix traffic flooding for MMIO devices [+ + +]
Author: Lorenzo Bianconi <lorenzo@kernel.org>
Date:   Tue Mar 4 09:50:23 2025 +0100

    net: dsa: mt7530: Fix traffic flooding for MMIO devices
    
    [ Upstream commit ccc2f5a436fbb0ae1fb598932a9b8e48423c1959 ]
    
    On MMIO devices (e.g. MT7988 or EN7581) unicast traffic received on lanX
    port is flooded on all other user ports if the DSA switch is configured
    without VLAN support since PORT_MATRIX in PCR regs contains all user
    ports. Similar to MDIO devices (e.g. MT7530 and MT7531) fix the issue
    defining default VLAN-ID 0 for MT7530 MMIO devices.
    
    Fixes: 110c18bfed414 ("net: dsa: mt7530: introduce driver for MT7988 built-in switch")
    Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
    Reviewed-by: Chester A. Unal <chester.a.unal@arinc9.com>
    Link: https://patch.msgid.link/20250304-mt7988-flooding-fix-v1-1-905523ae83e9@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device [+ + +]
Author: Maxime Chevallier <maxime.chevallier@bootlin.com>
Date:   Sat Mar 1 15:11:13 2025 +0100

    net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device
    
    [ Upstream commit 637399bf7e77797811adf340090b561a8f9d1213 ]
    
    ethnl_req_get_phydev() is used to lookup a phy_device, in the case an
    ethtool netlink command targets a specific phydev within a netdev's
    topology.
    
    It takes as a parameter a const struct nlattr *header that's used for
    error handling :
    
           if (!phydev) {
                   NL_SET_ERR_MSG_ATTR(extack, header,
                                       "no phy matching phyindex");
                   return ERR_PTR(-ENODEV);
           }
    
    In the notify path after a ->set operation however, there's no request
    attributes available.
    
    The typical callsite for the above function looks like:
    
            phydev = ethnl_req_get_phydev(req_base, tb[ETHTOOL_A_XXX_HEADER],
                                          info->extack);
    
    So, when tb is NULL (such as in the ethnl notify path), we have a nice
    crash.
    
    It turns out that there's only the PLCA command that is in that case, as
    the other phydev-specific commands don't have a notification.
    
    This commit fixes the crash by passing the cmd index and the nlattr
    array separately, allowing NULL-checking it directly inside the helper.
    
    Fixes: c15e065b46dc ("net: ethtool: Allow passing a phy index for some commands")
    Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
    Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
    Reported-by: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>
    Link: https://patch.msgid.link/20250301141114.97204-1-maxime.chevallier@bootlin.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ethtool: plumb PHY stats to PHY drivers [+ + +]
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Fri Jan 10 07:05:12 2025 +0100

    net: ethtool: plumb PHY stats to PHY drivers
    
    [ Upstream commit b7a2c1fe6b55364e61b4b54b991eb43a47bb1104 ]
    
    Introduce support for standardized PHY statistics reporting in ethtool
    by extending the PHYLIB framework. Add the functions
    phy_ethtool_get_phy_stats() and phy_ethtool_get_link_ext_stats() to
    provide a consistent interface for retrieving PHY-level and
    link-specific statistics. These functions are used within the ethtool
    implementation to avoid direct access to the phy_device structure
    outside of the PHYLIB framework.
    
    A new structure, ethtool_phy_stats, is introduced to standardize PHY
    statistics such as packet counts, byte counts, and error counters.
    Drivers are updated to include callbacks for retrieving PHY and
    link-specific statistics, ensuring values are explicitly set only for
    supported fields, initialized with ETHTOOL_STAT_NOT_SET to avoid
    ambiguity.
    
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Stable-dep-of: 637399bf7e77 ("net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: gso: fix ownership in __udp_gso_segment [+ + +]
Author: Antoine Tenart <atenart@kernel.org>
Date:   Wed Feb 26 18:13:42 2025 +0100

    net: gso: fix ownership in __udp_gso_segment
    
    [ Upstream commit ee01b2f2d7d0010787c2343463965bbc283a497f ]
    
    In __udp_gso_segment the skb destructor is removed before segmenting the
    skb but the socket reference is kept as-is. This is an issue if the
    original skb is later orphaned as we can hit the following bug:
    
      kernel BUG at ./include/linux/skbuff.h:3312!  (skb_orphan)
      RIP: 0010:ip_rcv_core+0x8b2/0xca0
      Call Trace:
       ip_rcv+0xab/0x6e0
       __netif_receive_skb_one_core+0x168/0x1b0
       process_backlog+0x384/0x1100
       __napi_poll.constprop.0+0xa1/0x370
       net_rx_action+0x925/0xe50
    
    The above can happen following a sequence of events when using
    OpenVSwitch, when an OVS_ACTION_ATTR_USERSPACE action precedes an
    OVS_ACTION_ATTR_OUTPUT action:
    
    1. OVS_ACTION_ATTR_USERSPACE is handled (in do_execute_actions): the skb
       goes through queue_gso_packets and then __udp_gso_segment, where its
       destructor is removed.
    2. The segments' data are copied and sent to userspace.
    3. OVS_ACTION_ATTR_OUTPUT is handled (in do_execute_actions) and the
       same original skb is sent to its path.
    4. If it later hits skb_orphan, we hit the bug.
    
    Fix this by also removing the reference to the socket in
    __udp_gso_segment.
    
    Fixes: ad405857b174 ("udp: better wmem accounting on gso")
    Signed-off-by: Antoine Tenart <atenart@kernel.org>
    Link: https://patch.msgid.link/20250226171352.258045-1-atenart@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: hns3: make sure ptp clock is unregister and freed if hclge_ptp_get_cycle returns an error [+ + +]
Author: Peiyang Wang <wangpeiyang1@huawei.com>
Date:   Fri Feb 28 18:52:58 2025 +0800

    net: hns3: make sure ptp clock is unregister and freed if hclge_ptp_get_cycle returns an error
    
    [ Upstream commit b7365eab39831487a84e63a9638209b68dc54008 ]
    
    During the initialization of ptp, hclge_ptp_get_cycle might return an error
    and returned directly without unregister clock and free it. To avoid that,
    call hclge_ptp_destroy_clock to unregist and free clock if
    hclge_ptp_get_cycle failed.
    
    Fixes: 8373cd38a888 ("net: hns3: change the method of obtaining default ptp cycle")
    Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
    Signed-off-by: Jijie Shao <shaojijie@huawei.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Link: https://patch.msgid.link/20250228105258.1243461-1-shaojijie@huawei.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ipa: Enable checksum for IPA_ENDPOINT_AP_MODEM_{RX,TX} for v4.7 [+ + +]
Author: Luca Weiss <luca.weiss@fairphone.com>
Date:   Thu Feb 27 11:33:42 2025 +0100

    net: ipa: Enable checksum for IPA_ENDPOINT_AP_MODEM_{RX,TX} for v4.7
    
    [ Upstream commit 934e69669e32eb653234898424ae007bae2f636e ]
    
    Enable the checksum option for these two endpoints in order to allow
    mobile data to actually work. Without this, no packets seem to make it
    through the IPA.
    
    Fixes: b310de784bac ("net: ipa: add IPA v4.7 support")
    Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
    Reviewed-by: Alex Elder <elder@riscstar.com>
    Link: https://patch.msgid.link/20250227-ipa-v4-7-fixes-v1-3-a88dd8249d8a@fairphone.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ipa: Fix QSB data for v4.7 [+ + +]
Author: Luca Weiss <luca.weiss@fairphone.com>
Date:   Thu Feb 27 11:33:41 2025 +0100

    net: ipa: Fix QSB data for v4.7
    
    [ Upstream commit 6a2843aaf551d87beb92d774f7d5b8ae007fe774 ]
    
    As per downstream reference, max_writes should be 12 and max_reads
    should be 13.
    
    Fixes: b310de784bac ("net: ipa: add IPA v4.7 support")
    Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
    Reviewed-by: Alex Elder <elder@riscstar.com>
    Link: https://patch.msgid.link/20250227-ipa-v4-7-fixes-v1-2-a88dd8249d8a@fairphone.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ipa: Fix v4.7 resource group names [+ + +]
Author: Luca Weiss <luca.weiss@fairphone.com>
Date:   Thu Feb 27 11:33:40 2025 +0100

    net: ipa: Fix v4.7 resource group names
    
    [ Upstream commit 5eb3dc1396aa7e315486b24df80df782912334b7 ]
    
    In the downstream IPA driver there's only one group defined for source
    and destination, and the destination group doesn't have a _DPL suffix.
    
    Fixes: b310de784bac ("net: ipa: add IPA v4.7 support")
    Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
    Reviewed-by: Alex Elder <elder@riscstar.com>
    Link: https://patch.msgid.link/20250227-ipa-v4-7-fixes-v1-1-a88dd8249d8a@fairphone.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ipv6: fix dst ref loop in ila lwtunnel [+ + +]
Author: Justin Iurman <justin.iurman@uliege.be>
Date:   Tue Mar 4 19:10:39 2025 +0100

    net: ipv6: fix dst ref loop in ila lwtunnel
    
    [ Upstream commit 0e7633d7b95b67f1758aea19f8e85621c5f506a3 ]
    
    This patch follows commit 92191dd10730 ("net: ipv6: fix dst ref loops in
    rpl, seg6 and ioam6 lwtunnels") and, on a second thought, the same patch
    is also needed for ila (even though the config that triggered the issue
    was pathological, but still, we don't want that to happen).
    
    Fixes: 79ff2fc31e0f ("ila: Cache a route to translated address")
    Cc: Tom Herbert <tom@herbertland.com>
    Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
    Link: https://patch.msgid.link/20250304181039.35951-1-justin.iurman@uliege.be
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ipv6: fix missing dst ref drop in ila lwtunnel [+ + +]
Author: Justin Iurman <justin.iurman@uliege.be>
Date:   Wed Mar 5 09:16:55 2025 +0100

    net: ipv6: fix missing dst ref drop in ila lwtunnel
    
    [ Upstream commit 5da15a9c11c1c47ef573e6805b60a7d8a1687a2a ]
    
    Add missing skb_dst_drop() to drop reference to the old dst before
    adding the new dst to the skb.
    
    Fixes: 79ff2fc31e0f ("ila: Cache a route to translated address")
    Cc: Tom Herbert <tom@herbertland.com>
    Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
    Link: https://patch.msgid.link/20250305081655.19032-1-justin.iurman@uliege.be
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
NFS: fix nfs_release_folio() to not deadlock via kcompactd writeback [+ + +]
Author: Mike Snitzer <snitzer@kernel.org>
Date:   Mon Feb 24 21:20:02 2025 -0500

    NFS: fix nfs_release_folio() to not deadlock via kcompactd writeback
    
    commit ce6d9c1c2b5cc785016faa11b48b6cd317eb367e upstream.
    
    Add PF_KCOMPACTD flag and current_is_kcompactd() helper to check for it so
    nfs_release_folio() can skip calling nfs_wb_folio() from kcompactd.
    
    Otherwise NFS can deadlock waiting for kcompactd enduced writeback which
    recurses back to NFS (which triggers writeback to NFSD via NFS loopback
    mount on the same host, NFSD blocks waiting for XFS's call to
    __filemap_get_folio):
    
    6070.550357] INFO: task kcompactd0:58 blocked for more than 4435 seconds.
    
    {---
    [58] "kcompactd0"
    [<0>] folio_wait_bit+0xe8/0x200
    [<0>] folio_wait_writeback+0x2b/0x80
    [<0>] nfs_wb_folio+0x80/0x1b0 [nfs]
    [<0>] nfs_release_folio+0x68/0x130 [nfs]
    [<0>] split_huge_page_to_list_to_order+0x362/0x840
    [<0>] migrate_pages_batch+0x43d/0xb90
    [<0>] migrate_pages_sync+0x9a/0x240
    [<0>] migrate_pages+0x93c/0x9f0
    [<0>] compact_zone+0x8e2/0x1030
    [<0>] compact_node+0xdb/0x120
    [<0>] kcompactd+0x121/0x2e0
    [<0>] kthread+0xcf/0x100
    [<0>] ret_from_fork+0x31/0x40
    [<0>] ret_from_fork_asm+0x1a/0x30
    ---}
    
    [akpm@linux-foundation.org: fix build]
    Link: https://lkml.kernel.org/r/20250225022002.26141-1-snitzer@kernel.org
    Fixes: 96780ca55e3c ("NFS: fix up nfs_release_folio() to try to release the page")
    Signed-off-by: Mike Snitzer <snitzer@kernel.org>
    Cc: Anna Schumaker <anna.schumaker@oracle.com>
    Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
nvme-ioctl: fix leaked requests on mapping error [+ + +]
Author: Keith Busch <kbusch@kernel.org>
Date:   Mon Feb 24 17:13:30 2025 -0800

    nvme-ioctl: fix leaked requests on mapping error
    
    [ Upstream commit 00817f0f1c45b007965f5676b9a2013bb39c7228 ]
    
    All the callers assume nvme_map_user_request() frees the request on a
    failure. This wasn't happening on invalid metadata or io_uring command
    flags, so we've been leaking those requests.
    
    Fixes: 23fd22e55b767b ("nvme: wire up fixed buffer support for nvme passthrough")
    Fixes: 7c2fd76048e95d ("nvme: fix metadata handling in nvme-passthrough")
    Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
    Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nvme-pci: add support for sgl metadata [+ + +]
Author: Keith Busch <kbusch@kernel.org>
Date:   Fri Nov 15 13:41:21 2024 -0800

    nvme-pci: add support for sgl metadata
    
    [ Upstream commit 979c6342f9c0a48696a6420f14f9dd409591657f ]
    
    Supporting this mode allows creating and merging multi-segment metadata
    requests that wouldn't be possible otherwise. It also allows directly
    using user space requests that straddle physically discontiguous pages.
    
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Stable-dep-of: 00817f0f1c45 ("nvme-ioctl: fix leaked requests on mapping error")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-pci: use sgls for all user requests if possible [+ + +]
Author: Keith Busch <kbusch@kernel.org>
Date:   Fri Nov 8 15:41:08 2024 -0800

    nvme-pci: use sgls for all user requests if possible
    
    [ Upstream commit 6fad84a4d624c300d03ebba457cc641765050c43 ]
    
    If the device supports SGLs, use these for all user requests. This
    format encodes the expected transfer length so it can catch short buffer
    errors in a user command, whether it occurred accidently or maliciously.
    
    For controllers that support SGL data mode, this is a viable mitigation
    to CVE-2023-6238. For controllers that don't support SGLs, log a warning
    in the passthrough path since not having the capability can corrupt
    data if the interface is not used correctly.
    
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Stable-dep-of: 00817f0f1c45 ("nvme-ioctl: fix leaked requests on mapping error")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nvme-tcp: add basic support for the C2HTermReq PDU [+ + +]
Author: Maurizio Lombardi <mlombard@redhat.com>
Date:   Mon Feb 17 17:08:27 2025 +0100

    nvme-tcp: add basic support for the C2HTermReq PDU
    
    [ Upstream commit 84e009042d0f3dfe91bec60bcd208ee3f866cbcd ]
    
    Previously, the NVMe/TCP host driver did not handle the C2HTermReq PDU,
    instead printing "unsupported pdu type (3)" when received. This patch adds
    support for processing the C2HTermReq PDU, allowing the driver
    to print the Fatal Error Status field.
    
    Example of output:
    nvme nvme4: Received C2HTermReq (FES = Invalid PDU Header Field)
    
    Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Stable-dep-of: ad95bab0cd28 ("nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu()")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-tcp: Fix a C2HTermReq error message [+ + +]
Author: Maurizio Lombardi <mlombard@redhat.com>
Date:   Mon Feb 24 15:40:58 2025 +0100

    nvme-tcp: Fix a C2HTermReq error message
    
    commit afb41b08c44e5386f2f52fa859010ac4afd2b66f upstream.
    
    In H2CTermReq, a FES with value 0x05 means "R2T Limit Exceeded"; but
    in C2HTermReq the same value has a different meaning (Data Transfer Limit
    Exceeded).
    
    Fixes: 84e009042d0f ("nvme-tcp: add basic support for the C2HTermReq PDU")
    Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu() [+ + +]
Author: Maurizio Lombardi <mlombard@redhat.com>
Date:   Wed Feb 26 14:42:18 2025 +0100

    nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu()
    
    [ Upstream commit ad95bab0cd28ed77c2c0d0b6e76e03e031391064 ]
    
    nvme_tcp_recv_pdu() doesn't check the validity of the header length.
    When header digests are enabled, a target might send a packet with an
    invalid header length (e.g. 255), causing nvme_tcp_verify_hdgst()
    to access memory outside the allocated area and cause memory corruptions
    by overwriting it with the calculated digest.
    
    Fix this by rejecting packets with an unexpected header length.
    
    Fixes: 3f2304f8c6d6 ("nvme-tcp: add NVMe over TCP host driver")
    Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-tcp: fix signedness bug in nvme_tcp_init_connection() [+ + +]
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Wed Mar 5 18:52:59 2025 +0300

    nvme-tcp: fix signedness bug in nvme_tcp_init_connection()
    
    [ Upstream commit 528361c49962708a60f51a1afafeb00987cebedf ]
    
    The kernel_recvmsg() function returns an int which could be either
    negative error codes or the number of bytes received.  The problem is
    that the condition:
    
            if (ret < sizeof(*icresp)) {
    
    is type promoted to type unsigned long and negative values are treated
    as high positive values which is success, when they should be treated as
    failure.  Handle invalid positive returns separately from negative
    error codes to avoid this problem.
    
    Fixes: 578539e09690 ("nvme-tcp: fix connect failure on receiving partial ICResp PDU")
    Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
    Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nvmet-tcp: Fix a possible sporadic response drops in weakly ordered arch [+ + +]
Author: Meir Elisha <meir.elisha@volumez.com>
Date:   Wed Feb 26 09:28:12 2025 +0200

    nvmet-tcp: Fix a possible sporadic response drops in weakly ordered arch
    
    [ Upstream commit a16f88964c647103dad7743a484b216d488a6352 ]
    
    The order in which queue->cmd and rcv_state are updated is crucial.
    If these assignments are reordered by the compiler, the worker might not
    get queued in nvmet_tcp_queue_response(), hanging the IO. to enforce the
    the correct reordering, set rcv_state using smp_store_release().
    
    Fixes: bdaf13279192 ("nvmet-tcp: fix a segmentation fault during io parsing error")
    
    Signed-off-by: Meir Elisha <meir.elisha@volumez.com>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf/core: Fix pmus_lock vs. pmus_srcu ordering [+ + +]
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Mon Nov 4 14:39:11 2024 +0100

    perf/core: Fix pmus_lock vs. pmus_srcu ordering
    
    [ Upstream commit 2565e42539b120b81a68a58da961ce5d1e34eac8 ]
    
    Commit a63fbed776c7 ("perf/tracing/cpuhotplug: Fix locking order")
    placed pmus_lock inside pmus_srcu, this makes perf_pmu_unregister()
    trip lockdep.
    
    Move the locking about such that only pmu_idr and pmus (list) are
    modified while holding pmus_lock. This avoids doing synchronize_srcu()
    while holding pmus_lock and all is well again.
    
    Fixes: a63fbed776c7 ("perf/tracing/cpuhotplug: Fix locking order")
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/r/20241104135517.679556858@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
platform/x86: thinkpad_acpi: Add battery quirk for ThinkPad X131e [+ + +]
Author: Mingcong Bai <jeffbai@aosc.io>
Date:   Sat Feb 22 00:48:24 2025 +0800

    platform/x86: thinkpad_acpi: Add battery quirk for ThinkPad X131e
    
    commit d0d10eaedcb53740883d7e5d53c5e15c879b48fb upstream.
    
    Based on the dmesg messages from the original reporter:
    
    [    4.964073] ACPI: \_SB_.PCI0.LPCB.EC__.HKEY: BCTG evaluated but flagged as error
    [    4.964083] thinkpad_acpi: Error probing battery 2
    
    Lenovo ThinkPad X131e also needs this battery quirk.
    
    Reported-by: Fan Yang <804284660@qq.com>
    Tested-by: Fan Yang <804284660@qq.com>
    Co-developed-by: Xi Ruoyao <xry111@xry111.site>
    Signed-off-by: Xi Ruoyao <xry111@xry111.site>
    Signed-off-by: Mingcong Bai <jeffbai@aosc.io>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20250221164825.77315-1-jeffbai@aosc.io
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ppp: Fix KMSAN uninit-value warning with bpf [+ + +]
Author: Jiayuan Chen <jiayuan.chen@linux.dev>
Date:   Fri Feb 28 22:14:08 2025 +0800

    ppp: Fix KMSAN uninit-value warning with bpf
    
    [ Upstream commit 4c2d14c40a68678d885eab4008a0129646805bae ]
    
    Syzbot caught an "KMSAN: uninit-value" warning [1], which is caused by the
    ppp driver not initializing a 2-byte header when using socket filter.
    
    The following code can generate a PPP filter BPF program:
    '''
    struct bpf_program fp;
    pcap_t *handle;
    handle = pcap_open_dead(DLT_PPP_PPPD, 65535);
    pcap_compile(handle, &fp, "ip and outbound", 0, 0);
    bpf_dump(&fp, 1);
    '''
    Its output is:
    '''
    (000) ldh [2]
    (001) jeq #0x21 jt 2 jf 5
    (002) ldb [0]
    (003) jeq #0x1 jt 4 jf 5
    (004) ret #65535
    (005) ret #0
    '''
    Wen can find similar code at the following link:
    https://github.com/ppp-project/ppp/blob/master/pppd/options.c#L1680
    The maintainer of this code repository is also the original maintainer
    of the ppp driver.
    
    As you can see the BPF program skips 2 bytes of data and then reads the
    'Protocol' field to determine if it's an IP packet. Then it read the first
    byte of the first 2 bytes to determine the direction.
    
    The issue is that only the first byte indicating direction is initialized
    in current ppp driver code while the second byte is not initialized.
    
    For normal BPF programs generated by libpcap, uninitialized data won't be
    used, so it's not a problem. However, for carefully crafted BPF programs,
    such as those generated by syzkaller [2], which start reading from offset
    0, the uninitialized data will be used and caught by KMSAN.
    
    [1] https://syzkaller.appspot.com/bug?extid=853242d9c9917165d791
    [2] https://syzkaller.appspot.com/text?tag=ReproC&x=11994913980000
    
    Cc: Paul Mackerras <paulus@samba.org>
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reported-by: syzbot+853242d9c9917165d791@syzkaller.appspotmail.com
    Closes: https://lore.kernel.org/bpf/000000000000dea025060d6bc3bc@google.com/
    Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Link: https://patch.msgid.link/20250228141408.393864-1-jiayuan.chen@linux.dev
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rapidio: add check for rio_add_net() in rio_scan_alloc_net() [+ + +]
Author: Haoxiang Li <haoxiang_li2024@163.com>
Date:   Thu Feb 27 12:11:31 2025 +0800

    rapidio: add check for rio_add_net() in rio_scan_alloc_net()
    
    commit e842f9a1edf306bf36fe2a4d847a0b0d458770de upstream.
    
    The return value of rio_add_net() should be checked.  If it fails,
    put_device() should be called to free the memory and give up the reference
    initialized in rio_add_net().
    
    Link: https://lkml.kernel.org/r/20250227041131.3680761-1-haoxiang_li2024@163.com
    Fixes: e6b585ca6e81 ("rapidio: move net allocation into core code")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
    Cc: Alexandre Bounine <alex.bou9@gmail.com>
    Cc: Matt Porter <mporter@kernel.crashing.org>
    Cc: Dan Carpenter <dan.carpenter@linaro.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rapidio: fix an API misues when rio_add_net() fails [+ + +]
Author: Haoxiang Li <haoxiang_li2024@163.com>
Date:   Thu Feb 27 15:34:09 2025 +0800

    rapidio: fix an API misues when rio_add_net() fails
    
    commit b2ef51c74b0171fde7eb69b6152d3d2f743ef269 upstream.
    
    rio_add_net() calls device_register() and fails when device_register()
    fails.  Thus, put_device() should be used rather than kfree().  Add
    "mport->net = NULL;" to avoid a use after free issue.
    
    Link: https://lkml.kernel.org/r/20250227073409.3696854-1-haoxiang_li2024@163.com
    Fixes: e8de370188d0 ("rapidio: add mport char device driver")
    Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
    Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
    Cc: Alexandre Bounine <alex.bou9@gmail.com>
    Cc: Matt Porter <mporter@kernel.crashing.org>
    Cc: Yang Yingliang <yangyingliang@huawei.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Revert "drivers/card_reader/rtsx_usb: Restore interrupt based detection" [+ + +]
Author: Christian Heusel <christian@heusel.eu>
Date:   Mon Feb 24 09:32:59 2025 +0100

    Revert "drivers/card_reader/rtsx_usb: Restore interrupt based detection"
    
    commit 2397d61ee45cddb8f3bd3a3a9840ef0f0b5aa843 upstream.
    
    This reverts commit 235b630eda072d7e7b102ab346d6b8a2c028a772.
    
    This commit was found responsible for issues with SD card recognition,
    as users had to re-insert their cards in the readers and wait for a
    while. As for some people the SD card was involved in the boot process
    it also caused boot failures.
    
    Cc: stable@vger.kernel.org
    Link: https://bbs.archlinux.org/viewtopic.php?id=303321
    Fixes: 235b630eda07 ("drivers/card_reader/rtsx_usb: Restore interrupt based detection")
    Reported-by: qf <quintafeira@tutanota.com>
    Closes: https://lore.kernel.org/all/1de87dfa-1e81-45b7-8dcb-ad86c21d5352@heusel.eu
    Signed-off-by: Christian Heusel <christian@heusel.eu>
    Link: https://lore.kernel.org/r/20250224-revert-sdcard-patch-v1-1-d1a457fbb796@heusel.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Revert "KVM: e500: always restore irqs" [+ + +]
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Mon Mar 10 16:47:34 2025 +0100

    Revert "KVM: e500: always restore irqs"
    
    This reverts commit 48fe216d7db6b651972c1c1d8e3180cd699971b0 which is
    commit 87ecfdbc699cc95fac73291b52650283ddcf929d upstream.
    
    It should not have been applied.
    
    Link: https://lore.kernel.org/r/CABgObfb5U9zwTQBPkPB=mKu-vMrRspPCm4wfxoQpB+SyAnb5WQ@mail.gmail.com
    Reported-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Revert "KVM: PPC: e500: Mark "struct page" dirty in kvmppc_e500_shadow_map()" [+ + +]
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Mon Mar 10 16:52:25 2025 +0100

    Revert "KVM: PPC: e500: Mark "struct page" dirty in kvmppc_e500_shadow_map()"
    
    This reverts commit dec857329fb9a66a5bce4f9db14c97ef64725a32 which is
    commit c9be85dabb376299504e0d391d15662c0edf8273 upstream.
    
    It should not have been applied.
    
    Link: https://lore.kernel.org/r/CABgObfb5U9zwTQBPkPB=mKu-vMrRspPCm4wfxoQpB+SyAnb5WQ@mail.gmail.com
    Reported-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Revert "KVM: PPC: e500: Mark "struct page" pfn accessed before dropping mmu_lock" [+ + +]
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Mon Mar 10 16:52:03 2025 +0100

    Revert "KVM: PPC: e500: Mark "struct page" pfn accessed before dropping mmu_lock"
    
    This reverts commit f2623aec7fdc2675667042c85f87502c9139c098 which is
    commit 84cf78dcd9d65c45ab73998d4ad50f433d53fb93 upstream.
    
    It should not have been applied.
    
    Link: https://lore.kernel.org/r/CABgObfb5U9zwTQBPkPB=mKu-vMrRspPCm4wfxoQpB+SyAnb5WQ@mail.gmail.com
    Reported-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Revert "KVM: PPC: e500: Use __kvm_faultin_pfn() to handle page faults" [+ + +]
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Mon Mar 10 16:51:47 2025 +0100

    Revert "KVM: PPC: e500: Use __kvm_faultin_pfn() to handle page faults"
    
    This reverts commit 833f69be62ac366b5c23b4a6434389e470dd5c7f which is
    commit 419cfb983ca93e75e905794521afefcfa07988bb upstream.
    
    It should not have been applied.
    
    Link: https://lore.kernel.org/r/CABgObfb5U9zwTQBPkPB=mKu-vMrRspPCm4wfxoQpB+SyAnb5WQ@mail.gmail.com
    Reported-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Revert "mm/page_alloc.c: don't show protection in zone's ->lowmem_reserve[] for empty zone" [+ + +]
Author: Gabriel Krisman Bertazi <krisman@suse.de>
Date:   Tue Feb 25 22:22:58 2025 -0500

    Revert "mm/page_alloc.c: don't show protection in zone's ->lowmem_reserve[] for empty zone"
    
    commit eae116d1f0449ade3269ca47a67432622f5c6438 upstream.
    
    Commit 96a5c186efff ("mm/page_alloc.c: don't show protection in zone's
    ->lowmem_reserve[] for empty zone") removes the protection of lower zones
    from allocations targeting memory-less high zones.  This had an unintended
    impact on the pattern of reclaims because it makes the high-zone-targeted
    allocation more likely to succeed in lower zones, which adds pressure to
    said zones.  I.e, the following corresponding checks in
    zone_watermark_ok/zone_watermark_fast are less likely to trigger:
    
            if (free_pages <= min + z->lowmem_reserve[highest_zoneidx])
                    return false;
    
    As a result, we are observing an increase in reclaim and kswapd scans, due
    to the increased pressure.  This was initially observed as increased
    latency in filesystem operations when benchmarking with fio on a machine
    with some memory-less zones, but it has since been associated with
    increased contention in locks related to memory reclaim.  By reverting
    this patch, the original performance was recovered on that machine.
    
    The original commit was introduced as a clarification of the
    /proc/zoneinfo output, so it doesn't seem there are usecases depending on
    it, making the revert a simple solution.
    
    For reference, I collected vmstat with and without this patch on a freshly
    booted system running intensive randread io from an nvme for 5 minutes.  I
    got:
    
    rpm-6.12.0-slfo.1.2 ->  pgscan_kswapd 5629543865
    Patched             ->  pgscan_kswapd 33580844
    
    33M scans is similar to what we had in kernels predating this patch.
    These numbers is fairly representative of the workload on this machine, as
    measured in several runs.  So we are talking about a 2-order of magnitude
    increase.
    
    Link: https://lkml.kernel.org/r/20250226032258.234099-1-krisman@suse.de
    Fixes: 96a5c186efff ("mm/page_alloc.c: don't show protection in zone's ->lowmem_reserve[] for empty zone")
    Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
    Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Acked-by: Mel Gorman <mgorman@suse.de>
    Cc: Baoquan He <bhe@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Revert "of: reserved-memory: Fix using wrong number of cells to get property 'alignment'" [+ + +]
Author: Rob Herring (Arm) <robh@kernel.org>
Date:   Wed Feb 26 13:38:19 2025 -0600

    Revert "of: reserved-memory: Fix using wrong number of cells to get property 'alignment'"
    
    commit 75f1f311d883dfaffb98be3c1da208d6ed5d4df9 upstream.
    
    This reverts commit 267b21d0bef8e67dbe6c591c9991444e58237ec9.
    
    Turns out some DTs do depend on this behavior. Specifically, a
    downstream Pixel 6 DT. Revert the change at least until we can decide if
    the DT spec can be changed instead.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Revert "selftests/mm: remove local __NR_* definitions" [+ + +]
Author: John Hubbard <jhubbard@nvidia.com>
Date:   Thu Feb 13 19:38:50 2025 -0800

    Revert "selftests/mm: remove local __NR_* definitions"
    
    commit 0a7565ee6ec31eb16c0476adbfc1af3f2271cb6b upstream.
    
    This reverts commit a5c6bc590094a1a73cf6fa3f505e1945d2bf2461.
    
    The general approach described in commit e076eaca5906 ("selftests: break
    the dependency upon local header files") was taken one step too far here:
    it should not have been extended to include the syscall numbers.  This is
    because doing so would require per-arch support in tools/include/uapi, and
    no such support exists.
    
    This revert fixes two separate reports of test failures, from Dave
    Hansen[1], and Li Wang[2].  An excerpt of Dave's report:
    
    Before this commit (a5c6bc590094a1a73cf6fa3f505e1945d2bf2461) things are
    fine.  But after, I get:
    
            running PKEY tests for unsupported CPU/OS
    
    An excerpt of Li's report:
    
        I just found that mlock2_() return a wrong value in mlock2-test
    
    [1] https://lore.kernel.org/dc585017-6740-4cab-a536-b12b37a7582d@intel.com
    [2] https://lore.kernel.org/CAEemH2eW=UMu9+turT2jRie7+6ewUazXmA6kL+VBo3cGDGU6RA@mail.gmail.com
    
    Link: https://lkml.kernel.org/r/20250214033850.235171-1-jhubbard@nvidia.com
    Fixes: a5c6bc590094 ("selftests/mm: remove local __NR_* definitions")
    Signed-off-by: John Hubbard <jhubbard@nvidia.com>
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: Li Wang <liwang@redhat.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Jeff Xu <jeffxu@chromium.org>
    Cc: Andrei Vagin <avagin@google.com>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: Christian Brauner <brauner@kernel.org>
    Cc: Kees Cook <kees@kernel.org>
    Cc: Kent Overstreet <kent.overstreet@linux.dev>
    Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
    Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Rich Felker <dalias@libc.org>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
rust: alloc: add __GFP_NOWARN to `Flags` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:36 2025 +0100

    rust: alloc: add __GFP_NOWARN to `Flags`
    
    commit 01b2196e5aac8af9343282d0044fa0d6b07d484c upstream.
    
    Some test cases in subsequent patches provoke allocation failures. Add
    `__GFP_NOWARN` to enable test cases to silence unpleasant warnings.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-11-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: add `Allocator` trait [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:27 2025 +0100

    rust: alloc: add `Allocator` trait
    
    commit b7a084ba4fbb8f416ce8d19c93a3a2bee63c9c89 upstream.
    
    Add a kernel specific `Allocator` trait, that in contrast to the one in
    Rust's core library doesn't require unstable features and supports GFP
    flags.
    
    Subsequent patches add the following trait implementors: `Kmalloc`,
    `Vmalloc` and `KVmalloc`.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-2-dakr@kernel.org
    [ Fixed typo. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: add `Box` to prelude [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:40 2025 +0100

    rust: alloc: add `Box` to prelude
    
    commit e1044c2238f54ae5bd902cac6d12e48835df418b upstream.
    
    Now that we removed `BoxExt` and the corresponding includes in
    prelude.rs, add the new kernel `Box` type instead.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-15-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: add `Vec` to prelude [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:47 2025 +0100

    rust: alloc: add `Vec` to prelude
    
    commit 3145dc91c3c0ad945f06354385a6eb89d22becdb upstream.
    
    Now that we removed `VecExt` and the corresponding includes in
    prelude.rs, add the new kernel `Vec` type instead.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-22-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: add module `allocator_test` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:33 2025 +0100

    rust: alloc: add module `allocator_test`
    
    commit 5a888c28e3b4ff6f54a53fca33951537d135e7f1 upstream.
    
    `Allocator`s, such as `Kmalloc`, will be used by e.g. `Box` and `Vec` in
    subsequent patches, and hence this dependency propagates throughout the
    whole kernel.
    
    Add the `allocator_test` module that provides an empty implementation
    for all `Allocator`s in the kernel, such that we don't break the
    `rusttest` make target in subsequent patches.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-8-dakr@kernel.org
    [ Added missing `_old_layout` parameter as discussed. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: Fix `ArrayLayout` allocations [+ + +]
Author: Asahi Lina <lina@asahilina.net>
Date:   Fri Mar 7 23:50:07 2025 +0100

    rust: alloc: Fix `ArrayLayout` allocations
    
    commit b7ed2b6f4e8d7f64649795e76ee9db67300de8eb upstream.
    
    We were accidentally allocating a layout for the *square* of the object
    size due to a variable shadowing mishap.
    
    Fixes memory bloat and page allocation failures in drm/asahi.
    
    Reported-by: Janne Grunau <j@jannau.net>
    Fixes: 9e7bbfa18276 ("rust: alloc: introduce `ArrayLayout`")
    Signed-off-by: Asahi Lina <lina@asahilina.net>
    Acked-by: Danilo Krummrich <dakr@kernel.org>
    Reviewed-by: Neal Gompa <neal@gompa.dev>
    Link: https://lore.kernel.org/r/20241123-rust-fix-arraylayout-v1-1-197e64c95bd4@asahilina.net
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement `Allocator` for `Kmalloc` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:32 2025 +0100

    rust: alloc: implement `Allocator` for `Kmalloc`
    
    commit a34822d1c4c93085f635b922441a017bd7e959b0 upstream.
    
    Implement `Allocator` for `Kmalloc`, the kernel's default allocator,
    typically used for objects smaller than page size.
    
    All memory allocations made with `Kmalloc` end up in `krealloc()`.
    
    It serves as allocator for the subsequently introduced types `KBox` and
    `KVec`.
    
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-7-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement `Cmalloc` in module allocator_test [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:51 2025 +0100

    rust: alloc: implement `Cmalloc` in module allocator_test
    
    commit dd09538fb4093176a818fcecd45114430cc5840f upstream.
    
    So far the kernel's `Box` and `Vec` types can't be used by userspace
    test cases, since all users of those types (e.g. `CString`) use kernel
    allocators for instantiation.
    
    In order to allow userspace test cases to make use of such types as
    well, implement the `Cmalloc` allocator within the allocator_test module
    and type alias all kernel allocators to `Cmalloc`. The `Cmalloc`
    allocator uses libc's `realloc()` function as allocator backend.
    
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-26-dakr@kernel.org
    [ Removed the temporary `allow(dead_code)` as discussed in the list and
      fixed typo, added backticks. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement `collect` for `IntoIter` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:44 2025 +0100

    rust: alloc: implement `collect` for `IntoIter`
    
    commit 93e602310f87b7b515b86a8f919cc0799387e5c3 upstream.
    
    Currently, we can't implement `FromIterator`. There are a couple of
    issues with this trait in the kernel, namely:
    
      - Rust's specialization feature is unstable. This prevents us to
        optimize for the special case where `I::IntoIter` equals `Vec`'s
        `IntoIter` type.
      - We also can't use `I::IntoIter`'s type ID either to work around this,
        since `FromIterator` doesn't require this type to be `'static`.
      - `FromIterator::from_iter` does return `Self` instead of
        `Result<Self, AllocError>`, hence we can't properly handle allocation
        failures.
      - Neither `Iterator::collect` nor `FromIterator::from_iter` can handle
        additional allocation flags.
    
    Instead, provide `IntoIter::collect`, such that we can at least convert
    `IntoIter` into a `Vec` again.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-19-dakr@kernel.org
    [ Added newline in documentation, changed case of section to be
      consistent with an existing one, fixed typo. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement `contains` for `Flags` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:50 2025 +0100

    rust: alloc: implement `contains` for `Flags`
    
    commit 909037ce0369bc3f4fd31743fd2d8d7096f06002 upstream.
    
    Provide a simple helper function to check whether given flags do
    contain one or multiple other flags.
    
    This is used by a subsequent patch implementing the Cmalloc `Allocator`
    to check for __GFP_ZERO.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-25-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement `IntoIterator` for `Vec` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:43 2025 +0100

    rust: alloc: implement `IntoIterator` for `Vec`
    
    commit 1d1d223aa3b37c34271aefc2706340d0843bfcb2 upstream.
    
    Implement `IntoIterator` for `Vec`, `Vec`'s `IntoIter` type, as well as
    `Iterator` for `IntoIter`.
    
    `Vec::into_iter` disassembles the `Vec` into its raw parts; additionally,
    `IntoIter` keeps track of a separate pointer, which is incremented
    correspondingly as the iterator advances, while the length, or the count
    of elements, is decremented.
    
    This also means that `IntoIter` takes the ownership of the backing
    buffer and is responsible to drop the remaining elements and free the
    backing buffer, if it's dropped.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-18-dakr@kernel.org
    [ Fixed typos. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement `KVmalloc` allocator [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:35 2025 +0100

    rust: alloc: implement `KVmalloc` allocator
    
    commit 8362c2608ba1be635ffa22a256dfcfe51c6238cc upstream.
    
    Implement `Allocator` for `KVmalloc`, an `Allocator` that tries to
    allocate memory with `kmalloc` first and, on failure, falls back to
    `vmalloc`.
    
    All memory allocations made with `KVmalloc` end up in
    `kvrealloc_noprof()`; all frees in `kvfree()`.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-10-dakr@kernel.org
    [ Reworded typo. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement `ReallocFunc` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:30 2025 +0100

    rust: alloc: implement `ReallocFunc`
    
    commit 8a799831fc63c988eec90d334fdd68ff5f2c7eb5 upstream.
    
    `ReallocFunc` is an abstraction for the kernel's realloc derivates, such
    as `krealloc`, `vrealloc` and `kvrealloc`.
    
    All of the named functions share the same function signature and
    implement the same semantics. The `ReallocFunc` abstractions provides a
    generalized wrapper around those, to trivialize the implementation of
    `Kmalloc`, `Vmalloc` and `KVmalloc` in subsequent patches.
    
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-5-dakr@kernel.org
    [ Added temporary `allow(dead_code)` for `dangling_from_layout` to clean
      warning in `rusttest` target as discussed in the list (but it is
      needed earlier, i.e. in this patch already). Added colon. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement `Vmalloc` allocator [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:34 2025 +0100

    rust: alloc: implement `Vmalloc` allocator
    
    commit 61c004781d6b928443052e7a6cf84b35d4f61401 upstream.
    
    Implement `Allocator` for `Vmalloc`, the kernel's virtually contiguous
    allocator, typically used for larger objects, (much) larger than page
    size.
    
    All memory allocations made with `Vmalloc` end up in `vrealloc()`.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-9-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement kernel `Box` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:37 2025 +0100

    rust: alloc: implement kernel `Box`
    
    commit c8cfa8d0c0b10be216861fe904ea68978b1dcc97 upstream.
    
    `Box` provides the simplest way to allocate memory for a generic type
    with one of the kernel's allocators, e.g. `Kmalloc`, `Vmalloc` or
    `KVmalloc`.
    
    In contrast to Rust's `Box` type, the kernel `Box` type considers the
    kernel's GFP flags for all appropriate functions, always reports
    allocation failures through `Result<_, AllocError>` and remains
    independent from unstable features.
    
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-12-dakr@kernel.org
    [ Added backticks, fixed typos. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: implement kernel `Vec` type [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:42 2025 +0100

    rust: alloc: implement kernel `Vec` type
    
    commit 2aac4cd7dae3d7bb0e0ddec2561b2ee4cbe6c8f6 upstream.
    
    `Vec` provides a contiguous growable array type with contents allocated
    with the kernel's allocators (e.g. `Kmalloc`, `Vmalloc` or `KVmalloc`).
    
    In contrast to Rust's stdlib `Vec` type, the kernel `Vec` type considers
    the kernel's GFP flags for all appropriate functions, always reports
    allocation failures through `Result<_, AllocError>` and remains
    independent from unstable features.
    
    [ This patch starts using a new unstable feature, `inline_const`, but
      it was stabilized in Rust 1.79.0, i.e. the next version after the
      minimum one, thus it will not be an issue. - Miguel ]
    
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-17-dakr@kernel.org
    [ Cleaned `rustdoc` unescaped backtick warning, added a couple more
      backticks elsewhere, fixed typos, sorted `feature`s, rewrapped
      documentation lines. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: introduce `ArrayLayout` [+ + +]
Author: Benno Lossin <benno.lossin@proton.me>
Date:   Fri Mar 7 23:49:41 2025 +0100

    rust: alloc: introduce `ArrayLayout`
    
    commit 9e7bbfa182767f638ba61dba3518ff78da9f31ff upstream.
    
    When allocating memory for arrays using allocators, the `Layout::array`
    function is typically used. It returns a result, since the given size
    might be too big. However, `Vec` and its iterators store their allocated
    capacity and thus they already did check that the size is not too big.
    
    The `ArrayLayout` type provides this exact behavior, as it can be
    infallibly converted into a `Layout`. Instead of a `usize` capacity,
    `Vec` and other similar array-storing types can use `ArrayLayout`
    instead.
    
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Benno Lossin <benno.lossin@proton.me>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-16-dakr@kernel.org
    [ Formatted a few comments. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: make `allocator` module public [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:31 2025 +0100

    rust: alloc: make `allocator` module public
    
    commit a87a36f0bf517dae22f3e3790b05c979070f776a upstream.
    
    Subsequent patches implement allocators such as `Kmalloc`, `Vmalloc`,
    `KVmalloc`; we need them to be available outside of the kernel crate as
    well.
    
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-6-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: remove `VecExt` extension [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:46 2025 +0100

    rust: alloc: remove `VecExt` extension
    
    commit 405966efc789888c3e1a53cd09d2c2b338064438 upstream.
    
    Now that all existing `Vec` users were moved to the kernel `Vec` type,
    remove the `VecExt` extension.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-21-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: remove extension of std's `Box` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:39 2025 +0100

    rust: alloc: remove extension of std's `Box`
    
    commit e8c6ccdbcaaf31f26c0fffd4073edd0b0147cdc6 upstream.
    
    Now that all existing `Box` users were moved to the kernel `Box` type,
    remove the `BoxExt` extension and all other related extensions.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-14-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: rename `KernelAllocator` to `Kmalloc` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:29 2025 +0100

    rust: alloc: rename `KernelAllocator` to `Kmalloc`
    
    commit 941e65531446c1eb5d573c5d30172117ebe96112 upstream.
    
    Subsequent patches implement `Vmalloc` and `KVmalloc` allocators, hence
    align `KernelAllocator` to this naming scheme.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-4-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: separate `aligned_size` from `krealloc_aligned` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:28 2025 +0100

    rust: alloc: separate `aligned_size` from `krealloc_aligned`
    
    commit a654a6e09644266e38ac05415ef7737d299c4497 upstream.
    
    Separate `aligned_size` from `krealloc_aligned`.
    
    Subsequent patches implement `Allocator` derivates, such as `Kmalloc`,
    that require `aligned_size` and replace the original `krealloc_aligned`.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-3-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: alloc: update module comment of alloc.rs [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:53 2025 +0100

    rust: alloc: update module comment of alloc.rs
    
    commit 8ae740c3917ff92108df17236b3cf1b9a74bd359 upstream.
    
    Before we remove Rust's alloc crate, rewrite the module comment in
    alloc.rs to avoid a rustdoc warning.
    
    Besides that, the module comment in alloc.rs isn't correct anymore,
    we're no longer extending Rust's alloc crate.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-28-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: block: fix formatting in GenDisk doc [+ + +]
Author: Yutaro Ohno <yutaro.ono.418@gmail.com>
Date:   Thu Oct 24 00:54:59 2024 +0900

    rust: block: fix formatting in GenDisk doc
    
    commit 0c5928deada15a8d075516e6e0d9ee19011bb000 upstream.
    
    Align bullet points and improve indentation in the `Invariants` section
    of the `GenDisk` struct documentation for better readability.
    
    [ Yutaro is also working on implementing the lint we suggested to catch
      this sort of issue in upstream Rust:
    
        https://github.com/rust-lang/rust-clippy/issues/13601
        https://github.com/rust-lang/rust-clippy/pull/13711
    
      Thanks a lot! - Miguel ]
    
    Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")
    Signed-off-by: Yutaro Ohno <yutaro.ono.418@gmail.com>
    Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
    Acked-by: Andreas Hindborg <a.hindborg@kernel.org>
    Link: https://lore.kernel.org/r/ZxkcU5yTFCagg_lX@ohnotp
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: enable `clippy::ignored_unit_patterns` lint [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:14 2025 +0100

    rust: enable `clippy::ignored_unit_patterns` lint
    
    commit 3fcc23397628c2357dbe66df59644e09f72ac725 upstream.
    
    In Rust 1.73.0, Clippy introduced the `ignored_unit_patterns` lint [1]:
    
    > Matching with `()` explicitly instead of `_` outlines the fact that
    > the pattern contains no data. Also it would detect a type change
    > that `_` would ignore.
    
    There is only a single case that requires a change:
    
        error: matching over `()` is more explicit
           --> rust/kernel/types.rs:176:45
            |
        176 |         ScopeGuard::new_with_data((), move |_| cleanup())
            |                                             ^ help: use `()` instead of `_`: `()`
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ignored_unit_patterns
            = note: requested on the command line with `-D clippy::ignored-unit-patterns`
    
    Thus clean it up and enable the lint -- no functional change intended.
    
    Link: https://rust-lang.github.io/rust-clippy/master/index.html#/ignored_unit_patterns [1]
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-8-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: enable `clippy::undocumented_unsafe_blocks` lint [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:11 2025 +0100

    rust: enable `clippy::undocumented_unsafe_blocks` lint
    
    commit db4f72c904cb116e2bf56afdd67fc5167a607a7b upstream.
    
    Checking that we are not missing any `// SAFETY` comments in our `unsafe`
    blocks is something we have wanted to do for a long time, as well as
    cleaning up the remaining cases that were not documented [1].
    
    Back when Rust for Linux started, this was something that could have
    been done via a script, like Rust's `tidy`. Soon after, in Rust 1.58.0,
    Clippy implemented the `undocumented_unsafe_blocks` lint [2].
    
    Even though the lint has a few false positives, e.g. in some cases where
    attributes appear between the comment and the `unsafe` block [3], there
    are workarounds and the lint seems quite usable already.
    
    Thus enable the lint now.
    
    We still have a few cases to clean up, so just allow those for the moment
    by writing a `TODO` comment -- some of those may be good candidates for
    new contributors.
    
    Link: https://github.com/Rust-for-Linux/linux/issues/351 [1]
    Link: https://rust-lang.github.io/rust-clippy/master/#/undocumented_unsafe_blocks [2]
    Link: https://github.com/rust-lang/rust-clippy/issues/13189 [3]
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-5-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: enable `clippy::unnecessary_safety_comment` lint [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:12 2025 +0100

    rust: enable `clippy::unnecessary_safety_comment` lint
    
    commit c28bfe76e4ba707775a205b0274710de7aa1e31c upstream.
    
    In Rust 1.67.0, Clippy added the `unnecessary_safety_comment` lint [1],
    which is the "inverse" of `undocumented_unsafe_blocks`: it finds places
    where safe code has a `// SAFETY` comment attached.
    
    The lint currently finds 3 places where we had such mistakes, thus it
    seems already quite useful.
    
    Thus clean those and enable it.
    
    Link: https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_safety_comment [1]
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-6-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: enable `clippy::unnecessary_safety_doc` lint [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:13 2025 +0100

    rust: enable `clippy::unnecessary_safety_doc` lint
    
    commit 23f42dc054b3c550373eae0c9ae97f1ce1501e0a upstream.
    
    In Rust 1.67.0, Clippy added the `unnecessary_safety_doc` lint [1],
    which is similar to `unnecessary_safety_comment`, but for `# Safety`
    sections, i.e. safety preconditions in the documentation.
    
    This is something that should not happen with our coding guidelines in
    mind. Thus enable the lint to have it machine-checked.
    
    Link: https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_safety_doc [1]
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-7-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: enable `rustdoc::unescaped_backticks` lint [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:15 2025 +0100

    rust: enable `rustdoc::unescaped_backticks` lint
    
    commit bef83245f5ed434932aaf07f890142b576dc5d85 upstream.
    
    In Rust 1.71.0, `rustdoc` added the `unescaped_backticks` lint, which
    detects what are typically typos in Markdown formatting regarding inline
    code [1], e.g. from the Rust standard library:
    
        /// ... to `deref`/`deref_mut`` must ...
    
        /// ... use [`from_mut`]`. Specifically, ...
    
    It does not seem to have almost any false positives, from the experience
    of enabling it in the Rust standard library [2], which will be checked
    starting with Rust 1.82.0. The maintainers also confirmed it is ready
    to be used.
    
    Thus enable it.
    
    Link: https://doc.rust-lang.org/rustdoc/lints.html#unescaped_backticks [1]
    Link: https://github.com/rust-lang/rust/pull/128307 [2]
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-9-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: enable Clippy's `check-private-items` [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:21 2025 +0100

    rust: enable Clippy's `check-private-items`
    
    commit 624063b9ac97f40cadca32a896aafeb28b1220fd upstream.
    
    In Rust 1.76.0, Clippy added the `check-private-items` lint configuration
    option. When turned on (the default is off), it makes several lints
    check private items as well.
    
    In our case, it affects two lints we have enabled [1]:
    `missing_safety_doc` and `unnecessary_safety_doc`.
    
    It also seems to affect the new `too_long_first_doc_paragraph` lint [2],
    even though the documentation does not mention it.
    
    Thus allow the few instances remaining we currently hit and enable
    the lint.
    
    Link: https://doc.rust-lang.org/nightly/clippy/lint_configuration.html#check-private-items [1]
    Link: https://rust-lang.github.io/rust-clippy/master/index.html#/too_long_first_doc_paragraph [2]
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-16-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: error: check for config `test` in `Error::name` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:49 2025 +0100

    rust: error: check for config `test` in `Error::name`
    
    commit 4a28ab469ff01855eb819dfd94754d1792f03f2a upstream.
    
    Additional to `testlib` also check for `test` in `Error::name`. This is
    required by a subsequent patch that (indirectly) uses `Error` in test
    cases.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-24-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: error: make conversion functions public [+ + +]
Author: Filipe Xavier <felipe_life@live.com>
Date:   Fri Mar 7 23:49:25 2025 +0100

    rust: error: make conversion functions public
    
    commit 5ed147473458f8c20f908a03227d8f5bb3cb8f7d upstream.
    
    Change visibility to public of functions in error.rs:
    from_err_ptr, from_errno, from_result and to_ptr.
    Additionally, remove dead_code annotations.
    
    Link: https://github.com/Rust-for-Linux/linux/issues/1105
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Signed-off-by: Filipe Xavier <felipe_life@live.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/DM4PR14MB7276E6948E67B3B23D8EA847E9652@DM4PR14MB7276.namprd14.prod.outlook.com
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: error: optimize error type to use nonzero [+ + +]
Author: Filipe Xavier <felipe_life@live.com>
Date:   Fri Mar 7 23:49:26 2025 +0100

    rust: error: optimize error type to use nonzero
    
    commit e9759c5b9ea555d09f426c70c880e9522e9b0576 upstream.
    
    Optimize `Result<(), Error>` size by changing `Error` type to
    `NonZero*` for niche optimization.
    
    This reduces the space used by the `Result` type, as the `NonZero*`
    type enables the compiler to apply more efficient memory layout.
    For example, the `Result<(), Error>` changes size from 8 to 4 bytes.
    
    Link: https://github.com/Rust-for-Linux/linux/issues/1120
    Signed-off-by: Filipe Xavier <felipe_life@live.com>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Fiona Behrens <me@kloenk.dev>
    Link: https://lore.kernel.org/r/BL0PR02MB4914B9B088865CF237731207E9732@BL0PR02MB4914.namprd02.prod.outlook.com
    [ Removed unneeded block around `match`, added backticks in panic
      message and added intra-doc link. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: error: use `core::alloc::LayoutError` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:48 2025 +0100

    rust: error: use `core::alloc::LayoutError`
    
    commit 29a48d25ff53c183482dc88a99133a0fb5aa541a upstream.
    
    Use `core::alloc::LayoutError` instead of `alloc::alloc::LayoutError` in
    preparation to get rid of Rust's alloc crate.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-23-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: finish using custom FFI integer types [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Sun Mar 9 21:42:16 2025 +0100

    rust: finish using custom FFI integer types
    
    commit 27c7518e7f1ccaaa43eb5f25dc362779d2dc2ccb upstream.
    
    In the last kernel cycle we migrated most of the `core::ffi` cases in
    commit d072acda4862 ("rust: use custom FFI integer types"):
    
        Currently FFI integer types are defined in libcore. This commit
        creates the `ffi` crate and asks bindgen to use that crate for FFI
        integer types instead of `core::ffi`.
    
        This commit is preparatory and no type changes are made in this
        commit yet.
    
    Finish now the few remaining/new cases so that we perform the actual
    remapping in the next commit as planned.
    
    Acked-by: Jocelyn Falempe <jfalempe@redhat.com> # drm
    Link: https://lore.kernel.org/rust-for-linux/CANiq72m_rg42SvZK=bF2f0yEoBLVA33UBhiAsv8THhVu=G2dPA@mail.gmail.com/
    Link: https://lore.kernel.org/all/cc9253fa-9d5f-460b-9841-94948fb6580c@redhat.com/
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: fix size_t in bindgen prototypes of C builtins [+ + +]
Author: Gary Guo <gary@garyguo.net>
Date:   Fri Mar 7 23:50:04 2025 +0100

    rust: fix size_t in bindgen prototypes of C builtins
    
    commit 75c1fd41a671a0843b89d1526411a837a7163fa2 upstream.
    
    Without `-fno-builtin`, for functions like memcpy/memmove (and many
    others), bindgen seems to be using the clang-provided prototype. This
    prototype is ABI-wise compatible, but the issue is that it does not have
    the same information as the source code w.r.t. typedefs.
    
    For example, bindgen generates the following:
    
        extern "C" {
            pub fn strlen(s: *const core::ffi::c_char) -> core::ffi::c_ulong;
        }
    
    note that the return type is `c_ulong` (i.e. unsigned long), despite the
    size_t-is-usize behavior (this is default, and we have not opted out
    from it using --no-size_t-is-usize).
    
    Similarly, memchr's size argument should be of type `__kernel_size_t`,
    but bindgen generates `c_ulong` directly.
    
    We want to ensure any `size_t` is translated to Rust `usize` so that we
    can avoid having them be different type on 32-bit and 64-bit
    architectures, and hence would require a lot of excessive type casts
    when calling FFI functions.
    
    I found that this bindgen behavior (which probably is caused by
    libclang) can be disabled by `-fno-builtin`. Using the flag for compiled
    code can result in less optimisation because compiler cannot assume
    about their properties anymore, but this should not affect bindgen.
    
    [ Trevor asked: "I wonder how reliable this behavior is. Maybe bindgen
      could do a better job controlling this, is there an open issue?".
    
      Gary replied: ..."apparently this is indeed the suggested approach in
      https://github.com/rust-lang/rust-bindgen/issues/1770". - Miguel ]
    
    Signed-off-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240913213041.395655-2-gary@garyguo.net
    [ Formatted comment. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: init: remove unneeded `#[allow(clippy::disallowed_names)]` [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:16 2025 +0100

    rust: init: remove unneeded `#[allow(clippy::disallowed_names)]`
    
    commit d5cc7ab0a0a99496de1bd933dac242699a417809 upstream.
    
    These few cases, unlike others in the same file, did not need the `allow`.
    
    Thus clean them up.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-10-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: introduce `.clippy.toml` [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:18 2025 +0100

    rust: introduce `.clippy.toml`
    
    commit 7d56786edcbdf58b6367fd7f01d5861214ad1c95 upstream.
    
    Some Clippy lints can be configured/tweaked. We will use these knobs to
    our advantage in later commits.
    
    This is done via a configuration file, `.clippy.toml` [1]. The file is
    currently unstable. This may be a problem in the future, but we can adapt
    as needed. In addition, we proposed adding Clippy to the Rust CI's RFL
    job [2], so we should be able to catch issues pre-merge.
    
    Thus introduce the file.
    
    Link: https://doc.rust-lang.org/clippy/configuration.html [1]
    Link: https://github.com/rust-lang/rust/pull/128928 [2]
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-12-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: kbuild: expand rusttest target for macros [+ + +]
Author: Ethan D. Twardy <ethan.twardy@gmail.com>
Date:   Fri Mar 7 23:50:03 2025 +0100

    rust: kbuild: expand rusttest target for macros
    
    commit b2c261fa8629dff2bd1143fa790797a773ace102 upstream.
    
    Previously, the rusttest target for the macros crate did not specify
    the dependencies necessary to run the rustdoc tests. These tests rely on
    the kernel crate, so add the dependencies.
    
    Signed-off-by: Ethan D. Twardy <ethan.twardy@gmail.com>
    Link: https://github.com/Rust-for-Linux/linux/issues/1076
    Link: https://lore.kernel.org/r/20240704145607.17732-2-ethan.twardy@gmail.com
    [ Rebased (`alloc` is gone nowadays, sysroot handling is simpler) and
      simplified (reused `rustdoc_test` rule instead of adding a new one,
      no need for `rustdoc-compiler_builtins`, removed unneeded `macros`
      explicit path). Made `vtable` example fail (avoiding to increase
      the complexity in the `rusttest` target). Removed unstable
      `-Zproc-macro-backtrace` option. Reworded accordingly. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: map `__kernel_size_t` and friends also to usize/isize [+ + +]
Author: Gary Guo <gary@garyguo.net>
Date:   Fri Mar 7 23:50:05 2025 +0100

    rust: map `__kernel_size_t` and friends also to usize/isize
    
    commit 2fd6f55c048d0c863ffbc8590b1bd2edb5ff13e5 upstream.
    
    Currently bindgen has special logic to recognise `size_t` and `ssize_t`
    and map them to Rust `usize` and `isize`. Similarly, `ptrdiff_t` is
    mapped to `isize`.
    
    However this falls short for `__kernel_size_t`, `__kernel_ssize_t` and
    `__kernel_ptrdiff_t`. To ensure that they are mapped to usize/isize
    rather than 32/64 integers depending on platform, blocklist them in
    bindgen parameters and manually provide their definition.
    
    Signed-off-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Link: https://lore.kernel.org/r/20240913213041.395655-3-gary@garyguo.net
    [ Formatted comment. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: map `long` to `isize` and `char` to `u8` [+ + +]
Author: Gary Guo <gary@garyguo.net>
Date:   Sun Mar 9 21:42:17 2025 +0100

    rust: map `long` to `isize` and `char` to `u8`
    
    commit 1bae8729e50a900f41e9a1c17ae81113e4cf62b8 upstream.
    
    The following FFI types are replaced compared to `core::ffi`:
    
    1. `char` type is now always mapped to `u8`, since kernel uses
       `-funsigned-char` on the C code. `core::ffi` maps it to platform
       default ABI, which can be either signed or unsigned.
    
    2. `long` is now always mapped to `isize`. It's very common in the
       kernel to use `long` to represent a pointer-sized integer, and in
       fact `intptr_t` is a typedef of `long` in the kernel. Enforce this
       mapping rather than mapping to `i32/i64` depending on platform can
       save us a lot of unnecessary casts.
    
    Signed-off-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Link: https://lore.kernel.org/r/20240913213041.395655-5-gary@garyguo.net
    [ Moved `uaccess` changes from the next commit, since they were
      irrefutable patterns that Rust >= 1.82.0 warns about. Reworded
      slightly and reformatted a few documentation comments. Rebased on
      top of `rust-next`. Added the removal of two casts to avoid Clippy
      warnings. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: provide proper code documentation titles [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:20 2025 +0100

    rust: provide proper code documentation titles
    
    commit 2f390cc589433dfcfedc307a141e103929a6fd4d upstream.
    
    Rust 1.82.0's Clippy is introducing [1][2] a new warn-by-default lint,
    `too_long_first_doc_paragraph` [3], which is intended to catch titles
    of code documentation items that are too long (likely because no title
    was provided and the item documentation starts with a paragraph).
    
    This lint does not currently trigger anywhere, but it does detect a couple
    cases if checking for private items gets enabled (which we will do in
    the next commit):
    
        error: first doc comment paragraph is too long
          --> rust/kernel/init/__internal.rs:18:1
           |
        18 | / /// This is the module-internal type implementing `PinInit` and `Init`. It is unsafe to create this
        19 | | /// type, since the closure needs to fulfill the same safety requirement as the
        20 | | /// `__pinned_init`/`__init` functions.
           | |_
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
           = note: `-D clippy::too-long-first-doc-paragraph` implied by `-D warnings`
           = help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]`
    
        error: first doc comment paragraph is too long
         --> rust/kernel/sync/arc/std_vendor.rs:3:1
          |
        3 | / //! The contents of this file come from the Rust standard library, hosted in
        4 | | //! the <https://github.com/rust-lang/rust> repository, licensed under
        5 | | //! "Apache-2.0 OR MIT" and adapted for kernel use. For copyright details,
        6 | | //! see <https://github.com/rust-lang/rust/blob/master/COPYRIGHT>.
          | |_
          |
          = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
    
    Thus clean those two instances.
    
    In addition, since we have a second `std_vendor.rs` file with a similar
    header, do the same there too (even if that one does not trigger the lint,
    because it is `doc(hidden)`).
    
    Link: https://github.com/rust-lang/rust/pull/129531 [1]
    Link: https://github.com/rust-lang/rust-clippy/pull/12993 [2]
    Link: https://rust-lang.github.io/rust-clippy/master/index.html#/too_long_first_doc_paragraph [3]
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-15-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: replace `clippy::dbg_macro` with `disallowed_macros` [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:19 2025 +0100

    rust: replace `clippy::dbg_macro` with `disallowed_macros`
    
    commit 8577c9dca799bd74377f7c30015d8cdc53a53ca2 upstream.
    
    Back when we used Rust 1.60.0 (before Rust was merged in the kernel),
    we added `-Wclippy::dbg_macro` to the compilation flags. This worked
    great with our custom `dbg!` macro (vendored from `std`, but slightly
    modified to use the kernel printing facilities).
    
    However, in the very next version, 1.61.0, it stopped working [1] since
    the lint started to use a Rust diagnostic item rather than a path to find
    the `dbg!` macro [1]. This behavior remains until the current nightly
    (1.83.0).
    
    Therefore, currently, the `dbg_macro` is not doing anything, which
    explains why we can invoke `dbg!` in samples/rust/rust_print.rs`, as well
    as why changing the `#[allow()]`s to `#[expect()]`s in `std_vendor.rs`
    doctests does not work since they are not fulfilled.
    
    One possible workaround is using `rustc_attrs` like the standard library
    does. However, this is intended to be internal, and we just started
    supporting several Rust compiler versions, so it is best to avoid it.
    
    Therefore, instead, use `disallowed_macros`. It is a stable lint and
    is more flexible (in that we can provide different macros), although
    its diagnostic message(s) are not as nice as the specialized one (yet),
    and does not allow to set different lint levels per macro/path [2].
    
    In turn, this requires allowing the (intentional) `dbg!` use in the
    sample, as one would have expected.
    
    Finally, in a single case, the `allow` is fixed to be an inner attribute,
    since otherwise it was not being applied.
    
    Link: https://github.com/rust-lang/rust-clippy/issues/11303 [1]
    Link: https://github.com/rust-lang/rust-clippy/issues/11307 [2]
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-13-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: sort global Rust flags [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:09 2025 +0100

    rust: sort global Rust flags
    
    commit a135aa3d30d28f26eb28a0ff5d48b387b0e0755f upstream.
    
    Sort the global Rust flags so that it is easier to follow along when we
    have more, like this patch series does.
    
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-3-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: start using the `#[expect(...)]` attribute [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:23 2025 +0100

    rust: start using the `#[expect(...)]` attribute
    
    commit 1f9ed172545687e5c04c77490a45896be6d2e459 upstream.
    
    In Rust, it is possible to `allow` particular warnings (diagnostics,
    lints) locally, making the compiler ignore instances of a given warning
    within a given function, module, block, etc.
    
    It is similar to `#pragma GCC diagnostic push` + `ignored` + `pop` in C:
    
        #pragma GCC diagnostic push
        #pragma GCC diagnostic ignored "-Wunused-function"
        static void f(void) {}
        #pragma GCC diagnostic pop
    
    But way less verbose:
    
        #[allow(dead_code)]
        fn f() {}
    
    By that virtue, it makes it possible to comfortably enable more
    diagnostics by default (i.e. outside `W=` levels) that may have some
    false positives but that are otherwise quite useful to keep enabled to
    catch potential mistakes.
    
    The `#[expect(...)]` attribute [1] takes this further, and makes the
    compiler warn if the diagnostic was _not_ produced. For instance, the
    following will ensure that, when `f()` is called somewhere, we will have
    to remove the attribute:
    
        #[expect(dead_code)]
        fn f() {}
    
    If we do not, we get a warning from the compiler:
    
        warning: this lint expectation is unfulfilled
         --> x.rs:3:10
          |
        3 | #[expect(dead_code)]
          |          ^^^^^^^^^
          |
          = note: `#[warn(unfulfilled_lint_expectations)]` on by default
    
    This means that `expect`s do not get forgotten when they are not needed.
    
    See the next commit for more details, nuances on its usage and
    documentation on the feature.
    
    The attribute requires the `lint_reasons` [2] unstable feature, but it
    is becoming stable in 1.81.0 (to be released on 2024-09-05) and it has
    already been useful to clean things up in this patch series, finding
    cases where the `allow`s should not have been there.
    
    Thus, enable `lint_reasons` and convert some of our `allow`s to `expect`s
    where possible.
    
    This feature was also an example of the ongoing collaboration between
    Rust and the kernel -- we tested it in the kernel early on and found an
    issue that was quickly resolved [3].
    
    Cc: Fridtjof Stoldt <xfrednet@gmail.com>
    Cc: Urgau <urgau@numericable.fr>
    Link: https://rust-lang.github.io/rfcs/2383-lint-reasons.html#expect-lint-attribute [1]
    Link: https://github.com/rust-lang/rust/issues/54503 [2]
    Link: https://github.com/rust-lang/rust/issues/114557 [3]
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-18-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: str: test: replace `alloc::format` [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:52 2025 +0100

    rust: str: test: replace `alloc::format`
    
    commit eb6f92cd3f755c179204ea1f933b07cf992892fd upstream.
    
    The current implementation of tests in str.rs use `format!` to format
    strings for comparison, which, internally, creates a new `String`.
    
    In order to prepare for getting rid of Rust's alloc crate, we have to
    cut this dependency. Instead, implement `format!` for `CString`.
    
    Note that for userspace tests, `Kmalloc`, which is backing `CString`'s
    memory, is just a type alias to `Cmalloc`.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-27-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: sync: remove unneeded `#[allow(clippy::non_send_fields_in_send_ty)]` [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:17 2025 +0100

    rust: sync: remove unneeded `#[allow(clippy::non_send_fields_in_send_ty)]`
    
    commit 5e7c9b84ad08cc7a41b2ddbbbaccb60057da3860 upstream.
    
    Rust 1.58.0 (before Rust was merged into the kernel) made Clippy's
    `non_send_fields_in_send_ty` lint part of the `suspicious` lint group for
    a brief window of time [1] until the minor version 1.58.1 got released
    a week after, where the lint was moved back to `nursery`.
    
    By that time, we had already upgraded to that Rust version, and thus we
    had `allow`ed the lint here for `CondVar`.
    
    Nowadays, Clippy's `non_send_fields_in_send_ty` would still trigger here
    if it were enabled.
    
    Moreover, if enabled, `Lock<T, B>` and `Task` would also require an
    `allow`. Therefore, it does not seem like someone is actually enabling it
    (in, e.g., a custom flags build).
    
    Finally, the lint does not appear to have had major improvements since
    then [2].
    
    Thus remove the `allow` since it is unneeded.
    
    Link: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1581-2022-01-20 [1]
    Link: https://github.com/rust-lang/rust-clippy/issues/8045 [2]
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-11-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: treewide: switch to our kernel `Box` type [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:38 2025 +0100

    rust: treewide: switch to our kernel `Box` type
    
    commit 8373147ce4961665c5700016b1c76299e962d077 upstream.
    
    Now that we got the kernel `Box` type in place, convert all existing
    `Box` users to make use of it.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-13-dakr@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: treewide: switch to the kernel `Vec` type [+ + +]
Author: Danilo Krummrich <dakr@kernel.org>
Date:   Fri Mar 7 23:49:45 2025 +0100

    rust: treewide: switch to the kernel `Vec` type
    
    commit 58eff8e872bd04ccb3adcf99aec7334ffad06cfd upstream.
    
    Now that we got the kernel `Vec` in place, convert all existing `Vec`
    users to make use of it.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Benno Lossin <benno.lossin@proton.me>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Signed-off-by: Danilo Krummrich <dakr@kernel.org>
    Link: https://lore.kernel.org/r/20241004154149.93856-20-dakr@kernel.org
    [ Converted `kasan_test_rust.rs` too, as discussed. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: types: avoid repetition in `{As,From}Bytes` impls [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:10 2025 +0100

    rust: types: avoid repetition in `{As,From}Bytes` impls
    
    commit 567cdff53e71de56ae67eaf4309db38778b7bcd3 upstream.
    
    In order to provide `// SAFETY` comments for every `unsafe impl`, we would
    need to repeat them, which is not very useful and would be harder to read.
    
    We could perhaps allow the lint (ideally within a small module), but we
    can take the chance to avoid the repetition of the `impl`s themselves
    too by using a small local macro, like in other places where we have
    had to do this sort of thing.
    
    Thus add the straightforward `impl_{from,as}bytes!` macros and use them
    to implement `FromBytes`.
    
    This, in turn, will allow us in the next patch to place a `// SAFETY`
    comment that defers to the actual invocation of the macro.
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-4-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: use custom FFI integer types [+ + +]
Author: Gary Guo <gary@garyguo.net>
Date:   Fri Mar 7 23:50:06 2025 +0100

    rust: use custom FFI integer types
    
    commit d072acda4862f095ec9056979b654cc06a22cc68 upstream.
    
    Currently FFI integer types are defined in libcore. This commit creates
    the `ffi` crate and asks bindgen to use that crate for FFI integer types
    instead of `core::ffi`.
    
    This commit is preparatory and no type changes are made in this commit
    yet.
    
    Signed-off-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240913213041.395655-4-gary@garyguo.net
    [ Added `rustdoc`, `rusttest` and KUnit tests support. Rebased on top of
      `rust-next` (e.g. migrated more `core::ffi` cases). Reworded crate
      docs slightly and formatted. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rust: workqueue: remove unneeded ``#[allow(clippy::new_ret_no_self)]` [+ + +]
Author: Miguel Ojeda <ojeda@kernel.org>
Date:   Fri Mar 7 23:49:08 2025 +0100

    rust: workqueue: remove unneeded ``#[allow(clippy::new_ret_no_self)]`
    
    commit 024f9676a6d236132119832a90fb9a1a9115b41a upstream.
    
    Perform the same clean commit b2516f7af9d2 ("rust: kernel: remove
    `#[allow(clippy::new_ret_no_self)]`") did for a case that appeared in
    workqueue in parallel in commit 7324b88975c5 ("rust: workqueue: add
    helper for defining work_struct fields"):
    
        Clippy triggered a false positive on its `new_ret_no_self` lint
        when using the `pin_init!` macro. Since Rust 1.67.0, that does
        not happen anymore, since Clippy learnt to not warn about
        `-> impl Trait<Self>` [1][2].
    
        The kernel nowadays uses Rust 1.72.1, thus remove the `#[allow]`.
    
        Link: https://github.com/rust-lang/rust-clippy/issues/7344 [1]
        Link: https://github.com/rust-lang/rust-clippy/pull/9733 [2]
    
    Reviewed-by: Alice Ryhl <aliceryhl@google.com>
    Reviewed-by: Trevor Gross <tmgross@umich.edu>
    Tested-by: Gary Guo <gary@garyguo.net>
    Reviewed-by: Gary Guo <gary@garyguo.net>
    Link: https://lore.kernel.org/r/20240904204347.168520-2-ojeda@kernel.org
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
s390/traps: Fix test_monitor_call() inline assembly [+ + +]
Author: Heiko Carstens <hca@linux.ibm.com>
Date:   Tue Feb 25 10:53:10 2025 +0100

    s390/traps: Fix test_monitor_call() inline assembly
    
    commit 5623bc23a1cb9f9a9470fa73b3a20321dc4c4870 upstream.
    
    The test_monitor_call() inline assembly uses the xgr instruction, which
    also modifies the condition code, to clear a register. However the clobber
    list of the inline assembly does not specify that the condition code is
    modified, which may lead to incorrect code generation.
    
    Use the lhi instruction instead to clear the register without that the
    condition code is modified. Furthermore this limits clearing to the lower
    32 bits of val, since its type is int.
    
    Fixes: 17248ea03674 ("s390: fix __EMIT_BUG() macro")
    Cc: stable@vger.kernel.org
    Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
    Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
sched/fair: Fix potential memory corruption in child_cfs_rq_on_list [+ + +]
Author: Zecheng Li <zecheng@google.com>
Date:   Tue Mar 4 21:40:31 2025 +0000

    sched/fair: Fix potential memory corruption in child_cfs_rq_on_list
    
    [ Upstream commit 3b4035ddbfc8e4521f85569998a7569668cccf51 ]
    
    child_cfs_rq_on_list attempts to convert a 'prev' pointer to a cfs_rq.
    This 'prev' pointer can originate from struct rq's leaf_cfs_rq_list,
    making the conversion invalid and potentially leading to memory
    corruption. Depending on the relative positions of leaf_cfs_rq_list and
    the task group (tg) pointer within the struct, this can cause a memory
    fault or access garbage data.
    
    The issue arises in list_add_leaf_cfs_rq, where both
    cfs_rq->leaf_cfs_rq_list and rq->leaf_cfs_rq_list are added to the same
    leaf list. Also, rq->tmp_alone_branch can be set to rq->leaf_cfs_rq_list.
    
    This adds a check `if (prev == &rq->leaf_cfs_rq_list)` after the main
    conditional in child_cfs_rq_on_list. This ensures that the container_of
    operation will convert a correct cfs_rq struct.
    
    This check is sufficient because only cfs_rqs on the same CPU are added
    to the list, so verifying the 'prev' pointer against the current rq's list
    head is enough.
    
    Fixes a potential memory corruption issue that due to current struct
    layout might not be manifesting as a crash but could lead to unpredictable
    behavior when the layout changes.
    
    Fixes: fdaba61ef8a2 ("sched/fair: Ensure that the CFS parent is added after unthrottling")
    Signed-off-by: Zecheng Li <zecheng@google.com>
    Reviewed-and-tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
    Link: https://lore.kernel.org/r/20250304214031.2882646-1-zecheng@google.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
selftests/bpf: Clean up open-coded gettid syscall invocations [+ + +]
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Date:   Mon Nov 4 09:19:58 2024 -0800

    selftests/bpf: Clean up open-coded gettid syscall invocations
    
    commit 0e2fb011a0ba8e2258ce776fdf89fbd589c2a3a6 upstream.
    
    Availability of the gettid definition across glibc versions supported by
    BPF selftests is not certain. Currently, all users in the tree open-code
    syscall to gettid. Convert them to a common macro definition.
    
    Reviewed-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
    Link: https://lore.kernel.org/r/20241104171959.2938862-3-memxor@gmail.com
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reported-by: Colm Harrington <colm.harrington@oracle.com>
    Signed-off-by: Alan Maguire <alan.maguire@oracle.com>

 
selftests/damon/damon_nr_regions: set ops update for merge results check to 100ms [+ + +]
Author: SeongJae Park <sj@kernel.org>
Date:   Tue Feb 25 14:23:32 2025 -0800

    selftests/damon/damon_nr_regions: set ops update for merge results check to 100ms
    
    commit 695469c07a65547acb6e229b3fdf6aaa881817e3 upstream.
    
    damon_nr_regions.py updates max_nr_regions to a number smaller than
    expected number of real regions and confirms DAMON respect the harsh
    limit.  To give time for DAMON to make changes for the regions, 3
    aggregation intervals (300 milliseconds) are given.
    
    The internal mechanism works with not only the max_nr_regions, but also
    sz_limit, though.  It avoids merging region if that casn make region of
    size larger than sz_limit.  In the test, sz_limit is set too small to
    achive the new max_nr_regions, unless it is updated for the new
    min_nr_regions.  But the update is done only once per operations set
    update interval, which is one second by default.
    
    Hence, the test randomly incurs false positive failures.  Fix it by
    setting the ops interval same to aggregation interval, to make sure
    sz_limit is updated by the time of the check.
    
    Link: https://lkml.kernel.org/r/20250225222333.505646-3-sj@kernel.org
    Fixes: 8bf890c81612 ("selftests/damon/damon_nr_regions: test online-tuned max_nr_regions")
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries [+ + +]
Author: SeongJae Park <sj@kernel.org>
Date:   Tue Feb 25 14:23:33 2025 -0800

    selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries
    
    commit 582ccf78f6090d88b1c7066b1e90b3d9ec952d08 upstream.
    
    damon_nr_regions.py starts DAMON, periodically collect number of regions
    in snapshots, and see if it is in the requested range.  The check code
    assumes the numbers are sorted on the collection list, but there is no
    such guarantee.  Hence this can result in false positive test success.
    Sort the list before doing the check.
    
    Link: https://lkml.kernel.org/r/20250225222333.505646-4-sj@kernel.org
    Fixes: 781497347d1b ("selftests/damon: implement test for min/max_nr_regions")
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
selftests/damon/damos_quota: make real expectation of quota exceeds [+ + +]
Author: SeongJae Park <sj@kernel.org>
Date:   Tue Feb 25 14:23:31 2025 -0800

    selftests/damon/damos_quota: make real expectation of quota exceeds
    
    commit 1c684d77dfbcf926e0dd28f6d260e8fdd8a58e85 upstream.
    
    Patch series "selftests/damon: three fixes for false results".
    
    Fix three DAMON selftest bugs that cause two and one false positive
    failures and successes.
    
    
    This patch (of 3):
    
    damos_quota.py assumes the quota will always exceeded.  But whether quota
    will be exceeded or not depend on the monitoring results.  Actually the
    monitored workload has chaning access pattern and hence sometimes the
    quota may not really be exceeded.  As a result, false positive test
    failures happen.  Expect how much time the quota will be exceeded by
    checking the monitoring results, and use it instead of the naive
    assumption.
    
    Link: https://lkml.kernel.org/r/20250225222333.505646-1-sj@kernel.org
    Link: https://lkml.kernel.org/r/20250225222333.505646-2-sj@kernel.org
    Fixes: 51f58c9da14b ("selftests/damon: add a test for DAMOS quota")
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
selftests/damon/damos_quota_goal: handle minimum quota that cannot be further reduced [+ + +]
Author: SeongJae Park <sj@kernel.org>
Date:   Mon Feb 17 10:23:04 2025 -0800

    selftests/damon/damos_quota_goal: handle minimum quota that cannot be further reduced
    
    commit 349db086a66051bc6114b64b4446787c20ac3f00 upstream.
    
    damos_quota_goal.py selftest see if DAMOS quota goals tuning feature
    increases or reduces the effective size quota for given score as expected.
    The tuning feature sets the minimum quota size as one byte, so if the
    effective size quota is already one, we cannot expect it further be
    reduced.  However the test is not aware of the edge case, and fails since
    it shown no expected change of the effective quota.  Handle the case by
    updating the failure logic for no change to see if it was the case, and
    simply skips to next test input.
    
    Link: https://lkml.kernel.org/r/20250217182304.45215-1-sj@kernel.org
    Fixes: f1c07c0a1662 ("selftests/damon: add a test for DAMOS quota goal")
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Reported-by: kernel test robot <oliver.sang@intel.com>
    Closes: https://lore.kernel.org/oe-lkp/202502171423.b28a918d-lkp@intel.com
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: <stable@vger.kernel.org>    [6.10.x]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
slimbus: messaging: Free transaction ID in delayed interrupt scenario [+ + +]
Author: Visweswara Tanuku <quic_vtanuku@quicinc.com>
Date:   Fri Jan 24 04:57:40 2025 -0800

    slimbus: messaging: Free transaction ID in delayed interrupt scenario
    
    commit dcb0d43ba8eb9517e70b1a0e4b0ae0ab657a0e5a upstream.
    
    In case of interrupt delay for any reason, slim_do_transfer()
    returns timeout error but the transaction ID (TID) is not freed.
    This results into invalid memory access inside
    qcom_slim_ngd_rx_msgq_cb() due to invalid TID.
    
    Fix the issue by freeing the TID in slim_do_transfer() before
    returning timeout error to avoid invalid memory access.
    
    Call trace:
    __memcpy_fromio+0x20/0x190
    qcom_slim_ngd_rx_msgq_cb+0x130/0x290 [slim_qcom_ngd_ctrl]
    vchan_complete+0x2a0/0x4a0
    tasklet_action_common+0x274/0x700
    tasklet_action+0x28/0x3c
    _stext+0x188/0x620
    run_ksoftirqd+0x34/0x74
    smpboot_thread_fn+0x1d8/0x464
    kthread+0x178/0x238
    ret_from_fork+0x10/0x20
    Code: aa0003e8 91000429 f100044a 3940002b (3800150b)
    ---[ end trace 0fe00bec2b975c99 ]---
    Kernel panic - not syncing: Oops: Fatal exception in interrupt.
    
    Fixes: afbdcc7c384b ("slimbus: Add messaging APIs to slimbus framework")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Visweswara Tanuku <quic_vtanuku@quicinc.com>
    Link: https://lore.kernel.org/r/20250124125740.16897-1-quic_vtanuku@quicinc.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
smb311: failure to open files of length 1040 when mounting with SMB3.1.1 POSIX extensions [+ + +]
Author: Steve French <stfrench@microsoft.com>
Date:   Sun Feb 16 22:17:54 2025 -0600

    smb311: failure to open files of length 1040 when mounting with SMB3.1.1 POSIX extensions
    
    [ Upstream commit 9df23801c83d3e12b4c09be39d37d2be385e52f9 ]
    
    If a file size has bits 0x410 = ATTR_DIRECTORY | ATTR_REPARSE set
    then during queryinfo (stat) the file is regarded as a directory
    and subsequent opens can fail. A simple test example is trying
    to open any file 1040 bytes long when mounting with "posix"
    (SMB3.1.1 POSIX/Linux Extensions).
    
    The cause of this bug is that Attributes field in smb2_file_all_info
    struct occupies the same place that EndOfFile field in
    smb311_posix_qinfo, and sometimes the latter struct is incorrectly
    processed as if it was the first one.
    
    Reported-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
    Tested-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
    Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
stmmac: loongson: Pass correct arg to PCI function [+ + +]
Author: Philipp Stanner <phasta@kernel.org>
Date:   Wed Feb 26 09:52:05 2025 +0100

    stmmac: loongson: Pass correct arg to PCI function
    
    commit 00371a3f48775967950c2fe3ec97b7c786ca956d upstream.
    
    pcim_iomap_regions() should receive the driver's name as its third
    parameter, not the PCI device's name.
    
    Define the driver name with a macro and use it at the appropriate
    places, including pcim_iomap_regions().
    
    Cc: stable@vger.kernel.org # v5.14+
    Fixes: 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson")
    Signed-off-by: Philipp Stanner <phasta@kernel.org>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
    Tested-by: Henry Chen <chenx97@aosc.io>
    Link: https://patch.msgid.link/20250226085208.97891-2-phasta@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
tracing: probe-events: Remove unused MAX_ARG_BUF_LEN macro [+ + +]
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date:   Wed Feb 26 15:19:18 2025 +0900

    tracing: probe-events: Remove unused MAX_ARG_BUF_LEN macro
    
    [ Upstream commit fd5ba38390c59e1c147480ae49b6133c4ac24001 ]
    
    Commit 18b1e870a496 ("tracing/probes: Add $arg* meta argument for all
    function args") introduced MAX_ARG_BUF_LEN but it is not used.
    Remove it.
    
    Link: https://lore.kernel.org/all/174055075876.4079315.8805416872155957588.stgit@mhiramat.tok.corp.google.com/
    
    Fixes: 18b1e870a496 ("tracing/probes: Add $arg* meta argument for all function args")
    Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

tracing: tprobe-events: Fix a memory leak when tprobe with $retval [+ + +]
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date:   Wed Feb 26 15:18:46 2025 +0900

    tracing: tprobe-events: Fix a memory leak when tprobe with $retval
    
    commit ac965d7d88fc36fb42e3d50225c0a44dd8326da4 upstream.
    
    Fix a memory leak when a tprobe is defined with $retval. This
    combination is not allowed, but the parse_symbol_and_return() does
    not free the *symbol which should not be used if it returns the error.
    Thus, it leaks the *symbol memory in that error path.
    
    Link: https://lore.kernel.org/all/174055072650.4079315.3063014346697447838.stgit@mhiramat.tok.corp.google.com/
    
    Fixes: ce51e6153f77 ("tracing: fprobe-event: Fix to check tracepoint event and return")
    Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

tracing: tprobe-events: Reject invalid tracepoint name [+ + +]
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date:   Wed Feb 26 15:18:54 2025 +0900

    tracing: tprobe-events: Reject invalid tracepoint name
    
    commit d0453655b6ddc685a4837f3cc0776ae8eef62d01 upstream.
    
    Commit 57a7e6de9e30 ("tracing/fprobe: Support raw tracepoints on
    future loaded modules") allows user to set a tprobe on non-exist
    tracepoint but it does not check the tracepoint name is acceptable.
    So it leads tprobe has a wrong character for events (e.g. with
    subsystem prefix). In this case, the event is not shown in the
    events directory.
    
    Reject such invalid tracepoint name.
    
    The tracepoint name must consist of alphabet or digit or '_'.
    
    Link: https://lore.kernel.org/all/174055073461.4079315.15875502830565214255.stgit@mhiramat.tok.corp.google.com/
    
    Fixes: 57a7e6de9e30 ("tracing/fprobe: Support raw tracepoints on future loaded modules")
    Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ublk: set_params: properly check if parameters can be applied [+ + +]
Author: Uday Shankar <ushankar@purestorage.com>
Date:   Tue Mar 4 14:34:26 2025 -0700

    ublk: set_params: properly check if parameters can be applied
    
    [ Upstream commit 5ac60242b0173be83709603ebaf27a473f16c4e4 ]
    
    The parameters set by the set_params call are only applied to the block
    device in the start_dev call. So if a device has already been started, a
    subsequently issued set_params on that device will not have the desired
    effect, and should return an error. There is an existing check for this
    - set_params fails on devices in the LIVE state. But this check is not
    sufficient to cover the recovery case. In this case, the device will be
    in the QUIESCED or FAIL_IO states, so set_params will succeed. But this
    success is misleading, because the parameters will not be applied, since
    the device has already been started (by a previous ublk server). The bit
    UB_STATE_USED is set on completion of the start_dev; use it to detect
    and fail set_params commands which arrive too late to be applied (after
    start_dev).
    
    Signed-off-by: Uday Shankar <ushankar@purestorage.com>
    Fixes: 0aa73170eba5 ("ublk_drv: add SET_PARAMS/GET_PARAMS control command")
    Reviewed-by: Ming Lei <ming.lei@redhat.com>
    Link: https://lore.kernel.org/r/20250304-set_params-v1-1-17b5e0887606@purestorage.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
uprobes: Fix race in uprobe_free_utask [+ + +]
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Thu Jan 9 15:14:40 2025 +0100

    uprobes: Fix race in uprobe_free_utask
    
    commit b583ef82b671c9a752fbe3e95bd4c1c51eab764d upstream.
    
    Max Makarov reported kernel panic [1] in perf user callchain code.
    
    The reason for that is the race between uprobe_free_utask and bpf
    profiler code doing the perf user stack unwind and is triggered
    within uprobe_free_utask function:
      - after current->utask is freed and
      - before current->utask is set to NULL
    
     general protection fault, probably for non-canonical address 0x9e759c37ee555c76: 0000 [#1] SMP PTI
     RIP: 0010:is_uprobe_at_func_entry+0x28/0x80
     ...
      ? die_addr+0x36/0x90
      ? exc_general_protection+0x217/0x420
      ? asm_exc_general_protection+0x26/0x30
      ? is_uprobe_at_func_entry+0x28/0x80
      perf_callchain_user+0x20a/0x360
      get_perf_callchain+0x147/0x1d0
      bpf_get_stackid+0x60/0x90
      bpf_prog_9aac297fb833e2f5_do_perf_event+0x434/0x53b
      ? __smp_call_single_queue+0xad/0x120
      bpf_overflow_handler+0x75/0x110
      ...
      asm_sysvec_apic_timer_interrupt+0x1a/0x20
     RIP: 0010:__kmem_cache_free+0x1cb/0x350
     ...
      ? uprobe_free_utask+0x62/0x80
      ? acct_collect+0x4c/0x220
      uprobe_free_utask+0x62/0x80
      mm_release+0x12/0xb0
      do_exit+0x26b/0xaa0
      __x64_sys_exit+0x1b/0x20
      do_syscall_64+0x5a/0x80
    
    It can be easily reproduced by running following commands in
    separate terminals:
    
      # while :; do bpftrace -e 'uprobe:/bin/ls:_start  { printf("hit\n"); }' -c ls; done
      # bpftrace -e 'profile:hz:100000 { @[ustack()] = count(); }'
    
    Fixing this by making sure current->utask pointer is set to NULL
    before we start to release the utask object.
    
    [1] https://github.com/grafana/pyroscope/issues/3673
    
    Fixes: cfa7f3d2c526 ("perf,x86: avoid missing caller address in stack traces captured in uprobe")
    Reported-by: Max Makarov <maxpain@linux.com>
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Acked-by: Oleg Nesterov <oleg@redhat.com>
    Acked-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/r/20250109141440.2692173-1-jolsa@kernel.org
    [Christian Simon: Rebased for 6.12.y, due to mainline change https://lore.kernel.org/all/20240929144239.GA9475@redhat.com/]
    Signed-off-by: Christian Simon <simon@swine.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
usb: atm: cxacru: fix a flaw in existing endpoint checks [+ + +]
Author: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Date:   Thu Feb 13 15:22:57 2025 +0300

    usb: atm: cxacru: fix a flaw in existing endpoint checks
    
    commit c90aad369899a607cfbc002bebeafd51e31900cd upstream.
    
    Syzbot once again identified a flaw in usb endpoint checking, see [1].
    This time the issue stems from a commit authored by me (2eabb655a968
    ("usb: atm: cxacru: fix endpoint checking in cxacru_bind()")).
    
    While using usb_find_common_endpoints() may usually be enough to
    discard devices with wrong endpoints, in this case one needs more
    than just finding and identifying the sufficient number of endpoints
    of correct types - one needs to check the endpoint's address as well.
    
    Since cxacru_bind() fills URBs with CXACRU_EP_CMD address in mind,
    switch the endpoint verification approach to usb_check_XXX_endpoints()
    instead to fix incomplete ep testing.
    
    [1] Syzbot report:
    usb 5-1: BOGUS urb xfer, pipe 3 != type 1
    WARNING: CPU: 0 PID: 1378 at drivers/usb/core/urb.c:504 usb_submit_urb+0xc4e/0x18c0 drivers/usb/core/urb.c:503
    ...
    RIP: 0010:usb_submit_urb+0xc4e/0x18c0 drivers/usb/core/urb.c:503
    ...
    Call Trace:
     <TASK>
     cxacru_cm+0x3c8/0xe50 drivers/usb/atm/cxacru.c:649
     cxacru_card_status drivers/usb/atm/cxacru.c:760 [inline]
     cxacru_bind+0xcf9/0x1150 drivers/usb/atm/cxacru.c:1223
     usbatm_usb_probe+0x314/0x1d30 drivers/usb/atm/usbatm.c:1058
     cxacru_usb_probe+0x184/0x220 drivers/usb/atm/cxacru.c:1377
     usb_probe_interface+0x641/0xbb0 drivers/usb/core/driver.c:396
     really_probe+0x2b9/0xad0 drivers/base/dd.c:658
     __driver_probe_device+0x1a2/0x390 drivers/base/dd.c:800
     driver_probe_device+0x50/0x430 drivers/base/dd.c:830
    ...
    
    Reported-and-tested-by: syzbot+ccbbc229a024fa3e13b5@syzkaller.appspotmail.com
    Closes: https://syzkaller.appspot.com/bug?extid=ccbbc229a024fa3e13b5
    Fixes: 2eabb655a968 ("usb: atm: cxacru: fix endpoint checking in cxacru_bind()")
    Cc: stable@kernel.org
    Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
    Link: https://lore.kernel.org/r/20250213122259.730772-1-n.zhandarovich@fintech.ru
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: dwc3: gadget: Prevent irq storm when TH re-executes [+ + +]
Author: Badhri Jagan Sridharan <badhri@google.com>
Date:   Sun Feb 16 22:30:02 2025 +0000

    usb: dwc3: gadget: Prevent irq storm when TH re-executes
    
    commit 69c58deec19628c8a686030102176484eb94fed4 upstream.
    
    While commit d325a1de49d6 ("usb: dwc3: gadget: Prevent losing events in
    event cache") makes sure that top half(TH) does not end up overwriting the
    cached events before processing them when the TH gets invoked more than one
    time, returning IRQ_HANDLED results in occasional irq storm where the TH
    hogs the CPU. The irq storm can be prevented by the flag before event
    handler busy is cleared. Default enable interrupt moderation in all
    versions which support them.
    
    ftrace event stub during dwc3 irq storm:
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000866: irq_handler_exit: irq=14 ret=handled
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000872: irq_handler_entry: irq=504 name=dwc3
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000874: irq_handler_exit: irq=504 ret=handled
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000881: irq_handler_entry: irq=504 name=dwc3
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000883: irq_handler_exit: irq=504 ret=handled
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000889: irq_handler_entry: irq=504 name=dwc3
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000892: irq_handler_exit: irq=504 ret=handled
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000898: irq_handler_entry: irq=504 name=dwc3
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000901: irq_handler_exit: irq=504 ret=handled
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000907: irq_handler_entry: irq=504 name=dwc3
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000909: irq_handler_exit: irq=504 ret=handled
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000915: irq_handler_entry: irq=504 name=dwc3
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000918: irq_handler_exit: irq=504 ret=handled
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000924: irq_handler_entry: irq=504 name=dwc3
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000927: irq_handler_exit: irq=504 ret=handled
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000933: irq_handler_entry: irq=504 name=dwc3
        irq/504_dwc3-1111  ( 1111) [000] .... 70.000935: irq_handler_exit: irq=504 ret=handled
        ....
    
    Cc: stable <stable@kernel.org>
    Suggested-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Fixes: d325a1de49d6 ("usb: dwc3: gadget: Prevent losing events in event cache")
    Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
    Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Link: https://lore.kernel.org/r/20250216223003.3568039-1-badhri@google.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: dwc3: Set SUSPENDENABLE soon after phy init [+ + +]
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Thu Jan 30 23:49:31 2025 +0000

    usb: dwc3: Set SUSPENDENABLE soon after phy init
    
    commit cc5bfc4e16fc1d1c520cd7bb28646e82b6e69217 upstream.
    
    After phy initialization, some phy operations can only be executed while
    in lower P states. Ensure GUSB3PIPECTL.SUSPENDENABLE and
    GUSB2PHYCFG.SUSPHY are set soon after initialization to avoid blocking
    phy ops.
    
    Previously the SUSPENDENABLE bits are only set after the controller
    initialization, which may not happen right away if there's no gadget
    driver or xhci driver bound. Revise this to clear SUSPENDENABLE bits
    only when there's mode switching (change in GCTL.PRTCAPDIR).
    
    Fixes: 6d735722063a ("usb: dwc3: core: Prevent phy suspend during init")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Link: https://lore.kernel.org/r/633aef0afee7d56d2316f7cc3e1b2a6d518a8cc9.1738280911.git.Thinh.Nguyen@synopsys.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: gadget: Check bmAttributes only if configuration is valid [+ + +]
Author: Prashanth K <prashanth.k@oss.qualcomm.com>
Date:   Mon Feb 24 14:26:04 2025 +0530

    usb: gadget: Check bmAttributes only if configuration is valid
    
    commit 8e812e9355a6f14dffd54a33d951ca403b9732f5 upstream.
    
    If the USB configuration is not valid, then avoid checking for
    bmAttributes to prevent null pointer deference.
    
    Cc: stable <stable@kernel.org>
    Fixes: 40e89ff5750f ("usb: gadget: Set self-powered based on MaxPower and bmAttributes")
    Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
    Link: https://lore.kernel.org/r/20250224085604.417327-1-prashanth.k@oss.qualcomm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: gadget: Fix setting self-powered state on suspend [+ + +]
Author: Marek Szyprowski <m.szyprowski@samsung.com>
Date:   Thu Feb 20 13:03:14 2025 +0100

    usb: gadget: Fix setting self-powered state on suspend
    
    commit c783e1258f29c5caac9eea0aea6b172870f1baf8 upstream.
    
    cdev->config might be NULL, so check it before dereferencing.
    
    CC: stable <stable@kernel.org>
    Fixes: 40e89ff5750f ("usb: gadget: Set self-powered based on MaxPower and bmAttributes")
    Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Link: https://lore.kernel.org/r/20250220120314.3614330-1-m.szyprowski@samsung.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: gadget: Set self-powered based on MaxPower and bmAttributes [+ + +]
Author: Prashanth K <prashanth.k@oss.qualcomm.com>
Date:   Mon Feb 17 17:33:28 2025 +0530

    usb: gadget: Set self-powered based on MaxPower and bmAttributes
    
    commit 40e89ff5750fca2c1d6da93f98a2038716bba86c upstream.
    
    Currently the USB gadget will be set as bus-powered based solely
    on whether its bMaxPower is greater than 100mA, but this may miss
    devices that may legitimately draw less than 100mA but still want
    to report as bus-powered. Similarly during suspend & resume, USB
    gadget is incorrectly marked as bus/self powered without checking
    the bmAttributes field. Fix these by configuring the USB gadget
    as self or bus powered based on bmAttributes, and explicitly set
    it as bus-powered if it draws more than 100mA.
    
    Cc: stable <stable@kernel.org>
    Fixes: 5e5caf4fa8d3 ("usb: gadget: composite: Inform controller driver of self-powered")
    Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
    Link: https://lore.kernel.org/r/20250217120328.2446639-1-prashanth.k@oss.qualcomm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails [+ + +]
Author: Prashanth K <prashanth.k@oss.qualcomm.com>
Date:   Wed Feb 12 15:38:40 2025 +0530

    usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails
    
    commit 17c2c87c37862c3e95b55f660681cc6e8d66660e upstream.
    
    Currently while UDC suspends, u_ether attempts to remote wakeup
    the host if there are any pending transfers. However, if remote
    wakeup fails, the UDC remains suspended but the is_suspend flag
    is not set. And since is_suspend flag isn't set, the subsequent
    eth_start_xmit() would queue USB requests to suspended UDC.
    
    To fix this, bail out from gether_suspend() only if remote wakeup
    operation is successful.
    
    Cc: stable <stable@kernel.org>
    Fixes: 0a1af6dfa077 ("usb: gadget: f_ecm: Add suspend/resume and remote wakeup support")
    Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
    Link: https://lore.kernel.org/r/20250212100840.3812153-1-prashanth.k@oss.qualcomm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: hub: lack of clearing xHC resources [+ + +]
Author: Pawel Laszczak <pawell@cadence.com>
Date:   Fri Feb 28 07:50:25 2025 +0000

    usb: hub: lack of clearing xHC resources
    
    commit 2b66ef84d0d2a0ea955b40bd306f5e3abbc5cf9c upstream.
    
    The xHC resources allocated for USB devices are not released in correct
    order after resuming in case when while suspend device was reconnected.
    
    This issue has been detected during the fallowing scenario:
    - connect hub HS to root port
    - connect LS/FS device to hub port
    - wait for enumeration to finish
    - force host to suspend
    - reconnect hub attached to root port
    - wake host
    
    For this scenario during enumeration of USB LS/FS device the Cadence xHC
    reports completion error code for xHC commands because the xHC resources
    used for devices has not been properly released.
    XHCI specification doesn't mention that device can be reset in any order
    so, we should not treat this issue as Cadence xHC controller bug.
    Similar as during disconnecting in this case the device resources should
    be cleared starting form the last usb device in tree toward the root hub.
    To fix this issue usbcore driver should call hcd->driver->reset_device
    for all USB devices connected to hub which was reconnected while
    suspending.
    
    Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Pawel Laszczak <pawell@cadence.com>
    Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
    Link: https://lore.kernel.org/r/PH7PR07MB953841E38C088678ACDCF6EEDDCC2@PH7PR07MB9538.namprd07.prod.outlook.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: quirks: Add DELAY_INIT and NO_LPM for Prolific Mass Storage Card Reader [+ + +]
Author: Miao Li <limiao@kylinos.cn>
Date:   Tue Mar 4 15:07:57 2025 +0800

    usb: quirks: Add DELAY_INIT and NO_LPM for Prolific Mass Storage Card Reader
    
    commit ff712188daa3fe3ce7e11e530b4dca3826dae14a upstream.
    
    When used on Huawei hisi platforms, Prolific Mass Storage Card Reader
    which the VID:PID is in 067b:2731 might fail to enumerate at boot time
    and doesn't work well with LPM enabled, combination quirks:
            USB_QUIRK_DELAY_INIT + USB_QUIRK_NO_LPM
    fixed the problems.
    
    Signed-off-by: Miao Li <limiao@kylinos.cn>
    Cc: stable <stable@kernel.org>
    Link: https://lore.kernel.org/r/20250304070757.139473-1-limiao870622@163.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: renesas_usbhs: Call clk_put() [+ + +]
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Date:   Tue Feb 25 13:02:46 2025 +0200

    usb: renesas_usbhs: Call clk_put()
    
    commit b5ea08aa883da05106fcc683d12489a4292d1122 upstream.
    
    Clocks acquired with of_clk_get() need to be freed with clk_put(). Call
    clk_put() on priv->clks[0] on error path.
    
    Fixes: 3df0e240caba ("usb: renesas_usbhs: Add multiple clocks management")
    Cc: stable <stable@kernel.org>
    Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
    Link: https://lore.kernel.org/r/20250225110248.870417-2-claudiu.beznea.uj@bp.renesas.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: renesas_usbhs: Flush the notify_hotplug_work [+ + +]
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Date:   Tue Feb 25 13:02:48 2025 +0200

    usb: renesas_usbhs: Flush the notify_hotplug_work
    
    commit 552ca6b87e3778f3dd5b87842f95138162e16c82 upstream.
    
    When performing continuous unbind/bind operations on the USB drivers
    available on the Renesas RZ/G2L SoC, a kernel crash with the message
    "Unable to handle kernel NULL pointer dereference at virtual address"
    may occur. This issue points to the usbhsc_notify_hotplug() function.
    
    Flush the delayed work to avoid its execution when driver resources are
    unavailable.
    
    Fixes: bc57381e6347 ("usb: renesas_usbhs: use delayed_work instead of work_struct")
    Cc: stable <stable@kernel.org>
    Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
    Link: https://lore.kernel.org/r/20250225110248.870417-4-claudiu.beznea.uj@bp.renesas.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: renesas_usbhs: Use devm_usb_get_phy() [+ + +]
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Date:   Tue Feb 25 13:02:47 2025 +0200

    usb: renesas_usbhs: Use devm_usb_get_phy()
    
    commit e0c92440938930e7fa7aa6362780d39cdea34449 upstream.
    
    The gpriv->transceiver is retrieved in probe() through usb_get_phy() but
    never released. Use devm_usb_get_phy() to handle this scenario.
    
    This issue was identified through code investigation. No issue was found
    without this change.
    
    Fixes: b5a2875605ca ("usb: renesas_usbhs: Allow an OTG PHY driver to provide VBUS")
    Cc: stable <stable@kernel.org>
    Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
    Link: https://lore.kernel.org/r/20250225110248.870417-3-claudiu.beznea.uj@bp.renesas.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: typec: tcpci_rt1711h: Unmask alert interrupts to fix functionality [+ + +]
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Date:   Wed Feb 19 12:47:00 2025 +0100

    usb: typec: tcpci_rt1711h: Unmask alert interrupts to fix functionality
    
    commit d6b82dafd17db0658f089b9cdec573982ca82bc5 upstream.
    
    During probe, the TCPC alert interrupts are getting masked to
    avoid unwanted interrupts during chip setup: this is ok to do
    but there is no unmasking happening at any later time, which
    means that the chip will not raise any interrupt, essentially
    making it not functional as, while internally it does perform
    all of the intended functions, it won't signal anything to the
    outside.
    
    Unmask the alert interrupts to fix functionality.
    
    Fixes: ce08eaeb6388 ("staging: typec: rt1711h typec chip driver")
    Cc: stable <stable@kernel.org>
    Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20250219114700.41700-1-angelogioacchino.delregno@collabora.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: typec: ucsi: Fix NULL pointer access [+ + +]
Author: Andrei Kuchynski <akuchynski@chromium.org>
Date:   Wed Mar 5 11:17:39 2025 +0000

    usb: typec: ucsi: Fix NULL pointer access
    
    commit b13abcb7ddd8d38de769486db5bd917537b32ab1 upstream.
    
    Resources should be released only after all threads that utilize them
    have been destroyed.
    This commit ensures that resources are not released prematurely by waiting
    for the associated workqueue to complete before deallocating them.
    
    Cc: stable <stable@kernel.org>
    Fixes: b9aa02ca39a4 ("usb: typec: ucsi: Add polling mechanism for partner tasks like alt mode checking")
    Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Link: https://lore.kernel.org/r/20250305111739.1489003-2-akuchynski@chromium.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: typec: ucsi: increase timeout for PPM reset operations [+ + +]
Author: Fedor Pchelkin <boddah8794@gmail.com>
Date:   Mon Feb 17 13:54:40 2025 +0300

    usb: typec: ucsi: increase timeout for PPM reset operations
    
    commit bf4f9ae1cb08ccaafbe6874be6c46f59b83ae778 upstream.
    
    It is observed that on some systems an initial PPM reset during the boot
    phase can trigger a timeout:
    
    [    6.482546] ucsi_acpi USBC000:00: failed to reset PPM!
    [    6.482551] ucsi_acpi USBC000:00: error -ETIMEDOUT: PPM init failed
    
    Still, increasing the timeout value, albeit being the most straightforward
    solution, eliminates the problem: the initial PPM reset may take up to
    ~8000-10000ms on some Lenovo laptops. When it is reset after the above
    period of time (or even if ucsi_reset_ppm() is not called overall), UCSI
    works as expected.
    
    Moreover, if the ucsi_acpi module is loaded/unloaded manually after the
    system has booted, reading the CCI values and resetting the PPM works
    perfectly, without any timeout. Thus it's only a boot-time issue.
    
    The reason for this behavior is not clear but it may be the consequence
    of some tricks that the firmware performs or be an actual firmware bug.
    As a workaround, increase the timeout to avoid failing the UCSI
    initialization prematurely.
    
    Fixes: b1b59e16075f ("usb: typec: ucsi: Increase command completion timeout value")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Fedor Pchelkin <boddah8794@gmail.com>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Link: https://lore.kernel.org/r/20250217105442.113486-3-boddah8794@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: xhci: Enable the TRB overfetch quirk on VIA VL805 [+ + +]
Author: Michal Pecio <michal.pecio@gmail.com>
Date:   Tue Feb 25 11:59:27 2025 +0200

    usb: xhci: Enable the TRB overfetch quirk on VIA VL805
    
    commit c133ec0e5717868c9967fa3df92a55e537b1aead upstream.
    
    Raspberry Pi is a major user of those chips and they discovered a bug -
    when the end of a transfer ring segment is reached, up to four TRBs can
    be prefetched from the next page even if the segment ends with link TRB
    and on page boundary (the chip claims to support standard 4KB pages).
    
    It also appears that if the prefetched TRBs belong to a different ring
    whose doorbell is later rung, they may be used without refreshing from
    system RAM and the endpoint will stay idle if their cycle bit is stale.
    
    Other users complain about IOMMU faults on x86 systems, unsurprisingly.
    
    Deal with it by using existing quirk which allocates a dummy page after
    each transfer ring segment. This was seen to resolve both problems. RPi
    came up with a more efficient solution, shortening each segment by four
    TRBs, but it complicated the driver and they ditched it for this quirk.
    
    Also rename the quirk and add VL805 device ID macro.
    
    Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
    Link: https://github.com/raspberrypi/linux/issues/4685
    Closes: https://bugzilla.kernel.org/show_bug.cgi?id=215906
    CC: stable@vger.kernel.org
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Link: https://lore.kernel.org/r/20250225095927.2512358-2-mathias.nyman@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
userfaultfd: do not block on locking a large folio with raised refcount [+ + +]
Author: Suren Baghdasaryan <surenb@google.com>
Date:   Wed Feb 26 10:55:08 2025 -0800

    userfaultfd: do not block on locking a large folio with raised refcount
    
    commit 37b338eed10581784e854d4262da05c8d960c748 upstream.
    
    Lokesh recently raised an issue about UFFDIO_MOVE getting into a deadlock
    state when it goes into split_folio() with raised folio refcount.
    split_folio() expects the reference count to be exactly mapcount +
    num_pages_in_folio + 1 (see can_split_folio()) and fails with EAGAIN
    otherwise.
    
    If multiple processes are trying to move the same large folio, they raise
    the refcount (all tasks succeed in that) then one of them succeeds in
    locking the folio, while others will block in folio_lock() while keeping
    the refcount raised.  The winner of this race will proceed with calling
    split_folio() and will fail returning EAGAIN to the caller and unlocking
    the folio.  The next competing process will get the folio locked and will
    go through the same flow.  In the meantime the original winner will be
    retried and will block in folio_lock(), getting into the queue of waiting
    processes only to repeat the same path.  All this results in a livelock.
    
    An easy fix would be to avoid waiting for the folio lock while holding
    folio refcount, similar to madvise_free_huge_pmd() where folio lock is
    acquired before raising the folio refcount.  Since we lock and take a
    refcount of the folio while holding the PTE lock, changing the order of
    these operations should not break anything.
    
    Modify move_pages_pte() to try locking the folio first and if that fails
    and the folio is large then return EAGAIN without touching the folio
    refcount.  If the folio is single-page then split_folio() is not called,
    so we don't have this issue.  Lokesh has a reproducer [1] and I verified
    that this change fixes the issue.
    
    [1] https://github.com/lokeshgidra/uffd_move_ioctl_deadlock
    
    [akpm@linux-foundation.org: reflow comment to 80 cols, s/end/end up/]
    Link: https://lkml.kernel.org/r/20250226185510.2732648-2-surenb@google.com
    Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
    Signed-off-by: Suren Baghdasaryan <surenb@google.com>
    Reported-by: Lokesh Gidra <lokeshgidra@google.com>
    Reviewed-by: Peter Xu <peterx@redhat.com>
    Acked-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Barry Song <21cnbao@gmail.com>
    Cc: Barry Song <v-songbaohua@oppo.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Jann Horn <jannh@google.com>
    Cc: Kalesh Singh <kaleshsingh@google.com>
    Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
    Cc: Matthew Wilcow (Oracle) <willy@infradead.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
vlan: enforce underlying device type [+ + +]
Author: Oscar Maes <oscmaes92@gmail.com>
Date:   Mon Mar 3 16:56:19 2025 +0100

    vlan: enforce underlying device type
    
    [ Upstream commit b33a534610067ade2bdaf2052900aaad99701353 ]
    
    Currently, VLAN devices can be created on top of non-ethernet devices.
    
    Besides the fact that it doesn't make much sense, this also causes a
    bug which leaks the address of a kernel function to usermode.
    
    When creating a VLAN device, we initialize GARP (garp_init_applicant)
    and MRP (mrp_init_applicant) for the underlying device.
    
    As part of the initialization process, we add the multicast address of
    each applicant to the underlying device, by calling dev_mc_add.
    
    __dev_mc_add uses dev->addr_len to determine the length of the new
    multicast address.
    
    This causes an out-of-bounds read if dev->addr_len is greater than 6,
    since the multicast addresses provided by GARP and MRP are only 6
    bytes long.
    
    This behaviour can be reproduced using the following commands:
    
    ip tunnel add gretest mode ip6gre local ::1 remote ::2 dev lo
    ip l set up dev gretest
    ip link add link gretest name vlantest type vlan id 100
    
    Then, the following command will display the address of garp_pdu_rcv:
    
    ip maddr show | grep 01:80:c2:00:00:21
    
    Fix the bug by enforcing the type of the underlying device during VLAN
    device initialization.
    
    Fixes: 22bedad3ce11 ("net: convert multicast list to list_head")
    Reported-by: syzbot+91161fe81857b396c8a0@syzkaller.appspotmail.com
    Closes: https://lore.kernel.org/netdev/000000000000ca9a81061a01ec20@google.com/
    Signed-off-by: Oscar Maes <oscmaes92@gmail.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Link: https://patch.msgid.link/20250303155619.8918-1-oscmaes92@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
wifi: cfg80211: regulatory: improve invalid hints checking [+ + +]
Author: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Date:   Fri Feb 28 16:46:57 2025 +0300

    wifi: cfg80211: regulatory: improve invalid hints checking
    
    commit 59b348be7597c4a9903cb003c69e37df20c04a30 upstream.
    
    Syzbot keeps reporting an issue [1] that occurs when erroneous symbols
    sent from userspace get through into user_alpha2[] via
    regulatory_hint_user() call. Such invalid regulatory hints should be
    rejected.
    
    While a sanity check from commit 47caf685a685 ("cfg80211: regulatory:
    reject invalid hints") looks to be enough to deter these very cases,
    there is a way to get around it due to 2 reasons.
    
    1) The way isalpha() works, symbols other than latin lower and
    upper letters may be used to determine a country/domain.
    For instance, greek letters will also be considered upper/lower
    letters and for such characters isalpha() will return true as well.
    However, ISO-3166-1 alpha2 codes should only hold latin
    characters.
    
    2) While processing a user regulatory request, between
    reg_process_hint_user() and regulatory_hint_user() there happens to
    be a call to queue_regulatory_request() which modifies letters in
    request->alpha2[] with toupper(). This works fine for latin symbols,
    less so for weird letter characters from the second part of _ctype[].
    
    Syzbot triggers a warning in is_user_regdom_saved() by first sending
    over an unexpected non-latin letter that gets malformed by toupper()
    into a character that ends up failing isalpha() check.
    
    Prevent this by enhancing is_an_alpha2() to ensure that incoming
    symbols are latin letters and nothing else.
    
    [1] Syzbot report:
    ------------[ cut here ]------------
    Unexpected user alpha2: A�
    WARNING: CPU: 1 PID: 964 at net/wireless/reg.c:442 is_user_regdom_saved net/wireless/reg.c:440 [inline]
    WARNING: CPU: 1 PID: 964 at net/wireless/reg.c:442 restore_alpha2 net/wireless/reg.c:3424 [inline]
    WARNING: CPU: 1 PID: 964 at net/wireless/reg.c:442 restore_regulatory_settings+0x3c0/0x1e50 net/wireless/reg.c:3516
    Modules linked in:
    CPU: 1 UID: 0 PID: 964 Comm: kworker/1:2 Not tainted 6.12.0-rc5-syzkaller-00044-gc1e939a21eb1 #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
    Workqueue: events_power_efficient crda_timeout_work
    RIP: 0010:is_user_regdom_saved net/wireless/reg.c:440 [inline]
    RIP: 0010:restore_alpha2 net/wireless/reg.c:3424 [inline]
    RIP: 0010:restore_regulatory_settings+0x3c0/0x1e50 net/wireless/reg.c:3516
    ...
    Call Trace:
     <TASK>
     crda_timeout_work+0x27/0x50 net/wireless/reg.c:542
     process_one_work kernel/workqueue.c:3229 [inline]
     process_scheduled_works+0xa65/0x1850 kernel/workqueue.c:3310
     worker_thread+0x870/0xd30 kernel/workqueue.c:3391
     kthread+0x2f2/0x390 kernel/kthread.c:389
     ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
     ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
     </TASK>
    
    Reported-by: syzbot+e10709ac3c44f3d4e800@syzkaller.appspotmail.com
    Closes: https://syzkaller.appspot.com/bug?extid=e10709ac3c44f3d4e800
    Fixes: 09d989d179d0 ("cfg80211: add regulatory hint disconnect support")
    Cc: stable@kernel.org
    Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
    Link: https://patch.msgid.link/20250228134659.1577656-1-n.zhandarovich@fintech.ru
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

wifi: iwlwifi: Fix A-MSDU TSO preparation [+ + +]
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Sun Feb 9 14:34:53 2025 +0200

    wifi: iwlwifi: Fix A-MSDU TSO preparation
    
    [ Upstream commit 3640dbc1f75ce15d128ea4af44226960d894f3fd ]
    
    The TSO preparation assumed that the skb head contained the headers
    while the rest of the data was in the fragments. Since this is not
    always true, e.g., it is possible that the data was linearised, modify
    the TSO preparation to start the data processing after the network
    headers.
    
    Fixes: 7f5e3038f029 ("wifi: iwlwifi: map entire SKB when sending AMSDUs")
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Reviewed-by: Benjamin Berg <benjamin.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250209143303.75769a4769bf.Iaf79e8538093cdf8c446c292cc96164ad6498f61@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: iwlwifi: Free pages allocated when failing to build A-MSDU [+ + +]
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Sun Feb 9 14:34:52 2025 +0200

    wifi: iwlwifi: Free pages allocated when failing to build A-MSDU
    
    [ Upstream commit 3b08e608d50c44ca1135beed179f266aa0461da7 ]
    
    When failing to prepare the data needed for A-MSDU transmission, the memory
    allocated for the TSO management was not freed. Fix it.
    
    Fixes: 7f5e3038f029 ("wifi: iwlwifi: map entire SKB when sending AMSDUs")
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250209143303.bc27fad9b3d5.Ibf43dd18fb652b1a59061204e081f11c9fa34a3f@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: iwlwifi: limit printed string from FW file [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Sun Feb 9 14:34:51 2025 +0200

    wifi: iwlwifi: limit printed string from FW file
    
    [ Upstream commit e0dc2c1bef722cbf16ae557690861e5f91208129 ]
    
    There's no guarantee here that the file is always with a
    NUL-termination, so reading the string may read beyond the
    end of the TLV. If that's the last TLV in the file, it can
    perhaps even read beyond the end of the file buffer.
    
    Fix that by limiting the print format to the size of the
    buffer we have.
    
    Fixes: aee1b6385e29 ("iwlwifi: support fseq tlv and print fseq version")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250209143303.cb5f9d0c2f5d.Idec695d53c6c2234aade306f7647b576c7e3d928@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: iwlwifi: mvm: clean up ROC on failure [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Sun Feb 9 14:34:47 2025 +0200

    wifi: iwlwifi: mvm: clean up ROC on failure
    
    [ Upstream commit f9751163bffd3fe60794929829f810968c6de73d ]
    
    If the firmware fails to start the session protection, then we
    do call iwl_mvm_roc_finished() here, but that won't do anything
    at all because IWL_MVM_STATUS_ROC_P2P_RUNNING was never set.
    Set IWL_MVM_STATUS_ROC_P2P_RUNNING in the failure/stop path.
    If it started successfully before, it's already set, so that
    doesn't matter, and if it didn't start it needs to be set to
    clean up.
    
    Not doing so will lead to a WARN_ON() later on a fresh remain-
    on-channel, since the link is already active when activated as
    it was never deactivated.
    
    Fixes: 35c1bbd93c4e ("wifi: iwlwifi: mvm: remove IWL_MVM_STATUS_NEED_FLUSH_P2P")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250209143303.0fe36c291068.I67f5dac742170dd937f11e4d4f937f45f71b7cb4@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: iwlwifi: mvm: don't try to talk to a dead firmware [+ + +]
Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Date:   Sun Feb 9 14:34:49 2025 +0200

    wifi: iwlwifi: mvm: don't try to talk to a dead firmware
    
    [ Upstream commit d73d2c6e3313f0ba60711ab4f4b9044eddca9ca5 ]
    
    This fixes:
    
     bad state = 0
     WARNING: CPU: 10 PID: 702 at drivers/net/wireless/inel/iwlwifi/iwl-trans.c:178 iwl_trans_send_cmd+0xba/0xe0 [iwlwifi]
     Call Trace:
      <TASK>
      ? __warn+0xca/0x1c0
      ? iwl_trans_send_cmd+0xba/0xe0 [iwlwifi 64fa9ad799a0e0d2ba53d4af93a53ad9a531f8d4]
      iwl_fw_dbg_clear_monitor_buf+0xd7/0x110 [iwlwifi 64fa9ad799a0e0d2ba53d4af93a53ad9a531f8d4]
      _iwl_dbgfs_fw_dbg_clear_write+0xe2/0x120 [iwlmvm 0e8adb18cea92d2c341766bcc10b18699290068a]
    
    Ask whether the firmware is alive before sending a command.
    
    Fixes: 268712dc3b34 ("wifi: iwlwifi: mvm: add a debugfs hook to clear the monitor data")
    Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250209143303.8e1597b62c70.I12ea71dd9b805b095c9fc12a10c9f34a4e801b61@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: iwlwifi: pcie: Fix TSO preparation [+ + +]
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Thu Mar 6 12:25:46 2025 +0200

    wifi: iwlwifi: pcie: Fix TSO preparation
    
    commit bbb18f7e23a3f5f56d5c8b4ee0f78f00edb3b1b2 upstream.
    
    The allocation of the scatter gather data structure should be done
    based on the number of memory chunks that need to be mapped, and it
    is not dependent on the overall payload length. Fix it.
    
    In addition, as the skb_to_sgvec() function returns an 'int' do not
    assign it to an 'unsigned int' as otherwise the error check would be
    useless.
    
    Fixes: 7f5e3038f029 ("wifi: iwlwifi: map entire SKB when sending AMSDUs")
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250306122425.8c0e23a3d583.I3cb4d6768c9d28ce3da6cd0a6c65466176cfc1ee@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

wifi: mac80211: fix MLE non-inheritance parsing [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Feb 21 11:24:50 2025 +0100

    wifi: mac80211: fix MLE non-inheritance parsing
    
    [ Upstream commit 99ca2c28e6b68084a0fb65585df09b9e28c3ec16 ]
    
    The code is erroneously applying the non-inheritance element
    to the inner elements rather than the outer, which is clearly
    completely wrong. Fix it by finding the MLE basic element at
    the beginning, and then applying the non-inheritance for the
    outer parsing.
    
    While at it, do some general cleanups such as not allowing
    callers to try looking for a specific non-transmitted BSS
    and link at the same time.
    
    Fixes: 45ebac4f059b ("wifi: mac80211: Parse station profile from association response")
    Reviewed-by: Ilan Peer <ilan.peer@intel.com>
    Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250221112451.b46d42f45b66.If5b95dc3c80208e0c62d8895fb6152aa54b6620b@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: mac80211: fix vendor-specific inheritance [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Feb 21 11:24:51 2025 +0100

    wifi: mac80211: fix vendor-specific inheritance
    
    [ Upstream commit 130067e9c13bdc4820748ef16076a6972364745f ]
    
    If there's any vendor-specific element in the subelements
    then the outer element parsing must not parse any vendor
    element at all. This isn't implemented correctly now due
    to parsing into the pointers and then overriding them, so
    explicitly skip vendor elements if any exist in the sub-
    elements (non-transmitted profile or per-STA profile).
    
    Fixes: 671042a4fb77 ("mac80211: support non-inheritance element")
    Reviewed-by: Ilan Peer <ilan.peer@intel.com>
    Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250221112451.fd71e5268840.I9db3e6a3367e6ff38d052d07dc07005f0dd3bd5c@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: mac80211: Support parsing EPCS ML element [+ + +]
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Thu Jan 2 16:20:01 2025 +0200

    wifi: mac80211: Support parsing EPCS ML element
    
    [ Upstream commit 24711d60f8492a30622e419cee643d59264ea939 ]
    
    Add support for parsing an ML element of type EPCS priority
    access, which can optionally be included in EHT protected action
    frames used to configure EPCS.
    
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Reviewed-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20250102161730.5afdf65cff46.I0ffa30b40fbad47bc5b608b5fd46047a8c44e904@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Stable-dep-of: 99ca2c28e6b6 ("wifi: mac80211: fix MLE non-inheritance parsing")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: nl80211: reject cooked mode if it is set along with other flags [+ + +]
Author: Vitaliy Shevtsov <v.shevtsov@mt-integration.ru>
Date:   Fri Jan 31 20:26:55 2025 +0500

    wifi: nl80211: reject cooked mode if it is set along with other flags
    
    commit 49f27f29446a5bfe633dd2cc0cfebd48a1a5e77f upstream.
    
    It is possible to set both MONITOR_FLAG_COOK_FRAMES and MONITOR_FLAG_ACTIVE
    flags simultaneously on the same monitor interface from the userspace. This
    causes a sub-interface to be created with no IEEE80211_SDATA_IN_DRIVER bit
    set because the monitor interface is in the cooked state and it takes
    precedence over all other states. When the interface is then being deleted
    the kernel calls WARN_ONCE() from check_sdata_in_driver() because of missing
    that bit.
    
    Fix this by rejecting MONITOR_FLAG_COOK_FRAMES if it is set along with
    other flags.
    
    Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
    
    Fixes: 66f7ac50ed7c ("nl80211: Add monitor interface configuration flags")
    Cc: stable@vger.kernel.org
    Reported-by: syzbot+2e5c1e55b9e5c28a3da7@syzkaller.appspotmail.com
    Closes: https://syzkaller.appspot.com/bug?extid=2e5c1e55b9e5c28a3da7
    Signed-off-by: Vitaliy Shevtsov <v.shevtsov@mt-integration.ru>
    Link: https://patch.msgid.link/20250131152657.5606-1-v.shevtsov@mt-integration.ru
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
x86/amd_nb: Use rdmsr_safe() in amd_get_mmconfig_range() [+ + +]
Author: Andrew Cooper <andrew.cooper3@citrix.com>
Date:   Fri Mar 7 00:28:46 2025 +0000

    x86/amd_nb: Use rdmsr_safe() in amd_get_mmconfig_range()
    
    commit 14cb5d83068ecf15d2da6f7d0e9ea9edbcbc0457 upstream.
    
    Xen doesn't offer MSR_FAM10H_MMIO_CONF_BASE to all guests.  This results
    in the following warning:
    
      unchecked MSR access error: RDMSR from 0xc0010058 at rIP: 0xffffffff8101d19f (xen_do_read_msr+0x7f/0xa0)
      Call Trace:
       xen_read_msr+0x1e/0x30
       amd_get_mmconfig_range+0x2b/0x80
       quirk_amd_mmconfig_area+0x28/0x100
       pnp_fixup_device+0x39/0x50
       __pnp_add_device+0xf/0x150
       pnp_add_device+0x3d/0x100
       pnpacpi_add_device_handler+0x1f9/0x280
       acpi_ns_get_device_callback+0x104/0x1c0
       acpi_ns_walk_namespace+0x1d0/0x260
       acpi_get_devices+0x8a/0xb0
       pnpacpi_init+0x50/0x80
       do_one_initcall+0x46/0x2e0
       kernel_init_freeable+0x1da/0x2f0
       kernel_init+0x16/0x1b0
       ret_from_fork+0x30/0x50
       ret_from_fork_asm+0x1b/0x30
    
    based on quirks for a "PNP0c01" device.  Treating MMCFG as disabled is the
    right course of action, so no change is needed there.
    
    This was most likely exposed by fixing the Xen MSR accessors to not be
    silently-safe.
    
    Fixes: 3fac3734c43a ("xen/pv: support selecting safe/unsafe msr accesses")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/r/20250307002846.3026685-1-andrew.cooper3@citrix.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 
x86/boot: Sanitize boot params before parsing command line [+ + +]
Author: Ard Biesheuvel <ardb@kernel.org>
Date:   Thu Mar 6 16:59:16 2025 +0100

    x86/boot: Sanitize boot params before parsing command line
    
    commit c00b413a96261faef4ce22329153c6abd4acef25 upstream.
    
    The 5-level paging code parses the command line to look for the 'no5lvl'
    string, and does so very early, before sanitize_boot_params() has been
    called and has been given the opportunity to wipe bogus data from the
    fields in boot_params that are not covered by struct setup_header, and
    are therefore supposed to be initialized to zero by the bootloader.
    
    This triggers an early boot crash when using syslinux-efi to boot a
    recent kernel built with CONFIG_X86_5LEVEL=y and CONFIG_EFI_STUB=n, as
    the 0xff padding that now fills the unused PE/COFF header is copied into
    boot_params by the bootloader, and interpreted as the top half of the
    command line pointer.
    
    Fix this by sanitizing the boot_params before use. Note that there is no
    harm in calling this more than once; subsequent invocations are able to
    spot that the boot_params have already been cleaned up.
    
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: <stable@vger.kernel.org> # v6.1+
    Link: https://lore.kernel.org/r/20250306155915.342465-2-ardb+git@google.com
    Closes: https://lore.kernel.org/all/202503041549.35913.ulrich.gemkow@ikr.uni-stuttgart.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
x86/cacheinfo: Validate CPUID leaf 0x2 EDX output [+ + +]
Author: Ahmed S. Darwish <darwi@linutronix.de>
Date:   Tue Mar 4 09:51:12 2025 +0100

    x86/cacheinfo: Validate CPUID leaf 0x2 EDX output
    
    commit 8177c6bedb7013cf736137da586cf783922309dd upstream.
    
    CPUID leaf 0x2 emits one-byte descriptors in its four output registers
    EAX, EBX, ECX, and EDX.  For these descriptors to be valid, the most
    significant bit (MSB) of each register must be clear.
    
    The historical Git commit:
    
      019361a20f016 ("- pre6: Intel: start to add Pentium IV specific stuff (128-byte cacheline etc)...")
    
    introduced leaf 0x2 output parsing.  It only validated the MSBs of EAX,
    EBX, and ECX, but left EDX unchecked.
    
    Validate EDX's most-significant bit.
    
    Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Cc: stable@vger.kernel.org
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Link: https://lore.kernel.org/r/20250304085152.51092-2-darwi@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
x86/cpu: Properly parse CPUID leaf 0x2 TLB descriptor 0x63 [+ + +]
Author: Ahmed S. Darwish <darwi@linutronix.de>
Date:   Tue Mar 4 09:51:14 2025 +0100

    x86/cpu: Properly parse CPUID leaf 0x2 TLB descriptor 0x63
    
    commit f6bdaab79ee4228a143ee1b4cb80416d6ffc0c63 upstream.
    
    CPUID leaf 0x2's one-byte TLB descriptors report the number of entries
    for specific TLB types, among other properties.
    
    Typically, each emitted descriptor implies the same number of entries
    for its respective TLB type(s).  An emitted 0x63 descriptor is an
    exception: it implies 4 data TLB entries for 1GB pages and 32 data TLB
    entries for 2MB or 4MB pages.
    
    For the TLB descriptors parsing code, the entry count for 1GB pages is
    encoded at the intel_tlb_table[] mapping, but the 2MB/4MB entry count is
    totally ignored.
    
    Update leaf 0x2's parsing logic 0x2 to account for 32 data TLB entries
    for 2MB/4MB pages implied by the 0x63 descriptor.
    
    Fixes: e0ba94f14f74 ("x86/tlb_info: get last level TLB entry number of CPU")
    Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Cc: stable@kernel.org
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Link: https://lore.kernel.org/r/20250304085152.51092-4-darwi@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

x86/cpu: Validate CPUID leaf 0x2 EDX output [+ + +]
Author: Ahmed S. Darwish <darwi@linutronix.de>
Date:   Tue Mar 4 09:51:13 2025 +0100

    x86/cpu: Validate CPUID leaf 0x2 EDX output
    
    commit 1881148215c67151b146450fb89ec22fd92337a7 upstream.
    
    CPUID leaf 0x2 emits one-byte descriptors in its four output registers
    EAX, EBX, ECX, and EDX.  For these descriptors to be valid, the most
    significant bit (MSB) of each register must be clear.
    
    Leaf 0x2 parsing at intel.c only validated the MSBs of EAX, EBX, and
    ECX, but left EDX unchecked.
    
    Validate EDX's most-significant bit as well.
    
    Fixes: e0ba94f14f74 ("x86/tlb_info: get last level TLB entry number of CPU")
    Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Cc: stable@kernel.org
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Link: https://lore.kernel.org/r/20250304085152.51092-3-darwi@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
x86/microcode/AMD: Add some forgotten models to the SHA check [+ + +]
Author: Borislav Petkov (AMD) <bp@alien8.de>
Date:   Fri Mar 7 23:02:56 2025 +0100

    x86/microcode/AMD: Add some forgotten models to the SHA check
    
    commit 058a6bec37c6c3b826158f6d26b75de43816a880 upstream.
    
    Add some more forgotten models to the SHA check.
    
    Fixes: 50cef76d5cb0 ("x86/microcode/AMD: Load only SHA256-checksummed patches")
    Reported-by: Toralf Förster <toralf.foerster@gmx.de>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Tested-by: Toralf Förster <toralf.foerster@gmx.de>
    Link: https://lore.kernel.org/r/20250307220256.11816-1-bp@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
x86/mm: Don't disable PCID when INVLPG has been fixed by microcode [+ + +]
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Wed May 22 10:06:24 2024 +0800

    x86/mm: Don't disable PCID when INVLPG has been fixed by microcode
    
    commit f24f669d03f884a6ef95cca84317d0f329e93961 upstream.
    
    Per the "Processor Specification Update" documentations referred by
    the intel-microcode-20240312 release note, this microcode release has
    fixed the issue for all affected models.
    
    So don't disable PCID if the microcode is new enough.  The precise
    minimum microcode revision fixing the issue was provided by Pawan
    Intel.
    
    [ dhansen: comment and changelog tweaks ]
    
    Signed-off-by: Xi Ruoyao <xry111@xry111.site>
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Acked-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
    Link: https://lore.kernel.org/all/168436059559.404.13934972543631851306.tip-bot2@tip-bot2/
    Link: https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/releases/tag/microcode-20240312
    Link: https://cdrdv2.intel.com/v1/dl/getContent/740518 # RPL042, rev. 13
    Link: https://cdrdv2.intel.com/v1/dl/getContent/682436 # ADL063, rev. 24
    Link: https://lore.kernel.org/all/20240325231300.qrltbzf6twm43ftb@desk/
    Link: https://lore.kernel.org/all/20240522020625.69418-1-xry111%40xry111.site
    Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
x86/sgx: Fix size overflows in sgx_encl_create() [+ + +]
Author: Jarkko Sakkinen <jarkko@kernel.org>
Date:   Wed Mar 5 07:00:05 2025 +0200

    x86/sgx: Fix size overflows in sgx_encl_create()
    
    [ Upstream commit 0d3e0dfd68fb9e6b0ec865be9f3377cc3ff55733 ]
    
    The total size calculated for EPC can overflow u64 given the added up page
    for SECS.  Further, the total size calculated for shmem can overflow even
    when the EPC size stays within limits of u64, given that it adds the extra
    space for 128 byte PCMD structures (one for each page).
    
    Address this by pre-evaluating the micro-architectural requirement of
    SGX: the address space size must be power of two. This is eventually
    checked up by ECREATE but the pre-check has the additional benefit of
    making sure that there is some space for additional data.
    
    Fixes: 888d24911787 ("x86/sgx: Add SGX_IOC_ENCLAVE_CREATE")
    Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
    Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Dave Hansen <dave.hansen@intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Link: https://lore.kernel.org/r/20250305050006.43896-1-jarkko@kernel.org
    
    Closes: https://lore.kernel.org/linux-sgx/c87e01a0-e7dd-4749-a348-0980d3444f04@stanley.mountain/
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
xhci: pci: Fix indentation in the PCI device ID definitions [+ + +]
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Wed Nov 6 12:14:48 2024 +0200

    xhci: pci: Fix indentation in the PCI device ID definitions
    
    commit 0309ed83791c079f239c13e0c605210425cd1a61 upstream.
    
    Some of the definitions are missing the one TAB, add it to them.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20241106101459.775897-23-mathias.nyman@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

xhci: Restrict USB4 tunnel detection for USB3 devices to Intel hosts [+ + +]
Author: Marc Zyngier <maz@kernel.org>
Date:   Thu Feb 27 19:45:29 2025 +0000

    xhci: Restrict USB4 tunnel detection for USB3 devices to Intel hosts
    
    commit 487cfd4a8e3dc42d34a759017978a4edaf85fce0 upstream.
    
    When adding support for USB3-over-USB4 tunnelling detection, a check
    for an Intel-specific capability was added. This capability, which
    goes by ID 206, is used without any check that we are actually
    dealing with an Intel host.
    
    As it turns out, the Cadence XHCI controller *also* exposes an
    extended capability numbered 206 (for unknown purposes), but of
    course doesn't have the Intel-specific registers that the tunnelling
    code is trying to access. Fun follows.
    
    The core of the problems is that the tunnelling code blindly uses
    vendor-specific capabilities without any check (the Intel-provided
    documentation I have at hand indicates that 192-255 are indeed
    vendor-specific).
    
    Restrict the detection code to Intel HW for real, preventing any
    further explosion on my (non-Intel) HW.
    
    Cc: stable <stable@kernel.org>
    Fixes: 948ce83fbb7df ("xhci: Add USB4 tunnel detection for USB3 devices on Intel hosts")
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Link: https://lore.kernel.org/r/20250227194529.2288718-1-maz@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>