From 388e6af9714e6f299f2c80ffd0b46758cb71284f Mon Sep 17 00:00:00 2001 From: Denis Drakhnia Date: Mon, 15 Jan 2024 17:10:29 +0200 Subject: [PATCH] e2k: set default procedure stack size to page size --- linux-user/e2k/target_syscall.h | 2 +- target/e2k/helper.c | 37 ++++++++++----------------------- target/e2k/helper.h | 3 --- target/e2k/translate.c | 7 ------- 4 files changed, 12 insertions(+), 37 deletions(-) diff --git a/linux-user/e2k/target_syscall.h b/linux-user/e2k/target_syscall.h index dcef8561be..adb247d24e 100644 --- a/linux-user/e2k/target_syscall.h +++ b/linux-user/e2k/target_syscall.h @@ -18,7 +18,7 @@ /* double-NRs */ #define E2K_DEFAULT_PCS_SIZE (TARGET_PAGE_SIZE) -#define E2K_DEFAULT_PS_SIZE (TARGET_PAGE_SIZE * 4) +#define E2K_DEFAULT_PS_SIZE (TARGET_PAGE_SIZE) typedef uint64_t e2k_greg_t; // double word diff --git a/target/e2k/helper.c b/target/e2k/helper.c index f34eb99607..bc69263068 100644 --- a/target/e2k/helper.c +++ b/target/e2k/helper.c @@ -143,18 +143,6 @@ static void crs_read(CPUE2KState *env, target_ulong addr, E2KCrs *crs) crs->cr1.hi = cpu_ldq_le_data(env, addr + offsetof(E2KCrs, cr1.hi)); } -static void pcs_push(CPUE2KState *env, E2KCrs *crs) -{ -#ifndef CONFIG_USER_ONLY - if ((env->pcsp.index + sizeof(E2KCrs) * 2) > env->pcsp.size) { - raise_exception(env, EXCP_CHAIN_STACK_BOUNDS); - } -#endif - - env->pcsp.index += sizeof(E2KCrs); - crs_write(env, env->pcsp.base + env->pcsp.index, crs); -} - static void pcs_pop(CPUE2KState *env, E2KCrs *crs) { crs_read(env, env->pcsp.base + env->pcsp.index, crs); @@ -171,6 +159,10 @@ void e2k_proc_call(CPUE2KState *env, int base, target_ulong ret_ip, { E2KCrs crs; + if ((env->pcsp.size - env->pcsp.index) <= (sizeof(E2KCrs) * 2)) { + raise_exception_ra(env, EXCP_CHAIN_STACK_BOUNDS, GETPC()); + } + crs.cr0_lo = env->pregs; crs.cr0_hi = ret_ip & ~7; crs.cr1.wbs = base / 2; @@ -182,7 +174,9 @@ void e2k_proc_call(CPUE2KState *env, int base, target_ulong ret_ip, crs.cr1.br = env_br_get(env); crs.cr1.ussz = env->usd.size >> 4; - pcs_push(env, &crs); + env->pcsp.index += sizeof(E2KCrs); + crs_write(env, env->pcsp.base + env->pcsp.index, &crs); + callee_window(env, base, env->wd.size, env->wd.fx || force_fx); env->wd.fx = true; @@ -236,19 +230,6 @@ void HELPER(call)(CPUE2KState *env, uint64_t ctpr_raw, int call_wbs, } } -#ifdef CONFIG_USER_ONLY -void HELPER(expand_stacks)(CPUE2KState *env) -{ - if ((env->psp.size - env->psp.index) <= (E2K_REG_LEN * E2K_NR_COUNT * 4)) { - raise_exception_ra(env, EXCP_PROC_STACK_BOUNDS, GETPC()); - } - - if ((env->pcsp.size - env->pcsp.index) <= (sizeof(E2KCrs) * 2)) { - raise_exception_ra(env, EXCP_CHAIN_STACK_BOUNDS, GETPC()); - } -} -#endif /* CONFIG_USER_ONLY */ - uint64_t HELPER(prep_return)(CPUE2KState *env, int ipd) { E2KCtpr ret = { 0 }; @@ -329,6 +310,10 @@ void HELPER(setwd)(CPUE2KState *env, int size, int nfx, int dbl) raise_exception(env, EXCP_ILLEGAL_OPCODE); } + if ((env->psp.size - env->psp.index) <= (E2K_REG_LEN * E2K_NR_COUNT * 4)) { + raise_exception_ra(env, EXCP_PROC_STACK_BOUNDS, GETPC()); + } + env->wd.size = size; env->wd.fx = nfx == 0; env->wdbl = dbl; diff --git a/target/e2k/helper.h b/target/e2k/helper.h index 34ef4b6cdf..2dd6cec3f0 100644 --- a/target/e2k/helper.h +++ b/target/e2k/helper.h @@ -2,9 +2,6 @@ #define vec i128 DEF_HELPER_2(raise_exception, noreturn, env, int) -#ifdef CONFIG_USER_ONLY -DEF_HELPER_1(expand_stacks, void, env) -#endif DEF_HELPER_4(call, void, env, i64, int, tl) DEF_HELPER_2(prep_return, i64, env, int) diff --git a/target/e2k/translate.c b/target/e2k/translate.c index 19f69c0ad7..2478626988 100644 --- a/target/e2k/translate.c +++ b/target/e2k/translate.c @@ -7698,13 +7698,6 @@ static void e2k_tr_translate_insn(DisasContextBase *db, CPUState *cs) default: { pc_next = do_decode(ctx, cs); -#ifdef CONFIG_USER_ONLY - if (ctx->cs1.type == CS1_CALL) { - gen_save_cpu_state(ctx); - gen_helper_expand_stacks(cpu_env); - } -#endif /* CONFIG_USER_ONLY */ - ctx->loop_mode = (ctx->bundle.hs & (1 << 10)) != 0; if (validate_bundle(ctx)) { gen_setwd(ctx);