Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2146577rwr; Fri, 28 Apr 2023 06:49:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EA7k/TnzlQKHfWf+rPrXhX4XaIPCw3paFuV4MhTBkcIA3eXoNJVgELxiDhEdCY7yJH3/f X-Received: by 2002:a17:902:f551:b0:1a9:5674:281c with SMTP id h17-20020a170902f55100b001a95674281cmr6689789plf.23.1682689768502; Fri, 28 Apr 2023 06:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682689768; cv=none; d=google.com; s=arc-20160816; b=xm+MSX4/S1LYS/HWgxeGaqaJUO7kQkPtgKWsImb4gy0Fkvxv18fF6fJjc/EGgywKvD +42iiWwr9P0mcPmZMFxE/GyQWHeVFmAztAtrARk8elT92Qqtl5I1sUPYiB/QbKO5Dz8n bdI+lqGLk15RUa20QXfvf7MdMHrbzQi96+4j63m7YpMZCxkJgGFw0iY8jDh0zYfSg8mS +6BCa5gDbrlat5Aouxs4r3P0w6ydIm5XMLrnDKMmdrsO37+8Ra0GFzS2P+DStnolvumE uFdFPjAFH8gnhGOpYUHULekMdjdmEsVz+w45rrba8SQUi+LTybxlEL+MHdKxZ11gwi+5 cmxQ== 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:subject:cc:to:from:date; bh=IMooSr59G+CycusxeNL7xml4RUrwmj0lFy+rVrYvFEU=; b=L/1wERYsVfea2hgIjQ7VXnYG9mlNw21OMWhTty05bRwrKidlqg8m+fTlGSl42TUV1J pxIqtMHJP9/0vvl5PBYkfJUbRMmK8n8P5c1hXvQuHWoeU/a0aFdjNwdLUVRZMefv0KBx 3qrilw+EmJmHHpkfwGHT6qtJfrg7rRgd9odxb1lObJVHJRmt0XZoqoZq1sa4x/rbO07Q yHSwfaw4wY1mCJCtrotI8KIlS7h3CHse0b7WTZBd4ilLn22Z0lVruo1Bmq0Pa0lIWNt4 HXjBf+Fwz4a9k3RVnMucej3MmQkYM80ULOcBMs067IBvaOk4ghAsDmpbJqt9CWoK3T0D Z7DA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a17090341ca00b001a63d8efabasi22421225ple.445.2023.04.28.06.49.14; Fri, 28 Apr 2023 06:49:28 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346335AbjD1NpC (ORCPT + 99 others); Fri, 28 Apr 2023 09:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjD1NpA (ORCPT ); Fri, 28 Apr 2023 09:45:00 -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 1588E268D; Fri, 28 Apr 2023 06:45:00 -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 A017663532; Fri, 28 Apr 2023 13:44:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55576C433EF; Fri, 28 Apr 2023 13:44:57 +0000 (UTC) Date: Fri, 28 Apr 2023 09:44:54 -0400 From: Steven Rostedt To: "Hou Wenlong" Cc: linux-kernel@vger.kernel.org, "Thomas Garnier" , "Lai Jiangshan" , "Kees Cook" , "Masami Hiramatsu" , "Mark Rutland" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , "Huacai Chen" , "Qing Zhang" , Subject: Re: [PATCH RFC 22/43] x86/ftrace: Adapt ftrace nop patching for PIE support Message-ID: <20230428094454.0f2f5049@gandalf.local.home> In-Reply-To: <38a5029cd2590e04209117740f8912db36eff58f.1682673543.git.houwenlong.hwl@antgroup.com> References: <38a5029cd2590e04209117740f8912db36eff58f.1682673543.git.houwenlong.hwl@antgroup.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 On Fri, 28 Apr 2023 17:51:02 +0800 "Hou Wenlong" wrote: > From: Thomas Garnier > > From: Thomas Garnier > > When using PIE with function tracing, the compiler generates a > call through the GOT (call *__fentry__@GOTPCREL). This instruction > takes 6-bytes instead of 5-bytes with a relative call. And -mnop-mcount > option is not implemented for -fPIE now. > > If PIE is enabled, replace the 6th byte of the GOT call by a 1-byte nop > so ftrace can handle the previous 5-bytes as before. Wait! This won't work! You can't just append another nop to fill in the blanks here. We must either have a single 6 byte nop, or we need to refactor the entire logic to something that other archs have. The two nops means that the CPU can take it as two separate commands. There's nothing stopping the computer from preempting a task between the two. If that happens, and you modify the 1byte nop and 5byte nop with a single 6 byte command, when the task get's rescheduled, it will execute the last 5 bytes of that 6 byte command and take a general protection fault, and likely crash the machine. NACK on this. It needs a better solution. -- Steve > > [Hou Wenlong: Adapt code change and fix wrong offset calculation in > make_nop_x86()] >