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: 56353 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1043935lbb; Tue, 10 Nov 2015 15:00:36 -0800 (PST) X-Received: by 10.68.65.8 with SMTP id t8mr6712799pbs.99.1447196436416; Tue, 10 Nov 2015 15:00:36 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gg7si7943576pbc.147.2015.11.10.15.00.36; Tue, 10 Nov 2015 15:00:36 -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; 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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752137AbbKJXA2 (ORCPT + 28 others); Tue, 10 Nov 2015 18:00:28 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:34756 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752046AbbKJXAY (ORCPT ); Tue, 10 Nov 2015 18:00:24 -0500 Received: by padhx2 with SMTP id hx2so10684313pad.1 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=cYDHI6OnYwF6cxa9Ft9ySkcp7klq+WV10kkz0/geE6QZIcS/sagHOVrWg9loR6edj4 VsoM3rOnXU9m+y60TB6O+guc5JAMoE07so7E6W5ivs+0q2KT/CO0AbNOUrMNIJwLGrdJ E5oypMdCjwVfk+V3STH5UGAC3ozXGAZZipRfkW/hkg97yVqOoDLVtRshwy+lqptl1uzZ ypnO8uE8scHV0ZXoVz6eGCXCjMSDB7BLoqAR8hi+ndkHzEIIJC8FmlPDgQ6RYC940zD8 aggPN2Z2ULuvgyUb2Xo8WHys+FIaY6LF/dX3J9zYMXZqJWhplu6L2GKR+QaMV4Jolp7Z EwtQ== X-Gm-Message-State: ALoCoQnyK0LscSipn9jMBvJ9QzFycmxl5VnVEgGt1l0pJ1m3HaqiY3JZGitVQQ2FNEUNOWuEtfT1 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 Cc: zlim.lnx@gmail.com, xi.wang@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.0.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ 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);