Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2097815ybl; Thu, 30 Jan 2020 11:18:53 -0800 (PST) X-Google-Smtp-Source: APXvYqykfyEjbX6xfh3KSO+eT5Z2TEa4mxdUurnXQDliJDLBsYc3Id8HYMbY7sBOfHNyoJqbx9BO X-Received: by 2002:a9d:784b:: with SMTP id c11mr4623129otm.246.1580411933564; Thu, 30 Jan 2020 11:18:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411933; cv=none; d=google.com; s=arc-20160816; b=sIIRqS7Wh0eaT3zBHS1fTSPidw2RzQ3+3QLIqOM0Xfsw/ZyE9CWwZye+iAT8OjuQxt QCAqXmkLnGE/FObbKQh5rJUF5OIm6JQiQF7nt/XhY2Pe/HETScGqS0mTNBeFHWBDSVXC xOnV4U4lNIwdb4TvPr71hsRHqzlaeFiNl/EOWJbyLI622NCq3dqNJ85Jmdkm9DzxnpnV jv+dIb9ibw8Kt0EH+5kKf63qOpmTNIi7xAqU40qqURvtOVfuS5q2R4eyp0MRBbXKrJ0P +bPb5bLor5frSTmubwdRpAY+GlTvFqUZHZE8EPj2G9VArd+PMl6QdoXswdD53AuqJ3Q4 9ozw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eE4vsZcFrwyI+089mpab1SjEexhixCM1Eh67TrRqS/U=; b=G6usETqp6seesk3Jv4osGlb37UFWXXbpDuLq9IqCyYd4y+31tPn7lYBLa8V/33fIG7 IQSvib/aMXW4Up0s9bZDk2qdaC1LZd5PB6Eb43c52//jsAWaUnGxALUqzsptgmonC7fT yL4UnHsWOp/+a6QNNnJNV4wbIF6wgSPKY7W9Ld/k9x3EkIcvzcQ2s9bEFFdATltwpcp2 4vLGr+UrehShHbz19R4l0FMqeo3Ix1AaorKvZTGmrPzQ6VDGDxk+S+7AtMRhJpT+n17t FQJZFx/8C/j8dwS4wRg7Ck7BIbWwM0wRAsgzhoiEM4y/1rvNU970lWn5tMsdjvZWzYD1 rTJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cNOrFn9g; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z73si3265203oia.40.2020.01.30.11.18.41; Thu, 30 Jan 2020 11:18:53 -0800 (PST) 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=cNOrFn9g; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730949AbgA3SpE (ORCPT + 99 others); Thu, 30 Jan 2020 13:45:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:54482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730680AbgA3SpD (ORCPT ); Thu, 30 Jan 2020 13:45:03 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 A82552082E; Thu, 30 Jan 2020 18:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409903; bh=AUJ7Mi/W3UD5YTk3TevtD9PxZSR5axwLwf8CCIlNtWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cNOrFn9g/dH7nAKhnb8SoC7HmHv0wwYA1WV2e+dSf9XeXRO/l3vjMsOzwUbYveIgR vFOVMWnhNdpSlYEa85HlRhs2ztylQm3GcScXcFNqxTE1ELkbKPPMbmxSJkLrYqxkiG LUI2S87TSbqMJv1T2uXRxVdLYrF7aIxkSr3lz8Vo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrii Nakryiko , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.4 078/110] libbpf: Fix BTF-defined maps __type macro handling of arrays Date: Thu, 30 Jan 2020 19:38:54 +0100 Message-Id: <20200130183623.512525712@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrii Nakryiko [ Upstream commit a53ba15d81995868651dd28a85d8045aef3d4e20 ] Due to a quirky C syntax of declaring pointers to array or function prototype, existing __type() macro doesn't work with map key/value types that are array or function prototype. One has to create a typedef first and use it to specify key/value type for a BPF map. By using typeof(), pointer to type is now handled uniformly for all kinds of types. Convert one of self-tests as a demonstration. Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20191004040211.2434033-1-andriin@fb.com Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/bpf_helpers.h | 2 +- tools/testing/selftests/bpf/progs/test_get_stack_rawtp.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h index 54a50699bbfda..9f77cbaac01c1 100644 --- a/tools/testing/selftests/bpf/bpf_helpers.h +++ b/tools/testing/selftests/bpf/bpf_helpers.h @@ -3,7 +3,7 @@ #define __BPF_HELPERS__ #define __uint(name, val) int (*name)[val] -#define __type(name, val) val *name +#define __type(name, val) typeof(val) *name /* helper macro to print out debug messages */ #define bpf_printk(fmt, ...) \ diff --git a/tools/testing/selftests/bpf/progs/test_get_stack_rawtp.c b/tools/testing/selftests/bpf/progs/test_get_stack_rawtp.c index f8ffa3f3d44bb..6cc4479ac9df6 100644 --- a/tools/testing/selftests/bpf/progs/test_get_stack_rawtp.c +++ b/tools/testing/selftests/bpf/progs/test_get_stack_rawtp.c @@ -47,12 +47,11 @@ struct { * issue and avoid complicated C programming massaging. * This is an acceptable workaround since there is one entry here. */ -typedef __u64 raw_stack_trace_t[2 * MAX_STACK_RAWTP]; struct { __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); __uint(max_entries, 1); __type(key, __u32); - __type(value, raw_stack_trace_t); + __type(value, __u64[2 * MAX_STACK_RAWTP]); } rawdata_map SEC(".maps"); SEC("raw_tracepoint/sys_enter") -- 2.20.1