[Qemu-devel] [PATCH v3 08/39] target/alpha: Use env_cpu, env_archcpu

Richard Henderson posted 39 patches 6 years, 9 months ago
Maintainers: Guan Xuetao <gxt@mprc.pku.edu.cn>, Laurent Vivier <laurent@vivier.eu>, Stefan Hajnoczi <stefanha@redhat.com>, Aurelien Jarno <aurelien@aurel32.net>, Chris Wulff <crwulff@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, David Hildenbrand <david@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, Andrzej Zaborowski <balrogg@gmail.com>, Stafford Horne <shorne@gmail.com>, Aleksandar Markovic <amarkovic@wavecomp.com>, Paolo Bonzini <pbonzini@redhat.com>, Aleksandar Rikalo <arikalo@wavecomp.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Sagar Karandikar <sagark@eecs.berkeley.edu>, Michael Walle <michael@walle.cc>, Eduardo Habkost <ehabkost@redhat.com>, Claudio Fontana <claudio.fontana@huawei.com>, Palmer Dabbelt <palmer@sifive.com>, Richard Henderson <rth@twiddle.net>, Artyom Tarasenko <atar4qemu@gmail.com>, Cornelia Huck <cohuck@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Alistair Francis <Alistair.Francis@wdc.com>, Christian Borntraeger <borntraeger@de.ibm.com>, Marek Vasut <marex@denx.de>, Anthony Green <green@moxielogic.com>, Halil Pasic <pasic@linux.ibm.com>, Riku Voipio <riku.voipio@iki.fi>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Max Filippov <jcmvbkbc@gmail.com>
There is a newer version of this series
[Qemu-devel] [PATCH v3 08/39] target/alpha: Use env_cpu, env_archcpu
Posted by Richard Henderson 6 years, 9 months ago
With exactly one exception, most uses of alpha_env_get_cpu
were failures to use the more proper, ENV_GET_CPU macro,
now replaced by env_cpu.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/alpha/cpu.h          | 5 -----
 linux-user/alpha/cpu_loop.c | 2 +-
 target/alpha/helper.c       | 8 +++-----
 target/alpha/sys_helper.c   | 8 ++++----
 4 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index 2c7f75f584..53c085f691 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -273,11 +273,6 @@ struct AlphaCPU {
     QEMUTimer *alarm_timer;
 };
 
-static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env)
-{
-    return container_of(env, AlphaCPU, env);
-}
-
 #define ENV_OFFSET offsetof(AlphaCPU, env)
 
 #ifndef CONFIG_USER_ONLY
diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c
index 61992571e1..7a94eee84c 100644
--- a/linux-user/alpha/cpu_loop.c
+++ b/linux-user/alpha/cpu_loop.c
@@ -23,7 +23,7 @@
 
 void cpu_loop(CPUAlphaState *env)
 {
-    CPUState *cs = CPU(alpha_env_get_cpu(env));
+    CPUState *cs = env_cpu(env);
     int trapnr;
     target_siginfo_t info;
     abi_long sysret;
diff --git a/target/alpha/helper.c b/target/alpha/helper.c
index 7201576aae..08dfb834a5 100644
--- a/target/alpha/helper.c
+++ b/target/alpha/helper.c
@@ -119,7 +119,7 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
                                 int prot_need, int mmu_idx,
                                 target_ulong *pphys, int *pprot)
 {
-    CPUState *cs = CPU(alpha_env_get_cpu(env));
+    CPUState *cs = env_cpu(env);
     target_long saddr = addr;
     target_ulong phys = 0;
     target_ulong L1pte, L2pte, L3pte;
@@ -463,8 +463,7 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags)
    We expect that ENV->PC has already been updated.  */
 void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error)
 {
-    AlphaCPU *cpu = alpha_env_get_cpu(env);
-    CPUState *cs = CPU(cpu);
+    CPUState *cs = env_cpu(env);
 
     cs->exception_index = excp;
     env->error_code = error;
@@ -475,8 +474,7 @@ void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error)
 void QEMU_NORETURN dynamic_excp(CPUAlphaState *env, uintptr_t retaddr,
                                 int excp, int error)
 {
-    AlphaCPU *cpu = alpha_env_get_cpu(env);
-    CPUState *cs = CPU(cpu);
+    CPUState *cs = env_cpu(env);
 
     cs->exception_index = excp;
     env->error_code = error;
diff --git a/target/alpha/sys_helper.c b/target/alpha/sys_helper.c
index ac22323191..f9c34b1144 100644
--- a/target/alpha/sys_helper.c
+++ b/target/alpha/sys_helper.c
@@ -44,17 +44,17 @@ uint64_t helper_load_pcc(CPUAlphaState *env)
 #ifndef CONFIG_USER_ONLY
 void helper_tbia(CPUAlphaState *env)
 {
-    tlb_flush(CPU(alpha_env_get_cpu(env)));
+    tlb_flush(env_cpu(env));
 }
 
 void helper_tbis(CPUAlphaState *env, uint64_t p)
 {
-    tlb_flush_page(CPU(alpha_env_get_cpu(env)), p);
+    tlb_flush_page(env_cpu(env), p);
 }
 
 void helper_tb_flush(CPUAlphaState *env)
 {
-    tb_flush(CPU(alpha_env_get_cpu(env)));
+    tb_flush(env_cpu(env));
 }
 
 void helper_halt(uint64_t restart)
@@ -78,7 +78,7 @@ uint64_t helper_get_walltime(void)
 
 void helper_set_alarm(CPUAlphaState *env, uint64_t expire)
 {
-    AlphaCPU *cpu = alpha_env_get_cpu(env);
+    AlphaCPU *cpu = env_archcpu(env);
 
     if (expire) {
         env->alarm_expire = expire;
-- 
2.17.1


Re: [Qemu-devel] [PATCH v3 08/39] target/alpha: Use env_cpu, env_archcpu
Posted by Alistair Francis 6 years, 9 months ago
On Tue, May 7, 2019 at 5:07 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> With exactly one exception, most uses of alpha_env_get_cpu
> were failures to use the more proper, ENV_GET_CPU macro,
> now replaced by env_cpu.
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/alpha/cpu.h          | 5 -----
>  linux-user/alpha/cpu_loop.c | 2 +-
>  target/alpha/helper.c       | 8 +++-----
>  target/alpha/sys_helper.c   | 8 ++++----
>  4 files changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
> index 2c7f75f584..53c085f691 100644
> --- a/target/alpha/cpu.h
> +++ b/target/alpha/cpu.h
> @@ -273,11 +273,6 @@ struct AlphaCPU {
>      QEMUTimer *alarm_timer;
>  };
>
> -static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env)
> -{
> -    return container_of(env, AlphaCPU, env);
> -}
> -
>  #define ENV_OFFSET offsetof(AlphaCPU, env)
>
>  #ifndef CONFIG_USER_ONLY
> diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c
> index 61992571e1..7a94eee84c 100644
> --- a/linux-user/alpha/cpu_loop.c
> +++ b/linux-user/alpha/cpu_loop.c
> @@ -23,7 +23,7 @@
>
>  void cpu_loop(CPUAlphaState *env)
>  {
> -    CPUState *cs = CPU(alpha_env_get_cpu(env));
> +    CPUState *cs = env_cpu(env);
>      int trapnr;
>      target_siginfo_t info;
>      abi_long sysret;
> diff --git a/target/alpha/helper.c b/target/alpha/helper.c
> index 7201576aae..08dfb834a5 100644
> --- a/target/alpha/helper.c
> +++ b/target/alpha/helper.c
> @@ -119,7 +119,7 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
>                                  int prot_need, int mmu_idx,
>                                  target_ulong *pphys, int *pprot)
>  {
> -    CPUState *cs = CPU(alpha_env_get_cpu(env));
> +    CPUState *cs = env_cpu(env);
>      target_long saddr = addr;
>      target_ulong phys = 0;
>      target_ulong L1pte, L2pte, L3pte;
> @@ -463,8 +463,7 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags)
>     We expect that ENV->PC has already been updated.  */
>  void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error)
>  {
> -    AlphaCPU *cpu = alpha_env_get_cpu(env);
> -    CPUState *cs = CPU(cpu);
> +    CPUState *cs = env_cpu(env);
>
>      cs->exception_index = excp;
>      env->error_code = error;
> @@ -475,8 +474,7 @@ void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error)
>  void QEMU_NORETURN dynamic_excp(CPUAlphaState *env, uintptr_t retaddr,
>                                  int excp, int error)
>  {
> -    AlphaCPU *cpu = alpha_env_get_cpu(env);
> -    CPUState *cs = CPU(cpu);
> +    CPUState *cs = env_cpu(env);
>
>      cs->exception_index = excp;
>      env->error_code = error;
> diff --git a/target/alpha/sys_helper.c b/target/alpha/sys_helper.c
> index ac22323191..f9c34b1144 100644
> --- a/target/alpha/sys_helper.c
> +++ b/target/alpha/sys_helper.c
> @@ -44,17 +44,17 @@ uint64_t helper_load_pcc(CPUAlphaState *env)
>  #ifndef CONFIG_USER_ONLY
>  void helper_tbia(CPUAlphaState *env)
>  {
> -    tlb_flush(CPU(alpha_env_get_cpu(env)));
> +    tlb_flush(env_cpu(env));
>  }
>
>  void helper_tbis(CPUAlphaState *env, uint64_t p)
>  {
> -    tlb_flush_page(CPU(alpha_env_get_cpu(env)), p);
> +    tlb_flush_page(env_cpu(env), p);
>  }
>
>  void helper_tb_flush(CPUAlphaState *env)
>  {
> -    tb_flush(CPU(alpha_env_get_cpu(env)));
> +    tb_flush(env_cpu(env));
>  }
>
>  void helper_halt(uint64_t restart)
> @@ -78,7 +78,7 @@ uint64_t helper_get_walltime(void)
>
>  void helper_set_alarm(CPUAlphaState *env, uint64_t expire)
>  {
> -    AlphaCPU *cpu = alpha_env_get_cpu(env);
> +    AlphaCPU *cpu = env_archcpu(env);
>
>      if (expire) {
>          env->alarm_expire = expire;
> --
> 2.17.1
>
>