Skip to content

Commit cae095b

Browse files
jxsteltersoftwarecki
authored andcommitted
module_adapter: Allocate data buffers from MMU shared heap
Allocates audio data buffer from shared memory 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 change is effective only when CONFIG_USERSPACE=y. Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com> Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent cc45308 commit cae095b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/audio/module_adapter/module_adapter.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ int module_adapter_prepare(struct comp_dev *dev)
176176
struct list_item *blist, *_blist;
177177
uint32_t buff_periods;
178178
uint32_t buff_size; /* size of local buffer */
179+
int memory_flags;
179180
int i = 0;
180181

181182
comp_dbg(dev, "module_adapter_prepare() start");
@@ -287,11 +288,11 @@ int module_adapter_prepare(struct comp_dev *dev)
287288

288289
module_adapter_check_data(mod, dev, sink);
289290

291+
memory_flags = dev->drv->drv_heap ? SOF_MEM_FLAG_USER_SHARED : SOF_MEM_FLAG_USER;
290292
/* allocate memory for input buffers */
291293
if (mod->max_sources) {
292294
mod->input_buffers =
293-
rzalloc(SOF_MEM_FLAG_USER,
294-
sizeof(*mod->input_buffers) * mod->max_sources);
295+
rzalloc(memory_flags, sizeof(*mod->input_buffers) * mod->max_sources);
295296
if (!mod->input_buffers) {
296297
comp_err(dev, "module_adapter_prepare(): failed to allocate input buffers");
297298
return -ENOMEM;
@@ -303,8 +304,7 @@ int module_adapter_prepare(struct comp_dev *dev)
303304
/* allocate memory for output buffers */
304305
if (mod->max_sinks) {
305306
mod->output_buffers =
306-
rzalloc(SOF_MEM_FLAG_USER,
307-
sizeof(*mod->output_buffers) * mod->max_sinks);
307+
rzalloc(memory_flags, sizeof(*mod->output_buffers) * mod->max_sinks);
308308
if (!mod->output_buffers) {
309309
comp_err(dev, "module_adapter_prepare(): failed to allocate output buffers");
310310
ret = -ENOMEM;
@@ -370,7 +370,7 @@ int module_adapter_prepare(struct comp_dev *dev)
370370
list_for_item(blist, &dev->bsource_list) {
371371
size_t size = MAX(mod->deep_buff_bytes, mod->period_bytes);
372372

373-
mod->input_buffers[i].data = rballoc(SOF_MEM_FLAG_USER, size);
373+
mod->input_buffers[i].data = rballoc(memory_flags, size);
374374
if (!mod->input_buffers[i].data) {
375375
comp_err(mod->dev, "module_adapter_prepare(): Failed to alloc input buffer data");
376376
ret = -ENOMEM;
@@ -382,7 +382,7 @@ int module_adapter_prepare(struct comp_dev *dev)
382382
/* allocate memory for output buffer data */
383383
i = 0;
384384
list_for_item(blist, &dev->bsink_list) {
385-
mod->output_buffers[i].data = rballoc(SOF_MEM_FLAG_USER, md->mpd.out_buff_size);
385+
mod->output_buffers[i].data = rballoc(memory_flags, md->mpd.out_buff_size);
386386
if (!mod->output_buffers[i].data) {
387387
comp_err(mod->dev, "module_adapter_prepare(): Failed to alloc output buffer data");
388388
ret = -ENOMEM;
@@ -395,7 +395,7 @@ int module_adapter_prepare(struct comp_dev *dev)
395395
if (list_is_empty(&mod->raw_data_buffers_list)) {
396396
for (i = 0; i < mod->num_of_sinks; i++) {
397397
/* allocate not shared buffer */
398-
struct comp_buffer *buffer = buffer_alloc(buff_size, SOF_MEM_FLAG_USER,
398+
struct comp_buffer *buffer = buffer_alloc(buff_size, memory_flags,
399399
PLATFORM_DCACHE_ALIGN, false);
400400
uint32_t flags;
401401

0 commit comments

Comments
 (0)