On Wed, 2026-10-28 at 14:30 +1000, Portia Stephens wrote:
> The system memory is the memory view of the Ascalon CPU. Store the
> memory directly in the TTAscalonClusterState and set it to
> system_memory. There is no need to track it at the machine level,
> get_system_memory() can be used when needed.
> 
> Signed-off-by: Portia Stephens <[email protected]>

My bot says, also I think you are missing the reviewed tags from v1:

- [MEDIUM] In hw/riscv/tt_atlantis.c (tt_ascalon_cluster_class_init),
the
  cluster class never sets dc->user_creatable = false, and this change
  deletes the 'memory' link check in tt_ascalon_cluster_realize that
made
  every standalone instantiation fail cleanly with an error. A user
running
  -device riscv.tt-ascalon-cluster without cpu-type now passes a NULL
  ac->cpu_type into object_property_set_str, where qstring_from_str
does
  strlen(NULL) and SIGSEGVs the host instead of reporting a device-
creation
  error. Set dc->user_creatable = false, matching
tt_atlantis_soc_class_init
  in the same file.

- [MEDIUM] In hw/riscv/tt_atlantis.c (tt_ascalon_cluster_realize), the
new
  code unconditionally initializes a UINT64_MAX container and attaches
it to
  get_system_memory() before the fallible bootrom-init and hart-array-
realize
  steps, and both error paths return without rolling anything back. The
  subregion reference held by system memory then prevents
  memory_region_finalize from ever running, so a failed standalone -
device
  realize leaves a permanent half-applied entry in the host address
map, and
  a successful one shadows the machine's boot ROM with zero-filled
memory at
  the reset vector because equal-priority subregions insert newest-
first.
  This violates the half-applied-mutation rule in the C error-
discipline
  notes: either move the system-memory attachment after all fallible
steps
  with a rollback path, or make the class non-user-creatable as with
the
  sibling SoC class.

Alistair

> ---
>  hw/riscv/tt_atlantis.c         | 43 ++++++++++++++------------------
> --
>  include/hw/riscv/tt_atlantis.h |  3 +--
>  2 files changed, 19 insertions(+), 27 deletions(-)
> 
> diff --git a/hw/riscv/tt_atlantis.c b/hw/riscv/tt_atlantis.c
> index 7f9231e6ff..9b37e845da 100644
> --- a/hw/riscv/tt_atlantis.c
> +++ b/hw/riscv/tt_atlantis.c
> @@ -558,18 +558,19 @@ static void
> tt_ascalon_cluster_realize(DeviceState *dev, Error **errp)
>  {
>      TTAscalonClusterState *ac = TT_ASCALON_CLUSTER(dev);
>  
> -    if (!ac->memory) {
> -        error_setg(errp, "'memory' link is not set");
> -        return;
> -    }
>      ac->memmap = tt_atlantis_memmap;
>  
> +    /* Ascalon's memory view is system memory */
> +    memory_region_init(&ac->memory, OBJECT(ac),
> +                       "tt-ascalon-memory", UINT64_MAX);
> +    memory_region_add_subregion(get_system_memory(), 0, &ac-
> >memory);
> +
>      /* Boot ROM */
>      if (!memory_region_init_rom(&ac->bootrom, OBJECT(ac), "tt-
> atlantis.bootrom",
>                                  ac->memmap[TT_ATL_BOOTROM].size,
> errp)) {
>          return;
>      }
> -    memory_region_add_subregion(ac->memory, ac-
> >memmap[TT_ATL_BOOTROM].base,
> +    memory_region_add_subregion(&ac->memory, ac-
> >memmap[TT_ATL_BOOTROM].base,
>                                  &ac->bootrom);
>  
>      /* CPUs */
> @@ -583,7 +584,7 @@ static void
> tt_ascalon_cluster_realize(DeviceState *dev, Error **errp)
>                              ac->memmap[TT_ATL_BOOTROM].base,
>                              &error_abort);
>      object_property_set_link(OBJECT(&ac->cpus), "memory",
> -                             OBJECT(ac->memory),
> +                             OBJECT(&ac->memory),
>                               &error_abort);
>      if (!sysbus_realize(SYS_BUS_DEVICE(&ac->cpus), errp)) {
>          return;
> @@ -593,8 +594,6 @@ static void
> tt_ascalon_cluster_realize(DeviceState *dev, Error **errp)
>  static const Property tt_ascalon_cluster_props[] = {
>      DEFINE_PROP_STRING("cpu-type", TTAscalonClusterState, cpu_type),
>      DEFINE_PROP_UINT32("num-harts", TTAscalonClusterState,
> num_harts, 8),
> -    DEFINE_PROP_LINK("memory", TTAscalonClusterState, memory,
> -                     TYPE_MEMORY_REGION, MemoryRegion *),
>  };
>  
>  static void tt_ascalon_cluster_class_init(ObjectClass *oc, const
> void *data)
> @@ -653,7 +652,7 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>  
>      ram_size = memory_region_size(s->dram);
>  
> -    s->irqchip = riscv_create_aia(ac->memory,
> +    s->irqchip = riscv_create_aia(&ac->memory,
>                                    true, TT_IMSIC_GUESTS,
>                                    TT_IMSIC_STRIDE,
>                                    TT_IMSIC_STRIDE,
> @@ -666,7 +665,7 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>                                    TT_IRQCHIP_NUM_MSIS,
>                                    TT_IRQCHIP_NUM_PRIO_BITS);
>  
> -    riscv_aclint_mtimer_create(ac->memory,
> +    riscv_aclint_mtimer_create(&ac->memory,
>              ac->memmap[TT_ATL_ACLINT].base,
>              TT_ACLINT_MTIME_SIZE,
>              0, hart_count,
> @@ -688,13 +687,13 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>  
>      memory_region_init_alias(&s->ram_hi, OBJECT(s), "ram.high", s-
> >dram,
>                               0, ram_size);
> -    memory_region_add_subregion(ac->memory,
> +    memory_region_add_subregion(&ac->memory,
>                                  ac->memmap[TT_ATL_DDR_HI].base, &s-
> >ram_hi);
>  
>      lo_ram_size = MIN(ram_size, ac->memmap[TT_ATL_DDR_LO].size);
>      memory_region_init_alias(&s->ram_lo, OBJECT(s), "ram.low", s-
> >dram,
>                               0, lo_ram_size);
> -    memory_region_add_subregion(ac->memory,
> +    memory_region_add_subregion(&ac->memory,
>                                  ac->memmap[TT_ATL_DDR_LO].base, &s-
> >ram_lo);
>  
>      /* 4 PRCM blocks */
> @@ -703,7 +702,7 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>          return;
>      }
>      memory_region_add_subregion(
> -        ac->memory, ac->memmap[TT_ATL_PRCM_RCPU].base,
> +        &ac->memory, ac->memmap[TT_ATL_PRCM_RCPU].base,
>          sysbus_mmio_get_region(
>              SYS_BUS_DEVICE(&s->prcm[TT_ATLANTIS_PRCM_DOMAIN_RCPU]),
> 0));
>  
> @@ -712,7 +711,7 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>          return;
>      }
>      memory_region_add_subregion(
> -        ac->memory, ac->memmap[TT_ATL_PRCM_HSIO].base,
> +        &ac->memory, ac->memmap[TT_ATL_PRCM_HSIO].base,
>          sysbus_mmio_get_region(
>              SYS_BUS_DEVICE(&s->prcm[TT_ATLANTIS_PRCM_DOMAIN_HSIO]),
> 0));
>  
> @@ -721,7 +720,7 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>          return;
>      }
>      memory_region_add_subregion(
> -        ac->memory, ac->memmap[TT_ATL_PRCM_PCIE].base,
> +        &ac->memory, ac->memmap[TT_ATL_PRCM_PCIE].base,
>          sysbus_mmio_get_region(
>              SYS_BUS_DEVICE(&s->prcm[TT_ATLANTIS_PRCM_DOMAIN_PCIE]),
> 0));
>  
> @@ -730,7 +729,7 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>          return;
>      }
>      memory_region_add_subregion(
> -        ac->memory, ac->memmap[TT_ATL_PRCM_MM].base,
> +        &ac->memory, ac->memmap[TT_ATL_PRCM_MM].base,
>          sysbus_mmio_get_region(
>              SYS_BUS_DEVICE(&s->prcm[TT_ATLANTIS_PRCM_DOMAIN_MM]),
> 0));
>  
> @@ -744,7 +743,7 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>              return;
>          }
>  
> -        memory_region_add_subregion(ac->memory,
> +        memory_region_add_subregion(&ac->memory,
>                                      ac->memmap[TT_ATL_UART0 +
> i].base,
>                                      sysbus_mmio_get_region(sbd, 0));
>          sysbus_connect_irq(sbd, 0,
> @@ -758,7 +757,7 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>          if (!sysbus_realize(sbd, errp)) {
>              return;
>          }
> -        memory_region_add_subregion(ac->memory,
> +        memory_region_add_subregion(&ac->memory,
>                                      ac->memmap[TT_ATL_I2C0 +
> i].base,
>                                      sysbus_mmio_get_region(sbd, 0));
>          sysbus_connect_irq(sbd, 0,
> @@ -787,10 +786,6 @@ static void
> tt_atlantis_machine_init(MachineState *machine)
>      TTAtlantisSoCState *s = &ams->soc;
>      TTAscalonClusterState *ac = &s->ascalon;
>  
> -    memory_region_init(&ams->soc_memory, OBJECT(machine),
> -                       "tt-atlantis.soc-memory", UINT64_MAX);
> -    memory_region_add_subregion(get_system_memory(), 0, &ams-
> >soc_memory);
> -
>      object_initialize_child(OBJECT(machine), "soc", &ams->soc,
>                              TYPE_TT_ATLANTIS_SOC);
>  
> @@ -802,9 +797,7 @@ static void tt_atlantis_machine_init(MachineState
> *machine)
>                              machine->smp.cpus,
>                              &error_abort);
>  
> -    object_property_set_link(OBJECT(ac), "memory",
> -                             OBJECT(&ams->soc_memory),
> &error_abort);
> -    object_property_set_link(OBJECT(&ams->soc), "dram",
> OBJECT(machine->ram),
> +    object_property_set_link(OBJECT(s), "dram", OBJECT(machine-
> >ram),
>                               &error_abort);
>  
>      qdev_realize(DEVICE(&ams->soc), NULL, &error_fatal);
> diff --git a/include/hw/riscv/tt_atlantis.h
> b/include/hw/riscv/tt_atlantis.h
> index 4e3d5d4b5f..52b44504ae 100644
> --- a/include/hw/riscv/tt_atlantis.h
> +++ b/include/hw/riscv/tt_atlantis.h
> @@ -37,7 +37,7 @@ struct TTAscalonClusterState {
>      /*< public >*/
>      const MemMapEntry *memmap;
>  
> -    MemoryRegion *memory;
> +    MemoryRegion memory;
>  
>      RISCVHartArrayState cpus;
>      MemoryRegion bootrom;
> @@ -70,7 +70,6 @@ struct TTAtlantisState {
>      /*< public >*/
>      Notifier machine_done;
>  
> -    MemoryRegion soc_memory;
>      TTAtlantisSoCState soc;
>  };
>  

Reply via email to