[...]
> +static __always_inline int
> +__lsui_user_swpb_asm(unsigned int *data, unsigned int addr)
> +{
> + unsigned char idx;
> + int err;
> + unsigned int addr_al;
> + union {
> + unsigned int var;
> + unsigned char raw[4];
> + } data_al;
> +
> + idx = addr & (sizeof(unsigned int) - 1);
> + addr_al = ALIGN_DOWN(addr, sizeof(unsigned int));
> +
> + if (get_user(data_al.var, (unsigned int *)(unsigned long)addr_al))
> + return -EFAULT;
> +
> + data_al.raw[idx] = *data;
> +
> + err = __lsui_user_swp_asm(&data_al.var, addr_al);
I found that using swpt for swpb can cause a race condition
when each CPU accesses its own dedicated byte memory region in 4 bytes.
So, unless there are any comments,
I’ll rework it with a cast in the next version.
> + if (!err)
> + *data = data_al.raw[idx];
> +
> + return err;
> +}
> +#endif /* CONFIG_AS_HAS_LSUI */
Thanks.
--
Sincerely,
Yeoreum Yun