From nobody Tue Dec 16 11:45:11 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1686157056; cv=none; d=zohomail.com; s=zohoarc; b=MAELBOfgPCp5DV7b7CYVRqUap8C97czt8frVEfYJzlPRE9qGs2ba99twtNxWQJiw6wmgtX4Z6v/YQ1iqt3512wgODgtUgkKuzHpoigYZ6sFdSor//l+KgaU6fBQe+Y9ImYK0kGrvM3GDDi55XLtEVo31y2QpWBA2hzhVQeeWPA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686157056; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HWq+po+SDANNoW47p4QL7IvACAQogmmtb9TL/tLcPBU=; b=GB3GHRh2tlfo0h2lJiAUAisEN8CcFCNTVMK9BUMbRQQRKsvqMDCvXvrndUN24nGk6EWR8o75bnBArn5+gy7vGHb0Yr/+EsqJjJAMW+jU2pcceCWY3JJstT7psV6WdEuQXgLfkWkYCLmhVrmaXdq9gfY+j4AfPxZkFJ5Y5G81DnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686157056126973.73085090805; Wed, 7 Jun 2023 09:57:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6wSr-0008Ci-19; Wed, 07 Jun 2023 12:56:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6wSp-0008CL-I2 for qemu-devel@nongnu.org; Wed, 07 Jun 2023 12:56:51 -0400 Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6wSj-0001k1-J4 for qemu-devel@nongnu.org; Wed, 07 Jun 2023 12:56:51 -0400 Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-62884fa0e53so46043816d6.0 for ; Wed, 07 Jun 2023 09:56:45 -0700 (PDT) Received: from localhost.localdomain ([223.104.40.226]) by smtp.gmail.com with ESMTPSA id 30-20020a17090a001e00b00250bf8495b3sm1671808pja.39.2023.06.07.09.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 09:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686157004; x=1688749004; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HWq+po+SDANNoW47p4QL7IvACAQogmmtb9TL/tLcPBU=; b=aRuXFbH2BdDozt/mll+og22h3lnOt6mo6YSk37w83d+wBqhcaGXxi2+2vyShnDYmOb WEB6N4q001Qk4lEMZWhClNB7nxEkobTbL14mo+IipkZpiUvvLaH4vOWT6UXI1eQGCH3S SGlCA7clQARh5aU/kPPXrUhZ8W8OxaUVSNb1vZNOvsdoSbi0WybfW87g6FaZWtMCI8pG jZDvQl+p0Fq5oDNJSTqB9UCnAEyus61RT6IqIfdofQsNNLx9ErcGp53STBISJVnPsmKm BHDtOTjkLLEC8FkBYdrB8yDwV81XaPqHlUpy5nB55Bawz7II3gp4N6mbHrbVUQ+MMtGu YRqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686157004; x=1688749004; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HWq+po+SDANNoW47p4QL7IvACAQogmmtb9TL/tLcPBU=; b=JBNwP48H6SiN7b1vgcc9FJTeyF0bjwqSoc75XykP6dSb7kd5q7GTpFieL/8ZVVVY4d XgIYKPLQNuSQ0a+Oe687Xnufk+RLQD1cJdSb+fVxxs8A5IRA4PkjXf7u/0qG3TFex9eC tgrxleeXFL99jRlu5y5VCWN9AjZNDvuC18ALOkYZuhD36WGDNkJxnJu1kdcFCBa7m3Mi ukNB2mJW7KlnjgQOu5eiEgiDiaR/l5gbPrBEZfFUxU0XXL5OuhKQtIUHEsC1sJn+BCTH Edh4H4igON3iDZ4HEZfuxaDL7mn3bGzYDagliIEJGgI8GcmF2ZQp8+iJOmWx2uyoU+CS pcCQ== X-Gm-Message-State: AC+VfDytwrffccfGpdwAjg1GDpe30OX+yQZhcSoGm++AFb5SXZDZenSg j53eUvmqhSjq1SP4DeWZ2pL3HGAHlNLen1OG+PY= X-Google-Smtp-Source: ACHHUZ7ioIFEGFtetFPNwci8sUmDsD7HPjZF2OWqZe0XecHOiip7QbddPmLFrg34pUFo0KcBYpNZXw== X-Received: by 2002:a17:90b:e15:b0:256:bc6c:cb5b with SMTP id ge21-20020a17090b0e1500b00256bc6ccb5bmr1874346pjb.33.1686156551355; Wed, 07 Jun 2023 09:49:11 -0700 (PDT) From: Yeqi Fu To: alex.bennee@linaro.org Cc: richard.henderson@linaro.org, qemu-devel@nongnu.org, Yeqi Fu , Paolo Bonzini , Thomas Huth , Riku Voipio , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC v2 1/6] build: Add configure options for native calls Date: Thu, 8 Jun 2023 00:47:45 +0800 Message-Id: <20230607164750.829586-2-fufuyqqqqqq@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607164750.829586-1-fufuyqqqqqq@gmail.com> References: <20230607164750.829586-1-fufuyqqqqqq@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f29; envelope-from=fufuyqqqqqq@gmail.com; helo=mail-qv1-xf29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1686157057581100006 Content-Type: text/plain; charset="utf-8" Signed-off-by: Yeqi Fu --- Makefile | 4 +++ common-user/native/Makefile.include | 9 ++++++ common-user/native/Makefile.target | 22 +++++++++++++ configure | 50 +++++++++++++++++++++++++++++ docs/devel/build-system.rst | 4 +++ meson.build | 8 +++++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 4 +++ 8 files changed, 103 insertions(+) create mode 100644 common-user/native/Makefile.include create mode 100644 common-user/native/Makefile.target diff --git a/Makefile b/Makefile index 3c7d67142f..923da109bf 100644 --- a/Makefile +++ b/Makefile @@ -185,6 +185,10 @@ SUBDIR_MAKEFLAGS=3D$(if $(V),,--no-print-directory --q= uiet) =20 include $(SRC_PATH)/tests/Makefile.include =20 +ifeq ($(CONFIG_USER_NATIVE),y) + include $(SRC_PATH)/common-user/native/Makefile.include +endif + all: recurse-all =20 ROMS_RULES=3D$(foreach t, all clean distclean, $(addsuffix /$(t), $(ROMS))) diff --git a/common-user/native/Makefile.include b/common-user/native/Makef= ile.include new file mode 100644 index 0000000000..40d20bcd4c --- /dev/null +++ b/common-user/native/Makefile.include @@ -0,0 +1,9 @@ +.PHONY: build-native +build-native: $(NATIVE_TARGETS:%=3Dbuild-native-library-%) +$(NATIVE_TARGETS:%=3Dbuild-native-library-%): build-native-library-%: + $(call quiet-command, \ + $(MAKE) -C common-user/native/$* $(SUBDIR_MAKEFLAGS), \ + "BUILD","$* native library") +# endif + +all: build-native diff --git a/common-user/native/Makefile.target b/common-user/native/Makefi= le.target new file mode 100644 index 0000000000..1038367b37 --- /dev/null +++ b/common-user/native/Makefile.target @@ -0,0 +1,22 @@ +# -*- Mode: makefile -*- +# +# Library for native calls=20 +# + +all: +-include ../config-host.mak +-include config-target.mak + +CFLAGS+=3D-I$(SRC_PATH)/include -O1 -fPIC -shared -fno-stack-protector +LDFLAGS+=3D + +SRC =3D $(SRC_PATH)/common-user/native/libnative.c +TARGET =3D libnative.so + +all: $(TARGET) + +$(TARGET): $(SRC) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + +clean: + rm -f $(TARGET) diff --git a/configure b/configure index 2a556d14c9..cc94d10c98 100755 --- a/configure +++ b/configure @@ -275,6 +275,7 @@ use_containers=3D"yes" gdb_bin=3D$(command -v "gdb-multiarch" || command -v "gdb") gdb_arches=3D"" werror=3D"" +user_native_call=3D"disabled" =20 # Don't accept a target_list environment variable. unset target_list @@ -787,6 +788,10 @@ for opt do ;; --disable-vfio-user-server) vfio_user_server=3D"disabled" ;; + --enable-user-native-call) user_native_call=3D"enabled" + ;; + --disable-user-native-call) user_native_call=3D"disabled" + ;; # everything else has the same name in configure and meson --*) meson_option_parse "$opt" "$optarg" ;; @@ -1898,6 +1903,50 @@ if test "$tcg" =3D "enabled"; then fi ) =20 +# common-user/native configuration +native_flag_i386=3D"-DTARGET_I386" +native_flag_x86_64=3D"-DTARGET_X86_64" +native_flag_mips=3D"-DTARGET_MIPS" +native_flag_mips64=3D"-DTARGET_MIPS64" +native_flag_arm=3D"-DTARGET_ARM" +native_flag_aarch64=3D"-DTARGET_AARCH64" + +(config_host_mak=3Dcommon-user/native/config-host.mak +mkdir -p common-user/native +echo "# Automatically generated by configure - do not modify" > $config_ho= st_mak +echo "SRC_PATH=3D$source_path" >> $config_host_mak +echo "HOST_CC=3D$host_cc" >> $config_host_mak + +native_targets=3D +for target in $target_list; do + arch=3D${target%%-*} + + case $target in + *-linux-user|*-bsd-user) + if probe_target_compiler $target || test -n "$container_image"; then + mkdir -p "common-user/native/$target" + config_target_mak=3Dcommon-user/native/$target/config-target.mak + ln -sf "$source_path/common-user/native/Makefile.target" "common-u= ser/native/$target/Makefile" + echo "# Automatically generated by configure - do not modify" > "$= config_target_mak" + echo "TARGET_NAME=3D$arch" >> "$config_target_mak" + echo "TARGET=3D$target" >> "$config_target_mak" + eval "target_native_flag=3D\${native_flag_$target_arch}" + target_cflags=3D"$target_cflags $target_native_flag" + write_target_makefile "build-native-library-$target" >> "$config_t= arget_mak" + native_targets=3D"$native_targets $target" + fi + ;; + esac +done + +# if native enabled +if test "$user_native_call" =3D "enabled"; then + echo "CONFIG_USER_NATIVE=3Dy" >> config-host.mak + echo "NATIVE_TARGETS=3D$native_targets" >> config-host.mak + =20 +fi +) + if test "$skip_meson" =3D no; then cross=3D"config-meson.cross.new" meson_quote() { @@ -1980,6 +2029,7 @@ if test "$skip_meson" =3D no; then test "$smbd" !=3D '' && meson_option_add "-Dsmbd=3D$smbd" test "$tcg" !=3D enabled && meson_option_add "-Dtcg=3D$tcg" test "$vfio_user_server" !=3D auto && meson_option_add "-Dvfio_user_serv= er=3D$vfio_user_server" + test "$user_native_call" !=3D auto && meson_option_add "-Duser_native_ca= ll=3D$user_native_call" run_meson() { NINJA=3D$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" = "$source_path" } diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst index 551c5a5ac0..05cfa8a21a 100644 --- a/docs/devel/build-system.rst +++ b/docs/devel/build-system.rst @@ -494,6 +494,10 @@ Built by configure: Configuration variables used to build the firmware and TCG tests, including paths to cross compilation toolchains. =20 +``common-user/native/config-host.mak``, ``common-user/native/*/config-targ= et.mak`` + Configuration variables used to build the native call libraries + including paths to cross compilation toolchains. + ``pyvenv`` =20 A Python virtual environment that is used for all Python code running diff --git a/meson.build b/meson.build index 0a5cdefd4d..04e99a4f25 100644 --- a/meson.build +++ b/meson.build @@ -2012,6 +2012,11 @@ have_virtfs_proxy_helper =3D get_option('virtfs_prox= y_helper') \ .require(libcap_ng.found(), error_message: 'the virtfs proxy helper re= quires libcap-ng') \ .allowed() =20 +have_user_native_call =3D get_option('user_native_call') \ + .require(have_user, error_message: 'user_native_call requires user') \ + .require(targetos =3D=3D 'linux', error_message: 'user_native_call req= uires Linux') \ + .allowed() + if get_option('block_drv_ro_whitelist') =3D=3D '' config_host_data.set('CONFIG_BDRV_RO_WHITELIST', '') else @@ -2853,6 +2858,9 @@ foreach target : target_dirs error('Target @0@ is only available on a Linux host'.format(target)) endif config_target +=3D { 'CONFIG_LINUX_USER': 'y' } + if have_user_native_call + config_target +=3D { 'CONFIG_USER_NATIVE_CALL': 'y' } + endif elif target.endswith('bsd-user') if 'CONFIG_BSD' not in config_host if default_targets diff --git a/meson_options.txt b/meson_options.txt index 90237389e2..57035e02f5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -352,3 +352,5 @@ option('slirp_smbd', type : 'feature', value : 'auto', =20 option('hexagon_idef_parser', type : 'boolean', value : true, description: 'use idef-parser to automatically generate TCG code fo= r the Hexagon frontend') +option('user_native_call', type : 'feature', value : 'disabled', + description: 'native bypass for library calls in user mode only') diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 5714fd93d9..9eda1898d6 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -173,6 +173,8 @@ meson_options_help() { printf "%s\n" ' tpm TPM support' printf "%s\n" ' u2f U2F emulation support' printf "%s\n" ' usb-redir libusbredir support' + printf "%s\n" ' user-native-call' + printf "%s\n" ' native bypass for library calls in user= mode only' printf "%s\n" ' vde vde network backend support' printf "%s\n" ' vdi vdi image format support' printf "%s\n" ' vduse-blk-export' @@ -472,6 +474,8 @@ _meson_option_parse() { --disable-u2f) printf "%s" -Du2f=3Ddisabled ;; --enable-usb-redir) printf "%s" -Dusb_redir=3Denabled ;; --disable-usb-redir) printf "%s" -Dusb_redir=3Ddisabled ;; + --enable-user-native-call) printf "%s" -Duser_native_call=3Denabled ;; + --disable-user-native-call) printf "%s" -Duser_native_call=3Ddisabled = ;; --enable-vde) printf "%s" -Dvde=3Denabled ;; --disable-vde) printf "%s" -Dvde=3Ddisabled ;; --enable-vdi) printf "%s" -Dvdi=3Denabled ;; --=20 2.34.1