mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
plugins/api: split out binary path/start/end/entry code
To move the main api.c to a single build compilation object we need to start splitting out user and system specific code. As we need to grob around host headers we move these particular helpers into the *-user mode directories. The binary/start/end/entry helpers are all NOPs for system mode. While using the plugin-api.c.inc trick means we build for both linux-user and bsd-user the BSD user-mode command line is still missing -plugin. This can be enabled once we have reliable check-tcg tests working for the BSDs. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20250304222439.2035603-27-alex.bennee@linaro.org>
This commit is contained in:
parent
8c15f6e435
commit
903e870f24
8 changed files with 115 additions and 44 deletions
|
@ -13,6 +13,7 @@ bsd_user_ss.add(files(
|
||||||
'elfload.c',
|
'elfload.c',
|
||||||
'main.c',
|
'main.c',
|
||||||
'mmap.c',
|
'mmap.c',
|
||||||
|
'plugin-api.c',
|
||||||
'signal.c',
|
'signal.c',
|
||||||
'strace.c',
|
'strace.c',
|
||||||
'uaccess.c',
|
'uaccess.c',
|
||||||
|
|
15
bsd-user/plugin-api.c
Normal file
15
bsd-user/plugin-api.c
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* QEMU Plugin API - bsd-user-mode only implementations
|
||||||
|
*
|
||||||
|
* Common user-mode only APIs are in plugins/api-user. These helpers
|
||||||
|
* are only specific to bsd-user.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017, Emilio G. Cota <cota@braap.org>
|
||||||
|
* Copyright (C) 2019-2025, Linaro
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu.h"
|
||||||
|
#include "common-user/plugin-api.c.inc"
|
43
common-user/plugin-api.c.inc
Normal file
43
common-user/plugin-api.c.inc
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* QEMU Plugin API - *-user-mode only implementations
|
||||||
|
*
|
||||||
|
* Common user-mode only APIs are in plugins/api-user. These helpers
|
||||||
|
* are only specific to the *-user frontends.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017, Emilio G. Cota <cota@braap.org>
|
||||||
|
* Copyright (C) 2019-2025, Linaro
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu/main-loop.h"
|
||||||
|
#include "qemu/plugin.h"
|
||||||
|
#include "qemu.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Binary path, start and end locations. Host specific due to TaskState.
|
||||||
|
*/
|
||||||
|
const char *qemu_plugin_path_to_binary(void)
|
||||||
|
{
|
||||||
|
TaskState *ts = get_task_state(current_cpu);
|
||||||
|
return g_strdup(ts->bprm->filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t qemu_plugin_start_code(void)
|
||||||
|
{
|
||||||
|
TaskState *ts = get_task_state(current_cpu);
|
||||||
|
return ts->info->start_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t qemu_plugin_end_code(void)
|
||||||
|
{
|
||||||
|
TaskState *ts = get_task_state(current_cpu);
|
||||||
|
return ts->info->end_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t qemu_plugin_entry_code(void)
|
||||||
|
{
|
||||||
|
TaskState *ts = get_task_state(current_cpu);
|
||||||
|
return ts->info->entry;
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ linux_user_ss.add(libdw)
|
||||||
linux_user_ss.add(when: 'TARGET_HAS_BFLT', if_true: files('flatload.c'))
|
linux_user_ss.add(when: 'TARGET_HAS_BFLT', if_true: files('flatload.c'))
|
||||||
linux_user_ss.add(when: 'TARGET_I386', if_true: files('vm86.c'))
|
linux_user_ss.add(when: 'TARGET_I386', if_true: files('vm86.c'))
|
||||||
linux_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', if_true: files('semihost.c'))
|
linux_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', if_true: files('semihost.c'))
|
||||||
|
linux_user_ss.add(when: 'CONFIG_TCG_PLUGINS', if_true: files('plugin-api.c'))
|
||||||
|
|
||||||
syscall_nr_generators = {}
|
syscall_nr_generators = {}
|
||||||
|
|
||||||
|
|
15
linux-user/plugin-api.c
Normal file
15
linux-user/plugin-api.c
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* QEMU Plugin API - linux-user-mode only implementations
|
||||||
|
*
|
||||||
|
* Common user-mode only APIs are in plugins/api-user. These helpers
|
||||||
|
* are only specific to linux-user.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017, Emilio G. Cota <cota@braap.org>
|
||||||
|
* Copyright (C) 2019-2025, Linaro
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu.h"
|
||||||
|
#include "common-user/plugin-api.c.inc"
|
39
plugins/api-system.c
Normal file
39
plugins/api-system.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* QEMU Plugin API - System specific implementations
|
||||||
|
*
|
||||||
|
* This provides the APIs that have a specific system implementation
|
||||||
|
* or are only relevant to system-mode.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017, Emilio G. Cota <cota@braap.org>
|
||||||
|
* Copyright (C) 2019-2025, Linaro
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu/main-loop.h"
|
||||||
|
#include "qemu/plugin.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In system mode we cannot trace the binary being executed so the
|
||||||
|
* helpers all return NULL/0.
|
||||||
|
*/
|
||||||
|
const char *qemu_plugin_path_to_binary(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t qemu_plugin_start_code(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t qemu_plugin_end_code(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t qemu_plugin_entry_code(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -471,49 +471,6 @@ bool qemu_plugin_bool_parse(const char *name, const char *value, bool *ret)
|
||||||
return name && value && qapi_bool_parse(name, value, ret, NULL);
|
return name && value && qapi_bool_parse(name, value, ret, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Binary path, start and end locations
|
|
||||||
*/
|
|
||||||
const char *qemu_plugin_path_to_binary(void)
|
|
||||||
{
|
|
||||||
char *path = NULL;
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
|
||||||
TaskState *ts = get_task_state(current_cpu);
|
|
||||||
path = g_strdup(ts->bprm->filename);
|
|
||||||
#endif
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t qemu_plugin_start_code(void)
|
|
||||||
{
|
|
||||||
uint64_t start = 0;
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
|
||||||
TaskState *ts = get_task_state(current_cpu);
|
|
||||||
start = ts->info->start_code;
|
|
||||||
#endif
|
|
||||||
return start;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t qemu_plugin_end_code(void)
|
|
||||||
{
|
|
||||||
uint64_t end = 0;
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
|
||||||
TaskState *ts = get_task_state(current_cpu);
|
|
||||||
end = ts->info->end_code;
|
|
||||||
#endif
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t qemu_plugin_entry_code(void)
|
|
||||||
{
|
|
||||||
uint64_t entry = 0;
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
|
||||||
TaskState *ts = get_task_state(current_cpu);
|
|
||||||
entry = ts->info->entry;
|
|
||||||
#endif
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create register handles.
|
* Create register handles.
|
||||||
*
|
*
|
||||||
|
|
|
@ -59,7 +59,7 @@ if host_os == 'windows'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
user_ss.add(files('user.c'))
|
user_ss.add(files('user.c'))
|
||||||
system_ss.add(files('system.c'))
|
system_ss.add(files('system.c', 'api-system.c'))
|
||||||
|
|
||||||
common_ss.add(files('loader.c'))
|
common_ss.add(files('loader.c'))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue