Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2054912imm; Thu, 27 Sep 2018 06:47:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV63axckWpySXtNpuTOUIYGT1zDsZA0EwQjQU/PsN2y3bZevc46nioYDKxrA3nbh+lW7E9bRP X-Received: by 2002:a62:6948:: with SMTP id e69-v6mr11575011pfc.166.1538056038564; Thu, 27 Sep 2018 06:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538056038; cv=none; d=google.com; s=arc-20160816; b=0eu3Zj6qMB3r9Nw1UXzYMcuCEIhBmP7n1l/BBgv/YGuydJm7C8VtcC8QC1Cd71eIcW XN8b8P4uW0Mj6Vv8OU4mH0i5aIJaBPdUuZmcqGJPFPj1POLtyVDkXGvgbvv9jJLAnGPU 7Ld57r2Gpl4pvuhObfdyjpUMGNybUSIbv5wdwGeeaTHXGO5YEkztIP/vEB/wbJnbv0w/ UubVDTzuci/eR/6vNMLb7BEV6oP/N/jTUWsNnh0jWq63+52EF9CdMHJCvoxFbNz2KyQO QUnZss9y7l+nFhNH0Cna9LC+vA3A857uHkUhHTU3Usni7+HHigtwI+gHrg+BpbDzrFe5 kDCA== 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=VOnL4OyT3UEHR9N+gK7/fgyK8yHEK1VR6QuTmYtvUT4=; b=FATQbZGUR3AWVkir/mpvEfIRG3QA2eRnsHXQpMk89xzIuTgo1hne8NqTGZ/7AYj4k7 251p/F1PqhhM8LhRQuERdJwGTfdgX8pahxATi3ihj3K9r5JBxJoDBExn9AlaPA99yJLp 5a2Qd66iubCXocOQj9w7xEMZD+EVgXrczGrHGTc2ZiTyUXL1voWlqHjU2I9WdRJwjq/m 9z/pw+PMQ2A83NG2kjy2XRzw1vc463Cg5ITxdQxbGUE2iXOqWB4Ydc6VI4Ah4XiBbzhn GmOPrusoSiBiqpo8ZcWw3zFqgcLNVqWVQEa8w7S2u6Z4Yag4rbLYUr/CSIFM6zNI9Taq MCTw== 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 q16-v6si1980084pgb.18.2018.09.27.06.46.54; Thu, 27 Sep 2018 06:47:18 -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 S1727453AbeI0UFA (ORCPT + 99 others); Thu, 27 Sep 2018 16:05:00 -0400 Received: from mga07.intel.com ([134.134.136.100]:4292 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727175AbeI0UE7 (ORCPT ); Thu, 27 Sep 2018 16:04:59 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2018 06:46:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,310,1534834800"; d="scan'208";a="89929163" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.69]) by fmsmga002.fm.intel.com with ESMTP; 27 Sep 2018 06:42:24 -0700 Date: Thu, 27 Sep 2018 16:42:23 +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: <20180927134223.GA8242@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9835e288-ba98-2f9e-ac73-504db9512bb9@intel.com> 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 Wed, Sep 26, 2018 at 01:16:59PM -0700, Dave Hansen wrote: > On 09/26/2018 11:12 AM, Andy Lutomirski wrote: > >> e omniscient. > >> > >> How about this? With formatting changes since it's long-winded... > >> > >> /* > >> * Access is blocked by the Enclave Page Cache Map (EPCM), i.e. the > >> * access is allowed by the PTE but not the EPCM. This usually happens > >> * when the EPCM is yanked out from under us, e.g. by hardware after a > >> * suspend/resume cycle. In any case, software, i.e. the kernel, can't > >> * fix the source of the fault as the EPCM can't be directly modified > >> * by software. Handle the fault as an access error in order to signal > >> * userspace, e.g. so that userspace can rebuild their enclave(s), even > >> * though userspace may not have actually violated access permissions. > >> */ > >> > > Looks good to me. > > Including the actual architectural definition of the bit might add some > clarity. The SDM explicitly says (Vol 3a section 4.7): > > The fault resulted from violation of SGX-specific access-control > requirements. > > Which totally squares with returning true from access_error(). > > There's also a tidbit that says: > > 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. /Jarkko