Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp302070lqp; Thu, 21 Mar 2024 01:19:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVz1nYHmVtso7pCFi1AXrZiBgS6jffzAcFCvv+O+1xXWVBRJZHAlvw6L03q0JpnD92acqT1VKKBA/tu7UF/hGeE1OOmXg5vbGTRW+uUEQ== X-Google-Smtp-Source: AGHT+IHQIpxIWc+BZmO5lOEJMh9PdIXWVuX174/+4Dd6UAt2Z5KB2Bc99nT/UaQK9BN1bj11W7Yh X-Received: by 2002:a50:aace:0:b0:568:d19e:7ab0 with SMTP id r14-20020a50aace000000b00568d19e7ab0mr1173725edc.36.1711009143973; Thu, 21 Mar 2024 01:19:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711009143; cv=pass; d=google.com; s=arc-20160816; b=WCK5O1BKcosg9rbv+bYRrzBiuvS9yzNjZxC/81xsg0r25GAX0eobGBfklz8pKrcUD0 HiUpqJ94qptg9DlzxuUQqeU87PVK7hRQdysgyVI8a53YdnU3nRJ0KN4FbN3a2C3HUrzf d3L/6L4wWcn38aFBgcP7YqzmyMvRc0roWS6fi2BAiMMw5/TCaOaCPR0iTk3KVMsCRNvu 2OhRv2cMug3uQ7hJCoxzdvKq7dDW0TIXR83sHG+r+tLxKRka7/vSoRH/X0olLurUXCMh Ocr4ffNMe1agQEOVidtrL/4lUN6nkVt9k1Jc/d9gOa1ACv4RHJv71t1zR+QwAZhSXz6T 8+jg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fNwara8hmM/oqZZWTbZfweFJpIhXMITtHmwHDwGJec8=; fh=So5eKGE8n49hs4NprCtBBw8PCkZz19hQ3GCO5S8nT04=; b=oZm1vw97PI7BLoV8UXUqpdAEo0+SdibvINSURRnH0fkVP5qaWmEJfQCpK8B9Neubki 407wKR9dooA2MWAuJbnqALPCxB4yr4k+yM9JHSJhp4nQUUvdYCJI9J14gLuc4+7KZyaU F639yVOSHDoma3tP9fd/cWwMK4o3g7kcObT0jwwrwJJTCsZSWtGZiBqh1TVDdX0OEDjE mDomwfW7dAIzjHWqK+oQwS9tq5D/pFO0q273tq/j76LUff72eQ7nxp1Mn+s12mwzwLmi QbERkKNhkdAqvHL1EgKwebYQOMDRq9dsnSPZkgcQvAUdeHGzyzIEvWz7RtheaLHLOviu uKww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="aTjTpQ7/"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-109778-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109778-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n7-20020a056402434700b0056bb6b87559si1157022edc.216.2024.03.21.01.19.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 01:19:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109778-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="aTjTpQ7/"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-109778-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109778-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AB8411F21005 for ; Thu, 21 Mar 2024 08:19:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A4025D733; Thu, 21 Mar 2024 08:18:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aTjTpQ7/" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 518405A0FE for ; Thu, 21 Mar 2024 08:18:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711009099; cv=none; b=UuRQztmborAsd7TKd+cyI0MGTSh08ow/BE3Y7qDq8OZognceKfdwNpsqSE/oleTUQr/rQ9+Td1pAcvPa8kDJQzbOT2KY3Br9niC/HBKhEIImb0X1SxLu+lhqNELrFQ2S3kuhrlnviJcwT7qplcL6gubfNpbCYmdUZjg+v37yEvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711009099; c=relaxed/simple; bh=tUl6Y+ILB3eCX9Bq6p+WZ/03L1ZXrx8Zy6xZm4TJ2Rg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BPVVLNaD0kRCMp4tkyXzbfACH9pSFqYzZQVteUEHQG1+tgIGLOfdfye+YrwwGuQC15boI14SrQTEtNSNEltypiPBwA+H77rZEc+jozhn3sFcv6C2ngp+v33tJ96ZR5hkPE9D9O0wKGl/yoZWrON9xccsF14Zxvw1C5k6pkLFj6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=aTjTpQ7/; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711009096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fNwara8hmM/oqZZWTbZfweFJpIhXMITtHmwHDwGJec8=; b=aTjTpQ7/2IL0nIsYZbPSd/NLSsGn8FYe8OfN473HY9NGIqDO19XzZTMm8SGbMBZMQkXXd0 48wxtCP+ES88PkuiVL13ZeB+PkOwmTeWYglyzPOZmy6Y47iwbIOubUK8A39U5tmqsN7vIU vFM4O60OELjZipfGrRtPwv+Rb2JrOvw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-wsHdh9YcM1OadUS2IBFShg-1; Thu, 21 Mar 2024 04:18:14 -0400 X-MC-Unique: wsHdh9YcM1OadUS2IBFShg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A11E9185A786; Thu, 21 Mar 2024 08:18:13 +0000 (UTC) Received: from alecto.usersys.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0A041C060A4; Thu, 21 Mar 2024 08:18:11 +0000 (UTC) From: Artem Savkov To: Xu Kuohai , Xi Wang , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf@vger.kernel.org, netdev@vger.kernel.org Cc: Catalin Marinas , linux-kernel@vger.kernel.org, Artem Savkov , Puranjay Mohan Subject: [PATCH bpf-next v2] arm64: bpf: fix 32bit unconditional bswap Date: Thu, 21 Mar 2024 09:18:09 +0100 Message-ID: <20240321081809.158803-1-asavkov@redhat.com> In-Reply-To: <20240313140205.3191564-1-asavkov@redhat.com> References: <20240313140205.3191564-1-asavkov@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 In case when is64 == 1 in emit(A64_REV32(is64, dst, dst), ctx) the generated insn reverses byte order for both high and low 32-bit words, resuling in an incorrect swap as indicated by the jit test: [ 9757.262607] test_bpf: #312 BSWAP 16: 0x0123456789abcdef -> 0xefcd jited:1 8 PASS [ 9757.264435] test_bpf: #313 BSWAP 32: 0x0123456789abcdef -> 0xefcdab89 jited:1 ret 1460850314 != -271733879 (0x5712ce8a != 0xefcdab89)FAIL (1 times) [ 9757.266260] test_bpf: #314 BSWAP 64: 0x0123456789abcdef -> 0x67452301 jited:1 8 PASS [ 9757.268000] test_bpf: #315 BSWAP 64: 0x0123456789abcdef >> 32 -> 0xefcdab89 jited:1 8 PASS [ 9757.269686] test_bpf: #316 BSWAP 16: 0xfedcba9876543210 -> 0x1032 jited:1 8 PASS [ 9757.271380] test_bpf: #317 BSWAP 32: 0xfedcba9876543210 -> 0x10325476 jited:1 ret -1460850316 != 271733878 (0xa8ed3174 != 0x10325476)FAIL (1 times) [ 9757.273022] test_bpf: #318 BSWAP 64: 0xfedcba9876543210 -> 0x98badcfe jited:1 7 PASS [ 9757.274721] test_bpf: #319 BSWAP 64: 0xfedcba9876543210 >> 32 -> 0x10325476 jited:1 9 PASS Fix this by forcing 32bit variant of rev32. Fixes: 1104247f3f979 ("bpf, arm64: Support unconditional bswap") Signed-off-by: Artem Savkov Tested-by: Puranjay Mohan Acked-by: Puranjay Mohan --- arch/arm64/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index c5b461dda4385..c3ededd23cbf6 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -943,7 +943,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, emit(A64_UXTH(is64, dst, dst), ctx); break; case 32: - emit(A64_REV32(is64, dst, dst), ctx); + emit(A64_REV32(0, dst, dst), ctx); /* upper 32 bits already cleared */ break; case 64: -- 2.44.0