qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [sh] Don't set FD bit in user mode emulation
@ 2008-12-13  0:03 Lionel Landwerlin
  2008-12-13  0:13 ` Laurent Desnogues
  2008-12-13 11:15 ` takasi-y
  0 siblings, 2 replies; 3+ messages in thread
From: Lionel Landwerlin @ 2008-12-13  0:03 UTC (permalink / raw)
  To: qemu-devel

>From 1823395215d00c436f91b218f15797e918659f20 Mon Sep 17 00:00:00 2001
From: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Date: Fri, 12 Dec 2008 09:55:32 +0100
Subject: [PATCH] [sh] Don't set FD bit in user mode emulation

      This causes qemu to exist very early (before libc initialization)

Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
---
 target-sh4/translate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index d6cfb7c..287b4a3 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -184,7 +184,7 @@ void cpu_dump_state(CPUState * env, FILE * f,
 static void cpu_sh4_reset(CPUSH4State * env)
 {
 #if defined(CONFIG_USER_ONLY)
-    env->sr = SR_FD;            /* FD - kernel does lazy fpu context switch */
+    /* env->sr = SR_FD; */            /* FD - kernel does lazy fpu context switch */
 #else
     env->sr = 0x700000F0;	/* MD, RB, BL, I3-I0 */
 #endif
-- 
1.5.6.5

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

* Re: [Qemu-devel] [sh] Don't set FD bit in user mode emulation
  2008-12-13  0:03 [Qemu-devel] [sh] Don't set FD bit in user mode emulation Lionel Landwerlin
@ 2008-12-13  0:13 ` Laurent Desnogues
  2008-12-13 11:15 ` takasi-y
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Desnogues @ 2008-12-13  0:13 UTC (permalink / raw)
  To: qemu-devel

On Sat, Dec 13, 2008 at 1:03 AM, Lionel Landwerlin
<lionel.landwerlin@openwide.fr> wrote:
>  static void cpu_sh4_reset(CPUSH4State * env)
>  {
>  #if defined(CONFIG_USER_ONLY)
> -    env->sr = SR_FD;            /* FD - kernel does lazy fpu context switch */
> +    /* env->sr = SR_FD; */            /* FD - kernel does lazy fpu context switch */

I think it's better when commenting out code to say why it's
commented out.

However in that particular case, I would simply remove the
code:  unless there's something I don't understand, I can't
see why FPU disable should be set (unless, as I said
previously, if the ELF header contains a flag stating the
program needs FPU instructions in which case this should
be handled differently).


Laurent

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

* Re: [Qemu-devel] [sh] Don't set FD bit in user mode emulation
  2008-12-13  0:03 [Qemu-devel] [sh] Don't set FD bit in user mode emulation Lionel Landwerlin
  2008-12-13  0:13 ` Laurent Desnogues
@ 2008-12-13 11:15 ` takasi-y
  1 sibling, 0 replies; 3+ messages in thread
From: takasi-y @ 2008-12-13 11:15 UTC (permalink / raw)
  To: Lionel Landwerlin; +Cc: qemu-devel

Hi,

>  #if defined(CONFIG_USER_ONLY)
> -    env->sr = SR_FD;            /* FD - kernel does lazy fpu context switch */
> +    /* env->sr = SR_FD; */            /* FD - kernel does lazy fpu context switch */
>  #else

I think this CPP conditional here itself is wrong.
This is where we do CPU reset. CPU reset should be done as datasheet says.

Initialization dedicated for linux_user emulation corresponds to user process
 initialization in linux kernel, which(for ELF) is in
 <linux_kernel>/fs/binfmt_elf.c:load_elf_binary()
that initializes registers using ELF_PLAT_INIT, which is in 
 <linux_kernel>/arch/sh/include/asm/elf.h:ELF_PLAT_INIT
that is
  do { _r->regs[0]=0; _r->regs[1]=0; _r->regs[2]=0; _r->regs[3]=0; \
       _r->regs[4]=0; _r->regs[5]=0; _r->regs[6]=0; _r->regs[7]=0; \
       _r->regs[8]=0; _r->regs[9]=0; _r->regs[10]=0; _r->regs[11]=0; \
       _r->regs[12]=0; _r->regs[13]=0; _r->regs[14]=0; \
       _r->sr = SR_FD; } while (0)
.
I guess "env->sr = SR_FD" comes from this.

In qemu, the corresponding place is linux-user/elfload.c, though qemu
 doesn't have such an arch depend initialization there.
But the initializations are in linux-user/main.c after loader_exec().
for sh4, this is as follows.
        for(i = 0; i < 16; i++) {
            env->gregs[i] = regs->regs[i];
        }
        env->pc = regs->pc;
I think this is good place to add env->sr = 0;
Fortunately, this works so far, because both ELF and bFLT use same initial
 register value on SuperH :). We can change it when ELF-FDPIC is suppoted.

BTW, the value is 0, but SR_FD.
Actually, Linux kernel do set FD when initialization as shown above.
This is a trap to know if the process use FPU, to do FPU context switching.
But, we don't need it in qemu user emulation, because we always have all
 FP context stored in env in qemu user emulation.
/yoshii

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

end of thread, other threads:[~2008-12-13 11:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-13  0:03 [Qemu-devel] [sh] Don't set FD bit in user mode emulation Lionel Landwerlin
2008-12-13  0:13 ` Laurent Desnogues
2008-12-13 11:15 ` takasi-y

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).