qemu-ppc
[Top][All Lists]
Advanced

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

Re: [PATCH v2 10/23] target/i386: Prefer fast cpu_env() over slower CPU


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 10/23] target/i386: Prefer fast cpu_env() over slower CPU QOM cast macro
Date: Sun, 28 Jan 2024 17:16:19 +0100
User-agent: Mozilla Thunderbird

On 27/1/24 13:21, Zhao Liu wrote:
Hi Philippe,

On Fri, Jan 26, 2024 at 11:03:52PM +0100, Philippe Mathieu-Daudé wrote:
Date: Fri, 26 Jan 2024 23:03:52 +0100
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Subject: [PATCH v2 10/23] target/i386: Prefer fast cpu_env() over slower
  CPU QOM cast macro
X-Mailer: git-send-email 2.41.0

Mechanical patch produced running the command documented
in scripts/coccinelle/cpu_env.cocci_template header.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
  target/i386/hvf/vmx.h               | 13 +++-------
  hw/i386/vmmouse.c                   |  6 ++---
  hw/i386/xen/xen-hvm.c               |  3 +--
  target/i386/arch_memory_mapping.c   |  3 +--
  target/i386/cpu-dump.c              |  3 +--
  target/i386/cpu.c                   | 37 +++++++++------------------
  target/i386/helper.c                | 39 ++++++++---------------------
  target/i386/hvf/hvf.c               |  8 ++----
  target/i386/hvf/x86.c               |  4 +--
  target/i386/hvf/x86_emu.c           |  6 ++---
  target/i386/hvf/x86_task.c          | 10 +++-----
  target/i386/hvf/x86hvf.c            |  6 ++---
  target/i386/kvm/kvm.c               |  6 ++---
  target/i386/kvm/xen-emu.c           | 32 ++++++++---------------
  target/i386/tcg/sysemu/bpt_helper.c |  3 +--
  target/i386/tcg/tcg-cpu.c           | 14 +++--------
  target/i386/tcg/user/excp_helper.c  |  3 +--
  target/i386/tcg/user/seg_helper.c   |  3 +--
  18 files changed, 59 insertions(+), 140 deletions(-)


[snip]

diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index 3b1ef5f49a..1e7fd587fe 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -238,8 +238,7 @@ void hvf_get_msrs(CPUState *cs)
int hvf_put_registers(CPUState *cs)
  {
-    X86CPU *x86cpu = X86_CPU(cs);
-    CPUX86State *env = &x86cpu->env;
+    CPUX86State *env = cpu_env(cs);
wreg(cs->accel->fd, HV_X86_RAX, env->regs[R_EAX]);
      wreg(cs->accel->fd, HV_X86_RBX, env->regs[R_EBX]);
@@ -282,8 +281,7 @@ int hvf_put_registers(CPUState *cs)
int hvf_get_registers(CPUState *cs)
  {
-    X86CPU *x86cpu = X86_CPU(cs);
-    CPUX86State *env = &x86cpu->env;
+    CPUX86State *env = cpu_env(cs);
env->regs[R_EAX] = rreg(cs->accel->fd, HV_X86_RAX);
      env->regs[R_EBX] = rreg(cs->accel->fd, HV_X86_RBX);

In this file, there's another corner case:

diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index 3b1ef5f49a8a..9a145aa5aa4f 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -342,8 +342,7 @@ void vmx_clear_int_window_exiting(CPUState *cs)

  bool hvf_inject_interrupts(CPUState *cs)
  {
-    X86CPU *x86cpu = X86_CPU(cs);
-    CPUX86State *env = &x86cpu->env;
+    CPUX86State *env = cpu_env(cs);

      uint8_t vector;
      uint64_t intr_type;
@@ -408,7 +407,7 @@ bool hvf_inject_interrupts(CPUState *cs)
      if (!(env->hflags & HF_INHIBIT_IRQ_MASK) &&
          (cs->interrupt_request & CPU_INTERRUPT_HARD) &&
          (env->eflags & IF_MASK) && !(info & VMCS_INTR_VALID)) {
-        int line = cpu_get_pic_interrupt(&x86cpu->env);
+        int line = cpu_get_pic_interrupt(env);
          cs->interrupt_request &= ~CPU_INTERRUPT_HARD;
          if (line >= 0) {
              wvmcs(cs->accel->fd, VMCS_ENTRY_INTR_INFO, line |


For this special case, I'm not sure if the script can cover it as well,
otherwise maybe it's OK to be cleaned up manually ;-).

BTW I forgot to mention I had to skip target/i386/tcg/translate.c
(7100 LoC) because it is too complex for Coccinelle.



reply via email to

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