Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker: introduce boot and pinned regions #34717

Merged
merged 19 commits into from
May 10, 2021

Conversation

dcpleung
Copy link
Member

This adds the bits so boot and pinned regions can be specified. These regions each contains their own text, data, rodata, bss and noinit linker sections. The boot region allows grouping of data and functions that are only used during the boot process. The associated physical page frames can be re-used if so desired with paging enabled. The pinned region hosts data and functions which must always reside in physical memory, for example, page fault handling routines for demand paging. This also provides the necessary macros to specify which section to place symbols. Currently, only a few source files are using these macros. More work needs to be done to classify at least the core kernel on where each symbol belongs.

@nashif
Copy link
Member

nashif commented May 6, 2021

@dcpleung can you rebase?

@dcpleung
Copy link
Member Author

dcpleung commented May 6, 2021

Rebased

Copy link
Collaborator

@jenmwms jenmwms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I spot tested on ehl_crb with twister for tests/kernel/timer and /threads. Please let me know if there is a better test to exercise this.

@galak galak removed this from the v2.6.0 milestone May 10, 2021
This is similar to Z_GENERIC_SECTION() but the resulting
section name has a period as prefix. This eases the need
to create a section name macro for both assembly and C.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The generic version of SECTION_VAR() is adding an extra space
during expansion before second argument (e.g.
SECTION_VAR(section, variable) => ".section. variable"
instead of ".section.variable") which would result in build
error. So remove the "##" in macro to fix this, and now it
will also behave the same as SECTION_FUNC().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
These macros are identical except the specified linker region.
So refactor them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
There is exactly one function being defined with TEXT_START
macro so the x86-32 __start can appear at the beginning of
text section. Since no one else is using it, better remove
TEXT_START to simplify things.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds the necessary bits for linker scripts and source code
to specify which symbols are needed for boot process so they
can be grouped together.

One use of this is to group boot related code and data so these
won't interval with other kernel and application for better
caching.

This is a must for demand paging as some functions and data
must be available during the boot process and before the memory
manager is initialized. During this time, paging cannot be used
so symbols linked in virtual memory space are unavailable.

This is up to the arch/SoC/board to define the sections in
their linker scripts as section may need special alignment
which cannot be done in common script snippets.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds the necessary bits for linker scripts and source code
to specify which symbols need to be pinned in memory. This is
needed for demand paging as some functions and data must reside
in memory all the time and cannot be paged out (e.g. paging,
scheduler, and interrupt routines for functionality).

This is up to the arch/SoC/board to define the sections in
their linker scripts as the pinned section may need special
alignment which cannot be done in common script snippets.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This allows interrupt service routine to be declared with
the __isr tag so they can be placed in the correct linker
section. The first would be putting them into the pinned
section.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Both boot and pinned regions need to be mapped and permissions
set correctly.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds both boot and pinned sections to the linker
script for ia32. This is required for enabling demand
paging for kernel and data.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This updates the test to account for boot and pinned sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds to the macros for device MMIO declaration so they can
be put into  boot or pinned linker sections as needed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This changes the ARCH_IRQ_CONNECT() to put the IRQ stubs into
pinned linker section if needed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This marks the functions into appropriate linker sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This marks the data and functions into appropriate
linker sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This marks the data and functions into appropriate
linker sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This marks the data and functions into appropriate
linker sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This marks code and data within x86/ia32 so they are going to
reside in boot and pinned regions. This is a step to enable
demand paging for whole kernel.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This enables the kconfig options so that the board would be
using boot and pinned linker sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds the tags for functions and variables so they
can be put into boot/pinned sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
@galak galak merged commit 660d147 into zephyrproject-rtos:master May 10, 2021
@dcpleung dcpleung deleted the linker_pinned_sections branch May 10, 2021 21:04
@@ -16,6 +16,7 @@
#define ZEPHYR_INCLUDE_SYS_DEVICE_MMIO_H

#include <toolchain/common.h>
#include <linker/sections.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #41555 I'm moving this #include before the previous one to fix a BUILD_ASSERT redefinition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants