Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2430005imm; Thu, 27 Sep 2018 12:44:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV63eiic9ETuoT8joYjs1OaK8Jw/EyAaJFj/mzw3KYJHOAZ/dU6qZEwH+oeM2xLEaxUI0MLDf X-Received: by 2002:a62:4803:: with SMTP id v3-v6mr13140133pfa.89.1538077472688; Thu, 27 Sep 2018 12:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538077472; cv=none; d=google.com; s=arc-20160816; b=ZIUBuLtB0rycqx5/ZmSAKNV+RTXjceN9ge1VeKq+zcoUCnmGtTm5SUKy3UFN8cJ64Z rKF53nQC9x1dD3SyBycloxNsAR0iiCjNg5IoU8doVYK9GcK7ezO+Ohkk9KRjv3Yb2xDI uNdl0k47VjMivJpV8TwdgjCu9v+i9ASHBbt7vyAQgVfYPD+PyGEE6TV5Xx2KTDH0I3ar uOEWgWgy3M9b+pSX8ay22d7y7rmHARXBf3quZVvHSbNnrKmah9+7oHAlaHWMzsBWAONE zrSLASWkFPDf7DcQ3gskq8NhRIGigZGCphvLln1cBdt34UL82ntcRNUAbimLEg7LjhtK 8Uzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from; bh=x0DHTjQEUnGmILGuos80LpB35EZ4t/w4Kw8TrANNDaY=; b=CXhWEsR9/kUKtOLTBtWBjETq1BcLeBc+yM2jswdQKCwPazZatS3CoFxh7Eio50ftxl XFoOwjlNzZ7+drFFLvYW9hkWgBe8mXxytskrbt14+MErn6cqAXdrqdDDvw4mURNYTAyt W0mSKi2QXKjadrJzwyei6A83Ajk8kuhYSbbZbfVrhrrBAGXkvk+r6XX+D8Z4RvvHK4k5 aD2IWKJk3wEBSE8ayb+0wpOJUG6naSXyw0E4CL5zll9DNARbEPaUXFZVJSqPV9l4rGfO U4YB3RJOAsmIPDE7l39pPWL4CxoK4B9LpggmE/S6Y3nbM6cwK3EXAnOIfn0LVoOxNmyl nKOw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f16-v6si2617002pgd.654.2018.09.27.12.44.16; Thu, 27 Sep 2018 12:44:32 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727489AbeI1CDp (ORCPT + 99 others); Thu, 27 Sep 2018 22:03:45 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:50820 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727266AbeI1CDp (ORCPT ); Thu, 27 Sep 2018 22:03:45 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1g5cCJ-0004mD-2v; Thu, 27 Sep 2018 13:43:39 -0600 Received: from [105.184.227.67] (helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1g5cCG-0001ja-UY; Thu, 27 Sep 2018 13:43:38 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Jarkko Sakkinen Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, dave.hansen@intel.com, sean.j.christopherson@intel.com, nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, andriy.shevchenko@linux.intel.com, Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org (open list:X86 MM) References: <20180925130845.9962-1-jarkko.sakkinen@linux.intel.com> <20180925130845.9962-10-jarkko.sakkinen@linux.intel.com> Date: Thu, 27 Sep 2018 21:43:15 +0200 In-Reply-To: <20180925130845.9962-10-jarkko.sakkinen@linux.intel.com> (Jarkko Sakkinen's message of "Tue, 25 Sep 2018 16:06:46 +0300") Message-ID: <87zhw2ohf0.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1g5cCG-0001ja-UY;;;mid=<87zhw2ohf0.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=105.184.227.67;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+xE+Rd+QqQGLxya5kt+TXMDzgj14CRP48= X-SA-Exim-Connect-IP: 105.184.227.67 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sa02.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.9 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,FVGT_m_MULTI_ODD,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01, XMSubLong autolearn=disabled version=3.4.0 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=1] * 0.4 FVGT_m_MULTI_ODD Contains multiple odd letter combinations * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Jarkko Sakkinen X-Spam-Relay-Country: X-Spam-Timing: total 1286 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 12 (0.9%), b_tie_ro: 10 (0.7%), parse: 3.8 (0.3%), extract_message_metadata: 40 (3.1%), get_uri_detail_list: 4.9 (0.4%), tests_pri_-1000: 15 (1.2%), tests_pri_-950: 2.9 (0.2%), tests_pri_-900: 2.3 (0.2%), tests_pri_-400: 46 (3.6%), check_bayes: 42 (3.3%), b_tokenize: 18 (1.4%), b_tok_get_all: 10 (0.8%), b_comp_prob: 6 (0.5%), b_tok_touch_all: 4.0 (0.3%), b_finish: 1.01 (0.1%), tests_pri_-100: 10 (0.8%), check_dkim_signature: 1.13 (0.1%), check_dkim_adsp: 5 (0.4%), tests_pri_0: 1116 (86.8%), tests_pri_10: 4.4 (0.3%), tests_pri_500: 22 (1.7%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH v14 09/19] x86/mm: x86/sgx: Signal SEGV_SGXERR for #PFs w/ PF_SGX X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jarkko Sakkinen writes: > From: Sean Christopherson > > Signal SIGSEGV(SEGV_SGXERR) for all faults with PF_SGX set in the > error code. The PF_SGX bit is set if and only if the #PF is detected > by the Enclave Page Cache Map (EPCM), which is consulted only after > an access walks the kernel's page tables, i.e.: > > a. the access was allowed by the kernel > b. the kernel's tables have become less restrictive than the EPCM > c. the kernel cannot fixup the cause of the fault > > Noteably, (b) implies that either the kernel has botched the EPC > mappings or the EPCM has been invalidated due to a power event. In > either case, userspace needs to be alerted so that it can take > appropriate action, e.g. restart the enclave. This is reinforced > by (c) as the kernel doesn't really have any other reasonable option, > e.g. we could kill the task or panic, but neither is warranted. > > Signed-off-by: Sean Christopherson > Cc: Dave Hansen > Signed-off-by: Jarkko Sakkinen > --- > arch/x86/mm/fault.c | 20 +++++++++++++++++--- > 1 file changed, 17 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > index 85d20516b2f3..3fb2b2838d6c 100644 > --- a/arch/x86/mm/fault.c > +++ b/arch/x86/mm/fault.c > @@ -960,10 +960,13 @@ static noinline void > bad_area_access_error(struct pt_regs *regs, unsigned long error_code, > unsigned long address, struct vm_area_struct *vma) > { > + int si_code = SEGV_ACCERR; > + > if (bad_area_access_from_pkeys(error_code, vma)) > - __bad_area(regs, error_code, address, vma, SEGV_PKUERR); > - else > - __bad_area(regs, error_code, address, vma, SEGV_ACCERR); > + si_code = SEGV_PKUERR; > + else if (unlikely(error_code & X86_PF_SGX)) > + si_code = SEGV_SGXERR; > + __bad_area(regs, error_code, address, vma, si_code); > } This conflicts with a cleanup in this area I have sitting in linux-next. It isn't in the x86 tree but you can find my siginfo tree at: git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git siginfo-next In my tree bad area no longer takes a vma parameter. If you are going to make changes to the fault handling code this cycle please let's figure out how to build it on top of my clean ups. Thank you, Eric Biederman