On Mon, 7 Sep 2020 21:46:28 +0200 Philippe Mathieu-Daudé <phi...@redhat.com> wrote:
> On 9/7/20 7:26 PM, Laurent Vivier wrote: > > On 07/09/2020 18:29, Laurent Vivier wrote: > >> I think we should not enter in cpu_loop() with halted set to 1. > >> > >> Before the patch of this series, s390_cpu_reset() is called twice, and > >> on the second call, halted is already 0. > >> > >> With start_powered_off set to true in initfn, on the first reset > >> "halted" is 0 and on the second it is 1 (because it has been copied from > >> start_powered_off) and so cpu_loop() starts with halted set to 1 and > >> fails. > > > > What is happening: > > > > [without start_powered_off] > > > > 1- halted is set to 1 in s390x_cpu_initfn() > > 2- halted is set to 0 in s390x_cpu_reset() by parent_reset() > > (cpu_common_reset() > > 3- cpu_loop() is always entered with halted set to 0 > > > > [with start_powered_off] > > > > 1- halted is set to start_powered_off (1) in s390x_cpu_reset() by > > parent_reset() (cpu_common_reset() > > 2- cpu_loop() is always entered with halted set to 1 > > > > So in the first case, cpu_loop() is always started with halted set to 0 > > and in the second case with halted set to 1. > > > > And I think, with linux-user, it should never be started with halted set > > to 1. linux-user always confuses me a bit, but this seems right. > > > > We can't add a "#ifdef CONFIG_USER_ONLY" in hw/core/cpu.c to set halted > > to 0 because it is in the common files, but we can do: > > > > diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c > > index 73d7d6007e8e..749cd548f0f3 100644 > > --- a/target/s390x/cpu.c > > +++ b/target/s390x/cpu.c > > @@ -291,9 +291,9 @@ static void s390_cpu_initfn(Object *obj) > > S390CPU *cpu = S390_CPU(obj); > > > > cpu_set_cpustate_pointers(cpu); > > - cs->start_powered_off = true; > > cs->exception_index = EXCP_HLT; > > #if !defined(CONFIG_USER_ONLY) > > + cs->start_powered_off = true; > > object_property_add(obj, "crash-information", "GuestPanicInformation", > > s390_cpu_get_crash_info_qom, NULL, NULL, NULL); > > cpu->env.tod_timer = > > This looks like the correct fix indeed :) > (Maybe worth adding a comment around). Agreed on both counts. > Thanks for investigating! And here as well :)