Re: [Qemu-devel] [PATCH 02/17] s390x: s390x-linux-user support

2011-04-18 Thread Riku Voipio
Hi,

The patch looks OK, but I'd like to have a try with some s390x static
binaries. Such binaries are also useful for me to test that new patches
for linxu-user don't break targets I don't usually use.

Riku

On Fri, Apr 15, 2011 at 05:32:43PM +0200, Alexander Graf wrote:
 From: Ulrich Hecht u...@suse.de
 
 This patch adds support for running s390x binaries in the linux-user emulation
 code.
 
 Signed-off-by: Ulrich Hecht u...@suse.de
 Signed-off-by: Alexander Graf ag...@suse.de
 
 ---
 
 v1 - v2:
 
   - always set 64bit flag for s390x binaries in elf loader
   - remove redundant EXECUTE_SVC
   - advance psw.addr in syscall execution path
 
 v3 - v4:
 
   - fix 32bit hosts
   - fix coding style (except for header files shared with Linux)
 ---
  linux-user/elfload.c |   19 ++
  linux-user/main.c|   83 +
  linux-user/s390x/syscall.h   |   23 +++
  linux-user/s390x/syscall_nr.h|  349 
 ++
  linux-user/s390x/target_signal.h |   26 +++
  linux-user/s390x/termbits.h  |  283 ++
  linux-user/signal.c  |  333 
  linux-user/syscall.c |   16 ++-
  linux-user/syscall_defs.h|   55 ++-
  scripts/qemu-binfmt-conf.sh  |4 +-
  10 files changed, 1184 insertions(+), 7 deletions(-)
  create mode 100644 linux-user/s390x/syscall.h
  create mode 100644 linux-user/s390x/syscall_nr.h
  create mode 100644 linux-user/s390x/target_signal.h
  create mode 100644 linux-user/s390x/termbits.h
 
 diff --git a/linux-user/elfload.c b/linux-user/elfload.c
 index 4c399f8..dcfeb7a 100644
 --- a/linux-user/elfload.c
 +++ b/linux-user/elfload.c
 @@ -867,6 +867,25 @@ static inline void init_thread(struct target_pt_regs 
 *regs,
  
  #endif /* TARGET_ALPHA */
  
 +#ifdef TARGET_S390X
 +
 +#define ELF_START_MMAP (0x200ULL)
 +
 +#define elf_check_arch(x) ( (x) == ELF_ARCH )
 +
 +#define ELF_CLASSELFCLASS64
 +#define ELF_DATA ELFDATA2MSB
 +#define ELF_ARCH EM_S390
 +
 +static inline void init_thread(struct target_pt_regs *regs, struct 
 image_info *infop)
 +{
 +regs-psw.addr = infop-entry;
 +regs-psw.mask = PSW_MASK_64 | PSW_MASK_32;
 +regs-gprs[15] = infop-start_stack;
 +}
 +
 +#endif /* TARGET_S390X */
 +
  #ifndef ELF_PLATFORM
  #define ELF_PLATFORM (NULL)
  #endif
 diff --git a/linux-user/main.c b/linux-user/main.c
 index a1e37e4..82aaf9d 100644
 --- a/linux-user/main.c
 +++ b/linux-user/main.c
 @@ -2701,6 +2701,80 @@ void cpu_loop (CPUState *env)
  }
  #endif /* TARGET_ALPHA */
  
 +#ifdef TARGET_S390X
 +void cpu_loop(CPUS390XState *env)
 +{
 +int trapnr;
 +target_siginfo_t info;
 +
 +while (1) {
 +trapnr = cpu_s390x_exec (env);
 +
 +switch (trapnr) {
 +case EXCP_INTERRUPT:
 +/* just indicate that signals should be handled asap */
 +break;
 +case EXCP_DEBUG:
 +{
 +int sig;
 +
 +sig = gdb_handlesig (env, TARGET_SIGTRAP);
 +if (sig) {
 +info.si_signo = sig;
 +info.si_errno = 0;
 +info.si_code = TARGET_TRAP_BRKPT;
 +queue_signal(env, info.si_signo, info);
 +}
 +}
 +break;
 +case EXCP_SVC:
 +{
 +int n = env-int_svc_code;
 +if (!n) {
 +/* syscalls  255 */
 +n = env-regs[1];
 +}
 +env-psw.addr += env-int_svc_ilc;
 +env-regs[2] = do_syscall(env, n,
 +   env-regs[2],
 +   env-regs[3],
 +   env-regs[4],
 +   env-regs[5],
 +   env-regs[6],
 +   env-regs[7]);
 +}
 +break;
 +case EXCP_ADDR:
 +{
 +info.si_signo = SIGSEGV;
 +info.si_errno = 0;
 +/* XXX: check env-error_code */
 +info.si_code = TARGET_SEGV_MAPERR;
 +info._sifields._sigfault._addr = env-__excp_addr;
 +queue_signal(env, info.si_signo, info);
 +}
 +break;
 +case EXCP_SPEC:
 +{
 +fprintf(stderr,specification exception insn 0x%08x%04x\n, 
 ldl(env-psw.addr), lduw(env-psw.addr + 4));
 +info.si_signo = SIGILL;
 +info.si_errno = 0;
 +info.si_code = TARGET_ILL_ILLOPC;
 +info._sifields._sigfault._addr = env-__excp_addr;
 +queue_signal(env, info.si_signo, info);
 +}
 +break;
 +default:
 +printf (Unhandled trap: 0x%x\n, trapnr);
 +cpu_dump_state(env, stderr, fprintf, 0);
 +exit (1);
 +}
 +

Re: [Qemu-devel] [PATCH 02/17] s390x: s390x-linux-user support

2011-04-18 Thread Alexander Graf

On 18.04.2011, at 13:38, Riku Voipio wrote:

 Hi,
 
 The patch looks OK, but I'd like to have a try with some s390x static
 binaries. Such binaries are also useful for me to test that new patches
 for linxu-user don't break targets I don't usually use.

Sure - what exactly would you like there? I can easily compile a few. Do you 
want to have them added to the tests/ directory?

Alex




Re: [Qemu-devel] [PATCH 02/17] s390x: s390x-linux-user support

2011-04-18 Thread Riku Voipio
On Mon, Apr 18, 2011 at 02:06:02PM +0200, Alexander Graf wrote:
  The patch looks OK, but I'd like to have a try with some s390x static
  binaries. Such binaries are also useful for me to test that new patches
  for linxu-user don't break targets I don't usually use.
 
 Sure - what exactly would you like there? I can easily compile a few. Do you 
 want to have them added to the tests/ directory?

busybox has so far been most useful.

Riku



Re: [Qemu-devel] [PATCH 02/17] s390x: s390x-linux-user support

2011-04-18 Thread Jan-Simon Möller
Am Montag, 18. April 2011, 14:19:26 schrieb Riku Voipio:
 On Mon, Apr 18, 2011 at 02:06:02PM +0200, Alexander Graf wrote:
   The patch looks OK, but I'd like to have a try with some s390x static
   binaries. Such binaries are also useful for me to test that new patches
   for linxu-user don't break targets I don't usually use.
  
  Sure - what exactly would you like there? I can easily compile a few. Do
  you want to have them added to the tests/ directory?
 
 busybox has so far been most useful.
 

Good idea, what about adding a collection of static busybox for the different 
arches? Not everyone testing has the compiler around for $ARCH . 

Best,
Jan-Simon



Re: [Qemu-devel] [PATCH 02/17] s390x: s390x-linux-user support

2011-04-18 Thread Alexander Graf

On 18.04.2011, at 15:21, Jan-Simon Möller wrote:

 Am Montag, 18. April 2011, 14:19:26 schrieb Riku Voipio:
 On Mon, Apr 18, 2011 at 02:06:02PM +0200, Alexander Graf wrote:
 The patch looks OK, but I'd like to have a try with some s390x static
 binaries. Such binaries are also useful for me to test that new patches
 for linxu-user don't break targets I don't usually use.
 
 Sure - what exactly would you like there? I can easily compile a few. Do
 you want to have them added to the tests/ directory?
 
 busybox has so far been most useful.
 
 
 Good idea, what about adding a collection of static busybox for the different 
 arches? Not everyone testing has the compiler around for $ARCH . 

It'd probably make more sense to help the busybox guys to build an s390 version 
automatically. The others are already available:

http://www.busybox.net/downloads/binaries/latest/


Alex



Re: [Qemu-devel] [PATCH 02/17] s390x: s390x-linux-user support

2011-04-18 Thread Aurelien Jarno
On Mon, Apr 18, 2011 at 03:21:54PM +0200, Jan-Simon Möller wrote:
 Am Montag, 18. April 2011, 14:19:26 schrieb Riku Voipio:
  On Mon, Apr 18, 2011 at 02:06:02PM +0200, Alexander Graf wrote:
The patch looks OK, but I'd like to have a try with some s390x static
binaries. Such binaries are also useful for me to test that new patches
for linxu-user don't break targets I don't usually use.
   
   Sure - what exactly would you like there? I can easily compile a few. Do
   you want to have them added to the tests/ directory?
  
  busybox has so far been most useful.
  
 
 Good idea, what about adding a collection of static busybox for the different 
 arches? Not everyone testing has the compiler around for $ARCH . 
 

It's something that already exists [1]. It would actually make sense to
add s390x binaries there. Also it might be a good idea to provide a
minimal system image as on other architectures.

[1] http://wiki.qemu.org/Download

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH 02/17] s390x: s390x-linux-user support

2011-04-18 Thread Alexander Graf

On 18.04.2011, at 15:36, Aurelien Jarno wrote:

 On Mon, Apr 18, 2011 at 03:21:54PM +0200, Jan-Simon Möller wrote:
 Am Montag, 18. April 2011, 14:19:26 schrieb Riku Voipio:
 On Mon, Apr 18, 2011 at 02:06:02PM +0200, Alexander Graf wrote:
 The patch looks OK, but I'd like to have a try with some s390x static
 binaries. Such binaries are also useful for me to test that new patches
 for linxu-user don't break targets I don't usually use.
 
 Sure - what exactly would you like there? I can easily compile a few. Do
 you want to have them added to the tests/ directory?
 
 busybox has so far been most useful.
 
 
 Good idea, what about adding a collection of static busybox for the 
 different 
 arches? Not everyone testing has the compiler around for $ARCH . 
 
 
 It's something that already exists [1]. It would actually make sense to
 add s390x binaries there. Also it might be a good idea to provide a
 minimal system image as on other architectures.
 
 [1] http://wiki.qemu.org/Download

I find the minimal systems rather useless, but love your Debian images. So if 
you could create one of those for s390, that'd be awesome! :)


Alex




Re: [Qemu-devel] [PATCH 02/17] s390x: s390x-linux-user support

2011-04-18 Thread Aurelien Jarno
On Mon, Apr 18, 2011 at 03:42:25PM +0200, Alexander Graf wrote:
 
 On 18.04.2011, at 15:36, Aurelien Jarno wrote:
 
  On Mon, Apr 18, 2011 at 03:21:54PM +0200, Jan-Simon Möller wrote:
  Am Montag, 18. April 2011, 14:19:26 schrieb Riku Voipio:
  On Mon, Apr 18, 2011 at 02:06:02PM +0200, Alexander Graf wrote:
  The patch looks OK, but I'd like to have a try with some s390x static
  binaries. Such binaries are also useful for me to test that new patches
  for linxu-user don't break targets I don't usually use.
  
  Sure - what exactly would you like there? I can easily compile a few. Do
  you want to have them added to the tests/ directory?
  
  busybox has so far been most useful.
  
  
  Good idea, what about adding a collection of static busybox for the 
  different 
  arches? Not everyone testing has the compiler around for $ARCH . 
  
  
  It's something that already exists [1]. It would actually make sense to
  add s390x binaries there. Also it might be a good idea to provide a
  minimal system image as on other architectures.
  
  [1] http://wiki.qemu.org/Download
 
 I find the minimal systems rather useless, but love your Debian images. So if 
 you could create one of those for s390, that'd be awesome! :)
 

Once I get qemu-system-s390x fully working, it looks my scripts to
produce images should work with minor changes for s390.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net