On Mon, 4 Nov 2024 at 22:18, Helge Deller <del...@kernel.org> wrote:
>
> Add the CPU reset method, which resets all CPU registers and the TLB to
> zero. Then the CPU will switch to 32-bit mode (PSW_W bit is not set) and
> start execution at address 0xf0000004.
> Although we currently want to zero out all values in the CPUHPPAState
> struct, add the end_reset_fields marker in case the state structs gets
> extended with other variables later on which should not be reset.
>
> Signed-off-by: Helge Deller <del...@gmx.de>
>
> V2: (based on feedback by Peter Maydell)
> - Add end_reset_fields marker
> - call reset function in hppa_cpu_initfn()
>
> diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
> index c38439c180..d12bf65021 100644
> --- a/target/hppa/cpu.c
> +++ b/target/hppa/cpu.c
> @@ -194,13 +194,8 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error 
> **errp)
>
>  static void hppa_cpu_initfn(Object *obj)
>  {
> -    CPUState *cs = CPU(obj);
> -    HPPACPU *cpu = HPPA_CPU(obj);
> -    CPUHPPAState *env = &cpu->env;
> -
> -    cs->exception_index = -1;
> -    cpu_hppa_loaded_fr0(env);
> -    cpu_hppa_put_psw(env, PSW_W);
> +    /* inital values loaded via reset in hppa_cpu_reset_hold() */
> +    resettable_reset(obj, RESET_TYPE_COLD);

You can't call reset from the CPU initfn (among other
things, the CPU object isn't fully constructed until
its realize method has been called).

CPU reset is rather awkward at the moment because it
doesn't happen automatically (because CPUs are not
subtypes of Device). So generally the way it works at
the moment is that the machine model code arranges to
reset the CPU object "manually". For Arm we do this
as part of setting up the CPU for however we're booting
the kernel in hw/arm/boot.c. It looks to me like for
HPPA the best place would be to call cpu_reset() in
hppa_machine_reset(), in the loop just before doing
the other CPU setup like calling cpu_set_pc().

>  }


Otherwise this looks good.

thanks
-- PMM

Reply via email to