[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for 6.2 48/49] bsd-user: Implement cpu_copy() helper routine
From: |
Warner Losh |
Subject: |
[PATCH for 6.2 48/49] bsd-user: Implement cpu_copy() helper routine |
Date: |
Sat, 7 Aug 2021 15:42:41 -0600 |
From: Warner Losh <imp@FreeBSD.org>
cpu_copy shouldbe called when processes are creating new threads. It
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>
---
bsd-user/main.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 2b0716d245..1de5dc189b 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -196,6 +196,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;
+}
+
void gemu_log(const char *fmt, ...)
{
va_list ap;
--
2.32.0
- [PATCH for 6.2 40/49] bsd-user: Add target_arch_reg to describe a target's register set, (continued)
- [PATCH for 6.2 40/49] bsd-user: Add target_arch_reg to describe a target's register set, Warner Losh, 2021/08/07
- [PATCH for 6.2 41/49] bsd-user: Add target_os_user.h to capture the user/kernel structures, Warner Losh, 2021/08/07
- [PATCH for 6.2 45/49] bsd-user: Make guest_base an unsigned long, Warner Losh, 2021/08/07
- [PATCH for 6.2 46/49] bsd-user: move qemu_log to later in the file, Warner Losh, 2021/08/07
- [PATCH for 6.2 48/49] bsd-user: Implement cpu_copy() helper routine,
Warner Losh <=
- [PATCH for 6.2 43/49] bsd-user: elfload.c style catch up patch, Warner Losh, 2021/08/07
- [PATCH for 6.2 44/49] bsd-user: Refactor load_elf_sections and is_target_elf_binary, Warner Losh, 2021/08/07
- [PATCH for 6.2 49/49] bsd-user: Add '-0 argv0' option to bsd-user/main.c, Warner Losh, 2021/08/07
- [PATCH for 6.2 47/49] bsd-user: Implement interlock for atomic operations, Warner Losh, 2021/08/07