qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h
@ 2023-06-27 11:51 Philippe Mathieu-Daudé
  2023-06-27 11:51 ` [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h' Philippe Mathieu-Daudé
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-27 11:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, Cédric Le Goater,
	qemu-ppc, Paolo Bonzini, Greg Kurz, kvm, Nicholas Piggin,
	Philippe Mathieu-Daudé

PPC specific changes of a bigger KVM cleanup, remove "kvm_ppc.h"
from user emulation. Mostly trivial IMO.

Philippe Mathieu-Daudé (6):
  target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h'
  target/ppc: Reorder #ifdef'ry in kvm_ppc.h
  target/ppc: Move CPU QOM definitions to cpu-qom.h
  target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h
  target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c
  target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h'

 target/ppc/cpu-qom.h  |  7 +++++
 target/ppc/cpu.h      |  6 ----
 target/ppc/kvm_ppc.h  | 70 ++++++++++++++++++-------------------------
 target/ppc/cpu_init.c |  2 +-
 4 files changed, 37 insertions(+), 48 deletions(-)

-- 
2.38.1



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h'
  2023-06-27 11:51 [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Philippe Mathieu-Daudé
@ 2023-06-27 11:51 ` Philippe Mathieu-Daudé
  2023-06-28 14:09   ` Greg Kurz
  2023-06-29  5:03   ` Cédric Le Goater
  2023-06-27 11:51 ` [PATCH v3 2/6] target/ppc: Reorder #ifdef'ry in kvm_ppc.h Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-27 11:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, Cédric Le Goater,
	qemu-ppc, Paolo Bonzini, Greg Kurz, kvm, Nicholas Piggin,
	Philippe Mathieu-Daudé

"kvm_ppc.h" declares:

  int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);

'struct kvm_run' is declared in "sysemu/kvm.h", include it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/ppc/kvm_ppc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 611debc3ce..2e395416f0 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -9,6 +9,7 @@
 #ifndef KVM_PPC_H
 #define KVM_PPC_H
 
+#include "sysemu/kvm.h"
 #include "exec/hwaddr.h"
 #include "cpu.h"
 
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 2/6] target/ppc: Reorder #ifdef'ry in kvm_ppc.h
  2023-06-27 11:51 [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Philippe Mathieu-Daudé
  2023-06-27 11:51 ` [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h' Philippe Mathieu-Daudé
@ 2023-06-27 11:51 ` Philippe Mathieu-Daudé
  2023-06-28 14:32   ` Greg Kurz
  2023-06-29  5:03   ` Cédric Le Goater
  2023-06-27 11:51 ` [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-27 11:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, Cédric Le Goater,
	qemu-ppc, Paolo Bonzini, Greg Kurz, kvm, Nicholas Piggin,
	Philippe Mathieu-Daudé

Keep a single if/else/endif block checking CONFIG_KVM.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/ppc/kvm_ppc.h | 62 ++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 34 deletions(-)

diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 2e395416f0..49954a300b 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -93,7 +93,34 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset);
 
 int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
 
-#else
+#define kvmppc_eieio() \
+    do {                                          \
+        if (kvm_enabled()) {                          \
+            asm volatile("eieio" : : : "memory"); \
+        } \
+    } while (0)
+
+/* Store data cache blocks back to memory */
+static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
+{
+    uint8_t *p;
+
+    for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) {
+        asm volatile("dcbst 0,%0" : : "r"(p) : "memory");
+    }
+}
+
+/* Invalidate instruction cache blocks */
+static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
+{
+    uint8_t *p;
+
+    for (p = addr; p < addr + len; p += cpu->env.icache_line_size) {
+        asm volatile("icbi 0,%0" : : "r"(p));
+    }
+}
+
+#else /* !CONFIG_KVM */
 
 static inline uint32_t kvmppc_get_tbfreq(void)
 {
@@ -440,10 +467,6 @@ static inline bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu)
     return false;
 }
 
-#endif
-
-#ifndef CONFIG_KVM
-
 #define kvmppc_eieio() do { } while (0)
 
 static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
@@ -454,35 +477,6 @@ static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
 {
 }
 
-#else   /* CONFIG_KVM */
-
-#define kvmppc_eieio() \
-    do {                                          \
-        if (kvm_enabled()) {                          \
-            asm volatile("eieio" : : : "memory"); \
-        } \
-    } while (0)
-
-/* Store data cache blocks back to memory */
-static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
-{
-    uint8_t *p;
-
-    for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) {
-        asm volatile("dcbst 0,%0" : : "r"(p) : "memory");
-    }
-}
-
-/* Invalidate instruction cache blocks */
-static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
-{
-    uint8_t *p;
-
-    for (p = addr; p < addr + len; p += cpu->env.icache_line_size) {
-        asm volatile("icbi 0,%0" : : "r"(p));
-    }
-}
-
 #endif  /* CONFIG_KVM */
 
 #endif /* KVM_PPC_H */
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h
  2023-06-27 11:51 [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Philippe Mathieu-Daudé
  2023-06-27 11:51 ` [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h' Philippe Mathieu-Daudé
  2023-06-27 11:51 ` [PATCH v3 2/6] target/ppc: Reorder #ifdef'ry in kvm_ppc.h Philippe Mathieu-Daudé
@ 2023-06-27 11:51 ` Philippe Mathieu-Daudé
  2023-06-28 15:05   ` Greg Kurz
  2023-06-29  5:03   ` Cédric Le Goater
  2023-06-27 11:51 ` [PATCH v3 4/6] target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-27 11:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, Cédric Le Goater,
	qemu-ppc, Paolo Bonzini, Greg Kurz, kvm, Nicholas Piggin,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/ppc/cpu-qom.h | 5 +++++
 target/ppc/cpu.h     | 6 ------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
index 9666f54f65..c2bff349cc 100644
--- a/target/ppc/cpu-qom.h
+++ b/target/ppc/cpu-qom.h
@@ -31,6 +31,11 @@
 
 OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
 
+#define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
+#define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
+#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
+#define cpu_list ppc_cpu_list
+
 ObjectClass *ppc_cpu_class_by_name(const char *name);
 
 typedef struct CPUArchState CPUPPCState;
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index af12c93ebc..e91e1774e5 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1468,12 +1468,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
 int ppc_dcr_read(ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp);
 int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
 
-#define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
-#define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
-#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
-
-#define cpu_list ppc_cpu_list
-
 /* MMU modes definitions */
 #define MMU_USER_IDX 0
 static inline int cpu_mmu_index(CPUPPCState *env, bool ifetch)
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 4/6] target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h
  2023-06-27 11:51 [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2023-06-27 11:51 ` [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h Philippe Mathieu-Daudé
@ 2023-06-27 11:51 ` Philippe Mathieu-Daudé
  2023-06-29  5:06   ` Cédric Le Goater
  2023-06-29  6:36   ` Greg Kurz
  2023-06-27 11:51 ` [PATCH v3 5/6] target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-27 11:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, Cédric Le Goater,
	qemu-ppc, Paolo Bonzini, Greg Kurz, kvm, Nicholas Piggin,
	Philippe Mathieu-Daudé

TYPE_HOST_POWERPC_CPU is used in various places of cpu_init.c,
in order to restrict "kvm_ppc.h" to sysemu, move this QOM-related
definition to cpu-qom.h.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/ppc/cpu-qom.h | 2 ++
 target/ppc/kvm_ppc.h | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
index c2bff349cc..4e4061068e 100644
--- a/target/ppc/cpu-qom.h
+++ b/target/ppc/cpu-qom.h
@@ -36,6 +36,8 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
 #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
 #define cpu_list ppc_cpu_list
 
+#define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
+
 ObjectClass *ppc_cpu_class_by_name(const char *name);
 
 typedef struct CPUArchState CPUPPCState;
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 49954a300b..901e188c9a 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -13,8 +13,6 @@
 #include "exec/hwaddr.h"
 #include "cpu.h"
 
-#define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
-
 #ifdef CONFIG_KVM
 
 uint32_t kvmppc_get_tbfreq(void);
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 5/6] target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c
  2023-06-27 11:51 [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2023-06-27 11:51 ` [PATCH v3 4/6] target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h Philippe Mathieu-Daudé
@ 2023-06-27 11:51 ` Philippe Mathieu-Daudé
  2023-06-29  5:06   ` Cédric Le Goater
  2023-06-29  6:36   ` Greg Kurz
  2023-06-27 11:51 ` [PATCH v3 6/6] target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h' Philippe Mathieu-Daudé
  2023-07-07  7:24 ` [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Daniel Henrique Barboza
  6 siblings, 2 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-27 11:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, Cédric Le Goater,
	qemu-ppc, Paolo Bonzini, Greg Kurz, kvm, Nicholas Piggin,
	Philippe Mathieu-Daudé

User emulation shouldn't need any of the KVM prototypes
declared in "kvm_ppc.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/ppc/cpu_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index aeff71d063..f2afb539eb 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -21,7 +21,6 @@
 #include "qemu/osdep.h"
 #include "disas/dis-asm.h"
 #include "gdbstub/helpers.h"
-#include "kvm_ppc.h"
 #include "sysemu/cpus.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/tcg.h"
@@ -49,6 +48,7 @@
 #ifndef CONFIG_USER_ONLY
 #include "hw/boards.h"
 #include "hw/intc/intc.h"
+#include "kvm_ppc.h"
 #endif
 
 /* #define PPC_DEBUG_SPR */
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 6/6] target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h'
  2023-06-27 11:51 [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2023-06-27 11:51 ` [PATCH v3 5/6] target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c Philippe Mathieu-Daudé
@ 2023-06-27 11:51 ` Philippe Mathieu-Daudé
  2023-06-29  5:10   ` Cédric Le Goater
  2023-06-29  6:37   ` Greg Kurz
  2023-07-07  7:24 ` [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Daniel Henrique Barboza
  6 siblings, 2 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-27 11:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, Cédric Le Goater,
	qemu-ppc, Paolo Bonzini, Greg Kurz, kvm, Nicholas Piggin,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/ppc/kvm_ppc.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 901e188c9a..6a4dd9c560 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -42,7 +42,6 @@ int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
 target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
                                      bool radix, bool gtse,
                                      uint64_t proc_tbl);
-#ifndef CONFIG_USER_ONLY
 bool kvmppc_spapr_use_multitce(void);
 int kvmppc_spapr_enable_inkernel_multitce(void);
 void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift,
@@ -52,7 +51,6 @@ int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
 int kvmppc_reset_htab(int shift_hint);
 uint64_t kvmppc_vrma_limit(unsigned int hash_shift);
 bool kvmppc_has_cap_spapr_vfio(void);
-#endif /* !CONFIG_USER_ONLY */
 bool kvmppc_has_cap_epr(void);
 int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function);
 int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp);
@@ -262,7 +260,6 @@ static inline void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset)
 {
 }
 
-#ifndef CONFIG_USER_ONLY
 static inline bool kvmppc_spapr_use_multitce(void)
 {
     return false;
@@ -322,8 +319,6 @@ static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)
     abort();
 }
 
-#endif /* !CONFIG_USER_ONLY */
-
 static inline bool kvmppc_has_cap_epr(void)
 {
     return false;
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h'
  2023-06-27 11:51 ` [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h' Philippe Mathieu-Daudé
@ 2023-06-28 14:09   ` Greg Kurz
  2023-06-29  5:03   ` Cédric Le Goater
  1 sibling, 0 replies; 22+ messages in thread
From: Greg Kurz @ 2023-06-28 14:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, David Gibson, Daniel Henrique Barboza,
	Cédric Le Goater, qemu-ppc, Paolo Bonzini, kvm,
	Nicholas Piggin

On Tue, 27 Jun 2023 13:51:19 +0200
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> "kvm_ppc.h" declares:
> 
>   int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
> 
> 'struct kvm_run' is declared in "sysemu/kvm.h", include it.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  target/ppc/kvm_ppc.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 611debc3ce..2e395416f0 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -9,6 +9,7 @@
>  #ifndef KVM_PPC_H
>  #define KVM_PPC_H
>  
> +#include "sysemu/kvm.h"
>  #include "exec/hwaddr.h"
>  #include "cpu.h"
>  



-- 
Greg


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/6] target/ppc: Reorder #ifdef'ry in kvm_ppc.h
  2023-06-27 11:51 ` [PATCH v3 2/6] target/ppc: Reorder #ifdef'ry in kvm_ppc.h Philippe Mathieu-Daudé
@ 2023-06-28 14:32   ` Greg Kurz
  2023-06-29  5:03   ` Cédric Le Goater
  1 sibling, 0 replies; 22+ messages in thread
From: Greg Kurz @ 2023-06-28 14:32 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, David Gibson, Daniel Henrique Barboza,
	Cédric Le Goater, qemu-ppc, Paolo Bonzini, kvm,
	Nicholas Piggin

On Tue, 27 Jun 2023 13:51:20 +0200
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> Keep a single if/else/endif block checking CONFIG_KVM.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  target/ppc/kvm_ppc.h | 62 ++++++++++++++++++++------------------------
>  1 file changed, 28 insertions(+), 34 deletions(-)
> 
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 2e395416f0..49954a300b 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -93,7 +93,34 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset);
>  
>  int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
>  
> -#else
> +#define kvmppc_eieio() \
> +    do {                                          \
> +        if (kvm_enabled()) {                          \
> +            asm volatile("eieio" : : : "memory"); \
> +        } \
> +    } while (0)
> +
> +/* Store data cache blocks back to memory */
> +static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> +{
> +    uint8_t *p;
> +
> +    for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) {
> +        asm volatile("dcbst 0,%0" : : "r"(p) : "memory");
> +    }
> +}
> +
> +/* Invalidate instruction cache blocks */
> +static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> +{
> +    uint8_t *p;
> +
> +    for (p = addr; p < addr + len; p += cpu->env.icache_line_size) {
> +        asm volatile("icbi 0,%0" : : "r"(p));
> +    }
> +}
> +
> +#else /* !CONFIG_KVM */
>  
>  static inline uint32_t kvmppc_get_tbfreq(void)
>  {
> @@ -440,10 +467,6 @@ static inline bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu)
>      return false;
>  }
>  
> -#endif
> -
> -#ifndef CONFIG_KVM
> -
>  #define kvmppc_eieio() do { } while (0)
>  
>  static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> @@ -454,35 +477,6 @@ static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
>  {
>  }
>  
> -#else   /* CONFIG_KVM */
> -
> -#define kvmppc_eieio() \

Arguably the kvm and non-kvm implementations will now come from
different commits in git blame. I personally favor keeping the
git blame consistency over bare code movement that doesn't fix
any actual bug.

Also this patch doesn't seem to be strictly needed to reach the
goal of kicking "kvm_ppc.h" out of user emulation.

> -    do {                                          \
> -        if (kvm_enabled()) {                          \
> -            asm volatile("eieio" : : : "memory"); \
> -        } \
> -    } while (0)
> -
> -/* Store data cache blocks back to memory */
> -static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> -{
> -    uint8_t *p;
> -
> -    for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) {
> -        asm volatile("dcbst 0,%0" : : "r"(p) : "memory");
> -    }
> -}
> -
> -/* Invalidate instruction cache blocks */
> -static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> -{
> -    uint8_t *p;
> -
> -    for (p = addr; p < addr + len; p += cpu->env.icache_line_size) {
> -        asm volatile("icbi 0,%0" : : "r"(p));
> -    }
> -}
> -
>  #endif  /* CONFIG_KVM */
>  
>  #endif /* KVM_PPC_H */



-- 
Greg


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h
  2023-06-27 11:51 ` [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h Philippe Mathieu-Daudé
@ 2023-06-28 15:05   ` Greg Kurz
  2023-06-30 14:06     ` Daniel Henrique Barboza
  2023-06-29  5:03   ` Cédric Le Goater
  1 sibling, 1 reply; 22+ messages in thread
From: Greg Kurz @ 2023-06-28 15:05 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, David Gibson, Daniel Henrique Barboza,
	Cédric Le Goater, qemu-ppc, Paolo Bonzini, kvm,
	Nicholas Piggin

On Tue, 27 Jun 2023 13:51:21 +0200
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  target/ppc/cpu-qom.h | 5 +++++
>  target/ppc/cpu.h     | 6 ------
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
> index 9666f54f65..c2bff349cc 100644
> --- a/target/ppc/cpu-qom.h
> +++ b/target/ppc/cpu-qom.h
> @@ -31,6 +31,11 @@
>  
>  OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
>  
> +#define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
> +#define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
> +#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
> +#define cpu_list ppc_cpu_list
> +
>  ObjectClass *ppc_cpu_class_by_name(const char *name);
>  
>  typedef struct CPUArchState CPUPPCState;
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index af12c93ebc..e91e1774e5 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1468,12 +1468,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
>  int ppc_dcr_read(ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp);
>  int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
>  
> -#define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
> -#define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
> -#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
> -

These seem appropriate to be moved to "cpu-qom.h".

> -#define cpu_list ppc_cpu_list

This one is much older according to git blame :

c913706581460 target/ppc/cpu.h (Igor Mammedov                 2017-08-30 1469) #define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
c913706581460 target/ppc/cpu.h (Igor Mammedov                 2017-08-30 1470) #define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
0dacec874fa3b target/ppc/cpu.h (Igor Mammedov                 2018-02-07 1471) #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
c913706581460 target/ppc/cpu.h (Igor Mammedov                 2017-08-30 1472) 
c732abe222795 target-ppc/cpu.h (Jocelyn Mayer                 2007-10-12 1473) #define cpu_list ppc_cpu_list

It is some plumbing used for `-cpu help`, not exactly QOM stuff.
Maybe keep it in "cpu.h" as all other targets do ?

> -
>  /* MMU modes definitions */
>  #define MMU_USER_IDX 0
>  static inline int cpu_mmu_index(CPUPPCState *env, bool ifetch)



-- 
Greg


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h'
  2023-06-27 11:51 ` [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h' Philippe Mathieu-Daudé
  2023-06-28 14:09   ` Greg Kurz
@ 2023-06-29  5:03   ` Cédric Le Goater
  1 sibling, 0 replies; 22+ messages in thread
From: Cédric Le Goater @ 2023-06-29  5:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, qemu-ppc, Paolo Bonzini,
	Greg Kurz, kvm, Nicholas Piggin

On 6/27/23 13:51, Philippe Mathieu-Daudé wrote:
> "kvm_ppc.h" declares:
> 
>    int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
> 
> 'struct kvm_run' is declared in "sysemu/kvm.h", include it.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>




Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.



> ---
>   target/ppc/kvm_ppc.h | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 611debc3ce..2e395416f0 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -9,6 +9,7 @@
>   #ifndef KVM_PPC_H
>   #define KVM_PPC_H
>   
> +#include "sysemu/kvm.h"
>   #include "exec/hwaddr.h"
>   #include "cpu.h"
>   



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/6] target/ppc: Reorder #ifdef'ry in kvm_ppc.h
  2023-06-27 11:51 ` [PATCH v3 2/6] target/ppc: Reorder #ifdef'ry in kvm_ppc.h Philippe Mathieu-Daudé
  2023-06-28 14:32   ` Greg Kurz
@ 2023-06-29  5:03   ` Cédric Le Goater
  1 sibling, 0 replies; 22+ messages in thread
From: Cédric Le Goater @ 2023-06-29  5:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, qemu-ppc, Paolo Bonzini,
	Greg Kurz, kvm, Nicholas Piggin

On 6/27/23 13:51, Philippe Mathieu-Daudé wrote:
> Keep a single if/else/endif block checking CONFIG_KVM.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>





Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.


> ---
>   target/ppc/kvm_ppc.h | 62 ++++++++++++++++++++------------------------
>   1 file changed, 28 insertions(+), 34 deletions(-)
> 
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 2e395416f0..49954a300b 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -93,7 +93,34 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset);
>   
>   int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
>   
> -#else
> +#define kvmppc_eieio() \
> +    do {                                          \
> +        if (kvm_enabled()) {                          \
> +            asm volatile("eieio" : : : "memory"); \
> +        } \
> +    } while (0)
> +
> +/* Store data cache blocks back to memory */
> +static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> +{
> +    uint8_t *p;
> +
> +    for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) {
> +        asm volatile("dcbst 0,%0" : : "r"(p) : "memory");
> +    }
> +}
> +
> +/* Invalidate instruction cache blocks */
> +static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> +{
> +    uint8_t *p;
> +
> +    for (p = addr; p < addr + len; p += cpu->env.icache_line_size) {
> +        asm volatile("icbi 0,%0" : : "r"(p));
> +    }
> +}
> +
> +#else /* !CONFIG_KVM */
>   
>   static inline uint32_t kvmppc_get_tbfreq(void)
>   {
> @@ -440,10 +467,6 @@ static inline bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu)
>       return false;
>   }
>   
> -#endif
> -
> -#ifndef CONFIG_KVM
> -
>   #define kvmppc_eieio() do { } while (0)
>   
>   static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> @@ -454,35 +477,6 @@ static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
>   {
>   }
>   
> -#else   /* CONFIG_KVM */
> -
> -#define kvmppc_eieio() \
> -    do {                                          \
> -        if (kvm_enabled()) {                          \
> -            asm volatile("eieio" : : : "memory"); \
> -        } \
> -    } while (0)
> -
> -/* Store data cache blocks back to memory */
> -static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> -{
> -    uint8_t *p;
> -
> -    for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) {
> -        asm volatile("dcbst 0,%0" : : "r"(p) : "memory");
> -    }
> -}
> -
> -/* Invalidate instruction cache blocks */
> -static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
> -{
> -    uint8_t *p;
> -
> -    for (p = addr; p < addr + len; p += cpu->env.icache_line_size) {
> -        asm volatile("icbi 0,%0" : : "r"(p));
> -    }
> -}
> -
>   #endif  /* CONFIG_KVM */
>   
>   #endif /* KVM_PPC_H */



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h
  2023-06-27 11:51 ` [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h Philippe Mathieu-Daudé
  2023-06-28 15:05   ` Greg Kurz
@ 2023-06-29  5:03   ` Cédric Le Goater
  1 sibling, 0 replies; 22+ messages in thread
From: Cédric Le Goater @ 2023-06-29  5:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, qemu-ppc, Paolo Bonzini,
	Greg Kurz, kvm, Nicholas Piggin

On 6/27/23 13:51, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>




Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.



> ---
>   target/ppc/cpu-qom.h | 5 +++++
>   target/ppc/cpu.h     | 6 ------
>   2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
> index 9666f54f65..c2bff349cc 100644
> --- a/target/ppc/cpu-qom.h
> +++ b/target/ppc/cpu-qom.h
> @@ -31,6 +31,11 @@
>   
>   OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
>   
> +#define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
> +#define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
> +#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
> +#define cpu_list ppc_cpu_list
> +
>   ObjectClass *ppc_cpu_class_by_name(const char *name);
>   
>   typedef struct CPUArchState CPUPPCState;
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index af12c93ebc..e91e1774e5 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1468,12 +1468,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
>   int ppc_dcr_read(ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp);
>   int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
>   
> -#define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
> -#define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
> -#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
> -
> -#define cpu_list ppc_cpu_list
> -
>   /* MMU modes definitions */
>   #define MMU_USER_IDX 0
>   static inline int cpu_mmu_index(CPUPPCState *env, bool ifetch)



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/6] target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h
  2023-06-27 11:51 ` [PATCH v3 4/6] target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h Philippe Mathieu-Daudé
@ 2023-06-29  5:06   ` Cédric Le Goater
  2023-06-29  6:36   ` Greg Kurz
  1 sibling, 0 replies; 22+ messages in thread
From: Cédric Le Goater @ 2023-06-29  5:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, qemu-ppc, Paolo Bonzini,
	Greg Kurz, kvm, Nicholas Piggin

On 6/27/23 13:51, Philippe Mathieu-Daudé wrote:
> TYPE_HOST_POWERPC_CPU is used in various places of cpu_init.c,
> in order to restrict "kvm_ppc.h" to sysemu, move this QOM-related
> definition to cpu-qom.h.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>




Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.



> ---
>   target/ppc/cpu-qom.h | 2 ++
>   target/ppc/kvm_ppc.h | 2 --
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
> index c2bff349cc..4e4061068e 100644
> --- a/target/ppc/cpu-qom.h
> +++ b/target/ppc/cpu-qom.h
> @@ -36,6 +36,8 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
>   #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
>   #define cpu_list ppc_cpu_list
>   
> +#define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
> +
>   ObjectClass *ppc_cpu_class_by_name(const char *name);
>   
>   typedef struct CPUArchState CPUPPCState;
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 49954a300b..901e188c9a 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -13,8 +13,6 @@
>   #include "exec/hwaddr.h"
>   #include "cpu.h"
>   
> -#define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
> -
>   #ifdef CONFIG_KVM
>   
>   uint32_t kvmppc_get_tbfreq(void);



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 5/6] target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c
  2023-06-27 11:51 ` [PATCH v3 5/6] target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c Philippe Mathieu-Daudé
@ 2023-06-29  5:06   ` Cédric Le Goater
  2023-06-29  6:36   ` Greg Kurz
  1 sibling, 0 replies; 22+ messages in thread
From: Cédric Le Goater @ 2023-06-29  5:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, qemu-ppc, Paolo Bonzini,
	Greg Kurz, kvm, Nicholas Piggin

On 6/27/23 13:51, Philippe Mathieu-Daudé wrote:
> User emulation shouldn't need any of the KVM prototypes
> declared in "kvm_ppc.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>



Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.


> ---
>   target/ppc/cpu_init.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index aeff71d063..f2afb539eb 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -21,7 +21,6 @@
>   #include "qemu/osdep.h"
>   #include "disas/dis-asm.h"
>   #include "gdbstub/helpers.h"
> -#include "kvm_ppc.h"
>   #include "sysemu/cpus.h"
>   #include "sysemu/hw_accel.h"
>   #include "sysemu/tcg.h"
> @@ -49,6 +48,7 @@
>   #ifndef CONFIG_USER_ONLY
>   #include "hw/boards.h"
>   #include "hw/intc/intc.h"
> +#include "kvm_ppc.h"
>   #endif
>   
>   /* #define PPC_DEBUG_SPR */



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 6/6] target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h'
  2023-06-27 11:51 ` [PATCH v3 6/6] target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h' Philippe Mathieu-Daudé
@ 2023-06-29  5:10   ` Cédric Le Goater
  2023-06-29  6:37   ` Greg Kurz
  1 sibling, 0 replies; 22+ messages in thread
From: Cédric Le Goater @ 2023-06-29  5:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: David Gibson, Daniel Henrique Barboza, qemu-ppc, Paolo Bonzini,
	Greg Kurz, kvm, Nicholas Piggin

On 6/27/23 13:51, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>


I guess the MemoryRegion code has sufficiently changed since commit
98efaf75282a ("ppc: Fix up usermode only builds") ?

Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.




> ---
>   target/ppc/kvm_ppc.h | 5 -----
>   1 file changed, 5 deletions(-)
> 
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 901e188c9a..6a4dd9c560 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -42,7 +42,6 @@ int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
>   target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
>                                        bool radix, bool gtse,
>                                        uint64_t proc_tbl);
> -#ifndef CONFIG_USER_ONLY
>   bool kvmppc_spapr_use_multitce(void);
>   int kvmppc_spapr_enable_inkernel_multitce(void);
>   void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift,
> @@ -52,7 +51,6 @@ int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
>   int kvmppc_reset_htab(int shift_hint);
>   uint64_t kvmppc_vrma_limit(unsigned int hash_shift);
>   bool kvmppc_has_cap_spapr_vfio(void);
> -#endif /* !CONFIG_USER_ONLY */
>   bool kvmppc_has_cap_epr(void);
>   int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function);
>   int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp);
> @@ -262,7 +260,6 @@ static inline void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset)
>   {
>   }
>   
> -#ifndef CONFIG_USER_ONLY
>   static inline bool kvmppc_spapr_use_multitce(void)
>   {
>       return false;
> @@ -322,8 +319,6 @@ static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)
>       abort();
>   }
>   
> -#endif /* !CONFIG_USER_ONLY */
> -
>   static inline bool kvmppc_has_cap_epr(void)
>   {
>       return false;



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/6] target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h
  2023-06-27 11:51 ` [PATCH v3 4/6] target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h Philippe Mathieu-Daudé
  2023-06-29  5:06   ` Cédric Le Goater
@ 2023-06-29  6:36   ` Greg Kurz
  1 sibling, 0 replies; 22+ messages in thread
From: Greg Kurz @ 2023-06-29  6:36 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, David Gibson, Daniel Henrique Barboza,
	Cédric Le Goater, qemu-ppc, Paolo Bonzini, kvm,
	Nicholas Piggin

On Tue, 27 Jun 2023 13:51:22 +0200
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> TYPE_HOST_POWERPC_CPU is used in various places of cpu_init.c,
> in order to restrict "kvm_ppc.h" to sysemu, move this QOM-related
> definition to cpu-qom.h.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  target/ppc/cpu-qom.h | 2 ++
>  target/ppc/kvm_ppc.h | 2 --
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
> index c2bff349cc..4e4061068e 100644
> --- a/target/ppc/cpu-qom.h
> +++ b/target/ppc/cpu-qom.h
> @@ -36,6 +36,8 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
>  #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
>  #define cpu_list ppc_cpu_list
>  
> +#define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
> +
>  ObjectClass *ppc_cpu_class_by_name(const char *name);
>  
>  typedef struct CPUArchState CPUPPCState;
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 49954a300b..901e188c9a 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -13,8 +13,6 @@
>  #include "exec/hwaddr.h"
>  #include "cpu.h"
>  
> -#define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
> -
>  #ifdef CONFIG_KVM
>  
>  uint32_t kvmppc_get_tbfreq(void);



-- 
Greg


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 5/6] target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c
  2023-06-27 11:51 ` [PATCH v3 5/6] target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c Philippe Mathieu-Daudé
  2023-06-29  5:06   ` Cédric Le Goater
@ 2023-06-29  6:36   ` Greg Kurz
  1 sibling, 0 replies; 22+ messages in thread
From: Greg Kurz @ 2023-06-29  6:36 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, David Gibson, Daniel Henrique Barboza,
	Cédric Le Goater, qemu-ppc, Paolo Bonzini, kvm,
	Nicholas Piggin

On Tue, 27 Jun 2023 13:51:23 +0200
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> User emulation shouldn't need any of the KVM prototypes
> declared in "kvm_ppc.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  target/ppc/cpu_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index aeff71d063..f2afb539eb 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -21,7 +21,6 @@
>  #include "qemu/osdep.h"
>  #include "disas/dis-asm.h"
>  #include "gdbstub/helpers.h"
> -#include "kvm_ppc.h"
>  #include "sysemu/cpus.h"
>  #include "sysemu/hw_accel.h"
>  #include "sysemu/tcg.h"
> @@ -49,6 +48,7 @@
>  #ifndef CONFIG_USER_ONLY
>  #include "hw/boards.h"
>  #include "hw/intc/intc.h"
> +#include "kvm_ppc.h"
>  #endif
>  
>  /* #define PPC_DEBUG_SPR */



-- 
Greg


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 6/6] target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h'
  2023-06-27 11:51 ` [PATCH v3 6/6] target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h' Philippe Mathieu-Daudé
  2023-06-29  5:10   ` Cédric Le Goater
@ 2023-06-29  6:37   ` Greg Kurz
  1 sibling, 0 replies; 22+ messages in thread
From: Greg Kurz @ 2023-06-29  6:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, David Gibson, Daniel Henrique Barboza,
	Cédric Le Goater, qemu-ppc, Paolo Bonzini, kvm,
	Nicholas Piggin

On Tue, 27 Jun 2023 13:51:24 +0200
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  target/ppc/kvm_ppc.h | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 901e188c9a..6a4dd9c560 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -42,7 +42,6 @@ int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
>  target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
>                                       bool radix, bool gtse,
>                                       uint64_t proc_tbl);
> -#ifndef CONFIG_USER_ONLY
>  bool kvmppc_spapr_use_multitce(void);
>  int kvmppc_spapr_enable_inkernel_multitce(void);
>  void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift,
> @@ -52,7 +51,6 @@ int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
>  int kvmppc_reset_htab(int shift_hint);
>  uint64_t kvmppc_vrma_limit(unsigned int hash_shift);
>  bool kvmppc_has_cap_spapr_vfio(void);
> -#endif /* !CONFIG_USER_ONLY */
>  bool kvmppc_has_cap_epr(void);
>  int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function);
>  int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp);
> @@ -262,7 +260,6 @@ static inline void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset)
>  {
>  }
>  
> -#ifndef CONFIG_USER_ONLY
>  static inline bool kvmppc_spapr_use_multitce(void)
>  {
>      return false;
> @@ -322,8 +319,6 @@ static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)
>      abort();
>  }
>  
> -#endif /* !CONFIG_USER_ONLY */
> -
>  static inline bool kvmppc_has_cap_epr(void)
>  {
>      return false;



-- 
Greg


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h
  2023-06-28 15:05   ` Greg Kurz
@ 2023-06-30 14:06     ` Daniel Henrique Barboza
  0 siblings, 0 replies; 22+ messages in thread
From: Daniel Henrique Barboza @ 2023-06-30 14:06 UTC (permalink / raw)
  To: Greg Kurz, Philippe Mathieu-Daudé
  Cc: qemu-devel, David Gibson, Cédric Le Goater, qemu-ppc,
	Paolo Bonzini, kvm, Nicholas Piggin

Phil,

On 6/28/23 12:05, Greg Kurz wrote:
> On Tue, 27 Jun 2023 13:51:21 +0200
> Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> 
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   target/ppc/cpu-qom.h | 5 +++++
>>   target/ppc/cpu.h     | 6 ------
>>   2 files changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
>> index 9666f54f65..c2bff349cc 100644
>> --- a/target/ppc/cpu-qom.h
>> +++ b/target/ppc/cpu-qom.h
>> @@ -31,6 +31,11 @@
>>   
>>   OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU)
>>   
>> +#define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
>> +#define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
>> +#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
>> +#define cpu_list ppc_cpu_list
>> +
>>   ObjectClass *ppc_cpu_class_by_name(const char *name);
>>   
>>   typedef struct CPUArchState CPUPPCState;
>> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
>> index af12c93ebc..e91e1774e5 100644
>> --- a/target/ppc/cpu.h
>> +++ b/target/ppc/cpu.h
>> @@ -1468,12 +1468,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
>>   int ppc_dcr_read(ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp);
>>   int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
>>   
>> -#define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
>> -#define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
>> -#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
>> -
> 
> These seem appropriate to be moved to "cpu-qom.h".
> 
>> -#define cpu_list ppc_cpu_list
> 
> This one is much older according to git blame :
> 
> c913706581460 target/ppc/cpu.h (Igor Mammedov                 2017-08-30 1469) #define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
> c913706581460 target/ppc/cpu.h (Igor Mammedov                 2017-08-30 1470) #define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
> 0dacec874fa3b target/ppc/cpu.h (Igor Mammedov                 2018-02-07 1471) #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
> c913706581460 target/ppc/cpu.h (Igor Mammedov                 2017-08-30 1472)
> c732abe222795 target-ppc/cpu.h (Jocelyn Mayer                 2007-10-12 1473) #define cpu_list ppc_cpu_list
> 
> It is some plumbing used for `-cpu help`, not exactly QOM stuff.
> Maybe keep it in "cpu.h" as all other targets do ?

Greg has a point:

$ git grep '#define cpu_list'
target/alpha/cpu.h:#define cpu_list alpha_cpu_list
target/arm/cpu.h:#define cpu_list arm_cpu_list
target/avr/cpu.h:#define cpu_list avr_cpu_list
target/cris/cpu.h:#define cpu_list cris_cpu_list
target/hexagon/cpu.h:#define cpu_list hexagon_cpu_list
target/i386/cpu.h:#define cpu_list x86_cpu_list
target/loongarch/cpu.h:#define cpu_list loongarch_cpu_list
target/m68k/cpu.h:#define cpu_list m68k_cpu_list
target/mips/cpu.h:#define cpu_list mips_cpu_list
target/openrisc/cpu.h:#define cpu_list cpu_openrisc_list
target/ppc/cpu.h:#define cpu_list ppc_cpu_list
target/riscv/cpu.h:#define cpu_list riscv_cpu_list
target/rx/cpu.h:#define cpu_list rx_cpu_list
target/s390x/cpu.h:#define cpu_list s390_cpu_list
target/sh4/cpu.h:#define cpu_list sh4_cpu_list
target/sparc/cpu.h:#define cpu_list sparc_cpu_list
target/tricore/cpu.h:#define cpu_list tricore_cpu_list
target/xtensa/cpu.h:#define cpu_list xtensa_cpu_list

I'm not against moving this define to cpu-qom.h per se but I believe that, for the sake
of consistency, this change should be done in a single swoop across all archs.

For now, if you agree with keeping the 'cpu_list' define in cpu.h, I'll queue this up
and amend it in-tree.


Thanks,

Daniel

> 
>> -
>>   /* MMU modes definitions */
>>   #define MMU_USER_IDX 0
>>   static inline int cpu_mmu_index(CPUPPCState *env, bool ifetch)
> 
> 
> 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h
  2023-06-27 11:51 [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2023-06-27 11:51 ` [PATCH v3 6/6] target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h' Philippe Mathieu-Daudé
@ 2023-07-07  7:24 ` Daniel Henrique Barboza
  2023-07-07  8:11   ` Philippe Mathieu-Daudé
  6 siblings, 1 reply; 22+ messages in thread
From: Daniel Henrique Barboza @ 2023-07-07  7:24 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: David Gibson, Cédric Le Goater, qemu-ppc, Paolo Bonzini,
	Greg Kurz, kvm, Nicholas Piggin

Phil,

I queued all patches to ppc-next. I fixed up patch 3 to not move the cpu_list
macro as Greg suggested. If you're strongly attached to it let me know and
I'll remove it from the queue.

Greg, feel free to send your R-b in patch 3 if patch 3 with this change pleases
you.


Daniel

On 6/27/23 08:51, Philippe Mathieu-Daudé wrote:
> PPC specific changes of a bigger KVM cleanup, remove "kvm_ppc.h"
> from user emulation. Mostly trivial IMO.
> 
> Philippe Mathieu-Daudé (6):
>    target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h'
>    target/ppc: Reorder #ifdef'ry in kvm_ppc.h
>    target/ppc: Move CPU QOM definitions to cpu-qom.h
>    target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h
>    target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c
>    target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h'
> 
>   target/ppc/cpu-qom.h  |  7 +++++
>   target/ppc/cpu.h      |  6 ----
>   target/ppc/kvm_ppc.h  | 70 ++++++++++++++++++-------------------------
>   target/ppc/cpu_init.c |  2 +-
>   4 files changed, 37 insertions(+), 48 deletions(-)
> 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h
  2023-07-07  7:24 ` [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Daniel Henrique Barboza
@ 2023-07-07  8:11   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-07-07  8:11 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel
  Cc: David Gibson, Cédric Le Goater, qemu-ppc, Paolo Bonzini,
	Greg Kurz, kvm, Nicholas Piggin

On 7/7/23 09:24, Daniel Henrique Barboza wrote:
> Phil,
> 
> I queued all patches to ppc-next. I fixed up patch 3 to not move the 
> cpu_list
> macro as Greg suggested. If you're strongly attached to it let me know and
> I'll remove it from the queue.

Sorry for missing that earlier, sure, no problem!

> Greg, feel free to send your R-b in patch 3 if patch 3 with this change 
> pleases
> you.
> 
> 
> Daniel



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-07-07  8:11 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-27 11:51 [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Philippe Mathieu-Daudé
2023-06-27 11:51 ` [PATCH v3 1/6] target/ppc: Have 'kvm_ppc.h' include 'sysemu/kvm.h' Philippe Mathieu-Daudé
2023-06-28 14:09   ` Greg Kurz
2023-06-29  5:03   ` Cédric Le Goater
2023-06-27 11:51 ` [PATCH v3 2/6] target/ppc: Reorder #ifdef'ry in kvm_ppc.h Philippe Mathieu-Daudé
2023-06-28 14:32   ` Greg Kurz
2023-06-29  5:03   ` Cédric Le Goater
2023-06-27 11:51 ` [PATCH v3 3/6] target/ppc: Move CPU QOM definitions to cpu-qom.h Philippe Mathieu-Daudé
2023-06-28 15:05   ` Greg Kurz
2023-06-30 14:06     ` Daniel Henrique Barboza
2023-06-29  5:03   ` Cédric Le Goater
2023-06-27 11:51 ` [PATCH v3 4/6] target/ppc: Define TYPE_HOST_POWERPC_CPU in cpu-qom.h Philippe Mathieu-Daudé
2023-06-29  5:06   ` Cédric Le Goater
2023-06-29  6:36   ` Greg Kurz
2023-06-27 11:51 ` [PATCH v3 5/6] target/ppc: Restrict 'kvm_ppc.h' to sysemu in cpu_init.c Philippe Mathieu-Daudé
2023-06-29  5:06   ` Cédric Le Goater
2023-06-29  6:36   ` Greg Kurz
2023-06-27 11:51 ` [PATCH v3 6/6] target/ppc: Remove pointless checks of CONFIG_USER_ONLY in 'kvm_ppc.h' Philippe Mathieu-Daudé
2023-06-29  5:10   ` Cédric Le Goater
2023-06-29  6:37   ` Greg Kurz
2023-07-07  7:24 ` [PATCH v3 0/6] target/ppc: Few cleanups in kvm_ppc.h Daniel Henrique Barboza
2023-07-07  8:11   ` Philippe Mathieu-Daudé

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).