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.
 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - https://gpgtools.org
 
 iQIzBAABCgAdFiEEIDX4lLAKo898zeG3bBzRKH2wEQAFAmcpkl0ACgkQbBzRKH2w
 EQADmRAAl301TtPNsGmrjq74qHgFWPNHc4SSQlK8oIIBgM2Mco/sva5N8ZsCIo4K
 G6uHRbDn3AXUzi7N72ZRKFxQMDQfthtQDskGvsg3zD96pYXkWF6dB3FwSs0Kg0QW
 ow3jj7qiP8NWlbAnMq4fXdtkLGD7S1Og606BYUvk13ILHLY6kwvSWJv53Cq+lDXg
 IQkHGWckG5Xvn/OY3KoLbw77APBCn/fbH6e2yAnBgS8STzEPf2I8xWEiwP6gMpc/
 /BdWkEmqJn5hM//Nf+Yz0uTVMh7egwP8+NjTqYMzWCU3kV0Gtk1cTvpJX3wyzZvZ
 exLOMjL4C+BClA7EJtBvsRrnvv+8ytxn7F3VCeqFR5nAZiU4L3+WfpSjVe8oYCAw
 DL8LYKQA0Abwt6F8EPHwxPxO7HWAKJ4Wxrwlz66juA8gOyuRp+ueVH11ztds6yeh
 rWEgwdXMBOuBcNCGgkuTOajFTRK8hmQNcf/okwODMa5Gj2ayyNmFTnD/bFPe7CbA
 GzJERU+Xtz1wFg+c5LRqqrOnDqD3wDXDrcOuHRhdRWbAl0rLCdH1CLORXZ3XTuF4
 m9JxmaRiCs++a5XswRrSzxb6BM6hKmKX3baGZUeVW6lKyGyyqvY+uUVKkv4U8KqP
 jLPPHE4dicl0/1QbGHZY52gkLYRFXdKa/xKhc8NHXtaWSFACzmo=
 =8H2C
 -----END PGP SIGNATURE-----

Merge tag 'bsd-user-2024q4-pull-request' of gitlab.com:bsdimp/qemu into staging

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.

# -----BEGIN PGP SIGNATURE-----
# Comment: GPGTools - https://gpgtools.org
#
# iQIzBAABCgAdFiEEIDX4lLAKo898zeG3bBzRKH2wEQAFAmcpkl0ACgkQbBzRKH2w
# EQADmRAAl301TtPNsGmrjq74qHgFWPNHc4SSQlK8oIIBgM2Mco/sva5N8ZsCIo4K
# G6uHRbDn3AXUzi7N72ZRKFxQMDQfthtQDskGvsg3zD96pYXkWF6dB3FwSs0Kg0QW
# ow3jj7qiP8NWlbAnMq4fXdtkLGD7S1Og606BYUvk13ILHLY6kwvSWJv53Cq+lDXg
# IQkHGWckG5Xvn/OY3KoLbw77APBCn/fbH6e2yAnBgS8STzEPf2I8xWEiwP6gMpc/
# /BdWkEmqJn5hM//Nf+Yz0uTVMh7egwP8+NjTqYMzWCU3kV0Gtk1cTvpJX3wyzZvZ
# exLOMjL4C+BClA7EJtBvsRrnvv+8ytxn7F3VCeqFR5nAZiU4L3+WfpSjVe8oYCAw
# DL8LYKQA0Abwt6F8EPHwxPxO7HWAKJ4Wxrwlz66juA8gOyuRp+ueVH11ztds6yeh
# rWEgwdXMBOuBcNCGgkuTOajFTRK8hmQNcf/okwODMa5Gj2ayyNmFTnD/bFPe7CbA
# GzJERU+Xtz1wFg+c5LRqqrOnDqD3wDXDrcOuHRhdRWbAl0rLCdH1CLORXZ3XTuF4
# m9JxmaRiCs++a5XswRrSzxb6BM6hKmKX3baGZUeVW6lKyGyyqvY+uUVKkv4U8KqP
# jLPPHE4dicl0/1QbGHZY52gkLYRFXdKa/xKhc8NHXtaWSFACzmo=
# =8H2C
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 05 Nov 2024 03:34:53 GMT
# gpg:                using RSA key 2035F894B00AA3CF7CCDE1B76C1CD1287DB01100
# gpg: Good signature from "Warner Losh <wlosh@netflix.com>" [unknown]
# gpg:                 aka "Warner Losh <imp@bsdimp.com>" [unknown]
# gpg:                 aka "Warner Losh <imp@freebsd.org>" [unknown]
# gpg:                 aka "Warner Losh <imp@village.org>" [unknown]
# gpg:                 aka "Warner Losh <wlosh@bsdimp.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 2035 F894 B00A A3CF 7CCD  E1B7 6C1C D128 7DB0 1100

* tag 'bsd-user-2024q4-pull-request' of gitlab.com:bsdimp/qemu:
  bsd-user: Set TaskState ts_tid for initial threads
  bsd-user/main: Allow setting tb-size
  bsd-user/x86_64/target_arch_thread.h: Align stack

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2024-11-06 15:00:37 +00:00
commit f7bc08e935
2 changed files with 11 additions and 1 deletions

View File

@ -60,6 +60,7 @@ uintptr_t qemu_host_page_size;
intptr_t qemu_host_page_mask; intptr_t qemu_host_page_mask;
static bool opt_one_insn_per_tb; static bool opt_one_insn_per_tb;
static unsigned long opt_tb_size;
uintptr_t guest_base; uintptr_t guest_base;
bool have_guest_base; bool have_guest_base;
/* /*
@ -169,6 +170,7 @@ static void usage(void)
" (use '-d help' for a list of log items)\n" " (use '-d help' for a list of log items)\n"
"-D logfile write logs to 'logfile' (default stderr)\n" "-D logfile write logs to 'logfile' (default stderr)\n"
"-one-insn-per-tb run with one guest instruction per emulated TB\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" "-strace log system calls\n"
"-trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n" "-trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
" specify tracing options\n" " specify tracing options\n"
@ -387,6 +389,11 @@ int main(int argc, char **argv)
seed_optarg = optarg; seed_optarg = optarg;
} else if (!strcmp(r, "one-insn-per-tb")) { } else if (!strcmp(r, "one-insn-per-tb")) {
opt_one_insn_per_tb = true; 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")) { } else if (!strcmp(r, "strace")) {
do_strace = 1; do_strace = 1;
} else if (!strcmp(r, "trace")) { } else if (!strcmp(r, "trace")) {
@ -452,6 +459,8 @@ int main(int argc, char **argv)
accel_init_interfaces(ac); accel_init_interfaces(ac);
object_property_set_bool(OBJECT(accel), "one-insn-per-tb", object_property_set_bool(OBJECT(accel), "one-insn-per-tb",
opt_one_insn_per_tb, &error_abort); opt_one_insn_per_tb, &error_abort);
object_property_set_int(OBJECT(accel), "tb-size",
opt_tb_size, &error_abort);
ac->init_machine(NULL); ac->init_machine(NULL);
} }
@ -601,6 +610,7 @@ int main(int argc, char **argv)
init_task_state(ts); init_task_state(ts);
ts->info = info; ts->info = info;
ts->bprm = &bprm; ts->bprm = &bprm;
ts->ts_tid = qemu_get_thread_id();
cpu->opaque = ts; cpu->opaque = ts;
target_set_brk(info->brk); target_set_brk(info->brk);

View File

@ -31,7 +31,7 @@ static inline void target_thread_init(struct target_pt_regs *regs,
struct image_info *infop) struct image_info *infop)
{ {
regs->rax = 0; regs->rax = 0;
regs->rsp = infop->start_stack; regs->rsp = ((infop->start_stack - 8) & ~0xfUL) + 8;
regs->rip = infop->entry; regs->rip = infop->entry;
regs->rdi = infop->start_stack; regs->rdi = infop->start_stack;
} }