Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2184202imm; Thu, 27 Sep 2018 08:41:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Ibnij50OGeNSd+UxRJVIKSguFwZs7sGHUEb1fwYWLfHx2Qoff4WIg3AI8fYE9+O0SiNBm X-Received: by 2002:a63:5e46:: with SMTP id s67-v6mr1636207pgb.373.1538062917624; Thu, 27 Sep 2018 08:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538062917; cv=none; d=google.com; s=arc-20160816; b=hwW4y3MoI+/ELdeww7dbU5QbcL3fj139rpWEU2KiE/gO+/LtTkuqe/RKlWcqtqMilY 0AI4zQvfga0VmoBb21R6I/S6FHDBfr2++N74oXWWLKUdQZxz9FeNpDuf2800F1WWsDAc qZvIasVYvLZeA6283q9Bg91EBYiw0Zcyfi+tUhVruN0h2RcdnmHJXWTuQArZJR7XLERM 6kQ+Fr9qo1oHkAnF2/RDk/NFptdR4R29vFNn5sSMUS9pubkLS9RqVvS/WKzDjBcsJA9u w2pupDlE1c4ZA8HWa65tkVuRstrF3KSgLNaEGx4FIVaOjBpJ/cgTfol17wDllmfh22rq L3DA== 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=X3TTytJ1oN8QAMOvJcCByB3Qpr83G+1K2z6Y0AmGSx0=; b=gIsqiklAJu9MIrF6UUJulBdSQ8L/0mD81chskc3PZv3BYig4mdmTjvjfxQJk+OPRb2 OklerdVr3Tm3SMNgZ/hLJiRopKxqoHWoygF8EGMRWxwVxNGxWYBiwoQCl7oA50Kxm2Lz SAk/7YvM4U9Vmm75QzhVhhmlsNw99SlyT7CPhBVCH9BfNS1KHZ2yIts+11uQWLtW1LOb 4p0Fa6kA3XzTR8DXmIujGtZCEYHy6OGO1U6roYiSwXOl1U34+azbgUer64RMXsWuoX04 PNmaHZL3Vii7E84LfxtGwD6eptMsU9EKLcjVYtmbJQeDWTZGtVJt/ybuDK7pDBmXfjCB gEvw== 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 33-v6si2240823pgm.94.2018.09.27.08.41.32; Thu, 27 Sep 2018 08:41:57 -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 S1727603AbeI0V6s (ORCPT + 99 others); Thu, 27 Sep 2018 17:58:48 -0400 Received: from mga12.intel.com ([192.55.52.136]:51310 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727262AbeI0V6s (ORCPT ); Thu, 27 Sep 2018 17:58:48 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2018 08:39:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,311,1534834800"; d="scan'208";a="93898656" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.69]) by fmsmga001.fm.intel.com with ESMTP; 27 Sep 2018 08:39:52 -0700 Date: Thu, 27 Sep 2018 18:39:52 +0300 From: Jarkko Sakkinen To: Dave Hansen Cc: Andy Lutomirski , Sean Christopherson , Andy Lutomirski , X86 ML , Platform Driver , nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, Andy Shevchenko , Dave Hansen , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , LKML Subject: Re: [PATCH v14 09/19] x86/mm: x86/sgx: Signal SEGV_SGXERR for #PFs w/ PF_SGX Message-ID: <20180927153952.GA13225@linux.intel.com> References: <20180925130845.9962-1-jarkko.sakkinen@linux.intel.com> <20180925130845.9962-10-jarkko.sakkinen@linux.intel.com> <20180926173516.GA10920@linux.intel.com> <2D60780F-ADB4-48A4-AB74-15683493D369@amacapital.net> <9835e288-ba98-2f9e-ac73-504db9512bb9@intel.com> <20180927134223.GA8242@linux.intel.com> 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.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 27, 2018 at 07:58:41AM -0700, Dave Hansen wrote: > On 09/27/2018 06:42 AM, Jarkko Sakkinen wrote: > >> This flag is 1 if the exception is unrelated to paging and > >> resulted from violation of SGX-specific access-control > >> requirements. ... such a violation can occur only if there > >> is no ordinary page fault... > >> > >> This is pretty important. It means that *none* of the other > >> paging-related stuff that we're doing applies. > >> > >> We also need to clarify how this can happen. Is it through something > >> than an app does, or is it solely when the hardware does something under > >> the covers, like suspend/resume. > > When you change page permissions lets say with mprotect after the and > > try to do an invalid access according to the EPCM permissions this can > > happen. > > So, there are pages that are non-executable, non-readable, or > non-writable both via the page tables and via underlying SGX > permissions. Then, we allow an mprotect() and a later access will > result in one of these SGX faults? The permissions are intersection of PTE and EPCM permissions. EPCM permissions are part of the enclave measurement. For SGX1 they are static. For SGX2 they can be changed with EMODPR/EACCEPT protocol (i.e. measurement can be updated after enclave initialization). > What permissions are these, exactly? Is it even a good idea to let that > mprotect() go through in the first place? You define RWX for each page when you do EADD. > Either way, it sounds like we have some new conditions to spell out in > that comment. Agreed. /Jarkko