Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1067481rwr; Thu, 4 May 2023 13:41:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78vOXbnVKZK2y4Z/dOiGAunRRbRsSJFl7lTkQllJnd65x+ZaQN3cCjgNGBMkeHcHTpXCnw X-Received: by 2002:a05:6a00:21d4:b0:63b:62d1:d868 with SMTP id t20-20020a056a0021d400b0063b62d1d868mr3856035pfj.8.1683232874002; Thu, 04 May 2023 13:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683232873; cv=none; d=google.com; s=arc-20160816; b=BKSnh5eSQnMN59rPZZECk8ueoZ8Vx3Q/ZjHiFE2DxzRBXM4QZnKSJ+AusS21iNiKoY YmeDcrg8Tp2H9QJRFeq6+bTT+UzRTFjRL4ufn1XnRtAh5p2X6huU+P4uDHqNrM5gI0+K +tpRNF+AMX0oNPtq3F3czkVmCB7S1bkxHraS15eNbRXUHUb5VD6tfKh9547+1Twc+vkq /DG/A/CTnb3BnwDThpqvh2rYV02PomlWG79xW7/ROxG/NQhnQJEq236QsPQYYzRj7iYp 6WbHpv0QxYqCOWFQHzcCl03jw8VeWuGm3vNuNgCEXSL6x/4lg3dfnuib53mlAQe5VRuY 0RXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6okVxbeHBRAn2bGrulOYh3168Je8y3zfaBovlNxroTk=; b=jKq2K6BqfPjDijI80/kUiQHpB28ztCwNBrwut81sQNP0iy5bnGRA3BQ7ijNydIcSyl MsD794cWu3XNQo1x/F2BZtIxMKJEp6428dmoi5r59pVRrbkgPnD1EaLtMp+WRye7I3Fe 5kMoxwR2Y44sbjQlAqYJt/P8nwCNZ5Ocl+HgygJtq+hP7dyGlSgUDkR1n3FzDsIr5aSI uuXIOBdc4llY+PWbhqeDRwkTE2RlHE25NJPIeTbsUSrF/H0qw+BK3RzMw85OJGBseduL ig8Kt5+vgPTBBtqLzlWpUsdFrEt1IPrBsbrw4NlISpGQ1KC5TY2NE4rMgWuExxEhO5ir Kilw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=up5Bk7EF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i124-20020a639d82000000b0052c885da616si287853pgd.337.2023.05.04.13.41.01; Thu, 04 May 2023 13:41:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=up5Bk7EF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbjEDTmr (ORCPT + 99 others); Thu, 4 May 2023 15:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjEDTmo (ORCPT ); Thu, 4 May 2023 15:42:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF5A93FC; Thu, 4 May 2023 12:42:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 18761636FD; Thu, 4 May 2023 19:42:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 359AAC433EF; Thu, 4 May 2023 19:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683229333; bh=yGdU6LmRneX8nmQX8uyT5+6jzBckt9pX6pzjCTeRi0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=up5Bk7EF5nRxMm1nEmcOJjDb/HdVhTu9QezQ1272GuQVm+Ha44TZxMMozvP1LgQ3Q siwMYouvP42rXuzFx4ukC9tODIu0ADWkG2gK3v2sXt7Xyr5ukoX/J2rpC5JyoZWAT5 OHV9JAhS6n7Pdes1LbctROp3BHzGNw+A5SICvIJFxET22gfuB8jLN50hwZ60lVX8Kk Z90ZUanyA0vWgdYIW4/ib775kfsTgTKIBRrNlNlsIurjTS+ilv9ghkby6VJLodYLRf Z0h1iHcRkR6/opv+i+/9+7ntOfrSj9y3twLPnjBKgzKCV9XjH6hf1EaBYCXMjtzkp/ YsK2LxxOigbkQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jiaxun Yang , Daniel Borkmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Johan Almbladh , Sasha Levin , tsbogend@alpha.franken.de, ast@kernel.org, andrii@kernel.org, paulburton@kernel.org, linux-mips@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 6.3 08/59] bpf, mips: Implement DADDI workarounds for JIT Date: Thu, 4 May 2023 15:40:51 -0400 Message-Id: <20230504194142.3805425-8-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230504194142.3805425-1-sashal@kernel.org> References: <20230504194142.3805425-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiaxun Yang [ Upstream commit bbefef2f07080cd502a93cb1c529e1c8a6c4ac8e ] For DADDI errata we just workaround by disable immediate operation for BPF_ADD / BPF_SUB to avoid generation of DADDIU. All other use cases in JIT won't cause overflow thus they are all safe. Signed-off-by: Jiaxun Yang Signed-off-by: Daniel Borkmann Reviewed-by: Philippe Mathieu-Daudé Acked-by: Johan Almbladh Link: https://lore.kernel.org/bpf/20230228113305.83751-2-jiaxun.yang@flygoat.com Signed-off-by: Sasha Levin --- arch/mips/Kconfig | 1 - arch/mips/net/bpf_jit_comp.c | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index e2f3ca73f40d6..edc7d8790f1e8 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -64,7 +64,6 @@ config MIPS select HAVE_DMA_CONTIGUOUS select HAVE_DYNAMIC_FTRACE select HAVE_EBPF_JIT if !CPU_MICROMIPS && \ - !CPU_DADDI_WORKAROUNDS && \ !CPU_R4000_WORKAROUNDS && \ !CPU_R4400_WORKAROUNDS select HAVE_EXIT_THREAD diff --git a/arch/mips/net/bpf_jit_comp.c b/arch/mips/net/bpf_jit_comp.c index b17130d510d49..a40d926b65139 100644 --- a/arch/mips/net/bpf_jit_comp.c +++ b/arch/mips/net/bpf_jit_comp.c @@ -218,9 +218,13 @@ bool valid_alu_i(u8 op, s32 imm) /* All legal eBPF values are valid */ return true; case BPF_ADD: + if (IS_ENABLED(CONFIG_CPU_DADDI_WORKAROUNDS)) + return false; /* imm must be 16 bits */ return imm >= -0x8000 && imm <= 0x7fff; case BPF_SUB: + if (IS_ENABLED(CONFIG_CPU_DADDI_WORKAROUNDS)) + return false; /* -imm must be 16 bits */ return imm >= -0x7fff && imm <= 0x8000; case BPF_AND: -- 2.39.2