qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 41/43] bsd-user: Implement cpu_copy() helper routine


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 41/43] bsd-user: Implement cpu_copy() helper routine
Date: Fri, 27 Aug 2021 06:47:12 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 8/26/21 11:11 PM, imp@bsdimp.com wrote:
> From: Warner Losh <imp@FreeBSD.org>
> 
> cpu_copy shouldbe called when processes are creating new threads. It

Typo "should be"

> copies the current state of the CPU to a new cpu state needed for the
> new thread.
> 
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> Signed-off-by: Justin Hibbits <chmeeedalf@gmail.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  bsd-user/main.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/bsd-user/main.c b/bsd-user/main.c
> index e2ed9e32ba..b35bcf4d1e 100644
> --- a/bsd-user/main.c
> +++ b/bsd-user/main.c
> @@ -180,6 +180,36 @@ void init_task_state(TaskState *ts)
>      ts->sigqueue_table[i].next = NULL;
>  }
>  
> +CPUArchState *cpu_copy(CPUArchState *env)
> +{
> +    CPUState *cpu = env_cpu(env);
> +    CPUState *new_cpu = cpu_create(cpu_type);
> +    CPUArchState *new_env = new_cpu->env_ptr;
> +    CPUBreakpoint *bp;
> +    CPUWatchpoint *wp;
> +
> +    /* Reset non arch specific state */
> +    cpu_reset(new_cpu);
> +
> +    memcpy(new_env, env, sizeof(CPUArchState));
> +
> +    /*
> +     * Clone all break/watchpoints.
> +     * Note: Once we support ptrace with hw-debug register access, make sure
> +     * BP_CPU break/watchpoints are handled correctly on clone.
> +     */
> +    QTAILQ_INIT(&cpu->breakpoints);
> +    QTAILQ_INIT(&cpu->watchpoints);
> +    QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
> +        cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);
> +    }
> +    QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
> +        cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL);
> +    }
> +
> +    return new_env;
> +}

But where is it called?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]