Skip to contentSkip to conversation

target/ppc: Move most of 'cpu-qom.h' definitions to 'cpu.h'

PATCH In review Philippe Mathieu-Daudé 4 participants 24 messages Oct 13, 2023 – Oct 16, 2023

lore
Share & tools
lore
#0 lore raw

cover target/ppc: Move most of 'cpu-qom.h' definitions to 'cpu.h'

Hi,

I'm going to post a v2 of "target: Make 'cpu-qom.h' really target agnostic" [*]. Since the series is already big enough, I extracted the PPC specific patches in their own preliminary series.

In short, "cpu-qom.h" exposes QOM definitions and must be target agnostic. This series moves the PPC specific definitions to target/ppc/cpu.h.

Please review,

Phil.

[*] https://lore.kernel.org/qemu-devel/[email protected]/

Philippe Mathieu-Daudé (7):
hw/ppc/spapr: Restrict PPCTimebase structure declaration to sPAPR target/ppc: Define powerpc_pm_insn_t in 'internal.h' target/ppc: Move ppc_cpu_class_by_name() declaration to 'cpu.h' target/ppc: Move PowerPCCPUClass definition to 'cpu.h' target/ppc: Move powerpc_excp_t definition to 'cpu.h' target/ppc: Move powerpc_mmu_t definition to 'cpu.h' target/ppc: Move powerpc_input_t definition to 'cpu.h'

 include/hw/ppc/ppc.h   |   2 +-
 include/hw/ppc/spapr.h |   6 ++
 target/ppc/cpu-qom.h   | 183 -----------------------------------------
 target/ppc/cpu.h       | 141 +++++++++++++++++++++++++++++++
 target/ppc/internal.h  |   9 ++
 hw/ppc/ppc.c           | 107 ------------------------
 hw/ppc/spapr.c         | 116 ++++++++++++++++++++++++++
 7 files changed, 273 insertions(+), 291 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/7 hw/ppc/spapr: Restrict PPCTimebase structure declaration to sPAPR

The PPCTimebase structure is only used by the sPAPR machine. Move its declaration to "hw/ppc/spapr.h".
Move vmstate_ppc_timebase and the VMSTATE_PPC_TIMEBASE_V() macro to hw/ppc/spapr.c, along with the timebase_foo() migration helpers.

---
 include/hw/ppc/spapr.h |   6 +++
 target/ppc/cpu-qom.h   |  22 --------
 hw/ppc/ppc.c           | 107 -------------------------------------
 hw/ppc/spapr.c         | 116 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 122 insertions(+), 129 deletions(-)
include/hw/ppc/spapr.h +6 -0
index e91791a1a9..3cf9978cba 100644
@@ -163,6 +163,12 @@ struct SpaprMachineClass {
     SpaprIrq *irq;
 };
 
+typedef struct PPCTimebase {
+    uint64_t guest_timebase;
+    int64_t time_of_the_day_ns;
+    bool runstate_paused;
+} PPCTimebase;
+
 #define WDT_MAX_WATCHDOGS       4      /* Maximum number of watchdog devices */
 
 #define TYPE_SPAPR_WDT "spapr-wdt"
target/ppc/cpu-qom.h +0 -22
index be33786bd8..b5deef5ca5 100644
@@ -197,26 +197,4 @@ struct PowerPCCPUClass {
     int  (*check_pow)(CPUPPCState *env);
 };
 
-#ifndef CONFIG_USER_ONLY
-typedef struct PPCTimebase {
-    uint64_t guest_timebase;
-    int64_t time_of_the_day_ns;
-    bool runstate_paused;
-} PPCTimebase;
-
-extern const VMStateDescription vmstate_ppc_timebase;
-
-#define VMSTATE_PPC_TIMEBASE_V(_field, _state, _version) {            \
-    .name       = (stringify(_field)),                                \
-    .version_id = (_version),                                         \
-    .size       = sizeof(PPCTimebase),                                \
-    .vmsd       = &vmstate_ppc_timebase,                              \
-    .flags      = VMS_STRUCT,                                         \
-    .offset     = vmstate_offset_value(_state, _field, PPCTimebase),  \
-}
-
-void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
-                                   RunState state);
-#endif
-
 #endif
hw/ppc/ppc.c +0 -107

119 lines not on this page · raw message

hw/ppc/spapr.c +116 -0

134 lines not on this page · raw message

Signature · 1 line
2.41.0
Reviewed-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] hw/ppc/spapr: Restrict PPCTimebase structure declaration to sPAPR

Quoted 6 lines · Philippe Mathieu-Daudé

The PPCTimebase structure is only used by the sPAPR machine. Move its declaration to "hw/ppc/spapr.h".
Move vmstate_ppc_timebase and the VMSTATE_PPC_TIMEBASE_V() macro to hw/ppc/spapr.c, along with the timebase_foo() migration helpers.

Quoted 7 lines
---
  include/hw/ppc/spapr.h |   6 +++
  target/ppc/cpu-qom.h   |  22 --------
  hw/ppc/ppc.c           | 107 -------------------------------------
  hw/ppc/spapr.c         | 116 +++++++++++++++++++++++++++++++++++++++++
  4 files changed, 122 insertions(+), 129 deletions(-)

r~

Reviewed-by on v1 1/7
#3 lore raw

Re: [PATCH 1/7] hw/ppc/spapr: Restrict PPCTimebase structure declaration to sPAPR

In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

The PPCTimebase structure is only used by the sPAPR machine. Move its declaration to "hw/ppc/spapr.h".
Move vmstate_ppc_timebase and the VMSTATE_PPC_TIMEBASE_V() macro to hw/ppc/spapr.c, along with the timebase_foo() migration helpers.

Thanks,

C.

Quoted 321 lines
---
  include/hw/ppc/spapr.h |   6 +++
  target/ppc/cpu-qom.h   |  22 --------
  hw/ppc/ppc.c           | 107 -------------------------------------
  hw/ppc/spapr.c         | 116 +++++++++++++++++++++++++++++++++++++++++
  4 files changed, 122 insertions(+), 129 deletions(-)
include/hw/ppc/spapr.h +6 -0
index e91791a1a9..3cf9978cba 100644
@@ -163,6 +163,12 @@ struct SpaprMachineClass {
      SpaprIrq *irq;
  };
 
+typedef struct PPCTimebase {
+    uint64_t guest_timebase;
+    int64_t time_of_the_day_ns;
+    bool runstate_paused;
+} PPCTimebase;
+
  #define WDT_MAX_WATCHDOGS       4      /* Maximum number of watchdog devices */
 
  #define TYPE_SPAPR_WDT "spapr-wdt"
target/ppc/cpu-qom.h +0 -22
index be33786bd8..b5deef5ca5 100644
@@ -197,26 +197,4 @@ struct PowerPCCPUClass {
      int  (*check_pow)(CPUPPCState *env);
  };
 
-#ifndef CONFIG_USER_ONLY
-typedef struct PPCTimebase {
-    uint64_t guest_timebase;
-    int64_t time_of_the_day_ns;
-    bool runstate_paused;
-} PPCTimebase;
-
-extern const VMStateDescription vmstate_ppc_timebase;
-
-#define VMSTATE_PPC_TIMEBASE_V(_field, _state, _version) {            \
-    .name       = (stringify(_field)),                                \
-    .version_id = (_version),                                         \
-    .size       = sizeof(PPCTimebase),                                \
-    .vmsd       = &vmstate_ppc_timebase,                              \
-    .flags      = VMS_STRUCT,                                         \
-    .offset     = vmstate_offset_value(_state, _field, PPCTimebase),  \
-}
-
-void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
-                                   RunState state);
-#endif
-
  #endif
hw/ppc/ppc.c +0 -107
index be167710a3..340cd6192f 100644
@@ -32,7 +32,6 @@
  #include "qemu/main-loop.h"
  #include "qemu/error-report.h"
  #include "sysemu/kvm.h"
-#include "sysemu/replay.h"
  #include "sysemu/runstate.h"
  #include "kvm_ppc.h"
  #include "migration/vmstate.h"
@@ -967,112 +966,6 @@ void cpu_ppc_store_purr(CPUPPCState *env, uint64_t value)
      _cpu_ppc_store_purr(env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), value);
  }
 
-static void timebase_save(PPCTimebase *tb)
-{
-    uint64_t ticks = cpu_get_host_ticks();
-    PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
-
-    if (!first_ppc_cpu->env.tb_env) {
-        error_report("No timebase object");
-        return;
-    }
-
-    if (replay_mode == REPLAY_MODE_NONE) {
-        /* not used anymore, we keep it for compatibility */
-        tb->time_of_the_day_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);
-    } else {
-        /* simpler for record-replay to avoid this event, compat not needed */
-        tb->time_of_the_day_ns = 0;
-    }
-
-    /*
-     * tb_offset is only expected to be changed by QEMU so
-     * there is no need to update it from KVM here
-     */
-    tb->guest_timebase = ticks + first_ppc_cpu->env.tb_env->tb_offset;
-
-    tb->runstate_paused =
-        runstate_check(RUN_STATE_PAUSED) || runstate_check(RUN_STATE_SAVE_VM);
-}
-
-static void timebase_load(PPCTimebase *tb)
-{
-    CPUState *cpu;
-    PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
-    int64_t tb_off_adj, tb_off;
-    unsigned long freq;
-
-    if (!first_ppc_cpu->env.tb_env) {
-        error_report("No timebase object");
-        return;
-    }
-
-    freq = first_ppc_cpu->env.tb_env->tb_freq;
-
-    tb_off_adj = tb->guest_timebase - cpu_get_host_ticks();
-
-    tb_off = first_ppc_cpu->env.tb_env->tb_offset;
-    trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off,
-                        (tb_off_adj - tb_off) / freq);
-
-    /* Set new offset to all CPUs */
-    CPU_FOREACH(cpu) {
-        PowerPCCPU *pcpu = POWERPC_CPU(cpu);
-        pcpu->env.tb_env->tb_offset = tb_off_adj;
-        kvmppc_set_reg_tb_offset(pcpu, pcpu->env.tb_env->tb_offset);
-    }
-}
-
-void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
-                                   RunState state)
-{
-    PPCTimebase *tb = opaque;
-
-    if (running) {
-        timebase_load(tb);
-    } else {
-        timebase_save(tb);
-    }
-}
-
-/*
- * When migrating a running guest, read the clock just
- * before migration, so that the guest clock counts
- * during the events between:
- *
- *  * vm_stop()
- *  *
- *  * pre_save()
- *
- *  This reduces clock difference on migration from 5s
- *  to 0.1s (when max_downtime == 5s), because sending the
- *  final pages of memory (which happens between vm_stop()
- *  and pre_save()) takes max_downtime.
- */
-static int timebase_pre_save(void *opaque)
-{
-    PPCTimebase *tb = opaque;
-
-    /* guest_timebase won't be overridden in case of paused guest or savevm */
-    if (!tb->runstate_paused) {
-        timebase_save(tb);
-    }
-
-    return 0;
-}
-
-const VMStateDescription vmstate_ppc_timebase = {
-    .name = "timebase",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .pre_save = timebase_pre_save,
-    .fields      = (VMStateField []) {
-        VMSTATE_UINT64(guest_timebase, PPCTimebase),
-        VMSTATE_INT64(time_of_the_day_ns, PPCTimebase),
-        VMSTATE_END_OF_LIST()
-    },
-};
-
  /* Set up (once) timebase frequency (in Hz) */
  void cpu_ppc_tb_init(CPUPPCState *env, uint32_t freq)
  {
hw/ppc/spapr.c +116 -0
index cb840676d3..fe8b425ffd 100644
@@ -37,6 +37,7 @@
  #include "sysemu/numa.h"
  #include "sysemu/qtest.h"
  #include "sysemu/reset.h"
+#include "sysemu/replay.h"
  #include "sysemu/runstate.h"
  #include "qemu/log.h"
  #include "hw/fw-path-provider.h"
@@ -1809,6 +1810,100 @@ static bool spapr_vga_init(PCIBus *pci_bus, Error **errp)
      }
  }
 
+static void timebase_save(PPCTimebase *tb)
+{
+    uint64_t ticks = cpu_get_host_ticks();
+    PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
+
+    if (!first_ppc_cpu->env.tb_env) {
+        error_report("No timebase object");
+        return;
+    }
+
+    if (replay_mode == REPLAY_MODE_NONE) {
+        /* not used anymore, we keep it for compatibility */
+        tb->time_of_the_day_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);
+    } else {
+        /* simpler for record-replay to avoid this event, compat not needed */
+        tb->time_of_the_day_ns = 0;
+    }
+
+    /*
+     * tb_offset is only expected to be changed by QEMU so
+     * there is no need to update it from KVM here
+     */
+    tb->guest_timebase = ticks + first_ppc_cpu->env.tb_env->tb_offset;
+
+    tb->runstate_paused =
+        runstate_check(RUN_STATE_PAUSED) || runstate_check(RUN_STATE_SAVE_VM);
+}
+
+static void timebase_load(PPCTimebase *tb)
+{
+    CPUState *cpu;
+    PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
+    int64_t tb_off_adj, tb_off;
+    unsigned long freq;
+
+    if (!first_ppc_cpu->env.tb_env) {
+        error_report("No timebase object");
+        return;
+    }
+
+    freq = first_ppc_cpu->env.tb_env->tb_freq;
+
+    tb_off_adj = tb->guest_timebase - cpu_get_host_ticks();
+
+    tb_off = first_ppc_cpu->env.tb_env->tb_offset;
+    trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off,
+                        (tb_off_adj - tb_off) / freq);
+
+    /* Set new offset to all CPUs */
+    CPU_FOREACH(cpu) {
+        PowerPCCPU *pcpu = POWERPC_CPU(cpu);
+        pcpu->env.tb_env->tb_offset = tb_off_adj;
+        kvmppc_set_reg_tb_offset(pcpu, pcpu->env.tb_env->tb_offset);
+    }
+}
+
+static void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
+                                          RunState state)
+{
+    PPCTimebase *tb = opaque;
+
+    if (running) {
+        timebase_load(tb);
+    } else {
+        timebase_save(tb);
+    }
+}
+
+/*
+ * When migrating a running guest, read the clock just
+ * before migration, so that the guest clock counts
+ * during the events between:
+ *
+ *  * vm_stop()
+ *  *
+ *  * pre_save()
+ *
+ *  This reduces clock difference on migration from 5s
+ *  to 0.1s (when max_downtime == 5s), because sending the
+ *  final pages of memory (which happens between vm_stop()
+ *  and pre_save()) takes max_downtime.
+ */
+static int timebase_pre_save(void *opaque)
+{
+    PPCTimebase *tb = opaque;
+
+    /* guest_timebase won't be overridden in case of paused guest or savevm */
+    if (!tb->runstate_paused) {
+        timebase_save(tb);
+    }
+
+    return 0;
+}
+
  static int spapr_pre_load(void *opaque)
  {
      int rc;
@@ -2081,6 +2176,27 @@ static const VMStateDescription vmstate_spapr_fwnmi = {
      },
  };
 
+static const VMStateDescription vmstate_spapr_timebase = {
+    .name = "timebase",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .pre_save = timebase_pre_save,
+    .fields      = (VMStateField []) {
+        VMSTATE_UINT64(guest_timebase, PPCTimebase),
+        VMSTATE_INT64(time_of_the_day_ns, PPCTimebase),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
+#define VMSTATE_PPC_TIMEBASE_V(_field, _state, _version) {            \
+    .name       = (stringify(_field)),                                \
+    .version_id = (_version),                                         \
+    .size       = sizeof(PPCTimebase),                                \
+    .vmsd       = &vmstate_spapr_timebase,                            \
+    .flags      = VMS_STRUCT,                                         \
+    .offset     = vmstate_offset_value(_state, _field, PPCTimebase),  \
+}
+
  static const VMStateDescription vmstate_spapr = {
      .name = "spapr",
      .version_id = 3,
#4 lore raw

Re: [PATCH 1/7] hw/ppc/spapr: Restrict PPCTimebase structure declaration to sPAPR

In reply to Philippe Mathieu-Daudé
Quoted 318 lines · Philippe Mathieu-Daudé

The PPCTimebase structure is only used by the sPAPR machine. Move its declaration to "hw/ppc/spapr.h".
Move vmstate_ppc_timebase and the VMSTATE_PPC_TIMEBASE_V() macro to hw/ppc/spapr.c, along with the timebase_foo() migration helpers.

---
  include/hw/ppc/spapr.h |   6 +++
  target/ppc/cpu-qom.h   |  22 --------
  hw/ppc/ppc.c           | 107 -------------------------------------
  hw/ppc/spapr.c         | 116 +++++++++++++++++++++++++++++++++++++++++
  4 files changed, 122 insertions(+), 129 deletions(-)
include/hw/ppc/spapr.h +6 -0
index e91791a1a9..3cf9978cba 100644
@@ -163,6 +163,12 @@ struct SpaprMachineClass {
      SpaprIrq *irq;
  };
 
+typedef struct PPCTimebase {
+    uint64_t guest_timebase;
+    int64_t time_of_the_day_ns;
+    bool runstate_paused;
+} PPCTimebase;
+
  #define WDT_MAX_WATCHDOGS       4      /* Maximum number of watchdog devices */
 
  #define TYPE_SPAPR_WDT "spapr-wdt"
target/ppc/cpu-qom.h +0 -22
index be33786bd8..b5deef5ca5 100644
@@ -197,26 +197,4 @@ struct PowerPCCPUClass {
      int  (*check_pow)(CPUPPCState *env);
  };
 
-#ifndef CONFIG_USER_ONLY
-typedef struct PPCTimebase {
-    uint64_t guest_timebase;
-    int64_t time_of_the_day_ns;
-    bool runstate_paused;
-} PPCTimebase;
-
-extern const VMStateDescription vmstate_ppc_timebase;
-
-#define VMSTATE_PPC_TIMEBASE_V(_field, _state, _version) {            \
-    .name       = (stringify(_field)),                                \
-    .version_id = (_version),                                         \
-    .size       = sizeof(PPCTimebase),                                \
-    .vmsd       = &vmstate_ppc_timebase,                              \
-    .flags      = VMS_STRUCT,                                         \
-    .offset     = vmstate_offset_value(_state, _field, PPCTimebase),  \
-}
-
-void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
-                                   RunState state);
-#endif
-
  #endif
hw/ppc/ppc.c +0 -107
index be167710a3..340cd6192f 100644
@@ -32,7 +32,6 @@
  #include "qemu/main-loop.h"
  #include "qemu/error-report.h"
  #include "sysemu/kvm.h"
-#include "sysemu/replay.h"
  #include "sysemu/runstate.h"
  #include "kvm_ppc.h"
  #include "migration/vmstate.h"
@@ -967,112 +966,6 @@ void cpu_ppc_store_purr(CPUPPCState *env, uint64_t value)
      _cpu_ppc_store_purr(env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), value);
  }
 
-static void timebase_save(PPCTimebase *tb)
-{
-    uint64_t ticks = cpu_get_host_ticks();
-    PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
-
-    if (!first_ppc_cpu->env.tb_env) {
-        error_report("No timebase object");
-        return;
-    }
-
-    if (replay_mode == REPLAY_MODE_NONE) {
-        /* not used anymore, we keep it for compatibility */
-        tb->time_of_the_day_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);
-    } else {
-        /* simpler for record-replay to avoid this event, compat not needed */
-        tb->time_of_the_day_ns = 0;
-    }
-
-    /*
-     * tb_offset is only expected to be changed by QEMU so
-     * there is no need to update it from KVM here
-     */
-    tb->guest_timebase = ticks + first_ppc_cpu->env.tb_env->tb_offset;
-
-    tb->runstate_paused =
-        runstate_check(RUN_STATE_PAUSED) || runstate_check(RUN_STATE_SAVE_VM);
-}
-
-static void timebase_load(PPCTimebase *tb)
-{
-    CPUState *cpu;
-    PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
-    int64_t tb_off_adj, tb_off;
-    unsigned long freq;
-
-    if (!first_ppc_cpu->env.tb_env) {
-        error_report("No timebase object");
-        return;
-    }
-
-    freq = first_ppc_cpu->env.tb_env->tb_freq;
-
-    tb_off_adj = tb->guest_timebase - cpu_get_host_ticks();
-
-    tb_off = first_ppc_cpu->env.tb_env->tb_offset;
-    trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off,
-                        (tb_off_adj - tb_off) / freq);
-
-    /* Set new offset to all CPUs */
-    CPU_FOREACH(cpu) {
-        PowerPCCPU *pcpu = POWERPC_CPU(cpu);
-        pcpu->env.tb_env->tb_offset = tb_off_adj;
-        kvmppc_set_reg_tb_offset(pcpu, pcpu->env.tb_env->tb_offset);
-    }
-}
-
-void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
-                                   RunState state)
-{
-    PPCTimebase *tb = opaque;
-
-    if (running) {
-        timebase_load(tb);
-    } else {
-        timebase_save(tb);
-    }
-}
-
-/*
- * When migrating a running guest, read the clock just
- * before migration, so that the guest clock counts
- * during the events between:
- *
- *  * vm_stop()
- *  *
- *  * pre_save()
- *
- *  This reduces clock difference on migration from 5s
- *  to 0.1s (when max_downtime == 5s), because sending the
- *  final pages of memory (which happens between vm_stop()
- *  and pre_save()) takes max_downtime.
- */
-static int timebase_pre_save(void *opaque)
-{
-    PPCTimebase *tb = opaque;
-
-    /* guest_timebase won't be overridden in case of paused guest or savevm */
-    if (!tb->runstate_paused) {
-        timebase_save(tb);
-    }
-
-    return 0;
-}
-
-const VMStateDescription vmstate_ppc_timebase = {
-    .name = "timebase",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .pre_save = timebase_pre_save,
-    .fields      = (VMStateField []) {
-        VMSTATE_UINT64(guest_timebase, PPCTimebase),
-        VMSTATE_INT64(time_of_the_day_ns, PPCTimebase),
-        VMSTATE_END_OF_LIST()
-    },
-};
-
  /* Set up (once) timebase frequency (in Hz) */
  void cpu_ppc_tb_init(CPUPPCState *env, uint32_t freq)
  {
hw/ppc/spapr.c +109 -0
index cb840676d3..fe8b425ffd 100644
@@ -37,6 +37,7 @@
  #include "sysemu/numa.h"
  #include "sysemu/qtest.h"
  #include "sysemu/reset.h"
+#include "sysemu/replay.h"
  #include "sysemu/runstate.h"
  #include "qemu/log.h"
  #include "hw/fw-path-provider.h"
@@ -1809,6 +1810,100 @@ static bool spapr_vga_init(PCIBus *pci_bus, Error **errp)
      }
  }
 
+static void timebase_save(PPCTimebase *tb)
+{
+    uint64_t ticks = cpu_get_host_ticks();
+    PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
+
+    if (!first_ppc_cpu->env.tb_env) {
+        error_report("No timebase object");
+        return;
+    }
+
+    if (replay_mode == REPLAY_MODE_NONE) {
+        /* not used anymore, we keep it for compatibility */
+        tb->time_of_the_day_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);
+    } else {
+        /* simpler for record-replay to avoid this event, compat not needed */
+        tb->time_of_the_day_ns = 0;
+    }
+
+    /*
+     * tb_offset is only expected to be changed by QEMU so
+     * there is no need to update it from KVM here
+     */
+    tb->guest_timebase = ticks + first_ppc_cpu->env.tb_env->tb_offset;
+
+    tb->runstate_paused =
+        runstate_check(RUN_STATE_PAUSED) || runstate_check(RUN_STATE_SAVE_VM);
+}
+
+static void timebase_load(PPCTimebase *tb)
+{
+    CPUState *cpu;
+    PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
+    int64_t tb_off_adj, tb_off;
+    unsigned long freq;
+
+    if (!first_ppc_cpu->env.tb_env) {
+        error_report("No timebase object");
+        return;
+    }
+
+    freq = first_ppc_cpu->env.tb_env->tb_freq;
+
+    tb_off_adj = tb->guest_timebase - cpu_get_host_ticks();
+
+    tb_off = first_ppc_cpu->env.tb_env->tb_offset;
+    trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off,
+                        (tb_off_adj - tb_off) / freq);
+
+    /* Set new offset to all CPUs */
+    CPU_FOREACH(cpu) {
+        PowerPCCPU *pcpu = POWERPC_CPU(cpu);
+        pcpu->env.tb_env->tb_offset = tb_off_adj;
+        kvmppc_set_reg_tb_offset(pcpu, pcpu->env.tb_env->tb_offset);
+    }
+}
+
+static void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
+                                          RunState state)
+{
+    PPCTimebase *tb = opaque;
+
+    if (running) {
+        timebase_load(tb);
+    } else {
+        timebase_save(tb);
+    }
+}
+
+/*
+ * When migrating a running guest, read the clock just
+ * before migration, so that the guest clock counts
+ * during the events between:
+ *
+ *  * vm_stop()
+ *  *
+ *  * pre_save()
+ *
+ *  This reduces clock difference on migration from 5s
+ *  to 0.1s (when max_downtime == 5s), because sending the
+ *  final pages of memory (which happens between vm_stop()
+ *  and pre_save()) takes max_downtime.
+ */
+static int timebase_pre_save(void *opaque)
+{
+    PPCTimebase *tb = opaque;
+
+    /* guest_timebase won't be overridden in case of paused guest or savevm */
+    if (!tb->runstate_paused) {
+        timebase_save(tb);
+    }
+
+    return 0;
+}
+
  static int spapr_pre_load(void *opaque)
  {
      int rc;
@@ -2081,6 +2176,27 @@ static const VMStateDescription vmstate_spapr_fwnmi = {
      },
  };
 
+static const VMStateDescription vmstate_spapr_timebase = {
+    .name = "timebase",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .pre_save = timebase_pre_save,
+    .fields      = (VMStateField []) {
+        VMSTATE_UINT64(guest_timebase, PPCTimebase),
+        VMSTATE_INT64(time_of_the_day_ns, PPCTimebase),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
+#define VMSTATE_PPC_TIMEBASE_V(_field, _state, _version) {            \
+    .name       = (stringify(_field)),                                \

hw/ppc/spapr.c static const VMStateDescription vmstate_spapr_fwnmi = { · line 2202

Quoted 10 lines
hw/ppc/spapr.c +7 -0
+    .version_id = (_version),                                         \
+    .size       = sizeof(PPCTimebase),                                \
+    .vmsd       = &vmstate_spapr_timebase,                            \
+    .flags      = VMS_STRUCT,                                         \
+    .offset     = vmstate_offset_value(_state, _field, PPCTimebase),  \
+}
+
  static const VMStateDescription vmstate_spapr = {
      .name = "spapr",
      .version_id = 3,

I saw this series when it was original posted, but I failed to spot that it didn't apply to the PPC Mac machines. I have a feeling this should solve a long-running issue I've been having with decrementer migration, in which case can it be moved (or left) somewhere where this is still possible?

ATB,

Mark.

#5 lore raw

Re: [PATCH 1/7] hw/ppc/spapr: Restrict PPCTimebase structure declaration to sPAPR

Hi Mark,

Quoted 17 lines · Mark Cave-Ayland
Quoted 6 lines · Philippe Mathieu-Daudé

The PPCTimebase structure is only used by the sPAPR machine. Move its declaration to "hw/ppc/spapr.h".
Move vmstate_ppc_timebase and the VMSTATE_PPC_TIMEBASE_V() macro to hw/ppc/spapr.c, along with the timebase_foo() migration helpers.

Quoted 7 lines

---
  include/hw/ppc/spapr.h |   6 +++
  target/ppc/cpu-qom.h   |  22 --------
  hw/ppc/ppc.c           | 107 ------------------------------------- hw/ppc/spapr.c         | 116 +++++++++++++++++++++++++++++++++++++++++

  4 files changed, 122 insertions(+), 129 deletions(-)
Quoted 1 line

I saw this series when it was original posted, but I failed to spot that it didn't apply to the PPC Mac machines. I have a feeling this should solve a long-running issue I've been having with decrementer migration, in which case can it be moved (or left) somewhere where this is still possible?

I'm not sure I understand what you ask. Do you want this code to still be available for non-sPAPR machines? If so, I could move the declarations to target/ppc/internal.h.

#6 lore raw

Re: [PATCH 1/7] hw/ppc/spapr: Restrict PPCTimebase structure declaration to sPAPR

Quoted 20 lines · Philippe Mathieu-Daudé

Hi Mark,

Quoted 15 lines · Mark Cave-Ayland
Quoted 13 lines · Philippe Mathieu-Daudé

The PPCTimebase structure is only used by the sPAPR machine. Move its declaration to "hw/ppc/spapr.h".
Move vmstate_ppc_timebase and the VMSTATE_PPC_TIMEBASE_V() macro to hw/ppc/spapr.c, along with the timebase_foo() migration helpers.

---
  include/hw/ppc/spapr.h |   6 +++
  target/ppc/cpu-qom.h   |  22 --------
  hw/ppc/ppc.c           | 107 ------------------------------------- hw/ppc/spapr.c         | 116 +++++++++++++++++++++++++++++++++++++++++

  4 files changed, 122 insertions(+), 129 deletions(-)
Quoted 5 lines
Quoted 1 line

I saw this series when it was original posted, but I failed to spot that it didn't apply to the PPC Mac machines. I have a feeling this should solve a long-running issue I've been having with decrementer migration, in which case can it be moved (or left) somewhere where this is still possible?

I'm not sure I understand what you ask. Do you want this code to still be available for non-sPAPR machines? If so, I could move the declarations to target/ppc/internal.h.

Yes, that's indeed what I meant. Sorry for not being completely clear about it!

ATB,

Mark.

#7 lore raw

PATCH 2/7 target/ppc: Define powerpc_pm_insn_t in 'internal.h'

In reply to Philippe Mathieu-Daudé

PM instructions are only used by TCG helpers. No need to expose to other hardware.

---
 target/ppc/cpu-qom.h  | 10 ----------
 target/ppc/internal.h |  9 +++++++++
 2 files changed, 9 insertions(+), 10 deletions(-)
target/ppc/cpu-qom.h +0 -10
index b5deef5ca5..b86fd46d25 100644
@@ -115,16 +115,6 @@ enum powerpc_excp_t {
     POWERPC_EXCP_POWER10,
 };
 
-/*****************************************************************************/
-/* PM instructions */
-typedef enum {
-    PPC_PM_DOZE,
-    PPC_PM_NAP,
-    PPC_PM_SLEEP,
-    PPC_PM_RVWINKLE,
-    PPC_PM_STOP,
-} powerpc_pm_insn_t;
-
 /*****************************************************************************/
 /* Input pins model                                                          */
 typedef enum powerpc_input_t powerpc_input_t;
target/ppc/internal.h +9 -0
index c881c67a8b..5b20ecbd33 100644
@@ -20,6 +20,15 @@
 
 #include "hw/registerfields.h"
 
+/* PM instructions */
+typedef enum {
+    PPC_PM_DOZE,
+    PPC_PM_NAP,
+    PPC_PM_SLEEP,
+    PPC_PM_RVWINKLE,
+    PPC_PM_STOP,
+} powerpc_pm_insn_t;
+
 #define FUNC_MASK(name, ret_type, size, max_val)                  \
 static inline ret_type name(uint##size##_t start,                 \
                               uint##size##_t end)                 \
Signature · 1 line
2.41.0
Reviewed-by on v1 2/7
#8 lore raw

Re: [PATCH 2/7] target/ppc: Define powerpc_pm_insn_t in 'internal.h'

Quoted 8 lines · Philippe Mathieu-Daudé

PM instructions are only used by TCG helpers. No need to expose to other hardware.

---
  target/ppc/cpu-qom.h  | 10 ----------
  target/ppc/internal.h |  9 +++++++++
  2 files changed, 9 insertions(+), 10 deletions(-)

r~

Reviewed-by on v1 2/7
#9 lore raw

Re: [PATCH 2/7] target/ppc: Define powerpc_pm_insn_t in 'internal.h'

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

PM instructions are only used by TCG helpers. No need to expose to other hardware.

Thanks,

C.

Quoted 46 lines
---
  target/ppc/cpu-qom.h  | 10 ----------
  target/ppc/internal.h |  9 +++++++++
  2 files changed, 9 insertions(+), 10 deletions(-)
target/ppc/cpu-qom.h +0 -10
index b5deef5ca5..b86fd46d25 100644
@@ -115,16 +115,6 @@ enum powerpc_excp_t {
      POWERPC_EXCP_POWER10,
  };
 
-/*****************************************************************************/
-/* PM instructions */
-typedef enum {
-    PPC_PM_DOZE,
-    PPC_PM_NAP,
-    PPC_PM_SLEEP,
-    PPC_PM_RVWINKLE,
-    PPC_PM_STOP,
-} powerpc_pm_insn_t;
-
  /*****************************************************************************/
  /* Input pins model                                                          */
  typedef enum powerpc_input_t powerpc_input_t;
target/ppc/internal.h +9 -0
index c881c67a8b..5b20ecbd33 100644
@@ -20,6 +20,15 @@
 
  #include "hw/registerfields.h"
 
+/* PM instructions */
+typedef enum {
+    PPC_PM_DOZE,
+    PPC_PM_NAP,
+    PPC_PM_SLEEP,
+    PPC_PM_RVWINKLE,
+    PPC_PM_STOP,
+} powerpc_pm_insn_t;
+
  #define FUNC_MASK(name, ret_type, size, max_val)                  \
  static inline ret_type name(uint##size##_t start,                 \
                                uint##size##_t end)                 \
#10 lore raw

PATCH 3/7 target/ppc: Move ppc_cpu_class_by_name() declaration to 'cpu.h'

In reply to Philippe Mathieu-Daudé

ppc_cpu_class_by_name() is only called in target/ppc/, no need to expose outside (in particular to hw/).

---
 target/ppc/cpu-qom.h | 2 --
 target/ppc/cpu.h     | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)
target/ppc/cpu-qom.h +0 -2
index b86fd46d25..3dc92a852e 100644
@@ -37,8 +37,6 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
 
 #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
-ObjectClass *ppc_cpu_class_by_name(const char *name);
-
 typedef struct CPUArchState CPUPPCState;
 typedef struct ppc_tb_t ppc_tb_t;
 typedef struct ppc_dcr_t ppc_dcr_t;
target/ppc/cpu.h +1 -0
index 30392ebeee..8bb66fbea4 100644
@@ -1342,6 +1342,7 @@ struct ArchCPU {
 };
 
 
+ObjectClass *ppc_cpu_class_by_name(const char *name);
 PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr);
 PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr);
 PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc);
Signature · 1 line
2.41.0
Reviewed-by on v1 3/7
#11 lore raw

Re: [PATCH 3/7] target/ppc: Move ppc_cpu_class_by_name() declaration to 'cpu.h'

Quoted 8 lines · Philippe Mathieu-Daudé

ppc_cpu_class_by_name() is only called in target/ppc/, no need to expose outside (in particular to hw/).

---
  target/ppc/cpu-qom.h | 2 --
  target/ppc/cpu.h     | 1 +
  2 files changed, 1 insertion(+), 2 deletions(-)

r~

Reviewed-by on v1 3/7
#12 lore raw

Re: [PATCH 3/7] target/ppc: Move ppc_cpu_class_by_name() declaration to 'cpu.h'

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

ppc_cpu_class_by_name() is only called in target/ppc/, no need to expose outside (in particular to hw/).

Thanks,

C.

Quoted 30 lines
---
  target/ppc/cpu-qom.h | 2 --
  target/ppc/cpu.h     | 1 +
  2 files changed, 1 insertion(+), 2 deletions(-)
target/ppc/cpu-qom.h +0 -2
index b86fd46d25..3dc92a852e 100644
@@ -37,8 +37,6 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
 
  #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
-ObjectClass *ppc_cpu_class_by_name(const char *name);
-
  typedef struct CPUArchState CPUPPCState;
  typedef struct ppc_tb_t ppc_tb_t;
  typedef struct ppc_dcr_t ppc_dcr_t;
target/ppc/cpu.h +1 -0
index 30392ebeee..8bb66fbea4 100644
@@ -1342,6 +1342,7 @@ struct ArchCPU {
  };
 
 
+ObjectClass *ppc_cpu_class_by_name(const char *name);
  PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr);
  PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr);
  PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc);
#13 lore raw

PATCH 4/7 target/ppc: Move PowerPCCPUClass definition to 'cpu.h'

In reply to Philippe Mathieu-Daudé

The OBJECT_DECLARE_CPU_TYPE() macro forward-declares the PowerPCCPUClass type. This forward declaration is sufficient for code in hw/ to use the QOM definitions. No need to expose the structure definition. Keep it local to target/ppc/ by moving it to target/ppc/cpu.h.

---
 include/hw/ppc/ppc.h |  2 +-
 target/ppc/cpu-qom.h | 56 --------------------------------------------
 target/ppc/cpu.h     | 51 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 57 deletions(-)
include/hw/ppc/ppc.h +1 -1
index 17a8dfc107..d5d119ea7f 100644
@@ -1,7 +1,7 @@
 #ifndef HW_PPC_H
 #define HW_PPC_H
 
-#include "target/ppc/cpu-qom.h"
+#include "target/ppc/cpu.h"
 
 void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level);
 PowerPCCPU *ppc_get_vcpu_by_pir(int pir);
target/ppc/cpu-qom.h +0 -56

72 lines not on this page · raw message

target/ppc/cpu.h +51 -0

66 lines not on this page · raw message

Signature · 1 line
2.41.0
Reviewed-by on v1 4/7
#14 lore raw

Re: [PATCH 4/7] target/ppc: Move PowerPCCPUClass definition to 'cpu.h'

Quoted 6 lines · Philippe Mathieu-Daudé

The OBJECT_DECLARE_CPU_TYPE() macro forward-declares the PowerPCCPUClass type. This forward declaration is sufficient for code in hw/ to use the QOM definitions. No need to expose the structure definition. Keep it local to target/ppc/ by moving it to target/ppc/cpu.h.

Quoted 7 lines
---
  include/hw/ppc/ppc.h |  2 +-
  target/ppc/cpu-qom.h | 56 --------------------------------------------
  target/ppc/cpu.h     | 51 ++++++++++++++++++++++++++++++++++++++++
  3 files changed, 52 insertions(+), 57 deletions(-)

r~

#15 lore raw

PATCH 5/7 target/ppc: Move powerpc_excp_t definition to 'cpu.h'

In reply to Philippe Mathieu-Daudé

The powerpc_excp_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

---
 target/ppc/cpu-qom.h | 29 -----------------------------
 target/ppc/cpu.h     | 27 +++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 29 deletions(-)
target/ppc/cpu-qom.h +0 -29
index 41e97a0ea1..b2e42c2996 100644
@@ -79,35 +79,6 @@ static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model)
     return mmu_model & POWERPC_MMU_64;
 }
 
-/*****************************************************************************/
-/* Exception model                                                           */
-typedef enum powerpc_excp_t powerpc_excp_t;
-enum powerpc_excp_t {
-    POWERPC_EXCP_UNKNOWN   = 0,
-    /* Standard PowerPC exception model */
-    POWERPC_EXCP_STD,
-    /* PowerPC 40x exception model      */
-    POWERPC_EXCP_40x,
-    /* PowerPC 603/604/G2 exception model */
-    POWERPC_EXCP_6xx,
-    /* PowerPC 7xx exception model      */
-    POWERPC_EXCP_7xx,
-    /* PowerPC 74xx exception model     */
-    POWERPC_EXCP_74xx,
-    /* BookE exception model            */
-    POWERPC_EXCP_BOOKE,
-    /* PowerPC 970 exception model      */
-    POWERPC_EXCP_970,
-    /* POWER7 exception model           */
-    POWERPC_EXCP_POWER7,
-    /* POWER8 exception model           */
-    POWERPC_EXCP_POWER8,
-    /* POWER9 exception model           */
-    POWERPC_EXCP_POWER9,
-    /* POWER10 exception model           */
-    POWERPC_EXCP_POWER10,
-};
-
 /*****************************************************************************/
 /* Input pins model                                                          */
 typedef enum powerpc_input_t powerpc_input_t;
target/ppc/cpu.h +27 -0
index d521ee97bb..d8cf4c03bf 100644
@@ -190,6 +190,33 @@ enum {
     POWERPC_EXCP_TRAP          = 0x40,
 };
 
+/* Exception model                                                           */
+typedef enum powerpc_excp_t {
+    POWERPC_EXCP_UNKNOWN   = 0,
+    /* Standard PowerPC exception model */
+    POWERPC_EXCP_STD,
+    /* PowerPC 40x exception model      */
+    POWERPC_EXCP_40x,
+    /* PowerPC 603/604/G2 exception model */
+    POWERPC_EXCP_6xx,
+    /* PowerPC 7xx exception model      */
+    POWERPC_EXCP_7xx,
+    /* PowerPC 74xx exception model     */
+    POWERPC_EXCP_74xx,
+    /* BookE exception model            */
+    POWERPC_EXCP_BOOKE,
+    /* PowerPC 970 exception model      */
+    POWERPC_EXCP_970,
+    /* POWER7 exception model           */
+    POWERPC_EXCP_POWER7,
+    /* POWER8 exception model           */
+    POWERPC_EXCP_POWER8,
+    /* POWER9 exception model           */
+    POWERPC_EXCP_POWER9,
+    /* POWER10 exception model           */
+    POWERPC_EXCP_POWER10,
+} powerpc_excp_t;
+
 #define PPC_INPUT(env) ((env)->bus_model)
 
 /*****************************************************************************/
Signature · 1 line
2.41.0
Reviewed-by on v1 5/7
#16 lore raw

Re: [PATCH 5/7] target/ppc: Move powerpc_excp_t definition to 'cpu.h'

Quoted 8 lines · Philippe Mathieu-Daudé

The powerpc_excp_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

---
  target/ppc/cpu-qom.h | 29 -----------------------------
  target/ppc/cpu.h     | 27 +++++++++++++++++++++++++++
  2 files changed, 27 insertions(+), 29 deletions(-)

r~

Reviewed-by on v1 5/7
#17 lore raw

Re: [PATCH 5/7] target/ppc: Move powerpc_excp_t definition to 'cpu.h'

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

The powerpc_excp_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

Thanks,

C.

Quoted 83 lines
---
  target/ppc/cpu-qom.h | 29 -----------------------------
  target/ppc/cpu.h     | 27 +++++++++++++++++++++++++++
  2 files changed, 27 insertions(+), 29 deletions(-)
target/ppc/cpu-qom.h +0 -29
index 41e97a0ea1..b2e42c2996 100644
@@ -79,35 +79,6 @@ static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model)
      return mmu_model & POWERPC_MMU_64;
  }
 
-/*****************************************************************************/
-/* Exception model                                                           */
-typedef enum powerpc_excp_t powerpc_excp_t;
-enum powerpc_excp_t {
-    POWERPC_EXCP_UNKNOWN   = 0,
-    /* Standard PowerPC exception model */
-    POWERPC_EXCP_STD,
-    /* PowerPC 40x exception model      */
-    POWERPC_EXCP_40x,
-    /* PowerPC 603/604/G2 exception model */
-    POWERPC_EXCP_6xx,
-    /* PowerPC 7xx exception model      */
-    POWERPC_EXCP_7xx,
-    /* PowerPC 74xx exception model     */
-    POWERPC_EXCP_74xx,
-    /* BookE exception model            */
-    POWERPC_EXCP_BOOKE,
-    /* PowerPC 970 exception model      */
-    POWERPC_EXCP_970,
-    /* POWER7 exception model           */
-    POWERPC_EXCP_POWER7,
-    /* POWER8 exception model           */
-    POWERPC_EXCP_POWER8,
-    /* POWER9 exception model           */
-    POWERPC_EXCP_POWER9,
-    /* POWER10 exception model           */
-    POWERPC_EXCP_POWER10,
-};
-
  /*****************************************************************************/
  /* Input pins model                                                          */
  typedef enum powerpc_input_t powerpc_input_t;
target/ppc/cpu.h +27 -0
index d521ee97bb..d8cf4c03bf 100644
@@ -190,6 +190,33 @@ enum {
      POWERPC_EXCP_TRAP          = 0x40,
  };
 
+/* Exception model                                                           */
+typedef enum powerpc_excp_t {
+    POWERPC_EXCP_UNKNOWN   = 0,
+    /* Standard PowerPC exception model */
+    POWERPC_EXCP_STD,
+    /* PowerPC 40x exception model      */
+    POWERPC_EXCP_40x,
+    /* PowerPC 603/604/G2 exception model */
+    POWERPC_EXCP_6xx,
+    /* PowerPC 7xx exception model      */
+    POWERPC_EXCP_7xx,
+    /* PowerPC 74xx exception model     */
+    POWERPC_EXCP_74xx,
+    /* BookE exception model            */
+    POWERPC_EXCP_BOOKE,
+    /* PowerPC 970 exception model      */
+    POWERPC_EXCP_970,
+    /* POWER7 exception model           */
+    POWERPC_EXCP_POWER7,
+    /* POWER8 exception model           */
+    POWERPC_EXCP_POWER8,
+    /* POWER9 exception model           */
+    POWERPC_EXCP_POWER9,
+    /* POWER10 exception model           */
+    POWERPC_EXCP_POWER10,
+} powerpc_excp_t;
+
  #define PPC_INPUT(env) ((env)->bus_model)
 
  /*****************************************************************************/
#18 lore raw

PATCH 6/7 target/ppc: Move powerpc_mmu_t definition to 'cpu.h'

In reply to Philippe Mathieu-Daudé

The powerpc_mmu_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

---
 target/ppc/cpu-qom.h | 43 -------------------------------------------
 target/ppc/cpu.h     | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 43 deletions(-)
target/ppc/cpu-qom.h +0 -43
index b2e42c2996..5bdca472be 100644
@@ -36,49 +36,6 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
 
 #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
-/*****************************************************************************/
-/* MMU model                                                                 */
-typedef enum powerpc_mmu_t powerpc_mmu_t;
-enum powerpc_mmu_t {
-    POWERPC_MMU_UNKNOWN    = 0x00000000,
-    /* Standard 32 bits PowerPC MMU                            */
-    POWERPC_MMU_32B        = 0x00000001,
-    /* PowerPC 6xx MMU with software TLB                       */
-    POWERPC_MMU_SOFT_6xx   = 0x00000002,
-    /*
-     * PowerPC 74xx MMU with software TLB (this has been
-     * disabled, see git history for more information.
-     * keywords: tlbld tlbli TLBMISS PTEHI PTELO)
-     */
-    POWERPC_MMU_SOFT_74xx  = 0x00000003,
-    /* PowerPC 4xx MMU with software TLB                       */
-    POWERPC_MMU_SOFT_4xx   = 0x00000004,
-    /* PowerPC MMU in real mode only                           */
-    POWERPC_MMU_REAL       = 0x00000006,
-    /* Freescale MPC8xx MMU model                              */
-    POWERPC_MMU_MPC8xx     = 0x00000007,
-    /* BookE MMU model                                         */
-    POWERPC_MMU_BOOKE      = 0x00000008,
-    /* BookE 2.06 MMU model                                    */
-    POWERPC_MMU_BOOKE206   = 0x00000009,
-#define POWERPC_MMU_64       0x00010000
-    /* 64 bits PowerPC MMU                                     */
-    POWERPC_MMU_64B        = POWERPC_MMU_64 | 0x00000001,
-    /* Architecture 2.03 and later (has LPCR) */
-    POWERPC_MMU_2_03       = POWERPC_MMU_64 | 0x00000002,
-    /* Architecture 2.06 variant                               */
-    POWERPC_MMU_2_06       = POWERPC_MMU_64 | 0x00000003,
-    /* Architecture 2.07 variant                               */
-    POWERPC_MMU_2_07       = POWERPC_MMU_64 | 0x00000004,
-    /* Architecture 3.00 variant                               */
-    POWERPC_MMU_3_00       = POWERPC_MMU_64 | 0x00000005,
-};
-
-static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model)
-{
-    return mmu_model & POWERPC_MMU_64;
-}
-
 /*****************************************************************************/
 /* Input pins model                                                          */
 typedef enum powerpc_input_t powerpc_input_t;
target/ppc/cpu.h +42 -0

48 lines not on this page · raw message

Signature · 1 line
2.41.0
Reviewed-by on v1 6/7
#19 lore raw

Re: [PATCH 6/7] target/ppc: Move powerpc_mmu_t definition to 'cpu.h'

Quoted 9 lines · Philippe Mathieu-Daudé

The powerpc_mmu_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

---
  target/ppc/cpu-qom.h | 43 -------------------------------------------
  target/ppc/cpu.h     | 42 ++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 42 insertions(+), 43 deletions(-)

r~

Reviewed-by on v1 6/7
#20 lore raw

Re: [PATCH 6/7] target/ppc: Move powerpc_mmu_t definition to 'cpu.h'

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

The powerpc_mmu_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

Thanks,

C.

Quoted 112 lines
---
  target/ppc/cpu-qom.h | 43 -------------------------------------------
  target/ppc/cpu.h     | 42 ++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 42 insertions(+), 43 deletions(-)
target/ppc/cpu-qom.h +0 -43
index b2e42c2996..5bdca472be 100644
@@ -36,49 +36,6 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
 
  #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
-/*****************************************************************************/
-/* MMU model                                                                 */
-typedef enum powerpc_mmu_t powerpc_mmu_t;
-enum powerpc_mmu_t {
-    POWERPC_MMU_UNKNOWN    = 0x00000000,
-    /* Standard 32 bits PowerPC MMU                            */
-    POWERPC_MMU_32B        = 0x00000001,
-    /* PowerPC 6xx MMU with software TLB                       */
-    POWERPC_MMU_SOFT_6xx   = 0x00000002,
-    /*
-     * PowerPC 74xx MMU with software TLB (this has been
-     * disabled, see git history for more information.
-     * keywords: tlbld tlbli TLBMISS PTEHI PTELO)
-     */
-    POWERPC_MMU_SOFT_74xx  = 0x00000003,
-    /* PowerPC 4xx MMU with software TLB                       */
-    POWERPC_MMU_SOFT_4xx   = 0x00000004,
-    /* PowerPC MMU in real mode only                           */
-    POWERPC_MMU_REAL       = 0x00000006,
-    /* Freescale MPC8xx MMU model                              */
-    POWERPC_MMU_MPC8xx     = 0x00000007,
-    /* BookE MMU model                                         */
-    POWERPC_MMU_BOOKE      = 0x00000008,
-    /* BookE 2.06 MMU model                                    */
-    POWERPC_MMU_BOOKE206   = 0x00000009,
-#define POWERPC_MMU_64       0x00010000
-    /* 64 bits PowerPC MMU                                     */
-    POWERPC_MMU_64B        = POWERPC_MMU_64 | 0x00000001,
-    /* Architecture 2.03 and later (has LPCR) */
-    POWERPC_MMU_2_03       = POWERPC_MMU_64 | 0x00000002,
-    /* Architecture 2.06 variant                               */
-    POWERPC_MMU_2_06       = POWERPC_MMU_64 | 0x00000003,
-    /* Architecture 2.07 variant                               */
-    POWERPC_MMU_2_07       = POWERPC_MMU_64 | 0x00000004,
-    /* Architecture 3.00 variant                               */
-    POWERPC_MMU_3_00       = POWERPC_MMU_64 | 0x00000005,
-};
-
-static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model)
-{
-    return mmu_model & POWERPC_MMU_64;
-}
-
  /*****************************************************************************/
  /* Input pins model                                                          */
  typedef enum powerpc_input_t powerpc_input_t;
target/ppc/cpu.h +42 -0
index d8cf4c03bf..c2cd069095 100644
@@ -217,6 +217,48 @@ typedef enum powerpc_excp_t {
      POWERPC_EXCP_POWER10,
  } powerpc_excp_t;
 
+/*****************************************************************************/
+/* MMU model                                                                 */
+typedef enum powerpc_mmu_t {
+    POWERPC_MMU_UNKNOWN    = 0x00000000,
+    /* Standard 32 bits PowerPC MMU                            */
+    POWERPC_MMU_32B        = 0x00000001,
+    /* PowerPC 6xx MMU with software TLB                       */
+    POWERPC_MMU_SOFT_6xx   = 0x00000002,
+    /*
+     * PowerPC 74xx MMU with software TLB (this has been
+     * disabled, see git history for more information.
+     * keywords: tlbld tlbli TLBMISS PTEHI PTELO)
+     */
+    POWERPC_MMU_SOFT_74xx  = 0x00000003,
+    /* PowerPC 4xx MMU with software TLB                       */
+    POWERPC_MMU_SOFT_4xx   = 0x00000004,
+    /* PowerPC MMU in real mode only                           */
+    POWERPC_MMU_REAL       = 0x00000006,
+    /* Freescale MPC8xx MMU model                              */
+    POWERPC_MMU_MPC8xx     = 0x00000007,
+    /* BookE MMU model                                         */
+    POWERPC_MMU_BOOKE      = 0x00000008,
+    /* BookE 2.06 MMU model                                    */
+    POWERPC_MMU_BOOKE206   = 0x00000009,
+#define POWERPC_MMU_64       0x00010000
+    /* 64 bits PowerPC MMU                                     */
+    POWERPC_MMU_64B        = POWERPC_MMU_64 | 0x00000001,
+    /* Architecture 2.03 and later (has LPCR) */
+    POWERPC_MMU_2_03       = POWERPC_MMU_64 | 0x00000002,
+    /* Architecture 2.06 variant                               */
+    POWERPC_MMU_2_06       = POWERPC_MMU_64 | 0x00000003,
+    /* Architecture 2.07 variant                               */
+    POWERPC_MMU_2_07       = POWERPC_MMU_64 | 0x00000004,
+    /* Architecture 3.00 variant                               */
+    POWERPC_MMU_3_00       = POWERPC_MMU_64 | 0x00000005,
+} powerpc_mmu_t;
+
+static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model)
+{
+    return mmu_model & POWERPC_MMU_64;
+}
+
  #define PPC_INPUT(env) ((env)->bus_model)
 
  /*****************************************************************************/
#21 lore raw

PATCH 7/7 target/ppc: Move powerpc_input_t definition to 'cpu.h'

In reply to Philippe Mathieu-Daudé

The powerpc_input_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

---
 target/ppc/cpu-qom.h | 21 ---------------------
 target/ppc/cpu.h     | 20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 21 deletions(-)
target/ppc/cpu-qom.h +0 -21
index 5bdca472be..6d39ad451c 100644
@@ -36,25 +36,4 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
 
 #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
-/*****************************************************************************/
-/* Input pins model                                                          */
-typedef enum powerpc_input_t powerpc_input_t;
-enum powerpc_input_t {
-    PPC_FLAGS_INPUT_UNKNOWN = 0,
-    /* PowerPC 6xx bus                  */
-    PPC_FLAGS_INPUT_6xx,
-    /* BookE bus                        */
-    PPC_FLAGS_INPUT_BookE,
-    /* PowerPC 405 bus                  */
-    PPC_FLAGS_INPUT_405,
-    /* PowerPC 970 bus                  */
-    PPC_FLAGS_INPUT_970,
-    /* PowerPC POWER7 bus               */
-    PPC_FLAGS_INPUT_POWER7,
-    /* PowerPC POWER9 bus               */
-    PPC_FLAGS_INPUT_POWER9,
-    /* Freescale RCPU bus               */
-    PPC_FLAGS_INPUT_RCPU,
-};
-
 #endif
target/ppc/cpu.h +20 -0
index c2cd069095..4b8b5d3d3e 100644
@@ -259,6 +259,26 @@ static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model)
     return mmu_model & POWERPC_MMU_64;
 }
 
+/*****************************************************************************/
+/* Input pins model                                                          */
+typedef enum powerpc_input_t {
+    PPC_FLAGS_INPUT_UNKNOWN = 0,
+    /* PowerPC 6xx bus                  */
+    PPC_FLAGS_INPUT_6xx,
+    /* BookE bus                        */
+    PPC_FLAGS_INPUT_BookE,
+    /* PowerPC 405 bus                  */
+    PPC_FLAGS_INPUT_405,
+    /* PowerPC 970 bus                  */
+    PPC_FLAGS_INPUT_970,
+    /* PowerPC POWER7 bus               */
+    PPC_FLAGS_INPUT_POWER7,
+    /* PowerPC POWER9 bus               */
+    PPC_FLAGS_INPUT_POWER9,
+    /* Freescale RCPU bus               */
+    PPC_FLAGS_INPUT_RCPU,
+} powerpc_input_t;
+
 #define PPC_INPUT(env) ((env)->bus_model)
 
 /*****************************************************************************/
Signature · 1 line
2.41.0
Reviewed-by on v1 7/7
#22 lore raw

Re: [PATCH 7/7] target/ppc: Move powerpc_input_t definition to 'cpu.h'

Quoted 8 lines · Philippe Mathieu-Daudé

The powerpc_input_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

---
  target/ppc/cpu-qom.h | 21 ---------------------
  target/ppc/cpu.h     | 20 ++++++++++++++++++++
  2 files changed, 20 insertions(+), 21 deletions(-)

r~

Reviewed-by on v1 7/7
#23 lore raw

Re: [PATCH 7/7] target/ppc: Move powerpc_input_t definition to 'cpu.h'

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

The powerpc_input_t definition is only used by target/ppc/, no need to expose it. Restrict it by moving it to "target/ppc/cpu.h".

Thanks,

C.

Quoted 66 lines
---
  target/ppc/cpu-qom.h | 21 ---------------------
  target/ppc/cpu.h     | 20 ++++++++++++++++++++
  2 files changed, 20 insertions(+), 21 deletions(-)
target/ppc/cpu-qom.h +0 -21
index 5bdca472be..6d39ad451c 100644
@@ -36,25 +36,4 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
 
  #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
-/*****************************************************************************/
-/* Input pins model                                                          */
-typedef enum powerpc_input_t powerpc_input_t;
-enum powerpc_input_t {
-    PPC_FLAGS_INPUT_UNKNOWN = 0,
-    /* PowerPC 6xx bus                  */
-    PPC_FLAGS_INPUT_6xx,
-    /* BookE bus                        */
-    PPC_FLAGS_INPUT_BookE,
-    /* PowerPC 405 bus                  */
-    PPC_FLAGS_INPUT_405,
-    /* PowerPC 970 bus                  */
-    PPC_FLAGS_INPUT_970,
-    /* PowerPC POWER7 bus               */
-    PPC_FLAGS_INPUT_POWER7,
-    /* PowerPC POWER9 bus               */
-    PPC_FLAGS_INPUT_POWER9,
-    /* Freescale RCPU bus               */
-    PPC_FLAGS_INPUT_RCPU,
-};
-
  #endif
target/ppc/cpu.h +20 -0
index c2cd069095..4b8b5d3d3e 100644
@@ -259,6 +259,26 @@ static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model)
      return mmu_model & POWERPC_MMU_64;
  }
 
+/*****************************************************************************/
+/* Input pins model                                                          */
+typedef enum powerpc_input_t {
+    PPC_FLAGS_INPUT_UNKNOWN = 0,
+    /* PowerPC 6xx bus                  */
+    PPC_FLAGS_INPUT_6xx,
+    /* BookE bus                        */
+    PPC_FLAGS_INPUT_BookE,
+    /* PowerPC 405 bus                  */
+    PPC_FLAGS_INPUT_405,
+    /* PowerPC 970 bus                  */
+    PPC_FLAGS_INPUT_970,
+    /* PowerPC POWER7 bus               */
+    PPC_FLAGS_INPUT_POWER7,
+    /* PowerPC POWER9 bus               */
+    PPC_FLAGS_INPUT_POWER9,
+    /* Freescale RCPU bus               */
+    PPC_FLAGS_INPUT_RCPU,
+} powerpc_input_t;
+
  #define PPC_INPUT(env) ((env)->bus_model)
 
  /*****************************************************************************/