From: Greg Kroah-Hartman Date: Wed, 5 Feb 2025 12:24:35 +0000 (+0100) Subject: 6.12-stable patches X-Git-Tag: v6.6.76~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ecb3dda04d4c012bd38b672112bb08376130fd90;p=thirdparty%2Fkernel%2Fstable-queue.git 6.12-stable patches added patches: asoc-da7213-initialize-the-mutex.patch btrfs-do-proper-folio-cleanup-when-run_delalloc_nocow-failed.patch drm-amd-display-add-hubp-cache-reset-when-powergating.patch kvm-x86-plumb-in-the-vcpu-to-kvm_x86_ops.hwapic_isr_update.patch loongarch-change-8-to-14-for-loongarch_max_-brp-wrp.patch memcg-fix-soft-lockup-in-the-oom-process.patch s390-add-std-gnu11-to-decompressor-and-purgatory-cflags.patch selftests-bpf-add-test-to-verify-tailcall-and-freplace-restrictions.patch selftests-mm-build-with-o2.patch --- diff --git a/queue-6.12/asoc-da7213-initialize-the-mutex.patch b/queue-6.12/asoc-da7213-initialize-the-mutex.patch new file mode 100644 index 0000000000..ea02c83dbc --- /dev/null +++ b/queue-6.12/asoc-da7213-initialize-the-mutex.patch @@ -0,0 +1,71 @@ +From 4a32a38cb68f55ff9e100df348ddb3d4b3e50643 Mon Sep 17 00:00:00 2001 +From: Claudiu Beznea +Date: Thu, 23 Jan 2025 14:10:36 +0200 +Subject: ASoC: da7213: Initialize the mutex + +From: Claudiu Beznea + +commit 4a32a38cb68f55ff9e100df348ddb3d4b3e50643 upstream. + +Initialize the struct da7213_priv::ctrl_lock mutex. Without it the +following stack trace is displayed when rebooting and lockdep is enabled: + +DEBUG_LOCKS_WARN_ON(lock->magic != lock) +WARNING: CPU: 0 PID: 180 at kernel/locking/mutex.c:564 __mutex_lock+0x254/0x4e4 +CPU: 0 UID: 0 PID: 180 Comm: alsactl Not tainted 6.13.0-next-20250123-arm64-renesas-00002-g132083a22d3d #30 +Hardware name: Renesas SMARC EVK version 2 based on r9a08g045s33 (DT) +pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) +pc : __mutex_lock+0x254/0x4e4 +lr : __mutex_lock+0x254/0x4e4 +sp : ffff800082c13c00 +x29: ffff800082c13c00 x28: ffff00001002b500 x27: 0000000000000000 +x26: 0000000000000000 x25: ffff800080b30db4 x24: 0000000000000002 +x23: ffff800082c13c70 x22: 0000ffffc2a68a70 x21: ffff000010348000 +x20: 0000000000000000 x19: ffff00000be2e488 x18: 0000000000000000 +x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 +x14: 00000000000003c1 x13: 00000000000003c1 x12: 0000000000000000 +x11: 0000000000000011 x10: 0000000000001420 x9 : ffff800082c13a70 +x8 : 0000000000000001 x7 : ffff800082c13a50 x6 : ffff800082c139e0 +x5 : ffff800082c14000 x4 : ffff800082c13a50 x3 : 0000000000000000 +x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff00001002b500 +Call trace: + __mutex_lock+0x254/0x4e4 (P) + mutex_lock_nested+0x20/0x28 + da7213_volsw_locked_get+0x34/0x60 + snd_ctl_elem_read+0xbc/0x114 + snd_ctl_ioctl+0x878/0xa70 + __arm64_sys_ioctl+0x94/0xc8 + invoke_syscall+0x44/0x104 + el0_svc_common.constprop.0+0xb4/0xd4 + do_el0_svc+0x18/0x20 + el0_svc+0x3c/0xf0 + el0t_64_sync_handler+0xc0/0xc4 + el0t_64_sync+0x154/0x158 + irq event stamp: 7713 + hardirqs last enabled at (7713): [] ktime_get_coarse_real_ts64+0xf0/0x10c + hardirqs last disabled at (7712): [] ktime_get_coarse_real_ts64+0xb4/0x10c + softirqs last enabled at (7550): [] fpsimd_restore_current_state+0x30/0xb8 + softirqs last disabled at (7548): [] fpsimd_restore_current_state+0x4/0xb8 + ---[ end trace 0000000000000000 ]--- + +Fixes: 64c3259b5f86 ("ASoC: da7213: Add new kcontrol for tonegen") +Cc: stable@vger.kernel.org +Signed-off-by: Claudiu Beznea +Link: https://patch.msgid.link/20250123121036.70406-1-claudiu.beznea.uj@bp.renesas.com +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman +--- + sound/soc/codecs/da7213.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/sound/soc/codecs/da7213.c ++++ b/sound/soc/codecs/da7213.c +@@ -2191,6 +2191,8 @@ static int da7213_i2c_probe(struct i2c_c + return ret; + } + ++ mutex_init(&da7213->ctrl_lock); ++ + pm_runtime_set_autosuspend_delay(&i2c->dev, 100); + pm_runtime_use_autosuspend(&i2c->dev); + pm_runtime_set_active(&i2c->dev); diff --git a/queue-6.12/btrfs-do-proper-folio-cleanup-when-run_delalloc_nocow-failed.patch b/queue-6.12/btrfs-do-proper-folio-cleanup-when-run_delalloc_nocow-failed.patch new file mode 100644 index 0000000000..713e5a26d6 --- /dev/null +++ b/queue-6.12/btrfs-do-proper-folio-cleanup-when-run_delalloc_nocow-failed.patch @@ -0,0 +1,274 @@ +From c2b47df81c8e20a8e8cd94f0d7df211137ae94ed Mon Sep 17 00:00:00 2001 +From: Qu Wenruo +Date: Thu, 12 Dec 2024 16:43:59 +1030 +Subject: btrfs: do proper folio cleanup when run_delalloc_nocow() failed + +From: Qu Wenruo + +commit c2b47df81c8e20a8e8cd94f0d7df211137ae94ed upstream. + +[BUG] +With CONFIG_DEBUG_VM set, test case generic/476 has some chance to crash +with the following VM_BUG_ON_FOLIO(): + + BTRFS error (device dm-3): cow_file_range failed, start 1146880 end 1253375 len 106496 ret -28 + BTRFS error (device dm-3): run_delalloc_nocow failed, start 1146880 end 1253375 len 106496 ret -28 + page: refcount:4 mapcount:0 mapping:00000000592787cc index:0x12 pfn:0x10664 + aops:btrfs_aops [btrfs] ino:101 dentry name(?):"f1774" + flags: 0x2fffff80004028(uptodate|lru|private|node=0|zone=2|lastcpupid=0xfffff) + page dumped because: VM_BUG_ON_FOLIO(!folio_test_locked(folio)) + ------------[ cut here ]------------ + kernel BUG at mm/page-writeback.c:2992! + Internal error: Oops - BUG: 00000000f2000800 [#1] SMP + CPU: 2 UID: 0 PID: 3943513 Comm: kworker/u24:15 Tainted: G OE 6.12.0-rc7-custom+ #87 + Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE + Hardware name: QEMU KVM Virtual Machine, BIOS unknown 2/2/2022 + Workqueue: events_unbound btrfs_async_reclaim_data_space [btrfs] + pc : folio_clear_dirty_for_io+0x128/0x258 + lr : folio_clear_dirty_for_io+0x128/0x258 + Call trace: + folio_clear_dirty_for_io+0x128/0x258 + btrfs_folio_clamp_clear_dirty+0x80/0xd0 [btrfs] + __process_folios_contig+0x154/0x268 [btrfs] + extent_clear_unlock_delalloc+0x5c/0x80 [btrfs] + run_delalloc_nocow+0x5f8/0x760 [btrfs] + btrfs_run_delalloc_range+0xa8/0x220 [btrfs] + writepage_delalloc+0x230/0x4c8 [btrfs] + extent_writepage+0xb8/0x358 [btrfs] + extent_write_cache_pages+0x21c/0x4e8 [btrfs] + btrfs_writepages+0x94/0x150 [btrfs] + do_writepages+0x74/0x190 + filemap_fdatawrite_wbc+0x88/0xc8 + start_delalloc_inodes+0x178/0x3a8 [btrfs] + btrfs_start_delalloc_roots+0x174/0x280 [btrfs] + shrink_delalloc+0x114/0x280 [btrfs] + flush_space+0x250/0x2f8 [btrfs] + btrfs_async_reclaim_data_space+0x180/0x228 [btrfs] + process_one_work+0x164/0x408 + worker_thread+0x25c/0x388 + kthread+0x100/0x118 + ret_from_fork+0x10/0x20 + Code: 910a8021 a90363f7 a9046bf9 94012379 (d4210000) + ---[ end trace 0000000000000000 ]--- + +[CAUSE] +The first two lines of extra debug messages show the problem is caused +by the error handling of run_delalloc_nocow(). + +E.g. we have the following dirtied range (4K blocksize 4K page size): + + 0 16K 32K + |//////////////////////////////////////| + | Pre-allocated | + +And the range [0, 16K) has a preallocated extent. + +- Enter run_delalloc_nocow() for range [0, 16K) + Which found range [0, 16K) is preallocated, can do the proper NOCOW + write. + +- Enter fallback_to_fow() for range [16K, 32K) + Since the range [16K, 32K) is not backed by preallocated extent, we + have to go COW. + +- cow_file_range() failed for range [16K, 32K) + So cow_file_range() will do the clean up by clearing folio dirty, + unlock the folios. + + Now the folios in range [16K, 32K) is unlocked. + +- Enter extent_clear_unlock_delalloc() from run_delalloc_nocow() + Which is called with PAGE_START_WRITEBACK to start page writeback. + But folios can only be marked writeback when it's properly locked, + thus this triggered the VM_BUG_ON_FOLIO(). + +Furthermore there is another hidden but common bug that +run_delalloc_nocow() is not clearing the folio dirty flags in its error +handling path. +This is the common bug shared between run_delalloc_nocow() and +cow_file_range(). + +[FIX] +- Clear folio dirty for range [@start, @cur_offset) + Introduce a helper, cleanup_dirty_folios(), which + will find and lock the folio in the range, clear the dirty flag and + start/end the writeback, with the extra handling for the + @locked_folio. + +- Introduce a helper to clear folio dirty, start and end writeback + +- Introduce a helper to record the last failed COW range end + This is to trace which range we should skip, to avoid double + unlocking. + +- Skip the failed COW range for the error handling + +CC: stable@vger.kernel.org +Reviewed-by: Boris Burkov +Signed-off-by: Qu Wenruo +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/inode.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++---- + fs/btrfs/subpage.h | 13 +++++++ + 2 files changed, 102 insertions(+), 6 deletions(-) + +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -2002,6 +2002,53 @@ static int can_nocow_file_extent(struct + } + + /* ++ * Cleanup the dirty folios which will never be submitted due to error. ++ * ++ * When running a delalloc range, we may need to split the ranges (due to ++ * fragmentation or NOCOW). If we hit an error in the later part, we will error ++ * out and previously successfully executed range will never be submitted, thus ++ * we have to cleanup those folios by clearing their dirty flag, starting and ++ * finishing the writeback. ++ */ ++static void cleanup_dirty_folios(struct btrfs_inode *inode, ++ struct folio *locked_folio, ++ u64 start, u64 end, int error) ++{ ++ struct btrfs_fs_info *fs_info = inode->root->fs_info; ++ struct address_space *mapping = inode->vfs_inode.i_mapping; ++ pgoff_t start_index = start >> PAGE_SHIFT; ++ pgoff_t end_index = end >> PAGE_SHIFT; ++ u32 len; ++ ++ ASSERT(end + 1 - start < U32_MAX); ++ ASSERT(IS_ALIGNED(start, fs_info->sectorsize) && ++ IS_ALIGNED(end + 1, fs_info->sectorsize)); ++ len = end + 1 - start; ++ ++ /* ++ * Handle the locked folio first. ++ * The btrfs_folio_clamp_*() helpers can handle range out of the folio case. ++ */ ++ btrfs_folio_clamp_finish_io(fs_info, locked_folio, start, len); ++ ++ for (pgoff_t index = start_index; index <= end_index; index++) { ++ struct folio *folio; ++ ++ /* Already handled at the beginning. */ ++ if (index == locked_folio->index) ++ continue; ++ folio = __filemap_get_folio(mapping, index, FGP_LOCK, GFP_NOFS); ++ /* Cache already dropped, no need to do any cleanup. */ ++ if (IS_ERR(folio)) ++ continue; ++ btrfs_folio_clamp_finish_io(fs_info, locked_folio, start, len); ++ folio_unlock(folio); ++ folio_put(folio); ++ } ++ mapping_set_error(mapping, error); ++} ++ ++/* + * when nowcow writeback call back. This checks for snapshots or COW copies + * of the extents that exist in the file, and COWs the file as required. + * +@@ -2016,6 +2063,11 @@ static noinline int run_delalloc_nocow(s + struct btrfs_root *root = inode->root; + struct btrfs_path *path; + u64 cow_start = (u64)-1; ++ /* ++ * If not 0, represents the inclusive end of the last fallback_to_cow() ++ * range. Only for error handling. ++ */ ++ u64 cow_end = 0; + u64 cur_offset = start; + int ret; + bool check_prev = true; +@@ -2176,6 +2228,7 @@ must_cow: + found_key.offset - 1); + cow_start = (u64)-1; + if (ret) { ++ cow_end = found_key.offset - 1; + btrfs_dec_nocow_writers(nocow_bg); + goto error; + } +@@ -2249,11 +2302,12 @@ must_cow: + cow_start = cur_offset; + + if (cow_start != (u64)-1) { +- cur_offset = end; + ret = fallback_to_cow(inode, locked_folio, cow_start, end); + cow_start = (u64)-1; +- if (ret) ++ if (ret) { ++ cow_end = end; + goto error; ++ } + } + + btrfs_free_path(path); +@@ -2261,12 +2315,41 @@ must_cow: + + error: + /* ++ * There are several error cases: ++ * ++ * 1) Failed without falling back to COW ++ * start cur_offset end ++ * |/////////////| | ++ * ++ * For range [start, cur_offset) the folios are already unlocked (except ++ * @locked_folio), EXTENT_DELALLOC already removed. ++ * Only need to clear the dirty flag as they will never be submitted. ++ * Ordered extent and extent maps are handled by ++ * btrfs_mark_ordered_io_finished() inside run_delalloc_range(). ++ * ++ * 2) Failed with error from fallback_to_cow() ++ * start cur_offset cow_end end ++ * |/////////////|-----------| | ++ * ++ * For range [start, cur_offset) it's the same as case 1). ++ * But for range [cur_offset, cow_end), the folios have dirty flag ++ * cleared and unlocked, EXTENT_DEALLLOC cleared by cow_file_range(). ++ * ++ * Thus we should not call extent_clear_unlock_delalloc() on range ++ * [cur_offset, cow_end), as the folios are already unlocked. ++ * ++ * So clear the folio dirty flags for [start, cur_offset) first. ++ */ ++ if (cur_offset > start) ++ cleanup_dirty_folios(inode, locked_folio, start, cur_offset - 1, ret); ++ ++ /* + * If an error happened while a COW region is outstanding, cur_offset +- * needs to be reset to cow_start to ensure the COW region is unlocked +- * as well. ++ * needs to be reset to @cow_end + 1 to skip the COW range, as ++ * cow_file_range() will do the proper cleanup at error. + */ +- if (cow_start != (u64)-1) +- cur_offset = cow_start; ++ if (cow_end) ++ cur_offset = cow_end + 1; + + /* + * We need to lock the extent here because we're clearing DELALLOC and +--- a/fs/btrfs/subpage.h ++++ b/fs/btrfs/subpage.h +@@ -152,6 +152,19 @@ DECLARE_BTRFS_SUBPAGE_OPS(writeback); + DECLARE_BTRFS_SUBPAGE_OPS(ordered); + DECLARE_BTRFS_SUBPAGE_OPS(checked); + ++/* ++ * Helper for error cleanup, where a folio will have its dirty flag cleared, ++ * with writeback started and finished. ++ */ ++static inline void btrfs_folio_clamp_finish_io(struct btrfs_fs_info *fs_info, ++ struct folio *locked_folio, ++ u64 start, u32 len) ++{ ++ btrfs_folio_clamp_clear_dirty(fs_info, locked_folio, start, len); ++ btrfs_folio_clamp_set_writeback(fs_info, locked_folio, start, len); ++ btrfs_folio_clamp_clear_writeback(fs_info, locked_folio, start, len); ++} ++ + bool btrfs_subpage_clear_and_test_dirty(const struct btrfs_fs_info *fs_info, + struct folio *folio, u64 start, u32 len); + diff --git a/queue-6.12/drm-amd-display-add-hubp-cache-reset-when-powergating.patch b/queue-6.12/drm-amd-display-add-hubp-cache-reset-when-powergating.patch new file mode 100644 index 0000000000..5be31f6279 --- /dev/null +++ b/queue-6.12/drm-amd-display-add-hubp-cache-reset-when-powergating.patch @@ -0,0 +1,256 @@ +From 01130f5260e5868fb6b15ab8c00dbc894139f48e Mon Sep 17 00:00:00 2001 +From: Aric Cyr +Date: Thu, 9 Jan 2025 15:03:48 -0500 +Subject: drm/amd/display: Add hubp cache reset when powergating + +From: Aric Cyr + +commit 01130f5260e5868fb6b15ab8c00dbc894139f48e upstream. + +[Why] +When HUBP is power gated, the SW state can get out of sync with the +hardware state causing cursor to not be programmed correctly. + +[How] +Similar to DPP, add a HUBP reset function which is called wherever +HUBP is initialized or powergated. This function will clear the cursor +position and attribute cache allowing for proper programming when the +HUBP is brought back up. + +Cc: Mario Limonciello +Cc: Alex Deucher +Cc: stable@vger.kernel.org +Reviewed-by: Sung Lee +Signed-off-by: Aric Cyr +Signed-off-by: Wayne Lin +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c | 3 +++ + drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c | 10 +++++++++- + drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.h | 2 ++ + drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c | 1 + + drivers/gpu/drm/amd/display/dc/hubp/dcn201/dcn201_hubp.c | 1 + + drivers/gpu/drm/amd/display/dc/hubp/dcn21/dcn21_hubp.c | 3 +++ + drivers/gpu/drm/amd/display/dc/hubp/dcn30/dcn30_hubp.c | 3 +++ + drivers/gpu/drm/amd/display/dc/hubp/dcn31/dcn31_hubp.c | 1 + + drivers/gpu/drm/amd/display/dc/hubp/dcn32/dcn32_hubp.c | 1 + + drivers/gpu/drm/amd/display/dc/hubp/dcn35/dcn35_hubp.c | 1 + + drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c | 3 ++- + drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c | 2 ++ + drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c | 2 ++ + drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h | 2 ++ + 14 files changed, 33 insertions(+), 2 deletions(-) + +--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c ++++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c +@@ -194,6 +194,9 @@ void dpp_reset(struct dpp *dpp_base) + dpp->filter_h = NULL; + dpp->filter_v = NULL; + ++ memset(&dpp_base->pos, 0, sizeof(dpp_base->pos)); ++ memset(&dpp_base->att, 0, sizeof(dpp_base->att)); ++ + memset(&dpp->scl_data, 0, sizeof(dpp->scl_data)); + memset(&dpp->pwl_data, 0, sizeof(dpp->pwl_data)); + } +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c +@@ -532,6 +532,12 @@ void hubp1_dcc_control(struct hubp *hubp + SECONDARY_SURFACE_DCC_IND_64B_BLK, dcc_ind_64b_blk); + } + ++void hubp_reset(struct hubp *hubp) ++{ ++ memset(&hubp->pos, 0, sizeof(hubp->pos)); ++ memset(&hubp->att, 0, sizeof(hubp->att)); ++} ++ + void hubp1_program_surface_config( + struct hubp *hubp, + enum surface_pixel_format format, +@@ -1337,8 +1343,9 @@ static void hubp1_wait_pipe_read_start(s + + void hubp1_init(struct hubp *hubp) + { +- //do nothing ++ hubp_reset(hubp); + } ++ + static const struct hubp_funcs dcn10_hubp_funcs = { + .hubp_program_surface_flip_and_addr = + hubp1_program_surface_flip_and_addr, +@@ -1351,6 +1358,7 @@ static const struct hubp_funcs dcn10_hub + .hubp_set_vm_context0_settings = hubp1_set_vm_context0_settings, + .set_blank = hubp1_set_blank, + .dcc_control = hubp1_dcc_control, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = min_set_viewport, + .set_hubp_blank_en = hubp1_set_hubp_blank_en, + .set_cursor_attributes = hubp1_cursor_set_attributes, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.h ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.h +@@ -746,6 +746,8 @@ void hubp1_dcc_control(struct hubp *hubp + bool enable, + enum hubp_ind_block_size independent_64b_blks); + ++void hubp_reset(struct hubp *hubp); ++ + bool hubp1_program_surface_flip_and_addr( + struct hubp *hubp, + const struct dc_plane_address *address, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c +@@ -1660,6 +1660,7 @@ static struct hubp_funcs dcn20_hubp_func + .set_blank = hubp2_set_blank, + .set_blank_regs = hubp2_set_blank_regs, + .dcc_control = hubp2_dcc_control, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = min_set_viewport, + .set_cursor_attributes = hubp2_cursor_set_attributes, + .set_cursor_position = hubp2_cursor_set_position, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn201/dcn201_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn201/dcn201_hubp.c +@@ -121,6 +121,7 @@ static struct hubp_funcs dcn201_hubp_fun + .set_cursor_position = hubp1_cursor_set_position, + .set_blank = hubp1_set_blank, + .dcc_control = hubp1_dcc_control, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = min_set_viewport, + .hubp_clk_cntl = hubp1_clk_cntl, + .hubp_vtg_sel = hubp1_vtg_sel, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn21/dcn21_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn21/dcn21_hubp.c +@@ -811,6 +811,8 @@ static void hubp21_init(struct hubp *hub + struct dcn21_hubp *hubp21 = TO_DCN21_HUBP(hubp); + //hubp[i].HUBPREQ_DEBUG.HUBPREQ_DEBUG[26] = 1; + REG_WRITE(HUBPREQ_DEBUG, 1 << 26); ++ ++ hubp_reset(hubp); + } + static struct hubp_funcs dcn21_hubp_funcs = { + .hubp_enable_tripleBuffer = hubp2_enable_triplebuffer, +@@ -823,6 +825,7 @@ static struct hubp_funcs dcn21_hubp_func + .hubp_set_vm_system_aperture_settings = hubp21_set_vm_system_aperture_settings, + .set_blank = hubp1_set_blank, + .dcc_control = hubp1_dcc_control, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = hubp21_set_viewport, + .set_cursor_attributes = hubp2_cursor_set_attributes, + .set_cursor_position = hubp1_cursor_set_position, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn30/dcn30_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn30/dcn30_hubp.c +@@ -483,6 +483,8 @@ void hubp3_init(struct hubp *hubp) + struct dcn20_hubp *hubp2 = TO_DCN20_HUBP(hubp); + //hubp[i].HUBPREQ_DEBUG.HUBPREQ_DEBUG[26] = 1; + REG_WRITE(HUBPREQ_DEBUG, 1 << 26); ++ ++ hubp_reset(hubp); + } + + static struct hubp_funcs dcn30_hubp_funcs = { +@@ -497,6 +499,7 @@ static struct hubp_funcs dcn30_hubp_func + .set_blank = hubp2_set_blank, + .set_blank_regs = hubp2_set_blank_regs, + .dcc_control = hubp3_dcc_control, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = min_set_viewport, + .set_cursor_attributes = hubp2_cursor_set_attributes, + .set_cursor_position = hubp2_cursor_set_position, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn31/dcn31_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn31/dcn31_hubp.c +@@ -79,6 +79,7 @@ static struct hubp_funcs dcn31_hubp_func + .hubp_set_vm_system_aperture_settings = hubp3_set_vm_system_aperture_settings, + .set_blank = hubp2_set_blank, + .dcc_control = hubp3_dcc_control, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = min_set_viewport, + .set_cursor_attributes = hubp2_cursor_set_attributes, + .set_cursor_position = hubp2_cursor_set_position, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn32/dcn32_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn32/dcn32_hubp.c +@@ -181,6 +181,7 @@ static struct hubp_funcs dcn32_hubp_func + .set_blank = hubp2_set_blank, + .set_blank_regs = hubp2_set_blank_regs, + .dcc_control = hubp3_dcc_control, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = min_set_viewport, + .set_cursor_attributes = hubp32_cursor_set_attributes, + .set_cursor_position = hubp2_cursor_set_position, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn35/dcn35_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn35/dcn35_hubp.c +@@ -199,6 +199,7 @@ static struct hubp_funcs dcn35_hubp_func + .hubp_set_vm_system_aperture_settings = hubp3_set_vm_system_aperture_settings, + .set_blank = hubp2_set_blank, + .dcc_control = hubp3_dcc_control, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = min_set_viewport, + .set_cursor_attributes = hubp2_cursor_set_attributes, + .set_cursor_position = hubp2_cursor_set_position, +--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c ++++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c +@@ -141,7 +141,7 @@ void hubp401_update_mall_sel(struct hubp + + void hubp401_init(struct hubp *hubp) + { +- //For now nothing to do, HUBPREQ_DEBUG_DB register is removed on DCN4x. ++ hubp_reset(hubp); + } + + void hubp401_vready_at_or_After_vsync(struct hubp *hubp, +@@ -974,6 +974,7 @@ static struct hubp_funcs dcn401_hubp_fun + .hubp_set_vm_system_aperture_settings = hubp3_set_vm_system_aperture_settings, + .set_blank = hubp2_set_blank, + .set_blank_regs = hubp2_set_blank_regs, ++ .hubp_reset = hubp_reset, + .mem_program_viewport = hubp401_set_viewport, + .set_cursor_attributes = hubp32_cursor_set_attributes, + .set_cursor_position = hubp401_cursor_set_position, +--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c ++++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c +@@ -1286,6 +1286,7 @@ void dcn10_plane_atomic_power_down(struc + if (hws->funcs.hubp_pg_control) + hws->funcs.hubp_pg_control(hws, hubp->inst, false); + ++ hubp->funcs->hubp_reset(hubp); + dpp->funcs->dpp_reset(dpp); + + REG_SET(DC_IP_REQUEST_CNTL, 0, +@@ -1447,6 +1448,7 @@ void dcn10_init_pipes(struct dc *dc, str + /* Disable on the current state so the new one isn't cleared. */ + pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i]; + ++ hubp->funcs->hubp_reset(hubp); + dpp->funcs->dpp_reset(dpp); + + pipe_ctx->stream_res.tg = tg; +--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c ++++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c +@@ -787,6 +787,7 @@ void dcn35_init_pipes(struct dc *dc, str + /* Disable on the current state so the new one isn't cleared. */ + pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i]; + ++ hubp->funcs->hubp_reset(hubp); + dpp->funcs->dpp_reset(dpp); + + pipe_ctx->stream_res.tg = tg; +@@ -940,6 +941,7 @@ void dcn35_plane_atomic_disable(struct d + /*to do, need to support both case*/ + hubp->power_gated = true; + ++ hubp->funcs->hubp_reset(hubp); + dpp->funcs->dpp_reset(dpp); + + pipe_ctx->stream = NULL; +--- a/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h ++++ b/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h +@@ -152,6 +152,8 @@ struct hubp_funcs { + void (*dcc_control)(struct hubp *hubp, bool enable, + enum hubp_ind_block_size blk_size); + ++ void (*hubp_reset)(struct hubp *hubp); ++ + void (*mem_program_viewport)( + struct hubp *hubp, + const struct rect *viewport, diff --git a/queue-6.12/kvm-x86-plumb-in-the-vcpu-to-kvm_x86_ops.hwapic_isr_update.patch b/queue-6.12/kvm-x86-plumb-in-the-vcpu-to-kvm_x86_ops.hwapic_isr_update.patch new file mode 100644 index 0000000000..adfe8ce05b --- /dev/null +++ b/queue-6.12/kvm-x86-plumb-in-the-vcpu-to-kvm_x86_ops.hwapic_isr_update.patch @@ -0,0 +1,108 @@ +From 76bce9f10162cd4b36ac0b7889649b22baf70ebd Mon Sep 17 00:00:00 2001 +From: Sean Christopherson +Date: Wed, 27 Nov 2024 16:00:09 -0800 +Subject: KVM: x86: Plumb in the vCPU to kvm_x86_ops.hwapic_isr_update() + +From: Sean Christopherson + +commit 76bce9f10162cd4b36ac0b7889649b22baf70ebd upstream. + +Pass the target vCPU to the hwapic_isr_update() vendor hook so that VMX +can defer the update until after nested VM-Exit if an EOI for L1's vAPIC +occurs while L2 is active. + +Note, commit d39850f57d21 ("KVM: x86: Drop @vcpu parameter from +kvm_x86_ops.hwapic_isr_update()") removed the parameter with the +justification that doing so "allows for a decent amount of (future) +cleanup in the APIC code", but it's not at all clear what cleanup was +intended, or if it was ever realized. + +No functional change intended. + +Cc: stable@vger.kernel.org +Reviewed-by: Chao Gao +Tested-by: Chao Gao +Link: https://lore.kernel.org/r/20241128000010.4051275-2-seanjc@google.com +Signed-off-by: Sean Christopherson +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/include/asm/kvm_host.h | 2 +- + arch/x86/kvm/lapic.c | 11 +++++------ + arch/x86/kvm/vmx/vmx.c | 2 +- + arch/x86/kvm/vmx/x86_ops.h | 2 +- + 4 files changed, 8 insertions(+), 9 deletions(-) + +--- a/arch/x86/include/asm/kvm_host.h ++++ b/arch/x86/include/asm/kvm_host.h +@@ -1735,7 +1735,7 @@ struct kvm_x86_ops { + bool allow_apicv_in_x2apic_without_x2apic_virtualization; + void (*refresh_apicv_exec_ctrl)(struct kvm_vcpu *vcpu); + void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr); +- void (*hwapic_isr_update)(int isr); ++ void (*hwapic_isr_update)(struct kvm_vcpu *vcpu, int isr); + void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap); + void (*set_virtual_apic_mode)(struct kvm_vcpu *vcpu); + void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu); +--- a/arch/x86/kvm/lapic.c ++++ b/arch/x86/kvm/lapic.c +@@ -763,7 +763,7 @@ static inline void apic_set_isr(int vec, + * just set SVI. + */ + if (unlikely(apic->apicv_active)) +- kvm_x86_call(hwapic_isr_update)(vec); ++ kvm_x86_call(hwapic_isr_update)(apic->vcpu, vec); + else { + ++apic->isr_count; + BUG_ON(apic->isr_count > MAX_APIC_VECTOR); +@@ -808,7 +808,7 @@ static inline void apic_clear_isr(int ve + * and must be left alone. + */ + if (unlikely(apic->apicv_active)) +- kvm_x86_call(hwapic_isr_update)(apic_find_highest_isr(apic)); ++ kvm_x86_call(hwapic_isr_update)(apic->vcpu, apic_find_highest_isr(apic)); + else { + --apic->isr_count; + BUG_ON(apic->isr_count < 0); +@@ -2786,7 +2786,7 @@ void kvm_lapic_reset(struct kvm_vcpu *vc + if (apic->apicv_active) { + kvm_x86_call(apicv_post_state_restore)(vcpu); + kvm_x86_call(hwapic_irr_update)(vcpu, -1); +- kvm_x86_call(hwapic_isr_update)(-1); ++ kvm_x86_call(hwapic_isr_update)(vcpu, -1); + } + + vcpu->arch.apic_arb_prio = 0; +@@ -3102,9 +3102,8 @@ int kvm_apic_set_state(struct kvm_vcpu * + kvm_apic_update_apicv(vcpu); + if (apic->apicv_active) { + kvm_x86_call(apicv_post_state_restore)(vcpu); +- kvm_x86_call(hwapic_irr_update)(vcpu, +- apic_find_highest_irr(apic)); +- kvm_x86_call(hwapic_isr_update)(apic_find_highest_isr(apic)); ++ kvm_x86_call(hwapic_irr_update)(vcpu, apic_find_highest_irr(apic)); ++ kvm_x86_call(hwapic_isr_update)(vcpu, apic_find_highest_isr(apic)); + } + kvm_make_request(KVM_REQ_EVENT, vcpu); + if (ioapic_in_kernel(vcpu->kvm)) +--- a/arch/x86/kvm/vmx/vmx.c ++++ b/arch/x86/kvm/vmx/vmx.c +@@ -6847,7 +6847,7 @@ out: + kvm_release_pfn_clean(pfn); + } + +-void vmx_hwapic_isr_update(int max_isr) ++void vmx_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr) + { + u16 status; + u8 old; +--- a/arch/x86/kvm/vmx/x86_ops.h ++++ b/arch/x86/kvm/vmx/x86_ops.h +@@ -48,7 +48,7 @@ void vmx_migrate_timers(struct kvm_vcpu + void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu); + void vmx_apicv_pre_state_restore(struct kvm_vcpu *vcpu); + void vmx_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr); +-void vmx_hwapic_isr_update(int max_isr); ++void vmx_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr); + int vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu); + void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode, + int trig_mode, int vector); diff --git a/queue-6.12/loongarch-change-8-to-14-for-loongarch_max_-brp-wrp.patch b/queue-6.12/loongarch-change-8-to-14-for-loongarch_max_-brp-wrp.patch new file mode 100644 index 0000000000..82902b5356 --- /dev/null +++ b/queue-6.12/loongarch-change-8-to-14-for-loongarch_max_-brp-wrp.patch @@ -0,0 +1,147 @@ +From f502ea618bf16d615d7dc6138c8988d3118fe750 Mon Sep 17 00:00:00 2001 +From: Tiezhu Yang +Date: Sun, 26 Jan 2025 21:49:59 +0800 +Subject: LoongArch: Change 8 to 14 for LOONGARCH_MAX_{BRP,WRP} + +From: Tiezhu Yang + +commit f502ea618bf16d615d7dc6138c8988d3118fe750 upstream. + +The maximum number of load/store watchpoints and fetch instruction +watchpoints is 14 each according to LoongArch Reference Manual, so +change 8 to 14 for the related code. + +Link: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#control-and-status-registers-related-to-watchpoints +Cc: stable@vger.kernel.org +Fixes: edffa33c7bb5 ("LoongArch: Add hardware breakpoints/watchpoints support") +Reviewed-by: WANG Xuerui +Signed-off-by: Tiezhu Yang +Signed-off-by: Huacai Chen +Signed-off-by: Greg Kroah-Hartman +--- + arch/loongarch/include/asm/hw_breakpoint.h | 4 - + arch/loongarch/include/asm/loongarch.h | 60 +++++++++++++++++++++++++++++ + arch/loongarch/kernel/hw_breakpoint.c | 16 ++++++- + 3 files changed, 76 insertions(+), 4 deletions(-) + +--- a/arch/loongarch/include/asm/hw_breakpoint.h ++++ b/arch/loongarch/include/asm/hw_breakpoint.h +@@ -38,8 +38,8 @@ struct arch_hw_breakpoint { + * Limits. + * Changing these will require modifications to the register accessors. + */ +-#define LOONGARCH_MAX_BRP 8 +-#define LOONGARCH_MAX_WRP 8 ++#define LOONGARCH_MAX_BRP 14 ++#define LOONGARCH_MAX_WRP 14 + + /* Virtual debug register bases. */ + #define CSR_CFG_ADDR 0 +--- a/arch/loongarch/include/asm/loongarch.h ++++ b/arch/loongarch/include/asm/loongarch.h +@@ -959,6 +959,36 @@ + #define LOONGARCH_CSR_DB7CTRL 0x34a /* data breakpoint 7 control */ + #define LOONGARCH_CSR_DB7ASID 0x34b /* data breakpoint 7 asid */ + ++#define LOONGARCH_CSR_DB8ADDR 0x350 /* data breakpoint 8 address */ ++#define LOONGARCH_CSR_DB8MASK 0x351 /* data breakpoint 8 mask */ ++#define LOONGARCH_CSR_DB8CTRL 0x352 /* data breakpoint 8 control */ ++#define LOONGARCH_CSR_DB8ASID 0x353 /* data breakpoint 8 asid */ ++ ++#define LOONGARCH_CSR_DB9ADDR 0x358 /* data breakpoint 9 address */ ++#define LOONGARCH_CSR_DB9MASK 0x359 /* data breakpoint 9 mask */ ++#define LOONGARCH_CSR_DB9CTRL 0x35a /* data breakpoint 9 control */ ++#define LOONGARCH_CSR_DB9ASID 0x35b /* data breakpoint 9 asid */ ++ ++#define LOONGARCH_CSR_DB10ADDR 0x360 /* data breakpoint 10 address */ ++#define LOONGARCH_CSR_DB10MASK 0x361 /* data breakpoint 10 mask */ ++#define LOONGARCH_CSR_DB10CTRL 0x362 /* data breakpoint 10 control */ ++#define LOONGARCH_CSR_DB10ASID 0x363 /* data breakpoint 10 asid */ ++ ++#define LOONGARCH_CSR_DB11ADDR 0x368 /* data breakpoint 11 address */ ++#define LOONGARCH_CSR_DB11MASK 0x369 /* data breakpoint 11 mask */ ++#define LOONGARCH_CSR_DB11CTRL 0x36a /* data breakpoint 11 control */ ++#define LOONGARCH_CSR_DB11ASID 0x36b /* data breakpoint 11 asid */ ++ ++#define LOONGARCH_CSR_DB12ADDR 0x370 /* data breakpoint 12 address */ ++#define LOONGARCH_CSR_DB12MASK 0x371 /* data breakpoint 12 mask */ ++#define LOONGARCH_CSR_DB12CTRL 0x372 /* data breakpoint 12 control */ ++#define LOONGARCH_CSR_DB12ASID 0x373 /* data breakpoint 12 asid */ ++ ++#define LOONGARCH_CSR_DB13ADDR 0x378 /* data breakpoint 13 address */ ++#define LOONGARCH_CSR_DB13MASK 0x379 /* data breakpoint 13 mask */ ++#define LOONGARCH_CSR_DB13CTRL 0x37a /* data breakpoint 13 control */ ++#define LOONGARCH_CSR_DB13ASID 0x37b /* data breakpoint 13 asid */ ++ + #define LOONGARCH_CSR_FWPC 0x380 /* instruction breakpoint config */ + #define LOONGARCH_CSR_FWPS 0x381 /* instruction breakpoint status */ + +@@ -1002,6 +1032,36 @@ + #define LOONGARCH_CSR_IB7CTRL 0x3ca /* inst breakpoint 7 control */ + #define LOONGARCH_CSR_IB7ASID 0x3cb /* inst breakpoint 7 asid */ + ++#define LOONGARCH_CSR_IB8ADDR 0x3d0 /* inst breakpoint 8 address */ ++#define LOONGARCH_CSR_IB8MASK 0x3d1 /* inst breakpoint 8 mask */ ++#define LOONGARCH_CSR_IB8CTRL 0x3d2 /* inst breakpoint 8 control */ ++#define LOONGARCH_CSR_IB8ASID 0x3d3 /* inst breakpoint 8 asid */ ++ ++#define LOONGARCH_CSR_IB9ADDR 0x3d8 /* inst breakpoint 9 address */ ++#define LOONGARCH_CSR_IB9MASK 0x3d9 /* inst breakpoint 9 mask */ ++#define LOONGARCH_CSR_IB9CTRL 0x3da /* inst breakpoint 9 control */ ++#define LOONGARCH_CSR_IB9ASID 0x3db /* inst breakpoint 9 asid */ ++ ++#define LOONGARCH_CSR_IB10ADDR 0x3e0 /* inst breakpoint 10 address */ ++#define LOONGARCH_CSR_IB10MASK 0x3e1 /* inst breakpoint 10 mask */ ++#define LOONGARCH_CSR_IB10CTRL 0x3e2 /* inst breakpoint 10 control */ ++#define LOONGARCH_CSR_IB10ASID 0x3e3 /* inst breakpoint 10 asid */ ++ ++#define LOONGARCH_CSR_IB11ADDR 0x3e8 /* inst breakpoint 11 address */ ++#define LOONGARCH_CSR_IB11MASK 0x3e9 /* inst breakpoint 11 mask */ ++#define LOONGARCH_CSR_IB11CTRL 0x3ea /* inst breakpoint 11 control */ ++#define LOONGARCH_CSR_IB11ASID 0x3eb /* inst breakpoint 11 asid */ ++ ++#define LOONGARCH_CSR_IB12ADDR 0x3f0 /* inst breakpoint 12 address */ ++#define LOONGARCH_CSR_IB12MASK 0x3f1 /* inst breakpoint 12 mask */ ++#define LOONGARCH_CSR_IB12CTRL 0x3f2 /* inst breakpoint 12 control */ ++#define LOONGARCH_CSR_IB12ASID 0x3f3 /* inst breakpoint 12 asid */ ++ ++#define LOONGARCH_CSR_IB13ADDR 0x3f8 /* inst breakpoint 13 address */ ++#define LOONGARCH_CSR_IB13MASK 0x3f9 /* inst breakpoint 13 mask */ ++#define LOONGARCH_CSR_IB13CTRL 0x3fa /* inst breakpoint 13 control */ ++#define LOONGARCH_CSR_IB13ASID 0x3fb /* inst breakpoint 13 asid */ ++ + #define LOONGARCH_CSR_DEBUG 0x500 /* debug config */ + #define LOONGARCH_CSR_DERA 0x501 /* debug era */ + #define LOONGARCH_CSR_DESAVE 0x502 /* debug save */ +--- a/arch/loongarch/kernel/hw_breakpoint.c ++++ b/arch/loongarch/kernel/hw_breakpoint.c +@@ -51,7 +51,13 @@ int hw_breakpoint_slots(int type) + READ_WB_REG_CASE(OFF, 4, REG, T, VAL); \ + READ_WB_REG_CASE(OFF, 5, REG, T, VAL); \ + READ_WB_REG_CASE(OFF, 6, REG, T, VAL); \ +- READ_WB_REG_CASE(OFF, 7, REG, T, VAL); ++ READ_WB_REG_CASE(OFF, 7, REG, T, VAL); \ ++ READ_WB_REG_CASE(OFF, 8, REG, T, VAL); \ ++ READ_WB_REG_CASE(OFF, 9, REG, T, VAL); \ ++ READ_WB_REG_CASE(OFF, 10, REG, T, VAL); \ ++ READ_WB_REG_CASE(OFF, 11, REG, T, VAL); \ ++ READ_WB_REG_CASE(OFF, 12, REG, T, VAL); \ ++ READ_WB_REG_CASE(OFF, 13, REG, T, VAL); + + #define GEN_WRITE_WB_REG_CASES(OFF, REG, T, VAL) \ + WRITE_WB_REG_CASE(OFF, 0, REG, T, VAL); \ +@@ -61,7 +67,13 @@ int hw_breakpoint_slots(int type) + WRITE_WB_REG_CASE(OFF, 4, REG, T, VAL); \ + WRITE_WB_REG_CASE(OFF, 5, REG, T, VAL); \ + WRITE_WB_REG_CASE(OFF, 6, REG, T, VAL); \ +- WRITE_WB_REG_CASE(OFF, 7, REG, T, VAL); ++ WRITE_WB_REG_CASE(OFF, 7, REG, T, VAL); \ ++ WRITE_WB_REG_CASE(OFF, 8, REG, T, VAL); \ ++ WRITE_WB_REG_CASE(OFF, 9, REG, T, VAL); \ ++ WRITE_WB_REG_CASE(OFF, 10, REG, T, VAL); \ ++ WRITE_WB_REG_CASE(OFF, 11, REG, T, VAL); \ ++ WRITE_WB_REG_CASE(OFF, 12, REG, T, VAL); \ ++ WRITE_WB_REG_CASE(OFF, 13, REG, T, VAL); + + static u64 read_wb_reg(int reg, int n, int t) + { diff --git a/queue-6.12/memcg-fix-soft-lockup-in-the-oom-process.patch b/queue-6.12/memcg-fix-soft-lockup-in-the-oom-process.patch new file mode 100644 index 0000000000..7649eb8a5d --- /dev/null +++ b/queue-6.12/memcg-fix-soft-lockup-in-the-oom-process.patch @@ -0,0 +1,121 @@ +From ade81479c7dda1ce3eedb215c78bc615bbd04f06 Mon Sep 17 00:00:00 2001 +From: Chen Ridong +Date: Tue, 24 Dec 2024 02:52:38 +0000 +Subject: memcg: fix soft lockup in the OOM process +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Chen Ridong + +commit ade81479c7dda1ce3eedb215c78bc615bbd04f06 upstream. + +A soft lockup issue was found in the product with about 56,000 tasks were +in the OOM cgroup, it was traversing them when the soft lockup was +triggered. + +watchdog: BUG: soft lockup - CPU#2 stuck for 23s! [VM Thread:1503066] +CPU: 2 PID: 1503066 Comm: VM Thread Kdump: loaded Tainted: G +Hardware name: Huawei Cloud OpenStack Nova, BIOS +RIP: 0010:console_unlock+0x343/0x540 +RSP: 0000:ffffb751447db9a0 EFLAGS: 00000247 ORIG_RAX: ffffffffffffff13 +RAX: 0000000000000001 RBX: 0000000000000000 RCX: 00000000ffffffff +RDX: 0000000000000000 RSI: 0000000000000004 RDI: 0000000000000247 +RBP: ffffffffafc71f90 R08: 0000000000000000 R09: 0000000000000040 +R10: 0000000000000080 R11: 0000000000000000 R12: ffffffffafc74bd0 +R13: ffffffffaf60a220 R14: 0000000000000247 R15: 0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 00007f2fe6ad91f0 CR3: 00000004b2076003 CR4: 0000000000360ee0 +DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 +DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 +Call Trace: + vprintk_emit+0x193/0x280 + printk+0x52/0x6e + dump_task+0x114/0x130 + mem_cgroup_scan_tasks+0x76/0x100 + dump_header+0x1fe/0x210 + oom_kill_process+0xd1/0x100 + out_of_memory+0x125/0x570 + mem_cgroup_out_of_memory+0xb5/0xd0 + try_charge+0x720/0x770 + mem_cgroup_try_charge+0x86/0x180 + mem_cgroup_try_charge_delay+0x1c/0x40 + do_anonymous_page+0xb5/0x390 + handle_mm_fault+0xc4/0x1f0 + +This is because thousands of processes are in the OOM cgroup, it takes a +long time to traverse all of them. As a result, this lead to soft lockup +in the OOM process. + +To fix this issue, call 'cond_resched' in the 'mem_cgroup_scan_tasks' +function per 1000 iterations. For global OOM, call +'touch_softlockup_watchdog' per 1000 iterations to avoid this issue. + +Link: https://lkml.kernel.org/r/20241224025238.3768787-1-chenridong@huaweicloud.com +Fixes: 9cbb78bb3143 ("mm, memcg: introduce own oom handler to iterate only over its own threads") +Signed-off-by: Chen Ridong +Acked-by: Michal Hocko +Cc: Roman Gushchin +Cc: Johannes Weiner +Cc: Shakeel Butt +Cc: Muchun Song +Cc: Michal Koutný +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + mm/memcontrol.c | 7 ++++++- + mm/oom_kill.c | 8 +++++++- + 2 files changed, 13 insertions(+), 2 deletions(-) + +--- a/mm/memcontrol.c ++++ b/mm/memcontrol.c +@@ -1139,6 +1139,7 @@ void mem_cgroup_scan_tasks(struct mem_cg + { + struct mem_cgroup *iter; + int ret = 0; ++ int i = 0; + + BUG_ON(mem_cgroup_is_root(memcg)); + +@@ -1147,8 +1148,12 @@ void mem_cgroup_scan_tasks(struct mem_cg + struct task_struct *task; + + css_task_iter_start(&iter->css, CSS_TASK_ITER_PROCS, &it); +- while (!ret && (task = css_task_iter_next(&it))) ++ while (!ret && (task = css_task_iter_next(&it))) { ++ /* Avoid potential softlockup warning */ ++ if ((++i & 1023) == 0) ++ cond_resched(); + ret = fn(task, arg); ++ } + css_task_iter_end(&it); + if (ret) { + mem_cgroup_iter_break(memcg, iter); +--- a/mm/oom_kill.c ++++ b/mm/oom_kill.c +@@ -45,6 +45,7 @@ + #include + #include + #include ++#include + + #include + #include "internal.h" +@@ -431,10 +432,15 @@ static void dump_tasks(struct oom_contro + mem_cgroup_scan_tasks(oc->memcg, dump_task, oc); + else { + struct task_struct *p; ++ int i = 0; + + rcu_read_lock(); +- for_each_process(p) ++ for_each_process(p) { ++ /* Avoid potential softlockup warning */ ++ if ((++i & 1023) == 0) ++ touch_softlockup_watchdog(); + dump_task(p, oc); ++ } + rcu_read_unlock(); + } + } diff --git a/queue-6.12/s390-add-std-gnu11-to-decompressor-and-purgatory-cflags.patch b/queue-6.12/s390-add-std-gnu11-to-decompressor-and-purgatory-cflags.patch new file mode 100644 index 0000000000..6dc6233383 --- /dev/null +++ b/queue-6.12/s390-add-std-gnu11-to-decompressor-and-purgatory-cflags.patch @@ -0,0 +1,63 @@ +From 3b8b80e993766dc96d1a1c01c62f5d15fafc79b9 Mon Sep 17 00:00:00 2001 +From: Nathan Chancellor +Date: Wed, 22 Jan 2025 19:54:27 -0700 +Subject: s390: Add '-std=gnu11' to decompressor and purgatory CFLAGS + +From: Nathan Chancellor + +commit 3b8b80e993766dc96d1a1c01c62f5d15fafc79b9 upstream. + +GCC changed the default C standard dialect from gnu17 to gnu23, +which should not have impacted the kernel because it explicitly requests +the gnu11 standard in the main Makefile. However, there are certain +places in the s390 code that use their own CFLAGS without a '-std=' +value, which break with this dialect change because of the kernel's own +definitions of bool, false, and true conflicting with the C23 reserved +keywords. + + include/linux/stddef.h:11:9: error: cannot use keyword 'false' as enumeration constant + 11 | false = 0, + | ^~~~~ + include/linux/stddef.h:11:9: note: 'false' is a keyword with '-std=c23' onwards + include/linux/types.h:35:33: error: 'bool' cannot be defined via 'typedef' + 35 | typedef _Bool bool; + | ^~~~ + include/linux/types.h:35:33: note: 'bool' is a keyword with '-std=c23' onwards + +Add '-std=gnu11' to the decompressor and purgatory CFLAGS to eliminate +these errors and make the C standard version of these areas match the +rest of the kernel. + +Cc: stable@vger.kernel.org +Signed-off-by: Nathan Chancellor +Tested-by: Heiko Carstens +Link: https://lore.kernel.org/r/20250122-s390-fix-std-for-gcc-15-v1-1-8b00cadee083@kernel.org +Signed-off-by: Alexander Gordeev +Signed-off-by: Greg Kroah-Hartman +--- + arch/s390/Makefile | 2 +- + arch/s390/purgatory/Makefile | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +--- a/arch/s390/Makefile ++++ b/arch/s390/Makefile +@@ -22,7 +22,7 @@ KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FL + ifndef CONFIG_AS_IS_LLVM + KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) + endif +-KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack ++KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack -std=gnu11 + KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY + KBUILD_CFLAGS_DECOMPRESSOR += -D__DECOMPRESSOR + KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain +--- a/arch/s390/purgatory/Makefile ++++ b/arch/s390/purgatory/Makefile +@@ -13,7 +13,7 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS - + $(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE + $(call if_changed_rule,as_o_S) + +-KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes ++KBUILD_CFLAGS := -std=gnu11 -fno-strict-aliasing -Wall -Wstrict-prototypes + KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare + KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding + KBUILD_CFLAGS += -Os -m64 -msoft-float -fno-common diff --git a/queue-6.12/selftests-bpf-add-test-to-verify-tailcall-and-freplace-restrictions.patch b/queue-6.12/selftests-bpf-add-test-to-verify-tailcall-and-freplace-restrictions.patch new file mode 100644 index 0000000000..481a3bb86a --- /dev/null +++ b/queue-6.12/selftests-bpf-add-test-to-verify-tailcall-and-freplace-restrictions.patch @@ -0,0 +1,232 @@ +From 021611d33e78694f4bd54573093c6fc70a812644 Mon Sep 17 00:00:00 2001 +From: Leon Hwang +Date: Tue, 15 Oct 2024 23:02:07 +0800 +Subject: selftests/bpf: Add test to verify tailcall and freplace restrictions + +From: Leon Hwang + +commit 021611d33e78694f4bd54573093c6fc70a812644 upstream. + +Add a test case to ensure that attaching a tail callee program with an +freplace program fails, and that updating an extended program to a +prog_array map is also prohibited. + +This test is designed to prevent the potential infinite loop issue caused +by the combination of tail calls and freplace, ensuring the correct +behavior and stability of the system. + +Additionally, fix the broken tailcalls/tailcall_freplace selftest +because an extension prog should not be tailcalled. + +cd tools/testing/selftests/bpf; ./test_progs -t tailcalls +337/25 tailcalls/tailcall_freplace:OK +337/26 tailcalls/tailcall_bpf2bpf_freplace:OK +337 tailcalls:OK +Summary: 1/26 PASSED, 0 SKIPPED, 0 FAILED + +Acked-by: Eduard Zingerman +Signed-off-by: Leon Hwang +Link: https://lore.kernel.org/r/20241015150207.70264-3-leon.hwang@linux.dev +Signed-off-by: Alexei Starovoitov +[ Yifei: bpf freplace update is backported to linux-6.12 by commit 987aa730bad3 + ("bpf: Prevent tailcall infinite loop caused by freplace"). It will cause + selftest #336/25 failed. ] +Signed-off-by: Yifei Liu +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/bpf/prog_tests/tailcalls.c | 120 ++++++++++++++++++--- + tools/testing/selftests/bpf/progs/tc_bpf2bpf.c | 5 + 2 files changed, 109 insertions(+), 16 deletions(-) + +--- a/tools/testing/selftests/bpf/prog_tests/tailcalls.c ++++ b/tools/testing/selftests/bpf/prog_tests/tailcalls.c +@@ -1496,8 +1496,8 @@ static void test_tailcall_bpf2bpf_hierar + RUN_TESTS(tailcall_bpf2bpf_hierarchy3); + } + +-/* test_tailcall_freplace checks that the attached freplace prog is OK to +- * update the prog_array map. ++/* test_tailcall_freplace checks that the freplace prog fails to update the ++ * prog_array map, no matter whether the freplace prog attaches to its target. + */ + static void test_tailcall_freplace(void) + { +@@ -1505,7 +1505,7 @@ static void test_tailcall_freplace(void) + struct bpf_link *freplace_link = NULL; + struct bpf_program *freplace_prog; + struct tc_bpf2bpf *tc_skel = NULL; +- int prog_fd, map_fd; ++ int prog_fd, tc_prog_fd, map_fd; + char buff[128] = {}; + int err, key; + +@@ -1523,9 +1523,10 @@ static void test_tailcall_freplace(void) + if (!ASSERT_OK_PTR(tc_skel, "tc_bpf2bpf__open_and_load")) + goto out; + +- prog_fd = bpf_program__fd(tc_skel->progs.entry_tc); ++ tc_prog_fd = bpf_program__fd(tc_skel->progs.entry_tc); + freplace_prog = freplace_skel->progs.entry_freplace; +- err = bpf_program__set_attach_target(freplace_prog, prog_fd, "subprog"); ++ err = bpf_program__set_attach_target(freplace_prog, tc_prog_fd, ++ "subprog_tc"); + if (!ASSERT_OK(err, "set_attach_target")) + goto out; + +@@ -1533,27 +1534,116 @@ static void test_tailcall_freplace(void) + if (!ASSERT_OK(err, "tailcall_freplace__load")) + goto out; + +- freplace_link = bpf_program__attach_freplace(freplace_prog, prog_fd, +- "subprog"); ++ map_fd = bpf_map__fd(freplace_skel->maps.jmp_table); ++ prog_fd = bpf_program__fd(freplace_prog); ++ key = 0; ++ err = bpf_map_update_elem(map_fd, &key, &prog_fd, BPF_ANY); ++ ASSERT_ERR(err, "update jmp_table failure"); ++ ++ freplace_link = bpf_program__attach_freplace(freplace_prog, tc_prog_fd, ++ "subprog_tc"); + if (!ASSERT_OK_PTR(freplace_link, "attach_freplace")) + goto out; + +- map_fd = bpf_map__fd(freplace_skel->maps.jmp_table); +- prog_fd = bpf_program__fd(freplace_prog); ++ err = bpf_map_update_elem(map_fd, &key, &prog_fd, BPF_ANY); ++ ASSERT_ERR(err, "update jmp_table failure"); ++ ++out: ++ bpf_link__destroy(freplace_link); ++ tailcall_freplace__destroy(freplace_skel); ++ tc_bpf2bpf__destroy(tc_skel); ++} ++ ++/* test_tailcall_bpf2bpf_freplace checks the failure that fails to attach a tail ++ * callee prog with freplace prog or fails to update an extended prog to ++ * prog_array map. ++ */ ++static void test_tailcall_bpf2bpf_freplace(void) ++{ ++ struct tailcall_freplace *freplace_skel = NULL; ++ struct bpf_link *freplace_link = NULL; ++ struct tc_bpf2bpf *tc_skel = NULL; ++ char buff[128] = {}; ++ int prog_fd, map_fd; ++ int err, key; ++ ++ LIBBPF_OPTS(bpf_test_run_opts, topts, ++ .data_in = buff, ++ .data_size_in = sizeof(buff), ++ .repeat = 1, ++ ); ++ ++ tc_skel = tc_bpf2bpf__open_and_load(); ++ if (!ASSERT_OK_PTR(tc_skel, "tc_bpf2bpf__open_and_load")) ++ goto out; ++ ++ prog_fd = bpf_program__fd(tc_skel->progs.entry_tc); ++ freplace_skel = tailcall_freplace__open(); ++ if (!ASSERT_OK_PTR(freplace_skel, "tailcall_freplace__open")) ++ goto out; ++ ++ err = bpf_program__set_attach_target(freplace_skel->progs.entry_freplace, ++ prog_fd, "subprog_tc"); ++ if (!ASSERT_OK(err, "set_attach_target")) ++ goto out; ++ ++ err = tailcall_freplace__load(freplace_skel); ++ if (!ASSERT_OK(err, "tailcall_freplace__load")) ++ goto out; ++ ++ /* OK to attach then detach freplace prog. */ ++ ++ freplace_link = bpf_program__attach_freplace(freplace_skel->progs.entry_freplace, ++ prog_fd, "subprog_tc"); ++ if (!ASSERT_OK_PTR(freplace_link, "attach_freplace")) ++ goto out; ++ ++ err = bpf_link__destroy(freplace_link); ++ if (!ASSERT_OK(err, "destroy link")) ++ goto out; ++ ++ /* OK to update prog_array map then delete element from the map. */ ++ + key = 0; ++ map_fd = bpf_map__fd(freplace_skel->maps.jmp_table); + err = bpf_map_update_elem(map_fd, &key, &prog_fd, BPF_ANY); + if (!ASSERT_OK(err, "update jmp_table")) + goto out; + +- prog_fd = bpf_program__fd(tc_skel->progs.entry_tc); +- err = bpf_prog_test_run_opts(prog_fd, &topts); +- ASSERT_OK(err, "test_run"); +- ASSERT_EQ(topts.retval, 34, "test_run retval"); ++ err = bpf_map_delete_elem(map_fd, &key); ++ if (!ASSERT_OK(err, "delete_elem from jmp_table")) ++ goto out; ++ ++ /* Fail to attach a tail callee prog with freplace prog. */ ++ ++ err = bpf_map_update_elem(map_fd, &key, &prog_fd, BPF_ANY); ++ if (!ASSERT_OK(err, "update jmp_table")) ++ goto out; ++ ++ freplace_link = bpf_program__attach_freplace(freplace_skel->progs.entry_freplace, ++ prog_fd, "subprog_tc"); ++ if (!ASSERT_ERR_PTR(freplace_link, "attach_freplace failure")) ++ goto out; ++ ++ err = bpf_map_delete_elem(map_fd, &key); ++ if (!ASSERT_OK(err, "delete_elem from jmp_table")) ++ goto out; ++ ++ /* Fail to update an extended prog to prog_array map. */ ++ ++ freplace_link = bpf_program__attach_freplace(freplace_skel->progs.entry_freplace, ++ prog_fd, "subprog_tc"); ++ if (!ASSERT_OK_PTR(freplace_link, "attach_freplace")) ++ goto out; ++ ++ err = bpf_map_update_elem(map_fd, &key, &prog_fd, BPF_ANY); ++ if (!ASSERT_ERR(err, "update jmp_table failure")) ++ goto out; + + out: + bpf_link__destroy(freplace_link); +- tc_bpf2bpf__destroy(tc_skel); + tailcall_freplace__destroy(freplace_skel); ++ tc_bpf2bpf__destroy(tc_skel); + } + + void test_tailcalls(void) +@@ -1606,4 +1696,6 @@ void test_tailcalls(void) + test_tailcall_bpf2bpf_hierarchy_3(); + if (test__start_subtest("tailcall_freplace")) + test_tailcall_freplace(); ++ if (test__start_subtest("tailcall_bpf2bpf_freplace")) ++ test_tailcall_bpf2bpf_freplace(); + } +--- a/tools/testing/selftests/bpf/progs/tc_bpf2bpf.c ++++ b/tools/testing/selftests/bpf/progs/tc_bpf2bpf.c +@@ -5,10 +5,11 @@ + #include "bpf_misc.h" + + __noinline +-int subprog(struct __sk_buff *skb) ++int subprog_tc(struct __sk_buff *skb) + { + int ret = 1; + ++ __sink(skb); + __sink(ret); + /* let verifier know that 'subprog_tc' can change pointers to skb->data */ + bpf_skb_change_proto(skb, 0, 0); +@@ -18,7 +19,7 @@ int subprog(struct __sk_buff *skb) + SEC("tc") + int entry_tc(struct __sk_buff *skb) + { +- return subprog(skb); ++ return subprog_tc(skb); + } + + char __license[] SEC("license") = "GPL"; diff --git a/queue-6.12/selftests-mm-build-with-o2.patch b/queue-6.12/selftests-mm-build-with-o2.patch new file mode 100644 index 0000000000..2f50681dbc --- /dev/null +++ b/queue-6.12/selftests-mm-build-with-o2.patch @@ -0,0 +1,57 @@ +From 46036188ea1f5266df23a6149dea0df1c77cd1c7 Mon Sep 17 00:00:00 2001 +From: Kevin Brodsky +Date: Mon, 9 Dec 2024 09:50:10 +0000 +Subject: selftests/mm: build with -O2 + +From: Kevin Brodsky + +commit 46036188ea1f5266df23a6149dea0df1c77cd1c7 upstream. + +The mm kselftests are currently built with no optimisation (-O0). It's +unclear why, and besides being obviously suboptimal, this also prevents +the pkeys tests from working as intended. Let's build all the tests with +-O2. + +[kevin.brodsky@arm.com: silence unused-result warnings] + Link: https://lkml.kernel.org/r/20250107170110.2819685-1-kevin.brodsky@arm.com +Link: https://lkml.kernel.org/r/20241209095019.1732120-6-kevin.brodsky@arm.com +Signed-off-by: Kevin Brodsky +Cc: Aruna Ramakrishna +Cc: Catalin Marinas +Cc: Dave Hansen +Cc: Joey Gouly +Cc: Keith Lucas +Cc: Ryan Roberts +Cc: Shuah Khan +Signed-off-by: Andrew Morton +Signed-off-by: Yifei Liu +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/mm/Makefile | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile +index f2db43c64f83..0d5d8f2f8652 100644 +--- a/tools/testing/selftests/mm/Makefile ++++ b/tools/testing/selftests/mm/Makefile +@@ -33,9 +33,16 @@ endif + # LDLIBS. + MAKEFLAGS += --no-builtin-rules + +-CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES) ++CFLAGS = -Wall -O2 -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES) + LDLIBS = -lrt -lpthread -lm + ++# Some distributions (such as Ubuntu) configure GCC so that _FORTIFY_SOURCE is ++# automatically enabled at -O1 or above. This triggers various unused-result ++# warnings where functions such as read() or write() are called and their ++# return value is not checked. Disable _FORTIFY_SOURCE to silence those ++# warnings. ++CFLAGS += -U_FORTIFY_SOURCE ++ + KDIR ?= /lib/modules/$(shell uname -r)/build + ifneq (,$(wildcard $(KDIR)/Module.symvers)) + ifneq (,$(wildcard $(KDIR)/include/linux/page_frag_cache.h)) +-- +2.48.1 + diff --git a/queue-6.12/series b/queue-6.12/series index 2a9520a4c5..cc160edcf2 100644 --- a/queue-6.12/series +++ b/queue-6.12/series @@ -580,3 +580,12 @@ xfrm-fix-acquire-state-insertion.patch ethtool-fix-access-to-uninitialized-fields-in-set-rxnfc-command.patch phy-freescale-fsl-samsung-hdmi-fix-64-by-32-division-cocci-warnings.patch revert-s390-mm-allow-large-pages-for-kasan-shadow-mapping.patch +selftests-bpf-add-test-to-verify-tailcall-and-freplace-restrictions.patch +asoc-da7213-initialize-the-mutex.patch +s390-add-std-gnu11-to-decompressor-and-purgatory-cflags.patch +drm-amd-display-add-hubp-cache-reset-when-powergating.patch +kvm-x86-plumb-in-the-vcpu-to-kvm_x86_ops.hwapic_isr_update.patch +memcg-fix-soft-lockup-in-the-oom-process.patch +loongarch-change-8-to-14-for-loongarch_max_-brp-wrp.patch +btrfs-do-proper-folio-cleanup-when-run_delalloc_nocow-failed.patch +selftests-mm-build-with-o2.patch