qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thiemo Seufer <ths@networkno.de>
To: "J. Mayer" <l_indien@magic.fr>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] RFC: cleanups: CPU_MEM_INDEX
Date: Wed, 10 Oct 2007 01:12:38 +0100	[thread overview]
Message-ID: <20071010001238.GA3379@networkno.de> (raw)
In-Reply-To: <1191958401.9976.87.camel@rapid>

J. Mayer wrote:
> Here's a proposal to add a int cpu_mem_index (CPUState *env) function in
> targets cpu.h header.
> The idea of this patch is:
> - avoid many #ifdef TARGET_xxx in exec-all.h and  softmmu_header.h then
> make the code more readable
> - avoid multiple implementation of the same code (3, in that particular
> case) this to avoid potential conflicts if the definition has to be
> updated for any reason (ie support for new memory access modes,
> emulation optimisation...)
> 
> Please comment.
> 
> -- 
> J. Mayer <l_indien@magic.fr>
> Never organized

> Index: cpu-exec.c
> ===================================================================
> RCS file: /sources/qemu/qemu/cpu-exec.c,v
> retrieving revision 1.119
> diff -u -d -d -p -r1.119 cpu-exec.c
> --- cpu-exec.c	8 Oct 2007 13:16:13 -0000	1.119
> +++ cpu-exec.c	9 Oct 2007 10:36:07 -0000
> @@ -885,7 +885,7 @@ static inline int handle_cpu_signal(unsi
>  
>      /* see if it is an MMU fault */
>      ret = cpu_x86_handle_mmu_fault(env, address, is_write,
> -                                   ((env->hflags & HF_CPL_MASK) == 3), 0);
> +                                   cpu_mem_index(env), 0);
>      if (ret < 0)
>          return 0; /* not an MMU fault */
>      if (ret == 0)
> @@ -1007,7 +1009,8 @@ static inline int handle_cpu_signal(unsi
>      }
>  
>      /* see if it is an MMU fault */
> -    ret = cpu_ppc_handle_mmu_fault(env, address, is_write, msr_pr, 0);
> +    ret = cpu_ppc_handle_mmu_fault(env, address, is_write,
> +                                   cpu_mem_index(env), 0);
>      if (ret < 0)
>          return 0; /* not an MMU fault */
>      if (ret == 0)
> @@ -1191,7 +1197,8 @@ static inline int handle_cpu_signal(unsi
>      }
>  
>      /* see if it is an MMU fault */
> -    ret = cpu_alpha_handle_mmu_fault(env, address, is_write, 1, 0);
> +    ret = cpu_alpha_handle_mmu_fault(env, address, is_write,
> +                                     cpu_mem_index(env), 0);

I have the feeling some architectures are missing here. :-)

>      if (ret < 0)
>          return 0; /* not an MMU fault */
>      if (ret == 0)
> Index: exec-all.h
> ===================================================================
> RCS file: /sources/qemu/qemu/exec-all.h,v
> retrieving revision 1.67
> diff -u -d -d -p -r1.67 exec-all.h
> --- exec-all.h	8 Oct 2007 13:16:14 -0000	1.67
> +++ exec-all.h	9 Oct 2007 10:36:07 -0000
> @@ -601,27 +606,7 @@ static inline target_ulong get_phys_addr
>      int is_user, index, pd;
>  
>      index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
> -#if defined(TARGET_I386)
> -    is_user = ((env->hflags & HF_CPL_MASK) == 3);
> -#elif defined (TARGET_PPC)
> -    is_user = msr_pr;
> -#elif defined (TARGET_MIPS)
> -    is_user = ((env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM);
> -#elif defined (TARGET_SPARC)
> -    is_user = (env->psrs == 0);
> -#elif defined (TARGET_ARM)
> -    is_user = ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_USR);
> -#elif defined (TARGET_SH4)
> -    is_user = ((env->sr & SR_MD) == 0);
> -#elif defined (TARGET_ALPHA)
> -    is_user = ((env->ps >> 3) & 3);
> -#elif defined (TARGET_M68K)
> -    is_user = ((env->sr & SR_S) == 0);
> -#elif defined (TARGET_CRIS)
> -    is_user = (0);
> -#else
> -#error unimplemented CPU
> -#endif
> +    is_user = cpu_mem_index(env);
>      if (__builtin_expect(env->tlb_table[is_user][index].addr_code !=
>                           (addr & TARGET_PAGE_MASK), 0)) {

I presume cpu_mem_index is supposed to do more than checking for
usermode. In that case, is_user should get renamed, and the
cpu_mem_index implementation of some (most?) CPUs should have a
FIXME comment as reminder to implement the missing MMU modes.

Other than that it looks good to me (and reminds me to check what the
supervisor mode on MIPS actually does now :-).


Thiemo

  reply	other threads:[~2007-10-10  0:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-09 19:33 [Qemu-devel] RFC: cleanups: CPU_MEM_INDEX J. Mayer
2007-10-10  0:12 ` Thiemo Seufer [this message]
2007-10-10  5:06   ` J. Mayer
2007-10-11 12:09     ` J. Mayer
2007-10-11 17:46       ` Thiemo Seufer
2007-10-11 22:27         ` J. Mayer
2007-10-12  7:01       ` J. Mayer
2007-10-13 21:14         ` J. Mayer
2007-10-13 22:55           ` Thiemo Seufer

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=20071010001238.GA3379@networkno.de \
    --to=ths@networkno.de \
    --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).