mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 18:06:50 +00:00
base: Fix stack pointer alignment for ARM
After some research we found that the stack pointer on ARM platforms must be at least double word aligned (See: "Procedure Call Standard for the ARM Architecture" - 5.2.1.1). Since a 'call' on ARM will not result in a stack pointer change (like on x86), the current behavior resulted in a 4 Byte aligned stack only. Follow up to #1043
This commit is contained in:
parent
df066521a5
commit
433a216919
27
base/include/arm/cpu/consts.h
Normal file
27
base/include/arm/cpu/consts.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* \brief Constants definitions for the ARM architecture.
|
||||||
|
* \author Sebastian Sumpf
|
||||||
|
* \date 2014-02-20
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011-2013 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INCLUDE__ARM__CPU__CONSTS_H_
|
||||||
|
#define _INCLUDE__ARM__CPU__CONSTS_H_
|
||||||
|
|
||||||
|
#include <base/stdint.h>
|
||||||
|
|
||||||
|
namespace Abi {
|
||||||
|
/**
|
||||||
|
* On ARM a call (or branch) will not change the stack pointer, so we do not
|
||||||
|
* need stack adjustment
|
||||||
|
*/
|
||||||
|
static constexpr Genode::size_t stack_adjustment() { return 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _INCLUDE__ARM__CPU__CONSTS_H_ */
|
@ -59,6 +59,7 @@
|
|||||||
#include <base/lock.h>
|
#include <base/lock.h>
|
||||||
#include <base/native_types.h>
|
#include <base/native_types.h>
|
||||||
#include <base/trace/logger.h>
|
#include <base/trace/logger.h>
|
||||||
|
#include <cpu/consts.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/bit_allocator.h>
|
#include <util/bit_allocator.h>
|
||||||
#include <ram_session/ram_session.h> /* for 'Ram_dataspace_capability' type */
|
#include <ram_session/ram_session.h> /* for 'Ram_dataspace_capability' type */
|
||||||
@ -103,12 +104,12 @@ namespace Genode {
|
|||||||
* Top of stack
|
* Top of stack
|
||||||
*
|
*
|
||||||
* The alignment matches an initial stack frame, which is
|
* The alignment matches an initial stack frame, which is
|
||||||
* sufficient for the AMD64 ABI (stack top + 8 is 16-byte
|
* sufficient for the AMD64 ABI (stack top + adjustment is 16-byte
|
||||||
* aligned).
|
* aligned).
|
||||||
*/
|
*/
|
||||||
addr_t stack_top() const
|
addr_t stack_top() const
|
||||||
{
|
{
|
||||||
return ((addr_t)_stack & ~0xf) - sizeof(addr_t);
|
return ((addr_t)_stack & ~0xf) - Abi::stack_adjustment();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#ifndef _INCLUDE__X86__CPU__CONSTS_H_
|
#ifndef _INCLUDE__X86__CPU__CONSTS_H_
|
||||||
#define _INCLUDE__X86__CPU__CONSTS_H_
|
#define _INCLUDE__X86__CPU__CONSTS_H_
|
||||||
|
|
||||||
|
#include <base/stdint.h>
|
||||||
|
|
||||||
namespace X86 {
|
namespace X86 {
|
||||||
|
|
||||||
enum Eflags_masks {
|
enum Eflags_masks {
|
||||||
@ -32,4 +34,11 @@ namespace X86 {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Abi {
|
||||||
|
/**
|
||||||
|
* On x86 a call will result in a growth of the stack by machine word size
|
||||||
|
*/
|
||||||
|
static constexpr Genode::size_t stack_adjustment() { return sizeof(Genode::addr_t); }
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _INCLUDE__X86__CPU__CONSTS_H_ */
|
#endif /* _INCLUDE__X86__CPU__CONSTS_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user