Skip to content

Commit

Permalink
ashmem: Fix flush routine of ashmem
Browse files Browse the repository at this point in the history
The ashmem flush function ashmem_flush_cache_range was calling
dmac_clean_range and dmac_flush_range with a user virtual address
which is not allowed. Instead of calling dmac_clean_range or
dmac_flush_range use flush_cache_user_range which can be called
with a user vitual address.

Change-Id: I5dd137fb248b45ef2c7ea5f7bdb4b540b8310af9
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
  • Loading branch information
Shubhraprakash Das authored and hyperb1iss committed May 25, 2011
1 parent 8573b4f commit b9385c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
1 change: 0 additions & 1 deletion include/linux/ashmem.h
Expand Up @@ -45,7 +45,6 @@ struct ashmem_pin {
#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
#define ASHMEM_CACHE_FLUSH_RANGE _IO(__ASHMEMIOC, 11)
#define ASHMEM_CACHE_CLEAN_RANGE _IO(__ASHMEMIOC, 12)

int get_ashmem_file(int fd, struct file **filp, struct file **vm_file,
unsigned long *len);
Expand Down
28 changes: 4 additions & 24 deletions mm/ashmem.c
Expand Up @@ -668,7 +668,7 @@ static unsigned int kgsl_virtaddr_to_physaddr(unsigned int virtaddr)
}
#endif

static int ashmem_flush_cache_range(struct ashmem_area *asma, unsigned long cmd)
static int ashmem_flush_cache_range(struct ashmem_area *asma)
{
#ifdef CONFIG_OUTER_CACHE
unsigned long end;
Expand All @@ -686,19 +686,7 @@ static int ashmem_flush_cache_range(struct ashmem_area *asma, unsigned long cmd)
goto done;
}

switch (cmd) {
case ASHMEM_CACHE_FLUSH_RANGE:
dmac_flush_range((const void *)addr,
(const void *)(addr + size));
break;
case ASHMEM_CACHE_CLEAN_RANGE:
dmac_clean_range((const void *)addr,
(const void *)(addr + size));
break;
default:
result = -EINVAL;
goto done;
}
flush_cache_user_range(addr, addr + size);
#ifdef CONFIG_OUTER_CACHE
for (end = addr; end < (addr + size); end += PAGE_SIZE) {
unsigned long physaddr;
Expand All @@ -708,14 +696,7 @@ static int ashmem_flush_cache_range(struct ashmem_area *asma, unsigned long cmd)
goto done;
}

switch (cmd) {
case ASHMEM_CACHE_FLUSH_RANGE:
outer_flush_range(physaddr, physaddr + PAGE_SIZE);
break;
case ASHMEM_CACHE_CLEAN_RANGE:
outer_clean_range(physaddr, physaddr + PAGE_SIZE);
break;
}
outer_flush_range(physaddr, physaddr + PAGE_SIZE);
}
mb();
#endif
Expand Down Expand Up @@ -765,8 +746,7 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
}
break;
case ASHMEM_CACHE_FLUSH_RANGE:
case ASHMEM_CACHE_CLEAN_RANGE:
ret = ashmem_flush_cache_range(asma, cmd);
ret = ashmem_flush_cache_range(asma);
break;
}

Expand Down

0 comments on commit b9385c3

Please sign in to comment.