1 From 966ff2b4c758eb8c8c04f26422cd183e6aa8eda5 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Wed, 23 Jan 2019 18:25:50 +0000
4 Subject: [PATCH 316/806] char: vc_mem: Fix up compat ioctls for 64bit kernel
6 compat_ioctl wasn't defined, so 32bit user/64bit kernel
8 VC_MEM_IOC_MEM_PHYS_ADDR was defined with parameter size
9 unsigned long, so the ioctl cmd changes between sizes.
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
13 drivers/char/broadcom/vc_mem.c | 40 +++++++++++++++++++++++++++++----
14 include/linux/broadcom/vc_mem.h | 4 ++++
15 2 files changed, 40 insertions(+), 4 deletions(-)
17 --- a/drivers/char/broadcom/vc_mem.c
18 +++ b/drivers/char/broadcom/vc_mem.c
19 @@ -148,7 +148,7 @@ vc_mem_ioctl(struct file *file, unsigned
23 - pr_debug("%s: called file = 0x%p\n", __func__, file);
24 + pr_debug("%s: called file = 0x%p, cmd %08x\n", __func__, file, cmd);
27 case VC_MEM_IOC_MEM_PHYS_ADDR:
28 @@ -167,7 +167,7 @@ vc_mem_ioctl(struct file *file, unsigned
29 // Get the videocore memory size first
32 - pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%u\n", __func__,
33 + pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%x\n", __func__,
36 if (copy_to_user((void *) arg, &mm_vc_mem_size,
37 @@ -181,7 +181,7 @@ vc_mem_ioctl(struct file *file, unsigned
38 // Get the videocore memory base
41 - pr_debug("%s: VC_MEM_IOC_MEM_BASE=%u\n", __func__,
42 + pr_debug("%s: VC_MEM_IOC_MEM_BASE=%x\n", __func__,
45 if (copy_to_user((void *) arg, &mm_vc_mem_base,
46 @@ -195,7 +195,7 @@ vc_mem_ioctl(struct file *file, unsigned
47 // Get the videocore memory base
50 - pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%u\n", __func__,
51 + pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%x\n", __func__,
54 if (copy_to_user((void *) arg, &mm_vc_mem_base,
55 @@ -214,6 +214,35 @@ vc_mem_ioctl(struct file *file, unsigned
61 +vc_mem_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
66 + case VC_MEM_IOC_MEM_PHYS_ADDR32:
67 + pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR32=0x%p\n",
68 + __func__, (void *)mm_vc_mem_phys_addr);
70 + /* This isn't correct, but will cover us for now as
71 + * VideoCore is 32bit only.
73 + if (copy_to_user((void *)arg, &mm_vc_mem_phys_addr,
74 + sizeof(compat_ulong_t)))
80 + rc = vc_mem_ioctl(file, cmd, arg);
88 /****************************************************************************
91 @@ -259,6 +288,9 @@ static const struct file_operations vc_m
93 .release = vc_mem_release,
94 .unlocked_ioctl = vc_mem_ioctl,
96 + .compat_ioctl = vc_mem_compat_ioctl,
101 --- a/include/linux/broadcom/vc_mem.h
102 +++ b/include/linux/broadcom/vc_mem.h
103 @@ -32,4 +32,8 @@ extern unsigned int mm_vc_mem_size;
104 extern int vc_mem_get_current_size( void );
107 +#ifdef CONFIG_COMPAT
108 +#define VC_MEM_IOC_MEM_PHYS_ADDR32 _IOR(VC_MEM_IOC_MAGIC, 0, compat_ulong_t)
111 #endif /* _VC_MEM_H */