From patchwork Tue Aug 27 13:39:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Yikai X-Patchwork-Id: 13779587 X-Patchwork-Delegate: bpf@iogearbox.net Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2087.outbound.protection.outlook.com [40.107.255.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFA431C0DEC; Tue, 27 Aug 2024 13:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724766033; cv=fail; b=bkAoKzSsGqiGJNzU5ek17VLDjqN5VTwSf4AktT9aDA7j4FSh5zPYcVzZVFuhblZK68p47oSvqnw2PP/ehRpJ3rB0KJOZX4aSU6CXpM5ipo1CWhBvXjZvSYhLkSfRLHgCcQyWKzLyUqhQA6yP9pz84DrGV824yJY0PI7D0O+V9ag= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724766033; c=relaxed/simple; bh=nXfbON76y8qaKlAOQIBOoPq+3UkB6dbrg4rJdq5SCVE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EGDreIda6sG6EMj/rs0Yp64LIDlXbzK5xjOeOeUiRQoNRLh7Uz1U981qtpOTID0pmx182jVuc+geeZVIL3GhERBbZFa4HKFaJoOrBWqVNFYmuRXpOz0K34WfUCvanOyZFefUhfX8AJJaafIEHnn9zI2750HYtGVcbJXPAJaz3Es= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=AyFtduH7; arc=fail smtp.client-ip=40.107.255.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="AyFtduH7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=boZBeOZRyiCq1zqnPUlrO333U81wHGakbw1K0cgO4K+5cDrPRPFUOkeaNdktyN45SXGtHKL+3nmNzG1gyfJGL3dP8NUAYpAwC/S1FOIFjhnx0SCjO+VMm96Z9WG34gEx43Zy0PAplPgdbb3DtSE/l9w9vHuJ9XcAYWT2c29MK67eAt9MKmlkkh+4VCvAw36d2NSDsBQLRfj+OVj3GYg1N6V6Z0ADBX2vttW67LUVyoH28Lc+Z0VgFkQ287fJ5BbLk4RZznweuiGR96Ay17fm9oWS5lTGI6Ex+1GnohHPI5fA4A6OlDF4vYJsGsDe3qIzfH5RMzu+Prh2PPNf+BDFRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=woPyhG9zeCpJnOQ2526b+B6SPQo5v7tKR8fEUkUxouY=; b=FY3Zf4rx6XwxZesQlSrWobuPmEVWsCAL6Fqz2ck6AIyzZgEnmh1tE/pzir6wrl5jGXjPfahG9l8ImBY68RGFSa2QpvncwpErn+lNyXYRQI7GbHQFhrrqhmfRxtcRm+UEGOpPr+orUz2aMfBvcPybD5G7TP/wiz21bBZaCMMOn5HaCYobBh3xm99pigLpwJXYyY1IotpR1q0HFag7Wja55fGxsCD3zcqxVuOwH/h1sBgDTeuMlpQgysPGcKO8sxZRmznNqjmGefQ7ZaW4FNgjc3T1/WNcGJNHILzgIfZQOZ2uj3tRbdL0nKcJY/TKTMNjk0m/XFSgUNsg6fAxMih15w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=woPyhG9zeCpJnOQ2526b+B6SPQo5v7tKR8fEUkUxouY=; b=AyFtduH7Cy/Mt44RkstKNplV7LtFeU2LuMhE9NCUWU9kSy1PtVvuijicZrlfUT4SzBH/65NyDb2nZFw5e8jWxmNhcK7o9Kl0cbT46STJ3dgqRRZVAjZbeuSCuBRFY2l74CMtFyUR7ivvqFZoL2yt7p/1LP7UriYm0AICQ9ZL3Zm4tTSwSrpPpEXZSJc8IqpKyeihn/Ejl0ed6NbJ3ExEyZFen00aK5eMpNJcy3Dpa5xdyKXVXHneuLie73hMqVgmXqf3urv3fjv2sb2+mDS24YeFB5dB2eELlM50vaz2sW/3zb7PGDNTPdccWV3nDotMiN1gZJCIT5Q1QvFe37TxYQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEYPR06MB5913.apcprd06.prod.outlook.com (2603:1096:101:da::16) by OSQPR06MB7153.apcprd06.prod.outlook.com (2603:1096:604:298::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Tue, 27 Aug 2024 13:40:26 +0000 Received: from SEYPR06MB5913.apcprd06.prod.outlook.com ([fe80::f049:a716:8200:c4a1]) by SEYPR06MB5913.apcprd06.prod.outlook.com ([fe80::f049:a716:8200:c4a1%4]) with mapi id 15.20.7897.021; Tue, 27 Aug 2024 13:40:26 +0000 From: Lin Yikai To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Nick Terrell , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, yikai.lin@vivo.com Subject: [PATCH bpf-next v1 1/2] selftests/bpf: Update "vmtest.sh" for cross-compile arm64 on x86_64 host. Date: Tue, 27 Aug 2024 21:39:58 +0800 Message-Id: <20240827133959.1269178-2-yikai.lin@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827133959.1269178-1-yikai.lin@vivo.com> References: <20240827133959.1269178-1-yikai.lin@vivo.com> X-ClientProxiedBy: SG2PR01CA0141.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::21) To SEYPR06MB5913.apcprd06.prod.outlook.com (2603:1096:101:da::16) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEYPR06MB5913:EE_|OSQPR06MB7153:EE_ X-MS-Office365-Filtering-Correlation-Id: 75e242fc-9798-41da-98ce-08dcc69dceb5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: lyBmDDofcy3uS94w5/wUM0M12JCYOsXlHHktst7fLH1wnXgu3kAv807Zy2N6YPIiMh0pPFtDcW1PTJ62cNXTCo0nvQsC3Ky64nNp4qOSRidLyF+C14PxLDzGvjy19VAenW6U4BJMcRxQGopxni7DLH8/0gyxzPGoG03PZrf9sEukYwjNfqDOsQ4HRJKfyWr7gjxsDVX4u/NLeiCXUqUdEcl+4XRrGdoZPGtGYR6XKtXhs01Qupnd8+1Guxdmh4lVGdpDxvoZys781E59f7A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WKUCLZlHdhZf0lzS//EDnEVPTl4E1ELAV+x2SBJLlp9FWWk1P X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEYPR06MB5913.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: utaaIGpUnzyKdQgCmsoOJEaBTHfdMSEdHrmn6VPsNFTt9LW6Rk7dRgsai7xObYWtN8/ejo3NNCuk1QpWSlBaIunMwGQ16mVxISdjPrmUy6hqX/J0P1D/AthwZuB8/4Kcy9axBUx0BytogYZpzFfrsYiQcGfgu34CHXO2soFVXRcYQe3sLYi3vpKcrcmPSlL1IPDImztdABc3V25BMY9AIhVeJMi4ap4HZNOxh9cjePbXH7eWCBuzzwWJ5z5DKISQYA12n6wRUnHSf4A5HFz4cd5q+uyJCXPgGO46iqQ/UAg0AHqXoXt8nMn52IIbH/XgWFAQh7EKMr97/OKhatE2vIsb2t6CLmfaw3RKezkByOGzWsFTDMZ/NMwur/LSXslklgGbtroWBg6VMo18ZM0yrFXiTY+WNpMSH3xyOD6o8X00HrXU82XEnY9vuqqhSeTfW5V+mlGweRwhZmvPcVB1A7mfHqZYgIs+ewQKgIYLXWEREIC05Z5HVfir3G/czFQK6CjTkvH/UCoV3KEbCg0hilW2ZIpRcjiWRowxbK1omwpKDHh6m8MkNbI73kpmodXKdNsJtKlH+giInxdRRZf4IpO/+ctywUA4R1jAKSANgnWIchDMZzkjsS42wF30wG5bpO0njKAxTuUTzsWDnK7eAVsHW+AhQCHQZ8FiKjXZBHZWKf5GLNaFL2IZXmI1LmGGwqTtm5+XoYMFGb/um1p2EqM4mypZHpz80Ibto+86rAOxbyA5+oBo/n8WFTpa7gffDoJLwqV73S1IkgdFoq0wYpigwdAzjB98R6C7uMvDXVc5ETKTOtVfl3sXKhCGzvNN1UTgYtj7Z6y1Wz76P/p6NH9V3sOo4C1vLK3rp5pxs6dfxsKGUdCdGh1kXSsftUU5AjhdZri28P2CpsYoq5omfD7EWxwuc2gw40SS1jPmFvfn0JrOQ9DMbUQoQpONLCsCfq6WF2nyIBIj4LXBAZqBey+MNdDsM3YVBCSwpoFOKLx3oGmmNybZIPtUBfS64QUQ6xZBp0YbEF52rVYXfbrxEI1Yc6pkxd/UvXe97tP/3aw9HpB/Gb7iyNmVhibDkBSpLq/a0Z7MCV3oSNhqa2hWG5yxQ2H1nGEa4puBzbBSaBc+C83EV7lhpiayNcVTXY7w+uPP8vY5f5Vlv64FbGFhEWolVh3xNL+C2f2Y9znOYAORl6E5qiEPinywpA5rhGUEHjKxUIQpQbAx9Hh1nn2db/vmEy7XXWD2Ct3MLlBKBbywh2exAHrYRL6Uu2IpIXKkgpT2BO3ZqrTJeHB2HGAb7LORP8W5vJ+CzQ4MnXybjcDuT1W0cd/5PsgYrJgJtGFs/77EZHmIoW/rGxY7ocsR+jzaNd9veOmE2eShJqmQobiMCWUxpRzz8hbGm0bKosio7YxTRJ075miNGTvCmkTp8cPIQVrIvmZ947oVusf4RdgYgfXU1EEcsLhWtEl6Vv7EXFy0hZuXZuRp6wPOxVLwby7I0mtR//RQMUZ09fhU0CU4MeZiSNpNKMEFMLkowlN6t+e78psYS3TO4BPKCNjqslqeu7m6rp8BlVxKQbceyKgJZv04AcklycZ9wIoX7CLY X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75e242fc-9798-41da-98ce-08dcc69dceb5 X-MS-Exchange-CrossTenant-AuthSource: SEYPR06MB5913.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 13:40:26.1533 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DgkAcrb6wrx/y+NHYBwC4aTDOq7ejxndjCpGHX5y4MXQGenUbts0bfN7xFbh/luzGNtTU+p6yi549bdibwfOSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSQPR06MB7153 X-Patchwork-Delegate: bpf@iogearbox.net Identify "$CROSS_COMPILE" to enable vm_test for cross-compile situation. Additionally, use "-cpu cortex-a57" flag to accommodate the majority of QEMU CPU lists, avoiding using "-cpu host," which can cause qemu_system_aarch64 start failure on x86_64 host. Signed-off-by: Lin Yikai --- tools/testing/selftests/bpf/README.rst | 12 ++++++++- tools/testing/selftests/bpf/vmtest.sh | 37 +++++++++++++++++++++----- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/README.rst b/tools/testing/selftests/bpf/README.rst index 9b974e425af3..c8e6eb8f299d 100644 --- a/tools/testing/selftests/bpf/README.rst +++ b/tools/testing/selftests/bpf/README.rst @@ -79,13 +79,23 @@ In case of linker errors when running selftests, try using static linking: $ LDLIBS=-static PKG_CONFIG='pkg-config --static' vmtest.sh +If you want to make corss-compile, such as compile arm64 on x86_64, you can try: + +.. code-block:: console + + $ make headers_install + $ export PATH=$PATH:{The corss-compile's path}/bin + $ export ARCH=arm64 + $ export CROSS_COMPILE=aarch64-linux-gnu- + $ LDLIBS=-static vmtest.sh + .. note:: Some distros may not support static linking. .. note:: The script uses pahole and clang based on host environment setting. If you want to change pahole and llvm, you can change `PATH` environment variable in the beginning of script. -.. note:: The script currently only supports x86_64 and s390x architectures. +.. note:: The script currently only supports x86_64, s390x and arm64 architectures. Additional information about selftest failures are documented here. diff --git a/tools/testing/selftests/bpf/vmtest.sh b/tools/testing/selftests/bpf/vmtest.sh index 65d14f3bbe30..c7461ed496ab 100755 --- a/tools/testing/selftests/bpf/vmtest.sh +++ b/tools/testing/selftests/bpf/vmtest.sh @@ -4,11 +4,11 @@ set -u set -e -# This script currently only works for x86_64 and s390x, as +# This script currently only works for x86_64, s390x and arm64, as # it is based on the VM image used by the BPF CI, which is # available only for these architectures. -ARCH="$(uname -m)" -case "${ARCH}" in +HOST_ARCH="$(uname -m)" +case "${HOST_ARCH}" in s390x) QEMU_BINARY=qemu-system-s390x QEMU_CONSOLE="ttyS1" @@ -32,13 +32,38 @@ aarch64) exit 1 ;; esac + +# process CROSS_COMPILE setting to enable cross-compilation +process_cross_compile() { + if [ -z "${CROSS_COMPILE+x}" ]; then + return + fi + case "$1" in + x86_64) + #Cross-compiling for arm64 on an x86_64 host + if [[ $CROSS_COMPILE == *aarch64* ]]; then + VM_ARCH=aarch64 + QEMU_CONSOLE="ttyAMA0,115200" + QEMU_BINARY=qemu-system-aarch64 + QEMU_FLAGS=(-M virt,gic-version=3 -cpu cortex-a57 -smp 8) + BZIMAGE="arch/arm64/boot/Image" + echo "Setting VM_ARCH from $HOST_ARCH to $VM_ARCH as specified by CROSS_COMPILE" + fi + ;; + esac +} + +VM_ARCH=${HOST_ARCH} +process_cross_compile "$VM_ARCH" + + DEFAULT_COMMAND="./test_progs" MOUNT_DIR="mnt" ROOTFS_IMAGE="root.img" OUTPUT_DIR="$HOME/.bpf_selftests" KCONFIG_REL_PATHS=("tools/testing/selftests/bpf/config" "tools/testing/selftests/bpf/config.vm" - "tools/testing/selftests/bpf/config.${ARCH}") + "tools/testing/selftests/bpf/config.${VM_ARCH}") INDEX_URL="https://raw.githubusercontent.com/libbpf/ci/master/INDEX" NUM_COMPILE_JOBS="$(nproc)" LOG_FILE_BASE="$(date +"bpf_selftests.%Y-%m-%d_%H-%M-%S")" @@ -109,7 +134,7 @@ newest_rootfs_version() { { for file in "${!URLS[@]}"; do - if [[ $file =~ ^"${ARCH}"/libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then + if [[ $file =~ ^"${VM_ARCH}"/libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then echo "${BASH_REMATCH[1]}" fi done @@ -126,7 +151,7 @@ download_rootfs() exit 1 fi - download "${ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | + download "${VM_ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | zstd -d | sudo tar -C "$dir" -x } From patchwork Tue Aug 27 13:39:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Yikai X-Patchwork-Id: 13779588 X-Patchwork-Delegate: bpf@iogearbox.net Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2087.outbound.protection.outlook.com [40.107.255.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB1091C2DBB; Tue, 27 Aug 2024 13:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724766035; cv=fail; b=fjVXDoL24Qv9mOfVUWlyiEZLFddU0dZItyVZyGdcbezsSW7JudIzjk45SWgxs6Orp8b/oJEP/yEH7x9uxnHM7ZF+AGJGYtCkcPdGfz644y9CIZvuI8bUcLCl04RavLCLNKVKrwaKmtA+LLw6hJOPgr34bY4/wtDeEKWCREJWnxY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724766035; c=relaxed/simple; bh=EonApa4sGNEO0js95RLioa48C6VTlbIq67fUhOD3Obo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rh4bfXj5mH2tKQHdhR1uG1SKTFk4QCzars3mhMG8nrr7EtPC3chByIU1ha26aaW1YCuN4n/UeU6iekXed2YcXina5IqtmP3HcfZiv4XEfmOPyWdLqQdJIAJmPghB4eJLGIV87PDoe3vDIeZVufqD+3BCgnklTATjs91k3mrRhdA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=c7lZYjKC; arc=fail smtp.client-ip=40.107.255.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="c7lZYjKC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mJc1ECqmL4WA9Sqg9/uGmewWpTAD3RQ3nbwEMUBYp4PnRgeIZdMjz7/XYhjIgpihLtrTEY5lGFjSxOC9pl5LtvmamcL5rkyBOXwWXAFbFTbmASyiXI4yt2QUKdak8+lBck+Yiq9z8Kno0m1zQJ0Ok2Vfs8DGkvGAqsZ4ysxGQgem1cB3P89hjujkVgCcquvzyeGFp/pqCRUcZCjxj4crg9VFULf5EZD6V5m2Blb3rjS18cbBNjRHmgRaZq+mCaQjxuZlNxwxCGtOqIAA6BiUi40J/3Qf9OIKZSUDcVpvTGeMWSDz/xu++ArBhuyq1jWYqqhLJOXrUUKchKYWZKW8lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mb5oHwtqeqmk8i0rRE0WhrUdnOtYaSMsDmqTS3V7ES4=; b=AfMSZ4wFmhl1ED7qOB2GRsj+lvQ7ooXa0XpMMFLDHCGWQK0Tcqs+pfeylrvK5y+RQuFY5ye57JQV0oCz9KAh0vTY1i2Sp6vP8hMXXkh6mt/OvS039JeoRzSGpWwelB/7b3tEr8D5seQwsimR1LN1/b/Cg+rATkpYteJH5B38JLY5O+ojb2Y1lW8URleMua4eDhq/btGGI+eQMRkxShBPMNopFBukKnuEpugcjwArjSH/YlmeBC0DRmShwMVeYjhJ3rCe/MMsSAbRn/tNOP77c3wrV8G+GetcUfJ+sIZjKJPfoNIqS/jKLFwHyN/l3cRFCBzZj+Skmj91jx8+4tQNZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mb5oHwtqeqmk8i0rRE0WhrUdnOtYaSMsDmqTS3V7ES4=; b=c7lZYjKCXGf3/lyCGT0jM3L93x81j4VpLxvtkyN7J6GQSGZEzSLDT1Qp8uxYW640QWxZ0uZgvbpjr6WYGX6AUbZFmR9/xIDDP5oWTcjGjeej055TgEOprydjs5cN7c4g7U0rN2eba6kuOryn0mEg/5yUeMHx8mfCMLbhTQdvV8PIujgZB1a9Tu0XIcYXFxptC+9YCw8bObprn/SEHhr2MpMO2SSAhuAeibKVd+jhX1nkBfaNeujQSCzE8oFJ7ZGduahZubYKjsdvcEvLtZfJozfZXSkO5hgs9YjCUDuJKq7SmC93JTbDF+O2XMX/rhlDEMVAJORieGBDdMVnRwwfEg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEYPR06MB5913.apcprd06.prod.outlook.com (2603:1096:101:da::16) by OSQPR06MB7153.apcprd06.prod.outlook.com (2603:1096:604:298::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Tue, 27 Aug 2024 13:40:30 +0000 Received: from SEYPR06MB5913.apcprd06.prod.outlook.com ([fe80::f049:a716:8200:c4a1]) by SEYPR06MB5913.apcprd06.prod.outlook.com ([fe80::f049:a716:8200:c4a1%4]) with mapi id 15.20.7897.021; Tue, 27 Aug 2024 13:40:30 +0000 From: Lin Yikai To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Nick Terrell , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, yikai.lin@vivo.com Subject: [PATCH bpf-next v1 2/2] selftests/bpf: Fix cross-compile issue for some files and a static compile issue for "-lzstd" Date: Tue, 27 Aug 2024 21:39:59 +0800 Message-Id: <20240827133959.1269178-3-yikai.lin@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827133959.1269178-1-yikai.lin@vivo.com> References: <20240827133959.1269178-1-yikai.lin@vivo.com> X-ClientProxiedBy: SG2PR01CA0141.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::21) To SEYPR06MB5913.apcprd06.prod.outlook.com (2603:1096:101:da::16) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEYPR06MB5913:EE_|OSQPR06MB7153:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f006ffe-830f-40cb-200d-08dcc69dd17c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: PUqyOdGJxHy0kGwyy+3SKfjQiTnp+2z7GrXgzXR5hRYrqj2InEnRpXENAhD8hLTcjiMA6t7EAwq7BG6d1i0cG53sAoO3clpOV5yuUBmYV4mYoAODUz2Zfr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d22mLGAW7pK+TI13xy05Mod7uYK+qKPAlhA023eaBtal+aeubkxL8nh+mXsJvbWPRgfKyO03nilRFYCmrjgSE91LpCMCrBUVH5E2GS0PuFM7EBOu4HwxrwJ6HV0boGvpK5GLCHGOqkK7jBw29LuniO0HEBx2crVM2RReizdOQoz3sLmfJegQTSc5NDN6ApdLu8qHwhdb6INUko/lYZhO9PVa/6u5QtNOYDpJSFTXW23ewf6GON/4pyzv+oY1hxV0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEYPR06MB5913.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tBMMR0+1gIA5QlWCcUR4Qya1QwjZRszzGNq/ggsFk7qC804BdqwgfZkJ6bnzuyqsLqQ5AOHPeb/rpvukHoumL/kLp7sZUqYgv/gO9wpznQYcEND4gRSPoW2JBTmcxxKrTvlF9UzyFIRZxZXeZTjqxtaP5YaSQOn+5qgKVbTttpgh0Fy1Ozb9YlD80QX1rmyengDBQUIXK+l7iRGelVOcrOl98g16+pyLhFDGHm5TlydwskWWvihis95XDPdOdMMPAfhJ027D7CZ2cKDfwMWWgu/PpTlx+AR4LmvHafslsnUlTPNzjuKf+btK1f6Ug7GIOXFSkrrehtMks/xk8VrCSP5/BusREyKwFSeOLUNZOpUvUN5Z1pDNBNs5kcj/9HQCNyNK0VGWURAJhq8xAlmTruPwprMXSTN/0rdzJybtVAEr+w/WEaJoPwM7wJkv13TjRDvqX+x1zMHmXBNdSZJUxR+wfgHoRTXkZzKIfqNZOtWFP9tBn4yCnZ/pjYXT1kOGfMUY7VTg0HffsBbanwSkCSfWAoMefaBhisND2Ixf3J/TPiNlwWd0wiIFZTNuxWsRg4aqDB2ooOU2mMfRs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dd17c X-MS-Exchange-CrossTenant-AuthSource: SEYPR06MB5913.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 13:40:30.8138 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ObUW2Yq6G4qcm7l72kIJWjWXgHMkY1dClDlFAI8e15IESfdxtQIuCDgGxjTuwmzwcdtm8WnXjNnWct3JyJfprg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSQPR06MB7153 X-Patchwork-Delegate: bpf@iogearbox.net 1. Fix cross-compile issue for some files: [Issue] When cross-compiling bpf selftests for arm64 on x86_64 host, the following error occurs: progs/loop2.c:20:7: error: incomplete definition of type 'struct user_pt_regs' 20 | if (PT_REGS_RC(ctx) & 1) | ^~~~~~~~~~~~~~~ There are same error in files: loop1.c, loop2.c, loop3.c, loop6.c ??? [Reason] On arm64, in file bpf_tracing.h, we use userspace's user_pt_regs, which is defined in "linux/ptrace.h". We include the header file by adding "-idirafter /usr/include" for "CLANG_CFLAGS". However, during cross-compiling, "linux/ptrace.h" is based on x86_64 and has no definition of "struct user_pt_regs". [Fix] Thus, to fix this issue, we include the Linux source tree's header file directory. 2. Fix static compile issue for "-lzstd": [Issue] By running the command "LDLIBS=-static LDFLAGS=--sysroot=/aarch64-linux-gnu/libc ./vmtest.sh -s -- ./test_progs", during static cross-compiling, an error occurs: /aarch64-linux-gnu/bin/ld: aarch64-linux-gnu/libc/usr/lib/libelf.a(elf_compress.o): in function `__libelf_compress': (.text+0xec): undefined reference to `ZSTD_createCCtx' /aarch64-linux-gnu/bin/ld: (.text+0xf0): undefined reference to `ZSTD_createCCtx' ... [Fix] For static compile, add "LDLIBS += -lzstd". Signed-off-by: Lin Yikai --- tools/testing/selftests/bpf/Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index ec7d425c4022..5b725bc890d2 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -48,6 +48,10 @@ CFLAGS += -g $(OPT_FLAGS) -rdynamic \ LDFLAGS += $(SAN_LDFLAGS) LDLIBS += $(LIBELF_LIBS) -lz -lrt -lpthread +ifneq (,$(findstring -static,$(LDLIBS))) +LDLIBS += -lzstd +endif + LDLIBS += $(shell $(PKG_CONFIG) --libs libpcap 2>/dev/null) CFLAGS += $(shell $(PKG_CONFIG) --cflags libpcap 2>/dev/null) CFLAGS += $(shell $(PKG_CONFIG) --exists libpcap 2>/dev/null && echo "-DTRAFFIC_MONITOR=1") @@ -443,13 +447,19 @@ CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) endif CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) +CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) + BPF_CFLAGS = -g -Wall -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \ -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR) \ -I$(abspath $(OUTPUT)/../usr/include) \ -Wno-compare-distinct-pointer-types # TODO: enable me -Wsign-compare -CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) +#"make headers_install" at first +ifneq ($(CROSS_COMPILE),) +src_uapi_dir := $(srctree)/usr/include +BPF_CFLAGS += -I$(src_uapi_dir) +endif $(OUTPUT)/test_l4lb_noinline.o: BPF_CFLAGS += -fno-inline $(OUTPUT)/test_xdp_noinline.o: BPF_CFLAGS += -fno-inline