All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] exec/cpu: Poison 'hwaddr' type in user-mode emulation
@ 2020-05-09 13:08 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

The 'hwaddr' type declared in "exec/hwaddr.h" is meant for
system-mode emulation only. Poison it in user-mode code.

Philippe Mathieu-Daudé (11):
  plugins: Restrict functions handling hwaddr to system-mode
  sysemu/accel: Restrict machine methods to system-mode
  sysemu/tcg: Only declare tcg_allowed when TCG is available
  sysemu/hvf: Only declare hvf_allowed when HVF is available
  target/ppc: Restrict PPCVirtualHypervisorClass to system-mode
  target/s390x: Only compile decode_basedisp() on system-mode
  target/s390x/helper: Clean ifdef'ry
  target/s390x: Restrict system-mode declarations
  target/cpu: Restrict handlers using hwaddr type to system-mode
  exec: Use 'cpu-common.h' instead of system-mode specific 'hwaddr.h'
  exec/cpu-common: Poison hwaddr type in user-mode emulation

 include/disas/disas.h           |  2 +-
 include/exec/cpu-common.h       |  8 ++++++--
 include/hw/core/cpu.h           | 10 ++++++----
 include/qemu/qemu-plugin.h      |  2 ++
 include/sysemu/accel.h          |  4 +++-
 include/sysemu/hvf.h            |  6 +++---
 include/sysemu/tcg.h            |  2 +-
 target/alpha/cpu.h              |  4 +++-
 target/arm/cpu.h                |  6 +++---
 target/arm/internals.h          |  4 ++++
 target/cris/cpu.h               |  2 ++
 target/hppa/cpu.h               |  2 +-
 target/i386/cpu.h               |  2 ++
 target/m68k/cpu.h               |  7 ++++++-
 target/microblaze/cpu.h         |  5 ++++-
 target/mips/internal.h          |  2 +-
 target/nios2/cpu.h              |  5 ++++-
 target/openrisc/cpu.h           |  3 ++-
 target/ppc/cpu.h                |  6 +++---
 target/ppc/kvm_ppc.h            | 22 +++++++++++-----------
 target/riscv/cpu.h              | 20 ++++++++++----------
 target/s390x/internal.h         | 15 ++++++++++-----
 target/sh4/cpu.h                |  2 +-
 target/sparc/cpu.h              |  2 ++
 target/xtensa/cpu.h             | 12 +++++++-----
 plugins/api.c                   | 17 ++---------------
 target/hppa/cpu.c               |  4 +++-
 target/ppc/translate_init.inc.c |  6 +++++-
 target/s390x/helper.c           |  7 ++-----
 29 files changed, 110 insertions(+), 79 deletions(-)

-- 
2.21.3



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

* [PATCH 00/11] exec/cpu: Poison 'hwaddr' type in user-mode emulation
@ 2020-05-09 13:08 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

The 'hwaddr' type declared in "exec/hwaddr.h" is meant for
system-mode emulation only. Poison it in user-mode code.

Philippe Mathieu-Daudé (11):
  plugins: Restrict functions handling hwaddr to system-mode
  sysemu/accel: Restrict machine methods to system-mode
  sysemu/tcg: Only declare tcg_allowed when TCG is available
  sysemu/hvf: Only declare hvf_allowed when HVF is available
  target/ppc: Restrict PPCVirtualHypervisorClass to system-mode
  target/s390x: Only compile decode_basedisp() on system-mode
  target/s390x/helper: Clean ifdef'ry
  target/s390x: Restrict system-mode declarations
  target/cpu: Restrict handlers using hwaddr type to system-mode
  exec: Use 'cpu-common.h' instead of system-mode specific 'hwaddr.h'
  exec/cpu-common: Poison hwaddr type in user-mode emulation

 include/disas/disas.h           |  2 +-
 include/exec/cpu-common.h       |  8 ++++++--
 include/hw/core/cpu.h           | 10 ++++++----
 include/qemu/qemu-plugin.h      |  2 ++
 include/sysemu/accel.h          |  4 +++-
 include/sysemu/hvf.h            |  6 +++---
 include/sysemu/tcg.h            |  2 +-
 target/alpha/cpu.h              |  4 +++-
 target/arm/cpu.h                |  6 +++---
 target/arm/internals.h          |  4 ++++
 target/cris/cpu.h               |  2 ++
 target/hppa/cpu.h               |  2 +-
 target/i386/cpu.h               |  2 ++
 target/m68k/cpu.h               |  7 ++++++-
 target/microblaze/cpu.h         |  5 ++++-
 target/mips/internal.h          |  2 +-
 target/nios2/cpu.h              |  5 ++++-
 target/openrisc/cpu.h           |  3 ++-
 target/ppc/cpu.h                |  6 +++---
 target/ppc/kvm_ppc.h            | 22 +++++++++++-----------
 target/riscv/cpu.h              | 20 ++++++++++----------
 target/s390x/internal.h         | 15 ++++++++++-----
 target/sh4/cpu.h                |  2 +-
 target/sparc/cpu.h              |  2 ++
 target/xtensa/cpu.h             | 12 +++++++-----
 plugins/api.c                   | 17 ++---------------
 target/hppa/cpu.c               |  4 +++-
 target/ppc/translate_init.inc.c |  6 +++++-
 target/s390x/helper.c           |  7 ++-----
 29 files changed, 110 insertions(+), 79 deletions(-)

-- 
2.21.3



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

* [PATCH 01/11] plugins: Restrict functions handling hwaddr to system-mode
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

Restrict qemu_plugin_hwaddr_is_io() and
qemu_plugin_hwaddr_device_offset() to system-mode.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/qemu/qemu-plugin.h |  2 ++
 plugins/api.c              | 17 ++---------------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
index 5502e112c8..06c271a107 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/qemu/qemu-plugin.h
@@ -326,6 +326,7 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info);
 struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
                                                   uint64_t vaddr);
 
+#ifndef CONFIG_USER_ONLY
 /*
  * The following additional queries can be run on the hwaddr structure
  * to return information about it. For non-IO accesses the device
@@ -333,6 +334,7 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
  */
 bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr);
 uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr);
+#endif /* CONFIG_USER_ONLY */
 
 typedef void
 (*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index,
diff --git a/plugins/api.c b/plugins/api.c
index 53c8a73582..785ad2e45e 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -249,7 +249,8 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info)
  * Virtual Memory queries
  */
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
+
 static __thread struct qemu_plugin_hwaddr hwaddr_info;
 
 struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
@@ -267,26 +268,14 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
 
     return &hwaddr_info;
 }
-#else
-struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
-                                                  uint64_t vaddr)
-{
-    return NULL;
-}
-#endif
 
 bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr)
 {
-#ifdef CONFIG_SOFTMMU
     return hwaddr->is_io;
-#else
-    return false;
-#endif
 }
 
 uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr)
 {
-#ifdef CONFIG_SOFTMMU
     if (haddr) {
         if (!haddr->is_io) {
             ram_addr_t ram_addr = qemu_ram_addr_from_host((void *) haddr->v.ram.hostaddr);
@@ -299,7 +288,6 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr
             return haddr->v.io.offset;
         }
     }
-#endif
     return 0;
 }
 
@@ -308,7 +296,6 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr
  * will be. This helps the plugin dimension per-vcpu arrays.
  */
 
-#ifndef CONFIG_USER_ONLY
 static MachineState * get_ms(void)
 {
     return MACHINE(qdev_get_machine());
-- 
2.21.3



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

* [PATCH 01/11] plugins: Restrict functions handling hwaddr to system-mode
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

Restrict qemu_plugin_hwaddr_is_io() and
qemu_plugin_hwaddr_device_offset() to system-mode.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/qemu/qemu-plugin.h |  2 ++
 plugins/api.c              | 17 ++---------------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
index 5502e112c8..06c271a107 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/qemu/qemu-plugin.h
@@ -326,6 +326,7 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info);
 struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
                                                   uint64_t vaddr);
 
+#ifndef CONFIG_USER_ONLY
 /*
  * The following additional queries can be run on the hwaddr structure
  * to return information about it. For non-IO accesses the device
@@ -333,6 +334,7 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
  */
 bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr);
 uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr);
+#endif /* CONFIG_USER_ONLY */
 
 typedef void
 (*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index,
diff --git a/plugins/api.c b/plugins/api.c
index 53c8a73582..785ad2e45e 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -249,7 +249,8 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info)
  * Virtual Memory queries
  */
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
+
 static __thread struct qemu_plugin_hwaddr hwaddr_info;
 
 struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
@@ -267,26 +268,14 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
 
     return &hwaddr_info;
 }
-#else
-struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
-                                                  uint64_t vaddr)
-{
-    return NULL;
-}
-#endif
 
 bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr)
 {
-#ifdef CONFIG_SOFTMMU
     return hwaddr->is_io;
-#else
-    return false;
-#endif
 }
 
 uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr)
 {
-#ifdef CONFIG_SOFTMMU
     if (haddr) {
         if (!haddr->is_io) {
             ram_addr_t ram_addr = qemu_ram_addr_from_host((void *) haddr->v.ram.hostaddr);
@@ -299,7 +288,6 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr
             return haddr->v.io.offset;
         }
     }
-#endif
     return 0;
 }
 
@@ -308,7 +296,6 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr
  * will be. This helps the plugin dimension per-vcpu arrays.
  */
 
-#ifndef CONFIG_USER_ONLY
 static MachineState * get_ms(void)
 {
     return MACHINE(qdev_get_machine());
-- 
2.21.3



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

* [PATCH 02/11] sysemu/accel: Restrict machine methods to system-mode
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

Restrict init_machine(), setup_post() and has_memory()
to system-mode.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/accel.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index 47e5788530..e08b8ab8fa 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -37,10 +37,12 @@ typedef struct AccelClass {
     /*< public >*/
 
     const char *name;
+#ifndef CONFIG_USER_ONLY
     int (*init_machine)(MachineState *ms);
     void (*setup_post)(MachineState *ms, AccelState *accel);
     bool (*has_memory)(MachineState *ms, AddressSpace *as,
                        hwaddr start_addr, hwaddr size);
+#endif
     bool *allowed;
     /*
      * Array of global properties that would be applied when specific
-- 
2.21.3



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

* [PATCH 02/11] sysemu/accel: Restrict machine methods to system-mode
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

Restrict init_machine(), setup_post() and has_memory()
to system-mode.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/accel.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index 47e5788530..e08b8ab8fa 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -37,10 +37,12 @@ typedef struct AccelClass {
     /*< public >*/
 
     const char *name;
+#ifndef CONFIG_USER_ONLY
     int (*init_machine)(MachineState *ms);
     void (*setup_post)(MachineState *ms, AccelState *accel);
     bool (*has_memory)(MachineState *ms, AddressSpace *as,
                        hwaddr start_addr, hwaddr size);
+#endif
     bool *allowed;
     /*
      * Array of global properties that would be applied when specific
-- 
2.21.3



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

* [PATCH 03/11] sysemu/tcg: Only declare tcg_allowed when TCG is available
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

When TCG is not available, the tcg_allowed variable does not exist.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/tcg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h
index 7d116d2e80..d9d3ca8559 100644
--- a/include/sysemu/tcg.h
+++ b/include/sysemu/tcg.h
@@ -8,9 +8,9 @@
 #ifndef SYSEMU_TCG_H
 #define SYSEMU_TCG_H
 
-extern bool tcg_allowed;
 void tcg_exec_init(unsigned long tb_size);
 #ifdef CONFIG_TCG
+extern bool tcg_allowed;
 #define tcg_enabled() (tcg_allowed)
 #else
 #define tcg_enabled() 0
-- 
2.21.3



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

* [PATCH 03/11] sysemu/tcg: Only declare tcg_allowed when TCG is available
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

When TCG is not available, the tcg_allowed variable does not exist.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/tcg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h
index 7d116d2e80..d9d3ca8559 100644
--- a/include/sysemu/tcg.h
+++ b/include/sysemu/tcg.h
@@ -8,9 +8,9 @@
 #ifndef SYSEMU_TCG_H
 #define SYSEMU_TCG_H
 
-extern bool tcg_allowed;
 void tcg_exec_init(unsigned long tb_size);
 #ifdef CONFIG_TCG
+extern bool tcg_allowed;
 #define tcg_enabled() (tcg_allowed)
 #else
 #define tcg_enabled() 0
-- 
2.21.3



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

* [PATCH 04/11] sysemu/hvf: Only declare hvf_allowed when HVF is available
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

When HVF is not available, the tcg_allowed variable does not exist.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/hvf.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
index d211e808e9..fe95743124 100644
--- a/include/sysemu/hvf.h
+++ b/include/sysemu/hvf.h
@@ -18,7 +18,6 @@
 #include "exec/memory.h"
 #include "sysemu/accel.h"
 
-extern bool hvf_allowed;
 #ifdef CONFIG_HVF
 #include <Hypervisor/hv.h>
 #include <Hypervisor/hv_vmx.h>
@@ -26,11 +25,12 @@ extern bool hvf_allowed;
 #include "target/i386/cpu.h"
 uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
                                  int reg);
+extern bool hvf_allowed;
 #define hvf_enabled() (hvf_allowed)
-#else
+#else /* !CONFIG_HVF */
 #define hvf_enabled() 0
 #define hvf_get_supported_cpuid(func, idx, reg) 0
-#endif
+#endif /* !CONFIG_HVF */
 
 /* hvf_slot flags */
 #define HVF_SLOT_LOG (1 << 0)
-- 
2.21.3



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

* [PATCH 04/11] sysemu/hvf: Only declare hvf_allowed when HVF is available
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

When HVF is not available, the tcg_allowed variable does not exist.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/hvf.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
index d211e808e9..fe95743124 100644
--- a/include/sysemu/hvf.h
+++ b/include/sysemu/hvf.h
@@ -18,7 +18,6 @@
 #include "exec/memory.h"
 #include "sysemu/accel.h"
 
-extern bool hvf_allowed;
 #ifdef CONFIG_HVF
 #include <Hypervisor/hv.h>
 #include <Hypervisor/hv_vmx.h>
@@ -26,11 +25,12 @@ extern bool hvf_allowed;
 #include "target/i386/cpu.h"
 uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
                                  int reg);
+extern bool hvf_allowed;
 #define hvf_enabled() (hvf_allowed)
-#else
+#else /* !CONFIG_HVF */
 #define hvf_enabled() 0
 #define hvf_get_supported_cpuid(func, idx, reg) 0
-#endif
+#endif /* !CONFIG_HVF */
 
 /* hvf_slot flags */
 #define HVF_SLOT_LOG (1 << 0)
-- 
2.21.3



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

* [PATCH 05/11] target/ppc: Restrict PPCVirtualHypervisorClass to system-mode
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

The code related to PPC Virtual Hypervisor is pointless in user-mode.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu.h                |  4 ++--
 target/ppc/kvm_ppc.h            | 22 +++++++++++-----------
 target/ppc/translate_init.inc.c |  4 ++++
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 6b6dd7e483..73920a9cac 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1176,6 +1176,7 @@ 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);
 
+#ifndef CONFIG_USER_ONLY
 struct PPCVirtualHypervisorClass {
     InterfaceClass parent;
     void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
@@ -1189,10 +1190,8 @@ struct PPCVirtualHypervisorClass {
     void (*hpte_set_r)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t pte1);
     void (*get_pate)(PPCVirtualHypervisor *vhyp, ppc_v3_pate_t *entry);
     target_ulong (*encode_hpt_for_kvm_pr)(PPCVirtualHypervisor *vhyp);
-#ifndef CONFIG_USER_ONLY
     void (*cpu_exec_enter)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
     void (*cpu_exec_exit)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
-#endif
 };
 
 #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor"
@@ -1204,6 +1203,7 @@ struct PPCVirtualHypervisorClass {
 #define PPC_VIRTUAL_HYPERVISOR_GET_CLASS(obj) \
     OBJECT_GET_CLASS(PPCVirtualHypervisorClass, (obj), \
                      TYPE_PPC_VIRTUAL_HYPERVISOR)
+#endif /* CONFIG_USER_ONLY */
 
 void ppc_cpu_do_interrupt(CPUState *cpu);
 bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index fcaf745516..701c0c262b 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -280,6 +280,17 @@ static inline bool kvmppc_has_cap_spapr_vfio(void)
     return false;
 }
 
+static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
+                                     hwaddr ptex, int n)
+{
+    abort();
+}
+
+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)
@@ -310,17 +321,6 @@ static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
     abort();
 }
 
-static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
-                                     hwaddr ptex, int n)
-{
-    abort();
-}
-
-static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)
-{
-    abort();
-}
-
 static inline bool kvmppc_has_cap_fixup_hcalls(void)
 {
     abort();
diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
index 2b6e832c4c..4ea0cc501b 100644
--- a/target/ppc/translate_init.inc.c
+++ b/target/ppc/translate_init.inc.c
@@ -10946,16 +10946,20 @@ static const TypeInfo ppc_cpu_type_info = {
     .class_init = ppc_cpu_class_init,
 };
 
+#ifndef CONFIG_USER_ONLY
 static const TypeInfo ppc_vhyp_type_info = {
     .name = TYPE_PPC_VIRTUAL_HYPERVISOR,
     .parent = TYPE_INTERFACE,
     .class_size = sizeof(PPCVirtualHypervisorClass),
 };
+#endif
 
 static void ppc_cpu_register_types(void)
 {
     type_register_static(&ppc_cpu_type_info);
+#ifndef CONFIG_USER_ONLY
     type_register_static(&ppc_vhyp_type_info);
+#endif
 }
 
 type_init(ppc_cpu_register_types)
-- 
2.21.3



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

* [PATCH 05/11] target/ppc: Restrict PPCVirtualHypervisorClass to system-mode
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

The code related to PPC Virtual Hypervisor is pointless in user-mode.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu.h                |  4 ++--
 target/ppc/kvm_ppc.h            | 22 +++++++++++-----------
 target/ppc/translate_init.inc.c |  4 ++++
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 6b6dd7e483..73920a9cac 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1176,6 +1176,7 @@ 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);
 
+#ifndef CONFIG_USER_ONLY
 struct PPCVirtualHypervisorClass {
     InterfaceClass parent;
     void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
@@ -1189,10 +1190,8 @@ struct PPCVirtualHypervisorClass {
     void (*hpte_set_r)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t pte1);
     void (*get_pate)(PPCVirtualHypervisor *vhyp, ppc_v3_pate_t *entry);
     target_ulong (*encode_hpt_for_kvm_pr)(PPCVirtualHypervisor *vhyp);
-#ifndef CONFIG_USER_ONLY
     void (*cpu_exec_enter)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
     void (*cpu_exec_exit)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
-#endif
 };
 
 #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor"
@@ -1204,6 +1203,7 @@ struct PPCVirtualHypervisorClass {
 #define PPC_VIRTUAL_HYPERVISOR_GET_CLASS(obj) \
     OBJECT_GET_CLASS(PPCVirtualHypervisorClass, (obj), \
                      TYPE_PPC_VIRTUAL_HYPERVISOR)
+#endif /* CONFIG_USER_ONLY */
 
 void ppc_cpu_do_interrupt(CPUState *cpu);
 bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index fcaf745516..701c0c262b 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -280,6 +280,17 @@ static inline bool kvmppc_has_cap_spapr_vfio(void)
     return false;
 }
 
+static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
+                                     hwaddr ptex, int n)
+{
+    abort();
+}
+
+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)
@@ -310,17 +321,6 @@ static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
     abort();
 }
 
-static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
-                                     hwaddr ptex, int n)
-{
-    abort();
-}
-
-static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)
-{
-    abort();
-}
-
 static inline bool kvmppc_has_cap_fixup_hcalls(void)
 {
     abort();
diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
index 2b6e832c4c..4ea0cc501b 100644
--- a/target/ppc/translate_init.inc.c
+++ b/target/ppc/translate_init.inc.c
@@ -10946,16 +10946,20 @@ static const TypeInfo ppc_cpu_type_info = {
     .class_init = ppc_cpu_class_init,
 };
 
+#ifndef CONFIG_USER_ONLY
 static const TypeInfo ppc_vhyp_type_info = {
     .name = TYPE_PPC_VIRTUAL_HYPERVISOR,
     .parent = TYPE_INTERFACE,
     .class_size = sizeof(PPCVirtualHypervisorClass),
 };
+#endif
 
 static void ppc_cpu_register_types(void)
 {
     type_register_static(&ppc_cpu_type_info);
+#ifndef CONFIG_USER_ONLY
     type_register_static(&ppc_vhyp_type_info);
+#endif
 }
 
 type_init(ppc_cpu_register_types)
-- 
2.21.3



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

* [PATCH 06/11] target/s390x: Only compile decode_basedisp() on system-mode
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

The decode_basedisp*() methods are only used in ioinst.c,
which is only build in system-mode emulation.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/s390x/internal.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index 8c95c734db..c1678dc6bc 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -204,6 +204,8 @@ enum cc_op {
     CC_OP_MAX
 };
 
+#ifndef CONFIG_USER_ONLY
+
 static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb,
                                        uint8_t *ar)
 {
@@ -225,6 +227,8 @@ static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb,
 /* Base/displacement are at the same locations. */
 #define decode_basedisp_rs decode_basedisp_s
 
+#endif /* CONFIG_USER_ONLY */
+
 /* arch_dump.c */
 int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
                               int cpuid, void *opaque);
-- 
2.21.3



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

* [PATCH 06/11] target/s390x: Only compile decode_basedisp() on system-mode
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

The decode_basedisp*() methods are only used in ioinst.c,
which is only build in system-mode emulation.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/s390x/internal.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index 8c95c734db..c1678dc6bc 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -204,6 +204,8 @@ enum cc_op {
     CC_OP_MAX
 };
 
+#ifndef CONFIG_USER_ONLY
+
 static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb,
                                        uint8_t *ar)
 {
@@ -225,6 +227,8 @@ static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb,
 /* Base/displacement are at the same locations. */
 #define decode_basedisp_rs decode_basedisp_s
 
+#endif /* CONFIG_USER_ONLY */
+
 /* arch_dump.c */
 int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
                               int cpuid, void *opaque);
-- 
2.21.3



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

* [PATCH 07/11] target/s390x/helper: Clean ifdef'ry
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

All this code is guarded checking CONFIG_USER_ONLY definition.
Drop the duplicated checks.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Suspicious ifdef'ry in s390_handle_wait() from commit 83f7f32901c.
---
 target/s390x/helper.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/target/s390x/helper.c b/target/s390x/helper.c
index 09f60406aa..26e3b366e8 100644
--- a/target/s390x/helper.c
+++ b/target/s390x/helper.c
@@ -33,6 +33,7 @@
 #endif
 
 #ifndef CONFIG_USER_ONLY
+
 void s390x_tod_timer(void *opaque)
 {
     cpu_inject_clock_comparator((S390CPU *) opaque);
@@ -42,9 +43,6 @@ void s390x_cpu_timer(void *opaque)
 {
     cpu_inject_cpu_timer((S390CPU *) opaque);
 }
-#endif
-
-#ifndef CONFIG_USER_ONLY
 
 hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)
 {
@@ -98,14 +96,12 @@ void s390_handle_wait(S390CPU *cpu)
     CPUState *cs = CPU(cpu);
 
     if (s390_cpu_halt(cpu) == 0) {
-#ifndef CONFIG_USER_ONLY
         if (is_special_wait_psw(cpu->env.psw.addr)) {
             qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
         } else {
             cpu->env.crash_reason = S390_CRASH_REASON_DISABLED_WAIT;
             qemu_system_guest_panicked(cpu_get_crash_info(cs));
         }
-#endif
     }
 }
 
@@ -328,6 +324,7 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len)
     cpu_physical_memory_unmap(sa, len, 1, len);
     return 0;
 }
+
 #endif /* CONFIG_USER_ONLY */
 
 void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags)
-- 
2.21.3



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

* [PATCH 07/11] target/s390x/helper: Clean ifdef'ry
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

All this code is guarded checking CONFIG_USER_ONLY definition.
Drop the duplicated checks.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Suspicious ifdef'ry in s390_handle_wait() from commit 83f7f32901c.
---
 target/s390x/helper.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/target/s390x/helper.c b/target/s390x/helper.c
index 09f60406aa..26e3b366e8 100644
--- a/target/s390x/helper.c
+++ b/target/s390x/helper.c
@@ -33,6 +33,7 @@
 #endif
 
 #ifndef CONFIG_USER_ONLY
+
 void s390x_tod_timer(void *opaque)
 {
     cpu_inject_clock_comparator((S390CPU *) opaque);
@@ -42,9 +43,6 @@ void s390x_cpu_timer(void *opaque)
 {
     cpu_inject_cpu_timer((S390CPU *) opaque);
 }
-#endif
-
-#ifndef CONFIG_USER_ONLY
 
 hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)
 {
@@ -98,14 +96,12 @@ void s390_handle_wait(S390CPU *cpu)
     CPUState *cs = CPU(cpu);
 
     if (s390_cpu_halt(cpu) == 0) {
-#ifndef CONFIG_USER_ONLY
         if (is_special_wait_psw(cpu->env.psw.addr)) {
             qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
         } else {
             cpu->env.crash_reason = S390_CRASH_REASON_DISABLED_WAIT;
             qemu_system_guest_panicked(cpu_get_crash_info(cs));
         }
-#endif
     }
 }
 
@@ -328,6 +324,7 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len)
     cpu_physical_memory_unmap(sa, len, 1, len);
     return 0;
 }
+
 #endif /* CONFIG_USER_ONLY */
 
 void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags)
-- 
2.21.3



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

* [PATCH 08/11] target/s390x: Restrict system-mode declarations
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

As these declarations are restricted to !CONFIG_USER_ONLY in
helper.c, only declare them when system-mode emulation is used.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/s390x/internal.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index c1678dc6bc..ddc276cdf4 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
 
 /* cc_helper.c */
 const char *cc_name(enum cc_op cc_op);
-void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
 uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
                  uint64_t vr);
 
@@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
 
 /* helper.c */
 void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
-hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+void do_restart_interrupt(CPUS390XState *env);
+
+#ifndef CONFIG_USER_ONLY
+void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
 uint64_t get_psw_mask(CPUS390XState *env);
 void s390_cpu_recompute_watchpoints(CPUState *cs);
 void s390x_tod_timer(void *opaque);
 void s390x_cpu_timer(void *opaque);
-void do_restart_interrupt(CPUS390XState *env);
 void s390_handle_wait(S390CPU *cpu);
+hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
 #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
 int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
 int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
-#ifndef CONFIG_USER_ONLY
 LowCore *cpu_map_lowcore(CPUS390XState *env);
 void cpu_unmap_lowcore(LowCore *lowcore);
 #endif /* CONFIG_USER_ONLY */
-- 
2.21.3



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

* [PATCH 08/11] target/s390x: Restrict system-mode declarations
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

As these declarations are restricted to !CONFIG_USER_ONLY in
helper.c, only declare them when system-mode emulation is used.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/s390x/internal.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index c1678dc6bc..ddc276cdf4 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
 
 /* cc_helper.c */
 const char *cc_name(enum cc_op cc_op);
-void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
 uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
                  uint64_t vr);
 
@@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
 
 /* helper.c */
 void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
-hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+void do_restart_interrupt(CPUS390XState *env);
+
+#ifndef CONFIG_USER_ONLY
+void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
 uint64_t get_psw_mask(CPUS390XState *env);
 void s390_cpu_recompute_watchpoints(CPUState *cs);
 void s390x_tod_timer(void *opaque);
 void s390x_cpu_timer(void *opaque);
-void do_restart_interrupt(CPUS390XState *env);
 void s390_handle_wait(S390CPU *cpu);
+hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
 #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
 int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
 int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
-#ifndef CONFIG_USER_ONLY
 LowCore *cpu_map_lowcore(CPUS390XState *env);
 void cpu_unmap_lowcore(LowCore *lowcore);
 #endif /* CONFIG_USER_ONLY */
-- 
2.21.3



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

* [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

Restrict the following handlers to system-mode:
- do_unaligned_access
- do_transaction_failed
- get_phys_page_debug
- get_phys_page_attrs_debug

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h           |  8 +++++---
 target/alpha/cpu.h              |  4 +++-
 target/arm/cpu.h                |  6 +++---
 target/arm/internals.h          |  4 ++++
 target/cris/cpu.h               |  2 ++
 target/hppa/cpu.h               |  2 +-
 target/i386/cpu.h               |  2 ++
 target/m68k/cpu.h               |  7 ++++++-
 target/microblaze/cpu.h         |  5 ++++-
 target/mips/internal.h          |  2 +-
 target/nios2/cpu.h              |  5 ++++-
 target/openrisc/cpu.h           |  3 ++-
 target/ppc/cpu.h                |  2 +-
 target/riscv/cpu.h              | 20 ++++++++++----------
 target/sh4/cpu.h                |  2 +-
 target/sparc/cpu.h              |  2 ++
 target/xtensa/cpu.h             | 12 +++++++-----
 target/hppa/cpu.c               |  4 +++-
 target/ppc/translate_init.inc.c |  2 +-
 19 files changed, 62 insertions(+), 32 deletions(-)

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 5bf94d28cf..ed09d056d1 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -167,6 +167,7 @@ typedef struct CPUClass {
     int reset_dump_flags;
     bool (*has_work)(CPUState *cpu);
     void (*do_interrupt)(CPUState *cpu);
+#ifndef CONFIG_USER_ONLY
     void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
                                 MMUAccessType access_type,
                                 int mmu_idx, uintptr_t retaddr);
@@ -174,6 +175,10 @@ typedef struct CPUClass {
                                   unsigned size, MMUAccessType access_type,
                                   int mmu_idx, MemTxAttrs attrs,
                                   MemTxResult response, uintptr_t retaddr);
+    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
+    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
+                                        MemTxAttrs *attrs);
+#endif /* CONFIG_USER_ONLY */
     bool (*virtio_is_big_endian)(CPUState *cpu);
     int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
                            uint8_t *buf, int len, bool is_write);
@@ -189,9 +194,6 @@ typedef struct CPUClass {
     bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
                      MMUAccessType access_type, int mmu_idx,
                      bool probe, uintptr_t retaddr);
-    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
-    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
-                                        MemTxAttrs *attrs);
     int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
     int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
     int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index be29bdd530..b12021803e 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -279,12 +279,14 @@ extern const VMStateDescription vmstate_alpha_cpu;
 void alpha_cpu_do_interrupt(CPUState *cpu);
 bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);
-hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
+#ifndef CONFIG_USER_ONLY
+hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
                                    MMUAccessType access_type,
                                    int mmu_idx, uintptr_t retaddr);
+#endif
 
 #define cpu_list alpha_cpu_list
 #define cpu_signal_handler cpu_alpha_signal_handler
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 8608da6b6f..d333036bb4 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -966,15 +966,15 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz);
 
 #ifndef CONFIG_USER_ONLY
 extern const VMStateDescription vmstate_arm_cpu;
+
+hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
+                                         MemTxAttrs *attrs);
 #endif
 
 void arm_cpu_do_interrupt(CPUState *cpu);
 void arm_v7m_cpu_do_interrupt(CPUState *cpu);
 bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req);
 
-hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
-                                         MemTxAttrs *attrs);
-
 int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 
diff --git a/target/arm/internals.h b/target/arm/internals.h
index e633aff36e..c0a2a5df71 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -812,6 +812,8 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
  * tables */
 bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);
 
+#ifndef CONFIG_USER_ONLY
+
 /* Raise a data fault alignment exception for the specified virtual address */
 void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
                                  MMUAccessType access_type,
@@ -827,6 +829,8 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
                                    int mmu_idx, MemTxAttrs attrs,
                                    MemTxResult response, uintptr_t retaddr);
 
+#endif /* !CONFIG_USER_ONLY */
+
 /* Call any registered EL change hooks */
 static inline void arm_call_pre_el_change_hook(ARMCPU *cpu)
 {
diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index 8f08d7628b..e9c858ada7 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -193,7 +193,9 @@ bool cris_cpu_exec_interrupt(CPUState *cpu, int int_req);
 
 void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags);
 
+#ifndef CONFIG_USER_ONLY
 hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
 
 int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int cris_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 801a4fb1ba..7848425f6a 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -320,7 +320,6 @@ void cpu_hppa_change_prot_id(CPUHPPAState *env);
 #define cpu_signal_handler cpu_hppa_signal_handler
 
 int cpu_hppa_signal_handler(int host_signum, void *pinfo, void *puc);
-hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
 int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void hppa_cpu_do_interrupt(CPUState *cpu);
@@ -330,6 +329,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                        MMUAccessType access_type, int mmu_idx,
                        bool probe, uintptr_t retaddr);
 #ifndef CONFIG_USER_ONLY
+hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
 int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
                               int type, hwaddr *pphys, int *pprot);
 extern const MemoryRegionOps hppa_io_eir_ops;
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index e818fc712a..00e0cc0828 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1767,8 +1767,10 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
 
 void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags);
 
+#ifndef CONFIG_USER_ONLY
 hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
                                          MemTxAttrs *attrs);
+#endif
 
 int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 521ac67cdd..efc940e7ec 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -167,10 +167,13 @@ struct M68kCPU {
 void m68k_cpu_do_interrupt(CPUState *cpu);
 bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 
+#ifndef CONFIG_USER_ONLY
+hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
+
 void m68k_tcg_init(void);
 void m68k_cpu_init_gdb(M68kCPU *cpu);
 /*
@@ -529,10 +532,12 @@ static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)
 bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                        MMUAccessType access_type, int mmu_idx,
                        bool probe, uintptr_t retaddr);
+#ifndef CONFIG_USER_ONLY
 void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
                                  unsigned size, MMUAccessType access_type,
                                  int mmu_idx, MemTxAttrs attrs,
                                  MemTxResult response, uintptr_t retaddr);
+#endif
 
 typedef CPUM68KState CPUArchState;
 typedef M68kCPU ArchCPU;
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index a31134b65c..eb57f04d3f 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -318,10 +318,13 @@ struct MicroBlazeCPU {
 void mb_cpu_do_interrupt(CPUState *cs);
 bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
 void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 
+#ifndef CONFIG_USER_ONLY
+hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
+
 void mb_tcg_init(void);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
diff --git a/target/mips/internal.h b/target/mips/internal.h
index 1bf274b3ef..c38666c6f5 100644
--- a/target/mips/internal.h
+++ b/target/mips/internal.h
@@ -81,7 +81,6 @@ enum CPUMIPSMSADataFormat {
 void mips_cpu_do_interrupt(CPUState *cpu);
 bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void mips_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int mips_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
@@ -150,6 +149,7 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
                                     MemTxResult response, uintptr_t retaddr);
 hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address,
                                   int rw);
+hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 #endif
 
 #define cpu_signal_handler cpu_mips_signal_handler
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 4dddf9c3a1..0703295133 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -199,11 +199,14 @@ void nios2_cpu_do_interrupt(CPUState *cs);
 int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc);
 void dump_mmu(CPUNios2State *env);
 void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
                                    MMUAccessType access_type,
                                    int mmu_idx, uintptr_t retaddr);
 
+#ifndef CONFIG_USER_ONLY
+hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
+
 qemu_irq *nios2_cpu_pic_init(Nios2CPU *cpu);
 void nios2_check_interrupts(CPUNios2State *env);
 
diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index f37a52e153..60de8ed787 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -319,7 +319,6 @@ void cpu_openrisc_list(void);
 void openrisc_cpu_do_interrupt(CPUState *cpu);
 bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void openrisc_translate_init(void);
@@ -335,6 +334,8 @@ int print_insn_or1k(bfd_vma addr, disassemble_info *info);
 #ifndef CONFIG_USER_ONLY
 extern const VMStateDescription vmstate_openrisc_cpu;
 
+hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+
 /* hw/openrisc_pic.c */
 void cpu_openrisc_pic_init(OpenRISCCPU *cpu);
 
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 73920a9cac..f7b27aefed 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1209,12 +1209,12 @@ void ppc_cpu_do_interrupt(CPUState *cpu);
 bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 void ppc_cpu_dump_statistics(CPUState *cpu, int flags);
-hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int reg);
 int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg);
 #ifndef CONFIG_USER_ONLY
+hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu);
 const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name);
 #endif
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index d0e7f5b9c5..69edee6484 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -303,18 +303,9 @@ void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable);
 bool riscv_cpu_force_hs_excep_enabled(CPURISCVState *env);
 void riscv_cpu_set_force_hs_excep(CPURISCVState *env, bool enable);
 int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch);
-hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
-void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
-                                    MMUAccessType access_type, int mmu_idx,
-                                    uintptr_t retaddr);
 bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                         MMUAccessType access_type, int mmu_idx,
                         bool probe, uintptr_t retaddr);
-void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
-                                     vaddr addr, unsigned size,
-                                     MMUAccessType access_type,
-                                     int mmu_idx, MemTxAttrs attrs,
-                                     MemTxResult response, uintptr_t retaddr);
 char *riscv_isa_string(RISCVCPU *cpu);
 void riscv_cpu_list(void);
 
@@ -323,12 +314,21 @@ void riscv_cpu_list(void);
 #define cpu_mmu_index riscv_cpu_mmu_index
 
 #ifndef CONFIG_USER_ONLY
+hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
+                                    MMUAccessType access_type, int mmu_idx,
+                                    uintptr_t retaddr);
+void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
+                                     vaddr addr, unsigned size,
+                                     MMUAccessType access_type,
+                                     int mmu_idx, MemTxAttrs attrs,
+                                     MemTxResult response, uintptr_t retaddr);
 void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env);
 int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint32_t interrupts);
 uint32_t riscv_cpu_update_mip(RISCVCPU *cpu, uint32_t mask, uint32_t value);
 #define BOOL_TO_MASK(x) (-!!(x)) /* helper for riscv_cpu_update_mip value */
 void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void));
-#endif
+#endif /* !CONFIG_USER_ONLY */
 void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv);
 
 void riscv_translate_init(void);
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index dbe58c7888..40d92413b8 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -207,7 +207,6 @@ struct SuperHCPU {
 void superh_cpu_do_interrupt(CPUState *cpu);
 bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
@@ -223,6 +222,7 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
 
 void sh4_cpu_list(void);
 #if !defined(CONFIG_USER_ONLY)
+hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void cpu_sh4_invalidate_tlb(CPUSH4State *s);
 uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,
                                        hwaddr addr);
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index b9369398f2..31887a811a 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -570,7 +570,9 @@ extern const VMStateDescription vmstate_sparc_cpu;
 
 void sparc_cpu_do_interrupt(CPUState *cpu);
 void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
+#ifndef CONFIG_USER_ONLY
 hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
 int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 7a46dccbe1..47fe57df87 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -564,19 +564,21 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                          bool probe, uintptr_t retaddr);
 void xtensa_cpu_do_interrupt(CPUState *cpu);
 bool xtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request);
-void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
-                                      unsigned size, MMUAccessType access_type,
-                                      int mmu_idx, MemTxAttrs attrs,
-                                      MemTxResult response, uintptr_t retaddr);
 void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void xtensa_count_regs(const XtensaConfig *config,
                        unsigned *n_regs, unsigned *n_core_regs);
 int xtensa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
+#ifndef CONFIG_USER_ONLY
+hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
+                                      unsigned size, MMUAccessType access_type,
+                                      int mmu_idx, MemTxAttrs attrs,
+                                      MemTxResult response, uintptr_t retaddr);
 void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
                                     MMUAccessType access_type,
                                     int mmu_idx, uintptr_t retaddr);
+#endif /* !CONFIG_USER_ONLY */
 
 #define cpu_signal_handler cpu_xtensa_signal_handler
 #define cpu_list xtensa_cpu_list
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index 71b6aca45d..6d33288d2a 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -70,6 +70,7 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
     info->print_insn = print_insn_hppa;
 }
 
+#ifndef CONFIG_USER_ONLY
 static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
                                          MMUAccessType access_type,
                                          int mmu_idx, uintptr_t retaddr)
@@ -86,6 +87,7 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
 
     cpu_loop_exit_restore(cs, retaddr);
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
 {
@@ -150,8 +152,8 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)
 #ifndef CONFIG_USER_ONLY
     cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug;
     dc->vmsd = &vmstate_hppa_cpu;
-#endif
     cc->do_unaligned_access = hppa_cpu_do_unaligned_access;
+#endif
     cc->disas_set_info = hppa_cpu_disas_set_info;
     cc->tcg_initialize = hppa_translate_init;
 
diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
index 4ea0cc501b..8c428e2009 100644
--- a/target/ppc/translate_init.inc.c
+++ b/target/ppc/translate_init.inc.c
@@ -10892,8 +10892,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
     cc->set_pc = ppc_cpu_set_pc;
     cc->gdb_read_register = ppc_cpu_gdb_read_register;
     cc->gdb_write_register = ppc_cpu_gdb_write_register;
-    cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
 #ifndef CONFIG_USER_ONLY
+    cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
     cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug;
     cc->vmsd = &vmstate_ppc_cpu;
 #endif
-- 
2.21.3



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

* [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

Restrict the following handlers to system-mode:
- do_unaligned_access
- do_transaction_failed
- get_phys_page_debug
- get_phys_page_attrs_debug

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h           |  8 +++++---
 target/alpha/cpu.h              |  4 +++-
 target/arm/cpu.h                |  6 +++---
 target/arm/internals.h          |  4 ++++
 target/cris/cpu.h               |  2 ++
 target/hppa/cpu.h               |  2 +-
 target/i386/cpu.h               |  2 ++
 target/m68k/cpu.h               |  7 ++++++-
 target/microblaze/cpu.h         |  5 ++++-
 target/mips/internal.h          |  2 +-
 target/nios2/cpu.h              |  5 ++++-
 target/openrisc/cpu.h           |  3 ++-
 target/ppc/cpu.h                |  2 +-
 target/riscv/cpu.h              | 20 ++++++++++----------
 target/sh4/cpu.h                |  2 +-
 target/sparc/cpu.h              |  2 ++
 target/xtensa/cpu.h             | 12 +++++++-----
 target/hppa/cpu.c               |  4 +++-
 target/ppc/translate_init.inc.c |  2 +-
 19 files changed, 62 insertions(+), 32 deletions(-)

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 5bf94d28cf..ed09d056d1 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -167,6 +167,7 @@ typedef struct CPUClass {
     int reset_dump_flags;
     bool (*has_work)(CPUState *cpu);
     void (*do_interrupt)(CPUState *cpu);
+#ifndef CONFIG_USER_ONLY
     void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
                                 MMUAccessType access_type,
                                 int mmu_idx, uintptr_t retaddr);
@@ -174,6 +175,10 @@ typedef struct CPUClass {
                                   unsigned size, MMUAccessType access_type,
                                   int mmu_idx, MemTxAttrs attrs,
                                   MemTxResult response, uintptr_t retaddr);
+    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
+    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
+                                        MemTxAttrs *attrs);
+#endif /* CONFIG_USER_ONLY */
     bool (*virtio_is_big_endian)(CPUState *cpu);
     int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
                            uint8_t *buf, int len, bool is_write);
@@ -189,9 +194,6 @@ typedef struct CPUClass {
     bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
                      MMUAccessType access_type, int mmu_idx,
                      bool probe, uintptr_t retaddr);
-    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
-    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
-                                        MemTxAttrs *attrs);
     int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
     int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
     int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index be29bdd530..b12021803e 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -279,12 +279,14 @@ extern const VMStateDescription vmstate_alpha_cpu;
 void alpha_cpu_do_interrupt(CPUState *cpu);
 bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);
-hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
+#ifndef CONFIG_USER_ONLY
+hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
                                    MMUAccessType access_type,
                                    int mmu_idx, uintptr_t retaddr);
+#endif
 
 #define cpu_list alpha_cpu_list
 #define cpu_signal_handler cpu_alpha_signal_handler
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 8608da6b6f..d333036bb4 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -966,15 +966,15 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz);
 
 #ifndef CONFIG_USER_ONLY
 extern const VMStateDescription vmstate_arm_cpu;
+
+hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
+                                         MemTxAttrs *attrs);
 #endif
 
 void arm_cpu_do_interrupt(CPUState *cpu);
 void arm_v7m_cpu_do_interrupt(CPUState *cpu);
 bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req);
 
-hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
-                                         MemTxAttrs *attrs);
-
 int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 
diff --git a/target/arm/internals.h b/target/arm/internals.h
index e633aff36e..c0a2a5df71 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -812,6 +812,8 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
  * tables */
 bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);
 
+#ifndef CONFIG_USER_ONLY
+
 /* Raise a data fault alignment exception for the specified virtual address */
 void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
                                  MMUAccessType access_type,
@@ -827,6 +829,8 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
                                    int mmu_idx, MemTxAttrs attrs,
                                    MemTxResult response, uintptr_t retaddr);
 
+#endif /* !CONFIG_USER_ONLY */
+
 /* Call any registered EL change hooks */
 static inline void arm_call_pre_el_change_hook(ARMCPU *cpu)
 {
diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index 8f08d7628b..e9c858ada7 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -193,7 +193,9 @@ bool cris_cpu_exec_interrupt(CPUState *cpu, int int_req);
 
 void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags);
 
+#ifndef CONFIG_USER_ONLY
 hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
 
 int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int cris_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 801a4fb1ba..7848425f6a 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -320,7 +320,6 @@ void cpu_hppa_change_prot_id(CPUHPPAState *env);
 #define cpu_signal_handler cpu_hppa_signal_handler
 
 int cpu_hppa_signal_handler(int host_signum, void *pinfo, void *puc);
-hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
 int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void hppa_cpu_do_interrupt(CPUState *cpu);
@@ -330,6 +329,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                        MMUAccessType access_type, int mmu_idx,
                        bool probe, uintptr_t retaddr);
 #ifndef CONFIG_USER_ONLY
+hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
 int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
                               int type, hwaddr *pphys, int *pprot);
 extern const MemoryRegionOps hppa_io_eir_ops;
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index e818fc712a..00e0cc0828 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1767,8 +1767,10 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
 
 void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags);
 
+#ifndef CONFIG_USER_ONLY
 hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
                                          MemTxAttrs *attrs);
+#endif
 
 int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 521ac67cdd..efc940e7ec 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -167,10 +167,13 @@ struct M68kCPU {
 void m68k_cpu_do_interrupt(CPUState *cpu);
 bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 
+#ifndef CONFIG_USER_ONLY
+hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
+
 void m68k_tcg_init(void);
 void m68k_cpu_init_gdb(M68kCPU *cpu);
 /*
@@ -529,10 +532,12 @@ static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)
 bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                        MMUAccessType access_type, int mmu_idx,
                        bool probe, uintptr_t retaddr);
+#ifndef CONFIG_USER_ONLY
 void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
                                  unsigned size, MMUAccessType access_type,
                                  int mmu_idx, MemTxAttrs attrs,
                                  MemTxResult response, uintptr_t retaddr);
+#endif
 
 typedef CPUM68KState CPUArchState;
 typedef M68kCPU ArchCPU;
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index a31134b65c..eb57f04d3f 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -318,10 +318,13 @@ struct MicroBlazeCPU {
 void mb_cpu_do_interrupt(CPUState *cs);
 bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
 void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 
+#ifndef CONFIG_USER_ONLY
+hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
+
 void mb_tcg_init(void);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
diff --git a/target/mips/internal.h b/target/mips/internal.h
index 1bf274b3ef..c38666c6f5 100644
--- a/target/mips/internal.h
+++ b/target/mips/internal.h
@@ -81,7 +81,6 @@ enum CPUMIPSMSADataFormat {
 void mips_cpu_do_interrupt(CPUState *cpu);
 bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void mips_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int mips_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
@@ -150,6 +149,7 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
                                     MemTxResult response, uintptr_t retaddr);
 hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address,
                                   int rw);
+hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 #endif
 
 #define cpu_signal_handler cpu_mips_signal_handler
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 4dddf9c3a1..0703295133 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -199,11 +199,14 @@ void nios2_cpu_do_interrupt(CPUState *cs);
 int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc);
 void dump_mmu(CPUNios2State *env);
 void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
                                    MMUAccessType access_type,
                                    int mmu_idx, uintptr_t retaddr);
 
+#ifndef CONFIG_USER_ONLY
+hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
+
 qemu_irq *nios2_cpu_pic_init(Nios2CPU *cpu);
 void nios2_check_interrupts(CPUNios2State *env);
 
diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index f37a52e153..60de8ed787 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -319,7 +319,6 @@ void cpu_openrisc_list(void);
 void openrisc_cpu_do_interrupt(CPUState *cpu);
 bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void openrisc_translate_init(void);
@@ -335,6 +334,8 @@ int print_insn_or1k(bfd_vma addr, disassemble_info *info);
 #ifndef CONFIG_USER_ONLY
 extern const VMStateDescription vmstate_openrisc_cpu;
 
+hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+
 /* hw/openrisc_pic.c */
 void cpu_openrisc_pic_init(OpenRISCCPU *cpu);
 
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 73920a9cac..f7b27aefed 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1209,12 +1209,12 @@ void ppc_cpu_do_interrupt(CPUState *cpu);
 bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 void ppc_cpu_dump_statistics(CPUState *cpu, int flags);
-hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int reg);
 int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg);
 #ifndef CONFIG_USER_ONLY
+hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu);
 const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name);
 #endif
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index d0e7f5b9c5..69edee6484 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -303,18 +303,9 @@ void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable);
 bool riscv_cpu_force_hs_excep_enabled(CPURISCVState *env);
 void riscv_cpu_set_force_hs_excep(CPURISCVState *env, bool enable);
 int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch);
-hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
-void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
-                                    MMUAccessType access_type, int mmu_idx,
-                                    uintptr_t retaddr);
 bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                         MMUAccessType access_type, int mmu_idx,
                         bool probe, uintptr_t retaddr);
-void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
-                                     vaddr addr, unsigned size,
-                                     MMUAccessType access_type,
-                                     int mmu_idx, MemTxAttrs attrs,
-                                     MemTxResult response, uintptr_t retaddr);
 char *riscv_isa_string(RISCVCPU *cpu);
 void riscv_cpu_list(void);
 
@@ -323,12 +314,21 @@ void riscv_cpu_list(void);
 #define cpu_mmu_index riscv_cpu_mmu_index
 
 #ifndef CONFIG_USER_ONLY
+hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
+                                    MMUAccessType access_type, int mmu_idx,
+                                    uintptr_t retaddr);
+void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
+                                     vaddr addr, unsigned size,
+                                     MMUAccessType access_type,
+                                     int mmu_idx, MemTxAttrs attrs,
+                                     MemTxResult response, uintptr_t retaddr);
 void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env);
 int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint32_t interrupts);
 uint32_t riscv_cpu_update_mip(RISCVCPU *cpu, uint32_t mask, uint32_t value);
 #define BOOL_TO_MASK(x) (-!!(x)) /* helper for riscv_cpu_update_mip value */
 void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void));
-#endif
+#endif /* !CONFIG_USER_ONLY */
 void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv);
 
 void riscv_translate_init(void);
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index dbe58c7888..40d92413b8 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -207,7 +207,6 @@ struct SuperHCPU {
 void superh_cpu_do_interrupt(CPUState *cpu);
 bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
@@ -223,6 +222,7 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
 
 void sh4_cpu_list(void);
 #if !defined(CONFIG_USER_ONLY)
+hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void cpu_sh4_invalidate_tlb(CPUSH4State *s);
 uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,
                                        hwaddr addr);
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index b9369398f2..31887a811a 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -570,7 +570,9 @@ extern const VMStateDescription vmstate_sparc_cpu;
 
 void sparc_cpu_do_interrupt(CPUState *cpu);
 void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
+#ifndef CONFIG_USER_ONLY
 hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+#endif
 int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 7a46dccbe1..47fe57df87 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -564,19 +564,21 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                          bool probe, uintptr_t retaddr);
 void xtensa_cpu_do_interrupt(CPUState *cpu);
 bool xtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request);
-void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
-                                      unsigned size, MMUAccessType access_type,
-                                      int mmu_idx, MemTxAttrs attrs,
-                                      MemTxResult response, uintptr_t retaddr);
 void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void xtensa_count_regs(const XtensaConfig *config,
                        unsigned *n_regs, unsigned *n_core_regs);
 int xtensa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
+#ifndef CONFIG_USER_ONLY
+hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
+                                      unsigned size, MMUAccessType access_type,
+                                      int mmu_idx, MemTxAttrs attrs,
+                                      MemTxResult response, uintptr_t retaddr);
 void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
                                     MMUAccessType access_type,
                                     int mmu_idx, uintptr_t retaddr);
+#endif /* !CONFIG_USER_ONLY */
 
 #define cpu_signal_handler cpu_xtensa_signal_handler
 #define cpu_list xtensa_cpu_list
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index 71b6aca45d..6d33288d2a 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -70,6 +70,7 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
     info->print_insn = print_insn_hppa;
 }
 
+#ifndef CONFIG_USER_ONLY
 static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
                                          MMUAccessType access_type,
                                          int mmu_idx, uintptr_t retaddr)
@@ -86,6 +87,7 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
 
     cpu_loop_exit_restore(cs, retaddr);
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
 {
@@ -150,8 +152,8 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)
 #ifndef CONFIG_USER_ONLY
     cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug;
     dc->vmsd = &vmstate_hppa_cpu;
-#endif
     cc->do_unaligned_access = hppa_cpu_do_unaligned_access;
+#endif
     cc->disas_set_info = hppa_cpu_disas_set_info;
     cc->tcg_initialize = hppa_translate_init;
 
diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
index 4ea0cc501b..8c428e2009 100644
--- a/target/ppc/translate_init.inc.c
+++ b/target/ppc/translate_init.inc.c
@@ -10892,8 +10892,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
     cc->set_pc = ppc_cpu_set_pc;
     cc->gdb_read_register = ppc_cpu_gdb_read_register;
     cc->gdb_write_register = ppc_cpu_gdb_write_register;
-    cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
 #ifndef CONFIG_USER_ONLY
+    cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
     cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug;
     cc->vmsd = &vmstate_ppc_cpu;
 #endif
-- 
2.21.3



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

* [PATCH 10/11] exec: Use 'cpu-common.h' instead of system-mode specific 'hwaddr.h'
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

The "exec/hwaddr.h" header is restricted to system-mode emulation.
Instead, use "exec/cpu-common.h", which is meant for all modes.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/disas/disas.h  | 2 +-
 include/hw/core/cpu.h  | 2 +-
 include/sysemu/accel.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/disas/disas.h b/include/disas/disas.h
index 36c33f6f19..531b42e002 100644
--- a/include/disas/disas.h
+++ b/include/disas/disas.h
@@ -1,7 +1,7 @@
 #ifndef QEMU_DISAS_H
 #define QEMU_DISAS_H
 
-#include "exec/hwaddr.h"
+#include "exec/cpu-common.h"
 
 #ifdef NEED_CPU_H
 #include "cpu.h"
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index ed09d056d1..a215ae451d 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -22,7 +22,7 @@
 
 #include "hw/qdev-core.h"
 #include "disas/dis-asm.h"
-#include "exec/hwaddr.h"
+#include "exec/cpu-common.h"
 #include "exec/memattrs.h"
 #include "qapi/qapi-types-run-state.h"
 #include "qemu/bitmap.h"
diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index e08b8ab8fa..e223a1d87b 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -24,7 +24,7 @@
 #define HW_ACCEL_H
 
 #include "qom/object.h"
-#include "exec/hwaddr.h"
+#include "exec/cpu-common.h"
 
 typedef struct AccelState {
     /*< private >*/
-- 
2.21.3



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

* [PATCH 10/11] exec: Use 'cpu-common.h' instead of system-mode specific 'hwaddr.h'
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

The "exec/hwaddr.h" header is restricted to system-mode emulation.
Instead, use "exec/cpu-common.h", which is meant for all modes.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/disas/disas.h  | 2 +-
 include/hw/core/cpu.h  | 2 +-
 include/sysemu/accel.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/disas/disas.h b/include/disas/disas.h
index 36c33f6f19..531b42e002 100644
--- a/include/disas/disas.h
+++ b/include/disas/disas.h
@@ -1,7 +1,7 @@
 #ifndef QEMU_DISAS_H
 #define QEMU_DISAS_H
 
-#include "exec/hwaddr.h"
+#include "exec/cpu-common.h"
 
 #ifdef NEED_CPU_H
 #include "cpu.h"
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index ed09d056d1..a215ae451d 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -22,7 +22,7 @@
 
 #include "hw/qdev-core.h"
 #include "disas/dis-asm.h"
-#include "exec/hwaddr.h"
+#include "exec/cpu-common.h"
 #include "exec/memattrs.h"
 #include "qapi/qapi-types-run-state.h"
 #include "qemu/bitmap.h"
diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index e08b8ab8fa..e223a1d87b 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -24,7 +24,7 @@
 #define HW_ACCEL_H
 
 #include "qom/object.h"
-#include "exec/hwaddr.h"
+#include "exec/cpu-common.h"
 
 typedef struct AccelState {
     /*< private >*/
-- 
2.21.3



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

* [PATCH 11/11] exec/cpu-common: Poison hwaddr type in user-mode emulation
  2020-05-09 13:08 ` Philippe Mathieu-Daudé
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

The 'hwaddr' type is restricted to system-mode.
Declare it poisoned on user-mode emulation.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Checkpatch complains:

 WARNING: architecture specific defines should be avoided
 #10: FILE: include/exec/cpu-common.h:7:
 +#ifdef __GNUC__
---
 include/exec/cpu-common.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index b47e5630e7..56cfce8153 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -3,9 +3,13 @@
 
 /* CPU interfaces that are target independent.  */
 
-#ifndef CONFIG_USER_ONLY
+#ifdef CONFIG_USER_ONLY
+#ifdef __GNUC__
+#pragma GCC poison hwaddr
+#endif /* __GNUC__ */
+#else
 #include "exec/hwaddr.h"
-#endif
+#endif /* CONFIG_USER_ONLY */
 
 /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
 void qemu_init_cpu_list(void);
-- 
2.21.3



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

* [PATCH 11/11] exec/cpu-common: Poison hwaddr type in user-mode emulation
@ 2020-05-09 13:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 13:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée, Philippe Mathieu-Daudé

The 'hwaddr' type is restricted to system-mode.
Declare it poisoned on user-mode emulation.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Checkpatch complains:

 WARNING: architecture specific defines should be avoided
 #10: FILE: include/exec/cpu-common.h:7:
 +#ifdef __GNUC__
---
 include/exec/cpu-common.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index b47e5630e7..56cfce8153 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -3,9 +3,13 @@
 
 /* CPU interfaces that are target independent.  */
 
-#ifndef CONFIG_USER_ONLY
+#ifdef CONFIG_USER_ONLY
+#ifdef __GNUC__
+#pragma GCC poison hwaddr
+#endif /* __GNUC__ */
+#else
 #include "exec/hwaddr.h"
-#endif
+#endif /* CONFIG_USER_ONLY */
 
 /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
 void qemu_init_cpu_list(void);
-- 
2.21.3



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

* Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-09 16:08     ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 16:08 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell, Eduardo Habkost
  Cc: Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Laurent Vivier, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic,
	Palmer Dabbelt, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, qemu-s390x, qemu-arm, Stafford Horne,
	Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

On 5/9/20 3:09 PM, Philippe Mathieu-Daudé wrote:
> Restrict the following handlers to system-mode:
> - do_unaligned_access
> - do_transaction_failed
> - get_phys_page_debug
> - get_phys_page_attrs_debug
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   include/hw/core/cpu.h           |  8 +++++---
>   target/alpha/cpu.h              |  4 +++-
>   target/arm/cpu.h                |  6 +++---
>   target/arm/internals.h          |  4 ++++
>   target/cris/cpu.h               |  2 ++
>   target/hppa/cpu.h               |  2 +-
>   target/i386/cpu.h               |  2 ++
>   target/m68k/cpu.h               |  7 ++++++-
>   target/microblaze/cpu.h         |  5 ++++-
>   target/mips/internal.h          |  2 +-
>   target/nios2/cpu.h              |  5 ++++-
>   target/openrisc/cpu.h           |  3 ++-
>   target/ppc/cpu.h                |  2 +-
>   target/riscv/cpu.h              | 20 ++++++++++----------
>   target/sh4/cpu.h                |  2 +-
>   target/sparc/cpu.h              |  2 ++
>   target/xtensa/cpu.h             | 12 +++++++-----
>   target/hppa/cpu.c               |  4 +++-
>   target/ppc/translate_init.inc.c |  2 +-
>   19 files changed, 62 insertions(+), 32 deletions(-)
> 
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> index 5bf94d28cf..ed09d056d1 100644
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -167,6 +167,7 @@ typedef struct CPUClass {
>       int reset_dump_flags;
>       bool (*has_work)(CPUState *cpu);
>       void (*do_interrupt)(CPUState *cpu);
> +#ifndef CONFIG_USER_ONLY

I forgot once Peter Maydell told me we can't do that for some reason I 
don't remember.

At least this changes the sizeof(CPUClass), so we get:

qom/object.c:315:type_initialize: assertion failed: (parent->class_size 
<= ti->class_size)

So we can't poison the hwaddr type? (final patch of this series).

>       void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
>                                   MMUAccessType access_type,
>                                   int mmu_idx, uintptr_t retaddr);
> @@ -174,6 +175,10 @@ typedef struct CPUClass {
>                                     unsigned size, MMUAccessType access_type,
>                                     int mmu_idx, MemTxAttrs attrs,
>                                     MemTxResult response, uintptr_t retaddr);
> +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> +                                        MemTxAttrs *attrs);
> +#endif /* CONFIG_USER_ONLY */
>       bool (*virtio_is_big_endian)(CPUState *cpu);
>       int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
>                              uint8_t *buf, int len, bool is_write);
> @@ -189,9 +194,6 @@ typedef struct CPUClass {
>       bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
>                        MMUAccessType access_type, int mmu_idx,
>                        bool probe, uintptr_t retaddr);
> -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> -                                        MemTxAttrs *attrs);
>       int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
>       int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
>       int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
[...]


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

* Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
@ 2020-05-09 16:08     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 16:08 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell, Eduardo Habkost
  Cc: Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko, qemu-s390x,
	qemu-arm, Stafford Horne, Alex Bennée, Richard Henderson,
	qemu-riscv, Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On 5/9/20 3:09 PM, Philippe Mathieu-Daudé wrote:
> Restrict the following handlers to system-mode:
> - do_unaligned_access
> - do_transaction_failed
> - get_phys_page_debug
> - get_phys_page_attrs_debug
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   include/hw/core/cpu.h           |  8 +++++---
>   target/alpha/cpu.h              |  4 +++-
>   target/arm/cpu.h                |  6 +++---
>   target/arm/internals.h          |  4 ++++
>   target/cris/cpu.h               |  2 ++
>   target/hppa/cpu.h               |  2 +-
>   target/i386/cpu.h               |  2 ++
>   target/m68k/cpu.h               |  7 ++++++-
>   target/microblaze/cpu.h         |  5 ++++-
>   target/mips/internal.h          |  2 +-
>   target/nios2/cpu.h              |  5 ++++-
>   target/openrisc/cpu.h           |  3 ++-
>   target/ppc/cpu.h                |  2 +-
>   target/riscv/cpu.h              | 20 ++++++++++----------
>   target/sh4/cpu.h                |  2 +-
>   target/sparc/cpu.h              |  2 ++
>   target/xtensa/cpu.h             | 12 +++++++-----
>   target/hppa/cpu.c               |  4 +++-
>   target/ppc/translate_init.inc.c |  2 +-
>   19 files changed, 62 insertions(+), 32 deletions(-)
> 
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> index 5bf94d28cf..ed09d056d1 100644
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -167,6 +167,7 @@ typedef struct CPUClass {
>       int reset_dump_flags;
>       bool (*has_work)(CPUState *cpu);
>       void (*do_interrupt)(CPUState *cpu);
> +#ifndef CONFIG_USER_ONLY

I forgot once Peter Maydell told me we can't do that for some reason I 
don't remember.

At least this changes the sizeof(CPUClass), so we get:

qom/object.c:315:type_initialize: assertion failed: (parent->class_size 
<= ti->class_size)

So we can't poison the hwaddr type? (final patch of this series).

>       void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
>                                   MMUAccessType access_type,
>                                   int mmu_idx, uintptr_t retaddr);
> @@ -174,6 +175,10 @@ typedef struct CPUClass {
>                                     unsigned size, MMUAccessType access_type,
>                                     int mmu_idx, MemTxAttrs attrs,
>                                     MemTxResult response, uintptr_t retaddr);
> +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> +                                        MemTxAttrs *attrs);
> +#endif /* CONFIG_USER_ONLY */
>       bool (*virtio_is_big_endian)(CPUState *cpu);
>       int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
>                              uint8_t *buf, int len, bool is_write);
> @@ -189,9 +194,6 @@ typedef struct CPUClass {
>       bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
>                        MMUAccessType access_type, int mmu_idx,
>                        bool probe, uintptr_t retaddr);
> -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> -                                        MemTxAttrs *attrs);
>       int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
>       int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
>       int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
[...]


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

* Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
  2020-05-09 16:08     ` Philippe Mathieu-Daudé
@ 2020-05-09 20:01       ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 20:01 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers, Peter Maydell, Eduardo Habkost
  Cc: Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Laurent Vivier, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic,
	Palmer Dabbelt, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, open list:vfio-ccw, qemu-arm, Stafford Horne,
	Alex Bennée, Richard Henderson, open list:RISC-V TCG CPUs,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	qemu-ppc@nongnu.org list:PowerPC, Paolo Bonzini, Aurelien Jarno

On Sat, May 9, 2020 at 6:08 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On 5/9/20 3:09 PM, Philippe Mathieu-Daudé wrote:
> > Restrict the following handlers to system-mode:
> > - do_unaligned_access
> > - do_transaction_failed
> > - get_phys_page_debug
> > - get_phys_page_attrs_debug
> >
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > ---
> >   include/hw/core/cpu.h           |  8 +++++---
> >   target/alpha/cpu.h              |  4 +++-
> >   target/arm/cpu.h                |  6 +++---
> >   target/arm/internals.h          |  4 ++++
> >   target/cris/cpu.h               |  2 ++
> >   target/hppa/cpu.h               |  2 +-
> >   target/i386/cpu.h               |  2 ++
> >   target/m68k/cpu.h               |  7 ++++++-
> >   target/microblaze/cpu.h         |  5 ++++-
> >   target/mips/internal.h          |  2 +-
> >   target/nios2/cpu.h              |  5 ++++-
> >   target/openrisc/cpu.h           |  3 ++-
> >   target/ppc/cpu.h                |  2 +-
> >   target/riscv/cpu.h              | 20 ++++++++++----------
> >   target/sh4/cpu.h                |  2 +-
> >   target/sparc/cpu.h              |  2 ++
> >   target/xtensa/cpu.h             | 12 +++++++-----
> >   target/hppa/cpu.c               |  4 +++-
> >   target/ppc/translate_init.inc.c |  2 +-
> >   19 files changed, 62 insertions(+), 32 deletions(-)
> >
> > diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> > index 5bf94d28cf..ed09d056d1 100644
> > --- a/include/hw/core/cpu.h
> > +++ b/include/hw/core/cpu.h
> > @@ -167,6 +167,7 @@ typedef struct CPUClass {
> >       int reset_dump_flags;
> >       bool (*has_work)(CPUState *cpu);
> >       void (*do_interrupt)(CPUState *cpu);
> > +#ifndef CONFIG_USER_ONLY
>
> I forgot once Peter Maydell told me we can't do that for some reason I
> don't remember.
>
> At least this changes the sizeof(CPUClass), so we get:
>
> qom/object.c:315:type_initialize: assertion failed: (parent->class_size
> <= ti->class_size)
>
> So we can't poison the hwaddr type? (final patch of this series).

Well, this works...:

-- >8 --
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -167,6 +167,7 @@ typedef struct CPUClass {
     int reset_dump_flags;
     bool (*has_work)(CPUState *cpu);
     void (*do_interrupt)(CPUState *cpu);
+#ifndef CONFIG_USER_ONLY
     void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
                                 MMUAccessType access_type,
                                 int mmu_idx, uintptr_t retaddr);
@@ -174,6 +175,12 @@ typedef struct CPUClass {
                                   unsigned size, MMUAccessType access_type,
                                   int mmu_idx, MemTxAttrs attrs,
                                   MemTxResult response, uintptr_t retaddr);
+    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
+    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
+                                        MemTxAttrs *attrs);
+#else
+    void (*reserved[4])(CPUState *cpu, ...);
+#endif /* CONFIG_USER_ONLY */
     bool (*virtio_is_big_endian)(CPUState *cpu);
     int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
                            uint8_t *buf, int len, bool is_write);
@@ -189,9 +196,6 @@ typedef struct CPUClass {
     bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
                      MMUAccessType access_type, int mmu_idx,
                      bool probe, uintptr_t retaddr);
-    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
-    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
-                                        MemTxAttrs *attrs);
     int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
     int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
     int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
---

Ugly?

>
> >       void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
> >                                   MMUAccessType access_type,
> >                                   int mmu_idx, uintptr_t retaddr);
> > @@ -174,6 +175,10 @@ typedef struct CPUClass {
> >                                     unsigned size, MMUAccessType access_type,
> >                                     int mmu_idx, MemTxAttrs attrs,
> >                                     MemTxResult response, uintptr_t retaddr);
> > +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > +                                        MemTxAttrs *attrs);
> > +#endif /* CONFIG_USER_ONLY */
> >       bool (*virtio_is_big_endian)(CPUState *cpu);
> >       int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
> >                              uint8_t *buf, int len, bool is_write);
> > @@ -189,9 +194,6 @@ typedef struct CPUClass {
> >       bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
> >                        MMUAccessType access_type, int mmu_idx,
> >                        bool probe, uintptr_t retaddr);
> > -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > -                                        MemTxAttrs *attrs);
> >       int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
> >       int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
> >       int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> [...]


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

* Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
@ 2020-05-09 20:01       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-09 20:01 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers, Peter Maydell, Eduardo Habkost
  Cc: Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic,
	qemu-ppc@nongnu.org list:PowerPC, Aleksandar Rikalo,
	David Gibson, Artyom Tarasenko, open list:vfio-ccw, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson,
	open list:RISC-V TCG CPUs, Bastian Koppelmann, Cornelia Huck,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Paolo Bonzini,
	Aurelien Jarno

On Sat, May 9, 2020 at 6:08 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On 5/9/20 3:09 PM, Philippe Mathieu-Daudé wrote:
> > Restrict the following handlers to system-mode:
> > - do_unaligned_access
> > - do_transaction_failed
> > - get_phys_page_debug
> > - get_phys_page_attrs_debug
> >
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > ---
> >   include/hw/core/cpu.h           |  8 +++++---
> >   target/alpha/cpu.h              |  4 +++-
> >   target/arm/cpu.h                |  6 +++---
> >   target/arm/internals.h          |  4 ++++
> >   target/cris/cpu.h               |  2 ++
> >   target/hppa/cpu.h               |  2 +-
> >   target/i386/cpu.h               |  2 ++
> >   target/m68k/cpu.h               |  7 ++++++-
> >   target/microblaze/cpu.h         |  5 ++++-
> >   target/mips/internal.h          |  2 +-
> >   target/nios2/cpu.h              |  5 ++++-
> >   target/openrisc/cpu.h           |  3 ++-
> >   target/ppc/cpu.h                |  2 +-
> >   target/riscv/cpu.h              | 20 ++++++++++----------
> >   target/sh4/cpu.h                |  2 +-
> >   target/sparc/cpu.h              |  2 ++
> >   target/xtensa/cpu.h             | 12 +++++++-----
> >   target/hppa/cpu.c               |  4 +++-
> >   target/ppc/translate_init.inc.c |  2 +-
> >   19 files changed, 62 insertions(+), 32 deletions(-)
> >
> > diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> > index 5bf94d28cf..ed09d056d1 100644
> > --- a/include/hw/core/cpu.h
> > +++ b/include/hw/core/cpu.h
> > @@ -167,6 +167,7 @@ typedef struct CPUClass {
> >       int reset_dump_flags;
> >       bool (*has_work)(CPUState *cpu);
> >       void (*do_interrupt)(CPUState *cpu);
> > +#ifndef CONFIG_USER_ONLY
>
> I forgot once Peter Maydell told me we can't do that for some reason I
> don't remember.
>
> At least this changes the sizeof(CPUClass), so we get:
>
> qom/object.c:315:type_initialize: assertion failed: (parent->class_size
> <= ti->class_size)
>
> So we can't poison the hwaddr type? (final patch of this series).

Well, this works...:

-- >8 --
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -167,6 +167,7 @@ typedef struct CPUClass {
     int reset_dump_flags;
     bool (*has_work)(CPUState *cpu);
     void (*do_interrupt)(CPUState *cpu);
+#ifndef CONFIG_USER_ONLY
     void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
                                 MMUAccessType access_type,
                                 int mmu_idx, uintptr_t retaddr);
@@ -174,6 +175,12 @@ typedef struct CPUClass {
                                   unsigned size, MMUAccessType access_type,
                                   int mmu_idx, MemTxAttrs attrs,
                                   MemTxResult response, uintptr_t retaddr);
+    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
+    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
+                                        MemTxAttrs *attrs);
+#else
+    void (*reserved[4])(CPUState *cpu, ...);
+#endif /* CONFIG_USER_ONLY */
     bool (*virtio_is_big_endian)(CPUState *cpu);
     int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
                            uint8_t *buf, int len, bool is_write);
@@ -189,9 +196,6 @@ typedef struct CPUClass {
     bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
                      MMUAccessType access_type, int mmu_idx,
                      bool probe, uintptr_t retaddr);
-    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
-    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
-                                        MemTxAttrs *attrs);
     int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
     int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
     int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
---

Ugly?

>
> >       void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
> >                                   MMUAccessType access_type,
> >                                   int mmu_idx, uintptr_t retaddr);
> > @@ -174,6 +175,10 @@ typedef struct CPUClass {
> >                                     unsigned size, MMUAccessType access_type,
> >                                     int mmu_idx, MemTxAttrs attrs,
> >                                     MemTxResult response, uintptr_t retaddr);
> > +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > +                                        MemTxAttrs *attrs);
> > +#endif /* CONFIG_USER_ONLY */
> >       bool (*virtio_is_big_endian)(CPUState *cpu);
> >       int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
> >                              uint8_t *buf, int len, bool is_write);
> > @@ -189,9 +194,6 @@ typedef struct CPUClass {
> >       bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
> >                        MMUAccessType access_type, int mmu_idx,
> >                        bool probe, uintptr_t retaddr);
> > -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > -                                        MemTxAttrs *attrs);
> >       int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
> >       int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
> >       int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> [...]


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

* Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
  2020-05-09 20:01       ` Philippe Mathieu-Daudé
@ 2020-05-09 21:03         ` Paolo Bonzini
  -1 siblings, 0 replies; 65+ messages in thread
From: Paolo Bonzini @ 2020-05-09 21:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Cornelia Huck, Sagar Karandikar,
	David Hildenbrand, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, Laurent Vivier, Max Filippov,
	Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, Palmer Dabbelt, Aleksandar Rikalo,
	David Gibson, Artyom Tarasenko, Eduardo Habkost,
	open list:vfio-ccw, qemu-arm, Stafford Horne, Alex Bennée,
	Richard Henderson, open list:RISC-V TCG CPUs, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc@nongnu.org list:PowerPC,
	Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 4338 bytes --]

Il sab 9 mag 2020, 22:01 Philippe Mathieu-Daudé <f4bug@amsat.org> ha
scritto:

> > I forgot once Peter Maydell told me we can't do that for some reason I
> > don't remember.
> >
> > At least this changes the sizeof(CPUClass), so we get:
> >
> > qom/object.c:315:type_initialize: assertion failed: (parent->class_size
> > <= ti->class_size)
> >
> > So we can't poison the hwaddr type? (final patch of this series).
>
> Well, this works...:
>
> -- >8 --
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -167,6 +167,7 @@ typedef struct CPUClass {
>      int reset_dump_flags;
>      bool (*has_work)(CPUState *cpu);
>      void (*do_interrupt)(CPUState *cpu);
> +#ifndef CONFIG_USER_ONLY
>      void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
>                                  MMUAccessType access_type,
>                                  int mmu_idx, uintptr_t retaddr);
> @@ -174,6 +175,12 @@ typedef struct CPUClass {
>                                    unsigned size, MMUAccessType
> access_type,
>                                    int mmu_idx, MemTxAttrs attrs,
>                                    MemTxResult response, uintptr_t
> retaddr);
> +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> +                                        MemTxAttrs *attrs);
> +#else
> +    void (*reserved[4])(CPUState *cpu, ...);
> +#endif /* CONFIG_USER_ONLY */
>      bool (*virtio_is_big_endian)(CPUState *cpu);
>      int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
>                             uint8_t *buf, int len, bool is_write);
> @@ -189,9 +196,6 @@ typedef struct CPUClass {
>      bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
>                       MMUAccessType access_type, int mmu_idx,
>                       bool probe, uintptr_t retaddr);
> -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> -                                        MemTxAttrs *attrs);
>      int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
>      int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
>      int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> ---
>
> Ugly?
>

More. :-) And hwaddr is only a small part, there are several other methods
that only make sense for system emulation. Let me review the rest of the
series, it may not be good enough to stop here while we figure out a way.

Paolo


> >
> > >       void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
> > >                                   MMUAccessType access_type,
> > >                                   int mmu_idx, uintptr_t retaddr);
> > > @@ -174,6 +175,10 @@ typedef struct CPUClass {
> > >                                     unsigned size, MMUAccessType
> access_type,
> > >                                     int mmu_idx, MemTxAttrs attrs,
> > >                                     MemTxResult response, uintptr_t
> retaddr);
> > > +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > > +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > > +                                        MemTxAttrs *attrs);
> > > +#endif /* CONFIG_USER_ONLY */
> > >       bool (*virtio_is_big_endian)(CPUState *cpu);
> > >       int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
> > >                              uint8_t *buf, int len, bool is_write);
> > > @@ -189,9 +194,6 @@ typedef struct CPUClass {
> > >       bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
> > >                        MMUAccessType access_type, int mmu_idx,
> > >                        bool probe, uintptr_t retaddr);
> > > -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > > -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > > -                                        MemTxAttrs *attrs);
> > >       int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
> > >       int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int
> reg);
> > >       int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> > [...]
>
>

[-- Attachment #2: Type: text/html, Size: 5674 bytes --]

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

* Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
@ 2020-05-09 21:03         ` Paolo Bonzini
  0 siblings, 0 replies; 65+ messages in thread
From: Paolo Bonzini @ 2020-05-09 21:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel@nongnu.org Developers, Peter Maydell, Eduardo Habkost,
	Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic,
	qemu-ppc@nongnu.org list:PowerPC, Aleksandar Rikalo,
	David Gibson, Artyom Tarasenko, open list:vfio-ccw, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson,
	open list:RISC-V TCG CPUs, Bastian Koppelmann, Cornelia Huck,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 4338 bytes --]

Il sab 9 mag 2020, 22:01 Philippe Mathieu-Daudé <f4bug@amsat.org> ha
scritto:

> > I forgot once Peter Maydell told me we can't do that for some reason I
> > don't remember.
> >
> > At least this changes the sizeof(CPUClass), so we get:
> >
> > qom/object.c:315:type_initialize: assertion failed: (parent->class_size
> > <= ti->class_size)
> >
> > So we can't poison the hwaddr type? (final patch of this series).
>
> Well, this works...:
>
> -- >8 --
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -167,6 +167,7 @@ typedef struct CPUClass {
>      int reset_dump_flags;
>      bool (*has_work)(CPUState *cpu);
>      void (*do_interrupt)(CPUState *cpu);
> +#ifndef CONFIG_USER_ONLY
>      void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
>                                  MMUAccessType access_type,
>                                  int mmu_idx, uintptr_t retaddr);
> @@ -174,6 +175,12 @@ typedef struct CPUClass {
>                                    unsigned size, MMUAccessType
> access_type,
>                                    int mmu_idx, MemTxAttrs attrs,
>                                    MemTxResult response, uintptr_t
> retaddr);
> +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> +                                        MemTxAttrs *attrs);
> +#else
> +    void (*reserved[4])(CPUState *cpu, ...);
> +#endif /* CONFIG_USER_ONLY */
>      bool (*virtio_is_big_endian)(CPUState *cpu);
>      int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
>                             uint8_t *buf, int len, bool is_write);
> @@ -189,9 +196,6 @@ typedef struct CPUClass {
>      bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
>                       MMUAccessType access_type, int mmu_idx,
>                       bool probe, uintptr_t retaddr);
> -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> -                                        MemTxAttrs *attrs);
>      int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
>      int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
>      int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> ---
>
> Ugly?
>

More. :-) And hwaddr is only a small part, there are several other methods
that only make sense for system emulation. Let me review the rest of the
series, it may not be good enough to stop here while we figure out a way.

Paolo


> >
> > >       void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
> > >                                   MMUAccessType access_type,
> > >                                   int mmu_idx, uintptr_t retaddr);
> > > @@ -174,6 +175,10 @@ typedef struct CPUClass {
> > >                                     unsigned size, MMUAccessType
> access_type,
> > >                                     int mmu_idx, MemTxAttrs attrs,
> > >                                     MemTxResult response, uintptr_t
> retaddr);
> > > +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > > +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > > +                                        MemTxAttrs *attrs);
> > > +#endif /* CONFIG_USER_ONLY */
> > >       bool (*virtio_is_big_endian)(CPUState *cpu);
> > >       int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
> > >                              uint8_t *buf, int len, bool is_write);
> > > @@ -189,9 +194,6 @@ typedef struct CPUClass {
> > >       bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
> > >                        MMUAccessType access_type, int mmu_idx,
> > >                        bool probe, uintptr_t retaddr);
> > > -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > > -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > > -                                        MemTxAttrs *attrs);
> > >       int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
> > >       int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int
> reg);
> > >       int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> > [...]
>
>

[-- Attachment #2: Type: text/html, Size: 5674 bytes --]

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

* Re: [PATCH 01/11] plugins: Restrict functions handling hwaddr to system-mode
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-10 10:44     ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-10 10:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Laurent Vivier, Max Filippov, Alistair Francis,
	Marek Vasut, Aleksandar Markovic, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Richard Henderson, qemu-riscv, Bastian Koppelmann, Cornelia Huck,
	Roman Bolshakov, qemu-ppc, Paolo Bonzini, Aurelien Jarno

On 5/9/20 3:09 PM, Philippe Mathieu-Daudé wrote:
> Restrict qemu_plugin_hwaddr_is_io() and
> qemu_plugin_hwaddr_device_offset() to system-mode.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   include/qemu/qemu-plugin.h |  2 ++
>   plugins/api.c              | 17 ++---------------
>   2 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
> index 5502e112c8..06c271a107 100644
> --- a/include/qemu/qemu-plugin.h
> +++ b/include/qemu/qemu-plugin.h
> @@ -326,6 +326,7 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info);
>   struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
>                                                     uint64_t vaddr);
>   
> +#ifndef CONFIG_USER_ONLY
>   /*
>    * The following additional queries can be run on the hwaddr structure
>    * to return information about it. For non-IO accesses the device
> @@ -333,6 +334,7 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
>    */
>   bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr);
>   uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr);
> +#endif /* CONFIG_USER_ONLY */
>   
>   typedef void
>   (*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index,
> diff --git a/plugins/api.c b/plugins/api.c
> index 53c8a73582..785ad2e45e 100644
> --- a/plugins/api.c
> +++ b/plugins/api.c
> @@ -249,7 +249,8 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info)
>    * Virtual Memory queries
>    */
>   
> -#ifdef CONFIG_SOFTMMU
> +#ifndef CONFIG_USER_ONLY
> +
>   static __thread struct qemu_plugin_hwaddr hwaddr_info;
>   
>   struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
> @@ -267,26 +268,14 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
>   
>       return &hwaddr_info;
>   }
> -#else
> -struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
> -                                                  uint64_t vaddr)
> -{
> -    return NULL;
> -}
> -#endif
>   
>   bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr)

Please disregard this patch, I misinterpreted the variable name with the 
hwaddr type.

>   {
> -#ifdef CONFIG_SOFTMMU
>       return hwaddr->is_io;
> -#else
> -    return false;
> -#endif
>   }
>   
>   uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr)
>   {
> -#ifdef CONFIG_SOFTMMU
>       if (haddr) {
>           if (!haddr->is_io) {
>               ram_addr_t ram_addr = qemu_ram_addr_from_host((void *) haddr->v.ram.hostaddr);
> @@ -299,7 +288,6 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr
>               return haddr->v.io.offset;
>           }
>       }
> -#endif
>       return 0;
>   }
>   
> @@ -308,7 +296,6 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr
>    * will be. This helps the plugin dimension per-vcpu arrays.
>    */
>   
> -#ifndef CONFIG_USER_ONLY
>   static MachineState * get_ms(void)
>   {
>       return MACHINE(qdev_get_machine());
> 


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

* Re: [PATCH 01/11] plugins: Restrict functions handling hwaddr to system-mode
@ 2020-05-10 10:44     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-10 10:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, Max Filippov, Alistair Francis, Marek Vasut,
	Aleksandar Markovic, Marcel Apfelbaum, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Richard Henderson, qemu-riscv, Bastian Koppelmann, Cornelia Huck,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Paolo Bonzini,
	Aurelien Jarno

On 5/9/20 3:09 PM, Philippe Mathieu-Daudé wrote:
> Restrict qemu_plugin_hwaddr_is_io() and
> qemu_plugin_hwaddr_device_offset() to system-mode.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   include/qemu/qemu-plugin.h |  2 ++
>   plugins/api.c              | 17 ++---------------
>   2 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
> index 5502e112c8..06c271a107 100644
> --- a/include/qemu/qemu-plugin.h
> +++ b/include/qemu/qemu-plugin.h
> @@ -326,6 +326,7 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info);
>   struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
>                                                     uint64_t vaddr);
>   
> +#ifndef CONFIG_USER_ONLY
>   /*
>    * The following additional queries can be run on the hwaddr structure
>    * to return information about it. For non-IO accesses the device
> @@ -333,6 +334,7 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
>    */
>   bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr);
>   uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr);
> +#endif /* CONFIG_USER_ONLY */
>   
>   typedef void
>   (*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index,
> diff --git a/plugins/api.c b/plugins/api.c
> index 53c8a73582..785ad2e45e 100644
> --- a/plugins/api.c
> +++ b/plugins/api.c
> @@ -249,7 +249,8 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info)
>    * Virtual Memory queries
>    */
>   
> -#ifdef CONFIG_SOFTMMU
> +#ifndef CONFIG_USER_ONLY
> +
>   static __thread struct qemu_plugin_hwaddr hwaddr_info;
>   
>   struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
> @@ -267,26 +268,14 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
>   
>       return &hwaddr_info;
>   }
> -#else
> -struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
> -                                                  uint64_t vaddr)
> -{
> -    return NULL;
> -}
> -#endif
>   
>   bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr)

Please disregard this patch, I misinterpreted the variable name with the 
hwaddr type.

>   {
> -#ifdef CONFIG_SOFTMMU
>       return hwaddr->is_io;
> -#else
> -    return false;
> -#endif
>   }
>   
>   uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr)
>   {
> -#ifdef CONFIG_SOFTMMU
>       if (haddr) {
>           if (!haddr->is_io) {
>               ram_addr_t ram_addr = qemu_ram_addr_from_host((void *) haddr->v.ram.hostaddr);
> @@ -299,7 +288,6 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr
>               return haddr->v.io.offset;
>           }
>       }
> -#endif
>       return 0;
>   }
>   
> @@ -308,7 +296,6 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr
>    * will be. This helps the plugin dimension per-vcpu arrays.
>    */
>   
> -#ifndef CONFIG_USER_ONLY
>   static MachineState * get_ms(void)
>   {
>       return MACHINE(qdev_get_machine());
> 


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

* Re: [PATCH 05/11] target/ppc: Restrict PPCVirtualHypervisorClass to system-mode
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11  1:15     ` David Gibson
  -1 siblings, 0 replies; 65+ messages in thread
From: David Gibson @ 2020-05-11  1:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, Artyom Tarasenko, Eduardo Habkost, qemu-s390x,
	qemu-arm, Stafford Horne, Alex Bennée, Richard Henderson,
	qemu-riscv, Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 4083 bytes --]

On Sat, May 09, 2020 at 03:09:04PM +0200, Philippe Mathieu-Daudé wrote:
> The code related to PPC Virtual Hypervisor is pointless in user-mode.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  target/ppc/cpu.h                |  4 ++--
>  target/ppc/kvm_ppc.h            | 22 +++++++++++-----------
>  target/ppc/translate_init.inc.c |  4 ++++
>  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 6b6dd7e483..73920a9cac 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1176,6 +1176,7 @@ 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);
>  
> +#ifndef CONFIG_USER_ONLY
>  struct PPCVirtualHypervisorClass {
>      InterfaceClass parent;
>      void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
> @@ -1189,10 +1190,8 @@ struct PPCVirtualHypervisorClass {
>      void (*hpte_set_r)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t pte1);
>      void (*get_pate)(PPCVirtualHypervisor *vhyp, ppc_v3_pate_t *entry);
>      target_ulong (*encode_hpt_for_kvm_pr)(PPCVirtualHypervisor *vhyp);
> -#ifndef CONFIG_USER_ONLY
>      void (*cpu_exec_enter)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
>      void (*cpu_exec_exit)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
> -#endif
>  };
>  
>  #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor"
> @@ -1204,6 +1203,7 @@ struct PPCVirtualHypervisorClass {
>  #define PPC_VIRTUAL_HYPERVISOR_GET_CLASS(obj) \
>      OBJECT_GET_CLASS(PPCVirtualHypervisorClass, (obj), \
>                       TYPE_PPC_VIRTUAL_HYPERVISOR)
> +#endif /* CONFIG_USER_ONLY */
>  
>  void ppc_cpu_do_interrupt(CPUState *cpu);
>  bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index fcaf745516..701c0c262b 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -280,6 +280,17 @@ static inline bool kvmppc_has_cap_spapr_vfio(void)
>      return false;
>  }
>  
> +static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
> +                                     hwaddr ptex, int n)
> +{
> +    abort();
> +}
> +
> +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)
> @@ -310,17 +321,6 @@ static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
>      abort();
>  }
>  
> -static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
> -                                     hwaddr ptex, int n)
> -{
> -    abort();
> -}
> -
> -static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)
> -{
> -    abort();
> -}
> -
>  static inline bool kvmppc_has_cap_fixup_hcalls(void)
>  {
>      abort();
> diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
> index 2b6e832c4c..4ea0cc501b 100644
> --- a/target/ppc/translate_init.inc.c
> +++ b/target/ppc/translate_init.inc.c
> @@ -10946,16 +10946,20 @@ static const TypeInfo ppc_cpu_type_info = {
>      .class_init = ppc_cpu_class_init,
>  };
>  
> +#ifndef CONFIG_USER_ONLY
>  static const TypeInfo ppc_vhyp_type_info = {
>      .name = TYPE_PPC_VIRTUAL_HYPERVISOR,
>      .parent = TYPE_INTERFACE,
>      .class_size = sizeof(PPCVirtualHypervisorClass),
>  };
> +#endif
>  
>  static void ppc_cpu_register_types(void)
>  {
>      type_register_static(&ppc_cpu_type_info);
> +#ifndef CONFIG_USER_ONLY
>      type_register_static(&ppc_vhyp_type_info);
> +#endif
>  }
>  
>  type_init(ppc_cpu_register_types)

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 05/11] target/ppc: Restrict PPCVirtualHypervisorClass to system-mode
@ 2020-05-11  1:15     ` David Gibson
  0 siblings, 0 replies; 65+ messages in thread
From: David Gibson @ 2020-05-11  1:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Hildenbrand, Alex Bennée

[-- Attachment #1: Type: text/plain, Size: 4083 bytes --]

On Sat, May 09, 2020 at 03:09:04PM +0200, Philippe Mathieu-Daudé wrote:
> The code related to PPC Virtual Hypervisor is pointless in user-mode.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  target/ppc/cpu.h                |  4 ++--
>  target/ppc/kvm_ppc.h            | 22 +++++++++++-----------
>  target/ppc/translate_init.inc.c |  4 ++++
>  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 6b6dd7e483..73920a9cac 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1176,6 +1176,7 @@ 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);
>  
> +#ifndef CONFIG_USER_ONLY
>  struct PPCVirtualHypervisorClass {
>      InterfaceClass parent;
>      void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
> @@ -1189,10 +1190,8 @@ struct PPCVirtualHypervisorClass {
>      void (*hpte_set_r)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t pte1);
>      void (*get_pate)(PPCVirtualHypervisor *vhyp, ppc_v3_pate_t *entry);
>      target_ulong (*encode_hpt_for_kvm_pr)(PPCVirtualHypervisor *vhyp);
> -#ifndef CONFIG_USER_ONLY
>      void (*cpu_exec_enter)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
>      void (*cpu_exec_exit)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
> -#endif
>  };
>  
>  #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor"
> @@ -1204,6 +1203,7 @@ struct PPCVirtualHypervisorClass {
>  #define PPC_VIRTUAL_HYPERVISOR_GET_CLASS(obj) \
>      OBJECT_GET_CLASS(PPCVirtualHypervisorClass, (obj), \
>                       TYPE_PPC_VIRTUAL_HYPERVISOR)
> +#endif /* CONFIG_USER_ONLY */
>  
>  void ppc_cpu_do_interrupt(CPUState *cpu);
>  bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index fcaf745516..701c0c262b 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -280,6 +280,17 @@ static inline bool kvmppc_has_cap_spapr_vfio(void)
>      return false;
>  }
>  
> +static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
> +                                     hwaddr ptex, int n)
> +{
> +    abort();
> +}
> +
> +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)
> @@ -310,17 +321,6 @@ static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
>      abort();
>  }
>  
> -static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
> -                                     hwaddr ptex, int n)
> -{
> -    abort();
> -}
> -
> -static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)
> -{
> -    abort();
> -}
> -
>  static inline bool kvmppc_has_cap_fixup_hcalls(void)
>  {
>      abort();
> diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
> index 2b6e832c4c..4ea0cc501b 100644
> --- a/target/ppc/translate_init.inc.c
> +++ b/target/ppc/translate_init.inc.c
> @@ -10946,16 +10946,20 @@ static const TypeInfo ppc_cpu_type_info = {
>      .class_init = ppc_cpu_class_init,
>  };
>  
> +#ifndef CONFIG_USER_ONLY
>  static const TypeInfo ppc_vhyp_type_info = {
>      .name = TYPE_PPC_VIRTUAL_HYPERVISOR,
>      .parent = TYPE_INTERFACE,
>      .class_size = sizeof(PPCVirtualHypervisorClass),
>  };
> +#endif
>  
>  static void ppc_cpu_register_types(void)
>  {
>      type_register_static(&ppc_cpu_type_info);
> +#ifndef CONFIG_USER_ONLY
>      type_register_static(&ppc_vhyp_type_info);
> +#endif
>  }
>  
>  type_init(ppc_cpu_register_types)

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11  1:16     ` David Gibson
  -1 siblings, 0 replies; 65+ messages in thread
From: David Gibson @ 2020-05-11  1:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, Artyom Tarasenko, Eduardo Habkost, qemu-s390x,
	qemu-arm, Stafford Horne, Alex Bennée, Richard Henderson,
	qemu-riscv, Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 23382 bytes --]

On Sat, May 09, 2020 at 03:09:08PM +0200, Philippe Mathieu-Daudé wrote:
> Restrict the following handlers to system-mode:
> - do_unaligned_access
> - do_transaction_failed
> - get_phys_page_debug
> - get_phys_page_attrs_debug
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

ppc parts

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  include/hw/core/cpu.h           |  8 +++++---
>  target/alpha/cpu.h              |  4 +++-
>  target/arm/cpu.h                |  6 +++---
>  target/arm/internals.h          |  4 ++++
>  target/cris/cpu.h               |  2 ++
>  target/hppa/cpu.h               |  2 +-
>  target/i386/cpu.h               |  2 ++
>  target/m68k/cpu.h               |  7 ++++++-
>  target/microblaze/cpu.h         |  5 ++++-
>  target/mips/internal.h          |  2 +-
>  target/nios2/cpu.h              |  5 ++++-
>  target/openrisc/cpu.h           |  3 ++-
>  target/ppc/cpu.h                |  2 +-
>  target/riscv/cpu.h              | 20 ++++++++++----------
>  target/sh4/cpu.h                |  2 +-
>  target/sparc/cpu.h              |  2 ++
>  target/xtensa/cpu.h             | 12 +++++++-----
>  target/hppa/cpu.c               |  4 +++-
>  target/ppc/translate_init.inc.c |  2 +-
>  19 files changed, 62 insertions(+), 32 deletions(-)
> 
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> index 5bf94d28cf..ed09d056d1 100644
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -167,6 +167,7 @@ typedef struct CPUClass {
>      int reset_dump_flags;
>      bool (*has_work)(CPUState *cpu);
>      void (*do_interrupt)(CPUState *cpu);
> +#ifndef CONFIG_USER_ONLY
>      void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
>                                  MMUAccessType access_type,
>                                  int mmu_idx, uintptr_t retaddr);
> @@ -174,6 +175,10 @@ typedef struct CPUClass {
>                                    unsigned size, MMUAccessType access_type,
>                                    int mmu_idx, MemTxAttrs attrs,
>                                    MemTxResult response, uintptr_t retaddr);
> +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> +                                        MemTxAttrs *attrs);
> +#endif /* CONFIG_USER_ONLY */
>      bool (*virtio_is_big_endian)(CPUState *cpu);
>      int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
>                             uint8_t *buf, int len, bool is_write);
> @@ -189,9 +194,6 @@ typedef struct CPUClass {
>      bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
>                       MMUAccessType access_type, int mmu_idx,
>                       bool probe, uintptr_t retaddr);
> -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> -                                        MemTxAttrs *attrs);
>      int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
>      int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
>      int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
> index be29bdd530..b12021803e 100644
> --- a/target/alpha/cpu.h
> +++ b/target/alpha/cpu.h
> @@ -279,12 +279,14 @@ extern const VMStateDescription vmstate_alpha_cpu;
>  void alpha_cpu_do_interrupt(CPUState *cpu);
>  bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);
> -hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> +#ifndef CONFIG_USER_ONLY
> +hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>                                     MMUAccessType access_type,
>                                     int mmu_idx, uintptr_t retaddr);
> +#endif
>  
>  #define cpu_list alpha_cpu_list
>  #define cpu_signal_handler cpu_alpha_signal_handler
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 8608da6b6f..d333036bb4 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -966,15 +966,15 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz);
>  
>  #ifndef CONFIG_USER_ONLY
>  extern const VMStateDescription vmstate_arm_cpu;
> +
> +hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
> +                                         MemTxAttrs *attrs);
>  #endif
>  
>  void arm_cpu_do_interrupt(CPUState *cpu);
>  void arm_v7m_cpu_do_interrupt(CPUState *cpu);
>  bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  
> -hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
> -                                         MemTxAttrs *attrs);
> -
>  int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  
> diff --git a/target/arm/internals.h b/target/arm/internals.h
> index e633aff36e..c0a2a5df71 100644
> --- a/target/arm/internals.h
> +++ b/target/arm/internals.h
> @@ -812,6 +812,8 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
>   * tables */
>  bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);
>  
> +#ifndef CONFIG_USER_ONLY
> +
>  /* Raise a data fault alignment exception for the specified virtual address */
>  void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
>                                   MMUAccessType access_type,
> @@ -827,6 +829,8 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
>                                     int mmu_idx, MemTxAttrs attrs,
>                                     MemTxResult response, uintptr_t retaddr);
>  
> +#endif /* !CONFIG_USER_ONLY */
> +
>  /* Call any registered EL change hooks */
>  static inline void arm_call_pre_el_change_hook(ARMCPU *cpu)
>  {
> diff --git a/target/cris/cpu.h b/target/cris/cpu.h
> index 8f08d7628b..e9c858ada7 100644
> --- a/target/cris/cpu.h
> +++ b/target/cris/cpu.h
> @@ -193,7 +193,9 @@ bool cris_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  
>  void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags);
>  
> +#ifndef CONFIG_USER_ONLY
>  hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
>  
>  int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int cris_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
> diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
> index 801a4fb1ba..7848425f6a 100644
> --- a/target/hppa/cpu.h
> +++ b/target/hppa/cpu.h
> @@ -320,7 +320,6 @@ void cpu_hppa_change_prot_id(CPUHPPAState *env);
>  #define cpu_signal_handler cpu_hppa_signal_handler
>  
>  int cpu_hppa_signal_handler(int host_signum, void *pinfo, void *puc);
> -hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
>  int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void hppa_cpu_do_interrupt(CPUState *cpu);
> @@ -330,6 +329,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>                         MMUAccessType access_type, int mmu_idx,
>                         bool probe, uintptr_t retaddr);
>  #ifndef CONFIG_USER_ONLY
> +hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
>  int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
>                                int type, hwaddr *pphys, int *pprot);
>  extern const MemoryRegionOps hppa_io_eir_ops;
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index e818fc712a..00e0cc0828 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1767,8 +1767,10 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
>  
>  void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags);
>  
> +#ifndef CONFIG_USER_ONLY
>  hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
>                                           MemTxAttrs *attrs);
> +#endif
>  
>  int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
> index 521ac67cdd..efc940e7ec 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -167,10 +167,13 @@ struct M68kCPU {
>  void m68k_cpu_do_interrupt(CPUState *cpu);
>  bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  
> +#ifndef CONFIG_USER_ONLY
> +hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
> +
>  void m68k_tcg_init(void);
>  void m68k_cpu_init_gdb(M68kCPU *cpu);
>  /*
> @@ -529,10 +532,12 @@ static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)
>  bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>                         MMUAccessType access_type, int mmu_idx,
>                         bool probe, uintptr_t retaddr);
> +#ifndef CONFIG_USER_ONLY
>  void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
>                                   unsigned size, MMUAccessType access_type,
>                                   int mmu_idx, MemTxAttrs attrs,
>                                   MemTxResult response, uintptr_t retaddr);
> +#endif
>  
>  typedef CPUM68KState CPUArchState;
>  typedef M68kCPU ArchCPU;
> diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
> index a31134b65c..eb57f04d3f 100644
> --- a/target/microblaze/cpu.h
> +++ b/target/microblaze/cpu.h
> @@ -318,10 +318,13 @@ struct MicroBlazeCPU {
>  void mb_cpu_do_interrupt(CPUState *cs);
>  bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
>  void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  
> +#ifndef CONFIG_USER_ONLY
> +hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
> +
>  void mb_tcg_init(void);
>  /* you can call this signal handler from your SIGBUS and SIGSEGV
>     signal handlers to inform the virtual CPU of exceptions. non zero
> diff --git a/target/mips/internal.h b/target/mips/internal.h
> index 1bf274b3ef..c38666c6f5 100644
> --- a/target/mips/internal.h
> +++ b/target/mips/internal.h
> @@ -81,7 +81,6 @@ enum CPUMIPSMSADataFormat {
>  void mips_cpu_do_interrupt(CPUState *cpu);
>  bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void mips_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int mips_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
> @@ -150,6 +149,7 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
>                                      MemTxResult response, uintptr_t retaddr);
>  hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address,
>                                    int rw);
> +hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  #endif
>  
>  #define cpu_signal_handler cpu_mips_signal_handler
> diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
> index 4dddf9c3a1..0703295133 100644
> --- a/target/nios2/cpu.h
> +++ b/target/nios2/cpu.h
> @@ -199,11 +199,14 @@ void nios2_cpu_do_interrupt(CPUState *cs);
>  int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc);
>  void dump_mmu(CPUNios2State *env);
>  void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>                                     MMUAccessType access_type,
>                                     int mmu_idx, uintptr_t retaddr);
>  
> +#ifndef CONFIG_USER_ONLY
> +hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
> +
>  qemu_irq *nios2_cpu_pic_init(Nios2CPU *cpu);
>  void nios2_check_interrupts(CPUNios2State *env);
>  
> diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
> index f37a52e153..60de8ed787 100644
> --- a/target/openrisc/cpu.h
> +++ b/target/openrisc/cpu.h
> @@ -319,7 +319,6 @@ void cpu_openrisc_list(void);
>  void openrisc_cpu_do_interrupt(CPUState *cpu);
>  bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void openrisc_translate_init(void);
> @@ -335,6 +334,8 @@ int print_insn_or1k(bfd_vma addr, disassemble_info *info);
>  #ifndef CONFIG_USER_ONLY
>  extern const VMStateDescription vmstate_openrisc_cpu;
>  
> +hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +
>  /* hw/openrisc_pic.c */
>  void cpu_openrisc_pic_init(OpenRISCCPU *cpu);
>  
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 73920a9cac..f7b27aefed 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1209,12 +1209,12 @@ void ppc_cpu_do_interrupt(CPUState *cpu);
>  bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
>  void ppc_cpu_dump_statistics(CPUState *cpu, int flags);
> -hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int reg);
>  int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg);
>  #ifndef CONFIG_USER_ONLY
> +hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu);
>  const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name);
>  #endif
> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> index d0e7f5b9c5..69edee6484 100644
> --- a/target/riscv/cpu.h
> +++ b/target/riscv/cpu.h
> @@ -303,18 +303,9 @@ void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable);
>  bool riscv_cpu_force_hs_excep_enabled(CPURISCVState *env);
>  void riscv_cpu_set_force_hs_excep(CPURISCVState *env, bool enable);
>  int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch);
> -hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> -void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
> -                                    MMUAccessType access_type, int mmu_idx,
> -                                    uintptr_t retaddr);
>  bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>                          MMUAccessType access_type, int mmu_idx,
>                          bool probe, uintptr_t retaddr);
> -void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
> -                                     vaddr addr, unsigned size,
> -                                     MMUAccessType access_type,
> -                                     int mmu_idx, MemTxAttrs attrs,
> -                                     MemTxResult response, uintptr_t retaddr);
>  char *riscv_isa_string(RISCVCPU *cpu);
>  void riscv_cpu_list(void);
>  
> @@ -323,12 +314,21 @@ void riscv_cpu_list(void);
>  #define cpu_mmu_index riscv_cpu_mmu_index
>  
>  #ifndef CONFIG_USER_ONLY
> +hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
> +                                    MMUAccessType access_type, int mmu_idx,
> +                                    uintptr_t retaddr);
> +void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
> +                                     vaddr addr, unsigned size,
> +                                     MMUAccessType access_type,
> +                                     int mmu_idx, MemTxAttrs attrs,
> +                                     MemTxResult response, uintptr_t retaddr);
>  void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env);
>  int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint32_t interrupts);
>  uint32_t riscv_cpu_update_mip(RISCVCPU *cpu, uint32_t mask, uint32_t value);
>  #define BOOL_TO_MASK(x) (-!!(x)) /* helper for riscv_cpu_update_mip value */
>  void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void));
> -#endif
> +#endif /* !CONFIG_USER_ONLY */
>  void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv);
>  
>  void riscv_translate_init(void);
> diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
> index dbe58c7888..40d92413b8 100644
> --- a/target/sh4/cpu.h
> +++ b/target/sh4/cpu.h
> @@ -207,7 +207,6 @@ struct SuperHCPU {
>  void superh_cpu_do_interrupt(CPUState *cpu);
>  bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
> @@ -223,6 +222,7 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>  
>  void sh4_cpu_list(void);
>  #if !defined(CONFIG_USER_ONLY)
> +hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void cpu_sh4_invalidate_tlb(CPUSH4State *s);
>  uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,
>                                         hwaddr addr);
> diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
> index b9369398f2..31887a811a 100644
> --- a/target/sparc/cpu.h
> +++ b/target/sparc/cpu.h
> @@ -570,7 +570,9 @@ extern const VMStateDescription vmstate_sparc_cpu;
>  
>  void sparc_cpu_do_interrupt(CPUState *cpu);
>  void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> +#ifndef CONFIG_USER_ONLY
>  hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
>  int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
> diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
> index 7a46dccbe1..47fe57df87 100644
> --- a/target/xtensa/cpu.h
> +++ b/target/xtensa/cpu.h
> @@ -564,19 +564,21 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>                           bool probe, uintptr_t retaddr);
>  void xtensa_cpu_do_interrupt(CPUState *cpu);
>  bool xtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request);
> -void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
> -                                      unsigned size, MMUAccessType access_type,
> -                                      int mmu_idx, MemTxAttrs attrs,
> -                                      MemTxResult response, uintptr_t retaddr);
>  void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void xtensa_count_regs(const XtensaConfig *config,
>                         unsigned *n_regs, unsigned *n_core_regs);
>  int xtensa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> +#ifndef CONFIG_USER_ONLY
> +hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
> +                                      unsigned size, MMUAccessType access_type,
> +                                      int mmu_idx, MemTxAttrs attrs,
> +                                      MemTxResult response, uintptr_t retaddr);
>  void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>                                      MMUAccessType access_type,
>                                      int mmu_idx, uintptr_t retaddr);
> +#endif /* !CONFIG_USER_ONLY */
>  
>  #define cpu_signal_handler cpu_xtensa_signal_handler
>  #define cpu_list xtensa_cpu_list
> diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
> index 71b6aca45d..6d33288d2a 100644
> --- a/target/hppa/cpu.c
> +++ b/target/hppa/cpu.c
> @@ -70,6 +70,7 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
>      info->print_insn = print_insn_hppa;
>  }
>  
> +#ifndef CONFIG_USER_ONLY
>  static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
>                                           MMUAccessType access_type,
>                                           int mmu_idx, uintptr_t retaddr)
> @@ -86,6 +87,7 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
>  
>      cpu_loop_exit_restore(cs, retaddr);
>  }
> +#endif /* !CONFIG_USER_ONLY */
>  
>  static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
>  {
> @@ -150,8 +152,8 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)
>  #ifndef CONFIG_USER_ONLY
>      cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug;
>      dc->vmsd = &vmstate_hppa_cpu;
> -#endif
>      cc->do_unaligned_access = hppa_cpu_do_unaligned_access;
> +#endif
>      cc->disas_set_info = hppa_cpu_disas_set_info;
>      cc->tcg_initialize = hppa_translate_init;
>  
> diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
> index 4ea0cc501b..8c428e2009 100644
> --- a/target/ppc/translate_init.inc.c
> +++ b/target/ppc/translate_init.inc.c
> @@ -10892,8 +10892,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
>      cc->set_pc = ppc_cpu_set_pc;
>      cc->gdb_read_register = ppc_cpu_gdb_read_register;
>      cc->gdb_write_register = ppc_cpu_gdb_write_register;
> -    cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
>  #ifndef CONFIG_USER_ONLY
> +    cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
>      cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug;
>      cc->vmsd = &vmstate_ppc_cpu;
>  #endif

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
@ 2020-05-11  1:16     ` David Gibson
  0 siblings, 0 replies; 65+ messages in thread
From: David Gibson @ 2020-05-11  1:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Hildenbrand, Alex Bennée

[-- Attachment #1: Type: text/plain, Size: 23382 bytes --]

On Sat, May 09, 2020 at 03:09:08PM +0200, Philippe Mathieu-Daudé wrote:
> Restrict the following handlers to system-mode:
> - do_unaligned_access
> - do_transaction_failed
> - get_phys_page_debug
> - get_phys_page_attrs_debug
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

ppc parts

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  include/hw/core/cpu.h           |  8 +++++---
>  target/alpha/cpu.h              |  4 +++-
>  target/arm/cpu.h                |  6 +++---
>  target/arm/internals.h          |  4 ++++
>  target/cris/cpu.h               |  2 ++
>  target/hppa/cpu.h               |  2 +-
>  target/i386/cpu.h               |  2 ++
>  target/m68k/cpu.h               |  7 ++++++-
>  target/microblaze/cpu.h         |  5 ++++-
>  target/mips/internal.h          |  2 +-
>  target/nios2/cpu.h              |  5 ++++-
>  target/openrisc/cpu.h           |  3 ++-
>  target/ppc/cpu.h                |  2 +-
>  target/riscv/cpu.h              | 20 ++++++++++----------
>  target/sh4/cpu.h                |  2 +-
>  target/sparc/cpu.h              |  2 ++
>  target/xtensa/cpu.h             | 12 +++++++-----
>  target/hppa/cpu.c               |  4 +++-
>  target/ppc/translate_init.inc.c |  2 +-
>  19 files changed, 62 insertions(+), 32 deletions(-)
> 
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> index 5bf94d28cf..ed09d056d1 100644
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -167,6 +167,7 @@ typedef struct CPUClass {
>      int reset_dump_flags;
>      bool (*has_work)(CPUState *cpu);
>      void (*do_interrupt)(CPUState *cpu);
> +#ifndef CONFIG_USER_ONLY
>      void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
>                                  MMUAccessType access_type,
>                                  int mmu_idx, uintptr_t retaddr);
> @@ -174,6 +175,10 @@ typedef struct CPUClass {
>                                    unsigned size, MMUAccessType access_type,
>                                    int mmu_idx, MemTxAttrs attrs,
>                                    MemTxResult response, uintptr_t retaddr);
> +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> +                                        MemTxAttrs *attrs);
> +#endif /* CONFIG_USER_ONLY */
>      bool (*virtio_is_big_endian)(CPUState *cpu);
>      int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
>                             uint8_t *buf, int len, bool is_write);
> @@ -189,9 +194,6 @@ typedef struct CPUClass {
>      bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
>                       MMUAccessType access_type, int mmu_idx,
>                       bool probe, uintptr_t retaddr);
> -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> -                                        MemTxAttrs *attrs);
>      int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
>      int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
>      int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
> index be29bdd530..b12021803e 100644
> --- a/target/alpha/cpu.h
> +++ b/target/alpha/cpu.h
> @@ -279,12 +279,14 @@ extern const VMStateDescription vmstate_alpha_cpu;
>  void alpha_cpu_do_interrupt(CPUState *cpu);
>  bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);
> -hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> +#ifndef CONFIG_USER_ONLY
> +hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>                                     MMUAccessType access_type,
>                                     int mmu_idx, uintptr_t retaddr);
> +#endif
>  
>  #define cpu_list alpha_cpu_list
>  #define cpu_signal_handler cpu_alpha_signal_handler
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 8608da6b6f..d333036bb4 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -966,15 +966,15 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz);
>  
>  #ifndef CONFIG_USER_ONLY
>  extern const VMStateDescription vmstate_arm_cpu;
> +
> +hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
> +                                         MemTxAttrs *attrs);
>  #endif
>  
>  void arm_cpu_do_interrupt(CPUState *cpu);
>  void arm_v7m_cpu_do_interrupt(CPUState *cpu);
>  bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  
> -hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
> -                                         MemTxAttrs *attrs);
> -
>  int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  
> diff --git a/target/arm/internals.h b/target/arm/internals.h
> index e633aff36e..c0a2a5df71 100644
> --- a/target/arm/internals.h
> +++ b/target/arm/internals.h
> @@ -812,6 +812,8 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
>   * tables */
>  bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);
>  
> +#ifndef CONFIG_USER_ONLY
> +
>  /* Raise a data fault alignment exception for the specified virtual address */
>  void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
>                                   MMUAccessType access_type,
> @@ -827,6 +829,8 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
>                                     int mmu_idx, MemTxAttrs attrs,
>                                     MemTxResult response, uintptr_t retaddr);
>  
> +#endif /* !CONFIG_USER_ONLY */
> +
>  /* Call any registered EL change hooks */
>  static inline void arm_call_pre_el_change_hook(ARMCPU *cpu)
>  {
> diff --git a/target/cris/cpu.h b/target/cris/cpu.h
> index 8f08d7628b..e9c858ada7 100644
> --- a/target/cris/cpu.h
> +++ b/target/cris/cpu.h
> @@ -193,7 +193,9 @@ bool cris_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  
>  void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags);
>  
> +#ifndef CONFIG_USER_ONLY
>  hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
>  
>  int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int cris_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
> diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
> index 801a4fb1ba..7848425f6a 100644
> --- a/target/hppa/cpu.h
> +++ b/target/hppa/cpu.h
> @@ -320,7 +320,6 @@ void cpu_hppa_change_prot_id(CPUHPPAState *env);
>  #define cpu_signal_handler cpu_hppa_signal_handler
>  
>  int cpu_hppa_signal_handler(int host_signum, void *pinfo, void *puc);
> -hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
>  int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void hppa_cpu_do_interrupt(CPUState *cpu);
> @@ -330,6 +329,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>                         MMUAccessType access_type, int mmu_idx,
>                         bool probe, uintptr_t retaddr);
>  #ifndef CONFIG_USER_ONLY
> +hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
>  int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
>                                int type, hwaddr *pphys, int *pprot);
>  extern const MemoryRegionOps hppa_io_eir_ops;
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index e818fc712a..00e0cc0828 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1767,8 +1767,10 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
>  
>  void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags);
>  
> +#ifndef CONFIG_USER_ONLY
>  hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
>                                           MemTxAttrs *attrs);
> +#endif
>  
>  int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
> index 521ac67cdd..efc940e7ec 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -167,10 +167,13 @@ struct M68kCPU {
>  void m68k_cpu_do_interrupt(CPUState *cpu);
>  bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  
> +#ifndef CONFIG_USER_ONLY
> +hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
> +
>  void m68k_tcg_init(void);
>  void m68k_cpu_init_gdb(M68kCPU *cpu);
>  /*
> @@ -529,10 +532,12 @@ static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)
>  bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>                         MMUAccessType access_type, int mmu_idx,
>                         bool probe, uintptr_t retaddr);
> +#ifndef CONFIG_USER_ONLY
>  void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
>                                   unsigned size, MMUAccessType access_type,
>                                   int mmu_idx, MemTxAttrs attrs,
>                                   MemTxResult response, uintptr_t retaddr);
> +#endif
>  
>  typedef CPUM68KState CPUArchState;
>  typedef M68kCPU ArchCPU;
> diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
> index a31134b65c..eb57f04d3f 100644
> --- a/target/microblaze/cpu.h
> +++ b/target/microblaze/cpu.h
> @@ -318,10 +318,13 @@ struct MicroBlazeCPU {
>  void mb_cpu_do_interrupt(CPUState *cs);
>  bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
>  void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  
> +#ifndef CONFIG_USER_ONLY
> +hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
> +
>  void mb_tcg_init(void);
>  /* you can call this signal handler from your SIGBUS and SIGSEGV
>     signal handlers to inform the virtual CPU of exceptions. non zero
> diff --git a/target/mips/internal.h b/target/mips/internal.h
> index 1bf274b3ef..c38666c6f5 100644
> --- a/target/mips/internal.h
> +++ b/target/mips/internal.h
> @@ -81,7 +81,6 @@ enum CPUMIPSMSADataFormat {
>  void mips_cpu_do_interrupt(CPUState *cpu);
>  bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void mips_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int mips_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
> @@ -150,6 +149,7 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
>                                      MemTxResult response, uintptr_t retaddr);
>  hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address,
>                                    int rw);
> +hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  #endif
>  
>  #define cpu_signal_handler cpu_mips_signal_handler
> diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
> index 4dddf9c3a1..0703295133 100644
> --- a/target/nios2/cpu.h
> +++ b/target/nios2/cpu.h
> @@ -199,11 +199,14 @@ void nios2_cpu_do_interrupt(CPUState *cs);
>  int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc);
>  void dump_mmu(CPUNios2State *env);
>  void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>                                     MMUAccessType access_type,
>                                     int mmu_idx, uintptr_t retaddr);
>  
> +#ifndef CONFIG_USER_ONLY
> +hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
> +
>  qemu_irq *nios2_cpu_pic_init(Nios2CPU *cpu);
>  void nios2_check_interrupts(CPUNios2State *env);
>  
> diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
> index f37a52e153..60de8ed787 100644
> --- a/target/openrisc/cpu.h
> +++ b/target/openrisc/cpu.h
> @@ -319,7 +319,6 @@ void cpu_openrisc_list(void);
>  void openrisc_cpu_do_interrupt(CPUState *cpu);
>  bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void openrisc_translate_init(void);
> @@ -335,6 +334,8 @@ int print_insn_or1k(bfd_vma addr, disassemble_info *info);
>  #ifndef CONFIG_USER_ONLY
>  extern const VMStateDescription vmstate_openrisc_cpu;
>  
> +hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +
>  /* hw/openrisc_pic.c */
>  void cpu_openrisc_pic_init(OpenRISCCPU *cpu);
>  
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 73920a9cac..f7b27aefed 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1209,12 +1209,12 @@ void ppc_cpu_do_interrupt(CPUState *cpu);
>  bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
>  void ppc_cpu_dump_statistics(CPUState *cpu, int flags);
> -hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int reg);
>  int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg);
>  #ifndef CONFIG_USER_ONLY
> +hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu);
>  const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name);
>  #endif
> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> index d0e7f5b9c5..69edee6484 100644
> --- a/target/riscv/cpu.h
> +++ b/target/riscv/cpu.h
> @@ -303,18 +303,9 @@ void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable);
>  bool riscv_cpu_force_hs_excep_enabled(CPURISCVState *env);
>  void riscv_cpu_set_force_hs_excep(CPURISCVState *env, bool enable);
>  int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch);
> -hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> -void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
> -                                    MMUAccessType access_type, int mmu_idx,
> -                                    uintptr_t retaddr);
>  bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>                          MMUAccessType access_type, int mmu_idx,
>                          bool probe, uintptr_t retaddr);
> -void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
> -                                     vaddr addr, unsigned size,
> -                                     MMUAccessType access_type,
> -                                     int mmu_idx, MemTxAttrs attrs,
> -                                     MemTxResult response, uintptr_t retaddr);
>  char *riscv_isa_string(RISCVCPU *cpu);
>  void riscv_cpu_list(void);
>  
> @@ -323,12 +314,21 @@ void riscv_cpu_list(void);
>  #define cpu_mmu_index riscv_cpu_mmu_index
>  
>  #ifndef CONFIG_USER_ONLY
> +hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
> +                                    MMUAccessType access_type, int mmu_idx,
> +                                    uintptr_t retaddr);
> +void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
> +                                     vaddr addr, unsigned size,
> +                                     MMUAccessType access_type,
> +                                     int mmu_idx, MemTxAttrs attrs,
> +                                     MemTxResult response, uintptr_t retaddr);
>  void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env);
>  int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint32_t interrupts);
>  uint32_t riscv_cpu_update_mip(RISCVCPU *cpu, uint32_t mask, uint32_t value);
>  #define BOOL_TO_MASK(x) (-!!(x)) /* helper for riscv_cpu_update_mip value */
>  void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void));
> -#endif
> +#endif /* !CONFIG_USER_ONLY */
>  void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv);
>  
>  void riscv_translate_init(void);
> diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
> index dbe58c7888..40d92413b8 100644
> --- a/target/sh4/cpu.h
> +++ b/target/sh4/cpu.h
> @@ -207,7 +207,6 @@ struct SuperHCPU {
>  void superh_cpu_do_interrupt(CPUState *cpu);
>  bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
> @@ -223,6 +222,7 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>  
>  void sh4_cpu_list(void);
>  #if !defined(CONFIG_USER_ONLY)
> +hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void cpu_sh4_invalidate_tlb(CPUSH4State *s);
>  uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,
>                                         hwaddr addr);
> diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
> index b9369398f2..31887a811a 100644
> --- a/target/sparc/cpu.h
> +++ b/target/sparc/cpu.h
> @@ -570,7 +570,9 @@ extern const VMStateDescription vmstate_sparc_cpu;
>  
>  void sparc_cpu_do_interrupt(CPUState *cpu);
>  void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> +#ifndef CONFIG_USER_ONLY
>  hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +#endif
>  int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
>  void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
> diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
> index 7a46dccbe1..47fe57df87 100644
> --- a/target/xtensa/cpu.h
> +++ b/target/xtensa/cpu.h
> @@ -564,19 +564,21 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
>                           bool probe, uintptr_t retaddr);
>  void xtensa_cpu_do_interrupt(CPUState *cpu);
>  bool xtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request);
> -void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
> -                                      unsigned size, MMUAccessType access_type,
> -                                      int mmu_idx, MemTxAttrs attrs,
> -                                      MemTxResult response, uintptr_t retaddr);
>  void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void xtensa_count_regs(const XtensaConfig *config,
>                         unsigned *n_regs, unsigned *n_core_regs);
>  int xtensa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
>  int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> +#ifndef CONFIG_USER_ONLY
> +hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
> +                                      unsigned size, MMUAccessType access_type,
> +                                      int mmu_idx, MemTxAttrs attrs,
> +                                      MemTxResult response, uintptr_t retaddr);
>  void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>                                      MMUAccessType access_type,
>                                      int mmu_idx, uintptr_t retaddr);
> +#endif /* !CONFIG_USER_ONLY */
>  
>  #define cpu_signal_handler cpu_xtensa_signal_handler
>  #define cpu_list xtensa_cpu_list
> diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
> index 71b6aca45d..6d33288d2a 100644
> --- a/target/hppa/cpu.c
> +++ b/target/hppa/cpu.c
> @@ -70,6 +70,7 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
>      info->print_insn = print_insn_hppa;
>  }
>  
> +#ifndef CONFIG_USER_ONLY
>  static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
>                                           MMUAccessType access_type,
>                                           int mmu_idx, uintptr_t retaddr)
> @@ -86,6 +87,7 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
>  
>      cpu_loop_exit_restore(cs, retaddr);
>  }
> +#endif /* !CONFIG_USER_ONLY */
>  
>  static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
>  {
> @@ -150,8 +152,8 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)
>  #ifndef CONFIG_USER_ONLY
>      cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug;
>      dc->vmsd = &vmstate_hppa_cpu;
> -#endif
>      cc->do_unaligned_access = hppa_cpu_do_unaligned_access;
> +#endif
>      cc->disas_set_info = hppa_cpu_disas_set_info;
>      cc->tcg_initialize = hppa_translate_init;
>  
> diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
> index 4ea0cc501b..8c428e2009 100644
> --- a/target/ppc/translate_init.inc.c
> +++ b/target/ppc/translate_init.inc.c
> @@ -10892,8 +10892,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
>      cc->set_pc = ppc_cpu_set_pc;
>      cc->gdb_read_register = ppc_cpu_gdb_read_register;
>      cc->gdb_write_register = ppc_cpu_gdb_write_register;
> -    cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
>  #ifndef CONFIG_USER_ONLY
> +    cc->do_unaligned_access = ppc_cpu_do_unaligned_access;
>      cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug;
>      cc->vmsd = &vmstate_ppc_cpu;
>  #endif

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 07/11] target/s390x/helper: Clean ifdef'ry
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11  9:43     ` David Hildenbrand
  -1 siblings, 0 replies; 65+ messages in thread
From: David Hildenbrand @ 2020-05-11  9:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, Mark Cave-Ayland,
	Max Filippov, Alistair Francis, Edgar E. Iglesias, Marek Vasut,
	Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On 09.05.20 15:09, Philippe Mathieu-Daudé wrote:
> All this code is guarded checking CONFIG_USER_ONLY definition.
> Drop the duplicated checks.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> Suspicious ifdef'ry in s390_handle_wait() from commit 83f7f32901c.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



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

* Re: [PATCH 07/11] target/s390x/helper: Clean ifdef'ry
@ 2020-05-11  9:43     ` David Hildenbrand
  0 siblings, 0 replies; 65+ messages in thread
From: David Hildenbrand @ 2020-05-11  9:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Cornelia Huck, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, Alex Bennée

On 09.05.20 15:09, Philippe Mathieu-Daudé wrote:
> All this code is guarded checking CONFIG_USER_ONLY definition.
> Drop the duplicated checks.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> Suspicious ifdef'ry in s390_handle_wait() from commit 83f7f32901c.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



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

* Re: [PATCH 03/11] sysemu/tcg: Only declare tcg_allowed when TCG is available
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11  9:46     ` Edgar E. Iglesias
  -1 siblings, 0 replies; 65+ messages in thread
From: Edgar E. Iglesias @ 2020-05-11  9:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Marek Vasut, Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo,
	David Gibson, Artyom Tarasenko, Eduardo Habkost, qemu-s390x,
	qemu-arm, Stafford Horne, Alex Bennée, Richard Henderson,
	qemu-riscv, Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat, May 09, 2020 at 03:09:02PM +0200, Philippe Mathieu-Daudé wrote:
> When TCG is not available, the tcg_allowed variable does not exist.

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>



> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/tcg.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h
> index 7d116d2e80..d9d3ca8559 100644
> --- a/include/sysemu/tcg.h
> +++ b/include/sysemu/tcg.h
> @@ -8,9 +8,9 @@
>  #ifndef SYSEMU_TCG_H
>  #define SYSEMU_TCG_H
>  
> -extern bool tcg_allowed;
>  void tcg_exec_init(unsigned long tb_size);
>  #ifdef CONFIG_TCG
> +extern bool tcg_allowed;
>  #define tcg_enabled() (tcg_allowed)
>  #else
>  #define tcg_enabled() 0
> -- 
> 2.21.3
> 


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

* Re: [PATCH 03/11] sysemu/tcg: Only declare tcg_allowed when TCG is available
@ 2020-05-11  9:46     ` Edgar E. Iglesias
  0 siblings, 0 replies; 65+ messages in thread
From: Edgar E. Iglesias @ 2020-05-11  9:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Palmer Dabbelt, Marcel Apfelbaum, Stafford Horne, Cornelia Huck,
	Roman Bolshakov, Sagar Karandikar, Eduardo Habkost, qemu-s390x,
	Aleksandar Rikalo, Marek Vasut, Alistair Francis,
	Artyom Tarasenko, Peter Maydell, qemu-riscv, Aurelien Jarno,
	Bastian Koppelmann, qemu-ppc, qemu-arm, Aleksandar Markovic,
	Paolo Bonzini, Chris Wulff, Richard Henderson, David Gibson,
	David Hildenbrand, Alex Bennée

On Sat, May 09, 2020 at 03:09:02PM +0200, Philippe Mathieu-Daudé wrote:
> When TCG is not available, the tcg_allowed variable does not exist.

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>



> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/tcg.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h
> index 7d116d2e80..d9d3ca8559 100644
> --- a/include/sysemu/tcg.h
> +++ b/include/sysemu/tcg.h
> @@ -8,9 +8,9 @@
>  #ifndef SYSEMU_TCG_H
>  #define SYSEMU_TCG_H
>  
> -extern bool tcg_allowed;
>  void tcg_exec_init(unsigned long tb_size);
>  #ifdef CONFIG_TCG
> +extern bool tcg_allowed;
>  #define tcg_enabled() (tcg_allowed)
>  #else
>  #define tcg_enabled() 0
> -- 
> 2.21.3
> 


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

* Re: [PATCH 04/11] sysemu/hvf: Only declare hvf_allowed when HVF is available
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11  9:47     ` Edgar E. Iglesias
  -1 siblings, 0 replies; 65+ messages in thread
From: Edgar E. Iglesias @ 2020-05-11  9:47 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Marek Vasut, Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo,
	David Gibson, Artyom Tarasenko, Eduardo Habkost, qemu-s390x,
	qemu-arm, Stafford Horne, Alex Bennée, Richard Henderson,
	qemu-riscv, Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat, May 09, 2020 at 03:09:03PM +0200, Philippe Mathieu-Daudé wrote:
> When HVF is not available, the tcg_allowed variable does not exist.

Typo in commit message tcg_allowed -> hvf_allowed.

With that fixed:
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/hvf.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
> index d211e808e9..fe95743124 100644
> --- a/include/sysemu/hvf.h
> +++ b/include/sysemu/hvf.h
> @@ -18,7 +18,6 @@
>  #include "exec/memory.h"
>  #include "sysemu/accel.h"
>  
> -extern bool hvf_allowed;
>  #ifdef CONFIG_HVF
>  #include <Hypervisor/hv.h>
>  #include <Hypervisor/hv_vmx.h>
> @@ -26,11 +25,12 @@ extern bool hvf_allowed;
>  #include "target/i386/cpu.h"
>  uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
>                                   int reg);
> +extern bool hvf_allowed;
>  #define hvf_enabled() (hvf_allowed)
> -#else
> +#else /* !CONFIG_HVF */
>  #define hvf_enabled() 0
>  #define hvf_get_supported_cpuid(func, idx, reg) 0
> -#endif
> +#endif /* !CONFIG_HVF */
>  
>  /* hvf_slot flags */
>  #define HVF_SLOT_LOG (1 << 0)
> -- 
> 2.21.3
> 


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

* Re: [PATCH 04/11] sysemu/hvf: Only declare hvf_allowed when HVF is available
@ 2020-05-11  9:47     ` Edgar E. Iglesias
  0 siblings, 0 replies; 65+ messages in thread
From: Edgar E. Iglesias @ 2020-05-11  9:47 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Palmer Dabbelt, Marcel Apfelbaum, Stafford Horne, Cornelia Huck,
	Roman Bolshakov, Sagar Karandikar, Eduardo Habkost, qemu-s390x,
	Aleksandar Rikalo, Marek Vasut, Alistair Francis,
	Artyom Tarasenko, Peter Maydell, qemu-riscv, Aurelien Jarno,
	Bastian Koppelmann, qemu-ppc, qemu-arm, Aleksandar Markovic,
	Paolo Bonzini, Chris Wulff, Richard Henderson, David Gibson,
	David Hildenbrand, Alex Bennée

On Sat, May 09, 2020 at 03:09:03PM +0200, Philippe Mathieu-Daudé wrote:
> When HVF is not available, the tcg_allowed variable does not exist.

Typo in commit message tcg_allowed -> hvf_allowed.

With that fixed:
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/hvf.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
> index d211e808e9..fe95743124 100644
> --- a/include/sysemu/hvf.h
> +++ b/include/sysemu/hvf.h
> @@ -18,7 +18,6 @@
>  #include "exec/memory.h"
>  #include "sysemu/accel.h"
>  
> -extern bool hvf_allowed;
>  #ifdef CONFIG_HVF
>  #include <Hypervisor/hv.h>
>  #include <Hypervisor/hv_vmx.h>
> @@ -26,11 +25,12 @@ extern bool hvf_allowed;
>  #include "target/i386/cpu.h"
>  uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
>                                   int reg);
> +extern bool hvf_allowed;
>  #define hvf_enabled() (hvf_allowed)
> -#else
> +#else /* !CONFIG_HVF */
>  #define hvf_enabled() 0
>  #define hvf_get_supported_cpuid(func, idx, reg) 0
> -#endif
> +#endif /* !CONFIG_HVF */
>  
>  /* hvf_slot flags */
>  #define HVF_SLOT_LOG (1 << 0)
> -- 
> 2.21.3
> 


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

* Re: [PATCH 02/11] sysemu/accel: Restrict machine methods to system-mode
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11  9:54     ` Edgar E. Iglesias
  -1 siblings, 0 replies; 65+ messages in thread
From: Edgar E. Iglesias @ 2020-05-11  9:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Chris Wulff, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Marek Vasut, Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo,
	David Gibson, Artyom Tarasenko, Eduardo Habkost, qemu-s390x,
	qemu-arm, Stafford Horne, Alex Bennée, Richard Henderson,
	qemu-riscv, Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat, May 09, 2020 at 03:09:01PM +0200, Philippe Mathieu-Daudé wrote:
> Restrict init_machine(), setup_post() and has_memory()
> to system-mode.

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/accel.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
> index 47e5788530..e08b8ab8fa 100644
> --- a/include/sysemu/accel.h
> +++ b/include/sysemu/accel.h
> @@ -37,10 +37,12 @@ typedef struct AccelClass {
>      /*< public >*/
>  
>      const char *name;
> +#ifndef CONFIG_USER_ONLY
>      int (*init_machine)(MachineState *ms);
>      void (*setup_post)(MachineState *ms, AccelState *accel);
>      bool (*has_memory)(MachineState *ms, AddressSpace *as,
>                         hwaddr start_addr, hwaddr size);
> +#endif
>      bool *allowed;
>      /*
>       * Array of global properties that would be applied when specific
> -- 
> 2.21.3
> 


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

* Re: [PATCH 02/11] sysemu/accel: Restrict machine methods to system-mode
@ 2020-05-11  9:54     ` Edgar E. Iglesias
  0 siblings, 0 replies; 65+ messages in thread
From: Edgar E. Iglesias @ 2020-05-11  9:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Palmer Dabbelt, Marcel Apfelbaum, Stafford Horne, Cornelia Huck,
	Roman Bolshakov, Sagar Karandikar, Eduardo Habkost, qemu-s390x,
	Aleksandar Rikalo, Marek Vasut, Alistair Francis,
	Artyom Tarasenko, Peter Maydell, qemu-riscv, Aurelien Jarno,
	Bastian Koppelmann, qemu-ppc, qemu-arm, Aleksandar Markovic,
	Paolo Bonzini, Chris Wulff, Richard Henderson, David Gibson,
	David Hildenbrand, Alex Bennée

On Sat, May 09, 2020 at 03:09:01PM +0200, Philippe Mathieu-Daudé wrote:
> Restrict init_machine(), setup_post() and has_memory()
> to system-mode.

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/accel.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
> index 47e5788530..e08b8ab8fa 100644
> --- a/include/sysemu/accel.h
> +++ b/include/sysemu/accel.h
> @@ -37,10 +37,12 @@ typedef struct AccelClass {
>      /*< public >*/
>  
>      const char *name;
> +#ifndef CONFIG_USER_ONLY
>      int (*init_machine)(MachineState *ms);
>      void (*setup_post)(MachineState *ms, AccelState *accel);
>      bool (*has_memory)(MachineState *ms, AddressSpace *as,
>                         hwaddr start_addr, hwaddr size);
> +#endif
>      bool *allowed;
>      /*
>       * Array of global properties that would be applied when specific
> -- 
> 2.21.3
> 


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

* Re: [PATCH 02/11] sysemu/accel: Restrict machine methods to system-mode
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11 10:17     ` Cornelia Huck
  -1 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, Laurent Vivier,
	Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat,  9 May 2020 15:09:01 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> Restrict init_machine(), setup_post() and has_memory()
> to system-mode.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/accel.h | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 02/11] sysemu/accel: Restrict machine methods to system-mode
@ 2020-05-11 10:17     ` Cornelia Huck
  0 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée

On Sat,  9 May 2020 15:09:01 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> Restrict init_machine(), setup_post() and has_memory()
> to system-mode.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/accel.h | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 03/11] sysemu/tcg: Only declare tcg_allowed when TCG is available
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11 10:20     ` Cornelia Huck
  -1 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, Laurent Vivier,
	Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat,  9 May 2020 15:09:02 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> When TCG is not available, the tcg_allowed variable does not exist.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/tcg.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 03/11] sysemu/tcg: Only declare tcg_allowed when TCG is available
@ 2020-05-11 10:20     ` Cornelia Huck
  0 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée

On Sat,  9 May 2020 15:09:02 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> When TCG is not available, the tcg_allowed variable does not exist.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/tcg.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 04/11] sysemu/hvf: Only declare hvf_allowed when HVF is available
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11 10:22     ` Cornelia Huck
  -1 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, Laurent Vivier,
	Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat,  9 May 2020 15:09:03 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> When HVF is not available, the tcg_allowed variable does not exist.

s/tcg_allowed/hvf_allowed/

> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/hvf.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 04/11] sysemu/hvf: Only declare hvf_allowed when HVF is available
@ 2020-05-11 10:22     ` Cornelia Huck
  0 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée

On Sat,  9 May 2020 15:09:03 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> When HVF is not available, the tcg_allowed variable does not exist.

s/tcg_allowed/hvf_allowed/

> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/sysemu/hvf.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 06/11] target/s390x: Only compile decode_basedisp() on system-mode
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11 10:39     ` Cornelia Huck
  -1 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, Laurent Vivier,
	Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat,  9 May 2020 15:09:05 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> The decode_basedisp*() methods are only used in ioinst.c,
> which is only build in system-mode emulation.

I/O instructions are privileged, and other S instructions are decoded
elsewhere.

> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/s390x/internal.h | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 06/11] target/s390x: Only compile decode_basedisp() on system-mode
@ 2020-05-11 10:39     ` Cornelia Huck
  0 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée

On Sat,  9 May 2020 15:09:05 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> The decode_basedisp*() methods are only used in ioinst.c,
> which is only build in system-mode emulation.

I/O instructions are privileged, and other S instructions are decoded
elsewhere.

> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/s390x/internal.h | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 07/11] target/s390x/helper: Clean ifdef'ry
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11 10:44     ` Cornelia Huck
  -1 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, Laurent Vivier,
	Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat,  9 May 2020 15:09:06 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> All this code is guarded checking CONFIG_USER_ONLY definition.
> Drop the duplicated checks.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> Suspicious ifdef'ry in s390_handle_wait() from commit 83f7f32901c.
> ---
>  target/s390x/helper.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/target/s390x/helper.c b/target/s390x/helper.c
> index 09f60406aa..26e3b366e8 100644
> --- a/target/s390x/helper.c
> +++ b/target/s390x/helper.c
> @@ -33,6 +33,7 @@
>  #endif
>  
>  #ifndef CONFIG_USER_ONLY
> +

I'd probably not have added the whitespace here...

>  void s390x_tod_timer(void *opaque)
>  {
>      cpu_inject_clock_comparator((S390CPU *) opaque);

(...)

> @@ -328,6 +324,7 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len)
>      cpu_physical_memory_unmap(sa, len, 1, len);
>      return 0;
>  }
> +

...and here, but I don't feel strongly about it.

>  #endif /* CONFIG_USER_ONLY */
>  
>  void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 07/11] target/s390x/helper: Clean ifdef'ry
@ 2020-05-11 10:44     ` Cornelia Huck
  0 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée

On Sat,  9 May 2020 15:09:06 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> All this code is guarded checking CONFIG_USER_ONLY definition.
> Drop the duplicated checks.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> Suspicious ifdef'ry in s390_handle_wait() from commit 83f7f32901c.
> ---
>  target/s390x/helper.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/target/s390x/helper.c b/target/s390x/helper.c
> index 09f60406aa..26e3b366e8 100644
> --- a/target/s390x/helper.c
> +++ b/target/s390x/helper.c
> @@ -33,6 +33,7 @@
>  #endif
>  
>  #ifndef CONFIG_USER_ONLY
> +

I'd probably not have added the whitespace here...

>  void s390x_tod_timer(void *opaque)
>  {
>      cpu_inject_clock_comparator((S390CPU *) opaque);

(...)

> @@ -328,6 +324,7 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len)
>      cpu_physical_memory_unmap(sa, len, 1, len);
>      return 0;
>  }
> +

...and here, but I don't feel strongly about it.

>  #endif /* CONFIG_USER_ONLY */
>  
>  void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
@ 2020-05-11 10:48     ` Cornelia Huck
  -1 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Edgar E. Iglesias, Marek Vasut, Aleksandar Markovic, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Alex Bennée, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, Laurent Vivier,
	Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On Sat,  9 May 2020 15:09:07 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> As these declarations are restricted to !CONFIG_USER_ONLY in
> helper.c, only declare them when system-mode emulation is used.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/s390x/internal.h | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
> index c1678dc6bc..ddc276cdf4 100644
> --- a/target/s390x/internal.h
> +++ b/target/s390x/internal.h
> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
>  
>  /* cc_helper.c */
>  const char *cc_name(enum cc_op cc_op);
> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>  uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
>                   uint64_t vr);
>  
> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
>  
>  /* helper.c */
>  void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
> +void do_restart_interrupt(CPUS390XState *env);
> +
> +#ifndef CONFIG_USER_ONLY
> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);

load_psw() is in cc_helper.c (and not in helper.c). Rather add the
#ifndef above, even if it is a bit awkward? Otherwise, the wrong
comment makes it confusing.

>  uint64_t get_psw_mask(CPUS390XState *env);
>  void s390_cpu_recompute_watchpoints(CPUState *cs);
>  void s390x_tod_timer(void *opaque);
>  void s390x_cpu_timer(void *opaque);
> -void do_restart_interrupt(CPUS390XState *env);
>  void s390_handle_wait(S390CPU *cpu);
> +hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>  #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
>  int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
>  int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
> -#ifndef CONFIG_USER_ONLY
>  LowCore *cpu_map_lowcore(CPUS390XState *env);
>  void cpu_unmap_lowcore(LowCore *lowcore);
>  #endif /* CONFIG_USER_ONLY */



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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
@ 2020-05-11 10:48     ` Cornelia Huck
  0 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-11 10:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland, Max Filippov,
	Edgar E. Iglesias, Palmer Dabbelt, Marcel Apfelbaum,
	Stafford Horne, Roman Bolshakov, Sagar Karandikar,
	Eduardo Habkost, qemu-s390x, Aleksandar Rikalo, Marek Vasut,
	Alistair Francis, Artyom Tarasenko, Peter Maydell, qemu-riscv,
	Aurelien Jarno, Bastian Koppelmann, qemu-ppc, qemu-arm,
	Aleksandar Markovic, Paolo Bonzini, Chris Wulff,
	Richard Henderson, David Gibson, David Hildenbrand,
	Alex Bennée

On Sat,  9 May 2020 15:09:07 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> As these declarations are restricted to !CONFIG_USER_ONLY in
> helper.c, only declare them when system-mode emulation is used.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/s390x/internal.h | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
> index c1678dc6bc..ddc276cdf4 100644
> --- a/target/s390x/internal.h
> +++ b/target/s390x/internal.h
> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
>  
>  /* cc_helper.c */
>  const char *cc_name(enum cc_op cc_op);
> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>  uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
>                   uint64_t vr);
>  
> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
>  
>  /* helper.c */
>  void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
> +void do_restart_interrupt(CPUS390XState *env);
> +
> +#ifndef CONFIG_USER_ONLY
> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);

load_psw() is in cc_helper.c (and not in helper.c). Rather add the
#ifndef above, even if it is a bit awkward? Otherwise, the wrong
comment makes it confusing.

>  uint64_t get_psw_mask(CPUS390XState *env);
>  void s390_cpu_recompute_watchpoints(CPUState *cs);
>  void s390x_tod_timer(void *opaque);
>  void s390x_cpu_timer(void *opaque);
> -void do_restart_interrupt(CPUS390XState *env);
>  void s390_handle_wait(S390CPU *cpu);
> +hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> +hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>  #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
>  int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
>  int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
> -#ifndef CONFIG_USER_ONLY
>  LowCore *cpu_map_lowcore(CPUS390XState *env);
>  void cpu_unmap_lowcore(LowCore *lowcore);
>  #endif /* CONFIG_USER_ONLY */



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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
  2020-05-11 10:48     ` Cornelia Huck
@ 2020-05-11 12:21       ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-11 12:21 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Laurent Vivier, Max Filippov,
	Alistair Francis, Marek Vasut, Aleksandar Markovic,
	Palmer Dabbelt, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

On 5/11/20 12:48 PM, Cornelia Huck wrote:
> On Sat,  9 May 2020 15:09:07 +0200
> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> 
>> As these declarations are restricted to !CONFIG_USER_ONLY in
>> helper.c, only declare them when system-mode emulation is used.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>   target/s390x/internal.h | 11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
>> index c1678dc6bc..ddc276cdf4 100644
>> --- a/target/s390x/internal.h
>> +++ b/target/s390x/internal.h
>> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
>>   
>>   /* cc_helper.c */
>>   const char *cc_name(enum cc_op cc_op);
>> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>   uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
>>                    uint64_t vr);
>>   
>> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
>>   
>>   /* helper.c */
>>   void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
>> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>> +void do_restart_interrupt(CPUS390XState *env);
>> +
>> +#ifndef CONFIG_USER_ONLY
>> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
> 
> load_psw() is in cc_helper.c (and not in helper.c). Rather add the
> #ifndef above, even if it is a bit awkward? Otherwise, the wrong
> comment makes it confusing.

I've been tempted to remove the kinda outdated /* helper.c */ comment...

> 
>>   uint64_t get_psw_mask(CPUS390XState *env);
>>   void s390_cpu_recompute_watchpoints(CPUState *cs);
>>   void s390x_tod_timer(void *opaque);
>>   void s390x_cpu_timer(void *opaque);
>> -void do_restart_interrupt(CPUS390XState *env);
>>   void s390_handle_wait(S390CPU *cpu);
>> +hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>> +hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>>   #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
>>   int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
>>   int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
>> -#ifndef CONFIG_USER_ONLY
>>   LowCore *cpu_map_lowcore(CPUS390XState *env);
>>   void cpu_unmap_lowcore(LowCore *lowcore);
>>   #endif /* CONFIG_USER_ONLY */
> 
> 


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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
@ 2020-05-11 12:21       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-11 12:21 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Marek Vasut, Aleksandar Markovic, Marcel Apfelbaum, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Richard Henderson, qemu-riscv, Bastian Koppelmann, Chris Wulff,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Paolo Bonzini,
	Aurelien Jarno

On 5/11/20 12:48 PM, Cornelia Huck wrote:
> On Sat,  9 May 2020 15:09:07 +0200
> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> 
>> As these declarations are restricted to !CONFIG_USER_ONLY in
>> helper.c, only declare them when system-mode emulation is used.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>   target/s390x/internal.h | 11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
>> index c1678dc6bc..ddc276cdf4 100644
>> --- a/target/s390x/internal.h
>> +++ b/target/s390x/internal.h
>> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
>>   
>>   /* cc_helper.c */
>>   const char *cc_name(enum cc_op cc_op);
>> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>   uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
>>                    uint64_t vr);
>>   
>> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
>>   
>>   /* helper.c */
>>   void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
>> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>> +void do_restart_interrupt(CPUS390XState *env);
>> +
>> +#ifndef CONFIG_USER_ONLY
>> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
> 
> load_psw() is in cc_helper.c (and not in helper.c). Rather add the
> #ifndef above, even if it is a bit awkward? Otherwise, the wrong
> comment makes it confusing.

I've been tempted to remove the kinda outdated /* helper.c */ comment...

> 
>>   uint64_t get_psw_mask(CPUS390XState *env);
>>   void s390_cpu_recompute_watchpoints(CPUState *cs);
>>   void s390x_tod_timer(void *opaque);
>>   void s390x_cpu_timer(void *opaque);
>> -void do_restart_interrupt(CPUS390XState *env);
>>   void s390_handle_wait(S390CPU *cpu);
>> +hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>> +hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>>   #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
>>   int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
>>   int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
>> -#ifndef CONFIG_USER_ONLY
>>   LowCore *cpu_map_lowcore(CPUS390XState *env);
>>   void cpu_unmap_lowcore(LowCore *lowcore);
>>   #endif /* CONFIG_USER_ONLY */
> 
> 


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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
  2020-05-11 12:21       ` Philippe Mathieu-Daudé
@ 2020-05-12  6:01         ` Cornelia Huck
  -1 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-12  6:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Laurent Vivier, Max Filippov,
	Alistair Francis, Marek Vasut, Aleksandar Markovic,
	Palmer Dabbelt, Aleksandar Rikalo, David Gibson,
	Artyom Tarasenko, Eduardo Habkost, qemu-s390x, qemu-arm,
	Stafford Horne, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

On Mon, 11 May 2020 14:21:27 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> On 5/11/20 12:48 PM, Cornelia Huck wrote:
> > On Sat,  9 May 2020 15:09:07 +0200
> > Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> >   
> >> As these declarations are restricted to !CONFIG_USER_ONLY in
> >> helper.c, only declare them when system-mode emulation is used.
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> >> ---
> >>   target/s390x/internal.h | 11 ++++++-----
> >>   1 file changed, 6 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
> >> index c1678dc6bc..ddc276cdf4 100644
> >> --- a/target/s390x/internal.h
> >> +++ b/target/s390x/internal.h
> >> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
> >>   
> >>   /* cc_helper.c */
> >>   const char *cc_name(enum cc_op cc_op);
> >> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
> >>   uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
> >>                    uint64_t vr);
> >>   
> >> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
> >>   
> >>   /* helper.c */
> >>   void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> >> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> >> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
> >> +void do_restart_interrupt(CPUS390XState *env);
> >> +
> >> +#ifndef CONFIG_USER_ONLY
> >> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);  
> > 
> > load_psw() is in cc_helper.c (and not in helper.c). Rather add the
> > #ifndef above, even if it is a bit awkward? Otherwise, the wrong
> > comment makes it confusing.  
> 
> I've been tempted to remove the kinda outdated /* helper.c */ comment...

I don't think they're really outdated, but not sure how useful they are
to people. I'm not personally attached to them, other opinions?

> 
> >   
> >>   uint64_t get_psw_mask(CPUS390XState *env);
> >>   void s390_cpu_recompute_watchpoints(CPUState *cs);
> >>   void s390x_tod_timer(void *opaque);
> >>   void s390x_cpu_timer(void *opaque);
> >> -void do_restart_interrupt(CPUS390XState *env);
> >>   void s390_handle_wait(S390CPU *cpu);
> >> +hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> >> +hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
> >>   #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
> >>   int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
> >>   int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
> >> -#ifndef CONFIG_USER_ONLY
> >>   LowCore *cpu_map_lowcore(CPUS390XState *env);
> >>   void cpu_unmap_lowcore(LowCore *lowcore);
> >>   #endif /* CONFIG_USER_ONLY */  
> > 
> >   
> 



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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
@ 2020-05-12  6:01         ` Cornelia Huck
  0 siblings, 0 replies; 65+ messages in thread
From: Cornelia Huck @ 2020-05-12  6:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Marek Vasut, Aleksandar Markovic, Marcel Apfelbaum, qemu-ppc,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Richard Henderson, qemu-riscv, Bastian Koppelmann, Chris Wulff,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Paolo Bonzini,
	Aurelien Jarno

On Mon, 11 May 2020 14:21:27 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> On 5/11/20 12:48 PM, Cornelia Huck wrote:
> > On Sat,  9 May 2020 15:09:07 +0200
> > Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> >   
> >> As these declarations are restricted to !CONFIG_USER_ONLY in
> >> helper.c, only declare them when system-mode emulation is used.
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> >> ---
> >>   target/s390x/internal.h | 11 ++++++-----
> >>   1 file changed, 6 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
> >> index c1678dc6bc..ddc276cdf4 100644
> >> --- a/target/s390x/internal.h
> >> +++ b/target/s390x/internal.h
> >> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
> >>   
> >>   /* cc_helper.c */
> >>   const char *cc_name(enum cc_op cc_op);
> >> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
> >>   uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
> >>                    uint64_t vr);
> >>   
> >> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
> >>   
> >>   /* helper.c */
> >>   void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> >> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> >> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
> >> +void do_restart_interrupt(CPUS390XState *env);
> >> +
> >> +#ifndef CONFIG_USER_ONLY
> >> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);  
> > 
> > load_psw() is in cc_helper.c (and not in helper.c). Rather add the
> > #ifndef above, even if it is a bit awkward? Otherwise, the wrong
> > comment makes it confusing.  
> 
> I've been tempted to remove the kinda outdated /* helper.c */ comment...

I don't think they're really outdated, but not sure how useful they are
to people. I'm not personally attached to them, other opinions?

> 
> >   
> >>   uint64_t get_psw_mask(CPUS390XState *env);
> >>   void s390_cpu_recompute_watchpoints(CPUState *cs);
> >>   void s390x_tod_timer(void *opaque);
> >>   void s390x_cpu_timer(void *opaque);
> >> -void do_restart_interrupt(CPUS390XState *env);
> >>   void s390_handle_wait(S390CPU *cpu);
> >> +hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> >> +hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
> >>   #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
> >>   int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
> >>   int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
> >> -#ifndef CONFIG_USER_ONLY
> >>   LowCore *cpu_map_lowcore(CPUS390XState *env);
> >>   void cpu_unmap_lowcore(LowCore *lowcore);
> >>   #endif /* CONFIG_USER_ONLY */  
> > 
> >   
> 



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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
  2020-05-12  6:01         ` Cornelia Huck
@ 2020-05-12  6:46           ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12  6:46 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Alistair Francis,
	Marek Vasut, Aleksandar Markovic, qemu-ppc, Aleksandar Rikalo,
	David Gibson, Artyom Tarasenko, Eduardo Habkost, qemu-s390x,
	qemu-arm, Stafford Horne, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, Laurent Vivier,
	Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On 5/12/20 8:01 AM, Cornelia Huck wrote:
> On Mon, 11 May 2020 14:21:27 +0200
> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> 
>> On 5/11/20 12:48 PM, Cornelia Huck wrote:
>>> On Sat,  9 May 2020 15:09:07 +0200
>>> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>>    
>>>> As these declarations are restricted to !CONFIG_USER_ONLY in
>>>> helper.c, only declare them when system-mode emulation is used.
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>> ---
>>>>    target/s390x/internal.h | 11 ++++++-----
>>>>    1 file changed, 6 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
>>>> index c1678dc6bc..ddc276cdf4 100644
>>>> --- a/target/s390x/internal.h
>>>> +++ b/target/s390x/internal.h
>>>> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
>>>>    
>>>>    /* cc_helper.c */
>>>>    const char *cc_name(enum cc_op cc_op);
>>>> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>>>    uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
>>>>                     uint64_t vr);
>>>>    
>>>> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
>>>>    
>>>>    /* helper.c */
>>>>    void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
>>>> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>>>> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>>>> +void do_restart_interrupt(CPUS390XState *env);
>>>> +
>>>> +#ifndef CONFIG_USER_ONLY
>>>> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>>
>>> load_psw() is in cc_helper.c (and not in helper.c). Rather add the
>>> #ifndef above, even if it is a bit awkward? Otherwise, the wrong
>>> comment makes it confusing.
>>
>> I've been tempted to remove the kinda outdated /* helper.c */ comment...
> 
> I don't think they're really outdated, but not sure how useful they are
> to people. I'm not personally attached to them, other opinions?

Since the project switched to git, developers can now use git-grep :)

> 
>>
>>>    
>>>>    uint64_t get_psw_mask(CPUS390XState *env);
>>>>    void s390_cpu_recompute_watchpoints(CPUState *cs);
>>>>    void s390x_tod_timer(void *opaque);
>>>>    void s390x_cpu_timer(void *opaque);
>>>> -void do_restart_interrupt(CPUS390XState *env);
>>>>    void s390_handle_wait(S390CPU *cpu);
>>>> +hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>>>> +hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>>>>    #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
>>>>    int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
>>>>    int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
>>>> -#ifndef CONFIG_USER_ONLY
>>>>    LowCore *cpu_map_lowcore(CPUS390XState *env);
>>>>    void cpu_unmap_lowcore(LowCore *lowcore);
>>>>    #endif /* CONFIG_USER_ONLY */
>>>
>>>    
>>
> 
> 


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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
@ 2020-05-12  6:46           ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 65+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12  6:46 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Peter Maydell, Sagar Karandikar, David Hildenbrand,
	Mark Cave-Ayland, qemu-devel, Laurent Vivier, Max Filippov,
	Alistair Francis, Marek Vasut, Aleksandar Markovic,
	Marcel Apfelbaum, Palmer Dabbelt, Aleksandar Rikalo,
	David Gibson, Artyom Tarasenko, Eduardo Habkost, qemu-s390x,
	qemu-arm, Stafford Horne, Richard Henderson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

On 5/12/20 8:01 AM, Cornelia Huck wrote:
> On Mon, 11 May 2020 14:21:27 +0200
> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> 
>> On 5/11/20 12:48 PM, Cornelia Huck wrote:
>>> On Sat,  9 May 2020 15:09:07 +0200
>>> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>>    
>>>> As these declarations are restricted to !CONFIG_USER_ONLY in
>>>> helper.c, only declare them when system-mode emulation is used.
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>> ---
>>>>    target/s390x/internal.h | 11 ++++++-----
>>>>    1 file changed, 6 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
>>>> index c1678dc6bc..ddc276cdf4 100644
>>>> --- a/target/s390x/internal.h
>>>> +++ b/target/s390x/internal.h
>>>> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
>>>>    
>>>>    /* cc_helper.c */
>>>>    const char *cc_name(enum cc_op cc_op);
>>>> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>>>    uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
>>>>                     uint64_t vr);
>>>>    
>>>> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
>>>>    
>>>>    /* helper.c */
>>>>    void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
>>>> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>>>> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>>>> +void do_restart_interrupt(CPUS390XState *env);
>>>> +
>>>> +#ifndef CONFIG_USER_ONLY
>>>> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>>
>>> load_psw() is in cc_helper.c (and not in helper.c). Rather add the
>>> #ifndef above, even if it is a bit awkward? Otherwise, the wrong
>>> comment makes it confusing.
>>
>> I've been tempted to remove the kinda outdated /* helper.c */ comment...
> 
> I don't think they're really outdated, but not sure how useful they are
> to people. I'm not personally attached to them, other opinions?

Since the project switched to git, developers can now use git-grep :)

> 
>>
>>>    
>>>>    uint64_t get_psw_mask(CPUS390XState *env);
>>>>    void s390_cpu_recompute_watchpoints(CPUState *cs);
>>>>    void s390x_tod_timer(void *opaque);
>>>>    void s390x_cpu_timer(void *opaque);
>>>> -void do_restart_interrupt(CPUS390XState *env);
>>>>    void s390_handle_wait(S390CPU *cpu);
>>>> +hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>>>> +hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>>>>    #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
>>>>    int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
>>>>    int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len);
>>>> -#ifndef CONFIG_USER_ONLY
>>>>    LowCore *cpu_map_lowcore(CPUS390XState *env);
>>>>    void cpu_unmap_lowcore(LowCore *lowcore);
>>>>    #endif /* CONFIG_USER_ONLY */
>>>
>>>    
>>
> 
> 


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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
  2020-05-12  6:46           ` Philippe Mathieu-Daudé
@ 2020-05-12  6:52             ` David Hildenbrand
  -1 siblings, 0 replies; 65+ messages in thread
From: David Hildenbrand @ 2020-05-12  6:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Cornelia Huck
  Cc: Peter Maydell, Sagar Karandikar, Mark Cave-Ayland, qemu-devel,
	Max Filippov, Alistair Francis, Marek Vasut, Aleksandar Markovic,
	qemu-ppc, Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Richard Henderson, qemu-riscv, Bastian Koppelmann, Chris Wulff,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Paolo Bonzini,
	Aurelien Jarno

On 12.05.20 08:46, Philippe Mathieu-Daudé wrote:
> On 5/12/20 8:01 AM, Cornelia Huck wrote:
>> On Mon, 11 May 2020 14:21:27 +0200
>> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>>> On 5/11/20 12:48 PM, Cornelia Huck wrote:
>>>> On Sat,  9 May 2020 15:09:07 +0200
>>>> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>>>    
>>>>> As these declarations are restricted to !CONFIG_USER_ONLY in
>>>>> helper.c, only declare them when system-mode emulation is used.
>>>>>
>>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>>> ---
>>>>>    target/s390x/internal.h | 11 ++++++-----
>>>>>    1 file changed, 6 insertions(+), 5 deletions(-)
>>>>>
>>>>> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
>>>>> index c1678dc6bc..ddc276cdf4 100644
>>>>> --- a/target/s390x/internal.h
>>>>> +++ b/target/s390x/internal.h
>>>>> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
>>>>>    
>>>>>    /* cc_helper.c */
>>>>>    const char *cc_name(enum cc_op cc_op);
>>>>> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>>>>    uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
>>>>>                     uint64_t vr);
>>>>>    
>>>>> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
>>>>>    
>>>>>    /* helper.c */
>>>>>    void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
>>>>> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>>>>> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>>>>> +void do_restart_interrupt(CPUS390XState *env);
>>>>> +
>>>>> +#ifndef CONFIG_USER_ONLY
>>>>> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>>>
>>>> load_psw() is in cc_helper.c (and not in helper.c). Rather add the
>>>> #ifndef above, even if it is a bit awkward? Otherwise, the wrong
>>>> comment makes it confusing.
>>>
>>> I've been tempted to remove the kinda outdated /* helper.c */ comment...
>>
>> I don't think they're really outdated, but not sure how useful they are
>> to people. I'm not personally attached to them, other opinions?
> 
> Since the project switched to git, developers can now use git-grep :)

I consider these quite valuable to structure the file. But my life would
go on without them.

-- 
Thanks,

David / dhildenb



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

* Re: [PATCH 08/11] target/s390x: Restrict system-mode declarations
@ 2020-05-12  6:52             ` David Hildenbrand
  0 siblings, 0 replies; 65+ messages in thread
From: David Hildenbrand @ 2020-05-12  6:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Cornelia Huck
  Cc: Peter Maydell, Sagar Karandikar, Mark Cave-Ayland, qemu-devel,
	Laurent Vivier, Max Filippov, Alistair Francis, Marek Vasut,
	Aleksandar Markovic, Marcel Apfelbaum, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, qemu-s390x, qemu-arm, Stafford Horne,
	Richard Henderson, qemu-riscv, Bastian Koppelmann, Chris Wulff,
	Roman Bolshakov, qemu-ppc, Paolo Bonzini, Aurelien Jarno

On 12.05.20 08:46, Philippe Mathieu-Daudé wrote:
> On 5/12/20 8:01 AM, Cornelia Huck wrote:
>> On Mon, 11 May 2020 14:21:27 +0200
>> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>>> On 5/11/20 12:48 PM, Cornelia Huck wrote:
>>>> On Sat,  9 May 2020 15:09:07 +0200
>>>> Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>>>    
>>>>> As these declarations are restricted to !CONFIG_USER_ONLY in
>>>>> helper.c, only declare them when system-mode emulation is used.
>>>>>
>>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>>> ---
>>>>>    target/s390x/internal.h | 11 ++++++-----
>>>>>    1 file changed, 6 insertions(+), 5 deletions(-)
>>>>>
>>>>> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
>>>>> index c1678dc6bc..ddc276cdf4 100644
>>>>> --- a/target/s390x/internal.h
>>>>> +++ b/target/s390x/internal.h
>>>>> @@ -236,7 +236,6 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
>>>>>    
>>>>>    /* cc_helper.c */
>>>>>    const char *cc_name(enum cc_op cc_op);
>>>>> -void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>>>>    uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
>>>>>                     uint64_t vr);
>>>>>    
>>>>> @@ -303,18 +302,20 @@ void s390_cpu_gdb_init(CPUState *cs);
>>>>>    
>>>>>    /* helper.c */
>>>>>    void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
>>>>> -hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>>>>> -hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
>>>>> +void do_restart_interrupt(CPUS390XState *env);
>>>>> +
>>>>> +#ifndef CONFIG_USER_ONLY
>>>>> +void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
>>>>
>>>> load_psw() is in cc_helper.c (and not in helper.c). Rather add the
>>>> #ifndef above, even if it is a bit awkward? Otherwise, the wrong
>>>> comment makes it confusing.
>>>
>>> I've been tempted to remove the kinda outdated /* helper.c */ comment...
>>
>> I don't think they're really outdated, but not sure how useful they are
>> to people. I'm not personally attached to them, other opinions?
> 
> Since the project switched to git, developers can now use git-grep :)

I consider these quite valuable to structure the file. But my life would
go on without them.

-- 
Thanks,

David / dhildenb



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

* Re: [PATCH 04/11] sysemu/hvf: Only declare hvf_allowed when HVF is available
  2020-05-09 13:09   ` Philippe Mathieu-Daudé
                     ` (2 preceding siblings ...)
  (?)
@ 2020-06-03 23:35   ` Cameron Esfahani
  -1 siblings, 0 replies; 65+ messages in thread
From: Cameron Esfahani @ 2020-06-03 23:35 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Cameron Esfahani via

Commit message typo tcg_allowed -> hvf_allowed.

If fixed:
Reviewed-by: Cameron Esfahani <dirty@apple.com>

Cameron Esfahani
dirty@apple.com

"You only live once, and the way I live, once is enough"

Frank Sinatra



> On May 9, 2020, at 6:09 AM, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> 
> When HVF is not available, the tcg_allowed variable does not exist.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> include/sysemu/hvf.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
> index d211e808e9..fe95743124 100644
> --- a/include/sysemu/hvf.h
> +++ b/include/sysemu/hvf.h
> @@ -18,7 +18,6 @@
> #include "exec/memory.h"
> #include "sysemu/accel.h"
> 
> -extern bool hvf_allowed;
> #ifdef CONFIG_HVF
> #include <Hypervisor/hv.h>
> #include <Hypervisor/hv_vmx.h>
> @@ -26,11 +25,12 @@ extern bool hvf_allowed;
> #include "target/i386/cpu.h"
> uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
>                                  int reg);
> +extern bool hvf_allowed;
> #define hvf_enabled() (hvf_allowed)
> -#else
> +#else /* !CONFIG_HVF */
> #define hvf_enabled() 0
> #define hvf_get_supported_cpuid(func, idx, reg) 0
> -#endif
> +#endif /* !CONFIG_HVF */
> 
> /* hvf_slot flags */
> #define HVF_SLOT_LOG (1 << 0)
> -- 
> 2.21.3
> 
> 



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

end of thread, other threads:[~2020-06-03 23:36 UTC | newest]

Thread overview: 65+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09 13:08 [PATCH 00/11] exec/cpu: Poison 'hwaddr' type in user-mode emulation Philippe Mathieu-Daudé
2020-05-09 13:08 ` Philippe Mathieu-Daudé
2020-05-09 13:09 ` [PATCH 01/11] plugins: Restrict functions handling hwaddr to system-mode Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-10 10:44   ` Philippe Mathieu-Daudé
2020-05-10 10:44     ` Philippe Mathieu-Daudé
2020-05-09 13:09 ` [PATCH 02/11] sysemu/accel: Restrict machine methods " Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-11  9:54   ` Edgar E. Iglesias
2020-05-11  9:54     ` Edgar E. Iglesias
2020-05-11 10:17   ` Cornelia Huck
2020-05-11 10:17     ` Cornelia Huck
2020-05-09 13:09 ` [PATCH 03/11] sysemu/tcg: Only declare tcg_allowed when TCG is available Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-11  9:46   ` Edgar E. Iglesias
2020-05-11  9:46     ` Edgar E. Iglesias
2020-05-11 10:20   ` Cornelia Huck
2020-05-11 10:20     ` Cornelia Huck
2020-05-09 13:09 ` [PATCH 04/11] sysemu/hvf: Only declare hvf_allowed when HVF " Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-11  9:47   ` Edgar E. Iglesias
2020-05-11  9:47     ` Edgar E. Iglesias
2020-05-11 10:22   ` Cornelia Huck
2020-05-11 10:22     ` Cornelia Huck
2020-06-03 23:35   ` Cameron Esfahani
2020-05-09 13:09 ` [PATCH 05/11] target/ppc: Restrict PPCVirtualHypervisorClass to system-mode Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-11  1:15   ` David Gibson
2020-05-11  1:15     ` David Gibson
2020-05-09 13:09 ` [PATCH 06/11] target/s390x: Only compile decode_basedisp() on system-mode Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-11 10:39   ` Cornelia Huck
2020-05-11 10:39     ` Cornelia Huck
2020-05-09 13:09 ` [PATCH 07/11] target/s390x/helper: Clean ifdef'ry Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-11  9:43   ` David Hildenbrand
2020-05-11  9:43     ` David Hildenbrand
2020-05-11 10:44   ` Cornelia Huck
2020-05-11 10:44     ` Cornelia Huck
2020-05-09 13:09 ` [PATCH 08/11] target/s390x: Restrict system-mode declarations Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-11 10:48   ` Cornelia Huck
2020-05-11 10:48     ` Cornelia Huck
2020-05-11 12:21     ` Philippe Mathieu-Daudé
2020-05-11 12:21       ` Philippe Mathieu-Daudé
2020-05-12  6:01       ` Cornelia Huck
2020-05-12  6:01         ` Cornelia Huck
2020-05-12  6:46         ` Philippe Mathieu-Daudé
2020-05-12  6:46           ` Philippe Mathieu-Daudé
2020-05-12  6:52           ` David Hildenbrand
2020-05-12  6:52             ` David Hildenbrand
2020-05-09 13:09 ` [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-09 16:08   ` Philippe Mathieu-Daudé
2020-05-09 16:08     ` Philippe Mathieu-Daudé
2020-05-09 20:01     ` Philippe Mathieu-Daudé
2020-05-09 20:01       ` Philippe Mathieu-Daudé
2020-05-09 21:03       ` Paolo Bonzini
2020-05-09 21:03         ` Paolo Bonzini
2020-05-11  1:16   ` David Gibson
2020-05-11  1:16     ` David Gibson
2020-05-09 13:09 ` [PATCH 10/11] exec: Use 'cpu-common.h' instead of system-mode specific 'hwaddr.h' Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé
2020-05-09 13:09 ` [PATCH 11/11] exec/cpu-common: Poison hwaddr type in user-mode emulation Philippe Mathieu-Daudé
2020-05-09 13:09   ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.