Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1234013imd; Thu, 1 Nov 2018 12:19:30 -0700 (PDT) X-Google-Smtp-Source: AJdET5dV9NHk9J//j3x1q8K1ps7E8FmPOQnQ3Ilgq9/9CSA1Rgw5b0ZmaXt/4TK2JBUYD0YNXwcg X-Received: by 2002:a17:902:1744:: with SMTP id i62-v6mr8496110pli.250.1541099970504; Thu, 01 Nov 2018 12:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541099970; cv=none; d=google.com; s=arc-20160816; b=S5HGMOGbKwzJ3nC+1H5FSnGCQ0MsqGswNwuhVY09iGJ1AcKMn33j3MFdphCObNxvJm joETCJF3bPxgAcM58Dn7JB301smSZLNFSM2aPJSjXNqbTU1UdJjJjPQX4nK3Otf5ne7D WfDmdu22w08Kb824tFzNSXM1b1QV4G1Qz4BQFUhE92DFWoKeIoGlrCA5HeaE/JQB3Ovg xYHb59luFgCkAx9c0A92ITy4mQqQ3DrtWE5r+/oecfuS7dT6VT8sP7DfHSkbSnWnKfmu EZVxL5hSf685LSU+yQXPaDR+OF3H4LIq0zu8sK0XXz4oKZa2LyK6H+gNjVt3lLzaAsrp 4Ovg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JR9rUjwyC6MIuio4ZAha46sSawiC0In9vkot0Q8cJ2Q=; b=QJTUCF+ogzuoEs9dvtZz81hbUme74wW6Iw67BFl5AI9QiVmcOrk6W2e4ULeXUamujY +QWdo4AN3R61Nx+BugSOFJaQ9nIYPDG5+AK334GEtB5xr3r/GIxtA6IyeKFyKT7a6VP1 cFeqz1Ok2ZFOlI6h5MAspptPW3yZPiBDeAa+sPXB1xc6pSfuFIL2Qlq9EfH8UpkJT8LO 6k7h9xpZEV8XejTEIOhrdK14f8IOeqggCm7DKhX1eeAQjmDPyhpOU8nrkyP+gt4OyOiy 8cQAKIZXFJg0/N8f/f99q3XhQCkyB8ofKpjFOjReDO1oIStPkFTZchmOsrvxZS8b+XaU sgDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="Nu/+Ijrl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1-v6si13485300pfd.166.2018.11.01.12.19.12; Thu, 01 Nov 2018 12:19:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="Nu/+Ijrl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726777AbeKBEXB (ORCPT + 99 others); Fri, 2 Nov 2018 00:23:01 -0400 Received: from mail-lj1-f172.google.com ([209.85.208.172]:38386 "EHLO mail-lj1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726147AbeKBEXB (ORCPT ); Fri, 2 Nov 2018 00:23:01 -0400 Received: by mail-lj1-f172.google.com with SMTP id q186-v6so5717961ljb.5 for ; Thu, 01 Nov 2018 12:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JR9rUjwyC6MIuio4ZAha46sSawiC0In9vkot0Q8cJ2Q=; b=Nu/+IjrlQBGr6lbwnDDEbN3gl7Dm5aEMZQdnVKQ/j2NiFCnJDdYsmTBTGgibLXHTFE P9NZAB+OG6Cuo1cSkQ5cSssqZKurVp5QdYgcJbSrqgi73Lkh3u82h2aSrnDfuCQlbRKA vv+QHJpJRE0c6EuXcEM12N8I9E//serNMtBL4= 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=JR9rUjwyC6MIuio4ZAha46sSawiC0In9vkot0Q8cJ2Q=; b=Q6W8DUyqt8ues2Alr+lVvN5KeL5OUXHG0z+rcD8qiV3az0r2PtkPluFx2PwA3BJ3q0 eCtpVjxJy2jTx3dWbq2HJZozLCVhbcp2IbhCvu4166/uwR5tZkjQJioFAdnK71L0Zdd6 Uzco2Ydlig5YMy87FoGRO34uWo5lnFfNSjC9It0ODjlBnk5vHhU6BeYk8BP2vEkdVL5P FuF0K/jZVmrggOe6EtnS/Zj4r4QMyPiD76t6yQWeJCFlVsRtEzQFuShzWSK8bNPoGjH0 /SGslVNR7Jctgt+eNo0Bi+8GJdcLxldz5TvsCFIkHOprhfWQNNDB1dqUzso+MpBj6QM0 F6sg== X-Gm-Message-State: AGRZ1gK4SUocfpcsBKWxeXKC+p8/Iid7B+Xp2nLm2/VI7fwmiXnKVLeE 3LdEjAxuyui/cUxNhyhm1RxIGBcqZ7o27Q== X-Received: by 2002:a2e:d11:: with SMTP id 17-v6mr6167351ljn.18.1541099922019; Thu, 01 Nov 2018 12:18:42 -0700 (PDT) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id h79-v6sm3350732ljf.67.2018.11.01.12.18.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 12:18:41 -0700 (PDT) Received: by mail-lf1-f47.google.com with SMTP id c16so14996765lfj.8 for ; Thu, 01 Nov 2018 12:18:41 -0700 (PDT) X-Received: by 2002:a19:288c:: with SMTP id o134-v6mr5447843lfo.124.1541099450974; Thu, 01 Nov 2018 12:10:50 -0700 (PDT) MIME-Version: 1.0 References: <20181101185225.GC5150@brightrain.aerifal.cx> In-Reply-To: <20181101185225.GC5150@brightrain.aerifal.cx> From: Linus Torvalds Date: Thu, 1 Nov 2018 12:10:35 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: RFC: userspace exception fixups To: dalias@libc.org Cc: Jann Horn , luto@kernel.org, dave.hansen@linux.intel.com, sean.j.christopherson@intel.com, jethro@fortanix.com, jarkko.sakkinen@linux.intel.com, fweimer@redhat.com, linux-api@vger.kernel.org, x86@kernel.org, linux-arch@vger.kernel.org, Linux Kernel Mailing List , Peter Zijlstra , nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, Ingo Molnar , bp@alien8.de, carlos@redhat.com, adhemerval.zanella@linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 1, 2018 at 11:52 AM Rich Felker wrote: > > There's no need to chain if the handler is specific to the context > where the fault happens. You just replace the handler with the one > relevant to the code you're about to run before you run it. That's much too expensive to do as a system call. Maybe an rseq-like "register an area where exception information will be found" and then you can just swap in a pointer there (and nest with previous pointers). But even that doesn't work. Maybe some library wants to capture page faults because they write-protected some area and want to log writes and then emulate them (or just enable them after logging - statistical logging is a thing). And then another library (or just nested code) wants to handle the eenter fault, so it overwrites the page handler fault. What do you do if you now get a page fault before you even do the eenter? The whole "one global error handler" model is broken. It's broken even if the "global" one is just per-thread. Don't do it. Even signals didn't make *that* bad a mistake, and signals are horrible. Linus