Skip to contentSkip to conversation

ppc: Clean up few headers to make them target agnostic

PATCH In review Philippe Mathieu-Daudé 5 participants 15 messages Dec 13, 2022 – Dec 22, 2022 KVM

lore
Share & tools
lore
#0 lore raw

cover ppc: Clean up few headers to make them target agnostic

Few changes in hw/ & target/ to reduce the target specificity of some sPAPR headers.

Philippe Mathieu-Daudé (4):
target/ppc/kvm: Add missing "cpu.h" and "exec/hwaddr.h" hw/ppc/vof: Do not include the full "cpu.h" hw/ppc/spapr: Reduce "vof.h" inclusion hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

 hw/ppc/spapr.c              | 1 +
 hw/ppc/spapr_ovec.c         | 3 ++-
 include/hw/ppc/spapr.h      | 3 ++-
 include/hw/ppc/spapr_ovec.h | 4 ++--
 include/hw/ppc/vof.h        | 2 +-
 target/ppc/kvm_ppc.h        | 3 +++
 6 files changed, 11 insertions(+), 5 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/4 target/ppc/kvm: Add missing "cpu.h" and "exec/hwaddr.h"

kvm_ppc.h is missing various declarations from "cpu.h":

target/ppc/kvm_ppc.h:128:40: error: unknown type name 'CPUPPCState'; did you mean 'CPUState'? static inline int kvmppc_get_hypercall(CPUPPCState *env,

                                         ^~~~~~~~~~~
                                         CPUState
  include/qemu/typedefs.h:45:25: note: 'CPUState' declared here
  typedef struct CPUState CPUState;
                          ^
  target/ppc/kvm_ppc.h:134:40: error: unknown type name 'PowerPCCPU'
  static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level)
                                         ^
  target/ppc/kvm_ppc.h:285:38: error: unknown type name 'hwaddr'
                                       hwaddr ptex, int n)
                                       ^
  target/ppc/kvm_ppc.h:220:15: error: unknown type name 'target_ulong'
  static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
                ^
  target/ppc/kvm_ppc.h:286:38: error: unknown type name 'ppc_hash_pte64_t'
  static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
                                       ^
---
 target/ppc/kvm_ppc.h | 3 +++
 1 file changed, 3 insertions(+)
target/ppc/kvm_ppc.h +3 -0
index ee9325bf9a..5fd9753953 100644
@@ -9,6 +9,9 @@
 #ifndef KVM_PPC_H
 #define KVM_PPC_H
 
+#include "exec/hwaddr.h"
+#include "cpu.h"
+
 #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
 #ifdef CONFIG_KVM
Signature · 1 line
2.38.1
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH-for-8.0 1/4] target/ppc/kvm: Add missing "cpu.h" and "exec/hwaddr.h"

Quoted 22 lines · Philippe Mathieu-Daudé

kvm_ppc.h is missing various declarations from "cpu.h":

target/ppc/kvm_ppc.h:128:40: error: unknown type name 'CPUPPCState'; did you mean 'CPUState'? static inline int kvmppc_get_hypercall(CPUPPCState *env,

                                          ^~~~~~~~~~~
                                          CPUState
   include/qemu/typedefs.h:45:25: note: 'CPUState' declared here
   typedef struct CPUState CPUState;
                           ^
   target/ppc/kvm_ppc.h:134:40: error: unknown type name 'PowerPCCPU'
   static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level)
                                          ^
   target/ppc/kvm_ppc.h:285:38: error: unknown type name 'hwaddr'
                                        hwaddr ptex, int n)
                                        ^
   target/ppc/kvm_ppc.h:220:15: error: unknown type name 'target_ulong'
   static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
                 ^
   target/ppc/kvm_ppc.h:286:38: error: unknown type name 'ppc_hash_pte64_t'
   static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
                                        ^
Quoted 2 lines

---

Quoted 17 lines
  target/ppc/kvm_ppc.h | 3 +++
  1 file changed, 3 insertions(+)
target/ppc/kvm_ppc.h +3 -0
index ee9325bf9a..5fd9753953 100644
@@ -9,6 +9,9 @@
  #ifndef KVM_PPC_H
  #define KVM_PPC_H
 
+#include "exec/hwaddr.h"
+#include "cpu.h"
+
  #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
  #ifdef CONFIG_KVM
#3 lore raw

PATCH 2/4 hw/ppc/vof: Do not include the full "cpu.h"

In reply to Philippe Mathieu-Daudé

"vof.h" doesn't need the full "cpu.h" to get the target_ulong definition, including "exec/cpu-defs.h" is enough.

---
 include/hw/ppc/vof.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/ppc/vof.h +1 -1
index f8c0effcaf..d3f293da8b 100644
@@ -9,7 +9,7 @@
 #include "qom/object.h"
 #include "exec/address-spaces.h"
 #include "exec/memory.h"
-#include "cpu.h"
+#include "exec/cpu-defs.h"
 
 typedef struct Vof {
     uint64_t top_addr; /* copied from rma_size */
Signature · 1 line
2.38.1
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH-for-8.0 2/4] hw/ppc/vof: Do not include the full "cpu.h"

Quoted 5 lines · Philippe Mathieu-Daudé

"vof.h" doesn't need the full "cpu.h" to get the target_ulong definition, including "exec/cpu-defs.h" is enough.

---

Quoted 16 lines
  include/hw/ppc/vof.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/ppc/vof.h +1 -1
index f8c0effcaf..d3f293da8b 100644
@@ -9,7 +9,7 @@
  #include "qom/object.h"
  #include "exec/address-spaces.h"
  #include "exec/memory.h"
-#include "cpu.h"
+#include "exec/cpu-defs.h"
 
  typedef struct Vof {
      uint64_t top_addr; /* copied from rma_size */
#5 lore raw

PATCH 3/4 hw/ppc/spapr: Reduce "vof.h" inclusion

In reply to Philippe Mathieu-Daudé

Currently objects including "hw/ppc/spapr.h" are forced to be target specific due to the inclusion of "vof.h" in "spapr.h".

"spapr.h" only uses a Vof pointer, so doesn't require the structure declaration. The only place where Vof structure is accessed is in spapr.c, so include "vof.h" there, and forward declare the structure in "spapr.h".

---
 hw/ppc/spapr.c         | 1 +
 include/hw/ppc/spapr.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +1 -0
index 66b414d2e9..f38a851ee3 100644
@@ -62,6 +62,7 @@
 #include "hw/ppc/fdt.h"
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"
+#include "hw/ppc/vof.h"
 #include "hw/qdev-properties.h"
 #include "hw/pci-host/spapr.h"
 #include "hw/pci/msi.h"
include/hw/ppc/spapr.h +2 -1
index 04a95669ab..5c8aabd444 100644
@@ -12,7 +12,6 @@
 #include "hw/ppc/spapr_xive.h"  /* For SpaprXive */
 #include "hw/ppc/xics.h"        /* For ICSState */
 #include "hw/ppc/spapr_tpm_proxy.h"
-#include "hw/ppc/vof.h"
 
 struct SpaprVioBus;
 struct SpaprPhbState;
@@ -22,6 +21,8 @@ typedef struct SpaprEventLogEntry SpaprEventLogEntry;
 typedef struct SpaprEventSource SpaprEventSource;
 typedef struct SpaprPendingHpt SpaprPendingHpt;
 
+typedef struct Vof Vof;
+
 #define HPTE64_V_HPTE_DIRTY     0x0000000000000040ULL
 #define SPAPR_ENTRY_POINT       0x100
 
Signature · 1 line
2.38.1
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH-for-8.0 3/4] hw/ppc/spapr: Reduce "vof.h" inclusion

Quoted 10 lines · Philippe Mathieu-Daudé

Currently objects including "hw/ppc/spapr.h" are forced to be target specific due to the inclusion of "vof.h" in "spapr.h".

"spapr.h" only uses a Vof pointer, so doesn't require the structure declaration. The only place where Vof structure is accessed is in spapr.c, so include "vof.h" there, and forward declare the structure in "spapr.h".

---

Quoted 37 lines
  hw/ppc/spapr.c         | 1 +
  include/hw/ppc/spapr.h | 3 ++-
  2 files changed, 3 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +1 -0
index 66b414d2e9..f38a851ee3 100644
@@ -62,6 +62,7 @@
  #include "hw/ppc/fdt.h"
  #include "hw/ppc/spapr.h"
  #include "hw/ppc/spapr_vio.h"
+#include "hw/ppc/vof.h"
  #include "hw/qdev-properties.h"
  #include "hw/pci-host/spapr.h"
  #include "hw/pci/msi.h"
include/hw/ppc/spapr.h +2 -1
index 04a95669ab..5c8aabd444 100644
@@ -12,7 +12,6 @@
  #include "hw/ppc/spapr_xive.h"  /* For SpaprXive */
  #include "hw/ppc/xics.h"        /* For ICSState */
  #include "hw/ppc/spapr_tpm_proxy.h"
-#include "hw/ppc/vof.h"
 
  struct SpaprVioBus;
  struct SpaprPhbState;
@@ -22,6 +21,8 @@ typedef struct SpaprEventLogEntry SpaprEventLogEntry;
  typedef struct SpaprEventSource SpaprEventSource;
  typedef struct SpaprPendingHpt SpaprPendingHpt;
 
+typedef struct Vof Vof;
+
  #define HPTE64_V_HPTE_DIRTY     0x0000000000000040ULL
  #define SPAPR_ENTRY_POINT       0x100
 
#7 lore raw

PATCH 4/4 hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

In reply to Philippe Mathieu-Daudé

spapr_ovec.c is a device, but it uses target_ulong which is target specific. The hwaddr type (declared in "exec/hwaddr.h") better fits hardware addresses.

Change spapr_ovec_parse_vector() to take a hwaddr argument, allowing the removal of "cpu.h" in a device header.

---
 hw/ppc/spapr_ovec.c         | 3 ++-
 include/hw/ppc/spapr_ovec.h | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
hw/ppc/spapr_ovec.c +2 -1
index b2567caa5c..a18a751b57 100644
@@ -19,6 +19,7 @@
 #include "qemu/error-report.h"
 #include "trace.h"
 #include <libfdt.h>
+#include "cpu.h"
 
 #define OV_MAXBYTES 256 /* not including length byte */
 #define OV_MAXBITS (OV_MAXBYTES * BITS_PER_BYTE)
@@ -176,7 +177,7 @@ static target_ulong vector_addr(target_ulong table_addr, int vector)
     return table_addr;
 }
 
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector)
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector)
 {
     SpaprOptionVector *ov;
     target_ulong addr;
include/hw/ppc/spapr_ovec.h +2 -2
index c3e8b98e7e..d756b916e4 100644
@@ -37,7 +37,7 @@
 #ifndef SPAPR_OVEC_H
 #define SPAPR_OVEC_H
 
-#include "cpu.h"
+#include "exec/hwaddr.h"
 
 typedef struct SpaprOptionVector SpaprOptionVector;
 
@@ -73,7 +73,7 @@ void spapr_ovec_set(SpaprOptionVector *ov, long bitnr);
 void spapr_ovec_clear(SpaprOptionVector *ov, long bitnr);
 bool spapr_ovec_test(SpaprOptionVector *ov, long bitnr);
 bool spapr_ovec_empty(SpaprOptionVector *ov);
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector);
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector);
 int spapr_dt_ovec(void *fdt, int fdt_offset,
                   SpaprOptionVector *ov, const char *name);
 
Signature · 1 line
2.38.1
#8 lore raw

Re: [PATCH-for-8.0 4/4] hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

Quoted 26 lines · Philippe Mathieu-Daudé

spapr_ovec.c is a device, but it uses target_ulong which is target specific. The hwaddr type (declared in "exec/hwaddr.h") better fits hardware addresses.

Change spapr_ovec_parse_vector() to take a hwaddr argument, allowing the removal of "cpu.h" in a device header.

---
  hw/ppc/spapr_ovec.c         | 3 ++-
  include/hw/ppc/spapr_ovec.h | 4 ++--
  2 files changed, 4 insertions(+), 3 deletions(-)
hw/ppc/spapr_ovec.c +1 -0
index b2567caa5c..a18a751b57 100644
@@ -19,6 +19,7 @@
  #include "qemu/error-report.h"
  #include "trace.h"
  #include <libfdt.h>
+#include "cpu.h"
 
  #define OV_MAXBYTES 256 /* not including length byte */
  #define OV_MAXBITS (OV_MAXBYTES * BITS_PER_BYTE)

hw/ppc/spapr_ovec.c static target_ulong vector_addr(target_ulong table_addr, int vector) · line 180

Quoted 5 lines
hw/ppc/spapr_ovec.c +1 -1
@@ -176,7 +177,7 @@ static target_ulong vector_addr(target_ulong table_addr, int vector)
      return table_addr;
  }
 
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector)
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector)

IIUC, Option vectors represents a data structure of vectors to advertise guest capabilities to the platform (ref b20b7b7adda4) and doesn't really represent a hardware device by itself. IMHO, target_ulong appears to be more appropriate for this purpose. However, the header file inclusion could be changed to cpu-defs.h if target_ulong is the only requirement here.

regards,
Harsh

Quoted 25 lines
hw/ppc/spapr_ovec.c +0 -0
  {
      SpaprOptionVector *ov;
      target_ulong addr;
include/hw/ppc/spapr_ovec.h +2 -2
index c3e8b98e7e..d756b916e4 100644
@@ -37,7 +37,7 @@
  #ifndef SPAPR_OVEC_H
  #define SPAPR_OVEC_H
 
-#include "cpu.h"
+#include "exec/hwaddr.h"
 
  typedef struct SpaprOptionVector SpaprOptionVector;
 
@@ -73,7 +73,7 @@ void spapr_ovec_set(SpaprOptionVector *ov, long bitnr);
  void spapr_ovec_clear(SpaprOptionVector *ov, long bitnr);
  bool spapr_ovec_test(SpaprOptionVector *ov, long bitnr);
  bool spapr_ovec_empty(SpaprOptionVector *ov);
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector);
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector);
  int spapr_dt_ovec(void *fdt, int fdt_offset,
                    SpaprOptionVector *ov, const char *name);
 
#9 lore raw

Re: [PATCH-for-8.0 4/4] hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

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

spapr_ovec.c is a device, but it uses target_ulong which is target specific. The hwaddr type (declared in "exec/hwaddr.h") better fits hardware addresses.

As said by Harsh, spapr_ovec is in fact a data structure that stores platform options that are supported by the guest.

That doesn't mean that I oppose the change made here. Aside from semantics - which I also don't have a strong opinion about it - I don't believe it matters that much - spapr is 64 bit only, so hwaddr will always be == target_ulong.

Cedric/David/Greg, let me know if you have any restriction/thoughts about this. I'm inclined to accept it as is.

Daniel

Quoted 53 lines

Change spapr_ovec_parse_vector() to take a hwaddr argument, allowing the removal of "cpu.h" in a device header.

---
  hw/ppc/spapr_ovec.c         | 3 ++-
  include/hw/ppc/spapr_ovec.h | 4 ++--
  2 files changed, 4 insertions(+), 3 deletions(-)
hw/ppc/spapr_ovec.c +2 -1
index b2567caa5c..a18a751b57 100644
@@ -19,6 +19,7 @@
  #include "qemu/error-report.h"
  #include "trace.h"
  #include <libfdt.h>
+#include "cpu.h"
 
  #define OV_MAXBYTES 256 /* not including length byte */
  #define OV_MAXBITS (OV_MAXBYTES * BITS_PER_BYTE)
@@ -176,7 +177,7 @@ static target_ulong vector_addr(target_ulong table_addr, int vector)
      return table_addr;
  }
 
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector)
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector)
  {
      SpaprOptionVector *ov;
      target_ulong addr;
include/hw/ppc/spapr_ovec.h +2 -2
index c3e8b98e7e..d756b916e4 100644
@@ -37,7 +37,7 @@
  #ifndef SPAPR_OVEC_H
  #define SPAPR_OVEC_H
 
-#include "cpu.h"
+#include "exec/hwaddr.h"
 
  typedef struct SpaprOptionVector SpaprOptionVector;
 
@@ -73,7 +73,7 @@ void spapr_ovec_set(SpaprOptionVector *ov, long bitnr);
  void spapr_ovec_clear(SpaprOptionVector *ov, long bitnr);
  bool spapr_ovec_test(SpaprOptionVector *ov, long bitnr);
  bool spapr_ovec_empty(SpaprOptionVector *ov);
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector);
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector);
  int spapr_dt_ovec(void *fdt, int fdt_offset,
                    SpaprOptionVector *ov, const char *name);
 
#10 lore raw

Re: [PATCH-for-8.0 4/4] hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

Quoted 10 lines · Daniel Henrique Barboza
Quoted 3 lines · Philippe Mathieu-Daudé

spapr_ovec.c is a device, but it uses target_ulong which is target specific. The hwaddr type (declared in "exec/hwaddr.h") better fits hardware addresses.

As said by Harsh, spapr_ovec is in fact a data structure that stores platform options that are supported by the guest.

Quoted 6 lines

That doesn't mean that I oppose the change made here. Aside from semantics - which I also don't have a strong opinion about it - I don't believe it matters that much - spapr is 64 bit only, so hwaddr will always be == target_ulong.

Cedric/David/Greg, let me know if you have any restriction/thoughts about this. I'm inclined to accept it as is.

Well, I am not sure.

The vector table variable is the result of a ppc64_phys_to_real() conversion of the CAS hcall parameter, which is a target_ulong, but ppc64_phys_to_real() returns a uint64_t.

The code is not consistent in another places :

hw/ppc/spapr_tpm_proxy.c uses a uint64_t
hw/ppc/spapr_hcall.c, a target_ulong
hw/ppc/spapr_rtas.c, a hwaddr
hw/ppc/spapr_drc.c, a hwaddr indirectly

Should we change ppc64_phys_to_real() to return an hwaddr (also) ?

C.

Quoted 51 lines

Daniel

Quoted 47 lines

Change spapr_ovec_parse_vector() to take a hwaddr argument, allowing the removal of "cpu.h" in a device header.

---
  hw/ppc/spapr_ovec.c         | 3 ++-
  include/hw/ppc/spapr_ovec.h | 4 ++--

  2 files changed, 4 insertions(+), 3 deletions(-)
hw/ppc/spapr_ovec.c +2 -1
index b2567caa5c..a18a751b57 100644
@@ -19,6 +19,7 @@
   #include "qemu/error-report.h"
   #include "trace.h"
   #include <libfdt.h>
+#include "cpu.h"
   #define OV_MAXBYTES 256 /* not including length byte */
   #define OV_MAXBITS (OV_MAXBYTES * BITS_PER_BYTE)
@@ -176,7 +177,7 @@ static target_ulong vector_addr(target_ulong table_addr, int vector)
       return table_addr;
   }
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector)
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector)
   {
       SpaprOptionVector *ov;
       target_ulong addr;
include/hw/ppc/spapr_ovec.h +2 -2
index c3e8b98e7e..d756b916e4 100644
@@ -37,7 +37,7 @@
   #ifndef SPAPR_OVEC_H
   #define SPAPR_OVEC_H
-#include "cpu.h"
+#include "exec/hwaddr.h"
   typedef struct SpaprOptionVector SpaprOptionVector;
@@ -73,7 +73,7 @@ void spapr_ovec_set(SpaprOptionVector *ov, long bitnr);
   void spapr_ovec_clear(SpaprOptionVector *ov, long bitnr);
   bool spapr_ovec_test(SpaprOptionVector *ov, long bitnr);
   bool spapr_ovec_empty(SpaprOptionVector *ov);
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector);
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector);
   int spapr_dt_ovec(void *fdt, int fdt_offset,
                     SpaprOptionVector *ov, const char *name);
#11 lore raw

Re: [PATCH-for-8.0 4/4] hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

Quoted 24 lines · Cédric Le Goater
Quoted 10 lines · Daniel Henrique Barboza
Quoted 3 lines · Philippe Mathieu-Daudé

spapr_ovec.c is a device, but it uses target_ulong which is target specific. The hwaddr type (declared in "exec/hwaddr.h") better fits hardware addresses.

As said by Harsh, spapr_ovec is in fact a data structure that stores platform options that are supported by the guest.

Quoted 6 lines

That doesn't mean that I oppose the change made here. Aside from semantics - which I also don't have a strong opinion about it - I don't believe it matters that much - spapr is 64 bit only, so hwaddr will always be == target_ulong.

Cedric/David/Greg, let me know if you have any restriction/thoughts about this. I'm inclined to accept it as is.

Well, I am not sure.

The vector table variable is the result of a ppc64_phys_to_real() conversion of the CAS hcall parameter, which is a target_ulong, but ppc64_phys_to_real() returns a uint64_t.

Quoted 8 lines

The code is not consistent in another places :

  hw/ppc/spapr_tpm_proxy.c uses a uint64_t
  hw/ppc/spapr_hcall.c, a target_ulong
  hw/ppc/spapr_rtas.c, a hwaddr
  hw/ppc/spapr_drc.c, a hwaddr indirectly

Should we change ppc64_phys_to_real() to return an hwaddr (also) ?

It makes sense to me a function called ppc64_phys_to_real() returning a hwaddr type.

Daniel

Quoted 56 lines

C.

Quoted 51 lines

Daniel

Quoted 47 lines

Change spapr_ovec_parse_vector() to take a hwaddr argument, allowing the removal of "cpu.h" in a device header.

---
  hw/ppc/spapr_ovec.c         | 3 ++-
  include/hw/ppc/spapr_ovec.h | 4 ++--

  2 files changed, 4 insertions(+), 3 deletions(-)
hw/ppc/spapr_ovec.c +2 -1
index b2567caa5c..a18a751b57 100644
@@ -19,6 +19,7 @@
   #include "qemu/error-report.h"
   #include "trace.h"
   #include <libfdt.h>
+#include "cpu.h"
   #define OV_MAXBYTES 256 /* not including length byte */
   #define OV_MAXBITS (OV_MAXBYTES * BITS_PER_BYTE)
@@ -176,7 +177,7 @@ static target_ulong vector_addr(target_ulong table_addr, int vector)
       return table_addr;
   }
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector)
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector)
   {
       SpaprOptionVector *ov;
       target_ulong addr;
include/hw/ppc/spapr_ovec.h +2 -2
index c3e8b98e7e..d756b916e4 100644
@@ -37,7 +37,7 @@
   #ifndef SPAPR_OVEC_H
   #define SPAPR_OVEC_H
-#include "cpu.h"
+#include "exec/hwaddr.h"
   typedef struct SpaprOptionVector SpaprOptionVector;
@@ -73,7 +73,7 @@ void spapr_ovec_set(SpaprOptionVector *ov, long bitnr);
   void spapr_ovec_clear(SpaprOptionVector *ov, long bitnr);
   bool spapr_ovec_test(SpaprOptionVector *ov, long bitnr);
   bool spapr_ovec_empty(SpaprOptionVector *ov);
-SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector);
+SpaprOptionVector *spapr_ovec_parse_vector(hwaddr table_addr, int vector);
   int spapr_dt_ovec(void *fdt, int fdt_offset,
                     SpaprOptionVector *ov, const char *name);
#12 lore raw

Re: [PATCH-for-8.0 4/4] hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

Quoted 34 lines · Daniel Henrique Barboza
Quoted 31 lines · Cédric Le Goater
Quoted 10 lines · Daniel Henrique Barboza
Quoted 3 lines · Philippe Mathieu-Daudé

spapr_ovec.c is a device, but it uses target_ulong which is target specific. The hwaddr type (declared in "exec/hwaddr.h") better fits hardware addresses.

As said by Harsh, spapr_ovec is in fact a data structure that stores platform options that are supported by the guest.

Quoted 6 lines

That doesn't mean that I oppose the change made here. Aside from semantics - which I also don't have a strong opinion about it - I don't believe it matters that much - spapr is 64 bit only, so hwaddr will always be == target_ulong.

Cedric/David/Greg, let me know if you have any restriction/thoughts about this. I'm inclined to accept it as is.

Well, I am not sure.

The vector table variable is the result of a ppc64_phys_to_real() conversion of the CAS hcall parameter, which is a target_ulong, but ppc64_phys_to_real() returns a uint64_t.

The code is not consistent in another places :

  hw/ppc/spapr_tpm_proxy.c uses a uint64_t
  hw/ppc/spapr_hcall.c, a target_ulong
  hw/ppc/spapr_rtas.c, a hwaddr
  hw/ppc/spapr_drc.c, a hwaddr indirectly

Quoted 4 lines
Quoted 1 line

Should we change ppc64_phys_to_real() to return an hwaddr (also) ?

It makes sense to me a function called ppc64_phys_to_real() returning a hwaddr type.

Yes, I also think that makes sense.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#13 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

Few changes in hw/ & target/ to reduce the target specificity of some sPAPR headers.

Philippe Mathieu-Daudé (4):
target/ppc/kvm: Add missing "cpu.h" and "exec/hwaddr.h" hw/ppc/vof: Do not include the full "cpu.h" hw/ppc/spapr: Reduce "vof.h" inclusion hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

Patches 1-3 queued in https://gitlab.com/danielhb/qemu/tree/ppc-next. Patch 4 can use a few more comments.

Thanks,

Daniel

Quoted 9 lines
  hw/ppc/spapr.c              | 1 +
  hw/ppc/spapr_ovec.c         | 3 ++-
  include/hw/ppc/spapr.h      | 3 ++-
  include/hw/ppc/spapr_ovec.h | 4 ++--
  include/hw/ppc/vof.h        | 2 +-
  target/ppc/kvm_ppc.h        | 3 +++
  6 files changed, 11 insertions(+), 5 deletions(-)
#14 lore raw
Quoted 6 lines · Daniel Henrique Barboza
Quoted 3 lines · Philippe Mathieu-Daudé

Few changes in hw/ & target/ to reduce the target specificity of some sPAPR headers.

Quoted 7 lines
Quoted 5 lines

Philippe Mathieu-Daudé (4):
   target/ppc/kvm: Add missing "cpu.h" and "exec/hwaddr.h" hw/ppc/vof: Do not include the full "cpu.h" hw/ppc/spapr: Reduce "vof.h" inclusion hw/ppc/spapr_ovec: Avoid target_ulong spapr_ovec_parse_vector()

Patches 1-3 queued in https://gitlab.com/danielhb/qemu/tree/ppc-next.

Thanks!

Quoted 1 line

Patch 4 can use a few more comments.

Yes, I'm not sure yet how to improve it, but I'll work on it.

Regards,

Phil.