Skip to content
  1. Aug 30, 2023
    • Trond Myklebust's avatar
      NFS: Fix a use after free in nfs_direct_join_group() · a3a91119
      Trond Myklebust authored
      commit be2fd156
      
       upstream.
      
      Be more careful when tearing down the subrequests of an O_DIRECT write
      as part of a retransmission.
      
      Reported-by: default avatarChris Mason <clm@fb.com>
      Fixes: ed5d588f
      
       ("NFS: Try to join page groups before an O_DIRECT retransmission")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a3a91119
    • Ryusuke Konishi's avatar
      nilfs2: fix general protection fault in nilfs_lookup_dirty_data_buffers() · c8df36ee
      Ryusuke Konishi authored
      commit f83913f8
      
       upstream.
      
      A syzbot stress test reported that create_empty_buffers() called from
      nilfs_lookup_dirty_data_buffers() can cause a general protection fault.
      
      Analysis using its reproducer revealed that the back reference "mapping"
      from a page/folio has been changed to NULL after dirty page/folio gang
      lookup in nilfs_lookup_dirty_data_buffers().
      
      Fix this issue by excluding pages/folios from being collected if, after
      acquiring a lock on each page/folio, its back reference "mapping" differs
      from the pointer to the address space struct that held the page/folio.
      
      Link: https://lkml.kernel.org/r/20230805132038.6435-1-konishi.ryusuke@gmail.com
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: default avatar <syzbot+0ad741797f4565e7e2d2@syzkaller.appspotmail.com>
      Closes: https://lkml.kernel.org/r/0000000000002930a705fc32b231@google.com
      Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c8df36ee
    • T.J. Mercier's avatar
      mm: multi-gen LRU: don't spin during memcg release · bca3e63b
      T.J. Mercier authored
      commit 6867c7a3 upstream.
      
      When a memcg is in the process of being released mem_cgroup_tryget will
      fail because its reference count has already reached 0.  This can happen
      during reclaim if the memcg has already been offlined, and we reclaim all
      remaining pages attributed to the offlined memcg.  shrink_many attempts to
      skip the empty memcg in this case, and continue reclaiming from the
      remaining memcgs in the old generation.  If there is only one memcg
      remaining, or if all remaining memcgs are in the process of being released
      then shrink_many will spin until all memcgs have finished being released.
      The release occurs through a workqueue, so it can take a while before
      kswapd is able to make any further progress.
      
      This fix results in reductions in kswapd activity and direct reclaim in
      a test where 28 apps (working set size > total memory) are repeatedly
      launched in a random sequence:
      
                                             A          B      delta   ratio(%)
                 allocstall_movable       5962       3539      -2423     -40.64
                  allocstall_normal       2661       2417       -244      -9.17
      kswapd_high_wmark_hit_quickly      53152       7594     -45558     -85.71
                         pageoutrun      57365      11750     -45615     -79.52
      
      Link: https://lkml.kernel.org/r/20230814151636.1639123-1-tjmercier@google.com
      Fixes: e4dde56c
      
       ("mm: multi-gen LRU: per-node lru_gen_folio lists")
      Signed-off-by: default avatarT.J. Mercier <tjmercier@google.com>
      Acked-by: default avatarYu Zhao <yuzhao@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bca3e63b
    • Miaohe Lin's avatar
      mm: memory-failure: fix unexpected return value in soft_offline_page() · 56d11051
      Miaohe Lin authored
      commit e2c1ab07 upstream.
      
      When page_handle_poison() fails to handle the hugepage or free page in
      retry path, soft_offline_page() will return 0 while -EBUSY is expected in
      this case.
      
      Consequently the user will think soft_offline_page succeeds while it in
      fact failed.  So the user will not try again later in this case.
      
      Link: https://lkml.kernel.org/r/20230627112808.1275241-1-linmiaohe@huawei.com
      Fixes: b94e0282
      
       ("mm,hwpoison: try to narrow window race for free pages")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      56d11051
    • Alexandre Ghiti's avatar
      mm: add a call to flush_cache_vmap() in vmap_pfn() · 22178c6e
      Alexandre Ghiti authored
      commit a50420c7 upstream.
      
      flush_cache_vmap() must be called after new vmalloc mappings are installed
      in the page table in order to allow architectures to make sure the new
      mapping is visible.
      
      It could lead to a panic since on some architectures (like powerpc),
      the page table walker could see the wrong pte value and trigger a
      spurious page fault that can not be resolved (see commit f1cb8f9b
      ("powerpc/64s/radix: avoid ptesync after set_pte and
      ptep_set_access_flags")).
      
      But actually the patch is aiming at riscv: the riscv specification
      allows the caching of invalid entries in the TLB, and since we recently
      removed the vmalloc page fault handling, we now need to emit a tlb
      shootdown whenever a new vmalloc mapping is emitted
      (https://lore.kernel.org/linux-riscv/20230725132246.817726-1-alexghiti@rivosinc.com/).
      That's a temporary solution, there are ways to avoid that :)
      
      Link: https://lkml.kernel.org/r/20230809164633.1556126-1-alexghiti@rivosinc.com
      Fixes: 3e9a9e25
      
       ("mm: add a vmap_pfn function")
      Reported-by: default avatarDylan Jhong <dylan@andestech.com>
      Closes: https://lore.kernel.org/linux-riscv/ZMytNY2J8iyjbPPy@atctrx.andestech.com/
      Signed-off-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Acked-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Reviewed-by: default avatarDylan Jhong <dylan@andestech.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22178c6e
    • Dietmar Eggemann's avatar
      cgroup/cpuset: Free DL BW in case can_attach() fails · 0677bed4
      Dietmar Eggemann authored
      commit 2ef269ef
      
       upstream.
      
      cpuset_can_attach() can fail. Postpone DL BW allocation until all tasks
      have been checked. DL BW is not allocated per-task but as a sum over
      all DL tasks migrating.
      
      If multiple controllers are attached to the cgroup next to the cpuset
      controller a non-cpuset can_attach() can fail. In this case free DL BW
      in cpuset_cancel_attach().
      
      Finally, update cpuset DL task count (nr_deadline_tasks) only in
      cpuset_attach().
      
      Suggested-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
      Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
      Reviewed-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0677bed4
    • Dietmar Eggemann's avatar
      sched/deadline: Create DL BW alloc, free & check overflow interface · d1cfa53e
      Dietmar Eggemann authored
      commit 85989106
      
       upstream.
      
      While moving a set of tasks between exclusive cpusets,
      cpuset_can_attach() -> task_can_attach() calls dl_cpu_busy(..., p) for
      DL BW overflow checking and per-task DL BW allocation on the destination
      root_domain for the DL tasks in this set.
      
      This approach has the issue of not freeing already allocated DL BW in
      the following error cases:
      
      (1) The set of tasks includes multiple DL tasks and DL BW overflow
          checking fails for one of the subsequent DL tasks.
      
      (2) Another controller next to the cpuset controller which is attached
          to the same cgroup fails in its can_attach().
      
      To address this problem rework dl_cpu_busy():
      
      (1) Split it into dl_bw_check_overflow() & dl_bw_alloc() and add a
          dedicated dl_bw_free().
      
      (2) dl_bw_alloc() & dl_bw_free() take a `u64 dl_bw` parameter instead of
          a `struct task_struct *p` used in dl_cpu_busy(). This allows to
          allocate DL BW for a set of tasks too rather than only for a single
          task.
      
      Signed-off-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
      Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1cfa53e
    • Juri Lelli's avatar
      cgroup/cpuset: Iterate only if DEADLINE tasks are present · c95a7514
      Juri Lelli authored
      commit c0f78fd5
      
       upstream.
      
      update_tasks_root_domain currently iterates over all tasks even if no
      DEADLINE task is present on the cpuset/root domain for which bandwidth
      accounting is being rebuilt. This has been reported to introduce 10+ ms
      delays on suspend-resume operations.
      
      Skip the costly iteration for cpusets that don't contain DEADLINE tasks.
      
      Reported-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Link: https://lore.kernel.org/lkml/20230206221428.2125324-1-qyousef@layalina.io/
      Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
      Reviewed-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c95a7514
    • Juri Lelli's avatar
      sched/cpuset: Keep track of SCHED_DEADLINE task in cpusets · 74fac5bb
      Juri Lelli authored
      commit 6c24849f
      
       upstream.
      
      Qais reported that iterating over all tasks when rebuilding root domains
      for finding out which ones are DEADLINE and need their bandwidth
      correctly restored on such root domains can be a costly operation (10+
      ms delays on suspend-resume).
      
      To fix the problem keep track of the number of DEADLINE tasks belonging
      to each cpuset and then use this information (followup patch) to only
      perform the above iteration if DEADLINE tasks are actually present in
      the cpuset for which a corresponding root domain is being rebuilt.
      
      Reported-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Link: https://lore.kernel.org/lkml/20230206221428.2125324-1-qyousef@layalina.io/
      Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
      Reviewed-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      74fac5bb
    • Juri Lelli's avatar
      sched/cpuset: Bring back cpuset_mutex · 00f3719c
      Juri Lelli authored
      commit 111cd11b upstream.
      
      Turns out percpu_cpuset_rwsem - commit 1243dc51
      
       ("cgroup/cpuset:
      Convert cpuset_mutex to percpu_rwsem") - wasn't such a brilliant idea,
      as it has been reported to cause slowdowns in workloads that need to
      change cpuset configuration frequently and it is also not implementing
      priority inheritance (which causes troubles with realtime workloads).
      
      Convert percpu_cpuset_rwsem back to regular cpuset_mutex. Also grab it
      only for SCHED_DEADLINE tasks (other policies don't care about stable
      cpusets anyway).
      
      Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
      Reviewed-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00f3719c
    • Juri Lelli's avatar
      cgroup/cpuset: Rename functions dealing with DEADLINE accounting · 4d17b2ea
      Juri Lelli authored
      commit ad3a557d
      
       upstream.
      
      rebuild_root_domains() and update_tasks_root_domain() have neutral
      names, but actually deal with DEADLINE bandwidth accounting.
      
      Rename them to use 'dl_' prefix so that intent is more clear.
      
      No functional change.
      
      Suggested-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
      Reviewed-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d17b2ea
    • Jani Nikula's avatar
      drm/i915: fix display probe for IVB Q and IVB D GT2 server · aefabccb
      Jani Nikula authored
      commit 423ffe62 upstream.
      
      The current display probe is unable to differentiate between IVB Q and
      IVB D GT2 server, as they both have the same device id, but different
      subvendor and subdevice. This leads to the latter being misidentified as
      the former, and should just end up not having a display. However, the no
      display case returns a NULL as the display device info, and promptly
      oopses.
      
      As the IVB Q case is rare, and we're anyway moving towards GMD ID,
      handle the identification requiring subvendor and subdevice as a special
      case first, instead of unnecessarily growing the intel_display_ids[]
      array with subvendor and subdevice.
      
      [    5.425298] BUG: kernel NULL pointer dereference, address: 0000000000000000
      [    5.426059] #PF: supervisor read access in kernel mode
      [    5.426810] #PF: error_code(0x0000) - not-present page
      [    5.427570] PGD 0 P4D 0
      [    5.428285] Oops: 0000 [#1] PREEMPT SMP PTI
      [    5.429035] CPU: 0 PID: 137 Comm: (udev-worker) Not tainted 6.4.0-1-amd64 #1  Debian 6.4.4-1
      [    5.429759] Hardware name: HP HP Z220 SFF Workstation/HP Z220 SFF Workstation, BIOS 4.19-218-gb184e6e0a1 02/02/2023
      [    5.430485] RIP: 0010:intel_device_info_driver_create+0xf1/0x120 [i915]
      [    5.431338] Code: 48 8b 97 80 1b 00 00 89 8f c0 1b 00 00 48 89 b7 b0 1b 00 00 48 89 97 b8 1b 00 00 0f b7 fd e8 76 e8 14 00 48 89 83 50 1b 00 00 <48> 8b 08 48 89 8b c4 1b 00 00 48 8b 48 08 48 89 8b cc 1b 00 00 8b
      [    5.432920] RSP: 0018:ffffb8254044fb98 EFLAGS: 00010206
      [    5.433707] RAX: 0000000000000000 RBX: ffff923076e80000 RCX: 0000000000000000
      [    5.434494] RDX: 0000000000000260 RSI: 0000000100001000 RDI: 000000000000016a
      [    5.435277] RBP: 000000000000016a R08: ffffb8254044fb00 R09: 0000000000000000
      [    5.436055] R10: ffff922d02761de8 R11: 00657361656c6572 R12: ffffffffc0e5d140
      [    5.436867] R13: ffff922d00b720d0 R14: 0000000076e80000 R15: ffff923078c0cae8
      [    5.437646] FS:  00007febd19a18c0(0000) GS:ffff92307c000000(0000) knlGS:0000000000000000
      [    5.438434] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    5.439218] CR2: 0000000000000000 CR3: 000000010256e002 CR4: 00000000001706f0
      [    5.440009] Call Trace:
      [    5.440824]  <TASK>
      [    5.441611]  ? __die+0x23/0x70
      [    5.442394]  ? page_fault_oops+0x17d/0x4c0
      [    5.443173]  ? exc_page_fault+0x7f/0x180
      [    5.443949]  ? asm_exc_page_fault+0x26/0x30
      [    5.444756]  ? intel_device_info_driver_create+0xf1/0x120 [i915]
      [    5.445652]  ? intel_device_info_driver_create+0xea/0x120 [i915]
      [    5.446545]  i915_driver_probe+0x7f/0xb60 [i915]
      [    5.447431]  ? drm_privacy_screen_get+0x15c/0x1a0 [drm]
      [    5.448240]  local_pci_probe+0x45/0xa0
      [    5.449013]  pci_device_probe+0xc7/0x240
      [    5.449748]  really_probe+0x19e/0x3e0
      [    5.450464]  ? __pfx___driver_attach+0x10/0x10
      [    5.451172]  __driver_probe_device+0x78/0x160
      [    5.451870]  driver_probe_device+0x1f/0x90
      [    5.452601]  __driver_attach+0xd2/0x1c0
      [    5.453293]  bus_for_each_dev+0x88/0xd0
      [    5.453989]  bus_add_driver+0x116/0x220
      [    5.454672]  driver_register+0x59/0x100
      [    5.455336]  i915_init+0x25/0xc0 [i915]
      [    5.456104]  ? __pfx_i915_init+0x10/0x10 [i915]
      [    5.456882]  do_one_initcall+0x5d/0x240
      [    5.457511]  do_init_module+0x60/0x250
      [    5.458126]  __do_sys_finit_module+0xac/0x120
      [    5.458721]  do_syscall_64+0x60/0xc0
      [    5.459314]  ? syscall_exit_to_user_mode+0x1b/0x40
      [    5.459897]  ? do_syscall_64+0x6c/0xc0
      [    5.460510]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
      [    5.461082] RIP: 0033:0x7febd20b0eb9
      [    5.461648] Code: 08 89 e8 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 2f 1f 0d 00 f7 d8 64 89 01 48
      [    5.462905] RSP: 002b:00007fffabb1ba78 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      [    5.463554] RAX: ffffffffffffffda RBX: 0000561e6304f410 RCX: 00007febd20b0eb9
      [    5.464201] RDX: 0000000000000000 RSI: 00007febd2244f0d RDI: 0000000000000015
      [    5.464869] RBP: 00007febd2244f0d R08: 0000000000000000 R09: 000000000000000a
      [    5.465512] R10: 0000000000000015 R11: 0000000000000246 R12: 0000000000020000
      [    5.466124] R13: 0000000000000000 R14: 0000561e63032b60 R15: 000000000000000a
      [    5.466700]  </TASK>
      [    5.467271] Modules linked in: i915(+) drm_buddy video crc32_pclmul sr_mod hid_generic wmi crc32c_intel i2c_algo_bit sd_mod cdrom drm_display_helper cec usbhid rc_core ghash_clmulni_intel hid sha512_ssse3 ttm sha512_generic xhci_pci ehci_pci xhci_hcd ehci_hcd nvme ahci drm_kms_helper nvme_core libahci t10_pi libata psmouse aesni_intel scsi_mod crypto_simd i2c_i801 scsi_common crc64_rocksoft_generic cryptd i2c_smbus drm lpc_ich crc64_rocksoft crc_t10dif e1000e usbcore crct10dif_generic usb_common crct10dif_pclmul crc64 crct10dif_common button
      [    5.469750] CR2: 0000000000000000
      [    5.470364] ---[ end trace 0000000000000000 ]---
      [    5.470971] RIP: 0010:intel_device_info_driver_create+0xf1/0x120 [i915]
      [    5.471699] Code: 48 8b 97 80 1b 00 00 89 8f c0 1b 00 00 48 89 b7 b0 1b 00 00 48 89 97 b8 1b 00 00 0f b7 fd e8 76 e8 14 00 48 89 83 50 1b 00 00 <48> 8b 08 48 89 8b c4 1b 00 00 48 8b 48 08 48 89 8b cc 1b 00 00 8b
      [    5.473034] RSP: 0018:ffffb8254044fb98 EFLAGS: 00010206
      [    5.473698] RAX: 0000000000000000 RBX: ffff923076e80000 RCX: 0000000000000000
      [    5.474371] RDX: 0000000000000260 RSI: 0000000100001000 RDI: 000000000000016a
      [    5.475045] RBP: 000000000000016a R08: ffffb8254044fb00 R09: 0000000000000000
      [    5.475725] R10: ffff922d02761de8 R11: 00657361656c6572 R12: ffffffffc0e5d140
      [    5.476405] R13: ffff922d00b720d0 R14: 0000000076e80000 R15: ffff923078c0cae8
      [    5.477124] FS:  00007febd19a18c0(0000) GS:ffff92307c000000(0000) knlGS:0000000000000000
      [    5.477811] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    5.478499] CR2: 0000000000000000 CR3: 000000010256e002 CR4: 00000000001706f0
      
      Fixes: 69d43981
      
       ("drm/i915/display: Make display responsible for probing its own IP")
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8991
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Cc: Andrzej Hajda <andrzej.hajda@intel.com>
      Reviewed-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230804084600.1005818-1-jani.nikula@intel.com
      (cherry picked from commit 14351883
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aefabccb
    • Matt Roper's avatar
      drm/i915/display: Handle GMD_ID identification in display code · 6621912f
      Matt Roper authored
      commit 12e6f6dc
      
       upstream.
      
      For platforms with GMD_ID support (i.e., everything MTL and beyond),
      identification of the display IP present should be based on the contents
      of the GMD_ID register rather than a PCI devid match.
      
      Note that since GMD_ID readout requires access to the PCI BAR, a slight
      change to the driver init sequence is needed --- pci_enable_device() is
      now called before i915_driver_create().
      
      v2:
       - Fix use of uninitialized i915 pointer in error path if
         pci_enable_device() fails before the i915 device is created.  (lkp)
       - Use drm_device parameter to intel_display_device_probe.  This goes
         against i915 conventions, but since the primary goal here is to make
         it easy to call this function from other drivers (like Xe) and since
         we don't need anything from the i915 structure, this seems like an
         exception where drm_device is a more natural fit.
      v3:
       - Go back do drm_i915_private for intel_display_device_probe.  (Jani)
       - Move forward decl to top of header.  (Jani)
      
      Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
      Reviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230523195609.73627-6-matthew.d.roper@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6621912f
    • Feng Tang's avatar
      x86/fpu: Set X86_FEATURE_OSXSAVE feature after enabling OSXSAVE in CR4 · 51777133
      Feng Tang authored
      commit 2c66ca39 upstream.
      
      0-Day found a 34.6% regression in stress-ng's 'af-alg' test case, and
      bisected it to commit b81fac90 ("x86/fpu: Move FPU initialization into
      arch_cpu_finalize_init()"), which optimizes the FPU init order, and moves
      the CR4_OSXSAVE enabling into a later place:
      
         arch_cpu_finalize_init
             identify_boot_cpu
      	   identify_cpu
      	       generic_identify
                         get_cpu_cap --> setup cpu capability
             ...
             fpu__init_cpu
                 fpu__init_cpu_xstate
                     cr4_set_bits(X86_CR4_OSXSAVE);
      
      As the FPU is not yet initialized the CPU capability setup fails to set
      X86_FEATURE_OSXSAVE. Many security module like 'camellia_aesni_avx_x86_64'
      depend on this feature and therefore fail to load, causing the regression.
      
      Cure this by setting X86_FEATURE_OSXSAVE feature right after OSXSAVE
      enabling.
      
      [ tglx: Moved it into the actual BSP FPU initialization code and added a comment ]
      
      Fixes: b81fac90
      
       ("x86/fpu: Move FPU initialization into arch_cpu_finalize_init()")
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/lkml/202307192135.203ac24e-oliver.sang@intel.com
      Link: https://lore.kernel.org/lkml/20230823065747.92257-1-feng.tang@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51777133
    • Rick Edgecombe's avatar
      x86/fpu: Invalidate FPU state correctly on exec() · 4b04c422
      Rick Edgecombe authored
      commit 1f69383b upstream.
      
      The thread flag TIF_NEED_FPU_LOAD indicates that the FPU saved state is
      valid and should be reloaded when returning to userspace. However, the
      kernel will skip doing this if the FPU registers are already valid as
      determined by fpregs_state_valid(). The logic embedded there considers
      the state valid if two cases are both true:
      
        1: fpu_fpregs_owner_ctx points to the current tasks FPU state
        2: the last CPU the registers were live in was the current CPU.
      
      This is usually correct logic. A CPU’s fpu_fpregs_owner_ctx is set to
      the current FPU during the fpregs_restore_userregs() operation, so it
      indicates that the registers have been restored on this CPU. But this
      alone doesn’t preclude that the task hasn’t been rescheduled to a
      different CPU, where the registers were modified, and then back to the
      current CPU. To verify that this was not the case the logic relies on the
      second condition. So the assumption is that if the registers have been
      restored, AND they haven’t had the chance to be modified (by being
      loaded on another CPU), then they MUST be valid on the current CPU.
      
      Besides the lazy FPU optimizations, the other cases where the FPU
      registers might not be valid are when the kernel modifies the FPU register
      state or the FPU saved buffer. In this case the operation modifying the
      FPU state needs to let the kernel know the correspondence has been
      broken. The comment in “arch/x86/kernel/fpu/context.h” has:
      /*
      ...
       * If the FPU register state is valid, the kernel can skip restoring the
       * FPU state from memory.
       *
       * Any code that clobbers the FPU registers or updates the in-memory
       * FPU state for a task MUST let the rest of the kernel know that the
       * FPU registers are no longer valid for this task.
       *
       * Either one of these invalidation functions is enough. Invalidate
       * a resource you control: CPU if using the CPU for something else
       * (with preemption disabled), FPU for the current task, or a task that
       * is prevented from running by the current task.
       */
      
      However, this is not completely true. When the kernel modifies the
      registers or saved FPU state, it can only rely on
      __fpu_invalidate_fpregs_state(), which wipes the FPU’s last_cpu
      tracking. The exec path instead relies on fpregs_deactivate(), which sets
      the CPU’s FPU context to NULL. This was observed to fail to restore the
      reset FPU state to the registers when returning to userspace in the
      following scenario:
      
      1. A task is executing in userspace on CPU0
      	- CPU0’s FPU context points to tasks
      	- fpu->last_cpu=CPU0
      
      2. The task exec()’s
      
      3. While in the kernel the task is preempted
      	- CPU0 gets a thread executing in the kernel (such that no other
      		FPU context is activated)
      	- Scheduler sets task’s fpu->last_cpu=CPU0 when scheduling out
      
      4. Task is migrated to CPU1
      
      5. Continuing the exec(), the task gets to
         fpu_flush_thread()->fpu_reset_fpregs()
      	- Sets CPU1’s fpu context to NULL
      	- Copies the init state to the task’s FPU buffer
      	- Sets TIF_NEED_FPU_LOAD on the task
      
      6. The task reschedules back to CPU0 before completing the exec() and
         returning to userspace
      	- During the reschedule, scheduler finds TIF_NEED_FPU_LOAD is set
      	- Skips saving the registers and updating task’s fpu→last_cpu,
      	  because TIF_NEED_FPU_LOAD is the canonical source.
      
      7. Now CPU0’s FPU context is still pointing to the task’s, and
         fpu->last_cpu is still CPU0. So fpregs_state_valid() returns true even
         though the reset FPU state has not been restored.
      
      So the root cause is that exec() is doing the wrong kind of invalidate. It
      should reset fpu->last_cpu via __fpu_invalidate_fpregs_state(). Further,
      fpu__drop() doesn't really seem appropriate as the task (and FPU) are not
      going away, they are just getting reset as part of an exec. So switch to
      __fpu_invalidate_fpregs_state().
      
      Also, delete the misleading comment that says that either kind of
      invalidate will be enough, because it’s not always the case.
      
      Fixes: 33344368
      
       ("x86/fpu: Clean up the fpu__clear() variants")
      Reported-by: default avatarLei Wang <lei4.wang@intel.com>
      Signed-off-by: default avatarRick Edgecombe <rick.p.edgecombe@intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarLijun Pan <lijun.pan@intel.com>
      Reviewed-by: default avatarSohil Mehta <sohil.mehta@intel.com>
      Acked-by: default avatarLijun Pan <lijun.pan@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20230818170305.502891-1-rick.p.edgecombe@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b04c422
    • Huacai Chen's avatar
      LoongArch: Fix hw_breakpoint_control() for watchpoints · 0c2a9b7b
      Huacai Chen authored
      commit 9730870b
      
       upstream.
      
      In hw_breakpoint_control(), encode_ctrl_reg() has already encoded the
      MWPnCFG3_LoadEn/MWPnCFG3_StoreEn bits in info->ctrl. We don't need to
      add (1 << MWPnCFG3_LoadEn | 1 << MWPnCFG3_StoreEn) unconditionally.
      
      Otherwise we can't set read watchpoint and write watchpoint separately.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c2a9b7b
    • Imre Deak's avatar
      drm/i915: Fix HPD polling, reenabling the output poll work as needed · 8771f80b
      Imre Deak authored
      commit 1dcc4374 upstream.
      
      After the commit in the Fixes: line below, HPD polling stopped working
      on i915, since after that change calling drm_kms_helper_poll_enable()
      doesn't restart drm_mode_config::output_poll_work if the work was
      stopped (no connectors needing polling) and enabling polling for a
      connector (during runtime suspend or detecting an HPD IRQ storm).
      
      After the above change calling drm_kms_helper_poll_enable() is a nop
      after it's been called already and polling for some connectors was
      disabled/re-enabled.
      
      Fix this by calling drm_kms_helper_poll_reschedule() added in the
      previous patch instead, which reschedules the work whenever expected.
      
      Fixes: d33a54e3
      
       ("drm/probe_helper: sort out poll_running vs poll_enabled")
      CC: stable@vger.kernel.org # 6.4+
      Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: default avatarJouni Högander <jouni.hogander@intel.com>
      Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230822113015.41224-2-imre.deak@intel.com
      (cherry picked from commit 50452f2f
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8771f80b
    • Ankit Nautiyal's avatar
      drm/display/dp: Fix the DP DSC Receiver cap size · 40b67b55
      Ankit Nautiyal authored
      commit 5ad1ab30 upstream.
      
      DP DSC Receiver Capabilities are exposed via DPCD 60h-6Fh.
      Fix the DSC RECEIVER CAP SIZE accordingly.
      
      Fixes: ffddc436
      
       ("drm/dp: Add DP DSC DPCD receiver capability size define and missing SHIFT")
      Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
      Cc: Manasi Navare <manasi.d.navare@intel.com>
      Cc: <stable@vger.kernel.org> # v5.0+
      
      Signed-off-by: default avatarAnkit Nautiyal <ankit.k.nautiyal@intel.com>
      Reviewed-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230818044436.177806-1-ankit.k.nautiyal@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      40b67b55
    • Anshuman Gupta's avatar
      drm/i915/dgfx: Enable d3cold at s2idle · 503d787d
      Anshuman Gupta authored
      commit 2872144a upstream.
      
      System wide suspend already has support for lmem save/restore during
      suspend therefore enabling d3cold for s2idle and keepng it disable for
      runtime PM.(Refer below commit for d3cold runtime PM disable justification)
      'commit 66eb93e7
      
       ("drm/i915/dgfx: Keep PCI autosuspend control
      'on' by default on all dGPU")'
      
      It will reduce the DG2 Card power consumption to ~0 Watt
      for s2idle power KPI.
      
      v2:
      - Added "Cc: stable@vger.kernel.org".
      
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8755
      Cc: stable@vger.kernel.org
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarAnshuman Gupta <anshuman.gupta@intel.com>
      Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Tested-by: default avatarAaron Ma <aaron.ma@canonical.com>
      Tested-by: default avatarJianshui Yu <Jianshui.yu@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230816125216.1722002-1-anshuman.gupta@intel.com
      (cherry picked from commit 2643e6d1
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      503d787d
    • David Michael's avatar
      drm/panfrost: Skip speed binning on EOPNOTSUPP · dd8683e0
      David Michael authored
      commit f19df6e4 upstream.
      
      Encountered on an ARM Mali-T760 MP4, attempting to read the nvmem
      variable can also return EOPNOTSUPP instead of ENOENT when speed
      binning is unsupported.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 7d690f93
      
       ("drm/panfrost: Add basic support for speed binning")
      Signed-off-by: default avatarDavid Michael <fedora.dm0@gmail.com>
      Reviewed-by: default avatarSteven Price <steven.price@arm.com>
      Signed-off-by: default avatarSteven Price <steven.price@arm.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/87msyryd7y.fsf@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd8683e0
    • Imre Deak's avatar
      drm: Add an HPD poll helper to reschedule the poll work · 933f1fc8
      Imre Deak authored
      commit a94e7ccf
      
       upstream.
      
      Add a helper to reschedule drm_mode_config::output_poll_work after
      polling has been enabled for a connector (and needing a reschedule,
      since previously polling was disabled for all connectors and hence
      output_poll_work was not running).
      
      This is needed by the next patch fixing HPD polling on i915.
      
      CC: stable@vger.kernel.org # 6.4+
      Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: default avatarJouni Högander <jouni.hogander@intel.com>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230822113015.41224-1-imre.deak@intel.com
      (cherry picked from commit fe2352fd
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      933f1fc8
    • Zack Rusin's avatar
      drm/vmwgfx: Fix possible invalid drm gem put calls · 6969e450
      Zack Rusin authored
      commit f9e96bf1
      
       upstream.
      
      vmw_bo_unreference sets the input buffer to null on exit, resulting in
      null ptr deref's on the subsequent drm gem put calls.
      
      This went unnoticed because only very old userspace would be exercising
      those paths but it wouldn't be hard to hit on old distros with brand
      new kernels.
      
      Introduce a new function that abstracts unrefing of user bo's to make
      the code cleaner and more explicit.
      
      Signed-off-by: default avatarZack Rusin <zackr@vmware.com>
      Reported-by: default avatarIan Forbes <iforbes@vmware.com>
      Fixes: 9ef8d83e
      
       ("drm/vmwgfx: Do not drop the reference to the handle too soon")
      Cc: <stable@vger.kernel.org> # v6.4+
      Reviewed-by: default avatarMaaz <Mombasawala&lt;mombasawalam@vmware.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230818041301.407636-1-zack@kde.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6969e450
    • Zack Rusin's avatar
      drm/vmwgfx: Fix shader stage validation · 5574b0cb
      Zack Rusin authored
      commit 14abdfae
      
       upstream.
      
      For multiple commands the driver was not correctly validating the shader
      stages resulting in possible kernel oopses. The validation code was only.
      if ever, checking the upper bound on the shader stages but never a lower
      bound (valid shader stages start at 1 not 0).
      
      Fixes kernel oopses ending up in vmw_binding_add, e.g.:
      Oops: 0000 [#1] PREEMPT SMP PTI
      CPU: 1 PID: 2443 Comm: testcase Not tainted 6.3.0-rc4-vmwgfx #1
      Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020
      RIP: 0010:vmw_binding_add+0x4c/0x140 [vmwgfx]
      Code: 7e 30 49 83 ff 0e 0f 87 ea 00 00 00 4b 8d 04 7f 89 d2 89 cb 48 c1 e0 03 4c 8b b0 40 3d 93 c0 48 8b 80 48 3d 93 c0 49 0f af de <48> 03 1c d0 4c 01 e3 49 8>
      RSP: 0018:ffffb8014416b968 EFLAGS: 00010206
      RAX: ffffffffc0933ec0 RBX: 0000000000000000 RCX: 0000000000000000
      RDX: 00000000ffffffff RSI: ffffb8014416b9c0 RDI: ffffb8014316f000
      RBP: ffffb8014416b998 R08: 0000000000000003 R09: 746f6c735f726564
      R10: ffffffffaaf2bda0 R11: 732e676e69646e69 R12: ffffb8014316f000
      R13: ffffb8014416b9c0 R14: 0000000000000040 R15: 0000000000000006
      FS:  00007fba8c0af740(0000) GS:ffff8a1277c80000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000007c0933eb8 CR3: 0000000118244001 CR4: 00000000003706e0
      Call Trace:
       <TASK>
       vmw_view_bindings_add+0xf5/0x1b0 [vmwgfx]
       ? ___drm_dbg+0x8a/0xb0 [drm]
       vmw_cmd_dx_set_shader_res+0x8f/0xc0 [vmwgfx]
       vmw_execbuf_process+0x590/0x1360 [vmwgfx]
       vmw_execbuf_ioctl+0x173/0x370 [vmwgfx]
       ? __drm_dev_dbg+0xb4/0xe0 [drm]
       ? __pfx_vmw_execbuf_ioctl+0x10/0x10 [vmwgfx]
       drm_ioctl_kernel+0xbc/0x160 [drm]
       drm_ioctl+0x2d2/0x580 [drm]
       ? __pfx_vmw_execbuf_ioctl+0x10/0x10 [vmwgfx]
       ? do_fault+0x1a6/0x420
       vmw_generic_ioctl+0xbd/0x180 [vmwgfx]
       vmw_unlocked_ioctl+0x19/0x20 [vmwgfx]
       __x64_sys_ioctl+0x96/0xd0
       do_syscall_64+0x5d/0x90
       ? handle_mm_fault+0xe4/0x2f0
       ? debug_smp_processor_id+0x1b/0x30
       ? fpregs_assert_state_consistent+0x2e/0x50
       ? exit_to_user_mode_prepare+0x40/0x180
       ? irqentry_exit_to_user_mode+0xd/0x20
       ? irqentry_exit+0x3f/0x50
       ? exc_page_fault+0x8b/0x180
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Signed-off-by: default avatarZack Rusin <zackr@vmware.com>
      Cc: security@openanolis.org
      Reported-by: default avatarZiming Zhang <ezrakiez@gmail.com>
      Testcase-found-by: default avatarNiels De Graef <ndegraef@redhat.com>
      Fixes: d80efd5c
      
       ("drm/vmwgfx: Initial DX support")
      Cc: <stable@vger.kernel.org> # v4.3+
      Reviewed-by: default avatarMaaz <Mombasawala&lt;mombasawalam@vmware.com>
      Reviewed-by: default avatarMartin Krastev <krastevm@vmware.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230616190934.54828-1-zack@kde.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5574b0cb
    • David Hildenbrand's avatar
      mm/gup: handle cont-PTE hugetlb pages correctly in gup_must_unshare() via GUP-fast · 980cde3a
      David Hildenbrand authored
      commit 5805192c upstream.
      
      In contrast to most other GUP code, GUP-fast common page table walking
      code like gup_pte_range() also handles hugetlb pages.  But in contrast to
      other hugetlb page table walking code, it does not look at the hugetlb PTE
      abstraction whereby we have only a single logical hugetlb PTE per hugetlb
      page, even when using multiple cont-PTEs underneath -- which is for
      example what huge_ptep_get() abstracts.
      
      So when we have a hugetlb page that is mapped via cont-PTEs, GUP-fast
      might stumble over a PTE that does not map the head page of a hugetlb page
      -- not the first "head" PTE of such a cont mapping.
      
      Logically, the whole hugetlb page is mapped (entire_mapcount == 1), but we
      might end up calling gup_must_unshare() with a tail page of a hugetlb
      page.
      
      We only maintain a single PageAnonExclusive flag per hugetlb page (as
      hugetlb pages cannot get partially COW-shared), stored for the head page.
      That flag is clear for all tail pages.
      
      So when gup_must_unshare() ends up calling PageAnonExclusive() with a tail
      page of a hugetlb page:
      
      1) With CONFIG_DEBUG_VM_PGFLAGS
      
      Stumbles over the:
      
      	VM_BUG_ON_PGFLAGS(PageHuge(page) && !PageHead(page), page);
      
      For example, when executing the COW selftests with 64k hugetlb pages on
      arm64:
      
        [   61.082187] page:00000000829819ff refcount:3 mapcount:1 mapping:0000000000000000 index:0x1 pfn:0x11ee11
        [   61.082842] head:0000000080f79bf7 order:4 entire_mapcount:1 nr_pages_mapped:0 pincount:2
        [   61.083384] anon flags: 0x17ffff80003000e(referenced|uptodate|dirty|head|mappedtodisk|node=0|zone=2|lastcpupid=0xfffff)
        [   61.084101] page_type: 0xffffffff()
        [   61.084332] raw: 017ffff800000000 fffffc00037b8401 0000000000000402 0000000200000000
        [   61.084840] raw: 0000000000000010 0000000000000000 00000000ffffffff 0000000000000000
        [   61.085359] head: 017ffff80003000e ffffd9e95b09b788 ffffd9e95b09b788 ffff0007ff63cf71
        [   61.085885] head: 0000000000000000 0000000000000002 00000003ffffffff 0000000000000000
        [   61.086415] page dumped because: VM_BUG_ON_PAGE(PageHuge(page) && !PageHead(page))
        [   61.086914] ------------[ cut here ]------------
        [   61.087220] kernel BUG at include/linux/page-flags.h:990!
        [   61.087591] Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
        [   61.087999] Modules linked in: ...
        [   61.089404] CPU: 0 PID: 4612 Comm: cow Kdump: loaded Not tainted 6.5.0-rc4+ #3
        [   61.089917] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
        [   61.090409] pstate: 604000c5 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
        [   61.090897] pc : gup_must_unshare.part.0+0x64/0x98
        [   61.091242] lr : gup_must_unshare.part.0+0x64/0x98
        [   61.091592] sp : ffff8000825eb940
        [   61.091826] x29: ffff8000825eb940 x28: 0000000000000000 x27: fffffc00037b8440
        [   61.092329] x26: 0400000000000001 x25: 0000000000080101 x24: 0000000000080000
        [   61.092835] x23: 0000000000080100 x22: ffff0000cffb9588 x21: ffff0000c8ec6b58
        [   61.093341] x20: 0000ffffad6b1000 x19: fffffc00037b8440 x18: ffffffffffffffff
        [   61.093850] x17: 2864616548656761 x16: 5021202626202965 x15: 6761702865677548
        [   61.094358] x14: 6567615028454741 x13: 2929656761702864 x12: 6165486567615021
        [   61.094858] x11: 00000000ffff7fff x10: 00000000ffff7fff x9 : ffffd9e958b7a1c0
        [   61.095359] x8 : 00000000000bffe8 x7 : c0000000ffff7fff x6 : 00000000002bffa8
        [   61.095873] x5 : ffff0008bb19e708 x4 : 0000000000000000 x3 : 0000000000000000
        [   61.096380] x2 : 0000000000000000 x1 : ffff0000cf6636c0 x0 : 0000000000000046
        [   61.096894] Call trace:
        [   61.097080]  gup_must_unshare.part.0+0x64/0x98
        [   61.097392]  gup_pte_range+0x3a8/0x3f0
        [   61.097662]  gup_pgd_range+0x1ec/0x280
        [   61.097942]  lockless_pages_from_mm+0x64/0x1a0
        [   61.098258]  internal_get_user_pages_fast+0xe4/0x1d0
        [   61.098612]  pin_user_pages_fast+0x58/0x78
        [   61.098917]  pin_longterm_test_start+0xf4/0x2b8
        [   61.099243]  gup_test_ioctl+0x170/0x3b0
        [   61.099528]  __arm64_sys_ioctl+0xa8/0xf0
        [   61.099822]  invoke_syscall.constprop.0+0x7c/0xd0
        [   61.100160]  el0_svc_common.constprop.0+0xe8/0x100
        [   61.100500]  do_el0_svc+0x38/0xa0
        [   61.100736]  el0_svc+0x3c/0x198
        [   61.100971]  el0t_64_sync_handler+0x134/0x150
        [   61.101280]  el0t_64_sync+0x17c/0x180
        [   61.101543] Code: aa1303e0 f00074c1 912b0021 97fffeb2 (d4210000)
      
      2) Without CONFIG_DEBUG_VM_PGFLAGS
      
      Always detects "not exclusive" for passed tail pages and refuses to PIN
      the tail pages R/O, as gup_must_unshare() == true.  GUP-fast will fallback
      to ordinary GUP.  As ordinary GUP properly considers the logical hugetlb
      PTE abstraction in hugetlb_follow_page_mask(), pinning the page will
      succeed when looking at the PageAnonExclusive on the head page only.
      
      So the only real effect of this is that with cont-PTE hugetlb pages, we'll
      always fallback from GUP-fast to ordinary GUP when not working on the head
      page, which ends up checking the head page and do the right thing.
      
      Consequently, the cow selftests pass with cont-PTE hugetlb pages as well
      without CONFIG_DEBUG_VM_PGFLAGS.
      
      Note that this only applies to anon hugetlb pages that are mapped using
      cont-PTEs: for example 64k hugetlb pages on a 4k arm64 kernel.
      
      ... and only when R/O-pinning (FOLL_PIN) such pages that are mapped into
      the page table R/O using GUP-fast.
      
      On production kernels (and even most debug kernels, that don't set
      CONFIG_DEBUG_VM_PGFLAGS) this patch should theoretically not be required
      to be backported.  But of course, it does not hurt.
      
      Link: https://lkml.kernel.org/r/20230805101256.87306-1-david@redhat.com
      Fixes: a7f22660
      
       ("mm/gup: trigger FAULT_FLAG_UNSHARE when R/O-pinning a possibly shared anonymous page")
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reported-by: default avatarRyan Roberts <ryan.roberts@arm.com>
      Reviewed-by: default avatarRyan Roberts <ryan.roberts@arm.com>
      Tested-by: default avatarRyan Roberts <ryan.roberts@arm.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Jason Gunthorpe <jgg@nvidia.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      980cde3a
    • David Hildenbrand's avatar
      mm/gup: reintroduce FOLL_NUMA as FOLL_HONOR_NUMA_FAULT · 2106dae0
      David Hildenbrand authored
      commit d74943a2 upstream.
      
      Unfortunately commit 474098ed ("mm/gup: replace FOLL_NUMA by
      gup_can_follow_protnone()") missed that follow_page() and
      follow_trans_huge_pmd() never implicitly set FOLL_NUMA because they really
      don't want to fail on PROT_NONE-mapped pages -- either due to NUMA hinting
      or due to inaccessible (PROT_NONE) VMAs.
      
      As spelled out in commit 0b9d7052 ("mm: numa: Support NUMA hinting
      page faults from gup/gup_fast"): "Other follow_page callers like KSM
      should not use FOLL_NUMA, or they would fail to get the pages if they use
      follow_page instead of get_user_pages."
      
      liubo reported [1] that smaps_rollup results are imprecise, because they
      miss accounting of pages that are mapped PROT_NONE.  Further, it's easy to
      reproduce that KSM no longer works on inaccessible VMAs on x86-64, because
      pte_protnone()/pmd_protnone() also indictaes "true" in inaccessible VMAs,
      and follow_page() refuses to return such pages right now.
      
      As KVM really depends on these NUMA hinting faults, removing the
      pte_protnone()/pmd_protnone() handling in GUP code completely is not
      really an option.
      
      To fix the issues at hand, let's revive FOLL_NUMA as FOLL_HONOR_NUMA_FAULT
      to restore the original behavior for now and add better comments.
      
      Set FOLL_HONOR_NUMA_FAULT independent of FOLL_FORCE in
      is_valid_gup_args(), to add that flag for all external GUP users.
      
      Note that there are three GUP-internal __get_user_pages() users that don't
      end up calling is_valid_gup_args() and consequently won't get
      FOLL_HONOR_NUMA_FAULT set.
      
      1) get_dump_page(): we really don't want to handle NUMA hinting
         faults. It specifies FOLL_FORCE and wouldn't have honored NUMA
         hinting faults already.
      2) populate_vma_page_range(): we really don't want to handle NUMA hinting
         faults. It specifies FOLL_FORCE on accessible VMAs, so it wouldn't have
         honored NUMA hinting faults already.
      3) faultin_vma_page_range(): we similarly don't want to handle NUMA
         hinting faults.
      
      To make the combination of FOLL_FORCE and FOLL_HONOR_NUMA_FAULT work in
      inaccessible VMAs properly, we have to perform VMA accessibility checks in
      gup_can_follow_protnone().
      
      As GUP-fast should reject such pages either way in
      pte_access_permitted()/pmd_access_permitted() -- for example on x86-64 and
      arm64 that both implement pte_protnone() -- let's just always fallback to
      ordinary GUP when stumbling over pte_protnone()/pmd_protnone().
      
      As Linus notes [2], honoring NUMA faults might only make sense for
      selected GUP users.
      
      So we should really see if we can instead let relevant GUP callers specify
      it manually, and not trigger NUMA hinting faults from GUP as default.
      Prepare for that by making FOLL_HONOR_NUMA_FAULT an external GUP flag and
      adding appropriate documenation.
      
      While at it, remove a stale comment from follow_trans_huge_pmd(): That
      comment for pmd_protnone() was added in commit 2b4847e7 ("mm: numa:
      serialise parallel get_user_page against THP migration"), which noted:
      
      	THP does not unmap pages due to a lack of support for migration
      	entries at a PMD level.  This allows races with get_user_pages
      
      Nowadays, we do have PMD migration entries, so the comment no longer
      applies.  Let's drop it.
      
      [1] https://lore.kernel.org/r/20230726073409.631838-1-liubo254@huawei.com
      [2] https://lore.kernel.org/r/CAHk-=wgRiP_9X0rRdZKT8nhemZGNateMtb366t37d8-x7VRs=g@mail.gmail.com
      
      Link: https://lkml.kernel.org/r/20230803143208.383663-2-david@redhat.com
      Fixes: 474098ed
      
       ("mm/gup: replace FOLL_NUMA by gup_can_follow_protnone()")
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reported-by: default avatarliubo <liubo254@huawei.com>
      Closes: https://lore.kernel.org/r/20230726073409.631838-1-liubo254@huawei.com
      Reported-by: default avatarPeter Xu <peterx@redhat.com>
      Closes: https://lore.kernel.org/all/ZMKJjDaqZ7FW0jfe@x1n/
      Acked-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Acked-by: default avatarPeter Xu <peterx@redhat.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2106dae0
    • Suren Baghdasaryan's avatar
      mm: enable page walking API to lock vmas during the walk · a55dd240
      Suren Baghdasaryan authored
      commit 49b06385
      
       upstream.
      
      walk_page_range() and friends often operate under write-locked mmap_lock.
      With introduction of vma locks, the vmas have to be locked as well during
      such walks to prevent concurrent page faults in these areas.  Add an
      additional member to mm_walk_ops to indicate locking requirements for the
      walk.
      
      The change ensures that page walks which prevent concurrent page faults
      by write-locking mmap_lock, operate correctly after introduction of
      per-vma locks.  With per-vma locks page faults can be handled under vma
      lock without taking mmap_lock at all, so write locking mmap_lock would
      not stop them.  The change ensures vmas are properly locked during such
      walks.
      
      A sample issue this solves is do_mbind() performing queue_pages_range()
      to queue pages for migration.  Without this change a concurrent page
      can be faulted into the area and be left out of migration.
      
      Link: https://lkml.kernel.org/r/20230804152724.3090321-2-surenb@google.com
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Suggested-by: default avatarLinus Torvalds <torvalds@linuxfoundation.org>
      Suggested-by: default avatarJann Horn <jannh@google.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Laurent Dufour <ldufour@linux.ibm.com>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Michel Lespinasse <michel@lespinasse.org>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a55dd240
    • Ayush Jain's avatar
      selftests/mm: FOLL_LONGTERM need to be updated to 0x100 · 2dcc0e4b
      Ayush Jain authored
      commit 1738b949 upstream.
      
      After commit 2c224108 ("mm/gup: move private gup FOLL_ flags to
      internal.h") FOLL_LONGTERM flag value got updated from 0x10000 to 0x100 at
      include/linux/mm_types.h.
      
      As hmm.hmm_device_private.hmm_gup_test uses FOLL_LONGTERM Updating same
      here as well.
      
      Before this change test goes in an infinite assert loop in
      hmm.hmm_device_private.hmm_gup_test
      ==========================================================
       RUN           hmm.hmm_device_private.hmm_gup_test ...
      hmm-tests.c:1962:hmm_gup_test:Expected HMM_DMIRROR_PROT_WRITE..
      ..(2) == m[2] (34)
      hmm-tests.c:157:hmm_gup_test:Expected ret (-1) == 0 (0)
      hmm-tests.c:157:hmm_gup_test:Expected ret (-1) == 0 (0)
      ...
      ==========================================================
      
       Call Trace:
       <TASK>
       ? sched_clock+0xd/0x20
       ? __lock_acquire.constprop.0+0x120/0x6c0
       ? ktime_get+0x2c/0xd0
       ? sched_clock+0xd/0x20
       ? local_clock+0x12/0xd0
       ? lock_release+0x26e/0x3b0
       pin_user_pages_fast+0x4c/0x70
       gup_test_ioctl+0x4ff/0xbb0
       ? gup_test_ioctl+0x68c/0xbb0
       __x64_sys_ioctl+0x99/0xd0
       do_syscall_64+0x60/0x90
       ? syscall_exit_to_user_mode+0x2a/0x50
       ? do_syscall_64+0x6d/0x90
       ? syscall_exit_to_user_mode+0x2a/0x50
       ? do_syscall_64+0x6d/0x90
       ? irqentry_exit_to_user_mode+0xd/0x20
       ? irqentry_exit+0x3f/0x50
       ? exc_page_fault+0x96/0x200
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
       RIP: 0033:0x7f6aaa31aaff
      
      After this change test is able to pass successfully.
      
      Link: https://lkml.kernel.org/r/20230808124347.79163-1-ayush.jain3@amd.com
      Fixes: 2c224108
      
       ("mm/gup: move private gup FOLL_ flags to internal.h")
      Signed-off-by: default avatarAyush Jain <ayush.jain3@amd.com>
      Reviewed-by: default avatarRaghavendra K T <raghavendra.kt@amd.com>
      Reviewed-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Jason Gunthorpe <jgg@nvidia.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2dcc0e4b
    • Takashi Iwai's avatar
      ALSA: ymfpci: Fix the missing snd_card_free() call at probe error · c02c4e76
      Takashi Iwai authored
      commit 1d0eb614 upstream.
      
      Like a few other drivers, YMFPCI driver needs to clean up with
      snd_card_free() call at an error path of the probe; otherwise the
      other devres resources are released before the card and it results in
      the UAF.
      
      This patch uses the helper for handling the probe error gracefully.
      
      Fixes: f33fc157
      
       ("ALSA: ymfpci: Create card with device-managed snd_devm_card_new()")
      Cc: <stable@vger.kernel.org>
      Reported-and-tested-by: default avatarTakashi Yano <takashi.yano@nifty.ne.jp>
      Closes: https://lore.kernel.org/r/20230823135846.1812-1-takashi.yano@nifty.ne.jp
      Link: https://lore.kernel.org/r/20230823161625.5807-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c02c4e76
    • Hugh Dickins's avatar
      shmem: fix smaps BUG sleeping while atomic · 6218f967
      Hugh Dickins authored
      commit e5548f85 upstream.
      
      smaps_pte_hole_lookup() is calling shmem_partial_swap_usage() with page
      table lock held: but shmem_partial_swap_usage() does cond_resched_rcu() if
      need_resched(): "BUG: sleeping function called from invalid context".
      
      Since shmem_partial_swap_usage() is designed to count across a range, but
      smaps_pte_hole_lookup() only calls it for a single page slot, just break
      out of the loop on the last or only page, before checking need_resched().
      
      Link: https://lkml.kernel.org/r/6fe3b3ec-abdf-332f-5c23-6a3b3a3b11a9@google.com
      Fixes: 23010032
      
       ("mm/smaps: simplify shmem handling of pte holes")
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Acked-by: default avatarPeter Xu <peterx@redhat.com>
      Cc: <stable@vger.kernel.org>	[5.16+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6218f967
    • Rik van Riel's avatar
      mm,ima,kexec,of: use memblock_free_late from ima_free_kexec_buffer · 535cdce0
      Rik van Riel authored
      commit f0362a25 upstream.
      
      The code calling ima_free_kexec_buffer runs long after the memblock
      allocator has already been torn down, potentially resulting in a use
      after free in memblock_isolate_range.
      
      With KASAN or KFENCE, this use after free will result in a BUG
      from the idle task, and a subsequent kernel panic.
      
      Switch ima_free_kexec_buffer over to memblock_free_late to avoid
      that issue.
      
      Fixes: fee3ff99
      
       ("powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c")
      Cc: stable@kernel.org
      Signed-off-by: default avatarRik van Riel <riel@surriel.com>
      Suggested-by: default avatarMike Rappoport <rppt@kernel.org>
      Link: https://lore.kernel.org/r/20230817135759.0888e5ef@imladris.surriel.com
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      535cdce0
    • Andrey Skvortsov's avatar
      clk: Fix slab-out-of-bounds error in devm_clk_release() · c856ff4a
      Andrey Skvortsov authored
      commit 66fbfb35 upstream.
      
      Problem can be reproduced by unloading snd_soc_simple_card, because in
      devm_get_clk_from_child() devres data is allocated as `struct clk`, but
      devm_clk_release() expects devres data to be `struct devm_clk_state`.
      
      KASAN report:
       ==================================================================
       BUG: KASAN: slab-out-of-bounds in devm_clk_release+0x20/0x54
       Read of size 8 at addr ffffff800ee09688 by task (udev-worker)/287
      
       Call trace:
        dump_backtrace+0xe8/0x11c
        show_stack+0x1c/0x30
        dump_stack_lvl+0x60/0x78
        print_report+0x150/0x450
        kasan_report+0xa8/0xf0
        __asan_load8+0x78/0xa0
        devm_clk_release+0x20/0x54
        release_nodes+0x84/0x120
        devres_release_all+0x144/0x210
        device_unbind_cleanup+0x1c/0xac
        really_probe+0x2f0/0x5b0
        __driver_probe_device+0xc0/0x1f0
        driver_probe_device+0x68/0x120
        __driver_attach+0x140/0x294
        bus_for_each_dev+0xec/0x160
        driver_attach+0x38/0x44
        bus_add_driver+0x24c/0x300
        driver_register+0xf0/0x210
        __platform_driver_register+0x48/0x54
        asoc_simple_card_init+0x24/0x1000 [snd_soc_simple_card]
        do_one_initcall+0xac/0x340
        do_init_module+0xd0/0x300
        load_module+0x2ba4/0x3100
        __do_sys_init_module+0x2c8/0x300
        __arm64_sys_init_module+0x48/0x5c
        invoke_syscall+0x64/0x190
        el0_svc_common.constprop.0+0x124/0x154
        do_el0_svc+0x44/0xdc
        el0_svc+0x14/0x50
        el0t_64_sync_handler+0xec/0x11c
        el0t_64_sync+0x14c/0x150
      
       Allocated by task 287:
        kasan_save_stack+0x38/0x60
        kasan_set_track+0x28/0x40
        kasan_save_alloc_info+0x20/0x30
        __kasan_kmalloc+0xac/0xb0
        __kmalloc_node_track_caller+0x6c/0x1c4
        __devres_alloc_node+0x44/0xb4
        devm_get_clk_from_child+0x44/0xa0
        asoc_simple_parse_clk+0x1b8/0x1dc [snd_soc_simple_card_utils]
        simple_parse_node.isra.0+0x1ec/0x230 [snd_soc_simple_card]
        simple_dai_link_of+0x1bc/0x334 [snd_soc_simple_card]
        __simple_for_each_link+0x2ec/0x320 [snd_soc_simple_card]
        asoc_simple_probe+0x468/0x4dc [snd_soc_simple_card]
        platform_probe+0x90/0xf0
        really_probe+0x118/0x5b0
        __driver_probe_device+0xc0/0x1f0
        driver_probe_device+0x68/0x120
        __driver_attach+0x140/0x294
        bus_for_each_dev+0xec/0x160
        driver_attach+0x38/0x44
        bus_add_driver+0x24c/0x300
        driver_register+0xf0/0x210
        __platform_driver_register+0x48/0x54
        asoc_simple_card_init+0x24/0x1000 [snd_soc_simple_card]
        do_one_initcall+0xac/0x340
        do_init_module+0xd0/0x300
        load_module+0x2ba4/0x3100
        __do_sys_init_module+0x2c8/0x300
        __arm64_sys_init_module+0x48/0x5c
        invoke_syscall+0x64/0x190
        el0_svc_common.constprop.0+0x124/0x154
        do_el0_svc+0x44/0xdc
        el0_svc+0x14/0x50
        el0t_64_sync_handler+0xec/0x11c
        el0t_64_sync+0x14c/0x150
      
       The buggy address belongs to the object at ffffff800ee09600
        which belongs to the cache kmalloc-256 of size 256
       The buggy address is located 136 bytes inside of
        256-byte region [ffffff800ee09600, ffffff800ee09700)
      
       The buggy address belongs to the physical page:
       page:000000002d97303b refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4ee08
       head:000000002d97303b order:1 compound_mapcount:0 compound_pincount:0
       flags: 0x10200(slab|head|zone=0)
       raw: 0000000000010200 0000000000000000 dead000000000122 ffffff8002c02480
       raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
       page dumped because: kasan: bad access detected
      
       Memory state around the buggy address:
        ffffff800ee09580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
        ffffff800ee09600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
       >ffffff800ee09680: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                             ^
        ffffff800ee09700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
        ffffff800ee09780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ==================================================================
      
      Fixes: abae8e57
      
       ("clk: generalize devm_clk_get() a bit")
      Signed-off-by: default avatarAndrey Skvortsov <andrej.skvortzov@gmail.com>
      Link: https://lore.kernel.org/r/20230805084847.3110586-1-andrej.skvortzov@gmail.com
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c856ff4a
    • Benjamin Coddington's avatar
      NFSv4: Fix dropped lock for racing OPEN and delegation return · ed2e9e10
      Benjamin Coddington authored
      commit 1cbc11aa upstream.
      
      Commmit f5ea1613
      
       ("NFSv4: Retry LOCK on OLD_STATEID during delegation
      return") attempted to solve this problem by using nfs4's generic async error
      handling, but introduced a regression where v4.0 lock recovery would hang.
      The additional complexity introduced by overloading that error handling is
      not necessary for this case.  This patch expects that commit to be
      reverted.
      
      The problem as originally explained in the above commit is:
      
          There's a small window where a LOCK sent during a delegation return can
          race with another OPEN on client, but the open stateid has not yet been
          updated.  In this case, the client doesn't handle the OLD_STATEID error
          from the server and will lose this lock, emitting:
          "NFS: nfs4_handle_delegation_recall_error: unhandled error -10024".
      
      Fix this by using the old_stateid refresh helpers if the server replies
      with OLD_STATEID.
      
      Suggested-by: default avatarTrond Myklebust <trondmy@hammerspace.com>
      Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed2e9e10
    • André Apitzsch's avatar
      platform/x86: ideapad-laptop: Add support for new hotkeys found on ThinkBook 14s Yoga ITL · ed29b5fb
      André Apitzsch authored
      commit a260f7d7
      
       upstream.
      
      The Lenovo Thinkbook 14s Yoga ITL has 4 new symbols/shortcuts on their
      F9-F11 and PrtSc keys:
      
      F9:    Has a symbol of a head with a headset, the manual says "Service key"
      F10:   Has a symbol of a telephone horn which has been picked up from the
             receiver, the manual says: "Answer incoming calls"
      F11:   Has a symbol of a telephone horn which is resting on the receiver,
             the manual says: "Reject incoming calls"
      PrtSc: Has a symbol of a siccor and a dashed ellipse, the manual says:
             "Open the Windows 'Snipping' Tool app"
      
      This commit adds support for these 4 new hkey events.
      
      Signed-off-by: default avatarAndré Apitzsch <git@apitzsch.eu>
      Link: https://lore.kernel.org/r/20230819-lenovo_keys-v1-1-9d34eac88e0a@apitzsch.eu
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed29b5fb
    • Swapnil Devesh's avatar
      platform/x86: lenovo-ymc: Add Lenovo Yoga 7 14ACN6 to ec_trigger_quirk_dmi_table · 3bdeb65c
      Swapnil Devesh authored
      commit db35610a
      
       upstream.
      
      This adds my laptop Lenovo Yoga 7 14ACN6, with Product Name: 82N7
      (from `dmidecode -t1 | grep "Product Name"`) to
      the ec_trigger_quirk_dmi_table, have tested that this is required
      for the YMC driver to work correctly on this model.
      
      Signed-off-by: default avatarSwapnil Devesh <me@sidevesh.com>
      Reviewed-by: default avatarGergő Köteles <soyer@irl.hu>
      Link: https://lore.kernel.org/r/18a08a8b173.895ef3b250414.1213194126082324071@sidevesh.com
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3bdeb65c
    • Ping-Ke Shih's avatar
      wifi: mac80211: limit reorder_buf_filtered to avoid UBSAN warning · 28eee9b4
      Ping-Ke Shih authored
      commit b98c1610 upstream.
      
      The commit 06470f74
      
       ("mac80211: add API to allow filtering frames in BA sessions")
      added reorder_buf_filtered to mark frames filtered by firmware, and it
      can only work correctly if hw.max_rx_aggregation_subframes <= 64 since
      it stores the bitmap in a u64 variable.
      
      However, new HE or EHT devices can support BlockAck number up to 256 or
      1024, and then using a higher subframe index leads UBSAN warning:
      
       UBSAN: shift-out-of-bounds in net/mac80211/rx.c:1129:39
       shift exponent 215 is too large for 64-bit type 'long long unsigned int'
       Call Trace:
        <IRQ>
        dump_stack_lvl+0x48/0x70
        dump_stack+0x10/0x20
        __ubsan_handle_shift_out_of_bounds+0x1ac/0x360
        ieee80211_release_reorder_frame.constprop.0.cold+0x64/0x69 [mac80211]
        ieee80211_sta_reorder_release+0x9c/0x400 [mac80211]
        ieee80211_prepare_and_rx_handle+0x1234/0x1420 [mac80211]
        ieee80211_rx_list+0xaef/0xf60 [mac80211]
        ieee80211_rx_napi+0x53/0xd0 [mac80211]
      
      Since only old hardware that supports <=64 BlockAck uses
      ieee80211_mark_rx_ba_filtered_frames(), limit the use as it is, so add a
      WARN_ONCE() and comment to note to avoid using this function if hardware
      capability is not suitable.
      
      Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
      Link: https://lore.kernel.org/r/20230818014004.16177-1-pkshih@realtek.com
      [edit commit message]
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28eee9b4
    • Michael Ellerman's avatar
      ibmveth: Use dcbf rather than dcbfl · a3009e19
      Michael Ellerman authored
      commit bfedba3b
      
       upstream.
      
      When building for power4, newer binutils don't recognise the "dcbfl"
      extended mnemonic.
      
      dcbfl RA, RB is equivalent to dcbf RA, RB, 1.
      
      Switch to "dcbf" to avoid the build error.
      
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a3009e19
    • Srinivas Goud's avatar
      spi: spi-cadence: Fix data corruption issues in slave mode · 06a128cb
      Srinivas Goud authored
      commit 627d05a4
      
       upstream.
      
      Remove 10us delay in cdns_spi_process_fifo() (called from cdns_spi_irq())
      to fix data corruption issue on Master side when this driver
      configured in Slave mode, as Slave is failed to prepare the date
      on time due to above delay.
      
      Add 10us delay before processing the RX FIFO as TX empty doesn't
      guarantee valid data in RX FIFO.
      
      Signed-off-by: default avatarSrinivas Goud <srinivas.goud@amd.com>
      Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Tested-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Link: https://lore.kernel.org/r/1692610216-217644-1-git-send-email-srinivas.goud@amd.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      06a128cb
    • Charles Keepax's avatar
      ASoC: cs35l41: Correct amp_gain_tlv values · 28b605e9
      Charles Keepax authored
      commit 1613781d
      
       upstream.
      
      The current analog gain TLV seems to have completely incorrect values in
      it. The gain starts at 0.5dB, proceeds in 1dB steps, and has no mute
      value, correct the control to match.
      
      Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Link: https://lore.kernel.org/r/20230823085308.753572-1-ckeepax@opensource.cirrus.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28b605e9
    • BrenoRCBrito's avatar
      ASoC: amd: yc: Add VivoBook Pro 15 to quirks list for acp6x · 8c7fd1ba
      BrenoRCBrito authored
      commit 3b1f0883
      
       upstream.
      
      VivoBook Pro 15 Ryzen Edition uses Ryzen 6800H processor, and adding to
       quirks list for acp6x will enable internal mic.
      
      Signed-off-by: default avatarBrenoRCBrito <brenorcbrito@gmail.com>
      Link: https://lore.kernel.org/r/20230818211417.32167-1-brenorcbrito@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c7fd1ba
    • Hangbin Liu's avatar
      bonding: fix macvlan over alb bond support · 1cc2d968
      Hangbin Liu authored
      [ Upstream commit e74216b8 ]
      
      The commit 14af9963 ("bonding: Support macvlans on top of tlb/rlb mode
      bonds") aims to enable the use of macvlans on top of rlb bond mode. However,
      the current rlb bond mode only handles ARP packets to update remote neighbor
      entries. This causes an issue when a macvlan is on top of the bond, and
      remote devices send packets to the macvlan using the bond's MAC address
      as the destination. After delivering the packets to the macvlan, the macvlan
      will rejects them as the MAC address is incorrect. Consequently, this commit
      makes macvlan over bond non-functional.
      
      To address this problem, one potential solution is to check for the presence
      of a macvlan port on the bond device using netif_is_macvlan_port(bond->dev)
      and return NULL in the rlb_arp_xmit() function. However, this approach
      doesn't fully resolve the situation when a VLAN exists between the bond and
      macvlan.
      
      So let's just do a partial revert for commit 14af9963 in rlb_arp_xmit().
      As the comment said, Don't modify or load balance ARPs that do not originate
      locally.
      
      Fixes: 14af9963
      
       ("bonding: Support macvlans on top of tlb/rlb mode bonds")
      Reported-by: default avatar <susan.zheng@veritas.com>
      Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2117816
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Acked-by: default avatarJay Vosburgh <jay.vosburgh@canonical.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1cc2d968