Skip to content

Commit 9b67276

Browse files
committed
zephyr: map IPC4 HOSTBOX partitions into user LL memory domain
The user-space IPC thread reads the IPC4 module init parameter block directly from MAILBOX_HOSTBOX_BASE (comp_new_ipc4() / comp_new_ipc4_user()), so the HOSTBOX region must be reachable from the user LL memory domain. Map two partitions when CONFIG_SOF_USERSPACE_LL && CONFIG_IPC_MAJOR_4: an uncached read-only view for the parameter reads, and a cached RW view because the sys_cache_data_invd_range() syscall verifier requires write access to the invalidated range. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 03c7169 commit 9b67276

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

zephyr/lib/userspace_helper.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,39 @@ int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id)
110110
if (ret < 0)
111111
return ret;
112112

113+
#if defined(CONFIG_SOF_USERSPACE_LL) && defined(CONFIG_IPC_MAJOR_4)
114+
/* HOSTBOX partitions for IPC4 module init parameter block reads.
115+
* comp_new_ipc4() accesses MAILBOX_HOSTBOX_BASE directly to get
116+
* the module configuration data sent by the host.
117+
*/
118+
struct k_mem_partition hostbox_partition;
119+
120+
/* Uncached HOSTBOX partition */
121+
hostbox_partition.start =
122+
(uintptr_t)sys_cache_uncached_ptr_get((void __sparse_cache *)MAILBOX_HOSTBOX_BASE);
123+
hostbox_partition.size = ALIGN_UP(MAILBOX_HOSTBOX_SIZE,
124+
CONFIG_MMU_PAGE_SIZE);
125+
hostbox_partition.attr = K_MEM_PARTITION_P_RO_U_RO;
126+
127+
ret = k_mem_domain_add_partition(domain, &hostbox_partition);
128+
if (ret < 0)
129+
return ret;
130+
131+
/* Cached HOSTBOX partition for cache invalidation path.
132+
* sys_cache_data_invd_range() syscall verification requires
133+
* write access to the region, so use RW instead of RO.
134+
*/
135+
hostbox_partition.start =
136+
(uintptr_t)sys_cache_cached_ptr_get((void *)MAILBOX_HOSTBOX_BASE);
137+
hostbox_partition.size = ALIGN_UP(MAILBOX_HOSTBOX_SIZE,
138+
CONFIG_MMU_PAGE_SIZE);
139+
hostbox_partition.attr = K_MEM_PARTITION_P_RW_U_RW;
140+
141+
ret = k_mem_domain_add_partition(domain, &hostbox_partition);
142+
if (ret < 0)
143+
return ret;
144+
#endif /* CONFIG_IPC_MAJOR_4 */
145+
113146
#ifndef CONFIG_IPC_MAJOR_4
114147
/*
115148
* Next mailbox_stream (not available in IPC4). Stream access is cached,

0 commit comments

Comments
 (0)