6.1.120-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 694/772 Bluetooth: hci_core: Fix not checking skb length on hci_acldata_packet
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 3fe288a8214e7dd784d1f9b7c9e448244d316b47 ]
This fixes not checking if skb really contains an ACL header otherwise the code may attempt to access some uninitilized/invalid memory past the valid skb->data.
--- net/bluetooth/hci_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
net/bluetooth/hci_core.c +9 -4
@@ -3829,18 +3829,22 @@ static void hci_tx_work(struct work_struct *work)/* ACL data packet */ static void hci_acldata_packet (struct hci_dev *hdev,struct sk_buff *skb) { -struct hci_acl_hdr *hdr = (void *) skb->data; +struct hci_acl_hdr *hdr;struct hci_conn *conn;__u16 handle, flags; -skb_pull (skb,HCI_ACL_HDR_SIZE ); + hdr =skb_pull_data (skb,sizeof (*hdr)); +if (!hdr) { +bt_dev_err (hdev,"ACL packet too small" ); + goto drop; + } handle =__le16_to_cpu (hdr->handle); flags =hci_flags (handle); handle =hci_handle (handle); -BT_DBG ("%s len %d handle 0x%4.4x flags 0x%4.4x" , hdev->name, skb->len, - handle, flags); +bt_dev_dbg (hdev,"len %d handle 0x%4.4x flags 0x%4.4x" , skb->len, + handle, flags); hdev->stat.acl_rx++;
@@ -3859,6 +3863,7 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb) handle); } +drop:kfree_skb (skb); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 695/772 ASoC: hdmi-codec: reorder channel allocation list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Karlman <[email protected]>
[ Upstream commit 82ff5abc2edcfba0c0f1a1be807795e2876f46e9 ]
The ordering in hdmi_codec_get_ch_alloc_table_idx() results in wrong channel allocation for a number of cases, e.g. when ELD reports FL|FR|LFE|FC|RL|RR or FL|FR|LFE|FC|RL|RR|RC|RLC|RRC:
ca_id 0x01 with speaker mask FL|FR|LFE is selected instead of ca_id 0x03 with speaker mask FL|FR|LFE|FC for 4 channels
and
ca_id 0x04 with speaker mask FL|FR|RC gets selected instead of ca_id 0x0b with speaker mask FL|FR|LFE|FC|RL|RR for 6 channels
Fix this by reordering the channel allocation list with most specific speaker masks at the top.
--- sound/soc/codecs/hdmi-codec.c | 140 +++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 63 deletions(-)
sound/soc/codecs/hdmi-codec.c +77 -63
@@ -184,84 +184,97 @@ static const struct snd_pcm_chmap_elem hdmi_codec_8ch_chmaps[] = {/* * hdmi_codec_channel_alloc: speaker configuration available for CEA * -* This is an ordered list that must match with hdmi_codec_8ch_chmaps struct +* This is an ordered list where ca_id must exist in hdmi_codec_8ch_chmaps * The preceding ones have better chances to be selected by * hdmi_codec_get_ch_alloc_table_idx(). */ static const struct hdmi_codec_cea_spk_alloc hdmi_codec_channel_alloc[] = { { .ca_id =0x00 , .n_ch =2 , - .mask =FL |FR }, -/* 2.1 */ - { .ca_id =0x01 , .n_ch =4 , - .mask =FL |FR |LFE }, -/* Dolby Surround */ + .mask =FL |FR }, + { .ca_id =0x03 , .n_ch =4 , + .mask =FL |FR |LFE |FC }, { .ca_id =0x02 , .n_ch =4 , .mask =FL |FR |FC }, -/* surround51 */ + { .ca_id =0x01 , .n_ch =4 , + .mask =FL |FR |LFE }, { .ca_id =0x0b , .n_ch =6 , - .mask =FL |FR |LFE |FC |RL |RR }, -/* surround40 */ - { .ca_id =0x08 , .n_ch =6 , - .mask =FL |FR |RL |RR }, -/* surround41 */ - { .ca_id =0x09 , .n_ch =6 , - .mask =FL |FR |LFE |RL |RR }, -/* surround50 */ + .mask =FL |FR |LFE |FC |RL |RR }, { .ca_id =0x0a , .n_ch =6 , .mask =FL |FR |FC |RL |RR }, -/* 6.1 */ - { .ca_id =0x0f , .n_ch =8 , - .mask =FL |FR |LFE |FC |RL |RR |RC }, -/* surround71 */ + { .ca_id =0x09 , .n_ch =6 , + .mask =FL |FR |LFE |RL |RR }, + { .ca_id =0x08 , .n_ch =6 , + .mask =FL |FR |RL |RR }, + { .ca_id =0x07 , .n_ch =6 , + .mask =FL |FR |LFE |FC |RC }, + { .ca_id =0x06 , .n_ch =6 , + .mask =FL |FR |FC |RC }, + { .ca_id =0x05 , .n_ch =6 , + .mask =FL |FR |LFE |RC }, + { .ca_id =0x04 , .n_ch =6 , + .mask =FL |FR |RC }, { .ca_id =0x13 , .n_ch =8 , .mask =FL |FR |LFE |FC |RL |RR |RLC |RRC }, -/* others */ - { .ca_id =0x03 , .n_ch =8 , - .mask =FL |FR |LFE |FC }, - { .ca_id =0x04 , .n_ch =8 , - .mask =FL |FR |RC }, - { .ca_id =0x05 , .n_ch =8 , - .mask =FL |FR |LFE |RC }, - { .ca_id =0x06 , .n_ch =8 , - .mask =FL |FR |FC |RC }, - { .ca_id =0x07 , .n_ch =8 , - .mask =FL |FR |LFE |FC |RC }, - { .ca_id =0x0c , .n_ch =8 , - .mask =FL |FR |RC |RL |RR }, - { .ca_id =0x0d , .n_ch =8 , - .mask =FL |FR |LFE |RL |RR |RC }, - { .ca_id =0x0e , .n_ch =8 , - .mask =FL |FR |FC |RL |RR |RC }, - { .ca_id =0x10 , .n_ch =8 , - .mask =FL |FR |RL |RR |RLC |RRC }, - { .ca_id =0x11 , .n_ch =8 , - .mask =FL |FR |LFE |RL |RR |RLC |RRC }, + { .ca_id =0x1f , .n_ch =8 , + .mask =FL |FR |LFE |FC |RL |RR |FLC |FRC }, { .ca_id =0x12 , .n_ch =8 , .mask =FL |FR |FC |RL |RR |RLC |RRC }, - { .ca_id =0x14 , .n_ch =8 , - .mask =FL |FR |FLC |FRC }, - { .ca_id =0x15 , .n_ch =8 , - .mask =FL |FR |LFE |FLC |FRC }, - { .ca_id =0x16 , .n_ch =8 , - .mask =FL |FR |FC |FLC |FRC }, - { .ca_id =0x17 , .n_ch =8 , - .mask =FL |FR |LFE |FC |FLC |FRC }, - { .ca_id =0x18 , .n_ch =8 , - .mask =FL |FR |RC |FLC |FRC }, - { .ca_id =0x19 , .n_ch =8 , - .mask =FL |FR |LFE |RC |FLC |FRC }, - { .ca_id =0x1a , .n_ch =8 , - .mask =FL |FR |RC |FC |FLC |FRC }, - { .ca_id =0x1b , .n_ch =8 , - .mask =FL |FR |LFE |RC |FC |FLC |FRC }, - { .ca_id =0x1c , .n_ch =8 , - .mask =FL |FR |RL |RR |FLC |FRC }, - { .ca_id =0x1d , .n_ch =8 , - .mask =FL |FR |LFE |RL |RR |FLC |FRC }, { .ca_id =0x1e , .n_ch =8 , .mask =FL |FR |FC |RL |RR |FLC |FRC }, - { .ca_id =0x1f , .n_ch =8 , - .mask =FL |FR |LFE |FC |RL |RR |FLC |FRC }, + { .ca_id =0x11 , .n_ch =8 , + .mask =FL |FR |LFE |RL |RR |RLC |RRC }, + { .ca_id =0x1d , .n_ch =8 , + .mask =FL |FR |LFE |RL |RR |FLC |FRC }, + { .ca_id =0x10 , .n_ch =8 , + .mask =FL |FR |RL |RR |RLC |RRC }, + { .ca_id =0x1c , .n_ch =8 , + .mask =FL |FR |RL |RR |FLC |FRC }, + { .ca_id =0x0f , .n_ch =8 , + .mask =FL |FR |LFE |FC |RL |RR |RC }, + { .ca_id =0x1b , .n_ch =8 , + .mask =FL |FR |LFE |RC |FC |FLC |FRC }, + { .ca_id =0x0e , .n_ch =8 , + .mask =FL |FR |FC |RL |RR |RC }, + { .ca_id =0x1a , .n_ch =8 , + .mask =FL |FR |RC |FC |FLC |FRC }, + { .ca_id =0x0d , .n_ch =8 , + .mask =FL |FR |LFE |RL |RR |RC }, + { .ca_id =0x19 , .n_ch =8 , + .mask =FL |FR |LFE |RC |FLC |FRC }, + { .ca_id =0x0c , .n_ch =8 , + .mask =FL |FR |RC |RL |RR }, + { .ca_id =0x18 , .n_ch =8 , + .mask =FL |FR |RC |FLC |FRC }, + { .ca_id =0x17 , .n_ch =8 , + .mask =FL |FR |LFE |FC |FLC |FRC }, + { .ca_id =0x16 , .n_ch =8 , + .mask =FL |FR |FC |FLC |FRC }, + { .ca_id =0x15 , .n_ch =8 , + .mask =FL |FR |LFE |FLC |FRC }, + { .ca_id =0x14 , .n_ch =8 , + .mask =FL |FR |FLC |FRC }, + { .ca_id =0x0b , .n_ch =8 , + .mask =FL |FR |LFE |FC |RL |RR }, + { .ca_id =0x0a , .n_ch =8 , + .mask =FL |FR |FC |RL |RR }, + { .ca_id =0x09 , .n_ch =8 , + .mask =FL |FR |LFE |RL |RR }, + { .ca_id =0x08 , .n_ch =8 , + .mask =FL |FR |RL |RR }, + { .ca_id =0x07 , .n_ch =8 , + .mask =FL |FR |LFE |FC |RC }, + { .ca_id =0x06 , .n_ch =8 , + .mask =FL |FR |FC |RC }, + { .ca_id =0x05 , .n_ch =8 , + .mask =FL |FR |LFE |RC }, + { .ca_id =0x04 , .n_ch =8 , + .mask =FL |FR |RC }, + { .ca_id =0x03 , .n_ch =8 , + .mask =FL |FR |LFE |FC }, + { .ca_id =0x02 , .n_ch =8 , + .mask =FL |FR |FC }, + { .ca_id =0x01 , .n_ch =8 , + .mask =FL |FR |LFE }, };struct hdmi_codec_priv {
@@ -370,7 +383,8 @@ static int hdmi_codec_chmap_ctl_get(struct snd_kcontrol *kcontrol,struct snd_pcm_chmap *info =snd_kcontrol_chip (kcontrol);struct hdmi_codec_priv *hcp = info->private_data; - map = info->chmap[hcp->chmap_idx].map; +if (hcp->chmap_idx !=HDMI_CODEC_CHMAP_IDX_UNKNOWN ) + map = info->chmap[hcp->chmap_idx].map;for (i =0 ; i < info->max_channels; i++) {if (hcp->chmap_idx ==HDMI_CODEC_CHMAP_IDX_UNKNOWN )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 696/772 rocker: fix link status detection in rocker_carrier_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Antipov <[email protected]>
[ Upstream commit e64285ff41bb7a934bd815bd38f31119be62ac37 ]
Since '1 << rocker_port->pport' may be undefined for port >= 32, cast the left operand to 'unsigned long long' like it's done in 'rocker_port_set_enable()' above. Compile tested only.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/ethernet/rocker/rocker_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/rocker/rocker_main.c +1 -1
@@ -2504,7 +2504,7 @@ static void rocker_carrier_init(const struct rocker_port *rocker_port)u64 link_status =rocker_read64 (rocker,PORT_PHYS_LINK_STATUS );bool link_up; - link_up = link_status & (1 << rocker_port->pport); + link_up = link_status & (1ULL << rocker_port->pport);if (link_up)netif_carrier_on (rocker_port->dev);else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 697/772 net/neighbor: clear error in case strict check is not set
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 0de6a472c3b38432b2f184bd64eb70d9ea36d107 ]
Commit 51183d233b5a ("net/neighbor: Update neigh_dump_info for strict data checking") added strict checking. The err variable is not cleared, so if we find no table to dump we will return the validation error even if user did not want strict checking.
I think the only way to hit this is to send an buggy request, and ask for a table which doesn't exist, so there's no point treating this as a real fix. I only noticed it because a syzbot repro depended on it to trigger another bug.
--- net/core/neighbour.c | 1 + 1 file changed, 1 insertion(+)
net/core/neighbour.c +1 -0
@@ -2865,6 +2865,7 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb) err =neigh_valid_dump_req (nlh, cb->strict_check, &filter, cb->extack);if (err <0 && cb->strict_check)return err; + err =0 ; s_t = cb->args[0 ];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 698/772 netpoll: Use rcu_access_pointer() in __netpoll_setup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit c69c5e10adb903ae2438d4f9c16eccf43d1fcbc1 ]
The ndev->npinfo pointer in __netpoll_setup() is RCU-protected but is being accessed directly for a NULL check. While no RCU read lock is held in this context, we should still use proper RCU primitives for consistency and correctness.
Replace the direct NULL check with rcu_access_pointer(), which is the appropriate primitive when only checking for NULL without dereferencing the pointer. This function provides the necessary ordering guarantees without requiring RCU read-side protection.
--- net/core/netpoll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/netpoll.c +1 -1
@@ -636,7 +636,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev) goto out; } -if (!ndev->npinfo) { +if (!rcu_access_pointer (ndev->npinfo)) { npinfo =kmalloc (sizeof (*npinfo),GFP_KERNEL );if (!npinfo) { err = -ENOMEM ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 699/772 pinctrl: freescale: fix COMPILE_TEST error with PINCTRL_IMX_SCU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esben Haabendal <[email protected]>
[ Upstream commit 58414a31c5713afb5449fd74a26a843d34cc62e8 ]
When PINCTRL_IMX_SCU was selected by PINCTRL_IMX8DXL or PINCTRL_IMX8QM combined with COMPILE_TEST on a non-arm platforms, the IMX_SCU dependency could not be enabled.
--- drivers/pinctrl/freescale/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/freescale/Kconfig +1 -1
@@ -9,7 +9,7 @@ config PINCTRL_IMX config PINCTRL_IMX_SCU tristate - depends on IMX_SCU + depends on IMX_SCU || COMPILE_TEST select PINCTRL_IMX config PINCTRL_IMX1_CORE
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 700/772 tracing/ftrace: disable preemption in syscall probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathieu Desnoyers <[email protected]>
[ Upstream commit 13d750c2c03e9861e15268574ed2c239cca9c9d5 ]
In preparation for allowing system call enter/exit instrumentation to handle page faults, make sure that ftrace can handle this change by explicitly disabling preemption within the ftrace system call tracepoint probes to respect the current expectations within ftrace ring buffer code.
This change does not yet allow ftrace to take page faults per se within its probe, but allows its existing probes to adapt to the upcoming change.
--- include/trace/trace_events.h | 36 +++++++++++++++++++++++++++++++---- kernel/trace/trace_syscalls.c | 12 ++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-)
include/trace/trace_events.h +32 -4
@@ -244,6 +244,9 @@ static struct trace_event_fields trace_event_fields_##call[] = { \ tstruct \ {} }; +#undef DECLARE_EVENT_SYSCALL_CLASS +#define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS +#undef DEFINE_EVENT_PRINT#define DEFINE_EVENT_PRINT (template, name, proto, args, print)
@@ -374,11 +377,11 @@ static inline notrace int trace_event_get_offsets_##call( \#include "stages/stage6_event_callback.h" -#undef DECLARE_EVENT_CLASS -#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ - \ + +#undef __DECLARE_EVENT_CLASS +#define __DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ static notrace void \ -trace_event_raw_event_##call(void *__data, proto) \ +do_trace_event_raw_event_##call(void *__data, proto) \ { \ struct trace_event_file *trace_file = __data; \ struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
@@ -403,6 +406,29 @@ trace_event_raw_event_##call(void *__data, proto) \ \trace_event_buffer_commit (&fbuffer); \ } + +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ +__DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args), PARAMS(tstruct), \ + PARAMS(assign), PARAMS(print)) \ +static notrace void \ +trace_event_raw_event_##call(void *__data, proto) \ +{ \ + do_trace_event_raw_event_##call(__data, args); \ +} + +#undef DECLARE_EVENT_SYSCALL_CLASS +#define DECLARE_EVENT_SYSCALL_CLASS (call, proto, args, tstruct, assign, print) \ +__DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args), PARAMS(tstruct), \ + PARAMS(assign), PARAMS(print)) \ +static notrace void \ +trace_event_raw_event_##call(void *__data, proto) \ +{ \ + preempt_disable_notrace(); \ + do_trace_event_raw_event_##call(__data, args); \ + preempt_enable_notrace(); \ +} +/* * The ftrace_test_probe is compiled out, it is only here as a build time check * to make sure that if the tracepoint handling changes, the ftrace probe will
@@ -418,6 +444,8 @@ static inline void ftrace_test_probe_##call(void) \#include TRACE_INCLUDE (TRACE_INCLUDE_FILE ) +#undef __DECLARE_EVENT_CLASS +#include "stages/stage7_class_define.h" #undef DECLARE_EVENT_CLASS
kernel/trace/trace_syscalls.c +12 -0
@@ -299,6 +299,12 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)int syscall_nr;int size; +/* +* Syscall probe called with preemption enabled, but the ring +* buffer and per-cpu data require preemption to be disabled. +*/ +guard (preempt_notrace)(); + syscall_nr =trace_get_syscall_nr (current, regs);if (syscall_nr <0 || syscall_nr >= NR_syscalls)return ;
@@ -338,6 +344,12 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)struct trace_event_buffer fbuffer;int syscall_nr; +/* +* Syscall probe called with preemption enabled, but the ring +* buffer and per-cpu data require preemption to be disabled. +*/ +guard (preempt_notrace)(); + syscall_nr =trace_get_syscall_nr (current, regs);if (syscall_nr <0 || syscall_nr >= NR_syscalls)return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 701/772 tracing: Use atomic64_inc_return() in trace_clock_counter()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uros Bizjak <[email protected]>
[ Upstream commit eb887c4567d1b0e7684c026fe7df44afa96589e6 ]
Use atomic64_inc_return(&ref) instead of atomic64_add_return(1, &ref) to use optimized implementation and ease register pressure around the primitive for targets that implement optimized variant.
--- kernel/trace/trace_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_clock.c +1 -1
@@ -154,5 +154,5 @@ static atomic64_t trace_counter;*/ u64 notrace trace_clock_counter(void) { -return atomic64_add_return (1 , &trace_counter); +return atomic64_inc_return (&trace_counter); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 702/772 tools/rtla: fix collision with glibc sched_attr/sched_set_attr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
[ Upstream commit 0eecee340672c4b512f6f4a8c6add26df05d130c ]
glibc commit 21571ca0d703 ("Linux: Add the sched_setattr and sched_getattr functions") now also provides 'struct sched_attr' and sched_setattr() which collide with the ones from rtla.
In file included from src/trace.c:11:
src/utils.h:49:8: error: redefinition of ‘struct sched_attr’
49 | struct sched_attr {
| ^~~~~~~~~~
In file included from /usr/include/bits/sched.h:60,
from /usr/include/sched.h:43,
from /usr/include/tracefs/tracefs.h:10,
from src/trace.c:4:
/usr/include/linux/sched/types.h:98:8: note: originally defined here
98 | struct sched_attr {
| ^~~~~~~~~~Define 'struct sched_attr' conditionally, similar to what strace did:
https://lore.kernel.org/all/[email protected]/
and rename rtla's version of sched_setattr() to avoid collision.
--- tools/tracing/rtla/src/utils.c | 4 ++-- tools/tracing/rtla/src/utils.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/utils.c +2 -2
@@ -238,7 +238,7 @@ long parse_ns_duration(char *val)#define SCHED_DEADLINE 6 -static inline int sched_setattr (pid_t pid,const struct sched_attr *attr, +static inline int syscall_sched_setattr (pid_t pid,const struct sched_attr *attr,unsigned int flags) {return syscall (__NR_sched_setattr, pid, attr, flags); }
@@ -248,7 +248,7 @@ int __set_sched_attr(int pid, struct sched_attr *attr)int flags =0 ;int retval; - retval =sched_setattr (pid, attr, flags); + retval =syscall_sched_setattr (pid, attr, flags);if (retval <0 ) {err_msg ("Failed to set sched attributes to the pid %d: %s\n" , pid,strerror (errno));
tools/tracing/rtla/src/utils.h +2 -0
@@ -44,6 +44,7 @@ update_sum(unsigned long long *a, unsigned long long *b) *a += *b; } +#ifndef SCHED_ATTR_SIZE_VER0 struct sched_attr { uint32_t size; uint32_t sched_policy;
@@ -54,6 +55,7 @@ struct sched_attr {uint64_t sched_deadline; uint64_t sched_period; }; +#endif /* SCHED_ATTR_SIZE_VER0 */ int parse_prio (char *arg,struct sched_attr *sched_param);int set_comm_sched_attr (const char *comm_prefix,struct sched_attr *attr);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 703/772 scsi: hisi_sas: Add cond_resched() for no forced preemption model
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yihang Li <[email protected]>
[ Upstream commit 2233c4a0b948211743659b24c13d6bd059fa75fc ]
For no forced preemption model kernel, in the scenario where the expander is connected to 12 high performance SAS SSDs, the following call trace may occur:
[ 214.409199][ C240] watchdog: BUG: soft lockup - CPU#240 stuck for 22s! [irq/149-hisi_sa:3211] [ 214.568533][ C240] pstate: 60400009 (nZCv daif +PAN -UAO -TCO BTYPE=--) [ 214.575224][ C240] pc : fput_many+0x8c/0xdc [ 214.579480][ C240] lr : fput+0x1c/0xf0 [ 214.583302][ C240] sp : ffff80002de2b900 [ 214.587298][ C240] x29: ffff80002de2b900 x28: ffff1082aa412000 [ 214.593291][ C240] x27: ffff3062a0348c08 x26: ffff80003a9f6000 [ 214.599284][ C240] x25: ffff1062bbac5c40 x24: 0000000000001000 [ 214.605277][ C240] x23: 000000000000000a x22: 0000000000000001 [ 214.611270][ C240] x21: 0000000000001000 x20: 0000000000000000 [ 214.617262][ C240] x19: ffff3062a41ae580 x18: 0000000000010000 [ 214.623255][ C240] x17: 0000000000000001 x16: ffffdb3a6efe5fc0 [ 214.629248][ C240] x15: ffffffffffffffff x14: 0000000003ffffff [ 214.635241][ C240] x13: 000000000000ffff x12: 000000000000029c [ 214.641234][ C240] x11: 0000000000000006 x10: ffff80003a9f7fd0 [ 214.647226][ C240] x9 : ffffdb3a6f0482fc x8 : 0000000000000001 [ 214.653219][ C240] x7 : 0000000000000002 x6 : 0000000000000080 [ 214.659212][ C240] x5 : ffff55480ee9b000 x4 : fffffde7f94c6554 [ 214.665205][ C240] x3 : 0000000000000002 x2 : 0000000000000020 [ 214.671198][ C240] x1 : 0000000000000021 x0 : ffff3062a41ae5b8 [ 214.677191][ C240] Call trace: [ 214.680320][ C240] fput_many+0x8c/0xdc [ 214.684230][ C240] fput+0x1c/0xf0 [ 214.687707][ C240] aio_complete_rw+0xd8/0x1fc [ 214.692225][ C240] blkdev_bio_end_io+0x98/0x140 [ 214.696917][ C240] bio_endio+0x160/0x1bc [ 214.701001][ C240] blk_update_request+0x1c8/0x3bc [ 214.705867][ C240] scsi_end_request+0x3c/0x1f0 [ 214.710471][ C240] scsi_io_completion+0x7c/0x1a0 [ 214.715249][ C240] scsi_finish_command+0x104/0x140 [ 214.720200][ C240] scsi_softirq_done+0x90/0x180 [ 214.724892][ C240] blk_mq_complete_request+0x5c/0x70 [ 214.730016][ C240] scsi_mq_done+0x48/0xac [ 214.734194][ C240] sas_scsi_task_done+0xbc/0x16c [libsas] [ 214.739758][ C240] slot_complete_v3_hw+0x260/0x760 [hisi_sas_v3_hw] [ 214.746185][ C240] cq_thread_v3_hw+0xbc/0x190 [hisi_sas_v3_hw] [ 214.752179][ C240] irq_thread_fn+0x34/0xa4 [ 214.756435][ C240] irq_thread+0xc4/0x130 [ 214.760520][ C240] kthread+0x108/0x13c [ 214.764430][ C240] ret_from_fork+0x10/0x18
This is because in the hisi_sas driver, both the hardware interrupt handler and the interrupt thread are executed on the same CPU. In the performance test scenario, function irq_wait_for_interrupt() will always return 0 if lots of interrupts occurs and the CPU will be continuously consumed. As a result, the CPU cannot run the watchdog thread. When the watchdog time exceeds the specified time, call trace occurs.
To fix it, add cond_resched() to execute the watchdog thread.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -0
@@ -2410,6 +2410,7 @@ static irqreturn_t cq_thread_v3_hw(int irq_no, void *p)/* update rd_point */ cq->rd_point = rd_point;hisi_sas_write32 (hisi_hba,COMPL_Q_0_RD_PTR + (0x14 * queue), rd_point); +cond_resched ();return IRQ_HANDLED ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 704/772 scsi: ufs: core: Make DMA mask configuration more flexible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 78bc671bd1501e2f6c571e063301a4fdc5db53b2 ]
Replace UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS with ufs_hba_variant_ops::set_dma_mask. Update the Renesas driver accordingly. This patch enables supporting other configurations than 32-bit or 64-bit DMA addresses, e.g. 36-bit DMA addresses.
--- drivers/ufs/core/ufshcd.c | 4 ++-- drivers/ufs/host/ufs-renesas.c | 9 ++++++++- include/ufs/ufshcd.h | 9 +++------ 3 files changed, 13 insertions(+), 9 deletions(-)
drivers/ufs/core/ufshcd.c +2 -2
@@ -2230,8 +2230,6 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)int err; hba->capabilities =ufshcd_readl (hba,REG_CONTROLLER_CAPABILITIES ); -if (hba->quirks &UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS ) - hba->capabilities &= ~MASK_64_ADDRESSING_SUPPORT ;/* nutrs and nutmrs are 0 based values */ hba->nutrs = (hba->capabilities &MASK_TRANSFER_REQUESTS_SLOTS ) +1 ;
@@ -9649,6 +9647,8 @@ EXPORT_SYMBOL_GPL(ufshcd_dealloc_host);*/ static int ufshcd_set_dma_mask (struct ufs_hba *hba) { +if (hba->vops && hba->vops->set_dma_mask) +return hba->vops->set_dma_mask (hba);if (hba->capabilities &MASK_64_ADDRESSING_SUPPORT ) {if (!dma_set_mask_and_coherent (hba->dev,DMA_BIT_MASK (64 )))return 0 ;
drivers/ufs/host/ufs-renesas.c +8 -1
@@ -7,6 +7,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/dma-mapping.h> #include <linux/err.h> #include <linux/iopoll.h> #include <linux/kernel.h>
@@ -364,14 +365,20 @@ static int ufs_renesas_init(struct ufs_hba *hba)return -ENOMEM ;ufshcd_set_variant (hba, priv); - hba->quirks |=UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS |UFSHCD_QUIRK_HIBERN_FASTAUTO ; + hba->quirks |=UFSHCD_QUIRK_HIBERN_FASTAUTO ;return 0 ; } +static int ufs_renesas_set_dma_mask (struct ufs_hba *hba) +{ +return dma_set_mask_and_coherent (hba->dev,DMA_BIT_MASK (32 )); +} +static const struct ufs_hba_variant_ops ufs_renesas_vops = { .name ="renesas" , .init = ufs_renesas_init, + .set_dma_mask = ufs_renesas_set_dma_mask, .setup_clocks = ufs_renesas_setup_clocks, .hce_enable_notify = ufs_renesas_hce_enable_notify, .dbg_register_dump = ufs_renesas_dbg_register_dump,
include/ufs/ufshcd.h +3 -6
@@ -272,6 +272,8 @@ struct ufs_pwr_mode_info {* @name: variant name * @init: called when the driver is initialized * @exit: called to cleanup everything done in init +* @set_dma_mask: For setting another DMA mask than indicated by the 64AS +* capability bit. * @get_ufs_hci_version: called to get UFS HCI version * @clk_scale_notify: notifies that clks are scaled up/down * @setup_clocks: called before touching any of the controller registers
@@ -305,6 +307,7 @@ struct ufs_hba_variant_ops {int (*init)(struct ufs_hba *);void (*exit)(struct ufs_hba *);u32 (*get_ufs_hci_version)(struct ufs_hba *); +int (*set_dma_mask)(struct ufs_hba *);int (*clk_scale_notify)(struct ufs_hba *,bool ,enum ufs_notify_change_status ); int (*setup_clocks)(struct ufs_hba *, bool,
@@ -584,12 +587,6 @@ enum ufshcd_quirks {*/ UFSHCD_QUIRK_SKIP_PH_CONFIGURATION = 1 << 16, -/* -* This quirk needs to be enabled if the host controller has -* 64-bit addressing supported capability but it doesn't work. -*/ - UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS = 1 << 17, -/* * This quirk needs to be enabled if the host controller has * auto-hibernate capability but it's FASTAUTO only.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 705/772 leds: class: Protect brightness_show() with led_cdev->led_access mutex
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 4ca7cd938725a4050dcd62ae9472e931d603118d ]
There is NULL pointer issue observed if from Process A where hid device being added which results in adding a led_cdev addition and later a another call to access of led_cdev attribute from Process B can result in NULL pointer issue.
Use mutex led_cdev->led_access to protect access to led->cdev and its attribute inside brightness_show() and max_brightness_show() and also update the comment for mutex that it should be used to protect the led class device fields.
Process A Process B
kthread+0x114
worker_thread+0x244
process_scheduled_works+0x248
uhid_device_add_worker+0x24
hid_add_device+0x120
device_add+0x268
bus_probe_device+0x94
device_initial_probe+0x14
__device_attach+0xfc
bus_for_each_drv+0x10c
__device_attach_driver+0x14c
driver_probe_device+0x3c
__driver_probe_device+0xa0
really_probe+0x190
hid_device_probe+0x130
ps_probe+0x990
ps_led_register+0x94
devm_led_classdev_register_ext+0x58
led_classdev_register_ext+0x1f8
device_create_with_groups+0x48
device_create_groups_vargs+0xc8
device_add+0x244
kobject_uevent+0x14
kobject_uevent_env[jt]+0x224
mutex_unlock[jt]+0xc4
__mutex_unlock_slowpath+0xd4
wake_up_q+0x70
try_to_wake_up[jt]+0x48c
preempt_schedule_common+0x28
__schedule+0x628
__switch_to+0x174
el0t_64_sync+0x1a8/0x1ac el0t_64_sync_handler+0x68/0xbc el0_svc+0x38/0x68 do_el0_svc+0x1c/0x28 el0_svc_common+0x80/0xe0 invoke_syscall+0x58/0x114 __arm64_sys_read+0x1c/0x2c ksys_read+0x78/0xe8 vfs_read+0x1e0/0x2c8 kernfs_fop_read_iter+0x68/0x1b4 seq_read_iter+0x158/0x4ec kernfs_seq_show+0x44/0x54 sysfs_kf_seq_show+0xb4/0x130 dev_attr_show+0x38/0x74 brightness_show+0x20/0x4c dualshock4_led_get_brightness+0xc/0x74
[ 3313.874295][ T4013] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000060 [ 3313.874301][ T4013] Mem abort info: [ 3313.874303][ T4013] ESR = 0x0000000096000006 [ 3313.874305][ T4013] EC = 0x25: DABT (current EL), IL = 32 bits [ 3313.874307][ T4013] SET = 0, FnV = 0 [ 3313.874309][ T4013] EA = 0, S1PTW = 0 [ 3313.874311][ T4013] FSC = 0x06: level 2 translation fault [ 3313.874313][ T4013] Data abort info: [ 3313.874314][ T4013] ISV = 0, ISS = 0x00000006, ISS2 = 0x00000000 [ 3313.874316][ T4013] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 3313.874318][ T4013] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 3313.874320][ T4013] user pgtable: 4k pages, 39-bit VAs, pgdp=00000008f2b0a000
..
[ 3313.874332][ T4013] Dumping ftrace buffer: [ 3313.874334][ T4013] (ftrace buffer empty) .. .. [ dd3313.874639][ T4013] CPU: 6 PID: 4013 Comm: InputReader [ 3313.874648][ T4013] pc : dualshock4_led_get_brightness+0xc/0x74 [ 3313.874653][ T4013] lr : led_update_brightness+0x38/0x60 [ 3313.874656][ T4013] sp : ffffffc0b910bbd0 .. .. [ 3313.874685][ T4013] Call trace: [ 3313.874687][ T4013] dualshock4_led_get_brightness+0xc/0x74 [ 3313.874690][ T4013] brightness_show+0x20/0x4c [ 3313.874692][ T4013] dev_attr_show+0x38/0x74 [ 3313.874696][ T4013] sysfs_kf_seq_show+0xb4/0x130 [ 3313.874700][ T4013] kernfs_seq_show+0x44/0x54 [ 3313.874703][ T4013] seq_read_iter+0x158/0x4ec [ 3313.874705][ T4013] kernfs_fop_read_iter+0x68/0x1b4 [ 3313.874708][ T4013] vfs_read+0x1e0/0x2c8 [ 3313.874711][ T4013] ksys_read+0x78/0xe8 [ 3313.874714][ T4013] __arm64_sys_read+0x1c/0x2c [ 3313.874718][ T4013] invoke_syscall+0x58/0x114 [ 3313.874721][ T4013] el0_svc_common+0x80/0xe0 [ 3313.874724][ T4013] do_el0_svc+0x1c/0x28 [ 3313.874727][ T4013] el0_svc+0x38/0x68 [ 3313.874730][ T4013] el0t_64_sync_handler+0x68/0xbc [ 3313.874732][ T4013] el0t_64_sync+0x1a8/0x1ac
--- drivers/leds/led-class.c | 14 +++++++++++--- include/linux/leds.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/leds/led-class.c +11 -3
@@ -28,11 +28,14 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { struct led_classdev *led_cdev = dev_get_drvdata(dev); +unsigned int brightness; -/* no lock needed for this */ +mutex_lock (&led_cdev->led_access);led_update_brightness (led_cdev); + brightness = led_cdev->brightness; +mutex_unlock (&led_cdev->led_access); -return sprintf (buf,"%u\n" , led_cdev->brightness); +return sprintf (buf,"%u\n" , brightness); } static ssize_t brightness_store(struct device *dev,
@@ -69,8 +72,13 @@ static ssize_t max_brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { struct led_classdev *led_cdev = dev_get_drvdata(dev); +unsigned int max_brightness; + +mutex_lock (&led_cdev->led_access); + max_brightness = led_cdev->max_brightness; +mutex_unlock (&led_cdev->led_access); -return sprintf (buf,"%u\n" , led_cdev->max_brightness); +return sprintf (buf,"%u\n" , max_brightness); }static DEVICE_ATTR_RO (max_brightness);
include/linux/leds.h +1 -1
@@ -161,7 +161,7 @@ struct led_classdev {struct kernfs_node *brightness_hw_changed_kn;#endif -/* Ensures consistent access to the LED Flash Class device */ +/* Ensures consistent access to the LED class device */ struct mutex led_access; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 706/772 scsi: st: Dont modify unknown block number in MTIOCGET
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Mäkisara <[email protected]>
[ Upstream commit 5bb2d6179d1a8039236237e1e94cfbda3be1ed9e ]
Struct mtget field mt_blkno -1 means it is unknown. Don't add anything to it.
--- drivers/scsi/st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/st.c +1 -1
@@ -3754,7 +3754,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) ((STp->density <<MT_ST_DENSITY_SHIFT ) &MT_ST_DENSITY_MASK ); mt_status.mt_blkno = STps->drv_block; mt_status.mt_fileno = STps->drv_file; -if (STp->block_size !=0 ) { +if (STp->block_size !=0 && mt_status.mt_blkno >=0 ) {if (STps->rw ==ST_WRITING ) mt_status.mt_blkno += (STp->buffer)->buffer_bytes / STp->block_size;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 707/772 scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Mäkisara <[email protected]>
[ Upstream commit 0b120edb37dc9dd8ca82893d386922eb6b16f860 ]
Most drives rewind the tape when the device is reset. Reading and writing are not allowed until something is done to make the tape position match the user's expectation (e.g., rewind the tape). Add MTIOCGET and MTLOAD to operations allowed after reset. MTIOCGET is modified to not touch the tape if pos_unknown is non-zero. The tape location is known after MTLOAD.
--- drivers/scsi/st.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
drivers/scsi/st.c +21 -8
@@ -3504,6 +3504,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)int i, cmd_nr, cmd_type, bt;int retval =0 ;unsigned int blk; +bool cmd_mtiocget;struct scsi_tape *STp = file->private_data;struct st_modedef *STm;struct st_partstat *STps;
@@ -3617,6 +3618,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)*/ if (mtc.mt_op != MTREW && mtc.mt_op != MTOFFL && + mtc.mt_op != MTLOAD && mtc.mt_op != MTRETEN && mtc.mt_op != MTERASE && mtc.mt_op != MTSEEK &&
@@ -3730,17 +3732,28 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) goto out; } + cmd_mtiocget = cmd_type ==_IOC_TYPE (MTIOCGET ) && cmd_nr ==_IOC_NR (MTIOCGET ); +if ((i =flush_buffer (STp,0 )) <0 ) { - retval = i; - goto out; - } -if (STp->can_partitions && - (i =switch_partition (STp)) <0 ) { - retval = i; - goto out; +if (cmd_mtiocget && STp->pos_unknown) { +/* flush fails -> modify status accordingly */ +reset_state (STp); + STp->pos_unknown =1 ; + }else {/* return error */ + retval = i; + goto out; + } + }else {/* flush_buffer succeeds */ +if (STp->can_partitions) { + i =switch_partition (STp); +if (i <0 ) { + retval = i; + goto out; + } + } } -if (cmd_type ==_IOC_TYPE (MTIOCGET ) && cmd_nr ==_IOC_NR (MTIOCGET )) { +if (cmd_mtiocget) {struct mtget mt_status;if (_IOC_SIZE (cmd_in) !=sizeof (struct mtget )) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 708/772 pinctrl: qcom-pmic-gpio: add support for PM8937
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Barnabás Czémán <[email protected]>
[ Upstream commit 89265a58ff24e3885c2c9ca722bc3aaa47018be9 ]
PM8937 has 8 GPIO-s with holes on GPIO3, GPIO4 and GPIO6.
--- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +2 -0
@@ -1219,6 +1219,8 @@ static const struct of_device_id pmic_gpio_of_match[] = { { .compatible = "qcom,pm8350c-gpio", .data = (void *) 9 }, { .compatible = "qcom,pm8450-gpio", .data = (void *) 4 }, { .compatible = "qcom,pm8916-gpio", .data = (void *) 4 }, + /* pm8937 has 8 GPIOs with holes on 3, 4 and 6 */ + { .compatible = "qcom,pm8937-gpio", .data = (void *) 8 }, { .compatible = "qcom,pm8941-gpio", .data = (void *) 36 }, /* pm8950 has 8 GPIOs with holes on 3 */ { .compatible = "qcom,pm8950-gpio", .data = (void *) 8 },
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 709/772 pinctrl: qcom: spmi-mpp: Add PM8937 compatible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Barnabás Czémán <[email protected]>
[ Upstream commit f755261190e88f5d19fe0a3b762f0bbaff6bd438 ]
The PM8937 provides 4 MPPs.
Add a compatible to support them.
--- drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +1 -0
@@ -964,6 +964,7 @@ static const struct of_device_id pmic_mpp_of_match[] = { { .compatible = "qcom,pm8226-mpp", .data = (void *) 8 }, { .compatible = "qcom,pm8841-mpp", .data = (void *) 4 }, { .compatible = "qcom,pm8916-mpp", .data = (void *) 4 }, + { .compatible = "qcom,pm8937-mpp", .data = (void *) 4 }, { .compatible = "qcom,pm8941-mpp", .data = (void *) 8 }, { .compatible = "qcom,pm8950-mpp", .data = (void *) 4 }, { .compatible = "qcom,pmi8950-mpp", .data = (void *) 4 },
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 710/772 nvdimm: rectify the illogical code within nd_dax_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Yang <[email protected]>
[ Upstream commit b61352101470f8b68c98af674e187cfaa7c43504 ]
When nd_dax is NULL, nd_pfn is consequently NULL as well. Nevertheless, it is inadvisable to perform pointer arithmetic or address-taking on a NULL pointer.
Introduce the nd_dax_devinit() function to enhance the code's logic and improve its readability.
--- drivers/nvdimm/dax_devs.c | 4 ++-- drivers/nvdimm/nd.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/nvdimm/dax_devs.c +2 -2
@@ -106,12 +106,12 @@ int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns)nvdimm_bus_lock (&ndns->dev); nd_dax =nd_dax_alloc (nd_region); - nd_pfn = &nd_dax->nd_pfn; - dax_dev =nd_pfn_devinit (nd_pfn, ndns); + dax_dev =nd_dax_devinit (nd_dax, ndns);nvdimm_bus_unlock (&ndns->dev);if (!dax_dev)return -ENOMEM ; pfn_sb =devm_kmalloc (dev,sizeof (*pfn_sb),GFP_KERNEL ); + nd_pfn = &nd_dax->nd_pfn; nd_pfn->pfn_sb = pfn_sb; rc =nd_pfn_validate (nd_pfn,DAX_SIG );dev_dbg (dev,"dax: %s\n" , rc ==0 ?dev_name (dax_dev) :"<none>" );
drivers/nvdimm/nd.h +7 -0
@@ -601,6 +601,13 @@ struct nd_dax *to_nd_dax(struct device *dev);int nd_dax_probe (struct device *dev,struct nd_namespace_common *ndns);bool is_nd_dax (struct device *dev);struct device *nd_dax_create (struct nd_region *nd_region); +static inline struct device *nd_dax_devinit (struct nd_dax *nd_dax, +struct nd_namespace_common *ndns) +{ +if (!nd_dax) +return NULL ; +return nd_pfn_devinit (&nd_dax->nd_pfn, ndns); +}#else static inline int nd_dax_probe (struct device *dev,struct nd_namespace_common *ndns)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 711/772 smb: client: memcpy() with surrounding object base address
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit f69b0187f8745a7a9584f6b13f5e792594b88b2e ]
Like commit f1f047bd7ce0 ("smb: client: Fix -Wstringop-overflow issues"), adjust the memcpy() destination address to be based off the surrounding object rather than based off the 4-byte "Protocol" member. This avoids a build-time warning when compiling under CONFIG_FORTIFY_SOURCE with GCC 15:
In function 'fortify_memcpy_chk',
inlined from 'CIFSSMBSetPathInfo' at ../fs/smb/client/cifssmb.c:5358:2:../include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
571 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- fs/smb/client/cifssmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifssmb.c +1 -1
@@ -5349,7 +5349,7 @@ CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon, param_offset = offsetof(struct smb_com_transaction2_spi_req , InformationLevel) -4 ; offset = param_offset + params; - data_offset = (char *) (&pSMB->hdr.Protocol) + offset; + data_offset = (char *)pSMB + offsetof(typeof(*pSMB), hdr.Protocol) + offset; pSMB->ParameterOffset =cpu_to_le16 (param_offset); pSMB->DataOffset =cpu_to_le16 (offset); pSMB->SetupCount =1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 712/772 verification/dot2: Improve dot parser robustness
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriele Monaco <[email protected]>
[ Upstream commit 571f8b3f866a6d990a50fe5c89fe0ea78784d70b ]
This patch makes the dot parser used by dot2c and dot2k slightly more robust, namely:
* allows parsing files with the gv extension (GraphViz)
* correctly parses edges with any indentation
* used to work only with a single character (e.g. '\t')
Additionally it fixes a couple of warnings reported by pylint such as wrong indentation and comparison to False instead of not ...
--- tools/verification/dot2/automata.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tools/verification/dot2/automata.py +9 -9
@@ -29,11 +29,11 @@ class Automata: def __get_model_name(self): basename = ntpath.basename(self.__dot_path) - if basename.endswith(".dot") == False: + if not basename.endswith(".dot") and not basename.endswith(".gv"): print("not a dot file") raise Exception("not a dot file: %s" % self.__dot_path) - model_name = basename[0:-4] + model_name = ntpath.splitext(basename)[0] if model_name.__len__() == 0: raise Exception("not a dot file: %s" % self.__dot_path)
@@ -68,9 +68,9 @@ class Automata: def __get_cursor_begin_events(self): cursor = 0 while self.__dot_lines[cursor].split()[0] != "{node": - cursor += 1 + cursor += 1 while self.__dot_lines[cursor].split()[0] == "{node": - cursor += 1 + cursor += 1 # skip initial state transition cursor += 1 return cursor
@@ -94,11 +94,11 @@ class Automata: initial_state = state[7:] else: states.append(state) - if self.__dot_lines[cursor].__contains__("doublecircle") == True: + if "doublecircle" in self.__dot_lines[cursor]: final_states.append(state) has_final_states = True - if self.__dot_lines[cursor].__contains__("ellipse") == True: + if "ellipse" in self.__dot_lines[cursor]: final_states.append(state) has_final_states = True
@@ -110,7 +110,7 @@ class Automata: # Insert the initial state at the bein og the states states.insert(0, initial_state) - if has_final_states == False: + if not has_final_states: final_states.append(initial_state) return states, initial_state, final_states
@@ -120,7 +120,7 @@ class Automata: cursor = self.__get_cursor_begin_events() events = [] - while self.__dot_lines[cursor][1] == '"': + while self.__dot_lines[cursor].lstrip()[0] == '"': # transitions have the format: # "all_fired" -> "both_fired" [ label = "disable_irq" ]; # ------------ event is here ------------^^^^^
@@ -161,7 +161,7 @@ class Automata: # and we are back! Let's fill the matrix cursor = self.__get_cursor_begin_events() - while self.__dot_lines[cursor][1] == '"': + while self.__dot_lines[cursor].lstrip()[0] == '"': if self.__dot_lines[cursor].split()[1] == "->": line = self.__dot_lines[cursor].split() origin_state = line[0].replace('"','').replace(',','_')
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 713/772 f2fs: fix f2fs_bug_on when uninstalling filesystem call f2fs_evict_inode.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qi Han <[email protected]>
[ Upstream commit d5c367ef8287fb4d235c46a2f8c8d68715f3a0ca ]
creating a large files during checkpoint disable until it runs out of space and then delete it, then remount to enable checkpoint again, and then unmount the filesystem triggers the f2fs_bug_on as below:
------------[ cut here ]------------ kernel BUG at fs/f2fs/inode.c:896! CPU: 2 UID: 0 PID: 1286 Comm: umount Not tainted 6.11.0-rc7-dirty #360 Oops: invalid opcode: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:f2fs_evict_inode+0x58c/0x610 Call Trace: __die_body+0x15/0x60 die+0x33/0x50 do_trap+0x10a/0x120 f2fs_evict_inode+0x58c/0x610 do_error_trap+0x60/0x80 f2fs_evict_inode+0x58c/0x610 exc_invalid_op+0x53/0x60 f2fs_evict_inode+0x58c/0x610 asm_exc_invalid_op+0x16/0x20 f2fs_evict_inode+0x58c/0x610 evict+0x101/0x260 dispose_list+0x30/0x50 evict_inodes+0x140/0x190 generic_shutdown_super+0x2f/0x150 kill_block_super+0x11/0x40 kill_f2fs_super+0x7d/0x140 deactivate_locked_super+0x2a/0x70 cleanup_mnt+0xb3/0x140 task_work_run+0x61/0x90
The root cause is: creating large files during disable checkpoint period results in not enough free segments, so when writing back root inode will failed in f2fs_enable_checkpoint. When umount the file system after enabling checkpoint, the root inode is dirty in f2fs_evict_inode function, which triggers BUG_ON. The steps to reproduce are as follows:
dd if=/dev/zero of=f2fs.img bs=1M count=55
mount f2fs.img f2fs_dir -o checkpoint=disable:10%
dd if=/dev/zero of=big bs=1M count=50
sync
rm big
mount -o remount,checkpoint=enable f2fs_dir
umount f2fs_dir
Let's redirty inode when there is not free segments during checkpoint is disable.
--- fs/f2fs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +3 -1
@@ -719,8 +719,10 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) !is_inode_flag_set(inode, FI_DIRTY_INODE))return 0 ; -if (!f2fs_is_checkpoint_ready (sbi)) +if (!f2fs_is_checkpoint_ready (sbi)) { +f2fs_mark_inode_dirty_sync (inode, true);return -ENOSPC ; + }/* * We need to balance fs here to prevent from producing dirty node pages
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 714/772 i3c: mipi-i3c-hci: Mask ring interrupts before ring stop request
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Nikula <[email protected]>
[ Upstream commit 6ca2738174e4ee44edb2ab2d86ce74f015a0cc32 ]
Bus cleanup path in DMA mode may trigger a RING_OP_STAT interrupt when the ring is being stopped. Depending on timing between ring stop request completion, interrupt handler removal and code execution this may lead to a NULL pointer dereference in hci_dma_irq_handler() if it gets to run after the io_data pointer is set to NULL in hci_dma_cleanup().
Prevent this my masking the ring interrupts before ring stop request.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +1 -1
@@ -174,10 +174,10 @@ static void hci_dma_cleanup(struct i3c_hci *hci)for (i =0 ; i < rings->total; i++) { rh = &rings->headers[i]; +rh_reg_write (INTR_SIGNAL_ENABLE ,0 );rh_reg_write (RING_CONTROL ,0 );rh_reg_write (CR_SETUP ,0 );rh_reg_write (IBI_SETUP ,0 ); -rh_reg_write (INTR_SIGNAL_ENABLE ,0 );if (rh->xfer) dma_free_coherent(&hci->master.dev,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 715/772 PCI: Detect and trust built-in Thunderbolt chips
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esther Shimanovich <[email protected]>
[ Upstream commit 3b96b895127b7c0aed63d82c974b46340e8466c1 ]
Some computers with CPUs that lack Thunderbolt features use discrete Thunderbolt chips to add Thunderbolt functionality. These Thunderbolt chips are located within the chassis; between the Root Port labeled ExternalFacingPort and the USB-C port.
These Thunderbolt PCIe devices should be labeled as fixed and trusted, as they are built into the computer. Otherwise, security policies that rely on those flags may have unintended results, such as preventing USB-C ports from enumerating.
Detect the above scenario through the process of elimination.
1) Integrated Thunderbolt host controllers already have Thunderbolt implemented, so anything outside their external facing Root Port is removable and untrusted.
Detect them using the following properties:
- Most integrated host controllers have the "usb4-host-interface" ACPI property, as described here:
- Integrated Thunderbolt PCIe Root Ports before Alder Lake do not have the "usb4-host-interface" ACPI property. Identify those by their PCI IDs instead.
2) If a Root Port does not have integrated Thunderbolt capabilities, but has the "ExternalFacingPort" ACPI property, that means the manufacturer has opted to use a discrete Thunderbolt host controller that is built into the computer.
This host controller can be identified by virtue of being located directly below an external-facing Root Port that lacks integrated Thunderbolt. Label it as trusted and fixed.
Everything downstream from it is untrusted and removable.
The "ExternalFacingPort" ACPI property is described here:
https://learn.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports#identifying-externally-exposed-pcie-root-ports
--- arch/x86/pci/acpi.c | 119 ++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/probe.c | 30 ++++++++--- include/linux/pci.h | 6 +++ 3 files changed, 148 insertions(+), 7 deletions(-)
arch/x86/pci/acpi.c +119 -0
@@ -248,6 +248,125 @@ void __init pci_acpi_crs_quirks(void)printk (KERN_INFO "PCI: Please notify [email protected] so future kernels can this automatically\n" ); } +/* +* Check if pdev is part of a PCIe switch that is directly below the +* specified bridge. +*/ +static bool pcie_switch_directly_under (struct pci_dev *bridge, +struct pci_dev *pdev) +{ +struct pci_dev *parent =pci_upstream_bridge (pdev); + +/* If the device doesn't have a parent, it's not under anything */ +if (!parent) +return false; + +/* +* If the device has a PCIe type, check if it is below the +* corresponding PCIe switch components (if applicable). Then check +* if its upstream port is directly beneath the specified bridge. +*/ +switch (pci_pcie_type (pdev)) { +case PCI_EXP_TYPE_UPSTREAM : +return parent == bridge; + +case PCI_EXP_TYPE_DOWNSTREAM : +if (pci_pcie_type (parent) !=PCI_EXP_TYPE_UPSTREAM ) +return false; + parent =pci_upstream_bridge (parent); +return parent == bridge; + +case PCI_EXP_TYPE_ENDPOINT : +if (pci_pcie_type (parent) !=PCI_EXP_TYPE_DOWNSTREAM ) +return false; + parent =pci_upstream_bridge (parent); +if (!parent ||pci_pcie_type (parent) !=PCI_EXP_TYPE_UPSTREAM ) +return false; + parent =pci_upstream_bridge (parent); +return parent == bridge; + } + +return false; +} + +static bool pcie_has_usb4_host_interface (struct pci_dev *pdev) +{ +struct fwnode_handle *fwnode; + +/* +* For USB4, the tunneled PCIe Root or Downstream Ports are marked +* with the "usb4-host-interface" ACPI property, so we look for +* that first. This should cover most cases. +*/ + fwnode =fwnode_find_reference (dev_fwnode (&pdev->dev), +"usb4-host-interface" ,0 ); +if (!IS_ERR (fwnode)) { +fwnode_handle_put (fwnode); +return true; + } + +/* +* Any integrated Thunderbolt 3/4 PCIe Root Ports from Intel +* before Alder Lake do not have the "usb4-host-interface" +* property so we use their PCI IDs instead. All these are +* tunneled. This list is not expected to grow. +*/ +if (pdev->vendor ==PCI_VENDOR_ID_INTEL ) { +switch (pdev->device) { +/* Ice Lake Thunderbolt 3 PCIe Root Ports */ +case 0x8a1d : +case 0x8a1f : +case 0x8a21 : +case 0x8a23 : +/* Tiger Lake-LP Thunderbolt 4 PCIe Root Ports */ +case 0x9a23 : +case 0x9a25 : +case 0x9a27 : +case 0x9a29 : +/* Tiger Lake-H Thunderbolt 4 PCIe Root Ports */ +case 0x9a2b : +case 0x9a2d : +case 0x9a2f : +case 0x9a31 : +return true; + } + } + +return false; +} + +bool arch_pci_dev_is_removable (struct pci_dev *pdev) +{ +struct pci_dev *parent, *root; + +/* pdev without a parent or Root Port is never tunneled */ + parent =pci_upstream_bridge (pdev); +if (!parent) +return false; + root =pcie_find_root_port (pdev); +if (!root) +return false; + +/* Internal PCIe devices are not tunneled */ +if (!root->external_facing) +return false; + +/* Anything directly behind a "usb4-host-interface" is tunneled */ +if (pcie_has_usb4_host_interface (parent)) +return true; + +/* +* Check if this is a discrete Thunderbolt/USB4 controller that is +* directly behind the non-USB4 PCIe Root Port marked as +* "ExternalFacingPort". Those are not behind a PCIe tunnel. +*/ +if (pcie_switch_directly_under (root, pdev)) +return false; + +/* PCIe devices after the discrete chip are tunneled */ +return true; +} +#ifdef CONFIG_PCI_MMCONFIG static int check_segment (u16 seg,struct device *dev,char *estr) {
drivers/pci/probe.c +23 -7
@@ -1593,23 +1593,33 @@ static void set_pcie_thunderbolt(struct pci_dev *dev)static void set_pcie_untrusted (struct pci_dev *dev) { -struct pci_dev *parent; +struct pci_dev *parent =pci_upstream_bridge (dev); +if (!parent) +return ;/* -* If the upstream bridge is untrusted we treat this device +* If the upstream bridge is untrusted we treat this device as * untrusted as well. */ - parent =pci_upstream_bridge (dev); -if (parent && (parent->untrusted || parent->external_facing)) +if (parent->untrusted) { + dev->untrusted = true; +return ; + } + +if (arch_pci_dev_is_removable (dev)) { +pci_dbg (dev,"marking as untrusted\n" ); dev->untrusted = true; + } }static void pci_set_removable (struct pci_dev *dev) {struct pci_dev *parent =pci_upstream_bridge (dev); +if (!parent) +return ;/* -* We (only) consider everything downstream from an external_facing +* We (only) consider everything tunneled below an external_facing * device to be removable by the user. We're mainly concerned with * consumer platforms with user accessible thunderbolt ports that are * vulnerable to DMA attacks, and we expect those ports to be marked by
@@ -1619,9 +1629,15 @@ static void pci_set_removable(struct pci_dev *dev)* accessible to user / may not be removed by end user, and thus not * exposed as "removable" to userspace. */ -if (parent && - (parent->external_facing ||dev_is_removable (&parent->dev))) +if (dev_is_removable (&parent->dev)) { +dev_set_removable (&dev->dev,DEVICE_REMOVABLE ); +return ; + } + +if (arch_pci_dev_is_removable (dev)) { +pci_dbg (dev,"marking as removable\n" );dev_set_removable (&dev->dev,DEVICE_REMOVABLE ); + } }/**
include/linux/pci.h +6 -0
@@ -2471,6 +2471,12 @@ pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }static inline bool pci_pr3_present (struct pci_dev *pdev) {return false; }#endif +#if defined(CONFIG_X86 ) && defined(CONFIG_ACPI ) +bool arch_pci_dev_is_removable (struct pci_dev *pdev); +#else +static inline bool arch_pci_dev_is_removable (struct pci_dev *pdev) {return false; } +#endif +#ifdef CONFIG_EEH static inline struct eeh_dev *pci_dev_to_eeh_dev (struct pci_dev *pdev) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 716/772 PCI: Add reset_subordinate to reset hierarchy below bridge
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 2fa046449a82a7d0f6d9721dd83e348816038444 ]
The "bus" and "cxl_bus" reset methods reset a device by asserting Secondary Bus Reset on the bridge leading to the device. These only work if the device is the only device below the bridge.
Add a sysfs 'reset_subordinate' attribute on bridges that can assert Secondary Bus Reset regardless of how many devices are below the bridge.
This resets all the devices below a bridge in a single command, including the locking and config space save/restore that reset methods normally do.
This may be the only way to reset devices that don't support other reset methods (ACPI, FLR, PM reset, etc).
--- Documentation/ABI/testing/sysfs-bus-pci | 11 +++++++++++ drivers/pci/pci-sysfs.c | 26 +++++++++++++++++++++++++ drivers/pci/pci.c | 2 +- drivers/pci/pci.h | 1 + 4 files changed, 39 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-pci +11 -0
@@ -163,6 +163,17 @@ Description: will be present in sysfs. Writing 1 to this file will perform reset. +What: /sys/bus/pci/devices/.../reset_subordinate +Date: October 2024 +Contact: [email protected] +Description: + This is visible only for bridge devices. If you want to reset + all devices attached through the subordinate bus of a specific + bridge device, writing 1 to this will try to do it. This will + affect all devices attached to the system through this bridge + similiar to writing 1 to their individual "reset" file, so use + with caution. + What: /sys/bus/pci/devices/.../vpd Date: February 2008 Contact: Ben Hutchings <[email protected]>
drivers/pci/pci-sysfs.c +26 -0
@@ -517,6 +517,31 @@ static ssize_t bus_rescan_store(struct device *dev,static struct device_attribute dev_attr_bus_rescan =__ATTR (rescan,0200 ,NULL , bus_rescan_store); +static ssize_t reset_subordinate_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_bus *bus = pdev->subordinate; +unsigned long val; + +if (!capable (CAP_SYS_ADMIN )) +return -EPERM ; + +if (kstrtoul (buf,0 , &val) <0 ) +return -EINVAL ; + +if (val) { +int ret =__pci_reset_bus (bus); + +if (ret) +return ret; + } + +return count; +} +static DEVICE_ATTR_WO (reset_subordinate); +#if defined(CONFIG_PM ) && defined(CONFIG_ACPI ) static ssize_t d3cold_allowed_store(struct device *dev, struct device_attribute *attr,
@@ -621,6 +646,7 @@ static struct attribute *pci_dev_attrs[] = {static struct attribute *pci_bridge_attrs[] = { &dev_attr_subordinate_bus_number.attr, &dev_attr_secondary_bus_number.attr, + &dev_attr_reset_subordinate.attr,NULL , };
drivers/pci/pci.c +1 -1
@@ -5933,7 +5933,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_bus);* * Same as above except return -EAGAIN if the bus cannot be locked */ -static int __pci_reset_bus (struct pci_bus *bus) +int __pci_reset_bus (struct pci_bus *bus) {int rc;
drivers/pci/pci.h +1 -0
@@ -37,6 +37,7 @@ bool pci_reset_supported(struct pci_dev *dev);void pci_init_reset_methods (struct pci_dev *dev);int pci_bridge_secondary_bus_reset (struct pci_dev *dev);int pci_bus_error_reset (struct pci_dev *dev); +int __pci_reset_bus (struct pci_bus *bus);struct pci_cap_saved_data {u16 cap_nr;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 717/772 PCI: Add ACS quirk for Wangxun FF5xxx NICs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mengyuan Lou <[email protected]>
[ Upstream commit aa46a3736afcb7b0793766d22479b8b99fc1b322 ]
Wangxun FF5xxx NICs are similar to SFxxx, RP1000 and RP2000 NICs. They may be multi-function devices, but they do not advertise an ACS capability.
But the hardware does isolate FF5xxx functions as though it had an ACS capability and PCI_ACS_RR and PCI_ACS_CR were set in the ACS Control register, i.e., all peer-to-peer traffic is directed upstream instead of being routed internally.
Add ACS quirk for FF5xxx NICs in pci_quirk_wangxun_nic_acs() so the functions can be in independent IOMMU groups.
--- drivers/pci/quirks.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/pci/quirks.c +9 -6
@@ -4881,18 +4881,21 @@ static int pci_quirk_brcm_acs(struct pci_dev *dev, u16 acs_flags) }/* -* Wangxun 10G/1G NICs have no ACS capability, and on multi-function -* devices, peer-to-peer transactions are not be used between the functions. -* So add an ACS quirk for below devices to isolate functions. +* Wangxun 40G/25G/10G/1G NICs have no ACS capability, but on +* multi-function devices, the hardware isolates the functions by +* directing all peer-to-peer traffic upstream as though PCI_ACS_RR and +* PCI_ACS_CR were set. * SFxxx 1G NICs(em). * RP1000/RP2000 10G NICs(sp). +* FF5xxx 40G/25G/10G NICs(aml). */ static int pci_quirk_wangxun_nic_acs (struct pci_dev *dev,u16 acs_flags) {switch (dev->device) { - case 0x0100 ... 0x010F: -case 0x1001 : -case 0x2001 : + case 0x0100 ... 0x010F: /* EM */ +case 0x1001 :case 0x2001 :/* SP */ +case 0x5010 :case 0x5025 :case 0x5040 :/* AML */ +case 0x5110 :case 0x5125 :case 0x5140 :/* AML */ return pci_acs_ctrl_enabled (acs_flags,PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 718/772 i3c: Use i3cdev->desc->info instead of calling i3c_device_get_info() to avoid deadlock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Defa Li <[email protected]>
[ Upstream commit 6cf7b65f7029914dc0cd7db86fac9ee5159008c6 ]
A deadlock may happen since the i3c_master_register() acquires &i3cbus->lock twice. See the log below.
Use i3cdev->desc->info instead of calling i3c_device_info() to avoid acquiring the lock twice.
v2:
- Modified the title and commit message
============================================
WARNING: possible recursive locking detected
6.11.0-mainline
--------------------------------------------
init/1 is trying to acquire lock:f1ffff80a6a40dc0 (&i3cbus->lock){++++}-{3:3}, at: i3c_bus_normaluse_lock
but task is already holding lock:f1ffff80a6a40dc0 (&i3cbus->lock){++++}-{3:3}, at: i3c_master_register
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&i3cbus->lock);
lock(&i3cbus->lock);
*** DEADLOCK ***
May be due to missing lock nesting notation
2 locks held by init/1:
#0: fcffff809b6798f8 (&dev->mutex){....}-{3:3}, at: __driver_attach #1: f1ffff80a6a40dc0 (&i3cbus->lock){++++}-{3:3}, at: i3c_master_register
stack backtrace: CPU: 6 UID: 0 PID: 1 Comm: init Call trace: dump_backtrace+0xfc/0x17c show_stack+0x18/0x28 dump_stack_lvl+0x40/0xc0 dump_stack+0x18/0x24 print_deadlock_bug+0x388/0x390 __lock_acquire+0x18bc/0x32ec lock_acquire+0x134/0x2b0 down_read+0x50/0x19c i3c_bus_normaluse_lock+0x14/0x24 i3c_device_get_info+0x24/0x58 i3c_device_uevent+0x34/0xa4 dev_uevent+0x310/0x384 kobject_uevent_env+0x244/0x414 kobject_uevent+0x14/0x20 device_add+0x278/0x460 device_register+0x20/0x34 i3c_master_register_new_i3c_devs+0x78/0x154 i3c_master_register+0x6a0/0x6d4 mtk_i3c_master_probe+0x3b8/0x4d8 platform_probe+0xa0/0xe0 really_probe+0x114/0x454 __driver_probe_device+0xa0/0x15c driver_probe_device+0x3c/0x1ac __driver_attach+0xc4/0x1f0 bus_for_each_dev+0x104/0x160 driver_attach+0x24/0x34 bus_add_driver+0x14c/0x294 driver_register+0x68/0x104 __platform_driver_register+0x20/0x30 init_module+0x20/0xfe4 do_one_initcall+0x184/0x464 do_init_module+0x58/0x1ec load_module+0xefc/0x10c8 __arm64_sys_finit_module+0x238/0x33c invoke_syscall+0x58/0x10c el0_svc_common+0xa8/0xdc do_el0_svc+0x1c/0x28 el0_svc+0x50/0xac el0t_64_sync_handler+0x70/0xbc el0t_64_sync+0x1a8/0x1ac
--- drivers/i3c/master.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/i3c/master.c +2 -1
@@ -279,7 +279,8 @@ static int i3c_device_uevent(struct device *dev, struct kobj_uevent_env *env)struct i3c_device_info devinfo;u16 manuf, part, ext; -i3c_device_get_info (i3cdev, &devinfo); +if (i3cdev->desc) + devinfo = i3cdev->desc->info; manuf =I3C_PID_MANUF_ID (devinfo.pid); part =I3C_PID_PART_ID (devinfo.pid); ext =I3C_PID_EXTRA_INFO (devinfo.pid);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 719/772 LoongArch: Fix sleeping in atomic context for PREEMPT_RT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit 88fd2b70120d52c1010257d36776876941375490 ]
Commit bab1c299f3945ffe79 ("LoongArch: Fix sleeping in atomic context in setup_tlb_handler()") changes the gfp flag from GFP_KERNEL to GFP_ATOMIC for alloc_pages_node(). However, for PREEMPT_RT kernels we can still get a "sleeping in atomic context" error:
[ 0.372259] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
[ 0.372266] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1
[ 0.372268] preempt_count: 1, expected: 0
[ 0.372270] RCU nest depth: 1, expected: 1
[ 0.372272] 3 locks held by swapper/1/0:
[ 0.372274] #0: 900000000c9f5e60 (&pcp->lock){+.+.}-{3:3}, at: get_page_from_freelist+0x524/0x1c60
[ 0.372294] #1: 90000000087013b8 (rcu_read_lock){....}-{1:3}, at: rt_spin_trylock+0x50/0x140
[ 0.372305] #2: 900000047fffd388 (&zone->lock){+.+.}-{3:3}, at: __rmqueue_pcplist+0x30c/0xea0
[ 0.372314] irq event stamp: 0
[ 0.372316] hardirqs last enabled at (0): [<0000000000000000>] 0x0
[ 0.372322] hardirqs last disabled at (0): [<9000000005947320>] copy_process+0x9c0/0x26e0
[ 0.372329] softirqs last enabled at (0): [<9000000005947320>] copy_process+0x9c0/0x26e0
[ 0.372335] softirqs last disabled at (0): [<0000000000000000>] 0x0
[ 0.372341] CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Not tainted 6.12.0-rc7+ #1891
[ 0.372346] Hardware name: Loongson Loongson-3A5000-7A1000-1w-CRB/Loongson-LS3A5000-7A1000-1w-CRB, BIOS vUDK2018-LoongArch-V2.0.0-prebeta9 10/21/2022
[ 0.372349] Stack : 0000000000000089 9000000005a0db9c 90000000071519c8 9000000100388000
[ 0.372486] 900000010038b890 0000000000000000 900000010038b898 9000000007e53788
[ 0.372492] 900000000815bcc8 900000000815bcc0 900000010038b700 0000000000000001
[ 0.372498] 0000000000000001 4b031894b9d6b725 00000000055ec000 9000000100338fc0
[ 0.372503] 00000000000000c4 0000000000000001 000000000000002d 0000000000000003
[ 0.372509] 0000000000000030 0000000000000003 00000000055ec000 0000000000000003
[ 0.372515] 900000000806d000 9000000007e53788 00000000000000b0 0000000000000004
[ 0.372521] 0000000000000000 0000000000000000 900000000c9f5f10 0000000000000000
[ 0.372526] 90000000076f12d8 9000000007e53788 9000000005924778 0000000000000000
[ 0.372532] 00000000000000b0 0000000000000004 0000000000000000 0000000000070000
[ 0.372537] ...
[ 0.372540] Call Trace:
[ 0.372542] [<9000000005924778>] show_stack+0x38/0x180
[ 0.372548] [<90000000071519c4>] dump_stack_lvl+0x94/0xe4
[ 0.372555] [<900000000599b880>] __might_resched+0x1a0/0x260
[ 0.372561] [<90000000071675cc>] rt_spin_lock+0x4c/0x140
[ 0.372565] [<9000000005cbb768>] __rmqueue_pcplist+0x308/0xea0
[ 0.372570] [<9000000005cbed84>] get_page_from_freelist+0x564/0x1c60
[ 0.372575] [<9000000005cc0d98>] __alloc_pages_noprof+0x218/0x1820
[ 0.372580] [<900000000593b36c>] tlb_init+0x1ac/0x298
[ 0.372585] [<9000000005924b74>] per_cpu_trap_init+0x114/0x140
[ 0.372589] [<9000000005921964>] cpu_probe+0x4e4/0xa60
[ 0.372592] [<9000000005934874>] start_secondary+0x34/0xc0
[ 0.372599] [<900000000715615c>] smpboot_entry+0x64/0x6cThis is because in PREEMPT_RT kernels normal spinlocks are replaced by rt spinlocks and rt_spin_lock() will cause sleeping. Fix it by disabling NUMA optimization completely for PREEMPT_RT kernels.
--- arch/loongarch/mm/tlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/mm/tlb.c +1 -1
@@ -279,7 +279,7 @@ void setup_tlb_handler(int cpu)/* Avoid lockdep warning */ rcu_cpu_starting (cpu); -#ifdef CONFIG_NUMA +#if defined(CONFIG_NUMA ) && !defined(CONFIG_PREEMPT_RT ) vec_sz =sizeof (exception_handlers);if (pcpu_handlers[cpu])
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 720/772 usb: chipidea: udc: handle USB Error Interrupt if IOC not set
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
[ Upstream commit 548f48b66c0c5d4b9795a55f304b7298cde2a025 ]
As per USBSTS register description about UEI:
When completion of a USB transaction results in an error condition, this bit is set by the Host/Device Controller. This bit is set along with the USBINT bit, if the TD on which the error interrupt occurred also had its interrupt on complete (IOC) bit set.
UI is set only when IOC set. Add checking UEI to fix miss call isr_tr_complete_handler() when IOC have not set and transfer error happen.
--- drivers/usb/chipidea/udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/chipidea/udc.c +1 -1
@@ -2052,7 +2052,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci) } } -if (USBi_UI & intr) +if ((USBi_UI | USBi_UEI) & intr)isr_tr_complete_handler (ci);if ((USBi_SLI & intr) && !(ci->suspended)) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 721/772 iio: light: ltr501: Add LTER0303 to the supported devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit c26acb09ccbef47d1fddaf0783c1392d0462122c ]
It has been found that the (non-vendor issued) ACPI ID for Lite-On LTR303 is present in Microsoft catalog. Add it to the list of the supported devices.
--- drivers/iio/light/ltr501.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/light/ltr501.c +2 -0
@@ -1631,6 +1631,8 @@ static const struct acpi_device_id ltr_acpi_match[] = { { "LTER0501", ltr501 }, { "LTER0559", ltr559 }, { "LTER0301", ltr301 }, +/* https://www.catalog.update.microsoft.com/Search.aspx?q=lter0303 */ + { "LTER0303", ltr303 }, { }, };MODULE_DEVICE_TABLE (acpi, ltr_acpi_match);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 722/772 MIPS: Loongson64: DTS: Really fix PCIe port nodes for ls7a
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xi Ruoyao <[email protected]>
[ Upstream commit 4fbd66d8254cedfd1218393f39d83b6c07a01917 ]
Fix the dtc warnings:
arch/mips/boot/dts/loongson/ls7a-pch.dtsi:68.16-416.5: Warning (interrupt_provider): /bus@10000000/pci@1a000000: '#interrupt-cells' found, but node is not an interrupt provider
arch/mips/boot/dts/loongson/ls7a-pch.dtsi:68.16-416.5: Warning (interrupt_provider): /bus@10000000/pci@1a000000: '#interrupt-cells' found, but node is not an interrupt provider
arch/mips/boot/dts/loongson/loongson64g_4core_ls7a.dtb: Warning (interrupt_map): Failed prerequisite 'interrupt_provider'And a runtime warning introduced in commit 045b14ca5c36 ("of: WARN on deprecated #address-cells/#size-cells handling"):
WARNING: CPU: 0 PID: 1 at drivers/of/base.c:106 of_bus_n_addr_cells+0x9c/0xe0
Missing '#address-cells' in /bus@10000000/pci@1a000000/pci_bridge@9,0The fix is similar to commit d89a415ff8d5 ("MIPS: Loongson64: DTS: Fix PCIe port nodes for ls7a"), which has fixed the issue for ls2k (despite its subject mentions ls7a).
--- arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 73 +++++++++++++++++++---- 1 file changed, 60 insertions(+), 13 deletions(-)
arch/mips/boot/dts/loongson/ls7a-pch.dtsi +60 -13
@@ -63,7 +63,6 @@ device_type = "pci"; #address-cells = <3>; #size-cells = <2>; - #interrupt-cells = <2>; msi-parent = <&msi>; reg = <0 0x1a000000 0 0x02000000>,
@@ -227,7 +226,7 @@ }; }; - pci_bridge@9,0 { + pcie@9,0 { compatible = "pci0014,7a19.1", "pci0014,7a19", "pciclass060400",
@@ -237,12 +236,16 @@ interrupts = <32 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 32 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@a,0 { + pcie@a,0 { compatible = "pci0014,7a09.1", "pci0014,7a09", "pciclass060400",
@@ -252,12 +255,16 @@ interrupts = <33 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 33 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@b,0 { + pcie@b,0 { compatible = "pci0014,7a09.1", "pci0014,7a09", "pciclass060400",
@@ -267,12 +274,16 @@ interrupts = <34 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 34 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@c,0 { + pcie@c,0 { compatible = "pci0014,7a09.1", "pci0014,7a09", "pciclass060400",
@@ -282,12 +293,16 @@ interrupts = <35 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 35 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@d,0 { + pcie@d,0 { compatible = "pci0014,7a19.1", "pci0014,7a19", "pciclass060400",
@@ -297,12 +312,16 @@ interrupts = <36 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 36 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@e,0 { + pcie@e,0 { compatible = "pci0014,7a09.1", "pci0014,7a09", "pciclass060400",
@@ -312,12 +331,16 @@ interrupts = <37 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 37 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@f,0 { + pcie@f,0 { compatible = "pci0014,7a29.1", "pci0014,7a29", "pciclass060400",
@@ -327,12 +350,16 @@ interrupts = <40 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 40 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@10,0 { + pcie@10,0 { compatible = "pci0014,7a19.1", "pci0014,7a19", "pciclass060400",
@@ -342,12 +369,16 @@ interrupts = <41 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 41 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@11,0 { + pcie@11,0 { compatible = "pci0014,7a29.1", "pci0014,7a29", "pciclass060400",
@@ -357,12 +388,16 @@ interrupts = <42 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 42 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@12,0 { + pcie@12,0 { compatible = "pci0014,7a19.1", "pci0014,7a19", "pciclass060400",
@@ -372,12 +407,16 @@ interrupts = <43 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 43 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@13,0 { + pcie@13,0 { compatible = "pci0014,7a29.1", "pci0014,7a29", "pciclass060400",
@@ -387,12 +426,16 @@ interrupts = <38 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 38 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; - pci_bridge@14,0 { + pcie@14,0 { compatible = "pci0014,7a19.1", "pci0014,7a19", "pciclass060400",
@@ -402,9 +445,13 @@ interrupts = <39 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&pic>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &pic 39 IRQ_TYPE_LEVEL_HIGH>; + ranges; }; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 723/772 ASoC: amd: yc: Add quirk for microphone on Lenovo Thinkpad T14s Gen 6 21M1CTO1WW
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit cbc86dd0a4fe9f8c41075328c2e740b68419d639 ]
Add a quirk for Tova's Lenovo Thinkpad T14s with product name 21M1.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -220,6 +220,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "21J6"), } }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "21M1"), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 724/772 powerpc/prom_init: Fixup missing powermac #size-cells
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit cf89c9434af122f28a3552e6f9cc5158c33ce50a ]
On some powermacs escc nodes are missing #size-cells properties, which is deprecated and now triggers a warning at boot since commit 045b14ca5c36 ("of: WARN on deprecated #address-cells/#size-cells handling").
For example:
Missing '#size-cells' in /pci@f2000000/mac-io@c/escc@13000
WARNING: CPU: 0 PID: 0 at drivers/of/base.c:133 of_bus_n_size_cells+0x98/0x108
Hardware name: PowerMac3,1 7400 0xc0209 PowerMac
...
Call Trace:
of_bus_n_size_cells+0x98/0x108 (unreliable)
of_bus_default_count_cells+0x40/0x60
__of_get_address+0xc8/0x21c
__of_address_to_resource+0x5c/0x228
pmz_init_port+0x5c/0x2ec
pmz_probe.isra.0+0x144/0x1e4
pmz_console_init+0x10/0x48
console_init+0xcc/0x138
start_kernel+0x5c4/0x694As powermacs boot via prom_init it's possible to add the missing properties to the device tree during boot, avoiding the warning. Note that escc-legacy nodes are also missing #size-cells properties, but they are skipped by the macio driver, so leave them alone.
Depends-on: 045b14ca5c36 ("of: WARN on deprecated #address-cells/#size-cells handling")
--- arch/powerpc/kernel/prom_init.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
arch/powerpc/kernel/prom_init.c +27 -2
@@ -2924,7 +2924,7 @@ static void __init fixup_device_tree_chrp(void)#endif #if defined(CONFIG_PPC64 ) && defined(CONFIG_PPC_PMAC ) -static void __init fixup_device_tree_pmac (void ) +static void __init fixup_device_tree_pmac64 (void ) {phandle u3, i2c, mpic;u32 u3_rev;
@@ -2964,7 +2964,31 @@ static void __init fixup_device_tree_pmac(void) &parent, sizeof(parent)); }#else -#define fixup_device_tree_pmac () +#define fixup_device_tree_pmac64 () +#endif + +#ifdef CONFIG_PPC_PMAC +static void __init fixup_device_tree_pmac (void ) +{ +__be32 val =1 ; +char type[8 ]; +phandle node; + +// Some pmacs are missing #size-cells on escc nodes +for (node =0 ;prom_next_node (&node); ) { + type[0 ] ='\0' ; +prom_getprop (node,"device_type" , type,sizeof (type)); +if (prom_strcmp (type,"escc" )) +continue ; + +if (prom_getproplen (node,"#size-cells" ) !=PROM_ERROR ) +continue ; + +prom_setprop (node,NULL ,"#size-cells" , &val,sizeof (val)); + } +} +#else +static inline void fixup_device_tree_pmac (void ) { }#endif #ifdef CONFIG_PPC_EFIKA
@@ -3189,6 +3213,7 @@ static void __init fixup_device_tree(void)fixup_device_tree_maple_memory_controller ();fixup_device_tree_chrp ();fixup_device_tree_pmac (); +fixup_device_tree_pmac64 ();fixup_device_tree_efika ();fixup_device_tree_pasemi (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 725/772 misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parker Newman <[email protected]>
[ Upstream commit 7738a7ab9d12c5371ed97114ee2132d4512e9fd5 ]
Add a quirk similar to eeprom_93xx46 to add an extra clock cycle before reading data from the EEPROM.
The 93Cx6 family of EEPROMs output a "dummy 0 bit" between the writing of the op-code/address from the host to the EEPROM and the reading of the actual data from the EEPROM.
More info can be found on page 6 of the AT93C46 datasheet (linked below). Similar notes are found in other 93xx6 datasheets.
In summary the read operation for a 93Cx6 EEPROM is:
Write to EEPROM: 110[A5-A0] (9 bits)
Read from EEPROM: 0[D15-D0] (17 bits)
Where:
110 is the start bit and READ OpCode [A5-A0] is the address to read from 0 is a "dummy bit" preceding the actual data [D15-D0] is the actual data.
Looking at the READ timing diagrams in the 93Cx6 datasheets the dummy bit should be clocked out on the last address bit clock cycle meaning it should be discarded naturally.
However, depending on the hardware configuration sometimes this dummy bit is not discarded. This is the case with Exar PCI UARTs which require an extra clock cycle between sending the address and reading the data.
Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-5193-SEEPROM-AT93C46D-Datasheet.pdf
--- drivers/misc/eeprom/eeprom_93cx6.c | 10 ++++++++++ include/linux/eeprom_93cx6.h | 11 +++++++++++ 2 files changed, 21 insertions(+)
drivers/misc/eeprom/eeprom_93cx6.c +10 -0
@@ -186,6 +186,11 @@ void eeprom_93cx6_read(struct eeprom_93cx6 *eeprom, const u8 word,eeprom_93cx6_write_bits (eeprom, command,PCI_EEPROM_WIDTH_OPCODE + eeprom->width); +if (has_quirk_extra_read_cycle (eeprom)) { +eeprom_93cx6_pulse_high (eeprom); +eeprom_93cx6_pulse_low (eeprom); + } +/* * Read the requested 16 bits. */
@@ -252,6 +257,11 @@ void eeprom_93cx6_readb(struct eeprom_93cx6 *eeprom, const u8 byte,eeprom_93cx6_write_bits (eeprom, command,PCI_EEPROM_WIDTH_OPCODE + eeprom->width +1 ); +if (has_quirk_extra_read_cycle (eeprom)) { +eeprom_93cx6_pulse_high (eeprom); +eeprom_93cx6_pulse_low (eeprom); + } +/* * Read the requested 8 bits. */
include/linux/eeprom_93cx6.h +11 -0
@@ -11,6 +11,8 @@Supported chipsets: 93c46, 93c56 and 93c66. */ +#include <linux/bits.h> +/* * EEPROM operation defines. */
@@ -34,6 +36,7 @@* @register_write(struct eeprom_93cx6 *eeprom): handler to * write to the eeprom register by using all reg_* fields. * @width: eeprom width, should be one of the PCI_EEPROM_WIDTH_* defines +* @quirks: eeprom or controller quirks * @drive_data: Set if we're driving the data line. * @reg_data_in: register field to indicate data input * @reg_data_out: register field to indicate data output
@@ -50,6 +53,9 @@ struct eeprom_93cx6 {void (*register_write)(struct eeprom_93cx6 *eeprom);int width; +unsigned int quirks; +/* Some EEPROMs require an extra clock cycle before reading */ +#define PCI_EEPROM_QUIRK_EXTRA_READ_CYCLE BIT(0)char drive_data;char reg_data_in;
@@ -71,3 +77,8 @@ extern void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable);extern void eeprom_93cx6_write (struct eeprom_93cx6 *eeprom,u8 addr,u16 data); + +static inline bool has_quirk_extra_read_cycle (struct eeprom_93cx6 *eeprom) +{ +return eeprom->quirks &PCI_EEPROM_QUIRK_EXTRA_READ_CYCLE ; +}
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 726/772 rtc: cmos: avoid taking rtc_lock for extended period of time
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
[ Upstream commit 0a6efab33eab4e973db26d9f90c3e97a7a82e399 ]
On my device reading entirety of /sys/devices/pnp0/00:03/cmos_nvram0/nvmem takes about 9 msec during which time interrupts are off on the CPU that does the read and the thread that performs the read can not be migrated or preempted by another higher priority thread (RT or not).
Allow readers and writers be preempted by taking and releasing rtc_lock spinlock for each individual byte read or written rather than once per read/write request.
--- drivers/rtc/rtc-cmos.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/rtc/rtc-cmos.c +15 -16
@@ -645,18 +645,17 @@ static int cmos_nvram_read(void *priv, unsigned int off, void *val,unsigned char *buf = val; off +=NVRAM_OFFSET ; -spin_lock_irq (&rtc_lock); -for (; count; count--, off++) { +for (; count; count--, off++, buf++) { +guard (spinlock_irq)(&rtc_lock);if (off <128 ) - *buf++ =CMOS_READ (off); + *buf =CMOS_READ (off);else if (can_bank2) - *buf++ =cmos_read_bank2 (off); + *buf =cmos_read_bank2 (off);else -break ; +return -EIO ; } -spin_unlock_irq (&rtc_lock); -return count ? -EIO :0 ; +return 0 ; } static int cmos_nvram_write(void *priv, unsigned int off, void *val,
@@ -671,23 +670,23 @@ static int cmos_nvram_write(void *priv, unsigned int off, void *val,* NVRAM to update, updating checksums is also part of its job. */ off +=NVRAM_OFFSET ; -spin_lock_irq (&rtc_lock); -for (; count; count--, off++) { +for (; count; count--, off++, buf++) {/* don't trash RTC registers */ if (off == cmos->day_alrm || off == cmos->mon_alrm || off == cmos->century) - buf++; -else if (off <128 ) -CMOS_WRITE (*buf++, off); +continue ; + +guard (spinlock_irq)(&rtc_lock); +if (off <128 ) +CMOS_WRITE (*buf, off);else if (can_bank2) -cmos_write_bank2 (*buf++, off); +cmos_write_bank2 (*buf, off);else -break ; +return -EIO ; } -spin_unlock_irq (&rtc_lock); -return count ? -EIO :0 ; +return 0 ; }/*----------------------------------------------------------------*/
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 727/772 serial: 8250_dw: Add Sophgo SG2044 quirk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit cad4dda82c7eedcfc22597267e710ccbcf39d572 ]
SG2044 relys on an internal divisor when calculating bitrate, which means a wrong clock for the most common bitrates. So add a quirk for this uart device to skip the set rate call and only relys on the internal UART divisor.
--- drivers/tty/serial/8250/8250_dw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_dw.c +3 -2
@@ -770,7 +770,7 @@ static const struct dw8250_platform_data dw8250_renesas_rzn1_data = { .quirks = DW_UART_QUIRK_IS_DMA_FC, }; -static const struct dw8250_platform_data dw8250_starfive_jh7100_data = { +static const struct dw8250_platform_data dw8250_skip_set_rate_data = { .usr_reg =DW_UART_USR , .quirks =DW_UART_QUIRK_SKIP_SET_RATE , };
@@ -780,7 +780,8 @@ static const struct of_device_id dw8250_of_match[] = { { .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data }, { .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data }, { .compatible = "renesas,rzn1-uart", .data = &dw8250_renesas_rzn1_data }, - { .compatible = "starfive,jh7100-uart", .data = &dw8250_starfive_jh7100_data }, + { .compatible = "sophgo,sg2044-uart", .data = &dw8250_skip_set_rate_data }, + { .compatible = "starfive,jh7100-uart", .data = &dw8250_skip_set_rate_data }, {/* Sentinel */ } };MODULE_DEVICE_TABLE (of, dw8250_of_match);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 728/772 io_uring/tctx: work around xa_store() allocation error issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit 7eb75ce7527129d7f1fee6951566af409a37a1c4 ]
syzbot triggered the following WARN_ON:
WARNING: CPU: 0 PID: 16 at io_uring/tctx.c:51 __io_uring_free+0xfa/0x140 io_uring/tctx.c:51
which is the
WARN_ON_ONCE(!xa_empty(&tctx->xa));
sanity check in __io_uring_free() when a io_uring_task is going through its final put. The syzbot test case includes injecting memory allocation failures, and it very much looks like xa_store() can fail one of its memory allocations and end up with ->head being non-NULL even though no entries exist in the xarray.
Until this issue gets sorted out, work around it by attempting to iterate entries in our xarray, and WARN_ON_ONCE() if one is found.
--- io_uring/tctx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
io_uring/tctx.c +12 -1
@@ -47,8 +47,19 @@ static struct io_wq *io_init_wq_offload(struct io_ring_ctx *ctx,void __io_uring_free (struct task_struct *tsk) {struct io_uring_task *tctx = tsk->io_uring; +struct io_tctx_node *node; +unsigned long index; -WARN_ON_ONCE (!xa_empty (&tctx->xa)); +/* +* Fault injection forcing allocation errors in the xa_store() path +* can lead to xa_empty() returning false, even though no actual +* node is stored in the xarray. Until that gets sorted out, attempt +* an iteration here and warn if any entries are found. +*/ +xa_for_each (&tctx->xa, index, node) { +WARN_ON_ONCE (1 ); +break ; + }WARN_ON_ONCE (tctx->io_wq);WARN_ON_ONCE (tctx->cached_refs);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 729/772 kasan: suppress recursive reports for HW_TAGS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Konovalov <[email protected]>
[ Upstream commit c6a690e0c978bda8106e7a489c13323f90b087d0 ]
KASAN suppresses reports for bad accesses done by the KASAN reporting code. The reporting code might access poisoned memory for reporting purposes.
Software KASAN modes do this by suppressing reports during reporting via current->kasan_depth, the same way they suppress reports during accesses to poisoned slab metadata.
Hardware Tag-Based KASAN does not use current->kasan_depth, and instead resets pointer tags for accesses to poisoned memory done by the reporting code.
Despite that, a recursive report can still happen:
1. On hardware with faulty MTE support. This was observed by Weizhao Ouyang on a faulty hardware that caused memory tags to randomly change from time to time.
2. Theoretically, due to a previous MTE-undetected memory corruption.
A recursive report can happen via:
1. Accessing a pointer with a non-reset tag in the reporting code, e.g. slab->slab_cache, which is what Weizhao Ouyang observed.
2. Theoretically, via external non-annotated routines, e.g. stackdepot.
To resolve this issue, resetting tags for all of the pointers in the reporting code and all the used external routines would be impractical.
Instead, disable tag checking done by the CPU for the duration of KASAN reporting for Hardware Tag-Based KASAN.
Without this fix, Hardware Tag-Based KASAN reporting code might deadlock.
Stable-dep-of: e30a0361b851 ("kasan: make report_lock a raw spinlock")
--- mm/kasan/report.c | 59 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 11 deletions(-)
mm/kasan/report.c +48 -11
@@ -73,10 +73,18 @@ static int __init kasan_set_multi_shot(char *str)__setup ("kasan_multi_shot" , kasan_set_multi_shot);/* -* Used to suppress reports within kasan_disable/enable_current() critical -* sections, which are used for marking accesses to slab metadata. +* This function is used to check whether KASAN reports are suppressed for +* software KASAN modes via kasan_disable/enable_current() critical sections. +* +* This is done to avoid: +* 1. False-positive reports when accessing slab metadata, +* 2. Deadlocking when poisoned memory is accessed by the reporting code. +* +* Hardware Tag-Based KASAN instead relies on: +* For #1: Resetting tags via kasan_reset_tag(). +* For #2: Suppression of tag checks via CPU, see report_suppress_start/end(). */ -static bool report_suppressed (void ) +static bool report_suppressed_sw (void ) {#if defined(CONFIG_KASAN_GENERIC ) || defined(CONFIG_KASAN_SW_TAGS )if (current->kasan_depth)
@@ -85,6 +93,30 @@ static bool report_suppressed(void)return false; } +static void report_suppress_start (void ) +{ +#ifdef CONFIG_KASAN_HW_TAGS +/* +* Disable preemption for the duration of printing a KASAN report, as +* hw_suppress_tag_checks_start() disables checks on the current CPU. +*/ +preempt_disable (); +hw_suppress_tag_checks_start (); +#else +kasan_disable_current (); +#endif +} + +static void report_suppress_stop (void ) +{ +#ifdef CONFIG_KASAN_HW_TAGS +hw_suppress_tag_checks_stop (); +preempt_enable (); +#else +kasan_enable_current (); +#endif +} +/* * Used to avoid reporting more than one KASAN bug unless kasan_multi_shot * is enabled. Note that KASAN tests effectively enable kasan_multi_shot
@@ -152,7 +184,7 @@ static void start_report(unsigned long *flags, bool sync)/* Do not allow LOCKDEP mangling KASAN reports. */ lockdep_off ();/* Make sure we don't end up in loop. */ -kasan_disable_current (); +report_suppress_start ();spin_lock_irqsave (&report_lock, *flags);pr_err ("==================================================================\n" ); }
@@ -170,7 +202,7 @@ static void end_report(unsigned long *flags, void *addr)panic ("kasan.fault=panic set ...\n" );add_taint (TAINT_BAD_PAGE ,LOCKDEP_NOW_UNRELIABLE );lockdep_on (); -kasan_enable_current (); +report_suppress_stop (); }static void print_error_description (struct kasan_report_info *info)
@@ -439,9 +471,13 @@ void kasan_report_invalid_free(void *ptr, unsigned long ip, enum kasan_report_tystruct kasan_report_info info;/* -* Do not check report_suppressed(), as an invalid-free cannot be -* caused by accessing slab metadata and thus should not be -* suppressed by kasan_disable/enable_current() critical sections. +* Do not check report_suppressed_sw(), as an invalid-free cannot be +* caused by accessing poisoned memory and thus should not be suppressed +* by kasan_disable/enable_current() critical sections. +* +* Note that for Hardware Tag-Based KASAN, kasan_report_invalid_free() +* is triggered by explicit tag checks and not by the ones performed by +* the CPU. Thus, reporting invalid-free is not suppressed as well. */ if (unlikely (!report_enabled ()))return ;
@@ -476,7 +512,7 @@ bool kasan_report(unsigned long addr, size_t size, bool is_write,unsigned long irq_flags;struct kasan_report_info info; -if (unlikely (report_suppressed ()) ||unlikely (!report_enabled ())) { +if (unlikely (report_suppressed_sw ()) ||unlikely (!report_enabled ())) { ret = false; goto out; }
@@ -508,8 +544,9 @@ void kasan_report_async(void)unsigned long flags;/* -* Do not check report_suppressed(), as kasan_disable/enable_current() -* critical sections do not affect Hardware Tag-Based KASAN. +* Do not check report_suppressed_sw(), as +* kasan_disable/enable_current() critical sections do not affect +* Hardware Tag-Based KASAN. */ if (unlikely (!report_enabled ()))return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 730/772 kasan: make report_lock a raw spinlock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jared Kangas <[email protected]>
[ Upstream commit e30a0361b8515d424c73c67de1a43e45a13b8ba2 ]
If PREEMPT_RT is enabled, report_lock is a sleeping spinlock and must not be locked when IRQs are disabled. However, KASAN reports may be triggered in such contexts. For example:
char *s = kzalloc(1, GFP_KERNEL);
kfree(s);
local_irq_disable();
char c = *s; /* KASAN report here leads to spin_lock() */
local_irq_enable();Make report_spinlock a raw spinlock to prevent rescheduling when PREEMPT_RT is enabled.
--- mm/kasan/report.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/kasan/report.c +3 -3
@@ -173,7 +173,7 @@ static void update_kunit_status(bool sync)static void update_kunit_status (bool sync) { }#endif -static DEFINE_SPINLOCK (report_lock); +static DEFINE_RAW_SPINLOCK (report_lock);static void start_report (unsigned long *flags,bool sync) {
@@ -185,7 +185,7 @@ static void start_report(unsigned long *flags, bool sync)lockdep_off ();/* Make sure we don't end up in loop. */ report_suppress_start (); -spin_lock_irqsave (&report_lock, *flags); +raw_spin_lock_irqsave (&report_lock, *flags);pr_err ("==================================================================\n" ); }
@@ -195,7 +195,7 @@ static void end_report(unsigned long *flags, void *addr)trace_error_report_end (ERROR_DETECTOR_KASAN , (unsigned long )addr);pr_err ("==================================================================\n" ); -spin_unlock_irqrestore (&report_lock, *flags); +raw_spin_unlock_irqrestore (&report_lock, *flags);if (!test_bit (KASAN_BIT_MULTI_SHOT , &kasan_flags))check_panic_on_warn ("KASAN" );if (kasan_arg_fault ==KASAN_ARG_FAULT_PANIC )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 731/772 sched/core: Remove the unnecessary need_resched() check in nohz_csd_func()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <[email protected]>
[ Upstream commit ea9cffc0a154124821531991d5afdd7e8b20d7aa ]
The need_resched() check currently in nohz_csd_func() can be tracked to have been added in scheduler_ipi() back in 2011 via commit ca38062e57e9 ("sched: Use resched IPI to kick off the nohz idle balance")
Since then, it has travelled quite a bit but it seems like an idle_cpu() check currently is sufficient to detect the need to bail out from an idle load balancing. To justify this removal, consider all the following case where an idle load balancing could race with a task wakeup:
o Since commit f3dd3f674555b ("sched: Remove the limitation of WF_ON_CPU on wakelist if wakee cpu is idle") a target perceived to be idle (target_rq->nr_running == 0) will return true for ttwu_queue_cond(target) which will offload the task wakeup to the idle target via an IPI.
In all such cases target_rq->ttwu_pending will be set to 1 before queuing the wake function.
If an idle load balance races here, following scenarios are possible:
- The CPU is not in TIF_POLLING_NRFLAG mode in which case an actual IPI is sent to the CPU to wake it out of idle. If the nohz_csd_func() queues before sched_ttwu_pending(), the idle load balance will bail out since idle_cpu(target) returns 0 since target_rq->ttwu_pending is 1. If the nohz_csd_func() is queued after sched_ttwu_pending() it should see rq->nr_running to be non-zero and bail out of idle load balancing.
- The CPU is in TIF_POLLING_NRFLAG mode and instead of an actual IPI, the sender will simply set TIF_NEED_RESCHED for the target to put it out of idle and flush_smp_call_function_queue() in do_idle() will execute the call function. Depending on the ordering of the queuing of nohz_csd_func() and sched_ttwu_pending(), the idle_cpu() check in nohz_csd_func() should either see target_rq->ttwu_pending = 1 or target_rq->nr_running to be non-zero if there is a genuine task wakeup racing with the idle load balance kick.
o The waker CPU perceives the target CPU to be busy (targer_rq->nr_running != 0) but the CPU is in fact going idle and due to a series of unfortunate events, the system reaches a case where the waker CPU decides to perform the wakeup by itself in ttwu_queue() on the target CPU but target is concurrently selected for idle load balance (XXX: Can this happen? I'm not sure, but we'll consider the mother of all coincidences to estimate the worst case scenario).
ttwu_do_activate() calls enqueue_task() which would increment "rq->nr_running" post which it calls wakeup_preempt() which is responsible for setting TIF_NEED_RESCHED (via a resched IPI or by setting TIF_NEED_RESCHED on a TIF_POLLING_NRFLAG idle CPU) The key thing to note in this case is that rq->nr_running is already non-zero in case of a wakeup before TIF_NEED_RESCHED is set which would lead to idle_cpu() check returning false.
In all cases, it seems that need_resched() check is unnecessary when checking for idle_cpu() first since an impending wakeup racing with idle load balancer will either set the "rq->ttwu_pending" or indicate a newly woken task via "rq->nr_running".
Chasing the reason why this check might have existed in the first place, I came across Peter's suggestion on the fist iteration of Suresh's patch from 2011 [1] where the condition to raise the SCHED_SOFTIRQ was:
sched_ttwu_do_pending(list); if (unlikely((rq->idle == current) && rq->nohz_balance_kick && !need_resched())) raise_softirq_irqoff(SCHED_SOFTIRQ);
Since the condition to raise the SCHED_SOFIRQ was preceded by sched_ttwu_do_pending() (which is equivalent of sched_ttwu_pending()) in the current upstream kernel, the need_resched() check was necessary to catch a newly queued task. Peter suggested modifying it to:
if (idle_cpu() && rq->nohz_balance_kick && !need_resched()) raise_softirq_irqoff(SCHED_SOFTIRQ);
where idle_cpu() seems to have replaced "rq->idle == current" check.
Even back then, the idle_cpu() check would have been sufficient to catch a new task being enqueued. Since commit b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") overloads the interpretation of TIF_NEED_RESCHED for TIF_POLLING_NRFLAG idling, remove the need_resched() check in nohz_csd_func() to raise SCHED_SOFTIRQ based on Peter's suggestion.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -1162,7 +1162,7 @@ static void nohz_csd_func(void *info)WARN_ON (!(flags &NOHZ_KICK_MASK )); rq->idle_balance =idle_cpu (cpu); -if (rq->idle_balance && !need_resched ()) { +if (rq->idle_balance) { rq->nohz_idle_balance = flags;raise_softirq_irqoff (SCHED_SOFTIRQ ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 732/772 sched/fair: Check idle_cpu() before need_resched() to detect ilb CPU turning busy
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <[email protected]>
[ Upstream commit ff47a0acfcce309cf9e175149c75614491953c8f ]
Commit b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") optimizes IPIs to idle CPUs in TIF_POLLING_NRFLAG mode by setting the TIF_NEED_RESCHED flag in idle task's thread info and relying on flush_smp_call_function_queue() in idle exit path to run the call-function. A softirq raised by the call-function is handled shortly after in do_softirq_post_smp_call_flush() but the TIF_NEED_RESCHED flag remains set and is only cleared later when schedule_idle() calls __schedule().
need_resched() check in _nohz_idle_balance() exists to bail out of load balancing if another task has woken up on the CPU currently in-charge of idle load balancing which is being processed in SCHED_SOFTIRQ context. Since the optimization mentioned above overloads the interpretation of TIF_NEED_RESCHED, check for idle_cpu() before going with the existing need_resched() check which can catch a genuine task wakeup on an idle CPU processing SCHED_SOFTIRQ from do_softirq_post_smp_call_flush(), as well as the case where ksoftirqd needs to be preempted as a result of new task wakeup or slice expiry.
In case of PREEMPT_RT or threadirqs, although the idle load balancing may be inhibited in some cases on the ilb CPU, the fact that ksoftirqd is the only fair task going back to sleep will trigger a newidle balance on the CPU which will alleviate some imbalance if it exists if idle balance fails to do so.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -11401,7 +11401,7 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags)* work being done for other CPUs. Next load * balancing owner will pick it up. */ -if (need_resched ()) { +if (!idle_cpu (this_cpu) &&need_resched ()) {if (flags &NOHZ_STATS_KICK ) has_blocked_load = true;if (flags &NOHZ_NEXT_KICK )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 733/772 sched/core: Prevent wakeup of ksoftirqd during idle load balance
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <[email protected]>
[ Upstream commit e932c4ab38f072ce5894b2851fea8bc5754bb8e5 ]
Scheduler raises a SCHED_SOFTIRQ to trigger a load balancing event on from the IPI handler on the idle CPU. If the SMP function is invoked from an idle CPU via flush_smp_call_function_queue() then the HARD-IRQ flag is not set and raise_softirq_irqoff() needlessly wakes ksoftirqd because soft interrupts are handled before ksoftirqd get on the CPU.
Adding a trace_printk() in nohz_csd_func() at the spot of raising SCHED_SOFTIRQ and enabling trace events for sched_switch, sched_wakeup, and softirq_entry (for SCHED_SOFTIRQ vector alone) helps observing the current behavior:
<idle>-0 [000] dN.1.: nohz_csd_func: Raising SCHED_SOFTIRQ from nohz_csd_func
<idle>-0 [000] dN.4.: sched_wakeup: comm=ksoftirqd/0 pid=16 prio=120 target_cpu=000
<idle>-0 [000] .Ns1.: softirq_entry: vec=7 [action=SCHED]
<idle>-0 [000] .Ns1.: softirq_exit: vec=7 [action=SCHED]
<idle>-0 [000] d..2.: sched_switch: prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=ksoftirqd/0 next_pid=16 next_prio=120
ksoftirqd/0-16 [000] d..2.: sched_switch: prev_comm=ksoftirqd/0 prev_pid=16 prev_prio=120 prev_state=S ==> next_comm=swapper/0 next_pid=0 next_prio=120
...Use __raise_softirq_irqoff() to raise the softirq. The SMP function call is always invoked on the requested CPU in an interrupt handler. It is guaranteed that soft interrupts are handled at the end.
Following are the observations with the changes when enabling the same set of events:
<idle>-0 [000] dN.1.: nohz_csd_func: Raising SCHED_SOFTIRQ for nohz_idle_balance
<idle>-0 [000] dN.1.: softirq_raise: vec=7 [action=SCHED]
<idle>-0 [000] .Ns1.: softirq_entry: vec=7 [action=SCHED]No unnecessary ksoftirqd wakeups are seen from idle task's context to service the softirq.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -1164,7 +1164,7 @@ static void nohz_csd_func(void *info) rq->idle_balance =idle_cpu (cpu);if (rq->idle_balance) { rq->nohz_idle_balance = flags; -raise_softirq_irqoff (SCHED_SOFTIRQ ); +__raise_softirq_irqoff (SCHED_SOFTIRQ ); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 734/772 btrfs: fix missing snapshot drew unlock when root is dead during swap activation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 9c803c474c6c002d8ade68ebe99026cc39c37f85 ]
When activating a swap file we acquire the root's snapshot drew lock and then check if the root is dead, failing and returning with -EPERM if it's dead but without unlocking the root's snapshot lock. Fix this by adding the missing unlock.
--- fs/btrfs/inode.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/inode.c +1 -0
@@ -11228,6 +11228,7 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,if (btrfs_root_dead (root)) {spin_unlock (&root->root_item_lock); +btrfs_drew_write_unlock (&root->snapshot_lock);btrfs_exclop_finish (fs_info); btrfs_warn(fs_info, "cannot activate swapfile because subvolume %llu is being deleted",
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 735/772 tracing/eprobe: Fix to release eprobe when failed to add dyn_event
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 494b332064c0ce2f7392fa92632bc50191c1b517 ]
Fix eprobe event to unregister event call and release eprobe when it fails to add dynamic event correctly.
--- kernel/trace/trace_eprobe.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/trace/trace_eprobe.c +5 -0
@@ -1069,6 +1069,11 @@ static int __trace_eprobe_create(int argc, const char *argv[]) goto error; } ret =dyn_event_add (&ep->devent, &ep->tp.event->call); +if (ret <0 ) { +trace_probe_unregister_event_call (&ep->tp); +mutex_unlock (&event_mutex); + goto error; + }mutex_unlock (&event_mutex);return ret; parse_error:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 736/772 Revert "unicode: Dont special case ignorable code points"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit 231825b2e1ff6ba799c5eaf396d3ab2354e37c6b ]
This reverts commit 5c26d2f1d3f5e4be3e196526bead29ecb139cf91.
It turns out that we can't do this, because while the old behavior of ignoring ignorable code points was most definitely wrong, we have case-folding filesystems with on-disk hash values with that wrong behavior.
So now you can't look up those names, because they hash to something different.
Of course, it's also entirely possible that in the meantime people have created *new* files with the new ("more correct") case folding logic, and reverting will just make other things break.
The correct solution is to not do case folding in filesystems, but sadly, people seem to never really understand that. People still see it as a feature, not a bug.
--- fs/unicode/mkutf8data.c | 70 + fs/unicode/utf8data.c_shipped | 6703 +++++++++++++++++---------------- 2 files changed, 3427 insertions(+), 3346 deletions(-)
fs/unicode/mkutf8data.c +70 -0
@@ -2230,6 +2230,75 @@ static void nfdicf_init(void)file_fail (fold_name); } +static void ignore_init (void ) +{ +FILE *file; +unsigned int unichar; +unsigned int first; +unsigned int last; +unsigned int *um; +int count; +int ret; + +if (verbose >0 ) +printf ("Parsing %s\n" , prop_name); + file =fopen (prop_name,"r" ); +if (!file) +open_fail (prop_name, errno); +assert (file); + count =0 ; +while (fgets (line,LINESIZE , file)) { + ret =sscanf (line,"%X..%X ; %s # " , &first, &last, buf0); +if (ret ==3 ) { +if (strcmp (buf0,"Default_Ignorable_Code_Point" )) +continue ; +if (!utf32valid (first) || !utf32valid (last)) +line_fail (prop_name, line); +for (unichar = first; unichar <= last; unichar++) { +free (unicode_data[unichar].utf32nfdi); + um =malloc (sizeof (unsigned int )); + *um =0 ; + unicode_data[unichar].utf32nfdi = um; +free (unicode_data[unichar].utf32nfdicf); + um =malloc (sizeof (unsigned int )); + *um =0 ; + unicode_data[unichar].utf32nfdicf = um; + count++; + } +if (verbose >1 ) +printf (" %X..%X Default_Ignorable_Code_Point\n" , + first, last); +continue ; + } + ret =sscanf (line,"%X ; %s # " , &unichar, buf0); +if (ret ==2 ) { +if (strcmp (buf0,"Default_Ignorable_Code_Point" )) +continue ; +if (!utf32valid (unichar)) +line_fail (prop_name, line); +free (unicode_data[unichar].utf32nfdi); + um =malloc (sizeof (unsigned int )); + *um =0 ; + unicode_data[unichar].utf32nfdi = um; +free (unicode_data[unichar].utf32nfdicf); + um =malloc (sizeof (unsigned int )); + *um =0 ; + unicode_data[unichar].utf32nfdicf = um; +if (verbose >1 ) +printf (" %X Default_Ignorable_Code_Point\n" , + unichar); + count++; +continue ; + } + } +fclose (file); + +if (verbose >0 ) +printf ("Found %d entries\n" , count); +if (count ==0 ) +file_fail (prop_name); +} +static void corrections_init (void ) {FILE *file;
@@ -3341,6 +3410,7 @@ int main(int argc, char *argv[])ccc_init ();nfdi_init ();nfdicf_init (); +ignore_init ();corrections_init ();hangul_decompose ();nfdi_decompose ();
fs/unicode/utf8data.c_shipped +3357 -3346
2,918 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.0
Part of the diff is not shown here. View the raw message.
Greg Kroah-Hartman
maintainerPATCH 737/772 vfio/mlx5: Align the page tracking max message size with the device capability
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
[ Upstream commit 9c7c5430bca36e9636eabbba0b3b53251479c7ab ]
Align the page tracking maximum message size with the device's capability instead of relying on PAGE_SIZE.
This adjustment resolves a mismatch on systems where PAGE_SIZE is 64K, but the firmware only supports a maximum message size of 4K.
Now that we rely on the device's capability for max_message_size, we must account for potential future increases in its value.
Key considerations include:
- Supporting message sizes that exceed a single system page (e.g., an 8K message on a 4K system).
- Ensuring the RQ size is adjusted to accommodate at least 4 WQEs/messages, in line with the device specification.
The above has been addressed as part of the patch.
--- drivers/vfio/pci/mlx5/cmd.c | 47 +++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 12 deletions(-)
drivers/vfio/pci/mlx5/cmd.c +35 -12
@@ -1106,7 +1106,8 @@ int mlx5vf_start_page_tracker(struct vfio_device *vdev,struct mlx5_vhca_qp *host_qp;struct mlx5_vhca_qp *fw_qp;struct mlx5_core_dev *mdev; -u32 max_msg_size =PAGE_SIZE ; +u32 log_max_msg_size; +u32 max_msg_size;u64 rq_size =SZ_2M ;u32 max_recv_wr;int err;
@@ -1123,6 +1124,12 @@ int mlx5vf_start_page_tracker(struct vfio_device *vdev, } mdev = mvdev->mdev; + log_max_msg_size =MLX5_CAP_ADV_VIRTUALIZATION (mdev, pg_track_log_max_msg_size); + max_msg_size = (1ULL << log_max_msg_size); +/* The RQ must hold at least 4 WQEs/messages for successful QP creation */ +if (rq_size <4 * max_msg_size) + rq_size =4 * max_msg_size; +memset (tracker,0 ,sizeof (*tracker)); tracker->uar =mlx5_get_uars_page (mdev);if (IS_ERR (tracker->uar)) {
@@ -1212,25 +1219,41 @@ set_report_output(u32 size, int index, struct mlx5_vhca_qp *qp, {u32 entry_size =MLX5_ST_SZ_BYTES (page_track_report_entry);u32 nent = size / entry_size; +u32 nent_in_page; +u32 nent_to_set;struct page *page; +u32 page_offset; +u32 page_index; +u32 buf_offset; +void *kaddr;u64 addr;u64 *buf;int i; -if (WARN_ON (index >= qp->recv_buf.npages || + buf_offset = index * qp->max_msg_size; +if (WARN_ON (buf_offset + size >= qp->recv_buf.npages *PAGE_SIZE || (nent > qp->max_msg_size / entry_size)))return ; - page = qp->recv_buf.page_list[index]; - buf =kmap_local_page (page); -for (i =0 ; i < nent; i++) { - addr =MLX5_GET (page_track_report_entry, buf + i, - dirty_address_low); - addr |= (u64 )MLX5_GET (page_track_report_entry, buf + i, - dirty_address_high) <<32 ; -iova_bitmap_set (dirty, addr, qp->tracked_page_size); - } -kunmap_local (buf); +do { + page_index = buf_offset /PAGE_SIZE ; + page_offset = buf_offset %PAGE_SIZE ; + nent_in_page = (PAGE_SIZE - page_offset) / entry_size; + page = qp->recv_buf.page_list[page_index]; + kaddr =kmap_local_page (page); + buf = kaddr + page_offset; + nent_to_set =min (nent, nent_in_page); +for (i =0 ; i < nent_to_set; i++) { + addr =MLX5_GET (page_track_report_entry, buf + i, + dirty_address_low); + addr |= (u64 )MLX5_GET (page_track_report_entry, buf + i, + dirty_address_high) <<32 ; +iova_bitmap_set (dirty, addr, qp->tracked_page_size); + } +kunmap_local (kaddr); + buf_offset += (nent_to_set * entry_size); + nent -= nent_to_set; + }while (nent); } static void
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 738/772 udf: Fold udf_getblk() into udf_bread()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 32f123a3f34283f9c6446de87861696f0502b02e upstream.
udf_getblk() has a single call site. Fold it there.
[acsjakub: backport-adjusting changes
udf_getblk() has changed between 6.1 and the backported commit, namely in commit 541e047b14c8 ("udf: Use udf_map_block() in udf_getblk()") Backport using the form of udf_getblk present in 6.1., that means use udf_get_block() instead of udf_map_block() and use dummy in buffer_new() and buffer_mapped(). ]
--- fs/udf/inode.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-)
fs/udf/inode.c +21 -25
@@ -369,29 +369,6 @@ abort:return err; } -static struct buffer_head *udf_getblk (struct inode *inode,udf_pblk_t block, -int create,int *err) -{ -struct buffer_head *bh; -struct buffer_head dummy; - - dummy.b_state =0 ; - dummy.b_blocknr =-1000 ; - *err =udf_get_block (inode, block, &dummy, create); -if (!*err &&buffer_mapped (&dummy)) { - bh =sb_getblk (inode->i_sb, dummy.b_blocknr); -if (buffer_new (&dummy)) { -lock_buffer (bh); -memset (bh->b_data,0x00 , inode->i_sb->s_blocksize); -set_buffer_uptodate (bh); -unlock_buffer (bh); -mark_buffer_dirty_inode (bh, inode); - } -return bh; - } - -return NULL ; -}/* Extend the file with new blocks totaling 'new_block_bytes', * return the number of extents added
@@ -1108,11 +1085,30 @@ struct buffer_head *udf_bread(struct ino int create, int *err) { struct buffer_head *bh = NULL; +struct buffer_head dummy; + + dummy.b_state =0 ; + dummy.b_blocknr =-1000 ; - bh =udf_getblk (inode, block, create, err); -if (!bh) + *err =udf_get_block (inode, block, &dummy, create); +if (*err || !buffer_mapped (&dummy))return NULL ; + bh =sb_getblk (inode->i_sb, dummy.b_blocknr); +if (!bh) { + *err = -ENOMEM ; +return NULL ; + } + +if (buffer_new (&dummy)) { +lock_buffer (bh); +memset (bh->b_data,0x00 , inode->i_sb->s_blocksize); +set_buffer_uptodate (bh); +unlock_buffer (bh); +mark_buffer_dirty_inode (bh, inode); +return bh; + } +if (bh_read (bh,0 ) >=0 )return bh;
Greg Kroah-Hartman
maintainerPATCH 739/772 KVM: arm64: vgic-its: Add a data length check in vgic_its_save_*
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jing Zhang <[email protected]>
commit 7fe28d7e68f92cc3d0668b8f2fbdf5c303ac3022 upstream.
In all the vgic_its_save_*() functinos, they do not check whether the data length is 8 bytes before calling vgic_write_guest_lock. This patch adds the check. To prevent the kernel from being blown up when the fault occurs, KVM_BUG_ON() is used. And the other BUG_ON()s are replaced together.
--- arch/arm64/kvm/vgic/vgic-its.c | 20 ++++++++------------ arch/arm64/kvm/vgic/vgic.h | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-)
arch/arm64/kvm/vgic/vgic-its.c +8 -12
@@ -2207,7 +2207,6 @@ static int scan_its_table(struct vgic_itstatic int vgic_its_save_ite (struct vgic_its *its,struct its_device *dev,struct its_ite *ite,gpa_t gpa,int ite_esz) { -struct kvm *kvm = its->dev->kvm;u32 next_offset;u64 val;
@@ -2216,7 +2215,8 @@ static int vgic_its_save_ite(struct vgic ((u64 )ite->irq->intid <<KVM_ITS_ITE_PINTID_SHIFT ) | ite->collection->collection_id; val =cpu_to_le64 (val); -return kvm_write_guest_lock (kvm, gpa, &val, ite_esz); + +return vgic_its_write_entry_lock (its, gpa, val, ite_esz); }/**
@@ -2357,7 +2357,6 @@ static int vgic_its_restore_itt(struct vstatic int vgic_its_save_dte (struct vgic_its *its,struct its_device *dev,gpa_t ptr,int dte_esz) { -struct kvm *kvm = its->dev->kvm;u64 val, itt_addr_field;u32 next_offset;
@@ -2368,7 +2367,8 @@ static int vgic_its_save_dte(struct vgic (itt_addr_field <<KVM_ITS_DTE_ITTADDR_SHIFT ) | (dev->num_eventid_bits - 1)); val =cpu_to_le64 (val); -return kvm_write_guest_lock (kvm, ptr, &val, dte_esz); + +return vgic_its_write_entry_lock (its, ptr, val, dte_esz); }/**
@@ -2555,7 +2555,8 @@ static int vgic_its_save_cte(struct vgic ((u64 )collection->target_addr <<KVM_ITS_CTE_RDBASE_SHIFT ) | collection->collection_id); val =cpu_to_le64 (val); -return kvm_write_guest_lock (its->dev->kvm, gpa, &val, esz); + +return vgic_its_write_entry_lock (its, gpa, val, esz); }/*
@@ -2571,8 +2572,7 @@ static int vgic_its_restore_cte(struct vu64 val;int ret; -BUG_ON (esz >sizeof (val)); - ret =kvm_read_guest_lock (kvm, gpa, &val, esz); + ret =vgic_its_read_entry_lock (its, gpa, &val, esz);if (ret)return ret; val =le64_to_cpu (val);
@@ -2610,7 +2610,6 @@ static int vgic_its_save_collection_tablu64 baser = its->baser_coll_table;gpa_t gpa =GITS_BASER_ADDR_48_to_52 (baser);struct its_collection *collection; -u64 val;size_t max_size, filled =0 ;int ret, cte_esz = abi->cte_esz;
@@ -2634,10 +2633,7 @@ static int vgic_its_save_collection_tabl* table is not fully filled, add a last dummy element * with valid bit unset */ - val =0 ; -BUG_ON (cte_esz >sizeof (val)); - ret =kvm_write_guest_lock (its->dev->kvm, gpa, &val, cte_esz); -return ret; +return vgic_its_write_entry_lock (its, gpa,0 , cte_esz); }/**
arch/arm64/kvm/vgic/vgic.h +24 -0
@@ -6,6 +6,7 @@#define __KVM_ARM_VGIC_NEW_H__#include <linux/irqchip/arm-gic-common.h> +#include <asm/kvm_mmu.h> #define PRODUCT_ID_KVM 0x4b/* ASCII code K */ #define IMPLEMENTER_ARM 0x43b
@@ -131,6 +132,29 @@ static inline bool vgic_irq_is_multi_sgireturn vgic_irq_get_lr_count (irq) >1 ; } +static inline int vgic_its_read_entry_lock (struct vgic_its *its,gpa_t eaddr, +u64 *eval,unsigned long esize) +{ +struct kvm *kvm = its->dev->kvm; + +if (KVM_BUG_ON (esize !=sizeof (*eval), kvm)) +return -EINVAL ; + +return kvm_read_guest_lock (kvm, eaddr, eval, esize); + +} + +static inline int vgic_its_write_entry_lock (struct vgic_its *its,gpa_t eaddr, +u64 eval,unsigned long esize) +{ +struct kvm *kvm = its->dev->kvm; + +if (KVM_BUG_ON (esize !=sizeof (eval), kvm)) +return -EINVAL ; + +return kvm_write_guest_lock (kvm, eaddr, &eval, esize); +} +/* * This struct provides an intermediate representation of the fields contained * in the GICH_VMCR and ICH_VMCR registers, such that code exporting the GIC
Greg Kroah-Hartman
maintainerPATCH 740/772 KVM: arm64: vgic-its: Clear DTE when MAPD unmaps a device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunkun Jiang <[email protected]>
commit e9649129d33dca561305fc590a7c4ba8c3e5675a upstream.
vgic_its_save_device_tables will traverse its->device_list to save DTE for each device. vgic_its_restore_device_tables will traverse each entry of device table and check if it is valid. Restore if valid.
But when MAPD unmaps a device, it does not invalidate the corresponding DTE. In the scenario of continuous saves and restores, there may be a situation where a device's DTE is not saved but is restored. This is unreasonable and may cause restore to fail. This patch clears the corresponding DTE when MAPD unmaps a device.
--- arch/arm64/kvm/vgic/vgic-its.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm64/kvm/vgic/vgic-its.c +4 -2
@@ -1211,9 +1211,11 @@ static int vgic_its_cmd_handle_mapd(strubool valid =its_cmd_get_validbit (its_cmd);u8 num_eventid_bits =its_cmd_get_size (its_cmd);gpa_t itt_addr =its_cmd_get_ittaddr (its_cmd); +int dte_esz =vgic_its_get_abi (its)->dte_esz;struct its_device *device; +gpa_t gpa; -if (!vgic_its_check_id (its, its->baser_device_table, device_id,NULL )) +if (!vgic_its_check_id (its, its->baser_device_table, device_id, &gpa))return E_ITS_MAPD_DEVICE_OOR ;if (valid && num_eventid_bits >VITS_TYPER_IDBITS )
@@ -1234,7 +1236,7 @@ static int vgic_its_cmd_handle_mapd(stru* is an error, so we are done in any case. */ if (!valid) -return 0 ; +return vgic_its_write_entry_lock (its, gpa,0 , dte_esz); device =vgic_its_alloc_device (its, device_id, itt_addr, num_eventid_bits);
Greg Kroah-Hartman
maintainerPATCH 741/772 KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunkun Jiang <[email protected]>
commit 7602ffd1d5e8927fadd5187cb4aed2fdc9c47143 upstream.
When DISCARD frees an ITE, it does not invalidate the corresponding ITE. In the scenario of continuous saves and restores, there may be a situation where an ITE is not saved but is restored. This is unreasonable and may cause restore to fail. This patch clears the corresponding ITE when DISCARD frees an ITE.
--- arch/arm64/kvm/vgic/vgic-its.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm64/kvm/vgic/vgic-its.c +5 -1
@@ -855,6 +855,9 @@ static int vgic_its_cmd_handle_discard(s ite =find_ite (its, device_id, event_id);if (ite &&its_is_collection_mapped (ite->collection)) { +struct its_device *device =find_its_device (its, device_id); +int ite_esz =vgic_its_get_abi (its)->ite_esz; +gpa_t gpa = device->itt_addr + ite->event_id * ite_esz;/* * Though the spec talks about removing the pending state, we * don't bother here since we clear the ITTE anyway and the
@@ -863,7 +866,8 @@ static int vgic_its_cmd_handle_discard(svgic_its_invalidate_cache (kvm);its_free_ite (kvm, ite); -return 0 ; + +return vgic_its_write_entry_lock (its, gpa,0 , ite_esz); }return E_ITS_DISCARD_UNMAPPED_INTERRUPT ;
Greg Kroah-Hartman
maintainerPATCH 742/772 KVM: x86/mmu: Ensure that kvm_release_pfn_clean() takes exact pfn from kvm_faultin_pfn()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Kuratov <[email protected]>
Since 5.16 and prior to 6.13 KVM can't be used with FSDAX guest memory (PMD pages). To reproduce the issue you need to reserve guest memory with memmap= cmdline, create and mount FS in DAX mode (tested both XFS and ext4), see doc link below. ndctl command for test:
ndctl create-namespace -v -e namespace1.0 --map=dev --mode=fsdax -a 2M Then pass memory object to qemu like:
-m 8G -object memory-backend-file,id=ram0,size=8G,\
mem-path=/mnt/pmem/guestmem,share=on,prealloc=on,dump=off,align=2097152 \
-numa node,memdev=ram0,cpus=0-1
QEMU fails to run guest with error: kvm run failed Bad address and there are two warnings in dmesg:
WARN_ON_ONCE(!page_count(page)) in kvm_is_zone_device_page() and WARN_ON_ONCE(folio_ref_count(folio) <= 0) in try_grab_folio() (v6.6.63)
It looks like in the past assumption was made that pfn won't change from faultin_pfn() to release_pfn_clean(), e.g. see
commit 4cd071d13c5c ("KVM: x86/mmu: Move calls to thp_adjust() down a level") But kvm_page_fault structure made pfn part of mutable state, so now release_pfn_clean() can take hugepage-adjusted pfn.
And it works for all cases (/dev/shm, hugetlb, devdax) except fsdax. Apparently in fsdax mode faultin-pfn and adjusted-pfn may refer to different folios, so we're getting get_page/put_page imbalance.
To solve this preserve faultin pfn in separate local variable and pass it in kvm_release_pfn_clean().
Patch tested for all mentioned guest memory backends with tdp_mmu={0,1}.
No bug in upstream as it was solved fundamentally by
commit 8dd861cc07e2 ("KVM: x86/mmu: Put refcounted pages instead of blindly releasing pfns") and related patch series.
--- arch/x86/kvm/mmu/mmu.c | 5 ++++- arch/x86/kvm/mmu/paging_tmpl.h | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
arch/x86/kvm/mmu/mmu.c +4 -1
@@ -4245,6 +4245,7 @@ static int direct_page_fault(struct kvm_bool is_tdp_mmu_fault =is_tdp_mmu (vcpu->arch.mmu);unsigned long mmu_seq; +kvm_pfn_t orig_pfn;int r; fault->gfn = fault->addr >>PAGE_SHIFT ;
@@ -4272,6 +4273,8 @@ static int direct_page_fault(struct kvm_if (r !=RET_PF_CONTINUE )return r; + orig_pfn = fault->pfn; + r =RET_PF_RETRY ;if (is_tdp_mmu_fault)
@@ -4296,7 +4299,7 @@ out_unlock:read_unlock (&vcpu->kvm->mmu_lock); else write_unlock(&vcpu->kvm->mmu_lock); -kvm_release_pfn_clean (fault->pfn); +kvm_release_pfn_clean (orig_pfn);return r; }
arch/x86/kvm/mmu/paging_tmpl.h +4 -1
@@ -790,6 +790,7 @@ FNAME(is_self_change_mapping)(struct kvmstatic int FNAME (page_fault )(struct kvm_vcpu *vcpu,struct kvm_page_fault *fault) {struct guest_walker walker; +kvm_pfn_t orig_pfn;int r;unsigned long mmu_seq;bool is_self_change_mapping;
@@ -868,6 +869,8 @@ static int FNAME(page_fault)(struct kvm_ walker.pte_access &= ~ACC_EXEC_MASK ; } + orig_pfn = fault->pfn; + r =RET_PF_RETRY ;write_lock (&vcpu->kvm->mmu_lock);
@@ -881,7 +884,7 @@ static int FNAME(page_fault)(struct kvm_ out_unlock:write_unlock (&vcpu->kvm->mmu_lock); -kvm_release_pfn_clean (fault->pfn); +kvm_release_pfn_clean (orig_pfn);return r; }
Greg Kroah-Hartman
maintainerPATCH 743/772 jffs2: Prevent rtime decompress memory corruption
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kinsey Moore <[email protected]>
commit fe051552f5078fa02d593847529a3884305a6ffe upstream.
The rtime decompression routine does not fully check bounds during the entirety of the decompression pass and can corrupt memory outside the decompression buffer if the compressed data is corrupted. This adds the required check to prevent this failure mode.
--- fs/jffs2/compr_rtime.c | 3 +++ 1 file changed, 3 insertions(+)
fs/jffs2/compr_rtime.c +3 -0
@@ -95,6 +95,9 @@ static int jffs2_rtime_decompress(unsign positions[value]=outpos;if (repeat) { +if ((outpos + repeat) >= destlen) { +return 1 ; + }if (backoffs + repeat >= outpos) {while (repeat) { cpage_out[outpos++] = cpage_out[backoffs++];
Greg Kroah-Hartman
maintainerPATCH 744/772 jffs2: Fix rtime decompressor
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit b29bf7119d6bbfd04aabb8d82b060fe2a33ef890 upstream.
The fix for a memory corruption contained a off-by-one error and caused the compressor to fail in legit cases.
--- fs/jffs2/compr_rtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jffs2/compr_rtime.c +1 -1
@@ -95,7 +95,7 @@ static int jffs2_rtime_decompress(unsign positions[value]=outpos;if (repeat) { -if ((outpos + repeat) >= destlen) { +if ((outpos + repeat) > destlen) {return 1 ; }if (backoffs + repeat >= outpos) {
Greg Kroah-Hartman
maintainerPATCH 745/772 mm/damon/vaddr: fix issue in damon_va_evenly_split_region()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Yejian <[email protected]>
commit f3c7a1ede435e2e45177d7a490a85fb0a0ec96d1 upstream.
Patch series "mm/damon/vaddr: Fix issue indamon_va_evenly_split_region()". v2.
According to the logic of damon_va_evenly_split_region(), currently following split case would not meet the expectation:
Suppose DAMON_MIN_REGION=0x1000,
Case: Split [0x0, 0x3000) into 2 pieces, then the result would be
acutually 3 regions:
[0x0, 0x1000), [0x1000, 0x2000), [0x2000, 0x3000)
but NOT the expected 2 regions:
[0x0, 0x1000), [0x1000, 0x3000) !!!
The root cause is that when calculating size of each split piece in damon_va_evenly_split_region():
sz_piece = ALIGN_DOWN(sz_orig / nr_pieces, DAMON_MIN_REGION);
both the dividing and the ALIGN_DOWN may cause loss of precision, then each time split one piece of size 'sz_piece' from origin 'start' to 'end' would cause more pieces are split out than expected!!!
To fix it, count for each piece split and make sure no more than 'nr_pieces'. In addition, add above case into damon_test_split_evenly().
And add 'nr_piece == 1' check in damon_va_evenly_split_region() for better code readability and add a corresponding kunit testcase.
This patch (of 2):
According to the logic of damon_va_evenly_split_region(), currently following split case would not meet the expectation:
Suppose DAMON_MIN_REGION=0x1000,
Case: Split [0x0, 0x3000) into 2 pieces, then the result would be
acutually 3 regions:
[0x0, 0x1000), [0x1000, 0x2000), [0x2000, 0x3000)
but NOT the expected 2 regions:
[0x0, 0x1000), [0x1000, 0x3000) !!!
The root cause is that when calculating size of each split piece in damon_va_evenly_split_region():
sz_piece = ALIGN_DOWN(sz_orig / nr_pieces, DAMON_MIN_REGION);
both the dividing and the ALIGN_DOWN may cause loss of precision, then each time split one piece of size 'sz_piece' from origin 'start' to 'end' would cause more pieces are split out than expected!!!
To fix it, count for each piece split and make sure no more than 'nr_pieces'. In addition, add above case into damon_test_split_evenly().
After this patch, damon-operations test passed:
# ./tools/testing/kunit/kunit.py run damon-operations [...] ============== damon-operations (6 subtests) =============== [PASSED] damon_test_three_regions_in_vmas [PASSED] damon_test_apply_three_regions1 [PASSED] damon_test_apply_three_regions2 [PASSED] damon_test_apply_three_regions3 [PASSED] damon_test_apply_three_regions4 [PASSED] damon_test_split_evenly ================ [PASSED] damon-operations =================
--- mm/damon/vaddr-test.h | 1 + mm/damon/vaddr.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
mm/damon/vaddr-test.h +1 -0
@@ -292,6 +292,7 @@ static void damon_test_split_evenly(strudamon_test_split_evenly_fail (test,0 ,100 ,0 );damon_test_split_evenly_succ (test,0 ,100 ,10 );damon_test_split_evenly_succ (test,5 ,59 ,5 ); +damon_test_split_evenly_succ (test,0 ,3 ,2 );damon_test_split_evenly_fail (test,5 ,6 ,2 ); }
mm/damon/vaddr.c +2 -2
@@ -67,6 +67,7 @@ static int damon_va_evenly_split_region(unsigned long sz_orig, sz_piece, orig_end;struct damon_region *n =NULL , *next;unsigned long start; +unsigned int i;if (!r || !nr_pieces)return -EINVAL ;
@@ -80,8 +81,7 @@ static int damon_va_evenly_split_region( r->ar.end = r->ar.start + sz_piece; next =damon_next_region (r); -for (start = r->ar.end; start + sz_piece <= orig_end; - start += sz_piece) { +for (start = r->ar.end, i =1 ; i < nr_pieces; start += sz_piece, i++) { n =damon_new_region (start, start + sz_piece);if (!n)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 746/772 io_uring: wake up optimisations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 3181e22fb79910c7071e84a43af93ac89e8a7106 upstream.
Flush completions is done either from the submit syscall or by the task_work, both are in the context of the submitter task, and when it goes for a single threaded rings like implied by ->task_complete, there won't be any waiters on ->cq_wait but the master task. That means that there can be no tasks sleeping on cq_wait while we run __io_submit_flush_completions() and so waking up can be skipped.
--- io_uring/io_uring.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
io_uring/io_uring.c +11 -1
@@ -582,6 +582,16 @@ static inline void __io_cq_unlock_post(sio_cqring_ev_posted (ctx); } +static inline void __io_cq_unlock_post_flush (struct io_ring_ctx *ctx) + __releases(ctx->completion_lock) +{ +io_commit_cqring (ctx); +spin_unlock (&ctx->completion_lock); +io_commit_cqring_flush (ctx); +if (!(ctx->flags &IORING_SETUP_DEFER_TASKRUN )) +__io_cqring_wake (ctx); +} +void io_cq_unlock_post (struct io_ring_ctx *ctx) {__io_cq_unlock_post (ctx);
@@ -1339,7 +1349,7 @@ static void __io_submit_flush_completionif (!(req->flags &REQ_F_CQE_SKIP ))__io_fill_cqe_req (ctx, req); } -__io_cq_unlock_post (ctx); +__io_cq_unlock_post_flush (ctx);io_free_batch_list (ctx, state->compl_reqs.first);INIT_WQ_LIST (&state->compl_reqs);
Greg Kroah-Hartman
maintainerPATCH 747/772 xhci: dbc: Fix STALL transfer event handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 9044ad57b60b0556d42b6f8aa218a68865e810a4 upstream.
Don't flush all pending DbC data requests when an endpoint halts.
An endpoint may halt and xHC DbC triggers a STALL error event if there's an issue with a bulk data transfer. The transfer should restart once xHC DbC receives a ClearFeature(ENDPOINT_HALT) request from the host.
Once xHC DbC restarts it will start from the TRB pointed to by dequeue field in the endpoint context, which might be the same TRB we got the STALL event for. Turn the TRB to a no-op in this case to make sure xHC DbC doesn't reuse and tries to retransmit this same TRB after we already handled it, and gave its corresponding data request back.
Other STALL events might be completely bogus.
Lukasz Bartosik discovered that xHC DbC might issue spurious STALL events if hosts sends a ClearFeature(ENDPOINT_HALT) request to non-halted endpoints even without any active bulk transfers.
Assume STALL event is spurious if it reports 0 bytes transferred, and the endpoint stopped on the STALLED TRB.
Don't give back the data request corresponding to the TRB in this case.
The halted status is per endpoint. Track it with a per endpoint flag instead of the driver invented DbC wide DS_STALLED state. DbC remains in DbC-Configured state even if endpoints halt. There is no Stalled state in the DbC Port state Machine (xhci section 7.6.6)
--- drivers/usb/host/xhci-dbgcap.c | 135 ++++++++++++++++++++++++----------------- drivers/usb/host/xhci-dbgcap.h | 2 2 files changed, 83 insertions(+), 54 deletions(-)
drivers/usb/host/xhci-dbgcap.c +82 -53
@@ -158,16 +158,18 @@ static void xhci_dbc_giveback(struct dbcspin_lock (&dbc->lock); } -static void xhci_dbc_flush_single_request (struct dbc_request *req) +static void trb_to_noop (union xhci_trb *trb) { -union xhci_trb *trb = req->trb; - trb->generic.field[0 ] =0 ; trb->generic.field[1 ] =0 ; trb->generic.field[2 ] =0 ; trb->generic.field[3 ] &=cpu_to_le32 (TRB_CYCLE ); trb->generic.field[3 ] |=cpu_to_le32 (TRB_TYPE (TRB_TR_NOOP )); +} +static void xhci_dbc_flush_single_request (struct dbc_request *req) +{ +trb_to_noop (req->trb);xhci_dbc_giveback (req, -ESHUTDOWN ); }
@@ -637,7 +639,6 @@ static void xhci_dbc_stop(struct xhci_dbcase DS_DISABLED :return ;case DS_CONFIGURED : -case DS_STALLED :if (dbc->driver->disconnect) dbc->driver->disconnect (dbc);break ;
@@ -658,6 +659,23 @@ static void xhci_dbc_stop(struct xhci_db }static void +handle_ep_halt_changes (struct xhci_dbc *dbc,struct dbc_ep *dep,bool halted) +{ +if (halted) { +dev_info (dbc->dev,"DbC Endpoint halted\n" ); + dep->halted =1 ; + + }else if (dep->halted) { +dev_info (dbc->dev,"DbC Endpoint halt cleared\n" ); + dep->halted =0 ; + +if (!list_empty (&dep->list_pending)) +writel (DBC_DOOR_BELL_TARGET (dep->direction), + &dbc->regs->doorbell); + } +} + +static void dbc_handle_port_status (struct xhci_dbc *dbc,union xhci_trb *event) {u32 portsc;
@@ -685,6 +703,7 @@ static void dbc_handle_xfer_event(structstruct xhci_ring *ring;int ep_id;int status; +struct xhci_ep_ctx *ep_ctx;u32 comp_code;size_t remain_length;struct dbc_request *req =NULL , *r;
@@ -694,8 +713,30 @@ static void dbc_handle_xfer_event(struct ep_id =TRB_TO_EP_ID (le32_to_cpu (event->generic.field[3 ])); dep = (ep_id ==EPID_OUT ) ?get_out_ep (dbc) :get_in_ep (dbc); + ep_ctx = (ep_id ==EPID_OUT ) ? +dbc_bulkout_ctx (dbc) :dbc_bulkin_ctx (dbc); ring = dep->ring; +/* Match the pending request: */ +list_for_each_entry (r, &dep->list_pending, list_pending) { +if (r->trb_dma == event->trans_event.buffer) { + req = r; +break ; + } +if (r->status == -COMP_STALL_ERROR ) { +dev_warn (dbc->dev,"Give back stale stalled req\n" ); + ring->num_trbs_free++; +xhci_dbc_giveback (r,0 ); + } + } + +if (!req) { +dev_warn (dbc->dev,"no matched request\n" ); +return ; + } + +trace_xhci_dbc_handle_transfer (ring, &req->trb->generic); +switch (comp_code) {case COMP_SUCCESS : remain_length =0 ;
@@ -706,31 +747,49 @@ static void dbc_handle_xfer_event(structcase COMP_TRB_ERROR :case COMP_BABBLE_DETECTED_ERROR :case COMP_USB_TRANSACTION_ERROR : -case COMP_STALL_ERROR :dev_warn (dbc->dev,"tx error %d detected\n" , comp_code); status = -comp_code;break ; +case COMP_STALL_ERROR : +dev_warn (dbc->dev,"Stall error at bulk TRB %llx, remaining %zu, ep deq %llx\n" , + event->trans_event.buffer, remain_length, ep_ctx->deq); + status =0 ; + dep->halted =1 ; + +/* +* xHC DbC may trigger a STALL bulk xfer event when host sends a +* ClearFeature(ENDPOINT_HALT) request even if there wasn't an +* active bulk transfer. +* +* Don't give back this transfer request as hardware will later +* start processing TRBs starting from this 'STALLED' TRB, +* causing TRBs and requests to be out of sync. +* +* If STALL event shows some bytes were transferred then assume +* it's an actual transfer issue and give back the request. +* In this case mark the TRB as No-Op to avoid hw from using the +* TRB again. +*/ + +if ((ep_ctx->deq & ~TRB_CYCLE ) == event->trans_event.buffer) { +dev_dbg (dbc->dev,"Ep stopped on Stalled TRB\n" ); +if (remain_length == req->length) { +dev_dbg (dbc->dev,"Spurious stall event, keep req\n" ); + req->status = -COMP_STALL_ERROR ; + req->actual =0 ; +return ; + } +dev_dbg (dbc->dev,"Give back stalled req, but turn TRB to No-op\n" ); +trb_to_noop (req->trb); + } +break ; +default :dev_err (dbc->dev,"unknown tx error %d\n" , comp_code); status = -comp_code;break ; } -/* Match the pending request: */ -list_for_each_entry (r, &dep->list_pending, list_pending) { -if (r->trb_dma == event->trans_event.buffer) { - req = r; -break ; - } - } - -if (!req) { -dev_warn (dbc->dev,"no matched request\n" ); -return ; - } - -trace_xhci_dbc_handle_transfer (ring, &req->trb->generic); - ring->num_trbs_free++; req->actual = req->length - remain_length;xhci_dbc_giveback (req, status);
@@ -750,7 +809,6 @@ static void inc_evt_deq(struct xhci_ringstatic enum evtreturn xhci_dbc_do_handle_events (struct xhci_dbc *dbc) {dma_addr_t deq; -struct dbc_ep *dep;union xhci_trb *evt;u32 ctrl, portsc;bool update_erdp = false;
@@ -802,43 +860,17 @@ static enum evtreturn xhci_dbc_do_handlereturn EVT_DISC ; } -/* Handle endpoint stall event: */ +/* Check and handle changes in endpoint halt status */ ctrl =readl (&dbc->regs->control); -if ((ctrl &DBC_CTRL_HALT_IN_TR ) || - (ctrl &DBC_CTRL_HALT_OUT_TR )) { -dev_info (dbc->dev,"DbC Endpoint stall\n" ); - dbc->state =DS_STALLED ; - -if (ctrl &DBC_CTRL_HALT_IN_TR ) { - dep =get_in_ep (dbc); -xhci_dbc_flush_endpoint_requests (dep); - } - -if (ctrl &DBC_CTRL_HALT_OUT_TR ) { - dep =get_out_ep (dbc); -xhci_dbc_flush_endpoint_requests (dep); - } - -return EVT_DONE ; - } +handle_ep_halt_changes (dbc,get_in_ep (dbc), ctrl &DBC_CTRL_HALT_IN_TR ); +handle_ep_halt_changes (dbc,get_out_ep (dbc), ctrl &DBC_CTRL_HALT_OUT_TR );/* Clear DbC run change bit: */ if (ctrl &DBC_CTRL_DBC_RUN_CHANGE ) {writel (ctrl, &dbc->regs->control); ctrl =readl (&dbc->regs->control); } -break ; -case DS_STALLED : - ctrl =readl (&dbc->regs->control); -if (!(ctrl &DBC_CTRL_HALT_IN_TR ) && - !(ctrl &DBC_CTRL_HALT_OUT_TR ) && - (ctrl &DBC_CTRL_DBC_RUN )) { - dbc->state =DS_CONFIGURED ; -break ; - } - -return EVT_DONE ;default :dev_err (dbc->dev,"Unknown DbC state %d\n" , dbc->state);break ;
@@ -941,9 +973,6 @@ static ssize_t dbc_show(struct device *dcase DS_CONFIGURED : p ="configured" ;break ; -case DS_STALLED : - p ="stalled" ; -break ;default : p ="unknown" ; }
drivers/usb/host/xhci-dbgcap.h +1 -1
@@ -81,7 +81,6 @@ enum dbc_state {DS_ENABLED ,DS_CONNECTED , DS_CONFIGURED, - DS_STALLED, }; struct dbc_ep {
@@ -89,6 +88,7 @@ struct dbc_ep {struct list_head list_pending;struct xhci_ring *ring; unsigned int direction:1; + unsigned int halted:1; };#define DBC_QUEUE_SIZE 16
Greg Kroah-Hartman
maintainerPATCH 748/772 mmc: mtk-sd: Fix error handle of probe function
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy-ld Lu <[email protected]>
commit 291220451c775a054cedc4fab4578a1419eb6256 upstream.
In the probe function, it goes to 'release_mem' label and returns after some procedure failure. But if the clocks (partial or all) have been enabled previously, they would not be disabled in msdc_runtime_suspend, since runtime PM is not yet enabled for this case.
That cause mmc related clocks always on during system suspend and block suspend flow. Below log is from a SDCard issue of MT8196 chromebook, it returns -ETIMEOUT while polling clock stable in the msdc_ungate_clock() and probe failed, but the enabled clocks could not be disabled anyway.
[ 129.059253] clk_chk_dev_pm_suspend() [ 129.350119] suspend warning: msdcpll is on [ 129.354494] [ck_msdc30_1_sel : enabled, 1, 1, 191999939, ck_msdcpll_d2] [ 129.362787] [ck_msdcpll_d2 : enabled, 1, 1, 191999939, msdcpll] [ 129.371041] [ck_msdc30_1_ck : enabled, 1, 1, 191999939, ck_msdc30_1_sel] [ 129.379295] [msdcpll : enabled, 1, 1, 383999878, clk26m]
Add a new 'release_clk' label and reorder the error handle functions to make sure the clocks be disabled after probe failure.
Message-ID: <[email protected]>
--- drivers/mmc/host/mtk-sd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/host/mtk-sd.c +5 -4
@@ -2755,7 +2755,7 @@ static int msdc_drv_probe(struct platfor ret =msdc_ungate_clock (host);if (ret) {dev_err (&pdev->dev,"Cannot ungate clocks!\n" ); - goto release_mem; + goto release_clk; }msdc_init_hw (host);
@@ -2765,14 +2765,14 @@ static int msdc_drv_probe(struct platfor GFP_KERNEL);if (!host->cq_host) { ret = -ENOMEM ; - goto host_free; + goto release; } host->cq_host->caps |=CQHCI_TASK_DESC_SZ_128 ; host->cq_host->mmio = host->base +0x800 ; host->cq_host->ops = &msdc_cmdq_ops; ret =cqhci_init (host->cq_host, mmc, true);if (ret) - goto host_free; + goto release; mmc->max_segs =128 ;/* cqhci 16bit length */ /* 0 size, means 65536 so we don't have to -1 here */
@@ -2797,9 +2797,10 @@ static int msdc_drv_probe(struct platfor end:pm_runtime_disable (host->dev); release: -platform_set_drvdata (pdev,NULL );msdc_deinit_hw (host); +release_clk:msdc_gate_clock (host); +platform_set_drvdata (pdev,NULL ); release_mem:if (host->dma.gpd) dma_free_coherent(&pdev->dev,
Greg Kroah-Hartman
maintainerPATCH 749/772 drm/amd/display: Check BIOS images before it is used
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Hung <[email protected]>
commit 8b0ddf19cca2a352b2a7e01d99d3ba949a99c84c upstream.
BIOS images may fail to load and null checks are added before they are used.
This fixes 6 NULL_RETURNS issues reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/bios/bios_parser.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +14 -0
@@ -664,6 +664,9 @@ static enum bp_result get_ss_info_v3_1( ss_table_header_include =GET_IMAGE (ATOM_ASIC_INTERNAL_SS_INFO_V3 ,DATA_TABLES (ASIC_InternalSS_Info)); +if (!ss_table_header_include) +return BP_RESULT_UNSUPPORTED ; + table_size = (le16_to_cpu (ss_table_header_include->sHeader.usStructureSize) -sizeof (ATOM_COMMON_TABLE_HEADER ))
@@ -1031,6 +1034,8 @@ static enum bp_result get_ss_info_from_i header =GET_IMAGE (ATOM_ASIC_INTERNAL_SS_INFO_V2 ,DATA_TABLES (ASIC_InternalSS_Info)); +if (!header) +return result;memset (info,0 ,sizeof (struct spread_spectrum_info ));
@@ -1104,6 +1109,8 @@ static enum bp_result get_ss_info_from_sget_atom_data_table_revision (header, &revision); tbl =GET_IMAGE (ATOM_SPREAD_SPECTRUM_INFO ,DATA_TABLES (SS_Info)); +if (!tbl) +return result;if (1 != revision.major ||2 > revision.minor)return result;
@@ -1631,6 +1638,8 @@ static uint32_t get_ss_entry_number_from tbl =GET_IMAGE (ATOM_SPREAD_SPECTRUM_INFO ,DATA_TABLES (SS_Info)); +if (!tbl) +return number;if (1 != revision.major ||2 > revision.minor)return number;
@@ -1711,6 +1720,8 @@ static uint32_t get_ss_entry_number_from header_include =GET_IMAGE (ATOM_ASIC_INTERNAL_SS_INFO_V2 ,DATA_TABLES (ASIC_InternalSS_Info)); +if (!header_include) +return 0 ; size = (le16_to_cpu (header_include->sHeader.usStructureSize) -sizeof (ATOM_COMMON_TABLE_HEADER ))
@@ -1748,6 +1759,9 @@ static uint32_t get_ss_entry_number_from header_include =GET_IMAGE (ATOM_ASIC_INTERNAL_SS_INFO_V3 ,DATA_TABLES (ASIC_InternalSS_Info)); +if (!header_include) +return number; + size = (le16_to_cpu (header_include->sHeader.usStructureSize) -sizeof (ATOM_COMMON_TABLE_HEADER )) /sizeof (ATOM_ASIC_SS_ASSIGNMENT_V3 );
Greg Kroah-Hartman
maintainerPATCH 750/772 ocfs2: Revert "ocfs2: fix the la space leak when unmounting an ocfs2 volume"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heming Zhao <[email protected]>
This reverts commit dfe6c5692fb5 ("ocfs2: fix the la space leak when unmounting an ocfs2 volume").
In commit dfe6c5692fb5, the commit log "This bug has existed since the initial OCFS2 code." is wrong. The correct introduction commit is 30dd3478c3cd ("ocfs2: correctly use ocfs2_find_next_zero_bit()").
The influence of commit dfe6c5692fb5 is that it provides a correct fix for the latest kernel. however, it shouldn't be pushed to stable branches. Let's use this commit to revert all branches that include dfe6c5692fb5 and use a new fix method to fix commit 30dd3478c3cd.
--- fs/ocfs2/localalloc.c | 19 ------------------- 1 file changed, 19 deletions(-)
fs/ocfs2/localalloc.c +0 -19
@@ -1008,25 +1008,6 @@ static int ocfs2_sync_local_to_main(stru start = bit_off +1 ; } -/* clear the contiguous bits until the end boundary */ -if (count) { - blkno = la_start_blk + -ocfs2_clusters_to_blocks (osb->sb, - start - count); - -trace_ocfs2_sync_local_to_main_free ( - count, start - count, - (unsigned long long )la_start_blk, - (unsigned long long )blkno); - - status =ocfs2_release_clusters (handle, - main_bm_inode, - main_bm_bh, blkno, - count); -if (status <0 ) -mlog_errno (status); - } - bail:if (status)mlog_errno (status);
Greg Kroah-Hartman
maintainerPATCH 751/772 Revert "drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read()"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Zekun <[email protected]>
This reverts commit 25d7e84343e1235b667cf5226c3934fdf36f0df6.
The origin mainline patch fix a buffer overflow issue in amdgpu_debugfs_gprwave_read(), but it has not been introduced in kernel 6.1 and older kernels. This patch add a check in a wrong function in the same file.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
@@ -419,7 +419,7 @@ static ssize_t amdgpu_debugfs_regs_pcie_ssize_t result =0 ;int r; -if (size >4096 || size &0x3 || *pos &0x3 ) +if (size &0x3 || *pos &0x3 )return -EINVAL ; r =pm_runtime_get_sync (adev_to_drm (adev)->dev);
Greg Kroah-Hartman
maintainerPATCH 752/772 gve: Fixes for napi_poll when budget is 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ziwei Xiao <[email protected]>
commit 278a370c1766060d2144d6cf0b06c101e1043b6d upstream.
Netpoll will explicilty pass the polling call with a budget of 0 to indicate it's clearing the Tx path only. For the gve_rx_poll and gve_xdp_poll, they were mistakenly taking the 0 budget as the indication to do all the work. Add check to avoid the rx path and xdp path being called when budget is 0. And also avoid napi_complete_done being called when budget is 0 for netpoll.
--- drivers/net/ethernet/google/gve/gve_main.c | 7 +++++++ drivers/net/ethernet/google/gve/gve_rx.c | 4 ---- drivers/net/ethernet/google/gve/gve_tx.c | 4 ---- 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/net/ethernet/google/gve/gve_main.c +7 -0
@@ -202,6 +202,10 @@ static int gve_napi_poll(struct napi_strif (block->tx) reschedule |=gve_tx_poll (block, budget); + +if (!budget) +return 0 ; +if (block->rx) { work_done =gve_rx_poll (block, budget); reschedule |= work_done == budget;
@@ -242,6 +246,9 @@ static int gve_napi_poll_dqo(struct napiif (block->tx) reschedule |=gve_tx_poll_dqo (block,/*do_clean=*/ true); +if (!budget) +return 0 ; +if (block->rx) { work_done =gve_rx_poll_dqo (block, budget); reschedule |= work_done == budget;
drivers/net/ethernet/google/gve/gve_rx.c +0 -4
@@ -778,10 +778,6 @@ int gve_rx_poll(struct gve_notify_block feat = block->napi.dev->features; -/* If budget is 0, do all the work */ -if (budget ==0 ) - budget =INT_MAX ; -if (budget >0 ) work_done =gve_clean_rx_done (rx, budget, feat);
drivers/net/ethernet/google/gve/gve_tx.c +0 -4
@@ -725,10 +725,6 @@ bool gve_tx_poll(struct gve_notify_blocku32 nic_done;u32 to_do; -/* If budget is 0, do all the work */ -if (budget ==0 ) - budget =INT_MAX ; -/* In TX path, it may try to clean completed pkts in order to xmit, * to avoid cleaning conflict, use spin_lock(), it yields better * concurrency between xmit/clean than netif's lock.
Greg Kroah-Hartman
maintainerPATCH 753/772 arm64/sve: Discard stale CPU state when handling SVE traps
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 751ecf6afd6568adc98f2a6052315552c0483d18 upstream.
The logic for handling SVE traps manipulates saved FPSIMD/SVE state incorrectly, and a race with preemption can result in a task having TIF_SVE set and TIF_FOREIGN_FPSTATE clear even though the live CPU state is stale (e.g. with SVE traps enabled). This has been observed to result in warnings from do_sve_acc() where SVE traps are not expected while TIF_SVE is set:
| if (test_and_set_thread_flag(TIF_SVE))
| WARN_ON(1); /* SVE access shouldn't have trapped */
Warnings of this form have been reported intermittently, e.g.
https://lore.kernel.org/linux-arm-kernel/CA+G9fYtEGe_DhY2Ms7+L7NKsLYUomGsgqpdBj+QwDLeSg=JhGg@mail.gmail.com/
https://lore.kernel.org/linux-arm-kernel/[email protected]/
The race can occur when the SVE trap handler is preempted before and after manipulating the saved FPSIMD/SVE state, starting and ending on the same CPU, e.g.
| void do_sve_acc(unsigned long esr, struct pt_regs *regs)
| {
| // Trap on CPU 0 with TIF_SVE clear, SVE traps enabled
| // task->fpsimd_cpu is 0.
| // per_cpu_ptr(&fpsimd_last_state, 0) is task.
|
| ...
|
| // Preempted; migrated from CPU 0 to CPU 1.
| // TIF_FOREIGN_FPSTATE is set.
|
| get_cpu_fpsimd_context();
|
| if (test_and_set_thread_flag(TIF_SVE))
| WARN_ON(1); /* SVE access shouldn't have trapped */
|
| sve_init_regs() {
| if (!test_thread_flag(TIF_FOREIGN_FPSTATE)) {
| ...
| } else {
| fpsimd_to_sve(current);
| current->thread.fp_type = FP_STATE_SVE;
| }
| }
|
| put_cpu_fpsimd_context();
|
| // Preempted; migrated from CPU 1 to CPU 0.
| // task->fpsimd_cpu is still 0
| // If per_cpu_ptr(&fpsimd_last_state, 0) is still task then:
| // - Stale HW state is reused (with SVE traps enabled)
| // - TIF_FOREIGN_FPSTATE is cleared
| // - A return to userspace skips HW state restore
| }Fix the case where the state is not live and TIF_FOREIGN_FPSTATE is set by calling fpsimd_flush_task_state() to detach from the saved CPU state. This ensures that a subsequent context switch will not reuse the stale CPU state, and will instead set TIF_FOREIGN_FPSTATE, forcing the new state to be reloaded from memory prior to a return to userspace.
--- arch/arm64/kernel/fpsimd.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/fpsimd.c +1 -0
@@ -1383,6 +1383,7 @@ static void sve_init_regs(void)fpsimd_bind_task_to_cpu (); }else {fpsimd_to_sve (current); +fpsimd_flush_task_state (current); } }
Greg Kroah-Hartman
maintainerPATCH 754/772 arm64: smccc: Remove broken support for SMCCCv1.3 SVE discard hint
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit 8c462d56487e3abdbf8a61cedfe7c795a54f4a78 upstream.
SMCCCv1.3 added a hint bit which callers can set in an SMCCC function ID (AKA "FID") to indicate that it is acceptable for the SMCCC implementation to discard SVE and/or SME state over a specific SMCCC call. The kernel support for using this hint is broken and SMCCC calls may clobber the SVE and/or SME state of arbitrary tasks, though FPSIMD state is unaffected.
The kernel support is intended to use the hint when there is no SVE or SME state to save, and to do this it checks whether TIF_FOREIGN_FPSTATE is set or TIF_SVE is clear in assembly code:
| ldr <flags>, [<current_task>, #TSK_TI_FLAGS] | tbnz <flags>, #TIF_FOREIGN_FPSTATE, 1f // Any live FP state? | tbnz <flags>, #TIF_SVE, 2f // Does that state include SVE? | | 1: orr <fid>, <fid>, ARM_SMCCC_1_3_SVE_HINT | 2: | << SMCCC call using FID >>
This is not safe as-is:
(1) SMCCC calls can be made in a preemptible context and preemption can result in TIF_FOREIGN_FPSTATE being set or cleared at arbitrary points in time. Thus checking for TIF_FOREIGN_FPSTATE provides no guarantee.
(2) TIF_FOREIGN_FPSTATE only indicates that the live FP/SVE/SME state in the CPU does not belong to the current task, and does not indicate that clobbering this state is acceptable.
When the live CPU state is clobbered it is necessary to update fpsimd_last_state.st to ensure that a subsequent context switch will reload FP/SVE/SME state from memory rather than consuming the clobbered state. This and the SMCCC call itself must happen in a critical section with preemption disabled to avoid races.
(3) Live SVE/SME state can exist with TIF_SVE clear (e.g. with only TIF_SME set), and checking TIF_SVE alone is insufficient.
Remove the broken support for the SMCCCv1.3 SVE saving hint. This is effectively a revert of commits:
* cfa7ff959a78 ("arm64: smccc: Support SMCCC v1.3 SVE register saving hint")
* a7c3acca5380 ("arm64: smccc: Save lr before calling __arm_smccc_sve_check()")
... leaving behind the ARM_SMCCC_VERSION_1_3 and ARM_SMCCC_1_3_SVE_HINT definitions, since these are simply definitions from the SMCCC specification, and the latter is used in KVM via ARM_SMCCC_CALL_HINTS.
If we want to bring this back in future, we'll probably want to handle this logic in C where we can use all the usual FPSIMD/SVE/SME helper functions, and that'll likely require some rework of the SMCCC code and/or its callers.
--- arch/arm64/kernel/smccc-call.S | 35 +++-------------------------------- drivers/firmware/smccc/smccc.c | 4 ---- include/linux/arm-smccc.h | 30 ++---------------------------- 3 files changed, 5 insertions(+), 64 deletions(-)
arch/arm64/kernel/smccc-call.S +3 -32
@@ -7,48 +7,19 @@ #include <asm/asm-offsets.h> #include <asm/assembler.h> -#include <asm/thread_info.h> - -/* - * If we have SMCCC v1.3 and (as is likely) no SVE state in - * the registers then set the SMCCC hint bit to say there's no - * need to preserve it. Do this by directly adjusting the SMCCC - * function value which is already stored in x0 ready to be called. - */ -SYM_FUNC_START(__arm_smccc_sve_check) - - ldr_l x16, smccc_has_sve_hint - cbz x16, 2f - - get_current_task x16 - ldr x16, [x16, #TSK_TI_FLAGS] - tbnz x16, #TIF_FOREIGN_FPSTATE, 1f // Any live FP state? - tbnz x16, #TIF_SVE, 2f // Does that state include SVE? - -1: orr x0, x0, ARM_SMCCC_1_3_SVE_HINT - -2: ret -SYM_FUNC_END(__arm_smccc_sve_check) -EXPORT_SYMBOL(__arm_smccc_sve_check) .macro SMCCC instr - stp x29, x30, [sp, #-16]! - mov x29, sp -alternative_if ARM64_SVE - bl __arm_smccc_sve_check -alternative_else_nop_endif \instr #0 - ldr x4, [sp, #16] + ldr x4, [sp] stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS] stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS] - ldr x4, [sp, #24] + ldr x4, [sp, #8] cbz x4, 1f /* no quirk structure */ ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS] cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6 b.ne 1f str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS] -1: ldp x29, x30, [sp], #16 - ret +1: ret .endm /*
drivers/firmware/smccc/smccc.c +0 -4
@@ -16,7 +16,6 @@ static u32 smccc_version = ARM_SMCCC_VERstatic enum arm_smccc_conduit smccc_conduit =SMCCC_CONDUIT_NONE ;bool __ro_after_init smccc_trng_available = false; -u64 __ro_after_init smccc_has_sve_hint = false;s32 __ro_after_init smccc_soc_id_version =SMCCC_RET_NOT_SUPPORTED ;s32 __ro_after_init smccc_soc_id_revision =SMCCC_RET_NOT_SUPPORTED ;
@@ -28,9 +27,6 @@ void __init arm_smccc_version_init(u32 v smccc_conduit = conduit; smccc_trng_available =smccc_probe_trng (); -if (IS_ENABLED (CONFIG_ARM64_SVE ) && - smccc_version >=ARM_SMCCC_VERSION_1_3 ) - smccc_has_sve_hint = true;if ((smccc_version >=ARM_SMCCC_VERSION_1_2 ) && (smccc_conduit !=SMCCC_CONDUIT_NONE )) {
include/linux/arm-smccc.h +2 -28
@@ -224,8 +224,6 @@ u32 arm_smccc_get_version(void);void __init arm_smccc_version_init (u32 version,enum arm_smccc_conduit conduit); -extern u64 smccc_has_sve_hint; -/** * arm_smccc_get_soc_id_version() *
@@ -324,15 +322,6 @@ struct arm_smccc_quirk { };/** -* __arm_smccc_sve_check() - Set the SVE hint bit when doing SMC calls -* -* Sets the SMCCC hint bit to indicate if there is live state in the SVE -* registers, this modifies x0 in place and should never be called from C -* code. -*/ -asmlinkage unsigned long __arm_smccc_sve_check (unsigned long x0); - -/** * __arm_smccc_smc() - make SMC calls * @a0-a7: arguments passed in registers 0 to 7 * @res: result values from registers 0 to 3
@@ -399,20 +388,6 @@ asmlinkage void __arm_smccc_hvc(unsigned#endif -/* nVHE hypervisor doesn't have a current thread so needs separate checks */ -#if defined(CONFIG_ARM64_SVE ) && !defined(__KVM_NVHE_HYPERVISOR__) - -#define SMCCC_SVE_CHECK ALTERNATIVE("nop \n", "bl __arm_smccc_sve_check \n", \ - ARM64_SVE) -#define smccc_sve_clobbers "x16", "x30", "cc", - -#else - -#define SMCCC_SVE_CHECK -#define smccc_sve_clobbers - -#endif -#define ___count_args (_0, _1, _2, _3, _4, _5, _6, _7, _8, x, ...) x#define __count_args (...) \
@@ -480,7 +455,7 @@ asmlinkage void __arm_smccc_hvc(unsigned#define ___constraints (count) \ : __constraint_read_ ## count \ - : smccc_sve_clobbers "memory" + : "memory"#define __constraints (count) ___constraints(count)/*
@@ -495,8 +470,7 @@ asmlinkage void __arm_smccc_hvc(unsigned registerunsigned long r2 asm("r2" ); \ registerunsigned long r3 asm("r3" ); \__declare_args (__count_args (__VA_ARGS__), __VA_ARGS__); \ - asmvolatile (SMCCC_SVE_CHECK \ - inst "\n" : \ + asmvolatile (inst"\n" : \"=r" (r0),"=r" (r1),"=r" (r2),"=r" (r3) \ __constraints(__count_args(__VA_ARGS__))); \if (___res) \
Greg Kroah-Hartman
maintainerPATCH 755/772 ASoC: Intel: avs: Fix return status of avs_pcm_hw_constraints_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amadeusz Sławiński <[email protected]>
commit a0aae96be5ffc5b456ca07bfe1385b721c20e184 upstream.
Check for return code from avs_pcm_hw_constraints_init() in avs_dai_fe_startup() only checks if value is different from 0. Currently function can return positive value, change it to return 0 on success.
I've observed KASAN on our setups and while patch itself is correct regardless. Problem seems to be caused by recent changes to rates, as this started happening after recent patchsets and doesn't reproduce with those reverted
https://lore.kernel.org/linux-sound/[email protected]/
https://lore.kernel.org/linux-sound/[email protected]/
I've tested using Mark tree, where they are both applied and for some reason snd_pcm_hw_constraint_minmax() started returning positive value, while previously it returned 0. I'm bit worried if it signals some potential deeper problem regarding constraints with above changes.
--- sound/soc/intel/avs/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/avs/pcm.c +1 -1
@@ -540,7 +540,7 @@ static int avs_dai_fe_hw_free(struct sndif (ret <0 )dev_dbg (dai->dev,"Failed to free pages!\n" ); -return ret; +return 0 ; }static int avs_dai_fe_prepare (struct snd_pcm_substream *substream,struct snd_soc_dai *dai)
Greg Kroah-Hartman
maintainerPATCH 756/772 mm: call the security_mmap_file() LSM hook in remap_file_pages()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shu Han <[email protected]>
commit ea7e2d5e49c05e5db1922387b09ca74aa40f46e2 upstream.
The remap_file_pages syscall handler calls do_mmap() directly, which doesn't contain the LSM security check. And if the process has called personality(READ_IMPLIES_EXEC) before and remap_file_pages() is called for RW pages, this will actually result in remapping the pages to RWX, bypassing a W^X policy enforced by SELinux.
So we should check prot by security_mmap_file LSM hook in the remap_file_pages syscall handler before do_mmap() is called. Otherwise, it potentially permits an attacker to bypass a W^X policy enforced by SELinux.
The bypass is similar to CVE-2016-10044, which bypass the same thing via AIO and can be found in [1].
The PoC:
$ cat > test.c
int main(void) {
size_t pagesz = sysconf(_SC_PAGE_SIZE);
int mfd = syscall(SYS_memfd_create, "test", 0);
const char *buf = mmap(NULL, 4 * pagesz, PROT_READ | PROT_WRITE,
MAP_SHARED, mfd, 0);
unsigned int old = syscall(SYS_personality, 0xffffffff);
syscall(SYS_personality, READ_IMPLIES_EXEC | old);
syscall(SYS_remap_file_pages, buf, pagesz, 0, 2, 0);
syscall(SYS_personality, old);
// show the RWX page exists even if W^X policy is enforced
int fd = open("/proc/self/maps", O_RDONLY);
unsigned char buf2[1024];
while (1) {
int ret = read(fd, buf2, 1024);
if (ret <= 0) break;
write(1, buf2, ret);
}
close(fd);
}$ gcc test.c -o test $ ./test | grep rwx 7f1836c34000-7f1836c35000 rwxs 00002000 00:01 2050 /memfd:test (deleted)
--- mm/mmap.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/mmap.c +4 -0
@@ -3021,8 +3021,12 @@ SYSCALL_DEFINE5(remap_file_pages, unsign flags |=MAP_LOCKED ; file =get_file (vma->vm_file); + ret =security_mmap_file (vma->vm_file, prot, flags); +if (ret) + goto out_fput; ret =do_mmap (vma->vm_file, start, size, prot, flags, pgoff, &populate,NULL ); +out_fput:fput (file); out:mmap_write_unlock (mm);
Greg Kroah-Hartman
maintainerPATCH 757/772 bpf: Fix helper writes to read-only maps
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit 32556ce93bc45c730829083cb60f95a2728ea48b upstream.
Lonial found an issue that despite user- and BPF-side frozen BPF map (like in case of .rodata), it was still possible to write into it from a BPF program side through specific helpers having ARG_PTR_TO_{LONG,INT} as arguments.
In check_func_arg() when the argument is as mentioned, the meta->raw_mode is never set. Later, check_helper_mem_access(), under the case of PTR_TO_MAP_VALUE as register base type, it assumes BPF_READ for the subsequent call to check_map_access_type() and given the BPF map is read-only it succeeds.
The helpers really need to be annotated as ARG_PTR_TO_{LONG,INT} | MEM_UNINIT when results are written into them as opposed to read out of them. The latter indicates that it's okay to pass a pointer to uninitialized memory as the memory is written to anyway.
However, ARG_PTR_TO_{LONG,INT} is a special case of ARG_PTR_TO_FIXED_SIZE_MEM just with additional alignment requirement. So it is better to just get rid of the ARG_PTR_TO_{LONG,INT} special cases altogether and reuse the fixed size memory types. For this, add MEM_ALIGNED to additionally ensure alignment given these helpers write directly into the args via *<ptr> = val. The .arg*_size has been initialized reflecting the actual sizeof(*<ptr>).
MEM_ALIGNED can only be used in combination with MEM_FIXED_SIZE annotated argument types, since in !MEM_FIXED_SIZE cases the verifier does not know the buffer size a priori and therefore cannot blindly write *<ptr> = val.
[ Resolve merge conflict in include/linux/bpf.h and merge conflict in
kernel/bpf/verifier.c.]
--- include/linux/bpf.h | 7 +++++-- kernel/bpf/helpers.c | 6 ++++-- kernel/bpf/syscall.c | 3 ++- kernel/bpf/verifier.c | 41 +++++------------------------------------ kernel/trace/bpf_trace.c | 6 ++++-- net/core/filter.c | 6 ++++-- 6 files changed, 24 insertions(+), 45 deletions(-)
include/linux/bpf.h +5 -2
@@ -475,6 +475,11 @@ enum bpf_type_flag {/* Size is known at compile time. */ MEM_FIXED_SIZE =BIT (10 +BPF_BASE_TYPE_BITS ), +/* Memory must be aligned on some architectures, used in combination with +* MEM_FIXED_SIZE. +*/ +MEM_ALIGNED =BIT (17 +BPF_BASE_TYPE_BITS ), + __BPF_TYPE_FLAG_MAX, __BPF_TYPE_LAST_FLAG = __BPF_TYPE_FLAG_MAX - 1, };
@@ -510,8 +515,6 @@ enum bpf_arg_type {ARG_ANYTHING ,/* any (initialized) argument is ok */ ARG_PTR_TO_SPIN_LOCK ,/* pointer to bpf_spin_lock */ ARG_PTR_TO_SOCK_COMMON ,/* pointer to sock_common */ -ARG_PTR_TO_INT ,/* pointer to int */ -ARG_PTR_TO_LONG ,/* pointer to long */ ARG_PTR_TO_SOCKET ,/* pointer to bpf_sock (fullsock) */ ARG_PTR_TO_BTF_ID ,/* pointer to in-kernel struct */ ARG_PTR_TO_ALLOC_MEM, /* pointer to dynamically allocated memory */
kernel/bpf/helpers.c +4 -2
@@ -531,7 +531,8 @@ const struct bpf_func_proto bpf_strtol_p .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY, .arg2_type = ARG_CONST_SIZE, .arg3_type = ARG_ANYTHING, - .arg4_type = ARG_PTR_TO_LONG, + .arg4_type = ARG_PTR_TO_FIXED_SIZE_MEM | MEM_UNINIT | MEM_ALIGNED, + .arg4_size = sizeof(s64), }; BPF_CALL_4(bpf_strtoul, const char *, buf, size_t, buf_len, u64, flags,
@@ -560,7 +561,8 @@ const struct bpf_func_proto bpf_strtoul_ .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY, .arg2_type = ARG_CONST_SIZE, .arg3_type = ARG_ANYTHING, - .arg4_type = ARG_PTR_TO_LONG, + .arg4_type = ARG_PTR_TO_FIXED_SIZE_MEM | MEM_UNINIT | MEM_ALIGNED, + .arg4_size = sizeof(u64), }; BPF_CALL_3(bpf_strncmp, const char *, s1, u32, s1_sz, const char *, s2)
kernel/bpf/syscall.c +2 -1
@@ -5260,7 +5260,8 @@ static const struct bpf_func_proto bpf_k .arg1_type = ARG_PTR_TO_MEM, .arg2_type = ARG_CONST_SIZE_OR_ZERO, .arg3_type = ARG_ANYTHING, - .arg4_type = ARG_PTR_TO_LONG, + .arg4_type = ARG_PTR_TO_FIXED_SIZE_MEM | MEM_UNINIT | MEM_ALIGNED, + .arg4_size = sizeof(u64), }; static const struct bpf_func_proto *
kernel/bpf/verifier.c +5 -36
71 lines not on this page · raw message
kernel/trace/bpf_trace.c +4 -2
@@ -1192,7 +1192,8 @@ static const struct bpf_func_proto bpf_g .ret_type = RET_INTEGER, .arg1_type = ARG_PTR_TO_CTX, .arg2_type = ARG_ANYTHING, - .arg3_type = ARG_PTR_TO_LONG, + .arg3_type = ARG_PTR_TO_FIXED_SIZE_MEM | MEM_UNINIT | MEM_ALIGNED, + .arg3_size = sizeof(u64), }; BPF_CALL_2(get_func_ret, void *, ctx, u64 *, value)
@@ -1208,7 +1209,8 @@ static const struct bpf_func_proto bpf_g .func = get_func_ret, .ret_type = RET_INTEGER, .arg1_type = ARG_PTR_TO_CTX, - .arg2_type = ARG_PTR_TO_LONG, + .arg2_type = ARG_PTR_TO_FIXED_SIZE_MEM | MEM_UNINIT | MEM_ALIGNED, + .arg2_size = sizeof(u64), }; BPF_CALL_1(get_func_arg_cnt, void *, ctx)
net/core/filter.c +4 -2
@@ -6233,7 +6233,8 @@ static const struct bpf_func_proto bpf_s .ret_type = RET_INTEGER, .arg1_type = ARG_PTR_TO_CTX, .arg2_type = ARG_ANYTHING, - .arg3_type = ARG_PTR_TO_INT, + .arg3_type = ARG_PTR_TO_FIXED_SIZE_MEM | MEM_UNINIT | MEM_ALIGNED, + .arg3_size = sizeof(u32), .arg4_type = ARG_ANYTHING, .arg5_type = ARG_ANYTHING, };
@@ -6244,7 +6245,8 @@ static const struct bpf_func_proto bpf_x .ret_type = RET_INTEGER, .arg1_type = ARG_PTR_TO_CTX, .arg2_type = ARG_ANYTHING, - .arg3_type = ARG_PTR_TO_INT, + .arg3_type = ARG_PTR_TO_FIXED_SIZE_MEM | MEM_UNINIT | MEM_ALIGNED, + .arg3_size = sizeof(u32), .arg4_type = ARG_ANYTHING, .arg5_type = ARG_ANYTHING, };
Greg Kroah-Hartman
maintainerPATCH 758/772 net: Move {l,t,d}stats allocation to core and convert veth & vrf
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 34d21de99cea9cb17967874313e5b0262527833c ]
Move {l,t,d}stats allocation to the core and let netdevs pick the stats type they need. That way the driver doesn't have to bother with error handling (allocation failure checking, making sure free happens in the right spot, etc) - all happening in the core.
Stable-dep-of: 024ee930cb3c ("bpf: Fix dev's rx stats for bpf_redirect_peer traffic")
--- drivers/net/veth.c | 16 +------------ drivers/net/vrf.c | 24 ++++++-------------- include/linux/netdevice.h | 30 ++++++++++++++++++++++---- net/core/dev.c | 53 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 85 insertions(+), 38 deletions(-)
drivers/net/veth.c +2 -14
@@ -1381,25 +1381,12 @@ static void veth_free_queues(struct net_static int veth_dev_init (struct net_device *dev) { -int err; - - dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats); -if (!dev->lstats) -return -ENOMEM ; - - err =veth_alloc_queues (dev); -if (err) { -free_percpu (dev->lstats); -return err; - } - -return 0 ; +return veth_alloc_queues (dev); }static void veth_dev_free (struct net_device *dev) {veth_free_queues (dev); -free_percpu (dev->lstats); }#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1625,6 +1612,7 @@ static void veth_setup(struct net_device NETIF_F_HW_VLAN_STAG_RX); dev->needs_free_netdev = true; dev->priv_destructor = veth_dev_free; + dev->pcpu_stat_type =NETDEV_PCPU_STAT_LSTATS ; dev->max_mtu =ETH_MAX_MTU ; dev->hw_features =VETH_FEATURES ;
drivers/net/vrf.c +7 -17
@@ -121,22 +121,12 @@ struct net_vrf {int ifindex; }; -struct pcpu_dstats { -u64 tx_pkts; -u64 tx_bytes; -u64 tx_drps; -u64 rx_pkts; -u64 rx_bytes; -u64 rx_drps; -struct u64_stats_sync syncp; -}; -static void vrf_rx_stats (struct net_device *dev,int len) {struct pcpu_dstats *dstats =this_cpu_ptr (dev->dstats);u64_stats_update_begin (&dstats->syncp); - dstats->rx_pkts++; + dstats->rx_packets++; dstats->rx_bytes += len;u64_stats_update_end (&dstats->syncp); }
@@ -161,10 +151,10 @@ static void vrf_get_stats64(struct net_ddo { start =u64_stats_fetch_begin_irq (&dstats->syncp); tbytes = dstats->tx_bytes; - tpkts = dstats->tx_pkts; - tdrops = dstats->tx_drps; + tpkts = dstats->tx_packets; + tdrops = dstats->tx_drops; rbytes = dstats->rx_bytes; - rpkts = dstats->rx_pkts; + rpkts = dstats->rx_packets; }while (u64_stats_fetch_retry_irq (&dstats->syncp, start)); stats->tx_bytes += tbytes; stats->tx_packets += tpkts;
@@ -421,7 +411,7 @@ static int vrf_local_xmit(struct sk_buffif (likely (__netif_rx (skb) ==NET_RX_SUCCESS ))vrf_rx_stats (dev, len);else -this_cpu_inc (dev->dstats->rx_drps); +this_cpu_inc (dev->dstats->rx_drops);return NETDEV_TX_OK ; }
@@ -616,11 +606,11 @@ static netdev_tx_t vrf_xmit(struct sk_bustruct pcpu_dstats *dstats =this_cpu_ptr (dev->dstats);u64_stats_update_begin (&dstats->syncp); - dstats->tx_pkts++; + dstats->tx_packets++; dstats->tx_bytes += len;u64_stats_update_end (&dstats->syncp); }else { -this_cpu_inc (dev->dstats->tx_drps); +this_cpu_inc (dev->dstats->tx_drops); }return ret;
include/linux/netdevice.h +26 -4
@@ -1747,6 +1747,13 @@ enum netdev_ml_priv_type { ML_PRIV_CAN, }; +enum netdev_stat_type { +NETDEV_PCPU_STAT_NONE , +NETDEV_PCPU_STAT_LSTATS ,/* struct pcpu_lstats */ +NETDEV_PCPU_STAT_TSTATS ,/* struct pcpu_sw_netstats */ +NETDEV_PCPU_STAT_DSTATS ,/* struct pcpu_dstats */ +}; +/** * struct net_device - The DEVICE structure. *
@@ -1941,10 +1948,14 @@ enum netdev_ml_priv_type {* * @ml_priv: Mid-layer private * @ml_priv_type: Mid-layer private type -* @lstats: Loopback statistics -* @tstats: Tunnel statistics -* @dstats: Dummy statistics -* @vstats: Virtual ethernet statistics +* +* @pcpu_stat_type: Type of device statistics which the core should +* allocate/free: none, lstats, tstats, dstats. none +* means the driver is handling statistics allocation/ +* freeing internally. +* @lstats: Loopback statistics: packets, bytes +* @tstats: Tunnel statistics: RX/TX packets, RX/TX bytes +* @dstats: Dummy statistics: RX/TX/drop packets, RX/TX bytes * * @garp_port: GARP * @mrp_port: MRP
@@ -2287,6 +2298,7 @@ struct net_device {void *ml_priv;enum netdev_ml_priv_type ml_priv_type; + enum netdev_stat_type pcpu_stat_type:8;union {struct pcpu_lstats __percpu *lstats;struct pcpu_sw_netstats __percpu *tstats;
@@ -2670,6 +2682,16 @@ struct pcpu_sw_netstats {struct u64_stats_sync syncp; }__aligned(4 * sizeof(u64)) ; +struct pcpu_dstats { +u64 rx_packets; +u64 rx_bytes; +u64 rx_drops; +u64 tx_packets; +u64 tx_bytes; +u64 tx_drops; +struct u64_stats_sync syncp; +}__aligned(8 * sizeof(u64)) ; +struct pcpu_lstats {u64_stats_t packets;u64_stats_t bytes;
net/core/dev.c +50 -3
93 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 759/772 bpf: Fix devs rx stats for bpf_redirect_peer traffic
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peilin Ye <[email protected]>
[ Upstream commit 024ee930cb3c9ae49e4266aee89cfde0ebb407e1 ]
Traffic redirected by bpf_redirect_peer() (used by recent CNIs like Cilium) is not accounted for in the RX stats of supported devices (that is, veth and netkit), confusing user space metrics collectors such as cAdvisor [0], as reported by Youlun.
Fix it by calling dev_sw_netstats_rx_add() in skb_do_redirect(), to update RX traffic counters. Devices that support ndo_get_peer_dev _must_ use the @tstats per-CPU counters (instead of @lstats, or @dstats).
To make this more fool-proof, error out when ndo_get_peer_dev is set but @tstats are not selected.
[0] Specifically, the "container_network_receive_{byte,packet}s_total" counters are affected.
--- net/core/dev.c | 8 ++++++++ net/core/filter.c | 1 + 2 files changed, 9 insertions(+)
net/core/dev.c +8 -0
@@ -9995,6 +9995,14 @@ static int netdev_do_alloc_pcpu_stats(st {void __percpu *v; +/* Drivers implementing ndo_get_peer_dev must support tstat +* accounting, so that skb_do_redirect() can bump the dev's +* RX stats upon network namespace switch. +*/ +if (dev->netdev_ops->ndo_get_peer_dev && + dev->pcpu_stat_type !=NETDEV_PCPU_STAT_TSTATS ) +return -EOPNOTSUPP ; +switch (dev->pcpu_stat_type) {case NETDEV_PCPU_STAT_NONE :return 0 ;
net/core/filter.c +1 -0
@@ -2491,6 +2491,7 @@ int skb_do_redirect(struct sk_buff *skb) net_eq(net, dev_net(dev)))) goto out_drop; skb->dev = dev; +dev_sw_netstats_rx_add (dev, skb->len);return -EAGAIN ; } return flags & BPF_F_NEIGH ?
Greg Kroah-Hartman
maintainerPATCH 760/772 veth: Use tstats per-CPU traffic counters
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peilin Ye <[email protected]>
[ Upstream commit 6f2684bf2b4460c84d0d34612a939f78b96b03fc ]
Currently veth devices use the lstats per-CPU traffic counters, which only cover TX traffic. veth_get_stats64() actually populates RX stats of a veth device from its peer's TX counters, based on the assumption that a veth device can _only_ receive packets from its peer, which is no longer true:
For example, recent CNIs (like Cilium) can use the bpf_redirect_peer() BPF helper to redirect traffic from NIC's tc ingress to veth's tc ingress (in a different netns), skipping veth's peer device. Unfortunately, this kind of traffic isn't currently accounted for in veth's RX stats.
In preparation for the fix, use tstats (instead of lstats) to maintain both RX and TX counters for each veth device. We'll use RX counters for bpf_redirect_peer() traffic, and keep using TX counters for the usual "peer-to-peer" traffic. In veth_get_stats64(), calculate RX stats by _adding_ RX count to peer's TX count, in order to cover both kinds of traffic.
veth_stats_rx() might need a name change (perhaps to "veth_stats_xdp()") for less confusion, but let's leave it to another patch to keep the fix minimal.
--- drivers/net/veth.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-)
drivers/net/veth.c +11 -19
@@ -342,7 +342,7 @@ static netdev_tx_t veth_xmit(struct sk_bskb_tx_timestamp (skb);if (likely (veth_forward_skb (rcv, skb, rq, use_napi) ==NET_RX_SUCCESS )) {if (!use_napi) -dev_lstats_add (dev, length); +dev_sw_netstats_tx_add (dev,1 , length); }else { drop:atomic64_inc (&priv->dropped);
@@ -357,14 +357,6 @@ drop:return ret; } -static u64 veth_stats_tx (struct net_device *dev,u64 *packets,u64 *bytes) -{ -struct veth_priv *priv =netdev_priv (dev); - -dev_lstats_read (dev, packets, bytes); -return atomic64_read (&priv->dropped); -} -static void veth_stats_rx (struct veth_stats *result,struct net_device *dev) {struct veth_priv *priv =netdev_priv (dev);
@@ -402,24 +394,24 @@ static void veth_get_stats64(struct net_struct veth_priv *priv =netdev_priv (dev);struct net_device *peer;struct veth_stats rx; -u64 packets, bytes; - tot->tx_dropped =veth_stats_tx (dev, &packets, &bytes); - tot->tx_bytes = bytes; - tot->tx_packets = packets; + tot->tx_dropped =atomic64_read (&priv->dropped); +dev_fetch_sw_netstats (tot, dev->tstats);veth_stats_rx (&rx, dev); tot->tx_dropped += rx.xdp_tx_err; tot->rx_dropped = rx.rx_drops + rx.peer_tq_xdp_xmit_err; - tot->rx_bytes = rx.xdp_bytes; - tot->rx_packets = rx.xdp_packets; + tot->rx_bytes += rx.xdp_bytes; + tot->rx_packets += rx.xdp_packets;rcu_read_lock (); peer =rcu_dereference (priv->peer);if (peer) { -veth_stats_tx (peer, &packets, &bytes); - tot->rx_bytes += bytes; - tot->rx_packets += packets; +struct rtnl_link_stats64 tot_peer = {}; + +dev_fetch_sw_netstats (&tot_peer, peer->tstats); + tot->rx_bytes += tot_peer.tx_bytes; + tot->rx_packets += tot_peer.tx_packets;veth_stats_rx (&rx, peer); tot->tx_dropped += rx.peer_tq_xdp_xmit_err;
@@ -1612,7 +1604,7 @@ static void veth_setup(struct net_device NETIF_F_HW_VLAN_STAG_RX); dev->needs_free_netdev = true; dev->priv_destructor = veth_dev_free; - dev->pcpu_stat_type =NETDEV_PCPU_STAT_LSTATS ; + dev->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ; dev->max_mtu =ETH_MAX_MTU ; dev->hw_features =VETH_FEATURES ;
Greg Kroah-Hartman
maintainerPATCH 761/772 drm/ttm: Make sure the mapped tt pages are decrypted when needed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <[email protected]>
commit 71ce046327cfd3aef3f93d1c44e091395eb03f8f upstream.
Some drivers require the mapped tt pages to be decrypted. In an ideal world this would have been handled by the dma layer, but the TTM page fault handling would have to be rewritten to able to do that.
A side-effect of the TTM page fault handling is using a dma allocation per order (via ttm_pool_alloc_page) which makes it impossible to just trivially use dma_mmap_attrs. As a result ttm has to be very careful about trying to make its pgprot for the mapped tt pages match what the dma layer thinks it is. At the ttm layer it's possible to deduce the requirement to have tt pages decrypted by checking whether coherent dma allocations have been requested and the system is running with confidential computing technologies.
This approach isn't ideal but keeping TTM matching DMAs expectations for the page properties is in general fragile, unfortunately proper fix would require a rewrite of TTM's page fault handling.
Fixes vmwgfx with SEV enabled.
v2: Explicitly include cc_platform.h
v3: Use CC_ATTR_GUEST_MEM_ENCRYPT instead of CC_ATTR_MEM_ENCRYPT to limit the scope to guests and log when memory decryption is enabled.
--- drivers/gpu/drm/ttm/ttm_bo_util.c | 13 +++++++++++-- drivers/gpu/drm/ttm/ttm_tt.c | 12 ++++++++++++ include/drm/ttm/ttm_tt.h | 7 +++++++ 3 files changed, 30 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +11 -2
@@ -274,7 +274,13 @@ pgprot_t ttm_io_prot(struct ttm_buffer_oenum ttm_caching caching; man =ttm_manager_type (bo->bdev, res->mem_type); - caching = man->use_tt ? bo->ttm->caching : res->bus.caching; +if (man->use_tt) { + caching = bo->ttm->caching; +if (bo->ttm->page_flags &TTM_TT_FLAG_DECRYPTED ) + tmp =pgprot_decrypted (tmp); + }else { + caching = res->bus.caching; + }return ttm_prot_from_caching (caching, tmp); }
@@ -317,6 +323,8 @@ static int ttm_bo_kmap_ttm(struct ttm_bu .no_wait_gpu = false };struct ttm_tt *ttm = bo->ttm; +struct ttm_resource_manager *man = +ttm_manager_type (bo->bdev, bo->resource->mem_type);pgprot_t prot;int ret;
@@ -326,7 +334,8 @@ static int ttm_bo_kmap_ttm(struct ttm_buif (ret)return ret; -if (num_pages ==1 && ttm->caching == ttm_cached) { +if (num_pages ==1 && ttm->caching == ttm_cached && + !(man->use_tt && (ttm->page_flags &TTM_TT_FLAG_DECRYPTED ))) {/* * We're mapping a single page, and the desired * page protection is consistent with the bo.
drivers/gpu/drm/ttm/ttm_tt.c +12 -0
@@ -31,11 +31,13 @@#define pr_fmt (fmt) "[TTM] " fmt +#include <linux/cc_platform.h> #include <linux/sched.h> #include <linux/shmem_fs.h> #include <linux/file.h> #include <linux/module.h> #include <drm/drm_cache.h> +#include <drm/drm_device.h> #include <drm/ttm/ttm_bo_driver.h> #include "ttm_module.h"
@@ -59,6 +61,7 @@ static atomic_long_t ttm_dma32_pages_allint ttm_tt_create (struct ttm_buffer_object *bo,bool zero_alloc) {struct ttm_device *bdev = bo->bdev; +struct drm_device *ddev = bo->base.dev;uint32_t page_flags =0 ;dma_resv_assert_held (bo->base.resv);
@@ -80,6 +83,15 @@ int ttm_tt_create(struct ttm_buffer_objepr_err ("Illegal buffer object type\n" );return -EINVAL ; } +/* +* When using dma_alloc_coherent with memory encryption the +* mapped TT pages need to be decrypted or otherwise the drivers +* will end up sending encrypted mem to the gpu. +*/ +if (bdev->pool.use_dma_alloc &&cc_platform_has (CC_ATTR_GUEST_MEM_ENCRYPT )) { + page_flags |=TTM_TT_FLAG_DECRYPTED ; +drm_info (ddev,"TT memory decryption enabled." ); + } bo->ttm = bdev->funcs->ttm_tt_create (bo, page_flags);if (unlikely (bo->ttm ==NULL ))
include/drm/ttm/ttm_tt.h +7 -0
@@ -79,6 +79,12 @@ struct ttm_tt {* page_flags = TTM_TT_FLAG_EXTERNAL | * TTM_TT_FLAG_EXTERNAL_MAPPABLE; * +* TTM_TT_FLAG_DECRYPTED: The mapped ttm pages should be marked as +* not encrypted. The framework will try to match what the dma layer +* is doing, but note that it is a little fragile because ttm page +* fault handling abuses the DMA api a bit and dma_map_attrs can't be +* used to assure pgprot always matches. +* * TTM_TT_FLAG_PRIV_POPULATED: TTM internal only. DO NOT USE. This is * set by TTM after ttm_tt_populate() has successfully returned, and is * then unset when TTM calls ttm_tt_unpopulate().
@@ -87,6 +93,7 @@ struct ttm_tt {#define TTM_TT_FLAG_ZERO_ALLOC (1 << 1)#define TTM_TT_FLAG_EXTERNAL (1 << 2)#define TTM_TT_FLAG_EXTERNAL_MAPPABLE (1 << 3) +#define TTM_TT_FLAG_DECRYPTED (1 << 4)#define TTM_TT_FLAG_PRIV_POPULATED (1U << 31)uint32_t page_flags;
Greg Kroah-Hartman
maintainerPATCH 762/772 drm/ttm: Print the memory decryption status just once
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <[email protected]>
commit 27906e5d78248b19bcdfdae72049338c828897bb upstream.
Stop printing the TT memory decryption status info each time tt is created and instead print it just once.
Reduces the spam in the system logs when running guests with SEV enabled.
--- drivers/gpu/drm/ttm/ttm_tt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_tt.c +1 -1
@@ -90,7 +90,7 @@ int ttm_tt_create(struct ttm_buffer_obje*/ if (bdev->pool.use_dma_alloc &&cc_platform_has (CC_ATTR_GUEST_MEM_ENCRYPT )) { page_flags |=TTM_TT_FLAG_DECRYPTED ; -drm_info (ddev,"TT memory decryption enabled." ); +drm_info_once (ddev,"TT memory decryption enabled." ); } bo->ttm = bdev->funcs->ttm_tt_create (bo, page_flags);
Greg Kroah-Hartman
maintainerPATCH 763/772 drm/amdgpu: rework resume handling for display (v2)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 73dae652dcac776296890da215ee7dec357a1032 upstream.
Split resume into a 3rd step to handle displays when DCC is enabled on DCN 4.0.1. Move display after the buffer funcs have been re-enabled so that the GPU will do the move and properly set the DCC metadata for DCN.
v2: fix fence irq resume ordering
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 +++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43 -2
@@ -3242,7 +3242,7 @@ static int amdgpu_device_ip_resume_phase* * @adev: amdgpu_device pointer * -* First resume function for hardware IPs. The list of all the hardware +* Second resume function for hardware IPs. The list of all the hardware * IPs that make up the asic is walked and the resume callbacks are run for * all blocks except COMMON, GMC, and IH. resume puts the hardware into a * functional state after a suspend and updates the software state as
@@ -3260,6 +3260,7 @@ static int amdgpu_device_ip_resume_phaseif (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_COMMON || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_GMC || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_IH || + adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_DCE || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_PSP )continue ; r = adev->ip_blocks[i].version->funcs->resume (adev);
@@ -3284,6 +3285,36 @@ static int amdgpu_device_ip_resume_phase }/** +* amdgpu_device_ip_resume_phase3 - run resume for hardware IPs +* +* @adev: amdgpu_device pointer +* +* Third resume function for hardware IPs. The list of all the hardware +* IPs that make up the asic is walked and the resume callbacks are run for +* all DCE. resume puts the hardware into a functional state after a suspend +* and updates the software state as necessary. This function is also used +* for restoring the GPU after a GPU reset. +* +* Returns 0 on success, negative error code on failure. +*/ +static int amdgpu_device_ip_resume_phase3 (struct amdgpu_device *adev) +{ +int i, r; + +for (i =0 ; i < adev->num_ip_blocks; i++) { +if (!adev->ip_blocks[i].status.valid || adev->ip_blocks[i].status.hw) +continue ; +if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_DCE ) { + r = adev->ip_blocks[i].version->funcs->resume (adev); +if (r) +return r; + } + } + +return 0 ; +} + +/** * amdgpu_device_ip_resume - run resume for hardware IPs * * @adev: amdgpu_device pointer
@@ -3313,6 +3344,13 @@ static int amdgpu_device_ip_resume(struc r =amdgpu_device_ip_resume_phase2 (adev); +if (r) +return r; + +amdgpu_fence_driver_hw_init (adev); + + r =amdgpu_device_ip_resume_phase3 (adev); +return r; }
@@ -4311,7 +4349,6 @@ int amdgpu_device_resume(struct drm_devidev_err (adev->dev,"amdgpu_device_ip_resume failed (%d).\n" , r);return r; } -amdgpu_fence_driver_hw_init (adev); r =amdgpu_device_ip_late_init (adev);if (r)
@@ -5065,6 +5102,10 @@ int amdgpu_do_asic_reset(struct list_heaif (r) goto out; + r =amdgpu_device_ip_resume_phase3 (tmp_adev); +if (r) + goto out; +if (vram_lost)amdgpu_device_fill_reset_magic (tmp_adev);
Greg Kroah-Hartman
maintainerPATCH 764/772 usb: dwc3: ep0: Dont reset resource alloc flag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thinh Nguyen <[email protected]>
commit f2e0eee4703869dc5edb5302a919861566ca7797 upstream.
The DWC3_EP_RESOURCE_ALLOCATED flag ensures that the resource of an endpoint is only assigned once. Unless the endpoint is reset, don't clear this flag. Otherwise we may set endpoint resource again, which prevents the driver from initiate transfer after handling a STALL or endpoint halt to the control endpoint.
--- drivers/usb/dwc3/ep0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/ep0.c +2 -1
@@ -224,7 +224,8 @@ void dwc3_ep0_stall_and_restart(struct d/* reinitialize physical ep1 */ dep = dwc->eps[1 ]; - dep->flags =DWC3_EP_ENABLED ; + dep->flags &=DWC3_EP_RESOURCE_ALLOCATED ; + dep->flags |=DWC3_EP_ENABLED ;/* stall is always issued on EP0 */ dep = dwc->eps[0 ];
Greg Kroah-Hartman
maintainerPATCH 765/772 serial: amba-pl011: fix build regression
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit b5a23a60e8ab5711f4952912424347bf3864ce8d upstream.
When CONFIG_DMA_ENGINE is disabled, the driver now fails to build:
drivers/tty/serial/amba-pl011.c: In function 'pl011_unthrottle_rx':drivers/tty/serial/amba-pl011.c:1822:16: error: 'struct uart_amba_port' has no member named 'using_rx_dma'
1822 | if (uap->using_rx_dma) {
| ^~drivers/tty/serial/amba-pl011.c:1823:20: error: 'struct uart_amba_port' has no member named 'dmacr'
1823 | uap->dmacr |= UART011_RXDMAE;
| ^~drivers/tty/serial/amba-pl011.c:1824:32: error: 'struct uart_amba_port' has no member named 'dmacr'
1824 | pl011_write(uap->dmacr, uap, REG_DMACR);
| ^~
Add the missing #ifdef check around these field accesses, matching what other parts of this driver do.
--- drivers/tty/serial/amba-pl011.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/amba-pl011.c +2 -0
@@ -1837,10 +1837,12 @@ static void pl011_unthrottle_rx(struct upl011_write (uap->im, uap,REG_IMSC ); +#ifdef CONFIG_DMA_ENGINE if (uap->using_rx_dma) { uap->dmacr |=UART011_RXDMAE ;pl011_write (uap->dmacr, uap,REG_DMACR ); } +#endif uart_port_unlock_irqrestore (&uap->port, flags); }
Greg Kroah-Hartman
maintainerPATCH 766/772 i3c: master: Remove i3c_dev_disable_ibi_locked(olddev) on device hotjoin
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 36faa04ce3d9c962b4b29d285ad07ca29e2988e4 upstream.
When a new device hotjoins, a new dynamic address is assigned. i3c_master_add_i3c_dev_locked() identifies that the device was previously attached to the bus and locates the olddev.
i3c_master_add_i3c_dev_locked()
{
...
olddev = i3c_master_search_i3c_dev_duplicate(newdev);
...
if (olddev) {
...
i3c_dev_disable_ibi_locked(olddev);
^^^^^^
The olddev should not receive any commands on the i3c bus as it
does not exist and has been assigned a new address. This will
result in NACK or timeout. So remove it.
}
i3c_dev_free_ibi_locked(olddev);
^^^^^^^^
This function internally calls i3c_dev_disable_ibi_locked() function
causing to send DISEC command with old Address.
The olddev should not receive any commands on the i3c bus as it
does not exist and has been assigned a new address. This will
result in NACK or timeout. So, update the olddev->ibi->enabled
flag to false to avoid DISEC with OldAddr.
}Include part of Ravindra Yashvant Shinde's work:
https://lore.kernel.org/linux-i3c/[email protected]/T/#u
--- drivers/i3c/master.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/i3c/master.c +9 -4
@@ -2031,11 +2031,16 @@ int i3c_master_add_i3c_dev_locked(struct ibireq.max_payload_len = olddev->ibi->max_payload_len; ibireq.num_slots = olddev->ibi->num_slots; -if (olddev->ibi->enabled) { +if (olddev->ibi->enabled) enable_ibi = true; -i3c_dev_disable_ibi_locked (olddev); - } - +/* +* The olddev should not receive any commands on the +* i3c bus as it does not exist and has been assigned +* a new address. This will result in NACK or timeout. +* So, update the olddev->ibi->enabled flag to false +* to avoid DISEC with OldAddr. +*/ + olddev->ibi->enabled = false;i3c_dev_free_ibi_locked (olddev); }mutex_unlock (&olddev->ibi_lock);
Greg Kroah-Hartman
maintainerPATCH 767/772 i3c: master: svc: fix possible assignment of the same address to two devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 3b2ac810d86eb96e882db80a3320a3848b133208 upstream.
svc_i3c_master_do_daa() {
...
for (i = 0; i < dev_nb; i++) {
ret = i3c_master_add_i3c_dev_locked(m, addrs[i]);
if (ret)
goto rpm_out;
}
}If two devices (A and B) are detected in DAA and address 0xa is assigned to device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked() for device A (addr: 0xa) could prevent device B (addr: 0xb) from being registered on the bus. The I3C stack might still consider 0xb a free address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A, causing both devices A and B to use the same address 0xb, violating the I3C specification.
The return value for i3c_master_add_i3c_dev_locked() should not be checked because subsequent steps will scan the entire I3C bus, independent of whether i3c_master_add_i3c_dev_locked() returns success.
If device A registration fails, there is still a chance to register device B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while retrieving device information.
--- drivers/i3c/master/svc-i3c-master.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
drivers/i3c/master/svc-i3c-master.c +21 -6
@@ -1010,12 +1010,27 @@ static int svc_i3c_master_do_daa(struct goto rpm_out; } -/* Register all devices who participated to the core */ -for (i =0 ; i < dev_nb; i++) { - ret =i3c_master_add_i3c_dev_locked (m, addrs[i]); -if (ret) - goto rpm_out; - } +/* +* Register all devices who participated to the core +* +* If two devices (A and B) are detected in DAA and address 0xa is assigned to +* device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked() +* for device A (addr: 0xa) could prevent device B (addr: 0xb) from being +* registered on the bus. The I3C stack might still consider 0xb a free +* address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A, +* causing both devices A and B to use the same address 0xb, violating the I3C +* specification. +* +* The return value for i3c_master_add_i3c_dev_locked() should not be checked +* because subsequent steps will scan the entire I3C bus, independent of +* whether i3c_master_add_i3c_dev_locked() returns success. +* +* If device A registration fails, there is still a chance to register device +* B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while +* retrieving device information. +*/ +for (i =0 ; i < dev_nb; i++) +i3c_master_add_i3c_dev_locked (m, addrs[i]);/* Configure IBI auto-rules */ ret =svc_i3c_update_ibirules (master);
Greg Kroah-Hartman
maintainerPATCH 768/772 PM / devfreq: Fix build issues with devfreq disabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <[email protected]>
commit dbd7a2a941b8cbf9e5f79a777ed9fe0090eebb61 upstream.
The existing no-op shims for when PM_DEVFREQ (or an individual governor) only do half the job. The governor specific config/tuning structs need to be available to avoid compile errors in drivers using devfreq.
Patchwork: https://patchwork.freedesktop.org/patch/519801/
--- include/linux/devfreq.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
include/linux/devfreq.h +2 -5
@@ -273,8 +273,8 @@ void devm_devfreq_unregister_notifier(ststruct devfreq *devfreq_get_devfreq_by_node (struct device_node *node);struct devfreq *devfreq_get_devfreq_by_phandle (struct device *dev,const char *phandle_name,int index); +#endif /* CONFIG_PM_DEVFREQ */ -#if IS_ENABLED (CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND )/** * struct devfreq_simple_ondemand_data - ``void *data`` fed to struct devfreq * and devfreq_add_device
@@ -292,9 +292,7 @@ struct devfreq_simple_ondemand_data {unsigned int upthreshold;unsigned int downdifferential; }; -#endif -#if IS_ENABLED (CONFIG_DEVFREQ_GOV_PASSIVE )enum devfreq_parent_dev_type {DEVFREQ_PARENT_DEV ,CPUFREQ_PARENT_DEV ,
@@ -337,9 +335,8 @@ struct devfreq_passive_data {struct notifier_block nb;struct list_head cpu_data_list; }; -#endif -#else /* !CONFIG_PM_DEVFREQ */ +#if !defined(CONFIG_PM_DEVFREQ ) static inline struct devfreq *devfreq_add_device(struct device *dev, struct devfreq_dev_profile *profile, const char *governor_name,
Greg Kroah-Hartman
maintainerPATCH 769/772 drm/msm: DEVFREQ_GOV_SIMPLE_ONDEMAND is no longer needed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
commit a722511b18268bd1f7084eee243af416b85f288f upstream.
DRM_MSM no longer needs DEVFREQ_GOV_SIMPLE_ONDEMAND (since commit dbd7a2a941b8 ("PM / devfreq: Fix build issues with devfreq disabled") in linux-next), so remove that select from the DRM_MSM Kconfig file.
Patchwork: https://patchwork.freedesktop.org/patch/523353/
--- drivers/gpu/drm/msm/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/msm/Kconfig +0 -1
@@ -23,7 +23,6 @@ config DRM_MSM select SHMEM select TMPFS select QCOM_SCM - select DEVFREQ_GOV_SIMPLE_ONDEMAND select WANT_DEV_COREDUMP select SND_SOC_HDMI_CODEC if SND_SOC select SYNC_FILE
Greg Kroah-Hartman
maintainerPATCH 770/772 fs/ntfs3: Sequential field availability check in mi_enum_attr()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
commit 090f612756a9720ec18b0b130e28be49839d7cb5 upstream.
The code is slightly reformatted to consistently check field availability without duplication.
--- fs/ntfs3/record.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
fs/ntfs3/record.c +7 -8
@@ -231,6 +231,7 @@ struct ATTRIB *mi_enum_attr(struct mft_i }/* Can we use the first field (attr->type). */ +/* NOTE: this code also checks attr->size availability. */ if (off +8 > used) {static_assert (ALIGN (sizeof (enum ATTR_TYPE ),8 ) ==8 );return NULL ;
@@ -251,10 +252,6 @@ struct ATTRIB *mi_enum_attr(struct mft_ireturn NULL ; asize =le32_to_cpu (attr->size); -if (asize <SIZEOF_RESIDENT ) { -/* Impossible 'cause we should not return such attribute. */ -return NULL ; - }/* Check overflow and boundary. */ if (off + asize < off || off + asize > used)
@@ -285,6 +282,10 @@ struct ATTRIB *mi_enum_attr(struct mft_iif (attr->non_res !=1 )return NULL ; +/* Can we use memory including attr->nres.valid_size? */ +if (asize <SIZEOF_NONRESIDENT ) +return NULL ; + t16 =le16_to_cpu (attr->nres.run_off);if (t16 > asize)return NULL ;
@@ -311,7 +312,8 @@ struct ATTRIB *mi_enum_attr(struct mft_iif (!attr->nres.svcn &&is_attr_ext (attr)) {/* First segment of sparse/compressed attribute */ -if (asize +8 <SIZEOF_NONRESIDENT_EX ) +/* Can we use memory including attr->nres.total_size? */ +if (asize <SIZEOF_NONRESIDENT_EX )return NULL ; tot_size =le64_to_cpu (attr->nres.total_size);
@@ -321,9 +323,6 @@ struct ATTRIB *mi_enum_attr(struct mft_iif (tot_size > alloc_size)return NULL ; }else { -if (asize +8 <SIZEOF_NONRESIDENT ) -return NULL ; -if (attr->nres.c_unit)return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 771/772 i3c: master: svc: Fix use after free vulnerability in svc_i3c_master Driver Due to Race Condition
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixin Wang <[email protected]>
commit 61850725779709369c7e907ae8c7c75dc7cec4f3 upstream.
In the svc_i3c_master_probe function, &master->hj_work is bound with svc_i3c_master_hj_work, &master->ibi_work is bound with svc_i3c_master_ibi_work. And svc_i3c_master_ibi_work can start the hj_work, svc_i3c_master_irq_handler can start the ibi_work.
If we remove the module which will call svc_i3c_master_remove to make cleanup, it will free master->base through i3c_master_unregister while the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows:
CPU0 CPU1
| svc_i3c_master_hj_work
svc_i3c_master_remove |
i3c_master_unregister(&master->base)|
device_unregister(&master->dev) |
device_release |
//free master->base |
| i3c_master_do_daa(&master->base)
| //use master->baseFix it by ensuring that the work is canceled before proceeding with the cleanup in svc_i3c_master_remove.
--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
@@ -1772,6 +1772,7 @@ static int svc_i3c_master_remove(struct {struct svc_i3c_master *master =platform_get_drvdata (pdev); +cancel_work_sync (&master->hj_work);i3c_master_unregister (&master->base);pm_runtime_dont_use_autosuspend (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 772/772 Bluetooth: MGMT: Fix possible deadlocks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit a66dfaf18fd61bb75ef8cee83db46b2aadf153d0 upstream.
This fixes possible deadlocks like the following caused by hci_cmd_sync_dequeue causing the destroy function to run:
INFO: task kworker/u19:0:143 blocked for more than 120 seconds.
Tainted: G W O 6.8.0-2024-03-19-intel-next-iLS-24ww14 #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/u19:0 state:D stack:0 pid:143 tgid:143 ppid:2 flags:0x00004000
Workqueue: hci0 hci_cmd_sync_work [bluetooth]
Call Trace:
<TASK>
__schedule+0x374/0xaf0
schedule+0x3c/0xf0
schedule_preempt_disabled+0x1c/0x30
__mutex_lock.constprop.0+0x3ef/0x7a0
__mutex_lock_slowpath+0x13/0x20
mutex_lock+0x3c/0x50
mgmt_set_connectable_complete+0xa4/0x150 [bluetooth]
? kfree+0x211/0x2a0
hci_cmd_sync_dequeue+0xae/0x130 [bluetooth]
? __pfx_cmd_complete_rsp+0x10/0x10 [bluetooth]
cmd_complete_rsp+0x26/0x80 [bluetooth]
mgmt_pending_foreach+0x4d/0x70 [bluetooth]
__mgmt_power_off+0x8d/0x180 [bluetooth]
? _raw_spin_unlock_irq+0x23/0x40
hci_dev_close_sync+0x445/0x5b0 [bluetooth]
hci_set_powered_sync+0x149/0x250 [bluetooth]
set_powered_sync+0x24/0x60 [bluetooth]
hci_cmd_sync_work+0x90/0x150 [bluetooth]
process_one_work+0x13e/0x300
worker_thread+0x2f7/0x420
? __pfx_worker_thread+0x10/0x10
kthread+0x107/0x140
? __pfx_kthread+0x10/0x10
ret_from_fork+0x3d/0x60
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1b/0x30
</TASK>--- net/bluetooth/mgmt.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
net/bluetooth/mgmt.c +18 -9
@@ -1521,7 +1521,8 @@ static void mgmt_set_discoverable_complebt_dev_dbg (hdev,"err %d" , err);/* Make sure cmd still outstanding. */ -if (cmd !=pending_find (MGMT_OP_SET_DISCOVERABLE , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_DISCOVERABLE , hdev))return ;hci_dev_lock (hdev);
@@ -1695,7 +1696,8 @@ static void mgmt_set_connectable_completbt_dev_dbg (hdev,"err %d" , err);/* Make sure cmd still outstanding. */ -if (cmd !=pending_find (MGMT_OP_SET_CONNECTABLE , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_CONNECTABLE , hdev))return ;hci_dev_lock (hdev);
@@ -1928,7 +1930,7 @@ static void set_ssp_complete(struct hci_bool changed;/* Make sure cmd still outstanding. */ -if (cmd !=pending_find (MGMT_OP_SET_SSP , hdev)) +if (err == -ECANCELED || cmd !=pending_find (MGMT_OP_SET_SSP , hdev))return ;if (err) {
@@ -3853,7 +3855,8 @@ static void set_name_complete(struct hcibt_dev_dbg (hdev,"err %d" , err); -if (cmd !=pending_find (MGMT_OP_SET_LOCAL_NAME , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_LOCAL_NAME , hdev))return ;if (status) {
@@ -4028,7 +4031,8 @@ static void set_default_phy_complete(strstruct sk_buff *skb = cmd->skb;u8 status =mgmt_status (err); -if (cmd !=pending_find (MGMT_OP_SET_PHY_CONFIGURATION , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_PHY_CONFIGURATION , hdev))return ;if (!status) {
@@ -5919,13 +5923,16 @@ static void start_discovery_complete(str {struct mgmt_pending_cmd *cmd = data; +bt_dev_dbg (hdev,"err %d" , err); + +if (err == -ECANCELED ) +return ; +if (cmd !=pending_find (MGMT_OP_START_DISCOVERY , hdev) && cmd !=pending_find (MGMT_OP_START_LIMITED_DISCOVERY , hdev) && cmd !=pending_find (MGMT_OP_START_SERVICE_DISCOVERY , hdev))return ; -bt_dev_dbg (hdev,"err %d" , err); -mgmt_cmd_complete (cmd->sk, cmd->index, cmd->opcode,mgmt_status (err), cmd->param,1 );mgmt_pending_remove (cmd);
@@ -6158,7 +6165,8 @@ static void stop_discovery_complete(stru {struct mgmt_pending_cmd *cmd = data; -if (cmd !=pending_find (MGMT_OP_STOP_DISCOVERY , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_STOP_DISCOVERY , hdev))return ;bt_dev_dbg (hdev,"err %d" , err);
@@ -8105,7 +8113,8 @@ static void read_local_oob_ext_data_compu8 status =mgmt_status (err);u16 eir_len; -if (cmd !=pending_find (MGMT_OP_READ_LOCAL_OOB_EXT_DATA , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_READ_LOCAL_OOB_EXT_DATA , hdev))return ;if (!status) {
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +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.1.120-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
The powerpc builds failed on Linux stable-rc linux-6.1.y due to following build warnings / errors.
powerpc:
* build/gcc-13-tqm8xx_defconfig
First seen on Linux stable-rc v6.1.119-773-g9f320894b9c2.
Good: v6.1.119
Bad: v6.1.119-773-g9f320894b9c2
Build log:
-----
/builds/linux/arch/powerpc/include/asm/page_32.h:16: error:
"ARCH_DMA_MINALIGN" redefined [-Werror]
16 | #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
|
In file included from /builds/linux/include/linux/slab.h:15:
/builds/linux/include/linux/cache.h:104: note: this is the location of the previous definition
104 | #define ARCH_DMA_MINALIGN __alignof__(unsigned long long)
|
cc1: all warnings being treated as errors
The bisection pointed to,
mm/slab: decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA_MINALIGN commit 4ab5f8ec7d71aea5fe13a48248242130f84ac6bb upstream.
Links:
-------
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.1.y/build/v6.1.119-773-g9f320894b9c2/testrun/26283233/suite/build/test/gcc-13-tqm8xx_defconfig/log
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.1.y/build/v6.1.119-773-g9f320894b9c2/testrun/26283233/suite/build/test/gcc-13-tqm8xx_defconfig/details/
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.1.y/build/v6.1.119-773-g9f320894b9c2/testrun/26283233/suite/build/test/gcc-13-tqm8xx_defconfig/history/
Steps to reproduce:
------------
# tuxmake --runtime podman --target-arch powerpc --toolchain gcc-13 --kconfig tqm8xx_defconfig
metadata:
----
git describe: v6.1.119-773-g9f320894b9c2
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git sha: 9f320894b9c2f9e21bda8aac6c57a2e6395f8eba
kernel config:
https://storage.tuxsuite.com/public/linaro/lkft/builds/2q7iTg4R40CXEIVAGM9hWTEqyjR/config
build url: https://storage.tuxsuite.com/public/linaro/lkft/builds/2q7iTg4R40CXEIVAGM9hWTEqyjR/
toolchain: gcc-13
config: gcc-13-tqm8xx_defconfig
arch: powerpc
--
Linaro LKFT
https://lkft.linaro.org
Greg Kroah-Hartman
maintainerQuoted 43 lines · Naresh Kamboju
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +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.1.120-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
The powerpc builds failed on Linux stable-rc linux-6.1.y due to following build warnings / errors.
powerpc:
* build/gcc-13-tqm8xx_defconfigFirst seen on Linux stable-rc v6.1.119-773-g9f320894b9c2.
Good: v6.1.119
Bad: v6.1.119-773-g9f320894b9c2Build log:
-----
/builds/linux/arch/powerpc/include/asm/page_32.h:16: error:
"ARCH_DMA_MINALIGN" redefined [-Werror]
16 | #defineARCH_DMA_MINALIGNL1_CACHE_BYTES|In file included from /builds/linux/include/linux/slab.h:15:
/builds/linux/include/linux/cache.h:104: note: this is the location of the previous definition
104 | #defineARCH_DMA_MINALIGN__alignof__(unsigned long long)
Quoted 6 lines
|cc1: all warnings being treated as errors
The bisection pointed to,
mm/slab: decoupleARCH_KMALLOC_MINALIGNfromARCH_DMA_MINALIGNcommit4ab5f8ec7d71aea5fe13a48248242130f84ac6bbupstream.
Ick, this was to fix a different build error. Looks like I need to queue up 78615c4ddb73 ("powerpc: move the ARCH_DMA_MINALIGN definition to asm/cache.h") as well, I'll go do that now...
thanks,
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +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.1.120-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.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:
There is a new warning though:
scripts/mod/modpost.c:969:44: warning: excess elements in array initializer
969 | .good_tosec = {ALL_TEXT_SECTIONS , NULL},
| ^~~~scripts/mod/modpost.c:969:44: note: (near initialization for ‘sectioncheck[10].good_tosec’)
HOSTLD scripts/mod/modpost
Signature · 1 line
Florian
Greg Kroah-Hartman
maintainerQuoted 24 lines · Florian Fainelli
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +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.1.120-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
On
ARCH_BRCMSTBusing 32-bit and 64-bit ARM kernels, build tested onBMIPS_GENERIC:Tested-by Florian Fainelli <[email protected]>
Quoted 8 lines
There is a new warning though:
scripts/mod/modpost.c:969:44: warning: excess elements in array initializer
969 | .good_tosec = {ALL_TEXT_SECTIONS, NULL},
| ^~~~scripts/mod/modpost.c:969:44: note: (near initialization for ‘sectioncheck[10].good_tosec’)
HOSTLDscripts/mod/modpost
I thought I saw that but kind of ignored it, but in looking at it further, it's not good at all. Let me go fix this up, for some reason we have "too many" entries in this list and so we could flow over the end of the buffer here...
thanks,
greg k-h
Am 12.12.2024 um 15:49 schrieb Greg Kroah-Hartman:
Quoted 4 lines
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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.
Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697 v2 server. No dmesg oddities or regressions found.
Beste Grüße,
Peter Schneider
Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge, enjoy the air and behold the view. Climb it so you can see the world, not so the world can see you. -- David McCullough Jr. OpenPGP: 0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244 Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc https://keys.mailvelope.com/pks/lookup?op=get&[email protected] https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +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.1.120-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
New warning on Linux 6.1.120-rc1.
scripts/mod/modpost.c:969:44: warning: excess elements in array initializer 969 | .good_tosec = {ALL_TEXT_SECTIONS , NULL},
| ^~~~ scripts/mod/modpost.c:969:44: note: (near initialization for ‘sectioncheck[10].good_tosec’)
Caused by commit 20e6d91ba71543164151fc63ef978f28dda75394
modpost: Add .irqentry.text to OTHER_SECTIONS
Greg Kroah-Hartman
maintainerQuoted 27 lines · Ron Economos
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +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.1.120-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
New warning on Linux 6.1.120-rc1.
scripts/mod/modpost.c:969:44: warning: excess elements in array initializer 969 | .good_tosec = {ALL_TEXT_SECTIONS, NULL},
| ^~~~scripts/mod/modpost.c:969:44: note: (near initialization for ‘sectioncheck[10].good_tosec’)
Quoted 5 lines
Caused by commit
20e6d91ba71543164151fc63ef978f28dda75394modpost: Add .irqentry.text to
OTHER_SECTIONS
Thanks, I've now fixed this up.
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +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.1.120-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v6.1:
10 builds: 10 pass, 0 fail
26 boots: 26 pass, 0 fail
115 tests: 115 pass, 0 failLinux version: 6.1.120-rc1-g9f320894b9c2
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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.
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +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.1.120-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Hello,
Quoted 7 lines · On Thu, 12 Dec 2024 15:49:05 +0100 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.1.120 release. There are 772 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 Sat, 14 Dec 2024 14:41:35 +0000. Anything received after that time might be too late.
This rc kernel passes DAMON functionality test[1] on my test machine. Attaching the test results summary below. Please note that I retrieved the kernel from linux-stable-rc tree[2].
[1] https://github.com/damonitor/damon-tests/tree/next/corr
[2] e4aa4e0f93a4 ("Linux 6.1.120-rc1")
Thanks,
SJ
[...]
---
ok 1 selftests: damon: debugfs_attrs.sh
ok 2 selftests: damon: debugfs_schemes.sh
ok 3 selftests: damon: debugfs_target_ids.sh
ok 4 selftests: damon: debugfs_empty_targets.sh
ok 5 selftests: damon: debugfs_huge_count_read_write.sh
ok 6 selftests: damon: debugfs_duplicate_context_creation.sh
ok 7 selftests: damon: sysfs.sh
ok 1 selftests: damon-tests: kunit.sh
ok 2 selftests: damon-tests: huge_count_read_write.sh
ok 3 selftests: damon-tests: buffer_overflow.sh
ok 4 selftests: damon-tests: rm_contexts.sh
ok 5 selftests: damon-tests: record_null_deref.sh
ok 6 selftests: damon-tests: dbgfs_target_ids_read_before_terminate_race.sh ok 7 selftests: damon-tests: dbgfs_target_ids_pid_leak.sh
ok 8 selftests: damon-tests: damo_tests.sh
ok 9 selftests: damon-tests: masim-record.sh
ok 10 selftests: damon-tests: build_i386.sh
ok 11 selftests: damon-tests: build_arm64.sh # SKIP
ok 12 selftests: damon-tests: build_m68k.sh # SKIP
ok 13 selftests: damon-tests: build_i386_idle_flag.sh
ok 14 selftests: damon-tests: build_i386_highpte.sh
ok 15 selftests: damon-tests: build_nomemcg.sh
[33m
[92mPASS [39m