qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thiemo Seufer <ths@networkno.de>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: "J. Mayer" <l_indien@magic.fr>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] RFC: fix run of 32 bits Linux executables on 64 bits targets
Date: Fri, 12 Oct 2007 19:42:29 +0100	[thread overview]
Message-ID: <20071012184229.GL3379@networkno.de> (raw)
In-Reply-To: <f43fc5580710120921m38256ad9o52597c13e84cc195@mail.gmail.com>

Blue Swirl wrote:
[snip]
> Index: qemu/linux-user/mipsn32/syscall.h
> ===================================================================
> --- qemu.orig/linux-user/mipsn32/syscall.h	2007-10-11 19:17:14.000000000 +0000
> +++ qemu/linux-user/mipsn32/syscall.h	2007-10-11 19:17:46.000000000 +0000
> @@ -4,15 +4,15 @@
>  
>  struct target_pt_regs {
>  	/* Saved main processor registers. */
> -	target_ulong regs[32];
> +	abi_ulong regs[32];
>  
>  	/* Saved special registers. */
> -	target_ulong cp0_status;
> -	target_ulong lo;
> -	target_ulong hi;
> -	target_ulong cp0_badvaddr;
> -	target_ulong cp0_cause;
> -	target_ulong cp0_epc;
> +	abi_ulong cp0_status;
> +	abi_ulong lo;
> +	abi_ulong hi;
> +	abi_ulong cp0_badvaddr;
> +	abi_ulong cp0_cause;
> +	abi_ulong cp0_epc;
>  };

This is broken. n32 has 64bit wide registers (and uses them for long long).

>  /* Target errno definitions taken from asm-mips/errno.h */
> Index: qemu/linux-user/mipsn32/target_signal.h
> ===================================================================
> --- qemu.orig/linux-user/mipsn32/target_signal.h	2007-10-11 19:17:14.000000000 +0000
> +++ qemu/linux-user/mipsn32/target_signal.h	2007-10-11 19:17:46.000000000 +0000
> @@ -21,7 +21,7 @@
>  #define TARGET_MINSIGSTKSZ    2048
>  #define TARGET_SIGSTKSZ       8192
>  
> -static inline target_ulong get_sp_from_cpustate(CPUMIPSState *state)
> +static inline abi_ulong get_sp_from_cpustate(CPUMIPSState *state)
>  {
>      return state->gpr[29][state->current_tc];
>  }

Same problem.

[snip]
> Index: qemu/linux-user/signal.c
> ===================================================================
> --- qemu.orig/linux-user/signal.c	2007-10-11 19:17:13.000000000 +0000
> +++ qemu/linux-user/signal.c	2007-10-12 15:58:08.000000000 +0000
[snip]
> @@ -2013,12 +2013,12 @@
>      uint32_t   sc_dsp;         /* dsp status, was sc_ssflags */
>      uint64_t   sc_mdhi;
>      uint64_t   sc_mdlo;
> -    target_ulong   sc_hi1;         /* Was sc_cause */
> -    target_ulong   sc_lo1;         /* Was sc_badvaddr */
> -    target_ulong   sc_hi2;         /* Was sc_sigset[4] */
> -    target_ulong   sc_lo2;
> -    target_ulong   sc_hi3;
> -    target_ulong   sc_lo3;
> +    abi_ulong  sc_hi1;         /* Was sc_cause */
> +    abi_ulong  sc_lo1;         /* Was sc_badvaddr */
> +    abi_ulong  sc_hi2;         /* Was sc_sigset[4] */
> +    abi_ulong  sc_lo2;
> +    abi_ulong  sc_hi3;
> +    abi_ulong  sc_lo3;
>  };

Likewise. When comparing with Linux kernel headers keep in mind that
a 64bit MIPS kernel is always n64, so the data types used on the kernel
side don't match the n32 userland ones.

I'm probably just too used to it to find it confusing, taking the
glibc headers as a guideline might be easier for you. :-)

[snip]
> Index: qemu/linux-user/syscall_defs.h
> ===================================================================
> --- qemu.orig/linux-user/syscall_defs.h	2007-10-11 19:17:13.000000000 +0000
> +++ qemu/linux-user/syscall_defs.h	2007-10-12 16:08:10.000000000 +0000
[snip]
> @@ -1272,7 +1272,7 @@
>  	unsigned int	st_dev;
>  	unsigned int	st_pad0[3];	/* Reserved for st_dev expansion  */
>  
> -	target_ulong	st_ino;
> +	abi_ulong	st_ino;
>  
>          unsigned int	st_mode;
>          unsigned int	st_nlink;

Another one. I leave out a few more instances which also break n32.

[snip]
> Index: qemu/configure
> ===================================================================
> --- qemu.orig/configure	2007-10-11 19:17:14.000000000 +0000
> +++ qemu/configure	2007-10-12 15:38:15.000000000 +0000
> @@ -504,7 +504,7 @@
>      fi
>  # the following are Linux specific
>      if [ "$linux_user" = "yes" ] ; then
> -        target_list="i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user ppc-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user ppc64-linux-user sh4-linux-user cris-linux-user $target_list"
> +        target_list="i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user sparc64-linux-user sparc32plus-linux-user ppc-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user ppc64-linux-user sh4-linux-user cris-linux-user $target_list"
>      fi
>  # the following are Darwin specific
>      if [ "$darwin_user" = "yes" ] ; then
> @@ -933,6 +933,7 @@
>  [ "$target_cpu" = "armeb" ] && target_bigendian=yes
>  [ "$target_cpu" = "sparc" ] && target_bigendian=yes
>  [ "$target_cpu" = "sparc64" ] && target_bigendian=yes
> +[ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
>  [ "$target_cpu" = "ppc" ] && target_bigendian=yes
>  [ "$target_cpu" = "ppc64" ] && target_bigendian=yes
>  [ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
> @@ -1005,6 +1006,7 @@
>  
>  if test "$target_cpu" = "i386" ; then
>    echo "TARGET_ARCH=i386" >> $config_mak
> +  echo "TARGET_ABI_DIR=i386" >> $config_mak
>    echo "#define TARGET_ARCH \"i386\"" >> $config_h
>    echo "#define TARGET_I386 1" >> $config_h
>    if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "i386" ; then

It would be less clutter to let TARGET_ABI_DIR default to TARGET_ARCH
and override it when needed.


Thiemo

  reply	other threads:[~2007-10-12 18:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10  7:42 [Qemu-devel] RFC: fix run of 32 bits Linux executables on 64 bits targets J. Mayer
2007-10-10  8:18 ` Fabrice Bellard
2007-10-10 16:09   ` Blue Swirl
2007-10-10 17:49   ` Thiemo Seufer
2007-10-10 18:40     ` Fabrice Bellard
2007-10-10 19:02       ` Blue Swirl
2007-10-10 21:51         ` J. Mayer
2007-10-11 15:17       ` Thiemo Seufer
2007-10-11 15:47         ` Blue Swirl
2007-10-11 16:00           ` Thiemo Seufer
2007-10-11 19:26       ` Blue Swirl
2007-10-11 22:00         ` J. Mayer
2007-10-12 16:21           ` Blue Swirl
2007-10-12 18:42             ` Thiemo Seufer [this message]
2007-10-12 19:37               ` Blue Swirl
2007-10-12 20:24                 ` Thiemo Seufer
2007-10-10 16:01 ` Blue Swirl
2007-10-10 18:42   ` J. Mayer

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=20071012184229.GL3379@networkno.de \
    --to=ths@networkno.de \
    --cc=blauwirbel@gmail.com \
    --cc=l_indien@magic.fr \
    --cc=qemu-devel@nongnu.org \
    /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).