Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp283574pxb; Wed, 3 Feb 2021 05:39:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwALszcFpY5CtPY34BrYiUzQmLyRG3u6adULmoiosHHfO7gMPI2r3ENRvAQWkX8HfnpBZ83 X-Received: by 2002:a17:906:344d:: with SMTP id d13mr3245357ejb.367.1612359583695; Wed, 03 Feb 2021 05:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612359583; cv=none; d=google.com; s=arc-20160816; b=vRjHsEMVp9u+Nd0VzbGm4TGiJvBUqNzJAInyfpHePEByxBEi/8jN3ylkMVP/b8UdpR FQhmzMDIPZga6tgULfLIDxF2yF/cuP2jLwerNhcNWttLo0vde23bCPFFdPWaDYUYylu/ j0bQwXncqSTzfbljqv+SOtPX5s5gxHvADSP8jwXk5cOv9ikIU+Zct1fOOevMm//LwZOj SMc4zTfGxXsqtVixatAjXutaNND+ne39shAMbbUASJ37C/w0of66WMvM7Q40wVRUXdS+ 2t7+ZBtFagojgAhhyHuxHFuXnY6WkCrlCE2YKR8Ubewdn1bNaHfovZnMDykweS4/OYjX Pa9g== 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 :dkim-signature; bh=yIsX+jGbwmNxjUFiVGrTOWe0ROe6uInKYABEIeY2mN8=; b=xO1DHzfE2lE893tTel6p+IvhUunK4swYEyj40XcZZzsixA7yH89cMPCQs9vayCxcCk woQNVTiIQMUFupZ/3NXEtROiwZnVuq5Xf+sDfx+gqUdWE3H7c47QAqM3yXEdTfFgnzWe s4EBOh/xQChpLWJIsuyBWG68weiLEdNpA0uNd2DogR1Vk4ddmLqA705F2f4sxwvmq62I E5JpFvsnPnSVSgnTFd/rdiP3hb98IOV3HI+cbj4ViAu1zl/wpU74LxYX7FB5LjgVlAfi P9SyTaZAdvX167jUbG+QhK5pEApUVqDrcoK86WrlTYnRU+6YMF2tBRX3S3upMKS3iX+c SEKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mJgTVWTu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l19si1415596ejb.324.2021.02.03.05.39.19; Wed, 03 Feb 2021 05:39:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mJgTVWTu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231867AbhBCNga (ORCPT + 99 others); Wed, 3 Feb 2021 08:36:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:40008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbhBCNeQ (ORCPT ); Wed, 3 Feb 2021 08:34:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C832C64F60; Wed, 3 Feb 2021 13:33:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612359214; bh=XZj7mDrQP+rPOgqmalaKB74DR65xAbL5fJISLaH4o24=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mJgTVWTunjnJgy+7Ky8HStxLhhswQvHy44xnsh5Yw+atc02TtfFiAI/DrIkuc5wxm eJyNVt78nw0c5vKatUuMI8jY4mICCh/nHmqtOpcs3sxQ5ROThw93R4rLseoVcW+dF9 at5Shobxoa2hqeSiPYLt/nN8I7P4mLbu4OkhLfYwmJxCgtB4u7QNaEemuXIMAaqMri WV5yf+ViAvpnNRdTqnvhy1ByP+LjZKt2XShnoG7d8Y5uH4tcMCt+SFMD/UDkczWP02 /bQoqEXFcoxi0kOsZBD84rUS41OAZuitbAVh0T7Ez8dpdb5HLqjirP2H2eIYOi/3e4 Zkf6q7/hHUOFg== Date: Wed, 3 Feb 2021 22:33:28 +0900 From: Masami Hiramatsu To: Steven Rostedt Cc: Peter Zijlstra , Alexei Starovoitov , Masami Hiramatsu , Nikolay Borisov , LKML , Alexei Starovoitov , bpf , Josh Poimboeuf Subject: Re: kprobes broken since 0d00449c7a28 ("x86: Replace ist_enter() with nmi_enter()") Message-Id: <20210203223328.9e99548d19d482ac2e2cda81@kernel.org> In-Reply-To: <20210202160513.38ada3a7@gandalf.local.home> References: <20210129175943.GH8912@worktop.programming.kicks-ass.net> <20210129140103.3ce971b7@gandalf.local.home> <20210129162454.293523c6@gandalf.local.home> <20210130074410.6384c2e2@oasis.local.home> <20210202095249.5abd6780@gandalf.local.home> <20210202115623.08e8164d@gandalf.local.home> <20210202160513.38ada3a7@gandalf.local.home> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2 Feb 2021 16:05:13 -0500 Steven Rostedt wrote: > On Tue, 2 Feb 2021 19:30:34 +0100 > Peter Zijlstra wrote: > > > That does mean that kprobes are then fundamentally running from > > in_nmi(), which is what started all this. > > I just thought about the fact that tracing records the context of the > function it is called in. If you set "in_nmi()" for all ftrace handlers, > then all functions will look like they are in an NMI context during tracing. > > That is, the preempt count is checked to fill in the flags in the ring > buffer that denotes what context the event (in this case the function) was > called in. Ah, that is what I worried about. ftrace and kprobes handler usually want to know "what is the actual status of the system where the probe hits". If the new kernel_exception_enter() for ftrace/kprobes or any other kernel instrumention does __preempt_count_add(KEX_OFFSET + NMI_OFFSET + HARDIRQ_OFFSET); And we can distinguish the KEX from NMI, and get the original status of the context. What would you think about? Thank you, -- Masami Hiramatsu