Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6947694ioo; Thu, 2 Jun 2022 17:58:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRBB4Q2V+hw7R1ssMkRfFESsgLWeeMtaHv0JJMhAzOA1wLtfZhNkmjW9CCpg1cxY1Eoeju X-Received: by 2002:a17:907:628a:b0:6fe:526c:ebc with SMTP id nd10-20020a170907628a00b006fe526c0ebcmr6501004ejc.531.1654217937927; Thu, 02 Jun 2022 17:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654217937; cv=none; d=google.com; s=arc-20160816; b=GGUFeypbVrqMiQAsdeO2FcL+XsMRyvyBmLjT2ohCSB3WtntcnVKC59Q2oA3zzNCKQ1 VmuYxp9IW7SkXKzzFALjLVhW5giGnedpUsaCi3B+qHMd2PG2Cqnu9eQWo4mTycaCJTCq /11qoHgcSC9QLGWbhU9+4MY1vsWUqIsOuG7R25U6yrP+S1H+LSmFzBFH4RedB/kSbE4e K18SC5kJ7EUF4O8X2lhpI7AKKbwl1nGVrytkrj3xqb8+W2oIeHczCz6zFaVmnPl0GNlV 0VSljHFdhyh6yOaEwrGYIzQsZFxOWyXaor02mC9LDQQTm3Pf2RNdwcEp8lwvvRxF3Z0K flpg== 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 :message-id:date:subject:cc:to:from; bh=A4Bte71N4qy7LgJAcOV3TZbyb5QNwARBHLiu2ONFqFA=; b=AGFTtBHxb7bZoc5rqlucL9W+XfiPXSq2GpM2dWDAzK+OEQknuGWB8vBbvVwMkNQTW9 G5i+Lweysfr3zGkuw2wN3LcOegMf7o7FajdpizR3VMhzsqq9KoXfvFjlgBb1kdLd5AeB UdKePxo9vFfrIN43aqEq42LrCwvyUqRmhIcibrIZfUu4fenMKV/wCrTtBn+kWXGObi0u p761xnxTOOg5FuXqoSClTO5ABeNpvtPkU1SCH2DHdZ8IPQKQEEHa5bJgo6aEZu3VAU6z eg4/reNkXhr6Pje3TSGhvFFISvHZmKXQp8DPXEHIvJXPw+gu6vNtKEYzIV3Inkgj2aiF kv0A== ARC-Authentication-Results: i=1; mx.google.com; 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 js22-20020a17090797d600b00708884b555asi5567115ejc.392.2022.06.02.17.58.29; Thu, 02 Jun 2022 17:58:57 -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; 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 S235313AbiFBTtJ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 2 Jun 2022 15:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239021AbiFBTs6 (ORCPT ); Thu, 2 Jun 2022 15:48:58 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E5E02E090 for ; Thu, 2 Jun 2022 12:48:48 -0700 (PDT) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2529sgXB008870 for ; Thu, 2 Jun 2022 12:48:48 -0700 Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3geu05bgdc-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 02 Jun 2022 12:48:47 -0700 Received: from twshared14818.18.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 2 Jun 2022 12:48:43 -0700 Received: by devbig932.frc1.facebook.com (Postfix, from userid 4523) id 531D786C006A; Thu, 2 Jun 2022 12:37:12 -0700 (PDT) From: Song Liu To: , , CC: , , , , , , , Song Liu Subject: [PATCH v2 bpf-next 0/5] ftrace: host klp and bpf trampoline together Date: Thu, 2 Jun 2022 12:37:01 -0700 Message-ID: <20220602193706.2607681-1-song@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: PtGov_HuZUxM4rCntXL3RxebVpgGhFhT X-Proofpoint-ORIG-GUID: PtGov_HuZUxM4rCntXL3RxebVpgGhFhT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-02_05,2022-06-02_01,2022-02-23_01 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Changes v1 => v2: 1. Fix build errors for different config. (kernel test robot) Kernel Live Patch (livepatch, or klp) and bpf trampoline are important features for modern systems. This set allows the two to work on the same kernel function as the same time. live patch uses ftrace with IPMODIFY, while bpf trampoline use direct ftrace. Existing policy does not allow the two to attach to the same kernel function. This is changed by fine tuning ftrace IPMODIFY policy, and allows one non-DIRECT IPMODIFY ftrace_ops and one non-IPMODIFY DIRECT ftrace_ops on the same kernel function at the same time. Please see 3/5 for more details on this. Note that, one of the constraint here is to let bpf trampoline use direct call when it is not working on the same function as live patch. This is achieved by allowing ftrace code to ask bpf trampoline to make changes. Jiri Olsa (1): bpf, x64: Allow to use caller address from stack Song Liu (4): ftrace: allow customized flags for ftrace_direct_multi ftrace_ops ftrace: add modify_ftrace_direct_multi_nolock ftrace: introduce FTRACE_OPS_FL_SHARE_IPMODIFY bpf: trampoline: support FTRACE_OPS_FL_SHARE_IPMODIFY arch/x86/net/bpf_jit_comp.c | 13 +- include/linux/bpf.h | 8 ++ include/linux/ftrace.h | 79 +++++++++++ kernel/bpf/trampoline.c | 109 +++++++++++++-- kernel/trace/ftrace.c | 269 +++++++++++++++++++++++++++++++----- 5 files changed, 424 insertions(+), 54 deletions(-) -- 2.30.2