Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10659268ybi; Thu, 11 Jul 2019 08:55:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCn2A5F25YqzS7vpRMnlwFRgihYv8SdHVuDhu3j8siVmKxKLb+6Wb2BxE8FDcp4BGfdqd5 X-Received: by 2002:a63:e807:: with SMTP id s7mr5008730pgh.194.1562860504585; Thu, 11 Jul 2019 08:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562860504; cv=none; d=google.com; s=arc-20160816; b=Yb/pN+TQrzDerdQRKfBwmTwLfWmk13wbRc556ltn2Gtwj0knt8+DbBQ7xD6rZepfJQ tKBGxx8UOWr5N5UdBNqO97zsdcyaXN1rIaCxoW6Q6s+GSbxLniudtnCwVevzM6cZt1jI pNOWxov09iz3QUUV2Ij1tnjh16kB7fVmBK+SZmpUFEgbqaLO40gh5+zm7zZFhoCGvpU5 IDFkDsDElWxZtaYam7OBKJbVzbfXa6yrAPm6F373kmeYYKBt3Ces/rzqBpVSQdvypOG1 azEsOyaGmyiugkLXAk5VItoJzEzYbkA/5GwBBFmp8Z164R8N8Sg5M3CRcSt0yx6QLctZ i/3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xD6s60hRSZzqB0LWbj2NxpxWb8apbf1kwafns5CAZqQ=; b=RyiPWf3RHIouaDj2Oc5CpqvF2cqBrqOhMleun4g01bmPv3NuNv0xv5XVYdlb+rmLh2 GNRt4lyg1iiCyqb6D5IWNOSHklj0yuNjtBPn6Tdl7dWo47fdGnzoQ1XF5qhQMpUmeXBm oqSShx05ppOBdX0VMT4eFuhdUFx/f5AS3x30iPC9s1GapObywJ3E0keIUJt/HU8iov9J v1v1WFAqRWlTMyhEARMqx9btDyu8R6CiKYU7ilhi9b3MnVUELw4+EZaGp5Wy3hL2+n7a zzSDvBEuSKl1qGuVzuTmP/XdU481hFrZ+ZgEI5KNWxMf90sXIHFnhfYomQ1tWEBQ7LT/ NL3g== 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 b13si5707922pfo.59.2019.07.11.08.54.48; Thu, 11 Jul 2019 08:55:04 -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 S1728405AbfGKPya (ORCPT + 99 others); Thu, 11 Jul 2019 11:54:30 -0400 Received: from mga01.intel.com ([192.55.52.88]:6810 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfGKPy3 (ORCPT ); Thu, 11 Jul 2019 11:54:29 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2019 08:54:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,479,1557212400"; d="scan'208";a="168061694" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.165]) by fmsmga007.fm.intel.com with ESMTP; 11 Jul 2019 08:54:28 -0700 Date: Thu, 11 Jul 2019 08:54:28 -0700 From: Sean Christopherson To: "Xing, Cedric" Cc: Jarkko Sakkinen , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "linux-sgx@vger.kernel.org" , "akpm@linux-foundation.org" , "Hansen, Dave" , "nhorman@redhat.com" , "npmccallum@redhat.com" , "Ayoun, Serge" , "Katz-zamir, Shay" , "Huang, Haitao" , "andriy.shevchenko@linux.intel.com" , "tglx@linutronix.de" , "Svahn, Kai" , "bp@alien8.de" , "josh@joshtriplett.org" , "luto@kernel.org" , "Huang, Kai" , "rientjes@google.com" , Andy Lutomirski , Dave Hansen Subject: Re: [PATCH v20 22/28] x86/traps: Attempt to fixup exceptions in vDSO before signaling Message-ID: <20190711155428.GC15067@linux.intel.com> References: <20190417103938.7762-1-jarkko.sakkinen@linux.intel.com> <20190417103938.7762-23-jarkko.sakkinen@linux.intel.com> <20190625154341.GA7046@linux.intel.com> <960B34DE67B9E140824F1DCDEC400C0F6551B873@ORSMSX116.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <960B34DE67B9E140824F1DCDEC400C0F6551B873@ORSMSX116.amr.corp.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 27, 2019 at 01:32:58PM -0700, Xing, Cedric wrote: > Just a reminder that #DB/#BP shall be treated differently because they are > used by debuggers. So instead of branching to the fixup address, the kernel > shall just signal the process. More importantly, doing fixup on #DB and #BP simply doesn't work. On Tue, Apr 23, 2019 at 11:59:37AM -0700, Sean Christopherson wrote: > On Mon, Apr 22, 2019 at 06:29:06PM -0700, Andy Lutomirski wrote: > > What's not tested here is running this code with EFLAGS.TF set and > > making sure that it unwinds correctly. Also, Jarkko, unless I missed > > something, the vDSO extable code likely has a bug. If you run the > > instruction right before ENCLU with EFLAGS.TF set, then do_debug() > > will eat the SIGTRAP and skip to the exception handler. Similarly, if > > you put an instruction breakpoint on ENCLU, it'll get skipped. Or is > > the code actually correct and am I just remembering wrong? > > The code is indeed broken, and I don't see a sane way to make it not > broken other than to never do vDSO fixup on #DB or #BP. But that's > probably the right thing to do anyways since an attached debugger is > likely the intended recipient the 99.9999999% of the time. > > The crux of the matter is that it's impossible to identify whether or > not a #DB/#BP originated from within an enclave, e.g. an INT3 in an > enclave will look identical to an INT3 at the AEP. Even if hardware > provided a magic flag, #DB still has scenarios where the intended > recipient is ambiguous, e.g. data breakpoint encountered in the enclave > but on an address outside of the enclave, breakpoint encountered in the > enclave and a code breakpoint on the AEP, etc...