Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1980802pxb; Fri, 29 Jan 2021 09:50:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhuNAEsxqX0//Hl4OowDbkHY8RDu+CGV312nDy0asuLNWbtZssvjRy5SpinViA5sDOi5Iq X-Received: by 2002:aa7:c643:: with SMTP id z3mr6726740edr.330.1611942656305; Fri, 29 Jan 2021 09:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611942656; cv=none; d=google.com; s=arc-20160816; b=mFJUKxxGc4Nt1Uxm/B6ZnG99ywQMheomI6559FIxmZ/2Eg8q3TDhbnqa8Zqdx+kdTY PIBY3mJ/Pcvlcue+oLtz0l7U2Cycl8Hm1npygE8LL7DbbYIf79iUZkgGeUg5HH09OCA9 ivJ65BIyNBRxn6NDIyc5Ud+0WFcQYbI9fZWhS/xbgqCTSc40Dujfb1bQPcJt/O1bQ73g dDk218+vLs8CHlVtz6Stckf507P0ZfjGEJIvapP3uB/oLhe7Jd8fRil5OvHJ8rARz+bx SHVTsJMsBb4eWJJvxfC1iggShcKnJoy3rW+AaFoLJFtd4nVjJMkcyhH/+XfZbxNqDa8U oAlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+OiLSidU7jcHvOmsUmz5FLYsay7uE4w9flc5/NGNfkQ=; b=GGy1HgnWrDedyHGZ32IteLllWVJkdP+RhN8iaph/Oy0S1YXftc8D41Wg9K476QgW2K 1r6KEHmQNFYBRx+UxrkVzrgUSkqTf4M7zQgWdEbrSHjvsYdrTt9LskHRzuaCKan9+hA+ I43PXMP9DZ+hslwa3+aW87lxTHz+o1VqBWzMp0cn8ZmfGx02H+8QzZczmDGHu4g6HFjq jASY3DudZsLZuaGWBu8wgUxfhAUeUYyApDkElbJu5amtwHzmGebcesycwKuPyCE+FJ7u QoyBumToTUH4XOZ1jApRoMxYN9pzv/3n0JrXdfesyl54fMx92pOJBTnn9VmY5JyyP+F/ NHgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c9c1fFAA; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb8si6982188edb.6.2021.01.29.09.50.31; Fri, 29 Jan 2021 09:50:56 -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=@gmail.com header.s=20161025 header.b=c9c1fFAA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232526AbhA2Rsj (ORCPT + 99 others); Fri, 29 Jan 2021 12:48:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbhA2Rq2 (ORCPT ); Fri, 29 Jan 2021 12:46:28 -0500 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC39EC0613ED; Fri, 29 Jan 2021 09:46:01 -0800 (PST) Received: by mail-lj1-x22a.google.com with SMTP id m22so4017580ljj.4; Fri, 29 Jan 2021 09:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+OiLSidU7jcHvOmsUmz5FLYsay7uE4w9flc5/NGNfkQ=; b=c9c1fFAA1Q8jIaxn1++ppLWGxW194CT3+GS7F07iA+23CjkP4o3p62TTBa9+JCPss8 G95v+K4CU6Kn6ZTEO0E/YFAyGCvA/o1XfIqYRj4KQwr3pfD6t1EjYAF6YKmFs85hdDwv w/AOuj4W3TGHANd4rOZkqPn9+2+PuY+X6+Vtlv63lJ8oBuVZ/p/O+kMKyMIihhvktChP BaiSqHxjA0ESb6iLgwEnIARFFFVe0kOPAckpIT5ulDSfRXZQrPAwPV5sfE5JBMetGk74 43umU4wu9L5N6DcwfwW1J9Zj7rS4ujbYTt7k69hIhZ86kpP+qHV4Mu2GTUhVI5JpeYV6 1meQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+OiLSidU7jcHvOmsUmz5FLYsay7uE4w9flc5/NGNfkQ=; b=nG8hEI0xR+mWhRAmDKjbJLlhCjSJLNgg/bLoVRvS7fGNlxkF6axz2+CSrRz2LNNndp +XAPOHVoQmDi12Jd+1kUjnwR5B8S9vvhwJp9qc5L8g/tVLwLLLC/j/+lJR5h6C1Q8cvj lYx2DKjL7iQ+HAFxe15dyIIX5IyyhmBDorVK3idaZEA3Xe6YCA68NrBDbADzVO+xw4q8 0VjdYTAEHw3Zw3DWYKw6hBHmzf7fS4ZJmhfpU1VxCVxWytgOQt1O6ySNCkuv2Q0XdS1c lJJ4J7N1JLx91QWnFSPf/Kst3JFNaXrjXboKZgX7KeyIaBO5Vi0KnANN4Qa/NiFS+Gpb 181Q== X-Gm-Message-State: AOAM532ViBFH+5A5RD0wsBn7460VCxzV9cALBGUQIDx6KbK0gkbhVxX9 VCBmFbtD0rrhDiH+3PvczdsVN705aLq/u9KnAic= X-Received: by 2002:a2e:3507:: with SMTP id z7mr2839145ljz.32.1611942360223; Fri, 29 Jan 2021 09:46:00 -0800 (PST) MIME-Version: 1.0 References: <20210128103415.d90be51ec607bb6123b2843c@kernel.org> <20210128123842.c9e33949e62f504b84bfadf5@gmail.com> <20210129013452.njuh3fomws62m4rc@ast-mbp.dhcp.thefacebook.com> <20210129224011.81bcdb3eba1227c414e69e1f@kernel.org> <20210129105952.74dc8464@gandalf.local.home> <20210129162438.GC8912@worktop.programming.kicks-ass.net> In-Reply-To: <20210129162438.GC8912@worktop.programming.kicks-ass.net> From: Alexei Starovoitov Date: Fri, 29 Jan 2021 09:45:48 -0800 Message-ID: Subject: Re: kprobes broken since 0d00449c7a28 ("x86: Replace ist_enter() with nmi_enter()") To: Peter Zijlstra Cc: Steven Rostedt , Masami Hiramatsu , Nikolay Borisov , LKML , Alexei Starovoitov , bpf , Josh Poimboeuf Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 29, 2021 at 8:24 AM Peter Zijlstra wrote: > > On Fri, Jan 29, 2021 at 10:59:52AM -0500, Steven Rostedt wrote: > > On Fri, 29 Jan 2021 22:40:11 +0900 > > Masami Hiramatsu wrote: > > > > > > So what, they can all happen with random locks held. Marking them as NMI > > > > enables a whole bunch of sanity checks that are entirely appropriate. > > > > > > How about introducing an idea of Asynchronous NMI (ANMI) and Synchronous > > > NMI (SNMI)? kprobes and ftrace is synchronously called and can be controlled > > > (we can expect the context) but ANMI may be caused by asynchronous > > > hardware events on any context. > > > > > > If we can distinguish those 2 NMIs on preempt count, bpf people can easily > > > avoid the inevitable situation. > > > > I don't like the name NMI IN SNMI, because they are not NMIs. They are > > actually more like kernel exceptions. Even page faults in the kernel is > > similar to a kprobe breakpoint or ftrace. It can happen anywhere, with any > > lock held. Perhaps we need a kernel exception context? Which by definition > > is synchronous. I like 'kernel exception' name. SNMI doesn't sound right. There is nothing 'non maskable' here. > > What problem are you trying to solve? AFAICT all these contexts have the > same restrictions, why try and muck about with different names for the > same thing? from core kernel perspective the difference between 'kernel exception' and true NMI is huge: this_cpu vs __this_cpu static checks vs runtime checks Same things apply to bpf side. We can statically prove safety for ftrace and kprobe attaching whereas to deal with NMI situation we have to use run-time checks for recursion prevention, etc.