Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp646153pxk; Wed, 16 Sep 2020 13:12:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD9ElAld14L7FsLzCV9INxP3s36N7HzLaUwz3QTFiBgiwzXq2nr232oLoXV0PSgv0qpNsp X-Received: by 2002:a17:906:f43:: with SMTP id h3mr26475439ejj.338.1600287134304; Wed, 16 Sep 2020 13:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600287134; cv=none; d=google.com; s=arc-20160816; b=eP9eSQ5nfnj1OQnma6IcU86/0E+6wb1iyRx/BhTddwSyfa4r3GuUfbZQZA9x5pFwjB 0RQ1qk3rll11zNnasYVVovO9yg/tFGlPkxUH8r2RvscBJxde8XQJ2l3Lat4AR4MMahOt MxBSNrrNtE5npasVZOiWWq1512PIPRGv44Qn06u6LIZtYLzKJqDaVZMYJZrpBPW9ufO7 ClXfs2Lm2v2F0ZfStUVNYiNLscSXxwCCtXC2P+UJ6x/cJq7O3a8yg2DHFuY5brtdNRKm RdcdLm0AcgKzLRK4o4m9PBIJXeuUZBgtksYC/PfhbtmItnRsZ+l2vpCyhn1Ui7gWreQI nbEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=NPzVMHj3XVHq963E2HNb7nFJ33J0AKwoKhJxk7Xuz2M=; b=PTzPUAcxYawFIkVqTFqr3czX0pPalagHlWqGAhqMS6UfLHoX0ABprfPb2tR1sNLRaG anU4qI8h+Ym/OuBRSjDUpmEQ43Kwh7nl6TnGl1XRCF2X/NWjnMx6ML/BO1AftX/AbfIY 6tM834KBnLToLJWAhMW2lQfznr3bOC/LJMNZmhEF6p4goI181eAu3pgOMB0sxgkE39Vm 83YB5t7lm1zq/9W+D+paOAXCPlbmakqH5LPcCs1krhGvAYJxEkAUipkRUAdueuWXcZAu HG/CB01dusvc1N9davdWHVHKO+D2HSirCxFlC/O1KzVO3YvWYi/KpybYNPLhj7CiL6wO nUUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=WZdSnuQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si13976410eja.288.2020.09.16.13.11.51; Wed, 16 Sep 2020 13:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=WZdSnuQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728273AbgIPUJP (ORCPT + 99 others); Wed, 16 Sep 2020 16:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727043AbgIPReN (ORCPT ); Wed, 16 Sep 2020 13:34:13 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A5BC0698D6; Wed, 16 Sep 2020 04:44:51 -0700 (PDT) Received: from zn.tnic (p200300ec2f0c3e000ee699b54c433a91.dip0.t-ipconnect.de [IPv6:2003:ec:2f0c:3e00:ee6:99b5:4c43:3a91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id A31221EC0136; Wed, 16 Sep 2020 13:44:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1600256689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=NPzVMHj3XVHq963E2HNb7nFJ33J0AKwoKhJxk7Xuz2M=; b=WZdSnuQv5G/ql6BEEZrnr7cd8xh9dzmCiijvQyUtmizQf9eVTzkuUIskLZn0iq2DMUyGCm +mqh9VCWUzdcpJFi63w4IbKWRk8a8coABoamUsG1V1jGhCdKQUFypgux0aj1VUXZ5v55l5 RqLB5j9QElE/Tg0L2iTha0kc+nsM6b4= Date: Wed, 16 Sep 2020 13:44:48 +0200 From: Borislav Petkov To: Jarkko Sakkinen Cc: x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Jethro Beekman , Darren Kenny , Borislav Petkov , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v38 03/24] x86/mm: x86/sgx: Signal SIGSEGV with PF_SGX Message-ID: <20200916114448.GI2643@zn.tnic> References: <20200915112842.897265-1-jarkko.sakkinen@linux.intel.com> <20200915112842.897265-4-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200915112842.897265-4-jarkko.sakkinen@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 02:28:21PM +0300, Jarkko Sakkinen wrote: > From: Sean Christopherson > > Include SGX bit to the PF error codes and throw SIGSEGV with PF_SGX when > a #PF with SGX set happens. > > CPU throws a #PF with the SGX set in the event of Enclave Page Cache Map > (EPCM) conflict. The EPCM is a CPU-internal table, which describes the > properties for a enclave page. Enclaves are measured and signed software > entities, which SGX hosts. [1] > > Although the primary purpose of the EPCM conflict checks is to prevent > malicious accesses to an enclave, an illegit access can happen also for > legit reasons. > > All SGX reserved memory, including EPCM is encrypted with a transient key > that does not survive from the power transition. Throwing a SIGSEGV allows > user space software to react when this happens (e.g. recreate the enclave, > which was invalidated). > > [1] Intel SDM: 36.5.1 Enclave Page Cache Map (EPCM) > > Acked-by: Jethro Beekman > Reviewed-by: Darren Kenny > Reviewed-by: Borislav Petkov > Signed-off-by: Sean Christopherson > Signed-off-by: Jarkko Sakkinen > --- > arch/x86/include/asm/traps.h | 14 ++++++++------ The SEV-ES patchset moved that to arch/x86/include/asm/trap_pf.h but fixing that up is real easy. Simply do this search-replace s!arch/x86/include/asm/traps.h!arch/x86/include/asm/trap_pf.h! on this patch. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette