From patchwork Wed Oct 28 17:15:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 316096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE633C388F7 for ; Thu, 29 Oct 2020 01:21:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 996BC20731 for ; Thu, 29 Oct 2020 01:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603934510; bh=FsmcOn0XxpUX5de9S0UmGY+4ZGOqbW4cCRPICKIXKI4=; h=From:To:Cc:Subject:Date:List-ID:From; b=O+4h2xsT6aXZfovP/nyev7/5hRqmpYctHnCUJAijqn3qHc4RRRsm/aZsbCIJxNJhf 2CZL6VlpdQ6bKzb1BEbSUpkqXSlV1g702B+skXbxSMJRJNo/TY08Nvse7Q0zdHCJ8x uFK4+UXbpCZg169FuELRdoArKEFLupeSHT6LMGhU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729684AbgJ1WE6 (ORCPT ); Wed, 28 Oct 2020 18:04:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:50704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729508AbgJ1WCX (ORCPT ); Wed, 28 Oct 2020 18:02:23 -0400 Received: from e123331-lin.nice.arm.com (lfbn-nic-1-188-42.w2-15.abo.wanadoo.fr [2.15.37.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA850247F5; Wed, 28 Oct 2020 17:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603905313; bh=FsmcOn0XxpUX5de9S0UmGY+4ZGOqbW4cCRPICKIXKI4=; h=From:To:Cc:Subject:Date:From; b=NF6yHpW3jDsvWT6SJd9HhXl7b6oqz9sIEwd04rVK4NSy14dPU/rkmGH6SIv1YrILN 2gNIEFCQsug2/rZ1HaJlj57elsl5UcgBaYU4petFMPCGb7JZOhmYkhIDcuqzQ06lzI B+TZ0wVcZ2fGIg/Q7v0lAo6dKYN2geM0EFiiH28c= From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, arnd@arndb.de, Ard Biesheuvel , Nick Desaulniers , Arvind Sankar , Randy Dunlap , Josh Poimboeuf , Thomas Gleixner , Alexei Starovoitov , Daniel Borkmann , Peter Zijlstra , Geert Uytterhoeven , Kees Cook Subject: [PATCH v2 0/2] get rid of GCC __attribute__((optimize)) for BPF Date: Wed, 28 Oct 2020 18:15:04 +0100 Message-Id: <20201028171506.15682-1-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a followup to [0]: [PATCH] bpf: don't rely on GCC __attribute__((optimize)) to disable GCSE[0] Changes since v1: - only use -fno-gcse when CONFIG_BPF_JIT_ALWAYS_ON=y and CONFIG_CC_IS_GCC=y (but ignore CONFIG_RETPOLINE since we want to avoid GCSE in all cases) - to avoid potential impact of disabling GCSE on other code, put the interpreter in a separate file (patch #2) Note that patch #1 is intended for backporting, as function scope GCC optimization attributes are really quite broken. I don't have a strong opinion on whether the interpreter code should be split off or not, but it looks like it can be done fairly painlessly, so it is probably a good idea to do it anyway. [0] https://lore.kernel.org/bpf/20201027205723.12514-1-ardb@kernel.org/ Cc: Nick Desaulniers Cc: Arvind Sankar Cc: Randy Dunlap Cc: Josh Poimboeuf Cc: Thomas Gleixner Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Peter Zijlstra (Intel) Cc: Geert Uytterhoeven Cc: Kees Cook Ard Biesheuvel (2): bpf: don't rely on GCC __attribute__((optimize)) to disable GCSE bpf: move interpreter into separate source file include/linux/compiler-gcc.h | 2 - include/linux/compiler_types.h | 4 - include/linux/filter.h | 1 + kernel/bpf/Makefile | 7 +- kernel/bpf/core.c | 567 ------------------ kernel/bpf/interp.c | 601 ++++++++++++++++++++ 6 files changed, 607 insertions(+), 575 deletions(-) create mode 100644 kernel/bpf/interp.c