Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2663879imd; Fri, 2 Nov 2018 15:41:42 -0700 (PDT) X-Google-Smtp-Source: AJdET5eDUDoYddd5y8W+GAMQ5dSB56zgb4chYOkuknN0Z1fq5aSIgG5s/92XycMpHtzcJQUVAiwV X-Received: by 2002:a17:902:8a93:: with SMTP id p19-v6mr13165145plo.41.1541198502564; Fri, 02 Nov 2018 15:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541198502; cv=none; d=google.com; s=arc-20160816; b=zPfUx6bR77KCYzHdUa0vVZCUcd/AOBmUj0pHr0jWiF5duuPgGJ2yMuEnFuqc0d+e+9 hCOivgmyXz6n8/fLln0KVGGSxnkQD+sVoO6+gLxJd21w9x/F/dRkyu5W34APxBef68tR xK1mUBFVuJwzhwIlcV42uIp8NttlMkk3G4aCm9o90JivCdIAoqeHwHLOHhuQs19BC5yu leMYYrbjdIIwjbc2qxmz7mZRo/lg/MxC8KTapZl87xADzSQWeQEywPSgelEDgTeSj1WJ Uw21yq2osaDKGgH5hQqBRbhk0caWoLqwQ5keTArUM9fyntf6SNErAwqbcYbCnrcWroqi AvFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=M38EiKXQuN7MU7E5SoIK6h4OFOl4EPNXpmLTCAhSZpA=; b=oz3sC6vTaQP3bGy6oKgi5LdBN3Wv3cpDcFSI23fsWJPLqFwA/ZTBJ7MbKhhoRnGONI DM5KhYGclObTI7reL6bJW2W9E+GmlQINdP5y2bejrR2eCUtrE4nT35pBP8K72yfDl6dH nHe68NRYNDXHVtW6y3vzMC4nvsufo2RSmwVhGDAxtsk2FCp7+QXpJtq6iQ9pQDhvlTLF a8Gl0YW3O1zFDIprPqwGYm9+a3rdjvZrBoeJuU0X5Jm4IN7J/t+w86SEDrTDHgpkRigi RImC6FvUp8AAbCZrIuZw8R9tdTeXWGCriuiFPQnkIykCiHcYjqfVCLitGRtiNmBhDRQ1 gk9A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7-v6si34668690pgh.131.2018.11.02.15.41.27; Fri, 02 Nov 2018 15:41:42 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728446AbeKCHrK (ORCPT + 99 others); Sat, 3 Nov 2018 03:47:10 -0400 Received: from mga01.intel.com ([192.55.52.88]:61363 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726778AbeKCHrK (ORCPT ); Sat, 3 Nov 2018 03:47:10 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2018 15:38:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,457,1534834800"; d="scan'208";a="103006930" Received: from btyborox-mobl.ger.corp.intel.com (HELO localhost) ([10.249.254.138]) by fmsmga004.fm.intel.com with ESMTP; 02 Nov 2018 15:37:59 -0700 Date: Sat, 3 Nov 2018 00:37:57 +0200 From: Jarkko Sakkinen To: Andy Lutomirski Cc: Linus Torvalds , Rich Felker , Jann Horn , Dave Hansen , "Christopherson, Sean J" , Jethro Beekman , Florian Weimer , Linux API , X86 ML , linux-arch , LKML , Peter Zijlstra , nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, Andy Shevchenko , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Carlos O'Donell , adhemerval.zanella@linaro.org Subject: Re: RFC: userspace exception fixups Message-ID: <20181102223757.GB24373@linux.intel.com> References: <20181101185225.GC5150@brightrain.aerifal.cx> <20181101193107.GE5150@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 01, 2018 at 04:22:55PM -0700, Andy Lutomirski wrote: > On Thu, Nov 1, 2018 at 2:24 PM Linus Torvalds > wrote: > > > > On Thu, Nov 1, 2018 at 12:31 PM Rich Felker wrote: > > > > > > See my other emails in this thread. You would register the *address* > > > (in TLS) of a function pointer object pointing to the handler, rather > > > than the function address of the handler. Then switching handler is > > > just a single store in userspace, no syscalls involved. > > > > Yes. > > > > And for just EENTER, maybe that's the right model. > > > > If we want to generalize it to other thread-synchronous faults, it > > needs way more information and a list of handlers, but if we limit the > > thing to _only_ EENTER getting an SGX fault, then a single "this is > > the fault handler" address is probably the right thing to do. > > It sounds like you're saying that the kernel should know, *before* > running any user fixup code, whether the fault in question is one that > wants a fixup. Sounds reasonable. > > I think it would be nice, but not absolutely necessary, if user code > didn't need to poke some value into TLS each time it ran a function > that had a fixup. With the poke-into-TLS approach, it looks a lot > like rseq, and rseq doesn't nest very nicely. I think we really want > this mechanism to Just Work. So we could maybe have a syscall that > associates a list of fixups with a given range of text addresses. We > might want the kernel to automatically zap the fixups when the text in > question is unmapped. If we would have a syscall to specify a list fixups that would do the job. Now essentially the only reason we require a vDSO is to implement a single fixup for EENTER. If this fixup stuff makes sense for other parts of the kernel, introducing a vDSO for EENTER means essentially adding ABI to the kernel that might possibly become legacy fast. /Jarkko