summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerban Constantinescu <serban.constantinescu@arm.com>2013-01-18 17:42:15 +0000
committerSerban Constantinescu <serban.constantinescu@arm.com>2013-01-23 13:21:26 +0000
commitfca1555ddc78a7801fde9e2d32ed86977287698b (patch)
tree6a04e483478e9478641d8108bc7b6cf21139be09
parent7d1f9aeff1ee4a20b1aeb377dd0f579fe9647619 (diff)
downloadlinux-topics-fca1555ddc78a7801fde9e2d32ed86977287698b.tar.gz
staging: android: ashmem: Add support for 32bit ashmem calls in a 64bit kernel
Android's shared memory subsystem, Ashmem, does not support calls from a 32-bit userspace in a 64 bit kernel. This patch adds support for syscalls coming from a 32-bit userspace in a 64-bit kernel. The patch has been successfully tested on ARMv8 AEM and Versatile Express V2P-CA9. Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
-rw-r--r--drivers/staging/android/ashmem.c20
-rw-r--r--drivers/staging/android/ashmem.h6
2 files changed, 25 insertions, 1 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 634b9ae713e..b93a557fb90 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -683,6 +683,22 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return ret;
}
+/* support for 32bit syscalls on 64bit systems */
+#ifdef CONFIG_COMPAT
+static long compat_ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ switch (cmd) {
+ case COMPAT_ASHMEM_SET_SIZE:
+ cmd = ASHMEM_SET_SIZE;
+ break;
+ case COMPAT_ASHMEM_SET_PROT_MASK:
+ cmd = ASHMEM_SET_PROT_MASK;
+ break;
+ }
+ return ashmem_ioctl(file, cmd, arg);
+}
+#endif /* CONFIG_COMPAT */
+
static const struct file_operations ashmem_fops = {
.owner = THIS_MODULE,
.open = ashmem_open,
@@ -691,7 +707,9 @@ static const struct file_operations ashmem_fops = {
.llseek = ashmem_llseek,
.mmap = ashmem_mmap,
.unlocked_ioctl = ashmem_ioctl,
- .compat_ioctl = ashmem_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = compat_ashmem_ioctl,
+#endif
};
static struct miscdevice ashmem_misc = {
diff --git a/drivers/staging/android/ashmem.h b/drivers/staging/android/ashmem.h
index 1976b10ef93..5605fd134df 100644
--- a/drivers/staging/android/ashmem.h
+++ b/drivers/staging/android/ashmem.h
@@ -45,4 +45,10 @@ struct ashmem_pin {
#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
+/* support for 32bit syscalls on 64bit systems */
+#ifdef CONFIG_COMPAT
+#define COMPAT_ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, compat_size_t)
+#define COMPAT_ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned int)
+#endif
+
#endif /* _LINUX_ASHMEM_H */