linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@tilera.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-arch@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [tile] sys_llseek() can *not* be used as compat_sys_llseek() there
Date: Wed, 27 Feb 2013 13:46:09 -0500	[thread overview]
Message-ID: <512E5471.2060908@tilera.com> (raw)
In-Reply-To: <20130225002913.GW4503@ZenIV.linux.org.uk>

On 2/24/2013 7:29 PM, Al Viro wrote:
> 	Unless I'm seriously misreading your code, you have all arguments of
> compat syscall sign-extended by asm glue.  If that's the case, consider
> what will happen to 32bit binary doing
> 	llseek(fd, 0, 0xffffffff, &pos, SEEK_CUR)
> on 32bit and 64bit hosts resp.  The former will move the current position
> by 4Gb forward; the latter - by one byte backwards...

Without testing this (I'm in an airport), I think you might be right.  But the fix seems like it might just be changing the parameters of the llseek syscall in read_write.c to be "unsigned int" for offset_high and offset_low.  That would let the usual syscall-wrappers code properly zero-extend the high bits.

> 	sys_llseek() will do the right thing for compat on architectures that
> zero-extend the arguments of compat syscall; x86/sparc/ppc/arm64 fall into
> that category.  mips and (AFAICS) tile do not (and s390 is just plain weird
> and needs wrappers for just about everything).  mips has sys_32_llseek() for
> a good reason; we probably want to take that into fs/read_write.c, but
> on such architectures something *is* needed - plain sys_llseek() won't work...
>
> 	FWIW, I suspect that we want __ARCH_COMPAT_ZERO_EXTENDS or
> __ARCH_COMPAT_SIGN_EXTENDS defined in asm/compat.h; the need of sys_llseek()
> would be "it's 32bit or it has compat and it's zero-extending", while
> "has compat and it's not zero-extending" would pick compat_sys_llseek()
> instead.  __ARCH_WANT_SYS_LLSEEK shouldn't exist...
>
> 	And things like "do we need compat_sys_lseek(), compat_sys_truncate()
> and their ilk" could be expressed via those as well - compat && !sign_extends.
>
> 	Comments?

Cleanups like these sound generally good.  For tilegx32, for good or bad, we emulated the register allocation conventions of our 32-bit tilepro architecture, so that for example truncate64 has r0 = filename, r1 = dummy, r2+r3 = offset.  This doesn't match what the compiler would generate for a simple "char *, long long" argument pair, since for tilegx32 we (obviously) represent long long as a 64-bit register value in general.  But for new architectures it might be good to look to make changes like those you are suggesting.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

  reply	other threads:[~2013-02-27 18:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-25  0:29 [tile] sys_llseek() can *not* be used as compat_sys_llseek() there Al Viro
2013-02-27 18:46 ` Chris Metcalf [this message]
2013-02-27 19:41   ` Al Viro
2013-03-04 16:19     ` [PATCH] tile: work around bug in the generic sys_llseek Chris Metcalf
2013-03-04 16:54       ` Al Viro
2013-03-04 17:45         ` Chris Metcalf
2013-03-04 18:37         ` [PATCH] tile: properly use COMPAT_SYSCALL_DEFINEx Chris Metcalf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512E5471.2060908@tilera.com \
    --to=cmetcalf@tilera.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).