Thread (15 messages) 15 messages, 4 authors, 2017-08-29
STALE3243d
Revisions (4)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 current
  4. v1 [diff vs current]

[PATCH 3/3] ARM: XIP kernel: store .data compressed in ROM

From: Nicolas Pitre <hidden>
Date: 2017-08-26 15:41:21

On Sat, 26 Aug 2017, Ard Biesheuvel wrote:
On 25 August 2017 at 17:26, Nicolas Pitre [off-list ref] wrote:
quoted
The .data segment stored in ROM is only copied to RAM once at boot time
and never referenced afterwards. This is arguably a suboptimal usage of
ROM resources.

This patch allows for compressing the .data segment before storing it
into ROM and decompressing it to RAM rather than simply copying it,
saving on precious ROM space.

Because global data is not available yet (obviously) we must allocate
decompressor workspace memory on the stack. The .bss area is used as a
stack area for that purpose before it is cleared. The required stack
frame is 9568 bytes for __inflate_kernel_data() alone, so make sure
the .bss is large enough to cope with that plus extra room for called
functions or fail the build.

Signed-off-by: Nicolas Pitre <redacted>
---
[...]
quoted
+#ifdef CONFIG_XIP_DEFLATED_DATA
+/*
+ * The .bss is used as a stack area for __inflate_kernel_data() whose stack
+ * frame is 9568 bytes. Make sure it has extra room left.
+ */
+ASSERT((_end - __bss_start) >= 12288, ".bss too small for CONFIG_XIP_DEFLATED_DATA")
The open coded numbers are a bit confusing here: the stack check uses
10240, the code actually needs >9568 bytes and here, you assert that
there is at least 12288 space between _end and __bss_start.
The 9568 bytes is what my particular gcc version actually uses for 
__inflate_kernel_data(). That is not a tail function so some more space 
is needed. I imagine this may vary a bit from compiler versions.

The 10240 is 2.5x page size and 12288 is 3x page size. Those numbers are 
arbitrary but I had to pick something.


Nicolas
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help