* [PULL 1/3] bsd-user/x86_64/target_arch_thread.h: Align stack
2024-11-05 3:40 [PULL 0/3] Bsd user 2024q4 patches Warner Losh
@ 2024-11-05 3:40 ` Warner Losh
2024-11-05 3:40 ` [PULL 2/3] bsd-user/main: Allow setting tb-size Warner Losh
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Warner Losh @ 2024-11-05 3:40 UTC (permalink / raw)
To: qemu-devel
Cc: Warner Losh, Jessica Clarke, Kyle Evans, Ilya Leoshkevich,
Richard Henderson
From: Ilya Leoshkevich <iii@linux.ibm.com>
bsd-user qemu-x86_64 almost immediately dies with:
qemu: 0x4002201a68: unhandled CPU exception 0xd - aborting
on FreeBSD 14.1-RELEASE. This is an instruction that requires
alignment:
(gdb) x/i 0x4002201a68
0x4002201a68: movaps %xmm0,-0x40(%rbp)
and the argument is not aligned:
(gdb) p/x env->regs[5]
$1 = 0x822443b58
A quick experiment shows that the userspace entry point expects
misaligned rsp:
(gdb) starti
(gdb) p/x $rsp
$1 = 0x7fffffffeaa8
Emulate this behavior in bsd-user.
[[ applied Richard's suggestion ]]
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/x86_64/target_arch_thread.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bsd-user/x86_64/target_arch_thread.h b/bsd-user/x86_64/target_arch_thread.h
index 52c28906d6d..7739bb2154b 100644
--- a/bsd-user/x86_64/target_arch_thread.h
+++ b/bsd-user/x86_64/target_arch_thread.h
@@ -31,7 +31,7 @@ static inline void target_thread_init(struct target_pt_regs *regs,
struct image_info *infop)
{
regs->rax = 0;
- regs->rsp = infop->start_stack;
+ regs->rsp = ((infop->start_stack - 8) & ~0xfUL) + 8;
regs->rip = infop->entry;
regs->rdi = infop->start_stack;
}
--
2.46.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PULL 2/3] bsd-user/main: Allow setting tb-size
2024-11-05 3:40 [PULL 0/3] Bsd user 2024q4 patches Warner Losh
2024-11-05 3:40 ` [PULL 1/3] bsd-user/x86_64/target_arch_thread.h: Align stack Warner Losh
@ 2024-11-05 3:40 ` Warner Losh
2024-11-05 3:40 ` [PULL 3/3] bsd-user: Set TaskState ts_tid for initial threads Warner Losh
2024-11-06 17:27 ` [PULL 0/3] Bsd user 2024q4 patches Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Warner Losh @ 2024-11-05 3:40 UTC (permalink / raw)
To: qemu-devel
Cc: Warner Losh, Jessica Clarke, Kyle Evans, Ilya Leoshkevich,
Philippe Mathieu-Daudé
From: Ilya Leoshkevich <iii@linux.ibm.com>
While qemu-system can set tb-size using -accel tcg,tb-size=n, there
is no similar knob for qemu-bsd-user. Add one in a way similar to how
one-insn-per-tb is already handled.
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/main.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index cc980e6f401..7c230b0c7a5 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -60,6 +60,7 @@ uintptr_t qemu_host_page_size;
intptr_t qemu_host_page_mask;
static bool opt_one_insn_per_tb;
+static unsigned long opt_tb_size;
uintptr_t guest_base;
bool have_guest_base;
/*
@@ -169,6 +170,7 @@ static void usage(void)
" (use '-d help' for a list of log items)\n"
"-D logfile write logs to 'logfile' (default stderr)\n"
"-one-insn-per-tb run with one guest instruction per emulated TB\n"
+ "-tb-size size TCG translation block cache size\n"
"-strace log system calls\n"
"-trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
" specify tracing options\n"
@@ -387,6 +389,11 @@ int main(int argc, char **argv)
seed_optarg = optarg;
} else if (!strcmp(r, "one-insn-per-tb")) {
opt_one_insn_per_tb = true;
+ } else if (!strcmp(r, "tb-size")) {
+ r = argv[optind++];
+ if (qemu_strtoul(r, NULL, 0, &opt_tb_size)) {
+ usage();
+ }
} else if (!strcmp(r, "strace")) {
do_strace = 1;
} else if (!strcmp(r, "trace")) {
@@ -452,6 +459,8 @@ int main(int argc, char **argv)
accel_init_interfaces(ac);
object_property_set_bool(OBJECT(accel), "one-insn-per-tb",
opt_one_insn_per_tb, &error_abort);
+ object_property_set_int(OBJECT(accel), "tb-size",
+ opt_tb_size, &error_abort);
ac->init_machine(NULL);
}
--
2.46.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PULL 3/3] bsd-user: Set TaskState ts_tid for initial threads
2024-11-05 3:40 [PULL 0/3] Bsd user 2024q4 patches Warner Losh
2024-11-05 3:40 ` [PULL 1/3] bsd-user/x86_64/target_arch_thread.h: Align stack Warner Losh
2024-11-05 3:40 ` [PULL 2/3] bsd-user/main: Allow setting tb-size Warner Losh
@ 2024-11-05 3:40 ` Warner Losh
2024-11-06 17:27 ` [PULL 0/3] Bsd user 2024q4 patches Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Warner Losh @ 2024-11-05 3:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Warner Losh, Jessica Clarke, Kyle Evans
From: Jessica Clarke <jrtc27@jrtc27.com>
Currently we only set it on fork.
Note: Upstream (blitz) commit also did new threads, but that code isn't
in qemu project repo yet.
Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
Pull-Request: https://github.com/qemu-bsd-user/qemu-bsd-user/pull/52
Reviewed-by: Warner Losh <imp@bsdimp.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 7c230b0c7a5..61ca73c4781 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -610,6 +610,7 @@ int main(int argc, char **argv)
init_task_state(ts);
ts->info = info;
ts->bprm = &bprm;
+ ts->ts_tid = qemu_get_thread_id();
cpu->opaque = ts;
target_set_brk(info->brk);
--
2.46.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PULL 0/3] Bsd user 2024q4 patches
2024-11-05 3:40 [PULL 0/3] Bsd user 2024q4 patches Warner Losh
` (2 preceding siblings ...)
2024-11-05 3:40 ` [PULL 3/3] bsd-user: Set TaskState ts_tid for initial threads Warner Losh
@ 2024-11-06 17:27 ` Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2024-11-06 17:27 UTC (permalink / raw)
To: Warner Losh; +Cc: qemu-devel, Jessica Clarke, Kyle Evans
On Tue, 5 Nov 2024 at 03:43, Warner Losh <imp@bsdimp.com> wrote:
>
> The following changes since commit daaf51001a13da007d7dde72e1ed3b06bc490791:
>
> Merge tag 'seabios-hppa-v17-pull-request' of https://github.com/hdeller/qemu-hppa into staging (2024-11-04 16:01:23 +0000)
>
> are available in the Git repository at:
>
> git@gitlab.com:bsdimp/qemu.git tags/bsd-user-2024q4-pull-request
>
> for you to fetch changes up to 52a523af71448f62e8523ed002447c95170381e9:
>
> bsd-user: Set TaskState ts_tid for initial threads (2024-11-04 20:26:40 -0700)
>
> ----------------------------------------------------------------
> bsd-user: Minor fixes
>
> These patches have been in my queue pending too long (I have a bunch of others
> that haven't been reviewd, but those will be done clsoe to the end of the
> release to not get in the way of the release).
>
> The patches align the stack properly on x86_64, implements setting the tb-size
> and properly setting the ts_tid for initial threads. They have all been
> reviewed.
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/9.2
for any user-visible changes.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread