Skip to content

Commit

Permalink
libtcmu: fix tcmulib to get next command on aarch64
Browse files Browse the repository at this point in the history
Use the appropriate atomic load instruction to ensure we synchronize
the read of the command ring head index with any previous stores. Not
doing this causes command ring corruption on aarch64:

[Tue Oct  4 15:45:50 2022] cmd_id 0 not found, ring is broken
[Tue Oct  4 15:45:50 2022] ring broken, not handling completions

Signed-off-by: Alex Reid <alex.reid@storageos.com>
  • Loading branch information
Alex Reid authored and lxbsz committed May 26, 2023
1 parent 7b9e500 commit 1bdb239
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libtcmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,13 @@ device_cmd_head(struct tcmu_device *dev)
{
struct tcmu_mailbox *mb = dev->map;

return (struct tcmu_cmd_entry *) ((char *) mb + mb->cmdr_off + mb->cmd_head);
/*
* We must load the mb_head index using an atomic load or we'll crash
* on aarch64. See https://github.com/open-iscsi/tcmu-runner/issues/688
*/
uint32_t mb_head = __atomic_load_n(&mb->cmd_head, __ATOMIC_ACQUIRE);
struct tcmu_cmd_entry* e = (struct tcmu_cmd_entry *) ((char *) mb + mb->cmdr_off + mb_head);
return e;
}

static inline struct tcmu_cmd_entry *
Expand Down

0 comments on commit 1bdb239

Please sign in to comment.