zephyr/include
Martí Bolívar a627666e06 device: add fudge factor for handle padding
When CONFIG_USERSPACE is enabled, the ELF file from linker pass 1 is
used to create a hash table that identifies kernel objects by address.
We therefore can't allow the size of any object in the pass 2 ELF to
change in a way that would change those addresses, or we would create
a garbage hash table.

Simultaneously (and regardless of CONFIG_USERSPACE's value),
gen_handles.py must transform arrays of handles from their pass 1
values to their pass 2 values; see the file's docstring for more
details on that transformation.

The way this works is that gen_handles.py just pads out each pass 2
array so its length is the same as its pass 1 value. The padding value
is a repeated run of DEVICE_HANDLE_ENDS values. This value is the
terminator which we look for at runtime in places like
device_required_handles_get(), so there must be at least one, and we
error out in gen_handles.py if there's no room in the pass 2 array for
at least one such value. (If there is extra room, we just keep
inserting extra DEVICE_HANDLE_ENDS values to pad the array to its
original length.)

However, it is possible that a device has more direct dependencies in
the pass 2 handles array than its corresponding devicetree node had in
the pass 1 array. When this happens, users have no recourse, so that's
a potential showstopper.

To work around this possibility for now, add a new config option,
CONFIG_DEVICE_HANDLE_PADDING, whose value defaults to 0.

When nonzero, it is a count of padding handles that are inserted into
each device handles array. When gen_handles.py errors out due to lack
of room, its error message now tells the user how much to increase
CONFIG_DEVICE_HANDLE_PADDING by to work around the problem.

It looks like a real fix for this is to allocate kernel objects whose
addresses are required for hash tables in CONFIG_USERSPACE=y
configurations *before* the handle arrays. The handle arrays could
then be resized as needed in pass 2, which saves ROM by avoiding
unnecessary padding, and would avoid the need for
CONFIG_DEVICE_HANDLE_PADDING altogether.

However, this 'real fix' is not available and we are facing a deadline
to get a temporary solution in for Zephyr v2.7.0, so this is a good
enough workaround for now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-09-30 21:37:59 -04:00
..
app_memory
arch riscv: linker: fix PMP support on non-XIP system. 2021-09-29 14:44:04 -04:00
audio
bluetooth Bluetooth: common: Add build asserts for address struct sizes 2021-09-29 19:07:52 +02:00
canbus modules: canopennode: move glue code to modules directory 2021-07-01 13:32:18 -04:00
console doc: Fix a few typos in docs/comments/messages 2021-09-03 06:06:59 -04:00
crypto
data json: Changes enum name of square brackets from list to array 2021-09-28 19:52:10 -04:00
debug
devicetree reserved-memory: Fix layering violation 2021-09-28 14:01:36 -04:00
dfu dfu: boot: Add implementation for multi-image swap type check 2021-08-26 09:13:13 -04:00
disk
display toolchain: migrate iterable sections calls to the external API 2021-08-12 17:47:04 -04:00
drivers drivers: hwinfo: add reset causes 2021-09-29 14:44:21 -04:00
dt-bindings ITE drivers/kscan: add keyboard scan driver for it8xxx2_evb 2021-09-28 19:53:15 -04:00
fs subsys/fs/nvs: nvs_write return missing documentation 2021-09-28 06:15:20 -04:00
ipc ipc: rpmsg_multi_instance: Fix misleading types 2021-08-30 13:42:45 -04:00
kernel kernel: macro to define pinned kernel thread stacks 2021-08-26 21:16:22 -04:00
linker reserved-memory: Fix layering violation 2021-09-28 14:01:36 -04:00
logging logging: Cleaning references to tracing in logging 2021-09-29 14:59:36 +02:00
lorawan
mgmt subsys/mgmt/hawkbit: Prevent multiple instances of hawkbit_probe 2021-08-18 20:10:21 -04:00
modbus
net net: sockets: Add socket processing priority 2021-09-28 20:11:26 -04:00
pm pm: Fix function prototype visibility 2021-09-12 18:20:34 -04:00
portability cmsis_rtos_v1: fix thread instances management. 2021-09-09 12:01:06 -04:00
posix ARC: MWDT: workaround for double clockid_t definition 2021-08-13 13:43:19 -05:00
power
random
settings toolchain: migrate iterable sections calls to the external API 2021-08-12 17:47:04 -04:00
shell shell: add init backend configuration 2021-09-28 20:02:01 -04:00
stats
storage
sys lib: os: mpsc_pbuf: Add const qualifier to API calls 2021-09-28 06:15:39 -04:00
task_wdt
timing
toolchain armclang: adding toolchain/armclang.h header 2021-08-30 08:54:23 -04:00
tracing tracing: Add user-definable tracing interface 2021-09-02 06:54:35 -04:00
usb include: usb: fix hid feature item typo 2021-09-28 19:22:06 +02:00
zephyr
cache.h
device.h device: add fudge factor for handle padding 2021-09-30 21:37:59 -04:00
devicetree.h devicetree: add devicetree/pinctrl.h 2021-08-25 18:09:00 -04:00
ec_host_cmd.h
emul.h
exc_handle.h
fatal.h
init.h
irq_nextlevel.h
irq_offload.h
irq.h
kernel_includes.h kernel: move internal headers into include/kernel 2021-06-16 20:38:55 -04:00
kernel_structs.h kernel/sched: Add CONFIG_CPU_MASK_PIN_ONLY 2021-09-28 20:15:05 -04:00
kernel_version.h
kernel.h kernel: fix deadline typo 2021-09-30 17:01:09 -04:00
ptp_clock.h
shared_irq.h
spinlock.h
sw_isr_table.h
sys_clock.h
syscall_handler.h
syscall.h kernel: syscall: pin generated inline functions 2021-08-26 21:16:22 -04:00
timeout_q.h
toolchain.h armclang: adding toolchain/armclang.h header 2021-08-30 08:54:23 -04:00
wait_q.h kernel: move internal headers into include/kernel 2021-06-16 20:38:55 -04:00
zephyr.h