next round of s390x cleanups
cover next round of s390x cleanups
No new functionality, only cleanups, some of the discussed during the last round of cleanups.
Not sure if the first two patches should be sent separatly? Anyhow, they are most probably not worth the trouble :)
The biggest part of this series is getting rid of s390-virtio.c and cleaning up our cpu number/id handling.
Based on: git://github.com/cohuck/qemu s390-next
David Hildenbrand (11):
exec,dump: don't include exec/exec-all.h explicitly
cpu: drop old comments describing members
s390x: store cpu states inside machine state
s390x: get rid of s390-virtio.c
s390x: rename s390-virtio.h to s390-virtio-hcall.h target/s390x: cleanup cpu number/address handling target/s390x: rename next_cpu_id to next_cpu_addr
s390x: allow only 1 CPU with TCG
target/s390x: tcg_s390_program_interrupt() will never return target/s390x: use trigger_pgm_exception() in
s390_cpu_handle_mmu_fault()
target/s390x: use program_interrupt() in per_check_exception()
dump.c | 1 - exec.c | 1 - hw/s390x/Makefile.objs | 1 - hw/s390x/s390-virtio-ccw.c | 169 ++++++++++++++++++++++++++++++- hw/s390x/s390-virtio-hcall.c | 2 +- hw/s390x/s390-virtio-hcall.h | 20 ++++ hw/s390x/s390-virtio.c | 201 ------------------------------------- hw/s390x/s390-virtio.h | 35 ------- include/hw/s390x/s390-virtio-ccw.h | 3 + include/qom/cpu.h | 6 +- target/s390x/cpu-qom.h | 2 +- target/s390x/cpu.c | 74 ++++---------- target/s390x/cpu.h | 5 +- target/s390x/cpu_models.c | 2 +- target/s390x/excp_helper.c | 5 +- target/s390x/helper.c | 8 +- target/s390x/interrupt.c | 3 +- target/s390x/misc_helper.c | 13 +-- target/s390x/translate.c | 5 +- 19 files changed, 230 insertions(+), 326 deletions(-) create mode 100644 hw/s390x/s390-virtio-hcall.h delete mode 100644 hw/s390x/s390-virtio.c delete mode 100644 hw/s390x/s390-virtio.h
Signature · 1 line
2.13.5
PATCH 1/11 exec, dump: don't include exec/exec-all.h explicitly
All but two, namely exec.c and dump.c, include exec/exec-all.h via cpu.h only. as these files already include cpu.h, let's just drop the additional include.
--- dump.c | 1 - exec.c | 1 - 2 files changed, 2 deletions(-)
dump.c +0 -1
@@ -15,7 +15,6 @@#include "qemu/cutils.h" #include "elf.h" #include "cpu.h" -#include "exec/cpu-all.h" #include "exec/hwaddr.h" #include "monitor/monitor.h" #include "sysemu/kvm.h"
exec.c +0 -1
@@ -23,7 +23,6 @@#include "qemu/cutils.h" #include "cpu.h" -#include "exec/exec-all.h" #include "exec/target_page.h" #include "tcg.h" #include "hw/qdev-core.h"
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 01/11] exec, dump: don't include exec/exec-all.h explicitly
Quoted 15 lines · David Hildenbrand
All but two, namely
exec.canddump.c, includeexec/exec-all.hviacpu.honly. as these files already includecpu.h, let's just drop the additional include.Signed-off-by David Hildenbrand <[email protected]>--- dump.c | 1 - exec.c | 1 - 2 files changed, 2 deletions(-)dump.c +0
-0
dump.c line 18
Quoted 4 lines
dump.c +0
-1@@ -15,7 +15,6 @@#include "qemu/cutils.h" #include "elf.h" #include "cpu.h" -#include "exec/cpu-all.h"
That's cpu-all.h, not exec-all.h ...
Quoted 8 lines
dump.c +0
-0#include "exec/hwaddr.h" #include "monitor/monitor.h" #include "sysemu/kvm.h" exec.c +0
-0
exec.c line 28
Quoted 7 lines
exec.c +0
-1@@ -23,7 +23,6 @@#include "qemu/cutils.h" #include "cpu.h" -#include "exec/exec-all.h" #include "exec/target_page.h" #include "tcg.h" #include "hw/qdev-core.h"
... and if I do a grep for exec-all.h in the cpu.h files, I hardly get any matches. => Your patch description sounds wrong ... I guess you only wanted to handle cpu-all.h here?
Thomas
Re: [Qemu-devel] [PATCH v1 01/11] exec, dump: don't include exec/exec-all.h explicitly
Quoted 43 lines · Thomas Huth
Quoted 15 lines · David Hildenbrand
All but two, namely
exec.canddump.c, includeexec/exec-all.hviacpu.honly. as these files already includecpu.h, let's just drop the additional include.Signed-off-by David Hildenbrand <[email protected]>--- dump.c | 1 - exec.c | 1 - 2 files changed, 2 deletions(-)dump.c +0
-0dump.c line 18
Quoted 4 lines
dump.c +0
-1@@ -15,7 +15,6 @@#include "qemu/cutils.h" #include "elf.h" #include "cpu.h" -#include "exec/cpu-all.h" That's
cpu-all.h, notexec-all.h...Quoted 8 lines
dump.c +0
-0#include "exec/hwaddr.h" #include "monitor/monitor.h" #include "sysemu/kvm.h" exec.c +0
-0exec.c line 28
Quoted 7 lines
exec.c +0
-1@@ -23,7 +23,6 @@#include "qemu/cutils.h" #include "cpu.h" -#include "exec/exec-all.h" #include "exec/target_page.h" #include "tcg.h" #include "hw/qdev-core.h" ... and if I do a grep for
exec-all.hin thecpu.hfiles, I hardly get any matches. => Your patch description sounds wrong ... I guess you only wanted to handlecpu-all.hhere?
Quoted 2 lines
Thomas
exec/cpu-all.h it is. Fixed the subject+description.
I'd really love to know what my brain was doing while composing that message. It will remain a mystery.
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 01/11] exec, dump: don't include exec/exec-all.h explicitly
In reply to David HildenbrandQuoted 10 lines · On Wed, 30 Aug 2017 19:05:51 +0200 David Hildenbrand <[email protected]> wrote:
All but two, namely
exec.canddump.c, includeexec/exec-all.hviacpu.honly. as these files already includecpu.h, let's just drop the additional include.Signed-off-by David Hildenbrand <[email protected]>--- dump.c | 1 - exec.c | 1 - 2 files changed, 2 deletions(-)
I think there are some more (target/<arch>/arch_dump.c and some i386 files) - do you want to clean up those as well?
Re: [Qemu-devel] [PATCH v1 01/11] exec, dump: don't include exec/exec-all.h explicitly
Quoted 14 lines · Cornelia Huck
Quoted 10 lines · On Wed, 30 Aug 2017 19:05:51 +0200 David Hildenbrand <[email protected]> wrote:
All but two, namely
exec.canddump.c, includeexec/exec-all.hviacpu.honly. as these files already includecpu.h, let's just drop the additional include.Signed-off-by David Hildenbrand <[email protected]>--- dump.c | 1 - exec.c | 1 - 2 files changed, 2 deletions(-)
Quoted 3 lines
I think there are some more (target/<arch>/arch_dump.c and some i386 files) - do you want to clean up those as well?
Whoops, missed these. Yes, will clean them up, too.
Signature · 3 lines
Thanks, David
PATCH 2/11 cpu: drop old comments describing members
In reply to David HildenbrandThese comments are obviously stale.
--- include/qom/cpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/qom/cpu.h +3 -3
@@ -378,10 +378,10 @@ struct CPUState {DECLARE_BITMAP (trace_dstate,CPU_TRACE_DSTATE_MAX_EVENTS );/* TODO Move common fields from CPUArchState here. */ -int cpu_index;/* used by alpha TCG */ -uint32_t halted;/* used by alpha, cris, ppc TCG */ +int cpu_index; +uint32_t halted;uint32_t can_do_io; -int32_t exception_index;/* used by m68k TCG */ +int32_t exception_index;/* shared by kvm, hax and hvf */ bool vcpu_dirty;
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 02/11] cpu: drop old comments describing members
Quoted 15 lines · On Wed, 30 Aug 2017 19:05:52 +0200 David Hildenbrand <[email protected]> wrote:
These comments are obviously stale.
Signed-off-by David Hildenbrand <[email protected]>--- include/qom/cpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)include/qom/cpu.h +0
-0@@ -378,10 +378,10 @@ struct CPUState {DECLARE_BITMAP (trace_dstate,CPU_TRACE_DSTATE_MAX_EVENTS );/* TODO Move common fields from CPUArchState here. */
include/qom/cpu.h struct CPUState { · line 387
Quoted 10 lines
include/qom/cpu.h +3
-3-int cpu_index;/* used by alpha TCG */ -uint32_t halted;/* used by alpha, cris, ppc TCG */ +int cpu_index; +uint32_t halted;uint32_t can_do_io; -int32_t exception_index;/* used by m68k TCG */ +int32_t exception_index;/* shared by kvm, hax and hvf */ bool vcpu_dirty;
Yup, no need to drag these around. In case I don't take this through s390-next:
PATCH 3/11 s390x: store cpu states inside machine state
In reply to David HildenbrandLet's avoid global variables. While at it, move both functions using it, so we won't have to temporarily add includes (we'll be getting rid of s390-virtio.c soon).
--- hw/s390x/s390-virtio-ccw.c | 39 ++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio.c | 38 ------------------------------------- hw/s390x/s390-virtio.h | 1 - include/hw/s390x/s390-virtio-ccw.h | 3 +++ 4 files changed, 42 insertions(+), 39 deletions(-)
hw/s390x/s390-virtio-ccw.c +39 -0
@@ -32,6 +32,45 @@#include "migration/register.h" #include "cpu_models.h" +S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) +{ +S390CcwMachineState *ms =S390_CCW_MACHINE (qdev_get_machine ()); + +if (cpu_addr >= max_cpus) { +return NULL ; + } + +/* Fast lookup via CPU ID */ +return ms->cpus[cpu_addr]; +} + +static void s390_init_cpus (MachineState *machine) +{ +S390CcwMachineState *ms =S390_CCW_MACHINE (machine); +int i; +gchar *name; + +if (machine->cpu_model ==NULL ) { + machine->cpu_model =s390_default_cpu_model_name (); + } + + ms->cpus = g_new0(S390CPU *, max_cpus); + +for (i =0 ; i < max_cpus; i++) { + name =g_strdup_printf ("cpu[%i]" , i); +object_property_add_link (OBJECT (machine), name,TYPE_S390_CPU , + (Object **) &ms->cpus[i], + object_property_allow_set_link, +OBJ_PROP_LINK_UNREF_ON_RELEASE , + &error_abort); +g_free (name); + } + +for (i =0 ; i < smp_cpus; i++) { +s390x_new_cpu (machine->cpu_model, i, &error_fatal); + } +} +static const char *const reset_dev_types[] = {TYPE_VIRTUAL_CSS_BRIDGE ,"s390-sclp-event-facility" ,
hw/s390x/s390-virtio.c +0 -38
@@ -48,18 +48,6 @@#define S390_TOD_CLOCK_VALUE_MISSING 0x00#define S390_TOD_CLOCK_VALUE_PRESENT 0x01 -static S390CPU **cpu_states; - -S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) -{ -if (cpu_addr >= max_cpus) { -return NULL ; - } - -/* Fast lookup via CPU ID */ -return cpu_states[cpu_addr]; -} - void s390_init_ipl_dev(const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
@@ -86,32 +74,6 @@ void s390_init_ipl_dev(const char *kernel_filename,qdev_init_nofail (dev); } -void s390_init_cpus (MachineState *machine) -{ -int i; -gchar *name; - -if (machine->cpu_model ==NULL ) { - machine->cpu_model =s390_default_cpu_model_name (); - } - - cpu_states = g_new0(S390CPU *, max_cpus); - -for (i =0 ; i < max_cpus; i++) { - name =g_strdup_printf ("cpu[%i]" , i); -object_property_add_link (OBJECT (machine), name,TYPE_S390_CPU , - (Object **) &cpu_states[i], - object_property_allow_set_link, -OBJ_PROP_LINK_UNREF_ON_RELEASE , - &error_abort); -g_free (name); - } - -for (i =0 ; i < smp_cpus; i++) { -s390x_new_cpu (machine->cpu_model, i, &error_fatal); - } -} -void s390_create_virtio_net (BusState *bus,const char *name) {
hw/s390x/s390-virtio.h +0 -1
@@ -19,7 +19,6 @@typedef int (*s390_virtio_fn )(const uint64_t *args);void s390_register_virtio_hypercall (uint64_t code,s390_virtio_fn fn); -void s390_init_cpus (MachineState *machine); void s390_init_ipl_dev(const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
include/hw/s390x/s390-virtio-ccw.h +3 -0
@@ -21,11 +21,14 @@#define S390_MACHINE_CLASS (klass) \ OBJECT_CLASS_CHECK(S390CcwMachineClass, (klass), TYPE_S390_CCW_MACHINE) +struct S390CPU ; + typedef struct S390CcwMachineState { /*< private >*/ MachineState parent_obj; /*< public >*/ + S390CPU **cpus; bool aes_key_wrap; bool dea_key_wrap; uint8_t loadparm[8];
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 21 lines · David Hildenbrand
Let's avoid global variables. While at it, move both functions using it, so we won't have to temporarily add includes (we'll be getting rid of
s390-virtio.csoon).Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 39 ++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio.c | 38 ------------------------------------- hw/s390x/s390-virtio.h | 1 - include/hw/s390x/s390-virtio-ccw.h | 3 +++ 4 files changed, 42 insertions(+), 39 deletions(-)hw/s390x/s390-virtio-ccw.c +1
-0@@ -32,6 +32,45 @@#include "migration/register.h" #include "cpu_models.h" +S390CPU *s390_cpu_addr2state (uint16_t cpu_addr)
hw/s390x/s390-virtio-ccw.c line 45
Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +10
-0+{ +S390CcwMachineState *ms =S390_CCW_MACHINE (qdev_get_machine ()); + +if (cpu_addr >= max_cpus) { +return NULL ; + } + +/* Fast lookup via CPU ID */ +return ms->cpus[cpu_addr]; +}
I wonder whether that function should rather go into a file in target/s390x/ instead, since it is also used there and its prototype is in cpu.h ?
[...]
include/hw/s390x/s390-virtio-ccw.h line 24
Quoted 9 lines
include/hw/s390x/s390-virtio-ccw.h +1
-0@@ -21,11 +21,14 @@#define S390_MACHINE_CLASS (klass) \ OBJECT_CLASS_CHECK(S390CcwMachineClass, (klass), TYPE_S390_CCW_MACHINE) +struct S390CPU ;
You define a "struct S390CPU" here ...
include/hw/s390x/s390-virtio-ccw.h line 31
Quoted 6 lines
include/hw/s390x/s390-virtio-ccw.h +1
-0typedef struct S390CcwMachineState { /*< private >*/ MachineState parent_obj; /*< public >*/ + S390CPU **cpus;
... but use the typedef'ed S390CPU here ... looks somewhat suspicious, I wonder whether the typedef is really in the right place?
include/hw/s390x/s390-virtio-ccw.h line 34
Quoted 3 lines
include/hw/s390x/s390-virtio-ccw.h +0
-0bool aes_key_wrap;bool dea_key_wrap;uint8_t loadparm[8 ];
Anyway, that were just nits, I'm also fine with the patch as it is, so:
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 16 lines
hw/s390x/s390-virtio-ccw.c line 45
Quoted 12 lines
hw/s390x/s390-virtio-ccw.c +11
-0+S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) +{ +S390CcwMachineState *ms =S390_CCW_MACHINE (qdev_get_machine ()); + +if (cpu_addr >= max_cpus) { +return NULL ; + } + +/* Fast lookup via CPU ID */ +return ms->cpus[cpu_addr]; +}I wonder whether that function should rather go into a file in target/s390x/ instead, since it is also used there and its prototype is in
cpu.h?
I thought about the same thing, but as it works directly on the machine, like ri_allowed() and friends. So I decided to keep it here for now.
I'll think about moving the definition also intoinclude/hw/s390x/s390-virtio-ccw.h
Quoted 10 lines
[...]
Quoted 8 lines
include/hw/s390x/s390-virtio-ccw.h +0
-0@@ -21,11 +21,14 @@#define S390_MACHINE_CLASS (klass) \ OBJECT_CLASS_CHECK(S390CcwMachineClass, (klass), TYPE_S390_CCW_MACHINE)
Quoted 10 lines
include/hw/s390x/s390-virtio-ccw.h line 24
Quoted 1 line
include/hw/s390x/s390-virtio-ccw.h +1
-0+struct S390CPU ;You define a "struct S390CPU" here ...
Quoted 6 lines
include/hw/s390x/s390-virtio-ccw.h +1
-0typedef struct S390CcwMachineState { /*< private >*/ MachineState parent_obj; /*< public >*/ + S390CPU **cpus;
I'll simply convert this to struct S390CPU, so this header stays independent from cpu headers.
Quoted 4 lines
... but use the typedef'ed S390CPU here ... looks somewhat suspicious, I wonder whether the typedef is really in the right place?
Quoted 8 lines
include/hw/s390x/s390-virtio-ccw.h line 34
Quoted 3 lines
include/hw/s390x/s390-virtio-ccw.h +0
-0bool aes_key_wrap;bool dea_key_wrap;uint8_t loadparm[8 ];Anyway, that were just nits, I'm also fine with the patch as it is, so:
Reviewed-by Thomas Huth <[email protected]>
Thanks!
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 16 lines · On Thu, 31 Aug 2017 15:11:28 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +7
-0+S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) +{ +S390CcwMachineState *ms =S390_CCW_MACHINE (qdev_get_machine ()); + +if (cpu_addr >= max_cpus) { +return NULL ; + }Quoted 8 lines
hw/s390x/s390-virtio-ccw.c line 45
Quoted 4 lines
hw/s390x/s390-virtio-ccw.c +4
-0+ +/* Fast lookup via CPU ID */ +return ms->cpus[cpu_addr]; +}I wonder whether that function should rather go into a file in target/s390x/ instead, since it is also used there and its prototype is in
cpu.h?
Quoted 5 lines
I thought about the same thing, but as it works directly on the machine, like
ri_allowed()and friends. So I decided to keep it here for now.I'll think about moving the definition also into
include/hw/s390x/s390-virtio-ccw.h
It would be a bit nicer.
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 19 lines · Cornelia Huck
Quoted 16 lines · On Thu, 31 Aug 2017 15:11:28 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 15 lines
hw/s390x/s390-virtio-ccw.c line 45
Quoted 11 lines
hw/s390x/s390-virtio-ccw.c +11
-0+S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) +{ +S390CcwMachineState *ms =S390_CCW_MACHINE (qdev_get_machine ()); + +if (cpu_addr >= max_cpus) { +return NULL ; + } + +/* Fast lookup via CPU ID */ +return ms->cpus[cpu_addr]; +}I wonder whether that function should rather go into a file in target/s390x/ instead, since it is also used there and its prototype is in
cpu.h?
Quoted 8 lines
Quoted 5 lines
I thought about the same thing, but as it works directly on the machine, like
ri_allowed()and friends. So I decided to keep it here for now.I'll think about moving the definition also into
include/hw/s390x/s390-virtio-ccw.hIt would be a bit nicer.
Adding patches right now to move everything out of cpu.h that lies under the "/* outside of target/s390x/ */" section. :)
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 23 lines · On Thu, 31 Aug 2017 16:30:59 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 22 lines · Cornelia Huck
Quoted 19 lines · On Thu, 31 Aug 2017 15:11:28 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +7
-0+S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) +{ +S390CcwMachineState *ms =S390_CCW_MACHINE (qdev_get_machine ()); + +if (cpu_addr >= max_cpus) { +return NULL ; + }Quoted 8 lines
hw/s390x/s390-virtio-ccw.c line 45
Quoted 4 lines
hw/s390x/s390-virtio-ccw.c +4
-0+ +/* Fast lookup via CPU ID */ +return ms->cpus[cpu_addr]; +}I wonder whether that function should rather go into a file in target/s390x/ instead, since it is also used there and its prototype is in
cpu.h?I thought about the same thing, but as it works directly on the machine, like
ri_allowed()and friends. So I decided to keep it here for now.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
I'll think about moving the definition also into
include/hw/s390x/s390-virtio-ccw.hIt would be a bit nicer.
Adding patches right now to move everything out of
cpu.hthat lies under the "/* outside of target/s390x/ */" section. :)
Ah, you really care about your patch count, don't you? :)
(I think it's a good idea.)
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 32 lines · Cornelia Huck
Quoted 29 lines · On Thu, 31 Aug 2017 16:30:59 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 27 lines · Cornelia Huck
Quoted 16 lines · On Thu, 31 Aug 2017 15:11:28 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +7
-0+S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) +{ +S390CcwMachineState *ms =S390_CCW_MACHINE (qdev_get_machine ()); + +if (cpu_addr >= max_cpus) { +return NULL ; + }Quoted 8 lines
hw/s390x/s390-virtio-ccw.c line 45
Quoted 4 lines
hw/s390x/s390-virtio-ccw.c +4
-0+ +/* Fast lookup via CPU ID */ +return ms->cpus[cpu_addr]; +}I wonder whether that function should rather go into a file in target/s390x/ instead, since it is also used there and its prototype is in
cpu.h?Quoted 5 lines
I thought about the same thing, but as it works directly on the machine, like
ri_allowed()and friends. So I decided to keep it here for now.I'll think about moving the definition also into
include/hw/s390x/s390-virtio-ccw.hIt would be a bit nicer.
Quoted 8 lines
Quoted 3 lines
Adding patches right now to move everything out of
cpu.hthat lies under the "/* outside of target/s390x/ */" section. :)Ah, you really care about your patch count, don't you? :)
(I think it's a good idea.)
.... so you want me to squash everything into a single patch then?! ;)
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
In reply to Thomas HuthQuoted 9 lines
Quoted 2 lines
+struct S390CPU;
You define a "struct S390CPU" here ...
Quoted 4 lines
typedef struct S390CcwMachineState { /*< private >*/ MachineState parent_obj;
Quoted 5 lines
Quoted 2 lines
/*< public >*/+ S390CPU **cpus;
... but use the typedef'ed S390CPU here ... looks somewhat suspicious, I wonder whether the typedef is really in the right place?
General question: how much do we care about headers that are not consistent?
E.g. shall I forward declare or simply ignore if compilers don't bite me?
Quoted 9 lines
Quoted 4 lines
bool aes_key_wrap; bool dea_key_wrap; uint8_t loadparm[8];Anyway, that were just nits, I'm also fine with the patch as it is, so:
Reviewed-by Thomas Huth <[email protected]>
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 12 lines · David Hildenbrand
Quoted 12 lines
Quoted 2 lines
+struct S390CPU;
You define a "struct S390CPU" here ...
Quoted 6 lines
typedef struct S390CcwMachineState { /*< private >*/ MachineState parent_obj; /*< public >*/+ S390CPU **cpus;
Quoted 6 lines
Quoted 2 lines
... but use the typedef'ed S390CPU here ... looks somewhat suspicious, I wonder whether the typedef is really in the right place?
General question: how much do we care about headers that are not consistent?
E.g. shall I forward declare or simply ignore if compilers don't bite me?
My remark was not so much about your patch, but about the original definition instead: "struct S390CPU" is declared in target/s390x/cpu.h, but "typedef struct S390CPU S390CPU" is in target/s390x/cpu-qom.h. I think they should rather be declared in the same header file instead. Or your "struct S390CPU;" forward declaration should go into cpu-qom.h instead, right in front of the typedef.
Thomas
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 16 lines · Thomas Huth
Quoted 15 lines · David Hildenbrand
Quoted 14 lines
Quoted 2 lines
+struct S390CPU;
You define a "struct S390CPU" here ...
Quoted 6 lines
typedef struct S390CcwMachineState { /*< private >*/ MachineState parent_obj; /*< public >*/+ S390CPU **cpus;
... but use the typedef'ed S390CPU here ... looks somewhat suspicious, I wonder whether the typedef is really in the right place?
Quoted 8 lines
Quoted 3 lines
General question: how much do we care about headers that are not consistent?
E.g. shall I forward declare or simply ignore if compilers don't bite me?
My remark was not so much about your patch, but about the original definition instead: "struct S390CPU" is declared in
target/s390x/cpu.h, but "typedef struct S390CPU S390CPU" is intarget/s390x/cpu-qom.h. I think they should rather be declared in the same header file instead. Or
I agree, will have a look.
Quoted 3 lines
your "struct S390CPU;" forward declaration should go into
cpu-qom.hinstead, right in front of the typedef.
Let me rephrase my question:
include/hw/s390x/s390-virtio-ccw.h does not include cpu.h/cpu-qom.h
If compilers don't complain, do we have to forward declare at all? (I think it is cleaner, but I would like to know what is suggested)
Quoted 2 lines
Thomas
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 03/11] s390x: store cpu states inside machine state
Quoted 32 lines · David Hildenbrand
Quoted 16 lines · Thomas Huth
Quoted 15 lines · David Hildenbrand
Quoted 14 lines
Quoted 2 lines
+struct S390CPU;
You define a "struct S390CPU" here ...
Quoted 6 lines
typedef struct S390CcwMachineState { /*< private >*/ MachineState parent_obj; /*< public >*/+ S390CPU **cpus;
... but use the typedef'ed S390CPU here ... looks somewhat suspicious, I wonder whether the typedef is really in the right place?
Quoted 8 lines
Quoted 3 lines
General question: how much do we care about headers that are not consistent?
E.g. shall I forward declare or simply ignore if compilers don't bite me?
My remark was not so much about your patch, but about the original definition instead: "struct S390CPU" is declared in
target/s390x/cpu.h, but "typedef struct S390CPU S390CPU" is intarget/s390x/cpu-qom.h. I think they should rather be declared in the same header file instead. OrI agree, will have a look.
Quoted 3 lines
your "struct S390CPU;" forward declaration should go into
cpu-qom.hinstead, right in front of the typedef.
Quoted 6 lines
Let me rephrase my question:
include/hw/s390x/s390-virtio-ccw.hdoes not includecpu.h/cpu-qom.hIf compilers don't complain, do we have to forward declare at all? (I think it is cleaner, but I would like to know what is suggested)
Well, doing a forward declaration with "struct S390CPU;" and then using the typedef'd "S390CPU" without "struct" does not make much sense - these are two "different" types. If you can use "S390CPU" here without the "struct S390CPU;" declaration, that means the cpu-qom.h header got included indirectly already - so I'd suggest to simply remove the "struct S390CPU;" forward declaration from your patch.
Thomas
PATCH 4/11 s390x: get rid of s390-virtio.c
In reply to David HildenbrandIt is a leftover from the days where we had still the !ccw virtio machine. As this one is long gone, let's move everything to s390-virtio-ccw.c.
Cornelia Huck <[email protected]>
--- hw/s390x/Makefile.objs | 1 - hw/s390x/s390-virtio-ccw.c | 120 ++++++++++++++++++++++++++++++++- hw/s390x/s390-virtio.c | 163 --------------------------------------------- hw/s390x/s390-virtio.h | 14 ---- 4 files changed, 119 insertions(+), 179 deletions(-) delete mode 100644 hw/s390x/s390-virtio.c
hw/s390x/Makefile.objs +0 -1
@@ -1,4 +1,3 @@ -obj-y += s390-virtio.o obj-y += s390-virtio-hcall.o obj-y += sclp.o obj-y += event-facility.o
hw/s390x/s390-virtio-ccw.c +119 -1
161 lines not on this page · raw message
hw/s390x/s390-virtio.c deleted +0 -163
163 lines not on this page · raw message
hw/s390x/s390-virtio.h +0 -14
@@ -12,23 +12,9 @@#ifndef HW_S390_VIRTIO_H #define HW_S390_VIRTIO_H -#include "hw/nmi.h" #include "standard-headers/asm-s390/kvm_virtio.h" #include "standard-headers/asm-s390/virtio-ccw.h" typedef int (*s390_virtio_fn )(const uint64_t *args);void s390_register_virtio_hypercall (uint64_t code,s390_virtio_fn fn); - -void s390_init_ipl_dev (const char *kernel_filename, -const char *kernel_cmdline, -const char *initrd_filename, -const char *firmware, -const char *netboot_fw, -bool enforce_bios); -void s390_create_virtio_net (BusState *bus,const char *name); -void s390_nmi (NMIState *n,int cpu_index,Error **errp); -void s390_machine_reset (void ); -void s390_memory_init (ram_addr_t mem_size); -void gtod_save (QEMUFile *f,void *opaque); -int gtod_load (QEMUFile *f,void *opaque,int version_id);#endif
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 04/11] s390x: get rid of s390-virtio.c
Quoted 7 lines · David Hildenbrand
It is a leftover from the days where we had still the !ccw virtio machine. As this one is long gone, let's move everything to
s390-virtio-ccw.c.Cornelia Huck <[email protected]>
Signed-off-by David Hildenbrand <[email protected]>---
[...]
Quoted 4 lines
hw/s390x/s390-virtio-ccw.c +0
-0
[...]
Quoted 16 lines
hw/s390x/s390-virtio-ccw.c +16
-0+static int gtod_load (QEMUFile *f,void *opaque,int version_id) +{ +uint64_t tod_low; +uint8_t tod_high; +int r; + +if (qemu_get_byte (f) ==S390_TOD_CLOCK_VALUE_MISSING ) { +fprintf (stderr,"WARNING: Guest clock was not migrated. This could " +"cause the guest to hang.\n" ); +return 0 ; + } + + tod_high =qemu_get_byte (f); + tod_low =qemu_get_be64 (f); + + r =s390_set_clock (&tod_high, &tod_low);
hw/s390x/s390-virtio-ccw.c void s390_memory_init(ram_addr_t mem_size) · line 202
Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +10
-0+if (r) { +fprintf (stderr,"WARNING: Unable to set guest clock value. " +"s390_get_clock returned error %d. This could cause " +"the guest to hang.\n" , r); + } + +return 0 ; +} + +
Nit: One empty line should be enough here.
Re: [Qemu-devel] [PATCH v1 04/11] s390x: get rid of s390-virtio.c
Quoted 10 lines
hw/s390x/s390-virtio-ccw.c void s390_memory_init(ram_addr_t mem_size) · line 191
Quoted 5 lines
hw/s390x/s390-virtio-ccw.c +4
-0+return 0 ; +} + +Nit: One empty line should be enough here.
Reviewed-by Thomas Huth <[email protected]>
Indeed, thanks!
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 04/11] s390x: get rid of s390-virtio.c
In reply to David HildenbrandI have not reviewed this, but the whole idea is
Quoted 392 lines · David Hildenbrand
It is a leftover from the days where we had still the !ccw virtio machine. As this one is long gone, let's move everything to
s390-virtio-ccw.c.Cornelia Huck <[email protected]>
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/Makefile.objs | 1 - hw/s390x/s390-virtio-ccw.c | 120 ++++++++++++++++++++++++++++++++- hw/s390x/s390-virtio.c | 163 --------------------------------------------- hw/s390x/s390-virtio.h | 14 ---- 4 files changed, 119 insertions(+), 179 deletions(-) delete mode 100644 hw/s390x/s390-virtio.chw/s390x/Makefile.objs +0
-1@@ -1,4 +1,3 @@ -obj-y += s390-virtio.o obj-y += s390-virtio-hcall.o obj-y += sclp.o obj-y += event-facility.ohw/s390x/s390-virtio-ccw.c +119
-1@@ -2,6 +2,7 @@* virtio ccw machine * * Copyright 2012 IBM Corp. +* Copyright (c) 2009 Alexander Graf <[email protected]> * Author(s): Cornelia Huck <[email protected]> * * This work is licensed under the terms of the GNU GPL, version 2 or (at @@ -31,6 +32,8 @@#include "hw/s390x/css-bridge.h" #include "migration/register.h" #include "cpu_models.h" +#include "qapi/qmp/qerror.h" +#include "hw/nmi.h" S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) {@@ -133,7 +136,7 @@ static void virtio_ccw_register_hcalls(void) virtio_ccw_hcall_early_printk); } -void s390_memory_init (ram_addr_t mem_size) +static void s390_memory_init (ram_addr_t mem_size) {MemoryRegion *sysmem =get_system_memory ();MemoryRegion *ram =g_new (MemoryRegion,1 );@@ -148,11 +151,104 @@ void s390_memory_init(ram_addr_t mem_size)s390_stattrib_init (); } +#define S390_TOD_CLOCK_VALUE_MISSING 0x00 +#define S390_TOD_CLOCK_VALUE_PRESENT 0x01 + +static void gtod_save (QEMUFile *f,void *opaque) +{ +uint64_t tod_low; +uint8_t tod_high; +int r; + + r =s390_get_clock (&tod_high, &tod_low); +if (r) { +fprintf (stderr,"WARNING: Unable to get guest clock for migration. " +"Error code %d. Guest clock will not be migrated " +"which could cause the guest to hang.\n" , r); +qemu_put_byte (f,S390_TOD_CLOCK_VALUE_MISSING ); +return ; + } + +qemu_put_byte (f,S390_TOD_CLOCK_VALUE_PRESENT ); +qemu_put_byte (f, tod_high); +qemu_put_be64 (f, tod_low); +} + +static int gtod_load (QEMUFile *f,void *opaque,int version_id) +{ +uint64_t tod_low; +uint8_t tod_high; +int r; + +if (qemu_get_byte (f) ==S390_TOD_CLOCK_VALUE_MISSING ) { +fprintf (stderr,"WARNING: Guest clock was not migrated. This could " +"cause the guest to hang.\n" ); +return 0 ; + } + + tod_high =qemu_get_byte (f); + tod_low =qemu_get_be64 (f); + + r =s390_set_clock (&tod_high, &tod_low); +if (r) { +fprintf (stderr,"WARNING: Unable to set guest clock value. " +"s390_get_clock returned error %d. This could cause " +"the guest to hang.\n" , r); + } + +return 0 ; +} + +static SaveVMHandlers savevm_gtod = { .save_state = gtod_save, .load_state = gtod_load, }; +static void s390_init_ipl_dev (const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename,const char *firmware, +const char *netboot_fw,bool enforce_bios) +{ +Object *new =object_new (TYPE_S390_IPL ); +DeviceState *dev =DEVICE (new); + +if (kernel_filename) { +qdev_prop_set_string (dev,"kernel" , kernel_filename); + } +if (initrd_filename) { +qdev_prop_set_string (dev,"initrd" , initrd_filename); + } +qdev_prop_set_string (dev,"cmdline" , kernel_cmdline); +qdev_prop_set_string (dev,"firmware" , firmware); +qdev_prop_set_string (dev,"netboot_fw" , netboot_fw); +qdev_prop_set_bit (dev,"enforce_bios" , enforce_bios); +object_property_add_child (qdev_get_machine (),TYPE_S390_IPL , + new,NULL ); +object_unref (new); +qdev_init_nofail (dev); +} + +static void s390_create_virtio_net (BusState *bus,const char *name) +{ +int i; + +for (i =0 ; i < nb_nics; i++) { +NICInfo *nd = &nd_table[i]; +DeviceState *dev; + +if (!nd->model) { + nd->model =g_strdup ("virtio" ); + } + +qemu_check_nic_model (nd,"virtio" ); + + dev =qdev_create (bus, name); +qdev_set_nic_properties (dev, nd); +qdev_init_nofail (dev); + } +} +static void ccw_init (MachineState *machine) {int ret;@@ -216,6 +312,19 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev,g_free (name); } +static void s390_machine_reset (void ) +{ +S390CPU *ipl_cpu =S390_CPU (qemu_get_cpu (0 )); + +s390_cmma_reset (); +qemu_devices_reset (); +s390_crypto_reset (); + +/* all cpus are stopped - configure and start the ipl cpu only */ +s390_ipl_prepare_cpu (ipl_cpu); +s390_cpu_set_state (CPU_STATE_OPERATING , ipl_cpu); +} +static void s390_machine_device_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -240,6 +349,15 @@ static void s390_hot_add_cpu(const int64_t id, Error **errp)s390x_new_cpu (machine->cpu_model, id, errp); } +static void s390_nmi (NMIState *n,int cpu_index,Error **errp) +{ +CPUState *cs =qemu_get_cpu (cpu_index); + +if (s390_cpu_restart (S390_CPU (cs))) { +error_setg (errp,QERR_UNSUPPORTED ); + } +} +static void ccw_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);hw/s390x/s390-virtio.c deleted +0
-163@@ -1,163 +0,0 @@ -/* -* QEMU S390 virtio target -* -* Copyright (c) 2009 Alexander Graf <[email protected]> -* Copyright IBM Corp 2012 -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* Contributions after 2012-10-29 are licensed under the terms of the -* GNU GPL, version 2 or (at your option) any later version. -* -* You should have received a copy of the GNU (Lesser) General Public -* License along with this library; if not, see <http://www.gnu.org/licenses/>. -*/ - -#include "qemu/osdep.h" -#include "qapi/error.h" -#include "hw/hw.h" -#include "qapi/qmp/qerror.h" -#include "qemu/error-report.h" -#include "sysemu/block-backend.h" -#include "sysemu/blockdev.h" -#include "sysemu/sysemu.h" -#include "net/net.h" -#include "hw/boards.h" -#include "hw/loader.h" -#include "hw/virtio/virtio.h" -#include "exec/address-spaces.h" -#include "sysemu/qtest.h" - -#include "hw/s390x/sclp.h" -#include "hw/s390x/s390_flic.h" -#include "hw/s390x/s390-virtio.h" -#include "hw/s390x/storage-keys.h" -#include "hw/s390x/ipl.h" -#include "cpu.h" - -#define MAX_BLK_DEVS 10 - -#define S390_TOD_CLOCK_VALUE_MISSING 0x00 -#define S390_TOD_CLOCK_VALUE_PRESENT 0x01 - -void s390_init_ipl_dev (const char *kernel_filename, -const char *kernel_cmdline, -const char *initrd_filename, -const char *firmware, -const char *netboot_fw, -bool enforce_bios) -{ -Object *new =object_new (TYPE_S390_IPL ); -DeviceState *dev =DEVICE (new); - -if (kernel_filename) { -qdev_prop_set_string (dev,"kernel" , kernel_filename); - } -if (initrd_filename) { -qdev_prop_set_string (dev,"initrd" , initrd_filename); - } -qdev_prop_set_string (dev,"cmdline" , kernel_cmdline); -qdev_prop_set_string (dev,"firmware" , firmware); -qdev_prop_set_string (dev,"netboot_fw" , netboot_fw); -qdev_prop_set_bit (dev,"enforce_bios" , enforce_bios); -object_property_add_child (qdev_get_machine (),TYPE_S390_IPL , - new,NULL ); -object_unref (new); -qdev_init_nofail (dev); -} - - -void s390_create_virtio_net (BusState *bus,const char *name) -{ -int i; - -for (i =0 ; i < nb_nics; i++) { -NICInfo *nd = &nd_table[i]; -DeviceState *dev; - -if (!nd->model) { - nd->model =g_strdup ("virtio" ); - } - -qemu_check_nic_model (nd,"virtio" ); - - dev =qdev_create (bus, name); -qdev_set_nic_properties (dev, nd); -qdev_init_nofail (dev); - } -} - -void gtod_save (QEMUFile *f,void *opaque) -{ -uint64_t tod_low; -uint8_t tod_high; -int r; - - r =s390_get_clock (&tod_high, &tod_low); -if (r) { -fprintf (stderr,"WARNING: Unable to get guest clock for migration. " -"Error code %d. Guest clock will not be migrated " -"which could cause the guest to hang.\n" , r); -qemu_put_byte (f,S390_TOD_CLOCK_VALUE_MISSING ); -return ; - } - -qemu_put_byte (f,S390_TOD_CLOCK_VALUE_PRESENT ); -qemu_put_byte (f, tod_high); -qemu_put_be64 (f, tod_low); -} - -int gtod_load (QEMUFile *f,void *opaque,int version_id) -{ -uint64_t tod_low; -uint8_t tod_high; -int r; - -if (qemu_get_byte (f) ==S390_TOD_CLOCK_VALUE_MISSING ) { -fprintf (stderr,"WARNING: Guest clock was not migrated. This could " -"cause the guest to hang.\n" ); -return 0 ; - } - - tod_high =qemu_get_byte (f); - tod_low =qemu_get_be64 (f); - - r =s390_set_clock (&tod_high, &tod_low); -if (r) { -fprintf (stderr,"WARNING: Unable to set guest clock value. " -"s390_get_clock returned error %d. This could cause " -"the guest to hang.\n" , r); - } - -return 0 ; -} - -void s390_nmi (NMIState *n,int cpu_index,Error **errp) -{ -CPUState *cs =qemu_get_cpu (cpu_index); - -if (s390_cpu_restart (S390_CPU (cs))) { -error_setg (errp,QERR_UNSUPPORTED ); - } -} - -void s390_machine_reset (void ) -{ -S390CPU *ipl_cpu =S390_CPU (qemu_get_cpu (0 )); - -s390_cmma_reset (); -qemu_devices_reset (); -s390_crypto_reset (); - -/* all cpus are stopped - configure and start the ipl cpu only */ -s390_ipl_prepare_cpu (ipl_cpu); -s390_cpu_set_state (CPU_STATE_OPERATING , ipl_cpu); -}hw/s390x/s390-virtio.h +0
-14@@ -12,23 +12,9 @@#ifndef HW_S390_VIRTIO_H #define HW_S390_VIRTIO_H -#include "hw/nmi.h" #include "standard-headers/asm-s390/kvm_virtio.h" #include "standard-headers/asm-s390/virtio-ccw.h" typedef int (*s390_virtio_fn )(const uint64_t *args);void s390_register_virtio_hypercall (uint64_t code,s390_virtio_fn fn); - -void s390_init_ipl_dev (const char *kernel_filename, -const char *kernel_cmdline, -const char *initrd_filename, -const char *firmware, -const char *netboot_fw, -bool enforce_bios); -void s390_create_virtio_net (BusState *bus,const char *name); -void s390_nmi (NMIState *n,int cpu_index,Error **errp); -void s390_machine_reset (void ); -void s390_memory_init (ram_addr_t mem_size); -void gtod_save (QEMUFile *f,void *opaque); -int gtod_load (QEMUFile *f,void *opaque,int version_id);#endif
Re: [Qemu-devel] [PATCH v1 04/11] s390x: get rid of s390-virtio.c
In reply to David HildenbrandQuoted 5 lines · David Hildenbrand
It is a leftover from the days where we had still the !ccw virtio machine. As this one is long gone, let's move everything to
s390-virtio-ccw.c.Cornelia Huck <[email protected]>
I will add the missing Suggested-by: :)
Quoted 2 lines
Signed-off-by David Hildenbrand <[email protected]>---
Signature · 3 lines
Thanks, David
PATCH 5/11 s390x: rename s390-virtio.h to s390-virtio-hcall.h
In reply to David HildenbrandThe only interface left, so let's properly rename it.
---
hw/s390x/s390-virtio-ccw.c | 2 +-
hw/s390x/s390-virtio-hcall.c | 2 +-
hw/s390x/{s390-virtio.h => s390-virtio-hcall.h} | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
rename hw/s390x/{s390-virtio.h => s390-virtio-hcall.h} (92%)hw/s390x/s390-virtio-ccw.c +1 -1
@@ -16,7 +16,7 @@#include "cpu.h" #include "hw/boards.h" #include "exec/address-spaces.h" -#include "s390-virtio.h" +#include "hw/s390x/s390-virtio-hcall.h" #include "hw/s390x/sclp.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/ioinst.h"
hw/s390x/s390-virtio-hcall.c +1 -1
@@ -11,7 +11,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "hw/s390x/s390-virtio.h" +#include "hw/s390x/s390-virtio-hcall.h" #define MAX_DIAG_SUBCODES 255
hw/s390x/s390-virtio-hcall.h renamed from hw/s390x/s390-virtio.h +1 -1
@@ -1,5 +1,5 @@/* -* Virtio interfaces for s390 +* Support for virtio hypercalls on s390x * * Copyright 2012 IBM Corp. * Author(s): Cornelia Huck <[email protected]>
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 05/11] s390x: rename s390-virtio.h to s390-virtio-hcall.h
Quoted 9 lines · David Hildenbrand
The only interface left, so let's properly rename it.
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- hw/s390x/s390-virtio-hcall.c | 2 +- hw/s390x/{s390-virtio.h => s390-virtio-hcall.h} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename hw/s390x/{s390-virtio.h => s390-virtio-hcall.h} (92%)
[...]
Quoted 9 lines
hw/s390x/s390-virtio-hcall.h renamed from hw/s390x/s390-virtio.h +0
-0
hw/s390x/s390-virtio-hcall.h line 5
Quoted 6 lines
hw/s390x/s390-virtio-hcall.h renamed from hw/s390x/s390-virtio.h +1
-1@@ -1,5 +1,5 @@/* -* Virtio interfaces for s390 +* Support for virtio hypercalls on s390x * * Copyright 2012 IBM Corp. * Author(s): Cornelia Huck <[email protected]>
Maybe also rename the HW_S390_VIRTIO_H header guard? Anyway:
Re: [Qemu-devel] [PATCH v1 05/11] s390x: rename s390-virtio.h to s390-virtio-hcall.h
Quoted 29 lines · Thomas Huth
Quoted 9 lines · David Hildenbrand
The only interface left, so let's properly rename it.
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- hw/s390x/s390-virtio-hcall.c | 2 +- hw/s390x/{s390-virtio.h => s390-virtio-hcall.h} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename hw/s390x/{s390-virtio.h => s390-virtio-hcall.h} (92%)[...]
Quoted 9 lines
hw/s390x/s390-virtio-hcall.h renamed from hw/s390x/s390-virtio.h +0
-0hw/s390x/s390-virtio-hcall.h line 5
Quoted 6 lines
hw/s390x/s390-virtio-hcall.h renamed from hw/s390x/s390-virtio.h +1
-1@@ -1,5 +1,5 @@/* -* Virtio interfaces for s390 +* Support for virtio hypercalls on s390x * * Copyright 2012 IBM Corp. * Author(s): Cornelia Huck <[email protected]> Maybe also rename the
HW_S390_VIRTIO_Hheader guard? Anyway:
Quoted 2 lines
Reviewed-by Thomas Huth <[email protected]>
Sure, will do. Is HW_S390_VIRTIO_HCALL_H okay?
(HW_S390X_S390_VIRTIO_HCALL_H doesn't sound necessary)
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 05/11] s390x: rename s390-virtio.h to s390-virtio-hcall.h
Quoted 30 lines · David Hildenbrand
Quoted 29 lines · Thomas Huth
Quoted 9 lines · David Hildenbrand
The only interface left, so let's properly rename it.
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- hw/s390x/s390-virtio-hcall.c | 2 +- hw/s390x/{s390-virtio.h => s390-virtio-hcall.h} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename hw/s390x/{s390-virtio.h => s390-virtio-hcall.h} (92%)[...]
Quoted 9 lines
hw/s390x/s390-virtio-hcall.h renamed from hw/s390x/s390-virtio.h +0
-0hw/s390x/s390-virtio-hcall.h line 5
Quoted 6 lines
hw/s390x/s390-virtio-hcall.h renamed from hw/s390x/s390-virtio.h +1
-1@@ -1,5 +1,5 @@/* -* Virtio interfaces for s390 +* Support for virtio hypercalls on s390x * * Copyright 2012 IBM Corp. * Author(s): Cornelia Huck <[email protected]> Maybe also rename the
HW_S390_VIRTIO_Hheader guard? Anyway:
Quoted 4 lines
Quoted 2 lines
Reviewed-by Thomas Huth <[email protected]>Sure, will do. Is
HW_S390_VIRTIO_HCALL_Hokay?
Sounds fine.
Thomas
PATCH 6/11 target/s390x: cleanup cpu number/address handling
In reply to David HildenbrandSome time ago we discussed that using "id" as property name is not the right thing to do, as it is a reserved property for other devices.
Switch to the term "addr" instead, which matches the definition in the PoP called "CPU address". There is no such thing as cpu number, so rename env.cpu_num to env.cpu_addr.
We can get rid of cpu->id now. Keep cpu->index and env->cpu_addr in sync. cpu->index was already implicitly used by e.g. cpu_exists(), so keeping both in sync seems to be the right thing to do.
cpu->index will now no longer automatically get set via cpu_exec_realizefn(). For now, we were lucky that both implicitly stayed in sync.
Our new cpu property "addr" can be a static property. Range checks can be avoided by using the correct type and the "setting after realized" check is done implicitly.
AFAIK, s390x only supports cpu_add and not device_add for cpus. So we should be able to safely rename that property (no the "id" property could properly be used for device_add, which needs an artificial id for identification purposes).
--- hw/s390x/s390-virtio-ccw.c | 2 +- target/s390x/cpu.c | 69 ++++++++++++---------------------------------- target/s390x/cpu.h | 5 ++-- target/s390x/cpu_models.c | 2 +- target/s390x/excp_helper.c | 2 +- target/s390x/helper.c | 4 +-- target/s390x/misc_helper.c | 4 +-- target/s390x/translate.c | 5 +--- 8 files changed, 28 insertions(+), 65 deletions(-)
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -306,7 +306,7 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev,S390CPU *cpu =S390_CPU (dev);CPUState *cs =CPU (dev); - name =g_strdup_printf ("cpu[%i]" , cpu->env.cpu_num); + name =g_strdup_printf ("cpu[%i]" , cpu->env.cpu_addr);object_property_set_link (OBJECT (hotplug_dev),OBJECT (cs), name, errp);g_free (name);
target/s390x/cpu.c +18 -51
120 lines not on this page · raw message
target/s390x/cpu.h +2 -3
@@ -149,7 +149,7 @@ typedef struct CPUS390XState {CPU_COMMON - uint32_t cpu_num; + uint32_t cpu_addr; /* same as cpu->index */uint64_t cpuid;uint64_t tod_offset;
@@ -193,7 +193,6 @@ struct S390CPU {/*< public >*/ CPUS390XState env; -int64_t id;S390CPUModel *model;/* needed for live migration */ void *irqstate;
@@ -690,7 +689,7 @@ const char *s390_default_cpu_model_name(void);/* helper.c */ S390CPU *cpu_s390x_init (const char *cpu_model);#define cpu_init (model) CPU(cpu_s390x_init(model)) -S390CPU *s390x_new_cpu (const char *cpu_model,int64_t id,Error **errp); +S390CPU *s390x_new_cpu (const char *cpu_model,uint32_t addr,Error **errp);/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */
target/s390x/cpu_models.c +1 -1
@@ -915,7 +915,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) cpu->env.cpuid =s390_cpuid_from_cpu_model (cpu->model);if (tcg_enabled ()) {/* basic mode, write the cpu address into the first 4 bit of the ID */ - cpu->env.cpuid =deposit64 (cpu->env.cpuid,54 ,4 , cpu->env.cpu_num); + cpu->env.cpuid =deposit64 (cpu->env.cpuid,54 ,4 , cpu->env.cpu_addr); } }
target/s390x/excp_helper.c +1 -1
@@ -251,7 +251,7 @@ static void do_ext_interrupt(CPUS390XState *env) lowcore->ext_params2 =cpu_to_be64 (q->param64); lowcore->external_old_psw.mask =cpu_to_be64 (get_psw_mask (env)); lowcore->external_old_psw.addr =cpu_to_be64 (env->psw.addr); - lowcore->cpu_addr =cpu_to_be16 (env->cpu_num |VIRTIO_SUBCODE_64 ); + lowcore->cpu_addr =cpu_to_be16 (env->cpu_addr |VIRTIO_SUBCODE_64 ); mask =be64_to_cpu (lowcore->external_new_psw.mask); addr =be64_to_cpu (lowcore->external_new_psw.addr);
target/s390x/helper.c +2 -2
@@ -104,7 +104,7 @@ S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp)return S390_CPU (CPU (object_new (typename))); } -S390CPU *s390x_new_cpu (const char *cpu_model,int64_t id,Error **errp) +S390CPU *s390x_new_cpu (const char *cpu_model,uint32_t addr,Error **errp) {S390CPU *cpu;Error *err =NULL ;
@@ -114,7 +114,7 @@ S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp) goto out; } -object_property_set_int (OBJECT (cpu), id,"id" , &err); +object_property_set_int (OBJECT (cpu), addr,"addr" , &err);if (err !=NULL ) { goto out; }
target/s390x/misc_helper.c +2 -2
@@ -230,7 +230,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0,/* XXX make different for different CPUs? */ ebcdic_put (sysib.sequence,"QEMUQEMUQEMUQEMU" ,16 );ebcdic_put (sysib.plant,"QEMU" ,4 ); -stw_p (&sysib.cpu_addr, env->cpu_num); +stw_p (&sysib.cpu_addr, env->cpu_addr);cpu_physical_memory_write (a0, &sysib,sizeof (sysib)); }else if ((sel1 ==2 ) && (sel2 ==2 )) {/* Basic Machine CPUs */
@@ -258,7 +258,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0,/* XXX make different for different CPUs? */ ebcdic_put (sysib.sequence,"QEMUQEMUQEMUQEMU" ,16 );ebcdic_put (sysib.plant,"QEMU" ,4 ); -stw_p (&sysib.cpu_addr, env->cpu_num); +stw_p (&sysib.cpu_addr, env->cpu_addr);stw_p (&sysib.cpu_id,0 );cpu_physical_memory_write (a0, &sysib,sizeof (sysib)); }else if ((sel1 ==2 ) && (sel2 ==2 )) {
target/s390x/translate.c +1 -4
@@ -3822,10 +3822,7 @@ static ExitStatus op_ssm(DisasContext *s, DisasOps *o)static ExitStatus op_stap (DisasContext *s,DisasOps *o) {check_privileged (s); -/* ??? Surely cpu address != cpu number. In any case the previous -version of this stored more than the required half-word, so it -is unlikely this has ever been tested. */ -tcg_gen_ld32u_i64 (o->out, cpu_env, offsetof(CPUS390XState , cpu_num)); +tcg_gen_ld32u_i64 (o->out, cpu_env, offsetof(CPUS390XState , cpu_addr));return NO_EXIT ; }
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 06/11] target/s390x: cleanup cpu number/address handling
Quoted 15 lines · On Wed, 30 Aug 2017 19:05:56 +0200 David Hildenbrand <[email protected]> wrote:
Some time ago we discussed that using "id" as property name is not the right thing to do, as it is a reserved property for other devices.
Switch to the term "addr" instead, which matches the definition in the PoP called "CPU address". There is no such thing as cpu number, so rename env.cpu_num to env.cpu_addr.
We can get rid of
cpu->idnow. Keepcpu->indexandenv->cpu_addrin sync.cpu->indexwas already implicitly used by e.g.cpu_exists(), so keeping both in sync seems to be the right thing to do.
cpu->indexwill now no longer automatically get set viacpu_exec_realizefn(). For now, we were lucky that both implicitly stayed in sync.
Quoted 8 lines
Our new cpu property "addr" can be a static property. Range checks can be avoided by using the correct type and the "setting after realized" check is done implicitly.
AFAIK, s390x only supports
cpu_addand notdevice_addfor cpus. So we should be able to safely rename that property (no the "id" property could properly be used fordevice_add, which needs an artificial id for identification purposes).
I cannot parse the sentence in the brackets...
Quoted 12 lines
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- target/s390x/cpu.c | 69 ++++++++++++---------------------------------- target/s390x/cpu.h | 5 ++-- target/s390x/cpu_models.c | 2 +- target/s390x/excp_helper.c | 2 +- target/s390x/helper.c | 4 +-- target/s390x/misc_helper.c | 4 +-- target/s390x/translate.c | 5 +--- 8 files changed, 28 insertions(+), 65 deletions(-)
...the patch seems fine, though :)
Re: [Qemu-devel] [PATCH v1 06/11] target/s390x: cleanup cpu number/address handling
Quoted 22 lines · Cornelia Huck
Quoted 19 lines · On Wed, 30 Aug 2017 19:05:56 +0200 David Hildenbrand <[email protected]> wrote:
Some time ago we discussed that using "id" as property name is not the right thing to do, as it is a reserved property for other devices.
Switch to the term "addr" instead, which matches the definition in the PoP called "CPU address". There is no such thing as cpu number, so rename env.cpu_num to env.cpu_addr.
We can get rid of
cpu->idnow. Keepcpu->indexandenv->cpu_addrin sync.cpu->indexwas already implicitly used by e.g.cpu_exists(), so keeping both in sync seems to be the right thing to do.
cpu->indexwill now no longer automatically get set viacpu_exec_realizefn(). For now, we were lucky that both implicitly stayed in sync.Our new cpu property "addr" can be a static property. Range checks can be avoided by using the correct type and the "setting after realized" check is done implicitly.
Quoted 6 lines
Quoted 4 lines
AFAIK, s390x only supports
cpu_addand notdevice_addfor cpus. So we should be able to safely rename that property (no the "id" property could properly be used fordevice_add, which needs an artificial id for identification purposes).I cannot parse the sentence in the brackets...
Me too :)
...So we should be able to safely rename that property. device_add will later need the reserved "id" property. Hotplugging a CPU would then look like this: "device_add host-s390-cpu id=cpu2 addr=2".
Quoted 16 lines
Quoted 13 lines
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- target/s390x/cpu.c | 69 ++++++++++++---------------------------------- target/s390x/cpu.h | 5 ++-- target/s390x/cpu_models.c | 2 +- target/s390x/excp_helper.c | 2 +- target/s390x/helper.c | 4 +-- target/s390x/misc_helper.c | 4 +-- target/s390x/translate.c | 5 +--- 8 files changed, 28 insertions(+), 65 deletions(-)...the patch seems fine, though :)
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 06/11] target/s390x: cleanup cpu number/address handling
Quoted 28 lines · On Thu, 31 Aug 2017 16:41:47 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 27 lines · Cornelia Huck
Quoted 23 lines · On Wed, 30 Aug 2017 19:05:56 +0200 David Hildenbrand <[email protected]> wrote:
Some time ago we discussed that using "id" as property name is not the right thing to do, as it is a reserved property for other devices.
Switch to the term "addr" instead, which matches the definition in the PoP called "CPU address". There is no such thing as cpu number, so rename env.cpu_num to env.cpu_addr.
We can get rid of
cpu->idnow. Keepcpu->indexandenv->cpu_addrin sync.cpu->indexwas already implicitly used by e.g.cpu_exists(), so keeping both in sync seems to be the right thing to do.
cpu->indexwill now no longer automatically get set viacpu_exec_realizefn(). For now, we were lucky that both implicitly stayed in sync.Our new cpu property "addr" can be a static property. Range checks can be avoided by using the correct type and the "setting after realized" check is done implicitly.
AFAIK, s390x only supports
cpu_addand notdevice_addfor cpus. So we should be able to safely rename that property (no the "id" property could properly be used fordevice_add, which needs an artificial id for identification purposes).
Quoted 7 lines
Quoted 1 line
I cannot parse the sentence in the brackets...
Me too :)
...So we should be able to safely rename that property.
device_addwill later need the reserved "id" property. Hotplugging a CPU would then look like this: "device_addhost-s390-cpu id=cpu2 addr=2".
Yup, that's understandable :)
Re: [Qemu-devel] [PATCH v1 06/11] target/s390x: cleanup cpu number/address handling
In reply to Cornelia HuckQuoted 18 lines · On Thu, 31 Aug 2017 16:35:13 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 15 lines · On Wed, 30 Aug 2017 19:05:56 +0200 David Hildenbrand <[email protected]> wrote:
Some time ago we discussed that using "id" as property name is not the right thing to do, as it is a reserved property for other devices.
Switch to the term "addr" instead, which matches the definition in the PoP called "CPU address". There is no such thing as cpu number, so rename env.cpu_num to env.cpu_addr.
We can get rid of
cpu->idnow. Keepcpu->indexandenv->cpu_addrin sync.cpu->indexwas already implicitly used by e.g.cpu_exists(), so keeping both in sync seems to be the right thing to do.
cpu->indexwill now no longer automatically get set viacpu_exec_realizefn(). For now, we were lucky that both implicitly stayed in sync.
Quoted 8 lines
Quoted 8 lines
Our new cpu property "addr" can be a static property. Range checks can be avoided by using the correct type and the "setting after realized" check is done implicitly.
AFAIK, s390x only supports
cpu_addand notdevice_addfor cpus. So we should be able to safely rename that property (no the "id" property could properly be used fordevice_add, which needs an artificial id for identification purposes).
this patch seems to somewhat conflicting with
https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg06505.html
that were supposed to go via machine tree and which I've respinned today to fix conflicts due just merged pull req.
Cornelia,
Could you put/merge it via s390x tree so that David and I work won't clash again?
Re: [Qemu-devel] [PATCH v1 06/11] target/s390x: cleanup cpu number/address handling
Quoted 29 lines · On Thu, 31 Aug 2017 18:03:52 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 18 lines · On Thu, 31 Aug 2017 16:35:13 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 15 lines · On Wed, 30 Aug 2017 19:05:56 +0200 David Hildenbrand <[email protected]> wrote:
Some time ago we discussed that using "id" as property name is not the right thing to do, as it is a reserved property for other devices.
Switch to the term "addr" instead, which matches the definition in the PoP called "CPU address". There is no such thing as cpu number, so rename env.cpu_num to env.cpu_addr.
We can get rid of
cpu->idnow. Keepcpu->indexandenv->cpu_addrin sync.cpu->indexwas already implicitly used by e.g.cpu_exists(), so keeping both in sync seems to be the right thing to do.
cpu->indexwill now no longer automatically get set viacpu_exec_realizefn(). For now, we were lucky that both implicitly stayed in sync.Quoted 8 lines
Quoted 8 lines
Our new cpu property "addr" can be a static property. Range checks can be avoided by using the correct type and the "setting after realized" check is done implicitly.
AFAIK, s390x only supports
cpu_addand notdevice_addfor cpus. So we should be able to safely rename that property (no the "id" property could properly be used fordevice_add, which needs an artificial id for identification purposes).
Quoted 8 lines
this patch seems to somewhat conflicting with
https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg06505.html
that were supposed to go via machine tree and which I've respinned today to fix conflicts due just merged pull req.Cornelia,
Could you put/merge it via s390x tree so that David and I work won't clash again?
I can do that, sure. I can put your patch on top of David's.
PATCH 7/11 target/s390x: rename next_cpu_id to next_cpu_addr
In reply to David HildenbrandAdapt the term address/adddr. While at it, fix the type and drop the initialization to 0 (which is superfluous).
--- target/s390x/cpu-qom.h | 2 +- target/s390x/cpu.c | 9 ++++----- target/s390x/helper.c | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-)
target/s390x/cpu-qom.h +1 -1
@@ -52,7 +52,7 @@ typedef struct S390CPUClass {bool is_migration_safe;const char *desc; -int64_t next_cpu_id; +uint32_t next_cpu_addr;DeviceRealize parent_realize;void (*parent_reset)(CPUState *cpu);
target/s390x/cpu.c +4 -5
@@ -201,10 +201,10 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp) cpu->env.cpu_addr); goto out; } -if (cpu->env.cpu_addr != scc->next_cpu_id) { +if (cpu->env.cpu_addr != scc->next_cpu_addr) {error_setg (&err,"Unable to add CPU: %" PRIu32 -", the next available nr is %" PRIi64, cpu->env.cpu_addr, - scc->next_cpu_id); +", the next available addr is %" PRIu32, cpu->env.cpu_addr, + scc->next_cpu_addr); goto out; }
@@ -214,7 +214,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)if (err !=NULL ) { goto out; } - scc->next_cpu_id++; + scc->next_cpu_addr++;#if !defined(CONFIG_USER_ONLY )qemu_register_reset (s390_cpu_machine_reset_cb, cpu);
@@ -459,7 +459,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (scc);DeviceClass *dc =DEVICE_CLASS (oc); - scc->next_cpu_id =0 ; scc->parent_realize = dc->realize; dc->realize = s390_cpu_realizefn; dc->props = s390x_cpu_properties;
target/s390x/helper.c +2 -2
@@ -134,9 +134,9 @@ S390CPU *cpu_s390x_init(const char *cpu_model)Error *err =NULL ;S390CPU *cpu;/* Use to track CPU ID for linux-user only */ -static int64_t next_cpu_id; +static uint32_t next_cpu_addr; - cpu =s390x_new_cpu (cpu_model, next_cpu_id++, &err); + cpu =s390x_new_cpu (cpu_model, next_cpu_addr++, &err);if (err) {error_report_err (err); }
Signature · 1 line
2.13.5
PATCH 8/11 s390x: allow only 1 CPU with TCG
In reply to David HildenbrandSpecifying more than 1 CPU (e.g. -smp 5) leads to SIGP errors (the guest tries to bring these CPUs up but fails), because we don't support multiple CPUs on s390x under TCG.
Let's bail out if more than 1 are specified, so we don't raise people's hope.
--- hw/s390x/s390-virtio-ccw.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/s390x/s390-virtio-ccw.c +6 -0
@@ -23,6 +23,7 @@#include "hw/s390x/css.h" #include "virtio-ccw.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" #include "hw/s390x/storage-attributes.h"
@@ -56,6 +57,11 @@ static void s390_init_cpus(MachineState *machine)if (machine->cpu_model ==NULL ) { machine->cpu_model =s390_default_cpu_model_name (); } +if (tcg_enabled () && max_cpus >1 ) { +error_report ("Number of SMP CPUs requested (%d) exceeds max CPUs " +"supported by TCG (1) on s390x" , max_cpus); +exit (1 ); + } ms->cpus = g_new0(S390CPU *, max_cpus);
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 08/11] s390x: allow only 1 CPU with TCG
Quoted 6 lines · David Hildenbrand
Specifying more than 1 CPU (e.g. -smp 5) leads to SIGP errors (the guest tries to bring these CPUs up but fails), because we don't support multiple CPUs on s390x under TCG.
Let's bail out if more than 1 are specified, so we don't raise people's hope.
Aurelien recently posted a patch to add that basic SIGP support:
https://patchwork.kernel.org/patch/9717489/
I think it would make more sense to get that included instead.
Thomas
Re: [Qemu-devel] [PATCH v1 08/11] s390x: allow only 1 CPU with TCG
Quoted 5 lines · On Wed, 30 Aug 2017 21:06:55 +0200 Thomas Huth <[email protected]> wrote:
Quoted 4 lines · David Hildenbrand
Specifying more than 1 CPU (e.g. -smp 5) leads to SIGP errors (the guest tries to bring these CPUs up but fails), because we don't support multiple CPUs on s390x under TCG.
Quoted 8 lines
Quoted 2 lines
Let's bail out if more than 1 are specified, so we don't raise people's hope.
Aurelien recently posted a patch to add that basic SIGP support:
https://patchwork.kernel.org/patch/9717489/
I think it would make more sense to get that included instead.
I'd look at it if it were reposted :)
Re: [Qemu-devel] [PATCH v1 08/11] s390x: allow only 1 CPU with TCG
In reply to Thomas HuthQuoted 8 lines · Thomas Huth
Quoted 6 lines · David Hildenbrand
Specifying more than 1 CPU (e.g. -smp 5) leads to SIGP errors (the guest tries to bring these CPUs up but fails), because we don't support multiple CPUs on s390x under TCG.
Let's bail out if more than 1 are specified, so we don't raise people's hope.
Quoted 8 lines
Aurelien recently posted a patch to add that basic SIGP support:
https://patchwork.kernel.org/patch/9717489/
I think it would make more sense to get that included instead.
Thomas
Even then, it doesn't work reliably:
- "*very rough* SMP support"
- "this patch is nothing more than a way to determine what needs to be implemented"
- "It should be rewritten from scratch before reaching in an acceptable state."
Such broken feature should not be exposed to the user. Once we have properly fixed that we can enable and announce it "s390x now supports more than 1 VCPU under TCG". At this point, this is just wrong, even with this patch included.
So I'd suggest including this now and reverting it once we have actual support. "so we don't raise people's hope."
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 08/11] s390x: allow only 1 CPU with TCG
In reply to David HildenbrandQuoted 25 lines · On Wed, 30 Aug 2017 19:05:58 +0200 David Hildenbrand <[email protected]> wrote:
Specifying more than 1 CPU (e.g. -smp 5) leads to SIGP errors (the guest tries to bring these CPUs up but fails), because we don't support multiple CPUs on s390x under TCG.
Let's bail out if more than 1 are specified, so we don't raise people's hope.
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/s390x/s390-virtio-ccw.c +1
-0@@ -23,6 +23,7 @@#include "hw/s390x/css.h" #include "virtio-ccw.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" #include "hw/s390x/storage-attributes.h"
hw/s390x/s390-virtio-ccw.c static void s390_init_cpus(MachineState *machine) · line 62
Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +3
-0@@ -56,6 +57,11 @@ static void s390_init_cpus(MachineState *machine)if (machine->cpu_model ==NULL ) { machine->cpu_model =s390_default_cpu_model_name (); } +if (tcg_enabled () && max_cpus >1 ) { +error_report ("Number of SMP CPUs requested (%d) exceeds max CPUs " +"supported by TCG (1) on s390x" , max_cpus);
Make this a #define, so we can just flip the switch when smp support is ready?
Quoted 5 lines
hw/s390x/s390-virtio-ccw.c +2
-0+exit (1 ); + } ms->cpus = g_new0(S390CPU *, max_cpus);
Re: [Qemu-devel] [PATCH v1 08/11] s390x: allow only 1 CPU with TCG
Quoted 29 lines · Cornelia Huck
Quoted 26 lines · On Wed, 30 Aug 2017 19:05:58 +0200 David Hildenbrand <[email protected]> wrote:
Specifying more than 1 CPU (e.g. -smp 5) leads to SIGP errors (the guest tries to bring these CPUs up but fails), because we don't support multiple CPUs on s390x under TCG.
Let's bail out if more than 1 are specified, so we don't raise people's hope.
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/s390x/s390-virtio-ccw.c +1
-0@@ -23,6 +23,7 @@#include "hw/s390x/css.h" #include "virtio-ccw.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" #include "hw/s390x/storage-attributes.h" @@ -56,6 +57,11 @@ static void s390_init_cpus(MachineState *machine)if (machine->cpu_model ==NULL ) {
Quoted 8 lines
hw/s390x/s390-virtio-ccw.c static void s390_init_cpus(MachineState *machine) · line 62
Quoted 5 lines
hw/s390x/s390-virtio-ccw.c +3
-0machine->cpu_model =s390_default_cpu_model_name (); } +if (tcg_enabled () && max_cpus >1 ) { +error_report ("Number of SMP CPUs requested (%d) exceeds max CPUs " +"supported by TCG (1) on s390x" , max_cpus);Make this a #define, so we can just flip the switch when smp support is ready?
As an alternative: yield a warning?
Quoted 7 lines
Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +2
-0+exit (1 ); + } ms->cpus = g_new0(S390CPU *, max_cpus);
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 08/11] s390x: allow only 1 CPU with TCG
Quoted 39 lines · On Thu, 31 Aug 2017 17:03:21 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 29 lines · Cornelia Huck
Quoted 26 lines · On Wed, 30 Aug 2017 19:05:58 +0200 David Hildenbrand <[email protected]> wrote:
Specifying more than 1 CPU (e.g. -smp 5) leads to SIGP errors (the guest tries to bring these CPUs up but fails), because we don't support multiple CPUs on s390x under TCG.
Let's bail out if more than 1 are specified, so we don't raise people's hope.
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/s390x/s390-virtio-ccw.c +1
-0@@ -23,6 +23,7 @@#include "hw/s390x/css.h" #include "virtio-ccw.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" #include "hw/s390x/storage-attributes.h" @@ -56,6 +57,11 @@ static void s390_init_cpus(MachineState *machine)if (machine->cpu_model ==NULL ) {Quoted 8 lines
hw/s390x/s390-virtio-ccw.c static void s390_init_cpus(MachineState *machine) · line 62
Quoted 5 lines
hw/s390x/s390-virtio-ccw.c +3
-0machine->cpu_model =s390_default_cpu_model_name (); } +if (tcg_enabled () && max_cpus >1 ) { +error_report ("Number of SMP CPUs requested (%d) exceeds max CPUs " +"supported by TCG (1) on s390x" , max_cpus);Make this a #define, so we can just flip the switch when smp support is ready?
Quoted 1 line
As an alternative: yield a warning?
If we know that this can't work, it makes sense to stop immediately, no?
Quoted 10 lines
Quoted 8 lines
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +2
-0+exit (1 ); + } ms->cpus = g_new0(S390CPU *, max_cpus);
Re: [Qemu-devel] [PATCH v1 08/11] s390x: allow only 1 CPU with TCG
Quoted 42 lines · Cornelia Huck
Quoted 39 lines · On Thu, 31 Aug 2017 17:03:21 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 37 lines · Cornelia Huck
Quoted 25 lines · On Wed, 30 Aug 2017 19:05:58 +0200 David Hildenbrand <[email protected]> wrote:
Specifying more than 1 CPU (e.g. -smp 5) leads to SIGP errors (the guest tries to bring these CPUs up but fails), because we don't support multiple CPUs on s390x under TCG.
Let's bail out if more than 1 are specified, so we don't raise people's hope.
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/s390x/s390-virtio-ccw.c +1
-0@@ -23,6 +23,7 @@#include "hw/s390x/css.h" #include "virtio-ccw.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" #include "hw/s390x/storage-attributes.h" hw/s390x/s390-virtio-ccw.c static void s390_init_cpus(MachineState *machine) · line 62
Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +3
-0@@ -56,6 +57,11 @@ static void s390_init_cpus(MachineState *machine)if (machine->cpu_model ==NULL ) { machine->cpu_model =s390_default_cpu_model_name (); } +if (tcg_enabled () && max_cpus >1 ) { +error_report ("Number of SMP CPUs requested (%d) exceeds max CPUs " +"supported by TCG (1) on s390x" , max_cpus);Make this a #define, so we can just flip the switch when smp support is ready?
Quoted 3 lines
Quoted 1 line
As an alternative: yield a warning?
If we know that this can't work, it makes sense to stop immediately, no?
Hmm, like that than?
hw/s390x/s390-virtio-ccw.c +7 -0
@@ -23,6 +23,7 @@#include "hw/s390x/css.h" #include "virtio-ccw.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" #include "hw/s390x/storage-attributes.h"
@@ -56,6 +57,12 @@ static void s390_init_cpus(MachineState *machine)if (machine->cpu_model ==NULL ) { machine->cpu_model =s390_default_cpu_model_name (); } +if (tcg_enabled () && max_cpus >S390_TCG_MAX_CPUS ) { +error_report ("Number of SMP CPUs requested (%d) exceeds max CPUs " +"supported by TCG (%d) on s390x" , max_cpus, +S390_TCG_MAX_CPUS ); +exit (1 ); + } ms->cpus = g_new0(S390CPU *, max_cpus);
target/s390x/cpu.h +0 -0
@@ -210,6 +210,8 @@ static inline S390CPU
*s390_env_get_cpu(CPUS390XState *env)
#define ENV_OFFSET offsetof(S390CPU, env)
+#define S390_TCG_MAX_CPUS 1
+
#ifndef CONFIG_USER_ONLY
extern const struct VMStateDescription vmstate_s390_cpu; #endif
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v1 08/11] s390x: allow only 1 CPU with TCG
Quoted 44 lines · On Thu, 31 Aug 2017 17:33:13 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 1 line · Cornelia Huck
If we know that this can't work, it makes sense to stop immediately, no?
Hmm, like that than?
hw/s390x/s390-virtio-ccw.c +7
-0@@ -23,6 +23,7 @@#include "hw/s390x/css.h" #include "virtio-ccw.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" #include "hw/s390x/storage-attributes.h" @@ -56,6 +57,12 @@ static void s390_init_cpus(MachineState *machine)if (machine->cpu_model ==NULL ) { machine->cpu_model =s390_default_cpu_model_name (); } +if (tcg_enabled () && max_cpus >S390_TCG_MAX_CPUS ) { +error_report ("Number of SMP CPUs requested (%d) exceeds max CPUs " +"supported by TCG (%d) on s390x" , max_cpus, +S390_TCG_MAX_CPUS ); +exit (1 ); + } ms->cpus = g_new0(S390CPU *, max_cpus);target/s390x/cpu.h +2
-0@@ -210,6 +210,8 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)#define ENV_OFFSET offsetof(S390CPU, env) +#define S390_TCG_MAX_CPUS 1 +#ifndef CONFIG_USER_ONLY extern const struct VMStateDescription vmstate_s390_cpu;
Quoted 3 lines
#endif
Looks good!
PATCH 9/11 target/s390x: tcg_s390_program_interrupt() will never return
In reply to David HildenbrandThe assert should hold in both scenarios.
--- target/s390x/interrupt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/s390x/interrupt.c +1 -2
@@ -32,9 +32,8 @@ static void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code,#ifdef CONFIG_TCG trigger_pgm_exception (env, code, ilen);cpu_loop_exit (CPU (s390_env_get_cpu (env))); -#else -g_assert_not_reached ();#endif +g_assert_not_reached (); }void program_interrupt (CPUS390XState *env,uint32_t code,int ilen)
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 09/11] target/s390x: tcg_s390_program_interrupt() will never return
Quoted 12 lines · David Hildenbrand
The assert should hold in both scenarios.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/interrupt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/s390x/interrupt.c +0
-0
target/s390x/interrupt.c static void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, · line 37
Quoted 8 lines
target/s390x/interrupt.c +1
-2@@ -32,9 +32,8 @@ static void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code,#ifdef CONFIG_TCG trigger_pgm_exception (env, code, ilen);cpu_loop_exit (CPU (s390_env_get_cpu (env))); -#else -g_assert_not_reached ();#endif +g_assert_not_reached (); }
Not sure if this really makes sense ... cpu_loop_exit() is already marked with QEMU_NORETURN, so a know-it-all new version of GCC might complain one day if there's other code after this call. I'd better keep it the way it is.
Thomas
Re: [Qemu-devel] [PATCH v1 09/11] target/s390x: tcg_s390_program_interrupt() will never return
Quoted 18 lines · Thomas Huth
Quoted 17 lines · David Hildenbrand
The assert should hold in both scenarios.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/interrupt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/s390x/interrupt.c +0
-2@@ -32,9 +32,8 @@ static void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code,#ifdef CONFIG_TCG trigger_pgm_exception (env, code, ilen);cpu_loop_exit (CPU (s390_env_get_cpu (env))); -#else -g_assert_not_reached ();
Quoted 8 lines
target/s390x/interrupt.c static void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, · line 37
Quoted 3 lines
target/s390x/interrupt.c +1
-0#endif +g_assert_not_reached (); }Not sure if this really makes sense ...
cpu_loop_exit()is already marked withQEMU_NORETURN, so a know-it-all new version of GCC might complain one day if there's other code after this call. I'd better keep it the way it is.
Good point, I'll drop this patch. Thanks!
Quoted 3 lines
Thomas
Signature · 3 lines
Thanks, David
PATCH 10/11 target/s390x: use trigger_pgm_exception() in s390_cpu_handle_mmu_fault()
In reply to David HildenbrandThis looks cleaner.
--- target/s390x/excp_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/s390x/excp_helper.c +1 -2
@@ -59,8 +59,7 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, {S390CPU *cpu =S390_CPU (cs); - cs->exception_index =EXCP_PGM ; - cpu->env.int_pgm_code =PGM_ADDRESSING ; +trigger_pgm_exception (&cpu->env,PGM_ADDRESSING ,ILEN_AUTO );/* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */ cpu->env.__excp_addr = address;
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 10/11] target/s390x: use trigger_pgm_exception() in s390_cpu_handle_mmu_fault()
Quoted 12 lines · David Hildenbrand
This looks cleaner.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/excp_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/s390x/excp_helper.c +0
-0
target/s390x/excp_helper.c int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, · line 65
Quoted 9 lines
target/s390x/excp_helper.c +1
-2@@ -59,8 +59,7 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, {S390CPU *cpu =S390_CPU (cs); - cs->exception_index =EXCP_PGM ; - cpu->env.int_pgm_code =PGM_ADDRESSING ; +trigger_pgm_exception (&cpu->env,PGM_ADDRESSING ,ILEN_AUTO );/* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */ cpu->env.__excp_addr = address;
trigger_pgm_exception() additionally sets int_pgm_ilen ... I assume that's OK here? A comment in the patch description would be helpful.
Thomas
Re: [Qemu-devel] [PATCH v1 10/11] target/s390x: use trigger_pgm_exception() in s390_cpu_handle_mmu_fault()
Quoted 16 lines · Thomas Huth
Quoted 15 lines · David Hildenbrand
This looks cleaner.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/excp_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/s390x/excp_helper.c +0
-0@@ -59,8 +59,7 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, {S390CPU *cpu =S390_CPU (cs);
Quoted 10 lines
target/s390x/excp_helper.c int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, · line 65
Quoted 6 lines
target/s390x/excp_helper.c +1
-2- cs->exception_index =EXCP_PGM ; - cpu->env.int_pgm_code =PGM_ADDRESSING ; +trigger_pgm_exception (&cpu->env,PGM_ADDRESSING ,ILEN_AUTO );/* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */ cpu->env.__excp_addr = address;
trigger_pgm_exception()additionally setsint_pgm_ilen... I assume that's OK here? A comment in the patch description would be helpful.
As far as I can tell, ilen is completely ignored for linux-user (see cpu_loop() in linux-user/main.c)
Will add a comment, thanks!
Quoted 2 lines
Thomas
Signature · 3 lines
Thanks, David
PATCH 11/11 target/s390x: use program_interrupt() in per_check_exception()
In reply to David HildenbrandI am not sure if we are handling ilen the right way here. ilen should always match the instruction triggering the exception. This is relevant for per exceptions triggered via EXECUTE instructions. The ilen to be indicated has to match the EXECUTE instruction.
Clean it up for now but leave ilen as is, we can fix that later.
--- target/s390x/misc_helper.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
target/s390x/misc_helper.c +3 -6
@@ -445,14 +445,11 @@ void HELPER(chsc)(CPUS390XState *env, uint64_t inst)#ifndef CONFIG_USER_ONLY void HELPER (per_check_exception )(CPUS390XState *env) { -CPUState *cs =CPU (s390_env_get_cpu (env)); +uint32_t ilen;if (env->per_perc_atmid) { - env->int_pgm_code =PGM_PER ; - env->int_pgm_ilen =get_ilen (cpu_ldub_code (env, env->per_address)); - - cs->exception_index =EXCP_PGM ; -cpu_loop_exit (cs); + ilen =get_ilen (cpu_ldub_code (env, env->per_address)); +program_interrupt (env,PGM_PER , ilen); } }
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v1 11/11] target/s390x: use program_interrupt() in per_check_exception()
Quoted 23 lines · David Hildenbrand
I am not sure if we are handling ilen the right way here. ilen should always match the instruction triggering the exception. This is relevant for per exceptions triggered via EXECUTE instructions. The ilen to be indicated has to match the EXECUTE instruction.
Clean it up for now but leave ilen as is, we can fix that later.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/misc_helper.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)target/s390x/misc_helper.c +1
-1@@ -445,14 +445,11 @@ void HELPER(chsc)(CPUS390XState *env, uint64_t inst)#ifndef CONFIG_USER_ONLY void HELPER (per_check_exception )(CPUS390XState *env) { -CPUState *cs =CPU (s390_env_get_cpu (env)); +uint32_t ilen;
target/s390x/misc_helper.c void HELPER(chsc)(CPUS390XState *env, uint64_t inst) · line 454
Quoted 10 lines
target/s390x/misc_helper.c +2
-5if (env->per_perc_atmid) { - env->int_pgm_code =PGM_PER ; - env->int_pgm_ilen =get_ilen (cpu_ldub_code (env, env->per_address)); - - cs->exception_index =EXCP_PGM ; -cpu_loop_exit (cs); + ilen =get_ilen (cpu_ldub_code (env, env->per_address)); +program_interrupt (env,PGM_PER , ilen); } }
The changes basically look fine to me, but may I suggest to
1) Add a comment to the code about your concerns with ilen
2) Change the patch description to focus on the work that is actually done here instead of only talking about your ilen concerns?
Thanks,
Thomas
Quoted 5 lines · On Wed, 30 Aug 2017 19:05:50 +0200 David Hildenbrand <[email protected]> wrote:
No new functionality, only cleanups, some of the discussed during the last round of cleanups.
Not sure if the first two patches should be sent separatly? Anyhow, they are most probably not worth the trouble :)
If you want to clean up the other unneeded includes of cpu-all.h as well, it might make sense to send them separately. Otherwise, I'm happy to route them through s390-next if nobody complains.
Quoted 5 lines
The biggest part of this series is getting rid of
s390-virtio.cand cleaning up our cpu number/id handling.Based on:
git://github.com/cohuck/qemus390-next
Looking forward to v2 :)
Quoted 40 lines
David Hildenbrand (11):
exec,dump: don't includeexec/exec-all.hexplicitly
cpu: drop old comments describing members
s390x: store cpu states inside machine state
s390x: get rid ofs390-virtio.c
s390x: renames390-virtio.htos390-virtio-hcall.htarget/s390x: cleanup cpu number/address handling target/s390x: renamenext_cpu_idtonext_cpu_addr
s390x: allow only 1 CPU with TCG
target/s390x:tcg_s390_program_interrupt()will never return target/s390x: usetrigger_pgm_exception()ins390_cpu_handle_mmu_fault()target/s390x: use
program_interrupt()inper_check_exception()dump.c | 1 - exec.c | 1 - hw/s390x/Makefile.objs | 1 - hw/s390x/s390-virtio-ccw.c | 169 ++++++++++++++++++++++++++++++- hw/s390x/s390-virtio-hcall.c | 2 +- hw/s390x/s390-virtio-hcall.h | 20 ++++ hw/s390x/s390-virtio.c | 201 ------------------------------------- hw/s390x/s390-virtio.h | 35 ------- include/hw/s390x/s390-virtio-ccw.h | 3 + include/qom/cpu.h | 6 +- target/s390x/cpu-qom.h | 2 +- target/s390x/cpu.c | 74 ++++---------- target/s390x/cpu.h | 5 +- target/s390x/cpu_models.c | 2 +- target/s390x/excp_helper.c | 5 +- target/s390x/helper.c | 8 +- target/s390x/interrupt.c | 3 +- target/s390x/misc_helper.c | 13 +-- target/s390x/translate.c | 5 +- 19 files changed, 230 insertions(+), 326 deletions(-) create mode 100644 hw/s390x/s390-virtio-hcall.h delete mode 100644 hw/s390x/s390-virtio.c delete mode 100644 hw/s390x/s390-virtio.h