6.1.84-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 130/272 net: hns3: tracing: fix hclgevf trace event strings
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 3f9952e8d80cca2da3b47ecd5ad9ec16cfd1a649 ]
The __string() and __assign_str() helper macros of the TRACE_EVENT() macro are going through some optimizations where only the source string of __string() will be used and the __assign_str() source will be ignored and later removed.
To make sure that there's no issues, a new check is added between the __string() src argument and the __assign_str() src argument that does a strcmp() to make sure they are the same string.
The hclgevf trace events have:
__assign_str(devname, &hdev->nic.kinfo.netdev->name);
Which triggers the warning:
hclgevf_trace.h:34:39: error: passing argument 1 of ‘strcmp’ from incompatible pointer type [-Werror=incompatible-pointer-types]
34 | __assign_str(devname, &hdev->nic.kinfo.netdev->name);
[..]arch/x86/include/asm/string_64.h:75:24: note: expected ‘const char *’ but argument is of type ‘char (*)[16]’
75 | int strcmp(const char *cs, const char *ct);
| ~~~~~~~~~~~~^~Because __assign_str() now has:
WARN_ON_ONCE(__builtin_constant_p(src) ? \ strcmp((src), __data_offsets.dst##_ptr_) : \ (src) != __data_offsets.dst##_ptr_); \
The problem is the '&' on hdev->nic.kinfo.netdev->name. That's because that name is:
char name[IFNAMSIZ]
Where passing an address '&' of a char array is not compatible with strcmp().
The '&' is not necessary, remove it.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h | 8 ++++---- .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h +4 -4
@@ -24,7 +24,7 @@ TRACE_EVENT(hclge_pf_mbx_get, __field(u8, code) __field(u8, subcode) __string(pciname, pci_name(hdev->pdev)) - __string(devname, &hdev->vport[0].nic.kinfo.netdev->name) + __string(devname, hdev->vport[0].nic.kinfo.netdev->name)__array (u32, mbx_data,PF_GET_MBX_LEN ) ),
@@ -33,7 +33,7 @@ TRACE_EVENT(hclge_pf_mbx_get, __entry->code = req->msg.code; __entry->subcode = req->msg.subcode;__assign_str (pciname,pci_name (hdev->pdev)); -__assign_str (devname, &hdev->vport[0 ].nic.kinfo.netdev->name); +__assign_str (devname, hdev->vport[0 ].nic.kinfo.netdev->name);memcpy (__entry->mbx_data, req,sizeof (struct hclge_mbx_vf_to_pf_cmd )); ),
@@ -56,7 +56,7 @@ TRACE_EVENT(hclge_pf_mbx_send, __field(u8, vfid) __field(u16, code) __string(pciname, pci_name(hdev->pdev)) - __string(devname, &hdev->vport[0].nic.kinfo.netdev->name) + __string(devname, hdev->vport[0].nic.kinfo.netdev->name)__array (u32, mbx_data,PF_SEND_MBX_LEN ) ),
@@ -64,7 +64,7 @@ TRACE_EVENT(hclge_pf_mbx_send, __entry->vfid = req->dest_vfid; __entry->code =le16_to_cpu (req->msg.code);__assign_str (pciname,pci_name (hdev->pdev)); -__assign_str (devname, &hdev->vport[0 ].nic.kinfo.netdev->name); +__assign_str (devname, hdev->vport[0 ].nic.kinfo.netdev->name);memcpy (__entry->mbx_data, req,sizeof (struct hclge_mbx_pf_to_vf_cmd )); ),
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h +4 -4
@@ -23,7 +23,7 @@ TRACE_EVENT(hclge_vf_mbx_get, __field(u8, vfid) __field(u16, code) __string(pciname, pci_name(hdev->pdev)) - __string(devname, &hdev->nic.kinfo.netdev->name) + __string(devname, hdev->nic.kinfo.netdev->name)__array (u32, mbx_data,VF_GET_MBX_LEN ) ),
@@ -31,7 +31,7 @@ TRACE_EVENT(hclge_vf_mbx_get, __entry->vfid = req->dest_vfid; __entry->code =le16_to_cpu (req->msg.code);__assign_str (pciname,pci_name (hdev->pdev)); -__assign_str (devname, &hdev->nic.kinfo.netdev->name); +__assign_str (devname, hdev->nic.kinfo.netdev->name);memcpy (__entry->mbx_data, req,sizeof (struct hclge_mbx_pf_to_vf_cmd )); ),
@@ -55,7 +55,7 @@ TRACE_EVENT(hclge_vf_mbx_send, __field(u8, code) __field(u8, subcode) __string(pciname, pci_name(hdev->pdev)) - __string(devname, &hdev->nic.kinfo.netdev->name) + __string(devname, hdev->nic.kinfo.netdev->name)__array (u32, mbx_data,VF_SEND_MBX_LEN ) ),
@@ -64,7 +64,7 @@ TRACE_EVENT(hclge_vf_mbx_send, __entry->code = req->msg.code; __entry->subcode = req->msg.subcode;__assign_str (pciname,pci_name (hdev->pdev)); -__assign_str (devname, &hdev->nic.kinfo.netdev->name); +__assign_str (devname, hdev->nic.kinfo.netdev->name);memcpy (__entry->mbx_data, req,sizeof (struct hclge_mbx_vf_to_pf_cmd )); ),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 131/272 LoongArch: Change __my_cpu_offset definition to avoid mis-optimization
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 c87e12e0e8c1241410e758e181ca6bf23efa5b5b ]
Quoted 1 line
From GCC commit
3f13154553f8546a("df-scan: remove ad-hoc handling of
global regs in asms"), global registers will no longer be forced to add to the def-use chain. Then current_thread_info(), current_stack_pointer and __my_cpu_offset may be lifted out of the loop because they are no longer treated as "volatile variables".
This optimization is still correct for the current_thread_info() and current_stack_pointer usages because they are associated to a thread. However it is wrong for __my_cpu_offset because it is associated to a CPU rather than a thread: if the thread migrates to a different CPU in the loop, __my_cpu_offset should be changed.
Change __my_cpu_offset definition to treat it as a "volatile variable", in order to avoid such a mis-optimization.
--- arch/loongarch/include/asm/percpu.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/loongarch/include/asm/percpu.h +6 -1
@@ -25,7 +25,12 @@ static inline void set_my_cpu_offset(unsigned long off) __my_cpu_offset = off;csr_write64 (off,PERCPU_BASE_KS ); } -#define __my_cpu_offset __my_cpu_offset + +#define __my_cpu_offset \ +({ \ + __asm__ __volatile__("":"+r"(__my_cpu_offset)); \ + __my_cpu_offset; \ +})#define PERCPU_OP (op, asm_op, c_op) \ static __always_inline unsigned long __percpu_##op(void *ptr, \
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 132/272 LoongArch: Define the __io_aw() hook as mmiowb()
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 9c68ece8b2a5c5ff9b2fcaea923dd73efeb174cd ]
Commit fb24ea52f78e0d595852e ("drivers: Remove explicit invocations of mmiowb()") remove all mmiowb() in drivers, but it says:
"NOTE: mmiowb() has only ever guaranteed ordering in conjunction with spin_unlock(). However, pairing each mmiowb() removal in this patch with the corresponding call to spin_unlock() is not at all trivial, so there is a small chance that this change may regress any drivers incorrectly relying on mmiowb() to order MMIO writes between CPUs using lock-free synchronisation."
The mmio in radeon_ring_commit() is protected by a mutex rather than a spinlock, but in the mutex fastpath it behaves similar to spinlock. We can add mmiowb() calls in the radeon driver but the maintainer says he doesn't like such a workaround, and radeon is not the only example of mutex protected mmio.
So we should extend the mmiowb tracking system from spinlock to mutex, and maybe other locking primitives. This is not easy and error prone, so we solve it in the architectural code, by simply defining the __io_aw() hook as mmiowb(). And we no longer need to override queued_spin_unlock() so use the generic definition.
Without this, we get such an error when run 'glxgears' on weak ordering architectures such as LoongArch:
radeon 0000:04:00.0: ring 0 stalled for more than 10324msec
radeon 0000:04:00.0: ring 3 stalled for more than 10240msec
radeon 0000:04:00.0: GPU lockup (current fence id 0x000000000001f412 last fence id 0x000000000001f414 on ring 3) radeon 0000:04:00.0: GPU lockup (current fence id 0x000000000000f940 last fence id 0x000000000000f941 on ring 0) radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
--- arch/loongarch/include/asm/io.h | 2 ++ 1 file changed, 2 insertions(+)
arch/loongarch/include/asm/io.h +2 -0
@@ -72,6 +72,8 @@ extern void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t#define memcpy_fromio (a, c, l) __memcpy_fromio((a), (c), (l))#define memcpy_toio (c, a, l) __memcpy_toio((c), (a), (l)) +#define __io_aw () mmiowb() +#include <asm-generic/io.h> #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 133/272 wireguard: netlink: check for dangling peer via is_dead instead of empty list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
[ Upstream commit 55b6c738673871c9b0edae05d0c97995c1ff08c4 ]
If all peers are removed via wg_peer_remove_all(), rather than setting peer_list to empty, the peer is added to a temporary list with a head on the stack of wg_peer_remove_all(). If a netlink dump is resumed and the cursored peer is one that has been removed via wg_peer_remove_all(), it will iterate from that peer and then attempt to dump freed peers.
Fix this by instead checking peer->is_dead, which was explictly created for this purpose. Also move up the device_update_lock lockdep assertion, since reading is_dead relies on that.
It can be reproduced by a small script like:
echo "Setting config..."
ip link add dev wg0 type wireguard
wg setconf wg0 /big-config
(
while true; do
echo "Showing config..."
wg showconf wg0 > /dev/null
done
) &
sleep 4
wg setconf wg0 <(printf "[Peer]\nPublicKey=$(wg genkey)\n")
Resulting in:
BUG: KASAN: slab-use-after-free in __lock_acquire+0x182a/0x1b20
Read of size 8 at addr ffff88811956ec70 by task wg/59
CPU: 2 PID: 59 Comm: wg Not tainted 6.8.0-rc2-debug+ #5
Call Trace:
<TASK>
dump_stack_lvl+0x47/0x70
print_address_description.constprop.0+0x2c/0x380
print_report+0xab/0x250
kasan_report+0xba/0xf0
__lock_acquire+0x182a/0x1b20
lock_acquire+0x191/0x4b0
down_read+0x80/0x440
get_peer+0x140/0xcb0
wg_get_device_dump+0x471/0x1130--- drivers/net/wireguard/netlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireguard/netlink.c +3 -3
@@ -255,17 +255,17 @@ static int wg_get_device_dump(struct sk_buff *skb, struct netlink_callback *cb)if (!peers_nest) goto out; ret =0 ; -/* If the last cursor was removed via list_del_init in peer_remove, then +lockdep_assert_held (&wg->device_update_lock); +/* If the last cursor was removed in peer_remove or peer_remove_all, then * we just treat this the same as there being no more peers left. The * reason is that seq_nr should indicate to userspace that this isn't a * coherent dump anyway, so they'll try again. */ if (list_empty (&wg->peer_list) || - (ctx->next_peer &&list_empty (&ctx->next_peer->peer_list))) { + (ctx->next_peer && ctx->next_peer->is_dead)) {nla_nest_cancel (skb, peers_nest); goto out; } -lockdep_assert_held (&wg->device_update_lock); peer =list_prepare_entry (ctx->next_peer, &wg->peer_list, peer_list);list_for_each_entry_continue (peer, &wg->peer_list, peer_list) {if (get_peer (peer, skb, ctx)) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 134/272 wireguard: netlink: access device through ctx instead of peer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
[ Upstream commit 71cbd32e3db82ea4a74e3ef9aeeaa6971969c86f ]
The previous commit fixed a bug that led to a NULL peer->device being dereferenced. It's actually easier and faster performance-wise to instead get the device from ctx->wg. This semantically makes more sense too, since ctx->wg->peer_allowedips.seq is compared with ctx->allowedips_seq, basing them both in ctx. This also acts as a defence in depth provision against freed peers.
--- drivers/net/wireguard/netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireguard/netlink.c +2 -2
@@ -164,8 +164,8 @@ get_peer(struct wg_peer *peer, struct sk_buff *skb, struct dump_ctx *ctx)if (!allowedips_node) goto no_allowedips;if (!ctx->allowedips_seq) - ctx->allowedips_seq = peer->device->peer_allowedips.seq; -else if (ctx->allowedips_seq != peer->device->peer_allowedips.seq) + ctx->allowedips_seq = ctx->wg->peer_allowedips.seq; +else if (ctx->allowedips_seq != ctx->wg->peer_allowedips.seq) goto no_allowedips; allowedips_nest =nla_nest_start (skb,WGPEER_A_ALLOWEDIPS );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 135/272 ahci: asm1064: correct count of reported ports
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Jr. Melnikov <[email protected]>
[ Upstream commit 9815e39617541ef52d0dfac4be274ad378c6dc09 ]
The ASM1064 SATA host controller always reports wrongly, that it has 24 ports. But in reality, it only has four ports.
before:
ahci 0000:04:00.0: SSS flag set, parallel bus scan disabled
ahci 0000:04:00.0: AHCI 0001.0301 32 slots 24 ports 6 Gbps 0xffff0f impl SATA mode ahci 0000:04:00.0: flags: 64bit ncq sntf stag pm led only pio sxs deso sadm sds apst
after:
ahci 0000:04:00.0: ASM1064 has only four ports
ahci 0000:04:00.0: forcing port_map 0xffff0f -> 0xf
ahci 0000:04:00.0: SSS flag set, parallel bus scan disabled
ahci 0000:04:00.0: AHCI 0001.0301 32 slots 24 ports 6 Gbps 0xf impl SATA mode ahci 0000:04:00.0: flags: 64bit ncq sntf stag pm led only pio sxs deso sadm sds apst
Stable-dep-of: 6cd8adc3e189 ("ahci: asm1064: asm1166: don't limit reported ports")
--- drivers/ata/ahci.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/ata/ahci.c +11 -3
@@ -671,9 +671,17 @@ MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets");static void ahci_pci_save_initial_config (struct pci_dev *pdev,struct ahci_host_priv *hpriv) { -if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA && pdev->device ==0x1166 ) { -dev_info (&pdev->dev,"ASM1166 has only six ports\n" ); - hpriv->saved_port_map =0x3f ; +if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA ) { +switch (pdev->device) { +case 0x1166 : +dev_info (&pdev->dev,"ASM1166 has only six ports\n" ); + hpriv->saved_port_map =0x3f ; +break ; +case 0x1064 : +dev_info (&pdev->dev,"ASM1064 has only four ports\n" ); + hpriv->saved_port_map =0xf ; +break ; + } }if (pdev->vendor ==PCI_VENDOR_ID_JMICRON && pdev->device ==0x2361 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 136/272 ahci: asm1064: asm1166: dont limit reported ports
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Conrad Kostecki <[email protected]>
[ Upstream commit 6cd8adc3e18960f6e59d797285ed34ef473cc896 ]
Previously, patches have been added to limit the reported count of SATA ports for asm1064 and asm1166 SATA controllers, as those controllers do report more ports than physically having.
While it is allowed to report more ports than physically having in CAP.NP, it is not allowed to report more ports than physically having in the PI (Ports Implemented) register, which is what these HBAs do. (This is a AHCI spec violation.)
Unfortunately, it seems that the PMP implementation in these ASMedia HBAs is also violating the AHCI and SATA-IO PMP specification.
What these HBAs do is that they do not report that they support PMP (CAP.SPM (Supports Port Multiplier) is not set).
Instead, they have decided to add extra "virtual" ports in the PI register that is used if a port multiplier is connected to any of the physical ports of the HBA.
Enumerating the devices behind the PMP as specified in the AHCI and SATA-IO specifications, by using PMP READ and PMP WRITE commands to the physical ports of the HBA is not possible, you have to use the "virtual" ports.
This is of course bad, because this gives us no way to detect the device and vendor ID of the PMP actually connected to the HBA, which means that we can not apply the proper PMP quirks for the PMP that is connected to the HBA.
Limiting the port map will thus stop these controllers from working with SATA Port Multipliers.
This patch reverts both patches for asm1064 and asm1166, so old behavior is restored and SATA PMP will work again, but it will also reintroduce the (minutes long) extra boot time for the ASMedia controllers that do not have a PMP connected (either on the PCIe card itself, or an external PMP).
However, a longer boot time for some, is the lesser evil compared to some other users not being able to detect their drives at all.
--- drivers/ata/ahci.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/ata/ahci.c +0 -13
@@ -671,19 +671,6 @@ MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets");static void ahci_pci_save_initial_config (struct pci_dev *pdev,struct ahci_host_priv *hpriv) { -if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA ) { -switch (pdev->device) { -case 0x1166 : -dev_info (&pdev->dev,"ASM1166 has only six ports\n" ); - hpriv->saved_port_map =0x3f ; -break ; -case 0x1064 : -dev_info (&pdev->dev,"ASM1064 has only four ports\n" ); - hpriv->saved_port_map =0xf ; -break ; - } - } -if (pdev->vendor ==PCI_VENDOR_ID_JMICRON && pdev->device ==0x2361 ) {dev_info (&pdev->dev,"JMB361 has only one port\n" ); hpriv->saved_port_map =1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 137/272 drm/amdgpu: amdgpu_ttm_gart_bind set gtt bound flag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philip Yang <[email protected]>
[ Upstream commit 6c6064cbe58b43533e3451ad6a8ba9736c109ac3 ]
Otherwise after the GTT bo is released, the GTT and gart space is freed but amdgpu_ttm_backend_unbind will not clear the gart page table entry and leave valid mapping entry pointing to the stale system page. Then if GPU access the gart address mistakely, it will read undefined value instead page fault, harder to debug and reproduce the real issue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
@@ -838,6 +838,7 @@ static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,amdgpu_gart_bind (adev, gtt->offset, ttm->num_pages, gtt->ttm.dma_address, flags); } + gtt->bound = true; }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 138/272 drm/amd/display: Return the correct HDCP error code
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Siqueira <[email protected]>
[ Upstream commit e64b3f55e458ce7e2087a0051f47edabf74545e7 ]
[WHY & HOW]
If the display is null when creating an HDCP session, return a proper error code.
--- drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c +3 -0
@@ -513,6 +513,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp) hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf;memset (hdcp_cmd,0 ,sizeof (struct ta_hdcp_shared_memory )); +if (!display) +return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND ; + hdcp_cmd->in_msg.hdcp2_create_session_v2.display_handle = display->index;if (hdcp->connection.link.adjust.hdcp2.force_type ==MOD_HDCP_FORCE_TYPE_0 )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 139/272 drm/amd/display: Fix noise issue on HDMI AV mute
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Ma <[email protected]>
[ Upstream commit 69e3be6893a7e668660b05a966bead82bbddb01d ]
[Why]
When mode switching is triggered there is momentary noise visible on some HDMI TV or displays.
[How]
Wait for 2 frames to make sure we have enough time to send out AV mute and sink receives a full frame.
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +11 -1
@@ -651,10 +651,20 @@ void dcn30_set_avmute(struct pipe_ctx *pipe_ctx, bool enable)if (pipe_ctx ==NULL )return ; -if (dc_is_hdmi_signal (pipe_ctx->stream->signal) && pipe_ctx->stream_res.stream_enc !=NULL ) +if (dc_is_hdmi_signal (pipe_ctx->stream->signal) && pipe_ctx->stream_res.stream_enc !=NULL ) { pipe_ctx->stream_res.stream_enc->funcs->set_avmute ( pipe_ctx->stream_res.stream_enc, enable); + +/* Wait for two frame to make sure AV mute is sent out */ +if (enable) { + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VACTIVE ); + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VBLANK ); + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VACTIVE ); + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VBLANK ); + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VACTIVE ); + } + } }void dcn30_update_info_frame (struct pipe_ctx *pipe_ctx)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 140/272 dm snapshot: fix lockup in dm_exception_table_exit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 6e7132ed3c07bd8a6ce3db4bb307ef2852b322dc ]
There was reported lockup when we exit a snapshot with many exceptions. Fix this by adding "cond_resched" to the loop that frees the exceptions.
--- drivers/md/dm-snap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/dm-snap.c +3 -1
@@ -679,8 +679,10 @@ static void dm_exception_table_exit(struct dm_exception_table *et,for (i =0 ; i < size; i++) { slot = et->table + i; -hlist_bl_for_each_entry_safe (ex, pos, n, slot, hash_list) +hlist_bl_for_each_entry_safe (ex, pos, n, slot, hash_list) {kmem_cache_free (mem, ex); +cond_resched (); + } }kvfree (et->table);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 141/272 x86/pm: Work around false positive kmemleak report in msr_build_context()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Altaparmakov <[email protected]>
[ Upstream commit e3f269ed0accbb22aa8f25d2daffa23c3fccd407 ]
Since:
7ee18d677989 ("x86/power: Make restore_processor_context() sane")
kmemleak reports this issue:
unreferenced object 0xf68241e0 (size 32):
comm "swapper/0", pid 1, jiffies 4294668610 (age 68.432s)
hex dump (first 32 bytes):
00 cc cc cc 29 10 01 c0 00 00 00 00 00 00 00 00 ....)...........
00 42 82 f6 cc cc cc cc cc cc cc cc cc cc cc cc .B..............
backtrace:
[<461c1d50>] __kmem_cache_alloc_node+0x106/0x260
[<ea65e13b>] __kmalloc+0x54/0x160
[<c3858cd2>] msr_build_context.constprop.0+0x35/0x100
[<46635aff>] pm_check_save_msr+0x63/0x80
[<6b6bb938>] do_one_initcall+0x41/0x1f0
[<3f3add60>] kernel_init_freeable+0x199/0x1e8
[<3b538fde>] kernel_init+0x1a/0x110
[<938ae2b2>] ret_from_fork+0x1c/0x28Which is a false positive.
Reproducer:
- Run rsync of whole kernel tree (multiple times if needed).
- start a kmemleak scan
- Note this is just an example: a lot of our internal tests hit these.
The root cause is similar to the fix in:
b0b592cf0836 x86/pm: Fix false positive kmemleak report in msr_build_context()
ie. the alignment within the packed struct saved_context which has everything unaligned as there is only "u16 gs;" at start of struct where in the past there were four u16 there thus aligning everything afterwards. The issue is with the fact that Kmemleak only searches for pointers that are aligned (see how pointers are scanned in kmemleak.c) so when the struct members are not aligned it doesn't see them.
Testing:
We run a lot of tests with our CI, and after applying this fix we do not see any kmemleak issues any more whilst without it we see hundreds of the above report. From a single, simple test run consisting of 416 individual test cases on kernel 5.10 x86 with kmemleak enabled we got 20 failures due to this, which is quite a lot. With this fix applied we get zero kmemleak related failures.
--- arch/x86/include/asm/suspend_32.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/include/asm/suspend_32.h +5 -5
@@ -12,11 +12,6 @@/* image of the saved processor state */ struct saved_context { -/* -* On x86_32, all segment registers except gs are saved at kernel -* entry in pt_regs. -*/ -u16 gs;unsigned long cr0, cr2, cr3, cr4;u64 misc_enable;struct saved_msrs saved_msrs;
@@ -27,6 +22,11 @@ struct saved_context {unsigned long tr;unsigned long safety;unsigned long return_address; +/* +* On x86_32, all segment registers except gs are saved at kernel +* entry in pt_regs. +*/ +u16 gs;bool misc_enable_saved; } __attribute__((packed));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 142/272 cpufreq: brcmstb-avs-cpufreq: fix up "add check for cpufreq_cpu_gets return value"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
In commit e72160cb6e23 ("cpufreq: brcmstb-avs-cpufreq: add check for cpufreq_cpu_get's return value"), build warnings occur because a variable is created after some logic, resulting in:
drivers/cpufreq/brcmstb-avs-cpufreq.c: In function 'brcm_avs_cpufreq_get':drivers/cpufreq/brcmstb-avs-cpufreq.c:486:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
486 | struct private_data *priv = policy->driver_data;
| ^~~~~~cc1: all warnings being treated as errors
make[2]: *** [scripts/Makefile.build:289:drivers/cpufreq/brcmstb-avs-cpufreq.o] Error 1
make[1]: *** [scripts/Makefile.build:552: drivers/cpufreq] Error 2 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1907: drivers] Error 2
Fix this up.
--- drivers/cpufreq/brcmstb-avs-cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cpufreq/brcmstb-avs-cpufreq.c +3 -2
@@ -481,10 +481,11 @@ static bool brcm_avs_is_firmware_loaded(static unsigned int brcm_avs_cpufreq_get (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_get (cpu); +struct private_data *priv; +if (!policy)return 0 ; -struct private_data *priv = policy->driver_data; - + priv = policy->driver_data;cpufreq_cpu_put (policy);return brcm_avs_get_frequency (priv->base);
Greg Kroah-Hartman
maintainerPATCH 143/272 platform/x86: p2sb: On Goldmont only cache P2SB and SPI devfn BAR
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit aec7d25b497ce4a8d044e9496de0aa433f7f8f06 upstream.
On Goldmont p2sb_bar() only ever gets called for 2 devices, the actual P2SB devfn 13,0 and the SPI controller which is part of the P2SB, devfn 13,2.
But the current p2sb code tries to cache BAR0 info for all of devfn 13,0 to 13,7 . This involves calling pci_scan_single_device() for device 13 functions 0-7 and the hw does not seem to like pci_scan_single_device() getting called for some of the other hidden devices. E.g. on an ASUS VivoBook D540NV-GQ065T this leads to continuous ACPI errors leading to high CPU usage.
Fix this by only caching BAR0 info and thus only calling pci_scan_single_device() for the P2SB and the SPI controller.
--- drivers/platform/x86/p2sb.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/platform/x86/p2sb.c +8 -15
@@ -20,9 +20,11 @@#define P2SBC_HIDE BIT(8)#define P2SB_DEVFN_DEFAULT PCI_DEVFN(31, 1) +#define P2SB_DEVFN_GOLDMONT PCI_DEVFN(13, 0) +#define SPI_DEVFN_GOLDMONT PCI_DEVFN(13, 2)static const struct x86_cpu_id p2sb_cpu_ids[] = { -X86_MATCH_INTEL_FAM6_MODEL (ATOM_GOLDMONT ,PCI_DEVFN (13 ,0 )), +X86_MATCH_INTEL_FAM6_MODEL (ATOM_GOLDMONT ,P2SB_DEVFN_GOLDMONT ), {} };
@@ -98,21 +100,12 @@ static void p2sb_scan_and_cache_devfn(ststatic int p2sb_scan_and_cache (struct pci_bus *bus,unsigned int devfn) { -unsigned int slot, fn; +/* Scan the P2SB device and cache its BAR0 */ +p2sb_scan_and_cache_devfn (bus, devfn); -if (PCI_FUNC (devfn) ==0 ) { -/* -* When function number of the P2SB device is zero, scan it and -* other function numbers, and if devices are available, cache -* their BAR0s. -*/ - slot =PCI_SLOT (devfn); -for (fn =0 ; fn <NR_P2SB_RES_CACHE ; fn++) -p2sb_scan_and_cache_devfn (bus,PCI_DEVFN (slot, fn)); - }else { -/* Scan the P2SB device and cache its BAR0 */ -p2sb_scan_and_cache_devfn (bus, devfn); - } +/* On Goldmont p2sb_bar() also gets called for the SPI controller */ +if (devfn ==P2SB_DEVFN_GOLDMONT ) +p2sb_scan_and_cache_devfn (bus,SPI_DEVFN_GOLDMONT );if (!p2sb_valid_resource (&p2sb_resources[PCI_FUNC (devfn)].res))return -ENOENT ;
Greg Kroah-Hartman
maintainerPATCH 144/272 tls: fix race between tx work scheduling and socket close
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
commit e01e3934a1b2d122919f73bc6ddbe1cdafc4bbdb upstream.
Similarly to previous commit, the submitting thread (recvmsg/sendmsg) may exit as soon as the async crypto handler calls complete(). Reorder scheduling the work before calling complete(). This seems more logical in the first place, as it's
the inverse order of what the submitting thread will do.
--- net/tls/tls_sw.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
net/tls/tls_sw.c +6 -10
@@ -449,7 +449,6 @@ static void tls_encrypt_done(crypto_compstruct scatterlist *sge;struct sk_msg *msg_en;struct tls_rec *rec; -bool ready = false;struct sock *sk; rec = container_of(aead_req, struct tls_rec, aead_req);
@@ -486,19 +485,16 @@ static void tls_encrypt_done(crypto_comp/* If received record is at head of tx_list, schedule tx */ first_rec =list_first_entry (&ctx->tx_list, struct tls_rec, list); -if (rec == first_rec) - ready = true; +if (rec == first_rec) { +/* Schedule the transmission */ +if (!test_and_set_bit (BIT_TX_SCHEDULED , + &ctx->tx_bitmask)) +schedule_delayed_work (&ctx->tx_work.work,1 ); + } }if (atomic_dec_and_test (&ctx->encrypt_pending))complete (&ctx->async_wait.completion); - -if (!ready) -return ; - -/* Schedule the transmission */ -if (!test_and_set_bit (BIT_TX_SCHEDULED , &ctx->tx_bitmask)) -schedule_delayed_work (&ctx->tx_work.work,1 ); }static int tls_encrypt_async_wait (struct tls_sw_context_tx *ctx)
Greg Kroah-Hartman
maintainerPATCH 145/272 netfilter: nf_tables: mark set as dead when unbinding anonymous set with timeout
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit 552705a3650bbf46a22b1adedc1b04181490fc36 upstream.
While the rhashtable set gc runs asynchronously, a race allows it to collect elements from anonymous sets with timeouts while it is being released from the commit path.
Mingi Cho originally reported this issue in a different path in 6.1.x with a pipapo set with low timeouts which is not possible upstream since 7395dfacfff6 ("netfilter: nf_tables: use timestamp to check for set element timeout").
Fix this by setting on the dead flag for anonymous sets to skip async gc in this case.
According to 08e4c8c5919f ("netfilter: nf_tables: mark newset as dead on transaction abort"), Florian plans to accelerate abort path by releasing objects via workqueue, therefore, this sets on the dead flag for abort path too.
--- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nf_tables_api.c +1 -0
@@ -5132,6 +5132,7 @@ static void nf_tables_unbind_set(const sif (list_empty (&set->bindings) &&nft_set_is_anonymous (set)) {list_del_rcu (&set->list); + set->dead =1 ;if (event)nf_tables_set_notify (ctx, set,NFT_MSG_DELSET ,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 146/272 netfilter: nf_tables: disallow anonymous set with timeout flag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit 16603605b667b70da974bea8216c93e7db043bf1 upstream.
Anonymous sets are never used with timeout from userspace, reject this. Exception to this rule is NFT_SET_EVAL to ensure legacy meters still work.
--- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_tables_api.c +3 -0
@@ -4711,6 +4711,9 @@ static int nf_tables_newset(struct sk_buif ((flags & (NFT_SET_EVAL |NFT_SET_OBJECT )) == (NFT_SET_EVAL |NFT_SET_OBJECT ))return -EOPNOTSUPP ; +if ((flags & (NFT_SET_ANONYMOUS |NFT_SET_TIMEOUT |NFT_SET_EVAL )) == + (NFT_SET_ANONYMOUS |NFT_SET_TIMEOUT )) +return -EOPNOTSUPP ; } desc.dtype =0 ;
Greg Kroah-Hartman
maintainerPATCH 147/272 netfilter: nf_tables: reject constant set with timeout
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit 5f4fc4bd5cddb4770ab120ce44f02695c4505562 upstream.
This set combination is weird: it allows for elements to be added/deleted, but once bound to the rule it cannot be updated anymore. Eventually, all elements expire, leading to an empty set which cannot be updated anymore. Reject this flags combination.
--- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_tables_api.c +3 -0
@@ -4714,6 +4714,9 @@ static int nf_tables_newset(struct sk_buif ((flags & (NFT_SET_ANONYMOUS |NFT_SET_TIMEOUT |NFT_SET_EVAL )) == (NFT_SET_ANONYMOUS |NFT_SET_TIMEOUT ))return -EOPNOTSUPP ; +if ((flags & (NFT_SET_CONSTANT |NFT_SET_TIMEOUT )) == + (NFT_SET_CONSTANT |NFT_SET_TIMEOUT )) +return -EOPNOTSUPP ; } desc.dtype =0 ;
Greg Kroah-Hartman
maintainerPATCH 148/272 Drivers: hv: vmbus: Calculate ring buffer size for more efficient use of memory
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Kelley <[email protected]>
commit b8209544296edbd1af186e2ea9c648642c37b18c upstream.
The VMBUS_RING_SIZE macro adds space for a ring buffer header to the requested ring buffer size. The header size is always 1 page, and so its size varies based on the PAGE_SIZE for which the kernel is built. If the requested ring buffer size is a large power-of-2 size and the header size is small, the resulting size is inefficient in its use of memory. For example, a 512 Kbyte ring buffer with a 4 Kbyte page size results in a 516 Kbyte allocation, which is rounded to up 1 Mbyte by the memory allocator, and wastes 508 Kbytes of memory.
In such situations, the exact size of the ring buffer isn't that important, and it's OK to allocate the 4 Kbyte header at the beginning of the 512 Kbytes, leaving the ring buffer itself with just 508 Kbytes. The memory allocation can be 512 Kbytes instead of 1 Mbyte and nothing is wasted.
Update VMBUS_RING_SIZE to implement this approach for "large" ring buffer sizes. "Large" is somewhat arbitrarily defined as 8 times the size of the ring buffer header (which is of size PAGE_SIZE). For example, for 4 Kbyte PAGE_SIZE, ring buffers of 32 Kbytes and larger use the first 4 Kbytes as the ring buffer header. For 64 Kbyte PAGE_SIZE, ring buffers of 512 Kbytes and larger use the first 64 Kbytes as the ring buffer header. In both cases, smaller sizes add space for the header so the ring size isn't reduced too much by using part of the space for the header. For example, with a 64 Kbyte page size, we don't want a 128 Kbyte ring buffer to be reduced to 64 Kbytes by allocating half of the space for the header. In such a case, the memory allocation is less efficient, but it's the best that can be done.
While the new algorithm slightly changes the amount of space allocated for ring buffers by drivers that use VMBUS_RING_SIZE, the devices aren't known to be sensitive to small changes in ring buffer size, so there shouldn't be any effect.
Message-ID: <[email protected]>
--- include/linux/hyperv.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
include/linux/hyperv.h +21 -1
@@ -164,8 +164,28 @@ struct hv_ring_buffer {u8 buffer[]; } __packed; + +/* +* If the requested ring buffer size is at least 8 times the size of the +* header, steal space from the ring buffer for the header. Otherwise, add +* space for the header so that is doesn't take too much of the ring buffer +* space. +* +* The factor of 8 is somewhat arbitrary. The goal is to prevent adding a +* relatively small header (4 Kbytes on x86) to a large-ish power-of-2 ring +* buffer size (such as 128 Kbytes) and so end up making a nearly twice as +* large allocation that will be almost half wasted. As a contrasting example, +* on ARM64 with 64 Kbyte page size, we don't want to take 64 Kbytes for the +* header from a 128 Kbyte allocation, leaving only 64 Kbytes for the ring. +* In this latter case, we must add 64 Kbytes for the header and not worry +* about what's wasted. +*/ +#define VMBUS_HEADER_ADJ (payload_sz) \ + ((payload_sz) >= 8 * sizeof(struct hv_ring_buffer) ? \ + 0 : sizeof(struct hv_ring_buffer)) +/* Calculate the proper size of a ringbuffer, it must be page-aligned */ -#define VMBUS_RING_SIZE (payload_sz) PAGE_ALIGN(sizeof(struct hv_ring_buffer) + \ +#define VMBUS_RING_SIZE (payload_sz) PAGE_ALIGN(VMBUS_HEADER_ADJ(payload_sz) + \ (payload_sz))struct hv_ring_buffer_info {
Greg Kroah-Hartman
maintainerPATCH 149/272 xfrm: Avoid clang fortify warning in copy_to_user_tmpl()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 1a807e46aa93ebad1dfbed4f82dc3bf779423a6e upstream.
After a couple recent changes in LLVM, there is a warning (or error with CONFIG_WERROR=y or W=e) from the compile time fortify source routines, specifically the memset() in copy_to_user_tmpl().
In file included from net/xfrm/xfrm_user.c:14:
...
include/linux/fortify-string.h:438:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
438 | __write_overflow_field(p_size_field, size);
| ^1 error generated.
While ->xfrm_nr has been validated against XFRM_MAX_DEPTH when its value is first assigned in copy_templates() by calling validate_tmpl() first (so there should not be any issue in practice), LLVM/clang cannot really deduce that across the boundaries of these functions. Without that knowledge, it cannot assume that the loop stops before i is greater than XFRM_MAX_DEPTH, which would indeed result a stack buffer overflow in the memset().
To make the bounds of ->xfrm_nr clear to the compiler and add additional defense in case copy_to_user_tmpl() is ever used in a path where ->xfrm_nr has not been properly validated against XFRM_MAX_DEPTH first, add an explicit bound check and early return, which clears up the warning.
--- net/xfrm/xfrm_user.c | 3 +++ 1 file changed, 3 insertions(+)
net/xfrm/xfrm_user.c +3 -0
@@ -1979,6 +1979,9 @@ static int copy_to_user_tmpl(struct xfrmif (xp->xfrm_nr ==0 )return 0 ; +if (xp->xfrm_nr >XFRM_MAX_DEPTH ) +return -ENOBUFS ; +for (i =0 ; i < xp->xfrm_nr; i++) {struct xfrm_user_tmpl *up = &vec[i];struct xfrm_tmpl *kp = &xp->xfrm_vec[i];
Greg Kroah-Hartman
maintainerPATCH 150/272 init/Kconfig: lower GCC version check for -Warray-bounds
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 3e00f5802fabf2f504070a591b14b648523ede13 upstream.
We continue to see false positives from -Warray-bounds even in GCC 10, which is getting reported in a few places[1] still:
security/security.c:811:2: warning: `memcpy' offset 32 is out of the bounds [0, 0] [-Warray-bounds]
Lower the GCC version check from 11 to 10.
--- init/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
init/Kconfig +3 -3
@@ -902,14 +902,14 @@ config CC_IMPLICIT_FALLTHROUGH default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5) default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough) -# Currently, disable gcc-11+ array-bounds globally. +# Currently, disable gcc-10+ array-bounds globally. # It's still broken in gcc-13, so no upper bound yet. -config GCC11_NO_ARRAY_BOUNDS +config GCC10_NO_ARRAY_BOUNDS def_bool y config CC_NO_ARRAY_BOUNDS bool - default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC11_NO_ARRAY_BOUNDS + default y if CC_IS_GCC && GCC_VERSION >= 100000 && GCC10_NO_ARRAY_BOUNDS # # For architectures that know their GCC __int128 support is sound
Greg Kroah-Hartman
maintainerPATCH 151/272 KVM: x86: Mark target gfn of emulated atomic instruction as dirty
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 910c57dfa4d113aae6571c2a8b9ae8c430975902 upstream.
When emulating an atomic access on behalf of the guest, mark the target gfn dirty if the CMPXCHG by KVM is attempted and doesn't fault. This fixes a bug where KVM effectively corrupts guest memory during live migration by writing to guest memory without informing userspace that the page is dirty.
Marking the page dirty got unintentionally dropped when KVM's emulated CMPXCHG was converted to do a user access. Before that, KVM explicitly mapped the guest page into kernel memory, and marked the page dirty during the unmap phase.
Mark the page dirty even if the CMPXCHG fails, as the old data is written back on failure, i.e. the page is still written. The value written is guaranteed to be the same because the operation is atomic, but KVM's ABI is that all writes are dirty logged regardless of the value written. And more importantly, that's what KVM did before the buggy commit.
Huge kudos to the folks on the Cc list (and many others), who did all the actual work of triaging and debugging.
base-commit: 6769ea8da8a93ed4630f1ce64df6aafcaabfce64
--- arch/x86/kvm/x86.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/x86/kvm/x86.c +10 -0
@@ -7758,6 +7758,16 @@ static int emulator_cmpxchg_emulated(strif (r <0 )return X86EMUL_UNHANDLEABLE ; + +/* +* Mark the page dirty _before_ checking whether or not the CMPXCHG was +* successful, as the old value is written back on failure. Note, for +* live migration, this is unnecessarily conservative as CMPXCHG writes +* back the original value and the access is atomic, but KVM's ABI is +* that all writes are dirty logged, regardless of the value written. +*/ +kvm_vcpu_mark_page_dirty (vcpu,gpa_to_gfn (gpa)); +if (r)return X86EMUL_CMPXCHG_FAILED ;
Greg Kroah-Hartman
maintainerPATCH 152/272 KVM: SVM: Flush pages under kvm->lock to fix UAF in svm_register_enc_region()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 5ef1d8c1ddbf696e47b226e11888eaf8d9e8e807 upstream.
Do the cache flush of converted pages in svm_register_enc_region() before dropping kvm->lock to fix use-after-free issues where region and/or its array of pages could be freed by a different task, e.g. if userspace has __unregister_enc_region_locked() already queued up for the region.
Note, the "obvious" alternative of using local variables doesn't fully resolve the bug, as region->pages is also dynamically allocated. I.e. the region structure itself would be fine, but region->pages could be freed.
Flushing multiple pages under kvm->lock is unfortunate, but the entire flow is a rare slow path, and the manual flush is only needed on CPUs that lack coherency for encrypted memory.
Message-Id: <[email protected]>
--- arch/x86/kvm/svm/sev.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
arch/x86/kvm/svm/sev.c +9 -7
@@ -1958,20 +1958,22 @@ int sev_mem_enc_register_region(struct k goto e_free; } - region->uaddr = range->addr; - region->size = range->size; - -list_add_tail (®ion->list, &sev->regions_list); -mutex_unlock (&kvm->lock); -/* * The guest may change the memory encryption attribute from C=0 -> C=1 * or vice versa for this memory range. Lets make sure caches are * flushed to ensure that guest data gets written into memory with -* correct C-bit. +* correct C-bit. Note, this must be done before dropping kvm->lock, +* as region and its array of pages can be freed by a different task +* once kvm->lock is released. */ sev_clflush_pages (region->pages, region->npages); + region->uaddr = range->addr; + region->size = range->size; + +list_add_tail (®ion->list, &sev->regions_list); +mutex_unlock (&kvm->lock); +return ret; e_free:
Greg Kroah-Hartman
maintainerPATCH 153/272 tracing: Use .flush() call to wake up readers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
commit e5d7c1916562f0e856eb3d6f569629fcd535fed2 upstream.
The .release() function does not get called until all readers of a file descriptor are finished.
If a thread is blocked on reading a file descriptor in ring_buffer_wait(), and another thread closes the file descriptor, it will not wake up the other thread as ring_buffer_wake_waiters() is called by .release(), and that will not get called until the .read() is finished.
The issue originally showed up in trace-cmd, but the readers are actually other processes with their own file descriptors. So calling close() would wake up the other tasks because they are blocked on another descriptor then the one that was closed(). But there's other wake ups that solve that issue.
When a thread is blocked on a read, it can still hang even when another thread closed its descriptor.
This is what the .flush() callback is for. Have the .flush() wake up the readers.
--- kernel/trace/trace.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
kernel/trace/trace.c +15 -6
@@ -8278,6 +8278,20 @@ tracing_buffers_read(struct file *filp,return size; } +static int tracing_buffers_flush (struct file *file,fl_owner_t id) +{ +struct ftrace_buffer_info *info = file->private_data; +struct trace_iterator *iter = &info->iter; + + iter->wait_index++; +/* Make sure the waiters see the new wait_index */ +smp_wmb (); + +ring_buffer_wake_waiters (iter->array_buffer->buffer, iter->cpu_file); + +return 0 ; +} +static int tracing_buffers_release (struct inode *inode,struct file *file) {struct ftrace_buffer_info *info = file->private_data;
@@ -8289,12 +8303,6 @@ static int tracing_buffers_release(struc__trace_array_put (iter->tr); - iter->wait_index++; -/* Make sure the waiters see the new wait_index */ -smp_wmb (); - -ring_buffer_wake_waiters (iter->array_buffer->buffer, iter->cpu_file); -if (info->spare)ring_buffer_free_read_page (iter->array_buffer->buffer, info->spare_cpu, info->spare);
@@ -8508,6 +8516,7 @@ static const struct file_operations trac .read = tracing_buffers_read, .poll = tracing_buffers_poll, .release = tracing_buffers_release, + .flush = tracing_buffers_flush, .splice_read = tracing_buffers_splice_read, .unlocked_ioctl = tracing_buffers_ioctl, .llseek = no_llseek,
Greg Kroah-Hartman
maintainerPATCH 154/272 drm/amdgpu/pm: Fix the error of pwm1_enable setting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Jun <[email protected]>
commit 0dafaf659cc463f2db0af92003313a8bc46781cd upstream.
Fix the pwm_mode value error which used forpwm1_enable setting
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +11 -1
@@ -2344,6 +2344,7 @@ static ssize_t amdgpu_hwmon_set_pwm1_ena {struct amdgpu_device *adev =dev_get_drvdata (dev);int err, ret; +u32 pwm_mode;int value;if (amdgpu_in_reset (adev))
@@ -2355,13 +2356,22 @@ static ssize_t amdgpu_hwmon_set_pwm1_enaif (err)return err; +if (value ==0 ) + pwm_mode =AMD_FAN_CTRL_NONE ; +else if (value ==1 ) + pwm_mode =AMD_FAN_CTRL_MANUAL ; +else if (value ==2 ) + pwm_mode =AMD_FAN_CTRL_AUTO ; +else +return -EINVAL ; + ret =pm_runtime_get_sync (adev_to_drm (adev)->dev);if (ret <0 ) {pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);return ret; } - ret =amdgpu_dpm_set_fan_control_mode (adev, value); + ret =amdgpu_dpm_set_fan_control_mode (adev, pwm_mode);pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);
Greg Kroah-Hartman
maintainerPATCH 155/272 drm/i915: Check before removing mm notifier
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nirmoy Das <[email protected]>
commit 01bb1ae35006e473138c90711bad1a6b614a1823 upstream.
Error in mmu_interval_notifier_insert() can leave a NULL notifier.mm pointer. Catch that and return early.
--- drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +3 -0
@@ -378,6 +378,9 @@ i915_gem_userptr_release(struct drm_i915 {GEM_WARN_ON (obj->userptr.page_ref); +if (!obj->userptr.notifier.mm) +return ; +mmu_interval_notifier_remove (&obj->userptr.notifier); obj->userptr.notifier.mm =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 156/272 ALSA: hda/realtek - Fix headset Mic no show at resume back for Lenovo ALC897 platform
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit d397b6e56151099cf3b1f7bfccb204a6a8591720 upstream.
Headset Mic will no show at resume back.
This patch will fix this issue.
--- sound/pci/hda/patch_realtek.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/pci/hda/patch_realtek.c +5 -2
@@ -11439,8 +11439,7 @@ static void alc897_hp_automute_hook(strusnd_hda_gen_hp_automute (codec, jack); vref = spec->gen.hp_jack_present ? (PIN_HP |AC_PINCTL_VREF_100 ) :PIN_HP ; -snd_hda_codec_write (codec,0x1b ,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL , - vref); +snd_hda_set_pin_ctl (codec,0x1b , vref); } static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
@@ -11449,6 +11448,10 @@ static void alc897_fixup_lenovo_headset_struct alc_spec *spec = codec->spec;if (action ==HDA_FIXUP_ACT_PRE_PROBE ) { spec->gen.hp_automute_hook = alc897_hp_automute_hook; + spec->no_shutup_pins =1 ; + } +if (action ==HDA_FIXUP_ACT_PROBE ) { +snd_hda_set_pin_ctl_cache (codec,0x1a ,PIN_IN |AC_PINCTL_VREF_100 ); } }
Greg Kroah-Hartman
maintainerPATCH 157/272 USB: usb-storage: Prevent divide-by-0 error in isd200_ata_command
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 014bcf41d946b36a8f0b8e9b5d9529efbb822f49 upstream.
The isd200 sub-driver in usb-storage uses the HEADS and SECTORS values in the ATA ID information to calculate cylinder and head values when creating a CDB for READ or WRITE commands. The calculation involves division and modulus operations, which will cause a crash if either of these values is 0. While this never happens with a genuine device, it could happen with a flawed or subversive emulation, as reported by the syzbot fuzzer.
Protect against this possibility by refusing to bind to the device if either the ATA_ID_HEADS or ATA_ID_SECTORS value in the device's ID information is 0. This requires isd200_Initialization() to return a negative error code when initialization fails; currently it always returns 0 (even when there is an error).
--- drivers/usb/storage/isd200.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/usb/storage/isd200.c +18 -5
@@ -1105,7 +1105,7 @@ static void isd200_dump_driveid(struct ustatic int isd200_get_inquiry_data (struct us_data *us ) {struct isd200_info *info = (struct isd200_info *)us->extra; -int retStatus =ISD200_GOOD ; +int retStatus;u16 *id = info->id;usb_stor_dbg (us,"Entering isd200_get_inquiry_data\n" );
@@ -1137,6 +1137,13 @@ static int isd200_get_inquiry_data( struisd200_fix_driveid (id);isd200_dump_driveid (us, id); +/* Prevent division by 0 in isd200_scsi_to_ata() */ +if (id[ATA_ID_HEADS ] ==0 || id[ATA_ID_SECTORS ] ==0 ) { +usb_stor_dbg (us," Invalid ATA Identify data\n" ); + retStatus =ISD200_ERROR ; + goto Done; + } +memset (&info->InquiryData,0 ,sizeof (info->InquiryData));/* Standard IDE interface only supports disks */
@@ -1202,6 +1209,7 @@ static int isd200_get_inquiry_data( stru } } + Done:usb_stor_dbg (us,"Leaving isd200_get_inquiry_data %08X\n" , retStatus);return (retStatus);
@@ -1481,22 +1489,27 @@ static int isd200_init_info(struct us_dastatic int isd200_Initialization (struct us_data *us) { +int rc =0 ; +usb_stor_dbg (us,"ISD200 Initialization...\n" );/* Initialize ISD200 info struct */ -if (isd200_init_info (us) ==ISD200_ERROR ) { +if (isd200_init_info (us) <0 ) {usb_stor_dbg (us,"ERROR Initializing ISD200 Info struct\n" ); + rc = -ENOMEM ; }else {/* Get device specific data */ -if (isd200_get_inquiry_data (us) !=ISD200_GOOD ) +if (isd200_get_inquiry_data (us) !=ISD200_GOOD ) {usb_stor_dbg (us,"ISD200 Initialization Failure\n" ); -else + rc = -EINVAL ; + }else {usb_stor_dbg (us,"ISD200 Initialization complete\n" ); + } } -return 0 ; +return rc; }
Greg Kroah-Hartman
maintainerPATCH 158/272 usb: gadget: ncm: Fix handling of zero block length packets
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Kurapati <[email protected]>
commit f90ce1e04cbcc76639d6cba0fdbd820cd80b3c70 upstream.
While connecting to a Linux host with CDC_NCM_NTB_DEF_SIZE_TX set to 65536, it has been observed that we receive short packets, which come at interval of 5-10 seconds sometimes and have block length zero but still contain 1-2 valid datagrams present.
According to the NCM spec:
"If wBlockLength = 0x0000, the block is terminated by a short packet. In this case, the USB transfer must still be shorter than dwNtbInMaxSize or dwNtbOutMaxSize. If exactly dwNtbInMaxSize or dwNtbOutMaxSize bytes are sent, and the size is a multiple of wMaxPacketSize for the given pipe, then no ZLP shall be sent.
wBlockLength= 0x0000 must be used with extreme care, because of the possibility that the host and device may get out of sync, and because of test issues.
wBlockLength = 0x0000 allows the sender to reduce latency by starting to send a very large NTB, and then shortening it when the sender discovers that there’s not sufficient data to justify sending a large NTB"
However, there is a potential issue with the current implementation, as it checks for the occurrence of multiple NTBs in a single giveback by verifying if the leftover bytes to be processed is zero or not. If the block length reads zero, we would process the same NTB infintely because the leftover bytes is never zero and it leads to a crash. Fix this by bailing out if block length reads zero.
--- drivers/usb/gadget/function/f_ncm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_ncm.c +1 -1
@@ -1348,7 +1348,7 @@ parse_ntb:if (to_process ==1 && (*(unsigned char *)(ntb_ptr + block_len) ==0x00 )) { to_process--; - }else if (to_process >0 ) { + }else if ((to_process >0 ) && (block_len !=0 )) { ntb_ptr = (unsigned char *)(ntb_ptr + block_len); goto parse_ntb; }
Greg Kroah-Hartman
maintainerPATCH 159/272 usb: port: Dont try to peer unused USB ports based on location
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 69c63350e573367f9c8594162288cffa8a26d0d1 upstream.
Unused USB ports may have bogus location data in ACPI PLD tables. This causes port peering failures as these unused USB2 and USB3 ports location may match.
Due to these failures the driver prints a
"usb: port power management may be unreliable" warning, and unnecessarily blocks port power off during runtime suspend.
This was debugged on a couple DELL systems where the unused ports all returned zeroes in their location data.
Similar bugreports exist for other systems.
Don't try to peer or match ports that have connect type set to USB_PORT_NOT_USED.
--- drivers/usb/core/port.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/core/port.c +3 -2
@@ -534,7 +534,7 @@ static int match_location(struct usb_devstruct usb_hub *peer_hub =usb_hub_to_struct_hub (peer_hdev);struct usb_device *hdev =to_usb_device (port_dev->dev.parent->parent); -if (!peer_hub) +if (!peer_hub || port_dev->connect_type ==USB_PORT_NOT_USED )return 0 ; hcd =bus_to_hcd (hdev->bus);
@@ -545,7 +545,8 @@ static int match_location(struct usb_devfor (port1 =1 ; port1 <= peer_hdev->maxchild; port1++) { peer = peer_hub->ports[port1 -1 ]; -if (peer && peer->location == port_dev->location) { +if (peer && peer->connect_type !=USB_PORT_NOT_USED && + peer->location == port_dev->location) {link_peers_report (port_dev, peer);return 1 ;/* done */ }
Greg Kroah-Hartman
maintainerPATCH 160/272 tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sherry Sun <[email protected]>
commit 74cb7e0355fae9641f825afa389d3fba3b617714 upstream.
If the remote uart device is not connected or not enabled after booting up, the CTS line is high by default. At this time, if we enable the flow control when opening the device(for example, using “stty -F /dev/ttyLP4 crtscts” command), there will be a pending idle preamble(first writing 0 and then writing 1 to UARTCTRL_TE will queue an idle preamble) that cannot be sent out, resulting in the uart port fail to close(waiting for TX empty), so the user space stty will have to wait for a long time or forever.
This is an LPUART IP bug(idle preamble has higher priority than CTS), here add a workaround patch to enable TX CTS after enabling UARTCTRL_TE, so that the idle preamble does not get stuck due to CTS is deasserted.
--- drivers/tty/serial/fsl_lpuart.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/tty/serial/fsl_lpuart.c +5 -2
@@ -2213,9 +2213,12 @@ lpuart32_set_termios(struct uart_port *plpuart32_write (&sport->port, bd,UARTBAUD );lpuart32_serial_setbrg (sport, baud); -lpuart32_write (&sport->port, modem,UARTMODIR ); -lpuart32_write (&sport->port, ctrl,UARTCTRL ); +/* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */ +lpuart32_write (&sport->port, modem & ~UARTMODIR_TXCTSE ,UARTMODIR );/* restore control register */ +lpuart32_write (&sport->port, ctrl,UARTCTRL ); +/* re-enable the CTS if needed */ +lpuart32_write (&sport->port, modem,UARTMODIR );if ((ctrl & (UARTCTRL_PE |UARTCTRL_M )) ==UARTCTRL_PE ) sport->is_cs7 = true;
Greg Kroah-Hartman
maintainerPATCH 161/272 serial: 8250_dw: Do not reclock if already at correct rate
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Collingbourne <[email protected]>
commit e5d6bd25f93d6ae158bb4cd04956cb497a85b8ef upstream.
When userspace opens the console, we call set_termios() passing a termios with the console's configured baud rate. Currently this causes dw8250_set_termios() to disable and then re-enable the UART clock at the same frequency as it was originally. This can cause corruption of any concurrent console output. Fix it by skipping the reclocking if we are already at the correct rate.
--- drivers/tty/serial/8250/8250_dw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_dw.c +3 -3
@@ -357,9 +357,9 @@ static void dw8250_set_termios(struct ualong rate;int ret; -clk_disable_unprepare (d->clk); rate =clk_round_rate (d->clk, newrate); -if (rate >0 ) { +if (rate >0 && p->uartclk != rate) { +clk_disable_unprepare (d->clk);/* * Note that any clock-notifer worker will block in * serial8250_update_uartclk() until we are done.
@@ -367,8 +367,8 @@ static void dw8250_set_termios(struct ua ret =clk_set_rate (d->clk, newrate);if (!ret) p->uartclk = rate; +clk_prepare_enable (d->clk); } -clk_prepare_enable (d->clk);dw8250_do_set_termios (p, termios, old); }
Greg Kroah-Hartman
maintainerPATCH 162/272 misc: lis3lv02d_i2c: Fix regulators getting en-/dis-abled twice on suspend/resume
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit ac3e0384073b2408d6cb0d972fee9fcc3776053d upstream.
When not configured for wakeup lis3lv02d_i2c_suspend() will call lis3lv02d_poweroff() even if the device has already been turned off by the runtime-suspend handler and if configured for wakeup and the device is runtime-suspended at this point then it is not turned back on to serve as a wakeup source.
Before commit b1b9f7a49440 ("misc: lis3lv02d_i2c: Add missing setting of the reg_ctrl callback"), lis3lv02d_poweroff() failed to disable the regulators which as a side effect made calling poweroff() twice ok.
Now that poweroff() correctly disables the regulators, doing this twice triggers a WARN() in the regulator core:
unbalanced disables for regulator-dummy
WARNING: CPU: 1 PID: 92 at drivers/regulator/core.c:2999 _regulator_disable
...
Fix lis3lv02d_i2c_suspend() to not call poweroff() a second time if already runtime-suspended and add a poweron() call when necessary to make wakeup work.
lis3lv02d_i2c_resume() has similar issues, with an added weirness that it always powers on the device if it is runtime suspended, after which the first runtime-resume will call poweron() again, causing the enabled count for the regulator to increase by 1 every suspend/resume. These unbalanced regulator_enable() calls cause the regulator to never be turned off and trigger the following WARN() on driver unbind:
WARNING: CPU: 1 PID: 1724 at drivers/regulator/core.c:2396 _regulator_put
Fix this by making lis3lv02d_i2c_resume() mirror the new suspend().
--- drivers/misc/lis3lv02d/lis3lv02d_i2c.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/misc/lis3lv02d/lis3lv02d_i2c.c +13 -8
@@ -199,8 +199,14 @@ static int lis3lv02d_i2c_suspend(structstruct i2c_client *client =to_i2c_client (dev);struct lis3lv02d *lis3 =i2c_get_clientdata (client); -if (!lis3->pdata || !lis3->pdata->wakeup_flags) +/* Turn on for wakeup if turned off by runtime suspend */ +if (lis3->pdata && lis3->pdata->wakeup_flags) { +if (pm_runtime_suspended (dev)) +lis3lv02d_poweron (lis3); +/* For non wakeup turn off if not already turned off by runtime suspend */ + }else if (!pm_runtime_suspended (dev))lis3lv02d_poweroff (lis3); +return 0 ; }
@@ -209,13 +215,12 @@ static int lis3lv02d_i2c_resume(struct dstruct i2c_client *client =to_i2c_client (dev);struct lis3lv02d *lis3 =i2c_get_clientdata (client); -/* -* pm_runtime documentation says that devices should always -* be powered on at resume. Pm_runtime turns them off after system -* wide resume is complete. -*/ -if (!lis3->pdata || !lis3->pdata->wakeup_flags || -pm_runtime_suspended (dev)) +/* Turn back off if turned on for wakeup and runtime suspended*/ +if (lis3->pdata && lis3->pdata->wakeup_flags) { +if (pm_runtime_suspended (dev)) +lis3lv02d_poweroff (lis3); +/* For non wakeup turn back on if not runtime suspended */ + }else if (!pm_runtime_suspended (dev))lis3lv02d_poweron (lis3);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 163/272 mei: me: add arrow lake point S DID
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 7a9b9012043e126f6d6f4683e67409312d1b707b upstream.
Add Arrow Lake S device id.
--- drivers/misc/mei/hw-me-regs.h | 1 + drivers/misc/mei/pci-me.c | 1 + 2 files changed, 2 insertions(+)
drivers/misc/mei/hw-me-regs.h +1 -0
@@ -112,6 +112,7 @@#define MEI_DEV_ID_RPL_S 0x7A68/* Raptor Lake Point S */ #define MEI_DEV_ID_MTL_M 0x7E70/* Meteor Lake Point M */ +#define MEI_DEV_ID_ARL_S 0x7F68/* Arrow Lake Point S */ /* * MEI HW Section
drivers/misc/mei/pci-me.c +1 -0
@@ -119,6 +119,7 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_RPL_S, MEI_ME_PCH15_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_MTL_M, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_ARL_S, MEI_ME_PCH15_CFG)},/* required last entry */ {0, }
Greg Kroah-Hartman
maintainerPATCH 164/272 mei: me: add arrow lake point H DID
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 8436f25802ec028ac7254990893f3e01926d9b79 upstream.
Add Arrow Lake H device id.
--- drivers/misc/mei/hw-me-regs.h | 1 + drivers/misc/mei/pci-me.c | 1 + 2 files changed, 2 insertions(+)
drivers/misc/mei/hw-me-regs.h +1 -0
@@ -113,6 +113,7 @@#define MEI_DEV_ID_MTL_M 0x7E70/* Meteor Lake Point M */ #define MEI_DEV_ID_ARL_S 0x7F68/* Arrow Lake Point S */ +#define MEI_DEV_ID_ARL_H 0x7770/* Arrow Lake Point H */ /* * MEI HW Section
drivers/misc/mei/pci-me.c +1 -0
@@ -120,6 +120,7 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_MTL_M, MEI_ME_PCH15_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_ARL_S, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_ARL_H, MEI_ME_PCH15_CFG)},/* required last entry */ {0, }
Greg Kroah-Hartman
maintainerPATCH 165/272 vt: fix unicode buffer corruption when deleting characters
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Pitre <[email protected]>
commit 1581dafaf0d34bc9c428a794a22110d7046d186d upstream.
This is the same issue that was fixed for the VGA text buffer in commit 39cdb68c64d8 ("vt: fix memory overlapping when deleting chars in the buffer"). The cure is also the same i.e. replace memcpy() with memmove() due to the overlaping buffers.
--- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vt/vt.c +1 -1
@@ -398,7 +398,7 @@ static void vc_uniscr_delete(struct vc_dchar32_t *ln = uniscr->lines[vc->state.y];unsigned int x = vc->state.x, cols = vc->vc_cols; -memcpy (&ln[x], &ln[x + nr], (cols - x - nr) *sizeof (*ln)); +memmove (&ln[x], &ln[x + nr], (cols - x - nr) *sizeof (*ln));memset32 (&ln[cols - nr],' ' , nr); } }
Greg Kroah-Hartman
maintainerPATCH 166/272 fs/aio: Check IOCB_AIO_RW before the struct aio_kiocb conversion
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]>
commit 961ebd120565cb60cebe21cb634fbc456022db4a upstream.
The first kiocb_set_cancel_fn() argument may point at a struct kiocb that is not embedded inside struct aio_kiocb. With the current code, depending on the compiler, the req->ki_ctx read happens either before the IOCB_AIO_RW test or after that test. Move the req->ki_ctx read such that it is guaranteed that the IOCB_AIO_RW test happens first.
--- fs/aio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +6 -2
@@ -591,8 +591,8 @@ static int aio_setup_ring(struct kioctxvoid kiocb_set_cancel_fn (struct kiocb *iocb,kiocb_cancel_fn *cancel) { - struct aio_kiocb *req = container_of(iocb, struct aio_kiocb, rw); -struct kioctx *ctx = req->ki_ctx; +struct aio_kiocb *req; +struct kioctx *ctx;unsigned long flags;/*
@@ -602,9 +602,13 @@ void kiocb_set_cancel_fn(struct kiocb *iif (!(iocb->ki_flags &IOCB_AIO_RW ))return ; + req = container_of(iocb, struct aio_kiocb, rw); +if (WARN_ON_ONCE (!list_empty (&req->ki_list)))return ; + ctx = req->ki_ctx; +spin_lock_irqsave (&ctx->ctx_lock, flags);list_add_tail (&req->ki_list, &ctx->active_reqs); req->ki_cancel = cancel;
Greg Kroah-Hartman
maintainerPATCH 167/272 ALSA: hda/realtek - Add Headset Mic supported Acer NB platform
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit 34ab5bbc6e82214d7f7393eba26d164b303ebb4e upstream.
It will be enable headset Mic for Acer NB platform.
--- sound/pci/hda/patch_realtek.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/patch_realtek.c +2 -0
@@ -10750,6 +10750,8 @@ static const struct snd_hda_pin_quirk al* at most one tbl is allowed to define for the same vendor and same codec */ static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = { +SND_HDA_PIN_QUIRK (0x10ec0256 ,0x1025 ,"Acer" ,ALC2XX_FIXUP_HEADSET_MIC , + {0x19, 0x40000000}),SND_HDA_PIN_QUIRK (0x10ec0289 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , {0x19, 0x40000000}, {0x1b, 0x40000000}),
Greg Kroah-Hartman
maintainerPATCH 168/272 ALSA: hda/realtek: fix mute/micmute LEDs for HP EliteBook
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Chi <[email protected]>
commit a17bd44c0146b00fcaa692915789c16bd1fb2a81 upstream.
The HP EliteBook using ALC236 codec which using 0x02 to control mute LED and 0x01 to control micmute LED. Therefore, add a quirk to make it works.
--- sound/pci/hda/patch_realtek.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/pci/hda/patch_realtek.c +4 -0
@@ -9792,6 +9792,10 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8c70 ,"HP EliteBook 835 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c71 ,"HP EliteBook 845 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c72 ,"HP EliteBook 865 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8c8a ,"HP EliteBook 630" ,ALC236_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8c8c ,"HP EliteBook 660" ,ALC236_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8c90 ,"HP EliteBook 640" ,ALC236_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8c91 ,"HP EliteBook 660" ,ALC236_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c96 ,"HP" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ),SND_PCI_QUIRK (0x103c ,0x8c97 ,"HP ZBook" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ), SND_PCI_QUIRK(0x103c, 0x8ca1, "HP ZBook Power", ALC236_FIXUP_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 169/272 tee: optee: Fix kernel panic caused by incorrect error handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumit Garg <[email protected]>
commit 95915ba4b987cf2b222b0f251280228a1ff977ac upstream.
The error path while failing to register devices on the TEE bus has a bug leading to kernel panic as follows:
[ 15.398930] Unable to handle kernel paging request at virtual address ffff07ed00626d7c [ 15.406913] Mem abort info: [ 15.409722] ESR = 0x0000000096000005 [ 15.413490] EC = 0x25: DABT (current EL), IL = 32 bits [ 15.418814] SET = 0, FnV = 0 [ 15.421878] EA = 0, S1PTW = 0 [ 15.425031] FSC = 0x05: level 1 translation fault [ 15.429922] Data abort info: [ 15.432813] ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000 [ 15.438310] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 15.443372] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 15.448697] swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000000d9e3e000 [ 15.455413] [ffff07ed00626d7c] pgd=1800000bffdf9003, p4d=1800000bffdf9003, pud=0000000000000000 [ 15.464146] Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP
Commit 7269cba53d90 ("tee: optee: Fix supplicant based device enumeration") lead to the introduction of this bug. So fix it appropriately.
--- drivers/tee/optee/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tee/optee/device.c +2 -1
@@ -90,13 +90,14 @@ static int optee_register_device(const uif (rc) {pr_err ("device registration failed, err: %d\n" , rc);put_device (&optee_device->dev); +return rc; }if (func ==PTA_CMD_GET_DEVICES_SUPP )device_create_file (&optee_device->dev, &dev_attr_need_supplicant); -return rc; +return 0 ; }static int __optee_enumerate_devices (u32 func)
Greg Kroah-Hartman
maintainerPATCH 170/272 mm, vmscan: prevent infinite loop for costly GFP_NOIO | __GFP_RETRY_MAYFAIL allocations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit 803de9000f334b771afacb6ff3e78622916668b0 upstream.
Sven reports an infinite loop in __alloc_pages_slowpath() for costly order __GFP_RETRY_MAYFAIL allocations that are also GFP_NOIO. Such combination can happen in a suspend/resume context where a GFP_KERNEL allocation can have __GFP_IO masked out via gfp_allowed_mask.
Quoting Sven:
1. try to do a "costly" allocation (order > PAGE_ALLOC_COSTLY_ORDER) with __GFP_RETRY_MAYFAIL set.
2. page alloc's __alloc_pages_slowpath tries to get a page from the freelist. This fails because there is nothing free of that costly order.
3. page alloc tries to reclaim by calling __alloc_pages_direct_reclaim, which bails out because a zone is ready to be compacted; it pretends to have made a single page of progress.
4. page alloc tries to compact, but this always bails out early because __GFP_IO is not set (it's not passed by the snd allocator, and even if it were, we are suspending so the __GFP_IO flag would be cleared anyway).
5. page alloc believes reclaim progress was made (because of the pretense in item 3) and so it checks whether it should retry compaction. The compaction retry logic thinks it should try again, because:
a) reclaim is needed because of the early bail-out in item 4
b) a zonelist is suitable for compaction
6. goto 2. indefinite stall.
(end quote)
The immediate root cause is confusing the COMPACT_SKIPPED returned from __alloc_pages_direct_compact() (step 4) due to lack of __GFP_IO to be indicating a lack of order-0 pages, and in step 5 evaluating that in should_compact_retry() as a reason to retry, before incrementing and limiting the number of retries. There are however other places that wrongly assume that compaction can happen while we lack __GFP_IO.
To fix this, introduce gfp_compaction_allowed() to abstract the __GFP_IO evaluation and switch the open-coded test in try_to_compact_pages() to use it.
Also use the new helper in:
- compaction_ready(), which will make reclaim not bail out in step 3, so there's at least one attempt to actually reclaim, even if chances are small for a costly order
- in_reclaim_compaction() which will make should_continue_reclaim() return false and we don't over-reclaim unnecessarily
- in __alloc_pages_slowpath() to set a local variable can_compact, which is then used to avoid retrying reclaim/compaction for costly allocations (step 5) if we can't compact and also to skip the early compaction attempt that we do in some cases
--- include/linux/gfp.h | 9 +++++++++ mm/compaction.c | 7 +------ mm/page_alloc.c | 10 ++++++---- mm/vmscan.c | 5 ++++- 4 files changed, 20 insertions(+), 11 deletions(-)
include/linux/gfp.h +9 -0
@@ -341,6 +341,15 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_maextern void pm_restrict_gfp_mask (void );extern void pm_restore_gfp_mask (void ); +/* +* Check if the gfp flags allow compaction - GFP_NOIO is a really +* tricky context because the migration might require IO. +*/ +static inline bool gfp_compaction_allowed (gfp_t gfp_mask) +{ +return IS_ENABLED (CONFIG_COMPACTION ) && (gfp_mask & __GFP_IO); +} +extern gfp_t vma_thp_gfp_mask (struct vm_area_struct *vma);#ifdef CONFIG_PM_SLEEP
mm/compaction.c +1 -6
@@ -2570,16 +2570,11 @@ enum compact_result try_to_compact_pages unsigned int alloc_flags, const struct alloc_context *ac, enum compact_priority prio, struct page **capture) { - int may_perform_io = (__force int)(gfp_mask & __GFP_IO); struct zoneref *z;struct zone *zone;enum compact_result rc =COMPACT_SKIPPED ; -/* -* Check if the GFP flags allow compaction - GFP_NOIO is really -* tricky context because the migration might require IO -*/ -if (!may_perform_io) +if (!gfp_compaction_allowed (gfp_mask))return COMPACT_SKIPPED ;trace_mm_compaction_try_to_compact_pages (order, gfp_mask, prio);
mm/page_alloc.c +6 -4
@@ -5012,6 +5012,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, u struct alloc_context *ac) {bool can_direct_reclaim = gfp_mask & __GFP_DIRECT_RECLAIM; +bool can_compact =gfp_compaction_allowed (gfp_mask);const bool costly_order = order >PAGE_ALLOC_COSTLY_ORDER ;struct page *page =NULL ;unsigned int alloc_flags;
@@ -5090,7 +5091,7 @@ restart:* Don't try this for allocations that are allowed to ignore * watermarks, as the ALLOC_NO_WATERMARKS attempt didn't yet happen. */ -if (can_direct_reclaim && +if (can_direct_reclaim && can_compact && (costly_order || (order >0 && ac->migratetype !=MIGRATE_MOVABLE )) && !gfp_pfmemalloc_allowed (gfp_mask)) {
@@ -5188,9 +5189,10 @@ retry:/* * Do not retry costly high order allocations unless they are -* __GFP_RETRY_MAYFAIL +* __GFP_RETRY_MAYFAIL and we can compact */ -if (costly_order && !(gfp_mask & __GFP_RETRY_MAYFAIL)) +if (costly_order && (!can_compact || + !(gfp_mask & __GFP_RETRY_MAYFAIL))) goto nopage; if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
@@ -5203,7 +5205,7 @@ retry:* implementation of the compaction depends on the sufficient amount * of free memory (see __compaction_suitable) */ -if (did_some_progress >0 && +if (did_some_progress >0 && can_compact &&should_compact_retry (ac, order, alloc_flags, compact_result, &compact_priority, &compaction_retries))
mm/vmscan.c +4 -1
@@ -6024,7 +6024,7 @@ static void shrink_lruvec(struct lruvec/* Use reclaim/compaction for costly allocs or under memory pressure */ static bool in_reclaim_compaction (struct scan_control *sc) { -if (IS_ENABLED (CONFIG_COMPACTION ) && sc->order && +if (gfp_compaction_allowed (sc->gfp_mask) && sc->order && (sc->order >PAGE_ALLOC_COSTLY_ORDER || sc->priority <DEF_PRIORITY -2 ))return true;
@@ -6266,6 +6266,9 @@ static inline bool compaction_ready(struunsigned long watermark;enum compact_result suitable; +if (!gfp_compaction_allowed (sc->gfp_mask)) +return false; + suitable =compaction_suitable (zone, sc->order,0 , sc->reclaim_idx);if (suitable ==COMPACT_SUCCESS )/* Allocation should succeed already. Don't reclaim. */
Greg Kroah-Hartman
maintainerPATCH 171/272 iio: accel: adxl367: fix DEVID read after reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Tanislav <[email protected]>
commit 1b926914bbe4e30cb32f268893ef7d82a85275b8 upstream.
regmap_read_poll_timeout() will not sleep before reading, causing the first read to return -ENXIO on I2C, since the chip does not respond to it while it is being reset.
The datasheet specifies that a soft reset operation has a latency of 7.5ms.
Add a 15ms sleep between reset and reading the DEVID register, and switch to a simple regmap_read() call.
--- drivers/iio/accel/adxl367.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iio/accel/adxl367.c +6 -2
@@ -1444,9 +1444,11 @@ static int adxl367_verify_devid(struct aunsigned int val;int ret; - ret =regmap_read_poll_timeout (st->regmap,ADXL367_REG_DEVID , val, - val ==ADXL367_DEVID_AD ,1000 ,10000 ); + ret =regmap_read (st->regmap,ADXL367_REG_DEVID , &val);if (ret) +return dev_err_probe (st->dev, ret,"Failed to read dev id\n" ); + +if (val !=ADXL367_DEVID_AD )return dev_err_probe (st->dev, -ENODEV ,"Invalid dev id 0x%02X, expected 0x%02X\n" , val,ADXL367_DEVID_AD );
@@ -1543,6 +1545,8 @@ int adxl367_probe(struct device *dev, coif (ret)return ret; +fsleep (15000 ); + ret =adxl367_verify_devid (st);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 172/272 iio: accel: adxl367: fix I2C FIFO data register
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Tanislav <[email protected]>
commit 11dadb631007324c7a8bcb2650eda88ed2b9eed0 upstream.
As specified in the datasheet, the I2C FIFO data register is 0x18, not 0x42. 0x42 was used by mistake when adapting the ADXL372 driver.
Fix this mistake.
--- drivers/iio/accel/adxl367_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/adxl367_i2c.c +1 -1
@@ -11,7 +11,7 @@#include "adxl367.h" -#define ADXL367_I2C_FIFO_DATA 0x42 +#define ADXL367_I2C_FIFO_DATA 0x18struct adxl367_i2c_state {struct regmap *regmap;
Signature · 1 line
2.44.0
Greg Kroah-Hartman
maintainerPATCH 173/272 i2c: i801: Avoid potential double call to gpiod_remove_lookup_table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit ceb013b2d9a2946035de5e1827624edc85ae9484 upstream.
If registering the platform device fails, the lookup table is removed in the error path. On module removal we would try to remove the lookup table again. Fix this by setting priv->lookup only if registering the platform device was successful. In addition free the memory allocated for the lookup table in the error path.
--- drivers/i2c/busses/i2c-i801.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +3 -1
@@ -1422,7 +1422,6 @@ static void i801_add_mux(struct i801_pri lookup->table[i] =GPIO_LOOKUP (mux_config->gpio_chip, mux_config->gpios[i],"mux" ,0 );gpiod_add_lookup_table (lookup); - priv->lookup = lookup;/* * Register the mux device, we use PLATFORM_DEVID_NONE here
@@ -1436,7 +1435,10 @@ static void i801_add_mux(struct i801_pri sizeof(struct i2c_mux_gpio_platform_data));if (IS_ERR (priv->mux_pdev)) {gpiod_remove_lookup_table (lookup); +devm_kfree (dev, lookup);dev_err (dev,"Failed to register i2c-mux-gpio device\n" ); + }else { + priv->lookup = lookup; } }
Greg Kroah-Hartman
maintainerPATCH 174/272 drm/amd/display: handle range offsets in VRR ranges
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 937844d661354bf142dc1c621396fdab10ecbacc upstream.
Need to check the offset bits for values greater than 255.
v2: also update amdgpu_dm_connector values.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +14 -5
@@ -10503,14 +10503,23 @@ void amdgpu_dm_update_freesync_caps(struif (range->flags !=1 )continue ; - amdgpu_dm_connector->min_vfreq = range->min_vfreq; - amdgpu_dm_connector->max_vfreq = range->max_vfreq; - amdgpu_dm_connector->pixel_clock_mhz = - range->pixel_clock_mhz *10 ; - connector->display_info.monitor_range.min_vfreq = range->min_vfreq; connector->display_info.monitor_range.max_vfreq = range->max_vfreq; +if (edid->revision >=4 ) { +if (data->pad2 &DRM_EDID_RANGE_OFFSET_MIN_VFREQ ) + connector->display_info.monitor_range.min_vfreq +=255 ; +if (data->pad2 &DRM_EDID_RANGE_OFFSET_MAX_VFREQ ) + connector->display_info.monitor_range.max_vfreq +=255 ; + } + + amdgpu_dm_connector->min_vfreq = + connector->display_info.monitor_range.min_vfreq; + amdgpu_dm_connector->max_vfreq = + connector->display_info.monitor_range.max_vfreq; + amdgpu_dm_connector->pixel_clock_mhz = + range->pixel_clock_mhz *10 ; +break ; }
Greg Kroah-Hartman
maintainerPATCH 175/272 x86/efistub: Call mixed mode boot services on the firmwares stack
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit cefcd4fe2e3aaf792c14c9e56dab89e3d7a65d02 upstream.
Normally, the EFI stub calls into the EFI boot services using the stack that was live when the stub was entered. According to the UEFI spec, this stack needs to be at least 128k in size - this might seem large but all asynchronous processing and event handling in EFI runs from the same stack and so quite a lot of space may be used in practice.
In mixed mode, the situation is a bit different: the bootloader calls the 32-bit EFI stub entry point, which calls the decompressor's 32-bit entry point, where the boot stack is set up, using a fixed allocation of 16k. This stack is still in use when the EFI stub is started in 64-bit mode, and so all calls back into the EFI firmware will be using the decompressor's limited boot stack.
Due to the placement of the boot stack right after the boot heap, any stack overruns have gone unnoticed. However, commit
5c4feadb0011983b ("x86/decompressor: Move global symbol references to C code")
moved the definition of the boot heap into C code, and now the boot stack is placed right at the base of BSS, where any overruns will corrupt the end of the .data section.
While it would be possible to work around this by increasing the size of the boot stack, doing so would affect all x86 systems, and mixed mode systems are a tiny (and shrinking) fraction of the x86 installed base.
So instead, record the firmware stack pointer value when entering from the 32-bit firmware, and switch to this stack every time a EFI boot service call is made.
--- arch/x86/boot/compressed/efi_mixed.S | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/boot/compressed/efi_mixed.S +9 -0
@@ -49,6 +49,11 @@ SYM_FUNC_START(startup_64_mixed_mode) lea efi32_boot_args(%rip), %rdx mov 0(%rdx), %edi mov 4(%rdx), %esi + + /* Switch to the firmware's stack */ + movl efi32_boot_sp(%rip), %esp + andl $~7, %esp + #ifdef CONFIG_EFI_HANDOVER_PROTOCOL mov 8(%rdx), %edx // saved bootparams pointer test %edx, %edx
@@ -260,6 +265,9 @@ SYM_FUNC_START_LOCAL(efi32_entry) /* Store firmware IDT descriptor */ sidtl (efi32_boot_idt - 1b)(%ebx) + /* Store firmware stack pointer */ + movl %esp, (efi32_boot_sp - 1b)(%ebx) + /* Store boot arguments */ leal (efi32_boot_args - 1b)(%ebx), %ebx movl %ecx, 0(%ebx)
@@ -324,5 +332,6 @@ SYM_DATA_END(efi32_boot_idt) SYM_DATA_LOCAL(efi32_boot_cs, .word 0) SYM_DATA_LOCAL(efi32_boot_ds, .word 0) +SYM_DATA_LOCAL(efi32_boot_sp, .long 0) SYM_DATA_LOCAL(efi32_boot_args, .long 0, 0, 0) SYM_DATA(efi_is64, .byte 1)
Greg Kroah-Hartman
maintainerPATCH 176/272 net: tls: handle backlogging of crypto requests
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
commit 8590541473188741055d27b955db0777569438e3 upstream.
Since we're setting the CRYPTO_TFM_REQ_MAY_BACKLOG flag on our requests to the crypto API, crypto_aead_{encrypt,decrypt} can return
-EBUSY instead of -EINPROGRESS in valid situations. For example, when
the cryptd queue for AESNI is full (easy to trigger with an artificially low cryptd.cryptd_max_cpu_qlen), requests will be enqueued to the backlog but still processed. In that case, the async callback will also be called twice: first with err == -EINPROGRESS, which it seems we can just ignore, then with err == 0.
Compared to Sabrina's original patch this version uses the new tls_*crypt_async_wait() helpers and converts the EBUSY to EINPROGRESS to avoid having to modify all the error handling paths. The handling is identical.
[Srish: v2: fixed hunk failures
fixed merge-conflict in stable branch linux-6.1.y,
needs to go on top of https://lore.kernel.org/stable/[email protected]/]
--- net/tls/tls_sw.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
net/tls/tls_sw.c +22 -0
@@ -195,6 +195,17 @@ static void tls_decrypt_done(crypto_compstruct sock *sk;int aead_size; +/* If requests get too backlogged crypto API returns -EBUSY and calls +* ->complete(-EINPROGRESS) immediately followed by ->complete(0) +* to make waiting for backlog to flush with crypto_wait_req() easier. +* First wait converts -EBUSY -> -EINPROGRESS, and the second one +* -EINPROGRESS -> 0. +* We have a single struct crypto_async_request per direction, this +* scheme doesn't help us, so just ignore the first ->complete(). +*/ +if (err == -EINPROGRESS ) +return ; + aead_size =sizeof (*aead_req) +crypto_aead_reqsize (aead); aead_size = ALIGN(aead_size, __alignof__(*dctx)); dctx = (void *)((u8 *)aead_req + aead_size);
@@ -268,6 +279,10 @@ static int tls_do_decryption(struct sock } ret =crypto_aead_decrypt (aead_req); +if (ret == -EBUSY ) { + ret =tls_decrypt_async_wait (ctx); + ret = ret ?: -EINPROGRESS ; + }if (ret == -EINPROGRESS ) {if (darg->async)return 0 ;
@@ -451,6 +466,9 @@ static void tls_encrypt_done(crypto_compstruct tls_rec *rec;struct sock *sk; +if (err == -EINPROGRESS )/* see the comment in tls_decrypt_done() */ +return ; + rec = container_of(aead_req, struct tls_rec, aead_req); msg_en = &rec->msg_encrypted;
@@ -556,6 +574,10 @@ static int tls_do_encryption(struct sockatomic_inc (&ctx->encrypt_pending); rc =crypto_aead_encrypt (aead_req); +if (rc == -EBUSY ) { + rc =tls_encrypt_async_wait (ctx); + rc = rc ?: -EINPROGRESS ; + }if (!rc || rc != -EINPROGRESS ) {atomic_dec (&ctx->encrypt_pending); sge->offset -= prot->prepend_size;
Greg Kroah-Hartman
maintainerPATCH 177/272 ASoC: amd: yc: Revert "Fix non-functional mic on Lenovo 21J2"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawei Wang <[email protected]>
commit 861b3415e4dee06cc00cd1754808a7827b9105bf upstream.
This reverts commit ed00a6945dc32462c2d3744a3518d2316da66fcc, which added a quirk entry to enable the Yellow Carp (YC) driver for the Lenovo 21J2 laptop.
Although the microphone functioned with the YC driver, it resulted in incorrect driver usage. The Lenovo 21J2 is not a Yellow Carp platform, but a Pink Sardine platform, which already has an upstreamed driver.
The microphone on the Lenovo 21J2 operates correctly with the CONFIG_SND_SOC_AMD_PS flag enabled and does not require the quirk entry. So this patch removes the quirk entry.
Thanks to Mukunda Vijendar [1] for pointing this out.
--- sound/soc/amd/yc/acp6x-mach.c | 7 ------- 1 file changed, 7 deletions(-)
sound/soc/amd/yc/acp6x-mach.c +0 -7
@@ -203,13 +203,6 @@ static const struct dmi_system_id yc_acp .driver_data = &acp6x_card, .matches = {DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), - DMI_MATCH(DMI_PRODUCT_NAME, "21J2"), - } - }, - { - .driver_data = &acp6x_card, - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), DMI_MATCH(DMI_PRODUCT_NAME, "21J0"), } },
Greg Kroah-Hartman
maintainerPATCH 178/272 iommu: Avoid races around default domain allocations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charan Teja Kalla <[email protected]>
This fix is applicable for LTS kernel, 6.1.y. In latest kernels, this race issue is fixed by the patch series [1] and [2]. The right thing to do here would have been propagating these changes from latest kernel to the stable branch, 6.1.y. However, these changes seems too intrusive to be picked for stable branches. Hence, the fix proposed can be taken as an alternative instead of backporting the patch series.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Issue:
A race condition is observed when arm_smmu_device_probe and modprobe of client devices happens in parallel. This results in the allocation of a new default domain for the iommu group even though it was previously allocated and the respective iova domain(iovad) was initialized. However, for this newly allocated default domain, iovad will not be initialized. As a result, for devices requesting dma allocations, this uninitialized iovad will be used, thereby causing NULL pointer dereference issue.
Flow:
- During arm_smmu_device_probe, bus_iommu_probe() will be called as part of iommu_device_register(). This results in the device probe, __iommu_probe_device().
- When the modprobe of the client device happens in parallel, it sets up the DMA configuration for the device using of_dma_configure_id(), which inturn calls iommu_probe_device(). Later, default domain is allocated and attached using iommu_alloc_default_domain() and __iommu_attach_device() respectively. It then ends up initializing a mapping domain(IOVA domain) and rcaches for the device via arch_setup_dma_ops()->iommu_setup_dma_ops().
- Now, in the bus_iommu_probe() path, it again tries to allocate a default domain via probe_alloc_default_domain(). This results in allocating a new default domain(along with IOVA domain) via __iommu_domain_alloc(). However, this newly allocated IOVA domain will not be initialized.
- Now, when the same client device tries dma allocations via iommu_dma_alloc(), it ends up accessing the rcaches of the newly allocated IOVA domain, which is not initialized. This results into NULL pointer dereferencing.
Fix this issue by adding a check in probe_alloc_default_domain() to see if the iommu_group already has a default domain allocated and initialized.
--- drivers/iommu/iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/iommu.c +3 -0
@@ -1741,6 +1741,9 @@ static void probe_alloc_default_domain(s {struct __group_domain_type gtype; +if (group->default_domain) +return ; +memset (>ype,0 ,sizeof (gtype));/* Ask for default domain requirements of all devices in the group */
Greg Kroah-Hartman
maintainerPATCH 179/272 clocksource/drivers/arm_global_timer: Fix maximum prescaler value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit b34b9547cee41575a4fddf390f615570759dc999 ]
The prescaler in the "Global Timer Control Register bit assignments" is documented to use bits [15:8], which means that the maximum prescaler register value is 0xff.
--- drivers/clocksource/arm_global_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_global_timer.c +1 -1
@@ -32,7 +32,7 @@#define GT_CONTROL_IRQ_ENABLE BIT(2)/* banked */ #define GT_CONTROL_AUTO_INC BIT(3)/* banked */ #define GT_CONTROL_PRESCALER_SHIFT 8 -#define GT_CONTROL_PRESCALER_MAX 0xF +#define GT_CONTROL_PRESCALER_MAX 0xFF#define GT_CONTROL_PRESCALER_MASK (GT_CONTROL_PRESCALER_MAX << \ GT_CONTROL_PRESCALER_SHIFT)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 180/272 entry: Respect changes to system call number by trace_sys_enter()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Rösti <[email protected]>
[ Upstream commit fb13b11d53875e28e7fbf0c26b288e4ea676aa9f ]
When a probe is registered at the trace_sys_enter() tracepoint, and that probe changes the system call number, the old system call still gets executed. This worked correctly until commit b6ec41346103 ("core/entry:
Report syscall correctly for trace and audit"), which removed the re-evaluation of the syscall number after the trace point.
Restore the original semantics by re-evaluating the system call number after trace_sys_enter().
The performance impact of this re-evaluation is minimal because it only takes place when a trace point is active, and compared to the actual trace point overhead the read from a cache hot variable is negligible.
--- kernel/entry/common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/entry/common.c +7 -1
@@ -77,8 +77,14 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,/* Either of the above might have changed the syscall number */ syscall =syscall_get_nr (current, regs); -if (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT )) +if (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT )) {trace_sys_enter (regs, syscall); +/* +* Probes or BPF hooks in the tracepoint may have changed the +* system call number as well. +*/ + syscall =syscall_get_nr (current, regs); + }syscall_enter_audit (regs, syscall);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 181/272 minmax: add umin(a, b) and umax(a, b)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit 80fcac55385ccb710d33a20dc1caaef29bd5a921 ]
Patch series "minmax: Relax type checks in min() and max()", v4.
The min() (etc) functions in minmax.h require that the arguments have exactly the same types.
However when the type check fails, rather than look at the types and fix the type of a variable/constant, everyone seems to jump on min_t(). In reality min_t() ought to be rare - when something unusual is being done, not normality.
The orginal min() (added in 2.4.9) replaced several inline functions and included the type - so matched the implicit casting of the function call. This was renamed min_t() in 2.4.10 and the current min() added. There is no actual indication that the conversion of negatve values to large unsigned values has ever been an actual problem.
A quick grep shows 5734 min() and 4597 min_t(). Having the casts on almost half of the calls shows that something is clearly wrong.
If the wrong type is picked (and it is far too easy to pick the type of the result instead of the larger input) then significant bits can get discarded.
Pretty much the worst example is in the derived clamp_val(), consider:
unsigned char x = 200u;
y = clamp_val(x, 10u, 300u);I also suspect that many of the min_t(u16, ...) are actually wrong. For example copy_data() in printk_ringbuffer.c contains:
data_size = min_t(u16, buf_size, len);
Here buf_size is 'unsigned int' and len 'u16', pass a 64k buffer (can you prove that doesn't happen?) and no data is returned. Apparantly it did - and has since been fixed.
The only reason that most of the min_t() are 'fine' is that pretty much all the values in the kernel are between 0 and INT_MAX.
Patch 1 adds umin(), this uses integer promotions to convert both arguments to 'unsigned long long'. It can be used to compare a signed type that is known to contain a non-negative value with an unsigned type. The compiler typically optimises it all away. Added first so that it can be referred to in patch 2.
Patch 2 replaces the 'same type' check with a 'same signedness' one. This makes min(unsigned_int_var, sizeof()) be ok. The error message is also improved and will contain the expanded form of both arguments (useful for seeing how constants are defined).
Patch 3 just fixes some whitespace.
Patch 4 allows comparisons of 'unsigned char' and 'unsigned short' to signed types. The integer promotion rules convert them both to 'signed int' prior to the comparison so they can never cause a negative value be converted to a large positive one.
Patch 5 (rewritted for v4) allows comparisons of unsigned values against non-negative constant integer expressions. This makes min(unsigned_int_var, 4) be ok.
The only common case that is still errored is the comparison of signed values against unsigned constant integer expressions below __INT_MAX__. Typcally min(int_val, sizeof (foo)), the real fix for this is casting the
constant: min(int_var, (int)sizeof (foo)).
With all the patches applied pretty much all the min_t() could be replaced by min(), and most of the rest by umin(). However they all need careful inspection due to code like:
sz = min_t(unsigned char, sz - 1, LIM - 1) + 1;
which converts 0 to LIM.
This patch (of 6):
umin() and umax() can be used when min()/max() errors a signed v unsigned compare when the signed value is known to be non-negative.
Unlike min_t(some_unsigned_type, a, b) umin() will never mask off high bits if an inappropriate type is selected.
The '+ 0u + 0ul + 0ull' may look strange.
The '+ 0u' is needed for 'signed int' on 64bit systems. The '+ 0ul' is needed for 'signed long' on 32bit systems. The '+ 0ull' is needed for 'signed long long'.
Stable-dep-of: 51b30ecb73b4 ("swiotlb: Fix alignment checks when both allocation and DMA masks are present")
--- include/linux/minmax.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/linux/minmax.h +17 -0
@@ -51,6 +51,23 @@*/ #define max (x, y) __careful_cmp(x, y, >) +/** +* umin - return minimum of two non-negative values +* Signed types are zero extended to match a larger unsigned type. +* @x: first value +* @y: second value +*/ +#define umin (x, y) \ + __careful_cmp((x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull, <) + +/** +* umax - return maximum of two non-negative values +* @x: first value +* @y: second value +*/ +#define umax (x, y) \ + __careful_cmp((x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull, >) +/** * min3 - return minimum of three values * @x: first value
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 182/272 swiotlb: Fix alignment checks when both allocation and DMA masks are present
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit 51b30ecb73b481d5fac6ccf2ecb4a309c9ee3310 ]
Nicolin reports that swiotlb buffer allocations fail for an NVME device behind an IOMMU using 64KiB pages. This is because we end up with a minimum allocation alignment of 64KiB (for the IOMMU to map the buffer safely) but a minimum DMA alignment mask corresponding to a 4KiB NVME page (i.e. preserving the 4KiB page offset from the original allocation). If the original address is not 4KiB-aligned, the allocation will fail because swiotlb_search_pool_area() erroneously compares these unmasked bits with the 64KiB-aligned candidate allocation.
Tweak swiotlb_search_pool_area() so that the DMA alignment mask is reduced based on the required alignment of the allocation.
--- kernel/dma/swiotlb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/dma/swiotlb.c +9 -2
@@ -654,8 +654,7 @@ static int swiotlb_do_find_slots(struct device *dev, int area_index,dma_addr_t tbl_dma_addr =phys_to_dma_unencrypted (dev, mem->start) & boundary_mask;unsigned long max_slots =get_max_slots (boundary_mask); -unsigned int iotlb_align_mask = -dma_get_min_align_mask (dev) & ~(IO_TLB_SIZE -1 ); +unsigned int iotlb_align_mask =dma_get_min_align_mask (dev);unsigned int nslots =nr_slots (alloc_size), stride;unsigned int index, wrap, count =0 , i;unsigned int offset =swiotlb_align_offset (dev, orig_addr);
@@ -666,6 +665,14 @@ static int swiotlb_do_find_slots(struct device *dev, int area_index,BUG_ON (!nslots);BUG_ON (area_index >= mem->nareas); +/* +* Ensure that the allocation is at least slot-aligned and update +* 'iotlb_align_mask' to ignore bits that will be preserved when +* offsetting into the allocation. +*/ + alloc_align_mask |= (IO_TLB_SIZE -1 ); + iotlb_align_mask &= ~alloc_align_mask; +/* * For mappings with an alignment requirement don't bother looping to * unaligned slots once we found an aligned one. For allocations of
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 183/272 iommu/dma: Force swiotlb_max_mapping_size on an untrusted device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit afc5aa46ed560f01ceda897c053c6a40c77ce5c4 ]
The swiotlb does not support a mapping size > swiotlb_max_mapping_size().
On the other hand, with a 64KB PAGE_SIZE configuration, it's observed that
an NVME device can map a size between 300KB~512KB, which certainly failed
the swiotlb mappings, though the default pool of swiotlb has many slots:
systemd[1]: Started Journal Service.
=> nvme 0000:00:01.0: swiotlb buffer is full (sz: 327680 bytes), total 32768 (slots), used 32 (slots)
note: journal-offline[392] exited with irqs disabled
note: journal-offline[392] exited with preempt_count 1
Call trace: [ 3.099918] swiotlb_tbl_map_single+0x214/0x240 [ 3.099921] iommu_dma_map_page+0x218/0x328 [ 3.099928] dma_map_page_attrs+0x2e8/0x3a0 [ 3.101985] nvme_prep_rq.part.0+0x408/0x878 [nvme] [ 3.102308] nvme_queue_rqs+0xc0/0x300 [nvme] [ 3.102313] blk_mq_flush_plug_list.part.0+0x57c/0x600 [ 3.102321] blk_add_rq_to_plug+0x180/0x2a0 [ 3.102323] blk_mq_submit_bio+0x4c8/0x6b8 [ 3.103463] __submit_bio+0x44/0x220 [ 3.103468] submit_bio_noacct_nocheck+0x2b8/0x360 [ 3.103470] submit_bio_noacct+0x180/0x6c8 [ 3.103471] submit_bio+0x34/0x130 [ 3.103473] ext4_bio_write_folio+0x5a4/0x8c8 [ 3.104766] mpage_submit_folio+0xa0/0x100 [ 3.104769] mpage_map_and_submit_buffers+0x1a4/0x400 [ 3.104771] ext4_do_writepages+0x6a0/0xd78 [ 3.105615] ext4_writepages+0x80/0x118 [ 3.105616] do_writepages+0x90/0x1e8 [ 3.105619] filemap_fdatawrite_wbc+0x94/0xe0 [ 3.105622] __filemap_fdatawrite_range+0x68/0xb8 [ 3.106656] file_write_and_wait_range+0x84/0x120 [ 3.106658] ext4_sync_file+0x7c/0x4c0 [ 3.106660] vfs_fsync_range+0x3c/0xa8 [ 3.106663] do_fsync+0x44/0xc0
Since untrusted devices might go down the swiotlb pathway with dma-iommu, these devices should not map a size larger than swiotlb_max_mapping_size.
To fix this bug, add iommu_dma_max_mapping_size() for untrusted devices to take into account swiotlb_max_mapping_size() v.s. iova_rcache_range() from the iommu_dma_opt_mapping_size().
--- drivers/iommu/dma-iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iommu/dma-iommu.c +9 -0
@@ -1547,6 +1547,14 @@ static size_t iommu_dma_opt_mapping_size(void)return iova_rcache_range (); } +static size_t iommu_dma_max_mapping_size (struct device *dev) +{ +if (dev_is_untrusted (dev)) +return swiotlb_max_mapping_size (dev); + +return SIZE_MAX ; +} +static const struct dma_map_ops iommu_dma_ops = { .flags =DMA_F_PCI_P2PDMA_SUPPORTED , .alloc = iommu_dma_alloc,
@@ -1569,6 +1577,7 @@ static const struct dma_map_ops iommu_dma_ops = { .unmap_resource = iommu_dma_unmap_resource, .get_merge_boundary = iommu_dma_get_merge_boundary, .opt_mapping_size = iommu_dma_opt_mapping_size, + .max_mapping_size = iommu_dma_max_mapping_size, };/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 184/272 printk: Update @console_may_schedule in console_trylock_spinning()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 8076972468584d4a21dab9aa50e388b3ea9ad8c7 ]
console_trylock_spinning() may takeover the console lock from a schedulable context. Update @console_may_schedule to make sure it reflects a trylock acquire.
--- kernel/printk/printk.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/printk/printk.c +6 -0
@@ -1947,6 +1947,12 @@ static int console_trylock_spinning(void)*/ mutex_acquire (&console_lock_dep_map,0 ,1 , _THIS_IP_); +/* +* Update @console_may_schedule for trylock because the previous +* owner may have been schedulable. +*/ + console_may_schedule =0 ; +return 1 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 185/272 irqchip/renesas-rzg2l: Implement restriction when writing ISCR register
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit ef88eefb1a81a8701eabb7d5ced761a66a465a49 ]
The RZ/G2L manual (chapter "IRQ Status Control Register (ISCR)") describes the operation to clear interrupts through the ISCR register as follows:
[Write operation]
When "Falling-edge detection", "Rising-edge detection" or "Falling/Rising-edge detection" is set in IITSR:
- In case ISTAT is 1
0: IRQn interrupt detection status is cleared. 1: Invalid to write.
- In case ISTAT is 0
Invalid to write.
When "Low-level detection" is set in IITSR.:
Invalid to write.
Take the interrupt type into account when clearing interrupts through the ISCR register to avoid writing the ISCR when the interrupt type is level.
Stable-dep-of: 9eec61df55c5 ("irqchip/renesas-rzg2l: Flush posted write in irq_eoi()")
--- drivers/irqchip/irq-renesas-rzg2l.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +10 -4
@@ -72,11 +72,17 @@ static void rzg2l_irq_eoi(struct irq_data *d)unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ;struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);u32 bit =BIT (hw_irq); -u32 reg; +u32 iitsr, iscr; - reg =readl_relaxed (priv->base +ISCR ); -if (reg & bit) -writel_relaxed (reg & ~bit, priv->base +ISCR ); + iscr =readl_relaxed (priv->base +ISCR ); + iitsr =readl_relaxed (priv->base +IITSR ); + +/* +* ISCR can only be cleared if the type is falling-edge, rising-edge or +* falling/rising-edge. +*/ +if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) +writel_relaxed (iscr & ~bit, priv->base +ISCR ); }static void rzg2l_tint_eoi (struct irq_data *d)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 186/272 irqchip/renesas-rzg2l: Flush posted write in irq_eoi()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 9eec61df55c51415409c7cc47e9a1c8de94a0522 ]
The irq_eoi() callback of the RZ/G2L interrupt chip clears the relevant interrupt cause bit in the TSCR register by writing to it.
This write is not sufficient because the write is posted and therefore not guaranteed to immediately clear the bit. Due to that delay the CPU can raise the just handled interrupt again.
Prevent this by reading the register back which causes the posted write to be flushed to the hardware before the read completes.
--- drivers/irqchip/irq-renesas-rzg2l.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +14 -2
@@ -81,8 +81,14 @@ static void rzg2l_irq_eoi(struct irq_data *d)* ISCR can only be cleared if the type is falling-edge, rising-edge or * falling/rising-edge. */ -if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) +if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) {writel_relaxed (iscr & ~bit, priv->base +ISCR ); +/* +* Enforce that the posted write is flushed to prevent that the +* just handled interrupt is raised again. +*/ +readl_relaxed (priv->base +ISCR ); + } }static void rzg2l_tint_eoi (struct irq_data *d)
@@ -93,8 +99,14 @@ static void rzg2l_tint_eoi(struct irq_data *d)u32 reg; reg =readl_relaxed (priv->base +TSCR ); -if (reg & bit) +if (reg & bit) {writel_relaxed (reg & ~bit, priv->base +TSCR ); +/* +* Enforce that the posted write is flushed to prevent that the +* just handled interrupt is raised again. +*/ +readl_relaxed (priv->base +TSCR ); + } }static void rzg2l_irqc_eoi (struct irq_data *d)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 187/272 irqchip/renesas-rzg2l: Add macro to retrieve TITSR register offset based on registers index
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 2eca4731cc66563b3919d8753dbd74d18c39f662 ]
There are 2 TITSR registers available on the IA55 interrupt controller.
Add a macro that retrieves the TITSR register offset based on it's index. This macro is useful in when adding suspend/resume support so both TITSR registers can be accessed in a for loop.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +6 -8
@@ -28,8 +28,7 @@#define ISCR 0x10#define IITSR 0x14#define TSCR 0x20 -#define TITSR0 0x24 -#define TITSR1 0x28 +#define TITSR (n) (0x24 + (n) * 4)#define TITSR0_MAX_INT 16#define TITSEL_WIDTH 0x2#define TSSR (n) (0x30 + ((n) * 4))
@@ -206,8 +205,7 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type)struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);unsigned int hwirq =irqd_to_hwirq (d);u32 titseln = hwirq -IRQC_TINT_START ; -u32 offset; -u8 sense; +u8 index, sense;u32 reg;switch (type &IRQ_TYPE_SENSE_MASK ) {
@@ -223,17 +221,17 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type)return -EINVAL ; } - offset =TITSR0 ; + index =0 ;if (titseln >=TITSR0_MAX_INT ) { titseln -=TITSR0_MAX_INT ; - offset =TITSR1 ; + index =1 ; }raw_spin_lock (&priv->lock); - reg =readl_relaxed (priv->base + offset); + reg =readl_relaxed (priv->base +TITSR (index)); reg &= ~(IRQ_MASK << (titseln *TITSEL_WIDTH )); reg |= sense << (titseln *TITSEL_WIDTH ); -writel_relaxed (reg, priv->base + offset); +writel_relaxed (reg, priv->base +TITSR (index));raw_spin_unlock (&priv->lock);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 188/272 irqchip/renesas-rzg2l: Rename rzg2l_tint_eoi()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 7cb6362c63df233172eaecddaf9ce2ce2f769112 ]
Rename rzg2l_tint_eoi()->rzg2l_clear_tint_int() and simplify the code by removing redundant priv and hw_irq local variables.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -5
@@ -90,11 +90,9 @@ static void rzg2l_irq_eoi(struct irq_data *d) } } -static void rzg2l_tint_eoi (struct irq_data *d) +static void rzg2l_clear_tint_int (struct rzg2l_irqc_priv *priv,unsigned int hwirq) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_TINT_START ; -struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); -u32 bit =BIT (hw_irq); +u32 bit =BIT (hwirq -IRQC_TINT_START );u32 reg; reg =readl_relaxed (priv->base +TSCR );
@@ -117,7 +115,7 @@ static void rzg2l_irqc_eoi(struct irq_data *d)if (hw_irq >=IRQC_IRQ_START && hw_irq <=IRQC_IRQ_COUNT )rzg2l_irq_eoi (d);else if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ ) -rzg2l_tint_eoi (d); +rzg2l_clear_tint_int (priv, hw_irq);raw_spin_unlock (&priv->lock);irq_chip_eoi_parent (d); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 189/272 irqchip/renesas-rzg2l: Rename rzg2l_irq_eoi()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit b4b5cd61a6fdd92ede0dc39f0850a182affd1323 ]
Rename rzg2l_irq_eoi()->rzg2l_clear_irq_int() and simplify the code by removing redundant priv local variable.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -4
@@ -66,10 +66,9 @@ static struct rzg2l_irqc_priv *irq_data_to_priv(struct irq_data *data)return data->domain->host_data; } -static void rzg2l_irq_eoi (struct irq_data *d) +static void rzg2l_clear_irq_int (struct rzg2l_irqc_priv *priv,unsigned int hwirq) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ; -struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); +unsigned int hw_irq = hwirq -IRQC_IRQ_START ;u32 bit =BIT (hw_irq);u32 iitsr, iscr;
@@ -113,7 +112,7 @@ static void rzg2l_irqc_eoi(struct irq_data *d)raw_spin_lock (&priv->lock);if (hw_irq >=IRQC_IRQ_START && hw_irq <=IRQC_IRQ_COUNT ) -rzg2l_irq_eoi (d); +rzg2l_clear_irq_int (priv, hw_irq);else if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ )rzg2l_clear_tint_int (priv, hw_irq);raw_spin_unlock (&priv->lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 190/272 irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 853a6030303f8a8fa54929b68e5665d9b21aa405 ]
RZ/G2L interrupt chips require that the interrupt is masked before changing the NMI, IRQ, TINT interrupt settings. Aside of that, after setting an edge trigger type it is required to clear the interrupt status register in order to avoid spurious interrupts.
The current implementation fails to do either of that and therefore is prone to generate spurious interrupts when setting the trigger type.
Address this by:
- Ensuring that the interrupt is masked at the chip level across the update for the TINT chip
- Clearing the interrupt status register after updating the trigger mode for edge type interrupts
[ tglx: Massaged changelog and reverted the spin_lock_irqsave() change as
the set_type() callback is always called with interrupts disabled. ]
--- drivers/irqchip/irq-renesas-rzg2l.c | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +32 -4
@@ -162,8 +162,10 @@ static void rzg2l_irqc_irq_enable(struct irq_data *d)static int rzg2l_irq_set_type (struct irq_data *d,unsigned int type) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ;struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); +unsigned int hwirq =irqd_to_hwirq (d); +u32 iitseln = hwirq -IRQC_IRQ_START ; +bool clear_irq_int = false;u16 sense, tmp;switch (type &IRQ_TYPE_SENSE_MASK ) {
@@ -173,14 +175,17 @@ static int rzg2l_irq_set_type(struct irq_data *d, unsigned int type)case IRQ_TYPE_EDGE_FALLING : sense =IITSR_IITSEL_EDGE_FALLING ; + clear_irq_int = true;break ;case IRQ_TYPE_EDGE_RISING : sense =IITSR_IITSEL_EDGE_RISING ; + clear_irq_int = true;break ;case IRQ_TYPE_EDGE_BOTH : sense =IITSR_IITSEL_EDGE_BOTH ; + clear_irq_int = true;break ;default :
@@ -189,21 +194,40 @@ static int rzg2l_irq_set_type(struct irq_data *d, unsigned int type)raw_spin_lock (&priv->lock); tmp =readl_relaxed (priv->base +IITSR ); - tmp &= ~IITSR_IITSEL_MASK (hw_irq); - tmp |=IITSR_IITSEL (hw_irq, sense); + tmp &= ~IITSR_IITSEL_MASK (iitseln); + tmp |=IITSR_IITSEL (iitseln, sense); +if (clear_irq_int) +rzg2l_clear_irq_int (priv, hwirq);writel_relaxed (tmp, priv->base +IITSR );raw_spin_unlock (&priv->lock);return 0 ; } +static u32 rzg2l_disable_tint_and_set_tint_source (struct irq_data *d,struct rzg2l_irqc_priv *priv, +u32 reg,u32 tssr_offset,u8 tssr_index) +{ +u32 tint = (u32 )(uintptr_t )irq_data_get_irq_chip_data (d); +u32 tien = reg & (TIEN <<TSSEL_SHIFT (tssr_offset)); + +/* Clear the relevant byte in reg */ + reg &= ~(TSSEL_MASK <<TSSEL_SHIFT (tssr_offset)); +/* Set TINT and leave TIEN clear */ + reg |= tint <<TSSEL_SHIFT (tssr_offset); +writel_relaxed (reg, priv->base +TSSR (tssr_index)); + +return reg | tien; +} +static int rzg2l_tint_set_edge (struct irq_data *d,unsigned int type) {struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);unsigned int hwirq =irqd_to_hwirq (d);u32 titseln = hwirq -IRQC_TINT_START ; +u32 tssr_offset =TSSR_OFFSET (titseln); +u8 tssr_index =TSSR_INDEX (titseln);u8 index, sense; -u32 reg; +u32 reg, tssr;switch (type &IRQ_TYPE_SENSE_MASK ) {case IRQ_TYPE_EDGE_RISING :
@@ -225,10 +249,14 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type) }raw_spin_lock (&priv->lock); + tssr =readl_relaxed (priv->base +TSSR (tssr_index)); + tssr =rzg2l_disable_tint_and_set_tint_source (d, priv, tssr, tssr_offset, tssr_index); reg =readl_relaxed (priv->base +TITSR (index)); reg &= ~(IRQ_MASK << (titseln *TITSEL_WIDTH )); reg |= sense << (titseln *TITSEL_WIDTH );writel_relaxed (reg, priv->base +TITSR (index)); +rzg2l_clear_tint_int (priv, hwirq); +writel_relaxed (tssr, priv->base +TSSR (tssr_index));raw_spin_unlock (&priv->lock);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 191/272 kprobes/x86: Use copy_from_kernel_nofault() to read from unsafe address
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 4e51653d5d871f40f1bd5cf95cc7f2d8b33d063b ]
Read from an unsafe address with copy_from_kernel_nofault() in arch_adjust_kprobe_addr() because this function is used before checking the address is in text or not. Syzcaller bot found a bug and reported the case if user specifies inaccessible data area, arch_adjust_kprobe_addr() will cause a kernel panic.
[ mingo: Clarified the comment. ]
--- arch/x86/kernel/kprobes/core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/x86/kernel/kprobes/core.c +10 -1
@@ -301,7 +301,16 @@ static int can_probe(unsigned long paddr)kprobe_opcode_t *arch_adjust_kprobe_addr (unsigned long addr,unsigned long offset,bool *on_func_entry) { -if (is_endbr (*(u32 *)addr)) { +u32 insn; + +/* +* Since 'addr' is not guaranteed to be safe to access, use +* copy_from_kernel_nofault() to read the instruction: +*/ +if (copy_from_kernel_nofault (&insn, (void *)addr,sizeof (u32))) +return NULL ; + +if (is_endbr (insn)) { *on_func_entry = !offset || offset ==4 ;if (*on_func_entry) offset =4 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 192/272 efi/libstub: fix efi_random_alloc() to allocate memory at alloc_min or higher address
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: KONDO KAZUMA(近藤 和真) <[email protected]>
[ Upstream commit 3cb4a4827596abc82e55b80364f509d0fefc3051 ]
Following warning is sometimes observed while booting my servers:
[ 3.594838] DMA: preallocated 4096 KiB GFP_KERNEL pool for atomic allocations [ 3.602918] swapper/0: page allocation failure: order:10, mode:0xcc1(GFP_KERNEL|GFP_DMA), nodemask=(null),cpuset=/,mems_allowed=0-1 ... [ 3.851862] DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA pool for atomic allocation
If 'nokaslr' boot option is set, the warning always happens.
On x86, ZONE_DMA is small zone at the first 16MB of physical address space. When this problem happens, most of that space seems to be used by decompressed kernel. Thereby, there is not enough space at DMA_ZONE to meet the request of DMA pool allocation.
The commit 2f77465b05b1 ("x86/efistub: Avoid placing the kernel below LOAD_PHYSICAL_ADDR") tried to fix this problem by introducing lower bound of allocation.
But the fix is not complete.
efi_random_alloc() allocates pages by following steps.
1. Count total available slots ('total_slots')
2. Select a slot ('target_slot') to allocate randomly
3. Calculate a starting address ('target') to be included target_slot
4. Allocate pages, which starting address is 'target'
In step 1, 'alloc_min' is used to offset the starting address of memory chunk. But in step 3 'alloc_min' is not considered at all. As the result, 'target' can be miscalculated and become lower than 'alloc_min'.
When KASLR is disabled, 'target_slot' is always 0 and the problem happens everytime if the EFI memory map of the system meets the condition.
Fix this problem by calculating 'target' considering 'alloc_min'.
--- drivers/firmware/efi/libstub/randomalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/randomalloc.c +1 -1
@@ -119,7 +119,7 @@ efi_status_t efi_random_alloc(unsigned long size,continue ; } - target =round_up (md->phys_addr, align) + target_slot * align; + target =round_up (max (md->phys_addr, alloc_min), align) + target_slot * align; pages = size /EFI_PAGE_SIZE ; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 193/272 x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adamos Ttofari <[email protected]>
[ Upstream commit 10e4b5166df9ff7a2d5316138ca668b42d004422 ]
Commit 672365477ae8 ("x86/fpu: Update XFD state where required") and commit 8bf26758ca96 ("x86/fpu: Add XFD state to fpstate") introduced a per CPU variable xfd_state to keep the MSR_IA32_XFD value cached, in order to avoid unnecessary writes to the MSR.
On CPU hotplug MSR_IA32_XFD is reset to the init_fpstate.xfd, which wipes out any stale state. But the per CPU cached xfd value is not reset, which brings them out of sync.
As a consequence a subsequent xfd_update_state() might fail to update the MSR which in turn can result in XRSTOR raising a #NM in kernel space, which crashes the kernel.
To fix this, introduce xfd_set_state() to write xfd_state together with MSR_IA32_XFD, and use it in all places that set MSR_IA32_XFD.
--- arch/x86/kernel/fpu/xstate.c | 5 +++-- arch/x86/kernel/fpu/xstate.h | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-)
arch/x86/kernel/fpu/xstate.c +3 -2
@@ -177,10 +177,11 @@ void fpu__init_cpu_xstate(void)* Must happen after CR4 setup and before xsetbv() to allow KVM * lazy passthrough. Write independent of the dynamic state static * key as that does not work on the boot CPU. This also ensures -* that any stale state is wiped out from XFD. +* that any stale state is wiped out from XFD. Reset the per CPU +* xfd cache too. */ if (cpu_feature_enabled (X86_FEATURE_XFD )) -wrmsrl (MSR_IA32_XFD , init_fpstate.xfd); +xfd_set_state (init_fpstate.xfd);/* * XCR_XFEATURE_ENABLED_MASK (aka. XCR0) sets user features
arch/x86/kernel/fpu/xstate.h +10 -4
@@ -148,20 +148,26 @@ static inline void xfd_validate_state(struct fpstate *fpstate, u64 mask, bool rs#endif #ifdef CONFIG_X86_64 +static inline void xfd_set_state (u64 xfd) +{ +wrmsrl (MSR_IA32_XFD , xfd); +__this_cpu_write (xfd_state, xfd); +} +static inline void xfd_update_state (struct fpstate *fpstate) {if (fpu_state_size_dynamic ()) {u64 xfd = fpstate->xfd; -if (__this_cpu_read (xfd_state) != xfd) { -wrmsrl (MSR_IA32_XFD , xfd); -__this_cpu_write (xfd_state, xfd); - } +if (__this_cpu_read (xfd_state) != xfd) +xfd_set_state (xfd); } }extern int __xfd_enable_feature (u64 which,struct fpu_guest *guest_fpu);#else +static inline void xfd_set_state (u64 xfd) { } +static inline void xfd_update_state (struct fpstate *fpstate) { }static inline int __xfd_enable_feature (u64 which,struct fpu_guest *guest_fpu) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 194/272 efi: fix panic in kdump kernel
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksandr Tymoshenko <[email protected]>
[ Upstream commit 62b71cd73d41ddac6b1760402bbe8c4932e23531 ]
Check if get_next_variable() is actually valid pointer before calling it. In kdump kernel this method is set to NULL that causes panic during the kexec-ed kernel boot.
Tested with QEMU and OVMF firmware.
--- drivers/firmware/efi/efi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firmware/efi/efi.c +2 -0
@@ -194,6 +194,8 @@ static bool generic_ops_supported(void) name_size =sizeof (name); +if (!efi.get_next_variable) +return false; status = efi.get_next_variable (&name_size, &name, &guid);if (status ==EFI_UNSUPPORTED )return false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 195/272 pwm: img: fix pwm clock lookup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zoltan HERPAI <[email protected]>
[ Upstream commit 9eb05877dbee03064d3d3483cd6702f610d5a358 ]
22e8e19 has introduced a regression in the imgchip->pwm_clk lookup, whereas the clock name has also been renamed to "imgchip". This causes the driver failing to load:
[ 0.546905] img-pwm 18101300.pwm: failed to get imgchip clock [ 0.553418] img-pwm: probe of 18101300.pwm failed with error -2
Fix this lookup by reverting the clock name back to "pwm".
--- drivers/pwm/pwm-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-img.c +2 -2
@@ -289,9 +289,9 @@ static int img_pwm_probe(struct platform_device *pdev)return PTR_ERR (imgchip->sys_clk); } - imgchip->pwm_clk =devm_clk_get (&pdev->dev,"imgchip" ); + imgchip->pwm_clk =devm_clk_get (&pdev->dev,"pwm" );if (IS_ERR (imgchip->pwm_clk)) { -dev_err (&pdev->dev,"failed to get imgchip clock\n" ); +dev_err (&pdev->dev,"failed to get pwm clock\n" );return PTR_ERR (imgchip->pwm_clk); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 196/272 tty: serial: imx: Fix broken RS485
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rickard x Andersson <[email protected]>
commit 672448ccf9b6a676f96f9352cbf91f4d35f4084a upstream.
When about to transmit the function imx_uart_start_tx is called and in some RS485 configurations this function will call imx_uart_stop_rx. The problem is that imx_uart_stop_rx will enable loopback in order to release the RS485 bus, but when loopback is enabled transmitted data will just be looped to RX.
This patch fixes the above problem by not enabling loopback when about to transmit.
This driver now works well when used for RS485 half duplex master configurations.
--- drivers/tty/serial/imx.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/tty/serial/imx.c +18 -4
@@ -496,8 +496,7 @@ static void imx_uart_stop_tx(struct uart } } -/* called with port.lock taken and irqs off */ -static void imx_uart_stop_rx (struct uart_port *port) +static void imx_uart_stop_rx_with_loopback_ctrl (struct uart_port *port,bool loopback) {struct imx_port *sport = (struct imx_port *)port;u32 ucr1, ucr2, ucr4, uts;
@@ -519,7 +518,7 @@ static void imx_uart_stop_rx(struct uart/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ if (port->rs485.flags &SER_RS485_ENABLED && port->rs485.flags &SER_RS485_RTS_ON_SEND && - sport->have_rtscts && !sport->have_rtsgpio) { + sport->have_rtscts && !sport->have_rtsgpio && loopback) { uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); uts |=UTS_LOOP ;imx_uart_writel (sport, uts,imx_uart_uts_reg (sport));
@@ -532,6 +531,16 @@ static void imx_uart_stop_rx(struct uart }/* called with port.lock taken and irqs off */ +static void imx_uart_stop_rx (struct uart_port *port) +{ +/* +* Stop RX and enable loopback in order to make sure RS485 bus +* is not blocked. Se comment in imx_uart_probe(). +*/ +imx_uart_stop_rx_with_loopback_ctrl (port, true); +} + +/* called with port.lock taken and irqs off */ static void imx_uart_enable_ms (struct uart_port *port) {struct imx_port *sport = (struct imx_port *)port;
@@ -719,8 +728,13 @@ static void imx_uart_start_tx(struct uarimx_uart_rts_inactive (sport, &ucr2);imx_uart_writel (sport, ucr2,UCR2 ); +/* +* Since we are about to transmit we can not stop RX +* with loopback enabled because that will make our +* transmitted data being just looped to RX. +*/ if (!(port->rs485.flags &SER_RS485_RX_DURING_TX )) -imx_uart_stop_rx (port); +imx_uart_stop_rx_with_loopback_ctrl (port, false); sport->tx_state =WAIT_AFTER_RTS ;
Greg Kroah-Hartman
maintainerPATCH 197/272 block: Fix page refcounts for unaligned buffers in __bio_release_pages()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
commit 38b43539d64b2fa020b3b9a752a986769f87f7a6 upstream.
Fix an incorrect number of pages being released for buffers that do not start at the beginning of a page.
[ Tony: backport to v6.1 by replacing bio_release_page() loop with
folio_put_refs() as commits fd363244e883 and e4cc64657bec are not present. ]
--- block/bio.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
block/bio.c +4 -7
@@ -1112,19 +1112,16 @@ void __bio_release_pages(struct bio *biostruct folio_iter fi;bio_for_each_folio_all (fi, bio) { -struct page *page; -size_t done =0 ; +size_t nr_pages;if (mark_dirty) {folio_lock (fi.folio);folio_mark_dirty (fi.folio);folio_unlock (fi.folio); } - page =folio_page (fi.folio, fi.offset /PAGE_SIZE ); -do { -folio_put (fi.folio); - done +=PAGE_SIZE ; - }while (done < fi.length); + nr_pages = (fi.offset + fi.length -1 ) /PAGE_SIZE - + fi.offset /PAGE_SIZE +1 ; +folio_put_refs (fi.folio, nr_pages); } }EXPORT_SYMBOL_GPL (__bio_release_pages);
Greg Kroah-Hartman
maintainerPATCH 198/272 blk-mq: release scheduler resource when request completes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengming Zhou <[email protected]>
commit e5c0ca13659e9d18f53368d651ed7e6e433ec1cf upstream.
Chuck reported [1] an IO hang problem on NFS exports that reside on SATA devices and bisected to commit 615939a2ae73 ("blk-mq: defer to the normal submission path for post-flush requests").
We analysed the IO hang problem, found there are two postflush requests waiting for each other.
The first postflush request completed the REQ_FSEQ_DATA sequence, so go to the REQ_FSEQ_POSTFLUSH sequence and added in the flush pending list, but failed to blk_kick_flush() because of the second postflush request which is inflight waiting in scheduler queue.
The second postflush waiting in scheduler queue can't be dispatched because the first postflush hasn't released scheduler resource even though it has completed by itself.
Fix it by releasing scheduler resource when the first postflush request completed, so the second postflush can be dispatched and completed, then make blk_kick_flush() succeed.
While at it, remove the check for e->ops.finish_request, as all schedulers set that. Reaffirm this requirement by adding a WARN_ON_ONCE() at scheduler registration time, just like we do for insert_requests and dispatch_request.
[1] https://lore.kernel.org/all/[email protected]/
[bvanassche: changed RQF_USE_SCHED into RQF_ELVPRIV; restored the finish_request pointer check before calling finish_request and removed the new warning from the elevator code. This patch fixes an I/O hang when submitting a REQ_FUA request to a request queue for a zoned block device for which FUA has been disabled (QUEUE_FLAG_FUA is not set).]
--- block/blk-mq.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
block/blk-mq.c +21 -3
@@ -675,6 +675,22 @@ out_queue_exit: }EXPORT_SYMBOL_GPL (blk_mq_alloc_request_hctx); +static void blk_mq_finish_request (struct request *rq) +{ +struct request_queue *q = rq->q; + +if ((rq->rq_flags &RQF_ELVPRIV ) && + q->elevator->type->ops.finish_request) { + q->elevator->type->ops.finish_request (rq); +/* +* For postflush request that may need to be +* completed twice, we should clear this flag +* to avoid double finish_request() on the rq. +*/ + rq->rq_flags &= ~RQF_ELVPRIV ; + } +} +static void __blk_mq_free_request (struct request *rq) {struct request_queue *q = rq->q;
@@ -701,9 +717,7 @@ void blk_mq_free_request(struct request {struct request_queue *q = rq->q; -if ((rq->rq_flags &RQF_ELVPRIV ) && - q->elevator->type->ops.finish_request) - q->elevator->type->ops.finish_request (rq); +blk_mq_finish_request (rq);if (unlikely (laptop_mode && !blk_rq_is_passthrough (rq)))laptop_io_completion (q->disk->bdi);
@@ -1025,6 +1039,8 @@ inline void __blk_mq_end_request(structif (blk_mq_need_time_stamp (rq))__blk_mq_end_request_acct (rq,ktime_get_ns ()); +blk_mq_finish_request (rq); +if (rq->end_io) {rq_qos_done (rq->q, rq);if (rq->end_io (rq, error) ==RQ_END_IO_FREE )
@@ -1079,6 +1095,8 @@ void blk_mq_end_request_batch(struct io_if (iob->need_ts)__blk_mq_end_request_acct (rq, now); +blk_mq_finish_request (rq); +rq_qos_done (rq->q, rq);/*
Greg Kroah-Hartman
maintainerPATCH 199/272 selftests: mptcp: diag: return KSFT_FAIL not test_cnt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
commit 45bcc0346561daa3f59e19a753cc7f3e08e8dff1 upstream.
The test counter 'test_cnt' should not be returned in diag.sh, e.g. what if only the 4th test fail? Will do 'exit 4' which is 'exit ${KSFT_SKIP}', the whole test will be marked as skipped instead of 'failed'!
So we should do ret=${KSFT_FAIL} instead.
--- tools/testing/selftests/net/mptcp/diag.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/diag.sh +3 -3
@@ -56,7 +56,7 @@ __chk_nr() echo "[ skip ] Feature probably not supported" else echo "[ fail ] expected $expected found $nr" - ret=$test_cnt + ret=${KSFT_FAIL} fi else echo "[ ok ]"
@@ -100,10 +100,10 @@ wait_msk_nr() printf "%-50s" "$msg" if [ $i -ge $timeout ]; then echo "[ fail ] timeout while expecting $expected max $max last $nr" - ret=$test_cnt + ret=${KSFT_FAIL} elif [ $nr != $expected ]; then echo "[ fail ] expected $expected found $nr" - ret=$test_cnt + ret=${KSFT_FAIL} else echo "[ ok ]" fi
Greg Kroah-Hartman
maintainerPATCH 200/272 vfio/pci: Disable auto-enable of exclusive INTx IRQ
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit fe9a7082684eb059b925c535682e68c34d487d43 ]
Currently for devices requiring masking at the irqchip for INTx, ie. devices without DisINTx support, the IRQ is enabled in request_irq() and subsequently disabled as necessary to align with the masked status flag. This presents a window where the interrupt could fire between these events, resulting in the IRQ incrementing the disable depth twice. This would be unrecoverable for a user since the masked flag prevents nested enables through vfio.
Instead, invert the logic using IRQF_NO_AUTOEN such that exclusive INTx is never auto-enabled, then unmask as required.
--- drivers/vfio/pci/vfio_pci_intrs.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/vfio/pci/vfio_pci_intrs.c +10 -7
@@ -251,8 +251,15 @@ static int vfio_intx_set_signal(struct v vdev->ctx[0 ].trigger = trigger; +/* +* Devices without DisINTx support require an exclusive interrupt, +* IRQ masking is performed at the IRQ chip. The masked status is +* protected by vdev->irqlock. Setup the IRQ without auto-enable and +* unmask as necessary below under lock. DisINTx is unmodified by +* the IRQ configuration and may therefore use auto-enable. +*/ if (!vdev->pci_2_3) - irqflags =0 ; + irqflags =IRQF_NO_AUTOEN ; ret =request_irq (pdev->irq, vfio_intx_handler, irqflags, vdev->ctx[0 ].name, vdev);
@@ -263,13 +270,9 @@ static int vfio_intx_set_signal(struct vreturn ret; } -/* -* INTx disable will stick across the new irq setup, -* disable_irq won't. -*/ spin_lock_irqsave (&vdev->irqlock, flags); -if (!vdev->pci_2_3 && vdev->ctx[0 ].masked) -disable_irq_nosync (pdev->irq); +if (!vdev->pci_2_3 && !vdev->ctx[0 ].masked) +enable_irq (pdev->irq);spin_unlock_irqrestore (&vdev->irqlock, flags);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 201/272 vfio: Introduce interface to flush virqfd inject workqueue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit b620ecbd17a03cacd06f014a5d3f3a11285ce053 ]
In order to synchronize changes that can affect the thread callback, introduce an interface to force a flush of the inject workqueue. The irqfd pointer is only valid under spinlock, but the workqueue cannot be flushed under spinlock. Therefore the flush work for the irqfd is queued under spinlock. The vfio_irqfd_cleanup_wq workqueue is re-used for queuing this work such that flushing the workqueue is also ordered relative to shutdown.
--- drivers/vfio/virqfd.c | 21 +++++++++++++++++++++ include/linux/vfio.h | 2 ++ 2 files changed, 23 insertions(+)
drivers/vfio/virqfd.c +21 -0
@@ -104,6 +104,13 @@ static void virqfd_inject(struct work_st virqfd->thread (virqfd->opaque, virqfd->data); } +static void virqfd_flush_inject (struct work_struct *work) +{ + struct virqfd *virqfd = container_of(work, struct virqfd, flush_inject); + +flush_work (&virqfd->inject); +} + int vfio_virqfd_enable(void *opaque, int (*handler)(void *, void *), void (*thread)(void *, void *),
@@ -127,6 +134,7 @@ int vfio_virqfd_enable(void *opaque,INIT_WORK (&virqfd->shutdown, virqfd_shutdown);INIT_WORK (&virqfd->inject, virqfd_inject); +INIT_WORK (&virqfd->flush_inject, virqfd_flush_inject); irqfd =fdget (fd);if (!irqfd.file) {
@@ -217,6 +225,19 @@ void vfio_virqfd_disable(struct virqfd * }EXPORT_SYMBOL_GPL (vfio_virqfd_disable); +void vfio_virqfd_flush_thread (struct virqfd **pvirqfd) +{ +unsigned long flags; + +spin_lock_irqsave (&virqfd_lock, flags); +if (*pvirqfd && (*pvirqfd)->thread) +queue_work (vfio_irqfd_cleanup_wq, &(*pvirqfd)->flush_inject); +spin_unlock_irqrestore (&virqfd_lock, flags); + +flush_workqueue (vfio_irqfd_cleanup_wq); +} +EXPORT_SYMBOL_GPL (vfio_virqfd_flush_thread); +module_init (vfio_virqfd_init);module_exit (vfio_virqfd_exit);
include/linux/vfio.h +2 -0
@@ -268,6 +268,7 @@ struct virqfd {wait_queue_entry_t wait;poll_table pt;struct work_struct shutdown; +struct work_struct flush_inject;struct virqfd **pvirqfd; };
@@ -275,5 +276,6 @@ int vfio_virqfd_enable(void *opaque, int void (*thread)(void *, void *), void *data, struct virqfd **pvirqfd, int fd);void vfio_virqfd_disable (struct virqfd **pvirqfd); +void vfio_virqfd_flush_thread (struct virqfd **pvirqfd);#endif /* VFIO_H */
Greg Kroah-Hartman
maintainerPATCH 202/272 vfio/pci: Create persistent INTx handler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit 18c198c96a815c962adc2b9b77909eec0be7df4d ]
A vulnerability exists where the eventfd for INTx signaling can be deconfigured, which unregisters the IRQ handler but still allows eventfds to be signaled with a NULL context through the SET_IRQS ioctl or through unmask irqfd if the device interrupt is pending.
Ideally this could be solved with some additional locking; the igate mutex serializes the ioctl and config space accesses, and the interrupt handler is unregistered relative to the trigger, but the irqfd path runs asynchronous to those. The igate mutex cannot be acquired from the atomic context of the eventfd wake function. Disabling the irqfd relative to the eventfd registration is potentially incompatible with existing userspace.
As a result, the solution implemented here moves configuration of the INTx interrupt handler to track the lifetime of the INTx context object and irq_type configuration, rather than registration of a particular trigger eventfd. Synchronization is added between the ioctl path and eventfd_signal() wrapper such that the eventfd trigger can be dynamically updated relative to in-flight interrupts or irqfd callbacks.
--- drivers/vfio/pci/vfio_pci_intrs.c | 149 ++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 67 deletions(-)
drivers/vfio/pci/vfio_pci_intrs.c +82 -67
@@ -55,8 +55,13 @@ static void vfio_send_intx_eventfd(void {struct vfio_pci_core_device *vdev = opaque; -if (likely (is_intx (vdev) && !vdev->virq_disabled)) -eventfd_signal (vdev->ctx[0 ].trigger,1 ); +if (likely (is_intx (vdev) && !vdev->virq_disabled)) { +struct eventfd_ctx *trigger; + + trigger =READ_ONCE (vdev->ctx[0 ].trigger); +if (likely (trigger)) +eventfd_signal (trigger,1 ); + } }/* Returns true if the INTx vfio_pci_irq_ctx.masked value is changed. */
@@ -191,98 +196,104 @@ static irqreturn_t vfio_intx_handler(intreturn ret; } -static int vfio_intx_enable (struct vfio_pci_core_device *vdev) +static int vfio_intx_enable (struct vfio_pci_core_device *vdev, +struct eventfd_ctx *trigger) { +struct pci_dev *pdev = vdev->pdev; +unsigned long irqflags; +char *name; +int ret; +if (!is_irq_none (vdev))return -EINVAL ; -if (!vdev->pdev->irq) +if (!pdev->irq)return -ENODEV ; + name =kasprintf (GFP_KERNEL_ACCOUNT ,"vfio-intx(%s)" ,pci_name (pdev)); +if (!name) +return -ENOMEM ; + vdev->ctx =kzalloc (sizeof (struct vfio_pci_irq_ctx ),GFP_KERNEL_ACCOUNT );if (!vdev->ctx)return -ENOMEM ; vdev->num_ctx =1 ; + vdev->ctx[0 ].name = name; + vdev->ctx[0 ].trigger = trigger; +/* -* If the virtual interrupt is masked, restore it. Devices -* supporting DisINTx can be masked at the hardware level -* here, non-PCI-2.3 devices will have to wait until the -* interrupt is enabled. +* Fill the initial masked state based on virq_disabled. After +* enable, changing the DisINTx bit in vconfig directly changes INTx +* masking. igate prevents races during setup, once running masked +* is protected via irqlock. +* +* Devices supporting DisINTx also reflect the current mask state in +* the physical DisINTx bit, which is not affected during IRQ setup. +* +* Devices without DisINTx support require an exclusive interrupt. +* IRQ masking is performed at the IRQ chip. Again, igate protects +* against races during setup and IRQ handlers and irqfds are not +* yet active, therefore masked is stable and can be used to +* conditionally auto-enable the IRQ. +* +* irq_type must be stable while the IRQ handler is registered, +* therefore it must be set before request_irq(). */ vdev->ctx[0 ].masked = vdev->virq_disabled; -if (vdev->pci_2_3) -pci_intx (vdev->pdev, !vdev->ctx[0 ].masked); +if (vdev->pci_2_3) { +pci_intx (pdev, !vdev->ctx[0 ].masked); + irqflags =IRQF_SHARED ; + }else { + irqflags = vdev->ctx[0 ].masked ?IRQF_NO_AUTOEN :0 ; + } vdev->irq_type =VFIO_PCI_INTX_IRQ_INDEX ; + ret =request_irq (pdev->irq, vfio_intx_handler, + irqflags, vdev->ctx[0 ].name, vdev); +if (ret) { + vdev->irq_type =VFIO_PCI_NUM_IRQS ; +kfree (name); + vdev->num_ctx =0 ; +kfree (vdev->ctx); +return ret; + } +return 0 ; } -static int vfio_intx_set_signal (struct vfio_pci_core_device *vdev,int fd) +static int vfio_intx_set_signal (struct vfio_pci_core_device *vdev, +struct eventfd_ctx *trigger) {struct pci_dev *pdev = vdev->pdev; -unsigned long irqflags =IRQF_SHARED ; -struct eventfd_ctx *trigger; -unsigned long flags; -int ret; - -if (vdev->ctx[0 ].trigger) { -free_irq (pdev->irq, vdev); -kfree (vdev->ctx[0 ].name); -eventfd_ctx_put (vdev->ctx[0 ].trigger); - vdev->ctx[0 ].trigger =NULL ; - } - -if (fd <0 )/* Disable only */ -return 0 ; - - vdev->ctx[0 ].name =kasprintf (GFP_KERNEL_ACCOUNT ,"vfio-intx(%s)" , -pci_name (pdev)); -if (!vdev->ctx[0 ].name) -return -ENOMEM ; - - trigger =eventfd_ctx_fdget (fd); -if (IS_ERR (trigger)) { -kfree (vdev->ctx[0 ].name); -return PTR_ERR (trigger); - } +struct eventfd_ctx *old; - vdev->ctx[0 ].trigger = trigger; + old = vdev->ctx[0 ].trigger; -/* -* Devices without DisINTx support require an exclusive interrupt, -* IRQ masking is performed at the IRQ chip. The masked status is -* protected by vdev->irqlock. Setup the IRQ without auto-enable and -* unmask as necessary below under lock. DisINTx is unmodified by -* the IRQ configuration and may therefore use auto-enable. -*/ -if (!vdev->pci_2_3) - irqflags =IRQF_NO_AUTOEN ; +WRITE_ONCE (vdev->ctx[0 ].trigger, trigger); - ret =request_irq (pdev->irq, vfio_intx_handler, - irqflags, vdev->ctx[0 ].name, vdev); -if (ret) { - vdev->ctx[0 ].trigger =NULL ; -kfree (vdev->ctx[0 ].name); -eventfd_ctx_put (trigger); -return ret; +/* Releasing an old ctx requires synchronizing in-flight users */ +if (old) { +synchronize_irq (pdev->irq); +vfio_virqfd_flush_thread (&vdev->ctx[0 ].unmask); +eventfd_ctx_put (old); } -spin_lock_irqsave (&vdev->irqlock, flags); -if (!vdev->pci_2_3 && !vdev->ctx[0 ].masked) -enable_irq (pdev->irq); -spin_unlock_irqrestore (&vdev->irqlock, flags); -return 0 ; }static void vfio_intx_disable (struct vfio_pci_core_device *vdev) { +struct pci_dev *pdev = vdev->pdev; +vfio_virqfd_disable (&vdev->ctx[0 ].unmask);vfio_virqfd_disable (&vdev->ctx[0 ].mask); -vfio_intx_set_signal (vdev,-1 ); +free_irq (pdev->irq, vdev); +if (vdev->ctx[0 ].trigger) +eventfd_ctx_put (vdev->ctx[0 ].trigger); +kfree (vdev->ctx[0 ].name); vdev->irq_type =VFIO_PCI_NUM_IRQS ; vdev->num_ctx =0 ;kfree (vdev->ctx);
@@ -534,19 +545,23 @@ static int vfio_pci_set_intx_trigger(strreturn -EINVAL ;if (flags &VFIO_IRQ_SET_DATA_EVENTFD ) { +struct eventfd_ctx *trigger =NULL ;int32_t fd = *(int32_t *)data;int ret; +if (fd >=0 ) { + trigger =eventfd_ctx_fdget (fd); +if (IS_ERR (trigger)) +return PTR_ERR (trigger); + } +if (is_intx (vdev)) -return vfio_intx_set_signal (vdev, fd); + ret =vfio_intx_set_signal (vdev, trigger); +else + ret =vfio_intx_enable (vdev, trigger); - ret =vfio_intx_enable (vdev); -if (ret) -return ret; - - ret =vfio_intx_set_signal (vdev, fd); -if (ret) -vfio_intx_disable (vdev); +if (ret && trigger) +eventfd_ctx_put (trigger);return ret; }
Greg Kroah-Hartman
maintainerPATCH 203/272 vfio/platform: Create persistent IRQ handlers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit 675daf435e9f8e5a5eab140a9864dfad6668b375 ]
The vfio-platform SET_IRQS ioctl currently allows loopback triggering of an interrupt before a signaling eventfd has been configured by the user, which thereby allows a NULL pointer dereference.
Rather than register the IRQ relative to a valid trigger, register all IRQs in a disabled state in the device open path. This allows mask operations on the IRQ to nest within the overall enable state governed by a valid eventfd signal. This decouples @masked, protected by the @locked spinlock from @trigger, protected via the @igate mutex.
In doing so, it's guaranteed that changes to @trigger cannot race the IRQ handlers because the IRQ handler is synchronously disabled before modifying the trigger, and loopback triggering of the IRQ via ioctl is safe due to serialization with trigger changes via igate.
For compatibility, request_irq() failures are maintained to be local to the SET_IRQS ioctl rather than a fatal error in the open device path. This allows, for example, a userspace driver with polling mode support to continue to work regardless of moving the request_irq() call site. This necessarily blocks all SET_IRQS access to the failed index.
--- drivers/vfio/platform/vfio_platform_irq.c | 101 ++++++++++++++++++++---------- 1 file changed, 68 insertions(+), 33 deletions(-)
drivers/vfio/platform/vfio_platform_irq.c +68 -33
@@ -136,6 +136,16 @@ static int vfio_platform_set_irq_unmask(return 0 ; } +/* +* The trigger eventfd is guaranteed valid in the interrupt path +* and protected by the igate mutex when triggered via ioctl. +*/ +static void vfio_send_eventfd (struct vfio_platform_irq *irq_ctx) +{ +if (likely (irq_ctx->trigger)) +eventfd_signal (irq_ctx->trigger,1 ); +} +static irqreturn_t vfio_automasked_irq_handler (int irq,void *dev_id) {struct vfio_platform_irq *irq_ctx = dev_id;
@@ -155,7 +165,7 @@ static irqreturn_t vfio_automasked_irq_hspin_unlock_irqrestore (&irq_ctx->lock, flags);if (ret ==IRQ_HANDLED ) -eventfd_signal (irq_ctx->trigger,1 ); +vfio_send_eventfd (irq_ctx);return ret; }
@@ -164,22 +174,19 @@ static irqreturn_t vfio_irq_handler(int {struct vfio_platform_irq *irq_ctx = dev_id; -eventfd_signal (irq_ctx->trigger,1 ); +vfio_send_eventfd (irq_ctx);return IRQ_HANDLED ; }static int vfio_set_trigger (struct vfio_platform_device *vdev,int index, -int fd,irq_handler_t handler) +int fd) {struct vfio_platform_irq *irq = &vdev->irqs[index];struct eventfd_ctx *trigger; -int ret;if (irq->trigger) { -irq_clear_status_flags (irq->hwirq,IRQ_NOAUTOEN ); -free_irq (irq->hwirq, irq); -kfree (irq->name); +disable_irq (irq->hwirq);eventfd_ctx_put (irq->trigger); irq->trigger =NULL ; }
@@ -187,30 +194,20 @@ static int vfio_set_trigger(struct vfio_if (fd <0 )/* Disable only */ return 0 ; - irq->name =kasprintf (GFP_KERNEL ,"vfio-irq[%d](%s)" , - irq->hwirq, vdev->name); -if (!irq->name) -return -ENOMEM ; - trigger =eventfd_ctx_fdget (fd); -if (IS_ERR (trigger)) { -kfree (irq->name); +if (IS_ERR (trigger))return PTR_ERR (trigger); - } irq->trigger = trigger; -irq_set_status_flags (irq->hwirq,IRQ_NOAUTOEN ); - ret =request_irq (irq->hwirq, handler,0 , irq->name, irq); -if (ret) { -kfree (irq->name); -eventfd_ctx_put (trigger); - irq->trigger =NULL ; -return ret; - } - -if (!irq->masked) -enable_irq (irq->hwirq); +/* +* irq->masked effectively provides nested disables within the overall +* enable relative to trigger. Specifically request_irq() is called +* with NO_AUTOEN, therefore the IRQ is initially disabled. The user +* may only further disable the IRQ with a MASK operations because +* irq->masked is initially false. +*/ +enable_irq (irq->hwirq);return 0 ; }
@@ -229,7 +226,7 @@ static int vfio_platform_set_irq_trigger handler = vfio_irq_handler;if (!count && (flags &VFIO_IRQ_SET_DATA_NONE )) -return vfio_set_trigger (vdev, index,-1 , handler); +return vfio_set_trigger (vdev, index,-1 );if (start !=0 || count !=1 )return -EINVAL ;
@@ -237,7 +234,7 @@ static int vfio_platform_set_irq_triggerif (flags &VFIO_IRQ_SET_DATA_EVENTFD ) {int32_t fd = *(int32_t *)data; -return vfio_set_trigger (vdev, index, fd, handler); +return vfio_set_trigger (vdev, index, fd); }if (flags &VFIO_IRQ_SET_DATA_NONE ) {
@@ -261,6 +258,14 @@ int vfio_platform_set_irqs_ioctl(struct unsigned start, unsigned count, uint32_t flags, void *data) = NULL; +/* +* For compatibility, errors from request_irq() are local to the +* SET_IRQS path and reflected in the name pointer. This allows, +* for example, polling mode fallback for an exclusive IRQ failure. +*/ +if (IS_ERR (vdev->irqs[index].name)) +return PTR_ERR (vdev->irqs[index].name); +switch (flags &VFIO_IRQ_SET_ACTION_TYPE_MASK ) {case VFIO_IRQ_SET_ACTION_MASK : func = vfio_platform_set_irq_mask;
@@ -281,7 +286,7 @@ int vfio_platform_set_irqs_ioctl(structint vfio_platform_irq_init (struct vfio_platform_device *vdev) { -int cnt =0 , i; +int cnt =0 , i, ret =0 ;while (vdev->get_irq (vdev, cnt) >=0 ) cnt++;
@@ -292,29 +297,54 @@ int vfio_platform_irq_init(struct vfio_pfor (i =0 ; i < cnt; i++) {int hwirq = vdev->get_irq (vdev, i); +irq_handler_t handler = vfio_irq_handler; -if (hwirq <0 ) +if (hwirq <0 ) { + ret = -EINVAL ; goto err; + }spin_lock_init (&vdev->irqs[i].lock); vdev->irqs[i].flags =VFIO_IRQ_INFO_EVENTFD ; -if (irq_get_trigger_type (hwirq) &IRQ_TYPE_LEVEL_MASK ) +if (irq_get_trigger_type (hwirq) &IRQ_TYPE_LEVEL_MASK ) { vdev->irqs[i].flags |=VFIO_IRQ_INFO_MASKABLE |VFIO_IRQ_INFO_AUTOMASKED ; + handler = vfio_automasked_irq_handler; + } vdev->irqs[i].count =1 ; vdev->irqs[i].hwirq = hwirq; vdev->irqs[i].masked = false; + vdev->irqs[i].name =kasprintf (GFP_KERNEL , +"vfio-irq[%d](%s)" , hwirq, + vdev->name); +if (!vdev->irqs[i].name) { + ret = -ENOMEM ; + goto err; + } + + ret =request_irq (hwirq, handler,IRQF_NO_AUTOEN , + vdev->irqs[i].name, &vdev->irqs[i]); +if (ret) { +kfree (vdev->irqs[i].name); + vdev->irqs[i].name =ERR_PTR (ret); + } } vdev->num_irqs = cnt;return 0 ; err: +for (--i; i >=0 ; i--) { +if (!IS_ERR (vdev->irqs[i].name)) { +free_irq (vdev->irqs[i].hwirq, &vdev->irqs[i]); +kfree (vdev->irqs[i].name); + } + }kfree (vdev->irqs); -return -EINVAL ; +return ret; }void vfio_platform_irq_cleanup (struct vfio_platform_device *vdev)
@@ -324,7 +354,12 @@ void vfio_platform_irq_cleanup(struct vffor (i =0 ; i < vdev->num_irqs; i++) {vfio_virqfd_disable (&vdev->irqs[i].mask);vfio_virqfd_disable (&vdev->irqs[i].unmask); -vfio_set_trigger (vdev, i,-1 ,NULL ); +if (!IS_ERR (vdev->irqs[i].name)) { +free_irq (vdev->irqs[i].hwirq, &vdev->irqs[i]); +if (vdev->irqs[i].trigger) +eventfd_ctx_put (vdev->irqs[i].trigger); +kfree (vdev->irqs[i].name); + } } vdev->num_irqs =0 ;
Greg Kroah-Hartman
maintainerPATCH 204/272 vfio/fsl-mc: Block calling interrupt handler without trigger
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit 7447d911af699a15f8d050dfcb7c680a86f87012 ]
The eventfd_ctx trigger pointer of the vfio_fsl_mc_irq object is initially NULL and may become NULL if the user sets the trigger eventfd to -1. The interrupt handler itself is guaranteed that trigger is always valid between request_irq() and free_irq(), but the loopback testing mechanisms to invoke the handler function need to test the trigger. The triggering and setting ioctl paths both make use of igate and are therefore mutually exclusive.
The vfio-fsl-mc driver does not make use of irqfds, nor does it support any sort of masking operations, therefore unlike vfio-pci and vfio-platform, the flow can remain essentially unchanged.
--- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c +4 -3
@@ -142,13 +142,14 @@ static int vfio_fsl_mc_set_irq_trigger(s irq = &vdev->mc_irqs[index];if (flags &VFIO_IRQ_SET_DATA_NONE ) { -vfio_fsl_mc_irq_handler (hwirq, irq); +if (irq->trigger) +eventfd_signal (irq->trigger,1 ); }else if (flags &VFIO_IRQ_SET_DATA_BOOL ) {u8 trigger = *(u8 *)data; -if (trigger) -vfio_fsl_mc_irq_handler (hwirq, irq); +if (trigger && irq->trigger) +eventfd_signal (irq->trigger,1 ); }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 205/272 x86/coco: Export cc_vendor
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
commit 3d91c537296794d5d0773f61abbe7b63f2f132d8 upstream.
It will be used in different checks in future changes. Export it directly and provide accessor functions and stubs so this can be used in general code when CONFIG_ARCH_HAS_CC_PLATFORM is not set.
No functional changes.
[ tglx: Add accessor functions ]
--- arch/x86/coco/core.c | 13 ++++--------- arch/x86/include/asm/coco.h | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 12 deletions(-)
arch/x86/coco/core.c +4 -9
@@ -13,7 +13,7 @@#include <asm/coco.h> #include <asm/processor.h> -static enum cc_vendor vendor__ro_after_init ; +enum cc_vendor cc_vendor__ro_after_init ;static u64 cc_mask__ro_after_init ;static bool intel_cc_platform_has (enum cc_attr attr)
@@ -83,7 +83,7 @@ static bool hyperv_cc_platform_has(enumbool cc_platform_has (enum cc_attr attr) { -switch (vendor) { +switch (cc_vendor) {case CC_VENDOR_AMD :return amd_cc_platform_has (attr);case CC_VENDOR_INTEL :
@@ -105,7 +105,7 @@ u64 cc_mkenc(u64 val)* - for AMD, bit *set* means the page is encrypted * - for Intel *clear* means encrypted. */ -switch (vendor) { +switch (cc_vendor) {case CC_VENDOR_AMD :return val | cc_mask;case CC_VENDOR_INTEL :
@@ -118,7 +118,7 @@ u64 cc_mkenc(u64 val)u64 cc_mkdec (u64 val) {/* See comment in cc_mkenc() */ -switch (vendor) { +switch (cc_vendor) {case CC_VENDOR_AMD :return val & ~cc_mask;case CC_VENDOR_INTEL :
@@ -129,11 +129,6 @@ u64 cc_mkdec(u64 val) }EXPORT_SYMBOL_GPL (cc_mkdec); -__init void cc_set_vendor (enum cc_vendor v) -{ - vendor = v; -} -__init void cc_set_mask (u64 mask) { cc_mask = mask;
arch/x86/include/asm/coco.h +20 -3
@@ -11,13 +11,30 @@ enum cc_vendor { CC_VENDOR_INTEL, }; -void cc_set_vendor (enum cc_vendor v); -void cc_set_mask (u64 mask); -#ifdef CONFIG_ARCH_HAS_CC_PLATFORM +extern enum cc_vendor cc_vendor; + +static inline enum cc_vendor cc_get_vendor (void ) +{ +return cc_vendor; +} + +static inline void cc_set_vendor (enum cc_vendor vendor) +{ + cc_vendor = vendor; +} + +void cc_set_mask (u64 mask);u64 cc_mkenc (u64 val);u64 cc_mkdec (u64 val);#else +static inline enum cc_vendor cc_get_vendor (void ) +{ +return CC_VENDOR_NONE ; +} + +static inline void cc_set_vendor (enum cc_vendor vendor) { } +static inline u64 cc_mkenc (u64 val) {return val;
Greg Kroah-Hartman
maintainerPATCH 206/272 x86/coco: Get rid of accessor functions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
commit da86eb9611840772a459693832e54c63cbcc040a upstream.
cc_vendor is __ro_after_init and thus can be used directly.
No functional changes.
--- arch/x86/coco/core.c | 2 +- arch/x86/coco/tdx/tdx.c | 2 +- arch/x86/include/asm/coco.h | 19 +------------------ arch/x86/kernel/cpu/mshyperv.c | 2 +- arch/x86/mm/mem_encrypt_identity.c | 2 +- 5 files changed, 5 insertions(+), 22 deletions(-)
arch/x86/coco/core.c +1 -1
@@ -13,7 +13,7 @@#include <asm/coco.h> #include <asm/processor.h> -enum cc_vendor cc_vendor__ro_after_init ; +enum cc_vendor cc_vendor__ro_after_init =CC_VENDOR_NONE ;static u64 cc_mask__ro_after_init ;static bool intel_cc_platform_has (enum cc_attr attr)
arch/x86/coco/tdx/tdx.c +1 -1
@@ -793,7 +793,7 @@ void __init tdx_early_init(void)setup_force_cpu_cap (X86_FEATURE_TDX_GUEST ); -cc_set_vendor (CC_VENDOR_INTEL ); + cc_vendor =CC_VENDOR_INTEL ;tdx_parse_tdinfo (&cc_mask);cc_set_mask (cc_mask);
arch/x86/include/asm/coco.h +1 -18
@@ -11,30 +11,13 @@ enum cc_vendor { CC_VENDOR_INTEL, }; -#ifdef CONFIG_ARCH_HAS_CC_PLATFORM extern enum cc_vendor cc_vendor; -static inline enum cc_vendor cc_get_vendor (void ) -{ -return cc_vendor; -} - -static inline void cc_set_vendor (enum cc_vendor vendor) -{ - cc_vendor = vendor; -} - +#ifdef CONFIG_ARCH_HAS_CC_PLATFORM void cc_set_mask (u64 mask);u64 cc_mkenc (u64 val);u64 cc_mkdec (u64 val);#else -static inline enum cc_vendor cc_get_vendor (void ) -{ -return CC_VENDOR_NONE ; -} - -static inline void cc_set_vendor (enum cc_vendor vendor) { } -static inline u64 cc_mkenc (u64 val) {return val;
arch/x86/kernel/cpu/mshyperv.c +1 -1
@@ -344,7 +344,7 @@ static void __init ms_hyperv_init_platfo/* Isolation VMs are unenlightened SEV-based VMs, thus this check: */ if (IS_ENABLED (CONFIG_AMD_MEM_ENCRYPT )) {if (hv_get_isolation_type () !=HV_ISOLATION_TYPE_NONE ) -cc_set_vendor (CC_VENDOR_HYPERV ); + cc_vendor =CC_VENDOR_HYPERV ; } }
arch/x86/mm/mem_encrypt_identity.c +1 -1
@@ -608,7 +608,7 @@ void __init sme_enable(struct boot_param out:if (sme_me_mask) { physical_mask &= ~sme_me_mask; -cc_set_vendor (CC_VENDOR_AMD ); + cc_vendor =CC_VENDOR_AMD ;cc_set_mask (sme_me_mask); } }
Greg Kroah-Hartman
maintainerPATCH 207/272 x86/Kconfig: Remove CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
commit 29956748339aa8757a7e2f927a8679dd08f24bb6 upstream.
It was meant well at the time but nothing's using it so get rid of it.
--- Documentation/admin-guide/kernel-parameters.txt | 4 +--- Documentation/x86/amd-memory-encryption.rst | 16 ++++++++-------- arch/x86/Kconfig | 13 ------------- arch/x86/mm/mem_encrypt_identity.c | 11 +---------- 4 files changed, 10 insertions(+), 34 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -3
@@ -3206,9 +3206,7 @@ mem_encrypt= [X86-64] AMD Secure Memory Encryption (SME) control Valid arguments: on, off - Default (depends on kernel configuration option): - on (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) - off (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=n) + Default: off mem_encrypt=on: Activate SME mem_encrypt=off: Do not activate SME
Documentation/x86/amd-memory-encryption.rst +8 -8
@@ -87,14 +87,14 @@ The state of SME in the Linux kernel can kernel is non-zero). SME can also be enabled and activated in the BIOS. If SME is enabled and -activated in the BIOS, then all memory accesses will be encrypted and it will -not be necessary to activate the Linux memory encryption support. If the BIOS -merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), then Linux can activate -memory encryption by default (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) or -by supplying mem_encrypt=on on the kernel command line. However, if BIOS does -not enable SME, then Linux will not be able to activate memory encryption, even -if configured to do so by default or the mem_encrypt=on command line parameter -is specified. +activated in the BIOS, then all memory accesses will be encrypted and it +will not be necessary to activate the Linux memory encryption support. + +If the BIOS merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), +then memory encryption can be enabled by supplying mem_encrypt=on on the +kernel command line. However, if BIOS does not enable SME, then Linux +will not be able to activate memory encryption, even if configured to do +so by default or the mem_encrypt=on command line parameter is specified. Secure Nested Paging (SNP) ==========================
arch/x86/Kconfig +0 -13
@@ -1553,19 +1553,6 @@ config AMD_MEM_ENCRYPT This requires an AMD processor that supports Secure Memory Encryption (SME). -config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT - bool "Activate AMD Secure Memory Encryption (SME) by default" - depends on AMD_MEM_ENCRYPT - help - Say yes to have system memory encrypted by default if running on - an AMD processor that supports Secure Memory Encryption (SME). - - If set to Y, then the encryption of system memory can be - deactivated with the mem_encrypt=off command line option. - - If set to N, then the encryption of system memory can be - activated with the mem_encrypt=on command line option. - # Common NUMA Features config NUMA bool "NUMA Memory Allocation and Scheduler Support"
arch/x86/mm/mem_encrypt_identity.c +1 -10
@@ -97,7 +97,6 @@ static char sme_workarea[2 * PMD_PAGE_SIstatic char sme_cmdline_arg[]__initdata ="mem_encrypt" ;static char sme_cmdline_on[]__initdata ="on" ; -static char sme_cmdline_off[]__initdata ="off" ;static void __init sme_clear_pgd (struct sme_populate_pgd_data *ppd) {
@@ -504,7 +503,7 @@ void __init sme_encrypt_kernel(struct bovoid __init sme_enable (struct boot_params *bp) { -const char *cmdline_ptr, *cmdline_arg, *cmdline_on, *cmdline_off; +const char *cmdline_ptr, *cmdline_arg, *cmdline_on;unsigned int eax, ebx, ecx, edx;unsigned long feature_mask;unsigned long me_mask;
@@ -587,12 +586,6 @@ void __init sme_enable(struct boot_param asm ("lea sme_cmdline_on(%%rip), %0" :"=r" (cmdline_on) :"p" (sme_cmdline_on)); - asm ("lea sme_cmdline_off(%%rip), %0" - :"=r" (cmdline_off) - :"p" (sme_cmdline_off)); - -if (IS_ENABLED (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT )) - sme_me_mask = me_mask; cmdline_ptr = (const char *)((u64 )bp->hdr.cmd_line_ptr | ((u64 )bp->ext_cmd_line_ptr <<32 ));
@@ -602,8 +595,6 @@ void __init sme_enable(struct boot_paramif (!strncmp (buffer, cmdline_on,sizeof (buffer))) sme_me_mask = me_mask; -else if (!strncmp (buffer, cmdline_off,sizeof (buffer))) - sme_me_mask =0 ; out:if (sme_me_mask) {
Greg Kroah-Hartman
maintainerPATCH 208/272 x86/sev: Fix position dependent variable references in startup code
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 1c811d403afd73f04bde82b83b24c754011bd0e8 upstream.
The early startup code executes from a 1:1 mapping of memory, which differs from the mapping that the code was linked and/or relocated to run at. The latter mapping is not active yet at this point, and so symbol references that rely on it will fault.
Given that the core kernel is built without -fPIC, symbol references are typically emitted as absolute, and so any such references occuring in the early startup code will therefore crash the kernel.
While an attempt was made to work around this for the early SEV/SME startup code, by forcing RIP-relative addressing for certain global SEV/SME variables via inline assembly (see snp_cpuid_get_table() for example), RIP-relative addressing must be pervasively enforced for SEV/SME global variables when accessed prior to page table fixups.
__startup_64() already handles this issue for select non-SEV/SME global variables using fixup_pointer(), which adjusts the pointer relative to a physaddr argument. To avoid having to pass around this physaddr argument across all functions needing to apply pointer fixups, introduce a macro RIP_RELATIVE_REF() which generates a RIP-relative reference to a given global variable. It is used where necessary to force RIP-relative accesses to global variables.
For backporting purposes, this patch makes no attempt at cleaning up other occurrences of this pattern, involving either inline asm or fixup_pointer(). Those will be addressed later.
[ bp: Call it "rip_rel_ref" everywhere like other code shortens
"rIP-relative reference" and make the asm wrapper __always_inline. ]
--- arch/x86/coco/core.c | 7 +------ arch/x86/include/asm/asm.h | 14 ++++++++++++++ arch/x86/include/asm/coco.h | 8 +++++++- arch/x86/include/asm/mem_encrypt.h | 15 +++++++++------ arch/x86/kernel/sev-shared.c | 12 ++++++------ arch/x86/kernel/sev.c | 4 ++-- arch/x86/mm/mem_encrypt_identity.c | 27 ++++++++++++--------------- 7 files changed, 51 insertions(+), 36 deletions(-)
arch/x86/coco/core.c +1 -6
@@ -14,7 +14,7 @@#include <asm/processor.h> enum cc_vendor cc_vendor__ro_after_init =CC_VENDOR_NONE ; -static u64 cc_mask__ro_after_init ; +u64 cc_mask__ro_after_init ;static bool intel_cc_platform_has (enum cc_attr attr) {
@@ -128,8 +128,3 @@ u64 cc_mkdec(u64 val) } }EXPORT_SYMBOL_GPL (cc_mkdec); - -__init void cc_set_mask (u64 mask) -{ - cc_mask = mask; -}
arch/x86/include/asm/asm.h +14 -0
@@ -113,6 +113,20 @@#endif +#ifndef __ASSEMBLY__ +#ifndef __pic__ +static __always_inline __pure void *rip_rel_ptr(void *p) +{ + asm("leaq %c1(%%rip), %0" :"=r" (p) :"i" (p)); + +return p; +} +#define RIP_REL_REF (var) (*(typeof(&(var)))rip_rel_ptr(&(var))) +#else +#define RIP_REL_REF (var) (var) +#endif +#endif +/* * Macros to generate condition code outputs from inline assembly, * The output operand must be type "bool".
arch/x86/include/asm/coco.h +7 -1
@@ -2,6 +2,7 @@#ifndef _ASM_X86_COCO_H#define _ASM_X86_COCO_H +#include <asm/asm.h> #include <asm/types.h> enum cc_vendor {
@@ -12,9 +13,14 @@ enum cc_vendor { };extern enum cc_vendor cc_vendor; +extern u64 cc_mask;#ifdef CONFIG_ARCH_HAS_CC_PLATFORM -void cc_set_mask (u64 mask); +static inline void cc_set_mask (u64 mask) +{ +RIP_REL_REF (cc_mask) = mask; +} +u64 cc_mkenc (u64 val);u64 cc_mkdec (u64 val);#else
arch/x86/include/asm/mem_encrypt.h +9 -6
@@ -15,7 +15,8 @@#include <linux/init.h> #include <linux/cc_platform.h> -#include <asm/bootparam.h> +#include <asm/asm.h> +struct boot_params ;#ifdef CONFIG_X86_MEM_ENCRYPT void __init mem_encrypt_init (void );
@@ -57,6 +58,11 @@ void __init mem_encrypt_free_decrypted_mvoid __init sev_es_init_vc_handling (void ); +static inline u64 sme_get_me_mask (void ) +{ +return RIP_REL_REF (sme_me_mask); +} +#define __bss_decrypted __section(".bss..decrypted")#else /* !CONFIG_AMD_MEM_ENCRYPT */
@@ -88,6 +94,8 @@ early_set_mem_enc_dec_hypercall(unsignedstatic inline void mem_encrypt_free_decrypted_mem (void ) { } +static inline u64 sme_get_me_mask (void ) {return 0 ; } +#define __bss_decrypted#endif /* CONFIG_AMD_MEM_ENCRYPT */
@@ -105,11 +113,6 @@ void add_encrypt_protection_map(void);extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[]; -static inline u64 sme_get_me_mask (void ) -{ -return sme_me_mask; -} -#endif /* __ASSEMBLY__ */ #endif /* __X86_MEM_ENCRYPT_H__ */
arch/x86/kernel/sev-shared.c +6 -6
@@ -553,9 +553,9 @@ static int snp_cpuid(struct ghcb *ghcb, leaf->eax = leaf->ebx = leaf->ecx = leaf->edx =0 ;/* Skip post-processing for out-of-range zero leafs. */ -if (!(leaf->fn <= cpuid_std_range_max || - (leaf->fn >=0x40000000 && leaf->fn <= cpuid_hyp_range_max) || - (leaf->fn >=0x80000000 && leaf->fn <= cpuid_ext_range_max))) +if (!(leaf->fn <=RIP_REL_REF (cpuid_std_range_max) || + (leaf->fn >=0x40000000 && leaf->fn <=RIP_REL_REF (cpuid_hyp_range_max)) || + (leaf->fn >=0x80000000 && leaf->fn <=RIP_REL_REF (cpuid_ext_range_max))))return 0 ; }
@@ -1060,10 +1060,10 @@ static void __init setup_cpuid_table(conconst struct snp_cpuid_fn *fn = &cpuid_table->fn[i];if (fn->eax_in ==0x0 ) - cpuid_std_range_max = fn->eax; +RIP_REL_REF (cpuid_std_range_max) = fn->eax;else if (fn->eax_in ==0x40000000 ) - cpuid_hyp_range_max = fn->eax; +RIP_REL_REF (cpuid_hyp_range_max) = fn->eax;else if (fn->eax_in ==0x80000000 ) - cpuid_ext_range_max = fn->eax; +RIP_REL_REF (cpuid_ext_range_max) = fn->eax; } }
arch/x86/kernel/sev.c +2 -2
@@ -736,7 +736,7 @@ void __init early_snp_set_memory_private* This eliminates worries about jump tables or checking boot_cpu_data * in the cc_platform_has() function. */ -if (!(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (!(RIP_REL_REF (sev_status) &MSR_AMD64_SEV_SNP_ENABLED ))return ;/*
@@ -758,7 +758,7 @@ void __init early_snp_set_memory_shared(* This eliminates worries about jump tables or checking boot_cpu_data * in the cc_platform_has() function. */ -if (!(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (!(RIP_REL_REF (sev_status) &MSR_AMD64_SEV_SNP_ENABLED ))return ;/* Invalidate the memory pages before they are marked shared in the RMP table. */
arch/x86/mm/mem_encrypt_identity.c +12 -15
@@ -304,7 +304,8 @@ void __init sme_encrypt_kernel(struct bo* instrumentation or checking boot_cpu_data in the cc_platform_has() * function. */ -if (!sme_get_me_mask () || sev_status &MSR_AMD64_SEV_ENABLED ) +if (!sme_get_me_mask () || +RIP_REL_REF (sev_status) &MSR_AMD64_SEV_ENABLED )return ;/*
@@ -541,11 +542,11 @@ void __init sme_enable(struct boot_param me_mask =1UL << (ebx &0x3f );/* Check the SEV MSR whether SEV or SME is enabled */ - sev_status =__rdmsr (MSR_AMD64_SEV ); - feature_mask = (sev_status &MSR_AMD64_SEV_ENABLED ) ?AMD_SEV_BIT :AMD_SME_BIT ; +RIP_REL_REF (sev_status) = msr =__rdmsr (MSR_AMD64_SEV ); + feature_mask = (msr &MSR_AMD64_SEV_ENABLED ) ?AMD_SEV_BIT :AMD_SME_BIT ;/* The SEV-SNP CC blob should never be present unless SEV-SNP is enabled. */ -if (snp && !(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (snp && !(msr &MSR_AMD64_SEV_SNP_ENABLED ))snp_abort ();/* Check if memory encryption is enabled */
@@ -571,7 +572,6 @@ void __init sme_enable(struct boot_paramreturn ; }else {/* SEV state cannot be controlled by a command line option */ - sme_me_mask = me_mask; goto out; }
@@ -590,16 +590,13 @@ void __init sme_enable(struct boot_param cmdline_ptr = (const char *)((u64 )bp->hdr.cmd_line_ptr | ((u64 )bp->ext_cmd_line_ptr <<32 )); -if (cmdline_find_option (cmdline_ptr, cmdline_arg, buffer,sizeof (buffer)) <0 ) - goto out; - -if (!strncmp (buffer, cmdline_on,sizeof (buffer))) - sme_me_mask = me_mask; +if (cmdline_find_option (cmdline_ptr, cmdline_arg, buffer,sizeof (buffer)) <0 || +strncmp (buffer, cmdline_on,sizeof (buffer))) +return ; out: -if (sme_me_mask) { - physical_mask &= ~sme_me_mask; - cc_vendor =CC_VENDOR_AMD ; -cc_set_mask (sme_me_mask); - } +RIP_REL_REF (sme_me_mask) = me_mask; + physical_mask &= ~me_mask; + cc_vendor =CC_VENDOR_AMD ; +cc_set_mask (me_mask); }
Greg Kroah-Hartman
maintainerPATCH 209/272 mm/migrate: set swap entry values of THP tail pages properly.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
The tail pages in a THP can have swap entry information stored in their private field. When migrating to a new page, all tail pages of the new page need to update ->private to avoid future data corruption.
This fix is stable-only, since after commit 07e09c483cbe ("mm/huge_memory:
work on folio->swap instead of page->private when splitting folio"), subpages of a swapcached THP no longer requires the maintenance.
Adding THPs to the swapcache was introduced in commit 38d8b4e6bdc87 ("mm, THP, swap: delay splitting THP during swap out"), where each subpage of a THP added to the swapcache had its own swapcache entry and required the ->private field to point to the correct swapcache entry. Later, when THP migration functionality was implemented in commit 616b8371539a6 ("mm: thp: enable thp migration in generic path"), it initially did not handle the subpages of swapcached THPs, failing to update their ->private fields or replace the subpage pointers in the swapcache. Subsequently, commit e71769ae5260 ("mm: enable thp migration for shmem thp") addressed the swapcache update aspect. This patch fixes the update of subpage ->private fields.
--- mm/migrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
mm/migrate.c +5 -1
@@ -423,8 +423,12 @@ int folio_migrate_mapping(struct addressif (folio_test_swapbacked (folio)) {__folio_set_swapbacked (newfolio);if (folio_test_swapcache (folio)) { +int i; +folio_set_swapcache (newfolio); - newfolio->private =folio_get_private (folio); +for (i =0 ; i < nr; i++) +set_page_private (folio_page (newfolio, i), +page_private (folio_page (folio, i))); } entries = nr; }else {
Greg Kroah-Hartman
maintainerPATCH 210/272 init: open /initrd.image with O_LARGEFILE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Sperbeck <[email protected]>
commit 4624b346cf67400ef46a31771011fb798dd2f999 upstream.
If initrd data is larger than 2Gb, we'll eventually fail to write to the /initrd.image file when we hit that limit, unless O_LARGEFILE is set.
--- init/initramfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
init/initramfs.c +1 -1
@@ -680,7 +680,7 @@ static void __init populate_initrd_imageprintk (KERN_INFO "rootfs image is not initramfs (%s); looks like an initrd\n" , err); - file =filp_open ("/initrd.image" ,O_WRONLY |O_CREAT ,0700 ); + file =filp_open ("/initrd.image" ,O_WRONLY |O_CREAT |O_LARGEFILE ,0700 );if (IS_ERR (file))return ;
Greg Kroah-Hartman
maintainerPATCH 211/272 x86/efistub: Add missing boot_params for mixed mode compat entry
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit d21f5a59ea773826cc489acb287811d690b703cc upstream.
The pure EFI stub entry point does not take a struct boot_params from the boot loader, but creates it from scratch, and populates only the fields that still have meaning in this context (command line, initrd base and size, etc)
The original mixed mode implementation used the EFI handover protocol instead, where the boot loader (i.e., GRUB) populates a boot_params struct and passes it to a special Linux specific EFI entry point that takes the boot_params pointer as its third argument.
When the new mixed mode implementation was introduced, using a special 32-bit PE entrypoint in the 64-bit kernel, it adopted the pure approach, and relied on the EFI stub to create the struct boot_params. This is preferred because it makes the bootloader side much easier to implement, as it does not need any x86-specific knowledge on how struct boot_params and struct setup_header are put together. This mixed mode implementation was adopted by systemd-boot version 252 and later.
When commit
e2ab9eab324c ("x86/boot/compressed: Move 32-bit entrypoint code into .text section")
refactored this code and moved it out of head_64.S, the fact that ESI was populated with the address of the base of the image was overlooked, and to simplify the code flow, ESI is now zeroed and stored to memory unconditionally in shared code, so that the NULL-ness of that variable can still be used later to determine which mixed mode boot protocol is in use.
With ESI pointing to the base of the image, it can serve as a struct boot_params pointer for startup_32(), which only accesses the init_data and kernel_alignment fields (and the scratch field as a temporary stack). Zeroing ESI means that those accesses produce garbage now, even though things appear to work if the first page of memory happens to be zeroed, and the region right before LOAD_PHYSICAL_ADDR (== 16 MiB) happens to be free.
The solution is to pass a special, temporary struct boot_params to startup_32() via ESI, one that is sufficient for getting it to create the page tables correctly and is discarded right after. This involves setting a minimal alignment of 4k, only to get the statically allocated page tables line up correctly, and setting init_size to the executable image size (_end - startup_32). This ensures that the page tables are covered by the static footprint of the PE image.
Given that EFI boot no longer calls the decompressor and no longer pads the image to permit the decompressor to execute in place, the same temporary struct boot_params should be used in the EFI handover protocol based mixed mode implementation as well, to prevent the page tables from being placed outside of allocated memory.
--- arch/x86/boot/compressed/efi_mixed.S | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
arch/x86/boot/compressed/efi_mixed.S +15 -5
@@ -15,10 +15,12 @@ */ #include <linux/linkage.h> +#include <asm/asm-offsets.h> #include <asm/msr.h> #include <asm/page_types.h> #include <asm/processor-flags.h> #include <asm/segment.h> +#include <asm/setup.h> .code64 .text
@@ -155,6 +157,7 @@ SYM_FUNC_END(__efi64_thunk) SYM_FUNC_START(efi32_stub_entry) call 1f 1: popl %ecx + leal (efi32_boot_args - 1b)(%ecx), %ebx /* Clear BSS */ xorl %eax, %eax
@@ -169,6 +172,7 @@ SYM_FUNC_START(efi32_stub_entry) popl %ecx popl %edx popl %esi + movl %esi, 8(%ebx) jmp efi32_entry SYM_FUNC_END(efi32_stub_entry) #endif
@@ -245,8 +249,6 @@ SYM_FUNC_END(efi_enter32) * * Arguments: %ecx image handle * %edx EFI system table pointer - * %esi struct bootparams pointer (or NULL when not using - * the EFI handover protocol) * * Since this is the point of no return for ordinary execution, no registers * are considered live except for the function parameters. [Note that the EFI
@@ -272,9 +274,18 @@ SYM_FUNC_START_LOCAL(efi32_entry) leal (efi32_boot_args - 1b)(%ebx), %ebx movl %ecx, 0(%ebx) movl %edx, 4(%ebx) - movl %esi, 8(%ebx) movb $0x0, 12(%ebx) // efi_is64 + /* + * Allocate some memory for a temporary struct boot_params, which only + * needs the minimal pieces that startup_32() relies on. + */ + subl $PARAM_SIZE, %esp + movl %esp, %esi + movl $PAGE_SIZE, BP_kernel_alignment(%esi) + movl $_end - 1b, BP_init_size(%esi) + subl $startup_32 - 1b, BP_init_size(%esi) + /* Disable paging */ movl %cr0, %eax btrl $X86_CR0_PG_BIT, %eax
@@ -300,8 +311,7 @@ SYM_FUNC_START(efi32_pe_entry) movl 8(%ebp), %ecx // image_handle movl 12(%ebp), %edx // sys_table - xorl %esi, %esi - jmp efi32_entry // pass %ecx, %edx, %esi + jmp efi32_entry // pass %ecx, %edx // no other registers remain live 2: popl %edi // restore callee-save registers
Greg Kroah-Hartman
maintainerPATCH 212/272 efi/libstub: Cast away type warning in use of max()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 61d130f261a3c15ae2c4b6f3ac3517d5d5b78855 upstream.
Avoid a type mismatch warning in max() by switching to max_t() and providing the type explicitly.
--- drivers/firmware/efi/libstub/randomalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/randomalloc.c +1 -1
@@ -119,7 +119,7 @@ efi_status_t efi_random_alloc(unsigned lcontinue ; } - target =round_up (max (md->phys_addr, alloc_min), align) + target_slot * align; + target =round_up (max_t (u64, md->phys_addr, alloc_min), align) + target_slot * align; pages = size /EFI_PAGE_SIZE ; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
Greg Kroah-Hartman
maintainerPATCH 213/272 btrfs: zoned: dont skip block groups with 100% zone unusable
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit a8b70c7f8600bc77d03c0b032c0662259b9e615e upstream.
Commit f4a9f219411f ("btrfs: do not delete unused block group if it may be used soon") changed the behaviour of deleting unused block-groups on zoned filesystems. Starting with this commit, we're using btrfs_space_info_used() to calculate the number of used bytes in a space_info. But btrfs_space_info_used() also accounts btrfs_space_info::bytes_zone_unusable as used bytes.
So if a block group is 100% zone_unusable it is skipped from the deletion step.
In order not to skip fully zone_unusable block-groups, also check if the block-group has bytes left that can be used on a zoned filesystem.
--- fs/btrfs/block-group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +2 -1
@@ -1413,7 +1413,8 @@ void btrfs_delete_unused_bgs(struct btrf* needing to allocate extents from the block group. */ used =btrfs_space_info_used (space_info, true); -if (space_info->total_bytes - block_group->length < used) { +if (space_info->total_bytes - block_group->length < used && + block_group->zone_unusable < block_group->length) {/* * Add a reference for the list, compensate for the ref * drop under the "next" label for the
Greg Kroah-Hartman
maintainerPATCH 214/272 btrfs: zoned: use zone aware sb location for scrub
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit 74098a989b9c3370f768140b7783a7aaec2759b3 upstream.
At the moment scrub_supers() doesn't grab the super block's location via the zoned device aware btrfs_sb_log_location() but via btrfs_sb_offset().
This leads to checksum errors on 'scrub' as we're not accessing the correct location of the super block.
So use btrfs_sb_log_location() for getting the super blocks location on scrub.
--- fs/btrfs/scrub.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/btrfs/scrub.c +11 -1
@@ -4177,7 +4177,17 @@ static noinline_for_stack int scrub_supe gen = fs_info->last_trans_committed;for (i =0 ; i <BTRFS_SUPER_MIRROR_MAX ; i++) { - bytenr =btrfs_sb_offset (i); + ret =btrfs_sb_log_location (scrub_dev, i,0 , &bytenr); +if (ret == -ENOENT ) +break ; + +if (ret) { +spin_lock (&sctx->stat_lock); + sctx->stat.super_errors++; +spin_unlock (&sctx->stat_lock); +continue ; + } +if (bytenr +BTRFS_SUPER_INFO_SIZE > scrub_dev->commit_total_bytes)break ;
Greg Kroah-Hartman
maintainerPATCH 215/272 wifi: mac80211: check/clear fast rx for non-4addr sta VLAN changes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 4f2bdb3c5e3189297e156b3ff84b140423d64685 upstream.
When moving a station out of a VLAN and deleting the VLAN afterwards, the fast_rx entry still holds a pointer to the VLAN's netdev, which can cause use-after-free bugs. Fix this by immediately calling ieee80211_check_fast_rx after the VLAN change.
--- net/mac80211/cfg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/mac80211/cfg.c +2 -3
@@ -2075,15 +2075,14 @@ static int ieee80211_change_station(stru }if (sta->sdata->vif.type ==NL80211_IFTYPE_AP_VLAN && - sta->sdata->u.vlan.sta) { -ieee80211_clear_fast_rx (sta); + sta->sdata->u.vlan.sta)RCU_INIT_POINTER (sta->sdata->u.vlan.sta,NULL ); - }if (test_sta_flag (sta,WLAN_STA_AUTHORIZED ))ieee80211_vif_dec_num_mcast (sta->sdata); sta->sdata = vlansdata; +ieee80211_check_fast_rx (sta);ieee80211_check_fast_xmit (sta);if (test_sta_flag (sta,WLAN_STA_AUTHORIZED )) {
Greg Kroah-Hartman
maintainerPATCH 216/272 wifi: iwlwifi: fw: dont always use FW dump trig
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 045a5b645dd59929b0e05375f493cde3a0318271 upstream.
Since the dump_data (struct iwl_fwrt_dump_data) is a union, it's not safe to unconditionally access and use the 'trig' member, it might be 'desc' instead. Access it only if it's known to be 'trig' rather than 'desc', i.e. if ini-debug is present.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +9 -8
@@ -2903,8 +2903,6 @@ static void iwl_fw_dbg_collect_sync(strustruct iwl_fw_dbg_params params = {0 };struct iwl_fwrt_dump_data *dump_data = &fwrt->dump.wks[wk_idx].dump_data; -u32 policy; -u32 time_point;if (!test_bit (wk_idx, &fwrt->dump.active_wks))return ;
@@ -2935,13 +2933,16 @@ static void iwl_fw_dbg_collect_sync(struiwl_fw_dbg_stop_restart_recording (fwrt, ¶ms, false); - policy =le32_to_cpu (dump_data->trig->apply_policy); - time_point =le32_to_cpu (dump_data->trig->time_point); - -if (policy &IWL_FW_INI_APPLY_POLICY_DUMP_COMPLETE_CMD ) { -IWL_DEBUG_FW_INFO (fwrt,"WRT: sending dump complete\n" ); -iwl_send_dbg_dump_complete_cmd (fwrt, time_point,0 ); +if (iwl_trans_dbg_ini_valid (fwrt->trans)) { +u32 policy =le32_to_cpu (dump_data->trig->apply_policy); +u32 time_point =le32_to_cpu (dump_data->trig->time_point); + +if (policy &IWL_FW_INI_APPLY_POLICY_DUMP_COMPLETE_CMD ) { +IWL_DEBUG_FW_INFO (fwrt,"WRT: sending dump complete\n" ); +iwl_send_dbg_dump_complete_cmd (fwrt, time_point,0 ); + } } +if (fwrt->trans->dbg.last_tp_resetfw ==IWL_FW_INI_RESET_FW_MODE_STOP_FW_ONLY )iwl_force_nmi (fwrt->trans);
Greg Kroah-Hartman
maintainerPATCH 217/272 exec: Fix NOMMU linux_binprm::exec in transfer_args_to_stack()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Filippov <[email protected]>
commit 2aea94ac14d1e0a8ae9e34febebe208213ba72f7 upstream.
In NOMMU kernel the value of linux_binprm::p is the offset inside the temporary program arguments array maintained in separate pages in the linux_binprm::page. linux_binprm::exec being a copy of linux_binprm::p thus must be adjusted when that array is copied to the user stack. Without that adjustment the value passed by the NOMMU kernel to the ELF program in the AT_EXECFN entry of the aux array doesn't make any sense and it may break programs that try to access memory pointed to by that entry.
Adjust linux_binprm::exec before the successful return from the transfer_args_to_stack().
--- fs/exec.c | 1 + 1 file changed, 1 insertion(+)
fs/exec.c +1 -0
@@ -896,6 +896,7 @@ int transfer_args_to_stack(struct linux_ goto out; } + bprm->exec += *sp_location -MAX_ARG_PAGES *PAGE_SIZE ; *sp_location = sp; out:
Greg Kroah-Hartman
maintainerPATCH 218/272 hexagon: vmlinux.lds.S: handle attributes section
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 549aa9678a0b3981d4821bf244579d9937650562 upstream.
After the linked LLVM change, the build fails with CONFIG_LD_ORPHAN_WARN_LEVEL="error", which happens with allmodconfig:
ld.lld: error: vmlinux.a(init/main.o):(.hexagon.attributes) is being placed in '.hexagon.attributes'
Handle the attributes section in a similar manner as arm and riscv by adding it after the primary ELF_DETAILS grouping in vmlinux.lds.S, which fixes the error.
--- arch/hexagon/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+)
arch/hexagon/kernel/vmlinux.lds.S +1 -0
@@ -64,6 +64,7 @@ SECTIONS STABS_DEBUG DWARF_DEBUG ELF_DETAILS + .hexagon.attributes 0 : { *(.hexagon.attributes) } DISCARDS }
Greg Kroah-Hartman
maintainerPATCH 219/272 mmc: sdhci-omap: re-tuning is needed after a pm transition to support emmc HS200 mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Romain Naour <[email protected]>
commit f9e2a5b00a35f2c064dc679808bc8db5cc779ed6 upstream.
"PM runtime functions" was been added in sdhci-omap driver in commit f433e8aac6b9 ("mmc: sdhci-omap: Implement PM runtime functions") along with "card power off and enable aggressive PM" in commit 3edf588e7fe0 ("mmc: sdhci-omap: Allow SDIO card power off and enable aggressive PM").
Since then, the sdhci-omap driver doesn't work using mmc-hs200 mode due to the tuning values being lost during a pm transition.
As for the sdhci_am654 driver, request a new tuning sequence before suspend (sdhci_omap_runtime_suspend()), otherwise the device will trigger cache flush error:
mmc1: cache flush error -110 (ETIMEDOUT)
mmc1: error -110 doing aggressive suspend
followed by I/O errors produced by fdisk -l /dev/mmcblk1boot1:
I/O error, dev mmcblk1boot0, sector 64384 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
I/O error, dev mmcblk1boot1, sector 64384 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
I/O error, dev mmcblk1boot1, sector 64384 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1boot1, logical block 8048, async page read I/O error, dev mmcblk1boot0, sector 64384 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1boot0, logical block 8048, async page read
Don't re-tune if auto retuning is supported in HW (when SDHCI_TUNING_MODE_3 is available).
--- drivers/mmc/host/sdhci-omap.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci-omap.c +3 -0
@@ -1442,6 +1442,9 @@ static int __maybe_unused sdhci_omap_runstruct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); +if (host->tuning_mode !=SDHCI_TUNING_MODE_3 ) +mmc_retune_needed (host->mmc); +if (omap_host->con != -EINVAL )sdhci_runtime_suspend_host (host);
Greg Kroah-Hartman
maintainerPATCH 220/272 mmc: core: Initialize mmc_blk_ioc_data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Rapeli <[email protected]>
commit 0cdfe5b0bf295c0dee97436a8ed13336933a0211 upstream.
Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") adds flags uint to struct mmc_blk_ioc_data, but it does not get initialized for RPMB ioctls which now fails.
Let's fix this by always initializing the struct and flags to zero.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -415,7 +415,7 @@ static struct mmc_blk_ioc_data *mmc_blk_struct mmc_blk_ioc_data *idata;int err; - idata =kmalloc (sizeof (*idata),GFP_KERNEL ); + idata =kzalloc (sizeof (*idata),GFP_KERNEL );if (!idata) { err = -ENOMEM ; goto out;
Greg Kroah-Hartman
maintainerPATCH 221/272 mmc: core: Avoid negative index with array access
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Rapeli <[email protected]>
commit cf55a7acd1ed38afe43bba1c8a0935b51d1dc014 upstream.
Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") assigns prev_idata = idatas[i - 1], but doesn't check that the iterator i is greater than zero. Let's fix this by adding a check.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -490,7 +490,7 @@ static int __mmc_blk_ioctl_cmd(struct mmif (idata->flags &MMC_BLK_IOC_DROP )return 0 ; -if (idata->flags &MMC_BLK_IOC_SBC ) +if (idata->flags &MMC_BLK_IOC_SBC && i >0 ) prev_idata = idatas[i -1 ];/*
Greg Kroah-Hartman
maintainerPATCH 222/272 block: Do not force full zone append completion in req_bio_endio()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 55251fbdf0146c252ceff146a1bb145546f3e034 upstream.
This reverts commit 748dc0b65ec2b4b7b3dbd7befcc4a54fdcac7988.
Partial zone append completions cannot be supported as there is no guarantees that the fragmented data will be written sequentially in the same manner as with a full command. Commit 748dc0b65ec2 ("block: fix partial zone append completion handling in req_bio_endio()") changed req_bio_endio() to always advance a partially failed BIO by its full length, but this can lead to incorrect accounting. So revert this change and let low level device drivers handle this case by always failing completely zone append operations. With this revert, users will still see an IO error for a partially completed zone append BIO.
--- block/blk-mq.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
block/blk-mq.c +2 -7
@@ -761,16 +761,11 @@ static void req_bio_endio(struct request/* * Partial zone append completions cannot be supported as the * BIO fragments may end up not being written sequentially. -* For such case, force the completed nbytes to be equal to -* the BIO size so that bio_advance() sets the BIO remaining -* size to 0 and we end up calling bio_endio() before returning. */ -if (bio->bi_iter.bi_size != nbytes) { +if (bio->bi_iter.bi_size != nbytes) bio->bi_status =BLK_STS_IOERR ; - nbytes = bio->bi_iter.bi_size; - }else { +else bio->bi_iter.bi_sector = rq->__sector; - } }bio_advance (bio, nbytes);
Greg Kroah-Hartman
maintainerPATCH 223/272 thermal: devfreq_cooling: Fix perf state when calculate dfc res_util
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Zhang <[email protected]>
commit a26de34b3c77ae3a969654d94be49e433c947e3b upstream.
The issue occurs when the devfreq cooling device uses the EM power model and the get_real_power() callback is provided by the driver.
The EM power table is sorted ascending,can't index the table by cooling device state,so convert cooling state to performance state by dfc->max_state - dfc->capped_state.
--- drivers/thermal/devfreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/devfreq_cooling.c +1 -1
@@ -201,7 +201,7 @@ static int devfreq_cooling_get_requested res = dfc->power_ops->get_real_power (df, power, freq, voltage);if (!res) { - state = dfc->capped_state; + state = dfc->max_state - dfc->capped_state;/* Convert EM power into milli-Watts first */ dfc->res_util = dfc->em_pd->table[state].power;
Greg Kroah-Hartman
maintainerPATCH 224/272 nouveau/dmem: handle kcalloc() allocation failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 16e87fe23d4af6df920406494ced5c0f4354567b upstream.
The kcalloc() in nouveau_dmem_evict_chunk() will return null if the physical memory has run out. As a result, if we dereference src_pfns, dst_pfns or dma_addrs, the null pointer dereference bugs will happen.
Moreover, the GPU is going away. If the kcalloc() fails, we could not evict all pages mapping a chunk. So this patch adds a __GFP_NOFAIL flag in kcalloc().
Finally, as there is no need to have physically contiguous memory, this patch switches kcalloc() to kvcalloc() in order to avoid failing allocations.
--- drivers/gpu/drm/nouveau/nouveau_dmem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dmem.c +6 -6
@@ -379,9 +379,9 @@ nouveau_dmem_evict_chunk(struct nouveau_dma_addr_t *dma_addrs;struct nouveau_fence *fence; - src_pfns =kcalloc (npages,sizeof (*src_pfns),GFP_KERNEL ); - dst_pfns =kcalloc (npages,sizeof (*dst_pfns),GFP_KERNEL ); - dma_addrs =kcalloc (npages,sizeof (*dma_addrs),GFP_KERNEL ); + src_pfns =kvcalloc (npages,sizeof (*src_pfns),GFP_KERNEL | __GFP_NOFAIL); + dst_pfns =kvcalloc (npages,sizeof (*dst_pfns),GFP_KERNEL | __GFP_NOFAIL); + dma_addrs =kvcalloc (npages,sizeof (*dma_addrs),GFP_KERNEL | __GFP_NOFAIL);migrate_device_range (src_pfns, chunk->pagemap.range.start >>PAGE_SHIFT , npages);
@@ -407,11 +407,11 @@ nouveau_dmem_evict_chunk(struct nouveau_migrate_device_pages (src_pfns, dst_pfns, npages);nouveau_dmem_fence_done (&fence);migrate_device_finalize (src_pfns, dst_pfns, npages); -kfree (src_pfns); -kfree (dst_pfns); +kvfree (src_pfns); +kvfree (dst_pfns);for (i =0 ; i < npages; i++)dma_unmap_page (chunk->drm->dev->dev, dma_addrs[i],PAGE_SIZE ,DMA_BIDIRECTIONAL ); -kfree (dma_addrs); +kvfree (dma_addrs); }void
Greg Kroah-Hartman
maintainerPATCH 225/272 net: ll_temac: platform_get_resource replaced by wrong function
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claus Hansen Ries <[email protected]>
commit 3a38a829c8bc27d78552c28e582eb1d885d07d11 upstream.
The function platform_get_resource was replaced with devm_platform_ioremap_resource_byname and is called using 0 as name.
This eventually ends up in platform_get_resource_byname in the call stack, where it causes a null pointer in strcmp.
if (type == resource_type(r) && !strcmp(r->name, name))
It should have been replaced with devm_platform_ioremap_resource.
--- drivers/net/ethernet/xilinx/ll_temac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +1 -1
@@ -1445,7 +1445,7 @@ static int temac_probe(struct platform_d }/* map device registers */ - lp->regs =devm_platform_ioremap_resource_byname (pdev,0 ); + lp->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (lp->regs)) {dev_err (&pdev->dev,"could not map TEMAC registers\n" );return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 226/272 drm/vmwgfx: Create debugfs ttm_resource_manager entry only if needed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jocelyn Falempe <[email protected]>
commit 4be9075fec0a639384ed19975634b662bfab938f upstream.
The driver creates /sys/kernel/debug/dri/0/mob_ttm even when the corresponding ttm_resource_manager is not allocated. This leads to a crash when trying to read from this file.
Add a check to create mob_ttm, system_mob_ttm, and gmr_ttm debug file only when the corresponding ttm_resource_manager is allocated.
crash> bt
PID: 3133409 TASK: ffff8fe4834a5000 CPU: 3 COMMAND: "grep"
#0 [ffffb954506b3b20] machine_kexec at ffffffffb2a6bec3 #1 [ffffb954506b3b78] __crash_kexec at ffffffffb2bb598a #2 [ffffb954506b3c38] crash_kexec at ffffffffb2bb68c1 #3 [ffffb954506b3c50] oops_end at ffffffffb2a2a9b1
#4 [ffffb954506b3c70] no_context at ffffffffb2a7e913 #5 [ffffb954506b3cc8] __bad_area_nosemaphore at ffffffffb2a7ec8c #6 [ffffb954506b3d10] do_page_fault at ffffffffb2a7f887 #7 [ffffb954506b3d40] page_fault at ffffffffb360116e
[exception RIP: ttm_resource_manager_debug+0x11]
RIP: ffffffffc04afd11 RSP: ffffb954506b3df0 RFLAGS: 00010246
RAX: ffff8fe41a6d1200 RBX: 0000000000000000 RCX: 0000000000000940
RDX: 0000000000000000 RSI: ffffffffc04b4338 RDI: 0000000000000000
RBP: ffffb954506b3e08 R8: ffff8fee3ffad000 R9: 0000000000000000
R10: ffff8fe41a76a000 R11: 0000000000000001 R12: 00000000ffffffff
R13: 0000000000000001 R14: ffff8fe5bb6f3900 R15: ffff8fe41a6d1200
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#8 [ffffb954506b3e00] ttm_resource_manager_show at ffffffffc04afde7 [ttm]
#9 [ffffb954506b3e30] seq_read at ffffffffb2d8f9f3
RIP: 00007f4c4eda8985 RSP: 00007ffdbba9e9f8 RFLAGS: 00000246
RAX: ffffffffffffffda RBX: 000000000037e000 RCX: 00007f4c4eda8985
RDX: 000000000037e000 RSI: 00007f4c41573000 RDI: 0000000000000003
RBP: 000000000037e000 R8: 0000000000000000 R9: 000000000037fe30
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f4c41573000
R13: 0000000000000003 R14: 00007f4c41572010 R15: 0000000000000003
ORIG_RAX: 0000000000000000 CS: 0033 SS: 002b--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +9 -6
@@ -1429,12 +1429,15 @@ static void vmw_debugfs_resource_manager root, "system_ttm");ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,TTM_PL_VRAM ), root,"vram_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_GMR ), - root,"gmr_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_MOB ), - root,"mob_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_SYSTEM ), - root,"system_mob_ttm" ); +if (vmw->has_gmr) +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_GMR ), + root,"gmr_ttm" ); +if (vmw->has_mob) { +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_MOB ), + root,"mob_ttm" ); +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_SYSTEM ), + root,"system_mob_ttm" ); + } } static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
Greg Kroah-Hartman
maintainerPATCH 227/272 drm/amdkfd: fix TLB flush after unmap for GFX9.4.2
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Huang <[email protected]>
commit 1210e2f1033dc56b666c9f6dfb761a2d3f9f5d6c upstream.
TLB flush after unmap accidentially was removed on gfx9.4.2. It is to add it back.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -1
@@ -1349,7 +1349,7 @@ void kfd_flush_tlb(struct kfd_process_destatic inline bool kfd_flush_tlb_after_unmap (struct kfd_dev *dev) { -return KFD_GC_VERSION (dev) >IP_VERSION (9 ,4 ,2 ) || +return KFD_GC_VERSION (dev) >=IP_VERSION (9 ,4 ,2 ) || (KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,1 ) && dev->sdma_fw_version >=18 ) ||KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,0 ); }
Greg Kroah-Hartman
maintainerPATCH 228/272 drm/i915/bios: Tolerate devdata==NULL in intel_bios_encoder_supports_dp_dual_mode()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 32e39bab59934bfd3f37097d4dd85ac5eb0fd549 upstream.
If we have no VBT, or the VBT didn't declare the encoder in question, we won't have the 'devdata' for the encoder. Instead of oopsing just bail early.
We won't be able to tell whether the port is DP++ or not, but so be it.
--- drivers/gpu/drm/i915/display/intel_bios.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/display/intel_bios.c +3 -0
@@ -3413,6 +3413,9 @@ static bool intel_bios_encoder_supports_ {const struct child_device_config *child = &devdata->child; +if (!devdata) +return false; +if (!intel_bios_encoder_supports_dp (devdata) || !intel_bios_encoder_supports_hdmi (devdata))return false;
Greg Kroah-Hartman
maintainerPATCH 229/272 drm/i915/gt: Reset queue_priority_hint on parking
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit 4a3859ea5240365d21f6053ee219bb240d520895 upstream.
Originally, with strict in order execution, we could complete execution only when the queue was empty. Preempt-to-busy allows replacement of an active request that may complete before the preemption is processed by HW. If that happens, the request is retired from the queue, but the queue_priority_hint remains set, preventing direct submission until after the next CS interrupt is processed.
This preempt-to-busy race can be triggered by the heartbeat, which will also act as the power-management barrier and upon completion allow us to idle the HW. We may process the completion of the heartbeat, and begin parking the engine before the CS event that restores the queue_priority_hint, causing us to fail the assertion that it is MIN.
<3>[ 166.210729] __engine_park:283 GEM_BUG_ON(engine->sched_engine->queue_priority_hint != (-((int)(~0U >> 1)) - 1))
<0>[ 166.210781] Dumping ftrace buffer:
<0>[ 166.210795] ---------------------------------
...
<0>[ 167.302811] drm_fdin-1097 2..s1. 165741070us : trace_ports: 0000:00:02.0 rcs0: promote { ccid:20 1217:2 prio 0 }
<0>[ 167.302861] drm_fdin-1097 2d.s2. 165741072us : execlists_submission_tasklet: 0000:00:02.0 rcs0: preempting last=1217:2, prio=0, hint=2147483646
<0>[ 167.302928] drm_fdin-1097 2d.s2. 165741072us : __i915_request_unsubmit: 0000:00:02.0 rcs0: fence 1217:2, current 0
<0>[ 167.302992] drm_fdin-1097 2d.s2. 165741073us : __i915_request_submit: 0000:00:02.0 rcs0: fence 3:4660, current 4659
<0>[ 167.303044] drm_fdin-1097 2d.s1. 165741076us : execlists_submission_tasklet: 0000:00:02.0 rcs0: context:3 schedule-in, ccid:40
<0>[ 167.303095] drm_fdin-1097 2d.s1. 165741077us : trace_ports: 0000:00:02.0 rcs0: submit { ccid:40 3:4660* prio 2147483646 }
<0>[ 167.303159] kworker/-89 11..... 165741139us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence c90:2, current 2
<0>[ 167.303208] kworker/-89 11..... 165741148us : __intel_context_do_unpin: 0000:00:02.0 rcs0: context:c90 unpin
<0>[ 167.303272] kworker/-89 11..... 165741159us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence 1217:2, current 2
<0>[ 167.303321] kworker/-89 11..... 165741166us : __intel_context_do_unpin: 0000:00:02.0 rcs0: context:1217 unpin
<0>[ 167.303384] kworker/-89 11..... 165741170us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence 3:4660, current 4660
<0>[ 167.303434] kworker/-89 11d..1. 165741172us : __intel_context_retire: 0000:00:02.0 rcs0: context:1216 retire runtime: { total:56028ns, avg:56028ns }
<0>[ 167.303484] kworker/-89 11..... 165741198us : __engine_park: 0000:00:02.0 rcs0: parked
<0>[ 167.303534] <idle>-0 5d.H3. 165741207us : execlists_irq_handler: 0000:00:02.0 rcs0: semaphore yield: 00000040
<0>[ 167.303583] kworker/-89 11..... 165741397us : __intel_context_retire: 0000:00:02.0 rcs0: context:1217 retire runtime: { total:325575ns, avg:0ns }
<0>[ 167.303756] kworker/-89 11..... 165741777us : __intel_context_retire: 0000:00:02.0 rcs0: context:c90 retire runtime: { total:0ns, avg:0ns }
<0>[ 167.303806] kworker/-89 11..... 165742017us : __engine_park: __engine_park:283 GEM_BUG_ON(engine->sched_engine->queue_priority_hint != (-((int)(~0U >> 1)) - 1))
<0>[ 167.303811] ---------------------------------
<4>[ 167.304722] ------------[ cut here ]------------
<2>[ 167.304725] kernel BUG at drivers/gpu/drm/i915/gt/intel_engine_pm.c:283!
<4>[ 167.304731] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
<4>[ 167.304734] CPU: 11 PID: 89 Comm: kworker/11:1 Tainted: G W 6.8.0-rc2-CI_DRM_14193-gc655e0fd2804+ #1
<4>[ 167.304736] Hardware name: Intel Corporation Rocket Lake Client Platform/RocketLake S UDIMM 6L RVP, BIOS RKLSFWI1.R00.3173.A03.2204210138 04/21/2022
<4>[ 167.304738] Workqueue: i915-unordered retire_work_handler [i915]
<4>[ 167.304839] RIP: 0010:__engine_park+0x3fd/0x680 [i915]
<4>[ 167.304937] Code: 00 48 c7 c2 b0 e5 86 a0 48 8d 3d 00 00 00 00 e8 79 48 d4 e0 bf 01 00 00 00 e8 ef 0a d4 e0 31 f6 bf 09 00 00 00 e8 03 49 c0 e0 <0f> 0b 0f 0b be 01 00 00 00 e8 f5 61 fd ff 31 c0 e9 34 fd ff ff 48
<4>[ 167.304940] RSP: 0018:ffffc9000059fce0 EFLAGS: 00010246
<4>[ 167.304942] RAX: 0000000000000200 RBX: 0000000000000000 RCX: 0000000000000006
<4>[ 167.304944] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000009
<4>[ 167.304946] RBP: ffff8881330ca1b0 R08: 0000000000000001 R09: 0000000000000001
<4>[ 167.304947] R10: 0000000000000001 R11: 0000000000000001 R12: ffff8881330ca000
<4>[ 167.304948] R13: ffff888110f02aa0 R14: ffff88812d1d0205 R15: ffff88811277d4f0
<4>[ 167.304950] FS: 0000000000000000(0000) GS:ffff88844f780000(0000) knlGS:0000000000000000
<4>[ 167.304952] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4>[ 167.304953] CR2: 00007fc362200c40 CR3: 000000013306e003 CR4: 0000000000770ef0
<4>[ 167.304955] PKRU: 55555554
<4>[ 167.304957] Call Trace:
<4>[ 167.304958] <TASK>
<4>[ 167.305573] ____intel_wakeref_put_last+0x1d/0x80 [i915]
<4>[ 167.305685] i915_request_retire.part.0+0x34f/0x600 [i915]
<4>[ 167.305800] retire_requests+0x51/0x80 [i915]
<4>[ 167.305892] intel_gt_retire_requests_timeout+0x27f/0x700 [i915]
<4>[ 167.305985] process_scheduled_works+0x2db/0x530
<4>[ 167.305990] worker_thread+0x18c/0x350
<4>[ 167.305993] kthread+0xfe/0x130
<4>[ 167.305997] ret_from_fork+0x2c/0x50
<4>[ 167.306001] ret_from_fork_asm+0x1b/0x30
<4>[ 167.306004] </TASK>It is necessary for the queue_priority_hint to be lower than the next request submission upon waking up, as we rely on the hint to decide when to kick the tasklet to submit that first request.
--- drivers/gpu/drm/i915/gt/intel_engine_pm.c | 3 --- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_pm.c +0 -3
@@ -253,9 +253,6 @@ static int __engine_park(struct intel_waintel_engine_park_heartbeat (engine);intel_breadcrumbs_park (engine->breadcrumbs); -/* Must be reset upon idling, or we may miss the busy wakeup. */ -GEM_BUG_ON (engine->sched_engine->queue_priority_hint !=INT_MIN ); -if (engine->park) engine->park (engine);
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +3 -0
@@ -3270,6 +3270,9 @@ static void execlists_park(struct intel_ {cancel_timer (&engine->execlists.timer);cancel_timer (&engine->execlists.preempt); + +/* Reset upon idling, or we may delay the busy wakeup. */ +WRITE_ONCE (engine->sched_engine->queue_priority_hint,INT_MIN ); }static void add_to_engine (struct i915_request *rq)
Greg Kroah-Hartman
maintainerPATCH 230/272 Bluetooth: hci_sync: Fix not checking error on hci_cmd_sync_cancel_sync
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 1c3366abdbe884be62e5a7502b4db758aa3974c6 upstream.
hci_cmd_sync_cancel_sync shall check the error passed to it since it will be propagated using req_result which is __u32 it needs to be properly set to a positive value if it was passed as negative othertise IS_ERR will not trigger as -(errno) would be converted to a positive value.
--- net/bluetooth/hci_core.c | 6 +++--- net/bluetooth/hci_sync.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-)
net/bluetooth/hci_core.c +3 -3
@@ -2838,7 +2838,7 @@ static void hci_cancel_cmd_sync(struct hcancel_delayed_work_sync (&hdev->ncmd_timer);atomic_set (&hdev->cmd_cnt,1 ); -hci_cmd_sync_cancel_sync (hdev, -err); +hci_cmd_sync_cancel_sync (hdev, err); }/* Suspend HCI device */
@@ -2858,7 +2858,7 @@ int hci_suspend_dev(struct hci_dev *hdevreturn 0 ;/* Cancel potentially blocking sync operation before suspend */ -hci_cancel_cmd_sync (hdev, -EHOSTDOWN ); +hci_cancel_cmd_sync (hdev,EHOSTDOWN );hci_req_sync_lock (hdev); ret =hci_suspend_sync (hdev);
@@ -4169,7 +4169,7 @@ static void hci_send_cmd_sync(struct hci err =hci_send_frame (hdev, skb);if (err <0 ) { -hci_cmd_sync_cancel_sync (hdev, err); +hci_cmd_sync_cancel_sync (hdev, -err);return ; }
net/bluetooth/hci_sync.c +4 -1
@@ -678,7 +678,10 @@ void hci_cmd_sync_cancel_sync(struct hcibt_dev_dbg (hdev,"err 0x%2.2x" , err);if (hdev->req_status ==HCI_REQ_PEND ) { - hdev->req_result = err; +/* req_result is __u32 so error must be positive to be properly +* propagated. +*/ + hdev->req_result = err <0 ? -err : err; hdev->req_status =HCI_REQ_CANCELED ;wake_up_interruptible (&hdev->req_wait_q);
Greg Kroah-Hartman
maintainerPATCH 231/272 Revert "usb: phy: generic: Get the vbus supply"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
commit fdada0db0b2ae2addef4ccafe50937874dbeeebe upstream.
This reverts commit 75fd6485cccef269ac9eb3b71cf56753341195ef. This patch was applied twice by accident, causing probe failures. Revert the accident.
--- drivers/usb/phy/phy-generic.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/usb/phy/phy-generic.c +0 -7
@@ -272,13 +272,6 @@ int usb_phy_gen_create_phy(struct devicereturn dev_err_probe (dev,PTR_ERR (nop->vbus_draw),"could not get vbus regulator\n" ); - nop->vbus_draw =devm_regulator_get_exclusive (dev,"vbus" ); -if (PTR_ERR (nop->vbus_draw) == -ENODEV ) - nop->vbus_draw =NULL ; -if (IS_ERR (nop->vbus_draw)) -return dev_err_probe (dev,PTR_ERR (nop->vbus_draw), -"could not get vbus regulator\n" ); - nop->dev = dev; nop->phy.dev = nop->dev; nop->phy.label ="nop-xceiv" ;
Greg Kroah-Hartman
maintainerPATCH 232/272 usb: cdc-wdm: close race between read and workqueue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 339f83612f3a569b194680768b22bf113c26a29d upstream.
wdm_read() cannot race with itself. However, in service_outstanding_interrupt() it can race with the workqueue, which can be triggered by error handling.
Hence we need to make sure that the WDM_RESPONDING flag is not just only set but tested.
--- drivers/usb/class/cdc-wdm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-wdm.c +5 -1
@@ -485,6 +485,7 @@ out_free_mem:static int service_outstanding_interrupt (struct wdm_device *desc) {int rv =0 ; +int used;/* submit read urb only if the device is waiting for it */ if (!desc->resp_count || !--desc->resp_count)
@@ -499,7 +500,10 @@ static int service_outstanding_interrupt goto out; } -set_bit (WDM_RESPONDING , &desc->flags); + used =test_and_set_bit (WDM_RESPONDING , &desc->flags); +if (used) + goto out; +spin_unlock_irq (&desc->iuspin); rv =usb_submit_urb (desc->response,GFP_KERNEL );spin_lock_irq (&desc->iuspin);
Greg Kroah-Hartman
maintainerPATCH 233/272 USB: UAS: return ENODEV when submit urbs fail with device not attached
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weitao Wang <[email protected]>
commit cd5432c712351a3d5f82512908f5febfca946ca6 upstream.
In the scenario of entering hibernation with udisk in the system, if the udisk was gone or resume fail in the thaw phase of hibernation. Its state will be set to NOTATTACHED. At this point, usb_hub_wq was already freezed and can't not handle disconnect event. Next, in the poweroff phase of hibernation, SYNCHRONIZE_CACHE SCSI command will be sent to this udisk when poweroff this scsi device, which will cause uas_submit_urbs to be called to submit URB for sense/data/cmd pipe. However, these URBs will submit fail as device was set to NOTATTACHED state. Then, uas_submit_urbs will return a value SCSI_MLQUEUE_DEVICE_BUSY to the caller. That will lead the SCSI layer go into an ugly loop and system fail to go into hibernation.
On the other hand, when we specially check for -ENODEV in function uas_queuecommand_lck, returning DID_ERROR to SCSI layer will cause device poweroff fail and system shutdown instead of entering hibernation.
To fix this issue, let uas_submit_urbs to return original generic error when submitting URB failed. At the same time, we need to translate -ENODEV to DID_NOT_CONNECT for the SCSI layer.
--- drivers/usb/storage/uas.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/usb/storage/uas.c +13 -15
@@ -533,7 +533,7 @@ static struct urb *uas_alloc_cmd_urb(str* daft to me. */ -static struct urb *uas_submit_sense_urb (struct scsi_cmnd *cmnd,gfp_t gfp) +static int uas_submit_sense_urb (struct scsi_cmnd *cmnd,gfp_t gfp) {struct uas_dev_info *devinfo = cmnd->device->hostdata;struct urb *urb;
@@ -541,30 +541,28 @@ static struct urb *uas_submit_sense_urb( urb =uas_alloc_sense_urb (devinfo, gfp, cmnd);if (!urb) -return NULL ; +return -ENOMEM ;usb_anchor_urb (urb, &devinfo->sense_urbs); err =usb_submit_urb (urb, gfp);if (err) {usb_unanchor_urb (urb);uas_log_cmd_state (cmnd,"sense submit err" , err);usb_free_urb (urb); -return NULL ; } -return urb; +return err; }static int uas_submit_urbs (struct scsi_cmnd *cmnd,struct uas_dev_info *devinfo) {struct uas_cmd_info *cmdinfo =scsi_cmd_priv (cmnd); -struct urb *urb;int err;lockdep_assert_held (&devinfo->lock);if (cmdinfo->state &SUBMIT_STATUS_URB ) { - urb =uas_submit_sense_urb (cmnd,GFP_ATOMIC ); -if (!urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; + err =uas_submit_sense_urb (cmnd,GFP_ATOMIC ); +if (err) +return err; cmdinfo->state &= ~SUBMIT_STATUS_URB ; }
@@ -572,7 +570,7 @@ static int uas_submit_urbs(struct scsi_c cmdinfo->data_in_urb =uas_alloc_data_urb (devinfo,GFP_ATOMIC , cmnd,DMA_FROM_DEVICE );if (!cmdinfo->data_in_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_DATA_IN_URB ; }
@@ -582,7 +580,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->data_in_urb);uas_log_cmd_state (cmnd,"data in submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->state &= ~SUBMIT_DATA_IN_URB ; cmdinfo->state |=DATA_IN_URB_INFLIGHT ;
@@ -592,7 +590,7 @@ static int uas_submit_urbs(struct scsi_c cmdinfo->data_out_urb =uas_alloc_data_urb (devinfo,GFP_ATOMIC , cmnd,DMA_TO_DEVICE );if (!cmdinfo->data_out_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_DATA_OUT_URB ; }
@@ -602,7 +600,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->data_out_urb);uas_log_cmd_state (cmnd,"data out submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->state &= ~SUBMIT_DATA_OUT_URB ; cmdinfo->state |=DATA_OUT_URB_INFLIGHT ;
@@ -611,7 +609,7 @@ static int uas_submit_urbs(struct scsi_cif (cmdinfo->state &ALLOC_CMD_URB ) { cmdinfo->cmd_urb =uas_alloc_cmd_urb (devinfo,GFP_ATOMIC , cmnd);if (!cmdinfo->cmd_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_CMD_URB ; }
@@ -621,7 +619,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->cmd_urb);uas_log_cmd_state (cmnd,"cmd submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->cmd_urb =NULL ; cmdinfo->state &= ~SUBMIT_CMD_URB ;
@@ -698,7 +696,7 @@ static int uas_queuecommand_lck(struct s* of queueing, no matter how fatal the error */ if (err == -ENODEV ) { -set_host_byte (cmnd,DID_ERROR ); +set_host_byte (cmnd,DID_NO_CONNECT );scsi_done (cmnd); goto zombie; }
Greg Kroah-Hartman
maintainerPATCH 234/272 usb: dwc3-am62: Rename private data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ladislav Michl <[email protected]>
[ Upstream commit 3609699c32aa4f2710a6fe2b21afc6a9a3c66bc5 ]
Rename dwc3_data to dwc3_am62 to make it consistent with other glue drivers, it's clearer that this is am62's specific. While there, do the same for data variable.
Stable-dep-of: 6661befe4100 ("usb: dwc3-am62: fix module unload/reload behavior")
--- drivers/usb/dwc3/dwc3-am62.c | 80 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-)
drivers/usb/dwc3/dwc3-am62.c +40 -40
@@ -89,7 +89,7 @@#define DWC3_AM62_AUTOSUSPEND_DELAY 100 -struct dwc3_data { +struct dwc3_am62 {struct device *dev;void __iomem *usbss;struct clk *usb2_refclk;
@@ -115,19 +115,19 @@ static const int dwc3_ti_rate_table[] = { /* in KHZ */ 52000, }; -static inline u32 dwc3_ti_readl (struct dwc3_data *data,u32 offset) +static inline u32 dwc3_ti_readl (struct dwc3_am62 *am62,u32 offset) { -return readl ((data->usbss) + offset); +return readl ((am62->usbss) + offset); } -static inline void dwc3_ti_writel (struct dwc3_data *data,u32 offset,u32 value) +static inline void dwc3_ti_writel (struct dwc3_am62 *am62,u32 offset,u32 value) { -writel (value, (data->usbss) + offset); +writel (value, (am62->usbss) + offset); } -static int phy_syscon_pll_refclk (struct dwc3_data *data) +static int phy_syscon_pll_refclk (struct dwc3_am62 *am62) { -struct device *dev = data->dev; +struct device *dev = am62->dev;struct device_node *node = dev->of_node;struct of_phandle_args args;struct regmap *syscon;
@@ -139,16 +139,16 @@ static int phy_syscon_pll_refclk(struct dwc3_data *data)return PTR_ERR (syscon); } - data->syscon = syscon; + am62->syscon = syscon; ret =of_parse_phandle_with_fixed_args (node,"ti,syscon-phy-pll-refclk" ,1 ,0 , &args);if (ret)return ret; - data->offset = args.args[0 ]; + am62->offset = args.args[0 ]; - ret =regmap_update_bits (data->syscon, data->offset,PHY_PLL_REFCLK_MASK , data->rate_code); + ret =regmap_update_bits (am62->syscon, am62->offset,PHY_PLL_REFCLK_MASK , am62->rate_code);if (ret) {dev_err (dev,"failed to set phy pll reference clock rate\n" );return ret;
@@ -161,32 +161,32 @@ static int dwc3_ti_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct device_node *node = pdev->dev.of_node; -struct dwc3_data *data; +struct dwc3_am62 *am62;int i, ret;unsigned long rate;u32 reg; - data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); -if (!data) + am62 =devm_kzalloc (dev,sizeof (*am62),GFP_KERNEL ); +if (!am62)return -ENOMEM ; - data->dev = dev; -platform_set_drvdata (pdev, data); + am62->dev = dev; +platform_set_drvdata (pdev, am62); - data->usbss =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (data->usbss)) { + am62->usbss =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (am62->usbss)) {dev_err (dev,"can't map IOMEM resource\n" ); -return PTR_ERR (data->usbss); +return PTR_ERR (am62->usbss); } - data->usb2_refclk =devm_clk_get (dev,"ref" ); -if (IS_ERR (data->usb2_refclk)) { + am62->usb2_refclk =devm_clk_get (dev,"ref" ); +if (IS_ERR (am62->usb2_refclk)) {dev_err (dev,"can't get usb2_refclk\n" ); -return PTR_ERR (data->usb2_refclk); +return PTR_ERR (am62->usb2_refclk); }/* Calculate the rate code */ - rate =clk_get_rate (data->usb2_refclk); + rate =clk_get_rate (am62->usb2_refclk); rate /=1000 ;// To KHz for (i =0 ; i <ARRAY_SIZE (dwc3_ti_rate_table); i++) {if (dwc3_ti_rate_table[i] == rate)
@@ -198,20 +198,20 @@ static int dwc3_ti_probe(struct platform_device *pdev)return -EINVAL ; } - data->rate_code = i; + am62->rate_code = i;/* Read the syscon property and set the rate code */ - ret =phy_syscon_pll_refclk (data); + ret =phy_syscon_pll_refclk (am62);if (ret)return ret;/* VBUS divider select */ - data->vbus_divider =device_property_read_bool (dev,"ti,vbus-divider" ); - reg =dwc3_ti_readl (data,USBSS_PHY_CONFIG ); -if (data->vbus_divider) + am62->vbus_divider =device_property_read_bool (dev,"ti,vbus-divider" ); + reg =dwc3_ti_readl (am62,USBSS_PHY_CONFIG ); +if (am62->vbus_divider) reg |=1 <<USBSS_PHY_VBUS_SEL_SHIFT ; -dwc3_ti_writel (data,USBSS_PHY_CONFIG , reg); +dwc3_ti_writel (am62,USBSS_PHY_CONFIG , reg);pm_runtime_set_active (dev);pm_runtime_enable (dev);
@@ -219,7 +219,7 @@ static int dwc3_ti_probe(struct platform_device *pdev)* Don't ignore its dependencies with its children */ pm_suspend_ignore_children (dev, false); -clk_prepare_enable (data->usb2_refclk); +clk_prepare_enable (am62->usb2_refclk);pm_runtime_get_noresume (dev); ret =of_platform_populate (node,NULL ,NULL , dev);
@@ -229,9 +229,9 @@ static int dwc3_ti_probe(struct platform_device *pdev) }/* Set mode valid bit to indicate role is valid */ - reg =dwc3_ti_readl (data,USBSS_MODE_CONTROL ); + reg =dwc3_ti_readl (am62,USBSS_MODE_CONTROL ); reg |=USBSS_MODE_VALID ; -dwc3_ti_writel (data,USBSS_MODE_CONTROL , reg); +dwc3_ti_writel (am62,USBSS_MODE_CONTROL , reg);/* Setting up autosuspend */ pm_runtime_set_autosuspend_delay (dev,DWC3_AM62_AUTOSUSPEND_DELAY );
@@ -241,7 +241,7 @@ static int dwc3_ti_probe(struct platform_device *pdev)return 0 ; err_pm_disable: -clk_disable_unprepare (data->usb2_refclk); +clk_disable_unprepare (am62->usb2_refclk);pm_runtime_disable (dev);pm_runtime_set_suspended (dev);return ret;
@@ -258,18 +258,18 @@ static int dwc3_ti_remove_core(struct device *dev, void *c)static int dwc3_ti_remove (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct dwc3_data *data =platform_get_drvdata (pdev); +struct dwc3_am62 *am62 =platform_get_drvdata (pdev);u32 reg;device_for_each_child (dev,NULL , dwc3_ti_remove_core);/* Clear mode valid bit */ - reg =dwc3_ti_readl (data,USBSS_MODE_CONTROL ); + reg =dwc3_ti_readl (am62,USBSS_MODE_CONTROL ); reg &= ~USBSS_MODE_VALID ; -dwc3_ti_writel (data,USBSS_MODE_CONTROL , reg); +dwc3_ti_writel (am62,USBSS_MODE_CONTROL , reg);pm_runtime_put_sync (dev); -clk_disable_unprepare (data->usb2_refclk); +clk_disable_unprepare (am62->usb2_refclk);pm_runtime_disable (dev);pm_runtime_set_suspended (dev);
@@ -280,18 +280,18 @@ static int dwc3_ti_remove(struct platform_device *pdev)#ifdef CONFIG_PM static int dwc3_ti_suspend_common (struct device *dev) { -struct dwc3_data *data =dev_get_drvdata (dev); +struct dwc3_am62 *am62 =dev_get_drvdata (dev); -clk_disable_unprepare (data->usb2_refclk); +clk_disable_unprepare (am62->usb2_refclk);return 0 ; }static int dwc3_ti_resume_common (struct device *dev) { -struct dwc3_data *data =dev_get_drvdata (dev); +struct dwc3_am62 *am62 =dev_get_drvdata (dev); -clk_prepare_enable (data->usb2_refclk); +clk_prepare_enable (am62->usb2_refclk);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 235/272 usb: dwc3-am62: fix module unload/reload behavior
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Quadros <[email protected]>
[ Upstream commit 6661befe41009c210efa2c1bcd16a5cc4cff8a06 ]
As runtime PM is enabled, the module can be runtime suspended when .remove() is called.
Do a pm_runtime_get_sync() to make sure module is active before doing any register operations.
Doing a pm_runtime_put_sync() should disable the refclk so no need to disable it again.
Fixes the below warning at module removel.
[ 39.705310] ------------[ cut here ]------------ [ 39.710004] clk:162:3 already disabled [ 39.713941] WARNING: CPU: 0 PID: 921 at drivers/clk/clk.c:1090 clk_core_disable+0xb0/0xb8
We called of_platform_populate() in .probe() so call the cleanup function of_platform_depopulate() in .remove(). Get rid of the now unnnecessary dwc3_ti_remove_core(). Without this, module re-load doesn't work properly.
--- drivers/usb/dwc3/dwc3-am62.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/usb/dwc3/dwc3-am62.c +2 -10
@@ -247,21 +247,14 @@ static int dwc3_ti_probe(struct platform_device *pdev)return ret; } -static int dwc3_ti_remove_core (struct device *dev,void *c) -{ -struct platform_device *pdev =to_platform_device (dev); - -platform_device_unregister (pdev); -return 0 ; -} -static int dwc3_ti_remove (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct dwc3_am62 *am62 =platform_get_drvdata (pdev);u32 reg; -device_for_each_child (dev,NULL , dwc3_ti_remove_core); +pm_runtime_get_sync (dev); +of_platform_depopulate (dev);/* Clear mode valid bit */ reg =dwc3_ti_readl (am62,USBSS_MODE_CONTROL );
@@ -269,7 +262,6 @@ static int dwc3_ti_remove(struct platform_device *pdev)dwc3_ti_writel (am62,USBSS_MODE_CONTROL , reg);pm_runtime_put_sync (dev); -clk_disable_unprepare (am62->usb2_refclk);pm_runtime_disable (dev);pm_runtime_set_suspended (dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 236/272 ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 051e0840ffa8ab25554d6b14b62c9ab9e4901457 upstream.
The dreamcastcard->timer could schedule the spu_dma_work and the spu_dma_work could also arm the dreamcastcard->timer.
When the snd_pcm_substream is closing, the aica_channel will be deallocated. But it could still be dereferenced in the worker thread. The reason is that del_timer() will return directly regardless of whether the timer handler is running or not and the worker could be rescheduled in the timer handler. As a result, the UAF bug will happen. The racy situation is shown below:
(Thread 1) | (Thread 2)
snd_aicapcm_pcm_close() |
... | run_spu_dma() //worker
| mod_timer()
flush_work() |
del_timer() | aica_period_elapsed() //timer
kfree(dreamcastcard->channel) | schedule_work()
| run_spu_dma() //worker
... | dreamcastcard->channel-> //USEIn order to mitigate this bug and other possible corner cases, call mod_timer() conditionally in run_spu_dma(), then implement PCM sync_stop op to cancel both the timer and worker. The sync_stop op will be called from PCM core appropriately when needed.
Message-ID: <[email protected]>
--- sound/sh/aica.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
sound/sh/aica.c +14 -3
@@ -278,7 +278,8 @@ static void run_spu_dma(struct work_stru dreamcastcard->clicks++;if (unlikely (dreamcastcard->clicks >=AICA_PERIOD_NUMBER )) dreamcastcard->clicks %=AICA_PERIOD_NUMBER ; -mod_timer (&dreamcastcard->timer, jiffies +1 ); +if (snd_pcm_running (dreamcastcard->substream)) +mod_timer (&dreamcastcard->timer, jiffies +1 ); } }
@@ -290,6 +291,8 @@ static void aica_period_elapsed(struct t/*timer function - so cannot sleep */ int play_period;struct snd_pcm_runtime *runtime; +if (!snd_pcm_running (substream)) +return ; runtime = substream->runtime; dreamcastcard = substream->pcm->private_data;/* Have we played out an additional period? */
@@ -350,12 +353,19 @@ static int snd_aicapcm_pcm_open(struct sreturn 0 ; } +static int snd_aicapcm_pcm_sync_stop (struct snd_pcm_substream *substream) +{ +struct snd_card_aica *dreamcastcard = substream->pcm->private_data; + +del_timer_sync (&dreamcastcard->timer); +cancel_work_sync (&dreamcastcard->spu_dma_work); +return 0 ; +} +static int snd_aicapcm_pcm_close (struct snd_pcm_substream *substream) {struct snd_card_aica *dreamcastcard = substream->pcm->private_data; -flush_work (&(dreamcastcard->spu_dma_work)); -del_timer (&dreamcastcard->timer); dreamcastcard->substream =NULL ;kfree (dreamcastcard->channel);spu_disable ();
@@ -401,6 +411,7 @@ static const struct snd_pcm_ops snd_aica .prepare = snd_aicapcm_pcm_prepare, .trigger = snd_aicapcm_pcm_trigger, .pointer = snd_aicapcm_pcm_pointer, + .sync_stop = snd_aicapcm_pcm_sync_stop, };/* TO DO: set up to handle more than one pcm instance */
Greg Kroah-Hartman
maintainerPATCH 237/272 scsi: core: Fix unremoved procfs host directory regression
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guilherme G. Piccoli <[email protected]>
commit f23a4d6e07570826fe95023ca1aa96a011fa9f84 upstream.
Commit fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier") fixed a bug related to modules loading/unloading, by adding a call to scsi_proc_hostdir_rm() on scsi_remove_host(). But that led to a potential duplicate call to the hostdir_rm() routine, since it's also called from scsi_host_dev_release(). That triggered a regression report, which was then fixed by commit be03df3d4bfe ("scsi: core: Fix a procfs host directory removal regression"). The fix just dropped the hostdir_rm() call from dev_release().
But it happens that this proc directory is created on scsi_host_alloc(), and that function "pairs" with scsi_host_dev_release(), while scsi_remove_host() pairs with scsi_add_host(). In other words, it seems the reason for removing the proc directory on dev_release() was meant to cover cases in which a SCSI host structure was allocated, but the call to scsi_add_host() didn't happen. And that pattern happens to exist in some error paths, for example.
Syzkaller causes that by using USB raw gadget device, error'ing on usb-storage driver, at usb_stor_probe2(). By checking that path, we can see that the BadDevice label leads to a scsi_host_put() after a SCSI host allocation, but there's no call to scsi_add_host() in such path. That leads to messages like this in dmesg (and a leak of the SCSI host proc structure):
usb-storage 4-1:87.51: USB Mass Storage device detected proc_dir_entry 'scsi/usb-storage' already registered
WARNING: CPU: 1 PID: 3519 at fs/proc/generic.c:377 proc_register+0x347/0x4e0 fs/proc/generic.c:376
The proper fix seems to still call scsi_proc_hostdir_rm() on dev_release(), but guard that with the state check for SHOST_CREATED; there is even a comment in scsi_host_dev_release() detailing that: such conditional is meant for cases where the SCSI host was allocated but there was no calls to {add,remove}_host(), like the usb-storage case.
This is what we propose here and with that, the error path of usb-storage does not trigger the warning anymore.
--- drivers/scsi/hosts.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/hosts.c +4 -3
@@ -353,12 +353,13 @@ static void scsi_host_dev_release(structif (shost->shost_state ==SHOST_CREATED ) {/* -* Free the shost_dev device name here if scsi_host_alloc() -* and scsi_host_put() have been called but neither +* Free the shost_dev device name and remove the proc host dir +* here if scsi_host_{alloc,put}() have been called but neither * scsi_host_add() nor scsi_host_remove() has been called. * This avoids that the memory allocated for the shost_dev -* name is leaked. +* name as well as the proc dir structure are leaked. */ +scsi_proc_hostdir_rm (shost->hostt);kfree (dev_name (&shost->shost_dev)); }
Greg Kroah-Hartman
maintainerPATCH 238/272 staging: vc04_services: changen strncpy() to strscpy_pad()
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 ef25725b7f8aaffd7756974d3246ec44fae0a5cf upstream.
gcc-14 warns about this strncpy() that results in a non-terminated string for an overflow:
In file included from include/linux/string.h:369,
from drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:20:
In function 'strncpy',
inlined from 'create_component' at drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:940:2:include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' specified bound 128 equals destination size [-Werror=stringop-truncation]
Change it to strscpy_pad(), which produces a properly terminated and zero-padded string.
--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +2 -2
@@ -938,8 +938,8 @@ static int create_component(struct vchiq/* build component create message */ m.h.type =MMAL_MSG_TYPE_COMPONENT_CREATE ; m.u.component_create.client_component = component->client_component; -strncpy (m.u.component_create.name, name, -sizeof (m.u.component_create.name)); +strscpy_pad (m.u.component_create.name, name, +sizeof (m.u.component_create.name)); ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),
Greg Kroah-Hartman
maintainerPATCH 239/272 staging: vc04_services: fix information leak in create_component()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit f37e76abd614b68987abc8e5c22d986013349771 upstream.
The m.u.component_create.pid field is for debugging and in the mainline kernel it's not used anything. However, it still needs to be set to something to prevent disclosing uninitialized stack data. Set it to zero.
--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +1 -0
@@ -940,6 +940,7 @@ static int create_component(struct vchiq m.u.component_create.client_component = component->client_component;strscpy_pad (m.u.component_create.name, name,sizeof (m.u.component_create.name)); + m.u.component_create.pid =0 ; ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),
Greg Kroah-Hartman
maintainerPATCH 240/272 USB: core: Add hub_get() and hub_put() routines
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit ee113b860aa169e9a4d2c167c95d0f1961c6e1b8 upstream.
Create hub_get() and hub_put() routines to encapsulate the kref_get() and kref_put() calls in hub.c. The new routines will be used by the next patch in this series.
--- drivers/usb/core/hub.c | 23 ++++++++++++++++------- drivers/usb/core/hub.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-)
drivers/usb/core/hub.c +16 -7
@@ -123,7 +123,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rws#define HUB_DEBOUNCE_STEP 25#define HUB_DEBOUNCE_STABLE 100 -static void hub_release (struct kref *kref);static int usb_reset_and_verify_device (struct usb_device *udev);static int hub_port_disable (struct usb_hub *hub,int port1,int set_state); static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
@@ -685,14 +684,14 @@ static void kick_hub_wq(struct usb_hub **/ intf =to_usb_interface (hub->intfdev);usb_autopm_get_interface_no_resume (intf); -kref_get (&hub->kref); +hub_get (hub);if (queue_work (hub_wq, &hub->events))return ;/* the work has already been scheduled */ usb_autopm_put_interface_async (intf); -kref_put (&hub->kref, hub_release); +hub_put (hub); }void usb_kick_hub_wq (struct usb_device *hdev)
@@ -1060,7 +1059,7 @@ static void hub_activate(struct usb_hub goto init2; goto init3; } -kref_get (&hub->kref); +hub_get (hub);/* The superspeed hub except for root hub has to use Hub Depth * value as an offset into the route string to locate the bits
@@ -1308,7 +1307,7 @@ static void hub_activate(struct usb_hubdevice_unlock (&hdev->dev); } -kref_put (&hub->kref, hub_release); +hub_put (hub); }/* Implement the continuations for the delays above */
@@ -1724,6 +1723,16 @@ static void hub_release(struct kref *krekfree (hub); } +void hub_get (struct usb_hub *hub) +{ +kref_get (&hub->kref); +} + +void hub_put (struct usb_hub *hub) +{ +kref_put (&hub->kref, hub_release); +} +static unsigned highspeed_hubs;static void hub_disconnect (struct usb_interface *intf)
@@ -1772,7 +1781,7 @@ static void hub_disconnect(struct usb_inonboard_hub_destroy_pdevs (&hub->onboard_hub_devs); -kref_put (&hub->kref, hub_release); +hub_put (hub); }static bool hub_descriptor_is_sane (struct usb_host_interface *desc)
@@ -5874,7 +5883,7 @@ out_hdev_lock:/* Balance the stuff in kick_hub_wq() and allow autosuspend */ usb_autopm_put_interface (intf); -kref_put (&hub->kref, hub_release); +hub_put (hub);kcov_remote_stop (); }
drivers/usb/core/hub.h +2 -0
@@ -118,6 +118,8 @@ extern void usb_hub_remove_port_device(sextern int usb_hub_set_port_power (struct usb_device *hdev,struct usb_hub *hub,int port1,bool set);extern struct usb_hub *usb_hub_to_struct_hub (struct usb_device *hdev); +extern void hub_get (struct usb_hub *hub); +extern void hub_put (struct usb_hub *hub);extern int hub_port_debounce (struct usb_hub *hub,int port1,bool must_be_connected); extern int usb_clear_port_feature(struct usb_device *hdev,
Greg Kroah-Hartman
maintainerPATCH 241/272 USB: core: Fix deadlock in port "disable" sysfs attribute
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit f4d1960764d8a70318b02f15203a1be2b2554ca1 upstream.
The show and store callback routines for the "disable" sysfs attribute file in port.c acquire the device lock for the port's parent hub device. This can cause problems if another process has locked the hub to remove it or change its configuration:
Removing the hub or changing its configuration requires the hub interface to be removed, which requires the port device to be removed, and device_del() waits until all outstanding sysfs attribute callbacks for the ports have returned. The lock can't be released until then.
But the disable_show() or disable_store() routine can't return until after it has acquired the lock.
The resulting deadlock can be avoided by calling sysfs_break_active_protection(). This will cause the sysfs core not to wait for the attribute's callback routine to return, allowing the removal to proceed. The disadvantage is that after making this call, there is no guarantee that the hub structure won't be deallocated at any moment. To prevent this, we have to acquire a reference to it first by calling hub_get().
--- drivers/usb/core/port.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-)
drivers/usb/core/port.c +34 -4
@@ -28,11 +28,22 @@ static ssize_t disable_show(struct devicu16 portstatus, unused;bool disabled;int rc; +struct kernfs_node *kn; +hub_get (hub); rc =usb_autopm_get_interface (intf);if (rc <0 ) -return rc; + goto out_hub_get; +/* +* Prevent deadlock if another process is concurrently +* trying to unregister hdev. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) { + rc = -ENODEV ; + goto out_autopm; + }usb_lock_device (hdev);if (hub->disconnected) { rc = -ENODEV ;
@@ -42,9 +53,13 @@ static ssize_t disable_show(struct devicusb_hub_port_status (hub, port1, &portstatus, &unused); disabled = !usb_port_is_power_on (hub, portstatus); -out_hdev_lock: + out_hdev_lock:usb_unlock_device (hdev); +sysfs_unbreak_active_protection (kn); + out_autopm:usb_autopm_put_interface (intf); + out_hub_get: +hub_put (hub);if (rc)return rc;
@@ -62,15 +77,26 @@ static ssize_t disable_store(struct deviint port1 = port_dev->portnum;bool disabled;int rc; +struct kernfs_node *kn; rc =strtobool (buf, &disabled);if (rc)return rc; +hub_get (hub); rc =usb_autopm_get_interface (intf);if (rc <0 ) -return rc; + goto out_hub_get; +/* +* Prevent deadlock if another process is concurrently +* trying to unregister hdev. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) { + rc = -ENODEV ; + goto out_autopm; + }usb_lock_device (hdev);if (hub->disconnected) { rc = -ENODEV ;
@@ -91,9 +117,13 @@ static ssize_t disable_store(struct deviif (!rc) rc = count; -out_hdev_lock: + out_hdev_lock:usb_unlock_device (hdev); +sysfs_unbreak_active_protection (kn); + out_autopm:usb_autopm_put_interface (intf); + out_hub_get: +hub_put (hub);return rc; }
Greg Kroah-Hartman
maintainerPATCH 242/272 scsi: sd: Fix TCG OPAL unlock on system resume
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 0c76106cb97548810214def8ee22700bbbb90543 upstream.
Commit 3cc2ffe5c16d ("scsi: sd: Differentiate system and runtime start/stop management") introduced the manage_system_start_stop scsi_device flag to allow libata to indicate to the SCSI disk driver that nothing should be done when resuming a disk on system resume. This change turned the execution of sd_resume() into a no-op for ATA devices on system resume. While this solved deadlock issues during device resume, this change also wrongly removed the execution of opal_unlock_from_suspend(). As a result, devices with TCG OPAL locking enabled remain locked and inaccessible after a system resume from sleep.
To fix this issue, introduce the SCSI driver resume method and implement it with the sd_resume() function calling opal_unlock_from_suspend(). The former sd_resume() function is renamed to sd_resume_common() and modified to call the new sd_resume() function. For non-ATA devices, this result in no functional changes.
In order for libata to explicitly execute sd_resume() when a device is resumed during system restart, the function scsi_resume_device() is introduced. libata calls this function from the revalidation work executed on devie resume, a state that is indicated with the new device flag ATA_DFLAG_RESUMING. Doing so, locked TCG OPAL enabled devices are unlocked on resume, allowing normal operation.
--- drivers/ata/libata-eh.c | 5 ++++- drivers/ata/libata-scsi.c | 9 +++++++++ drivers/scsi/scsi_scan.c | 34 ++++++++++++++++++++++++++++++++++ drivers/scsi/sd.c | 25 +++++++++++++++++++++---- include/linux/libata.h | 1 + include/scsi/scsi_driver.h | 1 + include/scsi/scsi_host.h | 1 + 7 files changed, 71 insertions(+), 5 deletions(-)
drivers/ata/libata-eh.c +4 -1
@@ -711,8 +711,10 @@ void ata_scsi_port_error_handler(struct ehc->saved_ncq_enabled |=1 << devno;/* If we are resuming, wake up the device */ -if (ap->pflags &ATA_PFLAG_RESUMING ) +if (ap->pflags &ATA_PFLAG_RESUMING ) { + dev->flags |=ATA_DFLAG_RESUMING ; ehc->i.dev_action[devno] |=ATA_EH_SET_ACTIVE ; + } } }
@@ -3089,6 +3091,7 @@ static int ata_eh_revalidate_and_attach(return 0 ; err: + dev->flags &= ~ATA_DFLAG_RESUMING ; *r_failed_dev = dev;return rc; }
drivers/ata/libata-scsi.c +9 -0
@@ -4652,6 +4652,7 @@ void ata_scsi_dev_rescan(struct work_strstruct ata_link *link;struct ata_device *dev;unsigned long flags; +bool do_resume;int ret =0 ;mutex_lock (&ap->scsi_scan_mutex);
@@ -4673,7 +4674,15 @@ void ata_scsi_dev_rescan(struct work_strif (scsi_device_get (sdev))continue ; + do_resume = dev->flags &ATA_DFLAG_RESUMING ; +spin_unlock_irqrestore (ap->lock, flags); +if (do_resume) { + ret =scsi_resume_device (sdev); +if (ret == -EWOULDBLOCK ) + goto unlock; + dev->flags &= ~ATA_DFLAG_RESUMING ; + } ret =scsi_rescan_device (sdev);scsi_device_put (sdev);spin_lock_irqsave (ap->lock, flags);
drivers/scsi/scsi_scan.c +34 -0
@@ -1611,6 +1611,40 @@ int scsi_add_device(struct Scsi_Host *ho }EXPORT_SYMBOL (scsi_add_device); +int scsi_resume_device (struct scsi_device *sdev) +{ +struct device *dev = &sdev->sdev_gendev; +int ret =0 ; + +device_lock (dev); + +/* +* Bail out if the device or its queue are not running. Otherwise, +* the rescan may block waiting for commands to be executed, with us +* holding the device lock. This can result in a potential deadlock +* in the power management core code when system resume is on-going. +*/ +if (sdev->sdev_state !=SDEV_RUNNING || +blk_queue_pm_only (sdev->request_queue)) { + ret = -EWOULDBLOCK ; + goto unlock; + } + +if (dev->driver &&try_module_get (dev->driver->owner)) { +struct scsi_driver *drv =to_scsi_driver (dev->driver); + +if (drv->resume) + ret = drv->resume (dev); +module_put (dev->driver->owner); + } + +unlock: +device_unlock (dev); + +return ret; +} +EXPORT_SYMBOL (scsi_resume_device); +int scsi_rescan_device (struct scsi_device *sdev) {struct device *dev = &sdev->sdev_gendev;
drivers/scsi/sd.c +21 -4
@@ -110,6 +110,7 @@ static int sd_suspend_system(struct devistatic int sd_suspend_runtime (struct device *);static int sd_resume_system (struct device *);static int sd_resume_runtime (struct device *); +static int sd_resume (struct device *);static void sd_rescan (struct device *);static blk_status_t sd_init_command (struct scsi_cmnd *SCpnt);static void sd_uninit_command (struct scsi_cmnd *SCpnt);
@@ -691,6 +692,7 @@ static struct scsi_driver sd_template = .pm = &sd_pm_ops, }, .rescan = sd_rescan, + .resume = sd_resume, .init_command = sd_init_command, .uninit_command = sd_uninit_command, .done = sd_done,
@@ -3830,7 +3832,22 @@ static int sd_suspend_runtime(struct devreturn sd_suspend_common (dev, true); } -static int sd_resume (struct device *dev,bool runtime) +static int sd_resume (struct device *dev) +{ +struct scsi_disk *sdkp =dev_get_drvdata (dev); + +if (sdkp->device->no_start_on_resume) +sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); + +if (opal_unlock_from_suspend (sdkp->opal_dev)) { +sd_printk (KERN_NOTICE , sdkp,"OPAL unlock failed\n" ); +return -EIO ; + } + +return 0 ; +} + +static int sd_resume_common (struct device *dev,bool runtime) {struct scsi_disk *sdkp =dev_get_drvdata (dev);int ret =0 ;
@@ -3849,7 +3866,7 @@ static int sd_resume(struct device *dev, }if (!ret) { -opal_unlock_from_suspend (sdkp->opal_dev); +sd_resume (dev); sdkp->suspended = false; }
@@ -3868,7 +3885,7 @@ static int sd_resume_system(struct devicreturn 0 ; } -return sd_resume (dev, false); +return sd_resume_common (dev, false); }static int sd_resume_runtime (struct device *dev)
@@ -3892,7 +3909,7 @@ static int sd_resume_runtime(struct devi "Failed to clear sense data\n"); } -return sd_resume (dev, true); +return sd_resume_common (dev, true); }/**
include/linux/libata.h +1 -0
@@ -102,6 +102,7 @@ enum {ATA_DFLAG_NCQ_SEND_RECV = (1 <<19 ),/* device supports NCQ SEND and RECV */ ATA_DFLAG_NCQ_PRIO = (1 <<20 ),/* device supports NCQ priority */ ATA_DFLAG_NCQ_PRIO_ENABLED = (1 <<21 ),/* Priority cmds sent to dev */ +ATA_DFLAG_RESUMING = (1 <<22 ),/* Device is resuming */ ATA_DFLAG_INIT_MASK = (1 <<24 ) -1 , ATA_DFLAG_DETACH = (1 << 24),
include/scsi/scsi_driver.h +1 -0
@@ -12,6 +12,7 @@ struct request;struct scsi_driver {struct device_driver gendrv; +int (*resume)(struct device *);void (*rescan)(struct device *);blk_status_t (*init_command)(struct scsi_cmnd *);void (*uninit_command)(struct scsi_cmnd *);
include/scsi/scsi_host.h +1 -0
@@ -752,6 +752,7 @@ extern int __must_check scsi_add_host_wi struct device *, struct device *);extern void scsi_scan_host (struct Scsi_Host *); +extern int scsi_resume_device (struct scsi_device *sdev);extern int scsi_rescan_device (struct scsi_device *sdev);extern void scsi_remove_host (struct Scsi_Host *);extern struct Scsi_Host *scsi_host_get (struct Scsi_Host *);
Greg Kroah-Hartman
maintainerPATCH 243/272 usb: dwc2: host: Fix remote wakeup from hibernation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit bae2bc73a59c200db53b6c15fb26bb758e2c6108 upstream.
Starting from core v4.30a changed order of programming GPWRDN_PMUACTV to 0 in case of exit from hibernation on remote wakeup signaling from device.
--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/hcd.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/usb/dwc2/core.h +1 -0
@@ -1084,6 +1084,7 @@ struct dwc2_hsotg {bool needs_byte_swap;/* DWC OTG HW Release versions */ +#define DWC2_CORE_REV_4_30a 0x4f54430a#define DWC2_CORE_REV_2_71a 0x4f54271a#define DWC2_CORE_REV_2_72a 0x4f54272a#define DWC2_CORE_REV_2_80a 0x4f54280a
drivers/usb/dwc2/hcd.c +13 -4
@@ -5610,10 +5610,12 @@ int dwc2_host_exit_hibernation(struct dwdwc2_writel (hsotg, hr->hcfg,HCFG );/* De-assert Wakeup Logic */ - gpwrdn =dwc2_readl (hsotg,GPWRDN ); - gpwrdn &= ~GPWRDN_PMUACTV ; -dwc2_writel (hsotg, gpwrdn,GPWRDN ); -udelay (10 ); +if (!(rem_wakeup && hsotg->hw_params.snpsid >= DWC2_CORE_REV_4_30a)) { + gpwrdn =dwc2_readl (hsotg,GPWRDN ); + gpwrdn &= ~GPWRDN_PMUACTV ; +dwc2_writel (hsotg, gpwrdn,GPWRDN ); +udelay (10 ); + } hprt0 = hr->hprt0; hprt0 |=HPRT0_PWR ;
@@ -5638,6 +5640,13 @@ int dwc2_host_exit_hibernation(struct dw hprt0 |=HPRT0_RES ;dwc2_writel (hsotg, hprt0,HPRT0 ); +/* De-assert Wakeup Logic */ +if ((rem_wakeup && hsotg->hw_params.snpsid >= DWC2_CORE_REV_4_30a)) { + gpwrdn =dwc2_readl (hsotg,GPWRDN ); + gpwrdn &= ~GPWRDN_PMUACTV ; +dwc2_writel (hsotg, gpwrdn,GPWRDN ); +udelay (10 ); + }/* Wait for Resume time and then program HPRT again */ mdelay (100 ); hprt0 &= ~HPRT0_RES ;
Greg Kroah-Hartman
maintainerPATCH 244/272 usb: dwc2: host: Fix hibernation flow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 3c7b9856a82227db01a20171d2e24c7ce305d59b upstream.
Added to backup/restore registers HFLBADDR, HCCHARi, HCSPLTi, HCTSIZi, HCDMAi and HCDMABi.
--- drivers/usb/dwc2/core.h | 12 ++++++++++++ drivers/usb/dwc2/hcd.c | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
drivers/usb/dwc2/core.h +12 -0
@@ -729,8 +729,14 @@ struct dwc2_dregs_backup {* struct dwc2_hregs_backup - Holds host registers state before * entering partial power down * @hcfg: Backup of HCFG register +* @hflbaddr: Backup of HFLBADDR register * @haintmsk: Backup of HAINTMSK register +* @hcchar: Backup of HCCHAR register +* @hcsplt: Backup of HCSPLT register * @hcintmsk: Backup of HCINTMSK register +* @hctsiz: Backup of HCTSIZ register +* @hdma: Backup of HCDMA register +* @hcdmab: Backup of HCDMAB register * @hprt0: Backup of HPTR0 register * @hfir: Backup of HFIR register * @hptxfsiz: Backup of HPTXFSIZ register
@@ -738,8 +744,14 @@ struct dwc2_dregs_backup {*/ struct dwc2_hregs_backup {u32 hcfg; +u32 hflbaddr;u32 haintmsk; +u32 hcchar[MAX_EPS_CHANNELS ]; +u32 hcsplt[MAX_EPS_CHANNELS ];u32 hcintmsk[MAX_EPS_CHANNELS ]; +u32 hctsiz[MAX_EPS_CHANNELS ]; +u32 hcidma[MAX_EPS_CHANNELS ]; +u32 hcidmab[MAX_EPS_CHANNELS ];u32 hprt0;u32 hfir;u32 hptxfsiz;
drivers/usb/dwc2/hcd.c +16 -2
@@ -5406,9 +5406,16 @@ int dwc2_backup_host_registers(struct dw/* Backup Host regs */ hr = &hsotg->hr_backup; hr->hcfg =dwc2_readl (hsotg,HCFG ); + hr->hflbaddr =dwc2_readl (hsotg,HFLBADDR ); hr->haintmsk =dwc2_readl (hsotg,HAINTMSK ); -for (i =0 ; i < hsotg->params.host_channels; ++i) +for (i =0 ; i < hsotg->params.host_channels; ++i) { + hr->hcchar[i] =dwc2_readl (hsotg,HCCHAR (i)); + hr->hcsplt[i] =dwc2_readl (hsotg,HCSPLT (i)); hr->hcintmsk[i] =dwc2_readl (hsotg,HCINTMSK (i)); + hr->hctsiz[i] =dwc2_readl (hsotg,HCTSIZ (i)); + hr->hcidma[i] =dwc2_readl (hsotg,HCDMA (i)); + hr->hcidmab[i] =dwc2_readl (hsotg,HCDMAB (i)); + } hr->hprt0 =dwc2_read_hprt0 (hsotg); hr->hfir =dwc2_readl (hsotg,HFIR );
@@ -5442,10 +5449,17 @@ int dwc2_restore_host_registers(struct d hr->valid = false;dwc2_writel (hsotg, hr->hcfg,HCFG ); +dwc2_writel (hsotg, hr->hflbaddr,HFLBADDR );dwc2_writel (hsotg, hr->haintmsk,HAINTMSK ); -for (i =0 ; i < hsotg->params.host_channels; ++i) +for (i =0 ; i < hsotg->params.host_channels; ++i) { +dwc2_writel (hsotg, hr->hcchar[i],HCCHAR (i)); +dwc2_writel (hsotg, hr->hcsplt[i],HCSPLT (i));dwc2_writel (hsotg, hr->hcintmsk[i],HCINTMSK (i)); +dwc2_writel (hsotg, hr->hctsiz[i],HCTSIZ (i)); +dwc2_writel (hsotg, hr->hcidma[i],HCDMA (i)); +dwc2_writel (hsotg, hr->hcidmab[i],HCDMAB (i)); + }dwc2_writel (hsotg, hr->hprt0,HPRT0 );dwc2_writel (hsotg, hr->hfir,HFIR );
Greg Kroah-Hartman
maintainerPATCH 245/272 usb: dwc2: host: Fix ISOC flow in DDMA mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit b258e42688501cadb1a6dd658d6f015df9f32d8f upstream.
Fixed ISOC completion flow in DDMA mode. Added isoc descriptor actual length value and update urb's start_frame value.
Fixed initialization of ISOC DMA descriptors flow.
--- drivers/usb/dwc2/hcd.c | 12 ++++++++++-- drivers/usb/dwc2/hcd_ddma.c | 17 +++++++++++------ drivers/usb/dwc2/hw.h | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-)
drivers/usb/dwc2/hcd.c +10 -2
@@ -2701,8 +2701,11 @@ enum dwc2_transaction_type dwc2_hcd_sele hsotg->available_host_channels--; } qh = list_entry(qh_ptr, struct dwc2_qh, qh_list_entry); -if (dwc2_assign_and_init_hc (hsotg, qh)) +if (dwc2_assign_and_init_hc (hsotg, qh)) { +if (hsotg->params.uframe_sched) + hsotg->available_host_channels++;break ; + }/* * Move the QH from the periodic ready schedule to the
@@ -2735,8 +2738,11 @@ enum dwc2_transaction_type dwc2_hcd_sele hsotg->available_host_channels--; } -if (dwc2_assign_and_init_hc (hsotg, qh)) +if (dwc2_assign_and_init_hc (hsotg, qh)) { +if (hsotg->params.uframe_sched) + hsotg->available_host_channels++;break ; + }/* * Move the QH from the non-periodic inactive schedule to the
@@ -4143,6 +4149,8 @@ void dwc2_host_complete(struct dwc2_hsot urb->actual_length);if (usb_pipetype (urb->pipe) ==PIPE_ISOCHRONOUS ) { +if (!hsotg->params.dma_desc_enable) + urb->start_frame = qtd->qh->start_active_frame; urb->error_count =dwc2_hcd_urb_get_error_count (qtd->urb);for (i =0 ; i < urb->number_of_packets; ++i) { urb->iso_frame_desc[i].actual_length =
drivers/usb/dwc2/hcd_ddma.c +11 -6
@@ -559,7 +559,7 @@ static void dwc2_init_isoc_dma_desc(stru idx = qh->td_last; inc = qh->host_interval; hsotg->frame_number =dwc2_hcd_get_frame_number (hsotg); - cur_idx =dwc2_frame_list_idx (hsotg->frame_number); + cur_idx = idx; next_idx =dwc2_desclist_idx_inc (qh->td_last, inc, qh->dev_speed);/*
@@ -866,6 +866,8 @@ static int dwc2_cmpl_host_isoc_dma_desc( {struct dwc2_dma_desc *dma_desc;struct dwc2_hcd_iso_packet_desc *frame_desc; +u16 frame_desc_idx; +struct urb *usb_urb = qtd->urb->priv;u16 remain =0 ;int rc =0 ;
@@ -878,8 +880,11 @@ static int dwc2_cmpl_host_isoc_dma_desc( DMA_FROM_DEVICE); dma_desc = &qh->desc_list[idx]; + frame_desc_idx = (idx - qtd->isoc_td_first) & (usb_urb->number_of_packets -1 ); - frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index_last]; + frame_desc = &qtd->urb->iso_descs[frame_desc_idx]; +if (idx == qtd->isoc_td_first) + usb_urb->start_frame =dwc2_hcd_get_frame_number (hsotg); dma_desc->buf = (u32)(qtd->urb->dma + frame_desc->offset);if (chan->ep_is_in) remain = (dma_desc->status & HOST_DMA_ISOC_NBYTES_MASK) >>
@@ -900,7 +905,7 @@ static int dwc2_cmpl_host_isoc_dma_desc( frame_desc->status =0 ; } -if (++qtd->isoc_frame_index == qtd->urb->packet_count) { +if (++qtd->isoc_frame_index == usb_urb->number_of_packets) {/* * urb->status is not used for isoc transfers here. The * individual frame_desc status are used instead.
@@ -1005,11 +1010,11 @@ static void dwc2_complete_isoc_xfer_ddmareturn ; idx =dwc2_desclist_idx_inc (idx, qh->host_interval, chan->speed); -if (!rc) +if (rc ==0 )continue ; -if (rc ==DWC2_CMPL_DONE ) -break ; +if (rc ==DWC2_CMPL_DONE || rc ==DWC2_CMPL_STOP ) + goto stop_scan;/* rc == DWC2_CMPL_STOP */
drivers/usb/dwc2/hw.h +1 -1
@@ -698,7 +698,7 @@#define TXSTS_QTOP_TOKEN_MASK (0x3 << 25)#define TXSTS_QTOP_TOKEN_SHIFT 25#define TXSTS_QTOP_TERMINATE BIT(24) -#define TXSTS_QSPCAVAIL_MASK (0xff << 16) +#define TXSTS_QSPCAVAIL_MASK (0x7f << 16)#define TXSTS_QSPCAVAIL_SHIFT 16#define TXSTS_FSPCAVAIL_MASK (0xffff << 0)#define TXSTS_FSPCAVAIL_SHIFT 0
Greg Kroah-Hartman
maintainerPATCH 246/272 usb: dwc2: gadget: Fix exiting from clock gating
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 31f42da31417bec88158f3cf62d19db836217f1e upstream.
Added exiting from the clock gating mode on USB Reset Detect interrupt if core in the clock gating mode.
Added new condition to check core in clock gating mode or no.
--- drivers/usb/dwc2/core_intr.c | 9 ++++++--- drivers/usb/dwc2/gadget.c | 6 ++++++ drivers/usb/dwc2/hcd.c | 2 +- drivers/usb/dwc2/platform.c | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-)
drivers/usb/dwc2/core_intr.c +6 -3
@@ -297,7 +297,8 @@ static void dwc2_handle_session_req_intr/* Exit gadget mode clock gating. */ if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_gadget_exit_clock_gating (hsotg,0 ); }
@@ -408,7 +409,8 @@ static void dwc2_handle_wakeup_detected_/* Exit gadget mode clock gating. */ if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_gadget_exit_clock_gating (hsotg,0 ); }else {/* Change to L0 state */
@@ -425,7 +427,8 @@ static void dwc2_handle_wakeup_detected_ }if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_host_exit_clock_gating (hsotg,1 );/*
drivers/usb/dwc2/gadget.c +6 -0
@@ -3728,6 +3728,12 @@ irq_retry:if (hsotg->in_ppd && hsotg->lx_state ==DWC2_L2 )dwc2_exit_partial_power_down (hsotg,0 , true); +/* Exit gadget mode clock gating. */ +if (hsotg->params.power_down == +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating) +dwc2_gadget_exit_clock_gating (hsotg,0 ); + hsotg->lx_state =DWC2_L0 ; }
drivers/usb/dwc2/hcd.c +1 -1
@@ -4657,7 +4657,7 @@ static int _dwc2_hcd_urb_enqueue(struct }if (hsotg->params.power_down ==DWC2_POWER_DOWN_PARAM_NONE && - hsotg->bus_suspended) { + hsotg->bus_suspended && !hsotg->params.no_clock_gating) {if (dwc2_is_device_mode (hsotg))dwc2_gadget_exit_clock_gating (hsotg,0 );else
drivers/usb/dwc2/platform.c +1 -1
@@ -298,7 +298,7 @@ static int dwc2_driver_remove(struct pla/* Exit clock gating when driver is removed. */ if (hsotg->params.power_down ==DWC2_POWER_DOWN_PARAM_NONE && - hsotg->bus_suspended) { + hsotg->bus_suspended && !hsotg->params.no_clock_gating) {if (dwc2_is_device_mode (hsotg))dwc2_gadget_exit_clock_gating (hsotg,0 );else
Greg Kroah-Hartman
maintainerPATCH 247/272 usb: dwc2: gadget: LPM flow fix
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 5d69a3b54e5a630c90d82a4c2bdce3d53dc78710 upstream.
Added functionality to exit from L1 state by device initiation using remote wakeup signaling, in case when function driver queuing request while core in L1 state.
--- drivers/usb/dwc2/core.h | 1 drivers/usb/dwc2/core_intr.c | 65 ++++++++++++++++++++++++++++--------------- drivers/usb/dwc2/gadget.c | 4 ++ 3 files changed, 48 insertions(+), 22 deletions(-)
drivers/usb/dwc2/core.h +1 -0
@@ -1334,6 +1334,7 @@ int dwc2_backup_global_registers(structint dwc2_restore_global_registers (struct dwc2_hsotg *hsotg);void dwc2_enable_acg (struct dwc2_hsotg *hsotg); +void dwc2_wakeup_from_lpm_l1 (struct dwc2_hsotg *hsotg,bool remotewakeup);/* This function should be called on every hardware interrupt. */ irqreturn_t dwc2_handle_common_intr (int irq,void *dev);
drivers/usb/dwc2/core_intr.c +43 -22
97 lines not on this page · raw message
drivers/usb/dwc2/gadget.c +4 -0
@@ -1416,6 +1416,10 @@ static int dwc2_hsotg_ep_queue(struct us ep->name, req, req->length, req->buf, req->no_interrupt, req->zero, req->short_not_ok); +if (hs->lx_state ==DWC2_L1 ) { +dwc2_wakeup_from_lpm_l1 (hs, true); + } +/* Prevent new request submission when controller is suspended */ if (hs->lx_state !=DWC2_L0 ) { dev_dbg(hs->dev, "%s: submit request only in active state\n",
Greg Kroah-Hartman
maintainerPATCH 248/272 usb: udc: remove warning when queue disabled ep
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: yuan linyu <[email protected]>
commit 2a587a035214fa1b5ef598aea0b81848c5b72e5e upstream.
It is possible trigger below warning message from mass storage function,
WARNING: CPU: 6 PID: 3839 at drivers/usb/gadget/udc/core.c:294 usb_ep_queue+0x7c/0x104 pc : usb_ep_queue+0x7c/0x104 lr : fsg_main_thread+0x494/0x1b3c
Root cause is mass storage function try to queue request from main thread, but other thread may already disable ep when function disable.
As there is no function failure in the driver, in order to avoid effort to fix warning, change WARN_ON_ONCE() in usb_ep_queue() to pr_debug().
--- drivers/usb/gadget/udc/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/core.c +3 -1
@@ -292,7 +292,9 @@ int usb_ep_queue(struct usb_ep *ep, {int ret =0 ; -if (WARN_ON_ONCE (!ep->enabled && ep->address)) { +if (!ep->enabled && ep->address) { +pr_debug ("USB gadget: queue request to disabled ep 0x%x (%s)\n" , + ep->address, ep->name); ret = -ESHUTDOWN ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 249/272 usb: typec: Return size of buffer if pd_set operation succeeds
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Tso <[email protected]>
commit 53f5094fdf5deacd99b8655df692e9278506724d upstream.
The attribute writing should return the number of bytes used from the buffer on success.
--- drivers/usb/typec/class.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/typec/class.c +6 -1
@@ -1245,6 +1245,7 @@ static ssize_t select_usb_power_delivery {struct typec_port *port =to_typec_port (dev);struct usb_power_delivery *pd; +int ret;if (!port->ops || !port->ops->pd_set)return -EOPNOTSUPP ;
@@ -1253,7 +1254,11 @@ static ssize_t select_usb_power_deliveryif (!pd)return -EINVAL ; -return port->ops->pd_set (port, pd); + ret = port->ops->pd_set (port, pd); +if (ret) +return ret; + +return size; } static ssize_t select_usb_power_delivery_show(struct device *dev,
Greg Kroah-Hartman
maintainerPATCH 250/272 usb: typec: ucsi: Clear EVENT_PENDING under PPM lock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 15b2e71b4653b3e13df34695a29ebeee237c5af2 upstream.
Suppose we sleep on the PPM lock after clearing the EVENT_PENDING bit because the thread for another connector is executing a command. In this case the command completion of the other command will still report the connector change for our connector.
Clear the EVENT_PENDING bit under the PPM lock to avoid another useless call to ucsi_handle_connector_change() in this case.
--- drivers/usb/typec/ucsi/ucsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +2 -2
@@ -829,11 +829,11 @@ static void ucsi_handle_connector_changeif (con->status.change &UCSI_CONSTAT_CAM_CHANGE )ucsi_partner_task (con, ucsi_check_altmodes,1 ,0 ); -clear_bit (EVENT_PENDING , &con->ucsi->flags); -mutex_lock (&ucsi->ppm_lock); +clear_bit (EVENT_PENDING , &con->ucsi->flags); ret =ucsi_acknowledge_connector_change (ucsi);mutex_unlock (&ucsi->ppm_lock); +if (ret)dev_err (ucsi->dev,"%s: ACK failed (%d)" , __func__, ret);
Greg Kroah-Hartman
maintainerPATCH 251/272 usb: typec: ucsi: Check for notifications after init
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56 upstream.
The completion notification for the final SET_NOTIFICATION_ENABLE command during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.
Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +9 -1
@@ -851,7 +851,7 @@ void ucsi_connector_change(struct ucsi *struct ucsi_connector *con = &ucsi->connector[num -1 ];if (!(ucsi->ntfy &UCSI_ENABLE_NTFY_CONNECTOR_CHANGE )) { -dev_dbg (ucsi->dev,"Bogus connector change event\n" ); +dev_dbg (ucsi->dev,"Early connector change event\n" );return ; }
@@ -1210,6 +1210,7 @@ static int ucsi_init(struct ucsi *ucsi) {struct ucsi_connector *con, *connector;u64 command, ntfy; +u32 cci;int ret;int i;
@@ -1262,6 +1263,13 @@ static int ucsi_init(struct ucsi *ucsi) ucsi->connector = connector; ucsi->ntfy = ntfy; + + ret = ucsi->ops->read (ucsi,UCSI_CCI , &cci,sizeof (cci)); +if (ret) +return ret; +if (UCSI_CCI_CONNECTOR (READ_ONCE (cci))) +ucsi_connector_change (ucsi, cci); +return 0 ; err_unregister:
Re: [PATCH 6.1 251/272] usb: typec: ucsi: Check for notifications after init
Hi Greg,
Quoted 26 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit
808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56upstream.The completion notification for the final
SET_NOTIFICATION_ENABLEcommand during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
Fixes 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask")Signed-off-by Christian A. Ehrhardt <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 3 lines
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
This change has an out of bounds memory access. Please drop it from the stable trees until a fix is available.
Sorry for the inconvenience!
Quoted 24 lines
drivers/usb/typec/ucsi/ucsi.c +2
-1@@ -851,7 +851,7 @@ void ucsi_connector_change(struct ucsi *struct ucsi_connector *con = &ucsi->connector[num -1 ];if (!(ucsi->ntfy &UCSI_ENABLE_NTFY_CONNECTOR_CHANGE )) { -dev_dbg (ucsi->dev,"Bogus connector change event\n" ); +dev_dbg (ucsi->dev,"Early connector change event\n" );return ; }@@ -1210,6 +1210,7 @@ static int ucsi_init(struct ucsi *ucsi) {struct ucsi_connector *con, *connector;u64 command, ntfy; +u32 cci;int ret;int i;@@ -1262,6 +1263,13 @@ static int ucsi_init(struct ucsi *ucsi) ucsi->connector = connector; ucsi->ntfy = ntfy;
drivers/usb/typec/ucsi/ucsi.c static int ucsi_init(struct ucsi *ucsi) · line 1275
Quoted 10 lines
drivers/usb/typec/ucsi/ucsi.c +7
-0+ + ret = ucsi->ops->read (ucsi,UCSI_CCI , &cci,sizeof (cci)); +if (ret) +return ret; +if (UCSI_CCI_CONNECTOR (READ_ONCE (cci))) +ucsi_connector_change (ucsi, cci); +return 0 ; err_unregister:
Best regards
Christian
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 251/272] usb: typec: ucsi: Check for notifications after init
Quoted 34 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 26 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit
808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56upstream.The completion notification for the final
SET_NOTIFICATION_ENABLEcommand during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
Fixes 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask")Signed-off-by Christian A. Ehrhardt <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Quoted 3 lines
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Quoted 2 lines
This change has an out of bounds memory access. Please drop it from the stable trees until a fix is available.
Shouldn't we get a fix for Linus's tree too? Have I missed that somewhere? Or should this just be reverted now?
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 251/272] usb: typec: ucsi: Check for notifications after init
Quoted 35 lines · Greg Kroah-Hartman
Quoted 34 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 29 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit
808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56upstream.The completion notification for the final
SET_NOTIFICATION_ENABLEcommand during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
Fixes 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask")Signed-off-by Christian A. Ehrhardt <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 2 lines
This change has an out of bounds memory access. Please drop it from the stable trees until a fix is available.
Shouldn't we get a fix for Linus's tree too? Have I missed that somewhere? Or should this just be reverted now?
Ah, I see the fix now, still catching up on email this morning...
Re: [PATCH 6.1 251/272] usb: typec: ucsi: Check for notifications after init
In reply to Greg Kroah-HartmanHi Greg,
Quoted 35 lines · Greg Kroah-Hartman
Quoted 34 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 29 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit
808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56upstream.The completion notification for the final
SET_NOTIFICATION_ENABLEcommand during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
Fixes 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask")Signed-off-by Christian A. Ehrhardt <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 2 lines
This change has an out of bounds memory access. Please drop it from the stable trees until a fix is available.
Shouldn't we get a fix for Linus's tree too? Have I missed that somewhere? Or should this just be reverted now?
I posted the fix a few hours after sending this mail. It is here:
https://lore.kernel.org/all/[email protected]/
Either this should be fast tracked to Linus or the original change reverted, yes.
Best regards
Christian
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 251/272] usb: typec: ucsi: Check for notifications after init
Quoted 42 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 38 lines · Greg Kroah-Hartman
Quoted 36 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 26 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit
808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56upstream.The completion notification for the final
SET_NOTIFICATION_ENABLEcommand during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
Fixes 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask")Signed-off-by Christian A. Ehrhardt <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Quoted 3 lines
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)This change has an out of bounds memory access. Please drop it from the stable trees until a fix is available.
Quoted 8 lines
Quoted 2 lines
Shouldn't we get a fix for Linus's tree too? Have I missed that somewhere? Or should this just be reverted now?
I posted the fix a few hours after sending this mail. It is here:
https://lore.kernel.org/all/[email protected]/Either this should be fast tracked to Linus or the original change reverted, yes.
I've dropped the offending commit from the stable queues now. Once this fix gets into Linus's tree, let us know and I will add both in then.
thanks,
greg k-h
Re: [PATCH 6.1 251/272] usb: typec: ucsi: Check for notifications after init
Hi Greg,
Quoted 46 lines · Greg Kroah-Hartman
Quoted 45 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 40 lines · Greg Kroah-Hartman
Quoted 34 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 26 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit
808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56upstream.The completion notification for the final
SET_NOTIFICATION_ENABLEcommand during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
Fixes 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask")Signed-off-by Christian A. Ehrhardt <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Quoted 3 lines
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)Quoted 2 lines
This change has an out of bounds memory access. Please drop it from the stable trees until a fix is available.
Shouldn't we get a fix for Linus's tree too? Have I missed that somewhere? Or should this just be reverted now?
Quoted 8 lines
Quoted 5 lines
I posted the fix a few hours after sending this mail. It is here:
https://lore.kernel.org/all/[email protected]/Either this should be fast tracked to Linus or the original change reverted, yes.
I've dropped the offending commit from the stable queues now. Once this fix gets into Linus's tree, let us know and I will add both in then.
The fix for
808a8b9e0b87 ("usb: typec: ucsi: Check for notifications after init")
has hit Linus's tree as
ce4c8d21054a ("usb: typec: ucsi: Fix connector check on init")
There is no urgency but this is to let you know that the original commit is eligible for -stable again, provided that the follow up commit is backported, too.
Best regards,
Christian
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 251/272] usb: typec: ucsi: Check for notifications after init
Quoted 59 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 46 lines · Greg Kroah-Hartman
Quoted 45 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 40 lines · Greg Kroah-Hartman
Quoted 34 lines · Christian A. Ehrhardt
Hi Greg,
Quoted 26 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit
808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56upstream.The completion notification for the final
SET_NOTIFICATION_ENABLEcommand during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
Fixes 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask")Signed-off-by Christian A. Ehrhardt <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Quoted 3 lines
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)Quoted 2 lines
This change has an out of bounds memory access. Please drop it from the stable trees until a fix is available.
Shouldn't we get a fix for Linus's tree too? Have I missed that somewhere? Or should this just be reverted now?
Quoted 8 lines
Quoted 5 lines
I posted the fix a few hours after sending this mail. It is here:
https://lore.kernel.org/all/[email protected]/Either this should be fast tracked to Linus or the original change reverted, yes.
I've dropped the offending commit from the stable queues now. Once this fix gets into Linus's tree, let us know and I will add both in then.
Quoted 8 lines
The fix for
808a8b9e0b87("usb: typec: ucsi: Check for notifications after init")
has hit Linus's tree as
ce4c8d21054a("usb: typec: ucsi: Fix connector check on init")There is no urgency but this is to let you know that the original commit is eligible for -stable again, provided that the follow up commit is backported, too.
Thanks, all now queued up.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 252/272 usb: typec: ucsi: Ack unsupported commands
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 6b5c85ddeea77d18c4b69e3bda60e9374a20c304 upstream.
If a command completes the OPM must send an ack. This applies to unsupported commands, too.
Send the required ACK for unsupported commands.
--- drivers/usb/typec/ucsi/ucsi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +5 -1
@@ -138,8 +138,12 @@ static int ucsi_exec_command(struct ucsiif (!(cci &UCSI_CCI_COMMAND_COMPLETE ))return -EIO ; -if (cci &UCSI_CCI_NOT_SUPPORTED ) +if (cci &UCSI_CCI_NOT_SUPPORTED ) { +if (ucsi_acknowledge_command (ucsi) <0 ) +dev_err (ucsi->dev, +"ACK of unsupported command failed\n" );return -EOPNOTSUPP ; + }if (cci &UCSI_CCI_ERROR ) {if (cmd ==UCSI_GET_ERROR_STATUS )
Greg Kroah-Hartman
maintainerPATCH 253/272 usb: typec: ucsi_acpi: Refactor and fix DELL quirk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 6aaceb7d9cd00f3e065dc4b054ecfe52c5253b03 upstream.
Some DELL systems don't like UCSI_ACK_CC_CI commands with the UCSI_ACK_CONNECTOR_CHANGE but not the UCSI_ACK_COMMAND_COMPLETE bit set. The current quirk still leaves room for races because it requires two consecutive ACK commands to be sent.
Refactor and significantly simplify the quirk to fix this:
Send a dummy command and bundle the connector change ack with the command completion ack in a single UCSI_ACK_CC_CI command. This removes the need to probe for the quirk.
While there define flag bits for struct ucsi_acpi->flags in ucsi_acpi.c and don't re-use definitions from ucsi.h for struct ucsi->flags.
--- drivers/usb/typec/ucsi/ucsi_acpi.c | 71 ++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 40 deletions(-)
drivers/usb/typec/ucsi/ucsi_acpi.c +31 -40
@@ -23,10 +23,11 @@ struct ucsi_acpi {void *base;struct completion complete;unsigned long flags; +#define UCSI_ACPI_SUPPRESS_EVENT 0 +#define UCSI_ACPI_COMMAND_PENDING 1 +#define UCSI_ACPI_ACK_PENDING 2guid_t guid;u64 cmd; -bool dell_quirk_probed; -bool dell_quirk_active; };static int ucsi_acpi_dsm (struct ucsi_acpi *ua,int func)
@@ -79,9 +80,9 @@ static int ucsi_acpi_sync_write(struct uint ret;if (ack) -set_bit (ACK_PENDING , &ua->flags); +set_bit (UCSI_ACPI_ACK_PENDING , &ua->flags);else -set_bit (COMMAND_PENDING , &ua->flags); +set_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags); ret =ucsi_acpi_async_write (ucsi, offset, val, val_len);if (ret)
@@ -92,9 +93,9 @@ static int ucsi_acpi_sync_write(struct u out_clear_bit:if (ack) -clear_bit (ACK_PENDING , &ua->flags); +clear_bit (UCSI_ACPI_ACK_PENDING , &ua->flags);else -clear_bit (COMMAND_PENDING , &ua->flags); +clear_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags);return ret; }
@@ -129,51 +130,40 @@ static const struct ucsi_operations ucsi };/* -* Some Dell laptops expect that an ACK command with the -* UCSI_ACK_CONNECTOR_CHANGE bit set is followed by a (separate) -* ACK command that only has the UCSI_ACK_COMMAND_COMPLETE bit set. -* If this is not done events are not delivered to OSPM and -* subsequent commands will timeout. +* Some Dell laptops don't like ACK commands with the +* UCSI_ACK_CONNECTOR_CHANGE but not the UCSI_ACK_COMMAND_COMPLETE +* bit set. To work around this send a dummy command and bundle the +* UCSI_ACK_CONNECTOR_CHANGE with the UCSI_ACK_COMMAND_COMPLETE +* for the dummy command. */ static int ucsi_dell_sync_write (struct ucsi *ucsi,unsigned int offset,const void *val,size_t val_len) {struct ucsi_acpi *ua =ucsi_get_drvdata (ucsi); -u64 cmd = *(u64 *)val, ack =0 ; +u64 cmd = *(u64 *)val; +u64 dummycmd =UCSI_GET_CAPABILITY ;int ret; -if (UCSI_COMMAND (cmd) ==UCSI_ACK_CC_CI && - cmd &UCSI_ACK_CONNECTOR_CHANGE ) - ack =UCSI_ACK_CC_CI |UCSI_ACK_COMMAND_COMPLETE ; +if (cmd == (UCSI_ACK_CC_CI |UCSI_ACK_CONNECTOR_CHANGE )) { + cmd |=UCSI_ACK_COMMAND_COMPLETE ; - ret =ucsi_acpi_sync_write (ucsi, offset, val, val_len); -if (ret !=0 ) -return ret; -if (ack ==0 ) -return ret; - -if (!ua->dell_quirk_probed) { - ua->dell_quirk_probed = true; +/* +* The UCSI core thinks it is sending a connector change ack +* and will accept new connector change events. We don't want +* this to happen for the dummy command as its response will +* still report the very event that the core is trying to clear. +*/ +set_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags); + ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &dummycmd, +sizeof (dummycmd)); +clear_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags); - cmd =UCSI_GET_CAPABILITY ; - ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &cmd, -sizeof (cmd)); -if (ret ==0 ) -return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , - &ack,sizeof (ack)); -if (ret != -ETIMEDOUT ) +if (ret <0 )return ret; - - ua->dell_quirk_active = true; -dev_err (ua->dev,"Firmware bug: Additional ACK required after ACKing a connector change.\n" ); -dev_err (ua->dev,"Firmware bug: Enabling workaround\n" ); } -if (!ua->dell_quirk_active) -return ret; - -return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &ack,sizeof (ack)); +return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &cmd,sizeof (cmd)); }static const struct ucsi_operations ucsi_dell_ops = {
@@ -209,13 +199,14 @@ static void ucsi_acpi_notify(acpi_handleif (ret)return ; -if (UCSI_CCI_CONNECTOR (cci)) +if (UCSI_CCI_CONNECTOR (cci) && + !test_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags))ucsi_connector_change (ua->ucsi,UCSI_CCI_CONNECTOR (cci));if (cci &UCSI_CCI_ACK_COMPLETE &&test_bit (ACK_PENDING , &ua->flags))complete (&ua->complete);if (cci &UCSI_CCI_COMMAND_COMPLETE && -test_bit (COMMAND_PENDING , &ua->flags)) +test_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags))complete (&ua->complete); }
Greg Kroah-Hartman
maintainerPATCH 254/272 usb: typec: ucsi: Clear UCSI_CCI_RESET_COMPLETE before reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 3de4f996a0b5412aa451729008130a488f71563e upstream.
Check the UCSI_CCI_RESET_COMPLETE complete flag before starting another reset. Use a UCSI_SET_NOTIFICATION_ENABLE command to clear the flag if it is set.
--- drivers/usb/typec/ucsi/ucsi.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +35 -1
@@ -878,13 +878,47 @@ static int ucsi_reset_connector(struct ustatic int ucsi_reset_ppm (struct ucsi *ucsi) { -u64 command =UCSI_PPM_RESET ; +u64 command;unsigned long tmo;u32 cci;int ret;mutex_lock (&ucsi->ppm_lock); + ret = ucsi->ops->read (ucsi,UCSI_CCI , &cci,sizeof (cci)); +if (ret <0 ) + goto out; + +/* +* If UCSI_CCI_RESET_COMPLETE is already set we must clear +* the flag before we start another reset. Send a +* UCSI_SET_NOTIFICATION_ENABLE command to achieve this. +* Ignore a timeout and try the reset anyway if this fails. +*/ +if (cci &UCSI_CCI_RESET_COMPLETE ) { + command =UCSI_SET_NOTIFICATION_ENABLE ; + ret = ucsi->ops->async_write (ucsi,UCSI_CONTROL , &command, +sizeof (command)); +if (ret <0 ) + goto out; + + tmo = jiffies +msecs_to_jiffies (UCSI_TIMEOUT_MS ); +do { + ret = ucsi->ops->read (ucsi,UCSI_CCI , + &cci,sizeof (cci)); +if (ret <0 ) + goto out; +if (cci &UCSI_CCI_COMMAND_COMPLETE ) +break ; +if (time_is_before_jiffies (tmo)) +break ; +msleep (20 ); + }while (1 ); + +WARN_ON (cci &UCSI_CCI_RESET_COMPLETE ); + } + + command =UCSI_PPM_RESET ; ret = ucsi->ops->async_write (ucsi,UCSI_CONTROL , &command,sizeof (command));if (ret <0 )
Greg Kroah-Hartman
maintainerPATCH 255/272 scsi: qla2xxx: Prevent command send on chip reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 4895009c4bb72f71f2e682f1e7d2c2d96e482087 upstream.
Currently IOCBs are allowed to push through while chip reset could be in progress. During chip reset the outstanding_cmds array is cleared twice. Once when any command on this array is returned as failed and secondly when the array is initialize to zero. If a command is inserted on to the array between these intervals, then the command will be lost. Check for chip reset before sending IOCB.
--- drivers/scsi/qla2xxx/qla_init.c | 8 ++++++-- drivers/scsi/qla2xxx/qla_iocb.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +6 -2
@@ -1187,8 +1187,12 @@ int qla24xx_async_gnl(struct scsi_qla_horeturn rval; done_free_sp: -/* ref: INIT */ -kref_put (&sp->cmd_kref, qla2x00_sp_release); +/* +* use qla24xx_async_gnl_sp_done to purge all pending gnl request. +* kref_put is call behind the scene. +*/ + sp->u.iocb_cmd.u.mbx.in_mb[0 ] =MBS_COMMAND_ERROR ; +qla24xx_async_gnl_sp_done (sp,QLA_COMMAND_ERROR ); fcport->flags &= ~(FCF_ASYNC_SENT ); done: fcport->flags &= ~(FCF_ASYNC_ACTIVE );
drivers/scsi/qla2xxx/qla_iocb.c +31 -2
@@ -2588,6 +2588,33 @@ void qla2x00_sp_release(struct kref *kref) { struct srb *sp = container_of(kref, struct srb, cmd_kref); +struct scsi_qla_host *vha = sp->vha; + +switch (sp->type) { +case SRB_CT_PTHRU_CMD : +/* GPSC & GFPNID use fcport->ct_desc.ct_sns for both req & rsp */ +if (sp->u.iocb_cmd.u.ctarg.req && + (!sp->fcport || + sp->u.iocb_cmd.u.ctarg.req != sp->fcport->ct_desc.ct_sns)) { +dma_free_coherent (&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.req_allocated_size, + sp->u.iocb_cmd.u.ctarg.req, + sp->u.iocb_cmd.u.ctarg.req_dma); + sp->u.iocb_cmd.u.ctarg.req =NULL ; + } +if (sp->u.iocb_cmd.u.ctarg.rsp && + (!sp->fcport || + sp->u.iocb_cmd.u.ctarg.rsp != sp->fcport->ct_desc.ct_sns)) { +dma_free_coherent (&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.rsp_allocated_size, + sp->u.iocb_cmd.u.ctarg.rsp, + sp->u.iocb_cmd.u.ctarg.rsp_dma); + sp->u.iocb_cmd.u.ctarg.rsp =NULL ; + } +break ; +default : +break ; + } sp->free (sp); }
@@ -2693,7 +2720,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v*/ sp =qla2x00_get_sp (vha, fcport,GFP_KERNEL );if (!sp) { -kfree (fcport); +qla2x00_free_fcport (fcport);ql_log (ql_log_info, vha,0x70e6 ,"SRB allocation failed\n" );return -ENOMEM ;
@@ -2748,6 +2775,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vif (rval !=QLA_SUCCESS ) {/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release); +qla2x00_free_fcport (fcport);return QLA_FUNCTION_FAILED ; }
@@ -2757,6 +2785,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v fcport->d_id.b.area, fcport->d_id.b.al_pa);wait_for_completion (&elsio->u.els_logo.comp); +qla2x00_free_fcport (fcport);/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release);
@@ -3916,7 +3945,7 @@ qla2x00_start_sp(srb_t *sp)return -EAGAIN ; } - pkt =__qla2x00_alloc_iocbs (sp->qpair, sp); + pkt =qla2x00_alloc_iocbs_ready (sp->qpair, sp);if (!pkt) { rval = -EAGAIN ; ql_log(ql_log_warn, vha, 0x700c,
Greg Kroah-Hartman
maintainerPATCH 256/272 scsi: qla2xxx: Fix N2N stuck connection
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 881eb861ca3877300570db10abbf11494e48548d upstream.
Disk failed to rediscover after chip reset error injection. The chip reset happens at the time when a PLOGI is being sent. This causes a flag to be left on which blocks the retry. Clear the blocking flag.
--- drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_iocb.c | 32 +++++++++++--------------------- drivers/scsi/qla2xxx/qla_os.c | 2 +- 3 files changed, 13 insertions(+), 23 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +1 -1
@@ -44,7 +44,7 @@ extern int qla2x00_fabric_login(scsi_qlaextern int qla2x00_local_device_login (scsi_qla_host_t *,fc_port_t *);extern int qla24xx_els_dcmd_iocb (scsi_qla_host_t *,int ,port_id_t ); -extern int qla24xx_els_dcmd2_iocb (scsi_qla_host_t *,int ,fc_port_t *,bool ); +extern int qla24xx_els_dcmd2_iocb (scsi_qla_host_t *,int ,fc_port_t *);extern void qla2x00_els_dcmd2_free (scsi_qla_host_t *vha,struct els_plogi *els_plogi);
drivers/scsi/qla2xxx/qla_iocb.c +11 -21
@@ -3042,7 +3042,7 @@ static void qla2x00_els_dcmd2_sp_done(srint qla24xx_els_dcmd2_iocb (scsi_qla_host_t *vha,int els_opcode, -fc_port_t *fcport,bool wait) +fc_port_t *fcport) {srb_t *sp;struct srb_iocb *elsio =NULL ;
@@ -3057,8 +3057,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!sp) {ql_log (ql_log_info, vha,0x70e6 ,"SRB allocation failed\n" ); - fcport->flags &= ~FCF_ASYNC_ACTIVE ; -return -ENOMEM ; + goto done; } fcport->flags |=FCF_ASYNC_SENT ;
@@ -3067,9 +3066,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *ql_dbg (ql_dbg_io, vha,0x3073 ,"%s Enter: PLOGI portid=%06x\n" , __func__, fcport->d_id.b24); -if (wait) - sp->flags =SRB_WAKEUP_ON_COMP ; - sp->type =SRB_ELS_DCMD ; sp->name ="ELS_DCMD" ; sp->fcport = fcport;
@@ -3085,7 +3081,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!elsio->u.els_plogi.els_plogi_pyld) { rval =QLA_FUNCTION_FAILED ; - goto out; + goto done_free_sp; } resp_ptr = elsio->u.els_plogi.els_resp_pyld =
@@ -3094,7 +3090,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!elsio->u.els_plogi.els_resp_pyld) { rval =QLA_FUNCTION_FAILED ; - goto out; + goto done_free_sp; }ql_dbg (ql_dbg_io, vha,0x3073 ,"PLOGI %p %p\n" , ptr, resp_ptr);
@@ -3109,7 +3105,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (els_opcode ==ELS_DCMD_PLOGI &&DBELL_ACTIVE (vha)) {struct fc_els_flogi *p = ptr; - p->fl_csp.sp_features |=cpu_to_be16 (FC_SP_FT_SEC ); }
@@ -3118,10 +3113,11 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t * (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, sizeof(*elsio->u.els_plogi.els_plogi_pyld)); -init_completion (&elsio->u.els_plogi.comp); rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS ) { - rval =QLA_FUNCTION_FAILED ; + fcport->flags |=FCF_LOGIN_NEEDED ; +set_bit (RELOGIN_NEEDED , &vha->dpc_flags); + goto done_free_sp; }else { ql_dbg(ql_dbg_disc, vha, 0x3074, "%s PLOGI sent, hdl=%x, loopid=%x, to port_id %06x from port_id %06x\n",
@@ -3129,21 +3125,15 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t * fcport->d_id.b24, vha->d_id.b24); } -if (wait) { -wait_for_completion (&elsio->u.els_plogi.comp); - -if (elsio->u.els_plogi.comp_status !=CS_COMPLETE ) - rval =QLA_FUNCTION_FAILED ; - }else { - goto done; - } +return rval; -out: - fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE ); +done_free_sp:qla2x00_els_dcmd2_free (vha, &elsio->u.els_plogi);/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release); done: + fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE ); +qla2x00_set_fcport_disc_state (fcport,DSC_DELETED );return rval; }
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -5562,7 +5562,7 @@ qla2x00_do_work(struct scsi_qla_host *vhbreak ;case QLA_EVT_ELS_PLOGI :qla24xx_els_dcmd2_iocb (vha,ELS_DCMD_PLOGI , - e->u.fcport.fcport, false); + e->u.fcport.fcport);break ;case QLA_EVT_SA_REPLACE : rc =qla24xx_issue_sa_replace_iocb (vha, e);
Greg Kroah-Hartman
maintainerPATCH 257/272 scsi: qla2xxx: Split FCE|EFT trace control
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 76a192e1a566e15365704b9f8fb3b70825f85064 upstream.
Current code combines the allocation of FCE|EFT trace buffers and enables the features all in 1 step.
Split this step into separate steps in preparation for follow-on patch to allow user to have a choice to enable / disable FCE trace feature.
--- drivers/scsi/qla2xxx/qla_init.c | 102 ++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 61 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +41 -61
@@ -2670,6 +2670,40 @@ exit:return rval; } +static void qla_enable_fce_trace (scsi_qla_host_t *vha) +{ +int rval; +struct qla_hw_data *ha = vha->hw; + +if (ha->fce) { + ha->flags.fce_enabled =1 ; +memset (ha->fce,0 ,fce_calc_size (ha->fce_bufs)); + rval =qla2x00_enable_fce_trace (vha, + ha->fce_dma, ha->fce_bufs, ha->fce_mb, &ha->fce_bufs); + +if (rval) { +ql_log (ql_log_warn, vha,0x8033 , +"Unable to reinitialize FCE (%d).\n" , rval); + ha->flags.fce_enabled =0 ; + } + } +} + +static void qla_enable_eft_trace (scsi_qla_host_t *vha) +{ +int rval; +struct qla_hw_data *ha = vha->hw; + +if (ha->eft) { +memset (ha->eft,0 ,EFT_SIZE ); + rval =qla2x00_enable_eft_trace (vha, ha->eft_dma,EFT_NUM_BUFFERS ); + +if (rval) { +ql_log (ql_log_warn, vha,0x8034 , +"Unable to reinitialize EFT (%d).\n" , rval); + } + } +}/* * qla2x00_initialize_adapter * Initialize board.
@@ -3673,9 +3707,8 @@ qla24xx_chip_diag(scsi_qla_host_t *vha) }static void -qla2x00_init_fce_trace (scsi_qla_host_t *vha) +qla2x00_alloc_fce_trace (scsi_qla_host_t *vha) { -int rval;dma_addr_t tc_dma;void *tc;struct qla_hw_data *ha = vha->hw;
@@ -3704,27 +3737,17 @@ qla2x00_init_fce_trace(scsi_qla_host_t *return ; } - rval =qla2x00_enable_fce_trace (vha, tc_dma,FCE_NUM_BUFFERS , - ha->fce_mb, &ha->fce_bufs); -if (rval) { -ql_log (ql_log_warn, vha,0x00bf , -"Unable to initialize FCE (%d).\n" , rval); -dma_free_coherent (&ha->pdev->dev,FCE_SIZE , tc, tc_dma); -return ; - } -ql_dbg (ql_dbg_init, vha,0x00c0 ,"Allocated (%d KB) for FCE...\n" ,FCE_SIZE /1024 ); - ha->flags.fce_enabled =1 ; ha->fce_dma = tc_dma; ha->fce = tc; + ha->fce_bufs =FCE_NUM_BUFFERS ; }static void -qla2x00_init_eft_trace (scsi_qla_host_t *vha) +qla2x00_alloc_eft_trace (scsi_qla_host_t *vha) { -int rval;dma_addr_t tc_dma;void *tc;struct qla_hw_data *ha = vha->hw;
@@ -3749,14 +3772,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t *return ; } - rval =qla2x00_enable_eft_trace (vha, tc_dma,EFT_NUM_BUFFERS ); -if (rval) { -ql_log (ql_log_warn, vha,0x00c2 , -"Unable to initialize EFT (%d).\n" , rval); -dma_free_coherent (&ha->pdev->dev,EFT_SIZE , tc, tc_dma); -return ; - } -ql_dbg (ql_dbg_init, vha,0x00c3 ,"Allocated (%d KB) EFT ...\n" ,EFT_SIZE /1024 );
@@ -3764,13 +3779,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t * ha->eft = tc; } -static void -qla2x00_alloc_offload_mem (scsi_qla_host_t *vha) -{ -qla2x00_init_fce_trace (vha); -qla2x00_init_eft_trace (vha); -} -void qla2x00_alloc_fw_dump (scsi_qla_host_t *vha) {
@@ -3825,10 +3833,10 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vif (ha->tgt.atio_ring) mq_size += ha->tgt.atio_q_length *sizeof (request_t); -qla2x00_init_fce_trace (vha); +qla2x00_alloc_fce_trace (vha);if (ha->fce) fce_size =sizeof (struct qla2xxx_fce_chain ) +FCE_SIZE ; -qla2x00_init_eft_trace (vha); +qla2x00_alloc_eft_trace (vha);if (ha->eft) eft_size =EFT_SIZE ; }
@@ -4258,7 +4266,6 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)struct qla_hw_data *ha = vha->hw;struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;unsigned long flags; -uint16_t fw_major_version;int done_once =0 ;if (IS_P3P_TYPE (ha)) {
@@ -4325,7 +4332,6 @@ execute_fw_with_lr: goto failed; enable_82xx_npiv: - fw_major_version = ha->fw_major_version;if (IS_P3P_TYPE (ha))qla82xx_check_md_needed (vha);else
@@ -4354,12 +4360,11 @@ enable_82xx_npiv:if (rval !=QLA_SUCCESS ) goto failed; -if (!fw_major_version && !(IS_P3P_TYPE (ha))) -qla2x00_alloc_offload_mem (vha); -if (ql2xallocfwdump && !(IS_P3P_TYPE (ha)))qla2x00_alloc_fw_dump (vha); +qla_enable_fce_trace (vha); +qla_enable_eft_trace (vha); }else { goto failed; }
@@ -7544,7 +7549,6 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_int qla2x00_abort_isp (scsi_qla_host_t *vha) { -int rval;uint8_t status =0 ;struct qla_hw_data *ha = vha->hw;struct scsi_qla_host *vp, *tvp;
@@ -7638,31 +7642,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)if (IS_QLA81XX (ha) ||IS_QLA8031 (ha))qla2x00_get_fw_version (vha); -if (ha->fce) { - ha->flags.fce_enabled =1 ; -memset (ha->fce,0 , -fce_calc_size (ha->fce_bufs)); - rval =qla2x00_enable_fce_trace (vha, - ha->fce_dma, ha->fce_bufs, ha->fce_mb, - &ha->fce_bufs); -if (rval) { -ql_log (ql_log_warn, vha,0x8033 , -"Unable to reinitialize FCE " -"(%d).\n" , rval); - ha->flags.fce_enabled =0 ; - } - } -if (ha->eft) { -memset (ha->eft,0 ,EFT_SIZE ); - rval =qla2x00_enable_eft_trace (vha, - ha->eft_dma,EFT_NUM_BUFFERS ); -if (rval) { -ql_log (ql_log_warn, vha,0x8034 , -"Unable to reinitialize EFT " -"(%d).\n" , rval); - } - } }else {/* failed the ISP abort */ vha->flags.online =1 ;if (test_bit (ISP_ABORT_RETRY , &vha->dpc_flags)) {
Greg Kroah-Hartman
maintainerPATCH 258/272 scsi: qla2xxx: Update manufacturer detail
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bikash Hazarika <[email protected]>
commit 688fa069fda6fce24d243cddfe0c7024428acb74 upstream.
Update manufacturer detail from "Marvell Semiconductor, Inc." to "Marvell".
--- drivers/scsi/qla2xxx/qla_def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_def.h +1 -1
@@ -83,7 +83,7 @@ typedef union {#include "qla_nvme.h" #define QLA2XXX_DRIVER_NAME "qla2xxx"#define QLA2XXX_APIDEV "ql2xapidev" -#define QLA2XXX_MANUFACTURER "Marvell Semiconductor, Inc." +#define QLA2XXX_MANUFACTURER "Marvell"/* * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
Greg Kroah-Hartman
maintainerPATCH 259/272 scsi: qla2xxx: NVME|FCP prefer flag not being honored
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 69aecdd410106dc3a8f543a4f7ec6379b995b8d0 upstream.
Changing of [FCP|NVME] prefer flag in flash has no effect on driver. For device that supports both FCP + NVMe over the same connection, driver continues to connect to this device using the previous successful login mode.
On completion of flash update, adapter will be reset. Driver will reset the prefer flag based on setting from flash.
--- drivers/scsi/qla2xxx/qla_init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/scsi/qla2xxx/qla_init.c +18 -0
@@ -7554,6 +7554,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)struct scsi_qla_host *vp, *tvp;struct req_que *req = ha->req_q_map[0 ];unsigned long flags; +fc_port_t *fcport;if (vha->flags.online) {qla2x00_abort_isp_cleanup (vha);
@@ -7622,6 +7623,15 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) "ISP Abort - ISP reg disconnect post nvmram config, exiting.\n");return status; } + +/* User may have updated [fcp|nvme] prefer in flash */ +list_for_each_entry (fcport, &vha->vp_fcports, list) { +if (NVME_PRIORITY (ha, fcport)) + fcport->do_prli_nvme =1 ; +else + fcport->do_prli_nvme =0 ; + } +if (!qla2x00_restart_isp (vha)) {clear_bit (RESET_MARKER_NEEDED , &vha->dpc_flags);
@@ -7692,6 +7702,14 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)atomic_inc (&vp->vref_count);spin_unlock_irqrestore (&ha->vport_slock, flags); +/* User may have updated [fcp|nvme] prefer in flash */ +list_for_each_entry (fcport, &vp->vp_fcports, list) { +if (NVME_PRIORITY (ha, fcport)) + fcport->do_prli_nvme =1 ; +else + fcport->do_prli_nvme =0 ; + } +qla2x00_vp_abort_isp (vp);spin_lock_irqsave (&ha->vport_slock, flags);
Greg Kroah-Hartman
maintainerPATCH 260/272 scsi: qla2xxx: Fix command flush on cable pull
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit a27d4d0e7de305def8a5098a614053be208d1aa1 upstream.
System crash due to command failed to flush back to SCSI layer.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 PGD 0 P4D 0 Oops: 0000 [#1] SMP NOPTI CPU: 27 PID: 793455 Comm: kworker/u130:6 Kdump: loaded Tainted: G OE --------- - - 4.18.0-372.9.1.el8.x86_64 #1 Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 09/03/2021 Workqueue: nvme-wq nvme_fc_connect_ctrl_work [nvme_fc] RIP: 0010:__wake_up_common+0x4c/0x190 Code: 24 10 4d 85 c9 74 0a 41 f6 01 04 0f 85 9d 00 00 00 48 8b 43 08 48 83 c3 08 4c 8d 48 e8 49 8d 41 18 48 39 c3 0f 84 f0 00 00 00 <49> 8b 41 18 89 54 24 08 31 ed 4c 8d 70 e8 45 8b 29 41 f6 c5 04 75 RSP: 0018:ffff95f3e0cb7cd0 EFLAGS: 00010086 RAX: 0000000000000000 RBX: ffff8b08d3b26328 RCX: 0000000000000000 RDX: 0000000000000001 RSI: 0000000000000003 RDI: ffff8b08d3b26320 RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffffffffffe8 R10: 0000000000000000 R11: ffff95f3e0cb7a60 R12: ffff95f3e0cb7d20 R13: 0000000000000003 R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff8b2fdf6c0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000002f1e410002 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: __wake_up_common_lock+0x7c/0xc0 qla_nvme_ls_req+0x355/0x4c0 [qla2xxx] qla2xxx [0000:12:00.1]-f084:3: qlt_free_session_done: se_sess 0000000000000000 / sess ffff8ae1407ca000 from port 21:32:00:02:ac:07:ee:b8 loop_id 0x02 s_id 01:02:00 logout 1 keep 0 els_logo 0 ? __nvme_fc_send_ls_req+0x260/0x380 [nvme_fc] qla2xxx [0000:12:00.1]-207d:3: FCPort 21:32:00:02:ac:07:ee:b8 state transitioned from ONLINE to LOST - portid=010200. ? nvme_fc_send_ls_req.constprop.42+0x1a/0x45 [nvme_fc] qla2xxx [0000:12:00.1]-2109:3: qla2x00_schedule_rport_del 21320002ac07eeb8. rport ffff8ae598122000 roles 1 ? nvme_fc_connect_ctrl_work.cold.63+0x1e3/0xa7d [nvme_fc] qla2xxx [0000:12:00.1]-f084:3: qlt_free_session_done: se_sess 0000000000000000 / sess ffff8ae14801e000 from port 21:32:01:02:ad:f7:ee:b8 loop_id 0x04 s_id 01:02:01 logout 1 keep 0 els_logo 0 ? __switch_to+0x10c/0x450 ? process_one_work+0x1a7/0x360 qla2xxx [0000:12:00.1]-207d:3: FCPort 21:32:01:02:ad:f7:ee:b8 state transitioned from ONLINE to LOST - portid=010201. ? worker_thread+0x1ce/0x390 ? create_worker+0x1a0/0x1a0 qla2xxx [0000:12:00.1]-2109:3: qla2x00_schedule_rport_del 21320102adf7eeb8. rport ffff8ae3b2312800 roles 70 ? kthread+0x10a/0x120 qla2xxx [0000:12:00.1]-2112:3: qla_nvme_unregister_remote_port: unregister remoteport on ffff8ae14801e000 21320102adf7eeb8 ? set_kthread_struct+0x40/0x40 qla2xxx [0000:12:00.1]-2110:3: remoteport_delete of ffff8ae14801e000 21320102adf7eeb8 completed. ? ret_from_fork+0x1f/0x40 qla2xxx [0000:12:00.1]-f086:3: qlt_free_session_done: waiting for sess ffff8ae14801e000 logout
The system was under memory stress where driver was not able to allocate an SRB to carry out error recovery of cable pull. The failure to flush causes upper layer to start modifying scsi_cmnd. When the system frees up some memory, the subsequent cable pull trigger another command flush. At this point the driver access a null pointer when attempting to DMA unmap the SGL.
Add a check to make sure commands are flush back on session tear down to prevent the null pointer access.
--- drivers/scsi/qla2xxx/qla_target.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/qla2xxx/qla_target.c +10 -0
@@ -1079,6 +1079,16 @@ void qlt_free_session_done(struct work_s "%s: sess %p logout completed\n", __func__, sess); } +/* check for any straggling io left behind */ +if (!(sess->flags &FCF_FCP2_DEVICE ) && +qla2x00_eh_wait_for_pending_commands (sess->vha, sess->d_id.b24,0 ,WAIT_TARGET )) { +ql_log (ql_log_warn, vha,0x3027 , +"IO not return. Resetting.\n" ); +set_bit (ISP_ABORT_NEEDED , &vha->dpc_flags); +qla2xxx_wake_dpc (vha); +qla2x00_wait_for_chip_reset (vha); + } +if (sess->logo_ack_needed) { sess->logo_ack_needed =0 ; qla24xx_async_notify_ack(vha, sess,
Greg Kroah-Hartman
maintainerPATCH 261/272 scsi: qla2xxx: Fix double free of fcport
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurav Kashyap <[email protected]>
commit 82f522ae0d97119a43da53e0f729275691b9c525 upstream.
The server was crashing after LOGO because fcport was getting freed twice.
-----------[ cut here ]-----------
kernel BUG at mm/slub.c:371!
invalid opcode: 0000 1 SMP PTI
CPU: 35 PID: 4610 Comm: bash Kdump: loaded Tainted: G OE --------- - - 4.18.0-425.3.1.el8.x86_64 #1 Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 09/03/2021 RIP: 0010:set_freepointer.part.57+0x0/0x10 RSP: 0018:ffffb07107027d90 EFLAGS: 00010246 RAX: ffff9cb7e3150000 RBX: ffff9cb7e332b9c0 RCX: ffff9cb7e3150400 RDX: 0000000000001f37 RSI: 0000000000000000 RDI: ffff9cb7c0005500 RBP: fffff693448c5400 R08: 0000000080000000 R09: 0000000000000009 R10: 0000000000000000 R11: 0000000000132af0 R12: ffff9cb7c0005500 R13: ffff9cb7e3150000 R14: ffffffffc06990e0 R15: ffff9cb7ea85ea58 FS: 00007ff6b79c2740(0000) GS:ffff9cb8f7ec0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055b426b7d700 CR3: 0000000169c18002 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: kfree+0x238/0x250 qla2x00_els_dcmd_sp_free+0x20/0x230 [qla2xxx] ? qla24xx_els_dcmd_iocb+0x607/0x690 [qla2xxx] qla2x00_issue_logo+0x28c/0x2a0 [qla2xxx] ? qla2x00_issue_logo+0x28c/0x2a0 [qla2xxx] ? kernfs_fop_write+0x11e/0x1a0
Remove one of the free calls and add check for valid fcport. Also use function qla2x00_free_fcport() instead of kfree().
--- drivers/scsi/qla2xxx/qla_iocb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_iocb.c +3 -2
@@ -2638,7 +2638,8 @@ static void qla2x00_els_dcmd_sp_free(srb {struct srb_iocb *elsio = &sp->u.iocb_cmd; -kfree (sp->fcport); +if (sp->fcport) +qla2x00_free_fcport (sp->fcport);if (elsio->u.els_logo.els_logo_pyld) dma_free_coherent(&sp->vha->hw->pdev->dev, DMA_POOL_SIZE,
@@ -2751,6 +2752,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vif (!elsio->u.els_logo.els_logo_pyld) {/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release); +qla2x00_free_fcport (fcport);return QLA_FUNCTION_FAILED ; }
@@ -2785,7 +2787,6 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v fcport->d_id.b.area, fcport->d_id.b.al_pa);wait_for_completion (&elsio->u.els_logo.comp); -qla2x00_free_fcport (fcport);/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release);
Greg Kroah-Hartman
maintainerPATCH 262/272 scsi: qla2xxx: Change debug message during driver unload
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurav Kashyap <[email protected]>
commit b5a30840727a3e41d12a336d19f6c0716b299161 upstream.
Upon driver unload, purge_mbox flag is set and the heartbeat monitor thread detects this flag and does not send the mailbox command down to FW with a debug message "Error detected: purge[1] eeh[0] cmd=0x0, Exiting". This being not a real error, change the debug message.
--- drivers/scsi/qla2xxx/qla_mbx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_mbx.c +1 -1
@@ -194,7 +194,7 @@ qla2x00_mailbox_command(scsi_qla_host_tif (ha->flags.purge_mbox || chip_reset != ha->chip_reset || ha->flags.eeh_busy) {ql_log (ql_log_warn, vha,0xd035 , -"Error detected: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n" , +"Purge mbox: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n" , ha->flags.purge_mbox, ha->flags.eeh_busy, mcp->mb[0 ]); rval =QLA_ABORTED ; goto premature_exit;
Greg Kroah-Hartman
maintainerPATCH 263/272 scsi: qla2xxx: Delay I/O Abort on PCI error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 591c1fdf2016d118b8fbde427b796fac13f3f070 upstream.
Currently when PCI error is detected, I/O is aborted manually through the ABORT IOCB mechanism which is not guaranteed to succeed.
Instead, wait for the OS or system to notify driver to wind down I/O through the pci_error_handlers api. Set eeh_busy flag to pause all traffic and wait for I/O to drain.
--- drivers/scsi/qla2xxx/qla_attr.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +12 -2
@@ -2741,7 +2741,13 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rpreturn ;if (unlikely (pci_channel_offline (fcport->vha->hw->pdev))) { -qla2x00_abort_all_cmds (fcport->vha,DID_NO_CONNECT <<16 ); +/* Will wait for wind down of adapter */ +ql_dbg (ql_dbg_aer, fcport->vha,0x900c , +"%s pci offline detected (id %06x)\n" , __func__, + fcport->d_id.b24); +qla_pci_set_eeh_busy (fcport->vha); +qla2x00_eh_wait_for_pending_commands (fcport->vha, fcport->d_id.b24, +0 ,WAIT_TARGET );return ; } }
@@ -2763,7 +2769,11 @@ qla2x00_terminate_rport_io(struct fc_rpo vha = fcport->vha;if (unlikely (pci_channel_offline (fcport->vha->hw->pdev))) { -qla2x00_abort_all_cmds (fcport->vha,DID_NO_CONNECT <<16 ); +/* Will wait for wind down of adapter */ +ql_dbg (ql_dbg_aer, fcport->vha,0x900b , +"%s pci offline detected (id %06x)\n" , __func__, + fcport->d_id.b24); +qla_pci_set_eeh_busy (vha);qla2x00_eh_wait_for_pending_commands (fcport->vha, fcport->d_id.b24,0 ,WAIT_TARGET );return ;
Greg Kroah-Hartman
maintainerPATCH 264/272 x86/cpu: Enable STIBP on AMD if Automatic IBRS is enabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kim Phillips <[email protected]>
commit fd470a8beed88440b160d690344fbae05a0b9b1b upstream.
Unlike Intel's Enhanced IBRS feature, AMD's Automatic IBRS does not provide protection to processes running at CPL3/user mode, see section "Extended Feature Enable Register (EFER)" in the APM v2 at
https://bugzilla.kernel.org/attachment.cgi?id=304652
Explicitly enable STIBP to protect against cross-thread CPL3 branch target injections on systems with Automatic IBRS enabled.
Also update the relevant documentation.
--- Documentation/admin-guide/hw-vuln/spectre.rst | 11 +++++++---- arch/x86/kernel/cpu/bugs.c | 15 +++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-)
Documentation/admin-guide/hw-vuln/spectre.rst +7 -4
@@ -484,11 +484,14 @@ Spectre variant 2 Systems which support enhanced IBRS (eIBRS) enable IBRS protection once at boot, by setting the IBRS bit, and they're automatically protected against - Spectre v2 variant attacks, including cross-thread branch target injections - on SMT systems (STIBP). In other words, eIBRS enables STIBP too. + Spectre v2 variant attacks. - Legacy IBRS systems clear the IBRS bit on exit to userspace and - therefore explicitly enable STIBP for that + On Intel's enhanced IBRS systems, this includes cross-thread branch target + injections on SMT systems (STIBP). In other words, Intel eIBRS enables + STIBP, too. + + AMD Automatic IBRS does not protect userspace, and Legacy IBRS systems clear + the IBRS bit on exit to userspace, therefore both explicitly enable STIBP. The retpoline mitigation is turned on by default on vulnerable CPUs. It can be forced on or off by the administrator
arch/x86/kernel/cpu/bugs.c +9 -6
@@ -1354,19 +1354,21 @@ spectre_v2_user_select_mitigation(void) }/* -* If no STIBP, enhanced IBRS is enabled, or SMT impossible, STIBP +* If no STIBP, Intel enhanced IBRS is enabled, or SMT impossible, STIBP * is not required. * -* Enhanced IBRS also protects against cross-thread branch target +* Intel's Enhanced IBRS also protects against cross-thread branch target * injection in user-mode as the IBRS bit remains always set which * implicitly enables cross-thread protections. However, in legacy IBRS * mode, the IBRS bit is set only on kernel entry and cleared on return -* to userspace. This disables the implicit cross-thread protection, -* so allow for STIBP to be selected in that case. +* to userspace. AMD Automatic IBRS also does not protect userspace. +* These modes therefore disable the implicit cross-thread protection, +* so allow for STIBP to be selected in those cases. */ if (!boot_cpu_has (X86_FEATURE_STIBP ) || !smt_possible || -spectre_v2_in_eibrs_mode (spectre_v2_enabled)) + (spectre_v2_in_eibrs_mode (spectre_v2_enabled) && + !boot_cpu_has (X86_FEATURE_AUTOIBRS )))return ;/*
@@ -2666,7 +2668,8 @@ static ssize_t rfds_show_state(char *bufstatic char *stibp_state (void ) { -if (spectre_v2_in_eibrs_mode (spectre_v2_enabled)) +if (spectre_v2_in_eibrs_mode (spectre_v2_enabled) && + !boot_cpu_has (X86_FEATURE_AUTOIBRS ))return "" ;switch (spectre_v2_user_stibp) {
Greg Kroah-Hartman
maintainerPATCH 265/272 tls: fix use-after-free on failed backlog decryption
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
commit 13114dc5543069f7b97991e3b79937b6da05f5b0 upstream.
When the decrypt request goes to the backlog and crypto_aead_decrypt returns -EBUSY, tls_do_decryption will wait until all async decryptions have completed. If one of them fails, tls_do_decryption will return -EBADMSG and tls_decrypt_sg jumps to the error path, releasing all the pages. But the pages have been passed to the async callback, and have already been released by tls_decrypt_done.
The only true async case is when crypto_aead_decrypt returns
-EINPROGRESS. With -EBUSY, we already waited so we can telltls_sw_recvmsg that the data is available for immediate copy, but we need to notify tls_decrypt_sg (via the new ->async_done flag) that the memory has already been released.
--- net/tls/tls_sw.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
net/tls/tls_sw.c +16 -8
@@ -51,6 +51,7 @@ struct tls_decrypt_arg {struct_group (inargs, bool zc; bool async; +bool async_done;u8 tail; );
@@ -279,18 +280,19 @@ static int tls_do_decryption(struct sock } ret =crypto_aead_decrypt (aead_req); +if (ret == -EINPROGRESS ) +return 0 ; +if (ret == -EBUSY ) { ret =tls_decrypt_async_wait (ctx); + darg->async_done = true; +/* all completions have run, we're not doing async anymore */ + darg->async = false; +return ret; ret = ret ?: -EINPROGRESS ; } -if (ret == -EINPROGRESS ) { -if (darg->async) -return 0 ; - ret =crypto_wait_req (ret, &ctx->async_wait); - }else if (darg->async) { -atomic_dec (&ctx->decrypt_pending); - } +atomic_dec (&ctx->decrypt_pending); darg->async = false;return ret;
@@ -1681,8 +1683,11 @@ static int tls_decrypt_sg(struct sock *s/* Prepare and submit AEAD request */ err =tls_do_decryption (sk, sgin, sgout, dctx->iv, data_len + prot->tail_size, aead_req, darg); -if (err) +if (err) { +if (darg->async_done) + goto exit_free_skb; goto exit_free_pages; + } darg->skb = clear_skb ?:tls_strp_msg (ctx); clear_skb =NULL ;
@@ -1694,6 +1699,9 @@ static int tls_decrypt_sg(struct sock *sreturn err; } +if (unlikely (darg->async_done)) +return 0 ; +if (prot->tail_size) darg->tail = dctx->tail;
Greg Kroah-Hartman
maintainerPATCH 266/272 scsi: lpfc: Correct size for cmdwqe/rspwqe for memset()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
commit 16cc2ba71b9f6440805aef7f92ba0f031f79b765 upstream.
The cmdwqe and rspwqe are of type lpfc_wqe128. They should be memset() with the same type.
--- drivers/scsi/lpfc/lpfc_bsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_bsg.c +2 -2
@@ -3169,10 +3169,10 @@ lpfc_bsg_diag_loopback_run(struct bsg_jo } cmdwqe = &cmdiocbq->wqe; -memset (cmdwqe,0 ,sizeof (union lpfc_wqe )); +memset (cmdwqe,0 ,sizeof (*cmdwqe));if (phba->sli_rev <LPFC_SLI_REV4 ) { rspwqe = &rspiocbq->wqe; -memset (rspwqe,0 ,sizeof (union lpfc_wqe )); +memset (rspwqe,0 ,sizeof (*rspwqe)); }INIT_LIST_HEAD (&head);
Greg Kroah-Hartman
maintainerPATCH 267/272 scsi: lpfc: Correct size for wqe for memset()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
commit 28d41991182c210ec1654f8af2e140ef4cc73f20 upstream.
The wqe is of type lpfc_wqe128. It should be memset with the same type.
--- drivers/scsi/lpfc/lpfc_nvmet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_nvmet.c +1 -1
@@ -1586,7 +1586,7 @@ lpfc_nvmet_setup_io_context(struct lpfc_ wqe = &nvmewqe->wqe;/* Initialize WQE */ -memset (wqe,0 ,sizeof (union lpfc_wqe )); +memset (wqe,0 ,sizeof (*wqe)); ctx_buf->iocbq->cmd_dmabuf =NULL ;spin_lock (&phba->sli4_hba.sgl_list_lock);
Greg Kroah-Hartman
maintainerPATCH 268/272 scsi: libsas: Add a helper sas_get_sas_addr_and_dev_type()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
commit a57345279fd311ba679b8083feb0eec5272c7729 upstream.
Add a helper to get attached_sas_addr and device type from disc_resp.
--- drivers/scsi/libsas/sas_expander.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/scsi/libsas/sas_expander.c +12 -7
@@ -1651,6 +1651,16 @@ out_err:/* ---------- Domain revalidation ---------- */ +static void sas_get_sas_addr_and_dev_type (struct smp_disc_resp *disc_resp, +u8 *sas_addr, +enum sas_device_type *type) +{ +memcpy (sas_addr, disc_resp->disc.attached_sas_addr,SAS_ADDR_SIZE ); + *type =to_dev_type (&disc_resp->disc); +if (*type ==SAS_PHY_UNUSED ) +memset (sas_addr,0 ,SAS_ADDR_SIZE ); +} +static int sas_get_phy_discover (struct domain_device *dev,int phy_id,struct smp_disc_resp *disc_resp) {
@@ -1704,13 +1714,8 @@ int sas_get_phy_attached_dev(struct domareturn -ENOMEM ; res =sas_get_phy_discover (dev, phy_id, disc_resp); -if (res ==0 ) { -memcpy (sas_addr, disc_resp->disc.attached_sas_addr, -SAS_ADDR_SIZE ); - *type =to_dev_type (&disc_resp->disc); -if (*type ==0 ) -memset (sas_addr,0 ,SAS_ADDR_SIZE ); - } +if (res ==0 ) +sas_get_sas_addr_and_dev_type (disc_resp, sas_addr, type);kfree (disc_resp);return res; }
Greg Kroah-Hartman
maintainerPATCH 269/272 scsi: libsas: Fix disk not being scanned in after being removed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
commit 8e68a458bcf5b5cb9c3624598bae28f08251601f upstream.
As of commit d8649fc1c5e4 ("scsi: libsas: Do discovery on empty PHY to update PHY info"), do discovery will send a new SMP_DISCOVER and update phy->phy_change_count. We found that if the disk is reconnected and phy change_count changes at this time, the disk scanning process will not be triggered.
Therefore, call sas_set_ex_phy() to update the PHY info with the results of the last query. And because the previous phy info will be used when calling sas_unregister_devs_sas_addr(), sas_unregister_devs_sas_addr() should be called before sas_set_ex_phy().
--- drivers/scsi/libsas/sas_expander.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/scsi/libsas/sas_expander.c +22 -10
@@ -1977,6 +1977,7 @@ static int sas_rediscover_dev(struct domstruct expander_device *ex = &dev->ex_dev;struct ex_phy *phy = &ex->ex_phy[phy_id];enum sas_device_type type =SAS_PHY_UNUSED ; +struct smp_disc_resp *disc_resp;u8 sas_addr[SAS_ADDR_SIZE ];char msg[80 ] ="" ;int res;
@@ -1988,33 +1989,41 @@ static int sas_rediscover_dev(struct dom SAS_ADDR(dev->sas_addr), phy_id, msg);memset (sas_addr,0 ,SAS_ADDR_SIZE ); - res =sas_get_phy_attached_dev (dev, phy_id, sas_addr, &type); + disc_resp =alloc_smp_resp (DISCOVER_RESP_SIZE ); +if (!disc_resp) +return -ENOMEM ; + + res =sas_get_phy_discover (dev, phy_id, disc_resp);switch (res) {case SMP_RESP_NO_PHY : phy->phy_state =PHY_NOT_PRESENT ;sas_unregister_devs_sas_addr (dev, phy_id, last); -return res; + goto out_free_resp;case SMP_RESP_PHY_VACANT : phy->phy_state =PHY_VACANT ;sas_unregister_devs_sas_addr (dev, phy_id, last); -return res; + goto out_free_resp;case SMP_RESP_FUNC_ACC :break ;case -ECOMM :break ;default : -return res; + goto out_free_resp; } +if (res ==0 ) +sas_get_sas_addr_and_dev_type (disc_resp, sas_addr, &type); +if ((SAS_ADDR (sas_addr) ==0 ) || (res == -ECOMM )) { phy->phy_state =PHY_EMPTY ;sas_unregister_devs_sas_addr (dev, phy_id, last);/* -* Even though the PHY is empty, for convenience we discover -* the PHY to update the PHY info, like negotiated linkrate. +* Even though the PHY is empty, for convenience we update +* the PHY info, like negotiated linkrate. */ -sas_ex_phy_discover (dev, phy_id); -return res; +if (res ==0 ) +sas_set_ex_phy (dev, phy_id, disc_resp); + goto out_free_resp; }else if (SAS_ADDR (sas_addr) ==SAS_ADDR (phy->attached_sas_addr) &&dev_type_flutter (type, phy->attached_dev_type)) {struct domain_device *ata_dev =sas_ex_to_ata (dev, phy_id);
@@ -2026,7 +2035,7 @@ static int sas_rediscover_dev(struct dom action =", needs recovery" ;pr_debug ("ex %016llx phy%02d broadcast flutter%s\n" ,SAS_ADDR (dev->sas_addr), phy_id, action); -return res; + goto out_free_resp; }/* we always have to delete the old device when we went here */
@@ -2035,7 +2044,10 @@ static int sas_rediscover_dev(struct dom SAS_ADDR(phy->attached_sas_addr));sas_unregister_devs_sas_addr (dev, phy_id, last); -return sas_discover_new (dev, phy_id); + res =sas_discover_new (dev, phy_id); +out_free_resp: +kfree (disc_resp); +return res; }/**