FAILED: patch "[PATCH] vfio/mlx5: Fix racy bitfields and tighten struct layout" failed to apply to 6.18-stable tree
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x f2365a63b02ddea32e7db78b742c2503ec7b81f1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026071330-plus-jackpot-fb60@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From f2365a63b02ddea32e7db78b742c2503ec7b81f1 Mon Sep 17 00:00:00 2001
From: Alex Williamson <[email protected]>
Date: Mon, 15 Jun 2026 13:12:32 -0600
Subject: [PATCH] vfio/mlx5: Fix racy bitfields and tighten struct layout
Bitfield operations are not atomic, they use a read-modify-write pattern, therefore we should be careful not to pack bitfields that can be concurrently updated into the same storage unit.
This split takes a binary approach: flags that are only modified pre/post open/close remain bitfields, flags modified from user action, including actions that reach across to another device (ex. reset) use dedicated storage units.
Note mlx5_vhca_page_tracker.status is relocated to fill the alignment hole this split exposes.
Bitfield justifications:
migrate_cap: written only in mlx5vf_cmd_set_migratable() at probe
chunk_mode: written only in mlx5vf_cmd_set_migratable() at probe
mig_state_cap: written only in mlx5vf_cmd_set_migratable() at probe
Dedicated storage units:
mdev_detach: written in the VF attach/detach event notifier
mlx5fv_vf_event() at runtime
log_active: written in mlx5vf_start_page_tracker()/
mlx5vf_stop_page_tracker() during runtime dirty tracking
deferred_reset: written in mlx5vf_state_mutex_unlock()/
mlx5vf_pci_aer_reset_done() during runtime reset handling
is_err: set by tracker error handling and dirty-log polling at runtime
object_changed: set by tracker event handling and cleared by dirty-log
polling at runtime
drivers/vfio/pci/mlx5/cmd.h +9 -6
@@ -158,26 +158,29 @@ struct mlx5_vhca_qp {struct mlx5_vhca_page_tracker {u32 id;u32 pdn; -u8 is_err:1 ; -u8 object_changed:1 ; +/* Flags modified at runtime - dedicated storage unit */ +u8 is_err; +u8 object_changed; +int status;struct mlx5_uars_page *uar;struct mlx5_vhca_cq cq;struct mlx5_vhca_qp *host_qp;struct mlx5_vhca_qp *fw_qp;struct mlx5_nb nb; -int status; };struct mlx5vf_pci_core_device {struct vfio_pci_core_device core_device;int vf_id;u16 vhca_id; +/* Flags only modified on setup/release - bitfield ok */ u8 migrate_cap:1 ; -u8 deferred_reset:1 ; -u8 mdev_detach:1 ; -u8 log_active:1 ;u8 chunk_mode:1 ;u8 mig_state_cap:1 ; +/* Flags modified at runtime - dedicated storage unit */ +u8 mdev_detach; +u8 log_active; +u8 deferred_reset;struct completion tracker_comp;/* protect migration state */ struct mutex state_mutex;
Sasha Levin
maintainerPATCH 1/1 vfio/mlx5: Fix racy bitfields and tighten struct layout
From: Alex Williamson <[email protected]>
[ Upstream commit f2365a63b02ddea32e7db78b742c2503ec7b81f1 ]
Bitfield operations are not atomic, they use a read-modify-write pattern, therefore we should be careful not to pack bitfields that can be concurrently updated into the same storage unit.
This split takes a binary approach: flags that are only modified pre/post open/close remain bitfields, flags modified from user action, including actions that reach across to another device (ex. reset) use dedicated storage units.
Note mlx5_vhca_page_tracker.status is relocated to fill the alignment hole this split exposes.
Bitfield justifications:
migrate_cap: written only in mlx5vf_cmd_set_migratable() at probe
chunk_mode: written only in mlx5vf_cmd_set_migratable() at probe
mig_state_cap: written only in mlx5vf_cmd_set_migratable() at probe
Dedicated storage units:
mdev_detach: written in the VF attach/detach event notifier
mlx5fv_vf_event() at runtime
log_active: written in mlx5vf_start_page_tracker()/
mlx5vf_stop_page_tracker() during runtime dirty tracking
deferred_reset: written in mlx5vf_state_mutex_unlock()/
mlx5vf_pci_aer_reset_done() during runtime reset handling
is_err: set by tracker error handling and dirty-log polling at runtime
object_changed: set by tracker event handling and cleared by dirty-log
polling at runtime
--- drivers/vfio/pci/mlx5/cmd.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/vfio/pci/mlx5/cmd.h +9 -6
@@ -155,25 +155,28 @@ struct mlx5_vhca_qp {struct mlx5_vhca_page_tracker {u32 id;u32 pdn; -u8 is_err:1 ; -u8 object_changed:1 ; +/* Flags modified at runtime - dedicated storage unit */ +u8 is_err; +u8 object_changed; +int status;struct mlx5_uars_page *uar;struct mlx5_vhca_cq cq;struct mlx5_vhca_qp *host_qp;struct mlx5_vhca_qp *fw_qp;struct mlx5_nb nb; -int status; };struct mlx5vf_pci_core_device {struct vfio_pci_core_device core_device;int vf_id;u16 vhca_id; +/* Flags only modified on setup/release - bitfield ok */ u8 migrate_cap:1 ; -u8 deferred_reset:1 ; -u8 mdev_detach:1 ; -u8 log_active:1 ;u8 chunk_mode:1 ; +/* Flags modified at runtime - dedicated storage unit */ +u8 mdev_detach; +u8 log_active; +u8 deferred_reset;struct completion tracker_comp;/* protect migration state */ struct mutex state_mutex;
Signature · 1 line
2.53.0