public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
* Re: [PATCH 13/19] Unify sys_mmap*
       [not found] <E1NHUfg-0007xZ-R1@ZenIV.linux.org.uk>
@ 2009-12-07  8:32 ` Geert Uytterhoeven
  2009-12-07 15:42   ` Al Viro
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2009-12-07  8:32 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-arch, torvalds, linux-kernel, Linux/m68k

On Mon, Dec 7, 2009 at 04:54, Al Viro <viro@ftp.linux.org.uk> wrote:
>
> New helper - sys_mmap_pgoff(); switch syscalls to using it.
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  arch/alpha/kernel/osf_sys.c               |   19 ++-----
>  arch/arm/kernel/entry-common.S            |    4 +-
>  arch/arm/kernel/sys_arm.c                 |   30 +----------
>  arch/avr32/include/asm/syscalls.h         |    4 --
>  arch/avr32/kernel/sys_avr32.c             |   31 -----------
>  arch/avr32/kernel/syscall-stubs.S         |    2 +-
>  arch/blackfin/kernel/sys_bfin.c           |   33 -----------
>  arch/blackfin/mach-common/entry.S         |    2 +-
>  arch/cris/kernel/sys_cris.c               |   30 +---------
>  arch/frv/kernel/sys_frv.c                 |   66 +----------------------
>  arch/h8300/kernel/sys_h8300.c             |   83 +----------------------------
>  arch/h8300/kernel/syscalls.S              |    2 +-
>  arch/ia64/kernel/sys_ia64.c               |   37 +------------
>  arch/m32r/kernel/sys_m32r.c               |   24 --------
>  arch/m32r/kernel/syscall_table.S          |    2 +-
>  arch/m68k/kernel/sys_m68k.c               |   79 ++--------------------------
>  arch/m68knommu/kernel/sys_m68k.c          |   38 +------------
>  arch/m68knommu/kernel/syscalltable.S      |    2 +-
>  arch/microblaze/kernel/sys_microblaze.c   |   38 +------------
>  arch/microblaze/kernel/syscall_table.S    |    2 +-
>  arch/mips/kernel/linux32.c                |   19 +------
>  arch/mips/kernel/syscall.c                |   29 +---------
>  arch/mn10300/kernel/entry.S               |    2 +-
>  arch/mn10300/kernel/sys_mn10300.c         |   31 +----------
>  arch/parisc/kernel/sys_parisc.c           |   30 ++---------
>  arch/powerpc/kernel/syscalls.c            |   15 +-----
>  arch/s390/kernel/compat_linux.c           |   32 +----------
>  arch/s390/kernel/sys_s390.c               |   30 +----------
>  arch/score/kernel/sys_score.c             |   21 +------
>  arch/sh/kernel/sys_sh.c                   |   28 +---------
>  arch/sparc/kernel/sys_sparc_32.c          |   31 ++---------
>  arch/sparc/kernel/sys_sparc_64.c          |   22 ++------
>  arch/um/kernel/syscall.c                  |   28 +---------
>  arch/um/sys-i386/shared/sysdep/syscalls.h |    4 --
>  arch/x86/ia32/ia32entry.S                 |    2 +-
>  arch/x86/ia32/sys_ia32.c                  |   43 +---------------
>  arch/x86/include/asm/sys_ia32.h           |    3 -
>  arch/x86/include/asm/syscalls.h           |    2 -
>  arch/x86/kernel/sys_i386_32.c             |   27 +---------
>  arch/x86/kernel/sys_x86_64.c              |   17 +------
>  arch/x86/kernel/syscall_table_32.S        |    2 +-
>  arch/xtensa/include/asm/syscall.h         |    2 -
>  arch/xtensa/include/asm/unistd.h          |    2 +-
>  arch/xtensa/kernel/syscall.c              |   25 ---------
>  include/linux/syscalls.h                  |    4 ++
>  mm/util.c                                 |   29 ++++++++++
>  46 files changed, 105 insertions(+), 903 deletions(-)
>

> diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
> index 7deb402..fdab0f0 100644
> --- a/arch/m68k/kernel/sys_m68k.c
> +++ b/arch/m68k/kernel/sys_m68k.c
> @@ -29,37 +29,12 @@
>  #include <asm/page.h>
>  #include <asm/unistd.h>
>
> -/* common code for old and new mmaps */
> -static inline long do_mmap2(
> -       unsigned long addr, unsigned long len,
> -       unsigned long prot, unsigned long flags,
> -       unsigned long fd, unsigned long pgoff)
> -{
> -       int error = -EBADF;
> -       struct file * file = NULL;
> -
> -       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
> -       if (!(flags & MAP_ANONYMOUS)) {
> -               file = fget(fd);
> -               if (!file)
> -                       goto out;
> -       }
> -
> -       down_write(&current->mm->mmap_sem);
> -       error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
> -       up_write(&current->mm->mmap_sem);
> -
> -       if (file)
> -               fput(file);
> -out:
> -       return error;
> -}
> -
>  asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
>        unsigned long prot, unsigned long flags,
>        unsigned long fd, unsigned long pgoff)
>  {
> -       return do_mmap2(addr, len, prot, flags, fd, pgoff);
> +       /* this is wrong for sun3, BTW */

Can you please add the why part to the comment?
Thanks!

> +       return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
>  }
>
>  /*
> @@ -90,57 +65,11 @@ asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
>        if (a.offset & ~PAGE_MASK)
>                goto out;
>
> -       a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
> -
> -       error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
> -out:
> -       return error;
> -}
> -
> -#if 0
> -struct mmap_arg_struct64 {
> -       __u32 addr;
> -       __u32 len;
> -       __u32 prot;
> -       __u32 flags;
> -       __u64 offset; /* 64 bits */
> -       __u32 fd;
> -};
> -
> -asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg)
> -{
> -       int error = -EFAULT;
> -       struct file * file = NULL;
> -       struct mmap_arg_struct64 a;
> -       unsigned long pgoff;
> -
> -       if (copy_from_user(&a, arg, sizeof(a)))
> -               return -EFAULT;
> -
> -       if ((long)a.offset & ~PAGE_MASK)
> -               return -EINVAL;
> -
> -       pgoff = a.offset >> PAGE_SHIFT;
> -       if ((a.offset >> PAGE_SHIFT) != pgoff)
> -               return -EINVAL;
> -
> -       if (!(a.flags & MAP_ANONYMOUS)) {
> -               error = -EBADF;
> -               file = fget(a.fd);
> -               if (!file)
> -                       goto out;
> -       }
> -       a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
> -
> -       down_write(&current->mm->mmap_sem);
> -       error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff);
> -       up_write(&current->mm->mmap_sem);
> -       if (file)
> -               fput(file);
> +       error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
> +                              a.offset >> PAGE_SHIFT);
>  out:
>        return error;
>  }
> -#endif
>
>  struct sel_arg_struct {
>        unsigned long n;

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 13/19] Unify sys_mmap*
  2009-12-07  8:32 ` [PATCH 13/19] Unify sys_mmap* Geert Uytterhoeven
@ 2009-12-07 15:42   ` Al Viro
  0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2009-12-07 15:42 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Al Viro, linux-arch, torvalds, linux-kernel, Linux/m68k

On Mon, Dec 07, 2009 at 09:32:05AM +0100, Geert Uytterhoeven wrote:
> On Mon, Dec 7, 2009 at 04:54, Al Viro <viro@ftp.linux.org.uk> wrote:

> > ??asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
> > ?? ?? ?? ??unsigned long prot, unsigned long flags,
> > ?? ?? ?? ??unsigned long fd, unsigned long pgoff)
> > ??{
> > - ?? ?? ?? return do_mmap2(addr, len, prot, flags, fd, pgoff);
> > + ?? ?? ?? /* this is wrong for sun3, BTW */
> 
> Can you please add the why part to the comment?
> Thanks!

Try libc mmap64() with e.g. 65536 as the last argument.  On mac and sun3.
Compare the results...

Basically, sun3 has larger pages and forgets to compensate.  Corresponding
part in libc (actual libc6 m68k binary) is
	movel %d6,%d2
	moveq #20,%d0
	lsll %d0,%d2
	movel %d7,%d1
	moveq #12,%d3
	lsrl %d3,%d1
	orl %d2,%d1
	moveal %d1,%a0		/* a0 = d6d7 >> 12 */
	movel %a3,%d5
	movel %a4,%d4
	movel %a5,%d3
	movel %a2,%d2
	%fp@(8),%d1
 	moveq #63,%d0
	notb %d0		/* 256 ^ 63, i.e. 192, i.e. __NR_mmap2 */
	trap #0

It does the last argument of mmap2 in 4Kb units (as on almost all
targets; ia64 is the exception, but it's actually not used by libc -
they have mmap64 aliased to mmap and using sys_mmap, not sys_mmap2).

So sun3 ought to shift the argument down by 1 before passing it to
do_mmap_pgoff() (or sys_mmap_pgoff() with these patches) - mm/mmap.c
stuff really expects the argument in PAGE_SIZE units.

Generally I'd agree that existing behaviour is a part of ABI, however
weird it might be, but since it's actually wrong for the only libc user
of the syscall *and* differs from the behaviour on other subarchitectures...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-12-07 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1NHUfg-0007xZ-R1@ZenIV.linux.org.uk>
2009-12-07  8:32 ` [PATCH 13/19] Unify sys_mmap* Geert Uytterhoeven
2009-12-07 15:42   ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox