mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
linux-user/aarch64: Allocate new gcs stack on clone
Allocate the new stack early, so that error reporting need not clean up other objects. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20251008215613.300150-65-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
committed by
Peter Maydell
parent
d0e16dcad9
commit
f57359b3f0
@@ -6686,6 +6686,21 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
||||
ts = g_new0(TaskState, 1);
|
||||
init_task_state(ts);
|
||||
|
||||
#ifdef TARGET_AARCH64
|
||||
/*
|
||||
* If GCS is enabled in the parent thread, it is also enabled
|
||||
* in the child thread, but with a newly allocated stack.
|
||||
*/
|
||||
abi_long new_gcspr = 0;
|
||||
if (env->cp15.gcscr_el[0] & GCSCR_PCRSEL) {
|
||||
new_gcspr = gcs_new_stack(ts);
|
||||
if (new_gcspr == -1) {
|
||||
g_free(ts);
|
||||
return -TARGET_ENOMEM;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Grab a mutex so that thread setup appears atomic. */
|
||||
pthread_mutex_lock(&clone_lock);
|
||||
|
||||
@@ -6707,6 +6722,11 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
||||
ts->info = parent_ts->info;
|
||||
ts->signal_mask = parent_ts->signal_mask;
|
||||
|
||||
#ifdef TARGET_AARCH64
|
||||
ts->gcs_el0_locked = parent_ts->gcs_el0_locked;
|
||||
new_env->cp15.gcspr_el[0] = new_gcspr;
|
||||
#endif
|
||||
|
||||
if (flags & CLONE_CHILD_CLEARTID) {
|
||||
ts->child_tidptr = child_tidptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user