On Wed, 2026-10-28 at 14:30 +1000, Portia Stephens wrote:
> Update tt-atlantis to, when the RCPU is enabled and bootrom binary is
> provided, load the provided bootrom binary for the RCPU to execute.
> 
> This adds a tt-atlantis machine property 'bootrom' that takes a file
> name. qemu_find_file() tries the filename before the search path, so
> both
> full file paths and filenames relative to -L work:
> 
>     -M tt-atlantis,rcpu=on,bootrom=out/bootrom.bin
> 
> Signed-off-by: Portia Stephens <[email protected]>

- [MEDIUM] In hw/riscv/tt_atlantis.c (tt_rcpu_cluster_realize), the new
else
  branch sets start_powered_off on the RCPU hart when no bootrom is
given, a
  silent guest-visible default behavior change (rcpu defaults to on and
the SoC
  models nothing that can power the hart back on, so the RCPU stays
halted
  forever). The commit body only describes the bootrom-loading path and
gives
  no rationale, and the series-final docs/system/riscv/tt_atlantis.rst
Boot
  options section still omits this. Explain the rationale in the commit
body
  and document the powered-off default in the board docs.

- [LOW] nit: In hw/riscv/tt_atlantis.c, the bootrom property is named
  inconsistently across layers: the user-facing machine property is
bootrom,
  but the SoC and cluster QOM properties it is forwarded through are
both
  bootrom-name, while the backing fields mix bootrom (machine/SoC) and
  bootrom_name (TTRCPUClusterState). This forces the machine and SoC
  object_property_set_str calls to translate names for no benefit and
makes the
  value harder to trace. Pick one name, e.g. bootrom, in
tt_rcpu_cluster_props,
  tt_atlantis_soc_props, and both forwarding callsites.

- [LOW] In hw/riscv/tt_atlantis.c (tt_rcpu_cluster_realize), a
load_image_mr
  failure is reported as a bare "could not load RCPU bootrom".
load_image_mr
  (hw/core/loader.c) returns -1 both for a read/size failure and for an
image
  larger than the boot ROM region, so the message conflates the two
and, unlike
  the adjacent not-found branch, omits the resolved filename although
rom_file
  is in scope. In-tree precedent such as aspeed_soc_common_realize
includes the
  image name; do the same here (and ideally report the region size
limit via
  size_to_str) so an oversized image is distinguishable from a read
failure.

Alistair

> ---
>  hw/riscv/tt_atlantis.c         | 62
> +++++++++++++++++++++++++++++++++-
>  include/hw/riscv/tt_atlantis.h |  4 +++
>  2 files changed, 65 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/riscv/tt_atlantis.c b/hw/riscv/tt_atlantis.c
> index 66cbb2b8cf..d2ba2935af 100644
> --- a/hw/riscv/tt_atlantis.c
> +++ b/hw/riscv/tt_atlantis.c
> @@ -9,6 +9,7 @@
>  #include "qemu/osdep.h"
>  #include "qapi/error.h"
>  #include "qemu/cutils.h"
> +#include "qemu/datadir.h"
>  #include "qemu/error-report.h"
>  #include "qemu/guest-random.h"
>  #include "qemu/units.h"
> @@ -671,13 +672,37 @@ static void tt_rcpu_cluster_realize(DeviceState
> *dev, Error **errp)
>       */
>      mmio_map_unimplemented(&rc->memory, SYS_BUS_DEVICE(&rc-
> >unimp_mem),
>                             "tt-rcpu.unimp", 0, UINT32_MAX);
> +
> +    if (rc->bootrom_name) {
> +        ssize_t rom_size;
> +
> +        g_autofree char *rom_file =
> qemu_find_file(QEMU_FILE_TYPE_BIOS, rc->bootrom_name);
> +        if (!rom_file) {
> +            error_setg(errp, "could not find bootrom image '%s'",
> rc->bootrom_name);
> +            return;
> +        }
> +
> +        rom_size = load_image_mr(rom_file, &rc->bootrom);
> +        if (rom_size <= 0) {
> +            error_setg(errp, "could not load RCPU bootrom");
> +            return;
> +        }
> +    } else {
> +        /* If no bootrom is provided, don't let the core run */
> +        CPU(&rc->cpus.harts[0])->start_powered_off = true;
> +    }
>  }
>  
> +static const Property tt_rcpu_cluster_props[] = {
> +    DEFINE_PROP_STRING("bootrom-name", TTRCPUClusterState,
> bootrom_name),
> +};
> +
>  static void tt_rcpu_cluster_class_init(ObjectClass *oc, const void
> *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(oc);
>  
>      dc->realize = tt_rcpu_cluster_realize;
> +    device_class_set_props(dc, tt_rcpu_cluster_props);
>  }
>  
>  static void tt_ascalon_cluster_init(Object *obj)
> @@ -832,6 +857,13 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>      if (s->has_rcpu) {
>          /* Only create the RCPU if it is enabled */
>          object_initialize_child(OBJECT(s), "rcpu", &s->rcpu,
> TYPE_TT_RCPU_CLUSTER);
> +
> +        if (s->bootrom) {
> +            object_property_set_str(OBJECT(rc), "bootrom-name",
> +                                    s->bootrom,
> +                                    &error_abort);
> +        }
> +
>          if (!qdev_realize(DEVICE(&s->rcpu), NULL, errp)) {
>              return;
>          }
> @@ -1010,7 +1042,8 @@ static void tt_atlantis_soc_realize(DeviceState
> *dev, Error **errp)
>  static const Property tt_atlantis_soc_props[] = {
>      DEFINE_PROP_LINK("dram", TTAtlantisSoCState, dram,
>                       TYPE_MEMORY_REGION, MemoryRegion *),
> -    DEFINE_PROP_BOOL("has-rcpu", TTAtlantisSoCState, has_rcpu,
> false)
> +    DEFINE_PROP_BOOL("has-rcpu", TTAtlantisSoCState, has_rcpu,
> false),
> +    DEFINE_PROP_STRING("bootrom-name", TTAtlantisSoCState, bootrom)
>  };
>  
>  static void tt_atlantis_soc_class_init(ObjectClass *oc, const void
> *data)
> @@ -1058,6 +1091,13 @@ static void
> tt_atlantis_machine_init(MachineState *machine)
>                              num_asc_harts,
>                              &error_abort);
>  
> +    if (ams->has_rcpu && ams->bootrom) {
> +        /* Set the RCPU bootrom file name provided on the command
> line */
> +        object_property_set_str(OBJECT(s), "bootrom-name",
> +                                ams->bootrom,
> +                                &error_abort);
> +    }
> +
>      object_property_set_link(OBJECT(s), "dram", OBJECT(machine-
> >ram),
>                               &error_abort);
>      object_property_set_bool(OBJECT(&ams->soc), "has-rcpu", ams-
> >has_rcpu,
> @@ -1094,6 +1134,22 @@ static void
> tt_atlantis_machine_set_rcpu(Object *obj, bool value, Error **errp)
>      s->has_rcpu = value;
>  }
>  
> +static char *tt_atlantis_get_bootrom(Object *obj, Error **errp)
> +{
> +    TTAtlantisState *s = TT_ATLANTIS_MACHINE(obj);
> +
> +    return g_strdup(s->bootrom);
> +}
> +
> +static void tt_atlantis_set_bootrom(Object *obj, const char *value,
> +                                   Error **errp)
> +{
> +    TTAtlantisState *s = TT_ATLANTIS_MACHINE(obj);
> +
> +    g_free(s->bootrom);
> +    s->bootrom = g_strdup(value);
> +}
> +
>  static void tt_atlantis_machine_class_init(ObjectClass *oc, const
> void *data)
>  {
>      MachineClass *mc = MACHINE_CLASS(oc);
> @@ -1121,6 +1177,10 @@ static void
> tt_atlantis_machine_class_init(ObjectClass *oc, const void *data)
>                                            "Set to enable/disable
> modeling the RCPU.");
>      object_property_set_default_bool(prop, true);
>  
> +    object_class_property_add_str(oc, "bootrom",
> +                                  tt_atlantis_get_bootrom,
> +                                  tt_atlantis_set_bootrom);
> +    object_class_property_set_description(oc, "bootrom", "RCPU
> bootrom image");
>  }
>  
>  static const TypeInfo tt_atlantis_types[] = {
> diff --git a/include/hw/riscv/tt_atlantis.h
> b/include/hw/riscv/tt_atlantis.h
> index 4dfeb993d4..cab7e2625f 100644
> --- a/include/hw/riscv/tt_atlantis.h
> +++ b/include/hw/riscv/tt_atlantis.h
> @@ -69,6 +69,8 @@ struct TTRCPUClusterState {
>       * prevent faults on accesses to regions not modeled.
>       */
>      UnimplementedDeviceState unimp_mem;
> +
> +    char *bootrom_name;
>  };
>  
>  struct TTAtlantisSoCState {
> @@ -89,6 +91,7 @@ struct TTAtlantisSoCState {
>      TTAtlantisPRCMState prcm[TT_ATL_NUM_PRCM];
>  
>      bool has_rcpu;              /* Enable RCPU */
> +    char *bootrom;              /* RCPU boot ROM image */
>  };
>  
>  struct TTAtlantisState {
> @@ -101,6 +104,7 @@ struct TTAtlantisState {
>      TTAtlantisSoCState soc;
>  
>      bool has_rcpu;              /* Enable RCPU */
> +    char *bootrom;              /* RCPU boot ROM image */
>  };
>  
>  enum {

Reply via email to