Re: [PATCH v2 07/12] hw/arm/raspi: Check ramsize is within chipset aperture

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> wrote:
>
> Add the 'max_ramsize' field to the soc_property[] array,
> corresponding to the maximum DRAM size a SoC can map.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
> ---
>  hw/arm/raspi.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index 68332fba027..d44277001ee 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -76,11 +76,12 @@ typedef enum RaspiProcessorId {
>  static const struct {
>      const char *type;
>      int cores_count;
> +    uint64_t max_ramsize;
>  } soc_property[] = {
> -    [PROCESSOR_ID_BCM2835] = {TYPE_BCM2835, 1},
> -    [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS},
> -    [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS},
> -    [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS},
> +    [PROCESSOR_ID_BCM2835] = {TYPE_BCM2835, 1,              512 * MiB},
> +    [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS,  1 * GiB},
> +    [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS,  1 * GiB},
> +    [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS,  8 * GiB},
>  };
>
>  static const struct {
> @@ -133,6 +134,11 @@ static int cores_count(uint32_t board_rev)
>      return soc_property[board_processor_id(board_rev)].cores_count;
>  }
>
> +static uint64_t ramsize_max(uint32_t board_rev)
> +{
> +    return soc_property[board_processor_id(board_rev)].max_ramsize;
> +}
> +
>  static const char *board_type(uint32_t board_rev)
>  {
>      assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
> @@ -294,6 +300,7 @@ void raspi_base_machine_init(MachineState *machine,
>      BlockBackend *blk;
>      BusState *bus;
>      DeviceState *carddev;
> +    uint64_t max_ramsize;
>
>      if (machine->ram_size != ram_size) {
>          char *size_str = size_to_str(ram_size);
> @@ -301,6 +308,12 @@ void raspi_base_machine_init(MachineState *machine,
>          g_free(size_str);
>          exit(1);
>      }
> +    max_ramsize = ramsize_max(board_rev);
> +    if (ram_size > max_ramsize) {
> +        g_autofree char *max_ramsize_str = size_to_str(max_ramsize);
> +        error_report("At most %s of RAM can be used", max_ramsize_str);
> +         exit(1);

Indent error?

> +    }

Otherwise
Reviewed-by: Peter Maydell <peter.maydell@xxxxxxxxxx>

thanks
-- PMM




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux