Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp92673ybi; Thu, 11 Jul 2019 15:22:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnaMUgwX2HUYxiVx6VP1RwSsL3JqEi+Ck1eYNYt8ngKE2cFEyGlRSLQCZGFZ9bWVdOHitv X-Received: by 2002:a17:902:2983:: with SMTP id h3mr7286059plb.45.1562883776381; Thu, 11 Jul 2019 15:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562883776; cv=none; d=google.com; s=arc-20160816; b=K/Mn5B/FS8X4GdlUS7qlMdMtJTeFo5F0XVYq+juq2x+kqdw2QBR3BBM7zpU5Yj3ftj 4kOuNHsfIJdl0LWcJAWOGljmJdIe5RahwbT0oPRd7DAniuksdXr4yZDusxpR2zRE2rDX M7lhZW4MES2eUkC+zXHMFGj5RbJVUoxUAXV/XikPAbr6zpTC+YVZjp3WMns6HK+RSCzg jHT0grV9k5pdWQsK40A1YQ2P3xl702GRHE2EcnKAiDEy+rvmfQuRHb/Vv1SHCgVWoffg cp3JksY/T5bVIiwmIDEj0L32f74mpV7hXQw3DG8Cm8xwDPCR+bOJO8tmwklj/JL91VLc Foqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=U61zIZKS+sBPkfpz0xUnOw4TMrrH0BIEurMqF6SMvt0=; b=0zskE1y8t02g7uiSDcWrVz8nZtrwPe3u9NfAospkbtInps/iDnFU4NAg5JgMvxHUu1 xjQ6y1BF3mmz01SZyu8h0G6fYfThezbhMM0EyYqywrng5va/2acL3xD2M40OAb2to+m+ V7YwQHXSpeh2PbczRDKHgHrf6ou/WNALsc+hT5U3BkfBqQ6kKfZ2m1bMEDLV6yiZk/cn 6GY+LB+/FnPBWfuZsOfr0lHiI/hFhZRaxYzueWGcymEBoJcG6LB2CcIuAwafa0B0z/va zyoOs83YTBhepO1q2C6/iLczvo65LBI+lP3jWAeaMzWeK0kHISmhpqS/2rpvgZAzxvzp B4gQ== 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 q32si6224857pjc.2.2019.07.11.15.22.39; Thu, 11 Jul 2019 15:22:56 -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 S1728757AbfGKWMm (ORCPT + 99 others); Thu, 11 Jul 2019 18:12:42 -0400 Received: from mga12.intel.com ([192.55.52.136]:42207 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbfGKWMl (ORCPT ); Thu, 11 Jul 2019 18:12:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2019 15:12:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,480,1557212400"; d="scan'208";a="168760918" Received: from bxing-desk.ccr.corp.intel.com (HELO [134.134.148.187]) ([134.134.148.187]) by orsmga003.jf.intel.com with ESMTP; 11 Jul 2019 15:12:39 -0700 Subject: Re: [PATCH v20 22/28] x86/traps: Attempt to fixup exceptions in vDSO before signaling To: Sean Christopherson 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 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> <20190711155428.GC15067@linux.intel.com> From: "Xing, Cedric" Message-ID: <8bb023a5-d5d9-96c2-2596-2628206d5bd7@intel.com> Date: Thu, 11 Jul 2019 15:12:36 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190711155428.GC15067@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/11/2019 8:54 AM, Sean Christopherson wrote: > 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. What's really needed is a signal, as if the fixup entry didn't exist. You don't have to care whether a debugger is attached or not. > 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...