zephyr/include
Nicolas Pitre f9461d1ac4 mmu: fix ARM64 compilation by removing z_mapped_size usage
The linker script defines `z_mapped_size` as follows:

```
	z_mapped_size = z_mapped_end - z_mapped_start;
```

This is done with the belief that precomputed values at link time will
make the code smaller and faster.

On Aarch64, symbol values are relocated and loaded relative to the PC
as those are normally meant to be memory addresses.

Now if you have e.g. `CONFIG_SRAM_BASE_ADDRESS=0x2000000000` then
`z_mapped_size` might still have a reasonable value, say 0x59334.
But, when interpreted as an address, that's very very far from the PC
whose value is in the neighborhood of 0x2000000000. That overflows the
4GB relocation range:

```
kernel/libkernel.a(mmu.c.obj): in function `z_mem_manage_init':
kernel/mmu.c:527:(.text.z_mem_manage_init+0x1c):
relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21
```

The solution is to define `Z_KERNEL_VIRT_SIZE` in terms of
`z_mapped_end - z_mapped_start` at the source code level. Given this
is used within loops that already start with `z_mapped_start` anyway,
the compiler is smart enough to combine the two occurrences and
dispense with a size counter, making the code effectively
slightly better for all while avoiding the Aarch64 relocation
overflow:

```
   text    data     bss     dec     hex filename
   1216       8  294936  296160   484e0 mmu.c.obj.arm64.before
   1212       8  294936  296156   484dc mmu.c.obj.arm64.after
   1110       8    9244   10362    287a mmu.c.obj.x86-64.before
   1106       8    9244   10358    2876 mmu.c.obj.x86-64.after
```

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-02-05 17:19:56 -05:00
..
app_memory kernel: move thread definitions to thread.h 2021-01-13 18:18:42 -05:00
arch mmu: fix ARM64 compilation by removing z_mapped_size usage 2021-02-05 17:19:56 -05:00
audio device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
bluetooth bluetooth: host: expand l2cap CID abbreviation 2021-02-04 08:31:20 -05:00
canbus subsys: canopen: Add a wrapper to avoid passing device to CO_init 2020-09-02 13:48:13 +02:00
cmsis_rtos_v1 all: Add 'U' suffix when using unsigned variables 2019-03-28 17:15:58 -05:00
cmsis_rtos_v2 global: Remove leading/trailing blank lines in files 2019-12-11 19:17:27 +01:00
console device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
crypto device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
data doc: fix @param usage in callbacks 2020-12-18 12:18:28 +01:00
debug debug: coredump: remove z_ prefix for stuff used outside subsys 2021-01-21 22:08:59 -05:00
devicetree devicetree: fix DT_GPIO_CTLR docstring 2021-01-16 08:09:51 -06:00
dfu modules: introduce MCUBOOT_BOOTUTIL module 2021-01-14 18:03:38 +01:00
disk device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
display device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
drivers dts: Rename compatible arm,arm-timer to arm,armv8-timer 2021-02-04 07:04:28 -05:00
dt-bindings clocks: add clock api for gpt 2021-01-22 08:34:49 -06:00
fs include/fs: fixed typo in fs_file_t_init() description 2021-02-05 07:32:20 -05:00
ipc ipc: RPMsg service to register multiple endpoints 2021-01-19 22:07:09 +01:00
kernel kernel: move thread definitions to thread.h 2021-01-13 18:18:42 -05:00
linker mmu: fix ARM64 compilation by removing z_mapped_size usage 2021-02-05 17:19:56 -05:00
logging logging: fix warnings when building with -Wunused-variable 2021-02-04 07:43:07 -05:00
lorawan lorawan,lora: fix C++ compilation/linking errors 2020-10-15 11:08:07 +02:00
mgmt doc: fix @param usage in callbacks 2020-12-18 12:18:28 +01:00
net net: coap: define default CoAP version 2021-02-02 14:03:01 -05:00
posix include/posix: fix extern "C" placement 2020-10-13 10:05:30 -05:00
power power: Use substate-id in pm subsystem 2021-01-22 09:31:20 -05:00
random random: Add syscalls for random subsystem 2020-07-08 21:05:36 -04:00
settings settings: disallow modifying the content of a static subtree name 2020-07-27 19:03:44 +02:00
shell shell: internal api update in shell.h 2021-01-14 12:07:25 +01:00
stats zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
storage storage/flash_map: Added function for get erased byte value 2020-10-30 15:53:38 +01:00
sys lib/os/heap: add alignment precisions to the documentation 2021-02-02 19:08:24 -05:00
timing timing: do not repeatedly do init()/start()/stop() 2020-11-11 23:55:49 -05:00
toolchain xcc: define __INT*_C() and __UINT*_C() 2021-02-05 07:45:07 -05:00
tracing tracing: trace mutex/semaphore using dedicated calls 2020-08-24 13:21:12 +02:00
usb doc: fix @param usage in callbacks 2020-12-18 12:18:28 +01:00
zephyr zephyr: introduce z_max_align_t 2020-11-17 11:44:16 +02:00
cache.h cache: libmetal: Redirect sys_cache_flush() 2021-01-19 14:31:02 -05:00
device.h device: fix potential truncation of DT-derived device names 2021-01-25 16:26:12 -05:00
devicetree.h devicetree: add DT_SAME_NODE() 2021-01-19 16:06:55 -05:00
ec_host_cmd.h include: remove enum build assert 2020-10-02 11:44:39 +02:00
emul.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
exc_handle.h kernel: rename z_arch_ to arch_ 2019-11-07 15:21:46 -08:00
fatal.h doc: fix misspelling in API doxygen comments 2019-10-29 06:00:14 +01:00
generated_dts_board.h dts: Add include/generated_dts_board.h for backwards compatibility 2020-01-17 17:57:59 +01:00
init.h device: deprecate DEVICE_AND_API_INIT 2021-01-12 08:31:12 -06:00
irq.h irq: document requirement that irq_lock/unlock provides a memory barrier 2021-01-26 13:42:17 -05:00
irq_nextlevel.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
irq_offload.h irq: Change offload API to take a constant parameter 2020-09-02 13:48:13 +02:00
kernel.h kernel: remove k_mem_pool API remnants 2021-02-02 22:51:40 -05:00
kernel_includes.h kernel: move thread definitions to thread.h 2021-01-13 18:18:42 -05:00
kernel_structs.h power: standarize PM Kconfigs and cleanup 2020-12-09 15:18:29 -05:00
kernel_version.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
mempool_heap.h kernel: Remove z_mem_pool wrapper internals 2020-12-07 21:50:14 -05:00
ptp_clock.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
sched_priq.h cleanup: include/: move misc/util.h to sys/util.h 2019-06-27 22:55:49 -04:00
shared_irq.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
spinlock.h kernel: fix usage of KERNEL_COHERENCE macro 2021-02-03 10:42:04 -05:00
sw_isr_table.h irq: Change dynamic API to take a constant parameter 2020-09-02 13:48:13 +02:00
sys_clock.h api: add C++ friendly version of Z_TIMEOUT_TICKS. 2021-01-20 09:23:20 -05:00
syscall.h global: Remove leading/trailing blank lines in files 2019-12-11 19:17:27 +01:00
syscall_handler.h kernel: Cleanup logger setup in kernel files 2020-11-27 09:56:34 -05:00
timeout_q.h kernel: timer: update _timeout API for const correctness 2020-10-02 11:29:14 +02:00
toolchain.h ARC: toolchain: handle difference in macros for MWDT and ARC GNU 2020-09-05 10:22:56 -05:00
wait_q.h headers: Refactor kernel and arch headers. 2019-11-06 16:07:32 -08:00
zephyr.h headers: Fix headers across the project 2018-09-17 15:49:26 -04:00