From nobody Wed Nov 5 16:43:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153564079737363.927391275599916; Thu, 30 Aug 2018 07:53:17 -0700 (PDT) Received: from localhost ([::1]:49364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvOJw-0007N0-0c for importer@patchew.org; Thu, 30 Aug 2018 10:53:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvOAP-0004cp-EB for qemu-devel@nongnu.org; Thu, 30 Aug 2018 10:43:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvNum-0003ap-Vv for qemu-devel@nongnu.org; Thu, 30 Aug 2018 10:27:21 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:54504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fvNum-0003Z1-Mf for qemu-devel@nongnu.org; Thu, 30 Aug 2018 10:27:16 -0400 Received: by mail-wm0-x241.google.com with SMTP id c14-v6so2210868wmb.4 for ; Thu, 30 Aug 2018 07:27:16 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id t4-v6sm10483893wrb.45.2018.08.30.07.27.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 07:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ra19++ZsUD4WMunUCjVWXSiPqzNPU/Ti3fkLDHeWq6E=; b=te9ua5mUgrumnEU8m8HAicTp4rWFsEzRSv7x4d8tqUDhPpYY7iLqEppKxMOu3JsYwG 47WJm6HckYik+Fzk+l44dqnU4xPzlLons3hzyk/nzsp/s2JyE5tJpVQZ0OMSqHkLD1bp m2zdU/osTWiTUxSUfeMStYK/tIC3ExorSWkiMMSNsi/loGZzjU0TwG7o3/Ca0r3VJPmB G0EBTcDAnGRzq2jOaXFZaFtIK1dzpeiT0R2LKfkphUlPr1zy1TRD8sTFZUlHDSaPLdZ9 R/7kei490ewzZq4bCiRzVMPvIE7qZqepRcD7ANtnHZwl3gy04JXkbWeK6oO+49ztgLDZ opYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ra19++ZsUD4WMunUCjVWXSiPqzNPU/Ti3fkLDHeWq6E=; b=lTtgGrLjPtGAfuBAb0ttCl9dLomOdSaRlfrZ/wUbd4SVVOV0sAiNAGGy+BrQAAVNG4 ppBBkX+j1SDDfqrNo1O6xwXQTi+uh26Y8Bw58gc7k9p1m7nnHtAbLdM/fb3Q8/+Ss5SZ wIFrUZ1vRcPgZrwdTiPUlG9ROXBitk1i3vbxaLLRIYLsgXGj/1L6TeDXdEfRiY/z2W9G x+4VwSJtrPpaF3rUOC1ykywZH0JMKj0VzKjl/eQWnNDtdWuLE1BU9hKSr5vBP1BoOFUZ Nj5GoTtXs4JxCk6Qm1F1yGX28FDFcy2lXyZTiJj/cSv1l9UNZ+PJf9sDnRwuJIlrMcLD o7EQ== X-Gm-Message-State: APzg51DTPIy6Y6ARTTeyKqPO5PUHsrR5GLoa2BNvpOAa3SuZA5y0TSxR Tq94PplUuOhJC9md0uxzPVnwefGWN1A= X-Google-Smtp-Source: ANB0Vdb5RuKeflwouwW57fHegRbLd0ZGdqigd3gJCHtTuhFdEMHJR2uQVO9Niwh7xLK2Si5P8it4BA== X-Received: by 2002:a1c:b707:: with SMTP id h7-v6mr1903462wmf.91.1535639235484; Thu, 30 Aug 2018 07:27:15 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org, Jason Wang Date: Thu, 30 Aug 2018 17:27:03 +0300 Message-Id: <20180830142708.14311-2-sameeh@daynix.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180830142708.14311-1-sameeh@daynix.com> References: <20180830142708.14311-1-sameeh@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [RFC 1/6] Add bpf support to qemu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sameeh Jubran This commit adds the bpf header provided by Linux to Qemu. Signed-off-by: Sameeh Jubran --- MAINTAINERS | 5 +++++ configure | 44 +++++++++++++++++++++++++++++++++++++= ++++ scripts/update-linux-headers.sh | 8 ++++++-- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 0fb5f38f9f..bf2619239c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2126,6 +2126,11 @@ F: hw/rdma/* F: hw/rdma/vmw/* F: docs/pvrdma.txt =20 +BPF +M: Sameeh Jubran +S: Maintained +F: linux-headers/linux/bpf.h + Build and test automation ------------------------- Build and test automation diff --git a/configure b/configure index a8c4094c87..21edaf59aa 100755 --- a/configure +++ b/configure @@ -348,6 +348,7 @@ libattr=3D"" xfs=3D"" tcg=3D"yes" membarrier=3D"" +bpf=3D"no" vhost_net=3D"no" vhost_crypto=3D"no" vhost_scsi=3D"no" @@ -1173,6 +1174,10 @@ for opt do ;; --enable-membarrier) membarrier=3D"yes" ;; + --disable-bpf) bpf=3D"no" + ;; + --enable-bpf) bpf=3D"yes" + ;; --disable-blobs) blobs=3D"no" ;; --with-pkgversion=3D*) pkgversion=3D"$optarg" @@ -1593,6 +1598,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: brlapi BrlAPI (Braile) curl curl connectivity membarrier membarrier system call (for Linux 4.14+ or Windows) + bpf bpf system calls (for Linux 3.18+) fdt fdt device tree bluez bluez stack connectivity kvm KVM acceleration support @@ -5232,6 +5238,38 @@ else fi =20 ########################################## +# check for usable bpf system call +if test "$bpf" =3D "yes"; then + have_bpf=3Dno + if test "$linux" =3D "yes" ; then + cat > $TMPC << EOF + #include + #include "linux/bpf.h" + #include + #include + #include + int main(void) { + union bpf_attr * attr =3D NULL; + syscall(__NR_bpf, BPF_PROG_LOAD, attr, sizeof(attr)); + exit(0); + } +EOF + bpf_include=3D"-Iinclude/standard-headers/linux" + bpf_cflags=3D"" + bpf_libs=3D"" + if compile_prog "$bpf_include" "$bpf_libs" ; then + have_bpf=3Dyes + fi + fi + if test "$have_bpf" =3D "no"; then + feature_not_found "bpf" "libelf libs are not available or else \ +the bpf system call is not available" + fi +else + bpf=3Dno +fi + +########################################## # check if rtnetlink.h exists and is useful have_rtnetlink=3Dno cat > $TMPC << EOF @@ -5871,6 +5909,7 @@ echo "malloc trim support $malloc_trim" echo "RDMA support $rdma" echo "fdt support $fdt" echo "membarrier $membarrier" +echo "bpf $bpf" echo "preadv support $preadv" echo "fdatasync $fdatasync" echo "madvise $madvise" @@ -6365,6 +6404,11 @@ fi if test "$membarrier" =3D "yes" ; then echo "CONFIG_MEMBARRIER=3Dy" >> $config_host_mak fi +if test "$bpf" =3D "yes" ; then + echo "CONFIG_BPF=3Dy" >> $config_host_mak + echo "LIBS_BPF=3D$bpf_libs" >> $config_host_mak + echo "CFLAGS_BPF=3D$bpf_cflags" >> $config_host_mak +fi if test "$signalfd" =3D "yes" ; then echo "CONFIG_SIGNALFD=3Dy" >> $config_host_mak fi diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers= .sh index feb75390aa..57df8228af 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -35,6 +35,8 @@ cp_portable() { grep '#include' "$f" | grep -v -e 'linux/virtio' \ -e 'linux/types' \ -e 'stdint' \ + -e 'stdio' \ + -e 'stdbool' \ -e 'linux/if_ether' \ -e 'input-event-codes' \ -e 'sys/' \ @@ -44,6 +46,7 @@ cp_portable() { -e 'linux/kernel' \ -e 'linux/sysinfo' \ -e 'asm-generic/kvm_para' \ + -e 'linux/bpf' \ > /dev/null then echo "Unexpected #include in input file $f". @@ -58,7 +61,7 @@ cp_portable() { -e 's/__le\([0-9][0-9]*\)/uint\1_t/g' \ -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \ -e 's/"\(input-event-codes\.h\)"/"standard-headers\/linux\/\1"/' \ - -e 's/]*\)>/"standard-headers\/linux\/\1"/' \ + -e 's/]*(?!bpf)\)>/"standard-headers\/linux\/\1"/' \ -e 's/__bitwise//' \ -e 's/__attribute__((packed))/QEMU_PACKED/' \ -e 's/__inline__/inline/' \ @@ -126,7 +129,8 @@ done rm -rf "$output/linux-headers/linux" mkdir -p "$output/linux-headers/linux" for header in kvm.h vfio.h vfio_ccw.h vhost.h \ - psci.h psp-sev.h userfaultfd.h; do + psci.h psp-sev.h userfaultfd.h \ + bpf.h; do cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux" done =20 --=20 2.13.6