[PATCH v6 13/25] powerpc: Remove direct call to mmap2 syscall handlers

Michael Ellerman mpe at ellerman.id.au
Fri Sep 30 23:19:46 AEST 2022


"Arnd Bergmann" <arnd at arndb.de> writes:
> On Wed, Sep 28, 2022, at 2:15 PM, Michael Ellerman wrote:
>
>> But I think it makes more sense to do the same as mmap2() and pass the
>> 4K offset through, and pass shift = PAGE_SHIFT - 12. I also borrowed the
>> "off_4k" name from arm64. End result:
>>
>> #ifdef CONFIG_COMPAT
>> COMPAT_SYSCALL_DEFINE6(mmap2,
>> 		       unsigned long, addr, size_t, len,
>> 		       unsigned long, prot, unsigned long, flags,
>> 		       unsigned long, fd, unsigned long, off_4k)
>> {
>> 	return do_mmap2(addr, len, prot, flags, fd, off_4k, PAGE_SHIFT-12);
>> }
>> #endif
>>
>> With that my G5 boots again :)
>
> Any chance we can instead add a working compat_sys_mmap2/sys_mmap2
> in mm/mmap.c alongside the sys_mmap_pgoff implementation?

I've merged this, but happy to clean things up in a subsequent patch :)

> While sys_mmap_pgoff() was meant to replace the various sys_mmap2()
> implementations, I think it was ultimately a mistake, and we later
> converged on the sys_mmap2() calling conventions with 12 bits
> offset for almost all 32-bit architectures.

I only see 3 compat mmap2s:

  $ gg "COMPAT_SYSCALL.*mmap2"
  arch/arm64/kernel/sys32.c:COMPAT_SYSCALL_DEFINE6(aarch32_mmap2, unsigned long, addr, unsigned long, len,
  arch/powerpc/kernel/syscalls.c:COMPAT_SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
  arch/s390/kernel/compat_linux.c:COMPAT_SYSCALL_DEFINE1(s390_mmap2, struct mmap_arg_struct_emu31 __user *, arg)

s390 is weird.

The arm64 one and ours are similar, but we have the additional call to
arch_validate_prot(prot, addr). arm64 does implement arch_validate_prot().

Similar with mmap2, we call arch_validate_prot() but no one else does (why not?).

cheers


More information about the Linuxppc-dev mailing list