6.16.2-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 446/570 ipmi: Use dev_warn_ratelimited() for incorrect message warnings
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit ec50ec378e3fd83bde9b3d622ceac3509a60b6b5 ]
During BMC firmware upgrades on live systems, the ipmi_msghandler generates excessive "BMC returned incorrect response" warnings while the BMC is temporarily offline. This can flood system logs in large deployments.
Replace dev_warn() with dev_warn_ratelimited() to throttle these warnings and prevent log spam during BMC maintenance operations.
Message-ID: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +4 -4
@@ -4607,10 +4607,10 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,* The NetFN and Command in the response is not even * marginally correct. */ -dev_warn (intf->si_dev, -"BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n" , - (msg->data[0 ] >>2 ) |1 , msg->data[1 ], - msg->rsp[0 ] >>2 , msg->rsp[1 ]); +dev_warn_ratelimited (intf->si_dev, +"BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n" , + (msg->data[0 ] >>2 ) |1 , msg->data[1 ], + msg->rsp[0 ] >>2 , msg->rsp[1 ]); goto return_unspecified; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 447/570 kconfig: gconf: avoid hardcoding model2 in on_treeview2_cursor_changed()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit cae9cdbcd9af044810bcceeb43a87accca47c71d ]
The on_treeview2_cursor_changed() handler is connected to both the left and right tree views, but it hardcodes model2 (the GtkTreeModel of the right tree view). This is incorrect. Get the associated model from the view.
--- scripts/kconfig/gconf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/kconfig/gconf.c +3 -2
@@ -942,13 +942,14 @@ on_treeview2_key_press_event(GtkWidget * widget,void on_treeview2_cursor_changed (GtkTreeView * treeview,gpointer user_data) { +GtkTreeModel *model =gtk_tree_view_get_model (treeview);GtkTreeSelection *selection;GtkTreeIter iter;struct menu *menu; selection =gtk_tree_view_get_selection (treeview); -if (gtk_tree_selection_get_selected (selection, &model2, &iter)) { -gtk_tree_model_get (model2, &iter,COL_MENU , &menu,-1 ); +if (gtk_tree_selection_get_selected (selection, &model, &iter)) { +gtk_tree_model_get (model, &iter,COL_MENU , &menu,-1 );text_insert_help (menu); } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 448/570 kconfig: gconf: fix potential memory leak in renderer_edited()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit f72ed4c6a375e52a3f4b75615e4a89d29d8acea7 ]
If gtk_tree_model_get_iter() fails, gtk_tree_path_free() is not called.
--- scripts/kconfig/gconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/kconfig/gconf.c +2 -1
@@ -748,7 +748,7 @@ static void renderer_edited(GtkCellRendererText * cell,struct symbol *sym;if (!gtk_tree_model_get_iter (model2, &iter, path)) -return ; + goto free;gtk_tree_model_get (model2, &iter,COL_MENU , &menu,-1 ); sym = menu->sym;
@@ -760,6 +760,7 @@ static void renderer_edited(GtkCellRendererText * cell,update_tree (&rootmenu,NULL ); +free:gtk_tree_path_free (path); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 449/570 kheaders: rebuild kheaders_data.tar.xz when a file is modified within a minute
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit 626c54af35764b0b8a4ed5c446458ba6ddfe9cc8 ]
When a header file is changed, kernel/gen_kheaders.sh may fail to update kernel/kheaders_data.tar.xz.
[steps to reproduce]
[1] Build kernel/kheaders_data.tar.xz
$ make -j$(nproc) kernel/kheaders.o
DESCEND objtool
INSTALL libsubcmd_headers
CALL scripts/checksyscalls.sh
CHK kernel/kheaders_data.tar.xz
GEN kernel/kheaders_data.tar.xz
CC kernel/kheaders.o[2] Modify a header without changing the file size
$ sed -i s/0xdeadbeef/0xfeedbeef/ include/linux/elfnote.h
[3] Rebuild kernel/kheaders_data.tar.xz
$ make -j$(nproc) kernel/kheaders.o
DESCEND objtool
INSTALL libsubcmd_headers
CALL scripts/checksyscalls.sh
CHK kernel/kheaders_data.tar.xzkernel/kheaders_data.tar.xz is not updated if steps [1] - [3] are run within the same minute.
The headers_md5 variable stores the MD5 hash of the 'ls -l' output for all header files. This hash value is used to determine whether kheaders_data.tar.xz needs to be rebuilt. However, 'ls -l' prints the modification times with minute-level granularity. If a file is modified within the same minute and its size remains the same, the MD5 hash does not change.
To reliably detect file modifications, this commit rewrites kernel/gen_kheaders.sh to output header dependencies to kernel/.kheaders_data.tar.xz.cmd. Then, Make compares the timestamps and reruns kernel/gen_kheaders.sh when necessary. This is the standard mechanism used by Make and Kbuild.
--- kernel/.gitignore | 2 + kernel/Makefile | 47 ++++++++++++++++++--- kernel/gen_kheaders.sh | 94 ++++++++++-------------------------------- 3 files changed, 66 insertions(+), 77 deletions(-)
kernel/.gitignore +2 -0
@@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only /config_data /kheaders.md5 +/kheaders-objlist +/kheaders-srclist
kernel/Makefile +42 -5
53 lines not on this page · raw message
kernel/gen_kheaders.sh +22 -72
109 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 450/570 kconfig: lxdialog: fix space to (de)select options
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yann E. MORIN <[email protected]>
[ Upstream commit 694174f94ebeeb5ec5cc0e9de9b40c82057e1d95 ]
In case a menu has comment without letters/numbers (eg. characters matching the regexp '^[^[:alpha:][:digit:]]+$', for example - or *), hitting space will cycle through those comments, rather than selecting/deselecting the currently-highlighted option.
This is the behaviour of hitting any letter/digit: jump to the next option which prompt starts with that letter. The only letters that do not behave as such are 'y' 'm' and 'n'. Prompts that start with one of those three letters are instead matched on the first letter that is not 'y', 'm' or 'n'.
Fix that by treating 'space' as we treat y/m/n, ie. as an action key, not as shortcut to jump to prompt.
--- scripts/kconfig/lxdialog/menubox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/lxdialog/menubox.c +1 -1
@@ -264,7 +264,7 @@ int dialog_menu(const char *title, const char *prompt,if (key <256 &&isalpha (key)) key =tolower (key); -if (strchr ("ynmh" , key)) +if (strchr ("ynmh " , key)) i = max_choice;else {for (i = choice +1 ; i < max_choice; i++) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 451/570 ipmi: Fix strcpy source and destination the same
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corey Minyard <[email protected]>
[ Upstream commit 8ffcb7560b4a15faf821df95e3ab532b2b020f8c ]
The source and destination of some strcpy operations was the same. Split out the part of the operations that needed to be done for those particular calls so the unnecessary copy wasn't done.
--- drivers/char/ipmi/ipmi_watchdog.c | 59 ++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 17 deletions(-)
drivers/char/ipmi/ipmi_watchdog.c +42 -17
@@ -1146,14 +1146,8 @@ static struct ipmi_smi_watcher smi_watcher = { .smi_gone = ipmi_smi_gone }; -static int action_op (const char *inval,char *outval) +static int action_op_set_val (const char *inval) { -if (outval) -strcpy (outval, action); - -if (!inval) -return 0 ; -if (strcmp (inval,"reset" ) ==0 ) action_val =WDOG_TIMEOUT_RESET ;else if (strcmp (inval,"none" ) ==0 )
@@ -1164,18 +1158,26 @@ static int action_op(const char *inval, char *outval) action_val =WDOG_TIMEOUT_POWER_DOWN ; else return -EINVAL; -strcpy (action, inval);return 0 ; } -static int preaction_op (const char *inval,char *outval) +static int action_op (const char *inval,char *outval) { +int rv; +if (outval) -strcpy (outval, preaction); +strcpy (outval, action);if (!inval)return 0 ; + rv =action_op_set_val (inval); +if (!rv) +strcpy (action, inval); +return rv; +} +static int preaction_op_set_val (const char *inval) +{if (strcmp (inval,"pre_none" ) ==0 ) preaction_val =WDOG_PRETIMEOUT_NONE ;else if (strcmp (inval,"pre_smi" ) ==0 )
@@ -1188,18 +1190,26 @@ static int preaction_op(const char *inval, char *outval) preaction_val =WDOG_PRETIMEOUT_MSG_INT ; else return -EINVAL; -strcpy (preaction, inval);return 0 ; } -static int preop_op (const char *inval,char *outval) +static int preaction_op (const char *inval,char *outval) { +int rv; +if (outval) -strcpy (outval, preop); +strcpy (outval, preaction);if (!inval)return 0 ; + rv =preaction_op_set_val (inval); +if (!rv) +strcpy (preaction, inval); +return 0 ; +} +static int preop_op_set_val (const char *inval) +{if (strcmp (inval,"preop_none" ) ==0 ) preop_val =WDOG_PREOP_NONE ;else if (strcmp (inval,"preop_panic" ) ==0 )
@@ -1208,7 +1218,22 @@ static int preop_op(const char *inval, char *outval) preop_val =WDOG_PREOP_GIVE_DATA ; else return -EINVAL; -strcpy (preop, inval); +return 0 ; +} + +static int preop_op (const char *inval,char *outval) +{ +int rv; + +if (outval) +strcpy (outval, preop); + +if (!inval) +return 0 ; + + rv =preop_op_set_val (inval); +if (!rv) +strcpy (preop, inval);return 0 ; }
@@ -1245,18 +1270,18 @@ static int __init ipmi_wdog_init(void) {int rv; -if (action_op (action,NULL )) { +if (action_op_set_val (action)) {action_op ("reset" ,NULL );pr_info ("Unknown action '%s', defaulting to reset\n" , action); } -if (preaction_op (preaction,NULL )) { +if (preaction_op_set_val (preaction)) {preaction_op ("pre_none" ,NULL );pr_info ("Unknown preaction '%s', defaulting to none\n" , preaction); } -if (preop_op (preop,NULL )) { +if (preop_op_set_val (preop)) {preop_op ("preop_none" ,NULL );pr_info ("Unknown preop '%s', defaulting to none\n" , preop); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 452/570 tools/power turbostat: Handle non-root legacy-uncore sysfs permissions
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit e60a13bcef206795d3ddf82f130fe8f570176d06 ]
/sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/ may be readable by all, but /sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/current_freq_khz may be readable only by root.
Non-root turbostat users see complaints in this scenario.
Fail probe of the interface if we can't read current_freq_khz.
--- tools/power/x86/turbostat/turbostat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +2 -1
@@ -6740,7 +6740,8 @@ static void probe_intel_uncore_frequency_legacy(void)sprintf (path_base,"/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d" , i, j); -if (access (path_base,R_OK )) +sprintf (path,"%s/current_freq_khz" , path_base); +if (access (path,R_OK ))continue ;BIC_PRESENT (BIC_UNCORE_MHZ );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 453/570 tools/power turbostat: Fix build with musl
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Calvin Owens <[email protected]>
[ Upstream commit 6ea0ec1b958a84aff9f03fb0ae4613a4d5bed3ea ]
turbostat.c: In function 'parse_int_file':
turbostat.c:5567:19: error: 'PATH_MAX' undeclared (first use in this function)
5567 | char path[PATH_MAX];
| ^~~~~~~~
turbostat.c: In function 'probe_graphics':
turbostat.c:6787:19: error: 'PATH_MAX' undeclared (first use in this function)
6787 | char path[PATH_MAX];
| ^~~~~~~~--- tools/power/x86/turbostat/turbostat.c | 1 + 1 file changed, 1 insertion(+)
tools/power/x86/turbostat/turbostat.c +1 -0
@@ -67,6 +67,7 @@#include <stdbool.h> #include <assert.h> #include <linux/kernel.h> +#include <limits.h> #define UNUSED (x) (void)(x)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 454/570 tools/power turbostat: Handle cap_get_proc() ENOSYS
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Calvin Owens <[email protected]>
[ Upstream commit d34fe509f5f76d9dc36291242d67c6528027ebbd ]
Kernels configured with CONFIG_MULTIUSER=n have no cap_get_proc(). Check for ENOSYS to recognize this case, and continue on to attempt to access the requested MSRs (such as temperature).
--- tools/power/x86/turbostat/turbostat.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +9 -1
@@ -6573,8 +6573,16 @@ int check_for_cap_sys_rawio(void)int ret =0 ; caps =cap_get_proc (); -if (caps ==NULL ) +if (caps ==NULL ) { +/* +* CONFIG_MULTIUSER=n kernels have no cap_get_proc() +* Allow them to continue and attempt to access MSRs +*/ +if (errno ==ENOSYS ) +return 0 ; +return 1 ; + }if (cap_get_flag (caps,CAP_SYS_RAWIO ,CAP_EFFECTIVE , &cap_flag_value)) { ret =1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 455/570 smb: client: dont call init_waitqueue_head(&info->conn_wait) twice in _smbd_get_connection
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <[email protected]>
[ Upstream commit 550a194c5998e4e77affc6235e80d3766dc2d27e ]
It is already called long before we may hit this cleanup code path.
--- fs/smb/client/smbdirect.c | 1 - 1 file changed, 1 deletion(-)
fs/smb/client/smbdirect.c +0 -1
@@ -1689,7 +1689,6 @@ static struct smbd_connection *_smbd_get_connection(cancel_delayed_work_sync (&info->idle_timer_work);destroy_caches_and_workqueue (info); sc->status =SMBDIRECT_SOCKET_NEGOTIATE_FAILED ; -init_waitqueue_head (&info->conn_wait);rdma_disconnect (sc->rdma.cm_id);wait_event (info->conn_wait, sc->status ==SMBDIRECT_SOCKET_DISCONNECTED );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 456/570 lib/sbitmap: convert shallow_depth from one word to the whole sbitmap
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit 42e6c6ce03fd3e41e39a0f93f9b1a1d9fa664338 ]
Currently elevators will record internal 'async_depth' to throttle asynchronous requests, and they both calculate shallow_dpeth based on sb->shift, with the respect that sb->shift is the available tags in one word.
However, sb->shift is not the availbale tags in the last word, see __map_depth:
if (index == sb->map_nr - 1)
return sb->depth - (index << sb->shift);
For consequence, if the last word is used, more tags can be get than expected, for example, assume nr_requests=256 and there are four words, in the worst case if user set nr_requests=32, then the first word is the last word, and still use bits per word, which is 64, to calculate async_depth is wrong.
One the ohter hand, due to cgroup qos, bfq can allow only one request to be allocated, and set shallow_dpeth=1 will still allow the number of words request to be allocated.
Fix this problems by using shallow_depth to the whole sbitmap instead of per word, also change kyber, mq-deadline and bfq to follow this, a new helper __map_depth_with_shallow() is introduced to calculate available bits in each word.
--- block/bfq-iosched.c | 35 ++++++++++++-------------- block/bfq-iosched.h | 3 +-- block/kyber-iosched.c | 9 ++----- block/mq-deadline.c | 16 +----------- include/linux/sbitmap.h | 6 ++--- lib/sbitmap.c | 56 +++++++++++++++++++++-------------------- 6 files changed, 52 insertions(+), 73 deletions(-)
block/bfq-iosched.c +16 -19
@@ -701,17 +701,13 @@ static void bfq_limit_depth(blk_opf_t opf, struct blk_mq_alloc_data *data) {struct bfq_data *bfqd = data->q->elevator->elevator_data;struct bfq_io_cq *bic =bfq_bic_lookup (data->q); -int depth; -unsigned limit = data->q->nr_requests; -unsigned int act_idx; +unsigned int limit, act_idx;/* Sync reads have full depth available */ -if (op_is_sync (opf) && !op_is_write (opf)) { - depth =0 ; - }else { - depth = bfqd->word_depths[!!bfqd->wr_busy_queues][op_is_sync (opf)]; - limit = (limit * depth) >> bfqd->full_depth_shift; - } +if (op_is_sync (opf) && !op_is_write (opf)) + limit = data->q->nr_requests; +else + limit = bfqd->async_depths[!!bfqd->wr_busy_queues][op_is_sync (opf)];for (act_idx =0 ; bic && act_idx < bfqd->num_actuators; act_idx++) {/* Fast path to check if bfqq is already allocated. */
@@ -725,14 +721,16 @@ static void bfq_limit_depth(blk_opf_t opf, struct blk_mq_alloc_data *data)* available requests and thus starve other entities. */ if (bfqq_request_over_limit (bfqd, bic, opf, act_idx, limit)) { - depth =1 ; + limit =1 ;break ; } } +bfq_log (bfqd,"[%s] wr_busy %d sync %d depth %u" , - __func__, bfqd->wr_busy_queues,op_is_sync (opf), depth); -if (depth) - data->shallow_depth = depth; + __func__, bfqd->wr_busy_queues,op_is_sync (opf), limit); + +if (limit < data->q->nr_requests) + data->shallow_depth = limit; } static struct bfq_queue *
@@ -7128,9 +7126,8 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg)*/ static void bfq_update_depths (struct bfq_data *bfqd,struct sbitmap_queue *bt) { -unsigned int depth =1U << bt->sb.shift; +unsigned int nr_requests = bfqd->queue->nr_requests; - bfqd->full_depth_shift = bt->sb.shift;/* * In-word depths if no bfq_queue is being weight-raised: * leaving 25% of tags only for sync reads.
@@ -7142,13 +7139,13 @@ static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)* limit 'something'. */ /* no more than 50% of tags for async I/O */ - bfqd->word_depths[0 ][0 ] =max (depth >>1 ,1U ); + bfqd->async_depths[0 ][0 ] =max (nr_requests >>1 ,1U );/* * no more than 75% of tags for sync writes (25% extra tags * w.r.t. async I/O, to prevent async I/O from starving sync * writes) */ - bfqd->word_depths[0 ][1 ] =max ((depth *3 ) >>2 ,1U ); + bfqd->async_depths[0 ][1 ] =max ((nr_requests *3 ) >>2 ,1U );/* * In-word depths in case some bfq_queue is being weight-
@@ -7158,9 +7155,9 @@ static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)* shortage. */ /* no more than ~18% of tags for async I/O */ - bfqd->word_depths[1 ][0 ] =max ((depth *3 ) >>4 ,1U ); + bfqd->async_depths[1 ][0 ] =max ((nr_requests *3 ) >>4 ,1U );/* no more than ~37% of tags for sync writes (~20% extra tags) */ - bfqd->word_depths[1 ][1 ] =max ((depth *6 ) >>4 ,1U ); + bfqd->async_depths[1 ][1 ] =max ((nr_requests *6 ) >>4 ,1U ); }static void bfq_depth_updated (struct blk_mq_hw_ctx *hctx)
block/bfq-iosched.h +1 -2
@@ -813,8 +813,7 @@ struct bfq_data {* Depth limits used in bfq_limit_depth (see comments on the * function) */ -unsigned int word_depths[2 ][2 ]; -unsigned int full_depth_shift; +unsigned int async_depths[2 ][2 ];/* * Number of independent actuators. This is equal to 1 in
block/kyber-iosched.c +2 -7
@@ -157,10 +157,7 @@ struct kyber_queue_data {*/ struct sbitmap_queue domain_tokens[KYBER_NUM_DOMAINS ]; -/* -* Async request percentage, converted to per-word depth for -* sbitmap_get_shallow(). -*/ +/* Number of allowed async requests. */ unsigned int async_depth;struct kyber_cpu_latency __percpu *cpu_latency;
@@ -454,10 +451,8 @@ static void kyber_depth_updated(struct blk_mq_hw_ctx *hctx) {struct kyber_queue_data *kqd = hctx->queue->elevator->elevator_data;struct blk_mq_tags *tags = hctx->sched_tags; -unsigned int shift = tags->bitmap_tags.sb.shift; - - kqd->async_depth = (1U << shift) *KYBER_ASYNC_PERCENT /100U ; + kqd->async_depth = hctx->queue->nr_requests *KYBER_ASYNC_PERCENT /100U ;sbitmap_queue_min_shallow_depth (&tags->bitmap_tags, kqd->async_depth); }
block/mq-deadline.c +1 -15
@@ -487,20 +487,6 @@ static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)return rq; } -/* -* 'depth' is a number in the range 1..INT_MAX representing a number of -* requests. Scale it with a factor (1 << bt->sb.shift) / q->nr_requests since -* 1..(1 << bt->sb.shift) is the range expected by sbitmap_get_shallow(). -* Values larger than q->nr_requests have the same effect as q->nr_requests. -*/ -static int dd_to_word_depth (struct blk_mq_hw_ctx *hctx,unsigned int qdepth) -{ -struct sbitmap_queue *bt = &hctx->sched_tags->bitmap_tags; -const unsigned int nrr = hctx->queue->nr_requests; - -return ((qdepth << bt->sb.shift) + nrr -1 ) / nrr; -} -/* * Called by __blk_mq_alloc_request(). The shallow_depth value set by this * function is used by __blk_mq_get_tag().
@@ -517,7 +503,7 @@ static void dd_limit_depth(blk_opf_t opf, struct blk_mq_alloc_data *data)* Throttle asynchronous requests and writes such that these requests * do not block the allocation of synchronous requests. */ - data->shallow_depth =dd_to_word_depth (data->hctx, dd->async_depth); + data->shallow_depth = dd->async_depth; }/* Called by blk_mq_update_nr_requests(). */
include/linux/sbitmap.h +3 -3
@@ -213,12 +213,12 @@ int sbitmap_get(struct sbitmap *sb);* sbitmap_get_shallow() - Try to allocate a free bit from a &struct sbitmap, * limiting the depth used from each word. * @sb: Bitmap to allocate from. -* @shallow_depth: The maximum number of bits to allocate from a single word. +* @shallow_depth: The maximum number of bits to allocate from the bitmap. * * This rather specific operation allows for having multiple users with * different allocation limits. E.g., there can be a high-priority class that * uses sbitmap_get() and a low-priority class that uses sbitmap_get_shallow() -* with a @shallow_depth of (1 << (@sb->shift - 1)). Then, the low-priority +* with a @shallow_depth of (sb->depth >> 1). Then, the low-priority * class can only allocate half of the total bits in the bitmap, preventing it * from starving out the high-priority class. *
@@ -478,7 +478,7 @@ unsigned long __sbitmap_queue_get_batch(struct sbitmap_queue *sbq, int nr_tags,* sbitmap_queue, limiting the depth used from each word, with preemption * already disabled. * @sbq: Bitmap queue to allocate from. -* @shallow_depth: The maximum number of bits to allocate from a single word. +* @shallow_depth: The maximum number of bits to allocate from the queue. * See sbitmap_get_shallow(). * * If you call this, make sure to call sbitmap_queue_min_shallow_depth() after
lib/sbitmap.c +29 -27
76 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 457/570 irqchip/mvebu-gicp: Clear pending interrupts on init
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Elad Nachman <[email protected]>
[ Upstream commit 3c3d7dbab2c70a4bca47634d564bf659351c05ca ]
When a kexec'ed kernel boots up, there might be stale unhandled interrupts pending in the interrupt controller. These are delivered as spurious interrupts once the boot CPU enables interrupts.
Clear all pending interrupts when the driver is initialized to prevent these spurious interrupts from locking the CPU in an endless loop.
--- drivers/irqchip/irq-mvebu-gicp.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/irqchip/irq-mvebu-gicp.c +10 -0
@@ -177,6 +177,7 @@ static int mvebu_gicp_probe(struct platform_device *pdev) .ops = &gicp_domain_ops, };struct mvebu_gicp *gicp; +void __iomem *base;int ret, i; gicp =devm_kzalloc (&pdev->dev,sizeof (*gicp),GFP_KERNEL );
@@ -236,6 +237,15 @@ static int mvebu_gicp_probe(struct platform_device *pdev)return -ENODEV ; } + base =ioremap (gicp->res->start, gicp->res->end - gicp->res->start); +if (IS_ERR (base)) { +dev_err (&pdev->dev,"ioremap() failed. Unable to clear pending interrupts.\n" ); + }else { +for (i =0 ; i <64 ; i++) +writel (i, base +GICP_CLRSPI_NSR_OFFSET ); +iounmap (base); + } +return msi_create_parent_irq_domain (&info, &gicp_msi_parent_ops) ?0 : -ENOMEM ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 458/570 ALSA: hda/realtek: add LG gram 16Z90R-A to alc269 fixup table
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Croft <[email protected]>
[ Upstream commit dbe05428c4e54068a86e7e02405f3b30b1d2b3dd ]
Several months ago, Joshua Grisham submitted a patch [1] for several ALC298 based sound cards.
The entry for the LG gram 16 in the alc269_fixup_tbl only matches the Subsystem ID for the 16Z90R-Q and 16Z90R-K models [2]. My 16Z90R-A has a different Subsystem ID [3]. I'm not sure why these IDs differ, but I speculate it's due to the NVIDIA GPU included in the 16Z90R-A model that isn't present in the other models.
I applied the patch to the latest Arch Linux kernel and the card was initialized as expected.
[1]: https://lore.kernel.org/linux-sound/[email protected]/
[2]: https://linux-hardware.org/?id=pci:8086-51ca-1854-0488
[3]: https://linux-hardware.org/?id=pci:8086-51ca-1854-0489
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -11401,6 +11401,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1854 ,0x0440 ,"LG CQ6" ,ALC256_FIXUP_HEADPHONE_AMP_VOL ),SND_PCI_QUIRK (0x1854 ,0x0441 ,"LG CQ6 AIO" ,ALC256_FIXUP_HEADPHONE_AMP_VOL ),SND_PCI_QUIRK (0x1854 ,0x0488 ,"LG gram 16 (16Z90R)" ,ALC298_FIXUP_SAMSUNG_AMP_V2_4_AMPS ), +SND_PCI_QUIRK (0x1854 ,0x0489 ,"LG gram 16 (16Z90R-A)" ,ALC298_FIXUP_SAMSUNG_AMP_V2_4_AMPS ),SND_PCI_QUIRK (0x1854 ,0x048a ,"LG gram 17 (17ZD90R)" ,ALC298_FIXUP_SAMSUNG_AMP_V2_4_AMPS ),SND_PCI_QUIRK (0x19e5 ,0x3204 ,"Huawei MACH-WX9" ,ALC256_FIXUP_HUAWEI_MACH_WX9_PINS ), SND_PCI_QUIRK(0x19e5, 0x320f, "Huawei WRT-WX9 ", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 459/570 ASoC: Intel: sof_sdw: Add quirk for Alienware Area 51 (2025) 0CCC SKU
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Jakubek <[email protected]>
[ Upstream commit 1b03391d073dad748636a1ad9668b837cce58265 ]
Add DMI quirk entry for Alienware systems with SKU "0CCC" to enable proper speaker codec configuration (SOC_SDW_CODEC_SPKR).
This system requires the same audio configuration as some existing Dell systems. Without this patch, the laptop's speakers and microphone will not work.
--- sound/soc/intel/boards/sof_sdw.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/intel/boards/sof_sdw.c +8 -0
@@ -741,6 +741,14 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { }, .driver_data = (void *)(SOC_SDW_CODEC_SPKR), }, + { + .callback = sof_sdw_quirk_cb, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Alienware" ), +DMI_EXACT_MATCH (DMI_PRODUCT_SKU ,"0CCC" ) + }, + .driver_data = (void *)(SOC_SDW_CODEC_SPKR), + }, /* Pantherlake devices*/ { .callback = sof_sdw_quirk_cb,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 460/570 regmap: irq: Free the regmap-irq mutex
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 1da33858af6250184d2ef907494d698af03283de ]
We do not currently free the mutex allocated by regmap-irq, do so.
--- drivers/base/regmap/regmap-irq.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/base/regmap/regmap-irq.c +11 -8
@@ -816,7 +816,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, d->mask_buf[i], chip->irq_drv_data);if (ret) - goto err_alloc; + goto err_mutex; }if (chip->mask_base && !chip->handle_mask_sync) {
@@ -827,7 +827,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,if (ret) {dev_err (map->dev,"Failed to set masks in 0x%x: %d\n" , reg, ret); - goto err_alloc; + goto err_mutex; } }
@@ -838,7 +838,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,if (ret) {dev_err (map->dev,"Failed to set masks in 0x%x: %d\n" , reg, ret); - goto err_alloc; + goto err_mutex; } }
@@ -855,7 +855,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,if (ret !=0 ) {dev_err (map->dev,"Failed to read IRQ status: %d\n" , ret); - goto err_alloc; + goto err_mutex; } }
@@ -879,7 +879,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,if (ret !=0 ) {dev_err (map->dev,"Failed to ack 0x%x: %d\n" , reg, ret); - goto err_alloc; + goto err_mutex; } } }
@@ -901,7 +901,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,if (ret !=0 ) {dev_err (map->dev,"Failed to set masks in 0x%x: %d\n" , reg, ret); - goto err_alloc; + goto err_mutex; } } }
@@ -910,7 +910,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,if (chip->status_is_level) { ret =read_irq_data (d);if (ret <0 ) - goto err_alloc; + goto err_mutex;memcpy (d->prev_status_buf, d->status_buf,array_size (d->chip->num_regs,sizeof (d->prev_status_buf[0 ])));
@@ -918,7 +918,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, ret =regmap_irq_create_domain (fwnode, irq_base, chip, d);if (ret) - goto err_alloc; + goto err_mutex; ret = request_threaded_irq(irq, NULL, regmap_irq_thread, irq_flags | IRQF_ONESHOT,
@@ -935,6 +935,8 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, err_domain:/* Should really dispose of the domain but... */ +err_mutex: +mutex_destroy (&d->lock); err_alloc:kfree (d->type_buf);kfree (d->type_buf_def);
@@ -1027,6 +1029,7 @@ void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d)kfree (d->config_buf[i]);kfree (d->config_buf); } +mutex_destroy (&d->lock);kfree (d); }EXPORT_SYMBOL_GPL (regmap_del_irq_chip);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 461/570 net: phy: smsc: add proper reset flags for LAN8710A
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Buday Csaba <[email protected]>
[ Upstream commit 57ec5a8735dc5dccd1ee68afdb1114956a3fce0d ]
According to the LAN8710A datasheet (Rev. B, section 3.8.5.1), a hardware reset is required after power-on, and the reference clock (REF_CLK) must be established before asserting reset.
--- drivers/net/phy/smsc.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/smsc.c +1 -0
@@ -785,6 +785,7 @@ static struct phy_driver smsc_phy_driver[] = {/* PHY_BASIC_FEATURES */ + .flags = PHY_RST_AFTER_CLK_EN, .probe = smsc_phy_probe,/* basic functions */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 462/570 ASoC: Intel: avs: Fix uninitialized pointer error in probe()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit 11f74f48c14c1f4fe16541900ea5944c42e30ccf ]
If pcim_request_all_regions() fails, error path operates on uninitialized 'bus' pointer. Found out by Coverity static analyzer.
--- sound/soc/intel/avs/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/intel/avs/core.c +2 -1
@@ -446,6 +446,8 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) adev =devm_kzalloc (dev,sizeof (*adev),GFP_KERNEL );if (!adev)return -ENOMEM ; + bus = &adev->base.core; + ret =avs_bus_init (adev, pci, id);if (ret <0 ) {dev_err (dev,"failed to init avs bus: %d\n" , ret);
@@ -456,7 +458,6 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)if (ret <0 )return ret; - bus = &adev->base.core; bus->addr =pci_resource_start (pci,0 ); bus->remap_addr =pci_ioremap_bar (pci,0 );if (!bus->remap_addr) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 463/570 block: avoid possible overflow for chunk_sectors check in blk_stack_limits()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Garry <[email protected]>
[ Upstream commit 448dfecc7ff807822ecd47a5c052acedca7d09e8 ]
In blk_stack_limits(), we check that the t->chunk_sectors value is a multiple of the t->physical_block_size value.
However, by finding the chunk_sectors value in bytes, we may overflow the unsigned int which holds chunk_sectors, so change the check to be based on sectors.
--- block/blk-settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-settings.c +1 -1
@@ -792,7 +792,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, }/* chunk_sectors a multiple of the physical block size? */ -if ((t->chunk_sectors <<9 ) & (t->physical_block_size -1 )) { +if (t->chunk_sectors % (t->physical_block_size >>SECTOR_SHIFT )) { t->chunk_sectors =0 ; t->flags |=BLK_FLAG_MISALIGNED ; ret =-1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 464/570 pNFS: Fix stripe mapping in block/scsi layout
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Bashirov <[email protected]>
[ Upstream commit 81438498a285759f31e843ac4800f82a5ce6521f ]
Because of integer division, we need to carefully calculate the disk offset. Consider the example below for a stripe of 6 volumes, a chunk size of 4096, and an offset of 70000.
chunk = div_u64(offset, dev->chunk_size) = 70000 / 4096 = 17 offset = chunk * dev->chunk_size = 17 * 4096 = 69632 disk_offset_wrong = div_u64(offset, dev->nr_children) = 69632 / 6 = 11605 disk_chunk = div_u64(chunk, dev->nr_children) = 17 / 6 = 2 disk_offset = disk_chunk * dev->chunk_size = 2 * 4096 = 8192
--- fs/nfs/blocklayout/dev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfs/blocklayout/dev.c +3 -2
@@ -257,10 +257,11 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset,struct pnfs_block_dev *child;u64 chunk;u32 chunk_idx; +u64 disk_chunk;u64 disk_offset; chunk =div_u64 (offset, dev->chunk_size); -div_u64_rem (chunk, dev->nr_children, &chunk_idx); + disk_chunk =div_u64_rem (chunk, dev->nr_children, &chunk_idx);if (chunk_idx >= dev->nr_children) { dprintk("%s: invalid chunk idx %d (%lld/%lld)\n",
@@ -273,7 +274,7 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset, offset = chunk * dev->chunk_size;/* disk offset of the stripe */ - disk_offset =div_u64 (offset, dev->nr_children); + disk_offset = disk_chunk * dev->chunk_size; child = &dev->children[chunk_idx]; child->map (child, disk_offset, map);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 465/570 pNFS: Fix disk addr range check in block/scsi layout
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Bashirov <[email protected]>
[ Upstream commit 7db6e66663681abda54f81d5916db3a3b8b1a13d ]
At the end of the isect translation, disc_addr represents the physical disk offset. Thus, end calculated from disk_addr is also a physical disk offset. Therefore, range checking should be done using map->disk_offset, not map->start.
--- fs/nfs/blocklayout/blocklayout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/blocklayout/blocklayout.c +2 -2
@@ -149,8 +149,8 @@ do_add_page_to_bio(struct bio *bio, int npg, enum req_op op, sector_t isect,/* limit length to what the device mapping allows */ end = disk_addr + *len; -if (end >= map->start + map->len) - *len = map->start + map->len - disk_addr; +if (end >= map->disk_offset + map->len) + *len = map->disk_offset + map->len - disk_addr; retry:if (!bio) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 466/570 pNFS: Handle RPC size limit for layoutcommits
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Bashirov <[email protected]>
[ Upstream commit d897d81671bc4615c80f4f3bd5e6b218f59df50c ]
When there are too many block extents for a layoutcommit, they may not all fit into the maximum-sized RPC. This patch allows the generic pnfs code to properly handle -ENOSPC returned by the block/scsi layout driver and trigger additional layoutcommits if necessary.
--- fs/nfs/pnfs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/nfs/pnfs.c +8 -3
@@ -3340,6 +3340,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)struct nfs_inode *nfsi =NFS_I (inode);loff_t end_pos;int status; +bool mark_as_dirty = false;if (!pnfs_layoutcommit_outstanding (inode))return 0 ;
@@ -3391,19 +3392,23 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)if (ld->prepare_layoutcommit) { status = ld->prepare_layoutcommit (&data->args);if (status) { -put_cred (data->cred); +if (status != -ENOSPC ) +put_cred (data->cred);spin_lock (&inode->i_lock);set_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags);if (end_pos > nfsi->layout->plh_lwb) nfsi->layout->plh_lwb = end_pos; - goto out_unlock; +if (status != -ENOSPC ) + goto out_unlock; +spin_unlock (&inode->i_lock); + mark_as_dirty = true; } } status =nfs4_proc_layoutcommit (data, sync); out: -if (status) +if (status || mark_as_dirty)mark_inode_dirty_sync (inode);dprintk ("<-- %s status %d\n" , __func__, status);return status;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 467/570 pNFS: Fix uninited ptr deref in block/scsi layout
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Bashirov <[email protected]>
[ Upstream commit 9768797c219326699778fba9cd3b607b2f1e7950 ]
The error occurs on the third attempt to encode extents. When function ext_tree_prepare_commit() reallocates a larger buffer to retry encoding extents, the "layoutupdate_pages" page array is initialized only after the retry loop. But ext_tree_free_commitdata() is called on every iteration and tries to put pages in the array, thus dereferencing uninitialized pointers.
An additional problem is that there is no limit on the maximum possible buffer_size. When there are too many extents, the client may create a layoutcommit that is larger than the maximum possible RPC size accepted by the server.
During testing, we observed two typical scenarios. First, one memory page for extents is enough when we work with small files, append data to the end of the file, or preallocate extents before writing. But when we fill a new large file without preallocating, the number of extents can be huge, and counting the number of written extents in ext_tree_encode_commit() does not help much. Since this number increases even more between unlocking and locking of ext_tree, the reallocated buffer may not be large enough again and again.
--- fs/nfs/blocklayout/extent_tree.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
fs/nfs/blocklayout/extent_tree.c +15 -5
@@ -552,6 +552,15 @@ static int ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p,return ret; } +/** +* ext_tree_prepare_commit - encode extents that need to be committed +* @arg: layout commit data +* +* Return values: +* %0: Success, all required extents are encoded +* %-ENOSPC: Some extents are encoded, but not all, due to RPC size limit +* %-ENOMEM: Out of memory, extents not encoded +*/ int ext_tree_prepare_commit (struct nfs4_layoutcommit_args *arg) {
@@ -568,12 +577,12 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg) start_p =page_address (arg->layoutupdate_page); arg->layoutupdate_pages = &arg->layoutupdate_page; -retry: - ret =ext_tree_encode_commit (bl, start_p +1 , buffer_size, &count, &arg->lastbytewritten); + ret =ext_tree_encode_commit (bl, start_p +1 , buffer_size, + &count, &arg->lastbytewritten);if (unlikely (ret)) {ext_tree_free_commitdata (arg, buffer_size); - buffer_size =ext_tree_layoutupdate_size (bl, count); + buffer_size =NFS_SERVER (arg->inode)->wsize; count =0 ; arg->layoutupdate_pages =
@@ -588,7 +597,8 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg)return -ENOMEM ; } - goto retry; + ret =ext_tree_encode_commit (bl, start_p +1 , buffer_size, + &count, &arg->lastbytewritten); } *start_p =cpu_to_be32 (count);
@@ -608,7 +618,7 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg) }dprintk ("%s found %zu ranges\n" , __func__, count); -return 0 ; +return ret; }void
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 468/570 rtc: ds1307: remove clear of oscillator stop flag (OSF) in probe
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meagan Lloyd <[email protected]>
[ Upstream commit 48458654659c9c2e149c211d86637f1592470da5 ]
In using CONFIG_RTC_HCTOSYS, rtc_hctosys() will sync the RTC time to the kernel time as long as rtc_read_time() succeeds. In some power loss situations, our supercapacitor-backed DS1342 RTC comes up with either an unpredictable future time or the default 01/01/00 from the datasheet. The oscillator stop flag (OSF) is set in these scenarios due to the power loss and can be used to determine the validity of the RTC data.
Some chip types in the ds1307 driver already have OSF handling to determine whether .read_time provides valid RTC data or returns -EINVAL.
This change removes the clear of the OSF in .probe as the OSF needs to be preserved to expand the OSF handling to the ds1341 chip type (note that DS1341 and DS1342 share a datasheet).
--- drivers/rtc/rtc-ds1307.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/rtc/rtc-ds1307.c +1 -3
@@ -1824,10 +1824,8 @@ static int ds1307_probe(struct i2c_client *client)regmap_write (ds1307->regmap,DS1337_REG_CONTROL , regs[0 ]); -/* oscillator fault? clear flag, and warn */ +/* oscillator fault? warn */ if (regs[1 ] &DS1337_BIT_OSF ) { -regmap_write (ds1307->regmap,DS1337_REG_STATUS , - regs[1 ] & ~DS1337_BIT_OSF );dev_warn (ds1307->dev,"SET TIME!\n" ); }break ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 469/570 scsi: ufs: core: Fix interrupt handling for MCQ Mode
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nitin Rawat <[email protected]>
[ Upstream commit 034d319c8899e8c5c0a35c6692c7fc7e8c12c374 ]
Commit 3c7ac40d7322 ("scsi: ufs: core: Delegate the interrupt service routine to a threaded IRQ handler") introduced a regression where the UFS interrupt status register (IS) was not cleared in ufshcd_intr() when operating in MCQ mode. As a result, the IS register remained uncleared.
This led to a persistent issue during UIC interrupts:ufshcd_is_auto_hibern8_error() consistently returned true because the UFSHCD_UIC_HIBERN8_MASK bit was set, while the active command was neither UIC_CMD_DME_HIBER_ENTER nor UIC_CMD_DME_HIBER_EXIT. This caused continuous auto hibern8 enter errors and device failed to boot.
To fix this, ensure that the interrupt status register is properly cleared in the ufshcd_intr() function for both MCQ mode with ESI enabled.
[ 4.553226] ufshcd-qcom 1d84000.ufs: ufshcd_check_errors: Auto Hibern8 Enter failed - status: 0x00000040, upmcrs: 0x00000001 [ 4.553229] ufshcd-qcom 1d84000.ufs: ufshcd_check_errors: saved_err 0x40 saved_uic_err 0x0 [ 4.553311] host_regs: 00000000: d5c7033f 20e0071f 00000400 00000000 [ 4.553312] host_regs: 00000010: 01000000 00010217 00000c96 00000000 [ 4.553314] host_regs: 00000020: 00000440 00170ef5 00000000 00000000 [ 4.553316] host_regs: 00000030: 0000010f 00000001 00000000 00000000 [ 4.553317] host_regs: 00000040: 00000000 00000000 00000000 00000000 [ 4.553319] host_regs: 00000050: fffdf000 0000000f 00000000 00000000 [ 4.553320] host_regs: 00000060: 00000001 80000000 00000000 00000000 [ 4.553322] host_regs: 00000070: fffde000 0000000f 00000000 00000000 [ 4.553323] host_regs: 00000080: 00000001 00000000 00000000 00000000 [ 4.553325] host_regs: 00000090: 00000002 d0020000 00000000 01930200
--- drivers/ufs/core/ufshcd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/ufs/core/ufshcd.c +7 -2
@@ -7110,14 +7110,19 @@ static irqreturn_t ufshcd_threaded_intr(int irq, void *__hba)static irqreturn_t ufshcd_intr (int irq,void *__hba) {struct ufs_hba *hba = __hba; +u32 intr_status, enabled_intr_status;/* Move interrupt handling to thread when MCQ & ESI are not enabled */ if (!hba->mcq_enabled || !hba->mcq_esi_enabled)return IRQ_WAKE_THREAD ; + intr_status =ufshcd_readl (hba,REG_INTERRUPT_STATUS ); + enabled_intr_status = intr_status &ufshcd_readl (hba,REG_INTERRUPT_ENABLE ); + +ufshcd_writel (hba, intr_status,REG_INTERRUPT_STATUS ); +/* Directly handle interrupts since MCQ ESI handlers does the hard job */ -return ufshcd_sl_intr (hba,ufshcd_readl (hba,REG_INTERRUPT_STATUS ) & -ufshcd_readl (hba,REG_INTERRUPT_ENABLE )); +return ufshcd_sl_intr (hba, enabled_intr_status); }static int ufshcd_clear_tm_cmd (struct ufs_hba *hba,int tag)
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 470/570 scsi: lpfc: Remove redundant assignment to avoid memory leak
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit eea6cafb5890db488fce1c69d05464214616d800 ]
Remove the redundant assignment if kzalloc() succeeds to avoid memory leak.
--- drivers/scsi/lpfc/lpfc_debugfs.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/lpfc/lpfc_debugfs.c +0 -1
@@ -6289,7 +6289,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) } phba->nvmeio_trc_on =1 ; phba->nvmeio_trc_output_idx =0 ; - phba->nvmeio_trc =NULL ; }else { nvmeio_off: phba->nvmeio_trc_size =0 ;
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 471/570 ASoC: fsl_sai: replace regmap_write with regmap_update_bits
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit 0e270f32975fd21874185ba53653630dd40bf560 ]
Use the regmap_write() for software reset in fsl_sai_config_disable would cause the FSL_SAI_CSR_BCE bit to be cleared. Refer to
commit 197c53c8ecb34 ("ASoC: fsl_sai: Don't disable bitclock for i.MX8MP") FSL_SAI_CSR_BCE should not be cleared. So need to use regmap_update_bits() instead of regmap_write() for these bit operations.
--- sound/soc/fsl/fsl_sai.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
sound/soc/fsl/fsl_sai.c +10 -10
@@ -809,9 +809,9 @@ static void fsl_sai_config_disable(struct fsl_sai *sai, int dir)* are running concurrently. */ /* Software Reset */ -regmap_write (sai->regmap,FSL_SAI_xCSR (tx, ofs),FSL_SAI_CSR_SR ); +regmap_update_bits (sai->regmap,FSL_SAI_xCSR (tx, ofs),FSL_SAI_CSR_SR ,FSL_SAI_CSR_SR );/* Clear SR bit to finish the reset */ -regmap_write (sai->regmap,FSL_SAI_xCSR (tx, ofs),0 ); +regmap_update_bits (sai->regmap,FSL_SAI_xCSR (tx, ofs),FSL_SAI_CSR_SR ,0 ); } static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
@@ -930,11 +930,11 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai)unsigned int ofs = sai->soc_data->reg_offset;/* Software Reset for both Tx and Rx */ -regmap_write (sai->regmap,FSL_SAI_TCSR (ofs),FSL_SAI_CSR_SR ); -regmap_write (sai->regmap,FSL_SAI_RCSR (ofs),FSL_SAI_CSR_SR ); +regmap_update_bits (sai->regmap,FSL_SAI_TCSR (ofs),FSL_SAI_CSR_SR ,FSL_SAI_CSR_SR ); +regmap_update_bits (sai->regmap,FSL_SAI_RCSR (ofs),FSL_SAI_CSR_SR ,FSL_SAI_CSR_SR );/* Clear SR bit to finish the reset */ -regmap_write (sai->regmap,FSL_SAI_TCSR (ofs),0 ); -regmap_write (sai->regmap,FSL_SAI_RCSR (ofs),0 ); +regmap_update_bits (sai->regmap,FSL_SAI_TCSR (ofs),FSL_SAI_CSR_SR ,0 ); +regmap_update_bits (sai->regmap,FSL_SAI_RCSR (ofs),FSL_SAI_CSR_SR ,0 ); regmap_update_bits(sai->regmap, FSL_SAI_TCR1(ofs), FSL_SAI_CR1_RFW_MASK(sai->soc_data->fifo_depth),
@@ -1824,11 +1824,11 @@ static int fsl_sai_runtime_resume(struct device *dev)regcache_cache_only (sai->regmap, false);regcache_mark_dirty (sai->regmap); -regmap_write (sai->regmap,FSL_SAI_TCSR (ofs),FSL_SAI_CSR_SR ); -regmap_write (sai->regmap,FSL_SAI_RCSR (ofs),FSL_SAI_CSR_SR ); +regmap_update_bits (sai->regmap,FSL_SAI_TCSR (ofs),FSL_SAI_CSR_SR ,FSL_SAI_CSR_SR ); +regmap_update_bits (sai->regmap,FSL_SAI_RCSR (ofs),FSL_SAI_CSR_SR ,FSL_SAI_CSR_SR );usleep_range (1000 ,2000 ); -regmap_write (sai->regmap,FSL_SAI_TCSR (ofs),0 ); -regmap_write (sai->regmap,FSL_SAI_RCSR (ofs),0 ); +regmap_update_bits (sai->regmap,FSL_SAI_TCSR (ofs),FSL_SAI_CSR_SR ,0 ); +regmap_update_bits (sai->regmap,FSL_SAI_RCSR (ofs),FSL_SAI_CSR_SR ,0 ); ret =regcache_sync (sai->regmap);if (ret)
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 472/570 ublk: check for unprivileged daemon on each I/O fetch
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Caleb Sander Mateos <[email protected]>
[ Upstream commit 5058a62875e1916e5133a1639f0207ea2148c0bc ]
Commit ab03a61c6614 ("ublk: have a per-io daemon instead of a per-queue daemon") allowed each ublk I/O to have an independent daemon task. However, nr_privileged_daemon is only computed based on whether the last I/O fetched in each ublk queue has an unprivileged daemon task. Fix this by checking whether every fetched I/O's daemon is privileged. Change nr_privileged_daemon from a count of queues to a boolean indicating whether any I/Os have an unprivileged daemon.
--- drivers/block/ublk_drv.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/block/ublk_drv.c +7 -9
@@ -215,7 +215,7 @@ struct ublk_device {struct completion completion;unsigned int nr_queues_ready; -unsigned int nr_privileged_daemon; +bool unprivileged_daemons;struct mutex cancel_mutex;bool canceling;pid_t ublksrv_tgid;
@@ -1532,7 +1532,7 @@ static void ublk_reset_ch_dev(struct ublk_device *ub)/* set to NULL, otherwise new tasks cannot mmap io_cmd_buf */ ub->mm =NULL ; ub->nr_queues_ready =0 ; - ub->nr_privileged_daemon =0 ; + ub->unprivileged_daemons = false; ub->ublksrv_tgid =-1 ; }
@@ -1945,12 +1945,10 @@ static void ublk_mark_io_ready(struct ublk_device *ub, struct ublk_queue *ubq) __must_hold(&ub->mutex) { ubq->nr_io_ready++; -if (ublk_queue_ready (ubq)) { +if (ublk_queue_ready (ubq)) ub->nr_queues_ready++; - -if (capable (CAP_SYS_ADMIN )) - ub->nr_privileged_daemon++; - } +if (!ub->unprivileged_daemons && !capable (CAP_SYS_ADMIN )) + ub->unprivileged_daemons = true;if (ub->nr_queues_ready == ub->dev_info.nr_hw_queues) {/* now we are ready for handling ublk io request */
@@ -2759,8 +2757,8 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub,ublk_apply_params (ub); -/* don't probe partitions if any one ubq daemon is un-trusted */ -if (ub->nr_privileged_daemon != ub->nr_queues_ready) +/* don't probe partitions if any daemon task is un-trusted */ +if (ub->unprivileged_daemons)set_bit (GD_SUPPRESS_PART_SCAN , &disk->state);ublk_get_device (ub);
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 473/570 block: fix kobject double initialization in add_disk
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Qixing <[email protected]>
[ Upstream commit 343dc5423bfe876c12bb80c56f5e44286e442a07 ]
Device-mapper can call add_disk() multiple times for the same gendisk due to its two-phase creation process (dm create + dm load). This leads to kobject double initialization errors when the underlying iSCSI devices become temporarily unavailable and then reappear.
However, if the first add_disk() call fails and is retried, the queue_kobj gets initialized twice, causing:
kobject: kobject (ffff88810c27bb90): tried to init an initialized object, something is seriously wrong.
Call Trace: <TASK> dump_stack_lvl+0x5b/0x80 kobject_init.cold+0x43/0x51 blk_register_queue+0x46/0x280 add_disk_fwnode+0xb5/0x280 dm_setup_md_queue+0x194/0x1c0 table_load+0x297/0x2d0 ctl_ioctl+0x2a2/0x480 dm_ctl_ioctl+0xe/0x20 __x64_sys_ioctl+0xc7/0x110 do_syscall_64+0x72/0x390 entry_SYSCALL_64_after_hwframe+0x76/0x7e
Fix this by separating kobject initialization from sysfs registration:
- Initialize queue_kobj early during gendisk allocation
- add_disk() only adds the already-initialized kobject to sysfs
- del_gendisk() removes from sysfs but doesn't destroy the kobject
- Final cleanup happens when the disk is released
--- block/blk-sysfs.c | 12 +++++------- block/blk.h | 1 + block/genhd.c | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-)
block/blk-sysfs.c +5 -7
@@ -821,7 +821,7 @@ static void blk_queue_release(struct kobject *kobj)/* nothing to do here, all data is associated with the parent gendisk */ } -static const struct kobj_type blk_queue_ktype = { +const struct kobj_type blk_queue_ktype = { .default_groups = blk_queue_attr_groups, .sysfs_ops = &queue_sysfs_ops, .release = blk_queue_release,
@@ -849,15 +849,14 @@ int blk_register_queue(struct gendisk *disk)struct request_queue *q = disk->queue;int ret; -kobject_init (&disk->queue_kobj, &blk_queue_ktype); ret =kobject_add (&disk->queue_kobj, &disk_to_dev (disk)->kobj,"queue" );if (ret <0 ) - goto out_put_queue_kobj; +return ret;if (queue_is_mq (q)) { ret =blk_mq_sysfs_register (disk);if (ret) - goto out_put_queue_kobj; + goto out_del_queue_kobj; }mutex_lock (&q->sysfs_lock);
@@ -908,8 +907,8 @@ int blk_register_queue(struct gendisk *disk)mutex_unlock (&q->sysfs_lock);if (queue_is_mq (q))blk_mq_sysfs_unregister (disk); -out_put_queue_kobj: -kobject_put (&disk->queue_kobj); +out_del_queue_kobj: +kobject_del (&disk->queue_kobj);return ret; }
@@ -960,5 +959,4 @@ void blk_unregister_queue(struct gendisk *disk)elevator_set_none (q);blk_debugfs_remove (disk); -kobject_put (&disk->queue_kobj); }
block/blk.h +1 -0
@@ -19,6 +19,7 @@ struct elevator_type;/* Max future timer expiry for timeouts */ #define BLK_MAX_TIMEOUT (5 * HZ) +extern const struct kobj_type blk_queue_ktype;extern struct dentry *blk_debugfs_root;struct blk_flush_queue {
block/genhd.c +2 -0
@@ -1303,6 +1303,7 @@ static void disk_release(struct device *dev)disk_free_zone_resources (disk);xa_destroy (&disk->part_tbl); +kobject_put (&disk->queue_kobj); disk->queue->disk =NULL ;blk_put_queue (disk->queue);
@@ -1486,6 +1487,7 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,INIT_LIST_HEAD (&disk->slave_bdevs);#endif mutex_init (&disk->rqos_state_mutex); +kobject_init (&disk->queue_kobj, &blk_queue_ktype);return disk; out_erase_part0:
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 474/570 cifs: Fix collect_sample() to handle any iterator type
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit b63335fb3d32579c5ff0b7038b9cc23688fff528 ]
collect_sample() is used to gather samples of the data in a Write op for analysis to try and determine if the compression algorithm is likely to achieve anything more quickly than actually running the compression algorithm.
However, collect_sample() assumes that the data it is going to be sampling is stored in an ITER_XARRAY-type iterator (which it now should never be) and doesn't actually check that it is before accessing the underlying xarray directly.
Fix this by replacing the code with a loop that just uses the standard iterator functions to sample every other 2KiB block, skipping the intervening ones. It's not quite the same as the previous algorithm as it doesn't necessarily align to the pages within an ordinary write from the pagecache.
Note that the btrfs code from which this was derived samples the inode's pagecache directly rather than the iterator - but that doesn't necessarily work for network filesystems if O_DIRECT is in operation.
--- fs/smb/client/compress.c | 71 ++++++++++++---------------------------- 1 file changed, 21 insertions(+), 50 deletions(-)
fs/smb/client/compress.c +21 -50
@@ -155,58 +155,29 @@ static int cmp_bkt(const void *_a, const void *_b) }/* -* TODO: -* Support other iter types, if required. -* Only ITER_XARRAY is supported for now. +* Collect some 2K samples with 2K gaps between. */ -static int collect_sample (const struct iov_iter *iter,ssize_t max,u8 *sample) +static int collect_sample (const struct iov_iter *source,ssize_t max,u8 *sample) { -struct folio *folios[16 ], *folio; -unsigned int nr, i, j, npages; -loff_t start = iter->xarray_start + iter->iov_offset; -pgoff_t last, index = start /PAGE_SIZE ; -size_t len, off, foff; -void *p; -int s =0 ; - - last = (start + max -1 ) /PAGE_SIZE ; -do { - nr =xa_extract (iter->xarray, (void **)folios, index, last,ARRAY_SIZE (folios), -XA_PRESENT ); -if (nr ==0 ) -return -EIO ; - -for (i =0 ; i < nr; i++) { - folio = folios[i]; - npages =folio_nr_pages (folio); - foff = start -folio_pos (folio); - off = foff %PAGE_SIZE ; - -for (j = foff /PAGE_SIZE ; j < npages; j++) { -size_t len2; - - len =min_t (size_t, max,PAGE_SIZE - off); - len2 =min_t (size_t, len,SZ_2K ); - - p =kmap_local_page (folio_page (folio, j)); -memcpy (&sample[s], p, len2); -kunmap_local (p); - - s += len2; - -if (len2 <SZ_2K || s >= max -SZ_2K ) -return s; - - max -= len; -if (max <=0 ) -return s; - - start += len; - off =0 ; - index++; - } - } - }while (nr ==ARRAY_SIZE (folios)); +struct iov_iter iter = *source; +size_t s =0 ; + +while (iov_iter_count (&iter) >=SZ_2K ) { +size_t part =umin (umin (iov_iter_count (&iter),SZ_2K ), max); +size_t n; + + n =copy_from_iter (sample + s, part, &iter); +if (n != part) +return -EFAULT ; + + s += n; + max -= n; + +if (iov_iter_count (&iter) <PAGE_SIZE -SZ_2K ) +break ; + +iov_iter_advance (&iter,SZ_2K ); + }return s; }
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 475/570 drm/i915/fbc: fix the implementation of wa_18038517565
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinod Govindapillai <[email protected]>
[ Upstream commit fd56b9c9507f32b16159f9a922e1af5628254567 ]
As per the wa_18038517565, we need to disable FBC compressor clock gating before enabling FBC and enable after disabling FBC. Placing the enabling of clock gating in the fbc deactivate function can make the above wa logic go wrong in case of frontbuffer rendering FBC mechanism. FBC deactivate can get called during fb invalidate and then the corresponding FBC activate can get called without properly disabling the clock gating and can result in compression stalled. So move the enable clock gating at the end of one FBC session after FBC is completely disabled for a pipe.
Bspec: 74212, 72197, 69741, 65555
--- drivers/gpu/drm/i915/display/intel_fbc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +4 -4
@@ -550,10 +550,6 @@ static void ilk_fbc_deactivate(struct intel_fbc *fbc)if (dpfc_ctl &DPFC_CTL_EN ) { dpfc_ctl &= ~DPFC_CTL_EN ;intel_de_write (display,ILK_DPFC_CONTROL (fbc->id), dpfc_ctl); - -/* wa_18038517565 Enable DPFC clock gating after FBC disable */ -if (display->platform.dg2 ||DISPLAY_VER (display) >=14 ) -fbc_compressor_clkgate_disable_wa (fbc, false); } }
@@ -1708,6 +1704,10 @@ static void __intel_fbc_disable(struct intel_fbc *fbc)__intel_fbc_cleanup_cfb (fbc); +/* wa_18038517565 Enable DPFC clock gating after FBC disable */ +if (display->platform.dg2 ||DISPLAY_VER (display) >=14 ) +fbc_compressor_clkgate_disable_wa (fbc, false); + fbc->state.plane =NULL ; fbc->flip_pending = false; fbc->busy_bits =0 ;
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 476/570 drm/i915/psr: Do not trigger Frame Change events from frontbuffer flush
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Högander <[email protected]>
[ Upstream commit 184889dfe0568528fd6d14bba864dd57ed45bbf2 ]
We want to get rid of triggering "Frame Change" events from frontbuffer flush calls. We are about to move using TRANS_PUSH register for this on LunarLake and onwards. Touching TRANS_PUSH register from fronbuffer flush would be problematic as it's written by DSB as well.
Fix this by using intel_psr_exit when flush or invalidate is done on LunarLake and onwards. This is not possible on AlderLake and MeteorLake due to HW bug in PSR2 disable.
This patch is also fixing problems with cursor plane where cursor is disappearing or duplicate cursor is seen on the screen.
v2: Commit message updated
Bspec: 68927, 68934, 66624
--- drivers/gpu/drm/i915/display/intel_psr.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/display/intel_psr.c +9 -5
@@ -3250,7 +3250,9 @@ static void intel_psr_configure_full_frame_update(struct intel_dp *intel_dp)static void _psr_invalidate_handle (struct intel_dp *intel_dp) { -if (intel_dp->psr.psr2_sel_fetch_enabled) { +struct intel_display *display =to_intel_display (intel_dp); + +if (DISPLAY_VER (display) <20 && intel_dp->psr.psr2_sel_fetch_enabled) {if (!intel_dp->psr.psr2_sel_fetch_cff_enabled) { intel_dp->psr.psr2_sel_fetch_cff_enabled = true;intel_psr_configure_full_frame_update (intel_dp);
@@ -3338,7 +3340,7 @@ static void _psr_flush_handle(struct intel_dp *intel_dp)struct intel_display *display =to_intel_display (intel_dp);struct drm_i915_private *dev_priv =to_i915 (display->drm); -if (intel_dp->psr.psr2_sel_fetch_enabled) { +if (DISPLAY_VER (display) <20 && intel_dp->psr.psr2_sel_fetch_enabled) {if (intel_dp->psr.psr2_sel_fetch_cff_enabled) {/* can we turn CFF off? */ if (intel_dp->psr.busy_frontbuffer_bits ==0 )
@@ -3355,11 +3357,13 @@ static void _psr_flush_handle(struct intel_dp *intel_dp)* existing SU configuration */ intel_psr_configure_full_frame_update (intel_dp); - } -intel_psr_force_update (intel_dp); +intel_psr_force_update (intel_dp); + }else { +intel_psr_exit (intel_dp); + } -if (!intel_dp->psr.psr2_sel_fetch_enabled && !intel_dp->psr.active && +if ((!intel_dp->psr.psr2_sel_fetch_enabled ||DISPLAY_VER (display) >=20 ) && !intel_dp->psr.busy_frontbuffer_bits)queue_work (dev_priv->unordered_wq, &intel_dp->psr.work); }
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 477/570 drm/xe/migrate: prevent infinite recursion
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
[ Upstream commit 9d7a1cbebbb691891671def57407ba2f8ee914e8 ]
If the buf + offset is not aligned to XE_CAHELINE_BYTES we fallback to using a bounce buffer. However the bounce buffer here is allocated on the stack, and the only alignment requirement here is that it's naturally aligned to u8, and not XE_CACHELINE_BYTES. If the bounce buffer is also misaligned we then recurse back into the function again, however the new bounce buffer might also not be aligned, and might never be until we eventually blow through the stack, as we keep recursing.
Instead of using the stack use kmalloc, which should respect the power-of-two alignment request here. Fixes a kernel panic when triggering this path through eudebug.
v2 (Stuart):
- Add build bug check for power-of-two restriction
- s/EINVAL/ENOMEM/
--- drivers/gpu/drm/xe/xe_migrate.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/gpu/drm/xe/xe_migrate.c +17 -12
@@ -1820,15 +1820,19 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,if (!IS_ALIGNED (len,XE_CACHELINE_BYTES ) || !IS_ALIGNED ((unsigned long )buf + offset,XE_CACHELINE_BYTES )) {int buf_offset =0 ; +void *bounce; +int err; + +BUILD_BUG_ON (!is_power_of_2 (XE_CACHELINE_BYTES )); + bounce =kmalloc (XE_CACHELINE_BYTES ,GFP_KERNEL ); +if (!bounce) +return -ENOMEM ;/* * Less than ideal for large unaligned access but this should be * fairly rare, can fixup if this becomes common. */ do { - u8 bounce[XE_CACHELINE_BYTES]; - void *ptr = (void *)bounce; - int err; int copy_bytes = min_t(int, bytes_left, XE_CACHELINE_BYTES - (offset & XE_CACHELINE_MASK));
@@ -1837,22 +1841,22 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo, err =xe_migrate_access_memory (m, bo, offset & ~XE_CACHELINE_MASK , - (void *)ptr, -sizeof (bounce),0 ); + bounce, +XE_CACHELINE_BYTES ,0 );if (err) -return err; +break ;if (write) { -memcpy (ptr + ptr_offset, buf + buf_offset, copy_bytes); +memcpy (bounce + ptr_offset, buf + buf_offset, copy_bytes); err =xe_migrate_access_memory (m, bo, offset & ~XE_CACHELINE_MASK , - (void *)ptr, -sizeof (bounce), write); + bounce, +XE_CACHELINE_BYTES , write);if (err) -return err; +break ; }else { -memcpy (buf + buf_offset, ptr + ptr_offset, +memcpy (buf + buf_offset, bounce + ptr_offset, copy_bytes); }
@@ -1861,7 +1865,8 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo, offset += copy_bytes; }while (bytes_left); -return 0 ; +kfree (bounce); +return err; } dma_addr =xe_migrate_dma_map (xe, buf, len + page_offset, write);
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 478/570 drm/xe/migrate: dont overflow max copy size
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
[ Upstream commit 4126cb327a2e3273c81fcef1c594c5b7b645c44c ]
With non-page aligned copy, we need to use 4 byte aligned pitch, however the size itself might still be close to our maximum of ~8M, and so the dimensions of the copy can easily exceed the S16_MAX limit of the copy command leading to the following assert:
xe 0000:03:00.0: [drm] Assertion size / pitch <= ((s16)(((u16)~0U) >> 1)) failed!
platform: BATTLEMAGE subplatform: 1
graphics: Xe2_HPG 20.01 step A0
media: Xe2_HPM 13.01 step A1
tile: 0 VRAM 10.0 GiB
GT: 0 type 1
WARNING: CPU: 23 PID: 10605 at drivers/gpu/drm/xe/xe_migrate.c:673 emit_copy+0x4b5/0x4e0 [xe]
To fix this account for the pitch when calculating the number of current bytes to copy.
--- drivers/gpu/drm/xe/xe_migrate.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/xe/xe_migrate.c +6 -0
@@ -1887,6 +1887,12 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,else current_bytes =min_t (int, bytes_left, cursor.size); +if (current_bytes & ~PAGE_MASK ) { +int pitch =4 ; + + current_bytes =min_t (int, current_bytes,S16_MAX * pitch); + } +if (fence)dma_fence_put (fence);
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 479/570 drm/xe/migrate: prevent potential UAF
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
[ Upstream commit 145832fbdd17b1d77ffd6cdd1642259e101d1b7e ]
If we hit the error path, the previous fence (if there is one) has already been put() prior to this, so doing a fence_wait could lead to UAF. Tweak the flow to do to the put() until after we do the wait.
--- drivers/gpu/drm/xe/xe_migrate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_migrate.c +5 -4
@@ -1893,9 +1893,6 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo, current_bytes =min_t (int, current_bytes,S16_MAX * pitch); } -if (fence) -dma_fence_put (fence); - __fence = xe_migrate_vram(m, current_bytes, (unsigned long)buf & ~PAGE_MASK, dma_addr + current_page,
@@ -1903,11 +1900,15 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo, XE_MIGRATE_COPY_TO_VRAM : XE_MIGRATE_COPY_TO_SRAM);if (IS_ERR (__fence)) { -if (fence) +if (fence) {dma_fence_wait (fence, false); +dma_fence_put (fence); + } fence = __fence; goto out_err; } + +dma_fence_put (fence); fence = __fence; buf += current_bytes;
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 480/570 drm/xe/hwmon: Add SW clamp for power limits writes
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karthik Poosa <[email protected]>
[ Upstream commit 55d49f06162e45686399df4ae6292167f0deab7c ]
Clamp writes to power limits powerX_crit/currX_crit, powerX_cap, powerX_max, to the maximum supported by the pcode mailbox when sysfs-provided values exceed this limit.
Although the pcode already performs clamping, values beyond the pcode mailbox's supported range get truncated, leading to incorrect critical power settings.
This patch ensures proper clamping to prevent such truncation.
v2:
- Address below review comments. (Riana)
- Split comments into multiple sentences.
- Use local variables for readability.
- Add a debug log.
- Use u64 instead of unsigned long.
v3:
- Change drm_dbg logs to drm_info. (Badal)
v4:
- Rephrase the drm_info log. (Rodrigo, Riana)
- Rename variable max_mbx_power_limit to max_supp_power_limit, as limit is same for platforms with and without mailbox power limit support.
--- drivers/gpu/drm/xe/xe_hwmon.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/gpu/drm/xe/xe_hwmon.c +29 -0
@@ -329,6 +329,7 @@ static int xe_hwmon_power_max_write(struct xe_hwmon *hwmon, u32 attr, int channeint ret =0 ;u32 reg_val;struct xe_reg rapl_limit; +u64 max_supp_power_limit =0 ;mutex_lock (&hwmon->hwmon_lock);
@@ -353,6 +354,20 @@ static int xe_hwmon_power_max_write(struct xe_hwmon *hwmon, u32 attr, int channe goto unlock; } +/* +* If the sysfs value exceeds the maximum pcode supported power limit value, clamp it to +* the supported maximum (U12.3 format). +* This is to avoid truncation during reg_val calculation below and ensure the valid +* power limit is sent for pcode which would clamp it to card-supported value. +*/ + max_supp_power_limit = ((PWR_LIM_VAL ) >> hwmon->scl_shift_power) *SF_POWER ; +if (value > max_supp_power_limit) { + value = max_supp_power_limit; +drm_info (&hwmon->xe->drm, +"Power limit clamped as selected %s exceeds channel %d limit\n" , +PWR_ATTR_TO_STR (attr), channel); + } +/* Computation in 64-bits to avoid overflow. Round to nearest. */ reg_val =DIV_ROUND_CLOSEST_ULL ((u64 )value << hwmon->scl_shift_power,SF_POWER ); reg_val =PWR_LIM_EN |REG_FIELD_PREP (PWR_LIM_VAL , reg_val);
@@ -697,9 +712,23 @@ static int xe_hwmon_power_curr_crit_write(struct xe_hwmon *hwmon, int channel, {int ret;u32 uval; +u64 max_crit_power_curr =0 ;mutex_lock (&hwmon->hwmon_lock); +/* +* If the sysfs value exceeds the pcode mailbox cmd POWER_SETUP_SUBCOMMAND_WRITE_I1 +* max supported value, clamp it to the command's max (U10.6 format). +* This is to avoid truncation during uval calculation below and ensure the valid power +* limit is sent for pcode which would clamp it to card-supported value. +*/ + max_crit_power_curr = (POWER_SETUP_I1_DATA_MASK >>POWER_SETUP_I1_SHIFT ) * scale_factor; +if (value > max_crit_power_curr) { + value = max_crit_power_curr; +drm_info (&hwmon->xe->drm, +"Power limit clamped as selected exceeds channel %d limit\n" , + channel); + } uval =DIV_ROUND_CLOSEST_ULL (value <<POWER_SETUP_I1_SHIFT , scale_factor); ret =xe_hwmon_pcode_write_i1 (hwmon, uval);
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 481/570 drm/amdgpu: fix vram reservation issue
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: YiPeng Chai <[email protected]>
[ Upstream commit 10ef476aad1c848449934e7bec2ab2374333c7b6 ]
The vram block allocation flag must be cleared before making vram reservation, otherwise reserving addresses within the currently freed memory range will always fail.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1 -2
@@ -648,9 +648,8 @@ static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,list_for_each_entry (block, &vres->blocks, link) vis_usage +=amdgpu_vram_mgr_vis_size (adev, block); -amdgpu_vram_mgr_do_reserve (man); -drm_buddy_free_list (mm, &vres->blocks, vres->flags); +amdgpu_vram_mgr_do_reserve (man);mutex_unlock (&mgr->lock);atomic64_sub (vis_usage, &mgr->vis_usage);
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 482/570 drm/amdgpu: fix incorrect vm flags to map bo
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Xiao <[email protected]>
[ Upstream commit 040bc6d0e0e9c814c9c663f6f1544ebaff6824a8 ]
It should use vm flags instead of pte flags
to specify bo vm attributes.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +2 -2
@@ -88,8 +88,8 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, } r =amdgpu_vm_bo_map (adev, *bo_va, csa_addr,0 , size, -AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE | -AMDGPU_PTE_EXECUTABLE ); +AMDGPU_VM_PAGE_READABLE |AMDGPU_VM_PAGE_WRITEABLE | +AMDGPU_VM_PAGE_EXECUTABLE );if (r) {DRM_ERROR ("failed to do bo_map on static CSA, err=%d\n" , r);
Signature · 1 line
2.50.1
RE: [PATCH 6.16 482/570] drm/amdgpu: fix incorrect vm flags to map bo
[Public]
Quoted 13 lines
-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, August 18, 2025 8:48 AM
To: [email protected]
Cc: Greg Kroah-Hartman <[email protected]>; [email protected]; Xiao, Jack <[email protected]>; Gao, Likun <[email protected]>; Deucher, Alexander <[email protected]>; Sasha Levin <[email protected]>
Subject: [PATCH 6.16 482/570] drm/amdgpu: fix incorrect vm flags to map bo6.16-stable review patch. If anyone has any objections, please let me know.
------------------
Quoted 7 lines
From: Jack Xiao <[email protected]>
[ Upstream commit
040bc6d0e0e9c814c9c663f6f1544ebaff6824a8]It should use vm flags instead of pte flags to specify bo vm attributes.
Fixes 7946340fa389 ("drm/amdgpu: Move csa related code to separate file")
I accidently tagged this with the wrong fixes tag. This patch should not go to anything other than 6.17. Sorry for the confusion. Please revert for older kernels.
Thanks,
Alex
Quoted 32 lines
Signed-off-by Jack Xiao <[email protected]>Reviewed-by Likun Gao <[email protected]>Signed-off-by Alex Deucher <[email protected]> (cherry picked fromcommit
b08425fa77ad2f305fe57a33dceb456be03b653f)Signed-off-by Sasha Levin <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +0
-1@@ -88,8 +88,8 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev,struct amdgpu_vm *vm, } r = amdgpu_vm_bo_map(adev, *bo_va, csa_addr, 0, size, - AMDGPU_PTE_READABLE |
AMDGPU_PTE_WRITEABLE|drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +1
-1- AMDGPU_PTE_EXECUTABLE); + AMDGPU_VM_PAGE_READABLE |
AMDGPU_VM_PAGE_WRITEABLE|
+AMDGPU_VM_PAGE_EXECUTABLE);if (r) { DRM_ERROR("failed to do bo_map on static CSA, err=%d\n", r);--
2.50.1
Greg Kroah-Hartman
maintainerRe: [PATCH 6.16 482/570] drm/amdgpu: fix incorrect vm flags to map bo
Quoted 17 lines · Alexander
[Public]
Quoted 15 lines
-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, August 18, 2025 8:48 AM
To: [email protected]
Cc: Greg Kroah-Hartman <[email protected]>; [email protected]; Xiao, Jack <[email protected]>; Gao, Likun <[email protected]>; Deucher, Alexander <[email protected]>; Sasha Levin <[email protected]>
Subject: [PATCH 6.16 482/570] drm/amdgpu: fix incorrect vm flags to map bo6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Xiao <[email protected]>
Quoted 7 lines
Quoted 5 lines
[ Upstream commit
040bc6d0e0e9c814c9c663f6f1544ebaff6824a8]It should use vm flags instead of pte flags to specify bo vm attributes.
Fixes 7946340fa389 ("drm/amdgpu: Move csa related code to separate file")I accidently tagged this with the wrong fixes tag. This patch should not go to anything other than 6.17. Sorry for the confusion. Please revert for older kernels.
So no stable releases at all?
And can you send a revert, this is already in released kernels.
thanks,
greg k-h
RE: [PATCH 6.16 482/570] drm/amdgpu: fix incorrect vm flags to map bo
[Public]
Quoted 37 lines
-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, August 25, 2025 4:19 PM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]; [email protected]; Xiao, Jack <[email protected]>; Gao, Likun <[email protected]>; Sasha Levin <[email protected]>
Subject: Re: [PATCH 6.16 482/570] drm/amdgpu: fix incorrect vm flags to map boQuoted 9 lines · Alexander
[Public]
Quoted 7 lines
-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, August 18, 2025 8:48 AM
To: [email protected]
Cc: Greg Kroah-Hartman <[email protected]>; [email protected]; Xiao, Jack <[email protected]>; Gao, Likun <[email protected]>; Deucher, AlexanderQuoted 17 lines
Quoted 16 lines
Sasha Levin <[email protected]>
Subject: [PATCH 6.16 482/570] drm/amdgpu: fix incorrect vm flags to map bo6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Xiao <[email protected]>
[ Upstream commit
040bc6d0e0e9c814c9c663f6f1544ebaff6824a8]It should use vm flags instead of pte flags to specify bo vm attributes.
Fixes 7946340fa389 ("drm/amdgpu: Move csa related code to separatefile")
Quoted 6 lines
Quoted 1 line
I accidently tagged this with the wrong fixes tag. This patch should not go to
anything other than 6.17. Sorry for the confusion. Please revert for older kernels.
So no stable releases at all?
And can you send a revert, this is already in released kernels.
Turns out this was not supposed to go to 6.17 either. I'll just send the revert in my -fixes PR this week and let the revert flow back via the standard channels. Sorry for the noise.
Alex
Greg Kroah-Hartman
maintainerPATCH 483/570 x86/sev: Improve handling of writes to intercepted TSC MSRs
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikunj A Dadhania <[email protected]>
[ Upstream commit 5eb1bcdb6a8c088514019c3a9bda5d565beed1af ]
Currently, when a Secure TSC enabled SNP guest attempts to write to the intercepted GUEST_TSC_FREQ MSR (a read-only MSR), the guest kernel response incorrectly implies a VMM configuration error, when in fact it is the usual VMM configuration to intercept writes to read-only MSRs, unless explicitly documented.
Modify the intercepted TSC MSR #VC handling:
* Write to GUEST_TSC_FREQ will generate a #GP instead of terminating the guest
* Write to MSR_IA32_TSC will generate a #GP instead of silently ignoring it
However, continue to terminate the guest when reading from intercepted GUEST_TSC_FREQ MSR with Secure TSC enabled, as intercepted reads indicate an improper VMM configuration for Secure TSC enabled SNP guests.
[ bp: simplify comment. ]
--- arch/x86/coco/sev/vc-handle.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
arch/x86/coco/sev/vc-handle.c +16 -15
@@ -371,29 +371,30 @@ static enum es_result __vc_handle_msr_caa(struct pt_regs *regs, bool write)* executing with Secure TSC enabled, so special handling is required for * accesses of MSR_IA32_TSC and MSR_AMD64_GUEST_TSC_FREQ. */ -static enum es_result __vc_handle_secure_tsc_msrs (struct pt_regs *regs,bool write) +static enum es_result __vc_handle_secure_tsc_msrs (struct es_em_ctxt *ctxt,bool write) { +struct pt_regs *regs = ctxt->regs;u64 tsc;/* -* GUEST_TSC_FREQ should not be intercepted when Secure TSC is enabled. -* Terminate the SNP guest when the interception is enabled. +* Writing to MSR_IA32_TSC can cause subsequent reads of the TSC to +* return undefined values, and GUEST_TSC_FREQ is read-only. Generate +* a #GP on all writes. */ -if (regs->cx ==MSR_AMD64_GUEST_TSC_FREQ ) -return ES_VMM_ERROR ; +if (write) { + ctxt->fi.vector =X86_TRAP_GP ; + ctxt->fi.error_code =0 ; +return ES_EXCEPTION ; + }/* -* Writes: Writing to MSR_IA32_TSC can cause subsequent reads of the TSC -* to return undefined values, so ignore all writes. -* -* Reads: Reads of MSR_IA32_TSC should return the current TSC value, use -* the value returned by rdtsc_ordered(). +* GUEST_TSC_FREQ read should not be intercepted when Secure TSC is +* enabled. Terminate the guest if a read is attempted. */ -if (write) { -WARN_ONCE (1 ,"TSC MSR writes are verboten!\n" ); -return ES_OK ; - } +if (regs->cx ==MSR_AMD64_GUEST_TSC_FREQ ) +return ES_VMM_ERROR ; +/* Reads of MSR_IA32_TSC should return the current TSC value. */ tsc =rdtsc_ordered (); regs->ax =lower_32_bits (tsc); regs->dx =upper_32_bits (tsc);
@@ -416,7 +417,7 @@ static enum es_result vc_handle_msr(struct ghcb *ghcb, struct es_em_ctxt *ctxt)case MSR_IA32_TSC :case MSR_AMD64_GUEST_TSC_FREQ :if (sev_status &MSR_AMD64_SNP_SECURE_TSC ) -return __vc_handle_secure_tsc_msrs (regs, write); +return __vc_handle_secure_tsc_msrs (ctxt, write);break ;default :break ;
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 484/570 x86/fpu: Fix NULL dereference in avx512_status()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fushuai Wang <[email protected]>
commit 31cd31c9e17ece125aad27259501a2af69ccb020 upstream.
Problem
-------
With CONFIG_X86_DEBUG_FPU enabled, reading /proc/[kthread]/arch_status causes a warning and a NULL pointer dereference.
This is because the AVX-512 timestamp code uses x86_task_fpu() but doesn't check it for NULL. CONFIG_X86_DEBUG_FPU addles that function for kernel threads (PF_KTHREAD specifically), making it return NULL.
The point of the warning was to ensure that kernel threads only access task->fpu after going through kernel_fpu_begin()/_end(). Note: all kernel tasks exposed in /proc have a valid task->fpu.
Solution
--------
One option is to silence the warning and check for NULL from x86_task_fpu(). However, that warning is fairly fresh and seems like a defense against misuse of the FPU state in kernel threads.
Instead, stop outputting AVX-512_elapsed_ms for kernel threads altogether. The data was garbage anyway because avx512_timestamp is only updated for user threads, not kernel threads.
If anyone ever wants to track kernel thread AVX-512 use, they can come back later and do it properly, separate from this bug fix.
[ dhansen: mostly rewrite changelog ]
--- arch/x86/kernel/fpu/xstate.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
arch/x86/kernel/fpu/xstate.c +10 -9
@@ -1855,19 +1855,20 @@ long fpu_xstate_prctl(int option, unsign#ifdef CONFIG_PROC_PID_ARCH_STATUS /* * Report the amount of time elapsed in millisecond since last AVX512 -* use in the task. +* use in the task. Report -1 if no AVX-512 usage. */ static void avx512_status (struct seq_file *m,struct task_struct *task) { -unsigned long timestamp =READ_ONCE (x86_task_fpu (task)->avx512_timestamp); -long delta; +unsigned long timestamp; +long delta =-1 ; -if (!timestamp) { -/* -* Report -1 if no AVX512 usage -*/ - delta =-1 ; - }else { +/* AVX-512 usage is not tracked for kernel threads. Don't report anything. */ +if (task->flags & (PF_KTHREAD |PF_USER_WORKER )) +return ; + + timestamp =READ_ONCE (x86_task_fpu (task)->avx512_timestamp); + +if (timestamp) { delta = (long )(jiffies - timestamp);/* * Cap to LONG_MAX if time difference > LONG_MAX
Greg Kroah-Hartman
maintainerPATCH 485/570 x86/sev: Ensure SVSM reserved fields in a page validation entry are initialized to zero
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Lendacky <[email protected]>
commit 3ee9cebd0a5e7ea47eb35cec95eaa1a866af982d upstream.
In order to support future versions of the SVSM_CORE_PVALIDATE call, all reserved fields within a PVALIDATE entry must be set to zero as an SVSM should be ensuring all reserved fields are zero in order to support future usage of reserved areas based on the protocol version.
--- arch/x86/boot/startup/sev-shared.c | 1 + arch/x86/coco/sev/core.c | 2 ++ 2 files changed, 3 insertions(+)
arch/x86/boot/startup/sev-shared.c +1 -0
@@ -785,6 +785,7 @@ static void __head svsm_pval_4k_page(uns pc->entry[0 ].page_size =RMP_PG_SIZE_4K ; pc->entry[0 ].action = validate; pc->entry[0 ].ignore_cf =0 ; + pc->entry[0 ].rsvd =0 ; pc->entry[0 ].pfn = paddr >>PAGE_SHIFT ;/* Protocol 0, Call ID 1 */
arch/x86/coco/sev/core.c +2 -0
@@ -227,6 +227,7 @@ static u64 svsm_build_ca_from_pfn_range( pe->page_size =RMP_PG_SIZE_4K ; pe->action = action; pe->ignore_cf =0 ; + pe->rsvd =0 ; pe->pfn = pfn; pe++;
@@ -257,6 +258,7 @@ static int svsm_build_ca_from_psc_desc(s pe->page_size = e->pagesize ?RMP_PG_SIZE_2M :RMP_PG_SIZE_4K ; pe->action = e->operation ==SNP_PAGE_STATE_PRIVATE ; pe->ignore_cf =0 ; + pe->rsvd =0 ; pe->pfn = e->gfn; pe++;
Greg Kroah-Hartman
maintainerPATCH 486/570 futex: Use user_write_access_begin/_end() in futex_put_value()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
commit dfb36e4a8db0cd56f92d4cb445f54e85a9b40897 upstream.
Commit cec199c5e39b ("futex: Implement FUTEX2_NUMA") introduced the futex_put_value() helper to write a value to the given user address.
However, it uses user_read_access_begin() before the write. For architectures that differentiate between read and write accesses, like PowerPC, futex_put_value() fails with -EFAULT.
Fix that by using the user_write_access_begin/user_write_access_end() pair instead.
--- kernel/futex/futex.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/futex/futex.h +3 -3
@@ -321,13 +321,13 @@ static __always_inline int futex_put_val {if (can_do_masked_user_access ()) to =masked_user_access_begin (to); -else if (!user_read_access_begin (to,sizeof (*to))) +else if (!user_write_access_begin (to,sizeof (*to)))return -EFAULT ;unsafe_put_user (val, to, Efault); -user_read_access_end (); +user_write_access_end ();return 0 ; Efault: -user_read_access_end (); +user_write_access_end ();return -EFAULT ; }
Greg Kroah-Hartman
maintainerPATCH 487/570 rust: kbuild: clean output before running `rustdoc`
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miguel Ojeda <[email protected]>
commit 252fea131e15aba2cd487119d1a8f546471199e2 upstream.
rustdoc can get confused when generating documentation into a folder that contains generated files from other rustdoc versions.
For instance, running something like:
rustup default 1.78.0
make LLVM=1 rustdoc
rustup default 1.88.0
make LLVM=1 rustdoc
may generate errors like:
error: couldn't generate documentation: invalid template: last line expected to start with a comment
|
= note: failed to create or modify "./Documentation/output/rust/rustdoc/src-files.js"
Thus just always clean the output folder before generating the documentation -- we are anyway regenerating it every time the rustdoc target gets called, at least for the time being.
--- rust/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
rust/Makefile +7 -3
@@ -103,14 +103,14 @@ rustdoc: rustdoc-core rustdoc-macros rus rustdoc-macros: private rustdoc_host = yes rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \ --extern proc_macro -rustdoc-macros: $(src)/macros/lib.rs FORCE +rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean FORCE +$(call if_changed,rustdoc) # Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should # not be needed -- see https://github.com/rust-lang/rust/pull/128307. rustdoc-core: private skip_flags = --edition=2021 -Wrustdoc::unescaped_backticks rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs) -rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs FORCE +rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE +$(call if_changed,rustdoc) rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
@@ -122,7 +122,8 @@ rustdoc-ffi: $(src)/ffi.rs rustdoc-core rustdoc-pin_init_internal: private rustdoc_host = yes rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \ --extern proc_macro --crate-type proc-macro -rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs FORCE +rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \ + rustdoc-clean FORCE +$(call if_changed,rustdoc) rustdoc-pin_init: private rustdoc_host = yes
@@ -140,6 +141,9 @@ rustdoc-kernel: $(src)/kernel/lib.rs rus $(obj)/bindings.o FORCE +$(call if_changed,rustdoc) +rustdoc-clean: FORCE + $(Q)rm -rf $(rustdoc_output) + quiet_cmd_rustc_test_library = $(RUSTC_OR_CLIPPY_QUIET) TL $< cmd_rustc_test_library = \ OBJTREE=$(abspath $(objtree)) \
Greg Kroah-Hartman
maintainerPATCH 488/570 rust: workaround `rustdoc` target modifiers bug
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miguel Ojeda <[email protected]>
commit abbf9a44944171ca99c150adad9361a2f517d3b6 upstream.
Starting with Rust 1.88.0 (released 2025-06-26), rustdoc complains about a target modifier mismatch in configurations where -Zfixed-x18 is passed:
error: mixing -Zfixed-x18 will cause an ABI mismatch in crate rust_out
|
= help: the -Zfixed-x18 flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely = note: unset -Zfixed-x18 in this crate is incompatible with -Zfixed-x18= in dependency core
= help: set -Zfixed-x18= in this crate or unset -Zfixed-x18 in core
= help: if you are sure this will not cause problems, you may use -Cunsafe-allow-abi-mismatch=fixed-x18 to silence this error
The reason is that rustdoc was not passing the target modifiers when configuring the session options, and thus it would report a mismatch that did not exist as soon as a target modifier is used in a dependency.
We did not notice it in the kernel until now because -Zfixed-x18 has been a target modifier only since 1.88.0 (and it is the only one we use so far).
The issue has been reported upstream [1] and a fix has been submitted [2], including a test similar to the kernel case.
[ This is now fixed upstream (thanks Guillaume for the quick review),
so it will be fixed in Rust 1.90.0 (expected 2025-09-18).
- Miguel ]
Meanwhile, conditionally pass -Cunsafe-allow-abi-mismatch=fixed-x18 to workaround the issue on our side.
--- rust/Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
rust/Makefile +6 -0
@@ -62,6 +62,10 @@ core-cfgs = \ core-edition := $(if $(call rustc-min-version,108700),2024,2021) +# `rustdoc` did not save the target modifiers, thus workaround for +# the time being (https://github.com/rust-lang/rust/issues/144521). +rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18) + # `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only # since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust # 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
@@ -74,6 +78,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustd -Zunstable-options --generate-link-to-definition \ --output $(rustdoc_output) \ --crate-name $(subst rustdoc-,,$@) \ + $(rustdoc_modifiers_workaround) \ $(if $(rustdoc_host),,--sysroot=/dev/null) \ @$(objtree)/include/generated/rustc_cfg $<
@@ -216,6 +221,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC --extern bindings --extern uapi \ --no-run --crate-name kernel -Zunstable-options \ --sysroot=/dev/null \ + $(rustdoc_modifiers_workaround) \ --test-builder $(objtree)/scripts/rustdoc_test_builder \ $< $(rustdoc_test_kernel_quiet); \ $(objtree)/scripts/rustdoc_test_gen
Greg Kroah-Hartman
maintainerPATCH 489/570 samples/damon/wsse: fix boot time enable handling
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 0ed1165c37277822b519f519d0982d36efc30006 upstream.
Patch series "mm/damon: fix misc bugs in DAMON modules".
Quoted 1 line
From manual code review, I found below bugs in DAMON modules.
DAMON sample modules crash if those are enabled at boot time, via kernel command line. A similar issue was found and fixed on DAMON non-sample modules in the past, but we didn't check that for sample modules.
DAMON non-sample modules are not setting 'enabled' parameters accordingly when real enabling is failed. Honggyu found and fixed[1] this type of bugs in DAMON sample modules, and my inspection was motivated by the great work. Kudos to Honggyu.
Finally, DAMON_RECLIAM is mistakenly losing scheme internal status due to misuse of damon_commit_ctx(). DAMON_LRU_SORT has a similar misuse, but fortunately it is not causing real status loss.
Fix the bugs. Since these are similar patterns of bugs that were found in the past, it would be better to add tests or refactor the code, in future.
This patch (of 6):
If 'enable' parameter of the 'wsse' DAMON sample module is set at boot time via the kernel command line, memory allocation is tried before the slab is initialized. As a result kernel NULL pointer dereference BUG can happen. Fix it by checking the initialization status.
--- samples/damon/wsse.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
samples/damon/wsse.c +11 -1
@@ -89,6 +89,8 @@ static void damon_sample_wsse_stop(void)put_pid (target_pidp); } +static bool init_called; +static int damon_sample_wsse_enable_store (const char *val,const struct kernel_param *kp) {
@@ -114,7 +116,15 @@ static int damon_sample_wsse_enable_storstatic int __init damon_sample_wsse_init (void ) { -return 0 ; +int err =0 ; + + init_called = true; +if (enable) { + err =damon_sample_wsse_start (); +if (err) + enable = false; + } +return err; }module_init (damon_sample_wsse_init);
Greg Kroah-Hartman
maintainerPATCH 490/570 samples/damon/mtier: support boot time enable setup
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 964314344eab7bc43e38a32be281c5ea0609773b upstream.
If 'enable' parameter of the 'mtier' DAMON sample module is set at boot time via the kernel command line, memory allocation is tried before the slab is initialized. As a result kernel NULL pointer dereference BUG can happen. Fix it by checking the initialization status.
--- samples/damon/mtier.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
samples/damon/mtier.c +10 -0
@@ -151,6 +151,8 @@ static void damon_sample_mtier_stop(voiddamon_destroy_ctx (ctxs[1 ]); } +static bool init_called; +static int damon_sample_mtier_enable_store (const char *val,const struct kernel_param *kp) {
@@ -176,6 +178,14 @@ static int damon_sample_mtier_enable_stostatic int __init damon_sample_mtier_init (void ) { +int err =0 ; + + init_called = true; +if (enable) { + err =damon_sample_mtier_start (); +if (err) + enable = false; + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 491/570 mm/damon/core: commit damos->target_nid
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bijan Tabatabai <[email protected]>
commit 579bd5006fe7f4a7abb32da0160d376476cab67d upstream.
When committing new scheme parameters from the sysfs, the target_nid field of the damos struct would not be copied. This would result in the target_nid field to retain its original value, despite being updated in the sysfs interface.
This patch fixes this issue by copying target_nid in damos_commit().
--- mm/damon/core.c | 1 + 1 file changed, 1 insertion(+)
mm/damon/core.c +1 -0
@@ -993,6 +993,7 @@ static int damos_commit(struct damos *dsreturn err; dst->wmarks = src->wmarks; + dst->target_nid = src->target_nid; err =damos_commit_filters (dst, src);return err;
Greg Kroah-Hartman
maintainerPATCH 492/570 block: Introduce bio_needs_zone_write_plugging()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit f70291411ba20d50008db90a6f0731efac27872c upstream.
In preparation for fixing device mapper zone write handling, introduce the inline helper function bio_needs_zone_write_plugging() to test if a BIO requires handling through zone write plugging using the function blk_zone_plug_bio(). This function returns true for any write (op_is_write(bio) == true) operation directed at a zoned block device using zone write plugging, that is, a block device with a disk that has a zone write plug hash table.
This helper allows simplifying the check on entry to blk_zone_plug_bio() and used in to protect calls to it for blk-mq devices and DM devices.
--- block/blk-mq.c | 6 +++-- block/blk-zoned.c | 20 ----------------- drivers/md/dm.c | 4 ++- include/linux/blkdev.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 22 deletions(-)
block/blk-mq.c +4 -2
@@ -3169,8 +3169,10 @@ void blk_mq_submit_bio(struct bio *bio)if (blk_mq_attempt_bio_merge (q, bio, nr_segs)) goto queue_exit; -if (blk_queue_is_zoned (q) &&blk_zone_plug_bio (bio, nr_segs)) - goto queue_exit; +if (bio_needs_zone_write_plugging (bio)) { +if (blk_zone_plug_bio (bio, nr_segs)) + goto queue_exit; + } new_request:if (rq) {
block/blk-zoned.c +1 -19
@@ -1116,25 +1116,7 @@ bool blk_zone_plug_bio(struct bio *bio, {struct block_device *bdev = bio->bi_bdev; -if (!bdev->bd_disk->zone_wplugs_hash) -return false; - -/* -* If the BIO already has the plugging flag set, then it was already -* handled through this path and this is a submission from the zone -* plug bio submit work. -*/ -if (bio_flagged (bio,BIO_ZONE_WRITE_PLUGGING )) -return false; - -/* -* We do not need to do anything special for empty flush BIOs, e.g -* BIOs such as issued by blkdev_issue_flush(). The is because it is -* the responsibility of the user to first wait for the completion of -* write operations for flush to have any effect on the persistence of -* the written data. -*/ -if (op_is_flush (bio->bi_opf) && !bio_sectors (bio)) +if (WARN_ON_ONCE (!bdev->bd_disk->zone_wplugs_hash))return false;/*
drivers/md/dm.c +3 -1
@@ -1788,7 +1788,9 @@ static inline bool dm_zone_bio_needs_spl }static inline bool dm_zone_plug_bio (struct mapped_device *md,struct bio *bio) { -return dm_emulate_zone_append (md) &&blk_zone_plug_bio (bio,0 ); +if (!bio_needs_zone_write_plugging (bio)) +return false; +return blk_zone_plug_bio (bio,0 ); } static blk_status_t __send_zone_reset_all_emulated(struct clone_info *ci,
include/linux/blkdev.h +55 -0
67 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 493/570 dm: Always split write BIOs to zoned device limits
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 2df7168717b7d2d32bcf017c68be16e4aae9dd13 upstream.
Any zoned DM target that requires zone append emulation will use the block layer zone write plugging. In such case, DM target drivers must not split BIOs using dm_accept_partial_bio() as doing so can potentially lead to deadlocks with queue freeze operations. Regular write operations used to emulate zone append operations also cannot be split by the target driver as that would result in an invalid writen sector value return using the BIO sector.
In order for zoned DM target drivers to avoid such incorrect BIO splitting, we must ensure that large BIOs are split before being passed to the map() function of the target, thus guaranteeing that the limits for the mapped device are not exceeded.
dm-crypt and dm-flakey are the only target drivers supporting zoned devices and using dm_accept_partial_bio().
In the case of dm-crypt, this function is used to split BIOs to the internal max_write_size limit (which will be suppressed in a different patch). However, since crypt_alloc_buffer() uses a bioset allowing only up to BIO_MAX_VECS (256) vectors in a BIO. The dm-crypt device max_segments limit, which is not set and so default to BLK_MAX_SEGMENTS (128), must thus be respected and write BIOs split accordingly.
In the case of dm-flakey, since zone append emulation is not required, the block layer zone write plugging is not used and no splitting of BIOs required.
Modify the function dm_zone_bio_needs_split() to use the block layer helper function bio_needs_zone_write_plugging() to force a call to bio_split_to_limits() in dm_split_and_process_bio(). This allows DM target drivers to avoid using dm_accept_partial_bio() for write operations on zoned DM devices.
--- drivers/md/dm.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/md/dm.c +22 -7
@@ -1780,12 +1780,29 @@ static inline bool dm_zone_bio_needs_spl struct bio *bio) {/* -* For mapped device that need zone append emulation, we must -* split any large BIO that straddles zone boundaries. +* Special case the zone operations that cannot or should not be split. */ -return dm_emulate_zone_append (md) &&bio_straddles_zones (bio) && - !bio_flagged (bio,BIO_ZONE_WRITE_PLUGGING ); +switch (bio_op (bio)) { +case REQ_OP_ZONE_APPEND : +case REQ_OP_ZONE_FINISH : +case REQ_OP_ZONE_RESET : +case REQ_OP_ZONE_RESET_ALL : +return false; +default : +break ; + } + +/* +* Mapped devices that require zone append emulation will use the block +* layer zone write plugging. In such case, we must split any large BIO +* to the mapped device limits to avoid potential deadlocks with queue +* freeze operations. +*/ +if (!dm_emulate_zone_append (md)) +return false; +return bio_needs_zone_write_plugging (bio) ||bio_straddles_zones (bio); } +static inline bool dm_zone_plug_bio (struct mapped_device *md,struct bio *bio) {if (!bio_needs_zone_write_plugging (bio))
@@ -1934,9 +1951,7 @@ static void dm_split_and_process_bio(str is_abnormal =is_abnormal_io (bio);if (static_branch_unlikely (&zoned_enabled)) { -/* Special case REQ_OP_ZONE_RESET_ALL as it cannot be split. */ - need_split = (bio_op (bio) !=REQ_OP_ZONE_RESET_ALL ) && - (is_abnormal ||dm_zone_bio_needs_split (md, bio)); + need_split = is_abnormal ||dm_zone_bio_needs_split (md, bio); }else { need_split = is_abnormal; }
Greg Kroah-Hartman
maintainerPATCH 494/570 clk: qcom: gcc-ipq8074: fix broken freq table for nss_port6_tx_clk_src
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
commit 077ec7bcec9a8987d2a133afb7e13011878c7576 upstream.
With the conversion done by commit e88f03230dc0 ("clk: qcom: gcc-ipq8074:
rework nss_port5/6 clock to multiple conf") a Copy-Paste error was made for the nss_port6_tx_clk_src frequency table.
This was caused by the wrong setting of the parent in ftbl_nss_port6_tx_clk_src that was wrongly set to P_UNIPHY1_RX instead of P_UNIPHY2_TX.
This cause the UNIPHY2 port to malfunction when it needs to be scaled to higher clock. The malfunction was observed with the example scenario with an Aquantia 10G PHY connected and a speed higher than 1G (example 2.5G)
Fix the broken frequency table to restore original functionality.
--- drivers/clk/qcom/gcc-ipq8074.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/qcom/gcc-ipq8074.c +3 -3
@@ -1895,10 +1895,10 @@ static const struct freq_conf ftbl_nss_pstatic const struct freq_multi_tbl ftbl_nss_port6_tx_clk_src[] = {FMS (19200000 ,P_XO ,1 ,0 ,0 ),FM (25000000 , ftbl_nss_port6_tx_clk_src_25), -FMS (78125000 ,P_UNIPHY1_RX ,4 ,0 ,0 ), +FMS (78125000 ,P_UNIPHY2_TX ,4 ,0 ,0 ),FM (125000000 , ftbl_nss_port6_tx_clk_src_125), -FMS (156250000 ,P_UNIPHY1_RX ,2 ,0 ,0 ), -FMS (312500000 ,P_UNIPHY1_RX ,1 ,0 ,0 ), +FMS (156250000 ,P_UNIPHY2_TX ,2 ,0 ,0 ), +FMS (312500000 ,P_UNIPHY2_TX ,1 ,0 ,0 ), { } };
Greg Kroah-Hartman
maintainerPATCH 495/570 clk: qcom: dispcc-sm8750: Fix setting rate byte and pixel clocks
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 0acf9e65a47d1e489c8b24c45a64436e30bcccf4 upstream.
On SM8750 the setting rate of pixel and byte clocks, while the parent DSI PHY PLL, fails with:
disp_cc_mdss_byte0_clk_src: rcg didn't update its configuration.
DSI PHY PLL has to be unprepared and its "PLL Power Down" bits in CMN_CTRL_0 asserted.
Mark these clocks with CLK_OPS_PARENT_ENABLE to ensure the parent is enabled during rate changes.
--- drivers/clk/qcom/dispcc-sm8750.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/clk/qcom/dispcc-sm8750.c +5 -5
@@ -393,7 +393,7 @@ static struct clk_rcg2 disp_cc_mdss_byte .name = "disp_cc_mdss_byte0_clk_src", .parent_data = disp_cc_parent_data_1, .num_parents = ARRAY_SIZE(disp_cc_parent_data_1), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_byte2_ops, }, };
@@ -408,7 +408,7 @@ static struct clk_rcg2 disp_cc_mdss_byte .name = "disp_cc_mdss_byte1_clk_src", .parent_data = disp_cc_parent_data_1, .num_parents = ARRAY_SIZE(disp_cc_parent_data_1), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_byte2_ops, }, };
@@ -712,7 +712,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk .name = "disp_cc_mdss_pclk0_clk_src", .parent_data = disp_cc_parent_data_1, .num_parents = ARRAY_SIZE(disp_cc_parent_data_1), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
@@ -727,7 +727,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk .name = "disp_cc_mdss_pclk1_clk_src", .parent_data = disp_cc_parent_data_1, .num_parents = ARRAY_SIZE(disp_cc_parent_data_1), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
@@ -742,7 +742,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk .name = "disp_cc_mdss_pclk2_clk_src", .parent_data = disp_cc_parent_data_1, .num_parents = ARRAY_SIZE(disp_cc_parent_data_1), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
Greg Kroah-Hartman
maintainerPATCH 496/570 cifs: reset iface weights when we cannot find a candidate
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit 9d5eff7821f6d70f7d1b4d8a60680fba4de868a7 upstream.
We now do a weighted selection of server interfaces when allocating new channels. The weights are decided based on the speed advertised. The fulfilled weight for an interface is a counter that is used to track the interface selection. It should be reset back to zero once all interfaces fulfilling their weight.
In cifs_chan_update_iface, this reset logic was missing. As a result when the server interface list changes, the client may not be able to find a new candidate for other channels after all interfaces have been fulfilled.
--- fs/smb/client/sess.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/smb/client/sess.c +9 -0
@@ -332,6 +332,7 @@ cifs_chan_update_iface(struct cifs_ses *struct cifs_server_iface *old_iface =NULL ;struct cifs_server_iface *last_iface =NULL ;struct sockaddr_storage ss; +int retry =0 ;spin_lock (&ses->chan_lock); chan_index =cifs_ses_get_chan_index (ses, server);
@@ -360,6 +361,7 @@ cifs_chan_update_iface(struct cifs_ses *return ; } +try_again: last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface, iface_head); iface_min_speed = last_iface->speed;
@@ -397,6 +399,13 @@ cifs_chan_update_iface(struct cifs_ses * }if (list_entry_is_head (iface, &ses->iface_list, iface_head)) { +list_for_each_entry (iface, &ses->iface_list, iface_head) + iface->weight_fulfilled =0 ; + +/* see if it can be satisfied in second attempt */ +if (!retry++) + goto try_again; + iface =NULL ;cifs_dbg (FYI ,"unable to find a suitable iface\n" ); }
Greg Kroah-Hartman
maintainerPATCH 497/570 iommu/vt-d: Optimize iotlb_sync_map for non-caching/non-RWBF modes
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
commit 12724ce3fe1a3d8f30d56e48b4f272d8860d1970 upstream.
The iotlb_sync_map iommu ops allows drivers to perform necessary cache flushes when new mappings are established. For the Intel iommu driver, this callback specifically serves two purposes:
- To flush caches when a second-stage page table is attached to a device whose iommu is operating in caching mode (CAP_REG.CM==1).
- To explicitly flush internal write buffers to ensure updates to memory- resident remapping structures are visible to hardware (CAP_REG.RWBF==1).
However, in scenarios where neither caching mode nor the RWBF flag is active, the cache_tag_flush_range_np() helper, which is called in the iotlb_sync_map path, effectively becomes a no-op.
Despite being a no-op, cache_tag_flush_range_np() involves iterating through all cache tags of the iommu's attached to the domain, protected by a spinlock. This unnecessary execution path introduces overhead, leading to a measurable I/O performance regression. On systems with NVMes under the same bridge, performance was observed to drop from approximately ~6150 MiB/s down to ~4985 MiB/s.
Introduce a flag in the dmar_domain structure. This flag will only be set when iotlb_sync_map is required (i.e., when CM or RWBF is set). The cache_tag_flush_range_np() is called only for domains where this flag is set. This flag, once set, is immutable, given that there won't be mixed configurations in real-world scenarios where some IOMMUs in a system operate in caching mode while others do not. Theoretically, the immutability of this flag does not impact functionality.
--- drivers/iommu/intel/iommu.c | 19 ++++++++++++++++++- drivers/iommu/intel/iommu.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +18 -1
@@ -1795,6 +1795,18 @@ static int domain_setup_first_level(stru (pgd_t *)pgd, flags, old); } +static bool domain_need_iotlb_sync_map (struct dmar_domain *domain, +struct intel_iommu *iommu) +{ +if (cap_caching_mode (iommu->cap) && !domain->use_first_level) +return true; + +if (rwbf_quirk ||cap_rwbf (iommu->cap)) +return true; + +return false; +} +static int dmar_domain_attach_device (struct dmar_domain *domain,struct device *dev) {
@@ -1832,6 +1844,8 @@ static int dmar_domain_attach_device(strif (ret) goto out_block_translation; + domain->iotlb_sync_map |=domain_need_iotlb_sync_map (domain, iommu); +return 0 ; out_block_translation:
@@ -3953,7 +3967,10 @@ static bool risky_device(struct pci_devstatic int intel_iommu_iotlb_sync_map (struct iommu_domain *domain,unsigned long iova,size_t size) { -cache_tag_flush_range_np (to_dmar_domain (domain), iova, iova + size -1 ); +struct dmar_domain *dmar_domain =to_dmar_domain (domain); + +if (dmar_domain->iotlb_sync_map) +cache_tag_flush_range_np (dmar_domain, iova, iova + size -1 );return 0 ; }
drivers/iommu/intel/iommu.h +3 -0
@@ -614,6 +614,9 @@ struct dmar_domain { u8 has_mappings:1; /* Has mappings configured through* iommu_map() interface. */ + u8 iotlb_sync_map:1; /* Need to flush IOTLB cache or write +* buffer when creating mappings. +*/ spinlock_t lock;/* Protect device tracking lists */ struct list_head devices;/* all devices' list */
Greg Kroah-Hartman
maintainerPATCH 498/570 iommu/arm-smmu-v3: Revert vmaster in the error path
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
commit 49f42634e8054e57d09c7f9ef5e4527e116059cb upstream.
The error path for err_free_master_domain leaks the vmaster. Move all the kfrees for vmaster into the goto error section.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +4 -3
@@ -2906,8 +2906,8 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state, master_domain =kzalloc (sizeof (*master_domain),GFP_KERNEL );if (!master_domain) { -kfree (state->vmaster); -return -ENOMEM ; + ret = -ENOMEM ; + goto err_free_vmaster; } master_domain->domain = new_domain; master_domain->master = master;
@@ -2941,7 +2941,6 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state, !arm_smmu_master_canwbs(master)) {spin_unlock_irqrestore (&smmu_domain->devices_lock, flags); -kfree (state->vmaster); ret = -EINVAL ; goto err_iopf; }
@@ -2967,6 +2966,8 @@ int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state,arm_smmu_disable_iopf (master, master_domain); err_free_master_domain:kfree (master_domain); +err_free_vmaster: +kfree (state->vmaster);return ret; }
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 499/570 iommu/arm-smmu-qcom: Add SM6115 MDSS compatible
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Klimov <[email protected]>
commit f7fa8520f30373ce99c436c4d57c76befdacbef3 upstream.
Add the SM6115 MDSS compatible to clients compatible list, as it also needs that workaround.
Without this workaround, for example, QRB4210 RB2 which is based on SM4250/SM6115 generates a lot of smmu unhandled context faults during boot:
arm_smmu_context_fault: 116854 callbacks suppressed arm-smmu c600000.iommu: Unhandled context fault: fsr=0x402, iova=0x5c0ec600, fsynr=0x320021, cbfrsynra=0x420, cb=5
arm-smmu c600000.iommu: FSR = 00000402 [Format=2 TF], SID=0x420
arm-smmu c600000.iommu: FSYNR0 = 00320021 [S1CBNDX=50 PNU PLVL=1] arm-smmu c600000.iommu: Unhandled context fault: fsr=0x402, iova=0x5c0d7800, fsynr=0x320021, cbfrsynra=0x420, cb=5
arm-smmu c600000.iommu: FSR = 00000402 [Format=2 TF], SID=0x420
and also failed initialisation of lontium lt9611uxc, gpu and dpu is observed:
(binding MDSS components triggered by lt9611uxc have failed)
------------[ cut here ]------------ !aspace WARNING: CPU: 6 PID: 324 at drivers/gpu/drm/msm/msm_gem_vma.c:130 msm_gem_vma_init+0x150/0x18c [msm] Modules linked in: ... (long list of modules) CPU: 6 UID: 0 PID: 324 Comm: (udev-worker) Not tainted 6.15.0-03037-gaacc73ceeb8b #4 PREEMPT Hardware name: Qualcomm Technologies, Inc. QRB4210 RB2 (DT) pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : msm_gem_vma_init+0x150/0x18c [msm] lr : msm_gem_vma_init+0x150/0x18c [msm] sp : ffff80008144b280 ... Call trace: msm_gem_vma_init+0x150/0x18c [msm] (P) get_vma_locked+0xc0/0x194 [msm] msm_gem_get_and_pin_iova_range+0x4c/0xdc [msm] msm_gem_kernel_new+0x48/0x160 [msm] msm_gpu_init+0x34c/0x53c [msm] adreno_gpu_init+0x1b0/0x2d8 [msm] a6xx_gpu_init+0x1e8/0x9e0 [msm] adreno_bind+0x2b8/0x348 [msm] component_bind_all+0x100/0x230 msm_drm_bind+0x13c/0x3d0 [msm] try_to_bring_up_aggregate_device+0x164/0x1d0 __component_add+0xa4/0x174 component_add+0x14/0x20 dsi_dev_attach+0x20/0x34 [msm] dsi_host_attach+0x58/0x98 [msm] devm_mipi_dsi_attach+0x34/0x90 lt9611uxc_attach_dsi.isra.0+0x94/0x124 [lontium_lt9611uxc] lt9611uxc_probe+0x540/0x5fc [lontium_lt9611uxc] i2c_device_probe+0x148/0x2a8 really_probe+0xbc/0x2c0 __driver_probe_device+0x78/0x120 driver_probe_device+0x3c/0x154 __driver_attach+0x90/0x1a0 bus_for_each_dev+0x68/0xb8 driver_attach+0x24/0x30 bus_add_driver+0xe4/0x208 driver_register+0x68/0x124 i2c_register_driver+0x48/0xcc lt9611uxc_driver_init+0x20/0x1000 [lontium_lt9611uxc] do_one_initcall+0x60/0x1d4 do_init_module+0x54/0x1fc load_module+0x1748/0x1c8c init_module_from_file+0x74/0xa0 __arm64_sys_finit_module+0x130/0x2f8 invoke_syscall+0x48/0x104 el0_svc_common.constprop.0+0xc0/0xe0 do_el0_svc+0x1c/0x28 el0_svc+0x2c/0x80 el0t_64_sync_handler+0x10c/0x138 el0t_64_sync+0x198/0x19c ---[ end trace 0000000000000000 ]--- msm_dpu 5e01000.display-controller: [drm:msm_gpu_init [msm]] *ERROR* could not allocate memptrs: -22 msm_dpu 5e01000.display-controller: failed to load adreno gpu platform a400000.remoteproc:glink-edge:apr:service@7:dais: Adding to iommu group 19 msm_dpu 5e01000.display-controller: failed to bind 5900000.gpu (ops a3xx_ops [msm]): -22 msm_dpu 5e01000.display-controller: adev bind failed: -22 lt9611uxc 0-002b: failed to attach dsi to host lt9611uxc 0-002b: probe with driver lt9611uxc failed with error -22
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +1 -0
@@ -380,6 +380,7 @@ static const struct of_device_id qcom_sm { .compatible = "qcom,sdm670-mdss" }, { .compatible = "qcom,sdm845-mdss" }, { .compatible = "qcom,sdm845-mss-pil" }, + { .compatible = "qcom,sm6115-mdss" }, { .compatible = "qcom,sm6350-mdss" }, { .compatible = "qcom,sm6375-mdss" }, { .compatible = "qcom,sm8150-mdss" },
Greg Kroah-Hartman
maintainerPATCH 500/570 iommufd: Report unmapped bytes in the error path of iopt_unmap_iova_range
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
commit b23e09f9997771b4b739c1c694fa832b5fa2de02 upstream.
There are callers that read the unmapped bytes even when rc != 0. Thus, do not forget to report it in the error path too.
--- drivers/iommu/iommufd/io_pagetable.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/iommufd/io_pagetable.c +5 -2
@@ -743,8 +743,10 @@ again:iommufd_access_notify_unmap (iopt, area_first, length);/* Something is not responding to unmap requests. */ tries++; -if (WARN_ON (tries >100 )) -return -EDEADLOCK ; +if (WARN_ON (tries >100 )) { + rc = -EDEADLOCK ; + goto out_unmapped; + } goto again; }
@@ -766,6 +768,7 @@ again: out_unlock_iova:up_write (&iopt->iova_rwsem);up_read (&iopt->domains_rwsem); +out_unmapped:if (unmapped) *unmapped = unmapped_bytes;return rc;
Greg Kroah-Hartman
maintainerPATCH 501/570 iommufd: Prevent ALIGN() overflow
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit b42497e3c0e74db061eafad41c0cd7243c46436b upstream.
When allocating IOVA the candidate range gets aligned to the target alignment. If the range is close to ULONG_MAX then the ALIGN() can wrap resulting in a corrupted iova.
Open code the ALIGN() using get_add_overflow() to prevent this. This simplifies the checks as we don't need to check for length earlier either.
Consolidate the two copies of this code under a single helper.
This bug would allow userspace to create a mapping that overlaps with some other mapping or a reserved range.
--- drivers/iommu/iommufd/io_pagetable.c | 41 +++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-)
drivers/iommu/iommufd/io_pagetable.c +25 -16
@@ -70,36 +70,45 @@ struct iopt_area *iopt_area_contig_next(return iter->area; } -static bool __alloc_iova_check_hole (struct interval_tree_double_span_iter *span, -unsigned long length, -unsigned long iova_alignment, -unsigned long page_offset) +static bool __alloc_iova_check_range (unsigned long *start,unsigned long last, +unsigned long length, +unsigned long iova_alignment, +unsigned long page_offset) { -if (span->is_used || span->last_hole - span->start_hole < length -1 ) +unsigned long aligned_start; + +/* ALIGN_UP() */ +if (check_add_overflow (*start, iova_alignment -1 , &aligned_start))return false; + aligned_start &= ~(iova_alignment -1 ); + aligned_start |= page_offset; - span->start_hole =ALIGN (span->start_hole, iova_alignment) | - page_offset; -if (span->start_hole > span->last_hole || - span->last_hole - span->start_hole < length -1 ) +if (aligned_start >= last || last - aligned_start < length -1 )return false; + *start = aligned_start;return true; } -static bool __alloc_iova_check_used (struct interval_tree_span_iter *span, +static bool __alloc_iova_check_hole (struct interval_tree_double_span_iter *span,unsigned long length,unsigned long iova_alignment,unsigned long page_offset) { -if (span->is_hole || span->last_used - span->start_used < length -1 ) +if (span->is_used)return false; +return __alloc_iova_check_range (&span->start_hole, span->last_hole, + length, iova_alignment, page_offset); +} - span->start_used =ALIGN (span->start_used, iova_alignment) | - page_offset; -if (span->start_used > span->last_used || - span->last_used - span->start_used < length -1 ) +static bool __alloc_iova_check_used (struct interval_tree_span_iter *span, +unsigned long length, +unsigned long iova_alignment, +unsigned long page_offset) +{ +if (span->is_hole)return false; -return true; +return __alloc_iova_check_range (&span->start_used, span->last_used, + length, iova_alignment, page_offset); }/*
Greg Kroah-Hartman
maintainerPATCH 502/570 ext4: fix zombie groups in average fragment size lists
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 1c320d8e92925bb7615f83a7b6e3f402a5c2ca63 upstream.
Groups with no free blocks shouldn't be in any average fragment size list. However, when all blocks in a group are allocated(i.e., bb_fragments or bb_free is 0), we currently skip updating the average fragment size, which means the group isn't removed from its previous s_mb_avg_fragment_size[old] list.
This created "zombie" groups that were always skipped during traversal as they couldn't satisfy any block allocation requests, negatively impacting traversal efficiency.
Therefore, when a group becomes completely full, bb_avg_fragment_size_order is now set to -1. If the old order was not -1, a removal operation is performed; if the new order is not -1, an insertion is performed.
--- fs/ext4/mballoc.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
fs/ext4/mballoc.c +17 -17
@@ -841,30 +841,30 @@ static void mb_update_avg_fragment_size(struct super_block *sb, struct ext4_group_info *grp) { struct ext4_sb_info *sbi = EXT4_SB(sb); -int new_order; +int new, old; -if (!test_opt2 (sb,MB_OPTIMIZE_SCAN ) || grp->bb_fragments ==0 ) +if (!test_opt2 (sb,MB_OPTIMIZE_SCAN ))return ; - new_order =mb_avg_fragment_size_order (sb, - grp->bb_free / grp->bb_fragments); -if (new_order == grp->bb_avg_fragment_size_order) + old = grp->bb_avg_fragment_size_order; + new = grp->bb_fragments ==0 ?-1 : +mb_avg_fragment_size_order (sb, grp->bb_free / grp->bb_fragments); +if (new == old)return ; -if (grp->bb_avg_fragment_size_order !=-1 ) { -write_lock (&sbi->s_mb_avg_fragment_size_locks[ - grp->bb_avg_fragment_size_order]); +if (old >=0 ) { +write_lock (&sbi->s_mb_avg_fragment_size_locks[old]);list_del (&grp->bb_avg_fragment_size_node); -write_unlock (&sbi->s_mb_avg_fragment_size_locks[ - grp->bb_avg_fragment_size_order]); +write_unlock (&sbi->s_mb_avg_fragment_size_locks[old]); + } + + grp->bb_avg_fragment_size_order = new; +if (new >=0 ) { +write_lock (&sbi->s_mb_avg_fragment_size_locks[new]); +list_add_tail (&grp->bb_avg_fragment_size_node, + &sbi->s_mb_avg_fragment_size[new]); +write_unlock (&sbi->s_mb_avg_fragment_size_locks[new]); } - grp->bb_avg_fragment_size_order = new_order; -write_lock (&sbi->s_mb_avg_fragment_size_locks[ - grp->bb_avg_fragment_size_order]); -list_add_tail (&grp->bb_avg_fragment_size_node, - &sbi->s_mb_avg_fragment_size[grp->bb_avg_fragment_size_order]); -write_unlock (&sbi->s_mb_avg_fragment_size_locks[ - grp->bb_avg_fragment_size_order]); }/*
Greg Kroah-Hartman
maintainerPATCH 503/570 ext4: fix largest free orders lists corruption on mb_optimize_scan switch
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 7d345aa1fac4c2ec9584fbd6f389f2c2368671d5 upstream.
The grp->bb_largest_free_order is updated regardless of whether mb_optimize_scan is enabled. This can lead to inconsistencies between grp->bb_largest_free_order and the actual s_mb_largest_free_orders list index when mb_optimize_scan is repeatedly enabled and disabled via remount.
For example, if mb_optimize_scan is initially enabled, largest free order is 3, and the group is in s_mb_largest_free_orders[3]. Then, mb_optimize_scan is disabled via remount, block allocations occur, updating largest free order to 2. Finally, mb_optimize_scan is re-enabled via remount, more block allocations update largest free order to 1.
At this point, the group would be removed from s_mb_largest_free_orders[3] under the protection of s_mb_largest_free_orders_locks[2]. This lock mismatch can lead to list corruption.
To fix this, whenever grp->bb_largest_free_order changes, we now always attempt to remove the group from its old order list. However, we only insert the group into the new order list if mb_optimize_scan is enabled. This approach helps prevent lock inconsistencies and ensures the data in the order lists remains reliable.
--- fs/ext4/mballoc.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-)
fs/ext4/mballoc.c +14 -19
@@ -1150,33 +1150,28 @@ static void mb_set_largest_free_order(struct super_block *sb, struct ext4_group_info *grp) { struct ext4_sb_info *sbi = EXT4_SB(sb); -int i; +int new, old = grp->bb_largest_free_order; -for (i =MB_NUM_ORDERS (sb) -1 ; i >=0 ; i--) -if (grp->bb_counters[i] >0 ) +for (new =MB_NUM_ORDERS (sb) -1 ; new >=0 ; new--) +if (grp->bb_counters[new] >0 )break ; +/* No need to move between order lists? */ -if (!test_opt2 (sb,MB_OPTIMIZE_SCAN ) || - i == grp->bb_largest_free_order) { - grp->bb_largest_free_order = i; +if (new == old)return ; - } -if (grp->bb_largest_free_order >=0 ) { -write_lock (&sbi->s_mb_largest_free_orders_locks[ - grp->bb_largest_free_order]); +if (old >=0 && !list_empty (&grp->bb_largest_free_order_node)) { +write_lock (&sbi->s_mb_largest_free_orders_locks[old]);list_del_init (&grp->bb_largest_free_order_node); -write_unlock (&sbi->s_mb_largest_free_orders_locks[ - grp->bb_largest_free_order]); +write_unlock (&sbi->s_mb_largest_free_orders_locks[old]); } - grp->bb_largest_free_order = i; -if (grp->bb_largest_free_order >=0 && grp->bb_free) { -write_lock (&sbi->s_mb_largest_free_orders_locks[ - grp->bb_largest_free_order]); + + grp->bb_largest_free_order = new; +if (test_opt2 (sb,MB_OPTIMIZE_SCAN ) && new >=0 && grp->bb_free) { +write_lock (&sbi->s_mb_largest_free_orders_locks[new]);list_add_tail (&grp->bb_largest_free_order_node, - &sbi->s_mb_largest_free_orders[grp->bb_largest_free_order]); -write_unlock (&sbi->s_mb_largest_free_orders_locks[ - grp->bb_largest_free_order]); + &sbi->s_mb_largest_free_orders[new]); +write_unlock (&sbi->s_mb_largest_free_orders_locks[new]); } }
Greg Kroah-Hartman
maintainerPATCH 504/570 ext4: initialize superblock fields in the kballoc-test.c kunit tests
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
commit 82e6381e23f1ea7a14f418215068aaa2ca046c84 upstream.
Various changes in the "ext4: better scalability for ext4 block allocation" patch series have resulted in kunit test failures, most notably in the test_new_blocks_simple and the test_mb_mark_used tests. The root cause of these failures is that various in-memory ext4 data structures were not getting initialized, and while previous versions of the functions exercised by the unit tests didn't use these structure members, this was arguably a test bug.
Since one of the patches in the block allocation scalability patches is a fix which is has a cc:stable tag, this commit also has a cc:stable tag.
--- fs/ext4/mballoc-test.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/ext4/mballoc-test.c +9 -0
@@ -155,6 +155,7 @@ static struct super_block *mbt_ext4_allobgl_lock_init (sbi->s_blockgroup_lock); sbi->s_es = &fsb->es; + sbi->s_sb = sb; sb->s_fs_info = sbi;up_write (&sb->s_umount);
@@ -802,6 +803,10 @@ static void test_mb_mark_used(struct kunKUNIT_ASSERT_EQ (test, ret,0 ); grp->bb_free =EXT4_CLUSTERS_PER_GROUP (sb); + grp->bb_largest_free_order =-1 ; + grp->bb_avg_fragment_size_order =-1 ; +INIT_LIST_HEAD (&grp->bb_largest_free_order_node); +INIT_LIST_HEAD (&grp->bb_avg_fragment_size_node);mbt_generate_test_ranges (sb, ranges,TEST_RANGE_COUNT );for (i =0 ; i <TEST_RANGE_COUNT ; i++) test_mb_mark_used_range(test, &e4b, ranges[i].start,
@@ -875,6 +880,10 @@ static void test_mb_free_blocks(struct kext4_unlock_group (sb,TEST_GOAL_GROUP ); grp->bb_free =0 ; + grp->bb_largest_free_order =-1 ; + grp->bb_avg_fragment_size_order =-1 ; +INIT_LIST_HEAD (&grp->bb_largest_free_order_node); +INIT_LIST_HEAD (&grp->bb_avg_fragment_size_node);memset (bitmap,0xff , sb->s_blocksize);mbt_generate_test_ranges (sb, ranges,TEST_RANGE_COUNT );
Greg Kroah-Hartman
maintainerPATCH 505/570 usb: core: config: Prevent OOB read in SS endpoint companion parsing
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xinyu Liu <[email protected]>
commit cf16f408364efd8a68f39011a3b073c83a03612d upstream.
usb_parse_ss_endpoint_companion() checks descriptor type before length, enabling a potentially odd read outside of the buffer size.
Fix this up by checking the size first before looking at any of the fields in the descriptor.
--- drivers/usb/core/config.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/usb/core/config.c +8 -2
@@ -107,8 +107,14 @@ static void usb_parse_ss_endpoint_compan*/ desc = (struct usb_ss_ep_comp_descriptor *) buffer; -if (desc->bDescriptorType !=USB_DT_SS_ENDPOINT_COMP || - size <USB_DT_SS_EP_COMP_SIZE ) { +if (size <USB_DT_SS_EP_COMP_SIZE ) { +dev_notice (ddev, +"invalid SuperSpeed endpoint companion descriptor " +"of length %d, skipping\n" , size); +return ; + } + +if (desc->bDescriptorType !=USB_DT_SS_ENDPOINT_COMP ) { dev_notice(ddev, "No SuperSpeed endpoint companion for config %d " " interface %d altsetting %d ep %d: " "using minimum values\n",
Greg Kroah-Hartman
maintainerPATCH 506/570 misc: rtsx: usb: Ensure mmc child device is active when card is present
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricky Wu <[email protected]>
commit 966c5cd72be8989c8a559ddef8e8ff07a37c5eb0 upstream.
When a card is present in the reader, the driver currently defers autosuspend by returning -EAGAIN during the suspend callback to trigger USB remote wakeup signaling. However, this does not guarantee that the mmc child device has been resumed, which may cause issues if it remains suspended while the card is accessible.
This patch ensures that all child devices, including the mmc host controller, are explicitly resumed before returning -EAGAIN. This fixes a corner case introduced by earlier remote wakeup handling, improving reliability of runtime PM when a card is inserted.
--- drivers/misc/cardreader/rtsx_usb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/misc/cardreader/rtsx_usb.c +9 -7
@@ -698,6 +698,12 @@ static void rtsx_usb_disconnect(struct u }#ifdef CONFIG_PM +static int rtsx_usb_resume_child (struct device *dev,void *data) +{ +pm_request_resume (dev); +return 0 ; +} +static int rtsx_usb_suspend (struct usb_interface *intf,pm_message_t message) { struct rtsx_ucr *ucr =
@@ -713,8 +719,10 @@ static int rtsx_usb_suspend(struct usb_imutex_unlock (&ucr->dev_mutex);/* Defer the autosuspend if card exists */ -if (val & (SD_CD |MS_CD )) +if (val & (SD_CD |MS_CD )) { +device_for_each_child (&intf->dev,NULL , rtsx_usb_resume_child);return -EAGAIN ; + } }else {/* There is an ongoing operation*/ return -EAGAIN ;
@@ -724,12 +732,6 @@ static int rtsx_usb_suspend(struct usb_ireturn 0 ; } -static int rtsx_usb_resume_child (struct device *dev,void *data) -{ -pm_request_resume (dev); -return 0 ; -} -static int rtsx_usb_resume (struct usb_interface *intf) {device_for_each_child (&intf->dev,NULL , rtsx_usb_resume_child);
Greg Kroah-Hartman
maintainerPATCH 507/570 usb: typec: ucsi: Update power_supply on power role change
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myrrh Periwinkle <[email protected]>
commit 7616f006db07017ef5d4ae410fca99279aaca7aa upstream.
The current power direction of an USB-C port also influences the power_supply's online status, so a power role change should also update the power_supply.
Fixes an issue on some systems where plugging in a normal USB device in for the first time after a reboot will cause upower to erroneously consider the system to be connected to AC power.
--- drivers/usb/typec/ucsi/ucsi.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/ucsi.c +1 -0
@@ -1246,6 +1246,7 @@ static void ucsi_handle_connector_changeif (change &UCSI_CONSTAT_POWER_DIR_CHANGE ) {typec_set_pwr_role (con->port, role); +ucsi_port_psy_changed (con);/* Complete pending power role swap */ if (!completion_done (&con->complete))
Greg Kroah-Hartman
maintainerPATCH 508/570 comedi: fix race between polling and detaching
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 35b6fc51c666fc96355be5cd633ed0fe4ccf68b2 upstream.
syzbot reports a use-after-free in comedi in the below link, which is due to comedi gladly removing the allocated async area even though poll requests are still active on the wait_queue_head inside of it. This can cause a use-after-free when the poll entries are later triggered or removed, as the memory for the wait_queue_head has been freed. We need to check there are no tasks queued on any of the subdevices' wait queues before allowing the device to be detached by the COMEDI_DEVCONFIG ioctl.
Tasks will read-lock dev->attach_lock before adding themselves to the subdevice wait queue, so fix the problem in the COMEDI_DEVCONFIG ioctl handler by write-locking dev->attach_lock before checking that all of the subdevices are safe to be deleted. This includes testing for any sleepers on the subdevices' wait queues. It remains locked until the device has been detached. This requires the comedi_device_detach() function to be refactored slightly, moving the bulk of it into new function comedi_device_detach_locked().
Note that the refactor of comedi_device_detach() results in comedi_device_cancel_all() now being called while dev->attach_lock is write-locked, which wasn't the case previously, but that does not matter.
Thanks to Jens Axboe for diagnosing the problem and co-developing this patch.
--- drivers/comedi/comedi_fops.c | 33 +++++++++++++++++++++++++-------- drivers/comedi/comedi_internal.h | 1 + drivers/comedi/drivers.c | 13 ++++++++++--- 3 files changed, 36 insertions(+), 11 deletions(-)
drivers/comedi/comedi_fops.c +25 -8
@@ -787,6 +787,7 @@ static int is_device_busy(struct comedi_struct comedi_subdevice *s;int i; +lockdep_assert_held_write (&dev->attach_lock);lockdep_assert_held (&dev->mutex);if (!dev->attached)return 0 ;
@@ -795,7 +796,16 @@ static int is_device_busy(struct comedi_ s = &dev->subdevices[i];if (s->busy)return 1 ; -if (s->async &&comedi_buf_is_mmapped (s)) +if (!s->async) +continue ; +if (comedi_buf_is_mmapped (s)) +return 1 ; +/* +* There may be tasks still waiting on the subdevice's wait +* queue, although they should already be about to be removed +* from it since the subdevice has no active async command. +*/ +if (wq_has_sleeper (&s->async->wait_head))return 1 ; }
@@ -825,15 +835,22 @@ static int do_devconfig_ioctl(struct comreturn -EPERM ;if (!arg) { -if (is_device_busy (dev)) -return -EBUSY ; -if (dev->attached) { -struct module *driver_module = dev->driver->module; +int rc =0 ; -comedi_device_detach (dev); -module_put (driver_module); +if (dev->attached) { +down_write (&dev->attach_lock); +if (is_device_busy (dev)) { + rc = -EBUSY ; + }else { +struct module *driver_module = + dev->driver->module; + +comedi_device_detach_locked (dev); +module_put (driver_module); + } +up_write (&dev->attach_lock); } -return 0 ; +return rc; }if (copy_from_user (&it, arg,sizeof (it)))
drivers/comedi/comedi_internal.h +1 -0
@@ -50,6 +50,7 @@ extern struct mutex comedi_drivers_list_int insn_inval (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); +void comedi_device_detach_locked (struct comedi_device *dev);void comedi_device_detach (struct comedi_device *dev);int comedi_device_attach (struct comedi_device *dev,struct comedi_devconfig *it);
drivers/comedi/drivers.c +10 -3
@@ -158,7 +158,7 @@ static void comedi_device_detach_cleanupint i;struct comedi_subdevice *s; -lockdep_assert_held (&dev->attach_lock); +lockdep_assert_held_write (&dev->attach_lock);lockdep_assert_held (&dev->mutex);if (dev->subdevices) {for (i =0 ; i < dev->n_subdevices; i++) {
@@ -196,16 +196,23 @@ static void comedi_device_detach_cleanupcomedi_clear_hw_dev (dev); } -void comedi_device_detach (struct comedi_device *dev) +void comedi_device_detach_locked (struct comedi_device *dev) { +lockdep_assert_held_write (&dev->attach_lock);lockdep_assert_held (&dev->mutex);comedi_device_cancel_all (dev); -down_write (&dev->attach_lock); dev->attached = false; dev->detach_count++;if (dev->driver) dev->driver->detach (dev);comedi_device_detach_cleanup (dev); +} + +void comedi_device_detach (struct comedi_device *dev) +{ +lockdep_assert_held (&dev->mutex); +down_write (&dev->attach_lock); +comedi_device_detach_locked (dev);up_write (&dev->attach_lock); }
Greg Kroah-Hartman
maintainerPATCH 509/570 thunderbolt: Fix copy+paste error in match_service_id()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 5cc1f66cb23cccc704e3def27ad31ed479e934a5 upstream.
The second instance of TBSVC_MATCH_PROTOCOL_VERSION seems to have been intended to be TBSVC_MATCH_PROTOCOL_REVISION.
--- drivers/thunderbolt/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thunderbolt/domain.c +1 -1
@@ -36,7 +36,7 @@ static bool match_service_id(const strucreturn false; } -if (id->match_flags &TBSVC_MATCH_PROTOCOL_VERSION ) { +if (id->match_flags &TBSVC_MATCH_PROTOCOL_REVISION ) {if (id->protocol_revision != svc->prtcrevs)return false; }
Greg Kroah-Hartman
maintainerPATCH 510/570 usb: typec: fusb302: cache PD RX state
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
commit 1e61f6ab08786d66a11cfc51e13d6f08a6b06c56 upstream.
This patch fixes a race condition communication error, which ends up in PD hard resets when losing the race. Some systems, like the Radxa ROCK 5B are powered through USB-C without any backup power source and use a FUSB302 chip to do the PD negotiation. This means it is quite important to avoid hard resets, since that effectively kills the system's power-supply.
I've found the following race condition while debugging unplanned power loss during booting the board every now and then:
1. lots of TCPM/FUSB302/PD initialization stuff
2. TCPM ends up in SNK_WAIT_CAPABILITIES (tcpm_set_pd_rx is enabled here)
3. the remote PD source does not send anything, so TCPM does a SOFT RESET
4. TCPM ends up in SNK_WAIT_CAPABILITIES for the second time (tcpm_set_pd_rx is enabled again, even though it is still on)
At this point I've seen broken CRC good messages being send by the FUSB302 with a logic analyzer sniffing the CC lines. Also it looks like messages are being lost and things generally going haywire with one of the two sides doing a hard reset once a broken CRC good message was send to the bus.
I think the system is running into a race condition, that the FIFOs are being cleared and/or the automatic good CRC message generation flag is being updated while a message is already arriving.
Let's avoid this by caching the PD RX enabled state, as we have already processed anything in the FIFOs and are in a good state. As a side effect that this also optimizes I2C bus usage :)
As far as I can tell the problem theoretically also exists when TCPM enters SNK_WAIT_CAPABILITIES the first time, but I believe this is less critical for the following reason:
On devices like the ROCK 5B, which are powered through a TCPM backed USB-C port, the bootloader must have done some prior PD communication (initial communication must happen within 5 seconds after plugging the USB-C plug). This means the first time the kernel TCPM state machine reaches SNK_WAIT_CAPABILITIES, the remote side is not sending messages actively. On other devices a hard reset simply adds some extra delay and things should be good afterwards.
--- drivers/usb/typec/tcpm/fusb302.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/typec/tcpm/fusb302.c +8 -0
@@ -104,6 +104,7 @@ struct fusb302_chip {bool vconn_on;bool vbus_on;bool charge_on; +bool pd_rx_on;bool vbus_present;enum typec_cc_polarity cc_polarity;enum typec_cc_status cc1;
@@ -841,6 +842,11 @@ static int tcpm_set_pd_rx(struct tcpc_deint ret =0 ;mutex_lock (&chip->lock); +if (chip->pd_rx_on == on) { +fusb302_log (chip,"pd is already %s" ,str_on_off (on)); + goto done; + } + ret =fusb302_pd_rx_flush (chip);if (ret <0 ) {fusb302_log (chip,"cannot flush pd rx buffer, ret=%d" , ret);
@@ -863,6 +869,8 @@ static int tcpm_set_pd_rx(struct tcpc_de str_on_off(on), ret); goto done; } + + chip->pd_rx_on = on;fusb302_log (chip,"pd := %s" ,str_on_off (on)); done:mutex_unlock (&chip->lock);
Greg Kroah-Hartman
maintainerPATCH 511/570 cdc-acm: fix race between initial clearing halt and open
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 64690a90cd7c6db16d3af8616be1f4bf8d492850 upstream.
On the devices that need their endpoints to get an initial clear_halt, this needs to be done before the devices can be opened. That means it needs to be before the devices are registered.
--- drivers/usb/class/cdc-acm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/usb/class/cdc-acm.c +6 -5
@@ -1520,6 +1520,12 @@ skip_countries: goto err_remove_files; } +if (quirks &CLEAR_HALT_CONDITIONS ) { +/* errors intentionally ignored */ +usb_clear_halt (usb_dev, acm->in); +usb_clear_halt (usb_dev, acm->out); + } + tty_dev =tty_port_register_device (&acm->port, acm_tty_driver, minor, &control_interface->dev);if (IS_ERR (tty_dev)) {
@@ -1527,11 +1533,6 @@ skip_countries: goto err_release_data_interface; } -if (quirks &CLEAR_HALT_CONDITIONS ) { -usb_clear_halt (usb_dev, acm->in); -usb_clear_halt (usb_dev, acm->out); - } -dev_info (&intf->dev,"ttyACM%d: USB ACM device\n" , minor);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 512/570 btrfs: zoned: use filesystem size not disk size for reclaim decision
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit 55f7c65b2f69c7e4cb7aa7c1654a228ccf734fd8 upstream.
When deciding if a zoned filesystem is reaching the threshold to reclaim data block groups, look at the size of the filesystem not to potentially total available size of all drives in the filesystem.
Especially if a filesystem was created with mkfs' -b option, constraining it to only a portion of the block device, the numbers won't match and potentially garbage collection is kicking in too late.
--- fs/btrfs/zoned.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/zoned.c +1 -2
@@ -2523,8 +2523,8 @@ bool btrfs_zoned_should_reclaim(const st {struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;struct btrfs_device *device; +u64 total =btrfs_super_total_bytes (fs_info->super_copy);u64 used =0 ; -u64 total =0 ;u64 factor;ASSERT (btrfs_is_zoned (fs_info));
@@ -2537,7 +2537,6 @@ bool btrfs_zoned_should_reclaim(const stif (!device->bdev)continue ; - total += device->disk_total_bytes; used += device->bytes_used; }mutex_unlock (&fs_devices->device_list_mutex);
Greg Kroah-Hartman
maintainerPATCH 513/570 btrfs: abort transaction during log replay if walk_log_tree() failed
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 2a5898c4aac67494c2f0f7fe38373c95c371c930 upstream.
If we failed walking a log tree during replay, we have a missing transaction abort to prevent committing a transaction where we didn't fully replay all the changes from a log tree and therefore can leave the respective subvolume tree in some inconsistent state. So add the missing transaction abort.
--- fs/btrfs/tree-log.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/tree-log.c +5 -2
@@ -7279,11 +7279,14 @@ again: wc.replay_dest->log_root = log; ret =btrfs_record_root_in_trans (trans, wc.replay_dest); -if (ret) +if (ret) {/* The loop needs to continue due to the root refs */ btrfs_abort_transaction (trans, ret); -else + }else { ret =walk_log_tree (trans, log, &wc); +if (ret) +btrfs_abort_transaction (trans, ret); + }if (!ret && wc.stage ==LOG_WALK_REPLAY_ALL ) { ret = fixup_inode_link_counts(trans, wc.replay_dest,
Greg Kroah-Hartman
maintainerPATCH 514/570 btrfs: zoned: reserve data_reloc block group on mount
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit 694ce5e143d67267ad26b04463e790a597500b00 upstream.
Create a block group dedicated for data relocation on mount of a zoned filesystem.
If there is already more than one empty DATA block group on mount, this one is picked for the data relocation block group, instead of a newly created one.
This is done to ensure, there is always space for performing garbage collection and the filesystem is not hitting ENOSPC under heavy overwrite workloads.
--- fs/btrfs/disk-io.c | 1 fs/btrfs/zoned.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/btrfs/zoned.h | 3 ++ 3 files changed, 65 insertions(+)
fs/btrfs/disk-io.c +1 -0
@@ -3561,6 +3561,7 @@ int __cold open_ctree(struct super_block goto fail_sysfs; } +btrfs_zoned_reserve_data_reloc_bg (fs_info);btrfs_free_zone_cache (fs_info);btrfs_check_active_zone_reservation (fs_info);
fs/btrfs/zoned.c +61 -0
73 lines not on this page · raw message
fs/btrfs/zoned.h +3 -0
@@ -88,6 +88,7 @@ void btrfs_zone_finish_endio(struct btrfvoid btrfs_schedule_zone_finish_bg (struct btrfs_block_group *bg,struct extent_buffer *eb);void btrfs_clear_data_reloc_bg (struct btrfs_block_group *bg); +void btrfs_zoned_reserve_data_reloc_bg (struct btrfs_fs_info *fs_info);void btrfs_free_zone_cache (struct btrfs_fs_info *fs_info);bool btrfs_zoned_should_reclaim (const struct btrfs_fs_info *fs_info); void btrfs_zoned_release_data_reloc_bg(struct btrfs_fs_info *fs_info, u64 logical,
@@ -241,6 +242,8 @@ static inline void btrfs_schedule_zone_fstatic inline void btrfs_clear_data_reloc_bg (struct btrfs_block_group *bg) { } +static inline void btrfs_zoned_reserve_data_reloc_bg (struct btrfs_fs_info *fs_info) { } +static inline void btrfs_free_zone_cache (struct btrfs_fs_info *fs_info) { }static inline bool btrfs_zoned_should_reclaim (const struct btrfs_fs_info *fs_info)
Greg Kroah-Hartman
maintainerPATCH 515/570 btrfs: zoned: requeue to unused block group list if zone finish failed
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naohiro Aota <[email protected]>
commit 62be7afcc13b2727bdc6a4c91aefed6b452e6ecc upstream.
btrfs_zone_finish() can fail for several reason. If it is -EAGAIN, we need to try it again later. So, put the block group to the retry list properly.
Failing to do so will keep the removable block group intact until remount and can causes unnecessary ENOSPC.
--- fs/btrfs/block-group.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +3 -1
@@ -1616,8 +1616,10 @@ void btrfs_delete_unused_bgs(struct btrf ret =btrfs_zone_finish (block_group);if (ret <0 ) {btrfs_dec_block_group_ro (block_group); -if (ret == -EAGAIN ) +if (ret == -EAGAIN ) { +btrfs_link_bg_list (block_group, &retry_list); ret =0 ; + } goto next; }
Greg Kroah-Hartman
maintainerPATCH 516/570 btrfs: zoned: do not remove unwritten non-data block group
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naohiro Aota <[email protected]>
commit 3061801420469610c8fa6080a950e56770773ef1 upstream.
There are some reports of "unable to find chunk map for logical 2147483648 length 16384" error message appears in dmesg. This means some IOs are occurring after a block group is removed.
When a metadata tree node is cleaned on a zoned setup, we keep that node still dirty and write it out not to create a write hole. However, this can make a block group's used bytes == 0 while there is a dirty region left.
Such an unused block group is moved into the unused_bg list and processed for removal. When the removal succeeds, the block group is removed from the transaction->dirty_bgs list, so the unused dirty nodes in the block group are not sent at the transaction commit time. It will be written at some later time e.g, sync or umount, and causes "unable to find chunk map" errors.
This can happen relatively easy on SMR whose zone size is 256MB. However, calling do_zone_finish() on such block group returns -EAGAIN and keep that block group intact, which is why the issue is hidden until now.
--- fs/btrfs/block-group.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
fs/btrfs/block-group.c +25 -2
@@ -34,6 +34,19 @@ int btrfs_should_fragment_free_space(con }#endif +static inline bool has_unwritten_metadata (struct btrfs_block_group *block_group) +{ +/* The meta_write_pointer is available only on the zoned setup. */ +if (!btrfs_is_zoned (block_group->fs_info)) +return false; + +if (block_group->flags &BTRFS_BLOCK_GROUP_DATA ) +return false; + +return block_group->start + block_group->alloc_offset > + block_group->meta_write_pointer; +} +/* * Return target flags in extended format or 0 if restripe for this chunk_type * is not in progress
@@ -1244,6 +1257,15 @@ int btrfs_remove_block_group(struct btrf goto out;spin_lock (&block_group->lock); +/* +* Hitting this WARN means we removed a block group with an unwritten +* region. It will cause "unable to find chunk map for logical" errors. +*/ +if (WARN_ON (has_unwritten_metadata (block_group))) +btrfs_warn (fs_info, +"block group %llu is removed before metadata write out" , + block_group->start); +set_bit (BLOCK_GROUP_FLAG_REMOVED , &block_group->runtime_flags);/*
@@ -1586,8 +1608,9 @@ void btrfs_delete_unused_bgs(struct btrf* needing to allocate extents from the block group. */ used =btrfs_space_info_used (space_info, true); -if (space_info->total_bytes - block_group->length < used && - block_group->zone_unusable < block_group->length) { +if ((space_info->total_bytes - block_group->length < used && + block_group->zone_unusable < block_group->length) || +has_unwritten_metadata (block_group)) {/* * Add a reference for the list, compensate for the ref * drop under the "next" label for the
Greg Kroah-Hartman
maintainerPATCH 517/570 btrfs: qgroup: set quota enabled bit if quota disable fails flushing reservations
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit e41c75ca3189341e76e6af64b857c05b68a1d7db upstream.
Before waiting for the rescan worker to finish and flushing reservations, we clear the BTRFS_FS_QUOTA_ENABLED flag from fs_info. If we fail flushing reservations we leave with the flag not set which is not correct since quotas are still enabled - we must set back the flag on error paths, such as when we fail to start a transaction, except for error paths that abort a transaction. The reservation flushing happens very early before we do any operation that actually disables quotas and before we start a transaction, so set back BTRFS_FS_QUOTA_ENABLED if it fails.
--- fs/btrfs/qgroup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +5 -2
@@ -1354,11 +1354,14 @@ int btrfs_quota_disable(struct btrfs_fs_/* * We have nothing held here and no trans handle, just return the error -* if there is one. +* if there is one and set back the quota enabled bit since we didn't +* actually disable quotas. */ ret =flush_reservations (fs_info); -if (ret) +if (ret) { +set_bit (BTRFS_FS_QUOTA_ENABLED , &fs_info->flags);return ret; + }/* * 1 For the root item
Greg Kroah-Hartman
maintainerPATCH 518/570 btrfs: dont ignore inode missing when replaying log tree
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 7ebf381a69421a88265d3c49cd0f007ba7336c9d upstream.
During log replay, at add_inode_ref(), we return -ENOENT if our current inode isn't found on the subvolume tree or if a parent directory isn't found. The error comes from btrfs_iget_logging() <- btrfs_iget() <- btrfs_read_locked_inode().
The single caller of add_inode_ref(), replay_one_buffer(), ignores an -ENOENT error because it expects that error to mean only that a parent directory wasn't found and that is ok.
Before commit 5f61b961599a ("btrfs: fix inode lookup error handling during log replay") we were converting any error when getting a parent directory to -ENOENT and any error when getting the current inode to -EIO, so our caller would fail log replay in case we can't find the current inode. After that commit however in case the current inode is not found we return -ENOENT to the caller and therefore it ignores the critical fact that the current inode was not found in the subvolume tree.
Fix this by converting -ENOENT to 0 when we don't find a parent directory, returning -ENOENT when we don't find the current inode and making the caller, replay_one_buffer(), not ignore -ENOENT anymore.
--- fs/btrfs/tree-log.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
fs/btrfs/tree-log.c +12 -2
@@ -1383,6 +1383,8 @@ static noinline int add_inode_ref(struct dir =btrfs_iget_logging (parent_objectid, root);if (IS_ERR (dir)) { ret =PTR_ERR (dir); +if (ret == -ENOENT ) + ret =0 ; dir =NULL ; goto out; }
@@ -1407,6 +1409,15 @@ static noinline int add_inode_ref(structif (IS_ERR (dir)) { ret =PTR_ERR (dir); dir =NULL ; +/* +* A new parent dir may have not been +* logged and not exist in the subvolume +* tree, see the comment above before +* the loop when getting the first +* parent dir. +*/ +if (ret == -ENOENT ) + ret =0 ; goto out; } }
@@ -2519,9 +2530,8 @@ static int replay_one_buffer(struct btrf key.type == BTRFS_INODE_EXTREF_KEY) { ret =add_inode_ref (wc->trans, root, log, path, eb, i, &key); -if (ret && ret != -ENOENT ) +if (ret)break ; - ret =0 ; } else if (key.type == BTRFS_EXTENT_DATA_KEY) { ret =replay_one_extent (wc->trans, root, path, eb, i, &key);
Greg Kroah-Hartman
maintainerPATCH 519/570 btrfs: fix ssd_spread overallocation
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
commit 807d9023e75fc20bfd6dd2ac0408ce4af53f1648 upstream.
If the ssd_spread mount option is enabled, then we run the so called clustered allocator for data block groups. In practice, this results in creating a btrfs_free_cluster which caches a block_group and borrows its free extents for allocation.
Since the introduction of allocation size classes in 6.1, there has been a bug in the interaction between that feature and ssd_spread. find_free_extent() has a number of nested loops. The loop going over the allocation stages, stored in ffe_ctl->loop and managed by find_free_extent_update_loop(), the loop over the raid levels, and the loop over all the block_groups in a space_info. The size class feature relies on the block_group loop to ensure it gets a chance to see a block_group of a given size class. However, the clustered allocator uses the cached cluster block_group and breaks that loop. Each call to do_allocation() will really just go back to the same cached block_group. Normally, this is OK, as the allocation either succeeds and we don't want to loop any more or it fails, and we clear the cluster and return its space to the block_group.
But with size classes, the allocation can succeed, then later fail, outside of do_allocation() due to size class mismatch. That latter failure is not properly handled due to the highly complex multi loop logic. The result is a painful loop where we continue to allocate the same num_bytes from the cluster in a tight loop until it fails and releases the cluster and lets us try a new block_group. But by then, we have skipped great swaths of the available block_groups and are likely to fail to allocate, looping the outer loop. In pathological cases like the reproducer below, the cached block_group is often the very last one, in which case we don't perform this tight bg loop but instead rip through the ffe stages to LOOP_CHUNK_ALLOC and allocate a chunk, which is now the last one, and we enter the tight inner loop until an allocation failure. Then allocation succeeds on the final block_group and if the next allocation is a size mismatch, the exact same thing happens again.
Triggering this is as easy as mounting with -o ssd_spread and then running:
mount -o ssd_spread $dev $mnt
dd if=/dev/zero of=$mnt/big bs=16M count=1 &>/dev/null dd if=/dev/zero of=$mnt/med bs=4M count=1 &>/dev/null sync
if you do the two writes + sync in a loop, you can force btrfs to spin an excessive amount on semi-successful clustered allocations, before ultimately failing and advancing to the stage where we force a chunk allocation. This results in 2G of data allocated per iteration, despite only using ~20M of data. By using a small size classed extent, the inner loop takes longer and we can spin for longer.
The simplest, shortest term fix to unbreak this is to make the clustered allocator size_class aware in the dumbest way, where it fails on size class mismatch. This may hinder the operation of the clustered allocator, but better hindered than completely broken and terribly overallocating.
Further re-design improvements are also in the works.
--- fs/btrfs/extent-tree.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
fs/btrfs/extent-tree.c +17 -16
@@ -3649,6 +3649,21 @@ btrfs_release_block_group(struct btrfs_bbtrfs_put_block_group (cache); } +static bool find_free_extent_check_size_class (const struct find_free_extent_ctl *ffe_ctl, +const struct btrfs_block_group *bg) +{ +if (ffe_ctl->policy ==BTRFS_EXTENT_ALLOC_ZONED ) +return true; +if (!btrfs_block_group_should_use_size_class (bg)) +return true; +if (ffe_ctl->loop >=LOOP_WRONG_SIZE_CLASS ) +return true; +if (ffe_ctl->loop >=LOOP_UNSET_SIZE_CLASS && + bg->size_class ==BTRFS_BG_SZ_NONE ) +return true; +return ffe_ctl->size_class == bg->size_class; +} +/* * Helper function for find_free_extent(). *
@@ -3670,7 +3685,8 @@ static int find_free_extent_clustered(stif (!cluster_bg) goto refill_cluster;if (cluster_bg != bg && (cluster_bg->ro || - !block_group_bits (cluster_bg, ffe_ctl->flags))) + !block_group_bits (cluster_bg, ffe_ctl->flags) || + !find_free_extent_check_size_class (ffe_ctl, cluster_bg))) goto release_cluster; offset = btrfs_alloc_from_cluster(cluster_bg, last_ptr,
@@ -4227,21 +4243,6 @@ static int find_free_extent_update_loop(return -ENOSPC ; } -static bool find_free_extent_check_size_class (struct find_free_extent_ctl *ffe_ctl, -struct btrfs_block_group *bg) -{ -if (ffe_ctl->policy ==BTRFS_EXTENT_ALLOC_ZONED ) -return true; -if (!btrfs_block_group_should_use_size_class (bg)) -return true; -if (ffe_ctl->loop >=LOOP_WRONG_SIZE_CLASS ) -return true; -if (ffe_ctl->loop >=LOOP_UNSET_SIZE_CLASS && - bg->size_class ==BTRFS_BG_SZ_NONE ) -return true; -return ffe_ctl->size_class == bg->size_class; -} - static int prepare_allocation_clustered(struct btrfs_fs_info *fs_info, struct find_free_extent_ctl *ffe_ctl, struct btrfs_space_info *space_info,
Greg Kroah-Hartman
maintainerPATCH 520/570 btrfs: qgroup: fix race between quota disable and quota rescan ioctl
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit e1249667750399a48cafcf5945761d39fa584edf upstream.
There's a race between a task disabling quotas and another running the rescan ioctl that can result in a use-after-free of qgroup records from the fs_info->qgroup_tree rbtree.
This happens as follows:
1) Task A enters btrfs_ioctl_quota_rescan() -> btrfs_qgroup_rescan();
2) Task B enters btrfs_quota_disable() and calls btrfs_qgroup_wait_for_completion(), which does nothing because at that point fs_info->qgroup_rescan_running is false (it wasn't set yet by task A);
3) Task B calls btrfs_free_qgroup_config() which starts freeing qgroups from fs_info->qgroup_tree without taking the lock fs_info->qgroup_lock;
4) Task A enters qgroup_rescan_zero_tracking() which starts iterating the fs_info->qgroup_tree tree while holding fs_info->qgroup_lock, but task B is freeing qgroup records from that tree without holding the lock, resulting in a use-after-free.
Fix this by taking fs_info->qgroup_lock at btrfs_free_qgroup_config(). Also at btrfs_qgroup_rescan() don't start the rescan worker if quotas were already disabled.
--- fs/btrfs/qgroup.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
fs/btrfs/qgroup.c +24 -7
@@ -630,22 +630,30 @@ bool btrfs_check_quota_leak(const struct/* * This is called from close_ctree() or open_ctree() or btrfs_quota_disable(), -* first two are in single-threaded paths.And for the third one, we have set -* quota_root to be null with qgroup_lock held before, so it is safe to clean -* up the in-memory structures without qgroup_lock held. +* first two are in single-threaded paths. */ void btrfs_free_qgroup_config (struct btrfs_fs_info *fs_info) {struct rb_node *n;struct btrfs_qgroup *qgroup; +/* +* btrfs_quota_disable() can be called concurrently with +* btrfs_qgroup_rescan() -> qgroup_rescan_zero_tracking(), so take the +* lock. +*/ +spin_lock (&fs_info->qgroup_lock);while ((n =rb_first (&fs_info->qgroup_tree))) { qgroup = rb_entry(n, struct btrfs_qgroup, node);rb_erase (n, &fs_info->qgroup_tree);__del_qgroup_rb (qgroup); +spin_unlock (&fs_info->qgroup_lock);btrfs_sysfs_del_one_qgroup (fs_info, qgroup);kfree (qgroup); +spin_lock (&fs_info->qgroup_lock); } +spin_unlock (&fs_info->qgroup_lock); +/* * We call btrfs_free_qgroup_config() when unmounting * filesystem and disabling quota, so we set qgroup_ulist
@@ -4039,12 +4047,21 @@ btrfs_qgroup_rescan(struct btrfs_fs_infoqgroup_rescan_zero_tracking (fs_info);mutex_lock (&fs_info->qgroup_rescan_lock); - fs_info->qgroup_rescan_running = true; -btrfs_queue_work (fs_info->qgroup_rescan_workers, - &fs_info->qgroup_rescan_work); +/* +* The rescan worker is only for full accounting qgroups, check if it's +* enabled as it is pointless to queue it otherwise. A concurrent quota +* disable may also have just cleared BTRFS_FS_QUOTA_ENABLED. +*/ +if (btrfs_qgroup_full_accounting (fs_info)) { + fs_info->qgroup_rescan_running = true; +btrfs_queue_work (fs_info->qgroup_rescan_workers, + &fs_info->qgroup_rescan_work); + }else { + ret = -ENOTCONN ; + }mutex_unlock (&fs_info->qgroup_rescan_lock); -return 0 ; +return ret; } int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info,
Greg Kroah-Hartman
maintainerPATCH 521/570 btrfs: populate otime when logging an inode item
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 1ef94169db0958d6de39f9ea6e063ce887342e2d upstream.
[TEST FAILURE WITH EXPERIMENTAL FEATURES]
When running test case generic/508, the test case will fail with the new btrfs shutdown support:
generic/508 - output mismatch (see /home/adam/xfstests/results//generic/508.out.bad)
# --- tests/generic/508.out 2022-05-11 11:25:30.806666664 +0930 # +++ /home/adam/xfstests/results//generic/508.out.bad 2025-07-02 14:53:22.401824212 +0930 # @@ -1,2 +1,6 @@ # QA output created by 508 # Silence is golden # +Before: # +After : stat.btime = Thu Jan 1 09:30:00 1970 # +Before: # +After : stat.btime = Wed Jul 2 14:53:22 2025 # ... # (Run 'diff -u /home/adam/xfstests/tests/generic/508.out /home/adam/xfstests/results//generic/508.out.bad' to see the entire diff)
Ran: generic/508
Failures: generic/508
Failed 1 of 1 tests
Please note that the test case requires shutdown support, thus the test case will be skipped using the current upstream kernel, as it doesn't have shutdown ioctl support.
[CAUSE]
The direct cause the 0 time stamp in the log tree:
leaf 30507008 items 2 free space 16057 generation 9 owner TREE_LOG leaf 30507008 flags 0x1(WRITTEN) backref revision 1 checksum stored e522548d
checksum calced e522548d
fs uuid 57d45451-481e-43e4-aa93-289ad707a3a0
chunk uuid d52bd3fd-5163-4337-98a7-7986993ad398
item 0 key (257 INODE_ITEM 0) itemoff 16123 itemsize 160 generation 9 transid 9 size 0 nbytes 0 block group 0 mode 100644 links 1 uid 0 gid 0 rdev 0 sequence 1 flags 0x0(none) atime 1751432947.492000000 (2025-07-02 14:39:07) ctime 1751432947.492000000 (2025-07-02 14:39:07) mtime 1751432947.492000000 (2025-07-02 14:39:07) otime 0.0 (1970-01-01 09:30:00) <<<
But the old fs tree has all the correct time stamp:
btrfs-progs v6.12
fs tree key (FS_TREE ROOT_ITEM 0)
leaf 30425088 items 2 free space 16061 generation 5 owner FS_TREE leaf 30425088 flags 0x1(WRITTEN) backref revision 1 checksum stored 48f6c57e
checksum calced 48f6c57e
fs uuid 57d45451-481e-43e4-aa93-289ad707a3a0
chunk uuid d52bd3fd-5163-4337-98a7-7986993ad398
item 0 key (256 INODE_ITEM 0) itemoff 16123 itemsize 160 generation 3 transid 0 size 0 nbytes 16384 block group 0 mode 40755 links 1 uid 0 gid 0 rdev 0 sequence 0 flags 0x0(none) atime 1751432947.0 (2025-07-02 14:39:07) ctime 1751432947.0 (2025-07-02 14:39:07) mtime 1751432947.0 (2025-07-02 14:39:07) otime 1751432947.0 (2025-07-02 14:39:07) <<<
The root cause is that fill_inode_item() in tree-log.c is only populating a/c/m time, not the otime (or btime in statx output).
Part of the reason is that, the vfs inode only has a/c/m time, no native btime support yet.
[FIX]
Thankfully btrfs has its otime stored in btrfs_inode::i_otime_sec and btrfs_inode::i_otime_nsec.
So what we really need is just fill the otime time stamp in fill_inode_item() of tree-log.c
There is another fill_inode_item() in inode.c, which is doing the proper otime population.
--- fs/btrfs/tree-log.c | 3 +++ 1 file changed, 3 insertions(+)
fs/btrfs/tree-log.c +3 -0
@@ -4221,6 +4221,9 @@ static void fill_inode_item(struct btrfsbtrfs_set_token_timespec_nsec (&token, &item->ctime,inode_get_ctime_nsec (inode)); +btrfs_set_timespec_sec (leaf, &item->otime,BTRFS_I (inode)->i_otime_sec); +btrfs_set_timespec_nsec (leaf, &item->otime,BTRFS_I (inode)->i_otime_nsec); +/* * We do not need to set the nbytes field, in fact during a fast fsync * its value may not even be correct, since a fast fsync does not wait
Hi
no regressions here on x86_64 (RKL, Intel 11th Gen. CPU)
Thanks
Greg Kroah-Hartman
maintainerPATCH 522/570 btrfs: dont skip accounting in early ENOTTY return in btrfs_uring_encoded_read()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Caleb Sander Mateos <[email protected]>
commit ea124ec327086325fc096abf42837dac471ac7ae upstream.
btrfs_uring_encoded_read() returns early with -ENOTTY if the uring_cmd is issued with IO_URING_F_COMPAT but the kernel doesn't support compat syscalls. However, this early return bypasses the syscall accounting. Go to out_acct instead to ensure the syscall is counted.
--- fs/btrfs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/ioctl.c +2 -1
@@ -4829,7 +4829,8 @@ static int btrfs_uring_encoded_read(stru#if defined(CONFIG_64BIT ) && defined(CONFIG_COMPAT ) copy_end = offsetofend(struct btrfs_ioctl_encoded_io_args_32, flags);#else -return -ENOTTY ; + ret = -ENOTTY ; + goto out_acct;#endif }else { copy_end = copy_end_kernel;
Greg Kroah-Hartman
maintainerPATCH 523/570 btrfs: qgroup: fix qgroup create ioctl returning success after quotas disabled
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 08530d6e638427e7e1344bd67bacc03882ba95b9 upstream.
When quotas are disabled qgroup ioctls are supposed to return -ENOTCONN, but the qgroup create ioctl stopped doing that when it races with a quota disable operation, returning 0 instead. This change of behaviour happened in commit 6ed05643ddb1 ("btrfs: create qgroup earlier in snapshot creation").
The issue happens as follows:
1) Task A enters btrfs_ioctl_qgroup_create(), qgroups are enabled and so qgroup_enabled() returns true since fs_info->quota_root is not NULL;
2) Task B enters btrfs_ioctl_quota_ctl() -> btrfs_quota_disable() and disables qgroups, so now fs_info->quota_root is NULL;
3) Task A enters btrfs_create_qgroup() and calls btrfs_qgroup_mode(), which returns BTRFS_QGROUP_MODE_DISABLED since quotas are disabled, and then btrfs_create_qgroup() returns 0 to the caller, which makes the ioctl return 0 instead of -ENOTCONN.
The check for fs_info->quota_root and returning -ENOTCONN if it's NULL is made only after the call btrfs_qgroup_mode().
Fix this by moving the check for disabled quotas with btrfs_qgroup_mode() into transaction.c:create_pending_snapshot(), so that we don't abort the transaction if btrfs_create_qgroup() returns -ENOTCONN and quotas are disabled.
--- fs/btrfs/qgroup.c | 3 --- fs/btrfs/transaction.c | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-)
fs/btrfs/qgroup.c +0 -3
@@ -1690,9 +1690,6 @@ int btrfs_create_qgroup(struct btrfs_trastruct btrfs_qgroup *prealloc =NULL ;int ret =0 ; -if (btrfs_qgroup_mode (fs_info) ==BTRFS_QGROUP_MODE_DISABLED ) -return 0 ; -mutex_lock (&fs_info->qgroup_ioctl_lock);if (!fs_info->quota_root) { ret = -ENOTCONN ;
fs/btrfs/transaction.c +4 -2
@@ -1735,8 +1735,10 @@ static noinline int create_pending_snaps ret =btrfs_create_qgroup (trans, objectid);if (ret && ret != -EEXIST ) { -btrfs_abort_transaction (trans, ret); - goto fail; +if (ret != -ENOTCONN ||btrfs_qgroup_enabled (fs_info)) { +btrfs_abort_transaction (trans, ret); + goto fail; + } }/*
Greg Kroah-Hartman
maintainerPATCH 524/570 btrfs: dont skip remaining extrefs if dir not found during log replay
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 24e066ded45b8147b79c7455ac43a5bff7b5f378 upstream.
During log replay, at add_inode_ref(), if we have an extref item that contains multiple extrefs and one of them points to a directory that does not exist in the subvolume tree, we are supposed to ignore it and process the remaining extrefs encoded in the extref item, since each extref can point to a different parent inode. However when that happens we just return from the function and ignore the remaining extrefs.
The problem has been around since extrefs were introduced, in commit f186373fef00 ("btrfs: extended inode refs"), but it's hard to hit in practice because getting extref items encoding multiple extref requires getting a hash collision when computing the offset of the extref's key. The offset if computed like this:
key.offset = btrfs_extref_hash(dir_ino, name->name, name->len);
and btrfs_extref_hash() is just a wrapper around crc32c().
Fix this by moving to next iteration of the loop when we don't find the parent directory that an extref points to.
--- fs/btrfs/tree-log.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
fs/btrfs/tree-log.c +14 -4
@@ -1400,6 +1400,8 @@ static noinline int add_inode_ref(structif (log_ref_ver) { ret =extref_get_fields (eb, ref_ptr, &name, &ref_index, &parent_objectid); +if (ret) + goto out;/* * parent object can change from one array * item to another.
@@ -1416,16 +1418,23 @@ static noinline int add_inode_ref(struct* the loop when getting the first * parent dir. */ -if (ret == -ENOENT ) +if (ret == -ENOENT ) { +/* +* The next extref may refer to +* another parent dir that +* exists, so continue. +*/ ret =0 ; + goto next; + } goto out; } } }else { ret =ref_get_fields (eb, ref_ptr, &name, &ref_index); +if (ret) + goto out; } -if (ret) - goto out; ret =inode_in_dir (root, path,btrfs_ino (dir),btrfs_ino (inode), ref_index, &name);
@@ -1459,10 +1468,11 @@ static noinline int add_inode_ref(struct }/* Else, ret == 1, we already have a perfect match, we're done. */ +next: ref_ptr = (unsigned long )(ref_ptr + ref_struct_size) + name.len;kfree (name.name); name.name =NULL ; -if (log_ref_ver) { +if (log_ref_ver && dir) {iput (&dir->vfs_inode); dir =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 525/570 btrfs: clear dirty status from extent buffer on error at insert_new_root()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit c0d013495a80cbb53e2288af7ae0ec4170aafd7c upstream.
If we failed to insert the tree mod log operation, we are not removing the dirty status from the allocated and dirtied extent buffer before we free it. Removing the dirty status is needed for several reasons such as to adjust the fs_info->dirty_metadata_bytes counter and remove the dirty status from the respective folios. So add the missing call to btrfs_clear_buffer_dirty().
--- fs/btrfs/ctree.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/ctree.c +1 -0
@@ -2872,6 +2872,7 @@ static noinline int insert_new_root(struif (ret <0 ) {int ret2; +btrfs_clear_buffer_dirty (trans, c); ret2 =btrfs_free_tree_block (trans,btrfs_root_id (root), c,0 ,1 );if (ret2 <0 )btrfs_abort_transaction (trans, ret2);
Greg Kroah-Hartman
maintainerPATCH 526/570 btrfs: send: use fallocate for hole punching with send stream v2
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 005b0a0c24e1628313e951516b675109a92cacfe upstream.
Currently holes are sent as writes full of zeroes, which results in unnecessarily using disk space at the receiving end and increasing the stream size.
In some cases we avoid sending writes of zeroes, like during a full send operation where we just skip writes for holes.
But for some cases we fill previous holes with writes of zeroes too, like in this scenario:
1) We have a file with a hole in the range [2M, 3M), we snapshot the subvolume and do a full send. The range [2M, 3M) stays as a hole at the receiver since we skip sending write commands full of zeroes;
2) We punch a hole for the range [3M, 4M) in our file, so that now it has a 2M hole in the range [2M, 4M), and snapshot the subvolume. Now if we do an incremental send, we will send write commands full of zeroes for the range [2M, 4M), removing the hole for [2M, 3M) at the receiver.
We could improve cases such as this last one by doing additional comparisons of file extent items (or their absence) between the parent and send snapshots, but that's a lot of code to add plus additional CPU and IO costs.
Since the send stream v2 already has a fallocate command and btrfs-progs implements a callback to execute fallocate since the send stream v2 support was added to it, update the kernel to use fallocate for punching holes for V2+ streams.
Test coverage is provided by btrfs/284 which is a version of btrfs/007 that exercises send stream v2 instead of v1, using fsstress with random operations and fssum to verify file contents.
--- fs/btrfs/send.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
fs/btrfs/send.c +33 -0
@@ -4,6 +4,7 @@*/ #include <linux/bsearch.h> +#include <linux/falloc.h> #include <linux/fs.h> #include <linux/file.h> #include <linux/sort.h>
@@ -5411,6 +5412,30 @@ tlv_put_failure:return ret; } +static int send_fallocate (struct send_ctx *sctx,u32 mode,u64 offset,u64 len) +{ +struct fs_path *path; +int ret; + + path =get_cur_inode_path (sctx); +if (IS_ERR (path)) +return PTR_ERR (path); + + ret =begin_cmd (sctx,BTRFS_SEND_C_FALLOCATE ); +if (ret <0 ) +return ret; + +TLV_PUT_PATH (sctx,BTRFS_SEND_A_PATH , path); +TLV_PUT_U32 (sctx,BTRFS_SEND_A_FALLOCATE_MODE , mode); +TLV_PUT_U64 (sctx,BTRFS_SEND_A_FILE_OFFSET , offset); +TLV_PUT_U64 (sctx,BTRFS_SEND_A_SIZE , len); + + ret =send_cmd (sctx); + +tlv_put_failure: +return ret; +} +static int send_hole (struct send_ctx *sctx,u64 end) {struct fs_path *p =NULL ;
@@ -5419,6 +5444,14 @@ static int send_hole(struct send_ctx *scint ret =0 ;/* +* Starting with send stream v2 we have fallocate and can use it to +* punch holes instead of sending writes full of zeroes. +*/ +if (proto_cmd_ok (sctx,BTRFS_SEND_C_FALLOCATE )) +return send_fallocate (sctx,FALLOC_FL_PUNCH_HOLE |FALLOC_FL_KEEP_SIZE , + offset, end - offset); + +/* * A hole that starts at EOF or beyond it. Since we do not yet support * fallocate (for extent preallocation and hole punching), sending a * write of zeroes starting at EOF or beyond would later require issuing
Greg Kroah-Hartman
maintainerPATCH 527/570 btrfs: fix log tree replay failure due to file with 0 links and extents
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 0a32e4f0025a74c70dcab4478e9b29c22f5ecf2f upstream.
If we log a new inode (not persisted in a past transaction) that has 0 links and extents, then log another inode with an higher inode number, we end up with failing to replay the log tree with -EINVAL. The steps for this are:
1) create new file A
2) write some data to file A
3) open an fd on file A
4) unlink file A
5) fsync file A using the previously open fd
6) create file B (has higher inode number than file A)
7) fsync file B
8) power fail before current transaction commits
Now when attempting to mount the fs, the log replay will fail with -ENOENT at replay_one_extent() when attempting to replay the first extent of file A. The failure comes when trying to open the inode for file A in the subvolume tree, since it doesn't exist.
Before commit 5f61b961599a ("btrfs: fix inode lookup error handling during log replay"), the returned error was -EIO instead of -ENOENT, since we converted any errors when attempting to read an inode during log replay to -EIO.
The reason for this is that the log replay procedure fails to ignore the current inode when we are at the stage LOG_WALK_REPLAY_ALL, our current inode has 0 links and last inode we processed in the previous stage has a non 0 link count. In other words, the issue is that at replay_one_extent() we only update wc->ignore_cur_inode if the current replay stage is LOG_WALK_REPLAY_INODES.
Fix this by updating wc->ignore_cur_inode whenever we find an inode item regardless of the current replay stage. This is a simple solution and easy to backport, but later we can do other alternatives like avoid logging extents or inode items other than the inode item for inodes with a link count of 0.
The problem with the wc->ignore_cur_inode logic has been around since commit f2d72f42d5fa ("Btrfs: fix warning when replaying log after fsync of a tmpfile") but it only became frequent to hit since the more recent commit 5e85262e542d ("btrfs: fix fsync of files with no hard links not persisting deletion"), because we stopped skipping inodes with a link count of 0 when logging, while before the problem would only be triggered if trying to replay a log tree created with an older kernel which has a logged inode with 0 links.
A test case for fstests will be submitted soon.
--- fs/btrfs/tree-log.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-)
fs/btrfs/tree-log.c +30 -18
@@ -321,8 +321,7 @@ struct walk_control {/* * Ignore any items from the inode currently being processed. Needs -* to be set every time we find a BTRFS_INODE_ITEM_KEY and we are in -* the LOG_WALK_REPLAY_INODES stage. +* to be set every time we find a BTRFS_INODE_ITEM_KEY. */ bool ignore_cur_inode;
@@ -2434,23 +2433,30 @@ static int replay_one_buffer(struct btrf nritems =btrfs_header_nritems (eb);for (i =0 ; i < nritems; i++) { -btrfs_item_key_to_cpu (eb, &key, i); +struct btrfs_inode_item *inode_item; -/* inode keys are done during the first stage */ -if (key.type ==BTRFS_INODE_ITEM_KEY && - wc->stage ==LOG_WALK_REPLAY_INODES ) { -struct btrfs_inode_item *inode_item; -u32 mode; +btrfs_item_key_to_cpu (eb, &key, i); - inode_item =btrfs_item_ptr (eb, i, - struct btrfs_inode_item); +if (key.type ==BTRFS_INODE_ITEM_KEY ) { + inode_item = btrfs_item_ptr(eb, i, struct btrfs_inode_item);/* -* If we have a tmpfile (O_TMPFILE) that got fsync'ed -* and never got linked before the fsync, skip it, as -* replaying it is pointless since it would be deleted -* later. We skip logging tmpfiles, but it's always -* possible we are replaying a log created with a kernel -* that used to log tmpfiles. +* An inode with no links is either: +* +* 1) A tmpfile (O_TMPFILE) that got fsync'ed and never +* got linked before the fsync, skip it, as replaying +* it is pointless since it would be deleted later. +* We skip logging tmpfiles, but it's always possible +* we are replaying a log created with a kernel that +* used to log tmpfiles; +* +* 2) A non-tmpfile which got its last link deleted +* while holding an open fd on it and later got +* fsynced through that fd. We always log the +* parent inodes when inode->last_unlink_trans is +* set to the current transaction, so ignore all the +* inode items for this inode. We will delete the +* inode when processing the parent directory with +* replay_dir_deletes(). */ if (btrfs_inode_nlink (eb, inode_item) ==0 ) { wc->ignore_cur_inode = true;
@@ -2458,8 +2464,14 @@ static int replay_one_buffer(struct btrf }else { wc->ignore_cur_inode = false; } - ret =replay_xattr_deletes (wc->trans, root, log, - path, key.objectid); + } + +/* Inode keys are done during the first stage. */ +if (key.type ==BTRFS_INODE_ITEM_KEY && + wc->stage ==LOG_WALK_REPLAY_INODES ) { +u32 mode; + + ret =replay_xattr_deletes (wc->trans, root, log, path, key.objectid);if (ret)break ; mode =btrfs_inode_mode (eb, inode_item);
Greg Kroah-Hartman
maintainerPATCH 528/570 btrfs: error on missing block group when unaccounting log tree extent buffers
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit fc5799986fbca957e2e3c0480027f249951b7bcf upstream.
Currently we only log an error message if we can't find the block group for a log tree extent buffer when unaccounting it (while freeing a log tree). A missing block group means something is seriously wrong and we end up leaking space from the metadata space info. So return -ENOENT in case we don't find the block group.
--- fs/btrfs/tree-log.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
fs/btrfs/tree-log.c +7 -12
@@ -2574,14 +2574,14 @@ static int replay_one_buffer(struct btrf/* * Correctly adjust the reserved bytes occupied by a log tree extent buffer */ -static void unaccount_log_buffer (struct btrfs_fs_info *fs_info,u64 start) +static int unaccount_log_buffer (struct btrfs_fs_info *fs_info,u64 start) {struct btrfs_block_group *cache; cache =btrfs_lookup_block_group (fs_info, start);if (!cache) {btrfs_err (fs_info,"unable to find block group for %llu" , start); -return ; +return -ENOENT ; }spin_lock (&cache->space_info->lock);
@@ -2592,27 +2592,22 @@ static void unaccount_log_buffer(structspin_unlock (&cache->space_info->lock);btrfs_put_block_group (cache); + +return 0 ; }static int clean_log_buffer (struct btrfs_trans_handle *trans,struct extent_buffer *eb) { -int ret; -btrfs_tree_lock (eb);btrfs_clear_buffer_dirty (trans, eb);wait_on_extent_buffer_writeback (eb);btrfs_tree_unlock (eb); -if (trans) { - ret =btrfs_pin_reserved_extent (trans, eb); -if (ret) -return ret; - }else { -unaccount_log_buffer (eb->fs_info, eb->start); - } +if (trans) +return btrfs_pin_reserved_extent (trans, eb); -return 0 ; +return unaccount_log_buffer (eb->fs_info, eb->start); } static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
Greg Kroah-Hartman
maintainerPATCH 529/570 btrfs: zoned: do not select metadata BG as finish target
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naohiro Aota <[email protected]>
commit 3a931e9b39c7ff8066657042f5f00d3b7e6ad315 upstream.
We call btrfs_zone_finish_one_bg() to zone finish one block group and make room to activate another block group. Currently, we can choose a metadata block group as a target. But, as we reserve an active metadata block group, we no longer want to select a metadata block group. So, skip it in the loop.
--- fs/btrfs/zoned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/zoned.c +1 -1
@@ -2651,7 +2651,7 @@ int btrfs_zone_finish_one_bg(struct btrfspin_lock (&block_group->lock);if (block_group->reserved || block_group->alloc_offset ==0 || - (block_group->flags &BTRFS_BLOCK_GROUP_SYSTEM ) || + !(block_group->flags &BTRFS_BLOCK_GROUP_DATA ) ||test_bit (BLOCK_GROUP_FLAG_ZONED_DATA_RELOC , &block_group->runtime_flags)) {spin_unlock (&block_group->lock);continue ;
Greg Kroah-Hartman
maintainerPATCH 530/570 btrfs: fix wrong length parameter for btrfs_cleanup_ordered_extents()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit deaf895212da74635a7f0a420e1ecf8f5eca1fe5 upstream.
Inside nocow_one_range(), if the checksum cloning for data reloc inode failed, we call btrfs_cleanup_ordered_extents() to cleanup the just allocated ordered extents.
But unlike extent_clear_unlock_delalloc(), btrfs_cleanup_ordered_extents() requires a length, not an inclusive end bytenr.
This can be problematic, as the @end is normally way larger than @len.
This means btrfs_cleanup_ordered_extents() can be called on folios out of the correct range, and if the out-of-range folio is under writeback, we can incorrectly clear the ordered flag of the folio, and trigger the DEBUG_WARN() inside btrfs_writepage_cow_fixup().
Fix the wrong parameter with correct length instead.
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -2010,7 +2010,7 @@ static int nocow_one_range(struct btrfs_* cleaered by the caller. */ if (ret <0 ) -btrfs_cleanup_ordered_extents (inode, file_pos, end); +btrfs_cleanup_ordered_extents (inode, file_pos, len);return ret; }
Greg Kroah-Hartman
maintainerPATCH 531/570 btrfs: fix iteration bug in __qgroup_excl_accounting()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
commit 7b632596188e1973c6b3ac1c9f8252f735e1039f upstream.
__qgroup_excl_accounting() uses the qgroup iterator machinery to update the account of one qgroups usage for all its parent hierarchy, when we either add or remove a relation and have only exclusive usage.
However, there is a small bug there: we loop with an extra iteration temporary qgroup called cur but never actually refer to that in the body of the loop. As a result, we redundantly account the same usage to the first qgroup in the list.
This can be reproduced in the following way:
mkfs.btrfs -f -O squota <dev>
mount <dev> <mnt>
btrfs subvol create <mnt>/sv
dd if=/dev/zero of=<mnt>/sv/f bs=1M count=1
sync
btrfs qgroup create 1/100 <mnt>
btrfs qgroup create 2/200 <mnt>
btrfs qgroup assign 1/100 2/200 <mnt>
btrfs qgroup assign 0/256 1/100 <mnt>
btrfs qgroup show <mnt>
and the broken result is (note the 2MiB on 1/100 and 0Mib on 2/100):
Qgroupid Referenced Exclusive Path -------- ---------- --------- ---- 0/5 16.00KiB 16.00KiB <toplevel> 0/256 1.02MiB 1.02MiB sv
Qgroupid Referenced Exclusive Path -------- ---------- --------- ---- 0/5 16.00KiB 16.00KiB <toplevel> 0/256 1.02MiB 1.02MiB sv 1/100 2.03MiB 2.03MiB 2/100<1 member qgroup> 2/100 0.00B 0.00B <0 member qgroups>
With this fix, which simply re-uses qgroup as the iteration variable, we see the expected result:
Qgroupid Referenced Exclusive Path -------- ---------- --------- ---- 0/5 16.00KiB 16.00KiB <toplevel> 0/256 1.02MiB 1.02MiB sv
Qgroupid Referenced Exclusive Path -------- ---------- --------- ---- 0/5 16.00KiB 16.00KiB <toplevel> 0/256 1.02MiB 1.02MiB sv 1/100 1.02MiB 1.02MiB 2/100<1 member qgroup> 2/100 1.02MiB 1.02MiB <0 member qgroups>
The existing fstests did not exercise two layer inheritance so this bug was missed. I intend to add that testing there, as well.
--- fs/btrfs/qgroup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/qgroup.c +1 -2
@@ -1481,7 +1481,6 @@ static int __qgroup_excl_accounting(stru struct btrfs_qgroup *src, int sign) {struct btrfs_qgroup *qgroup; -struct btrfs_qgroup *cur;LIST_HEAD (qgroup_list);u64 num_bytes = src->excl;int ret =0 ;
@@ -1491,7 +1490,7 @@ static int __qgroup_excl_accounting(stru goto out;qgroup_iterator_add (&qgroup_list, qgroup); -list_for_each_entry (cur, &qgroup_list, iterator) { +list_for_each_entry (qgroup, &qgroup_list, iterator) {struct btrfs_qgroup_list *glist; qgroup->rfer += sign * num_bytes;
Greg Kroah-Hartman
maintainerPATCH 532/570 btrfs: do not allow relocation of partially dropped subvolumes
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 4289b494ac553e74e86fed1c66b2bf9530bc1082 upstream.
[BUG]
There is an internal report that balance triggered transaction abort, with the following call trace:
item 85 key (594509824 169 0) itemoff 12599 itemsize 33
extent refs 1 gen 197740 flags 2
ref#0: tree block backref root 7
item 86 key (594558976 169 0) itemoff 12566 itemsize 33
extent refs 1 gen 197522 flags 2
ref#0: tree block backref root 7
...
BTRFS error (device loop0): extent item not found for insert, bytenr 594526208 num_bytes 16384 parent 449921024 root_objectid 934 owner 1 offset 0 BTRFS error (device loop0): failed to run delayed ref for logical 594526208 num_bytes 16384 type 182 action 1 ref_mod 1: -117
------------[ cut here ]------------ BTRFS: Transaction aborted (error -117) WARNING: CPU: 1 PID: 6963 at ../fs/btrfs/extent-tree.c:2168 btrfs_run_delayed_refs+0xfa/0x110 [btrfs]
And btrfs check doesn't report anything wrong related to the extent tree.
[CAUSE]
The cause is a little complex, firstly the extent tree indeed doesn't have the backref for 594526208.
The extent tree only have the following two backrefs around that bytenr on-disk:
item 65 key (594509824 METADATA_ITEM 0) itemoff 13880 itemsize 33
refs 1 gen 197740 flags TREE_BLOCK
tree block skinny level 0
(176 0x7) tree block backref root CSUM_TREE
item 66 key (594558976 METADATA_ITEM 0) itemoff 13847 itemsize 33
refs 1 gen 197522 flags TREE_BLOCK
tree block skinny level 0
(176 0x7) tree block backref root CSUM_TREE
But the such missing backref item is not an corruption on disk, as the offending delayed ref belongs to subvolume 934, and that subvolume is being dropped:
item 0 key (934 ROOT_ITEM 198229) itemoff 15844 itemsize 439
generation 198229 root_dirid 256 bytenr 10741039104 byte_limit 0 bytes_used 345571328
last_snapshot 198229 flags 0x1000000000001(RDONLY) refs 0
drop_progress key (206324 EXTENT_DATA 2711650304) drop_level 2
level 2 generation_v2 198229And that offending tree block 594526208 is inside the dropped range of that subvolume. That explains why there is no backref item for that bytenr and why btrfs check is not reporting anything wrong.
But this also shows another problem, as btrfs will do all the orphan subvolume cleanup at a read-write mount.
So half-dropped subvolume should not exist after an RW mount, and balance itself is also exclusive to subvolume cleanup, meaning we shouldn't hit a subvolume half-dropped during relocation.
The root cause is, there is no orphan item for this subvolume. In fact there are 5 subvolumes from around 2021 that have the same problem.
It looks like the original report has some older kernels running, and caused those zombie subvolumes.
Thankfully upstream commit 8d488a8c7ba2 ("btrfs: fix subvolume/snapshot deletion not triggered on mount") has long fixed the bug.
[ENHANCEMENT]
For repairing such old fs, btrfs-progs will be enhanced.
Considering how delayed the problem will show up (at run delayed ref time) and at that time we have to abort transaction already, it is too late.
Instead here we reject any half-dropped subvolume for reloc tree at the earliest time, preventing confusion and extra time wasted on debugging similar bugs.
--- fs/btrfs/relocation.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
fs/btrfs/relocation.c +19 -0
@@ -594,6 +594,25 @@ static struct btrfs_root *create_reloc_rif (btrfs_root_id (root) == objectid) {u64 commit_root_gen; +/* +* Relocation will wait for cleaner thread, and any half-dropped +* subvolume will be fully cleaned up at mount time. +* So here we shouldn't hit a subvolume with non-zero drop_progress. +* +* If this isn't the case, error out since it can make us attempt to +* drop references for extents that were already dropped before. +*/ +if (unlikely (btrfs_disk_key_objectid (&root->root_item.drop_progress))) { +struct btrfs_key cpu_key; + +btrfs_disk_key_to_cpu (&cpu_key, &root->root_item.drop_progress); +btrfs_err (fs_info, +"cannot relocate partially dropped subvolume %llu, drop progress key (%llu %u %llu)" , + objectid, cpu_key.objectid, cpu_key.type, cpu_key.offset); + ret = -EUCLEAN ; + goto fail; + } +/* called by btrfs_init_reloc_root */ ret =btrfs_copy_root (trans, root, root->commit_root, &eb,BTRFS_TREE_RELOC_OBJECTID );
Greg Kroah-Hartman
maintainerPATCH 533/570 xfs: fix scrub trace with null pointer in quotacheck
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Albershteyn <[email protected]>
commit 5d94b19f066480addfcdcb5efde66152ad5a7c0e upstream.
The quotacheck doesn't initialize sc->ip.
--- fs/xfs/scrub/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/scrub/trace.h +1 -1
@@ -479,7 +479,7 @@ DECLARE_EVENT_CLASS(xchk_dqiter_class,__field (xfs_exntst_t, state) ),TP_fast_assign ( - __entry->dev = cursor->sc->ip->i_mount->m_super->s_dev; + __entry->dev = cursor->sc->mp->m_super->s_dev; __entry->dqtype = cursor->dqtype; __entry->ino = cursor->quota_ip->i_ino; __entry->cur_id = cursor->id;
Greg Kroah-Hartman
maintainerPATCH 534/570 userfaultfd: fix a crash in UFFDIO_MOVE when PMD is a migration entry
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
commit aba6faec0103ed8f169be8dce2ead41fcb689446 upstream.
When UFFDIO_MOVE encounters a migration PMD entry, it proceeds with obtaining a folio and accessing it even though the entry is swp_entry_t. Add the missing check and let split_huge_pmd() handle migration entries. While at it also remove unnecessary folio check.
--- mm/userfaultfd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
mm/userfaultfd.c +9 -6
@@ -1829,13 +1829,16 @@ ssize_t move_pages(struct userfaultfd_ct/* Check if we can move the pmd without splitting it. */ if (move_splits_huge_pmd (dst_addr, src_addr, src_start + len) || !pmd_none (dst_pmdval)) { -struct folio *folio =pmd_folio (*src_pmd); +/* Can be a migration entry */ +if (pmd_present (*src_pmd)) { +struct folio *folio =pmd_folio (*src_pmd); -if (!folio || (!is_huge_zero_folio (folio) && - !PageAnonExclusive (&folio->page))) { -spin_unlock (ptl); - err = -EBUSY ; -break ; +if (!is_huge_zero_folio (folio) && + !PageAnonExclusive (&folio->page)) { +spin_unlock (ptl); + err = -EBUSY ; +break ; + } }spin_unlock (ptl);
Greg Kroah-Hartman
maintainerPATCH 535/570 fbdev: Fix vmalloc out-of-bounds write in fast_imageblit
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sravan Kumar Gundu <[email protected]>
commit af0db3c1f898144846d4c172531a199bb3ca375d upstream.
This issue triggers when a userspace program does an ioctl FBIOPUT_CON2FBMAP by passing console number and frame buffer number. Ideally this maps console to frame buffer and updates the screen if console is visible.
As part of mapping it has to do resize of console according to frame buffer info. if this resize fails and returns from vc_do_resize() and continues further. At this point console and new frame buffer are mapped and sets display vars. Despite failure still it continue to proceed updating the screen at later stages where vc_data is related to previous frame buffer and frame buffer info and display vars are mapped to new frame buffer and eventully leading to out-of-bounds write in fast_imageblit(). This bheviour is excepted only when fg_console is equal to requested console which is a visible console and updates screen with invalid struct references in fbcon_putcs().
--- drivers/video/fbdev/core/fbcon.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/video/fbdev/core/fbcon.c +5 -4
@@ -825,7 +825,8 @@ static void con2fb_init_display(struct v fg_vc->vc_rows); } -update_screen (vc_cons[fg_console].d); +if (fg_console != unit) +update_screen (vc_cons[fg_console].d); }/**
@@ -1362,6 +1363,7 @@ static void fbcon_set_disp(struct fb_infstruct vc_data *svc;struct fbcon_ops *ops = info->fbcon_par;int rows, cols; +unsigned long ret =0 ; p = &fb_display[unit];
@@ -1412,11 +1414,10 @@ static void fbcon_set_disp(struct fb_inf rows =FBCON_SWAP (ops->rotate, info->var.yres, info->var.xres); cols /= vc->vc_font.width; rows /= vc->vc_font.height; -vc_resize (vc, cols, rows); + ret =vc_resize (vc, cols, rows); -if (con_is_visible (vc)) { +if (con_is_visible (vc) && !ret)update_screen (vc); - } }static __inline__void ywrap_up (struct vc_data *vc,int count)
Greg Kroah-Hartman
maintainerPATCH 536/570 fbdev: nvidiafb: add depends on HAS_IOPORT
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
commit ecdd7df997fd992f0ec70b788e3b12258008a2bf upstream.
The nvidiafb driver uses inb()/outb() without depending on HAS_IOPORT, which leads to build errors since kernel v6.13-rc1:
commit 6f043e757445 ("asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n")
Add the HAS_IOPORT dependency to prevent the build errors.
(Found in ARCH=um allmodconfig builds)
drivers/video/fbdev/nvidia/nv_accel.c: In function ‘NVDmaWait’:include/asm-generic/io.h:596:15: error: call to ‘_outb’ declared with attribute error: outb() requires CONFIG_HAS_IOPORT
596 | #define _outb _outb
--- drivers/video/fbdev/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/Kconfig +1 -1
@@ -660,7 +660,7 @@ config FB_ATMEL config FB_NVIDIA tristate "nVidia Framebuffer Support" - depends on FB && PCI + depends on FB && PCI && HAS_IOPORT select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT
Greg Kroah-Hartman
maintainerPATCH 537/570 ocfs2: reset folio to NULL when get folio fails
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Xu <[email protected]>
commit 2ae826799932ff89409f56636ad3c25578fe7cf5 upstream.
The reproducer uses FAULT_INJECTION to make memory allocation fail, which causes __filemap_get_folio() to fail, when initializing w_folios[i] in ocfs2_grab_folios_for_write(), it only returns an error code and the value of w_folios[i] is the error code, which causes ocfs2_unlock_and_free_folios() to recycle the invalid w_folios[i] when releasing folios.
--- fs/ocfs2/aops.c | 1 + 1 file changed, 1 insertion(+)
fs/ocfs2/aops.c +1 -0
@@ -1071,6 +1071,7 @@ static int ocfs2_grab_folios_for_write(sif (IS_ERR (wc->w_folios[i])) { ret =PTR_ERR (wc->w_folios[i]);mlog_errno (ret); + wc->w_folios[i] =NULL ; goto out; } }
Greg Kroah-Hartman
maintainerPATCH 538/570 net/sched: ets: use old nbands while purging unused classes
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davide Caratti <[email protected]>
commit 87c6efc5ce9c126ae4a781bc04504b83780e3650 upstream.
Shuang reported sch_ets test-case [1] crashing in ets_class_qlen_notify() after recent changes from Lion [2]. The problem is: in ets_qdisc_change() we purge unused DWRR queues; the value of 'q->nbands' is the new one, and the cleanup should be done with the old one. The problem is here since my first attempts to fix ets_qdisc_change(), but it surfaced again after the recent qdisc len accounting fixes. Fix it purging idle DWRR queues before assigning a new value of 'q->nbands', so that all purge operations find a consistent configuration:
- old 'q->nbands' because it's needed by ets_class_find()
- old 'q->nstrict' because it's needed by ets_class_is_strict()
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: Oops: 0000 [#1] SMP NOPTI CPU: 62 UID: 0 PID: 39457 Comm: tc Kdump: loaded Not tainted 6.12.0-116.el10.x86_64 #1 PREEMPT(voluntary) Hardware name: Dell Inc. PowerEdge R640/06DKY5, BIOS 2.12.2 07/09/2021 RIP: 0010:__list_del_entry_valid_or_report+0x4/0x80 Code: ff 4c 39 c7 0f 84 39 19 8e ff b8 01 00 00 00 c3 cc cc cc cc 66 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa <48> 8b 17 48 8b 4f 08 48 85 d2 0f 84 56 19 8e ff 48 85 c9 0f 84 ab RSP: 0018:ffffba186009f400 EFLAGS: 00010202 RAX: 00000000000000d6 RBX: 0000000000000000 RCX: 0000000000000004 RDX: ffff9f0fa29b69c0 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffffffc12c2400 R08: 0000000000000008 R09: 0000000000000004 R10: ffffffffffffffff R11: 0000000000000004 R12: 0000000000000000 R13: ffff9f0f8cfe0000 R14: 0000000000100005 R15: 0000000000000000 FS: 00007f2154f37480(0000) GS:ffff9f269c1c0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000001530be001 CR4: 00000000007726f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <TASK> ets_class_qlen_notify+0x65/0x90 [sch_ets] qdisc_tree_reduce_backlog+0x74/0x110 ets_qdisc_change+0x630/0xa40 [sch_ets] __tc_modify_qdisc.constprop.0+0x216/0x7f0 tc_modify_qdisc+0x7c/0x120 rtnetlink_rcv_msg+0x145/0x3f0 netlink_rcv_skb+0x53/0x100 netlink_unicast+0x245/0x390 netlink_sendmsg+0x21b/0x470 ____sys_sendmsg+0x39d/0x3d0 ___sys_sendmsg+0x9a/0xe0 __sys_sendmsg+0x7a/0xd0 do_syscall_64+0x7d/0x160 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f2155114084 Code: 89 02 b8 ff ff ff ff eb bb 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 80 3d 25 f0 0c 00 00 74 13 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 48 83 ec 28 89 54 24 1c 48 89 RSP: 002b:00007fff1fd7a988 EFLAGS: 00000202 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 0000560ec063e5e0 RCX: 00007f2155114084 RDX: 0000000000000000 RSI: 00007fff1fd7a9f0 RDI: 0000000000000003 RBP: 00007fff1fd7aa60 R08: 0000000000000010 R09: 000000000000003f R10: 0000560ee9b3a010 R11: 0000000000000202 R12: 00007fff1fd7aae0 R13: 000000006891ccde R14: 0000560ec063e5e0 R15: 00007fff1fd7aad0 </TASK>
[1] https://lore.kernel.org/netdev/e08c7f4a6882f260011909a868311c6e9b54f3e4.1639153474.git.dcaratti@redhat.com/
[2] https://lore.kernel.org/netdev/[email protected]/
--- net/sched/sch_ets.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/sched/sch_ets.c +6 -5
@@ -651,6 +651,12 @@ static int ets_qdisc_change(struct Qdiscsch_tree_lock (sch); +for (i = nbands; i < oldbands; i++) { +if (i >= q->nstrict && q->classes[i].qdisc->q.qlen) +list_del_init (&q->classes[i].alist); +qdisc_purge_queue (q->classes[i].qdisc); + } +WRITE_ONCE (q->nbands, nbands);for (i = nstrict; i < q->nstrict; i++) {if (q->classes[i].qdisc->q.qlen) {
@@ -658,11 +664,6 @@ static int ets_qdisc_change(struct Qdisc q->classes[i].deficit = quanta[i]; } } -for (i = q->nbands; i < oldbands; i++) { -if (i >= q->nstrict && q->classes[i].qdisc->q.qlen) -list_del_init (&q->classes[i].alist); -qdisc_purge_queue (q->classes[i].qdisc); - }WRITE_ONCE (q->nstrict, nstrict);memcpy (q->prio2band, priomap,sizeof (priomap));
Greg Kroah-Hartman
maintainerPATCH 539/570 hv_netvsc: Fix panic during namespace deletion with VF
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haiyang Zhang <[email protected]>
commit 33caa208dba6fa639e8a92fd0c8320b652e5550c upstream.
The existing code move the VF NIC to new namespace when NETDEV_REGISTER is received on netvsc NIC. During deletion of the namespace, default_device_exit_batch() >> default_device_exit_net() is called. When netvsc NIC is moved back and registered to the default namespace, it automatically brings VF NIC back to the default namespace. This will cause the default_device_exit_net() >> for_each_netdev_safe loop unable to detect the list end, and hit NULL ptr:
[ 231.449420] mana 7870:00:00.0 enP30832s1: Moved VF to namespace with: eth0 [ 231.449656] BUG: kernel NULL pointer dereference, address: 0000000000000010 [ 231.450246] #PF: supervisor read access in kernel mode [ 231.450579] #PF: error_code(0x0000) - not-present page [ 231.450916] PGD 17b8a8067 P4D 0 [ 231.451163] Oops: Oops: 0000 [#1] SMP NOPTI [ 231.451450] CPU: 82 UID: 0 PID: 1394 Comm: kworker/u768:1 Not tainted 6.16.0-rc4+ #3 VOLUNTARY [ 231.452042] Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.1 11/21/2024 [ 231.452692] Workqueue: netns cleanup_net [ 231.452947] RIP: 0010:default_device_exit_batch+0x16c/0x3f0 [ 231.453326] Code: c0 0c f5 b3 e8 d5 db fe ff 48 85 c0 74 15 48 c7 c2 f8 fd ca b2 be 10 00 00 00 48 8d 7d c0 e8 7b 77 25 00 49 8b 86 28 01 00 00 <48> 8b 50 10 4c 8b 2a 4c 8d 62 f0 49 83 ed 10 4c 39 e0 0f 84 d6 00 [ 231.454294] RSP: 0018:ff75fc7c9bf9fd00 EFLAGS: 00010246 [ 231.454610] RAX: 0000000000000000 RBX: 0000000000000002 RCX: 61c8864680b583eb [ 231.455094] RDX: ff1fa9f71462d800 RSI: ff75fc7c9bf9fd38 RDI: 0000000030766564 [ 231.455686] RBP: ff75fc7c9bf9fd78 R08: 0000000000000000 R09: 0000000000000000 [ 231.456126] R10: 0000000000000001 R11: 0000000000000004 R12: ff1fa9f70088e340 [ 231.456621] R13: ff1fa9f70088e340 R14: ffffffffb3f50c20 R15: ff1fa9f7103e6340 [ 231.457161] FS: 0000000000000000(0000) GS:ff1faa6783a08000(0000) knlGS:0000000000000000 [ 231.457707] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 231.458031] CR2: 0000000000000010 CR3: 0000000179ab2006 CR4: 0000000000b73ef0 [ 231.458434] Call Trace: [ 231.458600] <TASK> [ 231.458777] ops_undo_list+0x100/0x220 [ 231.459015] cleanup_net+0x1b8/0x300 [ 231.459285] process_one_work+0x184/0x340
To fix it, move the ns change to a workqueue, and take rtnl_lock to avoid changing the netdev list when default_device_exit_net() is using it.
--- drivers/net/hyperv/hyperv_net.h | 3 +++ drivers/net/hyperv/netvsc_drv.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)
drivers/net/hyperv/hyperv_net.h +3 -0
@@ -1061,6 +1061,7 @@ struct net_device_context {struct net_device __rcu *vf_netdev;struct netvsc_vf_pcpu_stats __percpu *vf_stats;struct delayed_work vf_takeover; +struct delayed_work vfns_work;/* 1: allocated, serial number is valid. 0: not allocated */ u32 vf_alloc;
@@ -1075,6 +1076,8 @@ struct net_device_context {struct netvsc_device_info *saved_netvsc_dev_info; }; +void netvsc_vfns_work (struct work_struct *w); +/* Azure hosts don't support non-TCP port numbers in hashing for fragmented * packets. We can use ethtool to change UDP hash level when necessary. */
drivers/net/hyperv/netvsc_drv.c +28 -1
@@ -2530,6 +2530,7 @@ static int netvsc_probe(struct hv_devicespin_lock_init (&net_device_ctx->lock);INIT_LIST_HEAD (&net_device_ctx->reconfig_events);INIT_DELAYED_WORK (&net_device_ctx->vf_takeover, netvsc_vf_setup); +INIT_DELAYED_WORK (&net_device_ctx->vfns_work, netvsc_vfns_work); net_device_ctx->vf_stats = netdev_alloc_pcpu_stats(struct netvsc_vf_pcpu_stats);
@@ -2674,6 +2675,8 @@ static void netvsc_remove(struct hv_devicancel_delayed_work_sync (&ndev_ctx->dwork);rtnl_lock (); +cancel_delayed_work_sync (&ndev_ctx->vfns_work); + nvdev =rtnl_dereference (ndev_ctx->nvdev);if (nvdev) {cancel_work_sync (&nvdev->subchan_work);
@@ -2715,6 +2718,7 @@ static int netvsc_suspend(struct hv_devicancel_delayed_work_sync (&ndev_ctx->dwork);rtnl_lock (); +cancel_delayed_work_sync (&ndev_ctx->vfns_work); nvdev =rtnl_dereference (ndev_ctx->nvdev);if (nvdev ==NULL ) {
@@ -2808,6 +2812,27 @@ static void netvsc_event_set_vf_ns(struc } } +void netvsc_vfns_work (struct work_struct *w) +{ +struct net_device_context *ndev_ctx = + container_of(w, struct net_device_context, vfns_work.work); +struct net_device *ndev; + +if (!rtnl_trylock ()) { +schedule_delayed_work (&ndev_ctx->vfns_work,1 ); +return ; + } + + ndev =hv_get_drvdata (ndev_ctx->device_ctx); +if (!ndev) + goto out; + +netvsc_event_set_vf_ns (ndev); + +out: +rtnl_unlock (); +} +/* * On Hyper-V, every VF interface is matched with a corresponding * synthetic interface. The synthetic interface is presented first
@@ -2818,10 +2843,12 @@ static int netvsc_netdev_event(struct no unsigned long event, void *ptr) { struct net_device *event_dev = netdev_notifier_info_to_dev(ptr); +struct net_device_context *ndev_ctx;int ret =0 ;if (event_dev->netdev_ops == &device_ops && event ==NETDEV_REGISTER ) { -netvsc_event_set_vf_ns (event_dev); + ndev_ctx =netdev_priv (event_dev); +schedule_delayed_work (&ndev_ctx->vfns_work,0 );return NOTIFY_DONE ; }
Greg Kroah-Hartman
maintainerPATCH 540/570 i2c: core: Fix double-free of fwnode in i2c_unregister_device()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 1c24e5fc0c7096e00c202a6a3e0c342c1afb47c2 upstream.
Before commit df6d7277e552 ("i2c: core: Do not dereference fwnode in struct device"), i2c_unregister_device() only called fwnode_handle_put() on of_node-s in the form of calling of_node_put(client->dev.of_node).
But after this commit the i2c_client's fwnode now unconditionally gets fwnode_handle_put() on it.
When the i2c_client has no primary (ACPI / OF) fwnode but it does have a software fwnode, the software-node will be the primary node and fwnode_handle_put() will put() it.
But for the software fwnode device_remove_software_node() will also put() it leading to a double free:
[ 82.665598] ------------[ cut here ]------------ [ 82.665609] refcount_t: underflow; use-after-free. [ 82.665808] WARNING: CPU: 3 PID: 1502 at lib/refcount.c:28 refcount_warn_saturate+0xba/0x11 ... [ 82.666830] RIP: 0010:refcount_warn_saturate+0xba/0x110 ... [ 82.666962] <TASK> [ 82.666971] i2c_unregister_device+0x60/0x90
Fix this by not calling fwnode_handle_put() when the primary fwnode is a software-node.
--- drivers/i2c/i2c-core-base.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/i2c/i2c-core-base.c +7 -1
@@ -1066,7 +1066,13 @@ void i2c_unregister_device(struct i2c_client *client)of_node_clear_flag (to_of_node (fwnode),OF_POPULATED ); else if (is_acpi_device_node(fwnode)) acpi_device_clear_enumerated(to_acpi_device_node(fwnode)); -fwnode_handle_put (fwnode ); + +/* +* If the primary fwnode is a software node it is free-ed by +* device_remove_software_node() below, avoid double-free. +*/ +if (!is_software_node (fwnode)) +fwnode_handle_put (fwnode);device_remove_software_node (&client->dev);device_unregister (&client->dev);
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 541/570 parisc: Makefile: fix a typo in palo.conf
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
commit 963f1b20a8d2a098954606b9725cd54336a2a86c upstream.
Correct "objree" to "objtree". "objree" is not defined.
--- arch/parisc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/Makefile +1 -1
@@ -139,7 +139,7 @@ palo lifimage: vmlinuz fi @if test ! -f "$(PALOCONF)"; then \ cp $(srctree)/arch/parisc/defpalo.conf $(objtree)/palo.conf; \ - echo 'A generic palo config file ($(objree)/palo.conf) has been created for you.'; \ + echo 'A generic palo config file ($(objtree)/palo.conf) has been created for you.'; \ echo 'You should check it and re-run "make palo".'; \ echo 'WARNING: the "lifimage" file is now placed in this directory by default!'; \ false; \
Greg Kroah-Hartman
maintainerPATCH 542/570 mm, slab: restore NUMA policy support for large kmalloc
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit e2d18cbf178775ad377ad88ee55e6e183c38d262 upstream.
The slab allocator observes the task's NUMA policy in various places such as allocating slab pages. Large kmalloc() allocations used to do that too, until an unintended change by c4cab557521a ("mm/slab_common:
cleanup kmalloc_large()") resulted in ignoring mempolicy and just preferring the local node. Restore the NUMA policy support.
--- mm/slub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
mm/slub.c +6 -1
@@ -4269,7 +4269,12 @@ static void *___kmalloc_large_node(size_ flags =kmalloc_fix_flags (flags); flags |= __GFP_COMP; - folio = (struct folio *)alloc_pages_node_noprof (node, flags, order); + +if (node ==NUMA_NO_NODE ) + folio = (struct folio *)alloc_pages_noprof (flags, order); +else + folio = (struct folio *)__alloc_pages_noprof (flags, order, node,NULL ); +if (folio) { ptr =folio_address (folio); lruvec_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B,
Greg Kroah-Hartman
maintainerPATCH 543/570 mm/huge_memory: dont ignore queried cachemode in vmf_insert_pfn_pud()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
commit 09fefdca80aebd1023e827cb0ee174983d829d18 upstream.
Patch series "mm/huge_memory: vmf_insert_folio_*() and vmf_insert_pfn_pud() fixes", v3.
While working on improving vm_normal_page() and friends, I stumbled over this issues: refcounted "normal" folios must not be marked using pmd_special() / pud_special(). Otherwise, we're effectively telling the system that these folios are no "normal", violating the rules we documented for vm_normal_page().
Fortunately, there are not many pmd_special()/pud_special() users yet. So far there doesn't seem to be serious damage.
Tested using the ndctl tests ("ndctl:dax" suite).
This patch (of 3):
We set up the cache mode but ... don't forward the updated pgprot to insert_pfn_pud().
Only a problem on x86-64 PAT when mapping PFNs using PUDs that require a special cachemode.
Fix it by using the proper pgprot where the cachemode was setup.
It is unclear in which configurations we would get the cachemode wrong:
through vfio seems possible. Getting cachemodes wrong is usually ... bad. As the fix is easy, let's backport it to stable.
Identified by code inspection.
--- mm/huge_memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
mm/huge_memory.c +3 -4
@@ -1516,10 +1516,9 @@ static pud_t maybe_pud_mkwrite(pud_t pud }static void insert_pfn_pud (struct vm_area_struct *vma,unsigned long addr, -pud_t *pud,pfn_t pfn,bool write) +pud_t *pud,pfn_t pfn,pgprot_t prot,bool write) {struct mm_struct *mm = vma->vm_mm; -pgprot_t prot = vma->vm_page_prot;pud_t entry;if (!pud_none (*pud)) {
@@ -1581,7 +1580,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_pfnmap_setup_cachemode_pfn (pfn_t_to_pfn (pfn), &pgprot); ptl =pud_lock (vma->vm_mm, vmf->pud); -insert_pfn_pud (vma, addr, vmf->pud, pfn, write); +insert_pfn_pud (vma, addr, vmf->pud, pfn, pgprot, write);spin_unlock (ptl);return VM_FAULT_NOPAGE ;
@@ -1625,7 +1624,7 @@ vm_fault_t vmf_insert_folio_pud(struct vadd_mm_counter (mm,mm_counter_file (folio),HPAGE_PUD_NR ); }insert_pfn_pud (vma, addr, vmf->pud,pfn_to_pfn_t (folio_pfn (folio)), - write); + vma->vm_page_prot, write);spin_unlock (ptl);return VM_FAULT_NOPAGE ;
Greg Kroah-Hartman
maintainerPATCH 544/570 mm/ptdump: take the memory hotplug lock inside ptdump_walk_pgd()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshuman Khandual <[email protected]>
commit 59305202c67fea50378dcad0cc199dbc13a0e99a upstream.
Memory hot remove unmaps and tears down various kernel page table regions as required. The ptdump code can race with concurrent modifications of the kernel page tables. When leaf entries are modified concurrently, the dump code may log stale or inconsistent information for a VA range, but this is otherwise not harmful.
But when intermediate levels of kernel page table are freed, the dump code will continue to use memory that has been freed and potentially reallocated for another purpose. In such cases, the ptdump code may dereference bogus addresses, leading to a number of potential problems.
To avoid the above mentioned race condition, platforms such as arm64, riscv and s390 take memory hotplug lock, while dumping kernel page table via the sysfs interface /sys/kernel/debug/kernel_page_tables.
Similar race condition exists while checking for pages that might have been marked W+X via /sys/kernel/debug/kernel_page_tables/check_wx_pages which in turn calls ptdump_check_wx(). Instead of solving this race condition again, let's just move the memory hotplug lock inside generic ptdump_check_wx() which will benefit both the scenarios.
Drop get_online_mems() and put_online_mems() combination from all existing platform ptdump code paths.
--- arch/arm64/mm/ptdump_debugfs.c | 3 --- arch/riscv/mm/ptdump.c | 3 --- arch/s390/mm/dump_pagetables.c | 2 -- mm/ptdump.c | 2 ++ 4 files changed, 2 insertions(+), 8 deletions(-)
arch/arm64/mm/ptdump_debugfs.c +0 -3
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/debugfs.h> -#include <linux/memory_hotplug.h> #include <linux/seq_file.h> #include <asm/ptdump.h>
@@ -9,9 +8,7 @@ static int ptdump_show(struct seq_file * {struct ptdump_info *info = m->private; -get_online_mems ();ptdump_walk (m, info); -put_online_mems ();return 0 ; }DEFINE_SHOW_ATTRIBUTE (ptdump);
arch/riscv/mm/ptdump.c +0 -3
@@ -6,7 +6,6 @@#include <linux/efi.h> #include <linux/init.h> #include <linux/debugfs.h> -#include <linux/memory_hotplug.h> #include <linux/seq_file.h> #include <linux/ptdump.h>
@@ -413,9 +412,7 @@ bool ptdump_check_wx(void)static int ptdump_show (struct seq_file *m,void *v) { -get_online_mems ();ptdump_walk (m, m->private); -put_online_mems ();return 0 ; }
arch/s390/mm/dump_pagetables.c +0 -2
@@ -247,11 +247,9 @@ static int ptdump_show(struct seq_file * .marker = markers, }; -get_online_mems ();mutex_lock (&cpa_mutex);ptdump_walk_pgd (&st.ptdump, &init_mm,NULL );mutex_unlock (&cpa_mutex); -put_online_mems ();return 0 ; }DEFINE_SHOW_ATTRIBUTE (ptdump);
mm/ptdump.c +2 -0
@@ -175,6 +175,7 @@ void ptdump_walk_pgd(struct ptdump_state {const struct ptdump_range *range = st->range; +get_online_mems ();mmap_write_lock (mm);while (range->start != range->end) { walk_page_range_novma(mm, range->start, range->end,
@@ -182,6 +183,7 @@ void ptdump_walk_pgd(struct ptdump_state range++; }mmap_write_unlock (mm); +put_online_mems ();/* Flush out the last page */ st->note_page_flush (st);
Greg Kroah-Hartman
maintainerPATCH 545/570 mm/shmem, swap: improve cached mTHP handling and fix potential hang
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kairui Song <[email protected]>
commit 5c241ed8d031693dadf33dd98ed2e7cc363e9b66 upstream.
The current swap-in code assumes that, when a swap entry in shmem mapping is order 0, its cached folios (if present) must be order 0 too, which turns out not always correct.
The problem is shmem_split_large_entry is called before verifying the folio will eventually be swapped in, one possible race is:
CPU1 CPU2shmem_swapin_folio
/* swap in of order > 0 swap entry S1 */
folio = swap_cache_get_folio
/* folio = NULL */
order = xa_get_order
/* order > 0 */
folio = shmem_swap_alloc_folio
/* mTHP alloc failure, folio = NULL */
<... Interrupted ...>
shmem_swapin_folio
/* S1 is swapped in */
shmem_writeout
/* S1 is swapped out, folio cached */ shmem_split_large_entry(..., S1)
/* S1 is split, but the folio covering it has order > 0 now */
Now any following swapin of S1 will hang: xa_get_order returns 0, and folio lookup will return a folio with order > 0. The xa_get_order(&mapping->i_pages, index) != folio_order(folio) will always return false causing swap-in to return -EEXIST.
And this looks fragile. So fix this up by allowing seeing a larger folio in swap cache, and check the whole shmem mapping range covered by the swapin have the right swap value upon inserting the folio. And drop the redundant tree walks before the insertion.
This will actually improve performance, as it avoids two redundant Xarray tree walks in the hot path, and the only side effect is that in the failure path, shmem may redundantly reallocate a few folios causing temporary slight memory pressure.
And worth noting, it may seems the order and value check before inserting might help reducing the lock contention, which is not true. The swap cache layer ensures raced swapin will either see a swap cache folio or failed to do a swapin (we have SWAP_HAS_CACHE bit even if swap cache is bypassed), so holding the folio lock and checking the folio flag is already good enough for avoiding the lock contention. The chance that a folio passes the swap entry value check but the shmem mapping slot has changed should be very low.
--- mm/shmem.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-)
mm/shmem.c +30 -9
@@ -884,7 +884,9 @@ static int shmem_add_to_page_cache(struc pgoff_t index, void *expected, gfp_t gfp) { XA_STATE_ORDER(xas, &mapping->i_pages, index, folio_order(folio)); -long nr =folio_nr_pages (folio); +unsigned long nr =folio_nr_pages (folio); +swp_entry_t iter, swap; +void *entry;VM_BUG_ON_FOLIO (index !=round_down (index, nr), folio);VM_BUG_ON_FOLIO (!folio_test_locked (folio), folio);
@@ -896,14 +898,25 @@ static int shmem_add_to_page_cache(struc gfp &=GFP_RECLAIM_MASK ;folio_throttle_swaprate (folio, gfp); + swap =radix_to_swp_entry (expected); do { + iter = swap; xas_lock_irq(&xas); - if (expected != xas_find_conflict(&xas)) { - xas_set_err(&xas, -EEXIST); - goto unlock; + xas_for_each_conflict(&xas, entry) { + /* + * The range must either be empty, or filled with + * expected swap entries. Shmem swap entries are never + * partially freed without split of both entry and + * folio, so there shouldn't be any holes. + */ + if (!expected || entry != swp_to_radix_entry(iter)) { + xas_set_err(&xas, -EEXIST); + goto unlock; + } + iter.val += 1 << xas_get_order(&xas); } - if (expected && xas_find_conflict(&xas)) { + if (expected && iter.val - nr != swap.val) { xas_set_err(&xas, -EEXIST); goto unlock; }
@@ -2327,7 +2340,7 @@ static int shmem_swapin_folio(struct ino error = -ENOMEM ; goto failed; } - }else if (order !=folio_order (folio)) { + }else if (order >folio_order (folio)) {/* * Swap readahead may swap in order 0 folios into swapcache * asynchronously, while the shmem mapping can still stores
@@ -2352,15 +2365,23 @@ static int shmem_swapin_folio(struct ino swap =swp_entry (swp_type (swap),swp_offset (swap) + offset); } + }else if (order <folio_order (folio)) { + swap.val =round_down (swap.val,1 <<folio_order (folio)); + index =round_down (index,1 <<folio_order (folio)); } alloced: -/* We have to do this with folio locked to prevent races */ +/* +* We have to do this with the folio locked to prevent races. +* The shmem_confirm_swap below only checks if the first swap +* entry matches the folio, that's enough to ensure the folio +* is not used outside of shmem, as shmem swap entries +* and swap cache folios are never partially freed. +*/ folio_lock (folio);if ((!skip_swapcache && !folio_test_swapcache (folio)) || - folio->swap.val != swap.val || !shmem_confirm_swap (mapping, index, swap) || -xa_get_order (&mapping->i_pages, index) !=folio_order (folio)) { + folio->swap.val != swap.val) { error = -EEXIST ; goto unlock; }
Greg Kroah-Hartman
maintainerPATCH 546/570 mm/kmemleak: avoid soft lockup in __kmemleak_do_cleanup()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
commit d1534ae23c2b6be350c8ab060803fbf6e9682adc upstream.
A soft lockup warning was observed on a relative small system x86-64 system with 16 GB of memory when running a debug kernel with kmemleak enabled.
watchdog: BUG: soft lockup - CPU#8 stuck for 33s! [kworker/8:1:134]
The test system was running a workload with hot unplug happening in parallel. Then kemleak decided to disable itself due to its inability to allocate more kmemleak objects. The debug kernel has its CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE set to 40,000.
The soft lockup happened in kmemleak_do_cleanup() when the existing kmemleak objects were being removed and deleted one-by-one in a loop via a workqueue. In this particular case, there are at least 40,000 objects that need to be processed and given the slowness of a debug kernel and the fact that a raw_spinlock has to be acquired and released in __delete_object(), it could take a while to properly handle all these objects.
As kmemleak has been disabled in this case, the object removal and deletion process can be further optimized as locking isn't really needed. However, it is probably not worth the effort to optimize for such an edge case that should rarely happen. So the simple solution is to call cond_resched() at periodic interval in the iteration loop to avoid soft lockup.
--- mm/kmemleak.c | 5 +++++ 1 file changed, 5 insertions(+)
mm/kmemleak.c +5 -0
@@ -2181,6 +2181,7 @@ static const struct file_operations kmemstatic void __kmemleak_do_cleanup (void ) {struct kmemleak_object *object, *tmp; +unsigned int cnt =0 ;/* * Kmemleak has already been disabled, no need for RCU list traversal
@@ -2189,6 +2190,10 @@ static void __kmemleak_do_cleanup(void)list_for_each_entry_safe (object, tmp, &object_list, object_list) {__remove_object (object);__delete_object (object); + +/* Call cond_resched() once per 64 iterations to avoid soft lockup */ +if (!(++cnt &0x3f )) +cond_resched (); } }
Greg Kroah-Hartman
maintainerPATCH 547/570 mm/kmemleak: avoid deadlock by moving pr_warn() outside kmemleak_lock
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
commit 47b0f6d8f0d2be4d311a49e13d2fd5f152f492b2 upstream.
When netpoll is enabled, calling pr_warn_once() while holding kmemleak_lock in mem_pool_alloc() can cause a deadlock due to lock inversion with the netconsole subsystem. This occurs because pr_warn_once() may trigger netpoll, which eventually leads to __alloc_skb() and back into kmemleak code, attempting to reacquire kmemleak_lock.
This is the path for the deadlock.
mem_pool_alloc()
-> raw_spin_lock_irqsave(&kmemleak_lock, flags);
-> pr_warn_once()
-> netconsole subsystem
-> netpoll
-> __alloc_skb
-> __create_object
-> raw_spin_lock_irqsave(&kmemleak_lock, flags);Fix this by setting a flag and issuing the pr_warn_once() after kmemleak_lock is released.
--- mm/kmemleak.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
mm/kmemleak.c +4 -1
@@ -470,6 +470,7 @@ static struct kmemleak_object *mem_pool_ {unsigned long flags;struct kmemleak_object *object; +bool warn = false;/* try the slab allocator first */ if (object_cache) {
@@ -488,8 +489,10 @@ static struct kmemleak_object *mem_pool_else if (mem_pool_free_count) object = &mem_pool[--mem_pool_free_count];else -pr_warn_once ("Memory pool empty, consider increasing CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE\n" ); + warn = true;raw_spin_unlock_irqrestore (&kmemleak_lock, flags); +if (warn) +pr_warn_once ("Memory pool empty, consider increasing CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE\n" );return object; }
Greg Kroah-Hartman
maintainerPATCH 548/570 media: uvcvideo: Fix 1-byte out-of-bounds read in uvc_parse_format()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youngjun Lee <[email protected]>
commit 782b6a718651eda3478b1824b37a8b3185d2740c upstream.
The buffer length check before calling uvc_parse_format() only ensured that the buffer has at least 3 bytes (buflen > 2), buf the function accesses buffer[3], requiring at least 4 bytes.
This can lead to an out-of-bounds read if the buffer has exactly 3 bytes.
Fix it by checking that the buffer has at least 4 bytes in uvc_parse_format().
--- drivers/media/usb/uvc/uvc_driver.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +3 -0
@@ -344,6 +344,9 @@ static int uvc_parse_format(struct uvc_du8 ftype;int ret; +if (buflen <4 ) +return -EINVAL ; + format->type = buffer[2 ]; format->index = buffer[3 ]; format->frames = frames;
Greg Kroah-Hartman
maintainerPATCH 549/570 media: venus: Fix OOB read due to missing payload bound check
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vedang Nagar <[email protected]>
commit 06d6770ff0d8cc8dfd392329a8cc03e2a83e7289 upstream.
Currently, The event_seq_changed() handler processes a variable number of properties sent by the firmware. The number of properties is indicated by the firmware and used to iterate over the payload. However, the payload size is not being validated against the actual message length.
This can lead to out-of-bounds memory access if the firmware provides a property count that exceeds the data available in the payload. Such a condition can result in kernel crashes or potential information leaks if memory beyond the buffer is accessed.
Fix this by properly validating the remaining size of the payload before each property access and updating bounds accordingly as properties are parsed.
This ensures that property parsing is safely bounded within the received message buffer and protects against malformed or malicious firmware behavior.
--- drivers/media/platform/qcom/venus/hfi_msgs.c | 83 ++++++++++++++++++--------- 1 file changed, 58 insertions(+), 25 deletions(-)
drivers/media/platform/qcom/venus/hfi_msgs.c +58 -25
@@ -33,8 +33,9 @@ static void event_seq_changed(struct venstruct hfi_buffer_requirements *bufreq;struct hfi_extradata_input_crop *crop;struct hfi_dpb_counts *dpb_count; +u32 ptype, rem_bytes; +u32 size_read =0 ;u8 *data_ptr; -u32 ptype; inst->error =HFI_ERR_NONE ;
@@ -44,86 +45,118 @@ static void event_seq_changed(struct venbreak ;default : inst->error =HFI_ERR_SESSION_INVALID_PARAMETER ; - goto done; + inst->ops->event_notify (inst,EVT_SYS_EVENT_CHANGE , &event); +return ; } event.event_type = pkt->event_data1; num_properties_changed = pkt->event_data2; -if (!num_properties_changed) { - inst->error =HFI_ERR_SESSION_INSUFFICIENT_RESOURCES ; - goto done; - } +if (!num_properties_changed) + goto error; data_ptr = (u8 *)&pkt->ext_event_data[0 ]; + rem_bytes = pkt->shdr.hdr.size -sizeof (*pkt); +do { +if (rem_bytes <sizeof (u32)) + goto error; ptype = *((u32 *)data_ptr); + + data_ptr +=sizeof (u32); + rem_bytes -=sizeof (u32); +switch (ptype) {case HFI_PROPERTY_PARAM_FRAME_SIZE : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (struct hfi_framesize )) + goto error; + frame_sz = (struct hfi_framesize *)data_ptr; event.width = frame_sz->width; event.height = frame_sz->height; - data_ptr +=sizeof (*frame_sz); + size_read =sizeof (struct hfi_framesize );break ;case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (struct hfi_profile_level )) + goto error; + profile_level = (struct hfi_profile_level *)data_ptr; event.profile = profile_level->profile; event.level = profile_level->level; - data_ptr +=sizeof (*profile_level); + size_read =sizeof (struct hfi_profile_level );break ;case HFI_PROPERTY_PARAM_VDEC_PIXEL_BITDEPTH : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (struct hfi_bit_depth )) + goto error; + pixel_depth = (struct hfi_bit_depth *)data_ptr; event.bit_depth = pixel_depth->bit_depth; - data_ptr +=sizeof (*pixel_depth); + size_read =sizeof (struct hfi_bit_depth );break ;case HFI_PROPERTY_PARAM_VDEC_PIC_STRUCT : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (struct hfi_pic_struct )) + goto error; + pic_struct = (struct hfi_pic_struct *)data_ptr; event.pic_struct = pic_struct->progressive_only; - data_ptr +=sizeof (*pic_struct); + size_read =sizeof (struct hfi_pic_struct );break ;case HFI_PROPERTY_PARAM_VDEC_COLOUR_SPACE : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (struct hfi_colour_space )) + goto error; + colour_info = (struct hfi_colour_space *)data_ptr; event.colour_space = colour_info->colour_space; - data_ptr +=sizeof (*colour_info); + size_read =sizeof (struct hfi_colour_space );break ;case HFI_PROPERTY_CONFIG_VDEC_ENTROPY : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (u32)) + goto error; + event.entropy_mode = *(u32 *)data_ptr; - data_ptr +=sizeof (u32); + size_read =sizeof (u32);break ;case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (struct hfi_buffer_requirements )) + goto error; + bufreq = (struct hfi_buffer_requirements *)data_ptr; event.buf_count =hfi_bufreq_get_count_min (bufreq, ver); - data_ptr +=sizeof (*bufreq); + size_read =sizeof (struct hfi_buffer_requirements );break ;case HFI_INDEX_EXTRADATA_INPUT_CROP : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (struct hfi_extradata_input_crop )) + goto error; + crop = (struct hfi_extradata_input_crop *)data_ptr; event.input_crop.left = crop->left; event.input_crop.top = crop->top; event.input_crop.width = crop->width; event.input_crop.height = crop->height; - data_ptr +=sizeof (*crop); + size_read =sizeof (struct hfi_extradata_input_crop );break ;case HFI_PROPERTY_PARAM_VDEC_DPB_COUNTS : - data_ptr +=sizeof (u32); +if (rem_bytes <sizeof (struct hfi_dpb_counts )) + goto error; + dpb_count = (struct hfi_dpb_counts *)data_ptr; event.buf_count = dpb_count->fw_min_cnt; - data_ptr +=sizeof (*dpb_count); + size_read =sizeof (struct hfi_dpb_counts );break ;default : + size_read =0 ;break ; } + data_ptr += size_read; + rem_bytes -= size_read; num_properties_changed--; }while (num_properties_changed >0 ); -done: + inst->ops->event_notify (inst,EVT_SYS_EVENT_CHANGE , &event); +return ; + +error: + inst->error =HFI_ERR_SESSION_INSUFFICIENT_RESOURCES ; inst->ops->event_notify (inst,EVT_SYS_EVENT_CHANGE , &event); }
Greg Kroah-Hartman
maintainerPATCH 550/570 media: uvcvideo: Do not mark valid metadata as invalid
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit bda2859bff0b9596a19648f3740c697ce4c71496 upstream.
Currently, the driver performs a length check of the metadata buffer before the actual metadata size is known and before the metadata is decided to be copied. This results in valid metadata buffers being incorrectly marked as invalid.
Move the length check to occur after the metadata size is determined and is decided to be copied.
--- drivers/media/usb/uvc/uvc_video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/usb/uvc/uvc_video.c +6 -6
@@ -1442,12 +1442,6 @@ static void uvc_video_decode_meta(structif (!meta_buf || length ==2 )return ; -if (meta_buf->length - meta_buf->bytesused < - length +sizeof (meta->ns) +sizeof (meta->sof)) { - meta_buf->error =1 ; -return ; - } - has_pts = mem[1 ] &UVC_STREAM_PTS ; has_scr = mem[1 ] &UVC_STREAM_SCR ;
@@ -1468,6 +1462,12 @@ static void uvc_video_decode_meta(struct !memcmp(scr, stream->clock.last_scr, 6)))return ; +if (meta_buf->length - meta_buf->bytesused < + length +sizeof (meta->ns) +sizeof (meta->sof)) { + meta_buf->error =1 ; +return ; + } + meta = (struct uvc_meta_buf *)((u8 *)meta_buf->mem + meta_buf->bytesused);local_irq_save (flags); time =uvc_video_get_time ();
Greg Kroah-Hartman
maintainerPATCH 551/570 media: v4l2: Add support for NV12M tiled variants to v4l2_format_info()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
commit f7546da1d6eb8928efb89b7faacbd6c2f8f0de5c upstream.
Commit 6f1466123d73 ("media: s5p-mfc: Add YV12 and I420 multiplanar format support") added support for the new formats to s5p-mfc driver, what in turn required some internal calls to the v4l2_format_info() function while setting up formats. This in turn broke support for the "old" tiled NV12MT* formats, which are not recognized by this function. Fix this by adding those variants of NV12M pixel format to v4l2_format_info() function database.
--- drivers/media/v4l2-core/v4l2-common.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/v4l2-core/v4l2-common.c +6 -0
@@ -323,6 +323,12 @@ const struct v4l2_format_info *v4l2_form { .format = V4L2_PIX_FMT_NV61M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 1 }, { .format = V4L2_PIX_FMT_P012M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 }, + /* Tiled YUV formats, non contiguous variant */ + { .format = V4L2_PIX_FMT_NV12MT, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2, + .block_w = { 64, 32, 0, 0 }, .block_h = { 32, 16, 0, 0 }}, + { .format = V4L2_PIX_FMT_NV12MT_16X16, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2, + .block_w = { 16, 8, 0, 0 }, .block_h = { 16, 8, 0, 0 }}, + /* Bayer RGB formats */ { .format = V4L2_PIX_FMT_SBGGR8, .pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_SGBRG8, .pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
Greg Kroah-Hartman
maintainerPATCH 552/570 media: uvcvideo: Turn on the camera if V4L2_EVENT_SUB_FL_SEND_INITIAL
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit a03e32e60141058d46ea8cf4631654c43c740fdb upstream.
If we subscribe to an event with V4L2_EVENT_SUB_FL_SEND_INITIAL, the driver needs to report back some values that require the camera to be powered on. But VIDIOC_SUBSCRIBE_EVENT is not part of the ioctls that turn on the camera.
We could unconditionally turn on the camera during VIDIOC_SUBSCRIBE_EVENT, but it is more efficient to turn it on only during V4L2_EVENT_SUB_FL_SEND_INITIAL, which we believe is not a common usecase.
To avoid a list_del if uvc_pm_get() fails, we move list_add_tail to the end of the function.
--- drivers/media/usb/uvc/uvc_ctrl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_ctrl.c +9 -1
@@ -2072,18 +2072,24 @@ static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned elems) goto done; } -list_add_tail (&sev->node, &mapping->ev_subs);if (sev->flags &V4L2_EVENT_SUB_FL_SEND_INITIAL ) {struct v4l2_event ev;u32 changes =V4L2_EVENT_CTRL_CH_FLAGS ;s32 val =0 ; + ret =uvc_pm_get (handle->chain->dev); +if (ret) + goto done; +if (uvc_ctrl_mapping_is_compound (mapping) ||__uvc_ctrl_get (handle->chain, ctrl, mapping, &val) ==0 ) changes |=V4L2_EVENT_CTRL_CH_VALUE ;uvc_ctrl_fill_event (handle->chain, &ev, ctrl, mapping, val, changes); + +uvc_pm_put (handle->chain->dev); +/* * Mark the queue as active, allowing this initial event to be * accepted.
@@ -2092,6 +2098,8 @@ static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned elems)v4l2_event_queue_fh (sev->fh, &ev); } +list_add_tail (&sev->node, &mapping->ev_subs); + done:mutex_unlock (&handle->chain->ctrl_mutex);return ret;
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 553/570 media: i2c: vd55g1: Fix return code in vd55g1_enable_streams error path
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Mugnier <[email protected]>
commit 5931eed35cb632ff8b7e0b0cc91abc6014c64045 upstream.
Enable stream was returning success even if an error occurred, fix it by modifying the err_rpm_put return value to -EINVAL.
--- drivers/media/i2c/vd55g1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/vd55g1.c +1 -1
@@ -1082,7 +1082,7 @@ static int vd55g1_enable_streams(struct err_rpm_put:pm_runtime_put (sensor->dev); -return 0 ; +return -EINVAL ; } static int vd55g1_disable_streams(struct v4l2_subdev *sd,
Greg Kroah-Hartman
maintainerPATCH 554/570 tracing: fprobe: Fix infinite recursion using preempt_*_notrace()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
commit a3e892ab0fc287389176eabdcd74234508f6e52d upstream.
Since preempt_count_add/del() are tracable functions, it is not allowed to use preempt_disable/enable() in ftrace handlers. Without this fix, probing on preempt_count_add%return will cause an infinite recursion of fprobes.
To fix this problem, use preempt_disable/enable_notrace() in fprobe_return().
--- kernel/trace/fprobe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/fprobe.c +2 -2
@@ -352,7 +352,7 @@ static void fprobe_return(struct ftrace_ size_words =SIZE_IN_LONG (size); ret_ip =ftrace_regs_get_instruction_pointer (fregs); -preempt_disable (); +preempt_disable_notrace (); curr =0 ;while (size_words > curr) {
@@ -368,7 +368,7 @@ static void fprobe_return(struct ftrace_ } curr += size; } -preempt_enable (); +preempt_enable_notrace (); }NOKPROBE_SYMBOL (fprobe_return);
Greg Kroah-Hartman
maintainerPATCH 555/570 tools/nolibc: fix spelling of FD_SETBITMASK in FD_* macros
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willy Tarreau <[email protected]>
commit a477629baa2a0e9991f640af418e8c973a1c08e3 upstream.
While nolibc-test does test syscalls, it doesn't test as much the rest of the macros, and a wrong spelling of FD_SETBITMASK in commit feaf75658783a broke programs using either FD_SET() or FD_CLR() without being noticed. Let's fix these macros.
--- tools/include/nolibc/types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/include/nolibc/types.h +2 -2
@@ -128,7 +128,7 @@ typedef struct {int __fd = (fd); \if (__fd >=0 ) \ __set->fds[__fd /FD_SETIDXMASK ] &= \ - ~(1U << (__fd &FX_SETBITMASK )); \ + ~(1U << (__fd &FD_SETBITMASK )); \ } while (0)#define FD_SET (fd, set) do { \
@@ -145,7 +145,7 @@ typedef struct {int __r =0 ; \if (__fd >=0 ) \ __r = !!(__set->fds[__fd /FD_SETIDXMASK ] & \ -1U << (__fd &FD_SET_BITMASK )); \ +1U << (__fd &FD_SETBITMASK )); \ __r; \ })
Greg Kroah-Hartman
maintainerPATCH 556/570 RDMA/siw: Fix the sendmsg byte count in siw_tcp_sendpages
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pedro Falcato <[email protected]>
commit c18646248fed07683d4cee8a8af933fc4fe83c0d upstream.
Ever since commit c2ff29e99a76 ("siw: Inline do_tcp_sendpages()"), we have been doing this:
static int siw_tcp_sendpages(struct socket *s, struct page **page, int offset,
size_t size)
[...]
/* Calculate the number of bytes we need to push, for this page
* specifically */
size_t bytes = min_t(size_t, PAGE_SIZE - offset, size);
/* If we can't splice it, then copy it in, as normal */
if (!sendpage_ok(page[i]))
msg.msg_flags &= ~MSG_SPLICE_PAGES;
/* Set the bvec pointing to the page, with len $bytes */
bvec_set_page(&bvec, page[i], bytes, offset);
/* Set the iter to $size, aka the size of the whole sendpages (!!!) */
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size);
try_page_again:
lock_sock(sk);
/* Sendmsg with $size size (!!!) */
rv = tcp_sendmsg_locked(sk, &msg, size);This means we've been sending oversized iov_iters and tcp_sendmsg calls for a while. This has a been a benign bug because sendpage_ok() always returned true. With the recent slab allocator changes being slowly introduced into next (that disallow sendpage on large kmalloc allocations), we have recently hit out-of-bounds crashes, due to slight differences in iov_iter behavior between the MSG_SPLICE_PAGES and "regular" copy paths:
(MSG_SPLICE_PAGES)skb_splice_from_iter
iov_iter_extract_pages
iov_iter_extract_bvec_pages
uses i->nr_segs to correctly stop in its tracks before OoB'ing everywhere skb_splice_from_iter gets a "short" read
(!MSG_SPLICE_PAGES)skb_copy_to_page_nocache copy=iov_iter_count
[...]
copy_from_iter
/* this doesn't help */
if (unlikely(iter->count < len))
len = iter->count;
iterate_bvec
... and we run off the bvecsFix this by properly setting the iov_iter's byte count, plus sending the correct byte count to tcp_sendmsg_locked.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +2 -3
@@ -332,18 +332,17 @@ static int siw_tcp_sendpages(struct sockif (!sendpage_ok (page[i])) msg.msg_flags &= ~MSG_SPLICE_PAGES ;bvec_set_page (&bvec, page[i], bytes, offset); -iov_iter_bvec (&msg.msg_iter,ITER_SOURCE , &bvec,1 , size); +iov_iter_bvec (&msg.msg_iter,ITER_SOURCE , &bvec,1 , bytes); try_page_again:lock_sock (sk); - rv =tcp_sendmsg_locked (sk, &msg, size); + rv =tcp_sendmsg_locked (sk, &msg, bytes);release_sock (sk);if (rv >0 ) { size -= rv; sent += rv;if (rv != bytes) { - offset += rv; bytes -= rv; goto try_page_again; }
Greg Kroah-Hartman
maintainerPATCH 557/570 KVM: VMX: Extract checking of guests DEBUGCTL into helper
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 8a4351ac302cd8c19729ba2636acfd0467c22ae8 ]
Move VMX's logic to check DEBUGCTL values into a standalone helper so that the code can be used by nested VM-Enter to apply the same logic to the value being loaded from vmcs12.
KVM needs to explicitly check vmcs12->guest_ia32_debugctl on nested VM-Enter, as hardware may support features that KVM does not, i.e. relying on hardware to detect invalid guest state will result in false negatives. Unfortunately, that means applying KVM's funky suppression of BTF and LBR to vmcs12 so as not to break existing guests.
No functional change intended.
Stable-dep-of: 6b1dd26544d0 ("KVM: VMX: Preserve host's DEBUGCTLMSR_FREEZE_IN_SMM while running the guest")
--- arch/x86/kvm/vmx/vmx.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
arch/x86/kvm/vmx/vmx.c +17 -12
@@ -2193,6 +2193,19 @@ static u64 vmx_get_supported_debugctl(streturn debugctl; } +static bool vmx_is_valid_debugctl (struct kvm_vcpu *vcpu,u64 data, +bool host_initiated) +{ +u64 invalid; + + invalid = data & ~vmx_get_supported_debugctl (vcpu, host_initiated); +if (invalid & (DEBUGCTLMSR_BTF |DEBUGCTLMSR_LBR )) { +kvm_pr_unimpl_wrmsr (vcpu,MSR_IA32_DEBUGCTLMSR , data); + invalid &= ~(DEBUGCTLMSR_BTF |DEBUGCTLMSR_LBR ); + } +return !invalid; +} +/* * Writes msr value into the appropriate "register". * Returns 0 on success, non-0 otherwise.
@@ -2261,19 +2274,12 @@ int vmx_set_msr(struct kvm_vcpu *vcpu, s }vmcs_writel (GUEST_SYSENTER_ESP , data);break ; -case MSR_IA32_DEBUGCTLMSR : { -u64 invalid; - - invalid = data & ~vmx_get_supported_debugctl (vcpu, msr_info->host_initiated); -if (invalid & (DEBUGCTLMSR_BTF |DEBUGCTLMSR_LBR )) { -kvm_pr_unimpl_wrmsr (vcpu, msr_index, data); - data &= ~(DEBUGCTLMSR_BTF |DEBUGCTLMSR_LBR ); - invalid &= ~(DEBUGCTLMSR_BTF |DEBUGCTLMSR_LBR ); - } - -if (invalid) +case MSR_IA32_DEBUGCTLMSR : +if (!vmx_is_valid_debugctl (vcpu, data, msr_info->host_initiated))return 1 ; + data &=vmx_get_supported_debugctl (vcpu, msr_info->host_initiated); +if (is_guest_mode (vcpu) &&get_vmcs12 (vcpu)->vm_exit_controls &VM_EXIT_SAVE_DEBUG_CONTROLS )get_vmcs12 (vcpu)->guest_ia32_debugctl = data;
@@ -2283,7 +2289,6 @@ int vmx_set_msr(struct kvm_vcpu *vcpu, s (data & DEBUGCTLMSR_LBR))intel_pmu_create_guest_lbr_event (vcpu);return 0 ; - }case MSR_IA32_BNDCFGS : if (!kvm_mpx_supported() || (!msr_info->host_initiated &&
Greg Kroah-Hartman
maintainerPATCH 558/570 KVM: nVMX: Check vmcs12->guest_ia32_debugctl on nested VM-Enter
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxim Levitsky <[email protected]>
[ Upstream commit 095686e6fcb4150f0a55b1a25987fad3d8af58d6 ]
Add a consistency check for L2's guest_ia32_debugctl, as KVM only supports a subset of hardware functionality, i.e. KVM can't rely on hardware to detect illegal/unsupported values. Failure to check the vmcs12 value would allow the guest to load any harware-supported value while running L2.
Take care to exempt BTF and LBR from the validity check in order to match KVM's behavior for writes via WRMSR, but without clobbering vmcs12. Even if VM_EXIT_SAVE_DEBUG_CONTROLS is set in vmcs12, L1 can reasonably expect that vmcs12->guest_ia32_debugctl will not be modified if writes to the MSR are being intercepted.
Arguably, KVM _should_ update vmcs12 if VM_EXIT_SAVE_DEBUG_CONTROLS is set *and* writes to MSR_IA32_DEBUGCTLMSR are not being intercepted by L1, but that would incur non-trivial complexity and wouldn't change the fact that KVM's handling of DEBUGCTL is blatantly broken. I.e. the extra complexity is not worth carrying.
Stable-dep-of: 6b1dd26544d0 ("KVM: VMX: Preserve host's DEBUGCTLMSR_FREEZE_IN_SMM while running the guest")
--- arch/x86/kvm/vmx/nested.c | 12 ++++++++++-- arch/x86/kvm/vmx/vmx.c | 5 ++--- arch/x86/kvm/vmx/vmx.h | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-)
arch/x86/kvm/vmx/nested.c +10 -2
@@ -2663,7 +2663,8 @@ static int prepare_vmcs02(struct kvm_vcpif (vmx->nested.nested_run_pending && (vmcs12->vm_entry_controls &VM_ENTRY_LOAD_DEBUG_CONTROLS )) {kvm_set_dr (vcpu,7 , vmcs12->guest_dr7); -vmcs_write64 (GUEST_IA32_DEBUGCTL , vmcs12->guest_ia32_debugctl); +vmcs_write64 (GUEST_IA32_DEBUGCTL , vmcs12->guest_ia32_debugctl & +vmx_get_supported_debugctl (vcpu, false)); }else {kvm_set_dr (vcpu,7 , vcpu->arch.dr7);vmcs_write64 (GUEST_IA32_DEBUGCTL , vmx->nested.pre_vmenter_debugctl);
@@ -3156,7 +3157,8 @@ static int nested_vmx_check_guest_state(return -EINVAL ;if ((vmcs12->vm_entry_controls &VM_ENTRY_LOAD_DEBUG_CONTROLS ) && -CC (!kvm_dr7_valid (vmcs12->guest_dr7))) + (CC (!kvm_dr7_valid (vmcs12->guest_dr7)) || +CC (!vmx_is_valid_debugctl (vcpu, vmcs12->guest_ia32_debugctl, false))))return -EINVAL ; if ((vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PAT) &&
@@ -4608,6 +4610,12 @@ static void sync_vmcs02_to_vmcs12(struct (vmcs12->vm_entry_controls & ~VM_ENTRY_IA32E_MODE ) | (vm_entry_controls_get (to_vmx (vcpu)) &VM_ENTRY_IA32E_MODE ); +/* +* Note! Save DR7, but intentionally don't grab DEBUGCTL from vmcs02. +* Writes to DEBUGCTL that aren't intercepted by L1 are immediately +* propagated to vmcs12 (see vmx_set_msr()), as the value loaded into +* vmcs02 doesn't strictly track vmcs12. +*/ if (vmcs12->vm_exit_controls &VM_EXIT_SAVE_DEBUG_CONTROLS ) vmcs12->guest_dr7 = vcpu->arch.dr7;
arch/x86/kvm/vmx/vmx.c +2 -3
@@ -2174,7 +2174,7 @@ static u64 nested_vmx_truncate_sysenter_return (unsigned long )data; } -static u64 vmx_get_supported_debugctl (struct kvm_vcpu *vcpu,bool host_initiated) +u64 vmx_get_supported_debugctl (struct kvm_vcpu *vcpu,bool host_initiated) {u64 debugctl =0 ;
@@ -2193,8 +2193,7 @@ static u64 vmx_get_supported_debugctl(streturn debugctl; } -static bool vmx_is_valid_debugctl (struct kvm_vcpu *vcpu,u64 data, -bool host_initiated) +bool vmx_is_valid_debugctl (struct kvm_vcpu *vcpu,u64 data,bool host_initiated) {u64 invalid;
arch/x86/kvm/vmx/vmx.h +3 -0
@@ -414,6 +414,9 @@ static inline void vmx_set_intercept_forvoid vmx_update_cpu_dirty_logging (struct kvm_vcpu *vcpu); +u64 vmx_get_supported_debugctl (struct kvm_vcpu *vcpu,bool host_initiated); +bool vmx_is_valid_debugctl (struct kvm_vcpu *vcpu,u64 data,bool host_initiated); +/* * Note, early Intel manuals have the write-low and read-high bitmap offsets * the wrong way round. The bitmaps control MSRs 0x00000000-0x00001fff and
Greg Kroah-Hartman
maintainerPATCH 559/570 KVM: VMX: Wrap all accesses to IA32_DEBUGCTL with getter/setter APIs
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxim Levitsky <[email protected]>
[ Upstream commit 7d0cce6cbe71af6e9c1831bff101a2b9c249c4a2 ]
Introduce vmx_guest_debugctl_{read,write}() to handle all accesses to vmcs.GUEST_IA32_DEBUGCTL. This will allow stuffing FREEZE_IN_SMM into GUEST_IA32_DEBUGCTL based on the host setting without bleeding the state into the guest, and without needing to copy+paste the FREEZE_IN_SMM logic into every patch that accesses GUEST_IA32_DEBUGCTL.
No functional change intended.
Stable-dep-of: 6b1dd26544d0 ("KVM: VMX: Preserve host's DEBUGCTLMSR_FREEZE_IN_SMM while running the guest")
--- arch/x86/kvm/vmx/nested.c | 10 +++++----- arch/x86/kvm/vmx/pmu_intel.c | 8 ++++---- arch/x86/kvm/vmx/vmx.c | 8 +++++--- arch/x86/kvm/vmx/vmx.h | 10 ++++++++++ 4 files changed, 24 insertions(+), 12 deletions(-)
arch/x86/kvm/vmx/nested.c +5 -5
@@ -2663,11 +2663,11 @@ static int prepare_vmcs02(struct kvm_vcpif (vmx->nested.nested_run_pending && (vmcs12->vm_entry_controls &VM_ENTRY_LOAD_DEBUG_CONTROLS )) {kvm_set_dr (vcpu,7 , vmcs12->guest_dr7); -vmcs_write64 (GUEST_IA32_DEBUGCTL , vmcs12->guest_ia32_debugctl & -vmx_get_supported_debugctl (vcpu, false)); +vmx_guest_debugctl_write (vcpu, vmcs12->guest_ia32_debugctl & +vmx_get_supported_debugctl (vcpu, false)); }else {kvm_set_dr (vcpu,7 , vcpu->arch.dr7); -vmcs_write64 (GUEST_IA32_DEBUGCTL , vmx->nested.pre_vmenter_debugctl); +vmx_guest_debugctl_write (vcpu, vmx->nested.pre_vmenter_debugctl); }if (kvm_mpx_supported () && (!vmx->nested.nested_run_pending || !(vmcs12->vm_entry_controls &VM_ENTRY_LOAD_BNDCFGS )))
@@ -3532,7 +3532,7 @@ enum nvmx_vmentry_status nested_vmx_enteif (!vmx->nested.nested_run_pending || !(vmcs12->vm_entry_controls &VM_ENTRY_LOAD_DEBUG_CONTROLS )) - vmx->nested.pre_vmenter_debugctl =vmcs_read64 (GUEST_IA32_DEBUGCTL ); + vmx->nested.pre_vmenter_debugctl =vmx_guest_debugctl_read ();if (kvm_mpx_supported () && (!vmx->nested.nested_run_pending || !(vmcs12->vm_entry_controls &VM_ENTRY_LOAD_BNDCFGS )))
@@ -4806,7 +4806,7 @@ static void load_vmcs12_host_state(struc__vmx_set_segment (vcpu, &seg,VCPU_SREG_LDTR );kvm_set_dr (vcpu,7 ,0x400 ); -vmcs_write64 (GUEST_IA32_DEBUGCTL ,0 ); +vmx_guest_debugctl_write (vcpu,0 );if (nested_vmx_load_msr (vcpu, vmcs12->vm_exit_msr_load_addr, vmcs12->vm_exit_msr_load_count))
arch/x86/kvm/vmx/pmu_intel.c +4 -4
@@ -653,11 +653,11 @@ static void intel_pmu_reset(struct kvm_v*/ static void intel_pmu_legacy_freezing_lbrs_on_pmi (struct kvm_vcpu *vcpu) { -u64 data =vmcs_read64 (GUEST_IA32_DEBUGCTL ); +u64 data =vmx_guest_debugctl_read ();if (data &DEBUGCTLMSR_FREEZE_LBRS_ON_PMI ) { data &= ~DEBUGCTLMSR_LBR ; -vmcs_write64 (GUEST_IA32_DEBUGCTL , data); +vmx_guest_debugctl_write (vcpu, data); } }
@@ -730,7 +730,7 @@ void vmx_passthrough_lbr_msrs(struct kvmif (!lbr_desc->event) {vmx_disable_lbr_msrs_passthrough (vcpu); -if (vmcs_read64 (GUEST_IA32_DEBUGCTL ) &DEBUGCTLMSR_LBR ) +if (vmx_guest_debugctl_read () &DEBUGCTLMSR_LBR ) goto warn;if (test_bit (INTEL_PMC_IDX_FIXED_VLBR , pmu->pmc_in_use)) goto warn;
@@ -752,7 +752,7 @@ warn:static void intel_pmu_cleanup (struct kvm_vcpu *vcpu) { -if (!(vmcs_read64 (GUEST_IA32_DEBUGCTL ) &DEBUGCTLMSR_LBR )) +if (!(vmx_guest_debugctl_read () &DEBUGCTLMSR_LBR ))intel_pmu_release_guest_lbr_event (vcpu); }
arch/x86/kvm/vmx/vmx.c +5 -3
@@ -2149,7 +2149,7 @@ int vmx_get_msr(struct kvm_vcpu *vcpu, s msr_info->data = vmx->pt_desc.guest.addr_a[index /2 ];break ;case MSR_IA32_DEBUGCTLMSR : - msr_info->data =vmcs_read64 (GUEST_IA32_DEBUGCTL ); + msr_info->data =vmx_guest_debugctl_read ();break ;default : find_uret_msr:
@@ -2283,7 +2283,8 @@ int vmx_set_msr(struct kvm_vcpu *vcpu, s VM_EXIT_SAVE_DEBUG_CONTROLS) get_vmcs12(vcpu)->guest_ia32_debugctl = data; - vmcs_write64(GUEST_IA32_DEBUGCTL, data); + vmx_guest_debugctl_write(vcpu, data); + if (intel_pmu_lbr_is_enabled(vcpu) && !to_vmx(vcpu)->lbr_desc.event && (data & DEBUGCTLMSR_LBR)) intel_pmu_create_guest_lbr_event(vcpu);
@@ -4798,7 +4799,8 @@ static void init_vmcs(struct vcpu_vmx *vvmcs_write32 (GUEST_SYSENTER_CS ,0 );vmcs_writel (GUEST_SYSENTER_ESP ,0 );vmcs_writel (GUEST_SYSENTER_EIP ,0 ); -vmcs_write64 (GUEST_IA32_DEBUGCTL ,0 ); + +vmx_guest_debugctl_write (&vmx->vcpu,0 );if (cpu_has_vmx_tpr_shadow ()) {vmcs_write64 (VIRTUAL_APIC_PAGE_ADDR ,0 );
arch/x86/kvm/vmx/vmx.h +10 -0
@@ -417,6 +417,16 @@ void vmx_update_cpu_dirty_logging(structu64 vmx_get_supported_debugctl (struct kvm_vcpu *vcpu,bool host_initiated);bool vmx_is_valid_debugctl (struct kvm_vcpu *vcpu,u64 data,bool host_initiated); +static inline void vmx_guest_debugctl_write (struct kvm_vcpu *vcpu,u64 val) +{ +vmcs_write64 (GUEST_IA32_DEBUGCTL , val); +} + +static inline u64 vmx_guest_debugctl_read (void ) +{ +return vmcs_read64 (GUEST_IA32_DEBUGCTL ); +} +/* * Note, early Intel manuals have the write-low and read-high bitmap offsets * the wrong way round. The bitmaps control MSRs 0x00000000-0x00001fff and
Greg Kroah-Hartman
maintainerPATCH 560/570 KVM: VMX: Preserve hosts DEBUGCTLMSR_FREEZE_IN_SMM while running the guest
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxim Levitsky <[email protected]>
[ Upstream commit 6b1dd26544d045f6a79e8c73572c0c0db3ef3c1a ]
Set/clear DEBUGCTLMSR_FREEZE_IN_SMM in GUEST_IA32_DEBUGCTL based on the host's pre-VM-Enter value, i.e. preserve the host's FREEZE_IN_SMM setting while running the guest. When running with the "default treatment of SMIs" in effect (the only mode KVM supports), SMIs do not generate a VM-Exit that is visible to host (non-SMM) software, and instead transitions directly from VMX non-root to SMM. And critically, DEBUGCTL isn't context switched by hardware on SMI or RSM, i.e. SMM will run with whatever value was resident in hardware at the time of the SMI.
Failure to preserve FREEZE_IN_SMM results in the PMU unexpectedly counting events while the CPU is executing in SMM, which can pollute profiling and potentially leak information into the guest.
Check for changes in FREEZE_IN_SMM prior to every entry into KVM's inner run loop, as the bit can be toggled in IRQ context via IPI callback (SMP function call), by way of /sys/devices/cpu/freeze_on_smi.
Add a field in kvm_x86_ops to communicate which DEBUGCTL bits need to be preserved, as FREEZE_IN_SMM is only supported and defined for Intel CPUs, i.e. explicitly checking FREEZE_IN_SMM in common x86 is at best weird, and at worst could lead to undesirable behavior in the future if AMD CPUs ever happened to pick up a collision with the bit.
Exempt TDX vCPUs, i.e. protected guests, from the check, as the TDX Module owns and controls GUEST_IA32_DEBUGCTL.
WARN in SVM if KVM_RUN_LOAD_DEBUGCTL is set, mostly to document that the lack of handling isn't a KVM bug (TDX already WARNs on any run_flag).
Lastly, explicitly reload GUEST_IA32_DEBUGCTL on a VM-Fail that is missed by KVM but detected by hardware, i.e. in nested_vmx_restore_host_state(). Doing so avoids the need to track host_debugctl on a per-VMCS basis, as GUEST_IA32_DEBUGCTL is unconditionally written by prepare_vmcs02() and load_vmcs12_host_state(). For the VM-Fail case, even though KVM won't have actually entered the guest, vcpu_enter_guest() will have run with vmcs02 active and thus could result in vmcs01 being run with a stale value.
--- arch/x86/include/asm/kvm_host.h | 7 +++++++ arch/x86/kvm/vmx/main.c | 2 ++ arch/x86/kvm/vmx/nested.c | 3 +++ arch/x86/kvm/vmx/vmx.c | 3 +++ arch/x86/kvm/vmx/vmx.h | 15 ++++++++++++++- arch/x86/kvm/x86.c | 14 ++++++++++++-- 6 files changed, 41 insertions(+), 3 deletions(-)
arch/x86/include/asm/kvm_host.h +7 -0
@@ -1683,6 +1683,7 @@ static inline u16 kvm_lapic_irq_dest_modenum kvm_x86_run_flags {KVM_RUN_FORCE_IMMEDIATE_EXIT =BIT (0 ),KVM_RUN_LOAD_GUEST_DR6 =BIT (1 ), +KVM_RUN_LOAD_DEBUGCTL =BIT (2 ), };struct kvm_x86_ops {
@@ -1713,6 +1714,12 @@ struct kvm_x86_ops {void (*vcpu_load)(struct kvm_vcpu *vcpu,int cpu);void (*vcpu_put)(struct kvm_vcpu *vcpu); +/* +* Mask of DEBUGCTL bits that are owned by the host, i.e. that need to +* match the host's value even while the guest is active. +*/ +const u64 HOST_OWNED_DEBUGCTL ; +void (*update_exception_bitmap)(struct kvm_vcpu *vcpu);int (*get_msr)(struct kvm_vcpu *vcpu,struct msr_data *msr);int (*set_msr)(struct kvm_vcpu *vcpu,struct msr_data *msr);
arch/x86/kvm/vmx/main.c +2 -0
@@ -915,6 +915,8 @@ struct kvm_x86_ops vt_x86_ops __initdata .vcpu_load = vt_op(vcpu_load), .vcpu_put = vt_op(vcpu_put), + .HOST_OWNED_DEBUGCTL = DEBUGCTLMSR_FREEZE_IN_SMM, + .update_exception_bitmap = vt_op(update_exception_bitmap), .get_feature_msr = vmx_get_feature_msr, .get_msr = vt_op(get_msr),
arch/x86/kvm/vmx/nested.c +3 -0
@@ -4861,6 +4861,9 @@ static void nested_vmx_restore_host_statWARN_ON (kvm_set_dr (vcpu,7 ,vmcs_readl (GUEST_DR7 ))); } +/* Reload DEBUGCTL to ensure vmcs01 has a fresh FREEZE_IN_SMM value. */ +vmx_reload_guest_debugctl (vcpu); +/* * Note that calling vmx_set_{efer,cr0,cr4} is important as they * handle a variety of side effects to KVM's software model.
arch/x86/kvm/vmx/vmx.c +3 -0
@@ -7377,6 +7377,9 @@ fastpath_t vmx_vcpu_run(struct kvm_vcpuif (run_flags &KVM_RUN_LOAD_GUEST_DR6 )set_debugreg (vcpu->arch.dr6,6 ); +if (run_flags &KVM_RUN_LOAD_DEBUGCTL ) +vmx_reload_guest_debugctl (vcpu); +/* * Refresh vmcs.HOST_CR3 if necessary. This must be done immediately * prior to VM-Enter, as the kernel may load a new ASID (PCID) any time
arch/x86/kvm/vmx/vmx.h +14 -1
@@ -419,12 +419,25 @@ bool vmx_is_valid_debugctl(struct kvm_vcstatic inline void vmx_guest_debugctl_write (struct kvm_vcpu *vcpu,u64 val) { +WARN_ON_ONCE (val &DEBUGCTLMSR_FREEZE_IN_SMM ); + + val |= vcpu->arch.host_debugctl &DEBUGCTLMSR_FREEZE_IN_SMM ;vmcs_write64 (GUEST_IA32_DEBUGCTL , val); }static inline u64 vmx_guest_debugctl_read (void ) { -return vmcs_read64 (GUEST_IA32_DEBUGCTL ); +return vmcs_read64 (GUEST_IA32_DEBUGCTL ) & ~DEBUGCTLMSR_FREEZE_IN_SMM ; +} + +static inline void vmx_reload_guest_debugctl (struct kvm_vcpu *vcpu) +{ +u64 val =vmcs_read64 (GUEST_IA32_DEBUGCTL ); + +if (!((val ^ vcpu->arch.host_debugctl) &DEBUGCTLMSR_FREEZE_IN_SMM )) +return ; + +vmx_guest_debugctl_write (vcpu, val & ~DEBUGCTLMSR_FREEZE_IN_SMM ); }/*
arch/x86/kvm/x86.c +12 -2
@@ -10785,7 +10785,7 @@ static int vcpu_enter_guest(struct kvm_vdm_request_for_irq_injection (vcpu) &&kvm_cpu_accept_dm_intr (vcpu);fastpath_t exit_fastpath; -u64 run_flags; +u64 run_flags, debug_ctl;bool req_immediate_exit = false;
@@ -11057,7 +11057,17 @@ static int vcpu_enter_guest(struct kvm_vset_debugreg (DR7_FIXED_1 ,7 ); } - vcpu->arch.host_debugctl =get_debugctlmsr (); +/* +* Refresh the host DEBUGCTL snapshot after disabling IRQs, as DEBUGCTL +* can be modified in IRQ context, e.g. via SMP function calls. Inform +* vendor code if any host-owned bits were changed, e.g. so that the +* value loaded into hardware while running the guest can be updated. +*/ + debug_ctl =get_debugctlmsr (); +if ((debug_ctl ^ vcpu->arch.host_debugctl) & kvm_x86_ops.HOST_OWNED_DEBUGCTL && + !vcpu->arch.guest_state_protected) + run_flags |=KVM_RUN_LOAD_DEBUGCTL ; + vcpu->arch.host_debugctl = debug_ctl;guest_timing_enter_irqoff ();
Greg Kroah-Hartman
maintainerPATCH 561/570 ata: libata-sata: Add link_power_management_supported sysfs attribute
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 0060beec0bfa647c4b510df188b1c4673a197839 upstream.
A port link power management (LPM) policy can be controlled using the link_power_management_policy sysfs host attribute. However, this attribute exists also for hosts that do not support LPM and in such case, attempting to change the LPM policy for the host (port) will fail with -EOPNOTSUPP.
Introduce the new sysfs link_power_management_supported host attribute to indicate to the user if a the port and the devices connected to the port for the host support LPM, which implies that the link_power_management_policy attribute can be used.
Since checking that a port and its devices support LPM is common between the new ata_scsi_lpm_supported_show() function and the existing ata_scsi_lpm_store() function, the new helper ata_scsi_lpm_supported() is introduced.
--- drivers/ata/ata_piix.c | 1 drivers/ata/libahci.c | 1 drivers/ata/libata-sata.c | 53 +++++++++++++++++++++++++++++++++++----------- include/linux/libata.h | 1 4 files changed, 44 insertions(+), 12 deletions(-)
drivers/ata/ata_piix.c +1 -0
@@ -1089,6 +1089,7 @@ static struct ata_port_operations ich_pa };static struct attribute *piix_sidpr_shost_attrs[] = { + &dev_attr_link_power_management_supported.attr, &dev_attr_link_power_management_policy.attr,NULL };
drivers/ata/libahci.c +1 -0
@@ -111,6 +111,7 @@ static DEVICE_ATTR(em_buffer, S_IWUSR | static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL);static struct attribute *ahci_shost_attrs[] = { + &dev_attr_link_power_management_supported.attr, &dev_attr_link_power_management_policy.attr, &dev_attr_em_message_type.attr, &dev_attr_em_message.attr,
drivers/ata/libata-sata.c +41 -12
75 lines not on this page · raw message
include/linux/libata.h +1 -0
@@ -534,6 +534,7 @@ typedef void (*ata_postreset_fn_t)(strucextern struct device_attribute dev_attr_unload_heads;#ifdef CONFIG_SATA_HOST +extern struct device_attribute dev_attr_link_power_management_supported;extern struct device_attribute dev_attr_link_power_management_policy;extern struct device_attribute dev_attr_ncq_prio_supported;extern struct device_attribute dev_attr_ncq_prio_enable;
Greg Kroah-Hartman
maintainerPATCH 562/570 io_uring/rw: cast rw->flags assignment to rwf_t
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit 825aea662b492571877b32aeeae13689fd9fbee4 upstream.
kernel test robot reports that a recent change of the sqe->rw_flags field throws a sparse warning on 32-bit archs:
Quoted 1 line
Quoted 1 line
io_uring/rw.c:291:19: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted__kernel_rwf_t[usertype] flags @@ got unsigned int @@
io_uring/rw.c:291:19: sparse: expected restricted __kernel_rwf_t [usertype] flags
io_uring/rw.c:291:19: sparse: got unsigned int
Force cast it to rwf_t to silence that new sparse warning.
--- io_uring/rw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/rw.c +1 -1
@@ -288,7 +288,7 @@ static int __io_prep_rw(struct io_kiocb rw->addr =READ_ONCE (sqe->addr); rw->len =READ_ONCE (sqe->len); - rw->flags =READ_ONCE (sqe->rw_flags); + rw->flags = (__force rwf_t )READ_ONCE (sqe->rw_flags); attr_type_mask =READ_ONCE (sqe->attr_type_mask);if (attr_type_mask) {
Greg Kroah-Hartman
maintainerPATCH 563/570 firmware: arm_scmi: Convert to SYSTEM_SLEEP_PM_OPS
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 62d6b81e8bd207ad44eff39d1a0fe17f0df510a5 upstream.
The old SET_SYSTEM_SLEEP_PM_OPS() macro leads to a warning about an unused function:
| drivers/firmware/arm_scmi/scmi_power_control.c:363:12: error: | 'scmi_system_power_resume' defined but not used [-Werror=unused-function] | static int scmi_system_power_resume(struct device *dev)
The proper way to do this these days is to use SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr().
Message-Id: <[email protected]>
--- drivers/firmware/arm_scmi/scmi_power_control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/scmi_power_control.c +2 -2
@@ -369,7 +369,7 @@ static int scmi_system_power_resume(stru }static const struct dev_pm_ops scmi_system_power_pmops = { -SET_SYSTEM_SLEEP_PM_OPS (NULL , scmi_system_power_resume) +SYSTEM_SLEEP_PM_OPS (NULL , scmi_system_power_resume) };static const struct scmi_device_id scmi_id_table[] = {
@@ -380,7 +380,7 @@ MODULE_DEVICE_TABLE(scmi, scmi_id_table)static struct scmi_driver scmi_system_power_driver = { .driver = { - .pm = &scmi_system_power_pmops, + .pm =pm_sleep_ptr (&scmi_system_power_pmops), }, .name ="scmi-system-power" , .probe = scmi_syspower_probe,
Greg Kroah-Hartman
maintainerPATCH 564/570 drm/amd/display: Allow DCN301 to clear update flags
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Lipski <[email protected]>
commit 2d418e4fd9f1eca7dfce80de86dd702d36a06a25 upstream.
[Why & How]
Not letting DCN301 to clear after surface/stream update results in artifacts when switching between active overlay planes. The issue is known and has been solved initially. See below:
(https://gitlab.freedesktop.org/drm/amd/-/issues/3441)
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -1
@@ -5439,7 +5439,8 @@ bool dc_update_planes_and_stream(structelse ret =update_planes_and_stream_v2 (dc, srf_updates, surface_count, stream, stream_update); -if (ret && dc->ctx->dce_version >=DCN_VERSION_3_2 ) +if (ret && (dc->ctx->dce_version >=DCN_VERSION_3_2 || + dc->ctx->dce_version ==DCN_VERSION_3_01 ))clear_update_flags (srf_updates, surface_count, stream);return ret;
Greg Kroah-Hartman
maintainerPATCH 565/570 md: fix create on open mddev lifetime regression
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit 1df1fc845d221eb646539836dbf509eb96b41afd upstream.
Commit 9e59d609763f ("md: call del_gendisk in control path") moves setting MD_DELETED from __mddev_put() to do_md_stop(), however, for the case create on open, mddev can be freed without do_md_stop():
1) open
md_probe
md_alloc_and_put
md_alloc
mddev_alloc
atomic_set(&mddev->active, 1);
mddev->hold_active = UNTIL_IOCTL
mddev_put
atomic_dec_and_test(&mddev->active)
if (mddev->hold_active)
-> active is 0, hold_active is setmd_open
mddev_get
atomic_inc(&mddev->active);
2) ioctl that is not STOP_ARRAY, for example, GET_ARRAY_INFO:
md_ioctl
mddev->hold_active = 0
3) close
md_release
mddev_put(mddev);
atomic_dec_and_lock(&mddev->active, &all_mddevs_lock) __mddev_put
-> hold_active is cleared, mddev will be freed queue_work(md_misc_wq, &mddev->del_work)
Now that MD_DELETED is not set, before mddev is freed by mddev_delayed_delete(), md_open can still succeed and break mddev lifetime, causing mddev->kobj refcount underflow or mddev uaf problem.
Fix this problem by setting MD_DELETED before queuing del_work.
--- drivers/md/md.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/md/md.c +6 -0
@@ -637,6 +637,12 @@ static void __mddev_put(struct mddev *mdreturn ;/* +* If array is freed by stopping array, MD_DELETED is set by +* do_md_stop(), MD_DELETED is still set here in case mddev is freed +* directly by closing a mddev that is created by create_on_open. +*/ +set_bit (MD_DELETED , &mddev->flags); +/* * Call queue_work inside the spinlock so that flush_workqueue() after * mddev_find will succeed in waiting for the work to be done. */
Greg Kroah-Hartman
maintainerPATCH 566/570 rcu: Fix racy re-initialization of irq_work causing hangs
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
commit 61399e0c5410567ef60cb1cda34cca42903842e3 upstream.
RCU re-initializes the deferred QS irq work everytime before attempting to queue it. However there are situations where the irq work is attempted to be queued even though it is already queued. In that case re-initializing messes-up with the irq work queue that is about to be handled.
The chances for that to happen are higher when the architecture doesn't support self-IPIs and irq work are then all lazy, such as with the following sequence:
1) rcu_read_unlock() is called when IRQs are disabled and there is a grace period involving blocked tasks on the node. The irq work is then initialized and queued.
2) The related tasks are unblocked and the CPU quiescent state is reported. rdp->defer_qs_iw_pending is reset to DEFER_QS_IDLE, allowing the irq work to be requeued in the future (note the previous one hasn't fired yet).
3) A new grace period starts and the node has blocked tasks.
4) rcu_read_unlock() is called when IRQs are disabled again. The irq work is re-initialized (but it's queued! and its node is cleared) and requeued. Which means it's requeued to itself.
5) The irq work finally fires with the tick. But since it was requeued to itself, it loops and hangs.
Fix this with initializing the irq work only once before the CPU boots.
--- kernel/rcu/tree.c | 2 ++ kernel/rcu/tree.h | 1 + kernel/rcu/tree_plugin.h | 8 ++++++-- 3 files changed, 9 insertions(+), 2 deletions(-)
kernel/rcu/tree.c +2 -0
@@ -4233,6 +4233,8 @@ int rcutree_prepare_cpu(unsigned int cpu rdp->rcu_iw_gp_seq = rdp->gp_seq -1 ;trace_rcu_grace_period (rcu_state.name, rdp->gp_seq,TPS ("cpuonl" ));raw_spin_unlock_irqrestore_rcu_node (rnp, flags); + +rcu_preempt_deferred_qs_init (rdp);rcu_spawn_rnp_kthreads (rnp);rcu_spawn_cpu_nocb_kthread (cpu);ASSERT_EXCLUSIVE_WRITER (rcu_state.n_online_cpus);
kernel/rcu/tree.h +1 -0
@@ -488,6 +488,7 @@ static int rcu_print_task_exp_stall(strustatic void rcu_preempt_check_blocked_tasks (struct rcu_node *rnp);static void rcu_flavor_sched_clock_irq (int user);static void dump_blkd_tasks (struct rcu_node *rnp,int ncheck); +static void rcu_preempt_deferred_qs_init (struct rcu_data *rdp);static void rcu_initiate_boost (struct rcu_node *rnp,unsigned long flags);static void rcu_preempt_boost_start_gp (struct rcu_node *rnp);static bool rcu_is_callbacks_kthread (struct rcu_data *rdp);
kernel/rcu/tree_plugin.h +6 -2
@@ -699,8 +699,6 @@ static void rcu_read_unlock_special(stru cpu_online(rdp->cpu)) {// Get scheduler to re-evaluate and call hooks. // If !IRQ_WORK, FQS scan will eventually IPI. - rdp->defer_qs_iw = -IRQ_WORK_INIT_HARD (rcu_preempt_deferred_qs_handler); rdp->defer_qs_iw_pending =DEFER_QS_PENDING ;irq_work_queue_on (&rdp->defer_qs_iw, rdp->cpu); }
@@ -840,6 +838,10 @@ dump_blkd_tasks(struct rcu_node *rnp, in } } +static void rcu_preempt_deferred_qs_init (struct rcu_data *rdp) +{ + rdp->defer_qs_iw =IRQ_WORK_INIT_HARD (rcu_preempt_deferred_qs_handler); +}#else /* #ifdef CONFIG_PREEMPT_RCU */ /*
@@ -1039,6 +1041,8 @@ dump_blkd_tasks(struct rcu_node *rnp, in WARN_ON_ONCE(!list_empty(&rnp->blkd_tasks)); } +static void rcu_preempt_deferred_qs_init (struct rcu_data *rdp) { } +#endif /* #else #ifdef CONFIG_PREEMPT_RCU */ /*
Greg Kroah-Hartman
maintainerPATCH 567/570 irqchip/mvebu-gicp: Use resource_size() for ioremap()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 9f7488f24c7571d349d938061e0ede7a39b65d6b upstream.
0-day reported an off by one in the ioremap() sizing:
drivers/irqchip/irq-mvebu-gicp.c:240:45-48: WARNING:
Suspicious code. resource_size is maybe missing with gicp -> res
Convert it to resource_size(), which does the right thing.
--- drivers/irqchip/irq-mvebu-gicp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-mvebu-gicp.c +1 -1
@@ -237,7 +237,7 @@ static int mvebu_gicp_probe(struct platfreturn -ENODEV ; } - base =ioremap (gicp->res->start, gicp->res->end - gicp->res->start); + base =ioremap (gicp->res->start,resource_size (gicp->res));if (IS_ERR (base)) {dev_err (&pdev->dev,"ioremap() failed. Unable to clear pending interrupts.\n" ); }else {
Greg Kroah-Hartman
maintainerPATCH 568/570 dm: split write BIOs on zone boundaries when zone append is not emulated
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shin'ichiro Kawasaki <[email protected]>
commit 675f940576351bb049f5677615140b9d0a7712d0 upstream.
Commit 2df7168717b7 ("dm: Always split write BIOs to zoned device limits") updates the device-mapper driver to perform splits for the write BIOs. However, it did not address the cases where DM targets do not emulate zone append, such as in the cases of dm-linear or dm-flakey. For these targets, when the write BIOs span across zone boundaries, they trigger WARN_ON_ONCE(bio_straddles_zones(bio)) in blk_zone_wplug_handle_write(). This results in I/O errors. The errors are reproduced by running blktests test case zbd/004 using zoned dm-linear or dm-flakey devices.
To avoid the I/O errors, handle the write BIOs regardless whether DM targets emulate zone append or not, so that all write BIOs are split at zone boundaries. For that purpose, drop the check for zone append emulation in dm_zone_bio_needs_split(). Its argument 'md' is no longer used then drop it also.
--- drivers/md/dm.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/md/dm.c +7 -11
@@ -1776,8 +1776,7 @@ static void init_clone_info(struct clone }#ifdef CONFIG_BLK_DEV_ZONED -static inline bool dm_zone_bio_needs_split (struct mapped_device *md, -struct bio *bio) +static inline bool dm_zone_bio_needs_split (struct bio *bio) {/* * Special case the zone operations that cannot or should not be split.
@@ -1793,13 +1792,11 @@ static inline bool dm_zone_bio_needs_spl }/* -* Mapped devices that require zone append emulation will use the block -* layer zone write plugging. In such case, we must split any large BIO -* to the mapped device limits to avoid potential deadlocks with queue -* freeze operations. +* When mapped devices use the block layer zone write plugging, we must +* split any large BIO to the mapped device limits to not submit BIOs +* that span zone boundaries and to avoid potential deadlocks with +* queue freeze operations. */ -if (!dm_emulate_zone_append (md)) -return false;return bio_needs_zone_write_plugging (bio) ||bio_straddles_zones (bio); }
@@ -1923,8 +1920,7 @@ static blk_status_t __send_zone_reset_al }#else -static inline bool dm_zone_bio_needs_split (struct mapped_device *md, -struct bio *bio) +static inline bool dm_zone_bio_needs_split (struct bio *bio) {return false; }
@@ -1951,7 +1947,7 @@ static void dm_split_and_process_bio(str is_abnormal =is_abnormal_io (bio);if (static_branch_unlikely (&zoned_enabled)) { - need_split = is_abnormal ||dm_zone_bio_needs_split (md, bio); + need_split = is_abnormal ||dm_zone_bio_needs_split (bio); }else { need_split = is_abnormal; }
Greg Kroah-Hartman
maintainerPATCH 569/570 io_uring/zcrx: fix null ifq on area destruction
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 720df2310b89cf76c1dc1a05902536282506f8bf upstream.
Dan reports that ifq can be null when infering arguments for io_unaccount_mem() from io_zcrx_free_area(). Fix it by always setting a correct ifq.
--- io_uring/zcrx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
io_uring/zcrx.c +2 -3
@@ -394,8 +394,7 @@ static void io_free_rbuf_ring(struct io_static void io_zcrx_free_area (struct io_zcrx_area *area) { -if (area->ifq) -io_zcrx_unmap_area (area->ifq, area); +io_zcrx_unmap_area (area->ifq, area);io_release_area_mem (&area->mem);if (area->mem.account_pages)
@@ -428,6 +427,7 @@ static int io_zcrx_create_area(struct io area =kzalloc (sizeof (*area),GFP_KERNEL );if (!area) goto err; + area->ifq = ifq; ret =io_import_area (ifq, &area->mem, area_reg);if (ret)
@@ -462,7 +462,6 @@ static int io_zcrx_create_area(struct io } area->free_count = nr_iovs; - area->ifq = ifq;/* we're only supporting one area per ifq for now */ area->area_id =0 ; area_reg->rq_area_token = (u64 )area->area_id <<IORING_ZCRX_AREA_SHIFT ;
Greg Kroah-Hartman
maintainerPATCH 570/570 io_uring/zcrx: dont leak pages on account failure
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 6bbd3411ff87df1ca38ff32d36eb5dc673ca8021 upstream.
Someone needs to release pinned pages in io_import_umem() if accounting fails. Assign them to the area but return an error, the following io_zcrx_free_area() will clean them up.
--- io_uring/zcrx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
io_uring/zcrx.c +2 -4
@@ -187,15 +187,13 @@ static int io_import_umem(struct io_zcrx mem->account_pages =io_count_account_pages (pages, nr_pages); ret =io_account_mem (ifq->ctx, mem->account_pages); -if (ret <0 ) { +if (ret <0 ) mem->account_pages =0 ; -return ret; - } mem->pages = pages; mem->nr_folios = nr_pages; mem->size = area_reg->len; -return 0 ; +return ret; }static void io_release_area_mem (struct io_zcrx_mem *mem)
# Librecast Test Results
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 6.16.2-rc1-g7439b60c7df9 #43 SMP PREEMPT_DYNAMIC Mon Aug 18 16:04:04 -00 2025 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.16.2 release. There are 570 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 20 Aug 2025 12:43:43 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.16.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.16.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.16.2 release. There are 570 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 20 Aug 2025 12:43:43 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.16.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.16.y
and the diffstat can be found below.thanks,
greg k-h
Boot regression occurs on the Qualcomm DragonBoard 410c (arm64) with stable-rc 6.16.2-rc1. The kernel crashes during early boot with a NULL pointer dereference in the Qualcomm SCM/TZMEM subsystem.
The crash originates in qcom_scm_shm_bridge_enable() (drivers/firmware/qcom/qcom_scm.c) and is invoked by qcom_tzmem_enable() (drivers/firmware/qcom/qcom_tzmem.c). This happens while probing SCM during platform initialization, preventing the board from reaching userspace due to kernel panic.
Regression Analysis:
- New regression? yes
- Reproducibility? yes
Boot regression: stable-rc 6.16.2-rc1 arm64 Qualcomm Dragonboard 410c kernel NULL pointer dereference qcom_scm_shm_bridge_enable qcom_tzmem_enable
## Test log
[ 1.011897] scmi_core: SCMI protocol bus registered [ 1.014070] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [ 1.018776] Mem abort info: [ 1.027774] ESR = 0x0000000096000004 [ 1.030282] EC = 0x25: DABT (current EL), IL = 32 bits [ 1.034116] SET = 0, FnV = 0 [ 1.039581] EA = 0, S1PTW = 0 [ 1.042433] FSC = 0x04: level 0 translation fault [ 1.045486] Data abort info: [ 1.050341] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 1.053464] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 1.058768] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 1.063891] [0000000000000000] user address but active_mm is swapper [ 1.069276] Internal error: Oops: 0000000096000004 [#1] SMP [ 1.075601] Modules linked in: [ 1.081240] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.16.2-rc1 #1 PREEMPT [ 1.084114] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 1.091663] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 1.098607] pc : qcom_scm_shm_bridge_enable (drivers/firmware/qcom/qcom_scm.c:1618) [ 1.105285] lr : qcom_tzmem_enable (drivers/firmware/qcom/qcom_tzmem.c:98 drivers/firmware/qcom/qcom_tzmem.c:475) [ 1.110491] sp : ffff80008002b730 [ 1.114916] x29: ffff80008002b7c0 x28: 0000000000000000 x27: 0000000000000000 [ 1.118226] x26: 0000000000000000 x25: 0000000000000000 x24: ffff00003fcf2028 [ 1.125343] x23: ffff00003fcc1798 x22: 0000000000000000 x21: ffff000002cdf410 [ 1.132460] x20: ffff000002cdf400 x19: ffff80008288a000 x18: ffff8000813951f0 [ 1.139579] x17: 0000000000000000 x16: 00000000ffffffff x15: fffffffffffffc00 [ 1.146696] x14: ffffffffffffffff x13: 0000000000000020 x12: 0000000000000002 [ 1.153814] x11: 0000000000000000 x10: 0000000000000019 x9 : 0000000000000001 [ 1.160932] x8 : 0000000000000000 x7 : 7f7f7f7f7f7f7f7f x6 : fefefeff35302f37 [ 1.168052] x5 : 8080808000000000 x4 : 0000000000000020 x3 : 0000000036313038 [ 1.175169] x2 : 000000000000001c x1 : 000000000000000c x0 : 0000000000000000 [ 1.182289] Call trace: [ 1.189393] qcom_scm_shm_bridge_enable (drivers/firmware/qcom/qcom_scm.c:1618) (P) [ 1.191658] qcom_tzmem_enable (drivers/firmware/qcom/qcom_tzmem.c:98 drivers/firmware/qcom/qcom_tzmem.c:475) [ 1.196862] qcom_scm_probe (drivers/firmware/qcom/qcom_scm.c:2259) [ 1.200941] platform_probe (drivers/base/platform.c:1405) [ 1.204587] really_probe (drivers/base/dd.c:581 drivers/base/dd.c:657) [ 1.208408] __driver_probe_device (drivers/base/dd.c:0) [ 1.212055] driver_probe_device (drivers/base/dd.c:829) [ 1.216394] __driver_attach (drivers/base/dd.c:1216) [ 1.220299] bus_for_each_dev (drivers/base/bus.c:369) [ 1.224118] driver_attach (drivers/base/dd.c:1233) [ 1.228285] bus_add_driver (drivers/base/bus.c:679) [ 1.231844] driver_register (drivers/base/driver.c:250) [ 1.235403] __platform_driver_register (drivers/base/platform.c:867) [ 1.239225] qcom_scm_init (drivers/firmware/qcom/qcom_scm.c:2365) [ 1.244083] do_one_initcall (init/main.c:1252 init/main.c:1275) [ 1.247730] do_initcall_level (init/main.c:1335) [ 1.251289] do_initcalls (init/main.c:1349) [ 1.255455] do_basic_setup (init/main.c:1372) [ 1.258666] kernel_init_freeable (init/main.c:1588) [ 1.262488] kernel_init (init/main.c:1476) [ 1.266826] ret_from_fork (arch/arm64/kernel/entry.S:848) [ 1.270045] Code: a904ffff a903ffff a902ffff a900ffff (f9400100)
All code
========
Code starting with the faulting instruction
===========================================
[ 1.273870] ---[ end trace 0000000000000000 ]--- [ 1.279875] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 1.284550] SMP: stopping secondary CPUs [ 1.291930] ---[ end Kernel panic - not syncing: Attempted to kill
init! exitcode=0x0000000b ]---
Please refer full test log information in the below links.
## Source
* Kernel version: 6.16.2-rc1
* Git tree: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* Git describe: v6.16-1192-g7439b60c7df9
* Git commit: 7439b60c7df9cf7683dbfe417d128304e34a4f22
* Architectures: arm64 Dragonboard 410c
* Toolchains: gcc-13, clang-20
* Kconfigs: defconfig+lkft
## Test
* Boot log: https://qa-reports.linaro.org/api/testruns/29589924/log_file/
* Boot lava log: https://lkft.validation.linaro.org/scheduler/job/8407950#L2304
* Boot details:
https://regressions.linaro.org/lkft/linux-stable-rc-linux-6.16.y/v6.16-1192-g7439b60c7df9/log-parser-boot/panic-multiline-kernel-panic-not-syncing-attempted-to-kill-init-exitcode/
* Boot plan: https://tuxapi.tuxsuite.com/v1/groups/linaro/projects/lkft/tests/31SnSReSLRhyKacT9vTgYiE9GRJ
* Build link: https://storage.tuxsuite.com/public/linaro/lkft/builds/31SnQ9iEVyT81yLXvTtUzBV7I4A/
* Kernel config:
https://storage.tuxsuite.com/public/linaro/lkft/builds/31SnQ9iEVyT81yLXvTtUzBV7I4A/config
--
Linaro LKFT
https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.16.2 release. There are 570 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 20 Aug 2025 12:43:43 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.16.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.16.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Hi Greg
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.16.2 release. There are 570 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 20 Aug 2025 12:43:43 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.16.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.16.y
and the diffstat can be found below.thanks,
greg k-h
6.16.2-rc1 tested.
Build successfully completed.
Boot successfully completed.
No dmesg regressions.
Video output normal.
Sound output normal.
Lenovo ThinkPad X1 Carbon Gen10(Intel i7-1260P(x86_64) arch linux)
[ 0.000000] Linux version 6.16.2-rc1rv-g7439b60c7df9
(takeshi@ThinkPadX1Gen10J0764) (gcc (GCC) 15.2.1 20250813, GNU ld (GNU Binutils) 2.45.0) #1 SMP PREEMPT_DYNAMIC Tue Aug 19 07:00:35 JST 2025
Thanks
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.16.2 release. There are 570 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.16.y
6.15 passes our testing, too:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.15.y
Best regards,
Pavel
Signature · 2 lines
In cooperation with DENX Software Engineering GmbH, HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.16.2 release. There are 570 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 20 Aug 2025 12:43:43 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.16.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.16.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.16.2 release. There are 570 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 20 Aug 2025 12:43:43 +0000. Anything received after that time might be too late.
Hi Greg
6.16.2-rc1 compiles on x86_64 (Xeon E5-1620 v2, Slackware64-15.0),
and boots & runs on x86_64 (AMD Ryzen 5 7520U, Slackware64-current).
No regressions observed, apart from the already reported and being
worked on issue https://lore.kernel.org/stable/[email protected]/