Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3933209yba; Tue, 23 Apr 2019 12:01:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIWiEzvzI9KPuSqGll9fTfb0VJbvy9zDXoKiGO19QEPoWwpvH+6qF/V2DTOkgHRBbjimdE X-Received: by 2002:aa7:928b:: with SMTP id j11mr28747752pfa.200.1556046081169; Tue, 23 Apr 2019 12:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556046081; cv=none; d=google.com; s=arc-20160816; b=1J0ijvE9HNjT5fOCiSklfl67JiofQwwazdterEBNPBWSejIa7ZsHoaGXOxxDDY6Ny3 kevA/2HMNeXcwvfPHjive896wzQzttNu63dsby5ndjAu2v4t5nHA/RgxYf1llzANq7Fs X2kOrumKiWGAg0A6Veb++EuYP2O/fg5TlEhWhmnoryW1MVM5nCQyPZSgTi/S83P+o776 z5gY+kJxCnIft/gxuVFNwT78+82Jy55+Xq85DddCxnV4SDx23jGltVoV9tbn0OXOD+Fj 94ti5x6l+Qg48mmjAYtRu3XQRbls6L1GAAlnEiqoyjrdci4+CcbqMLBf9j2dM4AF4APD adBA== 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=2YMt8zfRrP41Kj7sA+2/tsztbgnpHyBJto4rC3VmWmQ=; b=e9/SfzEz+KPYd49yjyBMrtZ2KGJzAEHAm3v2KPQBCYlsKb3W0RrUP7M7UwVkPMPgiP O2jdEqMacAsROLm2zDlQvHtBkQB6NJ74j1DBGOUm6WEw8XDFN1wyRvlvhcl7FvJX7eAA Kv684ehNARG0kw/lso5DrlOb0RktbEkCOwV4XzWC8Q1gl2thQgfhPE5jS49b6W2jyJvZ dA3y1Z/dheJPbyScJzEYOkg2flwl9gQdxp1eHRV/wOT/9LfU15pnnvfWx4HTmJ7wGAnP Io1c/pofx+2UM+8oFsy2O4qbAeVdLUsRUiqkByu76L3Cv6/cn/pg01JnghOznhy4+SuA GrAw== 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 p14si16440005pfn.267.2019.04.23.12.01.05; Tue, 23 Apr 2019 12:01:21 -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 S1726142AbfDWS7j (ORCPT + 99 others); Tue, 23 Apr 2019 14:59:39 -0400 Received: from mga02.intel.com ([134.134.136.20]:50226 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbfDWS7i (ORCPT ); Tue, 23 Apr 2019 14:59:38 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2019 11:59:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,386,1549958400"; d="scan'208";a="138176113" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.181]) by orsmga006.jf.intel.com with ESMTP; 23 Apr 2019 11:59:38 -0700 Date: Tue, 23 Apr 2019 11:59:37 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: Cedric Xing , LKML , X86 ML , linux-sgx@vger.kernel.org, Andrew Morton , Dave , nhorman@redhat.com, npmccallum@redhat.com, Serge , Shay , Haitao , Andy Shevchenko , Thomas Gleixner , Kai , Borislav Petkov , Josh Triplett , Kai , David Rientjes , Jarkko Sakkinen Subject: Re: [RFC PATCH v1 3/3] selftests/x86: Augment SGX selftest to test new __vdso_sgx_enter_enclave() and its callback interface Message-ID: <20190423185937.GD10720@linux.intel.com> References: <20190417103938.7762-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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...