qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [sh] Don't set FD bit in user mode emulation


From: takasi-y
Subject: Re: [Qemu-devel] [sh] Don't set FD bit in user mode emulation
Date: Sat, 13 Dec 2008 20:15:20 +0900 (JST)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]