On Thu, Jan 2, 2025, at 19:34, Jiaxun Yang wrote: > > +#ifdef CONFIG_32BIT > +SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, unsigned long, > + prot, unsigned long, flags, unsigned long, fd, unsigned long, offset) > +{ > + /* > + * Note that the shift for mmap2 is constant (12), > + * regardless of PAGE_SIZE > + */ > + > + if (offset & (~PAGE_MASK >> 12)) > + return -EINVAL; > + > + return ksys_mmap_pgoff(addr, len, prot, flags, fd, > + offset >> (PAGE_SHIFT - 12)); > +} > +#endif I think it's time we move this into mm/mmap.c and agree on the calling conventions across architectures. I'm currently travelling, but I can dig out a patch I made a while ago to convert most 32-bit architectures over to a common mmap2() implementation. As far as I can tell, the only architectures that actually want mmap_pgoff() are m68k, arc and hexagon. Everything else either has a fixed 4KB page size (so mmap_pgoff and mmap2 are the same), or they already enforce the mmap2 semantics. There are some smaller differences between architectures at the moment that I think shouldn't really exist: sparc32/m68k/arm32/parisc skips the alignment check, sparc64 and alpha add an overflow check (on sys_mmap) and powerpc adds a pgprot argument check. I think the version you have is fine for common code (including the ones that don't check alignment today), not sure about the additional checks. Arnd