From patchwork Tue Nov 10 22:41:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 7592591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F19EF9F392 for ; Tue, 10 Nov 2015 23:02:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2237A20445 for ; Tue, 10 Nov 2015 23:02:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A8A4120498 for ; Tue, 10 Nov 2015 23:02:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwHuT-0007V7-Hs; Tue, 10 Nov 2015 23:01:05 +0000 Received: from mail-pa0-x232.google.com ([2607:f8b0:400e:c03::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwHu8-0007Gw-AG for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2015 23:00:44 +0000 Received: by pabfh17 with SMTP id fh17so10689947pab.0 for ; Tue, 10 Nov 2015 15:00:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aCCg+kcF9y89058Y7PAIdSlKS3XppLVKTMSvtr+M5sM=; b=G+UEJfRkC47mylpZ0zuylbFQqjTiixRl1IDghcTR+Q/jsRlgK9qIHOWsiFYxQXaD35 h5Z7kZ5yU5tHTSqJziX2bVBXuisr8Rb6FqAFS0NjFgGVwUDwELj2kzeKF3rRn7D6fRBl vbdz7Ou3+6ow9QexZpimlebXMmTCF4XFRw9sCV8FqKTx5O+thpliNE2RZy/Qn/mNPSvw 2Bc6Dm29OPjYcN/hfcp7CS3PVg4Tbv4eTA5oavFwDTmWWs3ZRDT1Z4bY2klWE08u0IhG JASIVrPfqU4BkhY90PMaTJiQHaDXlTWXfdN9Vi8SAkOqDm1gh/A5mGPZ801GPG3WxrEV KKlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aCCg+kcF9y89058Y7PAIdSlKS3XppLVKTMSvtr+M5sM=; b=O+gCVJbpqfW66HDsToo0ufKIgOr4uG+lO2jIRcKsWY0SWpPYomKM56feKOmfnp+WHh vK05IscdW69VM+3CcTU2J+/5/W38sjO+wRwDG7JVny98oQVOee/zySl9IOCzBO2Q+I4D 2H59WRazh77vgs3q22JgIJHXF6QZzUa/+80lgHk1oIBhDf8Qgprq5/yVNNib5nIABXSp NyNKidQBDveceKqcJUMNy0st6+SjXoH74LngjVPHa6a9V9lb3kUPRv66r5kpMFNqMFhz telmITZxUUxgVDg/mJfERzCJy/gfXCW95LBbGHoIPs9ebDGu+UFAroB+9s2HeIhkf6SQ pxdA== X-Gm-Message-State: ALoCoQnvA6J/Q4HOZlPbkS9PjTs2o1bi8OtB8yb0Z6caKVwxrHy2RomSNbZKWnLNfB7GOjHApvZr X-Received: by 10.68.218.1 with SMTP id pc1mr5539222pbc.132.1447196423280; Tue, 10 Nov 2015 15:00:23 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id c5sm6102743pbu.18.2015.11.10.15.00.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2015 15:00:22 -0800 (PST) From: Yang Shi To: ast@kernel.org, daniel@iogearbox.net, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH 2/2] arm64: bpf: add BPF XADD instruction Date: Tue, 10 Nov 2015 14:41:41 -0800 Message-Id: <1447195301-16757-3-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 In-Reply-To: <1447195301-16757-1-git-send-email-yang.shi@linaro.org> References: <1447195301-16757-1-git-send-email-yang.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151110_150044_501453_F480F784 X-CRM114-Status: GOOD ( 11.72 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.shi@linaro.org, linaro-kernel@lists.linaro.org, zlim.lnx@gmail.com, linux-kernel@vger.kernel.org, xi.wang@gmail.com, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP aarch64 doesn't have native support for XADD instruction, implement it by the below instruction sequence: Load (dst + off) to a register Add src to it Store it back to (dst + off) Signed-off-by: Yang Shi CC: Zi Shen Lim CC: Xi Wang --- arch/arm64/net/bpf_jit_comp.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 49c1f1b..0b1d2d3 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -609,7 +609,21 @@ emit_cond_jmp: case BPF_STX | BPF_XADD | BPF_W: /* STX XADD: lock *(u64 *)(dst + off) += src */ case BPF_STX | BPF_XADD | BPF_DW: - goto notyet; + ctx->tmp_used = 1; + emit_a64_mov_i(1, tmp2, off, ctx); + switch (BPF_SIZE(code)) { + case BPF_W: + emit(A64_LDR32(tmp, dst, tmp2), ctx); + emit(A64_ADD(is64, tmp, tmp, src), ctx); + emit(A64_STR32(tmp, dst, tmp2), ctx); + break; + case BPF_DW: + emit(A64_LDR64(tmp, dst, tmp2), ctx); + emit(A64_ADD(is64, tmp, tmp, src), ctx); + emit(A64_STR64(tmp, dst, tmp2), ctx); + break; + } + break; /* R0 = ntohx(*(size *)(((struct sk_buff *)R6)->data + imm)) */ case BPF_LD | BPF_ABS | BPF_W: @@ -679,9 +693,6 @@ emit_cond_jmp: } break; } -notyet: - pr_info_once("*** NOT YET: opcode %02x ***\n", code); - return -EFAULT; default: pr_err_once("unknown opcode %02x\n", code);