Changeset 14b5c30f in mainline for kernel/arch/arm64/src/arm64.c


Ignore:
Timestamp:
2020-02-07T11:22:28Z (4 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
db17889
Parents:
51da086
Message:

arm64: reset the kernel SP to its base value before entering user space

Without doing this, the part of the kernel stack that has been in use
before entering user space will remain forever unaccessible and wasted.

This is analogous to what is being done (by various means) on other
platforms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm64/src/arm64.c

    r51da086 r14b5c30f  
    167167        asm volatile (
    168168            /*
    169              * Clear all general-purpose registers, except x0 that holds an
    170              * argument for the user space.
     169             * Reset the kernel stack to its base value.
     170             *
     171             * Clear all general-purpose registers,
     172             * except x0 that holds an argument for
     173             * the user space.
    171174             */
     175            "mov sp, %[kstack]\n"
    172176            "mov x0, %[uspace_uarg]\n"
    173177            "mov x1, #0\n"
     
    202206            "mov x30, #0\n"
    203207            "eret\n"
    204             :: [uspace_uarg] "r" (kernel_uarg->uspace_uarg)
     208            :: [uspace_uarg] "r" (kernel_uarg->uspace_uarg),
     209               [kstack] "r" (((uint64_t) (THREAD->kstack))
     210                   + MEM_STACK_SIZE - SP_DELTA)
    205211        );
    206212
Note: See TracChangeset for help on using the changeset viewer.