52 #include "debug/Stack.hh" 54 #include "params/Process.hh" 71 fatal_if(params->useArchPT,
"Arch page tables not implemented.");
79 Addr stack_base = 0xbf000000
L;
80 Addr max_stack_size = 8 * 1024 * 1024;
81 Addr next_thread_stack_base = stack_base - max_stack_size;
82 Addr mmap_end = 0x40000000
L;
84 memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
85 next_thread_stack_base, mmap_end);
93 Addr stack_base = 0x7fffff0000
L;
94 Addr max_stack_size = 8 * 1024 * 1024;
95 Addr next_thread_stack_base = stack_base - max_stack_size;
96 Addr mmap_end = 0x4000000000
L;
98 memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
99 next_thread_stack_base, mmap_end);
153 Arm_FastMult = 1 << 4,
159 Arm_Crunch = 1 << 10,
160 Arm_ThumbEE = 1 << 11,
163 Arm_Vfpv3d16 = 1 << 14
166 return Arm_Swp | Arm_Half | Arm_Thumb | Arm_FastMult |
167 Arm_Vfp | Arm_Edsp | Arm_ThumbEE | Arm_Neon |
168 Arm_Vfpv3 | Arm_Vfpv3d16;
179 Arm_Evtstrm = 1 << 2,
185 Arm_Atomics = 1 << 8,
187 Arm_Asimdhp = 1 << 10,
189 Arm_Asimdrdm = 1 << 12,
197 Arm_Asimddp = 1 << 20,
198 Arm_Sha512 = 1 << 21,
200 Arm_Asimdfhm = 1 << 23,
203 Arm_Ilrcpc = 1 << 26,
213 hwcap |= (pf_r0.fp == 0) ? Arm_Fp : 0;
214 hwcap |= (pf_r0.fp == 1) ? Arm_Fphp | Arm_Fp : 0;
215 hwcap |= (pf_r0.advsimd == 0) ? Arm_Asimd : 0;
216 hwcap |= (pf_r0.advsimd == 1) ? Arm_Asimdhp | Arm_Asimd : 0;
217 hwcap |= (pf_r0.sve >= 1) ? Arm_Sve : 0;
218 hwcap |= (pf_r0.dit >= 1) ? Arm_Dit : 0;
222 hwcap |= (isa_r0.aes >= 1) ? Arm_Aes : 0;
223 hwcap |= (isa_r0.aes >= 2) ? Arm_Pmull : 0;
224 hwcap |= (isa_r0.sha1 >= 1) ? Arm_Sha1 : 0;
225 hwcap |= (isa_r0.sha2 >= 1) ? Arm_Sha2 : 0;
226 hwcap |= (isa_r0.sha2 >= 2) ? Arm_Sha512 : 0;
227 hwcap |= (isa_r0.crc32 >= 1) ? Arm_Crc32 : 0;
228 hwcap |= (isa_r0.atomic >= 1) ? Arm_Atomics : 0;
229 hwcap |= (isa_r0.rdm >= 1) ? Arm_Asimdrdm : 0;
230 hwcap |= (isa_r0.sha3 >= 1) ? Arm_Sha3 : 0;
231 hwcap |= (isa_r0.sm3 >= 1) ? Arm_Sm3 : 0;
232 hwcap |= (isa_r0.sm4 >= 1) ? Arm_Sm4 : 0;
233 hwcap |= (isa_r0.dp >= 1) ? Arm_Asimddp : 0;
234 hwcap |= (isa_r0.fhm >= 1) ? Arm_Asimdfhm : 0;
235 hwcap |= (isa_r0.ts >= 1) ? Arm_Flagm : 0;
239 hwcap |= (isa_r1.dpb >= 1) ? Arm_Dcpop : 0;
240 hwcap |= (isa_r1.jscvt >= 1) ? Arm_Jscvt : 0;
241 hwcap |= (isa_r1.fcma >= 1) ? Arm_Fcma : 0;
242 hwcap |= (isa_r1.lrcpc >= 1) ? Arm_Lrcpc : 0;
243 hwcap |= (isa_r1.lrcpc >= 2) ? Arm_Ilrcpc : 0;
247 hwcap |= (mm_fr2.at >= 1) ? Arm_Uscat : 0;
252 template <
class IntType>
256 int intSize =
sizeof(IntType);
275 IntType features = armHwcap<IntType>();
319 int sentry_size = intSize;
321 string platform =
"v71";
322 int platform_size = platform.size() + 1;
325 int aux_random_size = 16;
331 int aux_data_size = filename.size() + 1;
333 int env_data_size = 0;
334 for (
int i = 0;
i <
envp.size(); ++
i) {
335 env_data_size +=
envp[
i].size() + 1;
337 int arg_data_size = 0;
338 for (
int i = 0;
i <
argv.size(); ++
i) {
339 arg_data_size +=
argv[
i].size() + 1;
342 int info_block_size =
343 sentry_size + env_data_size + arg_data_size +
344 aux_data_size + platform_size + aux_random_size;
347 int aux_array_size = intSize * 2 * (auxv.size() + 1);
349 int envp_array_size = intSize * (
envp.size() + 1);
350 int argv_array_size = intSize * (
argv.size() + 1);
352 int argc_size = intSize;
364 int partial_size = frame_size;
365 int aligned_partial_size =
roundUp(partial_size, align);
366 int aux_padding = aligned_partial_size - partial_size;
368 int space_needed = frame_size + aux_padding;
379 IntType sentry_base =
memState->getStackBase() - sentry_size;
380 IntType aux_data_base = sentry_base - aux_data_size;
381 IntType env_data_base = aux_data_base - env_data_size;
382 IntType arg_data_base = env_data_base - arg_data_size;
383 IntType platform_base = arg_data_base - platform_size;
384 IntType aux_random_base = platform_base - aux_random_size;
385 IntType auxv_array_base = aux_random_base - aux_array_size - aux_padding;
386 IntType envp_array_base = auxv_array_base - envp_array_size;
387 IntType argv_array_base = envp_array_base - argv_array_size;
388 IntType argc_base = argv_array_base - argc_size;
390 DPRINTF(Stack,
"The addresses of items on the initial stack:\n");
391 DPRINTF(Stack,
"0x%x - aux data\n", aux_data_base);
392 DPRINTF(Stack,
"0x%x - env data\n", env_data_base);
393 DPRINTF(Stack,
"0x%x - arg data\n", arg_data_base);
394 DPRINTF(Stack,
"0x%x - random data\n", aux_random_base);
395 DPRINTF(Stack,
"0x%x - platform base\n", platform_base);
396 DPRINTF(Stack,
"0x%x - auxv array\n", auxv_array_base);
397 DPRINTF(Stack,
"0x%x - envp array\n", envp_array_base);
398 DPRINTF(Stack,
"0x%x - argv array\n", argv_array_base);
399 DPRINTF(Stack,
"0x%x - argc \n", argc_base);
405 IntType argc =
argv.size();
406 IntType guestArgc =
htole(argc);
409 IntType sentry_NULL = 0;
413 for (
int i = auxv.size() - 1;
i >= 0;
i--) {
415 auxv[
i].val = platform_base;
418 auxv[
i].val = aux_data_base;
421 auxv[
i].val = aux_random_base;
427 Addr auxv_array_end = auxv_array_base;
428 for (
const auto &aux: auxv) {
430 auxv_array_end +=
sizeof(aux);
435 auxv_array_end +=
sizeof(zero);
451 if (
argv.size() > 0) {
457 if (
envp.size() > 0) {
466 pc.nextThumb(pc.thumb());
468 pc.nextAArch64(pc.aarch64());
493 assert(width == 32 || width == 64);
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
Addr programHeaderTable()
const std::string & name()
virtual TheISA::PCState pcState() const =0
virtual RegVal readIntReg(RegIndex reg_idx) const =0
std::vector< ContextID > contextIds
void writeString(Addr addr, const char *str) const
Same as tryWriteString, but insists on success.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value) override
void allocateMem(Addr vaddr, int64_t size, bool clobber=false)
SETranslatingPortProxy initVirtMem
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Overload hash function for BasicBlockRange type.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value) override
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
ThreadContext * getThreadContext(ContextID tid) const
uint32_t armHwcapImpl() const override
AArch64 AT_HWCAP.
ArmProcess(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch)
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.
const Params * params() const
void copyStringArray(std::vector< std::string > &strings, AddrType array_ptr, AddrType data_ptr, const ByteOrder bo, PortProxy &memProxy)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
std::vector< std::string > envp
virtual void setCCReg(RegIndex reg_idx, RegVal val)=0
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()
uint32_t armHwcapImpl() const override
AArch32 AT_HWCAP.
Declarations of a non-full system Page Table.
uint16_t programHeaderCount()
ArmProcess64(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch)
GenericISA::SimplePCState< MachInst > PCState
RegVal getSyscallArg(ThreadContext *tc, int &i, int width) override
void argsInit(int pageSize, ArmISA::IntRegIndex spIndex)
ArmProcess32(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch)
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, int width) override
virtual RegVal readMiscReg(RegIndex misc_reg)=0