summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu
Commit message (Collapse)AuthorAgeFilesLines
...
* ARM: mmu32: Add pte_flags_to_pmd()Sascha Hauer2023-05-221-6/+29
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu32: Fix pmd_flags_to_pte() for ARMv4/5/6Sascha Hauer2023-05-221-11/+16
| | | | | | | | | | | | pmd_flags_to_pte() assumed ARMv7 page table format. This has the effect that random bit values end up in the access permission bits. This works because the domain is configured as manager in the DACR and thus the access permissions are ignored by the MMU. Nevertheless fix this and take the cpu architecture into account when translating the bits. Don't bother to translate the access permission bits though, just hardcode them as PTE_SMALL_AP_UNO_SRW. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu32: Assume MMU is onSascha Hauer2023-05-221-37/+10
| | | | | | | | As we now always enable the MMU during early initialization we can safely assume that the MMU is already enabled in __mmu_init() and drop the code path which enables the MMU. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu: always do MMU initialization early when MMU is enabledSascha Hauer2023-05-222-2/+2
| | | | | | | | | Drop the CONFIG_MMU_EARLY and make early MMU initialization the default. Doing so allows us for some simplifications in the MMU code as we have less code pathes to care and think about. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu: drop ttb argumentSascha Hauer2023-05-224-20/+15
| | | | | | | No need to pass ttb to the MMU code, the MMU code can itself call arm_mem_ttb() to get the desired base. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu64: create alloc_pte()Sascha Hauer2023-05-221-3/+17
| | | | | | | | | This is a preparation for using two level page tables in the PBL. To do that we need a way to allocate page tables in PBL. As malloc is not available in PBL, implement a function to allocate a page table from the area we also place the TTB. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu32: create alloc_pte()Sascha Hauer2023-05-221-2/+22
| | | | | | | | | This is a preparation for using two level page tables in the PBL. To do that we need a way to allocate page tables in PBL. As malloc is not available in PBL, implement a function to allocate a page table from the area we also place the TTB. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu: alloc 64k for early page tablesSascha Hauer2023-05-221-0/+6
| | | | | | | | | This is a preparation for using two level page tables in the PBL. To do that we need a way to allocate page tables in PBL. As malloc is not available in PBL, increase the area we use for the TTB to make some space available for page tables. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu: merge mmu-early_xx.c into mmu_xx.cSascha Hauer2023-05-225-157/+128
| | | | | | | The code will be further consolidated, so move it together for easier code sharing. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu: move dma_sync_single_for_device to extra fileSascha Hauer2023-05-225-31/+37
| | | | | | | | The next patch merges the mmu.c files with their corresponding mmu-early.c files. Before doing that move functions which can't be compiled for PBL out to extra files. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: Move early MMU after malloc initializationSascha Hauer2023-05-221-10/+10
| | | | | | | | Initialize the MMU after malloc so that we can use malloc in the MMU code, for example to allocate memory for page tables. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* ARM: i.MX: Drop HAB workaroundSascha Hauer2023-05-221-7/+0
| | | | | | | | | The i.MX HAB code on i.MX6 has to jump into ROM which happens to start at 0x0. To make that possible we used to map the ROM cached and jumped to it before the MMU is initialized. Instead, remap the ROM as needed in the HAB code so that we can safely jump into ROM with MMU enabled. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu32: implement zero_page_*()Sascha Hauer2023-05-224-14/+15
| | | | | | | We have functions to access the zero page and to make it faulting again. Implement them for AArch32. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu64: Use arch_remap_range where possibleSascha Hauer2023-05-221-6/+6
| | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* ARM: mmu: implement MAP_FAULTSascha Hauer2023-05-222-0/+7
| | | | | | MAP_FAULT can be used for the zero page to make it faulting. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: mmu32: rename mmu.h to mmu_32.hSascha Hauer2023-05-225-5/+4
| | | | | | | | mmu.h is AArch32 specific, so rename it to mmu_32.h like the C files have been renamed already. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* ARM: mmu-common.c: use common mmu includeSascha Hauer2023-05-221-1/+1
| | | | | | | | mmu-common.c needs things from mmu-common.h, but not from mmu.h, so include the former instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* ARM: cpu.c: remove unused includeSascha Hauer2023-05-221-2/+0
| | | | | | | cpu.c doesn't use anything from mmu.h, so drop its incusion. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* ARM: Add _32 suffix to aarch32 specific filenamesSascha Hauer2023-05-2210-10/+10
| | | | | | | | | | | | Several files in arch/arm/cpu/ have 32bit and 64bit versions. The 64bit versions have a _64 suffix, but the 32bit versions have none. This can be confusing sometimes as one doesn't know if a file is 32bit specific or common code. Add a _32 suffix to the 32bit files to avoid this confusion. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* ARM: drop cache function initializationSascha Hauer2023-05-225-55/+41
| | | | | | | | | We need a call to arm_set_cache_functions() before the cache maintenance functions can be used. Drop this call and just pick the correct functions on the first call. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* ARM: remove unused membase argumentSascha Hauer2023-05-223-7/+7
| | | | | | | | | The functions determining the different memory locations for stack, early malloc, ttb and op-tee all take a membase argument which is unused as all locations depend on the end of memory. Remove this unused argument. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2023-04-191-5/+0
|\
| * ARM: cleanup 32bit/64bit support in KconfigSascha Hauer2023-04-051-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The decision whether to build a 32bit or 64bit barebox has to be made first before anything else, so this makes CONFIG_64BIT a toplevel option without any further dependencies. With this patch we will only present the SoCs/boards which are actually supported by the selected code model in Kconfig. Without this patch it was often possible to select 32bit boards on a 64bit build or vice versa, which resulted in a broken build. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM64: setupc: don't invoke KASAN before relocationAhmad Fatoum2023-04-171-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | Plain memset and memcpy are checked by KASAN if enabled before calling unchecked __memset and __memcpy respectively. KASAN uses a kasan_initialized variable as first condition in its memory check, but that only works after relocation. For that reason, we must take care not to invoke KASAN before then. This was done for ARM32, but was missing for ARM64. Do so now. This fixes an annoying issue where network booting a KASAN-enabled barebox twice in a row would fail: The first happened to work because the memory kasan_initialized was placed at was zero. The second would behave erratically, because BSS initialization would silently fail and barebox static storage would then be initialized with the final values of the previous run. Fixes: 932ef7a02e2f ("ARM: Add KASan support") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230415083447.3069903-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/arm' into nextSascha Hauer2023-03-162-2/+2
|\
| * ARM: Do not print exception stacktrace in panicSascha Hauer2023-03-102-2/+2
| | | | | | | | | | | | | | | | | | | | panic() prints a stacktrace by default. When being called in a an exception this will print the stacktrace of the exception stack which is not useful, so drop it. We are printing the desired stacktrace anyway before calling panic(). Link: https://lore.barebox.org/20230309142631.338244-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: Enable frame pointers for arm64Sascha Hauer2023-03-091-0/+1
|/ | | | | | | | | | | | | stack unwinding on arm64 depends on framepointers, so enable them. OSELAS.Toolchain-2022.10.0 now defaults to -fomit-frame-pointer whereas earlier versions default to -fno-omit-frame-pointer. Fix stack unwinding for new OSELAS.Toolchain and other toolchains which omit frame pointers by default. Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230309135713.3874769-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: add DEBUG_LL support for ARM64 QEMU VirtAhmad Fatoum2023-01-311-0/+2
| | | | | | | | | We have DEBUG_LL for the PL011 on the ARM64 QEMU Virt, but it is unused. Wire it in. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230130064510.2398689-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-101-1/+1
| | | | | | | | | | | The '_d' suffix was originally meant to distinguish barebox struct names from Linux struct names. struct driver doesn't exist in Linux, so we can rename it and remove the meaningless suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-101-1/+1
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename device_d::device_node to device_d::of_nodeSascha Hauer2023-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | Linux struct device has the member of_node for the device_node pointer. Rename this in barebox accordingly to minimize the necessary changes when porting Linux code. This was done with the semantic patch: @@ struct device_d E; @@ - E.device_node + E.of_node @@ struct device_d *E; @@ - E->device_node + E->of_node Plus some manual adjustments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2022-12-121-0/+4
|\
| * ARM: start: print debugging info when CONFIG_DEBUG_INITCALLSAhmad Fatoum2022-12-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Like we now do during PBL, have CONFIG_DEBUG_INITCALLS also activate the early barebox start debug logging just prior to initcall execution. This is useful when debugging early hands and will only be visible if CONFIG_DEBUG_LL is enabled and configured appropriately. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221101062350.3206890-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM64: asm: mark __barebox_arm64_head as functionAhmad Fatoum2022-12-021-1/+1
|/ | | | | | | | | | | | | | | | | | | | | Calling objdump -d on the PBL ELF file will not disassemble the instructions comprising __barebox_arm64_head and instead will just print a hexdump. This is because we use linker magic to get the section in front of the text segment and GAS fails to detect that __barebox_arm64_head too is of function type. This is no longer the case with ENDPROC as it uses the GAS .type directive to explicitly mark a symbol as being a function: #define ENDPROC(name) \ .type name, @function; \ END(name) This only has effect on the ELF and introduces no functional change for the objcopied image. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221125100959.3981619-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/arm64-entry'Sascha Hauer2022-11-143-0/+36
|\
| * ARM64: asm: rewrite ENTRY_FUNCTION(_WITHSTACK) fully in assemblyAhmad Fatoum2022-10-262-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent episode with pointer authentication showed again that for platforms without __attribute__((naked)), we are better off writing the early header in assembly. We still want to keep the board specific entry points in C for ease of use, so we have ENTRY_FUNCTION_WITHSTACK generate two symbols: - A 32-bit stack top value that's placed in .rodata - An entry point with the normal C code, including stack-using prologues The new common assembly head code will access the stack pointer in a position-independent manner and set it up, before continuing with the C code. The barebox header is part of the common assembly head code ensuring it's not moved around due to compiler code generation. The common code will need access to board-specific entry point and stack top. The former is readily available as the alias __pbl_board_entry. The latter is a bit more complicated, as the symbol may not exist for boards not using the common header in a multi-image build. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221024065716.1215046-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM64: cpu: select HAVE_PBL_MULTI_IMAGES globallyAhmad Fatoum2022-10-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Incoming changes to the macro definition of ENTRY_FUNCTION will result in removal of barebox_arm_head for ARM64. Besides ENTRY_FUNCTION itself, only remaining user would be the non-PBL and single-PBL case. We already mandate PBL for all ARM64 boards, so mandate them to be multi-image capable as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221024065716.1215046-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: psci: client: don't hardcode method smc in fixupAhmad Fatoum2022-11-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When barebox is booted as QEMU -kernel, PSCI will have method = "hvc", because QEMU will act as Hypervisor. barebox handles this correctly and will use hvc instead of smc, but of_psci_fixup() always fixes up method = "smc" thereby breaking kernel boot. Fix this by forwarding the method read from barebox DT into the kernel DT. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20221105121154.3716964-2-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: psci: make PSCI method a of_psci_fixup parameterAhmad Fatoum2022-11-073-4/+5
|/ | | | | | | | | | | | | | We currently assume PSCI fixups to always be of method smc, but this is not true when barebox fixes up the node while running under QEMU. In preparation for handling QEMU boot properly when psci-client driver is enabled, give of_psci_fixup an extra parameter. No functional change. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20221105121154.3716964-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: cpu: add compiler barrier around unrelocated accessAhmad Fatoum2022-10-242-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC v11.1.1 was observed miscompiling relocate_to_current_adr() while generating THUMB2 code: dynsym = (void *)__dynsym_start + offset_var; 178c: 4b48 ldr r3, [pc, #288] ; (18b0 <relocate_to_current_adr+0x13c>) 178e: 5869 ldr r1, [r5, r1] dend = (void *)__rel_dyn_end + offset_var; 1790: 4407 add r7, r0 dynsym = (void *)__dynsym_start + offset_var; 1792: 58e8 ldr r0, [r5, r3] 1794: f102 0308 add.w r3, r2, #8 1798: 440b add r3, r1 179a: 4410 add r0, r2 dynend = (void *)__dynsym_end + offset_var; while (dstart < dend) { 179c: f1a3 0608 sub.w r6, r3, #8 17a0: 42b7 cmp r7, r6 17a2: d80a bhi.n 17ba <relocate_to_current_adr+0x46> dynend = (void *)__dynsym_end + offset_var; 17a4: 4b43 ldr r3, [pc, #268] ; (18b4 <relocate_to_current_adr+0x140>) } dstart += sizeof(*rel); } __memset(dynsym, 0, (unsigned long)dynend - (unsigned long)dynsym); 17a6: 2100 movs r1, #0 dynend = (void *)__dynsym_end + offset_var; 17a8: 58eb ldr r3, [r5, r3] 17aa: 441a add r2, r3 __memset(dynsym, 0, (unsigned long)dynend - (unsigned long)dynsym); 17ac: 1a12 subs r2, r2, r0 17ae: f000 fda5 bl 22fc <__memset> Both &__dynsym_start and &__dynsym_end will change value after relocation, so we absolutely want address calculation and addition of offset_var to happen before relocation. Compiler is within rights though to assume variables to be already relocated though and thus proves that &__dynsym_end may not change in the loop and thus move dynend calculation below the relocation loop and thus we end up with dynend being incremented by offset_var once more. The resulting out-of-bounds memset() will overwrite parts of barebox and break its startup. The naive solution of moving dynsym/dynend calculation beyond the relocation loop is insufficient as the compiler may decide to move it back. Instead the only solution short of rewriting this all in assembly seems to be hiding the origin of dynsym's value, so the optimizer may not prove the assumption that relocation would not affect its value. This is done using runtime_address, which was introduced in a previous commit. With this, the __memset call now uses precomputed values as expected: no last minute ldr, everything tidily placed into registers prior to the relocation loop: 17be: 2100 movs r1, #0 17c0: 1b52 subs r2, r2, r5 17c2: 4628 mov r0, r5 17c4: f000 fdaa bl 231c <__memset> Fixes: a8b788ba61eb ("relocate_to_current_adr: hang directly on error instead of panic()") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221020131510.3734338-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2022-10-132-2/+3
|\
| * relocate_to_current_adr: hang directly on error instead of panic()Ahmad Fatoum2022-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | panic() will format a panic message, turn on a panic LED, dump a stack trace and finally either restart the system or print a message to ask the user to restart the system before hanging. When relocation fails, all of these aren't possible, so instead of devolving into undefined behavior, fall directly into an infinite loop. Motivation for this change is to avoid linking printf code when it's only usage is the relocation error case. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220930154247.756577-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * include: move panic() prototype to <printk.h>Ahmad Fatoum2022-10-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The panic declaration in <linux/kernel.h> is out of place and unexpected as it's not a Linux kernel. printf() and printk() are defined in <printk.h>, so move it there too. Most files making use of panic(), pull it in via <common.h>, so we only need to adjust two headers for the new location. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220930154247.756577-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: start: drop support for machine type casted to boarddata pointerAhmad Fatoum2022-10-121-12/+0
|/ | | | | | | | | | | | | | | | | | | | | | | | | Commit 84d28cec7f49 ("ARM: add a machine number mechanism for boarddata") added in 2015 added a struct barebox_arm_boarddata mechanism for PBL to pass machine type to barebox proper without going the legacy router of casting the machine type integer to a pointer directly. The legacy way with casting was mostly broken two years ago with commit 390bc7834ffc ("ARM: start: check for machine type last"). Only user that complained about it was using an in-tree board that has in the meantime been fixed to use struct barebox_arm_boarddata instead. Take this as indication that the code is dead and can be safely removed. This may introduce regressions for boards that happened to work, despite their machine type integer being dereferenced as a pointer. If you happen to have such a board, please pass a pointer to a struct barebox_arm_boarddata instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Tested-by: Bastian Krause <bst@pengutronix.de> Link: https://lore.barebox.org/20221011114927.546670-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/sha256'Sascha Hauer2022-09-141-1/+1
|\
| * pbl: replace __piggydata_end with __image_endAhmad Fatoum2022-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __piggydata_end and __image_end used to be synonyms before the addition of external firmware. Now that external firmware is located after __piggydata_end, code using it needs to be revisited. There's no reason to have code reference __piggydata_end. Either they want all the rest of the image, so they should use __image_end instead or they want just the piggy data, in which case they can read the data size embedded into the piggydata itself. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220818050447.2072932-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/arm'Sascha Hauer2022-09-145-5/+33
|\ \
| * | ARM: early-mmu: don't cache/prefetch OPTEE_SIZE bytes from end of memoryAhmad Fatoum2022-09-122-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OPTEE_SIZE is always defined in <asm-generic/memory_layout.h> either as as CONFIG_OPTEE_SIZE or as 0 if the option is undefined. There is never a reason to map the last OPTEE_SIZE bytes in the initial memory as cached and executable: - OPTEE_SIZE == 0: no change - OPTEE_SIZE != 0 && CONFIG_PBL_OPTEE=y: cache must not be enabled for the region to avoid speculation - OPTEE_SIZE != 0 && CONFIG_BOOTM_OPTEE=y: we won't use this region for anything between MMU early init and normal init, so no harm in disabling caches. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220817114244.1810531-10-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | ARM: mmu: define attrs_uncached_mem() helperAhmad Fatoum2022-08-181-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | We already have a helper with the same name for ARMv8, so define it here for reuse in the follow-up commit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220817114244.1810531-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | ARM: mmu64: map reserved regions uncachedAhmad Fatoum2022-08-182-1/+24
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we have reserved memory regions specially marked in the SDRAM bank requests, we can use this information to map these regions uncached and eXecute Never to avoid speculative access into these regions from causing hard-to-debug data aborts. The sequence used here is safe because __mmu_init turns off the MMU if enabled, so even if we overwrite early MMU uncached entries they are without effect until the MMU is turned on again, by which time the for_each_reserved_region should have disabled caching for them again (e.g. because they were listed in DT as /reserve-memory). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220817114244.1810531-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>