Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp785694imm; Thu, 26 Jul 2018 11:59:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpccZtH7/9hl5JNmu0JL9fQ5ln9ynF0tKXW+HrNqkPiWa2ny/hbOQK379Qc13i9w0fNuGbBa X-Received: by 2002:a62:d544:: with SMTP id d65-v6mr3266084pfg.107.1532631556036; Thu, 26 Jul 2018 11:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532631556; cv=none; d=google.com; s=arc-20160816; b=ygd5/g0AHc0/9J2PkISrQK8ZkO2EN1wskSHYmB+NwsXEFOziM8nh9ckycMnKVILYag 0c9VibRjfpp4yyv58oRf8T11o6h0arPyJkNikr7gABtOL1ZR70kqTgaRI3jGlHK4N+yM sdYpxxeq3YMb3cp793IzzGisCbdpsQUzcbu+9PMJx83lBWguHxzt82SReIjW3kS5eQEc nJA0dCFkJyeY/XW5fH5mr6XJmnunC95ipmbGDvkwYPZ7z7aIFKcyuPyaSwpT5tcklTnw XhYXwCx4TKJeeWf3Hf7bYSvWU5SNKad3kYzqdl2DyZfBLVN2ybWvXCZW8Kq6MdgF/ziX ahPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=bO5+Trr+7wF5nmYkn8iVOrgtNu8P4Mao3D+lnVvGdmw=; b=NAex1mNHhjRKBKiCaHQv6Uap0EGGEWQX88HQz2VZ2Pwj1MlMOaZW9mrFEANT+Lvo0U 0MCAqmfie5qMGloxZXy3sEiGduYktB8pG4BYjWo6Bda4h5hKc8UojhweT15oXeP2/Q7+ 1wW+Kx0xN9jCw1aOofKy8HLgSXEZ4h+hDIGrZNUZsV1BTrOG+LxvjiWm8ELSRZk+ropS CIusfCIvpSykP60ZaRs+cMsKQPnsnc1HplzRPv+0Kh0WybGPW4atXqH7qzAzEMHW7WAq zV8qS68keHFKB0OH3Fbixd/a2effi4CVrcTGwfnKfArNTvWa1FTJBJI//yvr8Gyp1BG5 YRhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ANskvzSo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11-v6si1652265pgt.44.2018.07.26.11.58.59; Thu, 26 Jul 2018 11:59:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ANskvzSo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730581AbeGZUQS (ORCPT + 99 others); Thu, 26 Jul 2018 16:16:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:55332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730292AbeGZUQS (ORCPT ); Thu, 26 Jul 2018 16:16:18 -0400 Received: from jouet.infradead.org (unknown [177.79.81.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B5D920857; Thu, 26 Jul 2018 18:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1532631490; bh=H9xVnTTKMJFEWCI5J5/Xsdq+0iUY9RzjMNM0G+6YeHk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ANskvzSouT2cjaPRAaZKx/Uk0cI6ay2dNPUtkYkyl3ZN77fyBChtmnbSzDJjMjs/+ urQhC3brjnEw0m7yUU/u1Z/5+E0j+5/Ibt53d6do74PetumQg44o9SvSExA5Z+56qR GxEE9c+xQGdAKCxSObEnVRQ+aRlNB6PMjTFlAk1Y= Received: by jouet.infradead.org (Postfix, from userid 1000) id 8DAEC1403B8; Thu, 26 Jul 2018 15:58:05 -0300 (-03) Date: Thu, 26 Jul 2018 15:58:05 -0300 From: Arnaldo Carvalho de Melo To: Sandipan Das Cc: Alexei Starovoitov , Daniel Borkmann , Ingo Molnar , Martin KaFai Lau , Clark Williams , linux-perf-users@vger.kernel.org, Adrian Hunter , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Wang Nan , linux-kernel@vger.kernel.org, "Naveen N. Rao" Subject: Re: BPF relocation 'perf test' entries failing was: Re: [GIT PULL 00/27] perf/core improvements and fixes Message-ID: <20180726185805.GA20438@kernel.org> References: <20180726131534.GD17940@kernel.org> <2fbfac01-e103-8daf-6187-b94d1725dbd0@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2fbfac01-e103-8daf-6187-b94d1725dbd0@linux.ibm.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Jul 26, 2018 at 11:04:08PM +0530, Sandipan Das escreveu: > Hi Arnaldo, > > I came across the same problem. Does the following patch fix it? > https://lkml.org/lkml/2018/7/26/669 Oh my, that one was subtle... Checking... - Arnaldo > - Sandipan > > On Thursday 26 July 2018 06:45 PM, Arnaldo Carvalho de Melo wrote: > > Em Wed, Jul 25, 2018 at 02:59:34PM -0300, Arnaldo Carvalho de Melo escreveu: > >> Hi Ingo, > >> > >> Please consider pulling, I'm now investigating why these failed: > >> > >> 38: LLVM search and compile : > >> 38.1: Basic BPF llvm compile : Ok > >> 38.2: kbuild searching : Ok > >> 38.3: Compile source for BPF prologue generation : Ok > >> 38.4: Compile source for BPF relocation : FAILED! > >> 40: BPF filter : > >> 40.1: Basic BPF filtering : Ok > >> 40.2: BPF pinning : Ok > >> 40.3: BPF prologue generation : Ok > >> 40.4: BPF relocation checker : FAILED! > >> > >> I think these failures are not related to changes in this patch > >> kit. Details about the test environment, versions, etc. > > > > So, here are more details: > > > > The relevant bit seems to be: > > > > libbpf: Program 'func=sys_write' contains non-map related relo data pointing to section 65522 > > > > So this seems to be something that was caught by the kernel verifier and > > now is being caught by libbpf, /me goes to read the tools/lib/bpf > > changelog... > > > > - Arnaldo > > > > BPF filter subtest 2: Ok > > 40.3: BPF prologue generation : > > --- start --- > > test child forked, pid 13336 > > Kernel build dir is set to /lib/modules/4.18.0-rc6-00093-g9981b4fb8684/build > > set env: KBUILD_DIR=/lib/modules/4.18.0-rc6-00093-g9981b4fb8684/build > > unset env: KBUILD_OPTS > > include option is set to -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/7/include -I/home/acme/git/linux/arch/x86/include -I./arch/x86/include/generated -I/home/acme/git/linux/include -I./include -I/home/acme/git/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -I./include/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h > > set env: NR_CPUS=4 > > set env: LINUX_VERSION_CODE=0x41200 > > set env: CLANG_EXEC=/usr/lib64/ccache/clang > > set env: CLANG_OPTIONS=-xc > > set env: KERNEL_INC_OPTIONS= -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/7/include -I/home/acme/git/linux/arch/x86/include -I./arch/x86/include/generated -I/home/acme/git/linux/include -I./include -I/home/acme/git/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -I./include/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h > > set env: PERF_BPF_INC_OPTIONS=-I/home/acme/lib/include/perf/bpf > > set env: WORKING_DIR=/lib/modules/4.18.0-rc6-00093-g9981b4fb8684/build > > set env: CLANG_SOURCE=- > > llvm compiling command template: echo '/* > > * bpf-script-test-relocation.c > > * Test BPF loader checking relocation > > */ > > #ifndef LINUX_VERSION_CODE > > # error Need LINUX_VERSION_CODE > > # error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig' > > #endif > > #define BPF_ANY 0 > > #define BPF_MAP_TYPE_ARRAY 2 > > #define BPF_FUNC_map_lookup_elem 1 > > #define BPF_FUNC_map_update_elem 2 > > > > static void *(*bpf_map_lookup_elem)(void *map, void *key) = > > (void *) BPF_FUNC_map_lookup_elem; > > static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) = > > (void *) BPF_FUNC_map_update_elem; > > > > struct bpf_map_def { > > unsigned int type; > > unsigned int key_size; > > unsigned int value_size; > > unsigned int max_entries; > > }; > > > > #define SEC(NAME) __attribute__((section(NAME), used)) > > struct bpf_map_def SEC("maps") my_table = { > > .type = BPF_MAP_TYPE_ARRAY, > > .key_size = sizeof(int), > > .value_size = sizeof(int), > > .max_entries = 1, > > }; > > > > int this_is_a_global_val; > > > > SEC("func=sys_write") > > int bpf_func__sys_write(void *ctx) > > { > > int key = 0; > > int value = 0; > > > > /* > > * Incorrect relocation. Should not allow this program be > > * loaded into kernel. > > */ > > bpf_map_update_elem(&this_is_a_global_val, &key, &value, 0); > > return 0; > > } > > char _license[] SEC("license") = "GPL"; > > int _version SEC("version") = LINUX_VERSION_CODE; > > ' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS $PERF_BPF_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o - > > llvm compiling command : echo '/* > > * bpf-script-test-relocation.c > > * Test BPF loader checking relocation > > */ > > #ifndef LINUX_VERSION_CODE > > # error Need LINUX_VERSION_CODE > > # error Example: for 4.2 kernel, put 'clang-opt=-DLINUX_VERSION_CODE=0x40200 into llvm section of ~/.perfconfig' > > #endif > > #define BPF_ANY 0 > > #define BPF_MAP_TYPE_ARRAY 2 > > #define BPF_FUNC_map_lookup_elem 1 > > #define BPF_FUNC_map_update_elem 2 > > > > static void *(*bpf_map_lookup_elem)(void *map, void *key) = > > (void *) BPF_FUNC_map_lookup_elem; > > static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) = > > (void *) BPF_FUNC_map_update_elem; > > > > struct bpf_map_def { > > unsigned int type; > > unsigned int key_size; > > unsigned int value_size; > > unsigned int max_entries; > > }; > > > > #define SEC(NAME) __attribute__((section(NAME), used)) > > struct bpf_map_def SEC(maps) my_table = { > > .type = BPF_MAP_TYPE_ARRAY, > > .key_size = sizeof(int), > > .value_size = sizeof(int), > > .max_entries = 1, > > }; > > > > int this_is_a_global_val; > > > > SEC(func=sys_write) > > int bpf_func__sys_write(void *ctx) > > { > > int key = 0; > > int value = 0; > > > > /* > > * Incorrect relocation. Should not allow this program be > > * loaded into kernel. > > */ > > bpf_map_update_elem(&this_is_a_global_val, &key, &value, 0); > > return 0; > > } > > char _license[] SEC(license) = GPL; > > int _version SEC(version) = LINUX_VERSION_CODE; > > ' | /usr/lib64/ccache/clang -D__KERNEL__ -D__NR_CPUS__=4 -DLINUX_VERSION_CODE=0x41200 -xc -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/7/include -I/home/acme/git/linux/arch/x86/include -I./arch/x86/include/generated -I/home/acme/git/linux/include -I./include -I/home/acme/git/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -I./include/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h -I/home/acme/lib/include/perf/bpf -Wno-unused-value -Wno-pointer-sign -working-directory /lib/modules/4.18.0-rc6-00093-g9981b4fb8684/build -c - -target bpf -O2 -o - > > libbpf: loading object '[bpf_relocation_test]' from buffer > > libbpf: section(1) .strtab, size 115, link 0, flags 0, type=3 > > libbpf: skip section(1) .strtab > > libbpf: section(2) .text, size 0, link 0, flags 6, type=1 > > libbpf: skip section(2) .text > > libbpf: section(3) func=sys_write, size 104, link 0, flags 6, type=1 > > libbpf: found program func=sys_write > > libbpf: section(4) .relfunc=sys_write, size 16, link 8, flags 0, type=9 > > libbpf: section(5) maps, size 16, link 0, flags 3, type=1 > > libbpf: section(6) license, size 4, link 0, flags 3, type=1 > > libbpf: license of [bpf_relocation_test] is GPL > > libbpf: section(7) version, size 4, link 0, flags 3, type=1 > > libbpf: kernel version of [bpf_relocation_test] is 41200 > > libbpf: section(8) .symtab, size 144, link 1, flags 0, type=2 > > libbpf: maps in [bpf_relocation_test]: 1 maps in 16 bytes > > libbpf: map 0 is "my_table" > > libbpf: collecting relocating info for: 'func=sys_write' > > libbpf: relo for 5 value 4 name 21 > > libbpf: Program 'func=sys_write' contains non-map related relo data pointing to section 65522 > > bpf: failed to load buffer > > Compile BPF program failed. > > test child finished with 0 > > ---- end ---- > > BPF filter subtest 3: Ok > > 40.4: BPF relocation checker : > > --- start --- > > test child forked, pid 13746 > > test child finished with -1 > > ---- end ---- > > BPF filter subtest 4: FAILED! > > [root@seventh ~]# > > > >