On Wed, 12 Mar 2025, Andrew Randrianasulu wrote:
> ---quote from user manual ---
>
> 2.1.1.4 Processor ID Register (PIR)
> The Processor Identification Register (PIR) is a 32-bit register that
> holds a processor identification tag. In the
> 970MP processing unit, this tag is in the three least-significant bits
> (29:31). The least-significant bit of the
> processor identification tag (PID) is hardwired to ‘0’ for PU0 and to
> ‘1’ for PU1. This tag is used to tag bus
> transactions and to differentiate processors in multiprocessor
> systems. The PIR is a read-only register. The
> format of the register is as follows:
>
> 0:28—Reserved (read as zeros)
> 29:31 PID3-bit processor ID value (least-significant bit hardwired to
> differentiate PU0 and PU1)
>
>
> During power-on reset, PID is set to a unique value for each processor
> in a multi processor system.
>
> =====
>
> 7.2.2.4 Processor ID (PROCID[0:1])–Input
> The 2-bit processor ID is used to assign unique IDs to the two 970MP
> processing units in a system that can
> have up to eight processors. The PROCID signals are sampled during
> power-on reset, and the 2-bit value is
> placed in the second and third lowest-order bits of the Processor ID
> Register (PIR) of each processing unit.
> The lowest-order PIR bit is hardwired to a '0' for PU0 and to '1' for PU1.
> Timing: These signals should be permanently tied to VDD or GND, as
> appropriate for the required ID value.
>
> === quote end ===
This suggests that at least on G5 it's strapped in hardware by wiring the
chip pins so each CPU has a different ID. The G4 could write it from
software but maybe it doesn't do that and sets it by hardware pins as
well. In any case, OpenBIOS does not write it but would set the reg
property based on it so probably it should be set in QEMU when creating
the CPUs. Then the part of the OpenBIOS patch that comments out the call
to set reg property based on pir and the part that sets the reg property
later can be dropped and thus the patch simplified (need less changes to
OpenBIOS).
To set PIR in QEMU look at what other machines do. By searching for PIR in
hw/ppc I've found:
hw/ppc/spapr_cpu_core.c::spapr_realize_vcpu()
...
env->spr_cb[SPR_PIR].default_value = cs->cpu_index;
hw/ppc/e500.c::ppce500_init()
for (i = 0; i < smp_cpus; i++) {
...
env->spr_cb[SPR_BOOKE_PIR].default_value = cs->cpu_index = i;
The SPR number is different on e500 but the code is more similar to mac99
so in mac99 I think we should do what e500 does but use SPR_PIR instead of
SPR_BOOKE_PIR. What I'm not sure about if the cpu_reset in the kick
function would undo this but since it sets the default_value maybe that
means it would reset to this value so it should work. There's a -d
cpu_reset option to dump registers on cpu_reset but I think that shows
values before reset. You can try updating the patches accordingly (add a
line to QEMU as above and undo part of the openbios patch that should no
longer be needed) and test if that works any better. Even if it does not
fix anything it would be cleaner so one step towards upstreaming. I don't
plan to do anything with this, one of you should be able to do this as an
excercise.
You mean something like this in mac_newworld.c around line 300 after
/* Check this */
openpic_irqs[i].irq[OPENPIC_OUTPUT_RESET] =
qdev_get_gpio_in(dev, PPC6xx_INPUT_HRESET);
----> env->spr_cb[SPR_PIR].default_value = env->core_index = i;
After that it looks like the pir no longer needs to be set in openbios. But I think I see PIR 0 for CPU 1 and PIR 1 for CPU 0, which seems wrong.
The -d cpu_reset shows both cpus reset to the same values at boot:
CPU Reset (CPU 0)
NIP 0000000000000000 LR 0000000000000000 CTR 0000000000000000 XER 0000000000000000 CPU#0
MSR 0000000000000000 HID0 0000000000000000 HF 00000000 iidx 0 didx 0
TB 00000000 00000000 DECR 0
GPR00 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
CR 00000000 [ - - - - - - - - ] RES 000@0000000000000000
SRR0 0000000000000000 SRR1 0000000000000000 PVR 00000000000c0209 VRSAVE 0000000000000000
SPRG0 0000000000000000 SPRG1 0000000000000000 SPRG2 0000000000000000 SPRG3 0000000000000000
SPRG4 0000000000000000 SPRG5 0000000000000000 SPRG6 0000000000000000 SPRG7 0000000000000000
SDR1 0000000000000000 DAR 0000000000000000 DSISR 0000000000000000
CPU Reset (CPU 1)
NIP 0000000000000000 LR 0000000000000000 CTR 0000000000000000 XER 0000000000000000 CPU#1
MSR 0000000000000000 HID0 0000000000000000 HF 00000000 iidx 0 didx 0
TB 00000000 00000000 DECR 0
GPR00 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
CR 00000000 [ - - - - - - - - ] RES 000@0000000000000000
SRR0 0000000000000000 SRR1 0000000000000000 PVR 00000000000c0209 VRSAVE 0000000000000000
SPRG0 0000000000000000 SPRG1 0000000000000000 SPRG2 0000000000000000 SPRG3 0000000000000000
SPRG4 0000000000000000 SPRG5 0000000000000000 SPRG6 0000000000000000 SPRG7 0000000000000000
SDR1 0000000000000000 DAR 0000000000000000 DSISR 0000000000000000
At second reset for CPU 1 only
CPU Reset (CPU 1)
NIP 00000000fff00100 LR 0000000000000000 CTR 0000000000000000 XER 0000000000000000 CPU#1
MSR 0000000000000040 HID0 0000000000000000 HF 6c180002 iidx 3 didx 3
TB 00000001 4442106637 DECR 4147827965
GPR00 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
CR 00000000 [ - - - - - - - - ] RES 000@ffffffffffffffff
SRR0 0000000000000000 SRR1 0000000000000000 PVR 00000000000c0209 VRSAVE 0000000000000000
SPRG0 0000000000000000 SPRG1 0000000000000000 SPRG2 0000000000000000 SPRG3 0000000000000000
SPRG4 0000000000000000 SPRG5 0000000000000000 SPRG6 0000000000000000 SPRG7 0000000000000000
SDR1 0000000000000000 DAR 0000000000000000 DSISR 0000000000000000
BALATON Zoltan