diff mbox series

[v4,06/20] powerpc: Remove direct call to mmap2 syscall handlers

Message ID 20220824020548.62625-7-rmclure@linux.ibm.com (mailing list archive)
State Changes Requested
Headers show
Series powerpc: Syscall wrapper and register clearing | expand

Commit Message

Rohan McLure Aug. 24, 2022, 2:05 a.m. UTC
Syscall handlers should not be invoked internally by their symbol names,
as these symbols defined by the architecture-defined SYSCALL_DEFINE
macro. Move the compatibility syscall definition for mmap2 to
syscalls.c, so that all mmap implementations can share an inline helper
function, as is done with the personality handlers.

Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
---
V1 -> V2: Move mmap2 compat implementation to asm/kernel/syscalls.c.
V3 -> V4: Move to be applied before syscall wrapper introduced.
---
 arch/powerpc/kernel/sys_ppc32.c |  9 ---------
 arch/powerpc/kernel/syscalls.c  | 11 +++++++++++
 2 files changed, 11 insertions(+), 9 deletions(-)

Comments

Nicholas Piggin Sept. 12, 2022, 9:47 a.m. UTC | #1
On Wed Aug 24, 2022 at 12:05 PM AEST, Rohan McLure wrote:
> Syscall handlers should not be invoked internally by their symbol names,
> as these symbols defined by the architecture-defined SYSCALL_DEFINE
> macro. Move the compatibility syscall definition for mmap2 to
> syscalls.c, so that all mmap implementations can share an inline helper
> function, as is done with the personality handlers.
>
> Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>

Is there any point to keping sys_ppc32.c at all? Might as well move them
all to syscall.c IMO.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

> ---
> V1 -> V2: Move mmap2 compat implementation to asm/kernel/syscalls.c.
> V3 -> V4: Move to be applied before syscall wrapper introduced.
> ---
>  arch/powerpc/kernel/sys_ppc32.c |  9 ---------
>  arch/powerpc/kernel/syscalls.c  | 11 +++++++++++
>  2 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
> index f4edcc9489fb..bc6491ed6454 100644
> --- a/arch/powerpc/kernel/sys_ppc32.c
> +++ b/arch/powerpc/kernel/sys_ppc32.c
> @@ -25,7 +25,6 @@
>  #include <linux/poll.h>
>  #include <linux/personality.h>
>  #include <linux/stat.h>
> -#include <linux/mman.h>
>  #include <linux/in.h>
>  #include <linux/syscalls.h>
>  #include <linux/unistd.h>
> @@ -48,14 +47,6 @@
>  #include <asm/syscalls.h>
>  #include <asm/switch_to.h>
>  
> -unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
> -			  unsigned long prot, unsigned long flags,
> -			  unsigned long fd, unsigned long pgoff)
> -{
> -	/* This should remain 12 even if PAGE_SIZE changes */
> -	return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
> -}
> -
>  /* 
>   * long long munging:
>   * The 32 bit ABI passes long longs in an odd even register pair.
> diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
> index b8461128c8f7..32fadf3c2cd3 100644
> --- a/arch/powerpc/kernel/syscalls.c
> +++ b/arch/powerpc/kernel/syscalls.c
> @@ -56,6 +56,17 @@ SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
>  	return do_mmap2(addr, len, prot, flags, fd, pgoff, PAGE_SHIFT-12);
>  }
>  
> +#ifdef CONFIG_COMPAT
> +COMPAT_SYSCALL_DEFINE6(mmap2,
> +		       unsigned long, addr, size_t, len,
> +		       unsigned long, prot, unsigned long, flags,
> +		       unsigned long, fd, unsigned long, pgoff)
> +{
> +	/* This should remain 12 even if PAGE_SIZE changes */
> +	return do_mmap2(addr, len, prot, flags, fd, pgoff << 12, PAGE_SHIFT-12);
> +}
> +#endif
> +
>  SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
>  		unsigned long, prot, unsigned long, flags,
>  		unsigned long, fd, off_t, offset)
> -- 
> 2.34.1
Rohan McLure Sept. 15, 2022, 5:06 a.m. UTC | #2
> On 12 Sep 2022, at 7:47 pm, Nicholas Piggin <npiggin@gmail.com> wrote:
> 
> On Wed Aug 24, 2022 at 12:05 PM AEST, Rohan McLure wrote:
>> Syscall handlers should not be invoked internally by their symbol names,
>> as these symbols defined by the architecture-defined SYSCALL_DEFINE
>> macro. Move the compatibility syscall definition for mmap2 to
>> syscalls.c, so that all mmap implementations can share an inline helper
>> function, as is done with the personality handlers.
>> 
>> Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
> 
> Is there any point to keping sys_ppc32.c at all? Might as well move them
> all to syscall.c IMO.

Currently serves as a fairly arbitrary distinginction between compat calls
and others, noting that a compat variant of personality is in syscalls.c.
May as well get rid of it.

> Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
> 
>> ---
>> V1 -> V2: Move mmap2 compat implementation to asm/kernel/syscalls.c.
>> V3 -> V4: Move to be applied before syscall wrapper introduced.
>> ---
>> arch/powerpc/kernel/sys_ppc32.c |  9 ---------
>> arch/powerpc/kernel/syscalls.c  | 11 +++++++++++
>> 2 files changed, 11 insertions(+), 9 deletions(-)
>> 
>> diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
>> index f4edcc9489fb..bc6491ed6454 100644
>> --- a/arch/powerpc/kernel/sys_ppc32.c
>> +++ b/arch/powerpc/kernel/sys_ppc32.c
>> @@ -25,7 +25,6 @@
>> #include <linux/poll.h>
>> #include <linux/personality.h>
>> #include <linux/stat.h>
>> -#include <linux/mman.h>
>> #include <linux/in.h>
>> #include <linux/syscalls.h>
>> #include <linux/unistd.h>
>> @@ -48,14 +47,6 @@
>> #include <asm/syscalls.h>
>> #include <asm/switch_to.h>
>> 
>> -unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
>> -			  unsigned long prot, unsigned long flags,
>> -			  unsigned long fd, unsigned long pgoff)
>> -{
>> -	/* This should remain 12 even if PAGE_SIZE changes */
>> -	return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
>> -}
>> -
>> /* 
>>  * long long munging:
>>  * The 32 bit ABI passes long longs in an odd even register pair.
>> diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
>> index b8461128c8f7..32fadf3c2cd3 100644
>> --- a/arch/powerpc/kernel/syscalls.c
>> +++ b/arch/powerpc/kernel/syscalls.c
>> @@ -56,6 +56,17 @@ SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
>> 	return do_mmap2(addr, len, prot, flags, fd, pgoff, PAGE_SHIFT-12);
>> }
>> 
>> +#ifdef CONFIG_COMPAT
>> +COMPAT_SYSCALL_DEFINE6(mmap2,
>> +		       unsigned long, addr, size_t, len,
>> +		       unsigned long, prot, unsigned long, flags,
>> +		       unsigned long, fd, unsigned long, pgoff)
>> +{
>> +	/* This should remain 12 even if PAGE_SIZE changes */
>> +	return do_mmap2(addr, len, prot, flags, fd, pgoff << 12, PAGE_SHIFT-12);
>> +}
>> +#endif
>> +
>> SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
>> 		unsigned long, prot, unsigned long, flags,
>> 		unsigned long, fd, off_t, offset)
>> -- 
>> 2.34.1
>
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index f4edcc9489fb..bc6491ed6454 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -25,7 +25,6 @@ 
 #include <linux/poll.h>
 #include <linux/personality.h>
 #include <linux/stat.h>
-#include <linux/mman.h>
 #include <linux/in.h>
 #include <linux/syscalls.h>
 #include <linux/unistd.h>
@@ -48,14 +47,6 @@ 
 #include <asm/syscalls.h>
 #include <asm/switch_to.h>
 
-unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
-			  unsigned long prot, unsigned long flags,
-			  unsigned long fd, unsigned long pgoff)
-{
-	/* This should remain 12 even if PAGE_SIZE changes */
-	return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
-}
-
 /* 
  * long long munging:
  * The 32 bit ABI passes long longs in an odd even register pair.
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index b8461128c8f7..32fadf3c2cd3 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -56,6 +56,17 @@  SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
 	return do_mmap2(addr, len, prot, flags, fd, pgoff, PAGE_SHIFT-12);
 }
 
+#ifdef CONFIG_COMPAT
+COMPAT_SYSCALL_DEFINE6(mmap2,
+		       unsigned long, addr, size_t, len,
+		       unsigned long, prot, unsigned long, flags,
+		       unsigned long, fd, unsigned long, pgoff)
+{
+	/* This should remain 12 even if PAGE_SIZE changes */
+	return do_mmap2(addr, len, prot, flags, fd, pgoff << 12, PAGE_SHIFT-12);
+}
+#endif
+
 SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
 		unsigned long, prot, unsigned long, flags,
 		unsigned long, fd, off_t, offset)