arch: x86_64: Fix idle stack allocation

Summary:
- I noticed that qemu-intel64:nsh does not work
- And I found that commit 6e6eecaa73 affected this issue
- This commit changes idle stack allocation to fix the issue

Impact:
- None

Testing:
- Tested with qemu-intel64:nsh and qemu-intel64:ostest

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa
2021-08-31 14:36:47 +09:00
committed by Xiang Xiao
parent e95f23ef8b
commit 24697e8f67
3 changed files with 6 additions and 36 deletions
+4 -1
View File
@@ -50,6 +50,9 @@
* Public Functions
****************************************************************************/
const uintptr_t g_idle_topstack = (uintptr_t)&_ebss +
CONFIG_IDLETHREAD_STACKSIZE;
/****************************************************************************
* Name: up_allocate_heap
*
@@ -71,7 +74,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
/* Calculate the end of .bss section */
uintptr_t hstart = (((uintptr_t)&_ebss + PAGE_SIZE - 1) & PAGE_MASK);
uintptr_t hstart = (g_idle_topstack + PAGE_SIZE - 1) & PAGE_MASK;
*heap_start = (void *)hstart;
/* The size is the rest of the RAM */
+1 -1
View File
@@ -120,7 +120,7 @@ extern volatile uint64_t *g_current_regs;
* end of the heap is CONFIG_RAM_END
*/
extern uint64_t g_idle_topstack;
extern const uintptr_t g_idle_topstack;
/* Address of the saved user stack pointer */
+1 -34
View File
@@ -290,8 +290,7 @@ clear_bss:
jne clear_bss
// Properly setup RSP to idle stack
movabs $idle_stack, %rbx
add $CONFIG_IDLETHREAD_STACKSIZE, %rbx
movabs $g_idle_topstack, %rbx
mov %rbx, %rsp
@@ -468,35 +467,3 @@ pt_low:
.fill X86_NUM_PAGE_ENTRY * X86_NUM_PAGE_ENTRY, X86_PAGE_ENTRY_SIZE, 0
.fill X86_NUM_PAGE_ENTRY * X86_NUM_PAGE_ENTRY, X86_PAGE_ENTRY_SIZE, 0
/****************************************************************************
* .bss
****************************************************************************/
/* The stack for the IDLE task thread is declared in .bss. NuttX boots and
* initializes on the IDLE thread, then at the completion of OS startup, this
* thread becomes the thread that executes when there is nothing else to
* do in the system (see up_idle()).
*/
.section .bss
.type idle_stack, @object
.comm idle_stack, CONFIG_IDLETHREAD_STACKSIZE, 32
.size idle_stack, CONFIG_IDLETHREAD_STACKSIZE
/****************************************************************************
* .rodata
****************************************************************************/
.section .rodata, "a"
/* HEAP BASE: _sbss is the start of the BSS region (see ld.script) _ebss is
* the end of the BSS region (see liker script). The heap continues from there
* until the end of memory.
*/
.type g_idle_topstack, @object
g_idle_topstack:
.quad _ebss
.size g_idle_topstack, . - g_idle_topstack
.end