* [PULL 00/24] maintainer updates (scripts, semihosting, plugins)
@ 2025-09-26 13:17 Alex Bennée
2025-09-26 13:17 ` [PULL 01/24] scripts/ci: add gitlab-failure-analysis script Alex Bennée
` (24 more replies)
0 siblings, 25 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Alex Bennée
The following changes since commit 95b9e0d2ade5d633fd13ffba96a54e87c65baf39:
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2025-09-24 12:04:18 -0700)
are available in the Git repository at:
https://gitlab.com/stsquad/qemu.git tags/pull-10.2-maintainer-260925-1
for you to fetch changes up to 16b10fbf8bdb71ae20c7f74ab19c78d07c013ac7:
contrib/plugins/uftrace: add documentation (2025-09-26 10:07:54 +0100)
----------------------------------------------------------------
September maintainer updates (scripts, semihosting, plugins)
- new gitlab-failure-analysis script
- tweak checkpath to ignore license in removed lines
- refactor semihosting to build once
- add explicit assert to execlog for coverity
- new uftrace plugin
----------------------------------------------------------------
Alex Bennée (1):
scripts/ci: add gitlab-failure-analysis script
Nabih Estefan (1):
checkpatch: Ignore removed lines in license check
Peter Maydell (1):
contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure
Pierrick Bouvier (21):
semihosting/syscalls: compile once in system and per target for user mode
semihosting/syscalls: replace uint64_t with vaddr where appropriate
semihosting/guestfd: compile once for system/user
semihosting/arm-compat-semi: change common_semi_sys_exit_extended
target/riscv/common-semi-target: remove sizeof(target_ulong)
target/{arm, riscv}/common-semi-target: eradicate target_ulong
include/semihosting/common-semi: extract common_semi API
semihosting/arm-compat-semi: eradicate sizeof(target_ulong)
semihosting/arm-compat-semi: replace target_ulong
semihosting/arm-compat-semi: eradicate target_long
semihosting/arm-compat-semi: remove dependency on cpu.h
semihosting/arm-compat-semi: compile once in system and per target for user mode
contrib/plugins/uftrace: skeleton file
contrib/plugins/uftrace: define cpu operations and implement aarch64
contrib/plugins/uftrace: track callstack
contrib/plugins/uftrace: implement tracing
contrib/plugins/uftrace: implement privilege level tracing
contrib/plugins/uftrace: generate additional files for uftrace
contrib/plugins/uftrace: implement x64 support
contrib/plugins/uftrace_symbols.py
contrib/plugins/uftrace: add documentation
docs/about/emulation.rst | 199 +++++
include/semihosting/common-semi.h | 6 +
include/semihosting/guestfd.h | 7 -
include/semihosting/semihost.h | 2 +
include/semihosting/syscalls.h | 30 +-
contrib/plugins/execlog.c | 1 +
contrib/plugins/uftrace.c | 878 +++++++++++++++++++++
semihosting/arm-compat-semi-stub.c | 19 +
semihosting/arm-compat-semi.c | 63 +-
semihosting/guestfd.c | 26 +-
semihosting/syscalls.c | 109 ++-
.../{common-semi-target.h => common-semi-target.c} | 22 +-
.../{common-semi-target.h => common-semi-target.c} | 23 +-
contrib/plugins/meson.build | 3 +-
contrib/plugins/uftrace_symbols.py | 152 ++++
scripts/checkpatch.pl | 3 +-
scripts/ci/gitlab-failure-analysis | 117 +++
semihosting/meson.build | 18 +-
target/arm/meson.build | 4 +
target/riscv/meson.build | 4 +
20 files changed, 1538 insertions(+), 148 deletions(-)
create mode 100644 contrib/plugins/uftrace.c
create mode 100644 semihosting/arm-compat-semi-stub.c
rename target/arm/{common-semi-target.h => common-semi-target.c} (59%)
rename target/riscv/{common-semi-target.h => common-semi-target.c} (53%)
create mode 100755 contrib/plugins/uftrace_symbols.py
create mode 100755 scripts/ci/gitlab-failure-analysis
--
2.47.3
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PULL 01/24] scripts/ci: add gitlab-failure-analysis script
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 02/24] checkpatch: Ignore removed lines in license check Alex Bennée
` (23 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Alex Bennée, Philippe Mathieu-Daudé, Thomas Huth
This is a script designed to collect data from multiple pipelines and
analyse the failure modes they have. By default it will probe the last
3 failed jobs on the staging branch. However this can all be
controlled by the CLI:
./scripts/ci/gitlab-failure-analysis --count 2 --branch=testing/next --id 39915562 --status=
running pipeline 2028486060, total jobs 125, skipped 5, failed 0, 39742 tests, 0 failed tests
success pipeline 2015018135, total jobs 125, skipped 5, failed 0, 49219 tests, 0 failed tests
You can also skip failing jobs and just dump the tests:
./scripts/ci/gitlab-failure-analysis --branch= --id 39915562 --status= --skip-jobs --pipeline 1946202491 1919542960
failed pipeline 1946202491, total jobs 127, skipped 5, failed 26, 38742 tests, 278 skipped tests, 2 failed tests
Failed test qemu.qemu:qtest+qtest-s390x / qtest-s390x/boot-serial-test, check-system-opensuse, 1 /s390x/boot-serial/s390-ccw-virtio - FATAL-ERROR: Failed to find expected string. Please check '/tmp/qtest-boot-serial-sW77EA3'
Failed test qemu.qemu:qtest+qtest-aarch64 / qtest-aarch64/arm-cpu-features, check-system-opensuse, 1 /aarch64/arm/query-cpu-model-expansion - ERROR:../tests/qtest/arm-cpu-features.c:459:test_query_cpu_model_expansion: assertion failed (_error == "The CPU type 'host' requires KVM"): ("The CPU type 'host' requires hardware accelerator" == "The CPU type 'host' requires KVM")
failed pipeline 1919542960, total jobs 127, skipped 5, failed 2, 48753 tests, 441 skipped tests, 1 failed tests
Failed test qemu.qemu:unit / test-aio, msys2-64bit, 12 /aio/timer/schedule - ERROR:../tests/unit/test-aio.c:413:test_timer_schedule: assertion failed: (aio_poll(ctx, true))
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-3-alex.bennee@linaro.org>
diff --git a/scripts/ci/gitlab-failure-analysis b/scripts/ci/gitlab-failure-analysis
new file mode 100755
index 00000000000..906725be973
--- /dev/null
+++ b/scripts/ci/gitlab-failure-analysis
@@ -0,0 +1,117 @@
+#!/usr/bin/env python3
+#
+# A script to analyse failures in the gitlab pipelines. It requires an
+# API key from gitlab with the following permissions:
+# - api
+# - read_repository
+# - read_user
+#
+
+import argparse
+import gitlab
+import os
+
+#
+# Arguments
+#
+class NoneForEmptyStringAction(argparse.Action):
+ def __call__(self, parser, namespace, value, option_string=None):
+ if value == '':
+ setattr(namespace, self.dest, None)
+ else:
+ setattr(namespace, self.dest, value)
+
+
+parser = argparse.ArgumentParser(description="Analyse failed GitLab CI runs.")
+
+parser.add_argument("--gitlab",
+ default="https://gitlab.com",
+ help="GitLab instance URL (default: https://gitlab.com).")
+parser.add_argument("--id", default=11167699,
+ type=int,
+ help="GitLab project id (default: 11167699 for qemu-project/qemu)")
+parser.add_argument("--token",
+ default=os.getenv("GITLAB_TOKEN"),
+ help="Your personal access token with 'api' scope.")
+parser.add_argument("--branch",
+ type=str,
+ default="staging",
+ action=NoneForEmptyStringAction,
+ help="The name of the branch (default: 'staging')")
+parser.add_argument("--status",
+ type=str,
+ action=NoneForEmptyStringAction,
+ default="failed",
+ help="Filter by branch status (default: 'failed')")
+parser.add_argument("--count", type=int,
+ default=3,
+ help="The number of failed runs to fetch.")
+parser.add_argument("--skip-jobs",
+ default=False,
+ action='store_true',
+ help="Skip dumping the job info")
+parser.add_argument("--pipeline", type=int,
+ nargs="+",
+ default=None,
+ help="Explicit pipeline ID(s) to fetch.")
+
+
+if __name__ == "__main__":
+ args = parser.parse_args()
+
+ gl = gitlab.Gitlab(url=args.gitlab, private_token=args.token)
+ project = gl.projects.get(args.id)
+
+
+ pipelines_to_process = []
+
+ # Use explicit pipeline IDs if provided, otherwise fetch a list
+ if args.pipeline:
+ args.count = len(args.pipeline)
+ for p_id in args.pipeline:
+ pipelines_to_process.append(project.pipelines.get(p_id))
+ else:
+ # Use an iterator to fetch the pipelines
+ pipe_iter = project.pipelines.list(iterator=True,
+ status=args.status,
+ ref=args.branch)
+ # Check each failed pipeline
+ pipelines_to_process = [next(pipe_iter) for _ in range(args.count)]
+
+ # Check each pipeline
+ for p in pipelines_to_process:
+
+ jobs = p.jobs.list(get_all=True)
+ failed_jobs = [j for j in jobs if j.status == "failed"]
+ skipped_jobs = [j for j in jobs if j.status == "skipped"]
+ manual_jobs = [j for j in jobs if j.status == "manual"]
+
+ trs = p.test_report_summary.get()
+ total = trs.total["count"]
+ skipped = trs.total["skipped"]
+ failed = trs.total["failed"]
+
+ print(f"{p.status} pipeline {p.id}, total jobs {len(jobs)}, "
+ f"skipped {len(skipped_jobs)}, "
+ f"failed {len(failed_jobs)}, ",
+ f"{total} tests, "
+ f"{skipped} skipped tests, "
+ f"{failed} failed tests")
+
+ if not args.skip_jobs:
+ for j in failed_jobs:
+ print(f" Failed job {j.id}, {j.name}, {j.web_url}")
+
+ # It seems we can only extract failing tests from the full
+ # test report, maybe there is some way to filter it.
+
+ if failed > 0:
+ ftr = p.test_report.get()
+ failed_suites = [s for s in ftr.test_suites if
+ s["failed_count"] > 0]
+ for fs in failed_suites:
+ name = fs["name"]
+ tests = fs["test_cases"]
+ failed_tests = [t for t in tests if t["status"] == 'failed']
+ for t in failed_tests:
+ print(f" Failed test {t["classname"]}, {name}, {t["name"]}")
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 02/24] checkpatch: Ignore removed lines in license check
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
2025-09-26 13:17 ` [PULL 01/24] scripts/ci: add gitlab-failure-analysis script Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 03/24] semihosting/syscalls: compile once in system and per target for user mode Alex Bennée
` (22 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Nabih Estefan, Daniel P. Berrangé, Alex Bennée
From: Nabih Estefan <nabihestefan@google.com>
When running the license check, if we are updating a license it is
possible for the checkpatch script to test against old license lines
instead of newer ones, since the removal lines appear before the
addition lines in a .patch file.
Fix this by skipping over lines that start with "-" in the checkpatch
script.
Signed-off-by: Nabih Estefan <nabihestefan@google.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250916165928.10048-1-nabihestefan@google.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-4-alex.bennee@linaro.org>
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 91616c974f2..40b6955c698 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1816,7 +1816,8 @@ sub process {
}
# Check SPDX-License-Identifier references a permitted license
- if ($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) {
+ if (($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) &&
+ $rawline !~ /^-/) {
$fileinfo->{facts}->{sawspdx} = 1;
&checkspdx($realfile, $1);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 03/24] semihosting/syscalls: compile once in system and per target for user mode
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
2025-09-26 13:17 ` [PULL 01/24] scripts/ci: add gitlab-failure-analysis script Alex Bennée
2025-09-26 13:17 ` [PULL 02/24] checkpatch: Ignore removed lines in license check Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 04/24] semihosting/syscalls: replace uint64_t with vaddr where appropriate Alex Bennée
` (21 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We replace target_ulong mechanically by uint64_t.
We can't compile (easily) this code once for user, as it relies on
various target/function types, so leave it in specific_ss for user mode.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-2-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-5-alex.bennee@linaro.org>
diff --git a/include/semihosting/syscalls.h b/include/semihosting/syscalls.h
index 6627c45fb28..03aa45b7bb9 100644
--- a/include/semihosting/syscalls.h
+++ b/include/semihosting/syscalls.h
@@ -9,7 +9,7 @@
#ifndef SEMIHOSTING_SYSCALLS_H
#define SEMIHOSTING_SYSCALLS_H
-#include "exec/cpu-defs.h"
+#include "exec/vaddr.h"
#include "gdbstub/syscalls.h"
/*
@@ -24,23 +24,23 @@
typedef struct GuestFD GuestFD;
void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
+ vaddr fname, uint64_t fname_len,
int gdb_flags, int mode);
void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cb complete,
int fd);
void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong buf, target_ulong len);
+ int fd, vaddr buf, uint64_t len);
void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len);
+ GuestFD *gf, vaddr buf, uint64_t len);
void semihost_sys_write(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong buf, target_ulong len);
+ int fd, vaddr buf, uint64_t len);
void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len);
+ GuestFD *gf, vaddr buf, uint64_t len);
void semihost_sys_lseek(CPUState *cs, gdb_syscall_complete_cb complete,
int fd, int64_t off, int gdb_whence);
@@ -50,27 +50,27 @@ void semihost_sys_isatty(CPUState *cs, gdb_syscall_complete_cb complete,
void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb,
gdb_syscall_complete_cb flen_cb,
- int fd, target_ulong fstat_addr);
+ int fd, vaddr fstat_addr);
void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong addr);
+ int fd, vaddr addr);
void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
- target_ulong addr);
+ vaddr fname, uint64_t fname_len,
+ vaddr addr);
void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len);
+ vaddr fname, uint64_t fname_len);
void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong oname, target_ulong oname_len,
- target_ulong nname, target_ulong nname_len);
+ vaddr oname, uint64_t oname_len,
+ vaddr nname, uint64_t nname_len);
void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong cmd, target_ulong cmd_len);
+ vaddr cmd, uint64_t cmd_len);
void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong tv_addr, target_ulong tz_addr);
+ vaddr tv_addr, vaddr tz_addr);
void semihost_sys_poll_one(CPUState *cs, gdb_syscall_complete_cb complete,
int fd, GIOCondition cond, int timeout);
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index bcd13cd6dfd..64ddc749bf8 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -34,6 +34,7 @@
#include "qemu/osdep.h"
#include "qemu/timer.h"
#include "exec/gdbstub.h"
+#include "cpu.h"
#include "gdbstub/syscalls.h"
#include "semihosting/semihost.h"
#include "semihosting/console.h"
diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c
index f6451d9bb0e..f072d919193 100644
--- a/semihosting/syscalls.c
+++ b/semihosting/syscalls.c
@@ -8,7 +8,6 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
-#include "cpu.h"
#include "gdbstub/syscalls.h"
#include "semihosting/guestfd.h"
#include "semihosting/syscalls.h"
@@ -23,7 +22,7 @@
/*
* Validate or compute the length of the string (including terminator).
*/
-static int validate_strlen(CPUState *cs, target_ulong str, target_ulong tlen)
+static int validate_strlen(CPUState *cs, uint64_t str, uint64_t tlen)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char c;
@@ -52,7 +51,7 @@ static int validate_strlen(CPUState *cs, target_ulong str, target_ulong tlen)
}
static int validate_lock_user_string(char **pstr, CPUState *cs,
- target_ulong tstr, target_ulong tlen)
+ uint64_t tstr, uint64_t tlen)
{
int ret = validate_strlen(cs, tstr, tlen);
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
@@ -72,7 +71,7 @@ static int validate_lock_user_string(char **pstr, CPUState *cs,
* big-endian. Until we do something with gdb, also produce the
* same big-endian result from the host.
*/
-static int copy_stat_to_user(CPUState *cs, target_ulong addr,
+static int copy_stat_to_user(CPUState *cs, uint64_t addr,
const struct stat *s)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
@@ -129,7 +128,7 @@ static void gdb_open_cb(CPUState *cs, uint64_t ret, int err)
}
static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
+ uint64_t fname, uint64_t fname_len,
int gdb_flags, int mode)
{
int len = validate_strlen(cs, fname, fname_len);
@@ -151,14 +150,14 @@ static void gdb_close(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
gdb_do_syscall(complete, "read,%x,%lx,%lx",
(uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len);
}
static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
gdb_do_syscall(complete, "write,%x,%lx,%lx",
(uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len);
@@ -178,15 +177,15 @@ static void gdb_isatty(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong addr)
+ GuestFD *gf, uint64_t addr)
{
gdb_do_syscall(complete, "fstat,%x,%lx",
(uint32_t)gf->hostfd, (uint64_t)addr);
}
static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
- target_ulong addr)
+ uint64_t fname, uint64_t fname_len,
+ uint64_t addr)
{
int len = validate_strlen(cs, fname, fname_len);
if (len < 0) {
@@ -199,7 +198,7 @@ static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len)
+ uint64_t fname, uint64_t fname_len)
{
int len = validate_strlen(cs, fname, fname_len);
if (len < 0) {
@@ -211,8 +210,8 @@ static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong oname, target_ulong oname_len,
- target_ulong nname, target_ulong nname_len)
+ uint64_t oname, uint64_t oname_len,
+ uint64_t nname, uint64_t nname_len)
{
int olen, nlen;
@@ -233,7 +232,7 @@ static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong cmd, target_ulong cmd_len)
+ uint64_t cmd, uint64_t cmd_len)
{
int len = validate_strlen(cs, cmd, cmd_len);
if (len < 0) {
@@ -245,7 +244,7 @@ static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong tv_addr, target_ulong tz_addr)
+ uint64_t tv_addr, uint64_t tz_addr)
{
gdb_do_syscall(complete, "gettimeofday,%lx,%lx",
(uint64_t)tv_addr, (uint64_t)tz_addr);
@@ -256,7 +255,7 @@ static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
*/
static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
+ uint64_t fname, uint64_t fname_len,
int gdb_flags, int mode)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
@@ -316,7 +315,7 @@ static void host_close(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
void *ptr = lock_user(VERIFY_WRITE, buf, len, 0);
@@ -337,7 +336,7 @@ static void host_read(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
void *ptr = lock_user(VERIFY_READ, buf, len, 1);
@@ -395,7 +394,7 @@ static void host_flen(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong addr)
+ GuestFD *gf, uint64_t addr)
{
struct stat buf;
int ret;
@@ -410,8 +409,8 @@ static void host_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
- target_ulong addr)
+ uint64_t fname, uint64_t fname_len,
+ uint64_t addr)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
struct stat buf;
@@ -440,7 +439,7 @@ static void host_stat(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len)
+ uint64_t fname, uint64_t fname_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *p;
@@ -458,8 +457,8 @@ static void host_remove(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong oname, target_ulong oname_len,
- target_ulong nname, target_ulong nname_len)
+ uint64_t oname, uint64_t oname_len,
+ uint64_t nname, uint64_t nname_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ostr, *nstr;
@@ -484,7 +483,7 @@ static void host_rename(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_system(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong cmd, target_ulong cmd_len)
+ uint64_t cmd, uint64_t cmd_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *p;
@@ -502,7 +501,7 @@ static void host_system(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong tv_addr, target_ulong tz_addr)
+ uint64_t tv_addr, uint64_t tz_addr)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
struct gdb_timeval *p;
@@ -547,10 +546,10 @@ static void host_poll_one(CPUState *cs, gdb_syscall_complete_cb complete,
*/
static void staticfile_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
- target_ulong rest = gf->staticfile.len - gf->staticfile.off;
+ uint64_t rest = gf->staticfile.len - gf->staticfile.off;
void *ptr;
if (len > rest) {
@@ -605,7 +604,7 @@ static void staticfile_flen(CPUState *cs, gdb_syscall_complete_cb complete,
*/
static void console_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ptr;
@@ -622,7 +621,7 @@ static void console_read(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void console_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ptr = lock_user(VERIFY_READ, buf, len, 1);
@@ -638,7 +637,7 @@ static void console_write(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void console_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong addr)
+ GuestFD *gf, uint64_t addr)
{
static const struct stat tty_buf = {
.st_mode = 020666, /* S_IFCHR, ugo+rw */
@@ -683,7 +682,7 @@ static void console_poll_one(CPUState *cs, gdb_syscall_complete_cb complete,
*/
void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
+ vaddr fname, uint64_t fname_len,
int gdb_flags, int mode)
{
if (use_gdb_syscalls()) {
@@ -719,7 +718,7 @@ void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cb complete, int fd)
}
void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
/*
* Bound length for 64-bit guests on 32-bit hosts, not overflowing ssize_t.
@@ -748,7 +747,7 @@ void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete,
}
void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong buf, target_ulong len)
+ int fd, vaddr buf, uint64_t len)
{
GuestFD *gf = get_guestfd(fd);
@@ -760,7 +759,7 @@ void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete,
}
void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
/*
* Bound length for 64-bit guests on 32-bit hosts, not overflowing ssize_t.
@@ -790,7 +789,7 @@ void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete,
}
void semihost_sys_write(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong buf, target_ulong len)
+ int fd, vaddr buf, uint64_t len)
{
GuestFD *gf = get_guestfd(fd);
@@ -856,7 +855,7 @@ void semihost_sys_isatty(CPUState *cs, gdb_syscall_complete_cb complete, int fd)
void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb,
gdb_syscall_complete_cb flen_cb, int fd,
- target_ulong fstat_addr)
+ vaddr fstat_addr)
{
GuestFD *gf = get_guestfd(fd);
@@ -881,7 +880,7 @@ void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb,
}
void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong addr)
+ int fd, vaddr addr)
{
GuestFD *gf = get_guestfd(fd);
@@ -906,8 +905,8 @@ void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
}
void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
- target_ulong addr)
+ vaddr fname, uint64_t fname_len,
+ vaddr addr)
{
if (use_gdb_syscalls()) {
gdb_stat(cs, complete, fname, fname_len, addr);
@@ -917,7 +916,7 @@ void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete,
}
void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len)
+ vaddr fname, uint64_t fname_len)
{
if (use_gdb_syscalls()) {
gdb_remove(cs, complete, fname, fname_len);
@@ -927,8 +926,8 @@ void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete,
}
void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong oname, target_ulong oname_len,
- target_ulong nname, target_ulong nname_len)
+ vaddr oname, uint64_t oname_len,
+ vaddr nname, uint64_t nname_len)
{
if (use_gdb_syscalls()) {
gdb_rename(cs, complete, oname, oname_len, nname, nname_len);
@@ -938,7 +937,7 @@ void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete,
}
void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong cmd, target_ulong cmd_len)
+ vaddr cmd, uint64_t cmd_len)
{
if (use_gdb_syscalls()) {
gdb_system(cs, complete, cmd, cmd_len);
@@ -948,7 +947,7 @@ void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete,
}
void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong tv_addr, target_ulong tz_addr)
+ vaddr tv_addr, vaddr tz_addr)
{
if (use_gdb_syscalls()) {
gdb_gettimeofday(cs, complete, tv_addr, tz_addr);
diff --git a/semihosting/meson.build b/semihosting/meson.build
index b1ab2506c6e..77200a7f27b 100644
--- a/semihosting/meson.build
+++ b/semihosting/meson.build
@@ -1,6 +1,5 @@
specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
'guestfd.c',
- 'syscalls.c',
))
common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c'))
@@ -9,9 +8,12 @@ system_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
'config.c',
'console.c',
'uaccess.c',
+ 'syscalls.c',
), if_false: files(
'stubs-system.c',
))
+specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_USER_ONLY'],
+ if_true: files('syscalls.c'))
specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'],
if_true: files('arm-compat-semi.c'))
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 04/24] semihosting/syscalls: replace uint64_t with vaddr where appropriate
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (2 preceding siblings ...)
2025-09-26 13:17 ` [PULL 03/24] semihosting/syscalls: compile once in system and per target for user mode Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 05/24] semihosting/guestfd: compile once for system/user Alex Bennée
` (20 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-3-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-6-alex.bennee@linaro.org>
diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c
index f072d919193..20f155f869a 100644
--- a/semihosting/syscalls.c
+++ b/semihosting/syscalls.c
@@ -22,7 +22,7 @@
/*
* Validate or compute the length of the string (including terminator).
*/
-static int validate_strlen(CPUState *cs, uint64_t str, uint64_t tlen)
+static int validate_strlen(CPUState *cs, vaddr str, uint64_t tlen)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char c;
@@ -51,7 +51,7 @@ static int validate_strlen(CPUState *cs, uint64_t str, uint64_t tlen)
}
static int validate_lock_user_string(char **pstr, CPUState *cs,
- uint64_t tstr, uint64_t tlen)
+ vaddr tstr, uint64_t tlen)
{
int ret = validate_strlen(cs, tstr, tlen);
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
@@ -71,7 +71,7 @@ static int validate_lock_user_string(char **pstr, CPUState *cs,
* big-endian. Until we do something with gdb, also produce the
* same big-endian result from the host.
*/
-static int copy_stat_to_user(CPUState *cs, uint64_t addr,
+static int copy_stat_to_user(CPUState *cs, vaddr addr,
const struct stat *s)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
@@ -128,7 +128,7 @@ static void gdb_open_cb(CPUState *cs, uint64_t ret, int err)
}
static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t fname, uint64_t fname_len,
+ vaddr fname, uint64_t fname_len,
int gdb_flags, int mode)
{
int len = validate_strlen(cs, fname, fname_len);
@@ -139,7 +139,7 @@ static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete,
gdb_open_complete = complete;
gdb_do_syscall(gdb_open_cb, "open,%s,%x,%x",
- (uint64_t)fname, (uint32_t)len,
+ (vaddr)fname, (uint32_t)len,
(uint32_t)gdb_flags, (uint32_t)mode);
}
@@ -150,17 +150,17 @@ static void gdb_close(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t buf, uint64_t len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
gdb_do_syscall(complete, "read,%x,%lx,%lx",
- (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len);
+ (uint32_t)gf->hostfd, (vaddr)buf, (uint64_t)len);
}
static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t buf, uint64_t len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
gdb_do_syscall(complete, "write,%x,%lx,%lx",
- (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len);
+ (uint32_t)gf->hostfd, (vaddr)buf, (uint64_t)len);
}
static void gdb_lseek(CPUState *cs, gdb_syscall_complete_cb complete,
@@ -177,15 +177,15 @@ static void gdb_isatty(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t addr)
+ GuestFD *gf, vaddr addr)
{
gdb_do_syscall(complete, "fstat,%x,%lx",
- (uint32_t)gf->hostfd, (uint64_t)addr);
+ (uint32_t)gf->hostfd, (vaddr)addr);
}
static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t fname, uint64_t fname_len,
- uint64_t addr)
+ vaddr fname, uint64_t fname_len,
+ vaddr addr)
{
int len = validate_strlen(cs, fname, fname_len);
if (len < 0) {
@@ -194,11 +194,11 @@ static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete,
}
gdb_do_syscall(complete, "stat,%s,%lx",
- (uint64_t)fname, (uint32_t)len, (uint64_t)addr);
+ (vaddr)fname, (uint32_t)len, (vaddr)addr);
}
static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t fname, uint64_t fname_len)
+ vaddr fname, uint64_t fname_len)
{
int len = validate_strlen(cs, fname, fname_len);
if (len < 0) {
@@ -206,12 +206,12 @@ static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete,
return;
}
- gdb_do_syscall(complete, "unlink,%s", (uint64_t)fname, (uint32_t)len);
+ gdb_do_syscall(complete, "unlink,%s", (vaddr)fname, (uint32_t)len);
}
static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t oname, uint64_t oname_len,
- uint64_t nname, uint64_t nname_len)
+ vaddr oname, uint64_t oname_len,
+ vaddr nname, uint64_t nname_len)
{
int olen, nlen;
@@ -227,12 +227,12 @@ static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete,
}
gdb_do_syscall(complete, "rename,%s,%s",
- (uint64_t)oname, (uint32_t)olen,
- (uint64_t)nname, (uint32_t)nlen);
+ (vaddr)oname, (uint32_t)olen,
+ (vaddr)nname, (uint32_t)nlen);
}
static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t cmd, uint64_t cmd_len)
+ vaddr cmd, uint64_t cmd_len)
{
int len = validate_strlen(cs, cmd, cmd_len);
if (len < 0) {
@@ -240,14 +240,14 @@ static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete,
return;
}
- gdb_do_syscall(complete, "system,%s", (uint64_t)cmd, (uint32_t)len);
+ gdb_do_syscall(complete, "system,%s", (vaddr)cmd, (uint32_t)len);
}
static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t tv_addr, uint64_t tz_addr)
+ vaddr tv_addr, vaddr tz_addr)
{
gdb_do_syscall(complete, "gettimeofday,%lx,%lx",
- (uint64_t)tv_addr, (uint64_t)tz_addr);
+ (vaddr)tv_addr, (vaddr)tz_addr);
}
/*
@@ -255,7 +255,7 @@ static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
*/
static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t fname, uint64_t fname_len,
+ vaddr fname, uint64_t fname_len,
int gdb_flags, int mode)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
@@ -315,7 +315,7 @@ static void host_close(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t buf, uint64_t len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
void *ptr = lock_user(VERIFY_WRITE, buf, len, 0);
@@ -336,7 +336,7 @@ static void host_read(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t buf, uint64_t len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
void *ptr = lock_user(VERIFY_READ, buf, len, 1);
@@ -394,7 +394,7 @@ static void host_flen(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t addr)
+ GuestFD *gf, vaddr addr)
{
struct stat buf;
int ret;
@@ -409,8 +409,8 @@ static void host_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t fname, uint64_t fname_len,
- uint64_t addr)
+ vaddr fname, uint64_t fname_len,
+ vaddr addr)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
struct stat buf;
@@ -439,7 +439,7 @@ static void host_stat(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t fname, uint64_t fname_len)
+ vaddr fname, uint64_t fname_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *p;
@@ -457,8 +457,8 @@ static void host_remove(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t oname, uint64_t oname_len,
- uint64_t nname, uint64_t nname_len)
+ vaddr oname, uint64_t oname_len,
+ vaddr nname, uint64_t nname_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ostr, *nstr;
@@ -483,7 +483,7 @@ static void host_rename(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_system(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t cmd, uint64_t cmd_len)
+ vaddr cmd, uint64_t cmd_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *p;
@@ -501,7 +501,7 @@ static void host_system(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void host_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- uint64_t tv_addr, uint64_t tz_addr)
+ vaddr tv_addr, vaddr tz_addr)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
struct gdb_timeval *p;
@@ -546,7 +546,7 @@ static void host_poll_one(CPUState *cs, gdb_syscall_complete_cb complete,
*/
static void staticfile_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t buf, uint64_t len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
uint64_t rest = gf->staticfile.len - gf->staticfile.off;
@@ -604,7 +604,7 @@ static void staticfile_flen(CPUState *cs, gdb_syscall_complete_cb complete,
*/
static void console_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t buf, uint64_t len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ptr;
@@ -621,7 +621,7 @@ static void console_read(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void console_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t buf, uint64_t len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ptr = lock_user(VERIFY_READ, buf, len, 1);
@@ -637,7 +637,7 @@ static void console_write(CPUState *cs, gdb_syscall_complete_cb complete,
}
static void console_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, uint64_t addr)
+ GuestFD *gf, vaddr addr)
{
static const struct stat tty_buf = {
.st_mode = 020666, /* S_IFCHR, ugo+rw */
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 05/24] semihosting/guestfd: compile once for system/user
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (3 preceding siblings ...)
2025-09-26 13:17 ` [PULL 04/24] semihosting/syscalls: replace uint64_t with vaddr where appropriate Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 06/24] semihosting/arm-compat-semi: change common_semi_sys_exit_extended Alex Bennée
` (19 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We move relevant code to semihosting/arm-compat-semi.c, and add
functions to query CONFIG_ARM_COMPATIBLE_SEMIHOSTING at runtime.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-4-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-7-alex.bennee@linaro.org>
diff --git a/include/semihosting/guestfd.h b/include/semihosting/guestfd.h
index 3d426fedab3..a7ea1041ea0 100644
--- a/include/semihosting/guestfd.h
+++ b/include/semihosting/guestfd.h
@@ -35,13 +35,6 @@ typedef struct GuestFD {
};
} GuestFD;
-/*
- * For ARM semihosting, we have a separate structure for routing
- * data for the console which is outside the guest fd address space.
- */
-extern GuestFD console_in_gf;
-extern GuestFD console_out_gf;
-
/**
* alloc_guestfd:
*
diff --git a/include/semihosting/semihost.h b/include/semihosting/semihost.h
index b03e6375787..231dc890395 100644
--- a/include/semihosting/semihost.h
+++ b/include/semihosting/semihost.h
@@ -33,6 +33,8 @@ typedef enum SemihostingTarget {
* Return true if guest code is allowed to make semihosting calls.
*/
bool semihosting_enabled(bool is_user);
+bool semihosting_arm_compatible(void);
+void semihosting_arm_compatible_init(void);
SemihostingTarget semihosting_get_target(void);
const char *semihosting_get_arg(int i);
diff --git a/semihosting/arm-compat-semi-stub.c b/semihosting/arm-compat-semi-stub.c
new file mode 100644
index 00000000000..bfa3681e267
--- /dev/null
+++ b/semihosting/arm-compat-semi-stub.c
@@ -0,0 +1,19 @@
+/*
+ * Stubs for platforms different from ARM
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "semihosting/semihost.h"
+#include <glib.h>
+
+bool semihosting_arm_compatible(void)
+{
+ return false;
+}
+
+void semihosting_arm_compatible_init(void)
+{
+ g_assert_not_reached();
+}
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 64ddc749bf8..a239cfc5a9d 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -101,6 +101,13 @@ static int gdb_open_modeflags[12] = {
GDB_O_RDWR | GDB_O_CREAT | GDB_O_APPEND,
};
+/*
+ * For ARM semihosting, we have a separate structure for routing
+ * data for the console which is outside the guest fd address space.
+ */
+static GuestFD console_in_gf;
+static GuestFD console_out_gf;
+
#ifndef CONFIG_USER_ONLY
/**
@@ -353,6 +360,25 @@ static const uint8_t featurefile_data[] = {
SH_EXT_EXIT_EXTENDED | SH_EXT_STDOUT_STDERR, /* Feature byte 0 */
};
+bool semihosting_arm_compatible(void)
+{
+ return true;
+}
+
+void semihosting_arm_compatible_init(void)
+{
+ /* For ARM-compat, the console is in a separate namespace. */
+ if (use_gdb_syscalls()) {
+ console_in_gf.type = GuestFDGDB;
+ console_in_gf.hostfd = 0;
+ console_out_gf.type = GuestFDGDB;
+ console_out_gf.hostfd = 2;
+ } else {
+ console_in_gf.type = GuestFDConsole;
+ console_out_gf.type = GuestFDConsole;
+ }
+}
+
/*
* Do a semihosting call.
*
diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c
index d3241434c51..e8f236c690c 100644
--- a/semihosting/guestfd.c
+++ b/semihosting/guestfd.c
@@ -12,35 +12,20 @@
#include "gdbstub/syscalls.h"
#include "semihosting/semihost.h"
#include "semihosting/guestfd.h"
-#ifndef CONFIG_USER_ONLY
-#include CONFIG_DEVICES
-#endif
static GArray *guestfd_array;
-#ifdef CONFIG_ARM_COMPATIBLE_SEMIHOSTING
-GuestFD console_in_gf;
-GuestFD console_out_gf;
-#endif
-
void qemu_semihosting_guestfd_init(void)
{
/* New entries zero-initialized, i.e. type GuestFDUnused */
guestfd_array = g_array_new(FALSE, TRUE, sizeof(GuestFD));
-#ifdef CONFIG_ARM_COMPATIBLE_SEMIHOSTING
- /* For ARM-compat, the console is in a separate namespace. */
- if (use_gdb_syscalls()) {
- console_in_gf.type = GuestFDGDB;
- console_in_gf.hostfd = 0;
- console_out_gf.type = GuestFDGDB;
- console_out_gf.hostfd = 2;
- } else {
- console_in_gf.type = GuestFDConsole;
- console_out_gf.type = GuestFDConsole;
+ if (semihosting_arm_compatible()) {
+ semihosting_arm_compatible_init();
+ return;
}
-#else
- /* Otherwise, the stdio file descriptors apply. */
+
+ /* Out of ARM, the stdio file descriptors apply. */
guestfd_array = g_array_set_size(guestfd_array, 3);
#ifndef CONFIG_USER_ONLY
if (!use_gdb_syscalls()) {
@@ -54,7 +39,6 @@ void qemu_semihosting_guestfd_init(void)
associate_guestfd(0, 0);
associate_guestfd(1, 1);
associate_guestfd(2, 2);
-#endif
}
/*
diff --git a/semihosting/meson.build b/semihosting/meson.build
index 77200a7f27b..bb0db323937 100644
--- a/semihosting/meson.build
+++ b/semihosting/meson.build
@@ -1,17 +1,18 @@
-specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
- 'guestfd.c',
-))
-
common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c'))
-user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('user.c'))
+user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
+ 'user.c',
+ 'guestfd.c'))
system_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
'config.c',
'console.c',
+ 'guestfd.c',
'uaccess.c',
'syscalls.c',
), if_false: files(
'stubs-system.c',
))
+system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
+ if_false: files('arm-compat-semi-stub.c'))
specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_USER_ONLY'],
if_true: files('syscalls.c'))
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 06/24] semihosting/arm-compat-semi: change common_semi_sys_exit_extended
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (4 preceding siblings ...)
2025-09-26 13:17 ` [PULL 05/24] semihosting/guestfd: compile once for system/user Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 07/24] target/riscv/common-semi-target: remove sizeof(target_ulong) Alex Bennée
` (18 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée,
Peter Maydell, Palmer Dabbelt, Alistair Francis, Weiwei Li,
Daniel Henrique Barboza, Liu Zhiwei, open list:ARM TCG CPUs,
open list:RISC-V TCG CPUs
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We now check only is sys_exit is extended.
This allows to break dependency to TARGET_SYS_EXIT_EXTENDED which will
not be available anymore from this code.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-5-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-8-alex.bennee@linaro.org>
diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.h
index da51f2d7f54..7bb442f24ca 100644
--- a/target/arm/common-semi-target.h
+++ b/target/arm/common-semi-target.h
@@ -34,9 +34,9 @@ static inline void common_semi_set_ret(CPUState *cs, target_ulong ret)
}
}
-static inline bool common_semi_sys_exit_extended(CPUState *cs, int nr)
+static inline bool common_semi_sys_exit_is_extended(CPUState *cs)
{
- return nr == TARGET_SYS_EXIT_EXTENDED || is_a64(cpu_env(cs));
+ return is_a64(cpu_env(cs));
}
static inline bool is_64bit_semihosting(CPUArchState *env)
diff --git a/target/riscv/common-semi-target.h b/target/riscv/common-semi-target.h
index 7c8a59e0cc3..ba40e794dcc 100644
--- a/target/riscv/common-semi-target.h
+++ b/target/riscv/common-semi-target.h
@@ -25,9 +25,9 @@ static inline void common_semi_set_ret(CPUState *cs, target_ulong ret)
env->gpr[xA0] = ret;
}
-static inline bool common_semi_sys_exit_extended(CPUState *cs, int nr)
+static inline bool common_semi_sys_exit_is_extended(CPUState *cs)
{
- return (nr == TARGET_SYS_EXIT_EXTENDED || sizeof(target_ulong) == 8);
+ return sizeof(target_ulong) == 8;
}
static inline bool is_64bit_semihosting(CPUArchState *env)
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index a239cfc5a9d..26263a06b7a 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -755,7 +755,8 @@ void do_common_semihosting(CPUState *cs)
{
uint32_t ret;
- if (common_semi_sys_exit_extended(cs, nr)) {
+ if (nr == TARGET_SYS_EXIT_EXTENDED ||
+ common_semi_sys_exit_is_extended(cs)) {
/*
* The A64 version of SYS_EXIT takes a parameter block,
* so the application-exit type can return a subcode which
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 07/24] target/riscv/common-semi-target: remove sizeof(target_ulong)
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (5 preceding siblings ...)
2025-09-26 13:17 ` [PULL 06/24] semihosting/arm-compat-semi: change common_semi_sys_exit_extended Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 08/24] target/{arm, riscv}/common-semi-target: eradicate target_ulong Alex Bennée
` (17 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée,
Palmer Dabbelt, Alistair Francis, Weiwei Li,
Daniel Henrique Barboza, Liu Zhiwei, open list:RISC-V TCG CPUs
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Only riscv64 extends SYS_EXIT, similar to aarch64.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-6-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-9-alex.bennee@linaro.org>
diff --git a/target/riscv/common-semi-target.h b/target/riscv/common-semi-target.h
index ba40e794dcc..7e6ea8da02c 100644
--- a/target/riscv/common-semi-target.h
+++ b/target/riscv/common-semi-target.h
@@ -25,14 +25,14 @@ static inline void common_semi_set_ret(CPUState *cs, target_ulong ret)
env->gpr[xA0] = ret;
}
-static inline bool common_semi_sys_exit_is_extended(CPUState *cs)
+static inline bool is_64bit_semihosting(CPUArchState *env)
{
- return sizeof(target_ulong) == 8;
+ return riscv_cpu_mxl(env) != MXL_RV32;
}
-static inline bool is_64bit_semihosting(CPUArchState *env)
+static inline bool common_semi_sys_exit_is_extended(CPUState *cs)
{
- return riscv_cpu_mxl(env) != MXL_RV32;
+ return is_64bit_semihosting(cpu_env(cs));
}
static inline target_ulong common_semi_stack_bottom(CPUState *cs)
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 08/24] target/{arm, riscv}/common-semi-target: eradicate target_ulong
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (6 preceding siblings ...)
2025-09-26 13:17 ` [PULL 07/24] target/riscv/common-semi-target: remove sizeof(target_ulong) Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 09/24] include/semihosting/common-semi: extract common_semi API Alex Bennée
` (16 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée,
Peter Maydell, Palmer Dabbelt, Alistair Francis, Weiwei Li,
Daniel Henrique Barboza, Liu Zhiwei, open list:ARM TCG CPUs,
open list:RISC-V TCG CPUs
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We replace mechanically with uint64_t.
There is no semantic change, and allows us to extract a proper API from
this set of functions.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-7-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-10-alex.bennee@linaro.org>
diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.h
index 7bb442f24ca..6775a270aaa 100644
--- a/target/arm/common-semi-target.h
+++ b/target/arm/common-semi-target.h
@@ -12,7 +12,7 @@
#include "target/arm/cpu-qom.h"
-static inline target_ulong common_semi_arg(CPUState *cs, int argno)
+static inline uint64_t common_semi_arg(CPUState *cs, int argno)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
@@ -23,7 +23,7 @@ static inline target_ulong common_semi_arg(CPUState *cs, int argno)
}
}
-static inline void common_semi_set_ret(CPUState *cs, target_ulong ret)
+static inline void common_semi_set_ret(CPUState *cs, uint64_t ret)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
@@ -44,7 +44,7 @@ static inline bool is_64bit_semihosting(CPUArchState *env)
return is_a64(env);
}
-static inline target_ulong common_semi_stack_bottom(CPUState *cs)
+static inline uint64_t common_semi_stack_bottom(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
diff --git a/target/riscv/common-semi-target.h b/target/riscv/common-semi-target.h
index 7e6ea8da02c..663dedfdad2 100644
--- a/target/riscv/common-semi-target.h
+++ b/target/riscv/common-semi-target.h
@@ -11,14 +11,14 @@
#ifndef TARGET_RISCV_COMMON_SEMI_TARGET_H
#define TARGET_RISCV_COMMON_SEMI_TARGET_H
-static inline target_ulong common_semi_arg(CPUState *cs, int argno)
+static inline uint64_t common_semi_arg(CPUState *cs, int argno)
{
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
return env->gpr[xA0 + argno];
}
-static inline void common_semi_set_ret(CPUState *cs, target_ulong ret)
+static inline void common_semi_set_ret(CPUState *cs, uint64_t ret)
{
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
@@ -35,7 +35,7 @@ static inline bool common_semi_sys_exit_is_extended(CPUState *cs)
return is_64bit_semihosting(cpu_env(cs));
}
-static inline target_ulong common_semi_stack_bottom(CPUState *cs)
+static inline uint64_t common_semi_stack_bottom(CPUState *cs)
{
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 09/24] include/semihosting/common-semi: extract common_semi API
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (7 preceding siblings ...)
2025-09-26 13:17 ` [PULL 08/24] target/{arm, riscv}/common-semi-target: eradicate target_ulong Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 10/24] semihosting/arm-compat-semi: eradicate sizeof(target_ulong) Alex Bennée
` (15 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée,
Peter Maydell, Palmer Dabbelt, Alistair Francis, Weiwei Li,
Daniel Henrique Barboza, Liu Zhiwei, open list:ARM TCG CPUs,
open list:RISC-V TCG CPUs
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We transform target/{arm,riscv}/common-semi-target.h headers to proper
compilation units, and use them in arm-compat-semi.c.
This way, we can include only the declaration header (which is target
agnostic), and selectively link the appropriate implementation based on
current target.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-8-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-11-alex.bennee@linaro.org>
diff --git a/include/semihosting/common-semi.h b/include/semihosting/common-semi.h
index 0a91db7c414..aa511a46f42 100644
--- a/include/semihosting/common-semi.h
+++ b/include/semihosting/common-semi.h
@@ -35,5 +35,11 @@
#define COMMON_SEMI_H
void do_common_semihosting(CPUState *cs);
+uint64_t common_semi_arg(CPUState *cs, int argno);
+void common_semi_set_ret(CPUState *cs, uint64_t ret);
+bool is_64bit_semihosting(CPUArchState *env);
+bool common_semi_sys_exit_is_extended(CPUState *cs);
+uint64_t common_semi_stack_bottom(CPUState *cs);
+bool common_semi_has_synccache(CPUArchState *env);
#endif /* COMMON_SEMI_H */
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 26263a06b7a..604a69e3646 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -174,8 +174,7 @@ static LayoutInfo common_semi_find_bases(CPUState *cs)
#endif
-#include "cpu.h"
-#include "common-semi-target.h"
+#include "semihosting/common-semi.h"
/*
* Read the input value from the argument block; fail the semihosting
diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.c
similarity index 64%
rename from target/arm/common-semi-target.h
rename to target/arm/common-semi-target.c
index 6775a270aaa..2b77ce9c17b 100644
--- a/target/arm/common-semi-target.h
+++ b/target/arm/common-semi-target.c
@@ -7,12 +7,12 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
-#ifndef TARGET_ARM_COMMON_SEMI_TARGET_H
-#define TARGET_ARM_COMMON_SEMI_TARGET_H
-
+#include "qemu/osdep.h"
+#include "cpu.h"
+#include "semihosting/common-semi.h"
#include "target/arm/cpu-qom.h"
-static inline uint64_t common_semi_arg(CPUState *cs, int argno)
+uint64_t common_semi_arg(CPUState *cs, int argno)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
@@ -23,7 +23,7 @@ static inline uint64_t common_semi_arg(CPUState *cs, int argno)
}
}
-static inline void common_semi_set_ret(CPUState *cs, uint64_t ret)
+void common_semi_set_ret(CPUState *cs, uint64_t ret)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
@@ -34,27 +34,25 @@ static inline void common_semi_set_ret(CPUState *cs, uint64_t ret)
}
}
-static inline bool common_semi_sys_exit_is_extended(CPUState *cs)
+bool common_semi_sys_exit_is_extended(CPUState *cs)
{
return is_a64(cpu_env(cs));
}
-static inline bool is_64bit_semihosting(CPUArchState *env)
+bool is_64bit_semihosting(CPUArchState *env)
{
return is_a64(env);
}
-static inline uint64_t common_semi_stack_bottom(CPUState *cs)
+uint64_t common_semi_stack_bottom(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
return is_a64(env) ? env->xregs[31] : env->regs[13];
}
-static inline bool common_semi_has_synccache(CPUArchState *env)
+bool common_semi_has_synccache(CPUArchState *env)
{
/* Ok for A64, invalid for A32/T32 */
return is_a64(env);
}
-
-#endif
diff --git a/target/riscv/common-semi-target.h b/target/riscv/common-semi-target.c
similarity index 59%
rename from target/riscv/common-semi-target.h
rename to target/riscv/common-semi-target.c
index 663dedfdad2..aeaeb88d536 100644
--- a/target/riscv/common-semi-target.h
+++ b/target/riscv/common-semi-target.c
@@ -8,43 +8,42 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
-#ifndef TARGET_RISCV_COMMON_SEMI_TARGET_H
-#define TARGET_RISCV_COMMON_SEMI_TARGET_H
+#include "qemu/osdep.h"
+#include "cpu.h"
+#include "semihosting/common-semi.h"
-static inline uint64_t common_semi_arg(CPUState *cs, int argno)
+uint64_t common_semi_arg(CPUState *cs, int argno)
{
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
return env->gpr[xA0 + argno];
}
-static inline void common_semi_set_ret(CPUState *cs, uint64_t ret)
+void common_semi_set_ret(CPUState *cs, uint64_t ret)
{
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
env->gpr[xA0] = ret;
}
-static inline bool is_64bit_semihosting(CPUArchState *env)
+bool is_64bit_semihosting(CPUArchState *env)
{
return riscv_cpu_mxl(env) != MXL_RV32;
}
-static inline bool common_semi_sys_exit_is_extended(CPUState *cs)
+bool common_semi_sys_exit_is_extended(CPUState *cs)
{
return is_64bit_semihosting(cpu_env(cs));
}
-static inline uint64_t common_semi_stack_bottom(CPUState *cs)
+uint64_t common_semi_stack_bottom(CPUState *cs)
{
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
return env->gpr[xSP];
}
-static inline bool common_semi_has_synccache(CPUArchState *env)
+bool common_semi_has_synccache(CPUArchState *env)
{
return true;
}
-
-#endif
diff --git a/target/arm/meson.build b/target/arm/meson.build
index 914f1498fc5..638ee62525f 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -28,12 +28,16 @@ arm_user_ss.add(files(
'vfp_fpscr.c',
'el2-stubs.c',
))
+arm_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
+ if_true: files('common-semi-target.c'))
arm_common_system_ss.add(files('cpu.c'))
arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files(
'cpu32-stubs.c'))
arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
arm_common_system_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
+arm_common_system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
+ if_true: files('common-semi-target.c'))
arm_common_system_ss.add(files(
'arch_dump.c',
'arm-powerctl.c',
diff --git a/target/riscv/meson.build b/target/riscv/meson.build
index a4bd61e52a9..fdefe88ccdd 100644
--- a/target/riscv/meson.build
+++ b/target/riscv/meson.build
@@ -8,6 +8,10 @@ gen = [
riscv_ss = ss.source_set()
riscv_ss.add(gen)
+
+riscv_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
+ if_true: files('common-semi-target.c'))
+
riscv_ss.add(files(
'cpu.c',
'cpu_helper.c',
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 10/24] semihosting/arm-compat-semi: eradicate sizeof(target_ulong)
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (8 preceding siblings ...)
2025-09-26 13:17 ` [PULL 09/24] include/semihosting/common-semi: extract common_semi API Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 11/24] semihosting/arm-compat-semi: replace target_ulong Alex Bennée
` (14 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Richard Henderson, Philippe Mathieu-Daudé,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
No semantic change.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-9-pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-12-alex.bennee@linaro.org>
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 604a69e3646..6725dcf4ba7 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -786,7 +786,7 @@ void do_common_semihosting(CPUState *cs)
case TARGET_SYS_ELAPSED:
elapsed = get_clock() - clock_start;
- if (sizeof(target_ulong) == 8) {
+ if (is_64bit_semihosting(env)) {
if (SET_ARG(0, elapsed)) {
goto do_fault;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 11/24] semihosting/arm-compat-semi: replace target_ulong
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (9 preceding siblings ...)
2025-09-26 13:17 ` [PULL 10/24] semihosting/arm-compat-semi: eradicate sizeof(target_ulong) Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 12/24] semihosting/arm-compat-semi: eradicate target_long Alex Bennée
` (13 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Replace with vaddr or uint64_t where appropriate.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-10-pierrick.bouvier@linaro.org>
[AJB: tweak commit message]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-13-alex.bennee@linaro.org>
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 6725dcf4ba7..29cdab66f73 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -123,7 +123,7 @@ static GuestFD console_out_gf;
*/
typedef struct LayoutInfo {
- target_ulong rambase;
+ vaddr rambase;
size_t ramsize;
hwaddr heapbase;
hwaddr heaplimit;
@@ -214,7 +214,7 @@ static LayoutInfo common_semi_find_bases(CPUState *cs)
* global, and we assume that the guest takes care of avoiding any races.
*/
#ifndef CONFIG_USER_ONLY
-static target_ulong syscall_err;
+static uint64_t syscall_err;
#include "semihosting/uaccess.h"
#endif
@@ -260,8 +260,8 @@ static void common_semi_rw_cb(CPUState *cs, uint64_t ret, int err)
{
/* Recover the original length from the third argument. */
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
- target_ulong args = common_semi_arg(cs, 1);
- target_ulong arg2;
+ uint64_t args = common_semi_arg(cs, 1);
+ uint64_t arg2;
GET_ARG(2);
if (err) {
@@ -300,9 +300,9 @@ static void common_semi_seek_cb(CPUState *cs, uint64_t ret, int err)
* is defined by GDB's remote protocol and is not target-specific.)
* We put this on the guest's stack just below SP.
*/
-static target_ulong common_semi_flen_buf(CPUState *cs)
+static uint64_t common_semi_flen_buf(CPUState *cs)
{
- target_ulong sp = common_semi_stack_bottom(cs);
+ vaddr sp = common_semi_stack_bottom(cs);
return sp - 64;
}
@@ -389,9 +389,9 @@ void semihosting_arm_compatible_init(void)
void do_common_semihosting(CPUState *cs)
{
CPUArchState *env = cpu_env(cs);
- target_ulong args;
- target_ulong arg0, arg1, arg2, arg3;
- target_ulong ul_ret;
+ uint64_t args;
+ uint64_t arg0, arg1, arg2, arg3;
+ uint64_t ul_ret;
char * s;
int nr;
int64_t elapsed;
@@ -462,7 +462,7 @@ void do_common_semihosting(CPUState *cs)
case TARGET_SYS_WRITEC:
/*
- * FIXME: the byte to be written is in a target_ulong slot,
+ * FIXME: the byte to be written is in a uint64_t slot,
* which means this is wrong for a big-endian guest.
*/
semihost_sys_write_gf(cs, common_semi_dead_cb,
@@ -688,7 +688,7 @@ void do_common_semihosting(CPUState *cs)
case TARGET_SYS_HEAPINFO:
{
- target_ulong retvals[4];
+ uint64_t retvals[4];
int i;
#ifdef CONFIG_USER_ONLY
TaskState *ts = get_task_state(cs);
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 12/24] semihosting/arm-compat-semi: eradicate target_long
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (10 preceding siblings ...)
2025-09-26 13:17 ` [PULL 11/24] semihosting/arm-compat-semi: replace target_ulong Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 13/24] semihosting/arm-compat-semi: remove dependency on cpu.h Alex Bennée
` (12 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We use int64_t or int32_t depending on ret size.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-11-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-14-alex.bennee@linaro.org>
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 29cdab66f73..3c9192d8684 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -501,10 +501,13 @@ void do_common_semihosting(CPUState *cs)
break;
case TARGET_SYS_ISERROR:
+ {
GET_ARG(0);
- common_semi_set_ret(cs, (target_long)arg0 < 0);
+ bool ret = is_64bit_semihosting(env) ?
+ (int64_t)arg0 < 0 : (int32_t)arg0 < 0;
+ common_semi_set_ret(cs, ret);
break;
-
+ }
case TARGET_SYS_ISTTY:
GET_ARG(0);
semihost_sys_isatty(cs, common_semi_istty_cb, arg0);
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 13/24] semihosting/arm-compat-semi: remove dependency on cpu.h
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (11 preceding siblings ...)
2025-09-26 13:17 ` [PULL 12/24] semihosting/arm-compat-semi: eradicate target_long Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 14/24] semihosting/arm-compat-semi: compile once in system and per target for user mode Alex Bennée
` (11 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-12-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-15-alex.bennee@linaro.org>
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 3c9192d8684..61001267965 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -34,7 +34,6 @@
#include "qemu/osdep.h"
#include "qemu/timer.h"
#include "exec/gdbstub.h"
-#include "cpu.h"
#include "gdbstub/syscalls.h"
#include "semihosting/semihost.h"
#include "semihosting/console.h"
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 14/24] semihosting/arm-compat-semi: compile once in system and per target for user mode
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (12 preceding siblings ...)
2025-09-26 13:17 ` [PULL 13/24] semihosting/arm-compat-semi: remove dependency on cpu.h Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 15/24] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure Alex Bennée
` (10 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierrick Bouvier, Richard Henderson, Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We don't have any target dependency left in system mode, so we can
compile once.
User mode depends on qemu.h, which is duplicated between linux and bsd,
so we can't easily compile it once.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250822150058.18692-13-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-16-alex.bennee@linaro.org>
diff --git a/semihosting/meson.build b/semihosting/meson.build
index bb0db323937..99f10e2e2bb 100644
--- a/semihosting/meson.build
+++ b/semihosting/meson.build
@@ -12,9 +12,10 @@ system_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
'stubs-system.c',
))
system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
+ if_true: files('arm-compat-semi.c'),
if_false: files('arm-compat-semi-stub.c'))
specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_USER_ONLY'],
if_true: files('syscalls.c'))
-specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'],
+specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING', 'CONFIG_USER_ONLY'],
if_true: files('arm-compat-semi.c'))
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 15/24] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (13 preceding siblings ...)
2025-09-26 13:17 ` [PULL 14/24] semihosting/arm-compat-semi: compile once in system and per target for user mode Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 16/24] contrib/plugins/uftrace: skeleton file Alex Bennée
` (9 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Pierrick Bouvier, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Peter Maydell <peter.maydell@linaro.org>
In insn_check_regs() we don't explicitly check whether
qemu_plugin_read_register() failed, which confuses Coverity into
thinking that sz can be -1 in the memcmp(). In fact the assertion
that sz == reg->last->len means this can't happen, but it's clearer
to both humans and Coverity if we explicitly assert that sz > 0, as
we already do in init_vcpu_register().
Coverity: CID 1611901, 1611902
Fixes: af6e4e0a22c1 ("contrib/plugins: extend execlog to track register changes")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250710144543.1187715-1-peter.maydell@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-17-alex.bennee@linaro.org>
diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c
index 06ec76d6e9a..811f3203199 100644
--- a/contrib/plugins/execlog.c
+++ b/contrib/plugins/execlog.c
@@ -95,6 +95,7 @@ static void insn_check_regs(CPU *cpu)
g_byte_array_set_size(reg->new, 0);
sz = qemu_plugin_read_register(reg->handle, reg->new);
+ g_assert(sz > 0);
g_assert(sz == reg->last->len);
if (memcmp(reg->last->data, reg->new->data, sz)) {
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 16/24] contrib/plugins/uftrace: skeleton file
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (14 preceding siblings ...)
2025-09-26 13:17 ` [PULL 15/24] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 17/24] contrib/plugins/uftrace: define cpu operations and implement aarch64 Alex Bennée
` (8 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Manos Pitsidianakis, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We define a scoreboard that will hold our data per cpu. As well, we
define a buffer per cpu that will be used to read registers and memories
in a thread-safe way.
For now, we just instrument all instructions with an empty callback.
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250902075042.223990-2-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-18-alex.bennee@linaro.org>
diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c
new file mode 100644
index 00000000000..4af0130b159
--- /dev/null
+++ b/contrib/plugins/uftrace.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2025, Pierrick Bouvier <pierrick.bouvier@linaro.org>
+ *
+ * Generates a trace compatible with uftrace (similar to uftrace record).
+ * https://github.com/namhyung/uftrace
+ *
+ * See docs/about/emulation.rst|Uftrace for details and examples.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <qemu-plugin.h>
+#include <glib.h>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+typedef struct Cpu {
+ GByteArray *buf;
+} Cpu;
+
+static struct qemu_plugin_scoreboard *score;
+
+static void track_callstack(unsigned int cpu_index, void *udata)
+{
+}
+
+static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
+{
+ size_t n_insns = qemu_plugin_tb_n_insns(tb);
+
+ for (size_t i = 0; i < n_insns; i++) {
+ struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
+
+ uintptr_t pc = qemu_plugin_insn_vaddr(insn);
+ qemu_plugin_register_vcpu_insn_exec_cb(insn, track_callstack,
+ QEMU_PLUGIN_CB_R_REGS,
+ (void *) pc);
+ }
+}
+
+static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index)
+{
+ Cpu *cpu = qemu_plugin_scoreboard_find(score, vcpu_index);
+ cpu->buf = g_byte_array_new();
+}
+
+static void vcpu_end(unsigned int vcpu_index)
+{
+ Cpu *cpu = qemu_plugin_scoreboard_find(score, vcpu_index);
+ g_byte_array_free(cpu->buf, true);
+ memset(cpu, 0, sizeof(Cpu));
+}
+
+static void at_exit(qemu_plugin_id_t id, void *data)
+{
+ for (size_t i = 0; i < qemu_plugin_num_vcpus(); ++i) {
+ vcpu_end(i);
+ }
+
+ qemu_plugin_scoreboard_free(score);
+}
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info,
+ int argc, char **argv)
+{
+ score = qemu_plugin_scoreboard_new(sizeof(Cpu));
+ qemu_plugin_register_vcpu_init_cb(id, vcpu_init);
+ qemu_plugin_register_atexit_cb(id, at_exit, NULL);
+ qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
+
+ return 0;
+}
diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
index 1876bc78438..7eb3629c95d 100644
--- a/contrib/plugins/meson.build
+++ b/contrib/plugins/meson.build
@@ -1,5 +1,6 @@
contrib_plugins = ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotblocks',
- 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger']
+ 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger',
+ 'uftrace']
if host_os != 'windows'
# lockstep uses socket.h
contrib_plugins += 'lockstep'
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 17/24] contrib/plugins/uftrace: define cpu operations and implement aarch64
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (15 preceding siblings ...)
2025-09-26 13:17 ` [PULL 16/24] contrib/plugins/uftrace: skeleton file Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 18/24] contrib/plugins/uftrace: track callstack Alex Bennée
` (7 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Manos Pitsidianakis, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We define a new CpuOps structure that will be used to implement tracking
independently of guest architecture.
As well, we now instrument only instructions following ones that might
have touched the frame pointer.
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250902075042.223990-3-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-19-alex.bennee@linaro.org>
diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c
index 4af0130b159..d060513446c 100644
--- a/contrib/plugins/uftrace.c
+++ b/contrib/plugins/uftrace.c
@@ -11,14 +11,94 @@
#include <qemu-plugin.h>
#include <glib.h>
+#include <stdio.h>
QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+typedef struct Cpu Cpu;
+
+typedef struct {
+ void (*init)(Cpu *cpu);
+ void (*end)(Cpu *cpu);
+ uint64_t (*get_frame_pointer)(Cpu *cpu);
+ bool (*does_insn_modify_frame_pointer)(const char *disas);
+} CpuOps;
+
typedef struct Cpu {
GByteArray *buf;
+ CpuOps ops;
+ void *arch;
} Cpu;
+typedef struct {
+ struct qemu_plugin_register *reg_fp;
+} Aarch64Cpu;
+
static struct qemu_plugin_scoreboard *score;
+static CpuOps arch_ops;
+
+static uint64_t cpu_read_register64(Cpu *cpu, struct qemu_plugin_register *reg)
+{
+ GByteArray *buf = cpu->buf;
+ g_byte_array_set_size(buf, 0);
+ size_t sz = qemu_plugin_read_register(reg, buf);
+ g_assert(sz == 8);
+ g_assert(buf->len == 8);
+ return *((uint64_t *) buf->data);
+}
+
+static struct qemu_plugin_register *plugin_find_register(const char *name)
+{
+ g_autoptr(GArray) regs = qemu_plugin_get_registers();
+ for (int i = 0; i < regs->len; ++i) {
+ qemu_plugin_reg_descriptor *reg;
+ reg = &g_array_index(regs, qemu_plugin_reg_descriptor, i);
+ if (!strcmp(reg->name, name)) {
+ return reg->handle;
+ }
+ }
+ return NULL;
+}
+
+static uint64_t aarch64_get_frame_pointer(Cpu *cpu_)
+{
+ Aarch64Cpu *cpu = cpu_->arch;
+ return cpu_read_register64(cpu_, cpu->reg_fp);
+}
+
+static void aarch64_init(Cpu *cpu_)
+{
+ Aarch64Cpu *cpu = g_new0(Aarch64Cpu, 1);
+ cpu_->arch = cpu;
+ cpu->reg_fp = plugin_find_register("x29");
+ if (!cpu->reg_fp) {
+ fprintf(stderr, "uftrace plugin: frame pointer register (x29) is not "
+ "available. Please use an AArch64 cpu (or -cpu max).\n");
+ g_abort();
+ }
+}
+
+static void aarch64_end(Cpu *cpu)
+{
+ g_free(cpu->arch);
+}
+
+static bool aarch64_does_insn_modify_frame_pointer(const char *disas)
+{
+ /*
+ * Check if current instruction concerns fp register "x29".
+ * We add a prefix space to make sure we don't match addresses dump
+ * in disassembly.
+ */
+ return strstr(disas, " x29");
+}
+
+static CpuOps aarch64_ops = {
+ .init = aarch64_init,
+ .end = aarch64_end,
+ .get_frame_pointer = aarch64_get_frame_pointer,
+ .does_insn_modify_frame_pointer = aarch64_does_insn_modify_frame_pointer,
+};
static void track_callstack(unsigned int cpu_index, void *udata)
{
@@ -28,19 +108,37 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
{
size_t n_insns = qemu_plugin_tb_n_insns(tb);
+ /*
+ * Callbacks and inline instrumentation are inserted before an instruction.
+ * Thus, to see instruction effect, we need to wait for next one.
+ * Potentially, the last instruction of a block could modify the frame
+ * pointer. Thus, we need to always instrument first instruction in a tb.
+ */
+ bool instrument_insn = true;
for (size_t i = 0; i < n_insns; i++) {
struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
- uintptr_t pc = qemu_plugin_insn_vaddr(insn);
- qemu_plugin_register_vcpu_insn_exec_cb(insn, track_callstack,
- QEMU_PLUGIN_CB_R_REGS,
- (void *) pc);
+ if (instrument_insn) {
+ uintptr_t pc = qemu_plugin_insn_vaddr(insn);
+ qemu_plugin_register_vcpu_insn_exec_cb(insn, track_callstack,
+ QEMU_PLUGIN_CB_R_REGS,
+ (void *) pc);
+ instrument_insn = false;
+ }
+
+ char *disas = qemu_plugin_insn_disas(insn);
+ if (arch_ops.does_insn_modify_frame_pointer(disas)) {
+ instrument_insn = true;
+ }
}
}
static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index)
{
Cpu *cpu = qemu_plugin_scoreboard_find(score, vcpu_index);
+ cpu->ops = arch_ops;
+
+ cpu->ops.init(cpu);
cpu->buf = g_byte_array_new();
}
@@ -64,6 +162,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
const qemu_info_t *info,
int argc, char **argv)
{
+ if (!strcmp(info->target_name, "aarch64")) {
+ arch_ops = aarch64_ops;
+ } else {
+ fprintf(stderr, "plugin uftrace: %s target is not supported\n",
+ info->target_name);
+ return 1;
+ }
+
score = qemu_plugin_scoreboard_new(sizeof(Cpu));
qemu_plugin_register_vcpu_init_cb(id, vcpu_init);
qemu_plugin_register_atexit_cb(id, at_exit, NULL);
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 18/24] contrib/plugins/uftrace: track callstack
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (16 preceding siblings ...)
2025-09-26 13:17 ` [PULL 17/24] contrib/plugins/uftrace: define cpu operations and implement aarch64 Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 19/24] contrib/plugins/uftrace: implement tracing Alex Bennée
` (6 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Manos Pitsidianakis, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We now track callstack, based on frame pointer analysis. We can detect
function calls, returns, and discontinuities.
We implement a frame pointer based unwinding that is used for
discontinuities.
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250902075042.223990-4-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-20-alex.bennee@linaro.org>
diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c
index d060513446c..bb775916270 100644
--- a/contrib/plugins/uftrace.c
+++ b/contrib/plugins/uftrace.c
@@ -15,6 +15,15 @@
QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+typedef struct {
+ GArray *s;
+} Callstack;
+
+typedef struct {
+ uint64_t pc;
+ uint64_t frame_pointer;
+} CallstackEntry;
+
typedef struct Cpu Cpu;
typedef struct {
@@ -25,6 +34,7 @@ typedef struct {
} CpuOps;
typedef struct Cpu {
+ Callstack *cs;
GByteArray *buf;
CpuOps ops;
void *arch;
@@ -37,6 +47,71 @@ typedef struct {
static struct qemu_plugin_scoreboard *score;
static CpuOps arch_ops;
+static Callstack *callstack_new(void)
+{
+ Callstack *cs = g_new0(Callstack, 1);
+ cs->s = g_array_new(false, false, sizeof(CallstackEntry));
+ return cs;
+}
+
+static void callstack_free(Callstack *cs)
+{
+ g_array_free(cs->s, true);
+ cs->s = NULL;
+ g_free(cs);
+}
+
+static size_t callstack_depth(const Callstack *cs)
+{
+ return cs->s->len;
+}
+
+static size_t callstack_empty(const Callstack *cs)
+{
+ return callstack_depth(cs) == 0;
+}
+
+static void callstack_clear(Callstack *cs)
+{
+ g_array_set_size(cs->s, 0);
+}
+
+static const CallstackEntry *callstack_at(const Callstack *cs, size_t depth)
+{
+ g_assert(depth > 0);
+ g_assert(depth <= callstack_depth(cs));
+ return &g_array_index(cs->s, CallstackEntry, depth - 1);
+}
+
+static CallstackEntry callstack_top(const Callstack *cs)
+{
+ if (callstack_depth(cs) >= 1) {
+ return *callstack_at(cs, callstack_depth(cs));
+ }
+ return (CallstackEntry){};
+}
+
+static CallstackEntry callstack_caller(const Callstack *cs)
+{
+ if (callstack_depth(cs) >= 2) {
+ return *callstack_at(cs, callstack_depth(cs) - 1);
+ }
+ return (CallstackEntry){};
+}
+
+static void callstack_push(Callstack *cs, CallstackEntry e)
+{
+ g_array_append_val(cs->s, e);
+}
+
+static CallstackEntry callstack_pop(Callstack *cs)
+{
+ g_assert(!callstack_empty(cs));
+ CallstackEntry e = callstack_top(cs);
+ g_array_set_size(cs->s, callstack_depth(cs) - 1);
+ return e;
+}
+
static uint64_t cpu_read_register64(Cpu *cpu, struct qemu_plugin_register *reg)
{
GByteArray *buf = cpu->buf;
@@ -47,6 +122,50 @@ static uint64_t cpu_read_register64(Cpu *cpu, struct qemu_plugin_register *reg)
return *((uint64_t *) buf->data);
}
+static uint64_t cpu_read_memory64(Cpu *cpu, uint64_t addr)
+{
+ g_assert(addr);
+ GByteArray *buf = cpu->buf;
+ g_byte_array_set_size(buf, 0);
+ bool read = qemu_plugin_read_memory_vaddr(addr, buf, 8);
+ if (!read) {
+ return 0;
+ }
+ g_assert(buf->len == 8);
+ return *((uint64_t *) buf->data);
+}
+
+static void cpu_unwind_stack(Cpu *cpu, uint64_t frame_pointer, uint64_t pc)
+{
+ g_assert(callstack_empty(cpu->cs));
+
+ #define UNWIND_STACK_MAX_DEPTH 1024
+ CallstackEntry unwind[UNWIND_STACK_MAX_DEPTH];
+ size_t depth = 0;
+ do {
+ /* check we don't have an infinite stack */
+ for (size_t i = 0; i < depth; ++i) {
+ if (frame_pointer == unwind[i].frame_pointer) {
+ break;
+ }
+ }
+ CallstackEntry e = {.frame_pointer = frame_pointer, .pc = pc};
+ unwind[depth] = e;
+ depth++;
+ if (frame_pointer) {
+ frame_pointer = cpu_read_memory64(cpu, frame_pointer);
+ }
+ pc = cpu_read_memory64(cpu, frame_pointer + 8); /* read previous lr */
+ } while (frame_pointer && pc && depth < UNWIND_STACK_MAX_DEPTH);
+ #undef UNWIND_STACK_MAX_DEPTH
+
+ /* push it from bottom to top */
+ while (depth) {
+ callstack_push(cpu->cs, unwind[depth - 1]);
+ --depth;
+ }
+}
+
static struct qemu_plugin_register *plugin_find_register(const char *name)
{
g_autoptr(GArray) regs = qemu_plugin_get_registers();
@@ -102,6 +221,43 @@ static CpuOps aarch64_ops = {
static void track_callstack(unsigned int cpu_index, void *udata)
{
+ uint64_t pc = (uintptr_t) udata;
+ Cpu *cpu = qemu_plugin_scoreboard_find(score, cpu_index);
+ Callstack *cs = cpu->cs;
+
+ uint64_t fp = cpu->ops.get_frame_pointer(cpu);
+ if (!fp && callstack_empty(cs)) {
+ /*
+ * We simply push current pc. Note that we won't detect symbol change as
+ * long as a proper call does not happen.
+ */
+ callstack_push(cs, (CallstackEntry){.frame_pointer = fp, .pc = pc});
+ return;
+ }
+
+ CallstackEntry top = callstack_top(cs);
+ if (fp == top.frame_pointer) {
+ /* same function */
+ return;
+ }
+
+ CallstackEntry caller = callstack_caller(cs);
+ if (fp == caller.frame_pointer) {
+ /* return */
+ callstack_pop(cs);
+ return;
+ }
+
+ uint64_t caller_fp = fp ? cpu_read_memory64(cpu, fp) : 0;
+ if (caller_fp == top.frame_pointer) {
+ /* call */
+ callstack_push(cs, (CallstackEntry){.frame_pointer = fp, .pc = pc});
+ return;
+ }
+
+ /* discontinuity, exit current stack and unwind new one */
+ callstack_clear(cs);
+ cpu_unwind_stack(cpu, fp, pc);
}
static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
@@ -140,12 +296,16 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index)
cpu->ops.init(cpu);
cpu->buf = g_byte_array_new();
+
+ cpu->cs = callstack_new();
}
static void vcpu_end(unsigned int vcpu_index)
{
Cpu *cpu = qemu_plugin_scoreboard_find(score, vcpu_index);
g_byte_array_free(cpu->buf, true);
+
+ callstack_free(cpu->cs);
memset(cpu, 0, sizeof(Cpu));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 19/24] contrib/plugins/uftrace: implement tracing
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (17 preceding siblings ...)
2025-09-26 13:17 ` [PULL 18/24] contrib/plugins/uftrace: track callstack Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 20/24] contrib/plugins/uftrace: implement privilege level tracing Alex Bennée
` (5 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Philippe Mathieu-Daudé, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We implement tracing, following uftrace format.
Trace is flushed every 32 MB, so file operations don't impact
performance at runtime.
A different trace is generated per cpu, and we ensure they have a unique
name, based on vcpu_index, while keeping room for privilege level coming
in next commit.
Uftrace format is not officially documented, but it can be found here:
https://github.com/namhyung/uftrace/blob/v0.18/libmcount/record.c#L909
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250902075042.223990-5-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-21-alex.bennee@linaro.org>
diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c
index bb775916270..b9dcd531987 100644
--- a/contrib/plugins/uftrace.c
+++ b/contrib/plugins/uftrace.c
@@ -12,6 +12,15 @@
#include <qemu-plugin.h>
#include <glib.h>
#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+
+#define MiB (INT64_C(1) << 20)
+#define NANOSECONDS_PER_SECOND 1000000000LL
+#define TRACE_FLUSH_SIZE (32 * MiB)
+#define TRACE_ID_SCALE 100
QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
@@ -24,6 +33,13 @@ typedef struct {
uint64_t frame_pointer;
} CallstackEntry;
+typedef struct {
+ GArray *t;
+ GString *path;
+ GString *name;
+ uint32_t id;
+} Trace;
+
typedef struct Cpu Cpu;
typedef struct {
@@ -34,6 +50,7 @@ typedef struct {
} CpuOps;
typedef struct Cpu {
+ Trace *trace;
Callstack *cs;
GByteArray *buf;
CpuOps ops;
@@ -44,9 +61,41 @@ typedef struct {
struct qemu_plugin_register *reg_fp;
} Aarch64Cpu;
+typedef struct {
+ uint64_t timestamp;
+ uint64_t data;
+} UftraceEntry;
+
+typedef enum {
+ UFTRACE_ENTRY,
+ UFTRACE_EXIT,
+ UFTRACE_LOST,
+ UFTRACE_EVENT,
+} UftraceRecordType;
+
static struct qemu_plugin_scoreboard *score;
static CpuOps arch_ops;
+static uint64_t gettime_ns(void)
+{
+#ifdef _WIN32
+ /*
+ * On Windows, timespec_get is available only with UCRT, but not with
+ * MinGW64 environment. Simplify by using only gettimeofday on this
+ * platform. This may result in a precision loss.
+ */
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ uint64_t now_ns = tv.tv_sec * NANOSECONDS_PER_SECOND + tv.tv_usec * 1000;
+#else
+ /* We need nanosecond precision for short lived functions. */
+ struct timespec ts;
+ timespec_get(&ts, TIME_UTC);
+ uint64_t now_ns = ts.tv_sec * NANOSECONDS_PER_SECOND + ts.tv_nsec;
+#endif
+ return now_ns;
+}
+
static Callstack *callstack_new(void)
{
Callstack *cs = g_new0(Callstack, 1);
@@ -112,6 +161,86 @@ static CallstackEntry callstack_pop(Callstack *cs)
return e;
}
+static Trace *trace_new(uint32_t id, GString *name)
+{
+ Trace *t = g_new0(Trace, 1);
+ t->t = g_array_new(false, false, sizeof(UftraceEntry));
+ t->path = g_string_new(NULL);
+ g_string_append_printf(t->path, "./uftrace.data/%"PRIu32".dat", id);
+ t->name = g_string_new(name->str);
+ t->id = id;
+ return t;
+}
+
+static void trace_free(Trace *t)
+{
+ g_assert(t->t->len == 0);
+ g_array_free(t->t, true);
+ t->t = NULL;
+ g_string_free(t->path, true);
+ t->path = NULL;
+ g_string_free(t->name, true);
+ t->name = NULL;
+ g_free(t);
+}
+
+static void trace_flush(Trace *t, bool append)
+{
+ int create_dir = g_mkdir_with_parents("./uftrace.data",
+ S_IRWXU | S_IRWXG | S_IRWXO);
+ g_assert(create_dir == 0);
+ FILE *dat = fopen(t->path->str, append ? "a" : "w");
+ g_assert(dat);
+ GArray *data = t->t;
+ if (data->len) {
+ size_t wrote = fwrite(data->data, sizeof(UftraceEntry), data->len, dat);
+ g_assert(wrote == data->len);
+ }
+ fclose(dat);
+ g_array_set_size(data, 0);
+}
+
+static void trace_add_entry(Trace *t, uint64_t timestamp, uint64_t pc,
+ size_t depth, UftraceRecordType type)
+{
+ /* https://github.com/namhyung/uftrace/blob/v0.18/libmcount/record.c#L909 */
+ const uint64_t record_magic = 0x5;
+ uint64_t data = type | (record_magic << 3);
+ data += depth << 6;
+ data += pc << 16;
+ UftraceEntry e = {.timestamp = timestamp, .data = data};
+ g_array_append_val(t->t, e);
+ if (t->t->len * sizeof(UftraceEntry) > TRACE_FLUSH_SIZE) {
+ trace_flush(t, true);
+ }
+}
+
+static void trace_enter_function(Trace *t, uint64_t timestamp,
+ uint64_t pc, size_t depth)
+{
+ trace_add_entry(t, timestamp, pc, depth, UFTRACE_ENTRY);
+}
+
+static void trace_exit_function(Trace *t, uint64_t timestamp,
+ uint64_t pc, size_t depth)
+{
+ trace_add_entry(t, timestamp, pc, depth, UFTRACE_EXIT);
+}
+
+static void trace_enter_stack(Trace *t, Callstack *cs, uint64_t timestamp)
+{
+ for (size_t depth = 1; depth <= callstack_depth(cs); ++depth) {
+ trace_enter_function(t, timestamp, callstack_at(cs, depth)->pc, depth);
+ }
+}
+
+static void trace_exit_stack(Trace *t, Callstack *cs, uint64_t timestamp)
+{
+ for (size_t depth = callstack_depth(cs); depth > 0; --depth) {
+ trace_exit_function(t, timestamp, callstack_at(cs, depth)->pc, depth);
+ }
+}
+
static uint64_t cpu_read_register64(Cpu *cpu, struct qemu_plugin_register *reg)
{
GByteArray *buf = cpu->buf;
@@ -223,7 +352,9 @@ static void track_callstack(unsigned int cpu_index, void *udata)
{
uint64_t pc = (uintptr_t) udata;
Cpu *cpu = qemu_plugin_scoreboard_find(score, cpu_index);
+ uint64_t timestamp = gettime_ns();
Callstack *cs = cpu->cs;
+ Trace *t = cpu->trace;
uint64_t fp = cpu->ops.get_frame_pointer(cpu);
if (!fp && callstack_empty(cs)) {
@@ -232,6 +363,7 @@ static void track_callstack(unsigned int cpu_index, void *udata)
* long as a proper call does not happen.
*/
callstack_push(cs, (CallstackEntry){.frame_pointer = fp, .pc = pc});
+ trace_enter_function(t, timestamp, pc, callstack_depth(cs));
return;
}
@@ -244,7 +376,8 @@ static void track_callstack(unsigned int cpu_index, void *udata)
CallstackEntry caller = callstack_caller(cs);
if (fp == caller.frame_pointer) {
/* return */
- callstack_pop(cs);
+ CallstackEntry e = callstack_pop(cs);
+ trace_exit_function(t, timestamp, e.pc, callstack_depth(cs));
return;
}
@@ -252,12 +385,16 @@ static void track_callstack(unsigned int cpu_index, void *udata)
if (caller_fp == top.frame_pointer) {
/* call */
callstack_push(cs, (CallstackEntry){.frame_pointer = fp, .pc = pc});
+ trace_enter_function(t, timestamp, pc, callstack_depth(cs));
return;
}
/* discontinuity, exit current stack and unwind new one */
+ trace_exit_stack(t, cs, timestamp);
callstack_clear(cs);
+
cpu_unwind_stack(cpu, fp, pc);
+ trace_enter_stack(t, cs, timestamp);
}
static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
@@ -297,6 +434,16 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index)
cpu->ops.init(cpu);
cpu->buf = g_byte_array_new();
+ g_assert(vcpu_index < UINT32_MAX / TRACE_ID_SCALE);
+ /* trace_id is: cpu_number * TRACE_ID_SCALE */
+ uint32_t trace_id = (vcpu_index + 1) * TRACE_ID_SCALE;
+
+ g_autoptr(GString) trace_name = g_string_new(NULL);
+ g_string_append_printf(trace_name, "cpu%u", vcpu_index);
+ cpu->trace = trace_new(trace_id, trace_name);
+ /* create/truncate trace file */
+ trace_flush(cpu->trace, false);
+
cpu->cs = callstack_new();
}
@@ -305,6 +452,7 @@ static void vcpu_end(unsigned int vcpu_index)
Cpu *cpu = qemu_plugin_scoreboard_find(score, vcpu_index);
g_byte_array_free(cpu->buf, true);
+ trace_free(cpu->trace);
callstack_free(cpu->cs);
memset(cpu, 0, sizeof(Cpu));
}
@@ -312,6 +460,8 @@ static void vcpu_end(unsigned int vcpu_index)
static void at_exit(qemu_plugin_id_t id, void *data)
{
for (size_t i = 0; i < qemu_plugin_num_vcpus(); ++i) {
+ Cpu *cpu = qemu_plugin_scoreboard_find(score, i);
+ trace_flush(cpu->trace, true);
vcpu_end(i);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 20/24] contrib/plugins/uftrace: implement privilege level tracing
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (18 preceding siblings ...)
2025-09-26 13:17 ` [PULL 19/24] contrib/plugins/uftrace: implement tracing Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 21/24] contrib/plugins/uftrace: generate additional files for uftrace Alex Bennée
` (4 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Manos Pitsidianakis, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We add new option trace-privilege-level=bool, which will create a
separate trace for each privilege level.
This allows to follow changes of privilege during execution.
We implement aarch64 operations to track current privilege level
accordingly.
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250902075042.223990-6-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-22-alex.bennee@linaro.org>
diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c
index b9dcd531987..10abad0673c 100644
--- a/contrib/plugins/uftrace.c
+++ b/contrib/plugins/uftrace.c
@@ -46,19 +46,40 @@ typedef struct {
void (*init)(Cpu *cpu);
void (*end)(Cpu *cpu);
uint64_t (*get_frame_pointer)(Cpu *cpu);
+ uint8_t (*get_privilege_level)(Cpu *cpu);
+ uint8_t (*num_privilege_levels)(void);
+ const char *(*get_privilege_level_name)(uint8_t pl);
bool (*does_insn_modify_frame_pointer)(const char *disas);
} CpuOps;
typedef struct Cpu {
Trace *trace;
Callstack *cs;
+ uint8_t privilege_level;
+ GArray *traces; /* Trace *traces [] */
GByteArray *buf;
CpuOps ops;
void *arch;
} Cpu;
+typedef enum {
+ AARCH64_EL0_SECURE,
+ AARCH64_EL0_NONSECURE,
+ AARCH64_EL0_REALM,
+ AARCH64_EL1_SECURE,
+ AARCH64_EL1_NONSECURE,
+ AARCH64_EL1_REALM,
+ AARCH64_EL2_SECURE,
+ AARCH64_EL2_NONSECURE,
+ AARCH64_EL2_REALM,
+ AARCH64_EL3,
+ AARCH64_PRIVILEGE_LEVEL_MAX,
+} Aarch64PrivilegeLevel;
+
typedef struct {
struct qemu_plugin_register *reg_fp;
+ struct qemu_plugin_register *reg_cpsr;
+ struct qemu_plugin_register *reg_scr_el3;
} Aarch64Cpu;
typedef struct {
@@ -74,6 +95,7 @@ typedef enum {
} UftraceRecordType;
static struct qemu_plugin_scoreboard *score;
+static bool trace_privilege_level;
static CpuOps arch_ops;
static uint64_t gettime_ns(void)
@@ -251,6 +273,16 @@ static uint64_t cpu_read_register64(Cpu *cpu, struct qemu_plugin_register *reg)
return *((uint64_t *) buf->data);
}
+static uint32_t cpu_read_register32(Cpu *cpu, struct qemu_plugin_register *reg)
+{
+ GByteArray *buf = cpu->buf;
+ g_byte_array_set_size(buf, 0);
+ size_t sz = qemu_plugin_read_register(reg, buf);
+ g_assert(sz == 4);
+ g_assert(buf->len == 4);
+ return *((uint32_t *) buf->data);
+}
+
static uint64_t cpu_read_memory64(Cpu *cpu, uint64_t addr)
{
g_assert(addr);
@@ -308,6 +340,68 @@ static struct qemu_plugin_register *plugin_find_register(const char *name)
return NULL;
}
+static uint8_t aarch64_num_privilege_levels(void)
+{
+ return AARCH64_PRIVILEGE_LEVEL_MAX;
+}
+
+static const char *aarch64_get_privilege_level_name(uint8_t pl)
+{
+ switch (pl) {
+ case AARCH64_EL0_SECURE: return "S-EL0";
+ case AARCH64_EL0_NONSECURE: return "NS-EL0";
+ case AARCH64_EL0_REALM: return "R-EL0";
+ case AARCH64_EL1_SECURE: return "S-EL1";
+ case AARCH64_EL1_NONSECURE: return "NS-EL1";
+ case AARCH64_EL1_REALM: return "R-EL1";
+ case AARCH64_EL2_SECURE: return "S-EL2";
+ case AARCH64_EL2_NONSECURE: return "NS-EL2";
+ case AARCH64_EL2_REALM: return "R-EL2";
+ case AARCH64_EL3: return "EL3";
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static uint8_t aarch64_get_privilege_level(Cpu *cpu_)
+{
+ Aarch64Cpu *cpu = cpu_->arch;
+ /*
+ * QEMU gdbstub does not provide access to CurrentEL,
+ * so we use CPSR instead.
+ */
+ uint8_t el = cpu_read_register32(cpu_, cpu->reg_cpsr) >> 2 & 0b11;
+
+ if (el == 3) {
+ return AARCH64_EL3;
+ }
+
+ uint8_t ss = AARCH64_EL0_SECURE;
+ if (!cpu->reg_scr_el3) {
+ ss = AARCH64_EL0_NONSECURE;
+ }
+ uint64_t scr_el3 = cpu_read_register64(cpu_, cpu->reg_scr_el3);
+ uint64_t ns = (scr_el3 >> 0) & 0b1;
+ uint64_t nse = (scr_el3 >> 62) & 0b1;
+ switch (nse << 1 | ns) {
+ case 0b00:
+ ss = AARCH64_EL0_SECURE;
+ break;
+ case 0b01:
+ ss = AARCH64_EL0_NONSECURE;
+ break;
+ case 0b11:
+ ss = AARCH64_EL0_REALM;
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ const uint8_t num_ss = 3;
+ Aarch64PrivilegeLevel pl = el * num_ss + ss;
+ return pl;
+}
+
static uint64_t aarch64_get_frame_pointer(Cpu *cpu_)
{
Aarch64Cpu *cpu = cpu_->arch;
@@ -324,6 +418,10 @@ static void aarch64_init(Cpu *cpu_)
"available. Please use an AArch64 cpu (or -cpu max).\n");
g_abort();
}
+ cpu->reg_cpsr = plugin_find_register("cpsr");
+ g_assert(cpu->reg_cpsr);
+ cpu->reg_scr_el3 = plugin_find_register("SCR_EL3");
+ /* scr_el3 is optional */
}
static void aarch64_end(Cpu *cpu)
@@ -345,9 +443,34 @@ static CpuOps aarch64_ops = {
.init = aarch64_init,
.end = aarch64_end,
.get_frame_pointer = aarch64_get_frame_pointer,
+ .get_privilege_level = aarch64_get_privilege_level,
+ .num_privilege_levels = aarch64_num_privilege_levels,
+ .get_privilege_level_name = aarch64_get_privilege_level_name,
.does_insn_modify_frame_pointer = aarch64_does_insn_modify_frame_pointer,
};
+static void track_privilege_change(unsigned int cpu_index, void *udata)
+{
+ Cpu *cpu = qemu_plugin_scoreboard_find(score, cpu_index);
+ uint8_t new_pl = cpu->ops.get_privilege_level(cpu);
+
+ if (new_pl == cpu->privilege_level) {
+ return;
+ }
+
+ uint64_t pc = (uintptr_t) udata;
+ uint64_t timestamp = gettime_ns();
+
+ trace_exit_stack(cpu->trace, cpu->cs, timestamp);
+ callstack_clear(cpu->cs);
+
+ cpu->privilege_level = new_pl;
+ cpu->trace = g_array_index(cpu->traces, Trace*, new_pl);
+
+ cpu_unwind_stack(cpu, cpu->ops.get_frame_pointer(cpu), pc);
+ trace_enter_stack(cpu->trace, cpu->cs, timestamp);
+}
+
static void track_callstack(unsigned int cpu_index, void *udata)
{
uint64_t pc = (uintptr_t) udata;
@@ -400,6 +523,13 @@ static void track_callstack(unsigned int cpu_index, void *udata)
static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
{
size_t n_insns = qemu_plugin_tb_n_insns(tb);
+ uintptr_t tb_pc = qemu_plugin_tb_vaddr(tb);
+
+ if (trace_privilege_level) {
+ qemu_plugin_register_vcpu_tb_exec_cb(tb, track_privilege_change,
+ QEMU_PLUGIN_CB_R_REGS,
+ (void *) tb_pc);
+ }
/*
* Callbacks and inline instrumentation are inserted before an instruction.
@@ -433,18 +563,36 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index)
cpu->ops.init(cpu);
cpu->buf = g_byte_array_new();
+ cpu->traces = g_array_new(0, 0, sizeof(Trace *));
g_assert(vcpu_index < UINT32_MAX / TRACE_ID_SCALE);
- /* trace_id is: cpu_number * TRACE_ID_SCALE */
+ g_assert(cpu->ops.num_privilege_levels() < TRACE_ID_SCALE);
+ /* trace_id is: cpu_number * TRACE_ID_SCALE + privilege_level */
uint32_t trace_id = (vcpu_index + 1) * TRACE_ID_SCALE;
- g_autoptr(GString) trace_name = g_string_new(NULL);
- g_string_append_printf(trace_name, "cpu%u", vcpu_index);
- cpu->trace = trace_new(trace_id, trace_name);
- /* create/truncate trace file */
- trace_flush(cpu->trace, false);
+ if (trace_privilege_level) {
+ for (uint8_t pl = 0; pl < cpu->ops.num_privilege_levels(); ++pl) {
+ g_autoptr(GString) trace_name = g_string_new(NULL);
+ g_string_append_printf(trace_name, "cpu%u %s", vcpu_index,
+ cpu->ops.get_privilege_level_name(pl));
+ Trace *t = trace_new(trace_id + pl, trace_name);
+ g_array_append_val(cpu->traces, t);
+ }
+ } else {
+ g_autoptr(GString) trace_name = g_string_new(NULL);
+ g_string_append_printf(trace_name, "cpu%u", vcpu_index);
+ Trace *t = trace_new(trace_id, trace_name);
+ g_array_append_val(cpu->traces, t);
+ }
+
+ for (size_t i = 0; i < cpu->traces->len; ++i) {
+ /* create/truncate trace files */
+ Trace *t = g_array_index(cpu->traces, Trace*, i);
+ trace_flush(t, false);
+ }
cpu->cs = callstack_new();
+ cpu->trace = g_array_index(cpu->traces, Trace*, cpu->privilege_level);
}
static void vcpu_end(unsigned int vcpu_index)
@@ -452,7 +600,12 @@ static void vcpu_end(unsigned int vcpu_index)
Cpu *cpu = qemu_plugin_scoreboard_find(score, vcpu_index);
g_byte_array_free(cpu->buf, true);
- trace_free(cpu->trace);
+ for (size_t i = 0; i < cpu->traces->len; ++i) {
+ Trace *t = g_array_index(cpu->traces, Trace*, i);
+ trace_free(t);
+ }
+
+ g_array_free(cpu->traces, true);
callstack_free(cpu->cs);
memset(cpu, 0, sizeof(Cpu));
}
@@ -461,7 +614,13 @@ static void at_exit(qemu_plugin_id_t id, void *data)
{
for (size_t i = 0; i < qemu_plugin_num_vcpus(); ++i) {
Cpu *cpu = qemu_plugin_scoreboard_find(score, i);
- trace_flush(cpu->trace, true);
+ for (size_t j = 0; j < cpu->traces->len; ++j) {
+ Trace *t = g_array_index(cpu->traces, Trace*, j);
+ trace_flush(t, true);
+ }
+ }
+
+ for (size_t i = 0; i < qemu_plugin_num_vcpus(); ++i) {
vcpu_end(i);
}
@@ -472,6 +631,21 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
const qemu_info_t *info,
int argc, char **argv)
{
+ for (int i = 0; i < argc; i++) {
+ char *opt = argv[i];
+ g_auto(GStrv) tokens = g_strsplit(opt, "=", 2);
+ if (g_strcmp0(tokens[0], "trace-privilege-level") == 0) {
+ if (!qemu_plugin_bool_parse(tokens[0], tokens[1],
+ &trace_privilege_level)) {
+ fprintf(stderr, "boolean argument parsing failed: %s\n", opt);
+ return -1;
+ }
+ } else {
+ fprintf(stderr, "option parsing failed: %s\n", opt);
+ return -1;
+ }
+ }
+
if (!strcmp(info->target_name, "aarch64")) {
arch_ops = aarch64_ops;
} else {
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 21/24] contrib/plugins/uftrace: generate additional files for uftrace
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (19 preceding siblings ...)
2025-09-26 13:17 ` [PULL 20/24] contrib/plugins/uftrace: implement privilege level tracing Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 22/24] contrib/plugins/uftrace: implement x64 support Alex Bennée
` (3 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Manos Pitsidianakis, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Beyond traces per cpu, uftrace expect to find some specific files.
- info: contains information about machine/program run
those values are not impacting uftrace behaviour (only reported by
uftrace info), and we simply added empty strings.
- memory mapping: how every binary is mapped in memory. For system mode,
we generate an empty mapping (uftrace_symbols.py, coming in future
commit, will take care of that). For user mode, we copy current
/proc/self/maps. We don't need to do any special filtering, as
reported addresses will necessarily concern guest program, and not
QEMU and its libraries.
- task: list of tasks. We present every vcpu/privilege level as a
separate process, as it's the best view we can have when generating a
(visual) chrome trace. Using threads is less convenient in terms of
UI.
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250902075042.223990-7-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-23-alex.bennee@linaro.org>
diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c
index 10abad0673c..2386cc723bc 100644
--- a/contrib/plugins/uftrace.c
+++ b/contrib/plugins/uftrace.c
@@ -118,6 +118,127 @@ static uint64_t gettime_ns(void)
return now_ns;
}
+static void uftrace_write_map(bool system_emulation)
+{
+ const char *path = "./uftrace.data/sid-0.map";
+
+ if (system_emulation && access(path, F_OK) == 0) {
+ /* do not erase existing map in system emulation, as a custom one might
+ * already have been generated by uftrace_symbols.py */
+ return;
+ }
+
+ FILE *sid_map = fopen(path, "w");
+ g_assert(sid_map);
+
+ if (system_emulation) {
+ fprintf(sid_map,
+ "# map stack on highest address possible, to prevent uftrace\n"
+ "# from considering any kernel address\n");
+ fprintf(sid_map,
+ "ffffffffffff-ffffffffffff rw-p 00000000 00:00 0 [stack]\n");
+ } else {
+ /* in user mode, copy /proc/self/maps instead */
+ FILE *self_map = fopen("/proc/self/maps", "r");
+ g_assert(self_map);
+ for (;;) {
+ int c = fgetc(self_map);
+ if (c == EOF) {
+ break;
+ }
+ fputc(c, sid_map);
+ }
+ fclose(self_map);
+ }
+ fclose(sid_map);
+}
+
+static void uftrace_write_task(const GArray *traces)
+{
+ FILE *task = fopen("./uftrace.data/task.txt", "w");
+ g_assert(task);
+ for (int i = 0; i < traces->len; ++i) {
+ Trace *t = g_array_index(traces, Trace*, i);
+ fprintf(task, "SESS timestamp=0.0 pid=%"PRIu32" sid=0 exename=\"%s\"\n",
+ t->id, t->name->str);
+ fprintf(task, "TASK timestamp=0.0 tid=%"PRIu32" pid=%"PRIu32"\n",
+ t->id, t->id);
+ }
+ fclose(task);
+}
+
+static void uftrace_write_info(const GArray *traces)
+{
+ g_autoptr(GString) taskinfo_tids = g_string_new("taskinfo:tids=");
+ for (int i = 0; i < traces->len; ++i) {
+ Trace *t = g_array_index(traces, Trace*, i);
+ const char *delim = i > 0 ? "," : "";
+ g_string_append_printf(taskinfo_tids, "%s%"PRIu32, delim, t->id);
+ }
+
+ g_autoptr(GString) taskinfo_nr_tid = g_string_new("taskinfo:nr_tid=");
+ g_string_append_printf(taskinfo_nr_tid, "%d", traces->len);
+
+ FILE *info = fopen("./uftrace.data/info", "w");
+ g_assert(info);
+ /*
+ * $ uftrace dump --debug
+ * uftrace file header: magic = 4674726163652100
+ * uftrace file header: version = 4
+ * uftrace file header: header size = 40
+ * uftrace file header: endian = 1 (little)
+ * uftrace file header: class = 2 (64 bit)
+ * uftrace file header: features = 0x1263 (PLTHOOK | ...
+ * uftrace file header: info = 0x7bff (EXE_NAME | ...
+ * <0000000000000000>: 46 74 72 61 63 65 21 00 04 00 00 00 28 00 01 02
+ * <0000000000000010>: 63 12 00 00 00 00 00 00 ff 7b 00 00 00 00 00 00
+ * <0000000000000020>: 00 04 00 00 00 00 00 00
+ */
+ const uint8_t header[] = {0x46, 0x74, 0x72, 0x61, 0x63, 0x65, 0x21, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x01, 0x02,
+ 0x63, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ size_t wrote = fwrite(header, sizeof(header), 1, info);
+ g_assert(wrote == 1);
+ const char *info_data[] = {
+ "exename:",
+ "build_id:0000000000000000000000000000000000000000",
+ "exit_status:",
+ "cmdline:",
+ "cpuinfo:lines=2",
+ "cpuinfo:nr_cpus=",
+ "cpuinfo:desc=",
+ "meminfo:",
+ "osinfo:lines=3",
+ "osinfo:kernel=",
+ "osinfo:hostname=",
+ "osinfo:distro=",
+ "taskinfo:lines=2",
+ taskinfo_nr_tid->str,
+ taskinfo_tids->str,
+ "usageinfo:lines=6",
+ "usageinfo:systime=",
+ "usageinfo:usrtime=",
+ "usageinfo:ctxsw=",
+ "usageinfo:maxrss=",
+ "usageinfo:pagefault=",
+ "usageinfo:iops=",
+ "loadinfo:",
+ "record_date:",
+ "elapsed_time:",
+ "pattern_type:regex",
+ "uftrace_version:",
+ "utc_offset:",
+ 0};
+ const char **info_data_it = info_data;
+ while (*(info_data_it)) {
+ fprintf(info, "%s\n", *info_data_it);
+ ++info_data_it;
+ }
+ fclose(info);
+}
+
static Callstack *callstack_new(void)
{
Callstack *cs = g_new0(Callstack, 1);
@@ -612,14 +733,22 @@ static void vcpu_end(unsigned int vcpu_index)
static void at_exit(qemu_plugin_id_t id, void *data)
{
+ bool system_emulation = (bool) data;
+ g_autoptr(GArray) traces = g_array_new(0, 0, sizeof(Trace *));
+
for (size_t i = 0; i < qemu_plugin_num_vcpus(); ++i) {
Cpu *cpu = qemu_plugin_scoreboard_find(score, i);
for (size_t j = 0; j < cpu->traces->len; ++j) {
Trace *t = g_array_index(cpu->traces, Trace*, j);
trace_flush(t, true);
+ g_array_append_val(traces, t);
}
}
+ uftrace_write_map(system_emulation);
+ uftrace_write_info(traces);
+ uftrace_write_task(traces);
+
for (size_t i = 0; i < qemu_plugin_num_vcpus(); ++i) {
vcpu_end(i);
}
@@ -656,7 +785,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
score = qemu_plugin_scoreboard_new(sizeof(Cpu));
qemu_plugin_register_vcpu_init_cb(id, vcpu_init);
- qemu_plugin_register_atexit_cb(id, at_exit, NULL);
+ qemu_plugin_register_atexit_cb(id, at_exit, (void *) info->system_emulation);
qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
return 0;
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 22/24] contrib/plugins/uftrace: implement x64 support
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (20 preceding siblings ...)
2025-09-26 13:17 ` [PULL 21/24] contrib/plugins/uftrace: generate additional files for uftrace Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 23/24] contrib/plugins/uftrace_symbols.py Alex Bennée
` (2 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Manos Pitsidianakis, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
It's trivial to implement x64 support, as it's the same stack layout
as aarch64.
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250902075042.223990-8-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-24-alex.bennee@linaro.org>
diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c
index 2386cc723bc..b7d6124d2f5 100644
--- a/contrib/plugins/uftrace.c
+++ b/contrib/plugins/uftrace.c
@@ -82,6 +82,21 @@ typedef struct {
struct qemu_plugin_register *reg_scr_el3;
} Aarch64Cpu;
+typedef enum {
+ X64_RING0,
+ X64_RING1,
+ X64_RING2,
+ X64_RING3,
+ X64_REAL_MODE,
+ X64_PRIVILEGE_LEVEL_MAX,
+} X64PrivilegeLevel;
+
+typedef struct {
+ struct qemu_plugin_register *reg_rbp;
+ struct qemu_plugin_register *reg_cs;
+ struct qemu_plugin_register *reg_cr0;
+} X64Cpu;
+
typedef struct {
uint64_t timestamp;
uint64_t data;
@@ -570,6 +585,75 @@ static CpuOps aarch64_ops = {
.does_insn_modify_frame_pointer = aarch64_does_insn_modify_frame_pointer,
};
+static uint8_t x64_num_privilege_levels(void)
+{
+ return X64_PRIVILEGE_LEVEL_MAX;
+}
+
+static const char *x64_get_privilege_level_name(uint8_t pl)
+{
+ switch (pl) {
+ case X64_RING0: return "Ring0";
+ case X64_RING1: return "Ring1";
+ case X64_RING2: return "Ring2";
+ case X64_RING3: return "Ring3";
+ case X64_REAL_MODE: return "RealMode";
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static uint8_t x64_get_privilege_level(Cpu *cpu_)
+{
+ X64Cpu *cpu = cpu_->arch;
+ uint64_t cr0 = cpu_read_register64(cpu_, cpu->reg_cr0);
+ uint64_t protected_mode = (cr0 >> 0) & 0b1;
+ if (!protected_mode) {
+ return X64_REAL_MODE;
+ }
+ uint32_t cs = cpu_read_register32(cpu_, cpu->reg_cs);
+ uint32_t ring_level = (cs >> 0) & 0b11;
+ return ring_level;
+}
+
+static uint64_t x64_get_frame_pointer(Cpu *cpu_)
+{
+ X64Cpu *cpu = cpu_->arch;
+ return cpu_read_register64(cpu_, cpu->reg_rbp);
+}
+
+static void x64_init(Cpu *cpu_)
+{
+ X64Cpu *cpu = g_new0(X64Cpu, 1);
+ cpu_->arch = cpu;
+ cpu->reg_rbp = plugin_find_register("rbp");
+ g_assert(cpu->reg_rbp);
+ cpu->reg_cs = plugin_find_register("cs");
+ g_assert(cpu->reg_cs);
+ cpu->reg_cr0 = plugin_find_register("cr0");
+ g_assert(cpu->reg_cr0);
+}
+
+static void x64_end(Cpu *cpu)
+{
+ g_free(cpu->arch);
+}
+
+static bool x64_does_insn_modify_frame_pointer(const char *disas)
+{
+ return strstr(disas, "rbp");
+}
+
+static CpuOps x64_ops = {
+ .init = x64_init,
+ .end = x64_end,
+ .get_frame_pointer = x64_get_frame_pointer,
+ .get_privilege_level = x64_get_privilege_level,
+ .num_privilege_levels = x64_num_privilege_levels,
+ .get_privilege_level_name = x64_get_privilege_level_name,
+ .does_insn_modify_frame_pointer = x64_does_insn_modify_frame_pointer,
+};
+
static void track_privilege_change(unsigned int cpu_index, void *udata)
{
Cpu *cpu = qemu_plugin_scoreboard_find(score, cpu_index);
@@ -777,6 +861,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
if (!strcmp(info->target_name, "aarch64")) {
arch_ops = aarch64_ops;
+ } else if (!strcmp(info->target_name, "x86_64")) {
+ arch_ops = x64_ops;
} else {
fprintf(stderr, "plugin uftrace: %s target is not supported\n",
info->target_name);
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 23/24] contrib/plugins/uftrace_symbols.py
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (21 preceding siblings ...)
2025-09-26 13:17 ` [PULL 22/24] contrib/plugins/uftrace: implement x64 support Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-26 13:17 ` [PULL 24/24] contrib/plugins/uftrace: add documentation Alex Bennée
2025-09-27 15:42 ` [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Richard Henderson
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel
Cc: Pierrick Bouvier, Philippe Mathieu-Daudé, Alex Bennée,
Alexandre Iooss, Mahmoud Mandour
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
usage: contrib/plugins/uftrace_symbols.py \
--prefix-symbols \
arm-trusted-firmware/build/qemu/debug/bl1/bl1.elf \
arm-trusted-firmware/build/qemu/debug/bl2/bl2.elf \
arm-trusted-firmware/build/qemu/debug/bl31/bl31.elf \
u-boot/u-boot:0x60000000 \
u-boot/u-boot.relocated:0x000000023f6b6000 \
linux/vmlinux
Will generate symbols and memory mapping files for uftrace, allowing to
have an enhanced trace, instead of raw addresses.
It takes a collection of elf files, and automatically find all their
symbols, and generate an ordered memory map based on that.
This script uses the python (native) pyelftools module.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Acked-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250902075042.223990-9-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-25-alex.bennee@linaro.org>
diff --git a/contrib/plugins/uftrace_symbols.py b/contrib/plugins/uftrace_symbols.py
new file mode 100755
index 00000000000..b49e03203c8
--- /dev/null
+++ b/contrib/plugins/uftrace_symbols.py
@@ -0,0 +1,152 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# Create symbols and mapping files for uftrace.
+#
+# Copyright 2025 Linaro Ltd
+# Author: Pierrick Bouvier <pierrick.bouvier@linaro.org>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import argparse
+import elftools # pip install pyelftools
+import os
+
+from elftools.elf.elffile import ELFFile
+from elftools.elf.sections import SymbolTableSection
+
+def elf_func_symbols(elf):
+ symbol_tables = [(idx, s) for idx, s in enumerate(elf.iter_sections())
+ if isinstance(s, SymbolTableSection)]
+ symbols = []
+ for _, section in symbol_tables:
+ for _, symbol in enumerate(section.iter_symbols()):
+ if symbol_size(symbol) == 0:
+ continue
+ type = symbol['st_info']['type']
+ if type == 'STT_FUNC' or type == 'STT_NOTYPE':
+ symbols.append(symbol)
+ symbols.sort(key = lambda x: symbol_addr(x))
+ return symbols
+
+def symbol_size(symbol):
+ return symbol['st_size']
+
+def symbol_addr(symbol):
+ addr = symbol['st_value']
+ # clamp addr to 48 bits, like uftrace entries
+ return addr & 0xffffffffffff
+
+def symbol_name(symbol):
+ return symbol.name
+
+class BinaryFile:
+ def __init__(self, path, map_offset):
+ self.fullpath = os.path.realpath(path)
+ self.map_offset = map_offset
+ with open(path, 'rb') as f:
+ self.elf = ELFFile(f)
+ self.symbols = elf_func_symbols(self.elf)
+
+ def path(self):
+ return self.fullpath
+
+ def addr_start(self):
+ return self.map_offset
+
+ def addr_end(self):
+ last_sym = self.symbols[-1]
+ return symbol_addr(last_sym) + symbol_size(last_sym) + self.map_offset
+
+ def generate_symbol_file(self, prefix_symbols):
+ binary_name = os.path.basename(self.fullpath)
+ sym_file_path = f'./uftrace.data/{binary_name}.sym'
+ print(f'{sym_file_path} ({len(self.symbols)} symbols)')
+ with open(sym_file_path, 'w') as sym_file:
+ # print hexadecimal addresses on 48 bits
+ addrx = "0>12x"
+ for s in self.symbols:
+ addr = symbol_addr(s)
+ addr = f'{addr:{addrx}}'
+ size = f'{symbol_size(s):{addrx}}'
+ name = symbol_name(s)
+ if prefix_symbols:
+ name = f'{binary_name}:{name}'
+ print(addr, size, 'T', name, file=sym_file)
+
+def parse_parameter(p):
+ s = p.split(":")
+ path = s[0]
+ if len(s) == 1:
+ return path, 0
+ if len(s) > 2:
+ raise ValueError('only one offset can be set')
+ offset = s[1]
+ if not offset.startswith('0x'):
+ err = f'offset "{offset}" is not an hexadecimal constant. '
+ err += 'It should starts with "0x".'
+ raise ValueError(err)
+ offset = int(offset, 16)
+ return path, offset
+
+def is_from_user_mode(map_file_path):
+ if os.path.exists(map_file_path):
+ with open(map_file_path, 'r') as map_file:
+ if not map_file.readline().startswith('# map stack on'):
+ return True
+ return False
+
+def generate_map(binaries):
+ map_file_path = './uftrace.data/sid-0.map'
+
+ if is_from_user_mode(map_file_path):
+ print(f'do not overwrite {map_file_path} generated from qemu-user')
+ return
+
+ mappings = []
+
+ # print hexadecimal addresses on 48 bits
+ addrx = "0>12x"
+
+ mappings += ['# map stack on highest address possible, to prevent uftrace']
+ mappings += ['# from considering any kernel address']
+ mappings += ['ffffffffffff-ffffffffffff rw-p 00000000 00:00 0 [stack]']
+
+ for b in binaries:
+ m = f'{b.addr_start():{addrx}}-{b.addr_end():{addrx}}'
+ m += f' r--p 00000000 00:00 0 {b.path()}'
+ mappings.append(m)
+
+ with open(map_file_path, 'w') as map_file:
+ print('\n'.join(mappings), file=map_file)
+ print(f'{map_file_path}')
+ print('\n'.join(mappings))
+
+def main():
+ parser = argparse.ArgumentParser(description=
+ 'generate symbol files for uftrace')
+ parser.add_argument('elf_file', nargs='+',
+ help='path to an ELF file. '
+ 'Use /path/to/file:0xdeadbeef to add a mapping offset.')
+ parser.add_argument('--prefix-symbols',
+ help='prepend binary name to symbols',
+ action=argparse.BooleanOptionalAction)
+ args = parser.parse_args()
+
+ if not os.path.exists('./uftrace.data'):
+ os.mkdir('./uftrace.data')
+
+ binaries = []
+ for file in args.elf_file:
+ path, offset = parse_parameter(file)
+ b = BinaryFile(path, offset)
+ binaries.append(b)
+ binaries.sort(key = lambda b: b.addr_end());
+
+ for b in binaries:
+ b.generate_symbol_file(args.prefix_symbols)
+
+ generate_map(binaries)
+
+if __name__ == '__main__':
+ main()
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PULL 24/24] contrib/plugins/uftrace: add documentation
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (22 preceding siblings ...)
2025-09-26 13:17 ` [PULL 23/24] contrib/plugins/uftrace_symbols.py Alex Bennée
@ 2025-09-26 13:17 ` Alex Bennée
2025-09-27 15:42 ` [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Richard Henderson
24 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2025-09-26 13:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierrick Bouvier, Manos Pitsidianakis, Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
This documentation summarizes how to use the plugin, and present two
examples of the possibilities offered by it, in system and user mode.
As well, it explains how to rebuild and reproduce those examples.
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250902075042.223990-10-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-26-alex.bennee@linaro.org>
diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst
index 456d01d5b08..8a5e128f677 100644
--- a/docs/about/emulation.rst
+++ b/docs/about/emulation.rst
@@ -816,6 +816,205 @@ This plugin can limit the number of Instructions Per Second that are executed::
The lower the number the more accurate time will be, but the less efficient the plugin.
Defaults to ips/10
+Uftrace
+.......
+
+``contrib/plugins/uftrace.c``
+
+This plugin generates a binary trace compatible with
+`uftrace <https://github.com/namhyung/uftrace>`_.
+
+Plugin supports aarch64 and x64, and works in user and system mode, allowing to
+trace a system boot, which is not something possible usually.
+
+In user mode, the memory mapping is directly copied from ``/proc/self/maps`` at
+the end of execution. Uftrace should be able to retrieve symbols by itself,
+without any additional step.
+In system mode, the default memory mapping is empty, and you can generate
+one (and associated symbols) using ``contrib/plugins/uftrace_symbols.py``.
+Symbols must be present in ELF binaries.
+
+It tracks the call stack (based on frame pointer analysis). Thus, your program
+and its dependencies must be compiled using ``-fno-omit-frame-pointer
+-mno-omit-leaf-frame-pointer``. In 2024, `Ubuntu and Fedora enabled it by
+default again on x64
+<https://www.brendangregg.com/blog/2024-03-17/the-return-of-the-frame-pointers.html>`_.
+On aarch64, this is less of a problem, as they are usually part of the ABI,
+except for leaf functions. That's true for user space applications, but not
+necessarily for bare metal code. You can read this `section
+<uftrace_build_system_example>` to easily build a system with frame pointers.
+
+When tracing long scenarios (> 1 min), the generated trace can become very long,
+making it hard to extract data from it. In this case, a simple solution is to
+trace execution while generating a timestamped output log using
+``qemu-system-aarch64 ... | ts "%s"``. Then, ``uftrace --time-range=start~end``
+can be used to reduce trace for only this part of execution.
+
+Performance wise, overhead compared to normal tcg execution is around x5-x15.
+
+.. list-table:: Uftrace plugin arguments
+ :widths: 20 80
+ :header-rows: 1
+
+ * - Option
+ - Description
+ * - trace-privilege-level=[on|off]
+ - Generate separate traces for each privilege level (Exception Level +
+ Security State on aarch64, Rings on x64).
+
+.. list-table:: uftrace_symbols.py arguments
+ :widths: 20 80
+ :header-rows: 1
+
+ * - Option
+ - Description
+ * - elf_file [elf_file ...]
+ - path to an ELF file. Use /path/to/file:0xdeadbeef to add a mapping offset.
+ * - --prefix-symbols
+ - prepend binary name to symbols
+
+Example user trace
+++++++++++++++++++
+
+As an example, we can trace qemu itself running git::
+
+ $ ./build/qemu-aarch64 -plugin \
+ build/contrib/plugins/libuftrace.so \
+ ./build/qemu-aarch64 /usr/bin/git --help
+
+ # and generate a chrome trace directly
+ $ uftrace dump --chrome | gzip > ~/qemu_aarch64_git_help.json.gz
+
+For convenience, you can download this trace `qemu_aarch64_git_help.json.gz
+<https://fileserver.linaro.org/s/N8X8fnZ5yGRZLsT/download/qemu_aarch64_git_help.json.gz>`_.
+Download it and open this trace on https://ui.perfetto.dev/. You can zoom in/out
+using :kbd:`W`, :kbd:`A`, :kbd:`S`, :kbd:`D` keys.
+Some sequences taken from this trace:
+
+- Loading program and its interpreter
+
+.. image:: https://fileserver.linaro.org/s/fie8JgX76yyL5cq/preview
+ :height: 200px
+
+- open syscall
+
+.. image:: https://fileserver.linaro.org/s/rsXPTeZZPza4PcE/preview
+ :height: 200px
+
+- TB creation
+
+.. image:: https://fileserver.linaro.org/s/GXY6NKMw5EeRCew/preview
+ :height: 200px
+
+It's usually better to use ``uftrace record`` directly. However, tracing
+binaries through qemu-user can be convenient when you don't want to recompile
+them (``uftrace record`` requires instrumentation), as long as symbols are
+present.
+
+Example system trace
+++++++++++++++++++++
+
+A full trace example (chrome trace, from instructions below) generated from a
+system boot can be found `here
+<https://fileserver.linaro.org/s/WsemLboPEzo24nw/download/aarch64_boot.json.gz>`_.
+Download it and open this trace on https://ui.perfetto.dev/. You can see code
+executed for all privilege levels, and zoom in/out using
+:kbd:`W`, :kbd:`A`, :kbd:`S`, :kbd:`D` keys. You can find below some sequences
+taken from this trace:
+
+- Two first stages of boot sequence in Arm Trusted Firmware (EL3 and S-EL1)
+
+.. image:: https://fileserver.linaro.org/s/kkxBS552W7nYESX/preview
+ :height: 200px
+
+- U-boot initialization (until code relocation, after which we can't track it)
+
+.. image:: https://fileserver.linaro.org/s/LKTgsXNZFi5GFNC/preview
+ :height: 200px
+
+- Stat and open syscalls in kernel
+
+.. image:: https://fileserver.linaro.org/s/dXe4MfraKg2F476/preview
+ :height: 200px
+
+- Timer interrupt
+
+.. image:: https://fileserver.linaro.org/s/TM5yobYzJtP7P3C/preview
+ :height: 200px
+
+- Poweroff sequence (from kernel back to firmware, NS-EL2 to EL3)
+
+.. image:: https://fileserver.linaro.org/s/oR2PtyGKJrqnfRf/preview
+ :height: 200px
+
+Build and run system example
+++++++++++++++++++++++++++++
+
+.. _uftrace_build_system_example:
+
+Building a full system image with frame pointers is not trivial.
+
+We provide a `simple way <https://github.com/pbo-linaro/qemu-linux-stack>`_ to
+build an aarch64 system, combining Arm Trusted firmware, U-boot, Linux kernel
+and debian userland. It's based on containers (``podman`` only) and
+``qemu-user-static (binfmt)`` to make sure it's easily reproducible and does not depend
+on machine where you build it.
+
+You can follow the exact same instructions for a x64 system, combining edk2,
+Linux, and Ubuntu, simply by switching to
+`x86_64 <https://github.com/pbo-linaro/qemu-linux-stack/tree/x86_64>`_ branch.
+
+To build the system::
+
+ # Install dependencies
+ $ sudo apt install -y podman qemu-user-static
+
+ $ git clone https://github.com/pbo-linaro/qemu-linux-stack
+ $ cd qemu-linux-stack
+ $ ./build.sh
+
+ # system can be started using:
+ $ ./run.sh /path/to/qemu-system-aarch64
+
+To generate a uftrace for a system boot from that::
+
+ # run true and poweroff the system
+ $ env INIT=true ./run.sh path/to/qemu-system-aarch64 \
+ -plugin path/to/contrib/plugins/libuftrace.so,trace-privilege-level=on
+
+ # generate symbols and memory mapping
+ $ path/to/contrib/plugins/uftrace_symbols.py \
+ --prefix-symbols \
+ arm-trusted-firmware/build/qemu/debug/bl1/bl1.elf \
+ arm-trusted-firmware/build/qemu/debug/bl2/bl2.elf \
+ arm-trusted-firmware/build/qemu/debug/bl31/bl31.elf \
+ u-boot/u-boot:0x60000000 \
+ linux/vmlinux
+
+ # inspect trace with
+ $ uftrace replay
+
+Uftrace allows to filter the trace, and dump flamegraphs, or a chrome trace.
+This last one is very interesting to see visually the boot process::
+
+ $ uftrace dump --chrome > boot.json
+ # Open your browser, and load boot.json on https://ui.perfetto.dev/.
+
+Long visual chrome traces can't be easily opened, thus, it might be
+interesting to generate them around a particular point of execution::
+
+ # execute qemu and timestamp output log
+ $ env INIT=true ./run.sh path/to/qemu-system-aarch64 \
+ -plugin path/to/contrib/plugins/libuftrace.so,trace-privilege-level=on |&
+ ts "%s" | tee exec.log
+
+ $ cat exec.log | grep 'Run /init'
+ 1753122320 [ 11.834391] Run /init as init process
+ # init was launched at 1753122320
+
+ # generate trace around init execution (2 seconds):
+ $ uftrace dump --chrome --time-range=1753122320~1753122322 > init.json
+
Other emulation features
------------------------
--
2.47.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PULL 00/24] maintainer updates (scripts, semihosting, plugins)
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
` (23 preceding siblings ...)
2025-09-26 13:17 ` [PULL 24/24] contrib/plugins/uftrace: add documentation Alex Bennée
@ 2025-09-27 15:42 ` Richard Henderson
24 siblings, 0 replies; 26+ messages in thread
From: Richard Henderson @ 2025-09-27 15:42 UTC (permalink / raw)
To: qemu-devel
On 9/26/25 06:17, Alex Bennée wrote:
> The following changes since commit 95b9e0d2ade5d633fd13ffba96a54e87c65baf39:
>
> Merge tag 'for-upstream' ofhttps://gitlab.com/bonzini/qemu into staging (2025-09-24 12:04:18 -0700)
>
> are available in the Git repository at:
>
> https://gitlab.com/stsquad/qemu.git tags/pull-10.2-maintainer-260925-1
>
> for you to fetch changes up to 16b10fbf8bdb71ae20c7f74ab19c78d07c013ac7:
>
> contrib/plugins/uftrace: add documentation (2025-09-26 10:07:54 +0100)
>
> ----------------------------------------------------------------
> September maintainer updates (scripts, semihosting, plugins)
>
> - new gitlab-failure-analysis script
> - tweak checkpath to ignore license in removed lines
> - refactor semihosting to build once
> - add explicit assert to execlog for coverity
> - new uftrace plugin
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/10.2 as appropriate.
r~
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2025-09-27 15:43 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26 13:17 [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Alex Bennée
2025-09-26 13:17 ` [PULL 01/24] scripts/ci: add gitlab-failure-analysis script Alex Bennée
2025-09-26 13:17 ` [PULL 02/24] checkpatch: Ignore removed lines in license check Alex Bennée
2025-09-26 13:17 ` [PULL 03/24] semihosting/syscalls: compile once in system and per target for user mode Alex Bennée
2025-09-26 13:17 ` [PULL 04/24] semihosting/syscalls: replace uint64_t with vaddr where appropriate Alex Bennée
2025-09-26 13:17 ` [PULL 05/24] semihosting/guestfd: compile once for system/user Alex Bennée
2025-09-26 13:17 ` [PULL 06/24] semihosting/arm-compat-semi: change common_semi_sys_exit_extended Alex Bennée
2025-09-26 13:17 ` [PULL 07/24] target/riscv/common-semi-target: remove sizeof(target_ulong) Alex Bennée
2025-09-26 13:17 ` [PULL 08/24] target/{arm, riscv}/common-semi-target: eradicate target_ulong Alex Bennée
2025-09-26 13:17 ` [PULL 09/24] include/semihosting/common-semi: extract common_semi API Alex Bennée
2025-09-26 13:17 ` [PULL 10/24] semihosting/arm-compat-semi: eradicate sizeof(target_ulong) Alex Bennée
2025-09-26 13:17 ` [PULL 11/24] semihosting/arm-compat-semi: replace target_ulong Alex Bennée
2025-09-26 13:17 ` [PULL 12/24] semihosting/arm-compat-semi: eradicate target_long Alex Bennée
2025-09-26 13:17 ` [PULL 13/24] semihosting/arm-compat-semi: remove dependency on cpu.h Alex Bennée
2025-09-26 13:17 ` [PULL 14/24] semihosting/arm-compat-semi: compile once in system and per target for user mode Alex Bennée
2025-09-26 13:17 ` [PULL 15/24] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure Alex Bennée
2025-09-26 13:17 ` [PULL 16/24] contrib/plugins/uftrace: skeleton file Alex Bennée
2025-09-26 13:17 ` [PULL 17/24] contrib/plugins/uftrace: define cpu operations and implement aarch64 Alex Bennée
2025-09-26 13:17 ` [PULL 18/24] contrib/plugins/uftrace: track callstack Alex Bennée
2025-09-26 13:17 ` [PULL 19/24] contrib/plugins/uftrace: implement tracing Alex Bennée
2025-09-26 13:17 ` [PULL 20/24] contrib/plugins/uftrace: implement privilege level tracing Alex Bennée
2025-09-26 13:17 ` [PULL 21/24] contrib/plugins/uftrace: generate additional files for uftrace Alex Bennée
2025-09-26 13:17 ` [PULL 22/24] contrib/plugins/uftrace: implement x64 support Alex Bennée
2025-09-26 13:17 ` [PULL 23/24] contrib/plugins/uftrace_symbols.py Alex Bennée
2025-09-26 13:17 ` [PULL 24/24] contrib/plugins/uftrace: add documentation Alex Bennée
2025-09-27 15:42 ` [PULL 00/24] maintainer updates (scripts, semihosting, plugins) Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).