Skip to content

Commit 8381e0b

Browse files
committed
vregion: make 3 vregion API functions syscalls
vregion_get(), vregion_put() and vregion_set_interim() should also be callable from the userspace. Make them syscalls. Also remove redundant symbol exporting since the vregion API shouldn't be used directly by LLEXT modules. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 301e551 commit 8381e0b

3 files changed

Lines changed: 32 additions & 12 deletions

File tree

‎src/include/sof/lib/vregion.h‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct vregion *vregion_create(size_t memsize);
5151
*
5252
* @param[in] vr Pointer to the virtual region instance.
5353
*/
54-
void vregion_set_interim(struct vregion *vr);
54+
__syscall void vregion_set_interim(struct vregion *vr);
5555

5656
/**
5757
* @brief Increment virtual region's user count.
@@ -62,7 +62,7 @@ void vregion_set_interim(struct vregion *vr);
6262
* @param[in] vr Pointer to the virtual region instance to release.
6363
* @return struct vregion* Pointer to the virtual region instance.
6464
*/
65-
struct vregion *vregion_get(struct vregion *vr);
65+
__syscall struct vregion *vregion_get(struct vregion *vr);
6666

6767
/**
6868
* @brief Decrement virtual region's user count or destroy it.
@@ -73,7 +73,7 @@ struct vregion *vregion_get(struct vregion *vr);
7373
* @param[in] vr Pointer to the virtual region instance to release.
7474
* @return struct vregion* Pointer to the virtual region instance or NULL if it has been destroyed.
7575
*/
76-
struct vregion *vregion_put(struct vregion *vr);
76+
__syscall struct vregion *vregion_put(struct vregion *vr);
7777

7878
/**
7979
* @brief Allocate memory from the specified virtual region.
@@ -147,6 +147,8 @@ void vregion_owner_set(struct vregion *vr, void *owner);
147147
void *vregion_owner_get(struct vregion *vr);
148148
bool vregion_verify(struct vregion *vr);
149149

150+
#include <zephyr/syscalls/vregion.h>
151+
150152
#else /* CONFIG_SOF_VREGIONS */
151153

152154
struct vregion {
@@ -200,8 +202,4 @@ static inline bool vregion_verify(struct vregion *vr) {return false;}
200202
}
201203
#endif
202204

203-
#if CONFIG_SOF_VREGIONS
204-
#include <zephyr/syscalls/vregion.h>
205-
#endif
206-
207205
#endif /* __SOF_LIB_VREGION_H__ */

‎zephyr/lib/vregion.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ struct vregion *vregion_create(size_t memsize)
163163

164164
/* log the new vregion */
165165
LOG_INF("new at base %p size %#zx pages %u metadata at %p",
166-
(void *)vr->base, total_size, pages, (void *)vr);
166+
(void *)vregion_base, total_size, pages, (void *)vr);
167167

168168
return vr;
169169
}
170170

171-
struct vregion *vregion_get(struct vregion *vr)
171+
struct vregion *z_impl_vregion_get(struct vregion *vr)
172172
{
173173
if (!vr)
174174
return NULL;
@@ -186,7 +186,7 @@ struct vregion *vregion_get(struct vregion *vr)
186186
* @param[in] vr Pointer to the virtual region instance to release.
187187
* @return struct vregion* Pointer to the virtual region instance or NULL if it has been destroyed.
188188
*/
189-
struct vregion *vregion_put(struct vregion *vr)
189+
struct vregion *z_impl_vregion_put(struct vregion *vr)
190190
{
191191
unsigned int use_count;
192192

@@ -261,7 +261,7 @@ static void interim_heap_init(struct vregion *vr)
261261
vr->lifetime.used = (uint8_t *)vr->lifetime.ptr - (uint8_t *)vr->lifetime.base;
262262
}
263263

264-
void vregion_set_interim(struct vregion *vr)
264+
void z_impl_vregion_set_interim(struct vregion *vr)
265265
{
266266
if (!vr)
267267
return;
@@ -493,7 +493,6 @@ void vregion_info(struct vregion *vr)
493493
LOG_INF("lifetime used %#zx free count %d",
494494
vr->lifetime.used, vr->lifetime.free_count);
495495
}
496-
EXPORT_SYMBOL(vregion_info);
497496

498497
void vregion_mem_info(struct vregion *vr, size_t *size, uintptr_t *start)
499498
{

‎zephyr/syscall/vregion.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,26 @@ static inline void z_vrfy_vregion_free(struct vregion *vr, void *ptr)
4949
z_impl_vregion_free(vr, ptr);
5050
}
5151
#include <zephyr/syscalls/vregion_free_mrsh.c>
52+
53+
struct vregion *z_vrfy_vregion_get(struct vregion *vr)
54+
{
55+
if (vregion_verify(vr))
56+
return z_impl_vregion_get(vr);
57+
return NULL;
58+
}
59+
#include <zephyr/syscalls/vregion_get_mrsh.c>
60+
61+
struct vregion *z_vrfy_vregion_put(struct vregion *vr)
62+
{
63+
if (vregion_verify(vr))
64+
return z_impl_vregion_put(vr);
65+
return NULL;
66+
}
67+
#include <zephyr/syscalls/vregion_put_mrsh.c>
68+
69+
void z_vrfy_vregion_set_interim(struct vregion *vr)
70+
{
71+
if (vregion_verify(vr))
72+
z_impl_vregion_set_interim(vr);
73+
}
74+
#include <zephyr/syscalls/vregion_set_interim_mrsh.c>

0 commit comments

Comments
 (0)