Message ID | 20180830142708.14311-2-sameeh@daynix.com |
---|---|
State | New |
Headers | show |
Series | Virtio-net: Support RSS | expand |
On Thu, Aug 30, 2018 at 05:27:03PM +0300, Sameeh Jubran wrote: > From: Sameeh Jubran <sjubran@redhat.com> > > This commit adds the bpf header provided by Linux to Qemu. s/Qemu/QEMU/ > > Signed-off-by: Sameeh Jubran <sjubran@redhat.com> > --- > 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 > > +BPF > +M: Sameeh Jubran <sameeh@daynix.com> > +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="" > xfs="" > tcg="yes" > membarrier="" > +bpf="no" This should really default to "", with the check below automatically doing the right thing to automatically enable/disable it. > vhost_net="no" > vhost_crypto="no" > vhost_scsi="no" > @@ -1173,6 +1174,10 @@ for opt do > ;; > --enable-membarrier) membarrier="yes" > ;; > + --disable-bpf) bpf="no" > + ;; > + --enable-bpf) bpf="yes" > + ;; > --disable-blobs) blobs="no" > ;; > --with-pkgversion=*) pkgversion="$optarg" > @@ -1593,6 +1598,7 @@ disabled with --disable-FEATURE, default is enabled if 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 > > ########################################## > +# check for usable bpf system call > +if test "$bpf" = "yes"; then if test "x$bpf" != "xno"; then > + have_bpf=no > + if test "$linux" = "yes" ; then > + cat > $TMPC << EOF > + #include <sys/syscall.h> > + #include "linux/bpf.h" > + #include <unistd.h> > + #include <stdlib.h> > + #include <string.h> > + int main(void) { > + union bpf_attr * attr = NULL; > + syscall(__NR_bpf, BPF_PROG_LOAD, attr, sizeof(attr)); > + exit(0); > + } > +EOF > + bpf_include="-Iinclude/standard-headers/linux" > + bpf_cflags="" > + bpf_libs="" > + if compile_prog "$bpf_include" "$bpf_libs" ; then > + have_bpf=yes > + fi > + fi > + if test "$have_bpf" = "no"; then > + feature_not_found "bpf" "libelf libs are not available or else \ > +the bpf system call is not available" if test "$have_bpf" = "no"; then if test "x$bpf" = "xyes" ; then feature_not_found .... else bpf=no fi else bpf=yes fi > + fi > +else > + bpf=no > +fi > + Regards, Daniel
On Mon, Sep 3, 2018 at 2:59 PM, Daniel P. Berrangé <berrange@redhat.com> wrote: > On Thu, Aug 30, 2018 at 05:27:03PM +0300, Sameeh Jubran wrote: >> From: Sameeh Jubran <sjubran@redhat.com> >> >> This commit adds the bpf header provided by Linux to Qemu. > > s/Qemu/QEMU/ > >> >> Signed-off-by: Sameeh Jubran <sjubran@redhat.com> >> --- >> 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 >> >> +BPF >> +M: Sameeh Jubran <sameeh@daynix.com> >> +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="" >> xfs="" >> tcg="yes" >> membarrier="" >> +bpf="no" > > This should really default to "", with the check below > automatically doing the right thing to automatically > enable/disable it. > >> vhost_net="no" >> vhost_crypto="no" >> vhost_scsi="no" >> @@ -1173,6 +1174,10 @@ for opt do >> ;; >> --enable-membarrier) membarrier="yes" >> ;; >> + --disable-bpf) bpf="no" >> + ;; >> + --enable-bpf) bpf="yes" >> + ;; >> --disable-blobs) blobs="no" >> ;; >> --with-pkgversion=*) pkgversion="$optarg" >> @@ -1593,6 +1598,7 @@ disabled with --disable-FEATURE, default is enabled if 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 >> >> ########################################## >> +# check for usable bpf system call >> +if test "$bpf" = "yes"; then > > if test "x$bpf" != "xno"; then > >> + have_bpf=no >> + if test "$linux" = "yes" ; then >> + cat > $TMPC << EOF >> + #include <sys/syscall.h> >> + #include "linux/bpf.h" >> + #include <unistd.h> >> + #include <stdlib.h> >> + #include <string.h> >> + int main(void) { >> + union bpf_attr * attr = NULL; >> + syscall(__NR_bpf, BPF_PROG_LOAD, attr, sizeof(attr)); >> + exit(0); >> + } >> +EOF >> + bpf_include="-Iinclude/standard-headers/linux" >> + bpf_cflags="" >> + bpf_libs="" >> + if compile_prog "$bpf_include" "$bpf_libs" ; then >> + have_bpf=yes >> + fi >> + fi >> + if test "$have_bpf" = "no"; then >> + feature_not_found "bpf" "libelf libs are not available or else \ >> +the bpf system call is not available" > > if test "$have_bpf" = "no"; then > if test "x$bpf" = "xyes" ; > then > feature_not_found .... > else > bpf=no > fi > else > bpf=yes > fi I'll use the x prefix, for anyone wondering why this is necessary ( I didn't realize this before), checkout the following explanation: https://stackoverflow.com/questions/174119/why-do-shell-script-comparisons-often-use-xvar-xyes > >> + fi >> +else >> + bpf=no >> +fi >> + > > Regards, > Daniel > -- > |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| > |: https://libvirt.org -o- https://fstop138.berrange.com :| > |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
On 3 September 2018 at 12:59, Daniel P. Berrangé <berrange@redhat.com> wrote: >> ########################################## >> +# check for usable bpf system call >> +if test "$bpf" = "yes"; then > > if test "x$bpf" != "xno"; then We don't use the leading-x thingy elsewhere in configure, why is this condition special? (We can assume we don't have a broken shell, and we know that $bpf won't be a string starting with a hyphen.) thanks -- PMM
On Mon, Sep 3, 2018 at 3:24 PM, Peter Maydell <peter.maydell@linaro.org> wrote: > On 3 September 2018 at 12:59, Daniel P. Berrangé <berrange@redhat.com> wrote: > >>> ########################################## >>> +# check for usable bpf system call >>> +if test "$bpf" = "yes"; then >> >> if test "x$bpf" != "xno"; then > > We don't use the leading-x thingy elsewhere in configure, > why is this condition special? > (We can assume we don't have a broken shell, and we > know that $bpf won't be a string starting with a hyphen.) That's what Daniel suggested and I though it should be good for the reasons above. You have good points as well. Both approaches are okay with me :) > > thanks > -- PMM
On Mon, Sep 03, 2018 at 01:24:16PM +0100, Peter Maydell wrote: > On 3 September 2018 at 12:59, Daniel P. Berrangé <berrange@redhat.com> wrote: > > >> ########################################## > >> +# check for usable bpf system call > >> +if test "$bpf" = "yes"; then > > > > if test "x$bpf" != "xno"; then > > We don't use the leading-x thingy elsewhere in configure, > why is this condition special? > (We can assume we don't have a broken shell, and we > know that $bpf won't be a string starting with a hyphen.) It is just my habit. Drop the 'x' prefix if that's not used in QEMU's configure script normally. Regards, Daniel
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 +BPF +M: Sameeh Jubran <sameeh@daynix.com> +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="" xfs="" tcg="yes" membarrier="" +bpf="no" vhost_net="no" vhost_crypto="no" vhost_scsi="no" @@ -1173,6 +1174,10 @@ for opt do ;; --enable-membarrier) membarrier="yes" ;; + --disable-bpf) bpf="no" + ;; + --enable-bpf) bpf="yes" + ;; --disable-blobs) blobs="no" ;; --with-pkgversion=*) pkgversion="$optarg" @@ -1593,6 +1598,7 @@ disabled with --disable-FEATURE, default is enabled if 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 ########################################## +# check for usable bpf system call +if test "$bpf" = "yes"; then + have_bpf=no + if test "$linux" = "yes" ; then + cat > $TMPC << EOF + #include <sys/syscall.h> + #include "linux/bpf.h" + #include <unistd.h> + #include <stdlib.h> + #include <string.h> + int main(void) { + union bpf_attr * attr = NULL; + syscall(__NR_bpf, BPF_PROG_LOAD, attr, sizeof(attr)); + exit(0); + } +EOF + bpf_include="-Iinclude/standard-headers/linux" + bpf_cflags="" + bpf_libs="" + if compile_prog "$bpf_include" "$bpf_libs" ; then + have_bpf=yes + fi + fi + if test "$have_bpf" = "no"; then + feature_not_found "bpf" "libelf libs are not available or else \ +the bpf system call is not available" + fi +else + bpf=no +fi + +########################################## # check if rtnetlink.h exists and is useful have_rtnetlink=no 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" = "yes" ; then echo "CONFIG_MEMBARRIER=y" >> $config_host_mak fi +if test "$bpf" = "yes" ; then + echo "CONFIG_BPF=y" >> $config_host_mak + echo "LIBS_BPF=$bpf_libs" >> $config_host_mak + echo "CFLAGS_BPF=$bpf_cflags" >> $config_host_mak +fi if test "$signalfd" = "yes" ; then echo "CONFIG_SIGNALFD=y" >> $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/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \ + -e 's/<linux\/\([^>]*(?!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