[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/17] bsd-user: Implement cpu_copy()
|
From: |
Warner Losh |
|
Subject: |
[PATCH 04/17] bsd-user: Implement cpu_copy() |
|
Date: |
Fri, 2 Aug 2024 17:56:04 -0600 |
From: Stacey Son <sson@FreeBSD.org>
Catch up with 30ba0ee52d15 and implement cpu_copy(). It's needed for
threading. Stacey's original code, with bug fixes from Jessica, Justin
and myself.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
Signed-off-by: Justin Hibbits <chmeeedalf@gmail.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/main.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 1533fd51168..9ad31bd1efe 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -224,6 +224,37 @@ void init_task_state(TaskState *ts)
};
}
+CPUArchState *cpu_copy(CPUArchState *env)
+{
+ CPUState *cpu = env_cpu(env);
+ CPUState *new_cpu = cpu_create(cpu_type);
+ CPUArchState *new_env = cpu_env(new_cpu);
+ CPUBreakpoint *bp;
+ CPUWatchpoint *wp;
+
+ /* Reset non arch specific state */
+ cpu_reset(new_cpu);
+
+ new_cpu->tcg_cflags = cpu->tcg_cflags;
+ 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;
+}
+
void gemu_log(const char *fmt, ...)
{
va_list ap;
--
2.45.1
- [PATCH 00/17] For 9.2: A bunch of cleanups and work towards variable pagesize support, Warner Losh, 2024/08/02
- [PATCH 01/17] bsd-user: Delete TaskState next member, Warner Losh, 2024/08/02
- [PATCH 02/17] bsd-user: Make init_task_state global, Warner Losh, 2024/08/02
- [PATCH 04/17] bsd-user: Implement cpu_copy(),
Warner Losh <=
- [PATCH 05/17] bsd-user: Eliminate unused regs arg in load_elf_binary, Warner Losh, 2024/08/02
- [PATCH 12/17] bsd-user: Use guest_range_valid_untagged to validate range, Warner Losh, 2024/08/02
- [PATCH 03/17] bsd-user: Make cpu_model and cpu_type file scope, Warner Losh, 2024/08/02
- [PATCH 07/17] bsd-user: Remove deprecated -p argument, Warner Losh, 2024/08/02
- [PATCH 08/17] bsd-user: Eliminate unused qemu_uname_release, Warner Losh, 2024/08/02