Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1215381imm; Wed, 26 Sep 2018 13:44:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV62pQnvXt78jGelp2MzdX7LqTFe+LjDbD6iU6AL58lwhD01PVouck85NqYM4YFLU4oK03MKm X-Received: by 2002:a63:5fc5:: with SMTP id t188-v6mr7093748pgb.346.1537994669112; Wed, 26 Sep 2018 13:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537994669; cv=none; d=google.com; s=arc-20160816; b=qFkRZ7U+o7TGwtvrS10f5l0su/S/xDF5b9UNz3cWmaoqQorneUw+z5RFR3hV3GpATB 0E9xeuyh7JsMm5E/feTM0trjAR6Z0rvoIfWPH+Rg8RI3fYn9sYbBWKEu2eY5NNdZcPGs Lsnz1Z78fHFZHTV33+UVcLdhcEDhIHZ7/9u1bK+ypt7w0I8LxfBkR7WVeWNEBm7xAKPA VOnA5gWcQH5ilVNJPdaDen5/UHsUUg1+o2v4y5zHdVg5J7NFgWqZqwv16gmK2QzYFwWF MlI3XA6Oj5RmGDvAd+bJ8Hxm8qUSwCA8phtlIsPwaMUuvG/Cei2jDfqbwAy8iQCW6LVD 26OA== 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=MUKzV0KKO7epGKSieT3d0zavWjmpRB2Sw+hBA0gL5/Q=; b=Jbvjcg4GDi9FKc584Z6tanb0je7dmJsoihiFdMkfOqz1fpF5XCL50Dz8HK4zdBtftA F3dVCogSg1beFBgMfNTQoIwCw8RVN0PyqovfXY4DaCPeWJv3CXuy0YAnJJg6ef9LZ2wh nngl6ESfNUA6YYKiXSw5h6JJpqt0AssZKgFvT8q5ro/VxyS+l8qCviNooPjIVwkUk3e9 2YHZvWMmyBxylyrpshcMs3YR2E4OKDzltgHNuDYRXiMeBmc9S/S8hwSarox4SlfDPiGo 3eWEf3++8ZBwuh+hvX5BsGAskZ2EswpeegqXq2QmZ6yemDVFhuBmHQl19sOzlsINfSav ZqKw== 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 r15-v6si43441pgh.88.2018.09.26.13.44.14; Wed, 26 Sep 2018 13:44:29 -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 S1727062AbeI0C6p (ORCPT + 99 others); Wed, 26 Sep 2018 22:58:45 -0400 Received: from mga14.intel.com ([192.55.52.115]:50409 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbeI0C6p (ORCPT ); Wed, 26 Sep 2018 22:58:45 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2018 13:44:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,307,1534834800"; d="scan'208";a="260500420" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.55]) by orsmga005.jf.intel.com with ESMTP; 26 Sep 2018 13:44:00 -0700 Date: Wed, 26 Sep 2018 13:44:00 -0700 From: Sean Christopherson To: Dave Hansen Cc: Andy Lutomirski , Andy Lutomirski , Jarkko Sakkinen , 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: <20180926204400.GA11446@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> 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 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. Are you looking for something in the changelog, the comment, or just a response? If it's the latter... On bare metal with a bug-free kernel, the only scenario I'm aware of where we'll encounter these faults is when hardware pulls the rug out from under us. In a virtualized environment all bets are off because the architecture allows VMMs to silently "destroy" the EPC at will, e.g. KVM, and I believe Hyper-V, will take advantage of this behavior to support live migration. Post migration, the destination system will generate PF_SGX because the EPC{M} can't be migrated between system, i.e. the destination EPCM sees all EPC pages as invalid.