Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1860939rwr; Fri, 28 Apr 2023 02:55:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4P1DTcKxlY5WSxeGcZ3Iso+OTjkp1ILFjUvDVxGluNjS3i3JwGXpmvuBkeSp46ggS2ALpE X-Received: by 2002:a05:6a20:7490:b0:f0:fa9b:d4c7 with SMTP id p16-20020a056a20749000b000f0fa9bd4c7mr6182065pzd.55.1682675731248; Fri, 28 Apr 2023 02:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682675731; cv=none; d=google.com; s=arc-20160816; b=eCHpUvbM9z+PXtAHyzeUICCdswyQffa9DSUUoqYM7mEbFuiKMoq2/gYH/XQw8lWaNN 6WvNy7XtEAJCYdkZGlt40gOceTg6nW8kZRQw9m+AiVYWfwY/T30ZGWVo91hMsgiOxNcx oWcXDu0LksC0M30oB0aHiCpJmAgDPMGFJlRyVM95TsjfadNjZIqWDvvHk9N0ZHRMY6nS 5vbrMEjrxdBvcb9x/IkSM3lvlW+dOb+hWMaeJN8oEkoqure7ZjaqlUZLZtCX2whSSm/s hgbValrl2bZh5GjjILCpMqN8eDRltHh4IWdA/kbw+iggUzXqBYx8JVyCOu3sTNhT91ui TlvA== 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; bh=isBkn1tLNfql1GLqc9X8doCnxzEXWQyuL3aVxGfq4tY=; b=0MyEiSom0OZFnm6OupJEmD2LbV7YP9L4zJwBPydP4/l44Bdqf+LqBYPJl2HQM3V7Uq tumGBSqEr9VtPn0WUPhr8+hYIQWim7mUeGxrvdGS9xCmH9XDLeTTHfs7SbliE7/xPku/ zhtkgo5J/1VDuOgOlwOWMHNnKMneF63xWswA05jxaomDxe+T/O52uXCjCTch/gXuEK6i nuvQqPgKzUSOeUhX4xNJcqImsQRaFitOQqWyHe+eWJRUb97a7IXVxr1zkH/0oFWtQVU9 qSw8sclm7F5u6sgzKiWHwiSRRWfSkiDc8IJ9WwMMukaq98tzKBtKMg+DeJP7qYhgUa31 /E/w== 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020a63d001000000b005023e0f160dsi21136528pgf.489.2023.04.28.02.55.19; Fri, 28 Apr 2023 02:55:31 -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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345819AbjD1JzA (ORCPT + 99 others); Fri, 28 Apr 2023 05:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345886AbjD1Jyv (ORCPT ); Fri, 28 Apr 2023 05:54:51 -0400 Received: from out187-3.us.a.mail.aliyun.com (out187-3.us.a.mail.aliyun.com [47.90.187.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36E0D5593; Fri, 28 Apr 2023 02:54:24 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047201;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---.STDfs4A_1682675577; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.STDfs4A_1682675577) by smtp.aliyun-inc.com; Fri, 28 Apr 2023 17:52:58 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Thomas Garnier" , "Lai Jiangshan" , "Kees Cook" , "Hou Wenlong" , "Steven Rostedt" , "Masami Hiramatsu" , "Mark Rutland" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , Subject: [PATCH RFC 21/43] x86/ftrace: Adapt assembly for PIE support Date: Fri, 28 Apr 2023 17:51:01 +0800 Message-Id: <0092ce94b325ad8eb47ff4f95e012f9af1a127de.1682673543.git.houwenlong.hwl@antgroup.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Signed-off-by: Hou Wenlong Cc: Thomas Garnier Cc: Lai Jiangshan Cc: Kees Cook --- arch/x86/kernel/ftrace_64.S | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S index eddb4fabc16f..411fa4148e18 100644 --- a/arch/x86/kernel/ftrace_64.S +++ b/arch/x86/kernel/ftrace_64.S @@ -315,7 +315,14 @@ STACK_FRAME_NON_STANDARD_FP(ftrace_regs_caller) SYM_FUNC_START(__fentry__) CALL_DEPTH_ACCOUNT +#ifdef CONFIG_X86_PIE + pushq %r8 + leaq ftrace_stub(%rip), %r8 + cmpq %r8, ftrace_trace_function(%rip) + popq %r8 +#else cmpq $ftrace_stub, ftrace_trace_function +#endif jnz trace RET @@ -329,7 +336,7 @@ trace: * ip and parent ip are used and the list function is called when * function tracing is enabled. */ - movq ftrace_trace_function, %r8 + movq ftrace_trace_function(%rip), %r8 CALL_NOSPEC r8 restore_mcount_regs -- 2.31.1