From patchwork Thu Jan 27 07:53:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 12728163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B95C3C433F5 for ; Fri, 28 Jan 2022 09:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=a0VmlID/qfZOo9ql7bd219XNBL2Mv0DnV3sBvq/ii3c=; b=o4M8RFbNi9oUzG 2qWgzusit6XPtRAr7M9JaL4E8Rez6GZqh37vXUI/hISLzVkZMyHXRzxXxJ9+egxOEoR3vJcwImHav QZLMv49KIvXDeFaD9waRL5avmO8V1ond2X3OrBdTD5RhIkbyrW1D+L/bjJu8w4RsN8jvFyVb4BfxA gug4/LWGmkrTrdSLyvoLLCurdUIBOmQsYzpch8yNmJ+zK7P2S0xKunrsmypKqGRRljlmm8JbD0hFW qlzUjpY0s1vCLNvd4oDHOcp8yeqgQKh26NSyXWngCDpXt0xLT/cljr2ek2WQ++Ea+YiYhKCNlHycA BZQXnwx9Ffr1T5U0XH4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDNQg-001CgI-Ct; Fri, 28 Jan 2022 09:20:26 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDNQB-001CVz-Oh for linux-arm-kernel@lists.infradead.org; Fri, 28 Jan 2022 09:19:59 +0000 Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4JlX1z2Y97z9sTp; Fri, 28 Jan 2022 17:18:31 +0800 (CST) Received: from huawei.com (10.175.124.27) by dggpeml500025.china.huawei.com (7.185.36.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 28 Jan 2022 17:19:37 +0800 From: Hou Tao To: Alexei Starovoitov CC: Martin KaFai Lau , Yonghong Song , Daniel Borkmann , Andrii Nakryiko , Song Liu , "David S . Miller" , John Fastabend , , , , Zi Shen Lim , Catalin Marinas , Will Deacon , Julien Thierry , Mark Rutland , Ard Biesheuvel , Subject: [PATCH bpf-next v2 0/2] arm64, bpf: support more atomic ops Date: Thu, 27 Jan 2022 15:53:20 +0800 Message-ID: <20220127075322.675323-1-houtao1@huawei.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500025.china.huawei.com (7.185.36.35) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220128_011956_039087_21D5E5AA X-CRM114-Status: UNSURE ( 7.24 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, Atomics support in bpf has already been done by "Atomics for eBPF" patch series [1], but it only adds support for x86, and this patchset adds support for arm64. Patch #1 changes the type of test program from fentry/ to raw_tp/ for atomics test, because bpf trampoline is not available for arm64 now. After the change, atomics test will be available for arm64 and other archs. Patch #2 implements atomic[64]_fetch_add, atomic[64]_[fetch_]{and,or,xor} and atomic[64]_{xchg|cmpxchg} for arm64. For no-LSE-ATOMICS case and cpus_have_cap(ARM64_HAS_LSE_ATOMICS) case, both ./test_verifier and "./test_progs -t atomic" are exercised and passed correspondingly. Comments are always welcome. Regards, Tao [1]: https://lore.kernel.org/bpf/20210114181751.768687-2-jackmanb@google.com/ Change Log: v2: * patch #1: use two seperated ASSERT_OK() instead of ASSERT_TRUE() * add Acked-by tag for both patches v1: https://lore.kernel.org/bpf/20220121135632.136976-1-houtao1@huawei.com/ Hou Tao (2): selftests/bpf: use raw_tp program for atomic test arm64, bpf: support more atomic operations arch/arm64/include/asm/insn.h | 45 +++- arch/arm64/lib/insn.c | 155 +++++++++++-- arch/arm64/net/bpf_jit.h | 43 +++- arch/arm64/net/bpf_jit_comp.c | 216 ++++++++++++++---- .../selftests/bpf/prog_tests/atomics.c | 121 +++------- tools/testing/selftests/bpf/progs/atomics.c | 28 +-- 6 files changed, 444 insertions(+), 164 deletions(-)