-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
In _k_object's definition
struct _k_object {
char *name;
u8_t perms[CONFIG_MAX_THREAD_BYTES];
u8_t type;
u8_t flags;
u32_t data;
} __packed;
if CONFIG_MAX_THREAD_BYTES is 4, 8, 12.... , then the size of _k_object is not 4 bytes aligned.
Because __packed is used, this will may cause perms[CONFIG_MAX_THREAD_BYTES] even char * name are not 4 bytes aligned.
In usespace.c
void _thread_perms_set(struct _k_object *ko, struct k_thread *thread)
{
int index = thread_index_get(thread);
if (index != -1) {
sys_bitfield_set_bit((mem_addr_t)&ko->perms, index);
}
}
sys_bitfield_set is used to set some bit to of perms
However, for most arch in zephyr. an assumption of sys_bitfield_set is that the mem_addr_t addr should be 4 bytes/32 bit aligned .
For the case perms, if arch supports unaligned mem access, no exception will be raised, but possible performance downgrade; if arch does not support unaligned mem access or disable it, an exception will be raised.
So, suggest to guarantee the access to ** struct _k_object's perms** should be 4 bytes/32bit aligned.
Or guarantee the start address of struct _k_object should be 4 bytes/32 bit aligned