From: "Alex Bennée" <alex.bennee@linaro.org>
To: Yeqi Fu <fufuyqqqqqq@gmail.com>
Cc: richard.henderson@linaro.org, qemu-devel@nongnu.org,
Laurent Vivier <laurent@vivier.eu>
Subject: Re: [RFC v4 04/11] linux-user: Implement native-bypass option support
Date: Wed, 09 Aug 2023 16:47:26 +0100 [thread overview]
Message-ID: <87h6p843ko.fsf@linaro.org> (raw)
In-Reply-To: <20230808141739.3110740-5-fufuyqqqqqq@gmail.com>
Yeqi Fu <fufuyqqqqqq@gmail.com> writes:
> This commit implements the -native-bypass support in linux-user. The
> native_calls_enabled() function can be true only when the
> '-native-bypass' option is given.
>
> Signed-off-by: Yeqi Fu <fufuyqqqqqq@gmail.com>
> ---
> include/native/native.h | 9 +++++++++
> linux-user/main.c | 38 ++++++++++++++++++++++++++++++++++++++
> 2 files changed, 47 insertions(+)
> create mode 100644 include/native/native.h
>
> diff --git a/include/native/native.h b/include/native/native.h
> new file mode 100644
> index 0000000000..62951fafb1
> --- /dev/null
> +++ b/include/native/native.h
> @@ -0,0 +1,9 @@
> +/*
> + * Check if the native bypass feature is enabled.
> + */
> +#if defined(CONFIG_USER_ONLY) && defined(CONFIG_NATIVE_CALL)
> +extern char *native_lib_path;
> +#define native_bypass_enabled() native_lib_path ? true : false
> +#else
> +#define native_bypass_enabled() false
> +#endif
> diff --git a/linux-user/main.c b/linux-user/main.c
> index dba67ffa36..86ea0191f7 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -60,6 +60,11 @@
> #include "semihosting/semihost.h"
> #endif
>
> +#if defined(CONFIG_NATIVE_CALL)
> +#include "native/native.h"
> +char *native_lib_path;
> +#endif
> +
> #ifndef AT_FLAGS_PRESERVE_ARGV0
> #define AT_FLAGS_PRESERVE_ARGV0_BIT 0
> #define AT_FLAGS_PRESERVE_ARGV0 (1 << AT_FLAGS_PRESERVE_ARGV0_BIT)
> @@ -293,6 +298,17 @@ static void handle_arg_set_env(const char *arg)
> free(r);
> }
>
> +#if defined(CONFIG_NATIVE_CALL)
> +static void handle_arg_native_bypass(const char *arg)
> +{
> + if (access(arg, F_OK) != 0) {
> + fprintf(stderr, "native library %s does not exist\n", arg);
> + exit(EXIT_FAILURE);
> + }
> + native_lib_path = strdup(arg);
Although we never free this the coding style states:
Because of the memory management rules, you must use g_strdup/g_strndup
instead of plain strdup/strndup.
We do still have a few legacy strdup's to eliminate from the code base
though.
> +}
> +#endif
> +
> static void handle_arg_unset_env(const char *arg)
> {
> char *r, *p, *token;
> @@ -522,6 +538,10 @@ static const struct qemu_argument arg_table[] = {
> "", "Generate a /tmp/perf-${pid}.map file for perf"},
> {"jitdump", "QEMU_JITDUMP", false, handle_arg_jitdump,
> "", "Generate a jit-${pid}.dump file for perf"},
> +#if defined(CONFIG_NATIVE_CALL)
> + {"native-bypass", "QEMU_NATIVE_BYPASS", true, handle_arg_native_bypass,
> + "", "native bypass for library calls in user mode only."},
> +#endif
You can drop " in user mode only" because this help text will only show
up on linux-user binaries with support for native bypass.
Otherwise:
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2023-08-09 15:51 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 14:17 [RFC v4 00/11] Native Library Calls Yeqi Fu
2023-08-08 14:17 ` [RFC v4 01/11] build: Implement logic for sharing cross-building config files Yeqi Fu
2023-08-09 12:24 ` Manos Pitsidianakis
2023-08-09 14:42 ` Alex Bennée
2023-08-09 15:23 ` Alex Bennée
2023-08-10 8:41 ` Alex Bennée
2023-08-08 14:17 ` [RFC v4 02/11] build: Implement libnative library and the build machinery for libnative Yeqi Fu
2023-08-09 15:18 ` Alex Bennée
2023-08-09 16:10 ` Richard Henderson
2023-08-08 14:17 ` [RFC v4 03/11] linux-user: Implement envlist_appendenv and add tests for envlist Yeqi Fu
2023-08-09 15:27 ` Alex Bennée
2023-08-09 15:44 ` Richard Henderson
2023-08-09 16:06 ` Richard Henderson
2023-08-08 14:17 ` [RFC v4 04/11] linux-user: Implement native-bypass option support Yeqi Fu
2023-08-09 15:42 ` Richard Henderson
2023-08-09 15:47 ` Alex Bennée [this message]
2023-08-08 14:17 ` [RFC v4 05/11] linux-user/elfload: Add support for parsing symbols of native libraries Yeqi Fu
2023-08-09 16:14 ` Richard Henderson
2023-08-09 17:04 ` Alex Bennée
2023-08-08 14:17 ` [RFC v4 06/11] tcg: Add tcg opcodes and helpers for native library calls Yeqi Fu
2023-08-09 16:41 ` Alex Bennée
2023-08-08 14:17 ` [RFC v4 07/11] target/i386: Add support " Yeqi Fu
2023-08-09 16:44 ` Richard Henderson
2023-08-08 14:17 ` [RFC v4 08/11] target/mips: " Yeqi Fu
2023-08-08 14:17 ` [RFC v4 09/11] target/arm: " Yeqi Fu
2023-08-08 14:17 ` [RFC v4 10/11] tests/tcg/multiarch: Add nativecall.c test Yeqi Fu
2023-08-09 8:42 ` Alex Bennée
2023-08-09 17:01 ` Alex Bennée
2023-08-09 17:12 ` Alex Bennée
2023-08-08 14:17 ` [RFC v4 11/11] docs/user: Add doc for native library calls Yeqi Fu
2023-08-09 12:51 ` Manos Pitsidianakis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6p843ko.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=fufuyqqqqqq@gmail.com \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).