qemu/include/hw
Daniel Henrique Barboza 4b402886ac hw/riscv: change riscv_compute_fdt_addr() semantics
As it is now, riscv_compute_fdt_addr() is receiving a dram_base, a
mem_size (which is defaulted to MachineState::ram_size in all boards)
and the FDT pointer. And it makes a very important assumption: the DRAM
interval dram_base + mem_size is contiguous. This is indeed the case for
most boards that use a FDT.

The Icicle Kit board works with 2 distinct RAM banks that are separated
by a gap. We have a lower bank with 1GiB size, a gap follows, then at
64GiB the high memory starts. MachineClass::default_ram_size for this
board is set to 1.5Gb, and machine_init() is enforcing it as minimal RAM
size, meaning that there we'll always have at least 512 MiB in the Hi
RAM area.

Using riscv_compute_fdt_addr() in this board is weird because not only
the board has sparse RAM, and it's calling it using the base address of
the Lo RAM area, but it's also using a mem_size that we have guarantees
that it will go up to the Hi RAM. All the function assumptions doesn't
work for this board.

In fact, what makes the function works at all in this case is a
coincidence. Commit 1a475d39ef introduced a 3GB boundary for the FDT,
down from 4Gb, that is enforced if dram_base is lower than 3072 MiB. For
the Icicle Kit board, memmap[MICROCHIP_PFSOC_DRAM_LO].base is 0x80000000
(2 Gb) and it has a 1Gb size, so it will fall in the conditions to put
the FDT under a 3Gb address, which happens to be exactly at the end of
DRAM_LO. If the base address of the Lo area started later than 3Gb this
function would be unusable by the board. Changing any assumptions inside
riscv_compute_fdt_addr() can also break it by accident as well.

Let's change riscv_compute_fdt_addr() semantics to be appropriate to the
Icicle Kit board and for future boards that might have sparse RAM
topologies to worry about:

- relieve the condition that the dram_base + mem_size area is contiguous,
since this is already not the case today;

- receive an extra 'dram_size' size attribute that refers to a contiguous
RAM block that the board wants the FDT to reside on.

Together with 'mem_size' and 'fdt', which are now now being consumed by a
MachineState pointer, we're able to make clear assumptions based on the
DRAM block and total mem_size available to ensure that the FDT will be put
in a valid RAM address.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20230201171212.1219375-4-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2023-02-07 08:19:23 +10:00
..
acpi pcihp: make bridge describe itself using AcpiDevAmlIfClass:build_dev_aml 2023-01-28 06:21:29 -05:00
adc hw/arm/npcm7xx: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE() 2023-01-12 17:15:09 +00:00
arm hw/arm/virt: Consolidate GIC finalize logic 2023-02-03 12:59:22 +00:00
audio introduce -audio as a replacement for -soundhw 2022-05-14 12:33:44 +02:00
block include/hw/block: Include hw/block/block.h where needed 2023-01-20 07:25:06 +01:00
char hw/char/pl011: refactor FIFO depth handling code 2023-02-03 12:59:21 +00:00
core accel: introduce accelerator blocker API 2023-01-11 09:59:39 +01:00
cpu Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
cris include: Include headers where needed 2023-01-08 01:54:22 -05:00
cxl include/hw/cxl: Break inclusion loop cxl_pci.h and cxl_cdat_h 2023-01-08 01:54:22 -05:00
display include: Include headers where needed 2023-01-08 01:54:22 -05:00
dma include: Include headers where needed 2023-01-08 01:54:22 -05:00
firmware hw/smbios: add core_count2 to smbios table type 4 2022-11-07 14:08:17 -05:00
gpio hw/gpio: replace HWADDR_PRIx with PRIx64 2022-05-25 10:31:33 +02:00
hyperv hw/hyperv/vmbus: Remove unused vmbus_load/save_req() 2022-05-30 19:49:42 +02:00
i2c hw/i2c/versatile_i2c: Replace TYPE_VERSATILE_I2C -> TYPE_ARM_SBCON_I2C 2023-01-23 13:32:38 +00:00
i386 x86: don't let decompressed kernel image clobber setup_data 2023-01-28 06:21:29 -05:00
ide virtio,pc,pci: features, cleanups, fixes 2023-01-09 10:07:12 +00:00
input hw/input/tsc2xxx: Constify set_transform()'s MouseTransformInfo arg 2023-01-05 14:11:15 +00:00
intc hw/intc: Extract the IRQ counting functions into a separate file 2023-01-13 16:22:57 +01:00
ipack ipack: Rename ipack_bus_new_inplace() to ipack_bus_init() 2021-09-30 13:42:10 +01:00
ipmi Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
isa hw/isa/isa-bus: Turn isa_build_aml() into qbus_build_aml() 2023-01-27 11:47:02 -05:00
kvm target/i386: always create kvmclock device 2020-09-30 19:11:36 +02:00
loongarch hw/loongarch/virt: Add cfi01 pflash device 2022-12-15 15:46:12 +08:00
m68k hw/m68k/mcf: Add missing 'exec/hwaddr.h' header 2022-02-21 10:35:13 +01:00
mem acpi/nvdimm: Define trace events for NVDIMM and substitute nvdimm_debug() 2022-07-26 10:37:46 -04:00
mips hw/mips/bootloader: Handle buffers as opaque arrays 2023-01-13 09:32:32 +01:00
misc hw/arm/npcm7xx: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE() 2023-01-12 17:15:09 +00:00
net hw/arm/npcm7xx: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE() 2023-01-12 17:15:09 +00:00
nubus Clean up header guards that don't match their file name 2022-05-11 16:49:06 +02:00
nvram x86: don't let decompressed kernel image clobber setup_data 2023-01-28 06:21:29 -05:00
openrisc hw/openrisc: Split re-usable boot time apis out to boot.c 2022-09-04 07:02:56 +01:00
pci pci: make sure pci_bus_is_express() won't error out with "discards ‘const’ qualifier" 2023-01-28 06:21:29 -05:00
pci-bridge pci/pci_expander_bridge: For CXL HB delay the HB register memory region setup. 2022-06-09 19:32:49 -04:00
pci-host ppc/pnv/pci: Update PHB5 version register 2023-02-05 06:40:28 -03:00
ppc include/hw/ppc include/hw/pci-host: Drop extra typedefs 2023-01-20 07:25:22 +01:00
rdma qapi: introduce x-query-rdma QMP command 2021-11-02 15:55:14 +00:00
remote include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
riscv hw/riscv: change riscv_compute_fdt_addr() semantics 2023-02-07 08:19:23 +10:00
rtc hw/rtc/mc146818rtc: Make the mc146818 RTC device target independent 2023-01-13 16:22:57 +01:00
rx Clean up header guards that don't match their file name 2022-05-11 16:49:06 +02:00
s390x s390x/pci: reset ISM passthrough devices on shutdown and system reset 2022-12-15 15:02:34 +01:00
scsi include/hw/scsi/scsi.h: Remove unused scsi_legacy_handle_cmdline() prototype 2022-10-22 23:21:16 +02:00
sd hw/arm/npcm7xx: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE() 2023-01-12 17:15:09 +00:00
sensor hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators 2022-07-14 16:24:38 +02:00
sh4 hw/intc/sh_intc: Inline and drop sh_intc_source() function 2021-10-30 18:39:37 +02:00
southbridge include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
sparc hw: Replace anti-social QOM type names 2021-03-19 15:18:43 +01:00
ssi include: Include headers where needed 2023-01-08 01:54:22 -05:00
timer include: Include headers where needed 2023-01-08 01:54:22 -05:00
tricore Clean up ill-advised or unusual header guards 2022-05-11 16:50:01 +02:00
usb include: Include headers where needed 2023-01-08 01:54:22 -05:00
vfio vfio/common: Rename VFIOGuestIOMMU::iommu into ::iommu_mr 2022-05-06 09:06:51 -06:00
virtio virtio-blk: simplify virtio_blk_dma_restart_cb() 2023-01-23 15:01:23 -05:00
watchdog Clean up header guards that don't match their file name 2022-05-11 16:49:06 +02:00
xen hw/xen: use G_GNUC_PRINTF/SCANF for various functions 2023-01-11 10:44:33 +01:00
xtensa
boards.h virtio,pc,pci: features, cleanups, fixes 2023-01-09 10:07:12 +00:00
clock.h host-utils: add 128-bit quotient support to divu128/divs128 2021-10-27 17:10:00 -07:00
elf_ops.h treewide: Remove the unnecessary space before semicolon 2022-10-24 13:41:10 +02:00
fw-path-provider.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
hotplug.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
hw.h compiler.h: replace QEMU_NORETURN with G_NORETURN 2022-04-21 17:03:51 +04:00
ide.h include/hw/ide: Unexport pci_piix3_xen_ide_unplug() 2022-06-09 14:47:42 +01:00
irq.h hw/core/irq: remove unused 'qemu_irq_split' function 2022-04-21 11:37:04 +01:00
loader-fit.h nomaintainer: Fix Lesser GPL version number 2020-11-15 17:04:40 +01:00
loader.h hw/core/loader: return image sizes as ssize_t 2022-06-10 09:31:42 +10:00
nmi.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
or-irq.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
pcmcia.h Use OBJECT_DECLARE_TYPE when possible 2020-09-18 14:12:32 -04:00
platform-bus.h nomaintainer: Fix Lesser GPL version number 2020-11-15 17:04:40 +01:00
ptimer.h ptimer: Rename PTIMER_POLICY_DEFAULT to PTIMER_POLICY_LEGACY 2022-05-19 16:19:03 +01:00
qdev-clock.h clock: Add ClockEvent parameter to callbacks 2021-03-08 17:20:01 +00:00
qdev-core.h hw: Remove device_legacy_reset() 2022-12-16 15:55:32 +00:00
qdev-dma.h
qdev-properties-system.h qdev: Reuse DEFINE_PROP in all DEFINE_PROP_* macros 2020-12-18 15:20:17 -05:00
qdev-properties.h qdev-properties: Add a new macro with bitmask check for uint64_t property 2022-05-14 12:32:41 +02:00
register.h hw/core/register: Add more 64-bit utilities 2021-09-01 11:59:12 +10:00
registerfields.h hw/registerfields: Add shared fields macros 2022-06-22 09:49:34 +02:00
resettable.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
stream.h hw/core/stream: Rename StreamSlave as StreamSink 2020-12-10 12:15:04 -05:00
sysbus.h qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros 2020-09-18 14:12:32 -04:00
usb.h hw/usb: fix tab indentation 2022-11-08 11:13:48 +01:00
vmstate-if.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00