Skip to content

Commit

Permalink
kernel: dynamic: use 4k stack size for x86
Browse files Browse the repository at this point in the history
x86 architectures require a dynamic stack size that is a multiple
of 4096 bytes due to mmu restrictions.

For example, this test would previously fail when using the
default dynamic stack size of 1024 bytes for 32-bit
platforms.

```
west build -p auto -b qemu_x86/atom/nopae -t run \
  tests/posix/common/ -- -DCONFIG_USERSPACE=y
```

It would pass with an additional argument
```
west build -p auto -b qemu_x86/atom/nopae -t run \
  tests/posix/common/ -- -DCONFIG_USERSPACE=y \
  -DCONFIG_DYNAMIC_THREAD_STACK_SIZE=4096
```

Add a special default for x86 when using dynamic thread stacks.

The x86 default removes the need for `boards/qemu_x86*.conf`,
with the exception of `qemu_x86_tiny`.

qemu_x86_tiny did not have sufficient memory (or configuration)
to run the non-userspace tests, so bump up the available ram
from 256k to 512k for this test and clone the .conf from the
demand paging tests.

Eventually, the common posix test should be split into more
concise functional categories.

Signed-off-by: Chris Friedt <[email protected]>
  • Loading branch information
Chris Friedt authored and nashif committed Oct 5, 2024
1 parent 82ec1d7 commit b6aed5c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
5 changes: 3 additions & 2 deletions kernel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ if DYNAMIC_THREAD

config DYNAMIC_THREAD_STACK_SIZE
int "Size of each pre-allocated thread stack"
default 1024 if !64BIT
default 2048 if 64BIT
default 4096 if X86
default 1024 if !X86 && !64BIT
default 2048 if !X86 && 64BIT
help
Default stack size (in bytes) for dynamic threads.

Expand Down
1 change: 0 additions & 1 deletion tests/posix/common/boards/qemu_x86.conf

This file was deleted.

1 change: 0 additions & 1 deletion tests/posix/common/boards/qemu_x86_64.conf

This file was deleted.

16 changes: 16 additions & 0 deletions tests/posix/common/boards/qemu_x86_tiny.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# The test is highly sensitive to size of kernel image.
# However, specifying how many pages used by
# the backing store must be done in build time.
# So here we are, tuning this manually.
CONFIG_BACKING_STORE_RAM_PAGES=12

# The following is needed so that .text and following
# sections are present in physical memory to test
# using backing store for anonymous memory.
CONFIG_KERNEL_VM_BASE=0x0
CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT=y
CONFIG_BACKING_STORE_RAM=y
CONFIG_BACKING_STORE_QEMU_X86_TINY_FLASH=n
11 changes: 11 additions & 0 deletions tests/posix/common/boards/qemu_x86_tiny.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024, Tenstorrent AI ULC
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
dram0: memory@0 {
reg = <0x100000 0x80000>;
};
};

0 comments on commit b6aed5c

Please sign in to comment.