Skip to content

Commit 2fde596

Browse files
jxsteltersoftwarecki
authored andcommitted
module_adapter: Allocate data buffers from MMU shared heap
The security reqirements assume that the non-privileged modules data and code should be protected from other non-privileged modules access. The audio data could be accessible. This PR allocates audio data buffer from shared memory heap. This change is effective only when CONFIG_USERSPACE=y. Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
1 parent 5f6b452 commit 2fde596

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/audio/module_adapter/module_adapter.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ int module_adapter_prepare(struct comp_dev *dev)
265265
/* allocate memory for input buffers */
266266
if (mod->max_sources) {
267267
mod->input_buffers =
268-
rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
268+
rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_MMU_SHD,
269269
sizeof(*mod->input_buffers) * mod->max_sources);
270270
if (!mod->input_buffers) {
271271
comp_err(dev, "module_adapter_prepare(): failed to allocate input buffers");
@@ -278,7 +278,7 @@ int module_adapter_prepare(struct comp_dev *dev)
278278
/* allocate memory for output buffers */
279279
if (mod->max_sinks) {
280280
mod->output_buffers =
281-
rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
281+
rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_MMU_SHD,
282282
sizeof(*mod->output_buffers) * mod->max_sinks);
283283
if (!mod->output_buffers) {
284284
comp_err(dev, "module_adapter_prepare(): failed to allocate output buffers");
@@ -345,7 +345,7 @@ int module_adapter_prepare(struct comp_dev *dev)
345345
list_for_item(blist, &dev->bsource_list) {
346346
size_t size = MAX(mod->deep_buff_bytes, mod->period_bytes);
347347

348-
mod->input_buffers[i].data = rballoc(0, SOF_MEM_CAPS_RAM, size);
348+
mod->input_buffers[i].data = rballoc(0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_MMU_SHD, size);
349349
if (!mod->input_buffers[i].data) {
350350
comp_err(mod->dev, "module_adapter_prepare(): Failed to alloc input buffer data");
351351
ret = -ENOMEM;
@@ -357,7 +357,8 @@ int module_adapter_prepare(struct comp_dev *dev)
357357
/* allocate memory for output buffer data */
358358
i = 0;
359359
list_for_item(blist, &dev->bsink_list) {
360-
mod->output_buffers[i].data = rballoc(0, SOF_MEM_CAPS_RAM, md->mpd.out_buff_size);
360+
mod->output_buffers[i].data = rballoc(0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_MMU_SHD,
361+
md->mpd.out_buff_size);
361362
if (!mod->output_buffers[i].data) {
362363
comp_err(mod->dev, "module_adapter_prepare(): Failed to alloc output buffer data");
363364
ret = -ENOMEM;
@@ -370,7 +371,8 @@ int module_adapter_prepare(struct comp_dev *dev)
370371
if (list_is_empty(&mod->sink_buffer_list)) {
371372
for (i = 0; i < mod->num_of_sinks; i++) {
372373
/* allocate not shared buffer */
373-
struct comp_buffer *buffer = buffer_alloc(buff_size, SOF_MEM_CAPS_RAM,
374+
struct comp_buffer *buffer = buffer_alloc(buff_size,
375+
SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_MMU_SHD,
374376
0, PLATFORM_DCACHE_ALIGN, false);
375377
uint32_t flags;
376378

0 commit comments

Comments
 (0)