void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
{
ARMCPU *cpu = env_archcpu(env);
- CPUState *cs = env_cpu(env);
- TaskState *ts = get_task_state(cs);
- struct image_info *info = ts->info;
int i;
if (!(arm_feature(env, ARM_FEATURE_AARCH64))) {
if (cpu_isar_feature(aa64_pauth, cpu)) {
qemu_guest_getrandom_nofail(&env->keys, sizeof(env->keys));
}
-
- ts->heap_base = info->brk;
- /* This will be filled in on the first SYS_HEAPINFO call. */
- ts->heap_limit = 0;
}
for(i = 0; i < 16; i++) {
env->regs[i] = regs->uregs[i];
}
-#if TARGET_BIG_ENDIAN
- /* Enable BE8. */
- if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4
- && (info->elf_flags & EF_ARM_BE8)) {
- env->uncached_cpsr |= CPSR_E;
- env->cp15.sctlr_el[1] |= SCTLR_E0E;
- } else {
- env->cp15.sctlr_el[1] |= SCTLR_B;
- }
- arm_rebuild_hflags(env);
-#endif
- ts->heap_base = info->brk;
- /* This will be filled in on the first SYS_HEAPINFO call. */
- ts->heap_limit = 0;
+ if (TARGET_BIG_ENDIAN) {
+ /* Enable BE8. */
+ if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4
+ && (info->elf_flags & EF_ARM_BE8)) {
+ env->uncached_cpsr |= CPSR_E;
+ env->cp15.sctlr_el[1] |= SCTLR_E0E;
+ } else {
+ env->cp15.sctlr_el[1] |= SCTLR_B;
+ }
+ arm_rebuild_hflags(env);
+ }
}
void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
{
- CPUState *cpu = env_cpu(env);
- TaskState *ts = get_task_state(cpu);
- struct image_info *info = ts->info;
-
env->pc = regs->pc;
env->dregs[0] = regs->d0;
env->dregs[1] = regs->d1;
env->aregs[6] = regs->a6;
env->aregs[7] = regs->usp;
env->sr = regs->sr;
-
- ts->heap_base = info->brk;
- /* This will be filled in on the first SYS_HEAPINFO call. */
- ts->heap_limit = 0;
}
abi_ulong child_tidptr;
#ifdef TARGET_M68K
abi_ulong tp_value;
-#endif
-#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_RISCV)
- /* Extra fields for semihosted binaries. */
- abi_ulong heap_base;
- abi_ulong heap_limit;
#endif
int used; /* non zero if used */
struct image_info *info;
error_report("Incompatible ELF: RVE cpu requires RVE ABI binary");
exit(EXIT_FAILURE);
}
-
- ts->heap_base = info->brk;
- /* This will be filled in on the first SYS_HEAPINFO call. */
- ts->heap_limit = 0;
}
int i;
#ifdef CONFIG_USER_ONLY
TaskState *ts = get_task_state(cs);
- target_ulong limit;
+ static abi_ulong heapbase, heaplimit;
#else
LayoutInfo info = common_semi_find_bases(cs);
#endif
* Some C libraries assume the heap immediately follows .bss, so
* allocate it using sbrk.
*/
- if (!ts->heap_limit) {
- abi_ulong ret;
-
- ts->heap_base = do_brk(0);
- limit = ts->heap_base + COMMON_SEMI_HEAP_SIZE;
+ if (!heaplimit) {
+ heapbase = do_brk(0);
/* Try a big heap, and reduce the size if that fails. */
- for (;;) {
- ret = do_brk(limit);
+ for (abi_ulong size = COMMON_SEMI_HEAP_SIZE; ; size >>= 1) {
+ abi_ulong limit = heapbase + size;
+ abi_ulong ret = do_brk(limit);
if (ret >= limit) {
+ heaplimit = limit;
break;
}
- limit = (ts->heap_base >> 1) + (limit >> 1);
}
- ts->heap_limit = limit;
}
-
- retvals[0] = ts->heap_base;
- retvals[1] = ts->heap_limit;
+ retvals[0] = heapbase;
+ retvals[1] = heaplimit;
/*
* Note that semihosting is *not* thread aware.
* Always return the stack base of the main thread.