nova: define kernel memory based on system memory

Switch to kernel branch, that determines the available system memory during
boot time. The overall kernel memory is still static, but during boot time
dynamically the amount can be chosen. Following 3 config option exists:

CONFIG_MEMORY_BOOT is the amount of kernel memory allocated in the BSS
statically - effectively chosen during link time - see linker script.

CONFIG_MEMORY_DYN_MIN && CONFIG_MEMORY_DYN_PER_MILL configures the dynamic
part of the kernel memory allocation applied during early kernel boot time.
CONFIG_MEMORY_DYN_MIN is the amount of memory which should be allocated at
least. CONFIG_MEMORY_DYN_PER_MILL defines the amount of the system memory in
per mill which should be allocated at most. The overall maximum kernel memory
is restricted to ~1G (64bit), due to the chosen internal virtual memory layout.

Fixes #2985
This commit is contained in:
Alexander Boettcher 2018-09-13 16:53:57 +02:00 committed by Christian Helmuth
parent 5d15c8d534
commit 3824ad4756
4 changed files with 14 additions and 5 deletions

View File

@ -1 +1 @@
96a3ed33cf48798847b43f6023ae92a002224875
95f7056d34c5d48ef9dfbf67f5053fd0486e47b8

View File

@ -4,7 +4,7 @@ DOWNLOADS := nova.git
# r10 branch
URL(nova) := https://github.com/alex-ab/NOVA.git
REV(nova) := b44329a8601ff3936aa77336752d85cff95f1a94
REV(nova) := b156131007c928e2968fc5e551cea402c1886919
DIR(nova) := src/kernel/nova
PATCHES := $(sort $(wildcard $(REP_DIR)/patches/*.patch))

View File

@ -489,6 +489,7 @@ Platform::Platform() :
Hip::Mem_desc *boot_fb = nullptr;
bool efi_boot = false;
addr_t kernel_memory = 0;
/*
* All "available" ram must be added to our physical allocator before all
@ -501,6 +502,9 @@ Platform::Platform() :
if (mem_desc->type == Hip::Mem_desc::FRAMEBUFFER)
boot_fb = mem_desc;
if (mem_desc->type == Hip::Mem_desc::MICROHYPERVISOR)
kernel_memory += mem_desc->size;
if (mem_desc->type != Hip::Mem_desc::AVAILABLE_MEMORY) continue;
if (verbose_boot_info) {
@ -731,7 +735,7 @@ Platform::Platform() :
/* core log as ROM module */
{
void * phys_ptr = nullptr;
unsigned const pages = 1;
unsigned const pages = 4;
size_t const log_size = pages << get_page_size_log2();
ram_alloc()->alloc_aligned(log_size, &phys_ptr, get_page_size_log2());
@ -760,6 +764,8 @@ Platform::Platform() :
log(_rom_fs);
log(Number_of_bytes(kernel_memory), " kernel memory"); log("");
/* add capability selector ranges to map */
unsigned const first_index = 0x2000;
unsigned index = first_index;

View File

@ -20,7 +20,10 @@ CC_OPT += -pipe \
-fdata-sections -fomit-frame-pointer -freg-struct-return \
-freorder-blocks -funit-at-a-time -fno-exceptions -fno-rtti \
-fno-stack-protector -fvisibility-inlines-hidden \
-fno-asynchronous-unwind-tables -std=gnu++0x
-fno-asynchronous-unwind-tables -std=gnu++0x
# kernel memory: 28M minimum dynamic or 10 pro mill of the system memory
CC_OPT += -DCONFIG_MEMORY_DYN_MIN=0x1c00000 \
-DCONFIG_MEMORY_DYN_PER_MILL=10
CC_OPT_PIC :=
ifeq ($(filter-out $(SPECS),32bit),)
override CC_MARCH = -m32
@ -44,7 +47,7 @@ LD_SCRIPT_STATIC = hypervisor.o
$(TARGET): hypervisor.o
hypervisor.o: $(NOVA_SRC_DIR)/src/hypervisor.ld target.mk
$(VERBOSE)$(CC) $(INCLUDES) -DCONFIG_KERNEL_MEMORY=32M -MP -MMD -pipe $(CC_MARCH) -xc -E -P $< -o $@
$(VERBOSE)$(CC) $(INCLUDES) -DCONFIG_MEMORY_BOOT=4M -MP -MMD -pipe $(CC_MARCH) -xc -E -P $< -o $@
clean cleanall:
$(VERBOSE)rm -rf $(NOVA_BUILD_DIR)