41 #include "debug/Stack.hh" 43 #include "params/Process.hh" 57 fatal_if(params->useArchPT,
"Arch page tables not implemented.");
62 Addr stack_base = 0xbf000000
L;
64 Addr max_stack_size = 8 * 1024 * 1024;
67 Addr next_thread_stack_base = stack_base - max_stack_size;
70 Addr mmap_end = 0x70000000
L;
72 memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
73 next_thread_stack_base, mmap_end);
106 uint32_t features = 0;
146 int sentry_size = intSize;
148 string platform =
"v51";
149 int platform_size = platform.size() + 1;
155 int aux_data_size = filename.size() + 1;
157 int env_data_size = 0;
158 for (
int i = 0;
i <
envp.size(); ++
i) {
159 env_data_size +=
envp[
i].size() + 1;
161 int arg_data_size = 0;
162 for (
int i = 0;
i <
argv.size(); ++
i) {
163 arg_data_size +=
argv[
i].size() + 1;
166 int info_block_size =
167 sentry_size + env_data_size + arg_data_size +
168 aux_data_size + platform_size;
171 int aux_array_size = intSize * 2 * (auxv.size() + 1);
173 int envp_array_size = intSize * (
envp.size() + 1);
174 int argv_array_size = intSize * (
argv.size() + 1);
176 int argc_size = intSize;
188 int partial_size = frame_size;
189 int aligned_partial_size =
roundUp(partial_size, align);
190 int aux_padding = aligned_partial_size - partial_size;
192 int space_needed = frame_size + aux_padding;
194 Addr stack_min =
memState->getStackBase() - space_needed;
204 uint32_t sentry_base =
memState->getStackBase() - sentry_size;
205 uint32_t aux_data_base = sentry_base - aux_data_size;
206 uint32_t env_data_base = aux_data_base - env_data_size;
207 uint32_t arg_data_base = env_data_base - arg_data_size;
208 uint32_t platform_base = arg_data_base - platform_size;
209 uint32_t auxv_array_base = platform_base - aux_array_size - aux_padding;
210 uint32_t envp_array_base = auxv_array_base - envp_array_size;
211 uint32_t argv_array_base = envp_array_base - argv_array_size;
212 uint32_t argc_base = argv_array_base - argc_size;
214 DPRINTF(Stack,
"The addresses of items on the initial stack:\n");
215 DPRINTF(Stack,
"0x%x - aux data\n", aux_data_base);
216 DPRINTF(Stack,
"0x%x - env data\n", env_data_base);
217 DPRINTF(Stack,
"0x%x - arg data\n", arg_data_base);
218 DPRINTF(Stack,
"0x%x - platform base\n", platform_base);
219 DPRINTF(Stack,
"0x%x - auxv array\n", auxv_array_base);
220 DPRINTF(Stack,
"0x%x - envp array\n", envp_array_base);
221 DPRINTF(Stack,
"0x%x - argv array\n", argv_array_base);
222 DPRINTF(Stack,
"0x%x - argc \n", argc_base);
223 DPRINTF(Stack,
"0x%x - stack min\n", stack_min);
228 uint32_t argc =
argv.size();
229 uint32_t guestArgc =
htobe(argc);
232 uint32_t sentry_NULL = 0;
236 for (
int i = auxv.size() - 1;
i >= 0;
i--) {
238 auxv[
i].val = platform_base;
241 auxv[
i].val = aux_data_base;
247 Addr auxv_array_end = auxv_array_base;
248 for (
const auto &aux: auxv) {
250 auxv_array_end +=
sizeof(aux);
255 auxv_array_end +=
sizeof(zero);
Addr programHeaderTable()
const std::string & name()
bool write(const PortProxy &proxy) const
virtual TheISA::PCState pcState() const =0
virtual RegVal readIntReg(RegIndex reg_idx) const =0
bool successful() const
Was the system call successful?
std::vector< ContextID > contextIds
void writeString(Addr addr, const char *str) const
Same as tryWriteString, but insists on success.
void allocateMem(Addr vaddr, int64_t size, bool clobber=false)
SETranslatingPortProxy initVirtMem
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value) override
Overload hash function for BasicBlockRange type.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
std::shared_ptr< MemState > memState
ThreadContext is the external interface to all thread state for anything outside of the CPU...
int64_t encodedValue() const
The encoded value (as described above)
const ByteOrder GuestByteOrder
PowerProcess(ProcessParams *params, ObjectFile *objFile)
ThreadContext * getThreadContext(ContextID tid) const
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void align(const scfx_rep &lhs, const scfx_rep &rhs, int &new_wp, int &len_mant, scfx_mant_ref &lhs_mant, scfx_mant_ref &rhs_mant)
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
void copyStringArray(std::vector< std::string > &strings, AddrType array_ptr, AddrType data_ptr, const ByteOrder bo, PortProxy &memProxy)
void argsInit(int intSize, int pageSize)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
const RegIndex StackPointerReg
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
std::vector< std::string > envp
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint16_t programHeaderSize()
Declarations of a non-full system Page Table.
uint16_t programHeaderCount()
void write(Addr address, const T &data) const
Write object T to address.
const RegIndex ReturnValueReg
std::vector< std::string > argv
This class represents the return value from an emulated system call, including any errno setting...
RegVal getSyscallArg(ThreadContext *tc, int &i) override