6.7.7-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 121/334 firewire: core: send bus reset promptly on gap count error
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit 7ed4380009e96d9e9c605e12822e987b35b05648 ]
If we are bus manager and the bus has inconsistent gap counts, send a bus reset immediately instead of trying to read the root node's config ROM first. Otherwise, we could spend a lot of time trying to read the config ROM but never succeeding.
This eliminates a 50+ second delay before the FireWire bus is usable after a newly connected device is powered on in certain circumstances.
The delay occurs if a gap count inconsistency occurs, we are not the root node, and we become bus manager. One scenario that causes this is with a TI XIO2213B OHCI, the first time a Sony DSR-25 is powered on after being connected to the FireWire cable. In this configuration, the Linux box will not receive the initial PHY configuration packet sent by the DSR-25 as IRM, resulting in the DSR-25 having a gap count of 44 while the Linux box has a gap count of 63.
FireWire devices have a gap count parameter, which is set to 63 on power-up and can be changed with a PHY configuration packet. This determines the duration of the subaction and arbitration gaps. For reliable communication, all nodes on a FireWire bus must have the same gap count.
A node may have zero or more of the following roles: root node, bus manager (BM), isochronous resource manager (IRM), and cycle master. Unless a root node was forced with a PHY configuration packet, any node might become root node after a bus reset. Only the root node can become cycle master. If the root node is not cycle master capable, the BM or IRM should force a change of root node.
After a bus reset, each node sends a self-ID packet, which contains its current gap count. A single bus reset does not change the gap count, but two bus resets in a row will set the gap count to 63. Because a consistent gap count is required for reliable communication, IEEE 1394a-2000 requires that the bus manager generate a bus reset if it detects that the gap count is inconsistent.
When the gap count is inconsistent, build_tree() will notice this after the self identification process. It will set card->gap_count to the invalid value 0. If we become bus master, this will force bm_work() to send a bus reset when it performs gap count optimization.
After a bus reset, there is no bus manager. We will almost always try to become bus manager. Once we become bus manager, we will first determine whether the root node is cycle master capable. Then, we will determine if the gap count should be changed. If either the root node or the gap count should be changed, we will generate a bus reset.
To determine if the root node is cycle master capable, we read its configuration ROM. bm_work() will wait until we have finished trying to read the configuration ROM.
However, an inconsistent gap count can make this take a long time. read_config_rom() will read the first few quadlets from the config ROM. Due to the gap count inconsistency, eventually one of the reads will time out. When read_config_rom() fails, fw_device_init() calls it again until MAX_RETRIES is reached. This takes 50+ seconds.
Once we give up trying to read the configuration ROM, bm_work() will wake up, assume that the root node is not cycle master capable, and do a bus reset. Hopefully, this will resolve the gap count inconsistency.
This change makes bm_work() check for an inconsistent gap count before waiting for the root node's configuration ROM. If the gap count is inconsistent, bm_work() will immediately do a bus reset. This eliminates the 50+ second delay and rapidly brings the bus to a working state.
I considered that if the gap count is inconsistent, a PHY configuration packet might not be successful, so it could be desirable to skip the PHY configuration packet before the bus reset in this case. However, IEEE 1394a-2000 and IEEE 1394-2008 say that the bus manager may transmit a PHY configuration packet before a bus reset when correcting a gap count error. Since the standard endorses this, I decided it's safe to retain the PHY configuration packet transmission.
Normally, after a topology change, we will reset the bus a maximum of 5 times to change the root node and perform gap count optimization. However, if there is a gap count inconsistency, we must always generate a bus reset. Otherwise the gap count inconsistency will persist and communication will be unreliable. For that reason, if there is a gap count inconstency, we generate a bus reset even if we already reached the 5 reset limit.
Reference: https://sourceforge.net/p/linux1394/mailman/message/58727806/
--- drivers/firewire/core-card.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/firewire/core-card.c +17 -1
@@ -429,7 +429,23 @@ static void bm_work(struct work_struct *work)*/ card->bm_generation = generation; -if (root_device ==NULL ) { +if (card->gap_count ==0 ) { +/* +* If self IDs have inconsistent gap counts, do a +* bus reset ASAP. The config rom read might never +* complete, so don't wait for it. However, still +* send a PHY configuration packet prior to the +* bus reset. The PHY configuration packet might +* fail, but 1394-2008 8.4.5.2 explicitly permits +* it in this case, so it should be safe to try. +*/ + new_root_id = local_id; +/* +* We must always send a bus reset if the gap count +* is inconsistent, so bypass the 5-reset limit. +*/ + card->bm_retries =0 ; + }else if (root_device ==NULL ) {/* * Either link_on is false, or we failed to read the * config rom. In either case, pick another root.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 122/334 libceph: fail sparse-read if the data length doesnt match
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiubo Li <[email protected]>
[ Upstream commit cd7d469c25704d414d71bf3644f163fb74e7996b ]
Once this happens that means there have bugs.
--- include/linux/ceph/osd_client.h | 3 ++- net/ceph/osd_client.c | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-)
include/linux/ceph/osd_client.h +2 -1
@@ -45,6 +45,7 @@ enum ceph_sparse_read_state {CEPH_SPARSE_READ_HDR =0 ,CEPH_SPARSE_READ_EXTENTS ,CEPH_SPARSE_READ_DATA_LEN , +CEPH_SPARSE_READ_DATA_PRE , CEPH_SPARSE_READ_DATA, };
@@ -64,7 +65,7 @@ struct ceph_sparse_read {u64 sr_req_len;/* orig request length */ u64 sr_pos;/* current pos in buffer */ int sr_index;/* current extent index */ -__le32 sr_datalen;/* length of actual data */ +u32 sr_datalen;/* length of actual data */ u32 sr_count;/* extent count in reply */ int sr_ext_len;/* length of extent array */ struct ceph_sparse_extent *sr_extent;/* extent array */
net/ceph/osd_client.c +15 -3
@@ -5856,8 +5856,8 @@ static int osd_sparse_read(struct ceph_connection *con,struct ceph_osd *o = con->private;struct ceph_sparse_read *sr = &o->o_sparse_read;u32 count = sr->sr_count; -u64 eoff, elen; -int ret; +u64 eoff, elen, len =0 ; +int i, ret;switch (sr->sr_state) {case CEPH_SPARSE_READ_HDR :
@@ -5909,8 +5909,20 @@ static int osd_sparse_read(struct ceph_connection *con,convert_extent_map (sr); ret =sizeof (sr->sr_datalen); *pbuf = (char *)&sr->sr_datalen; - sr->sr_state =CEPH_SPARSE_READ_DATA ; + sr->sr_state =CEPH_SPARSE_READ_DATA_PRE ;break ; +case CEPH_SPARSE_READ_DATA_PRE : +/* Convert sr_datalen to host-endian */ + sr->sr_datalen =le32_to_cpu ((__force __le32 )sr->sr_datalen); +for (i =0 ; i < count; i++) + len += sr->sr_extent[i].len; +if (sr->sr_datalen != len) { +pr_warn_ratelimited ("data len %u != extent len %llu\n" , + sr->sr_datalen, len); +return -EREMOTEIO ; + } + sr->sr_state =CEPH_SPARSE_READ_DATA ; + fallthrough;case CEPH_SPARSE_READ_DATA :if (sr->sr_index >= count) { sr->sr_state =CEPH_SPARSE_READ_HDR ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 123/334 ceph: always check dir caps asynchronously
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiubo Li <[email protected]>
[ Upstream commit 07045648c07c5632e0dfd5ce084d3cd0cec0258a ]
The MDS will issue the 'Fr' caps for async dirop, while there is buggy in kclient and it could miss releasing the async dirop caps, which is 'Fsxr'. And then the MDS will complain with:
"[WRN] client.xxx isn't responding to mclientcaps(revoke) ..."
So when releasing the dirop async requests or when they fail we should always make sure that being revoked caps could be released.
--- fs/ceph/caps.c | 6 ------ fs/ceph/mds_client.c | 9 ++++----- fs/ceph/mds_client.h | 2 +- fs/ceph/super.h | 2 -- 4 files changed, 5 insertions(+), 14 deletions(-)
fs/ceph/caps.c +0 -6
@@ -3216,7 +3216,6 @@ static int ceph_try_drop_cap_snap(struct ceph_inode_info *ci,enum put_cap_refs_mode {PUT_CAP_REFS_SYNC =0 , -PUT_CAP_REFS_NO_CHECK ,PUT_CAP_REFS_ASYNC , };
@@ -3332,11 +3331,6 @@ void ceph_put_cap_refs_async(struct ceph_inode_info *ci, int had)__ceph_put_cap_refs (ci, had,PUT_CAP_REFS_ASYNC ); } -void ceph_put_cap_refs_no_check_caps (struct ceph_inode_info *ci,int had) -{ -__ceph_put_cap_refs (ci, had,PUT_CAP_REFS_NO_CHECK ); -} -/* * Release @nr WRBUFFER refs on dirty pages for the given @snapc snap * context. Adjust per-snap dirty page accounting as appropriate.
fs/ceph/mds_client.c +4 -5
@@ -1089,7 +1089,7 @@ void ceph_mdsc_release_request(struct kref *kref)struct ceph_mds_request *req =container_of (kref, struct ceph_mds_request, r_kref); -ceph_mdsc_release_dir_caps_no_check (req); +ceph_mdsc_release_dir_caps_async (req);destroy_reply_info (&req->r_reply_info);if (req->r_request)ceph_msg_put (req->r_request);
@@ -4247,7 +4247,7 @@ void ceph_mdsc_release_dir_caps(struct ceph_mds_request *req) } } -void ceph_mdsc_release_dir_caps_no_check (struct ceph_mds_request *req) +void ceph_mdsc_release_dir_caps_async (struct ceph_mds_request *req) {struct ceph_client *cl = req->r_mdsc->fsc->client;int dcaps;
@@ -4255,8 +4255,7 @@ void ceph_mdsc_release_dir_caps_no_check(struct ceph_mds_request *req) dcaps =xchg (&req->r_dir_caps,0 );if (dcaps) {doutc (cl,"releasing r_dir_caps=%s\n" ,ceph_cap_string (dcaps)); -ceph_put_cap_refs_no_check_caps (ceph_inode (req->r_parent), - dcaps); +ceph_put_cap_refs_async (ceph_inode (req->r_parent), dcaps); } }
@@ -4292,7 +4291,7 @@ static void replay_unsafe_requests(struct ceph_mds_client *mdsc,if (req->r_session->s_mds != session->s_mds)continue ; -ceph_mdsc_release_dir_caps_no_check (req); +ceph_mdsc_release_dir_caps_async (req);__send_request (session, req, true); }
fs/ceph/mds_client.h +1 -1
@@ -552,7 +552,7 @@ extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,struct inode *dir, struct ceph_mds_request *req);extern void ceph_mdsc_release_dir_caps (struct ceph_mds_request *req); -extern void ceph_mdsc_release_dir_caps_no_check (struct ceph_mds_request *req); +extern void ceph_mdsc_release_dir_caps_async (struct ceph_mds_request *req);static inline void ceph_mdsc_get_request (struct ceph_mds_request *req) {kref_get (&req->r_kref);
fs/ceph/super.h +0 -2
@@ -1254,8 +1254,6 @@ extern void ceph_take_cap_refs(struct ceph_inode_info *ci, int caps,extern void ceph_get_cap_refs (struct ceph_inode_info *ci,int caps);extern void ceph_put_cap_refs (struct ceph_inode_info *ci,int had);extern void ceph_put_cap_refs_async (struct ceph_inode_info *ci,int had); -extern void ceph_put_cap_refs_no_check_caps (struct ceph_inode_info *ci, -int had);extern void ceph_put_wrbuffer_cap_refs (struct ceph_inode_info *ci,int nr,struct ceph_snap_context *snapc); extern void __ceph_remove_capsnap(struct inode *inode,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 124/334 drm/amdgpu: skip to program GFXDEC registers for suspend abort
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prike Liang <[email protected]>
[ Upstream commit 93bafa32a6918154aa0caf9f66679a32c2431357 ]
In the suspend abort cases, the gfx power rail doesn't turn off so some GFXDEC registers/CSB can't reset to default value and at this moment reinitialize GFXDEC/CSB will result in an unexpected error. So let skip those program sequence for the suspend abort case.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 8 ++++++++ 3 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1041,6 +1041,8 @@ struct amdgpu_device {bool in_s3;bool in_s4;bool in_s0ix; +/* indicate amdgpu suspension status */ +bool suspend_complete;enum pp_mp1_state mp1_state;struct amdgpu_doorbell_index doorbell_index;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
@@ -2449,6 +2449,7 @@ static int amdgpu_pmops_suspend(struct device *dev)struct drm_device *drm_dev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (drm_dev); + adev->suspend_complete = false;if (amdgpu_acpi_is_s0ix_active (adev)) adev->in_s0ix = true;else if (amdgpu_acpi_is_s3_active (adev))
@@ -2463,6 +2464,7 @@ static int amdgpu_pmops_suspend_noirq(struct device *dev)struct drm_device *drm_dev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (drm_dev); + adev->suspend_complete = true;if (amdgpu_acpi_should_gpu_reset (adev))return amdgpu_asic_reset (adev);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +8 -0
@@ -3034,6 +3034,14 @@ static int gfx_v9_0_cp_gfx_start(struct amdgpu_device *adev)gfx_v9_0_cp_gfx_enable (adev, true); +/* Now only limit the quirk on the APU gfx9 series and already +* confirmed that the APU gfx10/gfx11 needn't such update. +*/ +if (adev->flags &AMD_IS_APU && + adev->in_s3 && !adev->suspend_complete) { +DRM_INFO (" Will skip the CSB packet resubmit\n" ); +return 0 ; + } r =amdgpu_ring_alloc (ring,gfx_v9_0_get_csb_size (adev) +4 +3 );if (r) {DRM_ERROR ("amdgpu: cp failed to lock ring (%d).\n" , r);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 125/334 drm/amdgpu: reset gpu for s3 suspend abort case
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prike Liang <[email protected]>
[ Upstream commit 6ef82ac664bb9568ca3956e0d9c9c478e25077ff ]
In the s3 suspend abort case some type of gfx9 power rail not turn off from FCH side and this will put the GPU in an unknown power status, so let's reset the gpu to a known good power state before reinitialize gpu device.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc15.c +22 -0
@@ -1297,10 +1297,32 @@ static int soc15_common_suspend(void *handle)return soc15_common_hw_fini (adev); } +static bool soc15_need_reset_on_resume (struct amdgpu_device *adev) +{ +u32 sol_reg; + + sol_reg =RREG32_SOC15 (MP0 ,0 , mmMP0_SMN_C2PMSG_81); + +/* Will reset for the following suspend abort cases. +* 1) Only reset limit on APU side, dGPU hasn't checked yet. +* 2) S3 suspend abort and TOS already launched. +*/ +if (adev->flags &AMD_IS_APU && adev->in_s3 && + !adev->suspend_complete && + sol_reg) +return true; + +return false; +} +static int soc15_common_resume (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (soc15_need_reset_on_resume (adev)) { +dev_info (adev->dev,"S3 suspend abort case, let's reset ASIC.\n" ); +soc15_asic_reset (adev); + }return soc15_common_hw_init (adev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 126/334 drm/amdgpu: Fix shared buff copy to user
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley.Yang <[email protected]>
[ Upstream commit 2dcf82a8e8dc930655787797ef8a3692b527c7a9 ]
ta if invoke node buffer
|-------- ta type ----------| |-------- ta id ----------| |-------- cmd id ----------| |------ shared buf len -----| |------ shared buffer ------|
ta if invoke node buffer is as above, copy shared buffer data to correct location
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1 -1
@@ -362,7 +362,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size } } -if (copy_to_user ((char *)buf, context->mem_context.shared_buf, shared_buf_len)) +if (copy_to_user ((char *)&buf[copy_pos], context->mem_context.shared_buf, shared_buf_len)) ret = -EFAULT ; err_free_shared_buf:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 117/334 LoongArch: vDSO: Disable UBSAN instrumentation
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit cca5efe77a6a2d02b3da4960f799fa233e460ab1 ]
The vDSO executes in userspace, so the kernel's UBSAN should not instrument it. Solves these kind of build errors:
loongarch64-linux-ld: arch/loongarch/vdso/vgettimeofday.o: in function `vdso_shift_ns':
lib/vdso/gettimeofday.c:23:(.text+0x3f8): undefined reference to `__ubsan_handle_shift_out_of_bounds'
--- arch/loongarch/vdso/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/loongarch/vdso/Makefile +1 -0
@@ -2,6 +2,7 @@ # Objects to go into the VDSO. KASAN_SANITIZE := n +UBSAN_SANITIZE := n KCOV_INSTRUMENT := n # Include the generic Makefile to check the built vdso.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 148/334 drm/ttm: Fix an invalid freeing on already freed page in error path
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <[email protected]>
commit 40510a941d27d405a82dc3320823d875f94625df upstream.
If caching mode change fails due to, for example, OOM we free the allocated pages in a two-step process. First the pages for which the caching change has already succeeded. Secondly the pages for which a caching change did not succeed.
However the second step was incorrectly freeing the pages already freed in the first step.
Fix.
--- drivers/gpu/drm/ttm/ttm_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_pool.c +1 -1
@@ -387,7 +387,7 @@ static void ttm_pool_free_range(struct tenum ttm_caching caching, pgoff_t start_page, pgoff_t end_page) { - struct page **pages = tt->pages; + struct page **pages = &tt->pages[start_page];unsigned int order;pgoff_t i, nr;
Greg Kroah-Hartman
maintainerPATCH 157/334 fs/aio: Restrict kiocb_set_cancel_fn() to I/O submitted via libaio
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit b820de741ae48ccf50dd95e297889c286ff4f760 upstream.
If kiocb_set_cancel_fn() is called for I/O submitted via io_uring, the following kernel warning appears:
WARNING: CPU: 3 PID: 368 at fs/aio.c:598 kiocb_set_cancel_fn+0x9c/0xa8 Call trace: kiocb_set_cancel_fn+0x9c/0xa8 ffs_epfile_read_iter+0x144/0x1d0 io_read+0x19c/0x498 io_issue_sqe+0x118/0x27c io_submit_sqes+0x25c/0x5fc __arm64_sys_io_uring_enter+0x104/0xab0 invoke_syscall+0x58/0x11c el0_svc_common+0xb4/0xf4 do_el0_svc+0x2c/0xb0 el0_svc+0x2c/0xa4 el0t_64_sync_handler+0x68/0xb4 el0t_64_sync+0x1a4/0x1a8
Fix this by setting the IOCB_AIO_RW flag for read and write I/O that is submitted by libaio.
--- fs/aio.c | 9 ++++++++- include/linux/fs.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-)
fs/aio.c +8 -1
@@ -594,6 +594,13 @@ void kiocb_set_cancel_fn(struct kiocb *istruct kioctx *ctx = req->ki_ctx;unsigned long flags; +/* +* kiocb didn't come from aio or is neither a read nor a write, hence +* ignore it. +*/ +if (!(iocb->ki_flags &IOCB_AIO_RW )) +return ; +if (WARN_ON_ONCE (!list_empty (&req->ki_list)))return ;
@@ -1463,7 +1470,7 @@ static int aio_prep_rw(struct kiocb *req req->ki_complete = aio_complete_rw; req->private =NULL ; req->ki_pos = iocb->aio_offset; - req->ki_flags = req->ki_filp->f_iocb_flags; + req->ki_flags = req->ki_filp->f_iocb_flags |IOCB_AIO_RW ;if (iocb->aio_flags &IOCB_FLAG_RESFD ) req->ki_flags |=IOCB_EVENTFD ;if (iocb->aio_flags &IOCB_FLAG_IOPRIO ) {
include/linux/fs.h +2 -0
@@ -352,6 +352,8 @@ enum rw_hint {* unrelated IO (like cache flushing, new IO generation, etc). */ #define IOCB_DIO_CALLER_COMP (1 << 22) +/* kiocb is a read or write operation submitted by fs/aio.c. */ +#define IOCB_AIO_RW (1 << 23)/* for use in trace events */ #define TRACE_IOCB_STRINGS \
Greg Kroah-Hartman
maintainerPATCH 158/334 lib/Kconfig.debug: TEST_IOV_ITER depends on MMU
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit 1eb1e984379e2da04361763f66eec90dd75cf63e upstream.
Trying to run the iov_iter unit test on a nommu system such as the qemu kc705-nommu emulation results in a crash.
KTAP version 1
# Subtest: iov_iter
# module: kunit_iov_iter
1..9
BUG: failure at mm/nommu.c:318/vmap()! Kernel panic - not syncing: BUG!
The test calls vmap() directly, but vmap() is not supported on nommu systems, causing the crash. TEST_IOV_ITER therefore needs to depend on MMU.
--- lib/Kconfig.debug | 1 + 1 file changed, 1 insertion(+)
lib/Kconfig.debug +1 -0
@@ -2234,6 +2234,7 @@ config TEST_DIV64 config TEST_IOV_ITER tristate "Test iov_iter operation" if !KUNIT_ALL_TESTS depends on KUNIT + depends on MMU default KUNIT_ALL_TESTS help Enable this to turn on testing of the operation of the I/O iterator
Greg Kroah-Hartman
maintainerPATCH 159/334 dm-crypt: recheck the integrity tag after a failure
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 42e15d12070b4ff9af2b980f1b65774c2dab0507 upstream.
If a userspace process reads (with O_DIRECT) multiple blocks into the same buffer, dm-crypt reports an authentication error [1]. The error is reported in a log and it may cause RAID leg being kicked out of the array.
This commit fixes dm-crypt, so that if integrity verification fails, the data is read again into a kernel buffer (where userspace can't modify it) and the integrity tag is rechecked. If the recheck succeeds, the content of the kernel buffer is copied into the user buffer; if the recheck fails, an integrity error is reported.
[1] https://people.redhat.com/~mpatocka/testcases/blk-auth-modify/read2.c
--- drivers/md/dm-crypt.c | 89 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 16 deletions(-)
drivers/md/dm-crypt.c +73 -16
@@ -62,6 +62,8 @@ struct convert_context {struct skcipher_request *req;struct aead_request *req_aead; } r; +bool aead_recheck; +bool aead_failed; };
@@ -82,6 +84,8 @@ struct dm_crypt_io {blk_status_t error;sector_t sector; +struct bvec_iter saved_bi_iter; +struct rb_node rb_node; }CRYPTO_MINALIGN_ATTR ;
@@ -1370,10 +1374,13 @@ static int crypt_convert_block_aead(struif (r == -EBADMSG ) {sector_t s =le64_to_cpu (*sector); -DMERR_LIMIT ("%pg: INTEGRITY AEAD ERROR, sector %llu" , - ctx->bio_in->bi_bdev, s); -dm_audit_log_bio (DM_MSG_PREFIX ,"integrity-aead" , - ctx->bio_in, s,0 ); + ctx->aead_failed = true; +if (ctx->aead_recheck) { +DMERR_LIMIT ("%pg: INTEGRITY AEAD ERROR, sector %llu" , + ctx->bio_in->bi_bdev, s); +dm_audit_log_bio (DM_MSG_PREFIX ,"integrity-aead" , + ctx->bio_in, s,0 ); + } }if (!r && cc->iv_gen_ops && cc->iv_gen_ops->post)
@@ -1757,6 +1764,8 @@ static void crypt_io_init(struct dm_cryp io->base_bio = bio; io->sector = sector; io->error =0 ; + io->ctx.aead_recheck = false; + io->ctx.aead_failed = false; io->ctx.r.req =NULL ; io->integrity_metadata =NULL ; io->integrity_metadata_from_pool = false;
@@ -1768,6 +1777,8 @@ static void crypt_inc_pending(struct dm_atomic_inc (&io->io_pending); } +static void kcryptd_queue_read (struct dm_crypt_io *io); +/* * One of the bios was finished. Check for completion of * the whole request and correctly clean up the buffer.
@@ -1781,6 +1792,15 @@ static void crypt_dec_pending(struct dm_if (!atomic_dec_and_test (&io->io_pending))return ; +if (likely (!io->ctx.aead_recheck) &&unlikely (io->ctx.aead_failed) && + cc->on_disk_tag_size &&bio_data_dir (base_bio) ==READ ) { + io->ctx.aead_recheck = true; + io->ctx.aead_failed = false; + io->error =0 ; +kcryptd_queue_read (io); +return ; + } +if (io->ctx.r.req)crypt_free_req (cc, io->ctx.r.req, base_bio);
@@ -1816,15 +1836,19 @@ static void crypt_endio(struct bio *clonstruct dm_crypt_io *io = clone->bi_private;struct crypt_config *cc = io->cc;unsigned int rw =bio_data_dir (clone); -blk_status_t error; +blk_status_t error = clone->bi_status; + +if (io->ctx.aead_recheck && !error) { +kcryptd_queue_crypt (io); +return ; + }/* * free the processed pages */ -if (rw ==WRITE ) +if (rw ==WRITE || io->ctx.aead_recheck)crypt_free_buffer_pages (cc, clone); - error = clone->bi_status;bio_put (clone);if (rw ==READ && !error) {
@@ -1845,6 +1869,22 @@ static int kcryptd_io_read(struct dm_crystruct crypt_config *cc = io->cc;struct bio *clone; +if (io->ctx.aead_recheck) { +if (!(gfp & __GFP_DIRECT_RECLAIM)) +return 1 ; +crypt_inc_pending (io); + clone =crypt_alloc_buffer (io, io->base_bio->bi_iter.bi_size); +if (unlikely (!clone)) { +crypt_dec_pending (io); +return 1 ; + } + clone->bi_iter.bi_sector = cc->start + io->sector; +crypt_convert_init (cc, &io->ctx, clone, clone, io->sector); + io->saved_bi_iter = clone->bi_iter; +dm_submit_bio_remap (io->base_bio, clone); +return 0 ; + } +/* * We need the original biovec array in order to decrypt the whole bio * data *afterwards* -- thanks to immutable biovecs we don't need to
@@ -2107,6 +2147,14 @@ dec:static void kcryptd_crypt_read_done (struct dm_crypt_io *io) { +if (io->ctx.aead_recheck) { +if (!io->error) { + io->ctx.bio_in->bi_iter = io->saved_bi_iter; +bio_copy_data (io->base_bio, io->ctx.bio_in); + } +crypt_free_buffer_pages (io->cc, io->ctx.bio_in); +bio_put (io->ctx.bio_in); + }crypt_dec_pending (io); }
@@ -2136,11 +2184,17 @@ static void kcryptd_crypt_read_convert(scrypt_inc_pending (io); -crypt_convert_init (cc, &io->ctx, io->base_bio, io->base_bio, - io->sector); +if (io->ctx.aead_recheck) { + io->ctx.cc_sector = io->sector + cc->iv_offset; + r =crypt_convert (cc, &io->ctx, +test_bit (DM_CRYPT_NO_READ_WORKQUEUE , &cc->flags), true); + }else { +crypt_convert_init (cc, &io->ctx, io->base_bio, io->base_bio, + io->sector); - r =crypt_convert (cc, &io->ctx, -test_bit (DM_CRYPT_NO_READ_WORKQUEUE , &cc->flags), true); + r =crypt_convert (cc, &io->ctx, +test_bit (DM_CRYPT_NO_READ_WORKQUEUE , &cc->flags), true); + }/* * Crypto API backlogged the request, because its queue was full * and we're in softirq context, so continue from a workqueue
@@ -2182,10 +2236,13 @@ static void kcryptd_async_done(void *datif (error == -EBADMSG ) {sector_t s =le64_to_cpu (*org_sector_of_dmreq (cc, dmreq)); -DMERR_LIMIT ("%pg: INTEGRITY AEAD ERROR, sector %llu" , - ctx->bio_in->bi_bdev, s); -dm_audit_log_bio (DM_MSG_PREFIX ,"integrity-aead" , - ctx->bio_in, s,0 ); + ctx->aead_failed = true; +if (ctx->aead_recheck) { +DMERR_LIMIT ("%pg: INTEGRITY AEAD ERROR, sector %llu" , + ctx->bio_in->bi_bdev, s); +dm_audit_log_bio (DM_MSG_PREFIX ,"integrity-aead" , + ctx->bio_in, s,0 ); + } io->error =BLK_STS_PROTECTION ; }else if (error <0 ) io->error =BLK_STS_IOERR ;
@@ -3110,7 +3167,7 @@ static int crypt_ctr_optional(struct dm_ sval =strchr (opt_string +strlen ("integrity:" ),':' ) +1 ;if (!strcasecmp (sval,"aead" )) {set_bit (CRYPT_MODE_INTEGRITY_AEAD , &cc->cipher_flags); - }else if (strcasecmp (sval,"none" )) { + }else if (strcasecmp (sval,"none" )) { ti->error ="Unknown integrity profile" ;return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 160/334 Revert "parisc: Only list existing CPUs in cpu_possible_mask"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 82b143aeb169b8b55798d7d2063032e1a6ceeeb0 upstream.
This reverts commit 0921244f6f4f0d05698b953fe632a99b38907226.
It broke CPU hotplugging because it modifies the __cpu_possible_mask after bootup, so that it will be different than nr_cpu_ids, which then effictively breaks the workqueue setup code and triggers crashes when shutting down CPUs at runtime.
Guenter was the first who noticed the wrong values in __cpu_possible_mask, since the cpumask Kunit tests were failig.
Reverting this commit fixes both issues, but sadly brings back this uncritical runtime warning:register_cpu_capacity_sysctl: too early to get CPU4 device!
--- arch/parisc/kernel/processor.c | 8 -------- 1 file changed, 8 deletions(-)
arch/parisc/kernel/processor.c +0 -8
@@ -172,7 +172,6 @@ static int __init processor_probe(struct p->cpu_num = cpu_info.cpu_num; p->cpu_loc = cpu_info.cpu_loc; -set_cpu_possible (cpuid, true);store_cpu_topology (cpuid);#ifdef CONFIG_SMP
@@ -474,13 +473,6 @@ static struct parisc_driver cpu_driver _*/ void __init processor_init (void ) { -unsigned int cpu; -reset_cpu_topology (); - -/* reset possible mask. We will mark those which are possible. */ -for_each_possible_cpu (cpu) -set_cpu_possible (cpu, false); -register_parisc_driver (&cpu_driver); }
Greg Kroah-Hartman
maintainerPATCH 161/334 dm-integrity: recheck the integrity tag after a failure
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit c88f5e553fe38b2ffc4c33d08654e5281b297677 upstream.
If a userspace process reads (with O_DIRECT) multiple blocks into the same buffer, dm-integrity reports an error [1]. The error is reported in a log and it may cause RAID leg being kicked out of the array.
This commit fixes dm-integrity, so that if integrity verification fails, the data is read again into a kernel buffer (where userspace can't modify it) and the integrity tag is rechecked. If the recheck succeeds, the content of the kernel buffer is copied into the user buffer; if the recheck fails, an integrity error is reported.
[1] https://people.redhat.com/~mpatocka/testcases/blk-auth-modify/read2.c
--- drivers/md/dm-integrity.c | 93 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 9 deletions(-)
drivers/md/dm-integrity.c +84 -9
@@ -278,6 +278,8 @@ struct dm_integrity_c {atomic64_t number_of_mismatches; +mempool_t recheck_pool; +struct notifier_block reboot_notifier; };
@@ -1689,6 +1691,79 @@ failed:get_random_bytes (result, ic->tag_size); } +static void integrity_recheck (struct dm_integrity_io *dio) +{ +struct bio *bio =dm_bio_from_per_bio_data (dio,sizeof (struct dm_integrity_io )); +struct dm_integrity_c *ic = dio->ic; +struct bvec_iter iter; +struct bio_vec bv; +sector_t sector, logical_sector, area, offset; +char checksum_onstack[max_t (size_t,HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )]; +struct page *page; +void *buffer; + +get_area_and_offset (ic, dio->range.logical_sector, &area, &offset); + dio->metadata_block =get_metadata_sector_and_offset (ic, area, offset, + &dio->metadata_offset); + sector =get_data_sector (ic, area, offset); + logical_sector = dio->range.logical_sector; + + page =mempool_alloc (&ic->recheck_pool,GFP_NOIO ); + buffer =page_to_virt (page); + +__bio_for_each_segment (bv, bio, iter, dio->bio_details.bi_iter) { +unsigned pos =0 ; + +do { +char *mem; +int r; +struct dm_io_request io_req; +struct dm_io_region io_loc; + io_req.bi_opf =REQ_OP_READ ; + io_req.mem.type =DM_IO_KMEM ; + io_req.mem.ptr.addr = buffer; + io_req.notify.fn =NULL ; + io_req.client = ic->io; + io_loc.bdev = ic->dev->bdev; + io_loc.sector = sector; + io_loc.count = ic->sectors_per_block; + + r =dm_io (&io_req,1 , &io_loc,NULL ); +if (unlikely (r)) { + dio->bi_status =errno_to_blk_status (r); + goto free_ret; + } + +integrity_sector_checksum (ic, logical_sector, buffer, + checksum_onstack); + r =dm_integrity_rw_tag (ic, checksum_onstack, &dio->metadata_block, + &dio->metadata_offset, ic->tag_size,TAG_CMP ); +if (r) { +if (r >0 ) { +DMERR_LIMIT ("%pg: Checksum failed at sector 0x%llx" , + bio->bi_bdev, logical_sector); +atomic64_inc (&ic->number_of_mismatches); +dm_audit_log_bio (DM_MSG_PREFIX ,"integrity-checksum" , + bio, logical_sector,0 ); + r = -EILSEQ ; + } + dio->bi_status =errno_to_blk_status (r); + goto free_ret; + } + + mem =bvec_kmap_local (&bv); +memcpy (mem + pos, buffer, ic->sectors_per_block <<SECTOR_SHIFT ); +kunmap_local (mem); + + pos += ic->sectors_per_block <<SECTOR_SHIFT ; + sector += ic->sectors_per_block; + logical_sector += ic->sectors_per_block; + }while (pos < bv.bv_len); + } +free_ret: +mempool_free (page, &ic->recheck_pool); +} +static void integrity_metadata (struct work_struct *w) { struct dm_integrity_io *dio = container_of(w, struct dm_integrity_io, work);
@@ -1776,15 +1851,8 @@ again: checksums_ptr - checksums, dio->op == REQ_OP_READ ? TAG_CMP : TAG_WRITE);if (unlikely (r)) {if (r >0 ) { -sector_t s; - - s = sector - ((r + ic->tag_size -1 ) / ic->tag_size); -DMERR_LIMIT ("%pg: Checksum failed at sector 0x%llx" , - bio->bi_bdev, s); - r = -EILSEQ ; -atomic64_inc (&ic->number_of_mismatches); -dm_audit_log_bio (DM_MSG_PREFIX ,"integrity-checksum" , - bio, s,0 ); +integrity_recheck (dio); + goto skip_io; }if (likely (checksums != checksums_onstack))kfree (checksums);
@@ -4261,6 +4329,12 @@ static int dm_integrity_ctr(struct dm_ta goto bad; } + r =mempool_init_page_pool (&ic->recheck_pool,1 ,0 ); +if (r) { + ti->error ="Cannot allocate mempool" ; + goto bad; + } + ic->metadata_wq =alloc_workqueue ("dm-integrity-metadata" ,WQ_MEM_RECLAIM ,METADATA_WORKQUEUE_MAX_ACTIVE );if (!ic->metadata_wq) {
@@ -4609,6 +4683,7 @@ static void dm_integrity_dtr(struct dm_tkvfree (ic->bbs);if (ic->bufio)dm_bufio_client_destroy (ic->bufio); +mempool_exit (&ic->recheck_pool);mempool_exit (&ic->journal_io_mempool);if (ic->io)dm_io_client_destroy (ic->io);
Greg Kroah-Hartman
maintainerPATCH 162/334 dm-crypt: dont modify the data when using authenticated encryption
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 50c70240097ce41fe6bce6478b80478281e4d0f7 upstream.
It was said that authenticated encryption could produce invalid tag when the data that is being encrypted is modified [1]. So, fix this problem by copying the data into the clone bio first and then encrypt them inside the clone bio.
This may reduce performance, but it is needed to prevent the user from corrupting the device by writing data with O_DIRECT and modifying them at the same time.
[1] https://lore.kernel.org/all/[email protected]/T/
--- drivers/md/dm-crypt.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/md/dm-crypt.c +6 -0
@@ -2111,6 +2111,12 @@ static void kcryptd_crypt_write_convert( io->ctx.bio_out = clone; io->ctx.iter_out = clone->bi_iter; +if (crypt_integrity_aead (cc)) { +bio_copy_data (clone, io->base_bio); + io->ctx.bio_in = clone; + io->ctx.iter_in = clone->bi_iter; + } + sector +=bio_sectors (clone);crypt_inc_pending (io);
Greg Kroah-Hartman
maintainerPATCH 163/334 dm-verity: recheck the hash after a failure
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 9177f3c0dea6143d05cac1bbd28668fd0e216d11 upstream.
If a userspace process reads (with O_DIRECT) multiple blocks into the same buffer, dm-verity reports an error [1].
This commit fixes dm-verity, so that if hash verification fails, the data is read again into a kernel buffer (where userspace can't modify it) and the hash is rechecked. If the recheck succeeds, the content of the kernel buffer is copied into the user buffer; if the recheck fails, an error is reported.
[1] https://people.redhat.com/~mpatocka/testcases/blk-auth-modify/read2.c
--- drivers/md/dm-verity-target.c | 86 +++++++++++++++++++++++++++++++++++++++--- drivers/md/dm-verity.h | 6 ++ 2 files changed, 86 insertions(+), 6 deletions(-)
drivers/md/dm-verity-target.c +80 -6
@@ -482,6 +482,63 @@ int verity_for_bv_block(struct dm_verityreturn 0 ; } +static int verity_recheck_copy (struct dm_verity *v,struct dm_verity_io *io, +u8 *data,size_t len) +{ +memcpy (data, io->recheck_buffer, len); + io->recheck_buffer += len; + +return 0 ; +} + +static int verity_recheck (struct dm_verity *v,struct dm_verity_io *io, +struct bvec_iter start,sector_t cur_block) +{ +struct page *page; +void *buffer; +int r; +struct dm_io_request io_req; +struct dm_io_region io_loc; + + page =mempool_alloc (&v->recheck_pool,GFP_NOIO ); + buffer =page_to_virt (page); + + io_req.bi_opf =REQ_OP_READ ; + io_req.mem.type =DM_IO_KMEM ; + io_req.mem.ptr.addr = buffer; + io_req.notify.fn =NULL ; + io_req.client = v->io; + io_loc.bdev = v->data_dev->bdev; + io_loc.sector = cur_block << (v->data_dev_block_bits -SECTOR_SHIFT ); + io_loc.count =1 << (v->data_dev_block_bits -SECTOR_SHIFT ); + r =dm_io (&io_req,1 , &io_loc,NULL ); +if (unlikely (r)) + goto free_ret; + + r =verity_hash (v,verity_io_hash_req (v, io), buffer, +1 << v->data_dev_block_bits, +verity_io_real_digest (v, io), true); +if (unlikely (r)) + goto free_ret; + +if (memcmp (verity_io_real_digest (v, io), +verity_io_want_digest (v, io), v->digest_size)) { + r = -EIO ; + goto free_ret; + } + + io->recheck_buffer = buffer; + r =verity_for_bv_block (v, io, &start, verity_recheck_copy); +if (unlikely (r)) + goto free_ret; + + r =0 ; +free_ret: +mempool_free (page, &v->recheck_pool); + +return r; +} +static int verity_bv_zero (struct dm_verity *v,struct dm_verity_io *io,u8 *data,size_t len) {
@@ -508,9 +565,7 @@ static int verity_verify_io(struct dm_ve {bool is_zero;struct dm_verity *v = io->v; -#if defined(CONFIG_DM_VERITY_FEC )struct bvec_iter start; -#endif struct bvec_iter iter_copy;struct bvec_iter *iter;struct crypto_wait wait;
@@ -561,10 +616,7 @@ static int verity_verify_io(struct dm_veif (unlikely (r <0 ))return r; -#if defined(CONFIG_DM_VERITY_FEC ) -if (verity_fec_is_enabled (v)) - start = *iter; -#endif + start = *iter; r =verity_for_io_block (v, io, iter, &wait);if (unlikely (r <0 ))return r;
@@ -586,6 +638,10 @@ static int verity_verify_io(struct dm_ve* tasklet since it may sleep, so fallback to work-queue. */ return -EAGAIN ; + }else if (verity_recheck (v, io, start, cur_block) ==0 ) { +if (v->validated_blocks) +set_bit (cur_block, v->validated_blocks); +continue ;#if defined(CONFIG_DM_VERITY_FEC ) } else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA, cur_block,NULL , &start) ==0 ) {
@@ -941,6 +997,10 @@ static void verity_dtr(struct dm_targetif (v->verify_wq)destroy_workqueue (v->verify_wq); +mempool_exit (&v->recheck_pool); +if (v->io) +dm_io_client_destroy (v->io); +if (v->bufio)dm_bufio_client_destroy (v->bufio);
@@ -1379,6 +1439,20 @@ static int verity_ctr(struct dm_target * } v->hash_blocks = hash_position; + r =mempool_init_page_pool (&v->recheck_pool,1 ,0 ); +if (unlikely (r)) { + ti->error ="Cannot allocate mempool" ; + goto bad; + } + + v->io =dm_io_client_create (); +if (IS_ERR (v->io)) { + r =PTR_ERR (v->io); + v->io =NULL ; + ti->error ="Cannot allocate dm io" ; + goto bad; + } + v->bufio = dm_bufio_client_create(v->hash_dev->bdev, 1 << v->hash_dev_block_bits, 1, sizeof(struct buffer_aux), dm_bufio_alloc_callback, NULL,
drivers/md/dm-verity.h +6 -0
@@ -11,6 +11,7 @@#ifndef DM_VERITY_H #define DM_VERITY_H +#include <linux/dm-io.h> #include <linux/dm-bufio.h> #include <linux/device-mapper.h> #include <linux/interrupt.h>
@@ -68,6 +69,9 @@ struct dm_verity {unsigned long *validated_blocks;/* bitset blocks validated */ char *signature_key_desc;/* signature keyring reference */ + +struct dm_io_client *io; +mempool_t recheck_pool; };struct dm_verity_io {
@@ -84,6 +88,8 @@ struct dm_verity_io {struct work_struct work; +char *recheck_buffer; +/* * Three variably-size fields follow this struct: *
Greg Kroah-Hartman
maintainerPATCH 164/334 cxl/acpi: Fix load failures due to single window creation failure
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit 5c6224bfabbf7f3e491c51ab50fd2c6f92ba1141 upstream.
The expectation is that cxl_parse_cfwms() continues in the face the of failure as evidenced by code like:
cxlrd = cxl_root_decoder_alloc(root_port, ways, cxl_calc_hb);
if (IS_ERR(cxlrd))
return 0;There are other error paths in that function which mistakenly follow idiomatic expectations and return an error when they should not. Most of those mistakes are innocuous checks that hardly ever fail in practice. However, a recent change succeed in making the implementation more fragile by applying an idiomatic, but still wrong "fix" [1]. In this failure case the kernel reports:
cxl root0: Failed to populate active decoder targets
cxl_acpi ACPI0017:00: Failed to add decode range: [mem 0x00000000-0x7fffffff flags 0x200]
...which is a real issue with that one window (to be fixed separately), but ends up failing the entirety of cxl_acpi_probe().
Undo that recent breakage while also removing the confusion about ignoring errors. Update all exits paths to return an error per typical expectations and let an outer wrapper function handle dropping the error.
--- drivers/cxl/acpi.c | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-)
drivers/cxl/acpi.c +28 -18
@@ -194,31 +194,27 @@ struct cxl_cfmws_context {int id; }; -static int cxl_parse_cfmws (union acpi_subtable_headers *header,void *arg, -const unsigned long end) +static int __cxl_parse_cfmws (struct acpi_cedt_cfmws *cfmws, +struct cxl_cfmws_context *ctx) {int target_map[CXL_DECODER_MAX_INTERLEAVE ]; -struct cxl_cfmws_context *ctx = arg;struct cxl_port *root_port = ctx->root_port;struct resource *cxl_res = ctx->cxl_res;struct cxl_cxims_context cxims_ctx;struct cxl_root_decoder *cxlrd;struct device *dev = ctx->dev; -struct acpi_cedt_cfmws *cfmws;cxl_calc_hb_fn cxl_calc_hb;struct cxl_decoder *cxld;unsigned int ways, i, ig;struct resource *res;int rc; - cfmws = (struct acpi_cedt_cfmws *) header; - rc =cxl_acpi_cfmws_verify (dev, cfmws);if (rc) {dev_err (dev,"CFMWS range %#llx-%#llx not registered\n" , cfmws->base_hpa, cfmws->base_hpa + cfmws->window_size -1 ); -return 0 ; +return rc; } rc =eiw_to_ways (cfmws->interleave_ways, &ways);
@@ -254,7 +250,7 @@ static int cxl_parse_cfmws(union acpi_su cxlrd =cxl_root_decoder_alloc (root_port, ways, cxl_calc_hb);if (IS_ERR (cxlrd)) -return 0 ; +return PTR_ERR (cxlrd); cxld = &cxlrd->cxlsd.cxld; cxld->flags =cfmws_to_decoder_flags (cfmws->restrictions);
@@ -298,16 +294,7 @@ err_xormap:put_device (&cxld->dev); else rc =cxl_decoder_autoremove (dev, cxld); -if (rc) { -dev_err (dev,"Failed to add decode range: %pr" , res); -return rc; - } -dev_dbg (dev,"add: %s node: %d range [%#llx - %#llx]\n" , -dev_name (&cxld->dev), -phys_to_target_node (cxld->hpa_range.start), - cxld->hpa_range.start, cxld->hpa_range.end); - -return 0 ; +return rc; err_insert:kfree (res->name);
@@ -316,6 +303,29 @@ err_name:return -ENOMEM ; } +static int cxl_parse_cfmws (union acpi_subtable_headers *header,void *arg, +const unsigned long end) +{ +struct acpi_cedt_cfmws *cfmws = (struct acpi_cedt_cfmws *)header; +struct cxl_cfmws_context *ctx = arg; +struct device *dev = ctx->dev; +int rc; + + rc =__cxl_parse_cfmws (cfmws, ctx); +if (rc) +dev_err (dev, +"Failed to add decode range: [%#llx - %#llx] (%d)\n" , + cfmws->base_hpa, + cfmws->base_hpa + cfmws->window_size -1 , rc); +else +dev_dbg (dev,"decode range: node: %d range [%#llx - %#llx]\n" , +phys_to_target_node (cfmws->base_hpa), cfmws->base_hpa, + cfmws->base_hpa + cfmws->window_size -1 ); + +/* never fail cxl_acpi load for a single window failure */ +return 0 ; +} + __mock struct acpi_device *to_cxl_host_bridge(struct device *host,struct device *dev) {
Greg Kroah-Hartman
maintainerPATCH 165/334 cxl/pci: Skip to handle RAS errors if CXL.mem device is detached
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Ming <[email protected]>
commit eef5c7b28dbecd6b141987a96db6c54e49828102 upstream.
The PCI AER model is an awkward fit for CXL error handling. While the expectation is that a PCI device can escalate to link reset to recover from an AER event, the same reset on CXL amounts to a surprise memory hotplug of massive amounts of memory.
At present, the CXL error handler attempts some optimistic error handling to unbind the device from the cxl_mem driver after reaping some RAS register values. This results in a "hopeful" attempt to unplug the memory, but there is no guarantee that will succeed.
A subsequent AER notification after the memdev unbind event can no longer assume the registers are mapped. Check for memdev bind before reaping status register values to avoid crashes of the form:
BUG: unable to handle page fault for address: ffa00000195e9100 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page [...] RIP: 0010:__cxl_handle_ras+0x30/0x110 [cxl_core] [...] Call Trace: <TASK> ? __die+0x24/0x70 ? page_fault_oops+0x82/0x160 ? kernelmode_fixup_or_oops+0x84/0x110 ? exc_page_fault+0x113/0x170 ? asm_exc_page_fault+0x26/0x30 ? __pfx_dpc_reset_link+0x10/0x10 ? __cxl_handle_ras+0x30/0x110 [cxl_core] ? find_cxl_port+0x59/0x80 [cxl_core] cxl_handle_rp_ras+0xbc/0xd0 [cxl_core] cxl_error_detected+0x6c/0xf0 [cxl_core] report_error_detected+0xc7/0x1c0 pci_walk_bus+0x73/0x90 pcie_do_recovery+0x23f/0x330
Longer term, the unbind and PCI_ERS_RESULT_DISCONNECT behavior might need to be replaced with a new PCI_ERS_RESULT_PANIC.
--- drivers/cxl/core/pci.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-)
drivers/cxl/core/pci.c +31 -12
@@ -931,11 +931,21 @@ static void cxl_handle_rdport_errors(strvoid cxl_cor_error_detected (struct pci_dev *pdev) {struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); +struct device *dev = &cxlds->cxlmd->dev; -if (cxlds->rcd) -cxl_handle_rdport_errors (cxlds); + scoped_guard(device, dev) { +if (!dev->driver) { +dev_warn (&pdev->dev, +"%s: memdev disabled, abort error handling\n" , +dev_name (dev)); +return ; + } -cxl_handle_endpoint_cor_ras (cxlds); +if (cxlds->rcd) +cxl_handle_rdport_errors (cxlds); + +cxl_handle_endpoint_cor_ras (cxlds); + } }EXPORT_SYMBOL_NS_GPL (cxl_cor_error_detected,CXL );
@@ -947,16 +957,25 @@ pci_ers_result_t cxl_error_detected(strustruct device *dev = &cxlmd->dev;bool ue; -if (cxlds->rcd) -cxl_handle_rdport_errors (cxlds); + scoped_guard(device, dev) { +if (!dev->driver) { +dev_warn (&pdev->dev, +"%s: memdev disabled, abort error handling\n" , +dev_name (dev)); +return PCI_ERS_RESULT_DISCONNECT ; + } + +if (cxlds->rcd) +cxl_handle_rdport_errors (cxlds); +/* +* A frozen channel indicates an impending reset which is fatal to +* CXL.mem operation, and will likely crash the system. On the off +* chance the situation is recoverable dump the status of the RAS +* capability registers and bounce the active state of the memdev. +*/ + ue =cxl_handle_endpoint_ras (cxlds); + } -/* -* A frozen channel indicates an impending reset which is fatal to -* CXL.mem operation, and will likely crash the system. On the off -* chance the situation is recoverable dump the status of the RAS -* capability registers and bounce the active state of the memdev. -*/ - ue =cxl_handle_endpoint_ras (cxlds);switch (state) {case pci_channel_io_normal:
Greg Kroah-Hartman
maintainerPATCH 166/334 cxl/pci: Fix disabling memory if DVSEC CXL Range does not match a CFMWS window
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Richter <[email protected]>
commit 0cab687205986491302cd2e440ef1d253031c221 upstream.
The Linux CXL subsystem is built on the assumption that HPA == SPA. That is, the host physical address (HPA) the HDM decoder registers are programmed with are system physical addresses (SPA).
During HDM decoder setup, the DVSEC CXL range registers (cxl-3.1, 8.1.3.8) are checked if the memory is enabled and the CXL range is in a HPA window that is described in a CFMWS structure of the CXL host bridge (cxl-3.1, 9.18.1.3).
Now, if the HPA is not an SPA, the CXL range does not match a CFMWS window and the CXL memory range will be disabled then. The HDM decoder stops working which causes system memory being disabled and further a system hang during HDM decoder initialization, typically when a CXL enabled kernel boots.
Prevent a system hang and do not disable the HDM decoder if the decoder's CXL range is not found in a CFMWS window.
Note the change only fixes a hardware hang, but does not implement HPA/SPA translation. Support for this can be added in a follow on patch series.
--- drivers/cxl/core/pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cxl/core/pci.c +3 -3
@@ -476,9 +476,9 @@ int cxl_hdm_decode_init(struct cxl_dev_s allowed++; } -if (!allowed) { -cxl_set_mem_enable (cxlds,0 ); - info->mem_enabled =0 ; +if (!allowed && info->mem_enabled) { +dev_err (dev,"Range register decodes outside platform defined CXL ranges.\n" ); +return -ENXIO ; }/*
Greg Kroah-Hartman
maintainerPATCH 149/334 drm/meson: Dont remove bridges which are created by other drivers
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
commit bd915ae73a2d78559b376ad2caf5e4ef51de2455 upstream.
Stop calling drm_bridge_remove() for bridges allocated/managed by other drivers in the remove paths of meson_encoder_{cvbs,dsi,hdmi}. drm_bridge_remove() unregisters the bridge so it cannot be used anymore. Doing so for bridges we don't own can lead to the video pipeline not being able to come up after -EPROBE_DEFER of the VPU because we're unregistering a bridge that's managed by another driver. The other driver doesn't know that we have unregistered it's bridge and on subsequent .probe() we're not able to find those bridges anymore (since nobody re-creates them).
This fixes probe errors on Meson8b boards with the CVBS outputs enabled.
--- drivers/gpu/drm/meson/meson_encoder_cvbs.c | 1 - drivers/gpu/drm/meson/meson_encoder_dsi.c | 1 - drivers/gpu/drm/meson/meson_encoder_hdmi.c | 1 - 3 files changed, 3 deletions(-)
drivers/gpu/drm/meson/meson_encoder_cvbs.c +0 -1
@@ -294,6 +294,5 @@ void meson_encoder_cvbs_remove(struct meif (priv->encoders[MESON_ENC_CVBS ]) { meson_encoder_cvbs = priv->encoders[MESON_ENC_CVBS ];drm_bridge_remove (&meson_encoder_cvbs->bridge); -drm_bridge_remove (meson_encoder_cvbs->next_bridge); } }
drivers/gpu/drm/meson/meson_encoder_dsi.c +0 -1
@@ -168,6 +168,5 @@ void meson_encoder_dsi_remove(struct mesif (priv->encoders[MESON_ENC_DSI ]) { meson_encoder_dsi = priv->encoders[MESON_ENC_DSI ];drm_bridge_remove (&meson_encoder_dsi->bridge); -drm_bridge_remove (meson_encoder_dsi->next_bridge); } }
drivers/gpu/drm/meson/meson_encoder_hdmi.c +0 -1
@@ -474,6 +474,5 @@ void meson_encoder_hdmi_remove(struct meif (priv->encoders[MESON_ENC_HDMI ]) { meson_encoder_hdmi = priv->encoders[MESON_ENC_HDMI ];drm_bridge_remove (&meson_encoder_hdmi->bridge); -drm_bridge_remove (meson_encoder_hdmi->next_bridge); } }
Greg Kroah-Hartman
maintainerPATCH 167/334 scsi: sd: usb_storage: uas: Access media prior to querying device properties
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin K. Petersen <[email protected]>
commit 321da3dc1f3c92a12e3c5da934090d2992a8814c upstream.
It has been observed that some USB/UAS devices return generic properties hardcoded in firmware for mode pages for a period of time after a device has been discovered. The reported properties are either garbage or they do not accurately reflect the characteristics of the physical storage device attached in the case of a bridge.
Prior to commit 1e029397d12f ("scsi: sd: Reorganize DIF/DIX code to avoid calling revalidate twice") we would call revalidate several times during device discovery. As a result, incorrect values would eventually get replaced with ones accurately describing the attached storage. When we did away with the redundant revalidate pass, several cases were reported where devices reported nonsensical values or would end up in write-protected state.
An initial attempt at addressing this issue involved introducing a delayed second revalidate invocation. However, this approach still left some devices reporting incorrect characteristics.
Tasos Sahanidis debugged the problem further and identified that introducing a READ operation prior to MODE SENSE fixed the problem and that it wasn't a timing issue. Issuing a READ appears to cause the devices to update their state to reflect the actual properties of the storage media. Device properties like vendor, model, and storage capacity appear to be correctly reported from the get-go. It is unclear why these devices defer populating the remaining characteristics.
Match the behavior of a well known commercial operating system and trigger a READ operation prior to querying device characteristics to force the device to populate the mode pages.
The additional READ is triggered by a flag set in the USB storage and UAS drivers. We avoid issuing the READ for other transport classes since some storage devices identify Linux through our particular discovery command sequence.
--- drivers/scsi/sd.c | 26 +++++++++++++++++++++++++- drivers/usb/storage/scsiglue.c | 7 +++++++ drivers/usb/storage/uas.c | 7 +++++++ include/scsi/scsi_device.h | 1 + 4 files changed, 40 insertions(+), 1 deletion(-)
drivers/scsi/sd.c +25 -1
@@ -3410,6 +3410,24 @@ static bool sd_validate_opt_xfer_size(streturn true; } +static void sd_read_block_zero (struct scsi_disk *sdkp) +{ +unsigned int buf_len = sdkp->device->sector_size; +char *buffer, cmd[10 ] = { }; + + buffer =kmalloc (buf_len,GFP_KERNEL ); +if (!buffer) +return ; + + cmd[0 ] =READ_10 ; +put_unaligned_be32 (0 , &cmd[2 ]);/* Logical block address 0 */ +put_unaligned_be16 (1 , &cmd[7 ]);/* Transfer 1 logical block */ + +scsi_execute_cmd (sdkp->device, cmd,REQ_OP_DRV_IN , buffer, buf_len, +SD_TIMEOUT , sdkp->max_retries,NULL ); +kfree (buffer); +} +/** * sd_revalidate_disk - called the first time a new disk is seen, * performs disk spin up, read_capacity, etc.
@@ -3449,7 +3467,13 @@ static int sd_revalidate_disk(struct gen*/ if (sdkp->media_present) {sd_read_capacity (sdkp, buffer); - +/* +* Some USB/UAS devices return generic values for mode pages +* until the media has been accessed. Trigger a READ operation +* to force the device to populate mode pages. +*/ +if (sdp->read_before_ms) +sd_read_block_zero (sdkp);/* * set the default to rotational. All non-rotational devices * support the block characteristics VPD page, which will
drivers/usb/storage/scsiglue.c +7 -0
@@ -180,6 +180,13 @@ static int slave_configure(struct scsi_d sdev->use_192_bytes_for_3f =1 ;/* +* Some devices report generic values until the media has been +* accessed. Force a READ(10) prior to querying device +* characteristics. +*/ + sdev->read_before_ms =1 ; + +/* * Some devices don't like MODE SENSE with page=0x3f, * which is the command used for checking if a device * is write-protected. Now that we tell the sd driver
drivers/usb/storage/uas.c +7 -0
@@ -879,6 +879,13 @@ static int uas_slave_configure(struct sc sdev->guess_capacity =1 ;/* +* Some devices report generic values until the media has been +* accessed. Force a READ(10) prior to querying device +* characteristics. +*/ + sdev->read_before_ms =1 ; + +/* * Some devices don't like MODE SENSE with page=0x3f, * which is the command used for checking if a device * is write-protected. Now that we tell the sd driver
include/scsi/scsi_device.h +1 -0
@@ -208,6 +208,7 @@ struct scsi_device { unsigned use_10_for_rw:1; /* first try 10-byte read / write */ unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */ + unsigned read_before_ms:1; /* perform a READ before MODE SENSE */ unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */ unsigned no_write_same:1; /* no WRITE SAME command */ unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */
Greg Kroah-Hartman
maintainerPATCH 168/334 scsi: target: pscsi: Fix bio_put() for error case
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naohiro Aota <[email protected]>
commit de959094eb2197636f7c803af0943cb9d3b35804 upstream.
As of commit 066ff571011d ("block: turn bio_kmalloc into a simple kmalloc wrapper"), a bio allocated by bio_kmalloc() must be freed by bio_uninit() and kfree(). That is not done properly for the error case, hitting WARN and NULL pointer dereference in bio_free().
--- drivers/target/target_core_pscsi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/target/target_core_pscsi.c +6 -3
@@ -907,12 +907,15 @@ new_bio:return 0 ; fail: -if (bio) -bio_put (bio); +if (bio) { +bio_uninit (bio); +kfree (bio); + }while (req->bio) { bio = req->bio; req->bio = bio->bi_next; -bio_put (bio); +bio_uninit (bio); +kfree (bio); } req->biotail =NULL ;return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ;
Greg Kroah-Hartman
maintainerPATCH 169/334 scsi: core: Consult supported VPD page list prior to fetching page
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin K. Petersen <[email protected]>
commit b5fc07a5fb56216a49e6c1d0b172d5464d99a89b upstream.
Commit c92a6b5d6335 ("scsi: core: Query VPD size before getting full page") removed the logic which checks whether a VPD page is present on the supported pages list before asking for the page itself. That was done because SPC helpfully states "The Supported VPD Pages VPD page list may or may not include all the VPD pages that are able to be returned by the device server". Testing had revealed a few devices that supported some of the 0xBn pages but didn't actually list them in page 0.
Julian Sikorski bisected a problem with his drive resetting during discovery to the commit above. As it turns out, this particular drive firmware will crash if we attempt to fetch page 0xB9.
Various approaches were attempted to work around this. In the end, reinstating the logic that consults VPD page 0 before fetching any other page was the path of least resistance. A firmware update for the devices which originally compelled us to remove the check has since been released.
--- drivers/scsi/scsi.c | 22 ++++++++++++++++++++-- include/scsi/scsi_device.h | 4 ---- 2 files changed, 20 insertions(+), 6 deletions(-)
drivers/scsi/scsi.c +20 -2
@@ -328,21 +328,39 @@ static int scsi_vpd_inquiry(struct scsi_return result +4 ; } +enum scsi_vpd_parameters { +SCSI_VPD_HEADER_SIZE =4 , +SCSI_VPD_LIST_SIZE =36 , +}; +static int scsi_get_vpd_size (struct scsi_device *sdev,u8 page) { -unsigned char vpd_header[SCSI_VPD_HEADER_SIZE ]__aligned(4) ; +unsigned char vpd[SCSI_VPD_LIST_SIZE ]__aligned(4) ;int result;if (sdev->no_vpd_size)return SCSI_DEFAULT_VPD_LEN ;/* +* Fetch the supported pages VPD and validate that the requested page +* number is present. +*/ +if (page !=0 ) { + result =scsi_vpd_inquiry (sdev, vpd,0 ,sizeof (vpd)); +if (result <SCSI_VPD_HEADER_SIZE ) +return 0 ; + + result -=SCSI_VPD_HEADER_SIZE ; +if (!memchr (&vpd[SCSI_VPD_HEADER_SIZE ], page, result)) +return 0 ; + } +/* * Fetch the VPD page header to find out how big the page * is. This is done to prevent problems on legacy devices * which can not handle allocation lengths as large as * potentially requested by the caller. */ - result =scsi_vpd_inquiry (sdev, vpd_header, page,sizeof (vpd_header)); + result =scsi_vpd_inquiry (sdev, vpd, page,SCSI_VPD_HEADER_SIZE );if (result <0 )return 0 ;
include/scsi/scsi_device.h +0 -4
@@ -100,10 +100,6 @@ struct scsi_vpd {unsigned char data[]; }; -enum scsi_vpd_parameters { -SCSI_VPD_HEADER_SIZE =4 , -}; -struct scsi_device {struct Scsi_Host *host;struct request_queue *request_queue;
Greg Kroah-Hartman
maintainerPATCH 170/334 selftests/mm: uffd-unit-test check if huge page size is 0
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Terry Tritton <[email protected]>
commit 7efa6f2c803366f84c3c362f01e822490669d72b upstream.
If HUGETLBFS is not enabled then the default_huge_page_size function will return 0 and cause a divide by 0 error. Add a check to see if the huge page size is 0 and skip the hugetlb tests if it is.
--- tools/testing/selftests/mm/uffd-unit-tests.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/mm/uffd-unit-tests.c +6 -0
@@ -1309,6 +1309,12 @@ int main(int argc, char *argv[])continue ;uffd_test_start ("%s on %s" , test->name, mem_type->name); +if ((mem_type->mem_flag ==MEM_HUGETLB || + mem_type->mem_flag ==MEM_HUGETLB_PRIVATE ) && + (default_huge_page_size () ==0 )) { +uffd_test_skip ("huge page size is 0, feature missing?" ); +continue ; + }if (!uffd_feature_supported (test)) {uffd_test_skip ("feature missing" );continue ;
Greg Kroah-Hartman
maintainerPATCH 171/334 mm/swap: fix race when skipping swapcache
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kairui Song <[email protected]>
commit 13ddaf26be324a7f951891ecd9ccd04466d27458 upstream.
When skipping swapcache for SWP_SYNCHRONOUS_IO, if two or more threads swapin the same entry at the same time, they get different pages (A, B). Before one thread (T0) finishes the swapin and installs page (A) to the PTE, another thread (T1) could finish swapin of page (B), swap_free the entry, then swap out the possibly modified page reusing the same entry. It breaks the pte_same check in (T0) because PTE value is unchanged, causing ABA problem. Thread (T0) will install a stalled page (A) into the PTE and cause data corruption.
One possible callstack is like this:
CPU0 CPU1 ---- ---- do_swap_page() do_swap_page() with same entry <direct swapin path> <direct swapin path> <alloc page A> <alloc page B> swap_read_folio() <- read to page A swap_read_folio() <- read to page B <slow on later locks or interrupt> <finished swapin first> ... set_pte_at()
swap_free() <- entry is free <write to page B, now page A stalled> <swap out page B to same swap entry>pte_same() <- Check pass, PTE seems
unchanged, but page A
is stalled!swap_free() <- page B content lost!set_pte_at() <- staled page A installed!
And besides, for ZRAM, swap_free() allows the swap device to discard the entry content, so even if page (B) is not modified, if swap_read_folio() on CPU0 happens later than swap_free() on CPU1, it may also cause data loss.
To fix this, reuse swapcache_prepare which will pin the swap entry using the cache flag, and allow only one thread to swap it in, also prevent any parallel code from putting the entry in the cache. Release the pin after PT unlocked.
Racers just loop and wait since it's a rare and very short event. A schedule_timeout_uninterruptible(1) call is added to avoid repeated page faults wasting too much CPU, causing livelock or adding too much noise to perf statistics. A similar livelock issue was described in commit 029c4628b2eb ("mm: swap: get rid of livelock in swapin readahead")
Reproducer:
This race issue can be triggered easily using a well constructed reproducer and patched brd (with a delay in read path) [1]:
With latest 6.8 mainline, race caused data loss can be observed easily:
$ gcc -g -lpthread test-thread-swap-race.c && ./a.out Polulating 32MB of memory region... Keep swapping out... Starting round 0... Spawning 65536 workers... 32746 workers spawned, wait for done... Round 0: Error on 0x5aa00, expected 32746, got 32743, 3 data loss! Round 0: Error on 0x395200, expected 32746, got 32743, 3 data loss! Round 0: Error on 0x3fd000, expected 32746, got 32737, 9 data loss! Round 0 Failed, 15 data loss!
This reproducer spawns multiple threads sharing the same memory region using a small swap device. Every two threads updates mapped pages one by one in opposite direction trying to create a race, with one dedicated thread keep swapping out the data out using madvise.
The reproducer created a reproduce rate of about once every 5 minutes, so the race should be totally possible in production.
After this patch, I ran the reproducer for over a few hundred rounds and no data loss observed.
Performance overhead is minimal, microbenchmark swapin 10G from 32G zram:
Before: 10934698 us After: 11157121 us Cached: 13155355 us (Dropping SWP_SYNCHRONOUS_IO flag)
--- include/linux/swap.h | 5 +++++ mm/memory.c | 20 ++++++++++++++++++++ mm/swap.h | 5 +++++ mm/swapfile.c | 13 +++++++++++++ 4 files changed, 43 insertions(+)
include/linux/swap.h +5 -0
@@ -553,6 +553,11 @@ static inline int swap_duplicate(swp_entreturn 0 ; } +static inline int swapcache_prepare (swp_entry_t swp) +{ +return 0 ; +} +static inline void swap_free (swp_entry_t swp) { }
mm/memory.c +20 -0
@@ -3785,6 +3785,7 @@ vm_fault_t do_swap_page(struct vm_faultstruct page *page;struct swap_info_struct *si =NULL ;rmap_t rmap_flags =RMAP_NONE ; +bool need_clear_cache = false;bool exclusive = false;swp_entry_t entry;pte_t pte;
@@ -3853,6 +3854,20 @@ vm_fault_t do_swap_page(struct vm_faultif (!folio) {if (data_race (si->flags &SWP_SYNCHRONOUS_IO ) &&__swap_count (entry) ==1 ) { +/* +* Prevent parallel swapin from proceeding with +* the cache flag. Otherwise, another thread may +* finish swapin first, free the entry, and swapout +* reusing the same entry. It's undetectable as +* pte_same() returns true due to entry reuse. +*/ +if (swapcache_prepare (entry)) { +/* Relax a bit to prevent rapid repeated page faults */ +schedule_timeout_uninterruptible (1 ); + goto out; + } + need_clear_cache = true; +/* skip swapcache */ folio =vma_alloc_folio (GFP_HIGHUSER_MOVABLE ,0 , vma, vmf->address, false);
@@ -4099,6 +4114,9 @@ unlock:if (vmf->pte)pte_unmap_unlock (vmf->pte, vmf->ptl); out: +/* Clear the swap cache pin for direct swapin after PTL unlock */ +if (need_clear_cache) +swapcache_clear (si, entry);if (si)put_swap_device (si);return ret;
@@ -4113,6 +4131,8 @@ out_release:folio_unlock (swapcache);folio_put (swapcache); } +if (need_clear_cache) +swapcache_clear (si, entry);if (si)put_swap_device (si);return ret;
mm/swap.h +5 -0
@@ -40,6 +40,7 @@ void __delete_from_swap_cache(struct folvoid delete_from_swap_cache (struct folio *folio);void clear_shadow_from_swap_cache (int type,unsigned long begin,unsigned long end); +void swapcache_clear (struct swap_info_struct *si,swp_entry_t entry);struct folio *swap_cache_get_folio (swp_entry_t entry,struct vm_area_struct *vma,unsigned long addr); struct folio *filemap_get_incore_folio(struct address_space *mapping,
@@ -97,6 +98,10 @@ static inline int swap_writepage(structreturn 0 ; } +static inline void swapcache_clear (struct swap_info_struct *si,swp_entry_t entry) +{ +} +static inline struct folio *swap_cache_get_folio (swp_entry_t entry,struct vm_area_struct *vma,unsigned long addr) {
mm/swapfile.c +13 -0
@@ -3363,6 +3363,19 @@ int swapcache_prepare(swp_entry_t entry)return __swap_duplicate (entry,SWAP_HAS_CACHE ); } +void swapcache_clear (struct swap_info_struct *si,swp_entry_t entry) +{ +struct swap_cluster_info *ci; +unsigned long offset =swp_offset (entry); +unsigned char usage; + + ci =lock_cluster_or_swap_info (si, offset); + usage =__swap_entry_free_locked (si, offset,SWAP_HAS_CACHE ); +unlock_cluster_or_swap_info (si, ci); +if (!usage) +free_swap_slot (entry); +} +struct swap_info_struct *swp_swap_info (swp_entry_t entry) {return swap_type_to_swap_info (swp_type (entry));
Greg Kroah-Hartman
maintainerPATCH 172/334 mm/damon/lru_sort: fix quota status loss due to online tunings
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 13d0599ab3b2ff17f798353f24bcbef1659d3cfc upstream.
For online parameters change, DAMON_LRU_SORT creates new schemes based on latest values of the parameters and replaces the old schemes with the new one. When creating it, the internal status of the quotas of the old schemes is not preserved. As a result, charging of the quota starts from zero after the online tuning. The data that collected to estimate the throughput of the scheme's action is also reset, and therefore the estimation should start from the scratch again. Because the throughput estimation is being used to convert the time quota to the effective size quota, this could result in temporal time quota inaccuracy. It would be recovered over time, though. In short, the quota accuracy could be temporarily degraded after online parameters update.
Fix the problem by checking the case and copying the internal fields for the status.
--- mm/damon/lru_sort.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-)
mm/damon/lru_sort.c +36 -7
@@ -185,9 +185,21 @@ static struct damos *damon_lru_sort_new_return damon_lru_sort_new_scheme (&pattern,DAMOS_LRU_DEPRIO ); } +static void damon_lru_sort_copy_quota_status (struct damos_quota *dst, +struct damos_quota *src) +{ + dst->total_charged_sz = src->total_charged_sz; + dst->total_charged_ns = src->total_charged_ns; + dst->charged_sz = src->charged_sz; + dst->charged_from = src->charged_from; + dst->charge_target_from = src->charge_target_from; + dst->charge_addr_from = src->charge_addr_from; +} +static int damon_lru_sort_apply_parameters (void ) { -struct damos *scheme; +struct damos *scheme, *hot_scheme, *cold_scheme; +struct damos *old_hot_scheme =NULL , *old_cold_scheme =NULL ;unsigned int hot_thres, cold_thres;int err =0 ;
@@ -195,18 +207,35 @@ static int damon_lru_sort_apply_parameteif (err)return err; +damon_for_each_scheme (scheme, ctx) { +if (!old_hot_scheme) { + old_hot_scheme = scheme; +continue ; + } + old_cold_scheme = scheme; + } + hot_thres =damon_max_nr_accesses (&damon_lru_sort_mon_attrs) * hot_thres_access_freq /1000 ; - scheme =damon_lru_sort_new_hot_scheme (hot_thres); -if (!scheme) + hot_scheme =damon_lru_sort_new_hot_scheme (hot_thres); +if (!hot_scheme)return -ENOMEM ; -damon_set_schemes (ctx, &scheme,1 ); +if (old_hot_scheme) +damon_lru_sort_copy_quota_status (&hot_scheme->quota, + &old_hot_scheme->quota); cold_thres = cold_min_age / damon_lru_sort_mon_attrs.aggr_interval; - scheme =damon_lru_sort_new_cold_scheme (cold_thres); -if (!scheme) + cold_scheme =damon_lru_sort_new_cold_scheme (cold_thres); +if (!cold_scheme) { +damon_destroy_scheme (hot_scheme);return -ENOMEM ; -damon_add_scheme (ctx, scheme); + } +if (old_cold_scheme) +damon_lru_sort_copy_quota_status (&cold_scheme->quota, + &old_cold_scheme->quota); + +damon_set_schemes (ctx, &hot_scheme,1 ); +damon_add_scheme (ctx, cold_scheme); return damon_set_region_biggest_system_ram_default(target, &monitor_region_start,
Greg Kroah-Hartman
maintainerPATCH 173/334 mm: memcontrol: clarify swapaccount=0 deprecation warning
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit 118642d7f606fc9b9c92ee611275420320290ffb upstream.
The swapaccount deprecation warning is throwing false positives. Since we deprecated the knob and defaulted to enabling, the only reports we've been getting are from folks that set swapaccount=1. While this is a nice affirmation that always-enabling was the right choice, we certainly don't want to warn when users request the supported mode.
Only warn when disabling is requested, and clarify the warning.
--- mm/memcontrol.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
mm/memcontrol.c +7 -3
@@ -7905,9 +7905,13 @@ bool mem_cgroup_swap_full(struct folio *static int __init setup_swap_account (char *s) { -pr_warn_once ("The swapaccount= commandline option is deprecated. " -"Please report your usecase to [email protected] if you " -"depend on this functionality.\n" ); +bool res; + +if (!kstrtobool (s, &res) && !res) +pr_warn_once ("The swapaccount=0 commandline option is deprecated " +"in favor of configuring swap control via cgroupfs. " +"Please report your usecase to [email protected] if you " +"depend on this functionality.\n" );return 1 ; }__setup ("swapaccount=" , setup_swap_account);
Greg Kroah-Hartman
maintainerPATCH 174/334 mm/damon/core: check apply interval in damon_do_apply_schemes()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit e9e3db69966d5e9e6f7e7d017b407c0025180fe5 upstream.
kdamond_apply_schemes() checks apply intervals of schemes and avoid further applying any schemes if no scheme passed its apply interval. However, the following schemes applying function, damon_do_apply_schemes() iterates all schemes without the apply interval check. As a result, the shortest apply interval is applied to all schemes. Fix the problem by checking the apply interval in damon_do_apply_schemes().
--- mm/damon/core.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
mm/damon/core.c +11 -4
@@ -1026,6 +1026,9 @@ static void damon_do_apply_schemes(strucdamon_for_each_scheme (s, c) {struct damos_quota *quota = &s->quota; +if (c->passed_sample_intervals != s->next_apply_sis) +continue ; +if (!s->wmarks.activated)continue ;
@@ -1126,10 +1129,6 @@ static void kdamond_apply_schemes(structif (c->passed_sample_intervals != s->next_apply_sis)continue ; - s->next_apply_sis += - (s->apply_interval_us ? s->apply_interval_us : - c->attrs.aggr_interval) / sample_interval; -if (!s->wmarks.activated)continue ;
@@ -1145,6 +1144,14 @@ static void kdamond_apply_schemes(structdamon_for_each_region_safe (r, next_r, t)damon_do_apply_schemes (c, t, r); } + +damon_for_each_scheme (s, c) { +if (c->passed_sample_intervals != s->next_apply_sis) +continue ; + s->next_apply_sis += + (s->apply_interval_us ? s->apply_interval_us : + c->attrs.aggr_interval) / sample_interval; + } }/*
Greg Kroah-Hartman
maintainerPATCH 175/334 mm/damon/reclaim: fix quota stauts loss due to online tunings
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 1b0ca4e4ff10a2c8402e2cf70132c683e1c772e4 upstream.
Patch series "mm/damon: fix quota status loss due to online tunings".
DAMON_RECLAIM and DAMON_LRU_SORT is not preserving internal quota status when applying new user parameters, and hence could cause temporal quota accuracy degradation. Fix it by preserving the status.
This patch (of 2):
For online parameters change, DAMON_RECLAIM creates new scheme based on latest values of the parameters and replaces the old scheme with the new one. When creating it, the internal status of the quota of the old scheme is not preserved. As a result, charging of the quota starts from zero after the online tuning. The data that collected to estimate the throughput of the scheme's action is also reset, and therefore the estimation should start from the scratch again. Because the throughput estimation is being used to convert the time quota to the effective size quota, this could result in temporal time quota inaccuracy. It would be recovered over time, though. In short, the quota accuracy could be temporarily degraded after online parameters update.
Fix the problem by checking the case and copying the internal fields for the status.
--- mm/damon/reclaim.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
mm/damon/reclaim.c +17 -1
@@ -150,9 +150,20 @@ static struct damos *damon_reclaim_new_s &damon_reclaim_wmarks); } +static void damon_reclaim_copy_quota_status (struct damos_quota *dst, +struct damos_quota *src) +{ + dst->total_charged_sz = src->total_charged_sz; + dst->total_charged_ns = src->total_charged_ns; + dst->charged_sz = src->charged_sz; + dst->charged_from = src->charged_from; + dst->charge_target_from = src->charge_target_from; + dst->charge_addr_from = src->charge_addr_from; +} +static int damon_reclaim_apply_parameters (void ) { -struct damos *scheme; +struct damos *scheme, *old_scheme;struct damos_filter *filter;int err =0 ;
@@ -164,6 +175,11 @@ static int damon_reclaim_apply_parameter scheme =damon_reclaim_new_scheme ();if (!scheme)return -ENOMEM ; +if (!list_empty (&ctx->schemes)) { +damon_for_each_scheme (old_scheme, ctx) +damon_reclaim_copy_quota_status (&scheme->quota, + &old_scheme->quota); + }if (skip_anon) { filter =damos_new_filter (DAMOS_FILTER_TYPE_ANON , true);if (!filter) {
Greg Kroah-Hartman
maintainerPATCH 176/334 mm/memblock: add MEMBLOCK_RSRV_NOINIT into flagname[] array
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshuman Khandual <[email protected]>
commit 4f155af0ae4464134bfcfd9f043b6b727c84e947 upstream.
The commit 77e6c43e137c ("memblock: introduce MEMBLOCK_RSRV_NOINIT flag") skipped adding this newly introduced memblock flag into flagname[] array, thus preventing a correct memblock flags output for applicable memblock regions.
--- mm/memblock.c | 1 + 1 file changed, 1 insertion(+)
mm/memblock.c +1 -0
@@ -2214,6 +2214,7 @@ static const char * const flagname[] = { [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", + [ilog2(MEMBLOCK_RSRV_NOINIT)] = "RSV_NIT", };static int memblock_debug_show (struct seq_file *m,void *private)
Greg Kroah-Hartman
maintainerPATCH 150/334 drm/buddy: Modify duplicate list_splice_tail call
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arunpravin Paneer Selvam <[email protected]>
commit 02f76a9cd4494719600baf1ab278930df39431ab upstream.
Remove the duplicate list_splice_tail call when the total_allocated < size condition is true.
--- drivers/gpu/drm/drm_buddy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_buddy.c +2 -2
@@ -538,13 +538,13 @@ static int __alloc_range(struct drm_buddy *mm,list_add (&block->left->tmp_link, dfs); }while (1 ); -list_splice_tail (&allocated, blocks); -if (total_allocated < size) { err = -ENOSPC ; goto err_free; } +list_splice_tail (&allocated, blocks); +return 0 ; err_undo:
Signature · 1 line
2.44.0
Greg Kroah-Hartman
maintainerPATCH 177/334 platform/x86: x86-android-tablets: Fix keyboard touchscreen on Lenovo Yogabook1 X90
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit bd8905d70944aae5063fd91c667e6f846ee92718 upstream.
After commit 4014ae236b1d ("platform/x86: x86-android-tablets: Stop using gpiolib private APIs") the touchscreen in the keyboard half of the Lenovo Yogabook1 X90 stopped working with the following error:
Goodix-TS i2c-goodix_ts: error -EBUSY: Failed to get irq GPIO
The problem is that when getting the IRQ for instantiated i2c_client-s from a GPIO (rather then using an IRQ directly from the IOAPIC), x86_acpi_irq_helper_get() now properly requests the GPIO, which disallows other drivers from requesting it. Normally this is a good thing, but the goodix touchscreen also uses the IRQ as an output during reset to select which of its 2 possible I2C addresses should be used.
Add a new free_gpio flag to struct x86_acpi_irq_data to deal with this and release the GPIO after getting the IRQ in this special case.
--- drivers/platform/x86/x86-android-tablets/core.c | 3 +++ drivers/platform/x86/x86-android-tablets/lenovo.c | 1 + drivers/platform/x86/x86-android-tablets/x86-android-tablets.h | 1 + 3 files changed, 5 insertions(+)
drivers/platform/x86/x86-android-tablets/core.c +3 -0
@@ -113,6 +113,9 @@ int x86_acpi_irq_helper_get(const structif (irq_type !=IRQ_TYPE_NONE && irq_type !=irq_get_trigger_type (irq))irq_set_irq_type (irq, irq_type); +if (data->free_gpio) +devm_gpiod_put (&x86_android_tablet_device->dev, gpiod); +return irq;case X86_ACPI_IRQ_TYPE_PMIC : status =acpi_get_handle (NULL , data->chip, &handle);
drivers/platform/x86/x86-android-tablets/lenovo.c +1 -0
@@ -96,6 +96,7 @@ static const struct x86_i2c_client_info .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, .con_id = "goodix_ts_irq", + .free_gpio = true, }, }, {/* Wacom Digitizer in keyboard half */
drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +1 -0
@@ -38,6 +38,7 @@ struct x86_acpi_irq_data {int index;int trigger;/* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */ int polarity;/* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */ +bool free_gpio;/* Release GPIO after getting IRQ (for TYPE_GPIOINT) */ const char *con_id; };
Greg Kroah-Hartman
maintainerPATCH 151/334 drm/amd/display: Only allow dig mapping to pwrseq in new asic
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lewis Huang <[email protected]>
commit 4e73826089ce899357580bbf6e0afe4e6f9900b7 upstream.
[Why]
The old asic only have 1 pwrseq hw.
We don't need to map the diginst to pwrseq inst in old asic.
[How]
1. Only mapping dig to pwrseq for new asic.
2. Move mapping function into dcn specific panel control component
--- drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c | 1 drivers/gpu/drm/amd/display/dc/dcn301/dcn301_panel_cntl.c | 1 drivers/gpu/drm/amd/display/dc/dcn31/dcn31_panel_cntl.c | 18 +++++++++ drivers/gpu/drm/amd/display/dc/inc/hw/panel_cntl.h | 2 - drivers/gpu/drm/amd/display/dc/link/link_factory.c | 26 -------------- 5 files changed, 21 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c +1 -0
@@ -290,4 +290,5 @@ void dce_panel_cntl_construct( dce_panel_cntl->base.funcs = &dce_link_panel_cntl_funcs; dce_panel_cntl->base.ctx = init_data->ctx; dce_panel_cntl->base.inst = init_data->inst; + dce_panel_cntl->base.pwrseq_inst =0 ; }
drivers/gpu/drm/amd/display/dc/dcn301/dcn301_panel_cntl.c +1 -0
@@ -215,4 +215,5 @@ void dcn301_panel_cntl_construct( dcn301_panel_cntl->base.funcs = &dcn301_link_panel_cntl_funcs; dcn301_panel_cntl->base.ctx = init_data->ctx; dcn301_panel_cntl->base.inst = init_data->inst; + dcn301_panel_cntl->base.pwrseq_inst =0 ; }
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_panel_cntl.c +17 -1
@@ -154,8 +154,24 @@ void dcn31_panel_cntl_construct(struct dcn31_panel_cntl *dcn31_panel_cntl, const struct panel_cntl_init_data *init_data) { + uint8_t pwrseq_inst = 0xF; + dcn31_panel_cntl->base.funcs = &dcn31_link_panel_cntl_funcs; dcn31_panel_cntl->base.ctx = init_data->ctx; dcn31_panel_cntl->base.inst = init_data->inst; - dcn31_panel_cntl->base.pwrseq_inst = init_data->pwrseq_inst; + +switch (init_data->eng_id) { +case ENGINE_ID_DIGA : + pwrseq_inst =0 ; +break ; +case ENGINE_ID_DIGB : + pwrseq_inst =1 ; +break ; +default : +DC_LOG_WARNING ("Unsupported pwrseq engine id: %d!\n" , init_data->eng_id); +ASSERT (false); +break ; + } + + dcn31_panel_cntl->base.pwrseq_inst = pwrseq_inst; }
drivers/gpu/drm/amd/display/dc/inc/hw/panel_cntl.h +1 -1
@@ -56,7 +56,7 @@ struct panel_cntl_funcs {struct panel_cntl_init_data {struct dc_context *ctx;uint32_t inst; -uint32_t pwrseq_inst; +uint32_t eng_id; };struct panel_cntl {
drivers/gpu/drm/amd/display/dc/link/link_factory.c +1 -25
@@ -368,30 +368,6 @@ static enum transmitter translate_encode } } -static uint8_t translate_dig_inst_to_pwrseq_inst (struct dc_link *link) -{ -uint8_t pwrseq_inst =0xF ; -struct dc_context *dc_ctx = link->dc->ctx; - -DC_LOGGER_INIT (dc_ctx->logger); - -switch (link->eng_id) { -case ENGINE_ID_DIGA : - pwrseq_inst =0 ; -break ; -case ENGINE_ID_DIGB : - pwrseq_inst =1 ; -break ; -default : -DC_LOG_WARNING ("Unsupported pwrseq engine id: %d!\n" , link->eng_id); -ASSERT (false); -break ; - } - -return pwrseq_inst; -} - -static void link_destruct (struct dc_link *link) {int i;
@@ -655,7 +631,7 @@ static bool construct_phy(struct dc_link link->link_id.id == CONNECTOR_ID_LVDS)) { panel_cntl_init_data.ctx = dc_ctx; panel_cntl_init_data.inst = panel_cntl_init_data.ctx->dc_edp_id_count; - panel_cntl_init_data.pwrseq_inst =translate_dig_inst_to_pwrseq_inst (link); + panel_cntl_init_data.eng_id = link->eng_id; link->panel_cntl = link->dc->res_pool->funcs->panel_cntl_create ( &panel_cntl_init_data);
Greg Kroah-Hartman
maintainerPATCH 152/334 drm/amd/display: adjust few initialization order in dm
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayne Lin <[email protected]>
commit 22e1dc4b2fec17af70f297a4295c5f19a0f3fbeb upstream.
[Why]
Observe error message "Can't retrieve aconnector in hpd_rx_irq_offload_work" when boot up with a mst tbt4 dock connected. After analyzing, there are few parts needed to be adjusted:
1. hpd_rx_offload_wq[].aconnector is not initialzed before the dmub outbox hpd_irq handler get registered which causes the error message.
2. registeration of hpd and hpd_rx_irq event for usb4 dp tunneling is not aligned with legacy interface sequence
[How]
Put DMUB_NOTIFICATION_HPD and DMUB_NOTIFICATION_HPD_IRQ handler registration into register_hpd_handlers() to align other interfaces and get hpd_rx_offload_wq[].aconnector initialized earlier than that.
Leave DMUB_NOTIFICATION_AUX_REPLY registered as it was since we need that while calling dc_link_detect(). USB4 connection status will be proactively detected by dc_link_detect_connection_type() in amdgpu_dm_initialize_drm_device()
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 37 ++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +18 -19
@@ -1810,21 +1810,12 @@ static int amdgpu_dm_init(struct amdgpu_DRM_ERROR ("amdgpu: fail to register dmub aux callback" ); goto error; } -if (!register_dmub_notify_callback (adev,DMUB_NOTIFICATION_HPD , dmub_hpd_callback, true)) { -DRM_ERROR ("amdgpu: fail to register dmub hpd callback" ); - goto error; - } -if (!register_dmub_notify_callback (adev,DMUB_NOTIFICATION_HPD_IRQ , dmub_hpd_callback, true)) { -DRM_ERROR ("amdgpu: fail to register dmub hpd callback" ); - goto error; - } - } - -/* Enable outbox notification only after IRQ handlers are registered and DMUB is alive. -* It is expected that DMUB will resend any pending notifications at this point, for -* example HPD from DPIA. -*/ -if (dc_is_dmub_outbox_supported (adev->dm.dc)) { +/* Enable outbox notification only after IRQ handlers are registered and DMUB is alive. +* It is expected that DMUB will resend any pending notifications at this point. Note +* that hpd and hpd_irq handler registration are deferred to register_hpd_handlers() to +* align legacy interface initialization sequence. Connection status will be proactivly +* detected once in the amdgpu_dm_initialize_drm_device. +*/ dc_enable_dmub_outbox (adev->dm.dc);/* DPIA trace goes to dmesg logs only if outbox is enabled */
@@ -3494,6 +3485,14 @@ static void register_hpd_handlers(struct int_params.requested_polarity =INTERRUPT_POLARITY_DEFAULT ; int_params.current_polarity =INTERRUPT_POLARITY_DEFAULT ; +if (dc_is_dmub_outbox_supported (adev->dm.dc)) { +if (!register_dmub_notify_callback (adev,DMUB_NOTIFICATION_HPD , dmub_hpd_callback, true)) +DRM_ERROR ("amdgpu: fail to register dmub hpd callback" ); + +if (!register_dmub_notify_callback (adev,DMUB_NOTIFICATION_HPD_IRQ , dmub_hpd_callback, true)) +DRM_ERROR ("amdgpu: fail to register dmub hpd callback" ); + } +list_for_each_entry (connector, &dev->mode_config.connector_list, head) {
@@ -3519,10 +3518,6 @@ static void register_hpd_handlers(struct handle_hpd_rx_irq, (void *) aconnector); } - -if (adev->dm.hpd_rx_offload_wq) - adev->dm.hpd_rx_offload_wq[connector->index].aconnector = - aconnector; } }
@@ -4493,6 +4488,10 @@ static int amdgpu_dm_initialize_drm_devi link =dc_get_link_at_index (dm->dc, i); +if (dm->hpd_rx_offload_wq) + dm->hpd_rx_offload_wq[aconnector->base.index].aconnector = + aconnector; +if (!dc_link_detect_connection_type (link, &new_connection_type))DRM_ERROR ("KMS: Failed to detect connector\n" );
Greg Kroah-Hartman
maintainerPATCH 153/334 drm/amdgpu: Fix the runtime resume failure issue
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Jun <[email protected]>
commit bbfaf2aea7164db59739728d62d9cc91d64ff856 upstream.
Don't set power state flag when system enter runtime suspend, or it may cause runtime resume failure issue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +3 -0
@@ -1528,6 +1528,9 @@ bool amdgpu_acpi_is_s0ix_active(struct a*/ void amdgpu_choose_low_power_state (struct amdgpu_device *adev) { +if (adev->in_runpm) +return ; +if (amdgpu_acpi_is_s0ix_active (adev)) adev->in_s0ix = true;else if (amdgpu_acpi_is_s3_active (adev))
Greg Kroah-Hartman
maintainerPATCH 154/334 s390/cio: fix invalid -EBUSY on ccw_device_start
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Oberparleiter <[email protected]>
commit 5ef1dc40ffa6a6cb968b0fdc43c3a61727a9e950 upstream.
The s390 common I/O layer (CIO) returns an unexpected -EBUSY return code when drivers try to start I/O while a path-verification (PV) process is pending. This can lead to failed device initialization attempts with symptoms like broken network connectivity after boot.
Fix this by replacing the -EBUSY return code with a deferred condition code 1 reply to make path-verification handling consistent from a driver's point of view.
The problem can be reproduced semi-regularly using the following process, while repeating steps 2-3 as necessary (example assumes an OSA device with bus-IDs 0.0.a000-0.0.a002 on CHPID 0.02):
1. echo 0.0.a000,0.0.a001,0.0.a002 >/sys/bus/ccwgroup/drivers/qeth/group
2. echo 0 > /sys/bus/ccwgroup/devices/0.0.a000/online
3. echo 1 > /sys/bus/ccwgroup/devices/0.0.a000/online ; \
echo on > /sys/devices/css0/chp0.02/status
Background information:
The common I/O layer starts path-verification I/Os when it receives indications about changes in a device path's availability. This occurs for example when hardware events indicate a change in channel-path status, or when a manual operation such as a CHPID vary or configure operation is performed.
If a driver attempts to start I/O while a PV is running, CIO reports a successful I/O start (ccw_device_start() return code 0). Then, after completion of PV, CIO synthesizes an interrupt response that indicates an asynchronous status condition that prevented the start of the I/O (deferred condition code 1).
If a PV indication arrives while a device is busy with driver-owned I/O, PV is delayed until after I/O completion was reported to the driver's interrupt handler. To ensure that PV can be started eventually, CIO reports a device busy condition (ccw_device_start() return code -EBUSY) if a driver tries to start another I/O while PV is pending.
In some cases this -EBUSY return code causes device drivers to consider a device not operational, resulting in failed device initialization.
Note: The code that introduced the problem was added in 2003. Symptoms started appearing with the following CIO commit that causes a PV indication when a device is removed from the cio_ignore list after the associated parent subchannel device was probed, but before online processing of the CCW device has started:
2297791c92d0 ("s390/cio: dont unregister subchannel from child-drivers")
During boot, the cio_ignore list is modified by the cio_ignore dracut module [1] as well as Linux vendor-specific systemd service scripts[2]. When combined, this commit and boot scripts cause a frequent occurrence of the problem during boot.
[1] https://github.com/dracutdevs/dracut/tree/master/modules.d/81cio_ignore
[2] https://github.com/SUSE/s390-tools/blob/master/cio_ignore.service
--- drivers/s390/cio/device_ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/s390/cio/device_ops.c +3 -3
@@ -202,7 +202,8 @@ int ccw_device_start_timeout_key(structreturn -EINVAL ;if (cdev->private->state ==DEV_STATE_NOT_OPER )return -ENODEV ; -if (cdev->private->state ==DEV_STATE_VERIFY ) { +if (cdev->private->state ==DEV_STATE_VERIFY || + cdev->private->flags.doverify) {/* Remember to fake irb when finished. */ if (!cdev->private->flags.fake_irb) { cdev->private->flags.fake_irb =FAKE_CMD_IRB ;
@@ -214,8 +215,7 @@ int ccw_device_start_timeout_key(struct }if (cdev->private->state !=DEV_STATE_ONLINE || ((sch->schib.scsw.cmd.stctl &SCSW_STCTL_PRIM_STATUS ) && - !(sch->schib.scsw.cmd.stctl &SCSW_STCTL_SEC_STATUS )) || - cdev->private->flags.doverify) + !(sch->schib.scsw.cmd.stctl &SCSW_STCTL_SEC_STATUS )))return -EBUSY ; ret =cio_set_options (sch, flags);if (ret)
Greg Kroah-Hartman
maintainerPATCH 155/334 ata: libata-core: Do not try to set sleeping devices to standby
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 4b085736e44dbbe69b5eea1a8a294f404678a1f4 upstream.
In ata ata_dev_power_set_standby(), check that the target device is not sleeping. If it is, there is no need to do anything.
--- drivers/ata/libata-core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/ata/libata-core.c +4 -0
@@ -2017,6 +2017,10 @@ void ata_dev_power_set_standby(struct atstruct ata_taskfile tf;unsigned int err_mask; +/* If the device is already sleeping, do nothing. */ +if (dev->flags &ATA_DFLAG_SLEEPING ) +return ; +/* * Some odd clown BIOSes issue spindown on power off (ACPI S4 or S5) * causing some drives to spin up and down again. For these, do nothing
Greg Kroah-Hartman
maintainerPATCH 156/334 ata: libata-core: Do not call ata_dev_power_set_standby() twice
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 9cec467d0502b24660f413a0e8fc782903b46d5b upstream.
For regular system shutdown, ata_dev_power_set_standby() will be executed twice: once the scsi device is removed and another when ata_pci_shutdown_one() executes and EH completes unloading the devices.
Make the second call to ata_dev_power_set_standby() do nothing by using ata_dev_power_is_active() and return if the device is already in standby.
--- drivers/ata/libata-core.c | 59 +++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 29 deletions(-)
drivers/ata/libata-core.c +30 -29
@@ -2001,6 +2001,33 @@ bool ata_dev_power_init_tf(struct ata_dereturn true; } +static bool ata_dev_power_is_active (struct ata_device *dev) +{ +struct ata_taskfile tf; +unsigned int err_mask; + +ata_tf_init (dev, &tf); + tf.flags |=ATA_TFLAG_DEVICE |ATA_TFLAG_ISADDR ; + tf.protocol =ATA_PROT_NODATA ; + tf.command =ATA_CMD_CHK_POWER ; + + err_mask =ata_exec_internal (dev, &tf,NULL ,DMA_NONE ,NULL ,0 ,0 ); +if (err_mask) { +ata_dev_err (dev,"Check power mode failed (err_mask=0x%x)\n" , + err_mask); +/* +* Assume we are in standby mode so that we always force a +* spinup in ata_dev_power_set_active(). +*/ +return false; + } + +ata_dev_dbg (dev,"Power mode: 0x%02x\n" , tf.nsect); + +/* Active or idle */ +return tf.nsect ==0xff ; +} +/** * ata_dev_power_set_standby - Set a device power mode to standby * @dev: target device
@@ -2017,8 +2044,9 @@ void ata_dev_power_set_standby(struct atstruct ata_taskfile tf;unsigned int err_mask; -/* If the device is already sleeping, do nothing. */ -if (dev->flags &ATA_DFLAG_SLEEPING ) +/* If the device is already sleeping or in standby, do nothing. */ +if ((dev->flags &ATA_DFLAG_SLEEPING ) || + !ata_dev_power_is_active (dev))return ;/*
@@ -2046,33 +2074,6 @@ void ata_dev_power_set_standby(struct at err_mask); } -static bool ata_dev_power_is_active (struct ata_device *dev) -{ -struct ata_taskfile tf; -unsigned int err_mask; - -ata_tf_init (dev, &tf); - tf.flags |=ATA_TFLAG_DEVICE |ATA_TFLAG_ISADDR ; - tf.protocol =ATA_PROT_NODATA ; - tf.command =ATA_CMD_CHK_POWER ; - - err_mask =ata_exec_internal (dev, &tf,NULL ,DMA_NONE ,NULL ,0 ,0 ); -if (err_mask) { -ata_dev_err (dev,"Check power mode failed (err_mask=0x%x)\n" , - err_mask); -/* -* Assume we are in standby mode so that we always force a -* spinup in ata_dev_power_set_active(). -*/ -return false; - } - -ata_dev_dbg (dev,"Power mode: 0x%02x\n" , tf.nsect); - -/* Active or idle */ -return tf.nsect ==0xff ; -} -/** * ata_dev_power_set_active - Set a device power mode to active * @dev: target device
Greg Kroah-Hartman
maintainerPATCH 147/334 btrfs: defrag: avoid unnecessary defrag caused by incorrect extent size
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit e42b9d8b9ea2672811285e6a7654887ff64d23f3 upstream.
[BUG]
With the following file extent layout, defrag would do unnecessary IO and result more on-disk space usage.
# mkfs.btrfs -f $dev # mount $dev $mnt # xfs_io -f -c "pwrite 0 40m" $mnt/foobar # sync # xfs_io -f -c "pwrite 40m 16k" $mnt/foobar # sync
Above command would lead to the following file extent layout:
item 6 key (257 EXTENT_DATA 0) itemoff 15816 itemsize 53
generation 7 type 1 (regular)
extent data disk byte 298844160 nr 41943040
extent data offset 0 nr 41943040 ram 41943040
extent compression 0 (none)
item 7 key (257 EXTENT_DATA 41943040) itemoff 15763 itemsize 53
generation 8 type 1 (regular)
extent data disk byte 13631488 nr 16384
extent data offset 0 nr 16384 ram 16384
extent compression 0 (none)Which is mostly fine. We can allow the final 16K to be merged with the previous 40M, but it's upon the end users' preference.
But if we defrag the file using the default parameters, it would result worse file layout:
# btrfs filesystem defrag $mnt/foobar # sync
item 6 key (257 EXTENT_DATA 0) itemoff 15816 itemsize 53
generation 7 type 1 (regular)
extent data disk byte 298844160 nr 41943040
extent data offset 0 nr 8650752 ram 41943040
extent compression 0 (none)
item 7 key (257 EXTENT_DATA 8650752) itemoff 15763 itemsize 53
generation 9 type 1 (regular)
extent data disk byte 340787200 nr 33292288
extent data offset 0 nr 33292288 ram 33292288
extent compression 0 (none)
item 8 key (257 EXTENT_DATA 41943040) itemoff 15710 itemsize 53
generation 8 type 1 (regular)
extent data disk byte 13631488 nr 16384
extent data offset 0 nr 16384 ram 16384
extent compression 0 (none)Note the original 40M extent is still there, but a new 32M extent is created for no benefit at all.
[CAUSE]
There is an existing check to make sure we won't defrag a large enough extent (the threshold is by default 32M).
But the check is using the length to the end of the extent:
range_len = em->len - (cur - em->start); /* Skip too large extent */ if (range_len >= extent_thresh) goto next;
This means, for the first 8MiB of the extent, the range_len is always smaller than the default threshold, and would not be defragged. But after the first 8MiB, the remaining part would fit the requirement, and be defragged.
Such different behavior inside the same extent caused the above problem, and we should avoid different defrag decision inside the same extent.
[FIX]
Instead of using @range_len, just use @em->len, so that we have a consistent decision among the same file extent.
Now with this fix, we won't touch the extent, thus not making it any worse.
--- fs/btrfs/defrag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/defrag.c +1 -1
@@ -1047,7 +1047,7 @@ static int defrag_collect_targets(struct goto add;/* Skip too large extent */ -if (range_len >= extent_thresh) +if (em->len >= extent_thresh) goto next;/*
Greg Kroah-Hartman
maintainerPATCH 179/334 platform/x86: touchscreen_dmi: Allow partial (prefix) matches for ACPI names
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit dbcbfd662a725641d118fb3ae5ffb7be4e3d0fb0 upstream.
On some devices the ACPI name of the touchscreen is e.g. either MSSL1680:00 or MSSL1680:01 depending on the BIOS version.
This happens for example on the "Chuwi Hi8 Air" tablet where the initial commit's ts_data uses "MSSL1680:00" but the tablets from the github issue and linux-hardware.org probe linked below both use "MSSL1680:01".
Replace the strcmp() match on ts_data->acpi_name with a strstarts() check to allow using a partial match on just the ACPI HID of "MSSL1680" and change the ts_data->acpi_name for the "Chuwi Hi8 Air" accordingly to fix the touchscreen not working on models where it is "MSSL1680:01".
Note this drops the length check for I2C_NAME_SIZE. This never was necessary since the ACPI names used are never more then 11 chars and I2C_NAME_SIZE is 20 so the replaced strncmp() would always stop long before reaching I2C_NAME_SIZE.
--- drivers/platform/x86/touchscreen_dmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/touchscreen_dmi.c +2 -2
@@ -81,7 +81,7 @@ static const struct property_entry chuwi };static const struct ts_dmi_data chuwi_hi8_air_data = { - .acpi_name ="MSSL1680:00" , + .acpi_name ="MSSL1680" , .properties = chuwi_hi8_air_props, };
@@ -1821,7 +1821,7 @@ static void ts_dmi_add_props(struct i2c_int error;if (has_acpi_companion (dev) && - !strncmp (ts_data->acpi_name, client->name,I2C_NAME_SIZE )) { +strstarts (client->name, ts_data->acpi_name)) { error =device_create_managed_software_node (dev, ts_data->properties,NULL );if (error)dev_err (dev,"failed to add properties: %d\n" , error);
Greg Kroah-Hartman
maintainerPATCH 188/334 KVM: arm64: vgic-its: Test for valid IRQ in MOVALL handler
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit 85a71ee9a0700f6c18862ef3b0011ed9dad99aca upstream.
It is possible that an LPI mapped in a different ITS gets unmapped while handling the MOVALL command. If that is the case, there is no state that can be migrated to the destination. Silently ignore it and continue migrating other LPIs.
--- arch/arm64/kvm/vgic/vgic-its.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/kvm/vgic/vgic-its.c +2 -0
@@ -1432,6 +1432,8 @@ static int vgic_its_cmd_handle_movall(stfor (i =0 ; i < irq_count; i++) { irq =vgic_get_irq (kvm,NULL , intids[i]); +if (!irq) +continue ;update_affinity (irq, vcpu2);
Greg Kroah-Hartman
maintainerPATCH 189/334 KVM: arm64: vgic-its: Test for valid IRQ in its_sync_lpi_pending_table()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit 8d3a7dfb801d157ac423261d7cd62c33e95375f8 upstream.
vgic_get_irq() may not return a valid descriptor if there is no ITS that holds a valid translation for the specified INTID. If that is the case, it is safe to silently ignore it and continue processing the LPI pending table.
--- arch/arm64/kvm/vgic/vgic-its.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kvm/vgic/vgic-its.c +3 -0
@@ -468,6 +468,9 @@ static int its_sync_lpi_pending_table(st } irq =vgic_get_irq (vcpu->kvm,NULL , intids[i]); +if (!irq) +continue ; +raw_spin_lock_irqsave (&irq->irq_lock, flags); irq->pending_latch = pendmask & (1U << bit_nr);vgic_queue_irq_unlock (vcpu->kvm, irq, flags);
Greg Kroah-Hartman
maintainerPATCH 190/334 accel/ivpu: Dont enable any tiles by default on VPU40xx
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrzej Kacprowski <[email protected]>
commit eb0d253ff9c74dee30aa92fe460b825eb28acd73 upstream.
There is no point in requesting 1 tile on VPU40xx as the FW will probably need more tiles to run workloads, so it will have to reconfigure PLL anyway. Don't enable any tiles and allow the FW to perform initial tile configuration.
This improves NPU boot stability as the tiles are always enabled only by the FW from the same initial state.
--- drivers/accel/ivpu/ivpu_hw_40xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_hw_40xx.c +1 -1
@@ -24,7 +24,7 @@#define SKU_HW_ID_SHIFT 16u#define SKU_HW_ID_MASK 0xffff0000u -#define PLL_CONFIG_DEFAULT 0x1 +#define PLL_CONFIG_DEFAULT 0x0#define PLL_CDYN_DEFAULT 0x80#define PLL_EPP_DEFAULT 0x80#define PLL_REF_CLK_FREQ (50 * 1000000)
Greg Kroah-Hartman
maintainerPATCH 191/334 gtp: fix use-after-free and null-ptr-deref in gtp_genl_dump_pdp()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasiliy Kovalev <[email protected]>
commit 136cfaca22567a03bbb3bf53a43d8cb5748b80ec upstream.
The gtp_net_ops pernet operations structure for the subsystem must be registered before registering the generic netlink family.
Syzkaller hit 'general protection fault in gtp_genl_dump_pdp' bug:
general protection fault, probably for non-canonical address
0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 1 PID: 5826 Comm: gtp Not tainted 6.8.0-rc3-std-def-alt1 #1
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-alt1 04/01/2014
RIP: 0010:gtp_genl_dump_pdp+0x1be/0x800 [gtp]
Code: c6 89 c6 e8 64 e9 86 df 58 45 85 f6 0f 85 4e 04 00 00 e8 c5 ee 86
df 48 8b 54 24 18 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80>
3c 02 00 0f 85 de 05 00 00 48 8b 44 24 18 4c 8b 30 4c 39 f0 74
RSP: 0018:ffff888014107220 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000002 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: ffff88800fcda588 R14: 0000000000000001 R15: 0000000000000000
FS: 00007f1be4eb05c0(0000) GS:ffff88806ce80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f1be4e766cf CR3: 000000000c33e000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
<TASK>
? show_regs+0x90/0xa0
? die_addr+0x50/0xd0
? exc_general_protection+0x148/0x220
? asm_exc_general_protection+0x22/0x30
? gtp_genl_dump_pdp+0x1be/0x800 [gtp]
? __alloc_skb+0x1dd/0x350
? __pfx___alloc_skb+0x10/0x10
genl_dumpit+0x11d/0x230
netlink_dump+0x5b9/0xce0
? lockdep_hardirqs_on_prepare+0x253/0x430
? __pfx_netlink_dump+0x10/0x10
? kasan_save_track+0x10/0x40
? __kasan_kmalloc+0x9b/0xa0
? genl_start+0x675/0x970
__netlink_dump_start+0x6fc/0x9f0
genl_family_rcv_msg_dumpit+0x1bb/0x2d0
? __pfx_genl_family_rcv_msg_dumpit+0x10/0x10
? genl_op_from_small+0x2a/0x440
? cap_capable+0x1d0/0x240
? __pfx_genl_start+0x10/0x10
? __pfx_genl_dumpit+0x10/0x10
? __pfx_genl_done+0x10/0x10
? security_capable+0x9d/0xe0--- drivers/net/gtp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/gtp.c +5 -5
@@ -1907,20 +1907,20 @@ static int __init gtp_init(void)if (err <0 ) goto error_out; - err =genl_register_family (>p_genl_family); + err =register_pernet_subsys (>p_net_ops);if (err <0 ) goto unreg_rtnl_link; - err =register_pernet_subsys (>p_net_ops); + err =genl_register_family (>p_genl_family);if (err <0 ) - goto unreg_genl_family; + goto unreg_pernet_subsys;pr_info ("GTP module loaded (pdp ctx size %zd bytes)\n" ,sizeof (struct pdp_ctx ));return 0 ; -unreg_genl_family: -genl_unregister_family (>p_genl_family); +unreg_pernet_subsys: +unregister_pernet_subsys (>p_net_ops); unreg_rtnl_link:rtnl_link_unregister (>p_link_ops); error_out:
Greg Kroah-Hartman
maintainerPATCH 192/334 crypto: virtio/akcipher - Fix stack overflow on memcpy
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: zhenwei pi <[email protected]>
commit c0ec2a712daf133d9996a8a1b7ee2d4996080363 upstream.
sizeof(struct virtio_crypto_akcipher_session_para) is less than sizeof(struct virtio_crypto_op_ctrl_req::u), copying more bytes from stack variable leads stack overflow. Clang reports this issue by commands:
make -j CC=clang-14 mrproper >/dev/null 2>&1
make -j O=/tmp/crypto-build CC=clang-14 allmodconfig >/dev/null 2>&1 make -j O=/tmp/crypto-build W=1 CC=clang-14 drivers/crypto/virtio/
virtio_crypto_akcipher_algs.o
--- drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/crypto/virtio/virtio_crypto_akcipher_algs.c +3 -2
@@ -104,7 +104,8 @@ static void virtio_crypto_dataq_akcipher }static int virtio_crypto_alg_akcipher_init_session (struct virtio_crypto_akcipher_ctx *ctx, -struct virtio_crypto_ctrl_header *header,void *para, +struct virtio_crypto_ctrl_header *header, +struct virtio_crypto_akcipher_session_para *para,const uint8_t *key,unsigned int keylen) {struct scatterlist outhdr_sg, key_sg, inhdr_sg, *sgs[3 ];
@@ -128,7 +129,7 @@ static int virtio_crypto_alg_akcipher_in ctrl = &vc_ctrl_req->ctrl;memcpy (&ctrl->header, header,sizeof (ctrl->header)); -memcpy (&ctrl->u, para,sizeof (ctrl->u)); +memcpy (&ctrl->u.akcipher_create_session.para, para,sizeof (*para)); input = &vc_ctrl_req->input; input->status =cpu_to_le32 (VIRTIO_CRYPTO_ERR );
Greg Kroah-Hartman
maintainerPATCH 193/334 irqchip/mbigen: Dont use bus_get_dev_root() to find the parent
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Jun <[email protected]>
commit fb33a46cd75e18773dd5a414744507d84ae90870 upstream.
bus_get_dev_root() returns sp->dev_root which is set in subsys_register(), but subsys_register() is not called by platform_bus_init().
Therefor for the platform_bus_type, bus_get_dev_root() always returns NULL. This makes mbigen_of_create_domain() always return -ENODEV.
Don't try to retrieve the parent via bus_get_dev_root() and unconditionally hand a NULL pointer to of_platform_device_create() to fix this.
--- drivers/irqchip/irq-mbigen.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/irqchip/irq-mbigen.c +1 -7
@@ -235,22 +235,17 @@ static const struct irq_domain_ops mbigestatic int mbigen_of_create_domain (struct platform_device *pdev,struct mbigen_device *mgn_chip) { -struct device *parent;struct platform_device *child;struct irq_domain *domain;struct device_node *np;u32 num_pins;int ret =0 ; - parent =bus_get_dev_root (&platform_bus_type); -if (!parent) -return -ENODEV ; -for_each_child_of_node (pdev->dev.of_node, np) {if (!of_property_read_bool (np,"interrupt-controller" ))continue ; - child =of_platform_device_create (np,NULL , parent); + child =of_platform_device_create (np,NULL ,NULL );if (!child) { ret = -ENOMEM ;break ;
@@ -273,7 +268,6 @@ static int mbigen_of_create_domain(struc } } -put_device (parent);if (ret)of_node_put (np);
Greg Kroah-Hartman
maintainerPATCH 194/334 irqchip/gic-v3-its: Do not assume vPE tables are preallocated
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit ec4308ecfc887128a468f03fb66b767559c57c23 upstream.
The GIC/ITS code is designed to ensure to pick up any preallocated LPI tables on the redistributors, as enabling LPIs is a one-way switch. There is no such restriction for vLPIs, and for GICv4.1 it is expected to allocate a new vPE table at boot.
This works as intended when initializing an ITS, however when setting up a redistributor in cpu_init_lpis() the early return for preallocated RD tables skips straight past the GICv4 setup. This all comes to a head when trying to kexec() into a new kernel, as the new kernel silently fails to set up GICv4, leading to a complete loss of SGIs and LPIs for KVM VMs.
Slap a band-aid on the problem by ensuring its_cpu_init_lpis() always initializes GICv4 on the way out, even if the other RD tables were preallocated.
--- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +1 -1
@@ -3181,6 +3181,7 @@ static void its_cpu_init_lpis(void) val |=GICR_CTLR_ENABLE_LPIS ;writel_relaxed (val, rbase +GICR_CTLR ); +out:if (gic_rdists->has_vlpis && !gic_rdists->has_rvpeid) {void __iomem *vlpi_base =gic_data_rdist_vlpi_base ();
@@ -3216,7 +3217,6 @@ static void its_cpu_init_lpis(void)/* Make sure the GIC has seen the above */ dsb (sy); -out:gic_data_rdist ()->flags |=RD_LOCAL_LPI_ENABLED ; pr_info("GICv3: CPU%d: using %s LPI pending table @%pa\n", smp_processor_id(),
Greg Kroah-Hartman
maintainerPATCH 195/334 irqchip/sifive-plic: Enable interrupt if needed before EOI
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nam Cao <[email protected]>
commit 9c92006b896c767218aabe8947b62026a571cfd0 upstream.
RISC-V PLIC cannot "end-of-interrupt" (EOI) disabled interrupts, as explained in the description of Interrupt Completion in the PLIC spec:
"The PLIC signals it has completed executing an interrupt handler by writing the interrupt ID it received from the claim to the claim/complete register. The PLIC does not check whether the completion ID is the same as the last claim ID for that target. If the completion ID does not match an interrupt source that *is currently enabled* for the target, the completion is silently ignored."
Commit 69ea463021be ("irqchip/sifive-plic: Fixup EOI failed when masked") ensured that EOI is successful by enabling interrupt first, before EOI.
Commit a1706a1c5062 ("irqchip/sifive-plic: Separate the enable and mask operations") removed the interrupt enabling code from the previous commit, because it assumes that interrupt should already be enabled at the point of EOI.
However, this is incorrect: there is a window after a hart claiming an interrupt and before irq_desc->lock getting acquired, interrupt can be disabled during this window. Thus, EOI can be invoked while the interrupt is disabled, effectively nullify this EOI. This results in the interrupt never gets asserted again, and the device who uses this interrupt appears frozen.
Make sure that interrupt is really enabled before EOI.
--- drivers/irqchip/irq-sifive-plic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/irqchip/irq-sifive-plic.c +7 -1
@@ -148,7 +148,13 @@ static void plic_irq_eoi(struct irq_data {struct plic_handler *handler =this_cpu_ptr (&plic_handlers); -writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); +if (unlikely (irqd_irq_disabled (d))) { +plic_toggle (handler, d->hwirq,1 ); +writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); +plic_toggle (handler, d->hwirq,0 ); + }else { +writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); + } }#ifdef CONFIG_SMP
Greg Kroah-Hartman
maintainerPATCH 196/334 PCI/MSI: Prevent MSI hardware interrupt number truncation
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidya Sagar <[email protected]>
commit db744ddd59be798c2627efbfc71f707f5a935a40 upstream.
While calculating the hardware interrupt number for a MSI interrupt, the higher bits (i.e. from bit-5 onwards a.k.a domain_nr >= 32) of the PCI domain number gets truncated because of the shifted value casting to return type of pci_domain_nr() which is 'int'. This for example is resulting in same hardware interrupt number for devices 0019:00:00.0 and 0039:00:00.0.
To address this cast the PCI domain number to 'irq_hw_number_t' before left shifting it to calculate the hardware interrupt number.
Please note that this fixes the issue only on 64-bit systems and doesn't change the behavior for 32-bit systems i.e. the 32-bit systems continue to have the issue. Since the issue surfaces only if there are too many PCIe controllers in the system which usually is the case in modern server systems and they don't tend to run 32-bit kernels.
--- drivers/pci/msi/irqdomain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/msi/irqdomain.c +1 -1
@@ -61,7 +61,7 @@ static irq_hw_number_t pci_msi_domain_careturn (irq_hw_number_t )desc->msi_index |pci_dev_id (dev) <<11 | - (pci_domain_nr (dev->bus) &0xFFFFFFFF ) <<27 ; + ((irq_hw_number_t)(pci_domain_nr (dev->bus) &0xFFFFFFFF )) <<27 ; } static void pci_msi_domain_set_desc(msi_alloc_info_t *arg,
Greg Kroah-Hartman
maintainerPATCH 197/334 l2tp: pass correct message length to ip6_append_data
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Parkin <[email protected]>
commit 359e54a93ab43d32ee1bff3c2f9f10cb9f6b6e79 upstream.
l2tp_ip6_sendmsg needs to avoid accounting for the transport header twice when splicing more data into an already partially-occupied skbuff.
To manage this, we check whether the skbuff contains data using skb_queue_empty when deciding how much data to append using ip6_append_data.
However, the code which performed the calculation was incorrect:
ulen = len + skb_queue_empty(&sk->sk_write_queue) ? transhdrlen : 0;
...due to C operator precedence, this ends up setting ulen to transhdrlen for messages with a non-zero length, which results in corrupted packets on the wire.
Add parentheses to correct the calculation in line with the original intent.
--- net/l2tp/l2tp_ip6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/l2tp/l2tp_ip6.c +1 -1
@@ -627,7 +627,7 @@ static int l2tp_ip6_sendmsg(struct sock back_from_confirm:lock_sock (sk); - ulen = len +skb_queue_empty (&sk->sk_write_queue) ? transhdrlen :0 ; + ulen = len + (skb_queue_empty (&sk->sk_write_queue) ? transhdrlen :0 ); err = ip6_append_data(sk, ip_generic_getfrag, msg, ulen, transhdrlen, &ipc6, &fl6, (struct rt6_info *)dst,
Greg Kroah-Hartman
maintainerPATCH 180/334 cachefiles: fix memory leak in cachefiles_add_cache()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit e21a2f17566cbd64926fb8f16323972f7a064444 upstream.
The following memory leak was reported after unbinding /dev/cachefiles:
==================================================================
unreferenced object 0xffff9b674176e3c0 (size 192):
comm "cachefilesd2", pid 680, jiffies 4294881224 hex dump (first 32 bytes):
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc ea38a44b):
[<ffffffff8eb8a1a5>] kmem_cache_alloc+0x2d5/0x370
[<ffffffff8e917f86>] prepare_creds+0x26/0x2e0
[<ffffffffc002eeef>] cachefiles_determine_cache_security+0x1f/0x120
[<ffffffffc00243ec>] cachefiles_add_cache+0x13c/0x3a0
[<ffffffffc0025216>] cachefiles_daemon_write+0x146/0x1c0
[<ffffffff8ebc4a3b>] vfs_write+0xcb/0x520
[<ffffffff8ebc5069>] ksys_write+0x69/0xf0
[<ffffffff8f6d4662>] do_syscall_64+0x72/0x140
[<ffffffff8f8000aa>] entry_SYSCALL_64_after_hwframe+0x6e/0x76
==================================================================Put the reference count of cache_cred in cachefiles_daemon_unbind() to fix the problem. And also put cache_cred in cachefiles_add_cache() error branch to avoid memory leaks.
--- fs/cachefiles/cache.c | 2 ++ fs/cachefiles/daemon.c | 1 + 2 files changed, 3 insertions(+)
fs/cachefiles/cache.c +2 -0
@@ -168,6 +168,8 @@ error_unsupported:dput (root); error_open_root:cachefiles_end_secure (cache, saved_cred); +put_cred (cache->cache_cred); + cache->cache_cred =NULL ; error_getsec:fscache_relinquish_cache (cache_cookie); cache->cache =NULL ;
fs/cachefiles/daemon.c +1 -0
@@ -805,6 +805,7 @@ static void cachefiles_daemon_unbind(strcachefiles_put_directory (cache->graveyard);cachefiles_put_directory (cache->store);mntput (cache->mnt); +put_cred (cache->cache_cred);kfree (cache->rootdirname);kfree (cache->secctx);
Greg Kroah-Hartman
maintainerPATCH 198/334 ARM: ep93xx: Add terminator to gpiod_lookup_table
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Shubin <[email protected]>
commit fdf87a0dc26d0550c60edc911cda42f9afec3557 upstream.
Without the terminator, if a con_id is passed to gpio_find() that does not exist in the lookup table the function will not stop looping correctly, and eventually cause an oops.
--- arch/arm/mach-ep93xx/core.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-ep93xx/core.c +1 -0
@@ -339,6 +339,7 @@ static struct gpiod_lookup_table ep93xx_ GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), GPIO_LOOKUP_IDX("G", 0, NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), + { } }, };
Greg Kroah-Hartman
maintainerPATCH 199/334 dm-integrity, dm-verity: reduce stack usage for recheck
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 66ad2fbcdbeab0edfd40c5d94f32f053b98c2320 upstream.
The newly added integrity_recheck() function has another larger stack allocation, just like its caller integrity_metadata(). When it gets inlined, the combination of the two exceeds the warning limit for 32-bit architectures and possibly risks an overflow when this is called from a deep call chain through a file system:
drivers/md/dm-integrity.c:1767:13: error: stack frame size (1048) exceeds limit (1024) in 'integrity_metadata' [-Werror,-Wframe-larger-than]
1767 | static void integrity_metadata(struct work_struct *w)
Since the caller at this point is done using its checksum buffer, just reuse the same buffer in the new function to avoid the double allocation.
[Mikulas: add "noinline" to integrity_recheck and verity_recheck. These functions are only called on error, so they shouldn't bloat the stack frame or code size of the caller.]
--- drivers/md/dm-integrity.c | 10 ++++------ drivers/md/dm-verity-target.c | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-)
drivers/md/dm-integrity.c +4 -6
@@ -1691,14 +1691,13 @@ failed:get_random_bytes (result, ic->tag_size); } -static void integrity_recheck (struct dm_integrity_io *dio) +static noinline void integrity_recheck(struct dm_integrity_io *dio, char *checksum) {struct bio *bio =dm_bio_from_per_bio_data (dio,sizeof (struct dm_integrity_io ));struct dm_integrity_c *ic = dio->ic;struct bvec_iter iter;struct bio_vec bv;sector_t sector, logical_sector, area, offset; -char checksum_onstack[max_t (size_t,HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )];struct page *page;void *buffer;
@@ -1734,9 +1733,8 @@ static void integrity_recheck(struct dm_ goto free_ret; } -integrity_sector_checksum (ic, logical_sector, buffer, - checksum_onstack); - r =dm_integrity_rw_tag (ic, checksum_onstack, &dio->metadata_block, +integrity_sector_checksum (ic, logical_sector, buffer, checksum); + r =dm_integrity_rw_tag (ic, checksum, &dio->metadata_block, &dio->metadata_offset, ic->tag_size,TAG_CMP );if (r) {if (r >0 ) {
@@ -1851,7 +1849,7 @@ again: checksums_ptr - checksums, dio->op == REQ_OP_READ ? TAG_CMP : TAG_WRITE);if (unlikely (r)) {if (r >0 ) { -integrity_recheck (dio); +integrity_recheck (dio, checksums); goto skip_io; }if (likely (checksums != checksums_onstack))
drivers/md/dm-verity-target.c +2 -2
@@ -491,8 +491,8 @@ static int verity_recheck_copy(struct dmreturn 0 ; } -static int verity_recheck (struct dm_verity *v,struct dm_verity_io *io, -struct bvec_iter start,sector_t cur_block) +static noinline int verity_recheck(struct dm_verity *v, struct dm_verity_io *io, +struct bvec_iter start,sector_t cur_block) {struct page *page;void *buffer;
Greg Kroah-Hartman
maintainerPATCH 200/334 erofs: fix refcount on the metabuf used for inode lookup
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandeep Dhavale <[email protected]>
commit 56ee7db31187dc36d501622cb5f1415e88e01c2a upstream.
In erofs_find_target_block() when erofs_dirnamecmp() returns 0, we do not assign the target metabuf. This causes the caller erofs_namei()'s erofs_put_metabuf() at the end to be not effective leaving the refcount on the page.
As the page from metabuf (buf->page) is never put, such page cannot be migrated or reclaimed. Fix it now by putting the metabuf from previous loop and assigning the current metabuf to target before returning so caller erofs_namei() can do the final put as it was intended.
--- fs/erofs/namei.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
fs/erofs/namei.c +14 -14
@@ -130,24 +130,24 @@ static void *erofs_find_target_block(str/* string comparison without already matched prefix */ diff =erofs_dirnamecmp (name, &dname, &matched); -if (!diff) { - *_ndirents =0 ; - goto out; - }else if (diff >0 ) { - head = mid +1 ; - startprfx = matched; - -if (!IS_ERR (candidate)) -erofs_put_metabuf (target); - *target = buf; - candidate = de; - *_ndirents = ndirents; - }else { +if (diff <0 ) {erofs_put_metabuf (&buf); - back = mid -1 ; endprfx = matched; +continue ; + } + +if (!IS_ERR (candidate)) +erofs_put_metabuf (target); + *target = buf; +if (!diff) { + *_ndirents =0 ; +return de; } + head = mid +1 ; + startprfx = matched; + candidate = de; + *_ndirents = ndirents;continue ; } out:/* free if the candidate is valid */
Greg Kroah-Hartman
maintainerPATCH 201/334 Revert "usb: typec: tcpm: reset counter when enter into unattached state after try role"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Jirman <[email protected]>
commit 23b1d2d99b0f55326f05e7d757fa197c4a95dc5c upstream.
The reverted commit makes the state machine only ever go from SRC_ATTACH_WAIT to SNK_TRY in endless loop when toggling. After revert it goes to SRC_ATTACHED after initially trying SNK_TRY earlier, as it should for toggling to ever detect the power source mode and the port is again able to provide power to attached power sinks.
This reverts commit 2d6d80127006ae3da26b1f21a65eccf957f2d1e5.
--- drivers/usb/typec/tcpm/tcpm.c | 3 --- 1 file changed, 3 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +0 -3
@@ -3730,9 +3730,6 @@ static void tcpm_detach(struct tcpm_portif (tcpm_port_is_disconnected (port)) port->hard_reset_count =0 ; - port->try_src_count =0 ; - port->try_snk_count =0 ; -if (!port->attached)return ;
Greg Kroah-Hartman
maintainerPATCH 202/334 serial: stm32: do not always set SER_RS485_RX_DURING_TX if RS485 is enabled
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lino Sanfilippo <[email protected]>
commit f418ae73311deb901c0110b08d1bbafc20c1820e upstream.
Before commit 07c30ea5861f ("serial: Do not hold the port lock when setting rx-during-tx GPIO") the SER_RS485_RX_DURING_TX flag was only set if the rx-during-tx mode was not controlled by a GPIO. Now the flag is set unconditionally when RS485 is enabled. This results in an incorrect setting if the rx-during-tx GPIO is not asserted.
Fix this by setting the flag only if the rx-during-tx mode is not controlled by a GPIO and thus restore the correct behaviour.
--- drivers/tty/serial/stm32-usart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/stm32-usart.c +3 -1
@@ -251,7 +251,9 @@ static int stm32_usart_config_rs485(struwritel_relaxed (cr3, port->membase + ofs->cr3);writel_relaxed (cr1, port->membase + ofs->cr1); - rs485conf->flags |=SER_RS485_RX_DURING_TX ; +if (!port->rs485_rx_during_tx_gpio) + rs485conf->flags |=SER_RS485_RX_DURING_TX ; + }else {stm32_usart_clr_bits (port, ofs->cr3,USART_CR3_DEM |USART_CR3_DEP );
Greg Kroah-Hartman
maintainerPATCH 203/334 serial: amba-pl011: Fix DMA transmission in RS485 mode
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lino Sanfilippo <[email protected]>
commit 3b69e32e151bc4a4e3c785cbdb1f918d5ee337ed upstream.
When DMA is used in RS485 mode make sure that the UARTs tx section is enabled before the DMA buffers are queued for transmission.
--- drivers/tty/serial/amba-pl011.c | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/tty/serial/amba-pl011.c +30 -30
@@ -1345,11 +1345,41 @@ static void pl011_start_tx_pio(struct ua } } +static void pl011_rs485_tx_start (struct uart_amba_port *uap) +{ +struct uart_port *port = &uap->port; +u32 cr; + +/* Enable transmitter */ + cr =pl011_read (uap,REG_CR ); + cr |=UART011_CR_TXE ; + +/* Disable receiver if half-duplex */ +if (!(port->rs485.flags &SER_RS485_RX_DURING_TX )) + cr &= ~UART011_CR_RXE ; + +if (port->rs485.flags &SER_RS485_RTS_ON_SEND ) + cr &= ~UART011_CR_RTS ; +else + cr |=UART011_CR_RTS ; + +pl011_write (cr, uap,REG_CR ); + +if (port->rs485.delay_rts_before_send) +mdelay (port->rs485.delay_rts_before_send); + + uap->rs485_tx_started = true; +} +static void pl011_start_tx (struct uart_port *port) {struct uart_amba_port *uap = container_of(port, struct uart_amba_port, port); +if ((uap->port.rs485.flags &SER_RS485_ENABLED ) && + !uap->rs485_tx_started) +pl011_rs485_tx_start (uap); +if (!pl011_dma_tx_start (uap))pl011_start_tx_pio (uap); }
@@ -1431,42 +1461,12 @@ static bool pl011_tx_char(struct uart_amreturn true; } -static void pl011_rs485_tx_start (struct uart_amba_port *uap) -{ -struct uart_port *port = &uap->port; -u32 cr; - -/* Enable transmitter */ - cr =pl011_read (uap,REG_CR ); - cr |=UART011_CR_TXE ; - -/* Disable receiver if half-duplex */ -if (!(port->rs485.flags &SER_RS485_RX_DURING_TX )) - cr &= ~UART011_CR_RXE ; - -if (port->rs485.flags &SER_RS485_RTS_ON_SEND ) - cr &= ~UART011_CR_RTS ; -else - cr |=UART011_CR_RTS ; - -pl011_write (cr, uap,REG_CR ); - -if (port->rs485.delay_rts_before_send) -mdelay (port->rs485.delay_rts_before_send); - - uap->rs485_tx_started = true; -} -/* Returns true if tx interrupts have to be (kept) enabled */ static bool pl011_tx_chars (struct uart_amba_port *uap,bool from_irq) {struct circ_buf *xmit = &uap->port.state->xmit;int count = uap->fifosize >>1 ; -if ((uap->port.rs485.flags &SER_RS485_ENABLED ) && - !uap->rs485_tx_started) -pl011_rs485_tx_start (uap); -if (uap->port.x_char) {if (!pl011_tx_char (uap, uap->port.x_char, from_irq))return true;
Greg Kroah-Hartman
maintainerPATCH 204/334 usb: dwc3: gadget: Dont disconnect if not started
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thinh Nguyen <[email protected]>
commit b191a18cb5c47109ca696370a74a5062a70adfd0 upstream.
Don't go through soft-disconnection sequence if the controller hasn't started. Otherwise, there will be timeout and warning reports from the soft-disconnection flow.
--- drivers/usb/dwc3/gadget.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/dwc3/gadget.c +5 -0
@@ -2650,6 +2650,11 @@ static int dwc3_gadget_soft_disconnect(sint ret;spin_lock_irqsave (&dwc->lock, flags); +if (!dwc->pullups_connected) { +spin_unlock_irqrestore (&dwc->lock, flags); +return 0 ; + } + dwc->connected = false;/*
Greg Kroah-Hartman
maintainerPATCH 205/334 usb: cdnsp: blocked some cdns3 specific code
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawel Laszczak <[email protected]>
commit 18a6be674306c9acb05c08e5c3fd376ef50a917c upstream.
host.c file has some parts of code that were introduced for CDNS3 driver and should not be used with CDNSP driver.
This patch blocks using these parts of codes by CDNSP driver. These elements include:
- xhci_plat_cdns3_xhci object
- cdns3 specific XECP_PORT_CAP_REG register
- cdns3 specific XECP_AUX_CTRL_REG1 register
--- drivers/usb/cdns3/host.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/usb/cdns3/host.c +14 -2
@@ -18,6 +18,11 @@#include "../host/xhci.h" #include "../host/xhci-plat.h" +/* +* The XECP_PORT_CAP_REG and XECP_AUX_CTRL_REG1 exist only +* in Cadence USB3 dual-role controller, so it can't be used +* with Cadence CDNSP dual-role controller. +*/ #define XECP_PORT_CAP_REG 0x8000#define XECP_AUX_CTRL_REG1 0x8120
@@ -57,6 +62,8 @@ static const struct xhci_plat_priv xhci_ .resume_quirk = xhci_cdns3_resume_quirk, }; +static const struct xhci_plat_priv xhci_plat_cdnsp_xhci; +static int __cdns_host_init (struct cdns *cdns) {struct platform_device *xhci;
@@ -81,8 +88,13 @@ static int __cdns_host_init(struct cdns goto err1; } - cdns->xhci_plat_data =kmemdup (&xhci_plat_cdns3_xhci, -sizeof (struct xhci_plat_priv ),GFP_KERNEL ); +if (cdns->version <CDNSP_CONTROLLER_V2 ) + cdns->xhci_plat_data =kmemdup (&xhci_plat_cdns3_xhci, +sizeof (struct xhci_plat_priv ),GFP_KERNEL ); +else + cdns->xhci_plat_data =kmemdup (&xhci_plat_cdnsp_xhci, +sizeof (struct xhci_plat_priv ),GFP_KERNEL ); +if (!cdns->xhci_plat_data) { ret = -ENOMEM ; goto err1;
Greg Kroah-Hartman
maintainerPATCH 206/334 usb: cdnsp: fixed issue with incorrect detecting CDNSP family controllers
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawel Laszczak <[email protected]>
commit 47625b018c6bc788bc10dd654c82696eb0a5ef11 upstream.
Cadence have several controllers from 0x000403xx family but current driver suuport detecting only one with DID equal 0x0004034E. It causes that if someone uses different CDNSP controller then driver will use incorrect version and register space.
Patch fix this issue.
--- drivers/usb/cdns3/core.c | 1 - drivers/usb/cdns3/drd.c | 13 +++++++++---- drivers/usb/cdns3/drd.h | 6 +++++- 3 files changed, 14 insertions(+), 6 deletions(-)
drivers/usb/cdns3/core.c +0 -1
@@ -395,7 +395,6 @@ pm_put:return ret; } -/** * cdns_wakeup_irq - interrupt handler for wakeup events * @irq: irq number for cdns3/cdnsp core device
drivers/usb/cdns3/drd.c +9 -4
@@ -156,7 +156,8 @@ bool cdns_is_device(struct cdns *cdns)*/ static void cdns_otg_disable_irq (struct cdns *cdns) { -writel (0 , &cdns->otg_irq_regs->ien); +if (cdns->version) +writel (0 , &cdns->otg_irq_regs->ien); }/**
@@ -422,15 +423,20 @@ int cdns_drd_init(struct cdns *cdns) cdns->otg_regs = (void __iomem *)&cdns->otg_v1_regs->cmd; -if (readl (&cdns->otg_cdnsp_regs->did) ==OTG_CDNSP_DID ) { + state =readl (&cdns->otg_cdnsp_regs->did); + +if (OTG_CDNSP_CHECK_DID (state)) { cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *) &cdns->otg_cdnsp_regs->ien; cdns->version =CDNSP_CONTROLLER_V2 ; - }else { + }else if (OTG_CDNS3_CHECK_DID (state)) { cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *) &cdns->otg_v1_regs->ien;writel (1 , &cdns->otg_v1_regs->simulate); cdns->version =CDNS3_CONTROLLER_V1 ; + }else { +dev_err (cdns->dev,"not supporte DID=0x%08x\n" , state); +return -EINVAL ; } dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
@@ -483,7 +489,6 @@ int cdns_drd_exit(struct cdns *cdns)return 0 ; } -/* Indicate the cdns3 core was power lost before */ bool cdns_power_is_lost (struct cdns *cdns) {
drivers/usb/cdns3/drd.h +5 -1
@@ -79,7 +79,11 @@ struct cdnsp_otg_regs {__le32 susp_timing_ctrl; }; -#define OTG_CDNSP_DID 0x0004034E +/* CDNSP driver supports 0x000403xx Cadence USB controller family. */ +#define OTG_CDNSP_CHECK_DID (did) (((did) & GENMASK(31, 8)) == 0x00040300) + +/* CDNS3 driver supports 0x000402xx Cadence USB controller family. */ +#define OTG_CDNS3_CHECK_DID (did) (((did) & GENMASK(31, 8)) == 0x00040200)/* * Common registers interface for both CDNS3 and CDNSP version of DRD.
Greg Kroah-Hartman
maintainerPATCH 207/334 usb: cdns3: fixed memory use after free at cdns3_gadget_ep_disable()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit cd45f99034b0c8c9cb346dd0d6407a95ca3d36f6 upstream.
... cdns3_gadget_ep_free_request(&priv_ep->endpoint, &priv_req->request); list_del_init(&priv_req->list); ...
'priv_req' actually free at cdns3_gadget_ep_free_request(). But list_del_init() use priv_req->list after it.
[ 1542.642868][ T534] BUG: KFENCE: use-after-free read in __list_del_entry_valid+0x10/0xd4 [ 1542.642868][ T534] [ 1542.653162][ T534] Use-after-free read at 0x000000009ed0ba99 (in kfence-#3): [ 1542.660311][ T534] __list_del_entry_valid+0x10/0xd4 [ 1542.665375][ T534] cdns3_gadget_ep_disable+0x1f8/0x388 [cdns3] [ 1542.671571][ T534] usb_ep_disable+0x44/0xe4 [ 1542.675948][ T534] ffs_func_eps_disable+0x64/0xc8 [ 1542.680839][ T534] ffs_func_set_alt+0x74/0x368 [ 1542.685478][ T534] ffs_func_disable+0x18/0x28
Move list_del_init() before cdns3_gadget_ep_free_request() to resolve this problem.
--- drivers/usb/cdns3/cdns3-gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/cdns3/cdns3-gadget.c +1 -1
@@ -2539,11 +2539,11 @@ static int cdns3_gadget_ep_disable(strucwhile (!list_empty (&priv_ep->wa2_descmiss_req_list)) { priv_req =cdns3_next_priv_request (&priv_ep->wa2_descmiss_req_list); +list_del_init (&priv_req->list);kfree (priv_req->request.buf);cdns3_gadget_ep_free_request (&priv_ep->endpoint, &priv_req->request); -list_del_init (&priv_req->list); --priv_ep->wa2_counter; }
Greg Kroah-Hartman
maintainerPATCH 181/334 sparc: Fix undefined reference to fb_is_primary_device
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Martinez Canillas <[email protected]>
commit ed683b9bb91fc274383e222ba5873a9ee9033462 upstream.
Commit 55bffc8170bb ("fbdev: Split frame buffer support in FB and FB_CORE symbols") added a new FB_CORE Kconfig symbol, that can be enabled to only have fbcon/VT and DRM fbdev emulation, but without support for any legacy fbdev driver.
Unfortunately, it missed to change the CONFIG_FB in arch/sparc makefiles, which leads to the following linking error in some sparc64 configurations:
sparc64-linux-ld: drivers/video/fbdev/core/fbcon.o: in function `fbcon_fb_registered':
Quoted 1 line
Quoted 1 line
fbcon.c:(.text+0x4f60): undefined reference to `fb_is_primary_device'
--- arch/sparc/Makefile | 2 +- arch/sparc/video/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/sparc/Makefile +1 -1
@@ -60,7 +60,7 @@ libs-y += arch/sparc/pro libs-y += arch/sparc/lib/ drivers-$(CONFIG_PM) += arch/sparc/power/ -drivers-$(CONFIG_FB) += arch/sparc/video/ +drivers-$(CONFIG_FB_CORE) += arch/sparc/video/ boot := arch/sparc/boot
arch/sparc/video/Makefile +1 -1
@@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_FB) += fbdev.o +obj-$(CONFIG_FB_CORE) += fbdev.o
Greg Kroah-Hartman
maintainerPATCH 208/334 usb: cdns3: fix memory double free when handle zero packet
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 5fd9e45f1ebcd57181358af28506e8a661a260b3 upstream.
829 if (request->complete) {
830 spin_unlock(&priv_dev->lock);
831 usb_gadget_giveback_request(&priv_ep->endpoint,
832 request);
833 spin_lock(&priv_dev->lock);
834 }
835
836 if (request->buf == priv_dev->zlp_buf)
837 cdns3_gadget_ep_free_request(&priv_ep->endpoint, request);
Driver append an additional zero packet request when queue a packet, which length mod max packet size is 0. When transfer complete, run to line 831, usb_gadget_giveback_request() will free this requestion. 836 condition is true, so cdns3_gadget_ep_free_request() free this request again.
Log:
[ 1920.140696][ T150] BUG: KFENCE: use-after-free read in cdns3_gadget_giveback+0x134/0x2c0 [cdns3] [ 1920.140696][ T150] [ 1920.151837][ T150] Use-after-free read at 0x000000003d1cd10b (in kfence-#36): [ 1920.159082][ T150] cdns3_gadget_giveback+0x134/0x2c0 [cdns3] [ 1920.164988][ T150] cdns3_transfer_completed+0x438/0x5f8 [cdns3]
Add check at line 829, skip call usb_gadget_giveback_request() if it is additional zero length packet request. Needn't call usb_gadget_giveback_request() because it is allocated in this driver.
--- drivers/usb/cdns3/cdns3-gadget.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/cdns3/cdns3-gadget.c +5 -1
@@ -828,7 +828,11 @@ void cdns3_gadget_giveback(struct cdns3_return ; } -if (request->complete) { +/* +* zlp request is appended by driver, needn't call usb_gadget_giveback_request() to notify +* gadget composite driver. +*/ +if (request->complete && request->buf != priv_dev->zlp_buf) {spin_unlock (&priv_dev->lock);usb_gadget_giveback_request (&priv_ep->endpoint, request);
Greg Kroah-Hartman
maintainerPATCH 209/334 usb: gadget: ncm: Avoid dropping datagrams of properly parsed NTBs
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Kurapati <[email protected]>
commit 76c51146820c5dac629f21deafab0a7039bc3ccd upstream.
It is observed sometimes when tethering is used over NCM with Windows 11 as host, at some instances, the gadget_giveback has one byte appended at the end of a proper NTB. When the NTB is parsed, unwrap call looks for any leftover bytes in SKB provided by u_ether and if there are any pending bytes, it treats them as a separate NTB and parses it. But in case the second NTB (as per unwrap call) is faulty/corrupt, all the datagrams that were parsed properly in the first NTB and saved in rx_list are dropped.
Adding a few custom traces showed the following:
[002] d..1 7828.532866: dwc3_gadget_giveback: ep1out:
req 000000003868811a length 1025/16384 zsI ==> 0
[002] d..1 7828.532867: ncm_unwrap_ntb: K: ncm_unwrap_ntb toprocess: 1025 [002] d..1 7828.532867: ncm_unwrap_ntb: K: ncm_unwrap_ntb nth: 1751999342 [002] d..1 7828.532868: ncm_unwrap_ntb: K: ncm_unwrap_ntb seq: 0xce67 [002] d..1 7828.532868: ncm_unwrap_ntb: K: ncm_unwrap_ntb blk_len: 0x400 [002] d..1 7828.532868: ncm_unwrap_ntb: K: ncm_unwrap_ntb ndp_len: 0x10 [002] d..1 7828.532869: ncm_unwrap_ntb: K: Parsed NTB with 1 frames
In this case, the giveback is of 1025 bytes and block length is 1024. The rest 1 byte (which is 0x00) won't be parsed resulting in drop of all datagrams in rx_list.
Same is case with packets of size 2048:
[002] d..1 7828.557948: dwc3_gadget_giveback: ep1out:
req 0000000011dfd96e length 2049/16384 zsI ==> 0
[002] d..1 7828.557949: ncm_unwrap_ntb: K: ncm_unwrap_ntb nth: 1751999342
[002] d..1 7828.557950: ncm_unwrap_ntb: K: ncm_unwrap_ntb blk_len: 0x800
Lecroy shows one byte coming in extra confirming that the byte is coming in from PC:
Transfer 2959 - Bytes Transferred(1025) Timestamp((18.524 843 590)
- Transaction 8391 - Data(1025 bytes) Timestamp(18.524 843 590) --- Packet 4063861
Data(1024 bytes)
Duration(2.117us) Idle(14.700ns) Timestamp(18.524 843 590)
--- Packet 4063863
Data(1 byte)
Duration(66.160ns) Time(282.000ns) Timestamp(18.524 845 722)According to Windows driver, no ZLP is needed if wBlockLength is non-zero, because the non-zero wBlockLength has already told the function side the size of transfer to be expected. However, there are in-market NCM devices that rely on ZLP as long as the wBlockLength is multiple of wMaxPacketSize. To deal with such devices, it pads an extra 0 at end so the transfer is no longer multiple of wMaxPacketSize.
--- drivers/usb/gadget/function/f_ncm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_ncm.c +9 -1
@@ -1325,7 +1325,15 @@ parse_ntb: "Parsed NTB with %d frames\n", dgram_counter); to_process -= block_len; -if (to_process !=0 ) { + +/* +* Windows NCM driver avoids USB ZLPs by adding a 1-byte +* zero pad as needed. +*/ +if (to_process ==1 && + (*(unsigned char *)(ntb_ptr + block_len) ==0x00 )) { + to_process--; + }else if (to_process >0 ) { ntb_ptr = (unsigned char *)(ntb_ptr + block_len); goto parse_ntb; }
Greg Kroah-Hartman
maintainerPATCH 182/334 md: Dont ignore suspended array in md_check_recovery()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit 1baae052cccd08daf9a9d64c3f959d8cdb689757 upstream.
mddev_suspend() never stop sync_thread, hence it doesn't make sense to ignore suspended array in md_check_recovery(), which might cause sync_thread can't be unregistered.
After commit f52f5c71f3d4 ("md: fix stopping sync thread"), following hang can be triggered by test shell/integrity-caching.sh:
1) suspend the array:raid_postsuspend
mddev_suspend
2) stop the array:raid_dtr
md_stop
__md_stop_writes
stop_sync_thread
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
md_wakeup_thread_directly(mddev->sync_thread);
wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))3) sync thread done:md_do_sync
set_bit(MD_RECOVERY_DONE, &mddev->recovery);
md_wakeup_thread(mddev->thread);
4) daemon thread can't unregister sync thread:md_check_recovery
if (mddev->suspended)
return; -> return directly
md_read_sync_thread clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); -> MD_RECOVERY_RUNNING can't be cleared, hence step 2 hang;
This problem is not just related to dm-raid, fix it by ignoring suspended array in md_check_recovery(). And follow up patches will improve dm-raid better to frozen sync thread during suspend.
--- drivers/md/md.c | 3 --- 1 file changed, 3 deletions(-)
drivers/md/md.c +0 -3
@@ -9519,9 +9519,6 @@ not_running:*/ void md_check_recovery (struct mddev *mddev) { -if (READ_ONCE (mddev->suspended)) -return ; -if (mddev->bitmap)md_bitmap_daemon_work (mddev);
Greg Kroah-Hartman
maintainerPATCH 183/334 md: Dont ignore read-only array in md_check_recovery()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit 55a48ad2db64737f7ffc0407634218cc6e4c513b upstream.
Usually if the array is not read-write, md_check_recovery() won't register new sync_thread in the first place. And if the array is read-write and sync_thread is registered, md_set_readonly() will unregister sync_thread before setting the array read-only. md/raid follow this behavior hence there is no problem.
After commit f52f5c71f3d4 ("md: fix stopping sync thread"), following hang can be triggered by test shell/integrity-caching.sh:
1) array is read-only. dm-raid update super block:rs_update_sbs
ro = mddev->ro
mddev->ro = 0
-> set array read-write
md_update_sb
2) register new sync thread concurrently.
3) dm-raid set array back to read-only:rs_update_sbs
mddev->ro = ro
4) stop the array:raid_dtr
md_stop
stop_sync_thread
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
md_wakeup_thread_directly(mddev->sync_thread);
wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))5) sync thread done:
md_do_sync
set_bit(MD_RECOVERY_DONE, &mddev->recovery);
md_wakeup_thread(mddev->thread);
6) daemon thread can't unregister sync thread:
md_check_recovery
if (!md_is_rdwr(mddev) &&
!test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
return;
-> -> MD_RECOVERY_RUNNING can't be cleared, hence step 4 hang;
The root cause is that dm-raid manipulate 'mddev->ro' by itself, however, dm-raid really should stop sync thread before setting the array read-only. Unfortunately, I need to read more code before I can refacter the handler of 'mddev->ro' in dm-raid, hence let's fix the problem the easy way for now to prevent dm-raid regression.
--- drivers/md/md.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/md/md.c +18 -13
@@ -9495,6 +9495,20 @@ not_running:sysfs_notify_dirent_safe (mddev->sysfs_action); } +static void unregister_sync_thread (struct mddev *mddev) +{ +if (!test_bit (MD_RECOVERY_DONE , &mddev->recovery)) { +/* resync/recovery still happening */ +clear_bit (MD_RECOVERY_NEEDED , &mddev->recovery); +return ; + } + +if (WARN_ON_ONCE (!mddev->sync_thread)) +return ; + +md_reap_sync_thread (mddev); +} +/* * This routine is regularly called by all per-raid-array threads to * deal with generic issues like resync and super-block update.
@@ -9532,7 +9546,8 @@ void md_check_recovery(struct mddev *mdd }if (!md_is_rdwr (mddev) && - !test_bit (MD_RECOVERY_NEEDED , &mddev->recovery)) + !test_bit (MD_RECOVERY_NEEDED , &mddev->recovery) && + !test_bit (MD_RECOVERY_DONE , &mddev->recovery))return ; if ( ! ( (mddev->sb_flags & ~ (1<<MD_SB_CHANGE_PENDING)) ||
@@ -9554,8 +9569,7 @@ void md_check_recovery(struct mddev *mddstruct md_rdev *rdev;if (test_bit (MD_RECOVERY_RUNNING , &mddev->recovery)) { -/* sync_work already queued. */ -clear_bit (MD_RECOVERY_NEEDED , &mddev->recovery); +unregister_sync_thread (mddev); goto unlock; }
@@ -9618,16 +9632,7 @@ void md_check_recovery(struct mddev *mdd* still set. */ if (test_bit (MD_RECOVERY_RUNNING , &mddev->recovery)) { -if (!test_bit (MD_RECOVERY_DONE , &mddev->recovery)) { -/* resync/recovery still happening */ -clear_bit (MD_RECOVERY_NEEDED , &mddev->recovery); - goto unlock; - } - -if (WARN_ON_ONCE (!mddev->sync_thread)) - goto unlock; - -md_reap_sync_thread (mddev); +unregister_sync_thread (mddev); goto unlock; }
Greg Kroah-Hartman
maintainerPATCH 184/334 md: Make sure md_do_sync() will set MD_RECOVERY_DONE
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit 82ec0ae59d02e89164b24c0cc8e4e50de78b5fd6 upstream.
stop_sync_thread() will interrupt md_do_sync(), and md_do_sync() must set MD_RECOVERY_DONE, so that follow up md_check_recovery() will unregister sync_thread, clear MD_RECOVERY_RUNNING and wake up stop_sync_thread().
If MD_RECOVERY_WAIT is set or the array is read-only, md_do_sync() will return without setting MD_RECOVERY_DONE, and after commit f52f5c71f3d4 ("md: fix stopping sync thread"), dm-raid switch from md_reap_sync_thread() to stop_sync_thread() to unregister sync_thread from md_stop() and md_stop_writes(), causing the test shell/lvconvert-raid-reshape.sh hang.
We shouldn't switch back to md_reap_sync_thread() because it's problematic in the first place. Fix the problem by making sure md_do_sync() will set MD_RECOVERY_DONE.
--- drivers/md/md.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/md/md.c +8 -4
@@ -8813,12 +8813,16 @@ void md_do_sync(struct md_thread *threadint ret;/* just incase thread restarts... */ -if (test_bit (MD_RECOVERY_DONE , &mddev->recovery) || -test_bit (MD_RECOVERY_WAIT , &mddev->recovery)) +if (test_bit (MD_RECOVERY_DONE , &mddev->recovery))return ; -if (!md_is_rdwr (mddev)) {/* never try to sync a read-only array */ + +if (test_bit (MD_RECOVERY_INTR , &mddev->recovery)) + goto skip; + +if (test_bit (MD_RECOVERY_WAIT , &mddev->recovery) || + !md_is_rdwr (mddev)) {/* never try to sync a read-only array */ set_bit (MD_RECOVERY_INTR , &mddev->recovery); -return ; + goto skip; }if (mddev_is_clustered (mddev)) {
Greg Kroah-Hartman
maintainerPATCH 185/334 md: Dont register sync_thread for reshape directly
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit ad39c08186f8a0f221337985036ba86731d6aafe upstream.
Currently, if reshape is interrupted, then reassemble the array will register sync_thread directly from pers->run(), in this case 'MD_RECOVERY_RUNNING' is set directly, however, there is no guarantee that md_do_sync() will be executed, hence stop_sync_thread() will hang because 'MD_RECOVERY_RUNNING' can't be cleared.
Last patch make sure that md_do_sync() will set MD_RECOVERY_DONE, however, following hang can still be triggered by dm-raid test shell/lvconvert-raid-reshape.sh occasionally:
[root@fedora ~]# cat /proc/1982/stack
[<0>] stop_sync_thread+0x1ab/0x270 [md_mod] [<0>] md_frozen_sync_thread+0x5c/0xa0 [md_mod] [<0>] raid_presuspend+0x1e/0x70 [dm_raid] [<0>] dm_table_presuspend_targets+0x40/0xb0 [dm_mod] [<0>] __dm_destroy+0x2a5/0x310 [dm_mod] [<0>] dm_destroy+0x16/0x30 [dm_mod] [<0>] dev_remove+0x165/0x290 [dm_mod] [<0>] ctl_ioctl+0x4bb/0x7b0 [dm_mod] [<0>] dm_ctl_ioctl+0x11/0x20 [dm_mod] [<0>] vfs_ioctl+0x21/0x60 [<0>] __x64_sys_ioctl+0xb9/0xe0 [<0>] do_syscall_64+0xc6/0x230 [<0>] entry_SYSCALL_64_after_hwframe+0x6c/0x74
Meanwhile mddev->recovery is:MD_RECOVERY_RUNNING |MD_RECOVERY_INTR |MD_RECOVERY_RESHAPE |MD_RECOVERY_FROZEN
Fix this problem by remove the code to register sync_thread directly from raid10 and raid5. And let md_check_recovery() to register sync_thread.
--- drivers/md/md.c | 5 ++++- drivers/md/raid10.c | 16 ++-------------- drivers/md/raid5.c | 29 ++--------------------------- 3 files changed, 8 insertions(+), 42 deletions(-)
drivers/md/md.c +4 -1
@@ -9422,6 +9422,7 @@ static void md_start_sync(struct work_st struct mddev *mddev = container_of(ws, struct mddev, sync_work);int spares =0 ;bool suspend = false; +char *name;if (md_spares_need_change (mddev)) suspend = true;
@@ -9454,8 +9455,10 @@ static void md_start_sync(struct work_stif (spares)md_bitmap_write_all (mddev->bitmap); + name =test_bit (MD_RECOVERY_RESHAPE , &mddev->recovery) ? +"reshape" :"resync" ;rcu_assign_pointer (mddev->sync_thread, -md_register_thread (md_do_sync, mddev,"resync" )); +md_register_thread (md_do_sync, mddev, name));if (!mddev->sync_thread) {pr_warn ("%s: could not start resync thread...\n" ,mdname (mddev));
drivers/md/raid10.c +2 -14
@@ -4307,11 +4307,7 @@ static int raid10_run(struct mddev *mddeclear_bit (MD_RECOVERY_SYNC , &mddev->recovery);clear_bit (MD_RECOVERY_CHECK , &mddev->recovery);set_bit (MD_RECOVERY_RESHAPE , &mddev->recovery); -set_bit (MD_RECOVERY_RUNNING , &mddev->recovery); -rcu_assign_pointer (mddev->sync_thread, -md_register_thread (md_do_sync, mddev,"reshape" )); -if (!mddev->sync_thread) - goto out_free_conf; +set_bit (MD_RECOVERY_NEEDED , &mddev->recovery); }return 0 ;
@@ -4707,16 +4703,8 @@ out:clear_bit (MD_RECOVERY_CHECK , &mddev->recovery);clear_bit (MD_RECOVERY_DONE , &mddev->recovery);set_bit (MD_RECOVERY_RESHAPE , &mddev->recovery); -set_bit (MD_RECOVERY_RUNNING , &mddev->recovery); - -rcu_assign_pointer (mddev->sync_thread, -md_register_thread (md_do_sync, mddev,"reshape" )); -if (!mddev->sync_thread) { - ret = -EAGAIN ; - goto abort; - } +set_bit (MD_RECOVERY_NEEDED , &mddev->recovery); conf->reshape_checkpoint = jiffies; -md_wakeup_thread (mddev->sync_thread);md_new_event ();return 0 ;
drivers/md/raid5.c +2 -27
@@ -8002,11 +8002,7 @@ static int raid5_run(struct mddev *mddevclear_bit (MD_RECOVERY_SYNC , &mddev->recovery);clear_bit (MD_RECOVERY_CHECK , &mddev->recovery);set_bit (MD_RECOVERY_RESHAPE , &mddev->recovery); -set_bit (MD_RECOVERY_RUNNING , &mddev->recovery); -rcu_assign_pointer (mddev->sync_thread, -md_register_thread (md_do_sync, mddev,"reshape" )); -if (!mddev->sync_thread) - goto abort; +set_bit (MD_RECOVERY_NEEDED , &mddev->recovery); }/* Ok, everything is just fine now */
@@ -8585,29 +8581,8 @@ static int raid5_start_reshape(struct mdclear_bit (MD_RECOVERY_CHECK , &mddev->recovery);clear_bit (MD_RECOVERY_DONE , &mddev->recovery);set_bit (MD_RECOVERY_RESHAPE , &mddev->recovery); -set_bit (MD_RECOVERY_RUNNING , &mddev->recovery); -rcu_assign_pointer (mddev->sync_thread, -md_register_thread (md_do_sync, mddev,"reshape" )); -if (!mddev->sync_thread) { - mddev->recovery =0 ; -spin_lock_irq (&conf->device_lock); -write_seqcount_begin (&conf->gen_lock); - mddev->raid_disks = conf->raid_disks = conf->previous_raid_disks; - mddev->new_chunk_sectors = - conf->chunk_sectors = conf->prev_chunk_sectors; - mddev->new_layout = conf->algorithm = conf->prev_algo; -rdev_for_each (rdev, mddev) - rdev->new_data_offset = rdev->data_offset; -smp_wmb (); - conf->generation --; - conf->reshape_progress = MaxSector; - mddev->reshape_position = MaxSector; -write_seqcount_end (&conf->gen_lock); -spin_unlock_irq (&conf->device_lock); -return -EAGAIN ; - } +set_bit (MD_RECOVERY_NEEDED , &mddev->recovery); conf->reshape_checkpoint = jiffies; -md_wakeup_thread (mddev->sync_thread);md_new_event ();return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 186/334 md: Dont suspend the array for interrupted reshape
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit 9e46c70e829bddc24e04f963471e9983a11598b7 upstream.
md_start_sync() will suspend the array if there are spares that can be added or removed from conf, however, if reshape is still in progress, this won't happen at all or data will be corrupted(remove_and_add_spares won't be called from md_choose_sync_action for reshape), hence there is no need to suspend the array if reshape is not done yet.
Meanwhile, there is a potential deadlock for raid456:
1) reshape is interrupted;
2) set one of the disk WantReplacement, and add a new disk to the array, however, recovery won't start until the reshape is finished;
3) then issue an IO across reshpae position, this IO will wait for reshape to make progress;
4) continue to reshape, then md_start_sync() found there is a spare disk that can be added to conf, mddev_suspend() is called;
Step 4 and step 3 is waiting for each other, deadlock triggered. Noted this problem is found by code review, and it's not reporduced yet.
Fix this porblem by don't suspend the array for interrupted reshape, this is safe because conf won't be changed until reshape is done.
--- drivers/md/md.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/md/md.c +9 -4
@@ -9424,12 +9424,17 @@ static void md_start_sync(struct work_stbool suspend = false;char *name; -if (md_spares_need_change (mddev)) +/* +* If reshape is still in progress, spares won't be added or removed +* from conf until reshape is done. +*/ +if (mddev->reshape_position == MaxSector && +md_spares_need_change (mddev)) { suspend = true; +mddev_suspend (mddev, false); + } - suspend ?mddev_suspend_and_lock_nointr (mddev) : -mddev_lock_nointr (mddev); - +mddev_lock_nointr (mddev);if (!md_is_rdwr (mddev)) {/* * On a read-only array we can:
Greg Kroah-Hartman
maintainerPATCH 187/334 md: Fix missing release of active_io for flush
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit 855678ed8534518e2b428bcbcec695de9ba248e8 upstream.
submit_flushes
atomic_set(&mddev->flush_pending, 1);
rdev_for_each_rcu(rdev, mddev)
atomic_inc(&mddev->flush_pending);
bi->bi_end_io = md_end_flush
submit_bio(bi);
/* flush io is done first */
md_end_flush
if (atomic_dec_and_test(&mddev->flush_pending))
percpu_ref_put(&mddev->active_io)
-> active_io is not released if (atomic_dec_and_test(&mddev->flush_pending))
-> missing release of active_io
For consequence, mddev_suspend() will wait for 'active_io' to be zero forever.
Fix this problem by releasing 'active_io' in submit_flushes() if 'flush_pending' is decreased to zero.
--- drivers/md/md.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/md/md.c +5 -1
@@ -579,8 +579,12 @@ static void submit_flushes(struct work_srcu_read_lock (); }rcu_read_unlock (); -if (atomic_dec_and_test (&mddev->flush_pending)) +if (atomic_dec_and_test (&mddev->flush_pending)) { +/* The pair is percpu_ref_get() from md_flush_request() */ +percpu_ref_put (&mddev->active_io); +queue_work (md_wq, &mddev->flush_work); + } }static void md_submit_flush_data (struct work_struct *ws)
Greg Kroah-Hartman
maintainerPATCH 178/334 platform/x86: intel-vbtn: Stop calling "VBDL" from notify_handler
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 84c16d01ff219bc0a5dca5219db6b8b86a6854fb upstream.
Commit 14c200b7ca46 ("platform/x86: intel-vbtn: Fix missing tablet-mode-switch events") causes 2 issues on the ThinkPad X1 Tablet Gen2:
1. The ThinkPad will wake up immediately from suspend
2. When put in tablet mode SW_TABLET_MODE reverts to 0 after about 1 second
Both these issues are caused by the "VBDL" ACPI method call added at the end of the notify_handler.
And it never became entirely clear if this call is even necessary to fix the issue of missing tablet-mode-switch events on the Dell Inspiron 7352.
Drop the "VBDL" ACPI method call again to fix the 2 issues this is causing on the ThinkPad X1 Tablet Gen2.
--- drivers/platform/x86/intel/vbtn.c | 3 --- 1 file changed, 3 deletions(-)
drivers/platform/x86/intel/vbtn.c +0 -3
@@ -200,9 +200,6 @@ static void notify_handler(acpi_handle h autorelease = val && (!ke_rel || ke_rel->type ==KE_IGNORE );sparse_keymap_report_event (input_dev, event, val, autorelease); - -/* Some devices need this to report further events */ -acpi_evaluate_object (handle,"VBDL" ,NULL ,NULL ); }/*
Greg Kroah-Hartman
maintainerPATCH 211/334 usb: roles: fix NULL pointer issue when put modules reference
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
commit 1c9be13846c0b2abc2480602f8ef421360e1ad9e upstream.
In current design, usb role class driver will get usb_role_switch parent's module reference after the user get usb_role_switch device and put the reference after the user put the usb_role_switch device. However, the parent device of usb_role_switch may be removed before the user put the usb_role_switch. If so, then, NULL pointer issue will be met when the user put the parent module's reference.
This will save the module pointer in structure of usb_role_switch. Then, we don't need to find module by iterating long relations.
--- drivers/usb/roles/class.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/usb/roles/class.c +11 -6
@@ -21,6 +21,7 @@ static const struct class role_class = {struct usb_role_switch {struct device dev;struct mutex lock;/* device lock*/ +struct module *module;/* the module this device depends on */ enum usb_role role;/* From descriptor */
@@ -135,7 +136,7 @@ struct usb_role_switch *usb_role_switch_ usb_role_switch_match);if (!IS_ERR_OR_NULL (sw)) -WARN_ON (!try_module_get (sw->dev.parent->driver->owner)); +WARN_ON (!try_module_get (sw->module));return sw; }
@@ -157,7 +158,7 @@ struct usb_role_switch *fwnode_usb_role_ sw =fwnode_connection_find_match (fwnode,"usb-role-switch" ,NULL , usb_role_switch_match);if (!IS_ERR_OR_NULL (sw)) -WARN_ON (!try_module_get (sw->dev.parent->driver->owner)); +WARN_ON (!try_module_get (sw->module));return sw; }
@@ -172,7 +173,7 @@ EXPORT_SYMBOL_GPL(fwnode_usb_role_switchvoid usb_role_switch_put (struct usb_role_switch *sw) {if (!IS_ERR_OR_NULL (sw)) { -module_put (sw->dev.parent->driver->owner); +module_put (sw->module);put_device (&sw->dev); } }
@@ -189,15 +190,18 @@ struct usb_role_switch * usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode) {struct device *dev; +struct usb_role_switch *sw =NULL ;if (!fwnode)return NULL ; dev =class_find_device_by_fwnode (&role_class, fwnode); -if (dev) -WARN_ON (!try_module_get (dev->parent->driver->owner)); +if (dev) { + sw =to_role_switch (dev); +WARN_ON (!try_module_get (sw->module)); + } -return dev ?to_role_switch (dev) :NULL ; +return sw; }EXPORT_SYMBOL_GPL (usb_role_switch_find_by_fwnode);
@@ -338,6 +342,7 @@ usb_role_switch_register(struct device * sw->set = desc->set; sw->get = desc->get; + sw->module = parent->driver->owner; sw->dev.parent = parent; sw->dev.fwnode = desc->fwnode; sw->dev.class = &role_class;
Greg Kroah-Hartman
maintainerPATCH 220/334 selftests: mptcp: simult flows: fix some subtest names
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 4d8e0dde0403b5a86aa83e243f020711a9c3e31f upstream.
The selftest was correctly recording all the results, but the 'reverse direction' part was missing in the name when needed.
It is important to have a unique (sub)test name in TAP, because some CI environments drop tests with duplicated name.
--- tools/testing/selftests/net/mptcp/simult_flows.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/simult_flows.sh +2 -1
@@ -267,7 +267,8 @@ run_test() [ $bail -eq 0 ] || exit $ret fi - printf "%-60s" "$msg - reverse direction" + msg+=" - reverse direction" + printf "%-60s" "${msg}" do_transfer $large $small $time lret=$? mptcp_lib_result_code "${lret}" "${msg}"
Greg Kroah-Hartman
maintainerPATCH 221/334 selftests: mptcp: pm nl: also list skipped tests
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit d2a2547565a9f1ad7989f7e21f97cbf065a9390d upstream.
If the feature is not supported by older kernels, and instead of just ignoring some tests, we should mark them as skipped, so we can still track them.
--- tools/testing/selftests/net/mptcp/pm_netlink.sh | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/net/mptcp/pm_netlink.sh +6 -0
@@ -194,6 +194,12 @@ subflow 10.0.1.1" " (nofullmesh ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ subflow,backup,fullmesh 10.0.1.1" " (backup,fullmesh)" +else + for st in fullmesh nofullmesh backup,fullmesh; do + st=" (${st})" + printf "%-50s%s\n" "${st}" "[SKIP]" + mptcp_lib_result_skip "${st}" + done fi mptcp_lib_result_print_all_tap
Greg Kroah-Hartman
maintainerPATCH 222/334 selftests: mptcp: pm nl: avoid error msg on older kernels
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 662f084f3396d8a804d56cb53ac05c9e39902a7b upstream.
Since the 'Fixes' commit mentioned below, and if the kernel being tested doesn't support the 'fullmesh' flag, this error will be printed:
netlink error -22 (Invalid argument) ./pm_nl_ctl: bailing out due to netlink error[s]
But that can be normal if the kernel doesn't support the feature, no need to print this worrying error message while everything else looks OK. So we can mute stderr. Failures will still be detected if any.
--- tools/testing/selftests/net/mptcp/pm_netlink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/pm_netlink.sh +1 -1
@@ -183,7 +183,7 @@ check "ip netns exec $ns1 ./pm_nl_ctl du subflow 10.0.1.1" " (nobackup)" # fullmesh support has been added later -ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh +ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh 2>/dev/null if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" || mptcp_lib_expect_all_features; then check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
Greg Kroah-Hartman
maintainerPATCH 223/334 selftests: mptcp: diag: check CURRESTAB counters
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
commit 81ab772819da408977ac79c0a17d8be57283379f upstream.
This patch adds a new helper chk_msk_cestab() to check the current established connections counter MIB_CURRESTAB in diag.sh. Invoke it to check the counter during the connection after every chk_msk_inuse().
--- tools/testing/selftests/net/mptcp/diag.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/diag.sh +16 -1
@@ -56,7 +56,7 @@ __chk_nr() local command="$1" local expected=$2 local msg="$3" - local skip="${4:-SKIP}" + local skip="${4-SKIP}" local nr nr=$(eval $command)
@@ -199,6 +199,15 @@ wait_local_port_listen() done } +# $1: cestab nr +chk_msk_cestab() +{ + local cestab=$1 + + __chk_nr "mptcp_lib_get_counter ${ns} MPTcpExtMPCurrEstab" \ + "${cestab}" "....chk ${cestab} cestab" "" +} + wait_connected() { local listener_ns="${1}"
@@ -236,9 +245,11 @@ chk_msk_nr 2 "after MPC handshake " chk_msk_remote_key_nr 2 "....chk remote_key" chk_msk_fallback_nr 0 "....chk no fallback" chk_msk_inuse 2 "....chk 2 msk in use" +chk_msk_cestab 2 flush_pids chk_msk_inuse 0 "....chk 0 msk in use after flush" +chk_msk_cestab 0 echo "a" | \ timeout ${timeout_test} \
@@ -254,9 +265,11 @@ echo "b" | \ wait_connected $ns 10001 chk_msk_fallback_nr 1 "check fallback" chk_msk_inuse 1 "....chk 1 msk in use" +chk_msk_cestab 1 flush_pids chk_msk_inuse 0 "....chk 0 msk in use after flush" +chk_msk_cestab 0 NR_CLIENTS=100 for I in `seq 1 $NR_CLIENTS`; do
@@ -278,9 +291,11 @@ done wait_msk_nr $((NR_CLIENTS*2)) "many msk socket present" chk_msk_inuse $((NR_CLIENTS*2)) "....chk many msk in use" +chk_msk_cestab $((NR_CLIENTS*2)) flush_pids chk_msk_inuse 0 "....chk 0 msk in use after flush" +chk_msk_cestab 0 mptcp_lib_result_print_all_tap exit $ret
Greg Kroah-Hartman
maintainerPATCH 224/334 selftests: mptcp: diag: fix bash warnings on older kernels
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 694bd45980a61045eb5ec07799e3b94c76db830e upstream.
Since the 'Fixes' commit mentioned below, the command that is executed in __chk_nr() helper can return nothing if the feature is not supported. This is the case when the MPTCP CURRESTAB counter is not supported.
To avoid this warning ...
./diag.sh: line 65: [: !=: unary operator expected
... we just need to surround '$nr' with double quotes, to support an empty string when the feature is not supported.
--- tools/testing/selftests/net/mptcp/diag.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/diag.sh +2 -2
@@ -62,8 +62,8 @@ __chk_nr() nr=$(eval $command) printf "%-50s" "$msg" - if [ $nr != $expected ]; then - if [ $nr = "$skip" ] && ! mptcp_lib_expect_all_features; then + if [ "$nr" != "$expected" ]; then + if [ "$nr" = "$skip" ] && ! mptcp_lib_expect_all_features; then echo "[ skip ] Feature probably not supported" mptcp_lib_result_skip "${msg}" else
Signature · 1 line
2.44.0
Greg Kroah-Hartman
maintainerPATCH 225/334 selftests: mptcp: diag: unique in use subtest names
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 645c1dc965ef6b5554e5e69737bb179c7a0f872f upstream.
It is important to have a unique (sub)test name in TAP, because some CI environments drop tests with duplicated name.
Some 'in use' subtests from the diag selftest had the same names, e.g.:
chk 0 msk in use after flush
Now the previous value is taken, to have different names, e.g.:
chk 2->0 msk in use after flush
While at it, avoid repeating the full message, declare it once in the helper.
--- tools/testing/selftests/net/mptcp/diag.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
tools/testing/selftests/net/mptcp/diag.sh +12 -8
@@ -166,9 +166,13 @@ chk_msk_listen() chk_msk_inuse() { local expected=$1 - local msg="$2" + local msg="....chk ${2:-${expected}} msk in use" local listen_nr + if [ "${expected}" -eq 0 ]; then + msg+=" after flush" + fi + listen_nr=$(ss -N "${ns}" -Ml | grep -c LISTEN) expected=$((expected + listen_nr))
@@ -179,7 +183,7 @@ chk_msk_inuse() sleep 0.1 done - __chk_nr get_msk_inuse $expected "$msg" 0 + __chk_nr get_msk_inuse $expected "${msg}" 0 } # $1: ns, $2: port
@@ -244,11 +248,11 @@ wait_connected $ns 10000 chk_msk_nr 2 "after MPC handshake " chk_msk_remote_key_nr 2 "....chk remote_key" chk_msk_fallback_nr 0 "....chk no fallback" -chk_msk_inuse 2 "....chk 2 msk in use" +chk_msk_inuse 2 chk_msk_cestab 2 flush_pids -chk_msk_inuse 0 "....chk 0 msk in use after flush" +chk_msk_inuse 0 "2->0" chk_msk_cestab 0 echo "a" | \
@@ -264,11 +268,11 @@ echo "b" | \ 127.0.0.1 >/dev/null & wait_connected $ns 10001 chk_msk_fallback_nr 1 "check fallback" -chk_msk_inuse 1 "....chk 1 msk in use" +chk_msk_inuse 1 chk_msk_cestab 1 flush_pids -chk_msk_inuse 0 "....chk 0 msk in use after flush" +chk_msk_inuse 0 "1->0" chk_msk_cestab 0 NR_CLIENTS=100
@@ -290,11 +294,11 @@ for I in `seq 1 $NR_CLIENTS`; do done wait_msk_nr $((NR_CLIENTS*2)) "many msk socket present" -chk_msk_inuse $((NR_CLIENTS*2)) "....chk many msk in use" +chk_msk_inuse $((NR_CLIENTS*2)) "many" chk_msk_cestab $((NR_CLIENTS*2)) flush_pids -chk_msk_inuse 0 "....chk 0 msk in use after flush" +chk_msk_inuse 0 "many->0" chk_msk_cestab 0 mptcp_lib_result_print_all_tap
Greg Kroah-Hartman
maintainerPATCH 226/334 selftests: mptcp: diag: unique cestab subtest names
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 4103d8480866fe5abb71ef0ed8af3a3b7b9625bf upstream.
It is important to have a unique (sub)test name in TAP, because some CI environments drop tests with duplicated name.
Some 'cestab' subtests from the diag selftest had the same names, e.g.:
....chk 0 cestab
Now the previous value is taken, to have different names, e.g.:
....chk 2->0 cestab after flush
While at it, the 'after flush' info is added, similar to what is done with the 'in use' subtests. Also inspired by these 'in use' subtests, 'many' is displayed instead of a large number:
many msk socket present [ ok ]
....chk many msk in use [ ok ]
....chk many cestab [ ok ]
....chk many->0 msk in use after flush [ ok ]
....chk many->0 cestab after flush [ ok ]--- tools/testing/selftests/net/mptcp/diag.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
tools/testing/selftests/net/mptcp/diag.sh +11 -6
@@ -206,10 +206,15 @@ wait_local_port_listen() # $1: cestab nr chk_msk_cestab() { - local cestab=$1 + local expected=$1 + local msg="....chk ${2:-${expected}} cestab" + + if [ "${expected}" -eq 0 ]; then + msg+=" after flush" + fi __chk_nr "mptcp_lib_get_counter ${ns} MPTcpExtMPCurrEstab" \ - "${cestab}" "....chk ${cestab} cestab" "" + "${expected}" "${msg}" "" } wait_connected()
@@ -253,7 +258,7 @@ chk_msk_cestab 2 flush_pids chk_msk_inuse 0 "2->0" -chk_msk_cestab 0 +chk_msk_cestab 0 "2->0" echo "a" | \ timeout ${timeout_test} \
@@ -273,7 +278,7 @@ chk_msk_cestab 1 flush_pids chk_msk_inuse 0 "1->0" -chk_msk_cestab 0 +chk_msk_cestab 0 "1->0" NR_CLIENTS=100 for I in `seq 1 $NR_CLIENTS`; do
@@ -295,11 +300,11 @@ done wait_msk_nr $((NR_CLIENTS*2)) "many msk socket present" chk_msk_inuse $((NR_CLIENTS*2)) "many" -chk_msk_cestab $((NR_CLIENTS*2)) +chk_msk_cestab $((NR_CLIENTS*2)) "many" flush_pids chk_msk_inuse 0 "many->0" -chk_msk_cestab 0 +chk_msk_cestab 0 "many->0" mptcp_lib_result_print_all_tap exit $ret
Greg Kroah-Hartman
maintainerPATCH 227/334 ahci: Extend ASM1061 43-bit DMA address quirk to other ASM106x parts
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lennert Buytenhek <[email protected]>
commit 51af8f255bdaca6d501afc0d085b808f67b44d91 upstream.
ASMedia have confirmed that all ASM106x parts currently listed in ahci_pci_tbl[] suffer from the 43-bit DMA address limitation that we ran into on the ASM1061, and therefore, we need to apply the quirk added by commit 20730e9b2778 ("ahci: add 43-bit DMA address quirk for ASMedia ASM1061 controllers") to the other supported ASM106x parts as well.
--- drivers/ata/ahci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/ata/ahci.c +5 -5
@@ -606,13 +606,13 @@ static const struct pci_device_id ahci_p { PCI_VDEVICE(PROMISE, 0x3781), board_ahci }, /* FastTrak TX8660 ahci-mode *//* ASMedia */ - { PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci }, /* ASM1060 */ - { PCI_VDEVICE(ASMEDIA, 0x0602), board_ahci }, /* ASM1060 */ + { PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci_43bit_dma }, /* ASM1060 */ + { PCI_VDEVICE(ASMEDIA, 0x0602), board_ahci_43bit_dma }, /* ASM1060 */ { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci_43bit_dma }, /* ASM1061 */ { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci_43bit_dma }, /* ASM1061/1062 */ - { PCI_VDEVICE(ASMEDIA, 0x0621), board_ahci }, /* ASM1061R */ - { PCI_VDEVICE(ASMEDIA, 0x0622), board_ahci }, /* ASM1062R */ - { PCI_VDEVICE(ASMEDIA, 0x0624), board_ahci }, /* ASM1062+JMB575 */ + { PCI_VDEVICE(ASMEDIA, 0x0621), board_ahci_43bit_dma }, /* ASM1061R */ + { PCI_VDEVICE(ASMEDIA, 0x0622), board_ahci_43bit_dma }, /* ASM1062R */ + { PCI_VDEVICE(ASMEDIA, 0x0624), board_ahci_43bit_dma }, /* ASM1062+JMB575 */ { PCI_VDEVICE(ASMEDIA, 0x1062), board_ahci }, /* ASM1062A */ { PCI_VDEVICE(ASMEDIA, 0x1064), board_ahci }, /* ASM1064 */ { PCI_VDEVICE(ASMEDIA, 0x1164), board_ahci }, /* ASM1164 */
Greg Kroah-Hartman
maintainerPATCH 228/334 smb3: add missing null server pointer check
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 45be0882c5f91e1b92e645001dd1a53b3bd58c97 upstream.
Address static checker warning in cifs_ses_get_chan_index():
warn: variable dereferenced before check 'server'
To be consistent, and reduce risk, we should add another check for null server pointer.
--- fs/smb/client/sess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/sess.c +1 -1
@@ -76,7 +76,7 @@ cifs_ses_get_chan_index(struct cifs_sesunsigned int i;/* if the channel is waiting for termination */ -if (server->terminate) +if (server && server->terminate)return CIFS_INVAL_CHAN_INDEX ;for (i =0 ; i < ses->chan_count; i++) {
Greg Kroah-Hartman
maintainerPATCH 229/334 drm/amd/display: Avoid enum conversion warning
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit d7643fe6fb76edb1f2f1497bf5e8b8f4774b5129 upstream.
Clang warns (or errors with CONFIG_WERROR=y) when performing arithmetic with different enumerated types, which is usually a bug:
drivers/gpu/drm/amd/amdgpu/../display/dc/link/protocols/link_dp_dpia_bw.c:548:24: error: arithmetic between different enumeration types ('const enum dc_link_rate' and 'const enum dc_lane_count') [-Werror,-Wenum-enum-conversion]
548 | link_cap->link_rate * link_cap->lane_count * LINK_RATE_REF_FREQ_IN_KHZ * 8;
| ~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
1 error generated.
In this case, there is not a problem because the enumerated types are basically treated as '#define' values. Add an explicit cast to an integral type to silence the warning.
--- drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia_bw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia_bw.c +3 -2
@@ -544,8 +544,9 @@ int link_dp_dpia_get_dp_overhead_in_dp_t*/ const struct dc_link_settings *link_cap =dc_link_get_link_cap (link); -uint32_t link_bw_in_kbps = - link_cap->link_rate * link_cap->lane_count *LINK_RATE_REF_FREQ_IN_KHZ *8 ; +uint32_t link_bw_in_kbps = (uint32_t )link_cap->link_rate * + (uint32_t )link_cap->lane_count * +LINK_RATE_REF_FREQ_IN_KHZ *8 ; link_mst_overhead = (link_bw_in_kbps /64 ) + ((link_bw_in_kbps %64 ) ?1 :0 ); }
Greg Kroah-Hartman
maintainerPATCH 212/334 usb: roles: dont get/set_role() when usb_role_switch is unregistered
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
commit b787a3e781759026a6212736ef8e52cf83d1821a upstream.
There is a possibility that usb_role_switch device is unregistered before the user put usb_role_switch. In this case, the user may still want to get/set_role() since the user can't sense the changes of usb_role_switch.
This will add a flag to show if usb_role_switch is already registered and avoid unwanted behaviors.
--- drivers/usb/roles/class.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/usb/roles/class.c +10 -2
@@ -23,6 +23,7 @@ struct usb_role_switch {struct mutex lock;/* device lock*/ struct module *module;/* the module this device depends on */ enum usb_role role; +bool registered;/* From descriptor */ struct device *usb2_port;
@@ -49,6 +50,9 @@ int usb_role_switch_set_role(struct usb_if (IS_ERR_OR_NULL (sw))return 0 ; +if (!sw->registered) +return -EOPNOTSUPP ; +mutex_lock (&sw->lock); ret = sw->set (sw, role);
@@ -74,7 +78,7 @@ enum usb_role usb_role_switch_get_role(s {enum usb_role role; -if (IS_ERR_OR_NULL (sw)) +if (IS_ERR_OR_NULL (sw) || !sw->registered)return USB_ROLE_NONE ;mutex_lock (&sw->lock);
@@ -357,6 +361,8 @@ usb_role_switch_register(struct device *return ERR_PTR (ret); } + sw->registered = true; +/* TODO: Symlinks for the host port and the device controller. */ return sw;
@@ -371,8 +377,10 @@ EXPORT_SYMBOL_GPL(usb_role_switch_regist*/ void usb_role_switch_unregister (struct usb_role_switch *sw) { -if (!IS_ERR_OR_NULL (sw)) +if (!IS_ERR_OR_NULL (sw)) { + sw->registered = false;device_unregister (&sw->dev); + } }EXPORT_SYMBOL_GPL (usb_role_switch_unregister);
Greg Kroah-Hartman
maintainerPATCH 230/334 drm/amd/display: Fix buffer overflow in get_host_router_total_dp_tunnel_bw()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
commit 97cba232549b9fe7e491fb60a69cf93075015f29 upstream.
The error message buffer overflow 'dc->links' 12 <= 12 suggests that the code is trying to access an element of the dc->links array that is beyond its bounds. In C, arrays are zero-indexed, so an array with 12 elements has valid indices from 0 to 11. Trying to access dc->links[12] would be an attempt to access the 13th element of a 12-element array, which is a buffer overflow.
To fix this, ensure that the loop does not go beyond the last valid index when accessing dc->links[i + 1] by subtracting 1 from the loop condition.
This would ensure that i + 1 is always a valid index in the array.
Fixes the below:drivers/gpu/drm/amd/amdgpu/../display/dc/link/protocols/link_dp_dpia_bw.c:208 get_host_router_total_dp_tunnel_bw() error: buffer overflow 'dc->links' 12 <= 12
--- drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia_bw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia_bw.c +1 -1
@@ -196,7 +196,7 @@ static int get_host_router_total_dp_tunnstruct dc_link *link_dpia_primary, *link_dpia_secondary;int total_bw =0 ; -for (uint8_t i =0 ; i <MAX_PIPES *2 ; ++i) { +for (uint8_t i =0 ; i < (MAX_PIPES *2 ) -1 ; ++i) {if (!dc->links[i] || dc->links[i]->ep_type !=DISPLAY_ENDPOINT_USB4_DPIA )continue ;
Greg Kroah-Hartman
maintainerPATCH 231/334 Revert "drm/amd/display: increased min_dcfclk_mhz and min_fclk_mhz"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sohaib Nadeem <[email protected]>
commit a538dabf772c169641e151834e161e241802ab33 upstream.
[why]:
This reverts commit 2ff33c759a4247c84ec0b7815f1f223e155ba82a.
The commit caused corruption when running some applications in fullscreen
--- drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +1 -1
@@ -2719,7 +2719,7 @@ static int build_synthetic_soc_states(bostruct _vcs_dpi_voltage_scaling_st entry = {0 };struct clk_limit_table_entry max_clk_data = {0 }; -unsigned int min_dcfclk_mhz =399 , min_fclk_mhz =599 ; +unsigned int min_dcfclk_mhz =199 , min_fclk_mhz =299 ;static const unsigned int num_dcfclk_stas =5 ;unsigned int dcfclk_sta_targets[DC__VOLTAGE_STATES ] = {199 ,615 ,906 ,1324 ,1564 };
Greg Kroah-Hartman
maintainerPATCH 232/334 IB/hfi1: Fix a memleak in init_credit_return
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhipeng Lu <[email protected]>
[ Upstream commit 809aa64ebff51eb170ee31a95f83b2d21efa32e2 ]
When dma_alloc_coherent fails to allocate dd->cr_base[i].va, init_credit_return should deallocate dd->cr_base and dd->cr_base[i] that allocated before. Or those resources would be never freed and a memleak is triggered.
--- drivers/infiniband/hw/hfi1/pio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/pio.c +5 -1
@@ -2086,7 +2086,7 @@ int init_credit_return(struct hfi1_devdata *dd)"Unable to allocate credit return DMA range for NUMA %d\n" , i); ret = -ENOMEM ; - goto done; + goto free_cr_base; } }set_dev_node (&dd->pcidev->dev, dd->node);
@@ -2094,6 +2094,10 @@ int init_credit_return(struct hfi1_devdata *dd) ret =0 ; done:return ret; + +free_cr_base: +free_credit_return (dd); + goto done; }void free_credit_return (struct hfi1_devdata *dd)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 233/334 RDMA/bnxt_re: Return error for SRQ resize
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit 3687b450c5f32e80f179ce4b09e0454da1449eac ]
SRQ resize is not supported in the driver. But driver is not returning error from bnxt_re_modify_srq() for SRQ resize.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +2 -3
@@ -1809,7 +1809,7 @@ int bnxt_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr,switch (srq_attr_mask) {case IB_SRQ_MAX_WR :/* SRQ resize is not supported */ -break ; +return -EINVAL ;case IB_SRQ_LIMIT :/* Change the SRQ threshold */ if (srq_attr->srq_limit > srq->qplib_srq.max_wqe)
@@ -1824,13 +1824,12 @@ int bnxt_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr,/* On success, update the shadow */ srq->srq_limit = srq_attr->srq_limit;/* No need to Build and send response back to udata */ -break ; +return 0 ;default :ibdev_err (&rdev->ibdev,"Unsupported srq_attr_mask 0x%x" , srq_attr_mask);return -EINVAL ; } -return 0 ; }int bnxt_re_query_srq (struct ib_srq *ib_srq,struct ib_srq_attr *srq_attr)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 234/334 RDMA/bnxt_re: Add a missing check in bnxt_qplib_query_srq
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit 80dde187f734cf9ccf988d5c2ef1a46b990660fd ]
Before populating the response, driver has to check the status of HWRM command.
--- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/qplib_fp.c +2 -1
@@ -748,7 +748,8 @@ int bnxt_qplib_query_srq(struct bnxt_qplib_res *res,bnxt_qplib_fill_cmdqmsg (&msg, &req, &resp, &sbuf,sizeof (req),sizeof (resp),0 ); rc =bnxt_qplib_rcfw_send_message (rcfw, &msg); - srq->threshold =le16_to_cpu (sb->srq_limit); +if (!rc) + srq->threshold =le16_to_cpu (sb->srq_limit);dma_free_coherent (&rcfw->pdev->dev, sbuf.size, sbuf.sb, sbuf.dma_addr);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 235/334 IB/mlx5: Dont expose debugfs entries for RRoCE general parameters if not supported
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Zhang <[email protected]>
[ Upstream commit 43fdbd140238d44e7e847232719fef7d20f9d326 ]
debugfs entries for RRoCE general CC parameters must be exposed only when they are supported, otherwise when accessing them there may be a syndrome error in kernel log, for example:
$ cat /sys/kernel/debug/mlx5/0000:08:00.1/cc_params/rtt_resp_dscp cat: '/sys/kernel/debug/mlx5/0000:08:00.1/cc_params/rtt_resp_dscp': Invalid argument $ dmesg mlx5_core 0000:08:00.1: mlx5_cmd_out_err:805:(pid 1253): QUERY_CONG_PARAMS(0x824) op_mod(0x0) failed, status bad parameter(0x3), syndrome (0x325a82), err(-22)
--- drivers/infiniband/hw/mlx5/cong.c | 6 ++++++ include/linux/mlx5/mlx5_ifc.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/cong.c +6 -0
@@ -458,6 +458,12 @@ void mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u32 port_num) dbg_cc_params->root =debugfs_create_dir ("cc_params" ,mlx5_debugfs_get_dev_root (mdev));for (i =0 ; i <MLX5_IB_DBG_CC_MAX ; i++) { +if ((i ==MLX5_IB_DBG_CC_GENERAL_RTT_RESP_DSCP_VALID || + i ==MLX5_IB_DBG_CC_GENERAL_RTT_RESP_DSCP )) +if (!MLX5_CAP_GEN (mdev, roce) || + !MLX5_CAP_ROCE (mdev, roce_cc_general)) +continue ; + dbg_cc_params->params[i].offset = i; dbg_cc_params->params[i].dev = dev; dbg_cc_params->params[i].port_num = port_num;
include/linux/mlx5/mlx5_ifc.h +1 -1
@@ -1103,7 +1103,7 @@ struct mlx5_ifc_roce_cap_bits {u8 sw_r_roce_src_udp_port[0x1 ];u8 fl_rc_qp_when_roce_disabled[0x1 ];u8 fl_rc_qp_when_roce_enabled[0x1 ]; -u8 reserved_at_7[0x1 ]; +u8 roce_cc_general[0x1 ];u8 qp_ooo_transmit_default[0x1 ];u8 reserved_at_9[0x15 ];u8 qp_ts_format[0x2 ];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 236/334 arm64: dts: imx8mp: Disable UART4 by default on Data Modul i.MX8M Plus eDM SBC
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit f03869698bc3bd6d9d2d9f216b20da08a8c2508a ]
UART4 is used as CM7 coprocessor debug UART and may not be accessible from Linux in case it is protected by RDC. The RDC protection is set up by the platform firmware. UART4 is not used on this platform by Linux. Disable UART4 by default to prevent boot hangs, which occur when the RDC protection is in place.
--- arch/arm64/boot/dts/freescale/imx8mp-data-modul-edm-sbc.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx8mp-data-modul-edm-sbc.dts +1 -1
@@ -486,7 +486,7 @@ &uart4 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart4>; - status = "okay"; + status = "disabled"; }; &usb3_phy0 {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 237/334 RDMA/irdma: Fix KASAN issue with tasklet
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Marciniszyn <[email protected]>
[ Upstream commit bd97cea7b18a0a553773af806dfbfac27a7c4acb ]
KASAN testing revealed the following issue assocated with freeing an IRQ.
[50006.466686] Call Trace: [50006.466691] <IRQ> [50006.489538] dump_stack+0x5c/0x80 [50006.493475] print_address_description.constprop.6+0x1a/0x150 [50006.499872] ? irdma_sc_process_ceq+0x483/0x790 [irdma] [50006.505742] ? irdma_sc_process_ceq+0x483/0x790 [irdma] [50006.511644] kasan_report.cold.11+0x7f/0x118 [50006.516572] ? irdma_sc_process_ceq+0x483/0x790 [irdma] [50006.522473] irdma_sc_process_ceq+0x483/0x790 [irdma] [50006.528232] irdma_process_ceq+0xb2/0x400 [irdma] [50006.533601] ? irdma_hw_flush_wqes_callback+0x370/0x370 [irdma] [50006.540298] irdma_ceq_dpc+0x44/0x100 [irdma] [50006.545306] tasklet_action_common.isra.14+0x148/0x2c0 [50006.551096] __do_softirq+0x1d0/0xaf8 [50006.555396] irq_exit_rcu+0x219/0x260 [50006.559670] irq_exit+0xa/0x20 [50006.563320] smp_apic_timer_interrupt+0x1bf/0x690 [50006.568645] apic_timer_interrupt+0xf/0x20 [50006.573341] </IRQ>
The issue is that a tasklet could be pending on another core racing the delete of the irq.
Fix by insuring any scheduled tasklet is killed after deleting the irq.
--- drivers/infiniband/hw/irdma/hw.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/hw/irdma/hw.c +7 -0
@@ -570,6 +570,13 @@ static void irdma_destroy_irq(struct irdma_pci_f *rf, dev->irq_ops->irdma_dis_irq (dev, msix_vec->idx);irq_update_affinity_hint (msix_vec->irq,NULL );free_irq (msix_vec->irq, dev_id); +if (rf == dev_id) { +tasklet_kill (&rf->dpc_tasklet); + }else { +struct irdma_ceq *iwceq = (struct irdma_ceq *)dev_id; + +tasklet_kill (&iwceq->dpc_tasklet); + } }/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 238/334 RDMA/irdma: Validate max_send_wr and max_recv_wr
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shiraz Saleem <[email protected]>
[ Upstream commit ee107186bcfd25d7873258f3f75440e20f5e6416 ]
Validate that max_send_wr and max_recv_wr is within the supported range.
--- drivers/infiniband/hw/irdma/verbs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +3 -1
@@ -839,7 +839,9 @@ static int irdma_validate_qp_attrs(struct ib_qp_init_attr *init_attr,if (init_attr->cap.max_inline_data > uk_attrs->max_hw_inline || init_attr->cap.max_send_sge > uk_attrs->max_hw_wq_frags || - init_attr->cap.max_recv_sge > uk_attrs->max_hw_wq_frags) + init_attr->cap.max_recv_sge > uk_attrs->max_hw_wq_frags || + init_attr->cap.max_send_wr > uk_attrs->max_hw_wq_quanta || + init_attr->cap.max_recv_wr > uk_attrs->max_hw_rq_quanta)return -EINVAL ;if (rdma_protocol_roce (&iwdev->ibdev,1 )) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 239/334 RDMA/irdma: Set the CQ read threshold for GEN 1
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mustafa Ismail <[email protected]>
[ Upstream commit 666047f3ece9f991774c1fe9b223139a9ef8908d ]
The CQ shadow read threshold is currently not set for GEN 2. This could cause an invalid CQ overflow condition, so remove the GEN check that exclused GEN 1.
--- drivers/infiniband/hw/irdma/verbs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +2 -3
@@ -2186,9 +2186,8 @@ static int irdma_create_cq(struct ib_cq *ibcq, info.cq_base_pa = iwcq->kmem.pa; } -if (dev->hw_attrs.uk_attrs.hw_rev >=IRDMA_GEN_2 ) - info.shadow_read_threshold =min (info.cq_uk_init_info.cq_size /2 , - (u32 )IRDMA_MAX_CQ_READ_THRESH ); + info.shadow_read_threshold =min (info.cq_uk_init_info.cq_size /2 , + (u32 )IRDMA_MAX_CQ_READ_THRESH );if (irdma_sc_cq_init (cq, &info)) {ibdev_dbg (&iwdev->ibdev,"VERBS: init cq fail\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 213/334 mptcp: add needs_id for userspace appending addr
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
commit 6c347be62ae963b301ead8e7fa7b9973e6e0d6e1 upstream.
When userspace PM requires to create an ID 0 subflow in "userspace pm create id 0 subflow" test like this:
userspace_pm_add_sf $ns2 10.0.3.2 0
An ID 1 subflow, in fact, is created.
Since in mptcp_pm_nl_append_new_local_addr(), 'id 0' will be treated as no ID is set by userspace, and will allocate a new ID immediately:
if (!e->addr.id)
e->addr.id = find_next_zero_bit(pernet->id_bitmap,
MPTCP_PM_MAX_ADDR_ID + 1,
1);To solve this issue, a new parameter needs_id is added for mptcp_userspace_pm_append_new_local_addr() to distinguish between whether userspace PM has set an ID 0 or whether userspace PM has not set any address.
needs_id is true in mptcp_userspace_pm_get_local_id(), but false in mptcp_pm_nl_announce_doit() and mptcp_pm_nl_subflow_create_doit().
--- net/mptcp/pm_userspace.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/mptcp/pm_userspace.c +7 -6
@@ -26,7 +26,8 @@ void mptcp_free_local_addr_list(struct m }static int mptcp_userspace_pm_append_new_local_addr (struct mptcp_sock *msk, -struct mptcp_pm_addr_entry *entry) +struct mptcp_pm_addr_entry *entry, +bool needs_id) {DECLARE_BITMAP (id_bitmap,MPTCP_PM_MAX_ADDR_ID +1 );struct mptcp_pm_addr_entry *match =NULL ;
@@ -41,7 +42,7 @@ static int mptcp_userspace_pm_append_newspin_lock_bh (&msk->pm.lock);list_for_each_entry (e, &msk->pm.userspace_pm_local_addr_list, list) { addr_match =mptcp_addresses_equal (&e->addr, &entry->addr, true); -if (addr_match && entry->addr.id ==0 ) +if (addr_match && entry->addr.id ==0 && needs_id) entry->addr.id = e->addr.id; id_match = (e->addr.id == entry->addr.id);if (addr_match && id_match) {
@@ -64,7 +65,7 @@ static int mptcp_userspace_pm_append_new } *e = *entry; -if (!e->addr.id) +if (!e->addr.id && needs_id) e->addr.id =find_next_zero_bit (id_bitmap,MPTCP_PM_MAX_ADDR_ID +1 ,1 );
@@ -153,7 +154,7 @@ int mptcp_userspace_pm_get_local_id(struif (new_entry.addr.port == msk_sport) new_entry.addr.port =0 ; -return mptcp_userspace_pm_append_new_local_addr (msk, &new_entry); +return mptcp_userspace_pm_append_new_local_addr (msk, &new_entry, true); }int mptcp_pm_nl_announce_doit (struct sk_buff *skb,struct genl_info *info)
@@ -198,7 +199,7 @@ int mptcp_pm_nl_announce_doit(struct sk_ goto announce_err; } - err =mptcp_userspace_pm_append_new_local_addr (msk, &addr_val); + err =mptcp_userspace_pm_append_new_local_addr (msk, &addr_val, false);if (err <0 ) {GENL_SET_ERR_MSG (info,"did not match address and id" ); goto announce_err;
@@ -378,7 +379,7 @@ int mptcp_pm_nl_subflow_create_doit(stru } local.addr = addr_l; - err =mptcp_userspace_pm_append_new_local_addr (msk, &local); + err =mptcp_userspace_pm_append_new_local_addr (msk, &local, false);if (err <0 ) {GENL_SET_ERR_MSG (info,"did not match address and id" ); goto create_err;
Greg Kroah-Hartman
maintainerPATCH 240/334 RDMA/irdma: Add AE for too many RNRS
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mustafa Ismail <[email protected]>
[ Upstream commit 630bdb6f28ca9e5ff79e244030170ac788478332 ]
Add IRDMA_AE_LLP_TOO_MANY_RNRS to the list of AE's processed as an abnormal asyncronous event.
--- drivers/infiniband/hw/irdma/defs.h | 1 + drivers/infiniband/hw/irdma/hw.c | 1 + 2 files changed, 2 insertions(+)
drivers/infiniband/hw/irdma/defs.h +1 -0
@@ -346,6 +346,7 @@ enum irdma_cqp_op_type {#define IRDMA_AE_LLP_TOO_MANY_KEEPALIVE_RETRIES 0x050b#define IRDMA_AE_LLP_DOUBT_REACHABILITY 0x050c#define IRDMA_AE_LLP_CONNECTION_ESTABLISHED 0x050e +#define IRDMA_AE_LLP_TOO_MANY_RNRS 0x050f#define IRDMA_AE_RESOURCE_EXHAUSTION 0x0520#define IRDMA_AE_RESET_SENT 0x0601#define IRDMA_AE_TERMINATE_SENT 0x0602
drivers/infiniband/hw/irdma/hw.c +1 -0
@@ -387,6 +387,7 @@ static void irdma_process_aeq(struct irdma_pci_f *rf)case IRDMA_AE_LLP_TOO_MANY_RETRIES :case IRDMA_AE_LCE_QP_CATASTROPHIC :case IRDMA_AE_LCE_FUNCTION_CATASTROPHIC : +case IRDMA_AE_LLP_TOO_MANY_RNRS :case IRDMA_AE_LCE_CQ_CATASTROPHIC :case IRDMA_AE_UDA_XMIT_DGRAM_TOO_LONG :default :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 241/334 RDMA/srpt: Support specifying the srpt_service_guid parameter
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit fdfa083549de5d50ebf7f6811f33757781e838c0 ]
Make loading ib_srpt with this parameter set work. The current behavior is that setting that parameter while loading the ib_srpt kernel module triggers the following kernel crash:
BUG: kernel NULL pointer dereference, address: 0000000000000000 Call Trace: <TASK> parse_one+0x18c/0x1d0 parse_args+0xe1/0x230 load_module+0x8de/0xa60 init_module_from_file+0x8b/0xd0 idempotent_init_module+0x181/0x240 __x64_sys_finit_module+0x5a/0xb0 do_syscall_64+0x5f/0xe0 entry_SYSCALL_64_after_hwframe+0x6e/0x76
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +6 -2
@@ -79,12 +79,16 @@ module_param(srpt_srq_size, int, 0444);MODULE_PARM_DESC (srpt_srq_size,"Shared receive queue (SRQ) size." ); +static int srpt_set_u64_x (const char *buffer,const struct kernel_param *kp) +{ +return kstrtou64 (buffer,16 , (u64 *)kp->arg); +}static int srpt_get_u64_x (char *buffer,const struct kernel_param *kp) {return sprintf (buffer,"0x%016llx\n" , *(u64 *)kp->arg); } -module_param_call (srpt_service_guid,NULL , srpt_get_u64_x, &srpt_service_guid, -0444 ); +module_param_call (srpt_service_guid, srpt_set_u64_x, srpt_get_u64_x, + &srpt_service_guid,0444 );MODULE_PARM_DESC (srpt_service_guid,"Using this value for ioc_guid, id_ext, and cm_listen_id instead of using the node_guid of the first HCA." );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 214/334 mptcp: add needs_id for netlink appending addr
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
commit 584f3894262634596532cf43a5e782e34a0ce374 upstream.
Just the same as userspace PM, a new parameter needs_id is added for in-kernel PM mptcp_pm_nl_append_new_local_addr() too.
Add a new helper mptcp_pm_has_addr_attr_id() to check whether an address ID is set from PM or not.
In mptcp_pm_nl_get_local_id(), needs_id is always true, but in mptcp_pm_nl_add_addr_doit(), pass mptcp_pm_has_addr_attr_id() to needs_it.
--- net/mptcp/pm_netlink.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
net/mptcp/pm_netlink.c +19 -5
@@ -901,7 +901,8 @@ static void __mptcp_pm_release_addr_entr }static int mptcp_pm_nl_append_new_local_addr (struct pm_nl_pernet *pernet, -struct mptcp_pm_addr_entry *entry) +struct mptcp_pm_addr_entry *entry, +bool needs_id) {struct mptcp_pm_addr_entry *cur, *del_entry =NULL ;unsigned int addr_max;
@@ -949,7 +950,7 @@ static int mptcp_pm_nl_append_new_local_ } } -if (!entry->addr.id) { +if (!entry->addr.id && needs_id) { find_next: entry->addr.id = find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1,
@@ -960,7 +961,7 @@ find_next: } } -if (!entry->addr.id) +if (!entry->addr.id && needs_id) goto out;__set_bit (entry->addr.id, pernet->id_bitmap);
@@ -1092,7 +1093,7 @@ int mptcp_pm_nl_get_local_id(struct mptc entry->ifindex =0 ; entry->flags =MPTCP_PM_ADDR_FLAG_IMPLICIT ; entry->lsk =NULL ; - ret =mptcp_pm_nl_append_new_local_addr (pernet, entry); + ret =mptcp_pm_nl_append_new_local_addr (pernet, entry, true);if (ret <0 )kfree (entry);
@@ -1285,6 +1286,18 @@ next:return 0 ; } +static bool mptcp_pm_has_addr_attr_id (const struct nlattr *attr, +struct genl_info *info) +{ +struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX +1 ]; + +if (!nla_parse_nested_deprecated (tb,MPTCP_PM_ADDR_ATTR_MAX , attr, + mptcp_pm_address_nl_policy, info->extack) && + tb[MPTCP_PM_ADDR_ATTR_ID ]) +return true; +return false; +} +int mptcp_pm_nl_add_addr_doit (struct sk_buff *skb,struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ];
@@ -1326,7 +1339,8 @@ int mptcp_pm_nl_add_addr_doit(struct sk_ goto out_free; } } - ret =mptcp_pm_nl_append_new_local_addr (pernet, entry); + ret =mptcp_pm_nl_append_new_local_addr (pernet, entry, + !mptcp_pm_has_addr_attr_id (attr, info));if (ret <0 ) {GENL_SET_ERR_MSG_FMT (info,"too many addresses or duplicate one: %d" , ret); goto out_free;
Greg Kroah-Hartman
maintainerPATCH 215/334 mptcp: fix lockless access in subflow ULP diag
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit b8adb69a7d29c2d33eb327bca66476fb6066516b upstream.
Since the introduction of the subflow ULP diag interface, the dump callback accessed all the subflow data with lockless.
We need either to annotate all the read and write operation accordingly, or acquire the subflow socket lock. Let's do latter, even if slower, to avoid a diffstat havoc.
--- include/net/tcp.h | 2 +- net/mptcp/diag.c | 6 +++++- net/tls/tls_main.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-)
include/net/tcp.h +1 -1
@@ -2502,7 +2502,7 @@ struct tcp_ulp_ops {/* cleanup ulp */ void (*release)(struct sock *sk);/* diagnostic */ -int (*get_info)(const struct sock *sk,struct sk_buff *skb); +int (*get_info)(struct sock *sk,struct sk_buff *skb);size_t (*get_info_size)(const struct sock *sk);/* clone ulp */ void (*clone)(const struct request_sock *req, struct sock *newsk,
net/mptcp/diag.c +5 -1
@@ -13,17 +13,19 @@#include <uapi/linux/mptcp.h> #include "protocol.h" -static int subflow_get_info (const struct sock *sk,struct sk_buff *skb) +static int subflow_get_info (struct sock *sk,struct sk_buff *skb) {struct mptcp_subflow_context *sf;struct nlattr *start;u32 flags =0 ; +bool slow;int err; start =nla_nest_start_noflag (skb,INET_ULP_INFO_MPTCP );if (!start)return -EMSGSIZE ; + slow =lock_sock_fast (sk);rcu_read_lock (); sf =rcu_dereference (inet_csk (sk)->icsk_ulp_data);if (!sf) {
@@ -69,11 +71,13 @@ static int subflow_get_info(const struct }rcu_read_unlock (); +unlock_sock_fast (sk, slow);nla_nest_end (skb, start);return 0 ; nla_failure:rcu_read_unlock (); +unlock_sock_fast (sk, slow);nla_nest_cancel (skb, start);return err; }
net/tls/tls_main.c +1 -1
@@ -1003,7 +1003,7 @@ static u16 tls_user_config(struct tls_coreturn 0 ; } -static int tls_get_info (const struct sock *sk,struct sk_buff *skb) +static int tls_get_info (struct sock *sk,struct sk_buff *skb) {u16 version, cipher_type;struct tls_context *ctx;
Greg Kroah-Hartman
maintainerPATCH 216/334 mptcp: fix data races on local_id
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit a7cfe776637004a4c938fde78be4bd608c32c3ef upstream.
The local address id is accessed lockless by the NL PM, add all the required ONCE annotation. There is a caveat: the local id can be initialized late in the subflow life-cycle, and its validity is controlled by the local_id_valid flag.
Remove such flag and encode the validity in the local_id field itself with negative value before initialization. That allows accessing the field consistently with a single read operation.
--- net/mptcp/diag.c | 2 +- net/mptcp/pm_netlink.c | 6 +++--- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 15 ++++++++++++--- net/mptcp/subflow.c | 9 +++++---- 6 files changed, 23 insertions(+), 13 deletions(-)
net/mptcp/diag.c +1 -1
@@ -65,7 +65,7 @@ static int subflow_get_info(struct sock sf->map_data_len) || nla_put_u32(skb, MPTCP_SUBFLOW_ATTR_FLAGS, flags) || nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_REM, sf->remote_id) || - nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_LOC, sf->local_id)) { + nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_LOC, subflow_get_local_id(sf))) { err = -EMSGSIZE ; goto nla_failure; }
net/mptcp/pm_netlink.c +3 -3
@@ -800,7 +800,7 @@ static void mptcp_pm_nl_rm_addr_or_subflmptcp_for_each_subflow_safe (msk, subflow, tmp) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow);int how =RCV_SHUTDOWN |SEND_SHUTDOWN ; -u8 id = subflow->local_id; +u8 id =subflow_get_local_id (subflow);if (rm_type ==MPTCP_MIB_RMADDR && subflow->remote_id != rm_id)continue ;
@@ -809,7 +809,7 @@ static void mptcp_pm_nl_rm_addr_or_subflpr_debug (" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u mpc_id=%u" , rm_type ==MPTCP_MIB_RMADDR ?"address" :"subflow" , - i, rm_id, subflow->local_id, subflow->remote_id, + i, rm_id, id, subflow->remote_id, msk->mpc_endpoint_id);spin_unlock_bh (&msk->pm.lock);mptcp_subflow_shutdown (sk, ssk, how);
@@ -1994,7 +1994,7 @@ static int mptcp_event_add_subflow(strucif (WARN_ON_ONCE (!sf))return -EINVAL ; -if (nla_put_u8 (skb,MPTCP_ATTR_LOC_ID , sf->local_id)) +if (nla_put_u8 (skb,MPTCP_ATTR_LOC_ID ,subflow_get_local_id (sf)))return -EMSGSIZE ;if (nla_put_u8 (skb,MPTCP_ATTR_REM_ID , sf->remote_id))
net/mptcp/pm_userspace.c +1 -1
@@ -234,7 +234,7 @@ static int mptcp_userspace_pm_remove_id_lock_sock (sk);mptcp_for_each_subflow (msk, subflow) { -if (subflow->local_id ==0 ) { +if (READ_ONCE (subflow->local_id) ==0 ) { has_id_0 = true;break ; }
net/mptcp/protocol.c +1 -1
@@ -99,7 +99,7 @@ static int __mptcp_socket_create(struct subflow->subflow_id = msk->subflow_id++;/* This is the first subflow, always with id 0 */ - subflow->local_id_valid =1 ; +WRITE_ONCE (subflow->local_id,0 );mptcp_sock_graft (msk->first, sk->sk_socket);iput (SOCK_INODE (ssock));
net/mptcp/protocol.h +12 -3
@@ -491,10 +491,9 @@ struct mptcp_subflow_context { remote_key_valid : 1, /* received the peer key from */ disposable : 1, /* ctx can be free at ulp release time */ stale : 1, /* unable to snd/rcv data, do not use for xmit */ - local_id_valid : 1, /* local_id is correctly initialized */ valid_csum_seen : 1, /* at least one csum validated */ is_mptfo : 1, /* subflow is doing TFO */ - __unused : 9; + __unused : 10;bool data_avail;bool scheduled;u32 remote_nonce;
@@ -505,7 +504,7 @@ struct mptcp_subflow_context {u8 hmac[MPTCPOPT_HMAC_LEN ];/* MPJ subflow only */ u64 iasn;/* initial ack sequence number, MPC subflows only */ }; -u8 local_id; +s16 local_id;/* if negative not initialized yet */ u8 remote_id; u8 reset_seen:1; u8 reset_transient:1;
@@ -556,6 +555,7 @@ mptcp_subflow_ctx_reset(struct mptcp_sub {memset (&subflow->reset,0 ,sizeof (subflow->reset)); subflow->request_mptcp =1 ; +WRITE_ONCE (subflow->local_id,-1 ); } static inline u64
@@ -1022,6 +1022,15 @@ int mptcp_pm_get_local_id(struct mptcp_sint mptcp_pm_nl_get_local_id (struct mptcp_sock *msk,struct mptcp_addr_info *skc);int mptcp_userspace_pm_get_local_id (struct mptcp_sock *msk,struct mptcp_addr_info *skc); +static inline u8 subflow_get_local_id (const struct mptcp_subflow_context *subflow) +{ +int local_id =READ_ONCE (subflow->local_id); + +if (local_id <0 ) +return 0 ; +return local_id; +} +void __init mptcp_pm_nl_init (void );void mptcp_pm_nl_work (struct mptcp_sock *msk); void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk,
net/mptcp/subflow.c +5 -4
@@ -577,8 +577,8 @@ do_reset:static void subflow_set_local_id (struct mptcp_subflow_context *subflow,int local_id) { - subflow->local_id = local_id; - subflow->local_id_valid =1 ; +WARN_ON_ONCE (local_id <0 || local_id >255 ); +WRITE_ONCE (subflow->local_id, local_id); }static int subflow_chk_local_id (struct sock *sk)
@@ -587,7 +587,7 @@ static int subflow_chk_local_id(struct sstruct mptcp_sock *msk =mptcp_sk (subflow->conn);int err; -if (likely (subflow->local_id_valid)) +if (likely (subflow->local_id >=0 ))return 0 ; err =mptcp_pm_get_local_id (msk, (struct sock_common *)sk);
@@ -1731,6 +1731,7 @@ static struct mptcp_subflow_context *subpr_debug ("subflow=%p" , ctx); ctx->tcp_sock = sk; +WRITE_ONCE (ctx->local_id,-1 );return ctx; }
@@ -1966,7 +1967,7 @@ static void subflow_ulp_clone(const stru new_ctx->idsn = subflow_req->idsn;/* this is the first subflow, id is always 0 */ - new_ctx->local_id_valid =1 ; +subflow_set_local_id (new_ctx,0 ); }else if (subflow_req->mp_join) { new_ctx->ssn_offset = subflow_req->ssn_offset; new_ctx->mp_join =1 ;
Greg Kroah-Hartman
maintainerPATCH 217/334 mptcp: fix data races on remote_id
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 967d3c27127e71a10ff5c083583a038606431b61 upstream.
Similar to the previous patch, address the data race on remote_id, adding the suitable ONCE annotations.
--- net/mptcp/pm_netlink.c | 8 ++++---- net/mptcp/subflow.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
net/mptcp/pm_netlink.c +4 -4
@@ -443,7 +443,7 @@ static unsigned int fill_remote_addressemptcp_for_each_subflow (msk, subflow) { ssk =mptcp_subflow_tcp_sock (subflow);remote_address ((struct sock_common *)ssk, &addrs[i]); - addrs[i].id = subflow->remote_id; + addrs[i].id =READ_ONCE (subflow->remote_id);if (deny_id0 && !addrs[i].id)continue ;
@@ -799,18 +799,18 @@ static void mptcp_pm_nl_rm_addr_or_subflmptcp_for_each_subflow_safe (msk, subflow, tmp) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow); +u8 remote_id =READ_ONCE (subflow->remote_id);int how =RCV_SHUTDOWN |SEND_SHUTDOWN ;u8 id =subflow_get_local_id (subflow); -if (rm_type ==MPTCP_MIB_RMADDR && subflow->remote_id != rm_id) +if (rm_type ==MPTCP_MIB_RMADDR && remote_id != rm_id)continue ;if (rm_type ==MPTCP_MIB_RMSUBFLOW && !mptcp_local_id_match (msk, id, rm_id))continue ;pr_debug (" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u mpc_id=%u" , rm_type ==MPTCP_MIB_RMADDR ?"address" :"subflow" , - i, rm_id, id, subflow->remote_id, - msk->mpc_endpoint_id); + i, rm_id, id, remote_id, msk->mpc_endpoint_id);spin_unlock_bh (&msk->pm.lock);mptcp_subflow_shutdown (sk, ssk, how);
net/mptcp/subflow.c +3 -3
@@ -535,7 +535,7 @@ static void subflow_finish_connect(struc subflow->backup = mp_opt.backup; subflow->thmac = mp_opt.thmac; subflow->remote_nonce = mp_opt.nonce; - subflow->remote_id = mp_opt.join_id; +WRITE_ONCE (subflow->remote_id, mp_opt.join_id);pr_debug ("subflow=%p, thmac=%llu, remote_nonce=%u backup=%d" , subflow, subflow->thmac, subflow->remote_nonce, subflow->backup);
@@ -1567,7 +1567,7 @@ int __mptcp_subflow_connect(struct sockpr_debug ("msk=%p remote_token=%u local_id=%d remote_id=%d" , msk, remote_token, local_id, remote_id); subflow->remote_token = remote_token; - subflow->remote_id = remote_id; +WRITE_ONCE (subflow->remote_id, remote_id); subflow->request_join =1 ; subflow->request_bkup = !!(flags &MPTCP_PM_ADDR_FLAG_BACKUP ); subflow->subflow_id = msk->subflow_id++;
@@ -1974,7 +1974,7 @@ static void subflow_ulp_clone(const stru new_ctx->fully_established =1 ; new_ctx->remote_key_valid =1 ; new_ctx->backup = subflow_req->backup; - new_ctx->remote_id = subflow_req->remote_id; +WRITE_ONCE (new_ctx->remote_id, subflow_req->remote_id); new_ctx->token = subflow_req->token; new_ctx->thmac = subflow_req->thmac;
Greg Kroah-Hartman
maintainerPATCH 218/334 mptcp: fix duplicate subflow creation
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 045e9d812868a2d80b7a57b224ce8009444b7bbc upstream.
Fullmesh endpoints could end-up unexpectedly generating duplicate subflows - same local and remote addresses - when multiple incoming ADD_ADDR are processed before the PM creates the subflow for the local endpoints.
Address the issue explicitly checking for duplicates at subflow creation time.
To avoid a quadratic computational complexity, track the unavailable remote address ids in a temporary bitmap and initialize such bitmap with the remote ids of all the existing subflows matching the local address currently processed.
The above allows additionally replacing the existing code checking for duplicate entry in the current set with a simple bit test operation.
--- net/mptcp/pm_netlink.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
net/mptcp/pm_netlink.c +18 -15
@@ -396,19 +396,6 @@ void mptcp_pm_free_anno_list(struct mptc } } -static bool lookup_address_in_vec (const struct mptcp_addr_info *addrs,unsigned int nr, -const struct mptcp_addr_info *addr) -{ -int i; - -for (i =0 ; i < nr; i++) { -if (addrs[i].id == addr->id) -return true; - } - -return false; -} -/* Fill all the remote addresses into the array addrs[], * and return the array size. */
@@ -440,6 +427,16 @@ static unsigned int fill_remote_addresse msk->pm.subflows++; addrs[i++] = remote; }else { +DECLARE_BITMAP (unavail_id,MPTCP_PM_MAX_ADDR_ID +1 ); + +/* Forbid creation of new subflows matching existing +* ones, possibly already created by incoming ADD_ADDR +*/ +bitmap_zero (unavail_id,MPTCP_PM_MAX_ADDR_ID +1 ); +mptcp_for_each_subflow (msk, subflow) +if (READ_ONCE (subflow->local_id) == local->id) +__set_bit (subflow->remote_id, unavail_id); +mptcp_for_each_subflow (msk, subflow) { ssk =mptcp_subflow_tcp_sock (subflow);remote_address ((struct sock_common *)ssk, &addrs[i]);
@@ -447,11 +444,17 @@ static unsigned int fill_remote_addresseif (deny_id0 && !addrs[i].id)continue ; +if (test_bit (addrs[i].id, unavail_id)) +continue ; +if (!mptcp_pm_addr_families_match (sk, local, &addrs[i]))continue ; -if (!lookup_address_in_vec (addrs, i, &addrs[i]) && - msk->pm.subflows < subflows_max) { +if (msk->pm.subflows < subflows_max) { +/* forbid creating multiple address towards +* this id +*/ +__set_bit (addrs[i].id, unavail_id); msk->pm.subflows++; i++; }
Greg Kroah-Hartman
maintainerPATCH 219/334 selftests: mptcp: userspace_pm: unique subtest names
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 2ef0d804c090658960c008446523863fd7e3541e upstream.
It is important to have a unique (sub)test name in TAP, because some CI environments drop tests with duplicated names.
Some subtests from the userspace_pm selftest had the same names. That's because different subflows are created (and deleted) between the same pair of IP addresses.
Simply adding the destination port in the name is then enough to have different names, because the destination port is always different.
Note that adding such info takes a bit more space, so we need to increase a bit the width to print the name, simply to keep all the '[ OK ]' aligned as before.
--- tools/testing/selftests/net/mptcp/userspace_pm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/userspace_pm.sh +2 -2
@@ -75,7 +75,7 @@ print_test() { test_name="${1}" - _printf "%-63s" "${test_name}" + _printf "%-68s" "${test_name}" } print_results()
@@ -555,7 +555,7 @@ verify_subflow_events() local remid local info - info="${e_saddr} (${e_from}) => ${e_daddr} (${e_to})" + info="${e_saddr} (${e_from}) => ${e_daddr}:${e_dport} (${e_to})" if [ "$e_type" = "$SUB_ESTABLISHED" ] then
Greg Kroah-Hartman
maintainerPATCH 210/334 usb: gadget: omap_udc: fix USB gadget regression on Palm TE
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaro Koskinen <[email protected]>
commit 858a74cb512833e276d96a72acb560ce8c138bec upstream.
When upgrading from 6.1 LTS to 6.6 LTS, I noticed the ethernet gadget stopped working on Palm TE.
Commit 8825acd7cc8a ("ARM: omap1: remove dead code") deleted Palm TE from machine_without_vbus_sense(), although the board is still used. Fix that.
--- drivers/usb/gadget/udc/omap_udc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/omap_udc.c +2 -1
@@ -2036,7 +2036,8 @@ static irqreturn_t omap_udc_iso_irq(intstatic inline int machine_without_vbus_sense (void ) { -return machine_is_omap_osk () ||machine_is_sx1 (); +return machine_is_omap_osk () ||machine_is_omap_palmte () || +machine_is_sx1 (); } static int omap_udc_start(struct usb_gadget *g,
Greg Kroah-Hartman
maintainerPATCH 243/334 bus: imx-weim: fix valid range check
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Stach <[email protected]>
[ Upstream commit 7bca405c986075c99b9f729d3587b5c45db39d01 ]
When the range parsing was open-coded the number of u32 entries to parse had to be a multiple of 4 and the driver checks this. With the range parsing converted to the range parser the counting changes from individual u32 entries to a complete range, so the check must not reject counts not divisible by 4.
--- drivers/bus/imx-weim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/imx-weim.c +1 -1
@@ -117,7 +117,7 @@ static int imx_weim_gpr_setup(struct platform_device *pdev) i++; } -if (i ==0 || i %4 ) +if (i ==0 ) goto err;for (i =0 ; i <ARRAY_SIZE (gprvals); i++) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 252/334 RDMA/srpt: fix function pointer cast warnings
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit eb5c7465c3240151cd42a55c7ace9da0026308a1 ]
clang-16 notices that srpt_qp_event() gets called through an incompatible pointer here:
drivers/infiniband/ulp/srpt/ib_srpt.c:1815:5: error: cast from 'void (*)(struct ib_event *, struct srpt_rdma_ch *)' to 'void (*)(struct ib_event *, void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
1815 | = (void(*)(struct ib_event *, void*))srpt_qp_event;
Change srpt_qp_event() to use the correct prototype and adjust the argument inside of it.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +5 -4
@@ -214,10 +214,12 @@ static const char *get_ch_state_name(enum rdma_ch_state s)/** * srpt_qp_event - QP event callback function * @event: Description of the event that occurred. -* @ch: SRPT RDMA channel. +* @ptr: SRPT RDMA channel. */ -static void srpt_qp_event (struct ib_event *event,struct srpt_rdma_ch *ch) +static void srpt_qp_event (struct ib_event *event,void *ptr) { +struct srpt_rdma_ch *ch = ptr; +pr_debug ("QP event %d on ch=%p sess_name=%s-%d state=%s\n" , event->event, ch, ch->sess_name, ch->qp->qp_num,get_ch_state_name (ch->state));
@@ -1811,8 +1813,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) ch->cq_size = ch->rq_size + sq_size; qp_init->qp_context = (void *)ch; - qp_init->event_handler - = (void (*)(struct ib_event *,void *))srpt_qp_event; + qp_init->event_handler = srpt_qp_event; qp_init->send_cq = ch->cq; qp_init->recv_cq = ch->cq; qp_init->sq_sig_type =IB_SIGNAL_REQ_WR ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 253/334 bpf, scripts: Correct GPL license name
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gianmarco Lusvardi <[email protected]>
[ Upstream commit e37243b65d528a8a9f8b9a57a43885f8e8dfc15c ]
The bpf_doc script refers to the GPL as the "GNU Privacy License". I strongly suspect that the author wanted to refer to the GNU General Public License, under which the Linux kernel is released, as, to the best of my knowledge, there is no license named "GNU Privacy License". This patch corrects the license name in the script accordingly.
--- scripts/bpf_doc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/bpf_doc.py +1 -1
@@ -513,7 +513,7 @@ eBPF programs can have an associated license, passed along with the bytecode instructions to the kernel when the programs are loaded. The format for that string is identical to the one in use for kernel modules (Dual licenses, such as "Dual BSD/GPL", may be used). Some helper functions are only accessible to -programs that are compatible with the GNU Privacy License (GPL). +programs that are compatible with the GNU General Public License (GNU GPL). In order to use such helpers, the eBPF program must be loaded with the correct license string passed (via **attr**) to the **bpf**\\ () system call, and this
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 254/334 scsi: ufs: Uninitialized variable in ufshcd_devfreq_target()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit f2dced9d1992824d677593072bc20eccf66ac5d5 ]
There is one goto where "sched_clk_scaling_suspend_work" is true but "scale_up" is uninitialized. It leads to a Smatch uninitialized variable warning:
drivers/ufs/core/ufshcd.c:1589 ufshcd_devfreq_target() error: uninitialized symbol 'scale_up'.
--- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +1 -1
@@ -1456,7 +1456,7 @@ static int ufshcd_devfreq_target(struct device *dev,int ret =0 ;struct ufs_hba *hba =dev_get_drvdata (dev);ktime_t start; -bool scale_up, sched_clk_scaling_suspend_work = false; +bool scale_up = false, sched_clk_scaling_suspend_work = false;struct list_head *clk_list = &hba->clk_list_head;struct ufs_clk_info *clki;unsigned long irq_flags;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 255/334 scsi: smartpqi: Fix disable_managed_interrupts
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Don Brace <[email protected]>
[ Upstream commit 5761eb9761d2d5fe8248a9b719efc4d8baf1f24a ]
Correct blk-mq registration issue with module parameter disable_managed_interrupts enabled.
When we turn off the default PCI_IRQ_AFFINITY flag, the driver needs to register with blk-mq using blk_mq_map_queues(). The driver is currently calling blk_mq_pci_map_queues() which results in a stack trace and possibly undefined behavior.
Stack Trace:
[ 7.860089] scsi host2: smartpqi [ 7.871934] WARNING: CPU: 0 PID: 238 at block/blk-mq-pci.c:52 blk_mq_pci_map_queues+0xca/0xd0 [ 7.889231] Modules linked in: sd_mod t10_pi sg uas smartpqi(+) crc32c_intel scsi_transport_sas usb_storage dm_mirror dm_region_hash dm_log dm_mod ipmi_devintf ipmi_msghandler fuse [ 7.924755] CPU: 0 PID: 238 Comm: kworker/0:3 Not tainted 4.18.0-372.88.1.el8_6_smartpqi_test.x86_64 #1 [ 7.944336] Hardware name: HPE ProLiant DL380 Gen10/ProLiant DL380 Gen10, BIOS U30 03/08/2022 [ 7.963026] Workqueue: events work_for_cpu_fn [ 7.978275] RIP: 0010:blk_mq_pci_map_queues+0xca/0xd0 [ 7.978278] Code: 48 89 de 89 c7 e8 f6 0f 4f 00 3b 05 c4 b7 8e 01 72 e1 5b 31 c0 5d 41 5c 41 5d 41 5e 41 5f e9 7d df 73 00 31 c0 e9 76 df 73 00 <0f> 0b eb bc 90 90 0f 1f 44 00 00 41 57 49 89 ff 41 56 41 55 41 54 [ 7.978280] RSP: 0018:ffffa95fc3707d50 EFLAGS: 00010216 [ 7.978283] RAX: 00000000ffffffff RBX: 0000000000000000 RCX: 0000000000000010 [ 7.978284] RDX: 0000000000000004 RSI: 0000000000000000 RDI: ffff9190c32d4310 [ 7.978286] RBP: 0000000000000000 R08: ffffa95fc3707d38 R09: ffff91929b81ac00 [ 7.978287] R10: 0000000000000001 R11: ffffa95fc3707ac0 R12: 0000000000000000 [ 7.978288] R13: ffff9190c32d4000 R14: 00000000ffffffff R15: ffff9190c4c950a8 [ 7.978290] FS: 0000000000000000(0000) GS:ffff9193efc00000(0000) knlGS:0000000000000000 [ 7.978292] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 8.172814] CR2: 000055d11166c000 CR3: 00000002dae10002 CR4: 00000000007706f0 [ 8.172816] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 8.172817] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 8.172818] PKRU: 55555554 [ 8.172819] Call Trace: [ 8.172823] blk_mq_alloc_tag_set+0x12e/0x310 [ 8.264339] scsi_add_host_with_dma.cold.9+0x30/0x245 [ 8.279302] pqi_ctrl_init+0xacf/0xc8e [smartpqi] [ 8.294085] ? pqi_pci_probe+0x480/0x4c8 [smartpqi] [ 8.309015] pqi_pci_probe+0x480/0x4c8 [smartpqi] [ 8.323286] local_pci_probe+0x42/0x80 [ 8.337855] work_for_cpu_fn+0x16/0x20 [ 8.351193] process_one_work+0x1a7/0x360 [ 8.364462] ? create_worker+0x1a0/0x1a0 [ 8.379252] worker_thread+0x1ce/0x390 [ 8.392623] ? create_worker+0x1a0/0x1a0 [ 8.406295] kthread+0x10a/0x120 [ 8.418428] ? set_kthread_struct+0x50/0x50 [ 8.431532] ret_from_fork+0x1f/0x40 [ 8.444137] ---[ end trace 1bf0173d39354506 ]---
--- drivers/scsi/smartpqi/smartpqi_init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_init.c +4 -1
@@ -6533,8 +6533,11 @@ static void pqi_map_queues(struct Scsi_Host *shost) {struct pqi_ctrl_info *ctrl_info =shost_to_hba (shost); -blk_mq_pci_map_queues (&shost->tag_set.map[HCTX_TYPE_DEFAULT ], +if (!ctrl_info->disable_managed_interrupts) +return blk_mq_pci_map_queues (&shost->tag_set.map[HCTX_TYPE_DEFAULT ], ctrl_info->pci_dev,0 ); +else +return blk_mq_map_queues (&shost->tag_set.map[HCTX_TYPE_DEFAULT ]); }static inline bool pqi_is_tape_changer_device (struct pqi_scsi_dev *device)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 256/334 scsi: jazz_esp: Only build if SCSI core is builtin
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 9ddf190a7df77b77817f955fdb9c2ae9d1c9c9a3 ]
JAZZ_ESP is a bool kconfig symbol that selects SCSI_SPI_ATTRS. When CONFIG_SCSI=m, this results in SCSI_SPI_ATTRS=m while JAZZ_ESP=y, which causes many undefined symbol linker errors.
Fix this by only offering to build this driver when CONFIG_SCSI=y.
[mkp: JAZZ_ESP is unique in that it does not support being compiled as a module unlike the remaining SPI SCSI HBA drivers]
--- drivers/scsi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/Kconfig +1 -1
@@ -1270,7 +1270,7 @@ source "drivers/scsi/arm/Kconfig" config JAZZ_ESP bool "MIPS JAZZ FAS216 SCSI support" - depends on MACH_JAZZ && SCSI + depends on MACH_JAZZ && SCSI=y select SCSI_SPI_ATTRS help This is the driver for the onboard SCSI host adapter of MIPS Magnum
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 257/334 net: bridge: switchdev: Skip MDB replays of deferred events on offload
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Waldekranz <[email protected]>
[ Upstream commit dc489f86257cab5056e747344f17a164f63bff4b ]
Before this change, generation of the list of MDB events to replay would race against the creation of new group memberships, either from the IGMP/MLD snooping logic or from user configuration.
While new memberships are immediately visible to walkers of br->mdb_list, the notification of their existence to switchdev event subscribers is deferred until a later point in time. So if a replay list was generated during a time that overlapped with such a window, it would also contain a replay of the not-yet-delivered event.
The driver would thus receive two copies of what the bridge internally considered to be one single event. On destruction of the bridge, only a single membership deletion event was therefore sent. As a consequence of this, drivers which reference count memberships (at least DSA), would be left with orphan groups in their hardware database when the bridge was destroyed.
This is only an issue when replaying additions. While deletion events may still be pending on the deferred queue, they will already have been removed from br->mdb_list, so no duplicates can be generated in that scenario.
To a user this meant that old group memberships, from a bridge in which a port was previously attached, could be reanimated (in hardware) when the port joined a new bridge, without the new bridge's knowledge.
For example, on an mv88e6xxx system, create a snooping bridge and immediately add a port to it:
root@infix-06-0b-00:~$ ip link add dev br0 up type bridge mcast_snooping 1 && \
Quoted 1 line
ip link set dev x3 up master br0
And then destroy the bridge:
root@infix-06-0b-00:~$ ip link del dev br0
root@infix-06-0b-00:~$ mvls atu
ADDRESS FID STATE Q F 0 1 2 3 4 5 6 7 8 9 a
DEV:0 Marvell 88E6393X
33:33:00:00:00:6a 1 static - - 0 . . . . . . . . . .
33:33:ff:87:e4:3f 1 static - - 0 . . . . . . . . . .
ff:ff:ff:ff:ff:ff 1 static - - 0 1 2 3 4 5 6 7 8 9 a
root@infix-06-0b-00:~$The two IPv6 groups remain in the hardware database because the port (x3) is notified of the host's membership twice: once via the original event and once via a replay. Since only a single delete notification is sent, the count remains at 1 when the bridge is destroyed.
Then add the same port (or another port belonging to the same hardware domain) to a new bridge, this time with snooping disabled:
root@infix-06-0b-00:~$ ip link add dev br1 up type bridge mcast_snooping 0 && \
Quoted 1 line
ip link set dev x3 up master br1
All multicast, including the two IPv6 groups from br0, should now be flooded, according to the policy of br1. But instead the old memberships are still active in the hardware database, causing the switch to only forward traffic to those groups towards the CPU (port 0).
Eliminate the race in two steps:
1. Grab the write-side lock of the MDB while generating the replay list.
This prevents new memberships from showing up while we are generating the replay list. But it leaves the scenario in which a deferred event was already generated, but not delivered, before we grabbed the lock. Therefore:
2. Make sure that no deferred version of a replay event is already enqueued to the switchdev deferred queue, before adding it to the replay list, when replaying additions.
--- include/net/switchdev.h | 3 ++ net/bridge/br_switchdev.c | 74 ++++++++++++++++++++++++--------------- net/switchdev/switchdev.c | 73 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 28 deletions(-)
include/net/switchdev.h +3 -0
@@ -308,6 +308,9 @@ void switchdev_deferred_process(void);int switchdev_port_attr_set (struct net_device *dev,const struct switchdev_attr *attr,struct netlink_ext_ack *extack); +bool switchdev_port_obj_act_is_deferred (struct net_device *dev, +enum switchdev_notifier_type nt, +const struct switchdev_obj *obj);int switchdev_port_obj_add (struct net_device *dev,const struct switchdev_obj *obj,struct netlink_ext_ack *extack);
net/bridge/br_switchdev.c +46 -28
118 lines not on this page · raw message
net/switchdev/switchdev.c +73 -0
85 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 258/334 net: bridge: switchdev: Ensure deferred event delivery on unoffload
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Waldekranz <[email protected]>
[ Upstream commit f7a70d650b0b6b0134ccba763d672c8439d9f09b ]
When unoffloading a device, it is important to ensure that all relevant deferred events are delivered to it before it disassociates itself from the bridge.
Before this change, this was true for the normal case when a device maps 1:1 to a net_bridge_port, i.e.
br0
/
swp0
When swp0 leaves br0, the call to switchdev_deferred_process() in del_nbp() makes sure to process any outstanding events while the device is still associated with the bridge.
In the case when the association is indirect though, i.e. when the device is attached to the bridge via an intermediate device, like a LAG...
br0
/ lag0
/
swp0
...then detaching swp0 from lag0 does not cause any net_bridge_port to be deleted, so there was no guarantee that all events had been processed before the device disassociated itself from the bridge.
Fix this by always synchronously processing all deferred events before signaling completion of unoffloading back to the driver.
--- net/bridge/br_switchdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/bridge/br_switchdev.c +10 -0
@@ -804,6 +804,16 @@ static void nbp_switchdev_unsync_objs(struct net_bridge_port *p,br_switchdev_mdb_replay (br_dev, dev, ctx, false, blocking_nb,NULL );br_switchdev_vlan_replay (br_dev, ctx, false, blocking_nb,NULL ); + +/* Make sure that the device leaving this bridge has seen all +* relevant events before it is disassociated. In the normal +* case, when the device is directly attached to the bridge, +* this is covered by del_nbp(). If the association was indirect +* however, e.g. via a team or bond, and the device is leaving +* that intermediate device, then the bridge port remains in +* place. +*/ +switchdev_deferred_process (); }/* Let the bridge know that this port is offloaded, so that it can assign a
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 259/334 dccp/tcp: Unhash sk from ehash for tb2 alloc failure after check_estalblished().
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 66b60b0c8c4a163b022a9f0ad6769b0fd3dc662f ]
syzkaller reported a warning [0] in inet_csk_destroy_sock() with no repro.
WARN_ON(inet_sk(sk)->inet_num && !inet_csk(sk)->icsk_bind_hash);
However, the syzkaller's log hinted that connect() failed just before the warning due to FAULT_INJECTION. [1]
When connect() is called for an unbound socket, we search for an available ephemeral port. If a bhash bucket exists for the port, we call __inet_check_established() or __inet6_check_established() to check if the bucket is reusable.
If reusable, we add the socket into ehash and set inet_sk(sk)->inet_num.
Later, we look up the corresponding bhash2 bucket and try to allocate it if it does not exist.
Although it rarely occurs in real use, if the allocation fails, we must revert the changes by check_established(). Otherwise, an unconnected socket could illegally occupy an ehash entry.
Note that we do not put tw back into ehash because sk might have already responded to a packet for tw and it would be better to free tw earlier under such memory presure.
[0]:
WARNING: CPU: 0 PID: 350830 at net/ipv4/inet_connection_sock.c:1193 inet_csk_destroy_sock (net/ipv4/inet_connection_sock.c:1193) Modules linked in: Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:inet_csk_destroy_sock (net/ipv4/inet_connection_sock.c:1193) Code: 41 5c 41 5d 41 5e e9 2d 4a 3d fd e8 28 4a 3d fd 48 89 ef e8 f0 cd 7d ff 5b 5d 41 5c 41 5d 41 5e e9 13 4a 3d fd e8 0e 4a 3d fd <0f> 0b e9 61 fe ff ff e8 02 4a 3d fd 4c 89 e7 be 03 00 00 00 e8 05 RSP: 0018:ffffc9000b21fd38 EFLAGS: 00010293 RAX: 0000000000000000 RBX: 0000000000009e78 RCX: ffffffff840bae40 RDX: ffff88806e46c600 RSI: ffffffff840bb012 RDI: ffff88811755cca8 RBP: ffff88811755c880 R08: 0000000000000003 R09: 0000000000000000 R10: 0000000000009e78 R11: 0000000000000000 R12: ffff88811755c8e0 R13: ffff88811755c892 R14: ffff88811755c918 R15: 0000000000000000 FS: 00007f03e5243800(0000) GS:ffff88811ae00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b32f21000 CR3: 0000000112ffe001 CR4: 0000000000770ef0 PKRU: 55555554 Call Trace: <TASK> ? inet_csk_destroy_sock (net/ipv4/inet_connection_sock.c:1193) dccp_close (net/dccp/proto.c:1078) inet_release (net/ipv4/af_inet.c:434) __sock_release (net/socket.c:660) sock_close (net/socket.c:1423) __fput (fs/file_table.c:377) __fput_sync (fs/file_table.c:462) __x64_sys_close (fs/open.c:1557 fs/open.c:1539 fs/open.c:1539) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:129) RIP: 0033:0x7f03e53852bb Code: 03 00 00 00 0f 05 48 3d 00 f0 ff ff 77 41 c3 48 83 ec 18 89 7c 24 0c e8 43 c9 f5 ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 c9 f5 ff 8b 44 RSP: 002b:00000000005dfba0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f03e53852bb RDX: 0000000000000002 RSI: 0000000000000002 RDI: 0000000000000003 RBP: 0000000000000000 R08: 0000000000000000 R09: 000000000000167c R10: 0000000008a79680 R11: 0000000000000293 R12: 00007f03e4e43000 R13: 00007f03e4e43170 R14: 00007f03e4e43178 R15: 00007f03e4e43170 </TASK>
[1]:FAULT_INJECTION: forcing a failure.
name failslab, interval 1, probability 0, space 0, times 0
CPU: 0 PID: 350833 Comm: syz-executor.1 Not tainted 6.7.0-12272-g2121c43f88f5 #9 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:107 (discriminator 1)) should_fail_ex (lib/fault-inject.c:52 lib/fault-inject.c:153) should_failslab (mm/slub.c:3748) kmem_cache_alloc (mm/slub.c:3763 mm/slub.c:3842 mm/slub.c:3867) inet_bind2_bucket_create (net/ipv4/inet_hashtables.c:135) __inet_hash_connect (net/ipv4/inet_hashtables.c:1100) dccp_v4_connect (net/dccp/ipv4.c:116) __inet_stream_connect (net/ipv4/af_inet.c:676) inet_stream_connect (net/ipv4/af_inet.c:747) __sys_connect_file (net/socket.c:2048 (discriminator 2)) __sys_connect (net/socket.c:2065) __x64_sys_connect (net/socket.c:2072) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:129) RIP: 0033:0x7f03e5284e5d Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 73 9f 1b 00 f7 d8 64 89 01 48 RSP: 002b:00007f03e4641cc8 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: ffffffffffffffda RBX: 00000000004bbf80 RCX: 00007f03e5284e5d RDX: 0000000000000010 RSI: 0000000020000000 RDI: 0000000000000003 RBP: 00000000004bbf80 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 R13: 000000000000000b R14: 00007f03e52e5530 R15: 0000000000000000 </TASK>
--- net/ipv4/inet_hashtables.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
net/ipv4/inet_hashtables.c +24 -1
@@ -1131,10 +1131,33 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,return 0 ; error: +if (sk_hashed (sk)) { +spinlock_t *lock =inet_ehash_lockp (hinfo, sk->sk_hash); + +sock_prot_inuse_add (net, sk->sk_prot,-1 ); + +spin_lock (lock); +sk_nulls_del_node_init_rcu (sk); +spin_unlock (lock); + + sk->sk_hash =0 ; +inet_sk (sk)->inet_sport =0 ; +inet_sk (sk)->inet_num =0 ; + +if (tw) +inet_twsk_bind_unhash (tw, hinfo); + } +spin_unlock (&head2->lock);if (tb_created)inet_bind_bucket_destroy (hinfo->bind_bucket_cachep, tb); -spin_unlock_bh (&head->lock); +spin_unlock (&head->lock); + +if (tw) +inet_twsk_deschedule_put (tw); + +local_bh_enable (); +return -ENOMEM ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 260/334 net: ethernet: adi: requires PHYLIB support
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit a9f80df4f51440303d063b55bb98720857693821 ]
This driver uses functions that are supplied by the Kconfig symbol PHYLIB, so select it to ensure that they are built as needed.
When CONFIG_ADIN1110=y and CONFIG_PHYLIB=m, there are multiple build (linker) errors that are resolved by this Kconfig change:
ld: drivers/net/ethernet/adi/adin1110.o: in function `adin1110_net_open':
drivers/net/ethernet/adi/adin1110.c:933: undefined reference to `phy_start'
ld: drivers/net/ethernet/adi/adin1110.o: in function `adin1110_probe_netdevs':
drivers/net/ethernet/adi/adin1110.c:1603: undefined reference to `get_phy_device'
ld: drivers/net/ethernet/adi/adin1110.c:1609: undefined reference to `phy_connect'
ld: drivers/net/ethernet/adi/adin1110.o: in function `adin1110_disconnect_phy':
drivers/net/ethernet/adi/adin1110.c:1226: undefined reference to `phy_disconnect'
ld: drivers/net/ethernet/adi/adin1110.o: in function `devm_mdiobus_alloc':
include/linux/phy.h:455: undefined reference to `devm_mdiobus_alloc_size'
ld: drivers/net/ethernet/adi/adin1110.o: in function `adin1110_register_mdiobus':
drivers/net/ethernet/adi/adin1110.c:529: undefined reference to `__devm_mdiobus_register'
ld: drivers/net/ethernet/adi/adin1110.o: in function `adin1110_net_stop':
drivers/net/ethernet/adi/adin1110.c:958: undefined reference to `phy_stop'
ld: drivers/net/ethernet/adi/adin1110.o: in function `adin1110_disconnect_phy':
drivers/net/ethernet/adi/adin1110.c:1226: undefined reference to `phy_disconnect'
ld: drivers/net/ethernet/adi/adin1110.o: in function `adin1110_adjust_link':
drivers/net/ethernet/adi/adin1110.c:1077: undefined reference to `phy_print_status'
ld: drivers/net/ethernet/adi/adin1110.o: in function `adin1110_ioctl':
drivers/net/ethernet/adi/adin1110.c:790: undefined reference to `phy_do_ioctl'
ld: drivers/net/ethernet/adi/adin1110.o:(.rodata+0xf60): undefined reference to `phy_ethtool_get_link_ksettings'
ld: drivers/net/ethernet/adi/adin1110.o:(.rodata+0xf68): undefined reference to `phy_ethtool_set_link_ksettings'
--- drivers/net/ethernet/adi/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/adi/Kconfig +1 -0
@@ -7,6 +7,7 @@ config NET_VENDOR_ADI bool "Analog Devices devices" default y depends on SPI + select PHYLIB help If you have a network (Ethernet) card belonging to this class, say Y.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 261/334 net/sched: act_mirred: Create function tcf_mirred_to_dev and improve readability
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 16085e48cb48aeb50a1178dc276747749910b0f2 ]
As a preparation for adding block ID to mirred, separate the part of mirred that redirect/mirrors to a dev into a specific function so that it can be called by blockcast for each dev.
Also improve readability. Eg. rename use_reinsert to dont_clone and skb2 to skb_to_send.
Stable-dep-of: 52f671db1882 ("net/sched: act_mirred: use the backlog for mirred ingress")
--- net/sched/act_mirred.c | 129 +++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 57 deletions(-)
net/sched/act_mirred.c +72 -57
@@ -225,48 +225,26 @@ static int tcf_mirred_forward(bool want_ingress, struct sk_buff *skb)return err; } -TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb, -const struct tc_action *a, -struct tcf_result *res) +static int tcf_mirred_to_dev (struct sk_buff *skb,struct tcf_mirred *m, +struct net_device *dev, +const bool m_mac_header_xmit,int m_eaction, +int retval) { -struct tcf_mirred *m =to_mirred (a); -struct sk_buff *skb2 = skb; -bool m_mac_header_xmit; -struct net_device *dev; -unsigned int nest_level; -int retval, err =0 ; -bool use_reinsert; +struct sk_buff *skb_to_send = skb;bool want_ingress;bool is_redirect;bool expects_nh;bool at_ingress; -int m_eaction; +bool dont_clone;int mac_len;bool at_nh; +int err; - nest_level =__this_cpu_inc_return (mirred_nest_level); -if (unlikely (nest_level >MIRRED_NEST_LIMIT )) { -net_warn_ratelimited ("Packet exceeded mirred recursion limit on dev %s\n" , -netdev_name (skb->dev)); -__this_cpu_dec (mirred_nest_level); -return TC_ACT_SHOT ; - } - -tcf_lastuse_update (&m->tcf_tm); -tcf_action_update_bstats (&m->common, skb); - - m_mac_header_xmit =READ_ONCE (m->tcfm_mac_header_xmit); - m_eaction =READ_ONCE (m->tcfm_eaction); - retval =READ_ONCE (m->tcf_action); - dev =rcu_dereference_bh (m->tcfm_dev); -if (unlikely (!dev)) { -pr_notice_once ("tc mirred: target device is gone\n" ); - goto out; - } - + is_redirect =tcf_mirred_is_act_redirect (m_eaction);if (unlikely (!(dev->flags &IFF_UP )) || !netif_carrier_ok (dev)) {net_notice_ratelimited ("tc mirred to Houston: device %s is down\n" , dev->name); + err = -ENODEV ; goto out; }
@@ -274,61 +252,98 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,* since we can't easily detect the clsact caller, skip clone only for * ingress - that covers the TC S/W datapath. */ - is_redirect =tcf_mirred_is_act_redirect (m_eaction); at_ingress =skb_at_tc_ingress (skb); - use_reinsert = at_ingress && is_redirect && -tcf_mirred_can_reinsert (retval); -if (!use_reinsert) { - skb2 =skb_clone (skb,GFP_ATOMIC ); -if (!skb2) + dont_clone =skb_at_tc_ingress (skb) && is_redirect && +tcf_mirred_can_reinsert (retval); +if (!dont_clone) { + skb_to_send =skb_clone (skb,GFP_ATOMIC ); +if (!skb_to_send) { + err = -ENOMEM ; goto out; + } } want_ingress =tcf_mirred_act_wants_ingress (m_eaction);/* All mirred/redirected skbs should clear previous ct info */ -nf_reset_ct (skb2); +nf_reset_ct (skb_to_send);if (want_ingress && !at_ingress)/* drop dst for egress -> ingress */ -skb_dst_drop (skb2); +skb_dst_drop (skb_to_send); expects_nh = want_ingress || !m_mac_header_xmit; at_nh = skb->data ==skb_network_header (skb);if (at_nh != expects_nh) { - mac_len =skb_at_tc_ingress (skb) ? skb->mac_len : + mac_len = at_ingress ? skb->mac_len :skb_network_offset (skb);if (expects_nh) {/* target device/action expect data at nh */ -skb_pull_rcsum (skb2, mac_len); +skb_pull_rcsum (skb_to_send, mac_len); }else {/* target device/action expect data at mac */ -skb_push_rcsum (skb2, mac_len); +skb_push_rcsum (skb_to_send, mac_len); } } - skb2->skb_iif = skb->dev->ifindex; - skb2->dev = dev; + skb_to_send->skb_iif = skb->dev->ifindex; + skb_to_send->dev = dev; -/* mirror is always swallowed */ if (is_redirect) { -skb_set_redirected (skb2, skb2->tc_at_ingress); - -/* let's the caller reinsert the packet, if possible */ -if (use_reinsert) { - err =tcf_mirred_forward (want_ingress, skb); -if (err) -tcf_action_inc_overlimit_qstats (&m->common); -__this_cpu_dec (mirred_nest_level); -return TC_ACT_CONSUMED ; - } +if (skb == skb_to_send) + retval =TC_ACT_CONSUMED ; + +skb_set_redirected (skb_to_send, skb_to_send->tc_at_ingress); + + err =tcf_mirred_forward (want_ingress, skb_to_send); + }else { + err =tcf_mirred_forward (want_ingress, skb_to_send); } - err =tcf_mirred_forward (want_ingress, skb2);if (err) { out:tcf_action_inc_overlimit_qstats (&m->common); -if (tcf_mirred_is_act_redirect (m_eaction)) +if (is_redirect) retval =TC_ACT_SHOT ; } + +return retval; +} + +TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb, +const struct tc_action *a, +struct tcf_result *res) +{ +struct tcf_mirred *m =to_mirred (a); +int retval =READ_ONCE (m->tcf_action); +unsigned int nest_level; +bool m_mac_header_xmit; +struct net_device *dev; +int m_eaction; + + nest_level =__this_cpu_inc_return (mirred_nest_level); +if (unlikely (nest_level >MIRRED_NEST_LIMIT )) { +net_warn_ratelimited ("Packet exceeded mirred recursion limit on dev %s\n" , +netdev_name (skb->dev)); + retval =TC_ACT_SHOT ; + goto dec_nest_level; + } + +tcf_lastuse_update (&m->tcf_tm); +tcf_action_update_bstats (&m->common, skb); + + dev =rcu_dereference_bh (m->tcfm_dev); +if (unlikely (!dev)) { +pr_notice_once ("tc mirred: target device is gone\n" ); +tcf_action_inc_overlimit_qstats (&m->common); + goto dec_nest_level; + } + + m_mac_header_xmit =READ_ONCE (m->tcfm_mac_header_xmit); + m_eaction =READ_ONCE (m->tcfm_eaction); + + retval =tcf_mirred_to_dev (skb, m, dev, m_mac_header_xmit, m_eaction, + retval); + +dec_nest_level:__this_cpu_dec (mirred_nest_level);return retval;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 244/334 iommufd/iova_bitmap: Bounds check mapped::pages access
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joao Martins <[email protected]>
[ Upstream commit a4ab7dedaee0e39b15653c5fd0367e420739f7ef ]
Dirty IOMMU hugepages reported on a base page page-size granularity can lead to an attempt to set dirty pages in the bitmap beyond the limits that are pinned.
Bounds check the page index of the array we are trying to access is within the limits before we kmap() and return otherwise.
While it is also a defensive check, this is also in preparation to defer setting bits (outside the mapped range) to the next iteration(s) when the pages become available.
--- drivers/iommu/iommufd/iova_bitmap.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iommu/iommufd/iova_bitmap.c +4 -0
@@ -409,6 +409,7 @@ void iova_bitmap_set(struct iova_bitmap *bitmap, mapped->pgshift) + mapped->pgoff * BITS_PER_BYTE;unsigned long last_bit = (((iova + length -1 ) - mapped->iova) >> mapped->pgshift) + mapped->pgoff *BITS_PER_BYTE ; +unsigned long last_page_idx = mapped->npages -1 ; do { unsigned int page_idx = cur_bit / BITS_PER_PAGE;
@@ -417,6 +418,9 @@ void iova_bitmap_set(struct iova_bitmap *bitmap, last_bit - cur_bit + 1);void *kaddr; +if (unlikely (page_idx > last_page_idx)) +break ; + kaddr =kmap_local_page (mapped->pages[page_idx]);bitmap_set (kaddr, offset, nbits);kunmap_local (kaddr);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 262/334 net/sched: act_mirred: use the backlog for mirred ingress
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 52f671db18823089a02f07efc04efdb2272ddc17 ]
The test Davide added in commit ca22da2fbd69 ("act_mirred: use the backlog for nested calls to mirred ingress") hangs our testing VMs every 10 or so runs, with the familiar tcp_v4_rcv -> tcp_v4_rcv deadlock reported by lockdep.
The problem as previously described by Davide (see Link) is that if we reverse flow of traffic with the redirect (egress -> ingress) we may reach the same socket which generated the packet. And we may still be holding its socket lock. The common solution to such deadlocks is to put the packet in the Rx backlog, rather than run the Rx path inline. Do that for all egress -> ingress reversals, not just once we started to nest mirred calls.
In the past there was a concern that the backlog indirection will lead to loss of error reporting / less accurate stats. But the current workaround does not seem to address the issue.
--- net/sched/act_mirred.c | 14 +++++--------- .../testing/selftests/net/forwarding/tc_actions.sh | 3 --- 2 files changed, 5 insertions(+), 12 deletions(-)
net/sched/act_mirred.c +5 -9
@@ -206,18 +206,14 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,return err; } -static bool is_mirred_nested (void ) -{ -return unlikely (__this_cpu_read (mirred_nest_level) >1 ); -} - -static int tcf_mirred_forward (bool want_ingress,struct sk_buff *skb) +static int +tcf_mirred_forward (bool at_ingress,bool want_ingress,struct sk_buff *skb) {int err;if (!want_ingress) err =tcf_dev_queue_xmit (skb, dev_queue_xmit); -else if (is_mirred_nested ()) +else if (!at_ingress) err =netif_rx (skb);else err =netif_receive_skb (skb);
@@ -293,9 +289,9 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m,skb_set_redirected (skb_to_send, skb_to_send->tc_at_ingress); - err =tcf_mirred_forward (want_ingress, skb_to_send); + err =tcf_mirred_forward (at_ingress, want_ingress, skb_to_send); }else { - err =tcf_mirred_forward (want_ingress, skb_to_send); + err =tcf_mirred_forward (at_ingress, want_ingress, skb_to_send); }if (err) {
tools/testing/selftests/net/forwarding/tc_actions.sh +0 -3
@@ -235,9 +235,6 @@ mirred_egress_to_ingress_tcp_test() check_err $? "didn't mirred redirect ICMP" tc_check_packets "dev $h1 ingress" 102 10 check_err $? "didn't drop mirred ICMP" - local overlimits=$(tc_rule_stats_get ${h1} 101 egress .overlimits) - test ${overlimits} = 10 - check_err $? "wrong overlimits, expected 10 got ${overlimits}" tc filter del dev $h1 egress protocol ip pref 100 handle 100 flower tc filter del dev $h1 egress protocol ip pref 101 handle 101 flower
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 263/334 net/sched: act_mirred: dont override retval if we already lost the skb
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 166c2c8a6a4dc2e4ceba9e10cfe81c3e469e3210 ]
If we're redirecting the skb, and haven't called tcf_mirred_forward(), yet, we need to tell the core to drop the skb by setting the retcode to SHOT. If we have called tcf_mirred_forward(), however, the skb is out of our hands and returning SHOT will lead to UaF.
Move the retval override to the error path which actually need it.
--- net/sched/act_mirred.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
net/sched/act_mirred.c +10 -12
@@ -240,8 +240,7 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m,if (unlikely (!(dev->flags &IFF_UP )) || !netif_carrier_ok (dev)) {net_notice_ratelimited ("tc mirred to Houston: device %s is down\n" , dev->name); - err = -ENODEV ; - goto out; + goto err_cant_do; }/* we could easily avoid the clone only if called by ingress and clsact;
@@ -253,10 +252,8 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m,tcf_mirred_can_reinsert (retval);if (!dont_clone) { skb_to_send =skb_clone (skb,GFP_ATOMIC ); -if (!skb_to_send) { - err = -ENOMEM ; - goto out; - } +if (!skb_to_send) + goto err_cant_do; } want_ingress =tcf_mirred_act_wants_ingress (m_eaction);
@@ -293,15 +290,16 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m, }else { err =tcf_mirred_forward (at_ingress, want_ingress, skb_to_send); } - -if (err) { -out: +if (err)tcf_action_inc_overlimit_qstats (&m->common); -if (is_redirect) - retval =TC_ACT_SHOT ; - }return retval; + +err_cant_do: +if (is_redirect) + retval =TC_ACT_SHOT ; +tcf_action_inc_overlimit_qstats (&m->common); +return retval; } TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 264/334 nouveau: fix function cast warnings
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 0affdba22aca5573f9d989bcb1d71d32a6a03efe ]
clang-16 warns about casting between incompatible function types:
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c:161:10: error: cast from 'void (*)(const struct firmware *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
161 | .fini = (void(*)(void *))release_firmware,
This one was done to use the generic shadow_fw_release() function as a callback for struct nvbios_source. Change it to use the same prototype as the other five instances, with a trivial helper function that actually calls release_firmware.
--- drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c +7 -1
@@ -154,11 +154,17 @@ shadow_fw_init(struct nvkm_bios *bios, const char *name)return (void *)fw; } +static void +shadow_fw_release (void *fw) +{ +release_firmware (fw); +} +static const struct nvbios_source shadow_fw = { .name ="firmware" , .init = shadow_fw_init, - .fini = (void (*)(void *))release_firmware, + .fini = shadow_fw_release, .read = shadow_fw_read, .rw = false, };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 265/334 drm/nouveau/mmu/r535: uninitialized variable in r535_bar_new_()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 65323796debe49a1922ba507020f7530a4b3f9af ]
If gf100_bar_new_() fails then "bar" is not initialized.
--- drivers/gpu/drm/nouveau/nvkm/subdev/bar/r535.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bar/r535.c +2 -3
@@ -168,12 +168,11 @@ r535_bar_new_(const struct nvkm_bar_func *hw, struct nvkm_device *device, rm->flush = r535_bar_flush; ret =gf100_bar_new_ (rm, device, type, inst, &bar); - *pbar = bar;if (ret) { -if (!bar) -kfree (rm); +kfree (rm);return ret; } + *pbar = bar; bar->flushBAR2PhysMode =ioremap (device->func->resource_addr (device,3 ),PAGE_SIZE );if (!bar->flushBAR2PhysMode)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 266/334 x86/numa: Fix the address overlap check in numa_fill_memblks()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 9b99c17f7510bed2adbe17751fb8abddba5620bc ]
numa_fill_memblks() fills in the gaps in numa_meminfo memblks over a physical address range. To do so, it first creates a list of existing memblks that overlap that address range. The issue is that it is off by one when comparing to the end of the address range, so memblks that do not overlap are selected.
The impact of selecting a memblk that does not actually overlap is that an existing memblk may be filled when the expected action is to do nothing and return NUMA_NO_MEMBLK to the caller. The caller can then add a new NUMA node and memblk.
Replace the broken open-coded search for address overlap with the memblock helper memblock_addrs_overlap(). Update the kernel doc and in code comments.
Suggested by: "Huang, Ying" <[email protected]>
--- arch/x86/mm/numa.c | 19 +++++++------------ include/linux/memblock.h | 2 ++ mm/memblock.c | 5 +++-- 3 files changed, 12 insertions(+), 14 deletions(-)
arch/x86/mm/numa.c +7 -12
@@ -974,14 +974,12 @@ static struct numa_memblk *numa_memblk_list[NR_NODE_MEMBLKS] __initdata;* @start: address to begin fill * @end: address to end fill * -* Find and extend numa_meminfo memblks to cover the @start-@end -* physical address range, such that the first memblk includes -* @start, the last memblk includes @end, and any gaps in between -* are filled. +* Find and extend numa_meminfo memblks to cover the physical +* address range @start-@end * * RETURNS: * 0 : Success -* NUMA_NO_MEMBLK : No memblk exists in @start-@end range +* NUMA_NO_MEMBLK : No memblks exist in address range @start-@end */ int __init numa_fill_memblks (u64 start,u64 end)
@@ -993,17 +991,14 @@ int __init numa_fill_memblks(u64 start, u64 end)/* * Create a list of pointers to numa_meminfo memblks that -* overlap start, end. Exclude (start == bi->end) since -* end addresses in both a CFMWS range and a memblk range -* are exclusive. -* -* This list of pointers is used to make in-place changes -* that fill out the numa_meminfo memblks. +* overlap start, end. The list is used to make in-place +* changes that fill out the numa_meminfo memblks. */ for (int i =0 ; i < mi->nr_blks; i++) {struct numa_memblk *bi = &mi->blk[i]; -if (start < bi->end && end >= bi->start) { +if (memblock_addrs_overlap (start, end - start, bi->start, + bi->end - bi->start)) { blk[count] = &mi->blk[i]; count++; }
include/linux/memblock.h +2 -0
@@ -121,6 +121,8 @@ int memblock_reserve(phys_addr_t base, phys_addr_t size);int memblock_physmem_add (phys_addr_t base,phys_addr_t size);#endif void memblock_trim_memory (phys_addr_t align); +unsigned long memblock_addrs_overlap (phys_addr_t base1,phys_addr_t size1, +phys_addr_t base2,phys_addr_t size2);bool memblock_overlaps_region (struct memblock_type *type,phys_addr_t base,phys_addr_t size);int memblock_mark_hotplug (phys_addr_t base,phys_addr_t size);
mm/memblock.c +3 -2
@@ -180,8 +180,9 @@ static inline phys_addr_t memblock_cap_size(phys_addr_t base, phys_addr_t *size)/* * Address comparison utilities */ -static unsigned long __init_memblock memblock_addrs_overlap (phys_addr_t base1,phys_addr_t size1, -phys_addr_t base2,phys_addr_t size2) +unsigned long __init_memblock +memblock_addrs_overlap (phys_addr_t base1,phys_addr_t size1,phys_addr_t base2, +phys_addr_t size2) {return ((base1 < (base2 + size2)) && (base2 < (base1 + size1))); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 267/334 x86/numa: Fix the sort compare func used in numa_fill_memblks()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit b626070ffc14acca5b87a2aa5f581db98617584c ]
The compare function used to sort memblks into starting address order fails when the result of its u64 address subtraction gets truncated to an int upon return.
The impact of the bad sort is that memblks will be filled out incorrectly. Depending on the set of memblks, a user may see no errors at all but still have a bad fill, or see messages reporting a node overlap that leads to numa init failure:
[] node 0 [mem: ] overlaps with node 1 [mem: ]
[] No NUMA configuration found
Replace with a comparison that can only result in: 1, 0, -1.
--- arch/x86/mm/numa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/numa.c +1 -1
@@ -964,7 +964,7 @@ static int __init cmp_memblk(const void *a, const void *b)const struct numa_memblk *ma = *(const struct numa_memblk **)a;const struct numa_memblk *mb = *(const struct numa_memblk **)b; -return ma->start - mb->start; +return (ma->start > mb->start) - (ma->start < mb->start); }static struct numa_memblk *numa_memblk_list[NR_NODE_MEMBLKS ]__initdata ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 268/334 net: stmmac: Fix incorrect dereference in interrupt handlers
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Sakharov <[email protected]>
[ Upstream commit 97dde84026339e4b4af9a6301f825d1828d7874b ]
If 'dev' or 'data' is NULL, the 'priv' variable has an incorrect address when dereferencing calling netdev_err().
Since we get as 'dev_id' or 'data' what was passed as the 'dev' argument to request_irq() during interrupt initialization (that is, the net_device and rx/tx queue pointers initialized at the time of the call) and since there are usually no checks for the 'dev_id' argument in such handlers in other drivers, remove these checks from the handlers in stmmac driver.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 ------------------- 1 file changed, 20 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -20
@@ -5977,11 +5977,6 @@ static irqreturn_t stmmac_mac_interrupt(int irq, void *dev_id)struct net_device *dev = (struct net_device *)dev_id;struct stmmac_priv *priv =netdev_priv (dev); -if (unlikely (!dev)) { -netdev_err (priv->dev,"%s: invalid dev pointer\n" , __func__); -return IRQ_NONE ; - } -/* Check if adapter is up */ if (test_bit (STMMAC_DOWN , &priv->state))return IRQ_HANDLED ;
@@ -5997,11 +5992,6 @@ static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id)struct net_device *dev = (struct net_device *)dev_id;struct stmmac_priv *priv =netdev_priv (dev); -if (unlikely (!dev)) { -netdev_err (priv->dev,"%s: invalid dev pointer\n" , __func__); -return IRQ_NONE ; - } -/* Check if adapter is up */ if (test_bit (STMMAC_DOWN , &priv->state))return IRQ_HANDLED ;
@@ -6023,11 +6013,6 @@ static irqreturn_t stmmac_msi_intr_tx(int irq, void *data) dma_conf = container_of(tx_q, struct stmmac_dma_conf, tx_queue[chan]); priv = container_of(dma_conf, struct stmmac_priv, dma_conf); -if (unlikely (!data)) { -netdev_err (priv->dev,"%s: invalid dev pointer\n" , __func__); -return IRQ_NONE ; - } -/* Check if adapter is up */ if (test_bit (STMMAC_DOWN , &priv->state))return IRQ_HANDLED ;
@@ -6054,11 +6039,6 @@ static irqreturn_t stmmac_msi_intr_rx(int irq, void *data) dma_conf = container_of(rx_q, struct stmmac_dma_conf, rx_queue[chan]); priv = container_of(dma_conf, struct stmmac_priv, dma_conf); -if (unlikely (!data)) { -netdev_err (priv->dev,"%s: invalid dev pointer\n" , __func__); -return IRQ_NONE ; - } -/* Check if adapter is up */ if (test_bit (STMMAC_DOWN , &priv->state))return IRQ_HANDLED ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 269/334 ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 081a0e3b0d4c061419d3f4679dec9f68725b17e4 ]
net->dev_base_seq and ipv4.dev_addr_genid are monotonically increasing.
If we XOR their values, we could miss to detect if both values were changed with the same amount.
--- net/ipv4/devinet.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
net/ipv4/devinet.c +17 -4
@@ -1825,6 +1825,21 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb,return err; } +/* Combine dev_addr_genid and dev_base_seq to detect changes. +*/ +static u32 inet_base_seq (const struct net *net) +{ +u32 res =atomic_read (&net->ipv4.dev_addr_genid) + + net->dev_base_seq; + +/* Must not return 0 (see nl_dump_check_consistent()). +* Chose a value far away from 0. +*/ +if (!res) + res =0x80000000 ; +return res; +} +static int inet_dump_ifaddr (struct sk_buff *skb,struct netlink_callback *cb) {const struct nlmsghdr *nlh = cb->nlh;
@@ -1876,8 +1891,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) idx =0 ; head = &tgt_net->dev_index_head[h];rcu_read_lock (); - cb->seq =atomic_read (&tgt_net->ipv4.dev_addr_genid) ^ - tgt_net->dev_base_seq; + cb->seq =inet_base_seq (tgt_net);hlist_for_each_entry_rcu (dev, head, index_hlist) {if (idx < s_idx) goto cont;
@@ -2278,8 +2292,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb, idx =0 ; head = &net->dev_index_head[h];rcu_read_lock (); - cb->seq =atomic_read (&net->ipv4.dev_addr_genid) ^ - net->dev_base_seq; + cb->seq =inet_base_seq (net);hlist_for_each_entry_rcu (dev, head, index_hlist) {if (idx < s_idx) goto cont;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 270/334 ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit e898e4cd1aab271ca414f9ac6e08e4c761f6913c ]
net->dev_base_seq and ipv6.dev_addr_genid are monotonically increasing.
If we XOR their values, we could miss to detect if both values were changed with the same amount.
--- net/ipv6/addrconf.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +18 -3
@@ -708,6 +708,22 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,return err; } +/* Combine dev_addr_genid and dev_base_seq to detect changes. +*/ +static u32 inet6_base_seq (const struct net *net) +{ +u32 res =atomic_read (&net->ipv6.dev_addr_genid) + + net->dev_base_seq; + +/* Must not return 0 (see nl_dump_check_consistent()). +* Chose a value far away from 0. +*/ +if (!res) + res =0x80000000 ; +return res; +} + +static int inet6_netconf_dump_devconf (struct sk_buff *skb,struct netlink_callback *cb) {
@@ -741,8 +757,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb, idx =0 ; head = &net->dev_index_head[h];rcu_read_lock (); - cb->seq =atomic_read (&net->ipv6.dev_addr_genid) ^ - net->dev_base_seq; + cb->seq =inet6_base_seq (net);hlist_for_each_entry_rcu (dev, head, index_hlist) {if (idx < s_idx) goto cont;
@@ -5362,7 +5377,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, }rcu_read_lock (); - cb->seq =atomic_read (&tgt_net->ipv6.dev_addr_genid) ^ tgt_net->dev_base_seq; + cb->seq =inet6_base_seq (tgt_net);for (h = s_h; h <NETDEV_HASHENTRIES ; h++, s_idx =0 ) { idx =0 ; head = &tgt_net->dev_index_head[h];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 271/334 net: bcmasp: Indicate MAC is in charge of PHY PM
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 5b76d928f8b779a1b19c5842e7cabee4cbb610c3 ]
Avoid the PHY library call unnecessarily into the suspend/resume functions by setting phydev->mac_managed_pm to true. The ASP driver essentially does exactly what mdio_bus_phy_resume() does.
--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +3 -0
@@ -1048,6 +1048,9 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect)netdev_err (dev,"could not attach to PHY\n" ); goto err_phy_disable; } + +/* Indicate that the MAC is responsible for PHY PM */ + phydev->mac_managed_pm = true; }else if (!intf->wolopts) { ret =phy_resume (dev->phydev);if (ret)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 245/334 iommufd/iova_bitmap: Switch iova_bitmap::bitmap to an u8 array
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joao Martins <[email protected]>
[ Upstream commit d18411ec305728c6371806c4fb09be07016aad0b ]
iova_bitmap_mapped_length() don't deal correctly with the small bitmaps (< 2M bitmaps) when the starting address isn't u64 aligned, leading to skipping a tiny part of the IOVA range. This is materialized as not marking data dirty that should otherwise have been.
Fix that by using a u8 * in the internal state of IOVA bitmap. Most of the data structures use the type of the bitmap to adjust its indexes, thus changing the type of the bitmap decreases the granularity of the bitmap indexes.
--- drivers/iommu/iommufd/iova_bitmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iommu/iommufd/iova_bitmap.c +4 -4
@@ -100,7 +100,7 @@ struct iova_bitmap {struct iova_bitmap_map mapped;/* userspace address of the bitmap */ -u64 __user *bitmap; +u8 __user *bitmap;/* u64 index that @mapped points to */ unsigned long mapped_base_index;
@@ -162,7 +162,7 @@ static int iova_bitmap_get(struct iova_bitmap *bitmap) {struct iova_bitmap_map *mapped = &bitmap->mapped;unsigned long npages; -u64 __user *addr; +u8 __user *addr;long ret;/*
@@ -247,7 +247,7 @@ struct iova_bitmap *iova_bitmap_alloc(unsigned long iova, size_t length, mapped = &bitmap->mapped; mapped->pgshift =__ffs (page_size); - bitmap->bitmap = data; + bitmap->bitmap = (u8 __user *)data; bitmap->mapped_total_index =iova_bitmap_offset_to_index (bitmap, length -1 ) +1 ; bitmap->iova = iova;
@@ -304,7 +304,7 @@ static unsigned long iova_bitmap_mapped_remaining(struct iova_bitmap *bitmap) remaining = bitmap->mapped_total_index - bitmap->mapped_base_index; remaining = min_t(unsigned long, remaining, - bytes /sizeof (*bitmap->bitmap)); +DIV_ROUND_UP (bytes,sizeof (*bitmap->bitmap)));return remaining; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 272/334 net: bcmasp: Sanity check is off by one
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Chen <[email protected]>
[ Upstream commit f120e62e37f0af4c4cbe08e5a88ea60a6a17c858 ]
A sanity check for OOB write is off by one leading to a false positive when the array is full.
--- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/asp2/bcmasp.c +3 -3
@@ -535,9 +535,6 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,int j =0 , i;for (i =0 ; i <NUM_NET_FILTERS ; i++) { -if (j == *rule_cnt) -return -EMSGSIZE ; -if (!priv->net_filters[i].claimed || priv->net_filters[i].port != intf->port)continue ;
@@ -547,6 +544,9 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs, priv->net_filters[i - 1].wake_filter)continue ; +if (j == *rule_cnt) +return -EMSGSIZE ; + rule_locs[j++] = priv->net_filters[i].fs.location; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 246/334 iommufd/iova_bitmap: Handle recording beyond the mapped pages
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joao Martins <[email protected]>
[ Upstream commit 2780025e01e2e1c92f83ee7da91d9727c2e58a3e ]
IOVA bitmap is a zero-copy scheme of recording dirty bits that iterate the different bitmap user pages at chunks of a maximum of PAGE_SIZE/sizeof(struct page*) pages.
When the iterations are split up into 64G, the end of the range may be broken up in a way that's aligned with a non base page PTE size. This leads to only part of the huge page being recorded in the bitmap. Note that in pratice this is only a problem for IOMMU dirty tracking i.e. when the backing PTEs are in IOMMU hugepages and the bitmap is in base page granularity. So far this not something that affects VF dirty trackers (which reports and records at the same granularity).
To fix that, if there is a remainder of bits left to set in which the current IOVA bitmap doesn't cover, make a copy of the bitmap structure and iterate-and-set the rest of the bits remaining. Finally, when advancing the iterator, skip all the bits that were set ahead.
--- drivers/iommu/iommufd/iova_bitmap.c | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
drivers/iommu/iommufd/iova_bitmap.c +43 -0
@@ -113,6 +113,9 @@ struct iova_bitmap {/* length of the IOVA range for the whole bitmap */ size_t length; + +/* length of the IOVA range set ahead the pinned pages */ +unsigned long set_ahead_length; };/*
@@ -341,6 +344,32 @@ static bool iova_bitmap_done(struct iova_bitmap *bitmap)return bitmap->mapped_base_index >= bitmap->mapped_total_index; } +static int iova_bitmap_set_ahead (struct iova_bitmap *bitmap, +size_t set_ahead_length) +{ +int ret =0 ; + +while (set_ahead_length >0 && !iova_bitmap_done (bitmap)) { +unsigned long length =iova_bitmap_mapped_length (bitmap); +unsigned long iova =iova_bitmap_mapped_iova (bitmap); + + ret =iova_bitmap_get (bitmap); +if (ret) +break ; + + length =min (length, set_ahead_length); +iova_bitmap_set (bitmap, iova, length); + + set_ahead_length -= length; + bitmap->mapped_base_index += +iova_bitmap_offset_to_index (bitmap, length -1 ) +1 ; +iova_bitmap_put (bitmap); + } + + bitmap->set_ahead_length =0 ; +return ret; +} +/* * Advances to the next range, releases the current pinned * pages and pins the next set of bitmap pages.
@@ -357,6 +386,15 @@ static int iova_bitmap_advance(struct iova_bitmap *bitmap)if (iova_bitmap_done (bitmap))return 0 ; +/* Iterate, set and skip any bits requested for next iteration */ +if (bitmap->set_ahead_length) { +int ret; + + ret =iova_bitmap_set_ahead (bitmap, bitmap->set_ahead_length); +if (ret) +return ret; + } +/* When advancing the index we pin the next set of bitmap pages */ return iova_bitmap_get (bitmap); }
@@ -426,5 +464,10 @@ void iova_bitmap_set(struct iova_bitmap *bitmap,kunmap_local (kaddr); cur_bit += nbits; }while (cur_bit <= last_bit); + +if (unlikely (cur_bit <= last_bit)) { + bitmap->set_ahead_length = + ((last_bit - cur_bit +1 ) << bitmap->mapped.pgshift); + } }EXPORT_SYMBOL_NS_GPL (iova_bitmap_set,IOMMUFD );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 247/334 iommufd/iova_bitmap: Consider page offset for the pages to be pinned
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joao Martins <[email protected]>
[ Upstream commit 4bbcbc6ea2fa379632a24c14cfb47aa603816ac6 ]
For small bitmaps that aren't PAGE_SIZE aligned *and* that are less than 512 pages in bitmap length, use an extra page to be able to cover the entire range e.g. [1M..3G] which would be iterated more efficiently in a single iteration, rather than two.
--- drivers/iommu/iommufd/iova_bitmap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/iommu/iommufd/iova_bitmap.c +7 -6
@@ -178,18 +178,19 @@ static int iova_bitmap_get(struct iova_bitmap *bitmap) bitmap->mapped_base_index) * sizeof(*bitmap->bitmap), PAGE_SIZE); -/* -* We always cap at max number of 'struct page' a base page can fit. -* This is, for example, on x86 means 2M of bitmap data max. -*/ - npages =min (npages,PAGE_SIZE /sizeof (struct page *)); -/* * Bitmap address to be pinned is calculated via pointer arithmetic * with bitmap u64 word index. */ addr = bitmap->bitmap + bitmap->mapped_base_index; +/* +* We always cap at max number of 'struct page' a base page can fit. +* This is, for example, on x86 means 2M of bitmap data max. +*/ + npages =min (npages + !!offset_in_page (addr), +PAGE_SIZE /sizeof (struct page *)); + ret =pin_user_pages_fast ((unsigned long )addr, npages,FOLL_WRITE , mapped->pages);if (ret <=0 )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 248/334 RDMA/qedr: Fix qedr_create_user_qp error flow
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kamal Heib <[email protected]>
[ Upstream commit 5ba4e6d5863c53e937f49932dee0ecb004c65928 ]
Avoid the following warning by making sure to free the allocated resources in case that qedr_init_user_queue() fail.
-----------[ cut here ]-----------
WARNING: CPU: 0 PID: 143192 at drivers/infiniband/core/rdma_core.c:874 uverbs_destroy_ufile_hw+0xcf/0xf0 [ib_uverbs] Modules linked in: tls target_core_user uio target_core_pscsi target_core_file target_core_iblock ib_srpt ib_srp scsi_transport_srp nfsd nfs_acl rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace fscache netfs 8021q garp mrp stp llc ext4 mbcache jbd2 opa_vnic ib_umad ib_ipoib sunrpc rdma_ucm ib_isert iscsi_target_mod target_core_mod ib_iser libiscsi scsi_transport_iscsi rdma_cm iw_cm ib_cm hfi1 intel_rapl_msr intel_rapl_common mgag200 qedr sb_edac drm_shmem_helper rdmavt x86_pkg_temp_thermal drm_kms_helper intel_powerclamp ib_uverbs coretemp i2c_algo_bit kvm_intel dell_wmi_descriptor ipmi_ssif sparse_keymap kvm ib_core rfkill syscopyarea sysfillrect video sysimgblt irqbypass ipmi_si ipmi_devintf fb_sys_fops rapl iTCO_wdt mxm_wmi iTCO_vendor_support intel_cstate pcspkr dcdbas intel_uncore ipmi_msghandler lpc_ich acpi_power_meter mei_me mei fuse drm xfs libcrc32c qede sd_mod ahci libahci t10_pi sg crct10dif_pclmul crc32_pclmul crc32c_intel qed libata tg3 ghash_clmulni_intel megaraid_sas crc8 wmi [last unloaded: ib_srpt] CPU: 0 PID: 143192 Comm: fi_rdm_tagged_p Kdump: loaded Not tainted 5.14.0-408.el9.x86_64 #1 Hardware name: Dell Inc. PowerEdge R430/03XKDV, BIOS 2.14.0 01/25/2022 RIP: 0010:uverbs_destroy_ufile_hw+0xcf/0xf0 [ib_uverbs] Code: 5d 41 5c 41 5d 41 5e e9 0f 26 1b dd 48 89 df e8 67 6a ff ff 49 8b 86 10 01 00 00 48 85 c0 74 9c 4c 89 e7 e8 83 c0 cb dd eb 92 <0f> 0b eb be 0f 0b be 04 00 00 00 48 89 df e8 8e f5 ff ff e9 6d ff RSP: 0018:ffffb7c6cadfbc60 EFLAGS: 00010286 RAX: ffff8f0889ee3f60 RBX: ffff8f088c1a5200 RCX: 00000000802a0016 RDX: 00000000802a0017 RSI: 0000000000000001 RDI: ffff8f0880042600 RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000 R10: ffff8f11fffd5000 R11: 0000000000039000 R12: ffff8f0d5b36cd80 R13: ffff8f088c1a5250 R14: ffff8f1206d91000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff8f11d7c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000147069200e20 CR3: 00000001c7210002 CR4: 00000000001706f0 Call Trace: <TASK> ? show_trace_log_lvl+0x1c4/0x2df ? show_trace_log_lvl+0x1c4/0x2df ? ib_uverbs_close+0x1f/0xb0 [ib_uverbs] ? uverbs_destroy_ufile_hw+0xcf/0xf0 [ib_uverbs] ? __warn+0x81/0x110 ? uverbs_destroy_ufile_hw+0xcf/0xf0 [ib_uverbs] ? report_bug+0x10a/0x140 ? handle_bug+0x3c/0x70 ? exc_invalid_op+0x14/0x70 ? asm_exc_invalid_op+0x16/0x20 ? uverbs_destroy_ufile_hw+0xcf/0xf0 [ib_uverbs] ib_uverbs_close+0x1f/0xb0 [ib_uverbs] __fput+0x94/0x250 task_work_run+0x5c/0x90 do_exit+0x270/0x4a0 do_group_exit+0x2d/0x90 get_signal+0x87c/0x8c0 arch_do_signal_or_restart+0x25/0x100 ? ib_uverbs_ioctl+0xc2/0x110 [ib_uverbs] exit_to_user_mode_loop+0x9c/0x130 exit_to_user_mode_prepare+0xb6/0x100 syscall_exit_to_user_mode+0x12/0x40 do_syscall_64+0x69/0x90 ? syscall_exit_work+0x103/0x130 ? syscall_exit_to_user_mode+0x22/0x40 ? do_syscall_64+0x69/0x90 ? syscall_exit_work+0x103/0x130 ? syscall_exit_to_user_mode+0x22/0x40 ? do_syscall_64+0x69/0x90 ? do_syscall_64+0x69/0x90 ? common_interrupt+0x43/0xa0 entry_SYSCALL_64_after_hwframe+0x72/0xdc RIP: 0033:0x1470abe3ec6b Code: Unable to access opcode bytes at RIP 0x1470abe3ec41. RSP: 002b:00007fff13ce9108 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: fffffffffffffffc RBX: 00007fff13ce9218 RCX: 00001470abe3ec6b RDX: 00007fff13ce9200 RSI: 00000000c0181b01 RDI: 0000000000000004 RBP: 00007fff13ce91e0 R08: 0000558d9655da10 R09: 0000558d9655dd00 R10: 00007fff13ce95c0 R11: 0000000000000246 R12: 00007fff13ce9358 R13: 0000000000000013 R14: 0000558d9655db50 R15: 00007fff13ce9470 </TASK>
--[ end trace 888a9b92e04c5c97 ]--
--- drivers/infiniband/hw/qedr/verbs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/hw/qedr/verbs.c +10 -1
@@ -1879,8 +1879,17 @@ static int qedr_create_user_qp(struct qedr_dev *dev,/* RQ - read access only (0) */ rc =qedr_init_user_queue (udata, dev, &qp->urq, ureq.rq_addr, ureq.rq_len, true,0 , alloc_and_init); -if (rc) +if (rc) { +ib_umem_release (qp->usq.umem); + qp->usq.umem =NULL ; +if (rdma_protocol_roce (&dev->ibdev,1 )) { +qedr_free_pbl (dev, &qp->usq.pbl_info, + qp->usq.pbl_tbl); + }else { +kfree (qp->usq.pbl_tbl); + }return rc; + } }memset (&in_params,0 ,sizeof (in_params));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 249/334 arm64: dts: rockchip: set num-cs property for spi on px30
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Stuebner <[email protected]>
[ Upstream commit 334bf0710c98d391f4067b72f535d6c4c84dfb6f ]
The px30 has two spi controllers with two chip-selects each. The num-cs property is specified as the total number of chip selects a controllers has and is used since 2020 to find uses of chipselects outside that range in the Rockchip spi driver.
Without the property set, the default is 1, so spi devices using the second chipselect will not be created.
--- arch/arm64/boot/dts/rockchip/px30.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/rockchip/px30.dtsi +2 -0
@@ -632,6 +632,7 @@ clock-names = "spiclk", "apb_pclk"; dmas = <&dmac 12>, <&dmac 13>; dma-names = "tx", "rx"; + num-cs = <2>; pinctrl-names = "default"; pinctrl-0 = <&spi0_clk &spi0_csn &spi0_miso &spi0_mosi>; #address-cells = <1>;
@@ -647,6 +648,7 @@ clock-names = "spiclk", "apb_pclk"; dmas = <&dmac 14>, <&dmac 15>; dma-names = "tx", "rx"; + num-cs = <2>; pinctrl-names = "default"; pinctrl-0 = <&spi1_clk &spi1_csn0 &spi1_csn1 &spi1_miso &spi1_mosi>; #address-cells = <1>;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 250/334 arm64: dts: rockchip: Correct Indiedroid Nova GPIO Names
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Morgan <[email protected]>
[ Upstream commit c22d03a95b0d815cd186302fdd93f74d99f1c914 ]
Correct the names given to a few of the GPIO pins. The original names were unknowingly based on the header from a pre-production board. The production board has a slightly different pin assignment for the 40-pin GPIO header.
--- .../boot/dts/rockchip/rk3588s-indiedroid-nova.dts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588s-indiedroid-nova.dts +5 -5
@@ -196,13 +196,13 @@ &gpio1 { gpio-line-names = /* GPIO1 A0-A7 */ - "HEADER_27_3v3", "HEADER_28_3v3", "", "", + "HEADER_27_3v3", "", "", "", "HEADER_29_1v8", "", "HEADER_7_1v8", "", /* GPIO1 B0-B7 */ "", "HEADER_31_1v8", "HEADER_33_1v8", "", "HEADER_11_1v8", "HEADER_13_1v8", "", "", /* GPIO1 C0-C7 */ - "", "", "", "", + "", "HEADER_28_3v3", "", "", "", "", "", "", /* GPIO1 D0-D7 */ "", "", "", "",
@@ -226,11 +226,11 @@ &gpio4 { gpio-line-names = /* GPIO4 A0-A7 */ - "", "", "HEADER_37_3v3", "HEADER_32_3v3", - "HEADER_36_3v3", "", "HEADER_35_3v3", "HEADER_38_3v3", + "", "", "HEADER_37_3v3", "HEADER_8_3v3", + "HEADER_10_3v3", "", "HEADER_32_3v3", "HEADER_35_3v3", /* GPIO4 B0-B7 */ "", "", "", "HEADER_40_3v3", - "HEADER_8_3v3", "HEADER_10_3v3", "", "", + "HEADER_38_3v3", "HEADER_36_3v3", "", "", /* GPIO4 C0-C7 */ "", "", "", "", "", "", "", "",
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 251/334 xsk: Add truesize to skb_add_rx_frag().
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 2127c604383666675789fd4a5fc2aead46c73aad ]
xsk_build_skb() allocates a page and adds it to the skb via skb_add_rx_frag() and specifies 0 for truesize. This leads to a warning in skb_add_rx_frag() with CONFIG_DEBUG_NET enabled because size is larger than truesize.
Increasing truesize requires to add the same amount to socket's sk_wmem_alloc counter in order not to underflow the counter during release in the destructor (sock_wfree()).
Pass the size of the allocated page as truesize to skb_add_rx_frag(). Add this mount to socket's sk_wmem_alloc counter.
--- net/xdp/xsk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/xdp/xsk.c +2 -1
@@ -711,7 +711,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,memcpy (vaddr, buffer, len);kunmap_local (vaddr); -skb_add_rx_frag (skb, nr_frags, page,0 , len,0 ); +skb_add_rx_frag (skb, nr_frags, page,0 , len,PAGE_SIZE ); +refcount_add (PAGE_SIZE , &xs->sk.sk_wmem_alloc); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 242/334 arm64: dts: tqma8mpql: fix audio codec iov-supply
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
[ Upstream commit a620a7f2ae8b08c5beea6369f61e87064ee222dc ]
IOVDD is supplied by 1.8V, fix the referenced regulator.
--- .../boot/dts/freescale/imx8mp-tqma8mpql-mba8mpxl.dts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx8mp-tqma8mpql-mba8mpxl.dts +8 -1
@@ -168,6 +168,13 @@ enable-active-high; }; + reg_vcc_1v8: regulator-1v8 { + compatible = "regulator-fixed"; + regulator-name = "VCC_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + reg_vcc_3v3: regulator-3v3 { compatible = "regulator-fixed"; regulator-name = "VCC_3V3";
@@ -464,7 +471,7 @@ clock-names = "mclk"; clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIOMIX_SAI3_MCLK1>; reset-gpios = <&gpio4 29 GPIO_ACTIVE_LOW>; - iov-supply = <®_vcc_3v3>; + iov-supply = <®_vcc_1v8>; ldoin-supply = <®_vcc_3v3>; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 274/334 selftests: bonding: set active slave to primary eth1 specifically
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
[ Upstream commit cd65c48d66920457129584553f217005d09b1edb ]
In bond priority testing, we set the primary interface to eth1 and add eth0,1,2 to bond in serial. This is OK in normal times. But when in debug kernel, the bridge port that eth0,1,2 connected would start slowly (enter blocking, forwarding state), which caused the primary interface down for a while after enslaving and active slave changed. Here is a test log from Jakub's debug test[1].
[ 400.399070][ T50] br0: port 1(s0) entered disabled state [ 400.400168][ T50] br0: port 4(s2) entered disabled state [ 400.941504][ T2791] bond0: (slave eth0): making interface the new active one [ 400.942603][ T2791] bond0: (slave eth0): Enslaving as an active interface with an up link [ 400.943633][ T2766] br0: port 1(s0) entered blocking state [ 400.944119][ T2766] br0: port 1(s0) entered forwarding state [ 401.128792][ T2792] bond0: (slave eth1): making interface the new active one [ 401.130771][ T2792] bond0: (slave eth1): Enslaving as an active interface with an up link [ 401.131643][ T69] br0: port 2(s1) entered blocking state [ 401.132067][ T69] br0: port 2(s1) entered forwarding state [ 401.346201][ T2793] bond0: (slave eth2): Enslaving as a backup interface with an up link [ 401.348414][ T50] br0: port 4(s2) entered blocking state [ 401.348857][ T50] br0: port 4(s2) entered forwarding state [ 401.519669][ T250] bond0: (slave eth0): link status definitely down, disabling slave [ 401.526522][ T250] bond0: (slave eth1): link status definitely down, disabling slave [ 401.526986][ T250] bond0: (slave eth2): making interface the new active one [ 401.629470][ T250] bond0: (slave eth0): link status definitely up [ 401.630089][ T250] bond0: (slave eth1): link status definitely up [...] # TEST: prio (active-backup ns_ip6_target primary_reselect 1) [FAIL] # Current active slave is eth2 but not eth1
Fix it by setting active slave to primary slave specifically before testing.
[1] https://netdev-3.bots.linux.dev/vmksft-bonding-dbg/results/464301/1-bond-options-sh/stdout
--- tools/testing/selftests/drivers/net/bonding/bond_options.sh | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/drivers/net/bonding/bond_options.sh +2 -0
@@ -62,6 +62,8 @@ prio_test() # create bond bond_reset "${param}" + # set active_slave to primary eth1 specifically + ip -n ${s_ns} link set bond0 type bond active_slave eth1 # check bonding member prio value ip -n ${s_ns} link set eth0 type bond_slave prio 0
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 283/334 KVM: PPC: Book3S HV: Fix L2 guest reboot failure due to empty arch_compat
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Machhiwal <[email protected]>
[ Upstream commit 20c8c4dafe93e82441583e93bd68c0d256d7bed4 ]
Currently, rebooting a pseries nested qemu-kvm guest (L2) results in below error as L1 qemu sends PVR value 'arch_compat' == 0 via ppc_set_compat ioctl. This triggers a condition failure in kvmppc_set_arch_compat() resulting in an EINVAL.
qemu-system-ppc64: Unable to set CPU compatibility mode in KVM: Invalid argument
Also, a value of 0 for arch_compat generally refers the default compatibility of the host. But, arch_compat, being a Guest Wide Element in nested API v2, cannot be set to 0 in GSB as PowerVM (L0) expects a non-zero value. A value of 0 triggers a kernel trap during a reboot and consequently causes it to fail:
[ 22.106360] reboot: Restarting system
KVM: unknown exit, hardware reason ffffffffffffffea
NIP 0000000000000100 LR 000000000000fe44 CTR 0000000000000000 XER 0000000020040092 CPU#0
MSR 0000000000001000 HID0 0000000000000000 HF 6c000000 iidx 3 didx 3 TB 00000000 00000000 DECR 0
GPR00 0000000000000000 0000000000000000 c000000002a8c300 000000007fe00000 GPR04 0000000000000000 0000000000000000 0000000000001002 8000000002803033 GPR08 000000000a000000 0000000000000000 0000000000000004 000000002fff0000 GPR12 0000000000000000 c000000002e10000 0000000105639200 0000000000000004 GPR16 0000000000000000 000000010563a090 0000000000000000 0000000000000000 GPR20 0000000105639e20 00000001056399c8 00007fffe54abab0 0000000105639288 GPR24 0000000000000000 0000000000000001 0000000000000001 0000000000000000 GPR28 0000000000000000 0000000000000000 c000000002b30840 0000000000000000
CR 00000000 [ - - - - - - - - ] RES 000@ffffffffffffffff
SRR0 0000000000000000 SRR1 0000000000000000 PVR 0000000000800200 VRSAVE 0000000000000000
SPRG0 0000000000000000 SPRG1 0000000000000000 SPRG2 0000000000000000 SPRG3 0000000000000000 SPRG4 0000000000000000 SPRG5 0000000000000000 SPRG6 0000000000000000 SPRG7 0000000000000000
HSRR0 0000000000000000 HSRR1 0000000000000000
CFAR 0000000000000000
LPCR 0000000000020400
PTCR 0000000000000000 DAR 0000000000000000 DSISR 0000000000000000
kernel:trap=0xffffffea | pc=0x100 | msr=0x1000
This patch updates kvmppc_set_arch_compat() to use the host PVR value if 'compat_pvr' == 0 indicating that qemu doesn't want to enforce any specific PVR compat mode.
The relevant part of the code might need a rework if PowerVM implements a support for arch_compat == 0 in nestedv2 API.
--- arch/powerpc/kvm/book3s_hv.c | 26 ++++++++++++++++++++++++-- arch/powerpc/kvm/book3s_hv_nestedv2.c | 20 ++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-)
arch/powerpc/kvm/book3s_hv.c +24 -2
@@ -391,6 +391,24 @@ static void kvmppc_set_pvr_hv(struct kvm_vcpu *vcpu, u32 pvr)/* Dummy value used in computing PCR value below */ #define PCR_ARCH_31 (PCR_ARCH_300 << 1) +static inline unsigned long map_pcr_to_cap (unsigned long pcr) +{ +unsigned long cap =0 ; + +switch (pcr) { +case PCR_ARCH_300 : + cap =H_GUEST_CAP_POWER9 ; +break ; +case PCR_ARCH_31 : + cap =H_GUEST_CAP_POWER10 ; +break ; +default : +break ; + } + +return cap; +} +static int kvmppc_set_arch_compat (struct kvm_vcpu *vcpu,u32 arch_compat) {unsigned long host_pcr_bit =0 , guest_pcr_bit =0 , cap =0 ;
@@ -424,11 +442,9 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)break ;case PVR_ARCH_300 : guest_pcr_bit =PCR_ARCH_300 ; - cap =H_GUEST_CAP_POWER9 ;break ;case PVR_ARCH_31 : guest_pcr_bit =PCR_ARCH_31 ; - cap =H_GUEST_CAP_POWER10 ;break ;default :return -EINVAL ;
@@ -440,6 +456,12 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)return -EINVAL ;if (kvmhv_on_pseries () &&kvmhv_is_nestedv2 ()) { +/* +* 'arch_compat == 0' would mean the guest should default to +* L1's compatibility. In this case, the guest would pick +* host's PCR and evaluate the corresponding capabilities. +*/ + cap =map_pcr_to_cap (guest_pcr_bit);if (!(cap & nested_capabilities))return -EINVAL ; }
arch/powerpc/kvm/book3s_hv_nestedv2.c +18 -2
@@ -138,6 +138,7 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb,vector128 v;int rc, i;u16 iden; +u32 arch_compat =0 ; vcpu = gsm->data;
@@ -347,8 +348,23 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb,break ; }case KVMPPC_GSID_LOGICAL_PVR : - rc =kvmppc_gse_put_u32 (gsb, iden, - vcpu->arch.vcore->arch_compat); +/* +* Though 'arch_compat == 0' would mean the default +* compatibility, arch_compat, being a Guest Wide +* Element, cannot be filled with a value of 0 in GSB +* as this would result into a kernel trap. +* Hence, when `arch_compat == 0`, arch_compat should +* default to L1's PVR. +*/ +if (!vcpu->arch.vcore->arch_compat) { +if (cpu_has_feature (CPU_FTR_ARCH_31 )) + arch_compat =PVR_ARCH_31 ; +else if (cpu_has_feature (CPU_FTR_ARCH_300 )) + arch_compat =PVR_ARCH_300 ; + }else { + arch_compat = vcpu->arch.vcore->arch_compat; + } + rc =kvmppc_gse_put_u32 (gsb, iden, arch_compat);break ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 284/334 gpiolib: Handle no pin_ranges in gpiochip_generic_config()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emil Renner Berthing <[email protected]>
[ Upstream commit ae366ba8576da0135d7d3db2dfa6304f3338d0c2 ]
Similar to gpiochip_generic_request() and gpiochip_generic_free() the gpiochip_generic_config() function needs to handle the case where there are no pinctrl pins mapped to the GPIOs, usually through the gpio-ranges device tree property.
Commit f34fd6ee1be8 ("gpio: dwapb: Use generic request, free and set_config") set the .set_config callback to gpiochip_generic_config() in the dwapb GPIO driver so the GPIO API can set pinctrl configuration for the corresponding pins. Most boards using the dwapb driver do not set the gpio-ranges device tree property though, and in this case gpiochip_generic_config() would return -EPROPE_DEFER rather than the previous -ENOTSUPP return value. This in turn makes gpio_set_config_with_argument_optional() fail and propagate the error to any driver requesting GPIOs.
--- drivers/gpio/gpiolib.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpio/gpiolib.c +5 -0
@@ -2043,6 +2043,11 @@ EXPORT_SYMBOL_GPL(gpiochip_generic_free);int gpiochip_generic_config (struct gpio_chip *gc,unsigned int offset,unsigned long config) { +#ifdef CONFIG_PINCTRL +if (list_empty (&gc->gpiodev->pin_ranges)) +return -ENOTSUPP ; +#endif +return pinctrl_gpio_set_config (gc, offset, config); }EXPORT_SYMBOL_GPL (gpiochip_generic_config);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 285/334 arm64/sme: Restore SME registers on exit from suspend
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 9533864816fb4a6207c63b7a98396351ce1a9fae ]
The fields in SMCR_EL1 and SMPRI_EL1 reset to an architecturally UNKNOWN value. Since we do not otherwise manage the traps configured in this register at runtime we need to reconfigure them after a suspend in case nothing else was kind enough to preserve them for us.
The vector length will be restored as part of restoring the SME state for the next SME using task.
--- arch/arm64/include/asm/fpsimd.h | 2 ++ arch/arm64/kernel/fpsimd.c | 14 ++++++++++++++ arch/arm64/kernel/suspend.c | 3 +++ 3 files changed, 19 insertions(+)
arch/arm64/include/asm/fpsimd.h +2 -0
@@ -386,6 +386,7 @@ extern void sme_alloc(struct task_struct *task, bool flush);extern unsigned int sme_get_vl (void );extern int sme_set_current_vl (unsigned long arg);extern int sme_get_current_vl (void ); +extern void sme_suspend_exit (void );/* * Return how many bytes of memory are required to store the full SME
@@ -421,6 +422,7 @@ static inline int sme_max_vl(void) { return 0; }static inline int sme_max_virtualisable_vl (void ) {return 0 ; }static inline int sme_set_current_vl (unsigned long arg) {return -EINVAL ; }static inline int sme_get_current_vl (void ) {return -EINVAL ; } +static inline void sme_suspend_exit (void ) { }static inline size_t sme_state_size (struct task_struct const *task) {
arch/arm64/kernel/fpsimd.c +14 -0
@@ -1339,6 +1339,20 @@ void __init sme_setup(void) get_sme_default_vl()); } +void sme_suspend_exit (void ) +{ +u64 smcr =0 ; + +if (!system_supports_sme ()) +return ; + +if (system_supports_fa64 ()) + smcr |= SMCR_ELx_FA64; + +write_sysreg_s (smcr,SYS_SMCR_EL1 ); +write_sysreg_s (0 ,SYS_SMPRI_EL1 ); +} +#endif /* CONFIG_ARM64_SME */ static void sve_init_regs (void )
arch/arm64/kernel/suspend.c +3 -0
@@ -12,6 +12,7 @@#include <asm/daifflags.h> #include <asm/debug-monitors.h> #include <asm/exec.h> +#include <asm/fpsimd.h> #include <asm/mte.h> #include <asm/memory.h> #include <asm/mmu_context.h>
@@ -80,6 +81,8 @@ void notrace __cpu_suspend_exit(void)*/ spectre_v4_enable_mitigation (NULL ); +sme_suspend_exit (); +/* Restore additional feature-specific configuration */ ptrauth_suspend_exit (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 286/334 arm64/sme: Restore SMCR_EL1.EZT0 on exit from suspend
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit d7b77a0d565b048cb0808fa8a4fb031352b22a01 ]
The fields in SMCR_EL1 reset to an architecturally UNKNOWN value. Since we do not otherwise manage the traps configured in this register at runtime we need to reconfigure them after a suspend in case nothing else was kind enough to preserve them for us. Do so for SMCR_EL1.EZT0.
--- arch/arm64/kernel/fpsimd.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/kernel/fpsimd.c +2 -0
@@ -1348,6 +1348,8 @@ void sme_suspend_exit(void)if (system_supports_fa64 ()) smcr |= SMCR_ELx_FA64; +if (system_supports_sme2 ()) + smcr |= SMCR_ELx_EZT0;write_sysreg_s (smcr,SYS_SMCR_EL1 );write_sysreg_s (0 ,SYS_SMPRI_EL1 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 287/334 platform/x86: thinkpad_acpi: Only update profile if successfully converted
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit 427c70dec738318b7f71e1b9d829ff0e9771d493 ]
Randomly a Lenovo Z13 will trigger a kernel warning traceback from this condition:
``` if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) ```
This happens because thinkpad-acpi always assumes that convert_dytc_to_profile() successfully updated the profile. On the contrary a condition can occur that when dytc_profile_refresh() is called the profile doesn't get updated as there is a -EOPNOTSUPP branch.
Catch this situation and avoid updating the profile. Also log this into dynamic debugging in case any other modes should be added in the future.
--- drivers/platform/x86/thinkpad_acpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +3 -2
@@ -10308,6 +10308,7 @@ static int convert_dytc_to_profile(int funcmode, int dytcmode,return 0 ;default :/* Unknown function */ +pr_debug ("unknown function 0x%x\n" , funcmode);return -EOPNOTSUPP ; }return 0 ;
@@ -10493,8 +10494,8 @@ static void dytc_profile_refresh(void)return ; perfmode = (output >>DYTC_GET_MODE_BIT ) &0xF ; -convert_dytc_to_profile (funcmode, perfmode, &profile); -if (profile != dytc_current_profile) { + err =convert_dytc_to_profile (funcmode, perfmode, &profile); +if (!err && profile != dytc_current_profile) { dytc_current_profile = profile;platform_profile_notify (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 288/334 drm/i915/tv: Fix TV mode
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Ripard <[email protected]>
[ Upstream commit fb1e881273f432e593f8789f99e725b09304cc97 ]
Commit 1fd4a5a36f9f ("drm/connector: Rename legacy TV property") failed to update all the users of the struct drm_tv_connector_state mode field, which resulted in a build failure in i915.
However, a subsequent commit in the same series reintroduced a mode field in that structure, with a different semantic but the same type, with the assumption that all previous users were updated.
Since that didn't happen, the i915 driver now compiles, but mixes accesses to the legacy_mode field and the newer mode field, but with the previous semantics.
This obviously doesn't work very well, so we need to update the accesses that weren't in the legacy renaming commit.
--- drivers/gpu/drm/i915/display/intel_sdvo.c | 10 +++++----- drivers/gpu/drm/i915/display/intel_tv.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/display/intel_sdvo.c +5 -5
@@ -1208,7 +1208,7 @@ static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo,struct intel_sdvo_tv_format format;u32 format_map; - format_map =1 << conn_state->tv.mode; + format_map =1 << conn_state->tv.legacy_mode;memset (&format,0 ,sizeof (format));memcpy (&format, &format_map,min (sizeof (format),sizeof (format_map)));
@@ -2288,7 +2288,7 @@ static int intel_sdvo_get_tv_modes(struct drm_connector *connector)* Read the list of supported input resolutions for the selected TV * format. */ - format_map =1 << conn_state->tv.mode; + format_map =1 << conn_state->tv.legacy_mode;memcpy (&tv_res, &format_map,min (sizeof (format_map),sizeof (struct intel_sdvo_sdtv_resolution_request )));
@@ -2353,7 +2353,7 @@ intel_sdvo_connector_atomic_get_property(struct drm_connector *connector,int i;for (i =0 ; i < intel_sdvo_connector->format_supported_num; i++) -if (state->tv.mode == intel_sdvo_connector->tv_format_supported[i]) { +if (state->tv.legacy_mode == intel_sdvo_connector->tv_format_supported[i]) { *val = i;return 0 ;
@@ -2409,7 +2409,7 @@ intel_sdvo_connector_atomic_set_property(struct drm_connector *connector,struct intel_sdvo_connector_state *sdvo_state =to_intel_sdvo_connector_state (state);if (property == intel_sdvo_connector->tv_format) { - state->tv.mode = intel_sdvo_connector->tv_format_supported[val]; + state->tv.legacy_mode = intel_sdvo_connector->tv_format_supported[val];if (state->crtc) { struct drm_crtc_state *crtc_state =
@@ -3066,7 +3066,7 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,drm_property_add_enum (intel_sdvo_connector->tv_format, i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]); - intel_sdvo_connector->base.base.state->tv.mode = intel_sdvo_connector->tv_format_supported[0 ]; + intel_sdvo_connector->base.base.state->tv.legacy_mode = intel_sdvo_connector->tv_format_supported[0 ];drm_object_attach_property (&intel_sdvo_connector->base.base.base, intel_sdvo_connector->tv_format,0 );return true;
drivers/gpu/drm/i915/display/intel_tv.c +5 -5
@@ -949,7 +949,7 @@ intel_disable_tv(struct intel_atomic_state *state,static const struct tv_mode *intel_tv_mode_find (const struct drm_connector_state *conn_state) { -int format = conn_state->tv.mode; +int format = conn_state->tv.legacy_mode;return &tv_modes[format]; }
@@ -1710,7 +1710,7 @@ static void intel_tv_find_better_format(struct drm_connector *connector)break ; } - connector->state->tv.mode = i; + connector->state->tv.legacy_mode = i; } static int
@@ -1865,7 +1865,7 @@ static int intel_tv_atomic_check(struct drm_connector *connector, old_state =drm_atomic_get_old_connector_state (state, connector); new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); - if (old_state->tv.mode != new_state->tv.mode || + if (old_state->tv.legacy_mode != new_state->tv.legacy_mode || old_state->tv.margins.left != new_state->tv.margins.left || old_state->tv.margins.right != new_state->tv.margins.right || old_state->tv.margins.top != new_state->tv.margins.top ||
@@ -1902,7 +1902,7 @@ static void intel_tv_add_properties(struct drm_connector *connector) conn_state->tv.margins.right =46 ; conn_state->tv.margins.bottom =37 ; - conn_state->tv.mode =0 ; + conn_state->tv.legacy_mode =0 ;/* Create TV properties then attach current values */ for (i =0 ; i <ARRAY_SIZE (tv_modes); i++) {
@@ -1916,7 +1916,7 @@ static void intel_tv_add_properties(struct drm_connector *connector)drm_object_attach_property (&connector->base, i915->drm.mode_config.legacy_tv_mode_property, - conn_state->tv.mode); + conn_state->tv.legacy_mode);drm_object_attach_property (&connector->base, i915->drm.mode_config.tv_left_margin_property, conn_state->tv.margins.left);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 289/334 iommu/vt-d: Update iotlb in nested domain attach
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Liu <[email protected]>
[ Upstream commit 29e10487d6df050afeee886b7c1da208f389cb5b ]
Should call domain_update_iotlb() to update the has_iotlb_device flag of the domain after attaching device to nested domain. Without it, this flag is not set properly and would result in missing device TLB flush.
--- drivers/iommu/intel/iommu.c | 4 +--- drivers/iommu/intel/iommu.h | 1 + drivers/iommu/intel/nested.c | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/iommu/intel/iommu.c +1 -3
@@ -540,8 +540,6 @@ static int domain_update_device_node(struct dmar_domain *domain)return nid; } -static void domain_update_iotlb (struct dmar_domain *domain); -/* Return the super pagesize bitmap if supported. */ static unsigned long domain_super_pgsize_bitmap (struct dmar_domain *domain) {
@@ -1362,7 +1360,7 @@ domain_lookup_dev_info(struct dmar_domain *domain,return NULL ; } -static void domain_update_iotlb (struct dmar_domain *domain) +void domain_update_iotlb (struct dmar_domain *domain) {struct dev_pasid_info *dev_pasid;struct device_domain_info *info;
drivers/iommu/intel/iommu.h +1 -0
@@ -888,6 +888,7 @@ int qi_submit_sync(struct intel_iommu *iommu, struct qi_desc *desc,*/ #define QI_OPT_WAIT_DRAIN BIT(0) +void domain_update_iotlb (struct dmar_domain *domain);int domain_attach_iommu (struct dmar_domain *domain,struct intel_iommu *iommu);void domain_detach_iommu (struct dmar_domain *domain,struct intel_iommu *iommu);void device_block_translation (struct device *dev);
drivers/iommu/intel/nested.c +2 -0
@@ -65,6 +65,8 @@ static int intel_nested_attach_dev(struct iommu_domain *domain,list_add (&info->link, &dmar_domain->devices);spin_unlock_irqrestore (&dmar_domain->lock, flags); +domain_update_iotlb (dmar_domain); +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 290/334 iommu/vt-d: Track nested domains in parent
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Liu <[email protected]>
[ Upstream commit 85ce8e1d6d73e8d54cb244d10dd4021771231746 ]
Today the parent domain (s2_domain) is unaware of which DID's are used by and which devices are attached to nested domains (s1_domain) nested on it. This leads to a problem that some operations (flush iotlb/devtlb and enable dirty tracking) on parent domain only apply to DID's and devices directly tracked in the parent domain hence are incomplete.
This tracks the nested domains in list in parent domain. With this, operations on parent domain can loop the nested domains and refer to the devices and iommu_array to ensure the operations on parent domain take effect on all the affected devices and iommus.
Stable-dep-of: f1e1610950ea ("iommu/vt-d: Add missing dirty tracking set for parent domain")
--- drivers/iommu/intel/iommu.c | 18 ++++++++++++++---- drivers/iommu/intel/iommu.h | 6 ++++++ drivers/iommu/intel/nested.c | 12 +++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-)
drivers/iommu/intel/iommu.c +14 -4
@@ -4069,6 +4069,7 @@ intel_iommu_domain_alloc_user(struct device *dev, u32 flags,bool dirty_tracking = flags &IOMMU_HWPT_ALLOC_DIRTY_TRACKING ;bool nested_parent = flags &IOMMU_HWPT_ALLOC_NEST_PARENT ;struct intel_iommu *iommu = info->iommu; +struct dmar_domain *dmar_domain;struct iommu_domain *domain;/* Must be NESTING domain */
@@ -4094,11 +4095,16 @@ intel_iommu_domain_alloc_user(struct device *dev, u32 flags,if (!domain)return ERR_PTR (-ENOMEM ); -if (nested_parent) -to_dmar_domain (domain)->nested_parent = true; + dmar_domain =to_dmar_domain (domain); + +if (nested_parent) { + dmar_domain->nested_parent = true; +INIT_LIST_HEAD (&dmar_domain->s1_domains); +spin_lock_init (&dmar_domain->s1_lock); + }if (dirty_tracking) { -if (to_dmar_domain (domain)->use_first_level) { +if (dmar_domain->use_first_level) {iommu_domain_free (domain);return ERR_PTR (-EOPNOTSUPP ); }
@@ -4110,8 +4116,12 @@ intel_iommu_domain_alloc_user(struct device *dev, u32 flags,static void intel_iommu_domain_free (struct iommu_domain *domain) { +struct dmar_domain *dmar_domain =to_dmar_domain (domain); + +WARN_ON (dmar_domain->nested_parent && + !list_empty (&dmar_domain->s1_domains));if (domain != &si_domain->domain) -domain_exit (to_dmar_domain (domain)); +domain_exit (dmar_domain); } int prepare_domain_attach_device(struct iommu_domain *domain,
drivers/iommu/intel/iommu.h +6 -0
@@ -630,6 +630,10 @@ struct dmar_domain {int agaw;/* maximum mapped address */ u64 max_addr; +/* Protect the s1_domains list */ +spinlock_t s1_lock; +/* Track s1_domains nested on this domain */ +struct list_head s1_domains; };/* Nested user domain */
@@ -640,6 +644,8 @@ struct dmar_domain {unsigned long s1_pgtbl;/* page table attributes */ struct iommu_hwpt_vtd_s1 s1_cfg; +/* link to parent domain siblings */ +struct list_head s2_link; }; };
drivers/iommu/intel/nested.c +11 -1
@@ -72,7 +72,13 @@ static int intel_nested_attach_dev(struct iommu_domain *domain,static void intel_nested_domain_free (struct iommu_domain *domain) { -kfree (to_dmar_domain (domain)); +struct dmar_domain *dmar_domain =to_dmar_domain (domain); +struct dmar_domain *s2_domain = dmar_domain->s2_domain; + +spin_lock (&s2_domain->s1_lock); +list_del (&dmar_domain->s2_link); +spin_unlock (&s2_domain->s1_lock); +kfree (dmar_domain); }static const struct iommu_domain_ops intel_nested_domain_ops = {
@@ -115,5 +121,9 @@ struct iommu_domain *intel_nested_domain_alloc(struct iommu_domain *parent,spin_lock_init (&domain->lock);xa_init (&domain->iommu_array); +spin_lock (&s2_domain->s1_lock); +list_add (&domain->s2_link, &s2_domain->s1_domains); +spin_unlock (&s2_domain->s1_lock); +return &domain->domain; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 291/334 iommu/vt-d: Remove domain parameter for intel_pasid_setup_dirty_tracking()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Liu <[email protected]>
[ Upstream commit 56ecaf6c5834ace14941d7f13dceb48bc3327111 ]
The only usage of input @domain is to get the domain id (DID) to flush cache after setting dirty tracking. However, DID can be obtained from the pasid entry. So no need to pass in domain. This can make this helper cleaner when adding the missing dirty tracking for the parent domain, which needs to use the DID of nested domain.
Stable-dep-of: f1e1610950ea ("iommu/vt-d: Add missing dirty tracking set for parent domain")
--- drivers/iommu/intel/iommu.c | 7 +++---- drivers/iommu/intel/pasid.c | 3 +-- drivers/iommu/intel/pasid.h | 1 - 3 files changed, 4 insertions(+), 7 deletions(-)
drivers/iommu/intel/iommu.c +3 -4
@@ -4877,8 +4877,7 @@ static int intel_iommu_set_dirty_tracking(struct iommu_domain *domain, goto out_unlock;list_for_each_entry (info, &dmar_domain->devices, link) { - ret =intel_pasid_setup_dirty_tracking (info->iommu, - info->domain, info->dev, + ret =intel_pasid_setup_dirty_tracking (info->iommu, info->dev,IOMMU_NO_PASID , enable);if (ret) goto err_unwind;
@@ -4892,8 +4891,8 @@ static int intel_iommu_set_dirty_tracking(struct iommu_domain *domain, err_unwind:list_for_each_entry (info, &dmar_domain->devices, link) -intel_pasid_setup_dirty_tracking (info->iommu, dmar_domain, - info->dev,IOMMU_NO_PASID , +intel_pasid_setup_dirty_tracking (info->iommu, info->dev, +IOMMU_NO_PASID , dmar_domain->dirty_tracking);spin_unlock (&dmar_domain->lock);return ret;
drivers/iommu/intel/pasid.c +1 -2
@@ -695,7 +695,6 @@ int intel_pasid_setup_second_level(struct intel_iommu *iommu,* Set up dirty tracking on a second only or nested translation type. */ int intel_pasid_setup_dirty_tracking (struct intel_iommu *iommu, -struct dmar_domain *domain,struct device *dev,u32 pasid,bool enabled) {
@@ -712,7 +711,7 @@ int intel_pasid_setup_dirty_tracking(struct intel_iommu *iommu,return -ENODEV ; } - did =domain_id_iommu (domain, iommu); + did =pasid_get_domain_id (pte); pgtt =pasid_pte_get_pgtt (pte);if (pgtt !=PASID_ENTRY_PGTT_SL_ONLY && pgtt !=PASID_ENTRY_PGTT_NESTED ) {
drivers/iommu/intel/pasid.h +0 -1
@@ -107,7 +107,6 @@ int intel_pasid_setup_second_level(struct intel_iommu *iommu,struct dmar_domain *domain, struct device *dev, u32 pasid);int intel_pasid_setup_dirty_tracking (struct intel_iommu *iommu, -struct dmar_domain *domain,struct device *dev,u32 pasid,bool enabled); int intel_pasid_setup_pass_through(struct intel_iommu *iommu,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 292/334 iommu/vt-d: Wrap the dirty tracking loop to be a helper
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Liu <[email protected]>
[ Upstream commit 0c7f2497b39da44253d7bcf2b41f52b0048859ad ]
Add device_set_dirty_tracking() to loop all the devices and set the dirty tracking per the @enable parameter.
Stable-dep-of: f1e1610950ea ("iommu/vt-d: Add missing dirty tracking set for parent domain")
--- drivers/iommu/intel/iommu.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/iommu/intel/iommu.c +24 -11
@@ -4865,23 +4865,38 @@ static void *intel_iommu_hw_info(struct device *dev, u32 *length, u32 *type)return vtd; } +/* +* Set dirty tracking for the device list of a domain. The caller must +* hold the domain->lock when calling it. +*/ +static int device_set_dirty_tracking (struct list_head *devices,bool enable) +{ +struct device_domain_info *info; +int ret =0 ; + +list_for_each_entry (info, devices, link) { + ret =intel_pasid_setup_dirty_tracking (info->iommu, info->dev, +IOMMU_NO_PASID , enable); +if (ret) +break ; + } + +return ret; +} +static int intel_iommu_set_dirty_tracking (struct iommu_domain *domain,bool enable) {struct dmar_domain *dmar_domain =to_dmar_domain (domain); -struct device_domain_info *info;int ret;spin_lock (&dmar_domain->lock);if (dmar_domain->dirty_tracking == enable) goto out_unlock; -list_for_each_entry (info, &dmar_domain->devices, link) { - ret =intel_pasid_setup_dirty_tracking (info->iommu, info->dev, -IOMMU_NO_PASID , enable); -if (ret) - goto err_unwind; - } + ret =device_set_dirty_tracking (&dmar_domain->devices, enable); +if (ret) + goto err_unwind; dmar_domain->dirty_tracking = enable; out_unlock:
@@ -4890,10 +4905,8 @@ static int intel_iommu_set_dirty_tracking(struct iommu_domain *domain,return 0 ; err_unwind: -list_for_each_entry (info, &dmar_domain->devices, link) -intel_pasid_setup_dirty_tracking (info->iommu, info->dev, -IOMMU_NO_PASID , - dmar_domain->dirty_tracking); +device_set_dirty_tracking (&dmar_domain->devices, + dmar_domain->dirty_tracking);spin_unlock (&dmar_domain->lock);return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 275/334 ata: ahci_ceva: fix error handling for Xilinx GT PHY support
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Radhey Shyam Pandey <[email protected]>
[ Upstream commit 26c8404e162b43dddcb037ba2d0cb58c0ed60aab ]
Platform clock and phy error resources are not cleaned up in Xilinx GT PHY error path.
To fix introduce the function ceva_ahci_platform_enable_resources() which is a customized version of ahci_platform_enable_resources() and inline with SATA IP programming sequence it does:
- Assert SATA reset
- Program PS GTR phy
- Bring SATA by de-asserting the reset
- Wait for GT lane PLL to be locked
ceva_ahci_platform_enable_resources() is also used in the resume path as the same SATA programming sequence (as in probe) should be followed. Also cleanup the mixed usage of ahci_platform_enable_resources() and custom implementation in the probe function as both are not required.
--- drivers/ata/ahci_ceva.c | 125 +++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 46 deletions(-)
drivers/ata/ahci_ceva.c +79 -46
@@ -88,7 +88,6 @@ struct ceva_ahci_priv {u32 axicc;bool is_cci_enabled;int flags; -struct reset_control *rst; }; static unsigned int ceva_ahci_read_id(struct ata_device *dev,
@@ -189,6 +188,60 @@ static const struct scsi_host_template ahci_platform_sht = { AHCI_SHT(DRV_NAME), }; +static int ceva_ahci_platform_enable_resources (struct ahci_host_priv *hpriv) +{ +int rc, i; + + rc =ahci_platform_enable_regulators (hpriv); +if (rc) +return rc; + + rc =ahci_platform_enable_clks (hpriv); +if (rc) + goto disable_regulator; + +/* Assert the controller reset */ + rc =ahci_platform_assert_rsts (hpriv); +if (rc) + goto disable_clks; + +for (i =0 ; i < hpriv->nports; i++) { + rc =phy_init (hpriv->phys[i]); +if (rc) + goto disable_rsts; + } + +/* De-assert the controller reset */ +ahci_platform_deassert_rsts (hpriv); + +for (i =0 ; i < hpriv->nports; i++) { + rc =phy_power_on (hpriv->phys[i]); +if (rc) { +phy_exit (hpriv->phys[i]); + goto disable_phys; + } + } + +return 0 ; + +disable_rsts: +ahci_platform_deassert_rsts (hpriv); + +disable_phys: +while (--i >=0 ) { +phy_power_off (hpriv->phys[i]); +phy_exit (hpriv->phys[i]); + } + +disable_clks: +ahci_platform_disable_clks (hpriv); + +disable_regulator: +ahci_platform_disable_regulators (hpriv); + +return rc; +} +static int ceva_ahci_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;
@@ -203,47 +256,19 @@ static int ceva_ahci_probe(struct platform_device *pdev)return -ENOMEM ; cevapriv->ahci_pdev = pdev; - - cevapriv->rst =devm_reset_control_get_optional_exclusive (&pdev->dev, -NULL ); -if (IS_ERR (cevapriv->rst)) -dev_err_probe (&pdev->dev,PTR_ERR (cevapriv->rst), -"failed to get reset\n" ); - hpriv =ahci_platform_get_resources (pdev,0 );if (IS_ERR (hpriv))return PTR_ERR (hpriv); -if (!cevapriv->rst) { - rc =ahci_platform_enable_resources (hpriv); -if (rc) -return rc; - }else { -int i; + hpriv->rsts =devm_reset_control_get_optional_exclusive (&pdev->dev, +NULL ); +if (IS_ERR (hpriv->rsts)) +return dev_err_probe (&pdev->dev,PTR_ERR (hpriv->rsts), +"failed to get reset\n" ); - rc =ahci_platform_enable_clks (hpriv); -if (rc) -return rc; -/* Assert the controller reset */ -reset_control_assert (cevapriv->rst); - -for (i =0 ; i < hpriv->nports; i++) { - rc =phy_init (hpriv->phys[i]); -if (rc) -return rc; - } - -/* De-assert the controller reset */ -reset_control_deassert (cevapriv->rst); - -for (i =0 ; i < hpriv->nports; i++) { - rc =phy_power_on (hpriv->phys[i]); -if (rc) { -phy_exit (hpriv->phys[i]); -return rc; - } - } - } + rc =ceva_ahci_platform_enable_resources (hpriv); +if (rc) +return rc;if (of_property_read_bool (np,"ceva,broken-gen2" )) cevapriv->flags =CEVA_FLAG_BROKEN_GEN2 ;
@@ -252,52 +277,60 @@ static int ceva_ahci_probe(struct platform_device *pdev)if (of_property_read_u8_array (np,"ceva,p0-cominit-params" , (u8 *)&cevapriv->pp2c[0 ],4 ) <0 ) {dev_warn (dev,"ceva,p0-cominit-params property not defined\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto disable_resources; }if (of_property_read_u8_array (np,"ceva,p1-cominit-params" , (u8 *)&cevapriv->pp2c[1 ],4 ) <0 ) {dev_warn (dev,"ceva,p1-cominit-params property not defined\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto disable_resources; }/* Read OOB timing value for COMWAKE from device-tree*/ if (of_property_read_u8_array (np,"ceva,p0-comwake-params" , (u8 *)&cevapriv->pp3c[0 ],4 ) <0 ) {dev_warn (dev,"ceva,p0-comwake-params property not defined\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto disable_resources; }if (of_property_read_u8_array (np,"ceva,p1-comwake-params" , (u8 *)&cevapriv->pp3c[1 ],4 ) <0 ) {dev_warn (dev,"ceva,p1-comwake-params property not defined\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto disable_resources; }/* Read phy BURST timing value from device-tree */ if (of_property_read_u8_array (np,"ceva,p0-burst-params" , (u8 *)&cevapriv->pp4c[0 ],4 ) <0 ) {dev_warn (dev,"ceva,p0-burst-params property not defined\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto disable_resources; }if (of_property_read_u8_array (np,"ceva,p1-burst-params" , (u8 *)&cevapriv->pp4c[1 ],4 ) <0 ) {dev_warn (dev,"ceva,p1-burst-params property not defined\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto disable_resources; }/* Read phy RETRY interval timing value from device-tree */ if (of_property_read_u16_array (np,"ceva,p0-retry-params" , (u16 *)&cevapriv->pp5c[0 ],2 ) <0 ) {dev_warn (dev,"ceva,p0-retry-params property not defined\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto disable_resources; }if (of_property_read_u16_array (np,"ceva,p1-retry-params" , (u16 *)&cevapriv->pp5c[1 ],2 ) <0 ) {dev_warn (dev,"ceva,p1-retry-params property not defined\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto disable_resources; }/*
@@ -335,7 +368,7 @@ static int __maybe_unused ceva_ahci_resume(struct device *dev)struct ahci_host_priv *hpriv = host->private_data;int rc; - rc =ahci_platform_enable_resources (hpriv); + rc =ceva_ahci_platform_enable_resources (hpriv);if (rc)return rc;
Signature · 1 line
2.43.0