| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
__request_sdram_region() returns NULL on failure, so test for this value
and not for an error pointer. Also all callers of reserve_sdram_region()
expect NULL on failure, so return that value in case of failure.
Link: https://lore.barebox.org/20240109161527.3237581-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
barebox remaps all reserved entries as uncached to avoid speculative
access into the described regions using remap_range.
The ARM implementation requires buffers to be page aligned, which we
can't assume unconditionally. For this reason, reserve_sdram_region
will align region start and size before mapping uncached.
__mmu_init called later on, will remap everything outside the reserved
entries cached, e.g. to cache additional DRAM not known at PBL time.
No realignment will happen then though triggering the BUG(!IS_ALIGNED)
in ARM's arch_remap_range.
By moving the realignment before __request_sdram_region(), we ensure
that no misaligned memory regions will be passed to arch_remap_range by
core code.
This fixes chainloading barebox from an older barebox[1] that reserves
the FDT prior to relocation.
[1]: anything prior to 0b6b146a5508 ("fdt: Do not reserve device tree blob")
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20231109113012.1063774-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
reserve_sdram_region() has the purpose of reserving SDRAM regions from
being accessed by the CPU. Right now this remaps the reserved region
during MMU setup. Instead of doing this, remap the region immediately.
The MMU may be enabled already by early code. This means that when
reserve_sdram_region() is called with MMU enabled, we can't rely on
the region being mapped non-executable right after the call, but only
when __mmu_init() is executed. This patch relaxes this constraint.
Also, reserve_sdram_region() may now be called after __mmu_init() is
executed.
So far we silently aligned the remapped region to page boundaries, but
really calling reserve_sdram_region() with non page aligned boundaries
has undesired effects on the regions between the reserved region and
the page boundaries. Stay with this behaviour, but warn the user when
the to be reserved region is not page aligned as this really shouldn't
happen.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
barebox will fuse overlapping memory banks to avoid the common issue of
the device tree being modified upstream to contain a minimum RAM size
that would then conflict with a RAM size barebox determines by
querying the memory controller. This was recently broken, because we
changed memory banks to have IORESOURCE_MEM in their flags field,
but resource_contains() used to compare regions won't return true if
memory type differs. Fix this by settings .flags = IORESOURCE_MEM
for the new resource as well.
Reported-by: Ian Abbott <abbotti@mev.co.uk>
Fixes: d0b5f6bde15b ("of: reserved-mem: reserve regions prior to mmu_initcall()")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Tested-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.barebox.org/20221017133859.299705-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that we both have a way to mark SDRAM regions requested as reserved
and an postmem_initcall() to do this add, change device tree memory
reservation parsing code to use them instead of requesting them as
normal memory at coredevice_initcall() level. This allows us to
reuse this information for MMU setup in the follow-up commit.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220817114244.1810531-6-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Memory banks are added in mem_initcall() and are used in mmu_initcall()
which directly follows it to set caching attributes for the banks.
Code that requires memory banks to be registered, thus has to use
mmu_initcall(), but this is not possible for code that reliably needs to
run before MMU init: We need to give board code and device tree parsing
code the chance to reserve_sdram_region parts of SDRAM that contain
secure firmware to avoid speculative execution into them once the MMU is
turned on. For this reason, define a new postmem_initcall() level and
already use it for add_mem_devices, which has nothing to do with
mmu_initcall. Another user that can't be mmu_initcall() will follow in a
later commit.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220817114244.1810531-5-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that __request_region accepts a flag parameter, define
__request_sdram_region, which also accepts a flag parameter and passes
it through. The default flags for request_sdram_region() will be
IORESOURCE_MEM as that ensures resource_contains behaves correctly when
comparing against another memory resource.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220817114244.1810531-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
__request_region allocates a child resource within the parent resource,
which so far always had a flags field of zero. Later commits will
use the flags field to mark reserved SDRAM regions, so MMU init code can
take that into consideration and ensure that CPU doesn't speculate into
these regions and risk aborts. Prepare for this by giving
__request_region a flags parameter.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220817114244.1810531-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
| |
Add a new of_reserved_mem_walk that can be used to request
reserved memory regions. This avoids e.g. bootm trying to
place the kernel into a reserved region.
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220609111810.2454588-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some ARM subarchitectures read back RAM size from the SDRAM
controller and use the info to register memory banks.
If an overlapping memory region is already registered, e.g. via device
tree /memory, this second registration will fail.
This is especially annoying as it can regress after a device tree sync:
- Kind soul updates upstream device tree to describe minimal available
RAM across hardware variants
- barebox PBL has enough info about the board to set up larger RAM size
and relocates barebox to the end of the RAM
- barebox proper starts with new device tree and is upset to
find itself outside of registered memory
Account for this by growing the existing bank if a bank to be added
happens to overlap it. As a special case, if the existing bank
completely contains the new memory bank, the function is a no-op.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210531071239.30653-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Follow-up commit will fuse overlapping RAM banks. As all memory is
supposed to be registered during mem_initcall or before, we can postpone
device creation to mmu_initcall, so we can directly allocate devices
spanning the correct region.
The mem driver and the devinfo command are the only consumers of these
devices, so it's ok to register the devices at mmu_initcall.
While at it, drop the struct memory_bank::dev member.
It's unused anywhere.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210531071239.30653-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
iomem was so far unimplemented for EFI, because barebox didn't know what
to put there as the UEFI implementation does the heavy lifting.
Add an initcall that uses the EFI get_memory_map entry point to
remedy this.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
Link: https://lore.pengutronix.de/20210410110355.2105448-1-ahmad@a3f.at
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For all files in common/ that already have a license text:
- Replace with appropriate SPDX-License-Identifier
- Remove empty comment lines around replacement
- remove comment completely if only thing remaining is name
of file without description
Reviewed-by: Roland Hieber <rhi@pengutronix.de>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
This updates the tlsf implementation to v3.1. This is taken from
commit deff9ab509341f264addbd3c8ada533678591905 in
https://github.com/mattconte/tlsf.git.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97
("Remove the CREDITS file"). Remove references to it from several files.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since kernel 4.16 the memory nodes got a @<reg> suffix so the fixup
won't work correctly anymore, because instead of adapting the extisting
one the fixup creates a new node and keeps the old (maybe incorrect)
node.
To be compatible with the old and new layout delete the found memory
node and create a new one. The new node follows the new @<reg> style.
The patch also renames the node parameter to make it clearer.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
The bootm code needs to put the Kernel image and initrd into free
RAM. Add some functions to find free RAM chunks to help this code.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Replace users which use of_set_property() to set a property to a string
with of_property_write_string().
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
prepare to drop the efi arch as efi boot up is not arch sepecific
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
This adds support for running barebox in an EFI environment
on X86 PC hardware.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Rework the current framework so that I/O mapped I/O resources are
also possible.
Signed-off-by: Michel Stam <michel@reverze.net>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
If drivers want to fixup their specific instance they need some context
to know which instance they have to fixup.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Now that we are completely independent of libfdt remove the unused
code.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Add barebox-data section in arm branch to get complete
barebox regions in sdram regions tree.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix size address calculation.
Global variables from <asm/sections.h> which are defined
in linker script *.lds files for end addresses has already
a +1 calculation.
For example:
stext = 0x100 with a size about 0x50 will result a etext = 0x150.
In this case a correct size calculation is (etext - stext) = 0x50.
In function 'request_sdram_region' the end address will be
calculated with (start + size - 1) which result a correct
end address of 0x149 in this example.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
When a memory bank is already registered, return an error code
instead of throwing a bug. This can happen if a board has registered
a memory bank and the same bank is then probed from the devicetree.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
The FSF address has changed in the past. Instead of updating it
each time the address changes, just drop it completely treewide.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
Storing the size instead of the resource end in struct resource was
a mistake. 'size' ranges from 0 to UINT[32|64]_MAX + 1 which obviously
leads to problems. 'end' on the other hand will never exceed
UINT[32|64]_MAX. Also this way we can express a iomem region covering
the whole address space.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Also, request the sdram regions used by the barebox binary,
bss, malloc space and stack.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Thanks to a common memory handling barebox knows the sdram banks
and sizes, so we can add a common fixup functions for the nodes
in the devicetree.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
On arm we have the concept of memory banks which can
be registered and iterated over. This is useful for
other architectures aswell, so add some generic infrastructure
for this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
These functions are needed independently of the specific
malloc implementation, so move them out.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|