Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1039189rwb; Thu, 1 Dec 2022 11:29:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf6rrF3bqVUHrfbV/a4HG2qO4dIpmCgmT96fp+d9q2WZK5Vc6ie8gWqpKKaEeaHskVPilYz8 X-Received: by 2002:a17:907:d68b:b0:7b9:dff1:b26e with SMTP id wf11-20020a170907d68b00b007b9dff1b26emr92912ejc.289.1669922958531; Thu, 01 Dec 2022 11:29:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669922958; cv=none; d=google.com; s=arc-20160816; b=QNKl6YF06qzBOdawfJjOw8G58CVdiWJwbwx6xlODPh4f5l85yyUjmcoMoB54atX63i dtbQoB4ciMfSgYO71rEEGebkeWZ5YuFYSx25fioUx3w7/rn3ZSWDOtJYODiJcKD0ImbI 8fHLSbSmVq58Pmpa5wR0dYFRGjFVTWcXRMXbILyWCf4wIKP3lJLCnz9RVitb0AbUKvpY /74Y7YPlqUQn5KefUpIOVW0bwDduQVuerrv/phB7yekG1OBjaus7bzwkjFWhOpblJ+ns HGStNwwewxf33RibGkMnt+Mi4kZQ+ilqwtp0d9T7E2ZmSzxm+0fA+8RQb/cpvEniDdig xMrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8lBn7HA8s73zkhGBNG3m4Sb/6k6XYlgLSYhUWX2vb1I=; b=MH/HOop3p1P/mOMBLYA9PQR9a3aS1jGNrh3MbHTS/RKYZtUh52NJBJM9bvFJqqYNwF IYxLQuQt2/orr90YC0qGdSZrkNeXsSUx94nLimEp0b7fTiE7AD6EbcAdQfvbl1rN62Dg rQUji62nl+bcKqE2kFMKZBXWx8hYMGo8VBFRY5UQRilL/wMtVn+sI7XpLIb5ipAlIpts AP4EeTvmpzKcx7Zj1dKzRkDOhKWu1OuW0BTTXRTY/0nIKX9xoV6quoZ1JYHOMTt0aSNS ZshTGKXYPGBRWIa6UQfuLMvpk3MYAPJKaB8t6BGgeN88IWoWs2IUZs715oCNltLMxYiC 5bqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=R1N6Q+6E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s24-20020a05640217d800b0045c9dbe290csi4298818edy.406.2022.12.01.11.28.54; Thu, 01 Dec 2022 11:29:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=R1N6Q+6E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbiLATLA (ORCPT + 83 others); Thu, 1 Dec 2022 14:11:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbiLATKs (ORCPT ); Thu, 1 Dec 2022 14:10:48 -0500 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8878C5E04; Thu, 1 Dec 2022 11:10:47 -0800 (PST) Received: by mail-qt1-x829.google.com with SMTP id fz10so2121966qtb.3; Thu, 01 Dec 2022 11:10:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8lBn7HA8s73zkhGBNG3m4Sb/6k6XYlgLSYhUWX2vb1I=; b=R1N6Q+6EHAvFNQV7/6IZX3Aixg6UnmIt/9PjjzdEbOApqMebnO6IX1H7Mb50Gm02gz VXdj+LWNboN0dcXgELaAg69k6+dZ4o68EkPz+PyNYIIo2VN1SQo89z8JZtKnvL9057it leOaMYglJnV+FUMHAgoarShMntNo1M1DLtf34CvYeOjRmsXWyjkoZFYOM570hcHsHqGJ xpMlzjuNgXuC0ILwBMhTPAsg9vA6a7InK0DJmlHmuCPCY8GgUKwob5zyBYaJHdTKBEF1 6N9919eAfx3ZqrhGhRfecNzr7v13/YbmRVEyYbhbdqqSc1SX6k+JorAXSrFE3d5DDvMd 3EIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8lBn7HA8s73zkhGBNG3m4Sb/6k6XYlgLSYhUWX2vb1I=; b=okGilCwvprJ5/rkBpGExkY+Sgm3fvsF/dnwKYWsa2hMFbeGmrx/Km/mn/cWXTUgK3m +FVAVs6Boz5rJnVccVaY0TBe2mA5VBP6CHAXSGjNXhcwBIsP2peuk+y9iRCGHKp0IArg SMPi6nupN0JYt6RaZhITGhgD4633GIp4danywS54rR5Bvpw0TsDmVB8PRIBwfSLYL6og SkmZZxqFMoMZctPiOBjEy8uF5AxO50PSgH/GCznmfYPMU/UZlOGmtwa+6y2YN+yU2gpM mp9AcerXncv3t3wrpGVhvZJLHb2hmigjJPgyaO4vxWOZC0OqCnsNwlbdhLNjGTs3YOBF UGiA== X-Gm-Message-State: ANoB5plw8vh+h/cprNjwE3GiE+Nlxa1quiu8wGE3hzqa3lT17j2YnxvF QWEDB6VYu78264gPyq4nUeb1mPxrXYm+mn1R X-Received: by 2002:a37:be45:0:b0:6fb:f7a0:987d with SMTP id o66-20020a37be45000000b006fbf7a0987dmr48096466qkf.191.1669921846406; Thu, 01 Dec 2022 11:10:46 -0800 (PST) Received: from james-x399.localdomain (71-33-132-231.hlrn.qwest.net. [71.33.132.231]) by smtp.gmail.com with ESMTPSA id bs17-20020a05620a471100b006bbc3724affsm4006972qkb.45.2022.12.01.11.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 11:10:45 -0800 (PST) From: James Hilliard To: bpf@vger.kernel.org Cc: James Hilliard , "Jose E . Marchesi" , David Faust , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] selftests/bpf: add GCC compatible builtins to bpf_legacy.h Date: Thu, 1 Dec 2022 12:09:39 -0700 Message-Id: <20221201190939.3230513-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The bpf_legacy.h header uses llvm specific load functions, add GCC compatible variants as well to fix tests using these functions under GCC. Signed-off-by: James Hilliard Cc: Jose E. Marchesi Cc: David Faust --- tools/testing/selftests/bpf/bpf_legacy.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/bpf/bpf_legacy.h b/tools/testing/selftests/bpf/bpf_legacy.h index 845209581440..256c2a90aa20 100644 --- a/tools/testing/selftests/bpf/bpf_legacy.h +++ b/tools/testing/selftests/bpf/bpf_legacy.h @@ -2,6 +2,15 @@ #ifndef __BPF_LEGACY__ #define __BPF_LEGACY__ +#if __GNUC__ && !__clang__ +/* Functions to emit BPF_LD_ABS and BPF_LD_IND instructions. We + * provide the "standard" names as synonyms of the corresponding GCC + * builtins. Note how the SKB argument is ignored. + */ +#define load_byte(skb,off) __builtin_bpf_load_byte((off)) +#define load_half(skb,off) __builtin_bpf_load_half((off)) +#define load_word(skb,off) __builtin_bpf_load_word((off)) +#else /* llvm builtin functions that eBPF C program may use to * emit BPF_LD_ABS and BPF_LD_IND instructions */ @@ -11,6 +20,7 @@ unsigned long long load_half(void *skb, unsigned long long off) asm("llvm.bpf.load.half"); unsigned long long load_word(void *skb, unsigned long long off) asm("llvm.bpf.load.word"); +#endif #endif -- 2.34.1