|
@@ -182,7 +182,9 @@
|
|
#define FASTRPC_CPUINFO_EARLY_WAKEUP (1)
|
|
#define FASTRPC_CPUINFO_EARLY_WAKEUP (1)
|
|
|
|
|
|
#define INIT_FILELEN_MAX (2*1024*1024)
|
|
#define INIT_FILELEN_MAX (2*1024*1024)
|
|
-#define INIT_MEMLEN_MAX (8*1024*1024)
|
|
|
|
|
|
+#define INIT_MEMLEN_MAX_STATIC (8*1024*1024)
|
|
|
|
+#define INIT_MEMLEN_MAX_DYNAMIC (200*1024*1024)
|
|
|
|
+#define INIT_MEMLEN_MIN_DYNAMIC (3*1024*1024)
|
|
#define MAX_CACHE_BUF_SIZE (8*1024*1024)
|
|
#define MAX_CACHE_BUF_SIZE (8*1024*1024)
|
|
|
|
|
|
/* Maximum buffers cached in cached buffer list */
|
|
/* Maximum buffers cached in cached buffer list */
|
|
@@ -3622,7 +3624,7 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
|
|
remote_arg_t ra[6];
|
|
remote_arg_t ra[6];
|
|
int fds[6];
|
|
int fds[6];
|
|
unsigned int gid = 0, one_mb = 1024*1024;
|
|
unsigned int gid = 0, one_mb = 1024*1024;
|
|
- unsigned int dsp_userpd_memlen = 3 * one_mb;
|
|
|
|
|
|
+ unsigned int dsp_userpd_memlen = 0;
|
|
struct fastrpc_buf *init_mem;
|
|
struct fastrpc_buf *init_mem;
|
|
|
|
|
|
struct {
|
|
struct {
|
|
@@ -3642,6 +3644,20 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
fl->dsp_process_state = PROCESS_CREATE_IS_INPROGRESS;
|
|
fl->dsp_process_state = PROCESS_CREATE_IS_INPROGRESS;
|
|
|
|
+
|
|
|
|
+ if (init->memlen) {
|
|
|
|
+ if(init->memlen > INIT_MEMLEN_MAX_DYNAMIC || init->memlen < INIT_MEMLEN_MIN_DYNAMIC) {
|
|
|
|
+ ADSPRPC_ERR(
|
|
|
|
+ "init memory for process %d should be between %d and %d\n",
|
|
|
|
+ init->memlen, INIT_MEMLEN_MIN_DYNAMIC, INIT_MEMLEN_MAX_DYNAMIC);
|
|
|
|
+ err = -EINVAL;
|
|
|
|
+ goto bail;
|
|
|
|
+ }
|
|
|
|
+ dsp_userpd_memlen = init->memlen;
|
|
|
|
+ } else {
|
|
|
|
+ dsp_userpd_memlen = 3*one_mb;
|
|
|
|
+ }
|
|
|
|
+
|
|
spin_unlock(&fl->hlock);
|
|
spin_unlock(&fl->hlock);
|
|
|
|
|
|
inbuf.pgid = fl->tgid;
|
|
inbuf.pgid = fl->tgid;
|
|
@@ -3733,7 +3749,7 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
|
|
* additional static heap initialized within the process.
|
|
* additional static heap initialized within the process.
|
|
*/
|
|
*/
|
|
if (fl->is_unsigned_pd)
|
|
if (fl->is_unsigned_pd)
|
|
- dsp_userpd_memlen += 2*one_mb;
|
|
|
|
|
|
+ dsp_userpd_memlen = 5*one_mb;
|
|
memlen = ALIGN(max(dsp_userpd_memlen, init->filelen * 4), one_mb);
|
|
memlen = ALIGN(max(dsp_userpd_memlen, init->filelen * 4), one_mb);
|
|
imem_dma_attr = DMA_ATTR_DELAYED_UNMAP | DMA_ATTR_NO_KERNEL_MAPPING;
|
|
imem_dma_attr = DMA_ATTR_DELAYED_UNMAP | DMA_ATTR_NO_KERNEL_MAPPING;
|
|
err = fastrpc_buf_alloc(fl, memlen, imem_dma_attr, 0,
|
|
err = fastrpc_buf_alloc(fl, memlen, imem_dma_attr, 0,
|
|
@@ -3859,6 +3875,14 @@ static int fastrpc_init_create_static_process(struct fastrpc_file *fl,
|
|
"untrusted app trying to attach to audio PD\n");
|
|
"untrusted app trying to attach to audio PD\n");
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
+ VERIFY(err, init->memlen <= INIT_MEMLEN_MAX_STATIC);
|
|
|
|
+ if (err) {
|
|
|
|
+ ADSPRPC_ERR(
|
|
|
|
+ "init memory for static process %d is more than max allowed init len %d\n",
|
|
|
|
+ init->memlen, INIT_MEMLEN_MAX_STATIC);
|
|
|
|
+ err = -EFBIG;
|
|
|
|
+ goto bail;
|
|
|
|
+ }
|
|
|
|
|
|
if (!init->filelen)
|
|
if (!init->filelen)
|
|
goto bail;
|
|
goto bail;
|
|
@@ -4038,12 +4062,12 @@ int fastrpc_init_process(struct fastrpc_file *fl,
|
|
struct fastrpc_channel_ctx *chan = NULL;
|
|
struct fastrpc_channel_ctx *chan = NULL;
|
|
|
|
|
|
VERIFY(err, init->filelen < INIT_FILELEN_MAX
|
|
VERIFY(err, init->filelen < INIT_FILELEN_MAX
|
|
- && init->memlen < INIT_MEMLEN_MAX);
|
|
|
|
|
|
+ && init->memlen <= INIT_MEMLEN_MAX_DYNAMIC);
|
|
if (err) {
|
|
if (err) {
|
|
ADSPRPC_ERR(
|
|
ADSPRPC_ERR(
|
|
"file size 0x%x or init memory 0x%x is more than max allowed file size 0x%x or init len 0x%x\n",
|
|
"file size 0x%x or init memory 0x%x is more than max allowed file size 0x%x or init len 0x%x\n",
|
|
init->filelen, init->memlen,
|
|
init->filelen, init->memlen,
|
|
- INIT_FILELEN_MAX, INIT_MEMLEN_MAX);
|
|
|
|
|
|
+ INIT_FILELEN_MAX, INIT_MEMLEN_MAX_DYNAMIC);
|
|
err = -EFBIG;
|
|
err = -EFBIG;
|
|
goto bail;
|
|
goto bail;
|
|
}
|
|
}
|
|
@@ -6582,7 +6606,6 @@ bail:
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
static inline int fastrpc_mmap_device_ioctl(struct fastrpc_file *fl,
|
|
static inline int fastrpc_mmap_device_ioctl(struct fastrpc_file *fl,
|
|
unsigned int ioctl_num, union fastrpc_ioctl_param *p,
|
|
unsigned int ioctl_num, union fastrpc_ioctl_param *p,
|
|
void *param)
|
|
void *param)
|