[PATCH 0/5] hw: Fix unit addresses of FDT CPU nodes

Vivian Wang posted 5 patches 2 days, 8 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260409-fix-unit-address-v1-0-946840930af2@iscas.ac.cn
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Leif Lindholm <leif.lindholm@oss.qualcomm.com>, Song Gao <gaosong@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Paul Burton <paulburton@kernel.org>, Aleksandar Rikalo <arikalo@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Jia Liu <proljc@gmail.com>, Stafford Horne <shorne@gmail.com>, Alistair Francis <Alistair.Francis@wdc.com>, Palmer Dabbelt <palmer@dabbelt.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu.zevorn@gmail.com>
hw/arm/sbsa-ref.c             | 4 ++--
hw/arm/virt.c                 | 7 +++++--
hw/loongarch/virt-fdt-build.c | 4 ++--
hw/mips/boston.c              | 2 +-
hw/or1k/or1k-sim.c            | 2 +-
hw/or1k/virt.c                | 2 +-
hw/riscv/sifive_u.c           | 9 +++++----
hw/riscv/spike.c              | 4 ++--
hw/riscv/virt.c               | 4 ++--
9 files changed, 21 insertions(+), 17 deletions(-)
[PATCH 0/5] hw: Fix unit addresses of FDT CPU nodes
Posted by Vivian Wang 2 days, 8 hours ago
Apply some pendantry to the node unit addresses of /cpus/cpu@*:

    / {
        cpus {
            cpu@??? /* <- here */ {
                reg = <10>; /* Equivalently, <0xa> */
            }
        };
    };

According to de facto convention, as confirmed by DTSpec maintainers,
these unit addresses should be in hexadecimal [2], i.e. cpu@a instead of
cpu@10. Currently apparently everything uses decimal which is wrong.

hw/arm/{sbsa-ref,virt} have an additional problem where the unit address
doesn't match up with the reg value. Fix that also.

I've tried to use the types of existing variables / return values, hence
the slightly different patterns in these patches:

  int cpu;                       -> "cpu@%x", (unsigned)cpu  [easy case]
  uint64_t mpidr;                -> "cpu@%" PRIx64, mpidr
  uint32_t hartid_base; int cpu; -> "cpu@%" PRIx32, hartid_base + (uint32_t)cpu

[1]: https://github.com/devicetree-org/devicetree-specification/blob/v0.4/source/chapter2-devicetree-basics.rst#devicetree-structure-and-conventions
[2]: https://lore.kernel.org/devicetree-spec/CAL_JsqJFv3+UJ-bjLGk0i7Wc+spsowCrqQZ_s3P4gN8r1W-Q-w@mail.gmail.com/

---
Vivian Wang (5):
      hw/arm: Fix unit addresses of FDT CPU nodes
      hw/loongarch: Use hex unit addresses in FDT CPU nodes
      hw/mips: Use hex unit addresses in FDT CPU nodes
      hw/or1k: Use hex unit addresses in FDT CPU nodes
      hw/riscv: Use hex unit addresses in FDT CPU nodes

 hw/arm/sbsa-ref.c             | 4 ++--
 hw/arm/virt.c                 | 7 +++++--
 hw/loongarch/virt-fdt-build.c | 4 ++--
 hw/mips/boston.c              | 2 +-
 hw/or1k/or1k-sim.c            | 2 +-
 hw/or1k/virt.c                | 2 +-
 hw/riscv/sifive_u.c           | 9 +++++----
 hw/riscv/spike.c              | 4 ++--
 hw/riscv/virt.c               | 4 ++--
 9 files changed, 21 insertions(+), 17 deletions(-)
---
base-commit: b6a7d06213e5d2f7d124d16418bc289c4a8a4b82
change-id: 20260409-fix-unit-address-22c0340a4708

Best regards,
--  
Vivian "dramforever" Wang
Re: [PATCH 0/5] hw: Fix unit addresses of FDT CPU nodes
Posted by Peter Maydell 2 days, 6 hours ago
On Thu, 9 Apr 2026 at 07:40, Vivian Wang <wangruikang@iscas.ac.cn> wrote:
>
> Apply some pendantry to the node unit addresses of /cpus/cpu@*:
>
>     / {
>         cpus {
>             cpu@??? /* <- here */ {
>                 reg = <10>; /* Equivalently, <0xa> */
>             }
>         };
>     };
>
> According to de facto convention, as confirmed by DTSpec maintainers,
> these unit addresses should be in hexadecimal [2], i.e. cpu@a instead of
> cpu@10. Currently apparently everything uses decimal which is wrong.

Who counts CPUs in hex, though? Decimal works fine, so it
seems to me more sensible to say "you can use either base".
These are just node names, there's no particular obligation
to use any specific name format.

-- PMM
Re: [PATCH 0/5] hw: Fix unit addresses of FDT CPU nodes
Posted by Vivian Wang 2 days, 5 hours ago
On 4/9/26 14:40, Vivian Wang wrote:
> Apply some pendantry to the node unit addresses of /cpus/cpu@*:
>
>     / {
>         cpus {
>             cpu@??? /* <- here */ {
>                 reg = <10>; /* Equivalently, <0xa> */
>             }
>         };
>     };
>
> According to de facto convention, as confirmed by DTSpec maintainers,
> these unit addresses should be in hexadecimal [2], i.e. cpu@a instead of
> cpu@10. Currently apparently everything uses decimal which is wrong.

For clarity, as discussed under patch 1 [1], this is really not
something that needs fixing in QEMU.

Consider this entire series abandoned.

Vivian "dramforever" Wang

[1]:
https://lore.kernel.org/qemu-devel/CAFEAcA-mTY3VksBcANok4+49UvVDv_w9X6ubKooQZ-kvWZ7r1Q@mail.gmail.com/