kernel: app_smem: allowing pinning memory partitions

This allows memory partitions to be put into the pinned
section so they are available during boot. For example,
the stack guard (in libc partition) is needed during boot
but before the paging mechanism is initialized. Without
pinning it in physical memory, it would fault in early
boot process.

A new cmake property app_smem,pinned_partitions is
introduced so that additional partitions can be pinned
if needed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2021-07-12 13:33:32 -07:00 committed by Christopher Friedt
commit 2117a2a44b
10 changed files with 216 additions and 26 deletions

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2021 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* This hackish way of including files is due to CMake issues:
* https://gitlab.kitware.com/cmake/cmake/issues/11985
* https://gitlab.kitware.com/cmake/cmake/issues/13718
*
* When using the "Unix Makefiles" generator, CMake simply
* greps for "#include" to generate dependency list.
* So if doing it normally, both files are being included
* in the dependency list. This creates weird dependency
* issue:
*
* 1. Using A.ld to create a linker script A.cmd.
* 2. Using A.cmd to generate A_prebuilt.elf.
* 3. Using A_prebuilt.elf to create B.ld.
* 4. Creating B.cmd with B.ld.
* 5. Creating B_prebuilt.elf using B.cmd.
*
* Since the dependency list of A.cmd contains both
* A.ld and B.ld, when make is invoked again, B.ld
* is newer than A.cmd so everything from this point on
* gets rebuilt. In order to break this cycle, this
* hackish needs to be used since CMake does not parse
* macros, and thus these will not appear in
* the dependency list. The dependencies should then be
* put in CMakeLists.txt instead.
*
* Note: Ninja generator does not suffer from this issue.
*/
#ifdef LINKER_APP_SMEM_UNALIGNED
#define APP_SMEM_LD <app_smem_pinned_unaligned.ld>
#else
#define APP_SMEM_LD <app_smem_pinned_aligned.ld>
#endif
#include APP_SMEM_LD
#undef APP_SMEM_LD

View file

@ -0,0 +1,7 @@
/*
* Copyright (c) 2021 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Empty file */

View file

@ -0,0 +1,7 @@
/*
* Copyright (c) 2021 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Empty file */

View file

@ -197,6 +197,13 @@ extern char _app_smem_size[];
extern char _app_smem_rom_start[];
extern char _app_smem_num_words[];
#ifdef CONFIG_LINKER_USE_PINNED_SECTION
extern char _app_smem_pinned_start[];
extern char _app_smem_pinned_end[];
extern char _app_smem_pinned_size[];
extern char _app_smem_pinned_num_words[];
#endif
/* Memory owned by the kernel. Start and end will be aligned for memory
* management/protection hardware for the target architecture.
*

View file

@ -28,6 +28,8 @@
#define _APP_BSS_SECTION_NAME app_bss
#define _APP_NOINIT_SECTION_NAME app_noinit
#define _APP_SMEM_PINNED_SECTION_NAME app_smem_pinned
#define _UNDEFINED_SECTION_NAME undefined
/* Interrupts */