Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp74196imu; Mon, 10 Dec 2018 16:26:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/WfEw3xVwPjSVkxfgUUBT6CbfXQKHRb+vA2eUjvlpI3FGZ8FmejagTeRffz2nXIJQMwngvy X-Received: by 2002:a63:7e5b:: with SMTP id o27mr12624806pgn.214.1544488000114; Mon, 10 Dec 2018 16:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544488000; cv=none; d=google.com; s=arc-20160816; b=wGKf4uSz1UZBnNOCsVRaoogMtkzn90LwAttvgHCMVw9jtFaT4SCV8FKdscRAVJfXD9 NwnVgurOEGy4Pzl14iMSaxCcMf6wcVSr0GT+ajgQcfx0+KgXvPy20Bse6TfmqceGaFVL c5MA9Akx7ACB5zJt38BUdxaN5nxaz5AbkjHHi/Cz2sbbtzt22kIdA6B4raatXKNYKsYj s25g22ggFqjKFJd0rri7aq097X/46znXgVA8KimDrvGqu0CVSbvl/Ez7f97WaPPC10FQ 37KOvVL1gvaT7WdkhoTeHIQ3z7ovNvUeOIJT1wTykfJheLi2lDOFjiMrc4sHXJqjCpfi OjgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3JITYtC2yb5U4Vhgl/XFUh3s3kwL3VgpBWx8UF4270A=; b=qtw+oh4yVhf949zYLsfaBpz1sdbx8LOUlXYz7n3P99dPb3qTw49t4gReSRZ5Mz4oMw 4mQxk6sXnsRD1tYwKDpdFKJSW4Mq+IVfKwDU++atcWiPlYuUdVWeMKA1p4lsORFzdzT+ 3FboSE9n0fgKwDRIlaGb2cjsT3mYpew7FNip9zMh17+DwOpS9w+rdNpheUwWkLz7EMtz sb71+ZwJ3IlpZHnwQ/LMJpRDV+higPjFhBkBNLcEaGRQhNer/f2NmJ8NY2N20tF+jm5e iPhWfBQoVI0o+Gq9rp1j2AEWTYtzZpEnoSz8yJ6VyhzWBsX7UI00q6StHiiX9nYnOPGj sNFA== 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 q5si11031319pgr.435.2018.12.10.16.26.24; Mon, 10 Dec 2018 16:26:40 -0800 (PST) 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 S1730066AbeLJXWF (ORCPT + 99 others); Mon, 10 Dec 2018 18:22:05 -0500 Received: from mga04.intel.com ([192.55.52.120]:11282 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729768AbeLJXV7 (ORCPT ); Mon, 10 Dec 2018 18:21:59 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 15:21:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,340,1539673200"; d="scan'208";a="117684783" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.154]) by orsmga001.jf.intel.com with ESMTP; 10 Dec 2018 15:21:57 -0800 From: Sean Christopherson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Jarkko Sakkinen , Sean Christopherson , Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, Andy Lutomirski , Josh Triplett , Haitao Huang , Jethro Beekman , "Dr . Greg Wettstein" Subject: [RFC PATCH v3 3/4] x86/traps: Attempt to fixup exceptions in vDSO before signaling Date: Mon, 10 Dec 2018 15:21:40 -0800 Message-Id: <20181210232141.5425-4-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181210232141.5425-1-sean.j.christopherson@intel.com> References: <20181210232141.5425-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call fixup_sgx_enclu_exception() in all trap flows that generate signals to userspace immediately prior to generating any such signal. If the exception is fixed, return cleanly and don't generate a signal. Cc: Andy Lutomirski Cc: Jarkko Sakkinen Cc: Dave Hansen Cc: Josh Triplett Signed-off-by: Sean Christopherson --- arch/x86/kernel/traps.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 9b7c4ca8f0a7..dd664503803b 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -61,6 +61,7 @@ #include #include #include +#include #ifdef CONFIG_X86_64 #include @@ -223,6 +224,10 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str, tsk->thread.error_code = error_code; tsk->thread.trap_nr = trapnr; + if (user_mode(regs) && + fixup_sgx_enclu_exception(regs, trapnr, error_code, 0)) + return 0; + return -1; } @@ -563,6 +568,9 @@ do_general_protection(struct pt_regs *regs, long error_code) tsk->thread.error_code = error_code; tsk->thread.trap_nr = X86_TRAP_GP; + if (fixup_sgx_enclu_exception(regs, X86_TRAP_GP, error_code, 0)) + return; + show_signal(tsk, SIGSEGV, "", desc, regs, error_code); force_sig(SIGSEGV, tsk); @@ -791,6 +799,10 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) goto exit; } + if (user_mode(regs) && + fixup_sgx_enclu_exception(regs, X86_TRAP_DB, error_code, 0)) + goto exit; + if (WARN_ON_ONCE((dr6 & DR_STEP) && !user_mode(regs))) { /* * Historical junk that used to handle SYSENTER single-stepping. @@ -854,6 +866,9 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr) if (!si_code) return; + if (fixup_sgx_enclu_exception(regs, trapnr, error_code, 0)) + return; + force_sig_fault(SIGFPE, si_code, (void __user *)uprobe_get_trap_addr(regs), task); } -- 2.19.2