Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Trevor Woerner <mips081@vtnet.ca>
Cc: linux-mips@linux-mips.org
Subject: Re: 64-bit sysinfo
Date: Thu, 12 Jun 2003 13:35:20 +0200	[thread overview]
Message-ID: <20030612113520.GA8390@linux-mips.org> (raw)
In-Reply-To: <200306120659.26501.mips081@vtnet.ca>

On Thu, Jun 12, 2003 at 06:59:26AM -0400, Trevor Woerner wrote:

> (good to see some familiar and friendly faces from the PPC list! :-)
> 
> I ran into a problem yesterday and I just don't know how I'm going to 
> approach solving it.
> 
> I compiled a 64-bit MIPS kernel, then built a busybox-based ramdisk. At 
> first I couldn't get busybox's 'init' to work but later solved it by 
> disabling the 'check_memory()' call.
> 
> Further investigation into why the 'check_memory()' call was failing 
> revealed a problem with the 'sysinfo()' system call. The kernel is 
> 64-bit, therefore when it fills in the 'struct sysinfo' (as it does 
> when 'sys_meminfo()' is called) unsigned int's are 64 bits. But back in 
> userspace, the 'struct sysinfo' that gets allocated thinks that 
> unsigned int's are 32 bits.
> 
> This causes a crash if the 'struct sysinfo' is allocated on the stack 
> back in userspace, and causes seg faults if it's allocated in the .data 
> section (globally).
> 
> I'm crossing my fingers and hoping that my solution is to build all 
> user-space apps with some switch that will set the sizes of data types 
> to be the same between user space and kernel space. Does some such 
> option exist?

Userspace really shouldn't need to know what kind of kernel it's running
on ...

The kernel has a wrapper for 32-bit code (see sys32_sysinfo) and that one
seems to look correct to me.

Can you check that your program is actually using the right syscall,
that is syscall number 4116?  If it's using 5097 it's using the native
64-bit syscall which obviously would explain your observation.

Any piece of usercode that's directly using <asm/unistd.h> is likely
to do something like this.  In short, using <asm/unistd.h> from userspace
is a really bad idea ...

  Ralf

  reply	other threads:[~2003-06-12 11:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-12 10:59 64-bit sysinfo Trevor Woerner
2003-06-12 11:35 ` Ralf Baechle [this message]
2003-06-12 12:07   ` Trevor Woerner
2003-06-12 12:27     ` Ralf Baechle
2003-06-12 21:36 ` Andrew Clausen
2003-06-12 11:44   ` Ralf Baechle
2003-06-12 12:02     ` Trevor Woerner
  -- strict thread matches above, loose matches on Subject: below --
2003-06-12 11:19 Tor Arntsen
2003-06-12 12:04 ` Trevor Woerner
2003-06-12 12:04   ` Trevor Woerner

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=20030612113520.GA8390@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=linux-mips@linux-mips.org \
    --cc=mips081@vtnet.ca \
    /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