diff options
4 files changed, 270 insertions, 0 deletions
diff --git a/queue-6.12/media-uvcvideo-rollback-non-processed-entities-on-error.patch b/queue-6.12/media-uvcvideo-rollback-non-processed-entities-on-error.patch new file mode 100644 index 0000000000..4e3e4a40bd --- /dev/null +++ b/queue-6.12/media-uvcvideo-rollback-non-processed-entities-on-error.patch @@ -0,0 +1,113 @@ +From a70705d3c020d0d5c3ab6a5cc93e011ac35e7d48 Mon Sep 17 00:00:00 2001 +From: Ricardo Ribalda <ribalda@chromium.org> +Date: Mon, 24 Feb 2025 10:34:55 +0000 +Subject: media: uvcvideo: Rollback non processed entities on error + +From: Ricardo Ribalda <ribalda@chromium.org> + +commit a70705d3c020d0d5c3ab6a5cc93e011ac35e7d48 upstream. + +If we fail to commit an entity, we need to restore the +UVC_CTRL_DATA_BACKUP for the other uncommitted entities. Otherwise the +control cache and the device would be out of sync. + +Cc: stable@kernel.org +Fixes: b4012002f3a3 ("[media] uvcvideo: Add support for control events") +Reported-by: Hans de Goede <hdegoede@redhat.com> +Closes: https://lore.kernel.org/linux-media/fe845e04-9fde-46ee-9763-a6f00867929a@redhat.com/ +Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> +Message-ID: <20250224-uvc-data-backup-v2-3-de993ed9823b@chromium.org> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> +Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + drivers/media/usb/uvc/uvc_ctrl.c | 34 +++++++++++++++++++++++----------- + 1 file changed, 23 insertions(+), 11 deletions(-) + +--- a/drivers/media/usb/uvc/uvc_ctrl.c ++++ b/drivers/media/usb/uvc/uvc_ctrl.c +@@ -1848,7 +1848,7 @@ static int uvc_ctrl_commit_entity(struct + unsigned int processed_ctrls = 0; + struct uvc_control *ctrl; + unsigned int i; +- int ret; ++ int ret = 0; + + if (entity == NULL) + return 0; +@@ -1877,8 +1877,6 @@ static int uvc_ctrl_commit_entity(struct + dev->intfnum, ctrl->info.selector, + uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), + ctrl->info.size); +- else +- ret = 0; + + if (!ret) + processed_ctrls++; +@@ -1890,17 +1888,24 @@ static int uvc_ctrl_commit_entity(struct + + ctrl->dirty = 0; + +- if (ret < 0) { ++ if (ret < 0 && !rollback) { + if (err_ctrl) + *err_ctrl = ctrl; +- return ret; ++ /* ++ * If we fail to set a control, we need to rollback ++ * the next ones. ++ */ ++ rollback = 1; + } + +- if (!rollback && handle && ++ if (!rollback && handle && !ret && + ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS) + uvc_ctrl_set_handle(handle, ctrl, handle); + } + ++ if (ret) ++ return ret; ++ + return processed_ctrls; + } + +@@ -1931,7 +1936,8 @@ int __uvc_ctrl_commit(struct uvc_fh *han + struct uvc_video_chain *chain = handle->chain; + struct uvc_control *err_ctrl; + struct uvc_entity *entity; +- int ret = 0; ++ int ret_out = 0; ++ int ret; + + /* Find the control. */ + list_for_each_entry(entity, &chain->entities, chain) { +@@ -1942,17 +1948,23 @@ int __uvc_ctrl_commit(struct uvc_fh *han + ctrls->error_idx = + uvc_ctrl_find_ctrl_idx(entity, ctrls, + err_ctrl); +- goto done; ++ /* ++ * When we fail to commit an entity, we need to ++ * restore the UVC_CTRL_DATA_BACKUP for all the ++ * controls in the other entities, otherwise our cache ++ * and the hardware will be out of sync. ++ */ ++ rollback = 1; ++ ++ ret_out = ret; + } else if (ret > 0 && !rollback) { + uvc_ctrl_send_events(handle, entity, + ctrls->controls, ctrls->count); + } + } + +- ret = 0; +-done: + mutex_unlock(&chain->ctrl_mutex); +- return ret; ++ return ret_out; + } + + int uvc_ctrl_get(struct uvc_video_chain *chain, diff --git a/queue-6.12/series b/queue-6.12/series index 6e2c7e29be..40855055ee 100644 --- a/queue-6.12/series +++ b/queue-6.12/series @@ -184,3 +184,6 @@ drm-i915-dsi-fix-off-by-one-in-bxt_mipi_trans_vtotal.patch drm-amdgpu-fix-sdma-utc_l1-handling-during-start-stop-sequences.patch drm-amdgpu-switch-job-hw_fence-to-amdgpu_fence.patch drm-amd-display-fix-mpv-playback-corruption-on-weston.patch +media-uvcvideo-rollback-non-processed-entities-on-error.patch +x86-fpu-refactor-xfeature-bitmask-update-code-for-sigframe-xsave.patch +x86-pkeys-simplify-pkru-update-in-signal-frame.patch diff --git a/queue-6.12/x86-fpu-refactor-xfeature-bitmask-update-code-for-sigframe-xsave.patch b/queue-6.12/x86-fpu-refactor-xfeature-bitmask-update-code-for-sigframe-xsave.patch new file mode 100644 index 0000000000..7b9f59a3c0 --- /dev/null +++ b/queue-6.12/x86-fpu-refactor-xfeature-bitmask-update-code-for-sigframe-xsave.patch @@ -0,0 +1,85 @@ +From 64e54461ab6e8524a8de4e63b7d1a3e4481b5cf3 Mon Sep 17 00:00:00 2001 +From: "Chang S. Bae" <chang.seok.bae@intel.com> +Date: Tue, 15 Apr 2025 19:16:57 -0700 +Subject: x86/fpu: Refactor xfeature bitmask update code for sigframe XSAVE + +From: Chang S. Bae <chang.seok.bae@intel.com> + +commit 64e54461ab6e8524a8de4e63b7d1a3e4481b5cf3 upstream. + +Currently, saving register states in the signal frame, the legacy feature +bits are always set in xregs_state->header->xfeatures. This code sequence +can be generalized for reuse in similar cases. + +Refactor the logic to ensure a consistent approach across similar usages. + +Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com> +Signed-off-by: Ingo Molnar <mingo@kernel.org> +Cc: Andy Lutomirski <luto@kernel.org> +Cc: H. Peter Anvin <hpa@zytor.com> +Cc: Linus Torvalds <torvalds@linux-foundation.org> +Cc: Oleg Nesterov <oleg@redhat.com> +Link: https://lore.kernel.org/r/20250416021720.12305-8-chang.seok.bae@intel.com +Cc: Ben Hutchings <ben@decadent.org.uk> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/x86/kernel/fpu/signal.c | 11 +---------- + arch/x86/kernel/fpu/xstate.h | 13 +++++++++++++ + 2 files changed, 14 insertions(+), 10 deletions(-) + +--- a/arch/x86/kernel/fpu/signal.c ++++ b/arch/x86/kernel/fpu/signal.c +@@ -119,7 +119,6 @@ static inline bool save_xstate_epilog(vo + { + struct xregs_state __user *x = buf; + struct _fpx_sw_bytes sw_bytes = {}; +- u32 xfeatures; + int err; + + /* Setup the bytes not touched by the [f]xsave and reserved for SW. */ +@@ -133,12 +132,6 @@ static inline bool save_xstate_epilog(vo + (__u32 __user *)(buf + fpstate->user_size)); + + /* +- * Read the xfeatures which we copied (directly from the cpu or +- * from the state in task struct) to the user buffers. +- */ +- err |= __get_user(xfeatures, (__u32 __user *)&x->header.xfeatures); +- +- /* + * For legacy compatible, we always set FP/SSE bits in the bit + * vector while saving the state to the user context. This will + * enable us capturing any changes(during sigreturn) to +@@ -149,9 +142,7 @@ static inline bool save_xstate_epilog(vo + * header as well as change any contents in the memory layout. + * xrestore as part of sigreturn will capture all the changes. + */ +- xfeatures |= XFEATURE_MASK_FPSSE; +- +- err |= __put_user(xfeatures, (__u32 __user *)&x->header.xfeatures); ++ err |= set_xfeature_in_sigframe(x, XFEATURE_MASK_FPSSE); + + return !err; + } +--- a/arch/x86/kernel/fpu/xstate.h ++++ b/arch/x86/kernel/fpu/xstate.h +@@ -69,6 +69,19 @@ static inline u64 xfeatures_mask_indepen + return fpu_kernel_cfg.independent_features; + } + ++static inline int set_xfeature_in_sigframe(struct xregs_state __user *xbuf, u64 mask) ++{ ++ u64 xfeatures; ++ int err; ++ ++ /* Read the xfeatures value already saved in the user buffer */ ++ err = __get_user(xfeatures, &xbuf->header.xfeatures); ++ xfeatures |= mask; ++ err |= __put_user(xfeatures, &xbuf->header.xfeatures); ++ ++ return err; ++} ++ + /* + * Update the value of PKRU register that was already pushed onto the signal frame. + */ diff --git a/queue-6.12/x86-pkeys-simplify-pkru-update-in-signal-frame.patch b/queue-6.12/x86-pkeys-simplify-pkru-update-in-signal-frame.patch new file mode 100644 index 0000000000..3d16ec4868 --- /dev/null +++ b/queue-6.12/x86-pkeys-simplify-pkru-update-in-signal-frame.patch @@ -0,0 +1,69 @@ +From d1e420772cd1eb0afe5858619c73ce36f3e781a1 Mon Sep 17 00:00:00 2001 +From: "Chang S. Bae" <chang.seok.bae@intel.com> +Date: Tue, 15 Apr 2025 19:16:58 -0700 +Subject: x86/pkeys: Simplify PKRU update in signal frame + +From: Chang S. Bae <chang.seok.bae@intel.com> + +commit d1e420772cd1eb0afe5858619c73ce36f3e781a1 upstream. + +The signal delivery logic was modified to always set the PKRU bit in +xregs_state->header->xfeatures by this commit: + + ae6012d72fa6 ("x86/pkeys: Ensure updated PKRU value is XRSTOR'd") + +However, the change derives the bitmask value using XGETBV(1), rather +than simply updating the buffer that already holds the value. Thus, this +approach induces an unnecessary dependency on XGETBV1 for PKRU handling. + +Eliminate the dependency by using the established helper function. +Subsequently, remove the now-unused 'mask' argument. + +Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com> +Signed-off-by: Ingo Molnar <mingo@kernel.org> +Cc: Andy Lutomirski <luto@kernel.org> +Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com> +Cc: H. Peter Anvin <hpa@zytor.com> +Cc: Linus Torvalds <torvalds@linux-foundation.org> +Cc: Oleg Nesterov <oleg@redhat.com> +Cc: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com> +Cc: Dave Hansen <dave.hansen@linux.intel.com> +Link: https://lore.kernel.org/r/20250416021720.12305-9-chang.seok.bae@intel.com +Cc: Ben Hutchings <ben@decadent.org.uk> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/x86/kernel/fpu/xstate.h | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +--- a/arch/x86/kernel/fpu/xstate.h ++++ b/arch/x86/kernel/fpu/xstate.h +@@ -85,18 +85,15 @@ static inline int set_xfeature_in_sigfra + /* + * Update the value of PKRU register that was already pushed onto the signal frame. + */ +-static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u64 mask, u32 pkru) ++static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u32 pkru) + { +- u64 xstate_bv; + int err; + + if (unlikely(!cpu_feature_enabled(X86_FEATURE_OSPKE))) + return 0; + + /* Mark PKRU as in-use so that it is restored correctly. */ +- xstate_bv = (mask & xfeatures_in_use()) | XFEATURE_MASK_PKRU; +- +- err = __put_user(xstate_bv, &buf->header.xfeatures); ++ err = set_xfeature_in_sigframe(buf, XFEATURE_MASK_PKRU); + if (err) + return err; + +@@ -317,7 +314,7 @@ static inline int xsave_to_user_sigframe + clac(); + + if (!err) +- err = update_pkru_in_sigframe(buf, mask, pkru); ++ err = update_pkru_in_sigframe(buf, pkru); + + return err; + } |