From patchwork Fri Jan 21 13:56:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 12719745 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 3F8CAC433F5 for ; Fri, 21 Jan 2022 13:59:06 +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=bdN5aIHbvQ0efPJUTBmA8BQCG8iZdgMYy1KaXp5VX30=; b=PtaxR+jPs/oHup 2BGOx8kfo8crXKujSYkgrWC+sbt2OjG4IH+b1JVDDPxuPPyKO+ekynw0YShNQjr3TLBRoOM3DpIe/ k/ogtvhPJQEb2ChvkZbfNHX4M80f0y4+lPRP+lBP1X34hsQNsDzBte9Mcjf8A3k6UmCQTzfjsMg8m G0d4i9tENOzg1nLnauhO54kaCmwEJ1jMgkY3aKFJvPVtx9voGo90veo7fORfbWuq56aXcKS8qYGF9 mFXQaMu1b+rZEbWga2htfvk7soNRvnNkVVcDABkNJCO89WGOON/R/dM34ttROyoZJmQZFCUcfa6GL uxvsDmTjrlWthNMF385g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAuQF-00FFhY-1G; Fri, 21 Jan 2022 13:57:47 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAuQA-00FFb4-UM for linux-arm-kernel@lists.infradead.org; Fri, 21 Jan 2022 13:57:45 +0000 Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4JgLTr5GCFz8wTF; Fri, 21 Jan 2022 21:54:40 +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.20; Fri, 21 Jan 2022 21:57:32 +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 0/2] arm64, bpf: support more atomic ops Date: Fri, 21 Jan 2022 21:56:30 +0800 Message-ID: <20220121135632.136976-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: dggems703-chm.china.huawei.com (10.3.19.180) 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-20220121_055743_206619_95131061 X-CRM114-Status: UNSURE ( 6.97 ) 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 arches. 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 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 | 114 +++------ tools/testing/selftests/bpf/progs/atomics.c | 29 +-- 6 files changed, 438 insertions(+), 164 deletions(-)