Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1035466imu; Tue, 11 Dec 2018 11:33:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/X6YDQqnUwi9Fzd25GtTnC3mOX6bRr1LB+hUvVUoYTTb/gpElAqWVE9NSU+K2Rc8cgljQ4y X-Received: by 2002:a62:d74d:: with SMTP id v13mr17175419pfl.34.1544556836371; Tue, 11 Dec 2018 11:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544556836; cv=none; d=google.com; s=arc-20160816; b=gv4paUkKlF/xKCH6sJCLhgXQGqbaBOTthiVKU3wMK5OQLBiwu3JO4N/2+RpGPThlv/ cE3Rq5RxpQrwYLB77D5Rt6P1xEwE7Y8ZTV2dkGQD0kuG1mJ7CVRf3GyK6CO+kev18vXx n0hsNDD6Evs4EaG5Z5stoI4PnDJlS9sXWRaSmWG/ziYDyyWXHvtZsbzuKrC0o6LPkv12 kBCz+Z9cb6C0nVE9XefIQBLE4JqyUCfQu50k+r/DD8rPkesWNy4BIFYBy1p2KWLJIcqK uvn5+U7N8i8UeTdAel1+N+olf6P6oq13Lui7ruN4Qy84iaf5M0CPgGBirJbiNo+aMA4n Y0/w== 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=8zSeYg+L64l6i7le3VmUnAjPsV0VVEhJ7bJXtWK12cQ=; b=EGAtY8YcOnieM/vd4vAf5eM12aUx2ZICuZl/6b9qyTxgEJv4NgOsD9U28MBrVOyYm1 J+sbWuXdQzX7hU7K+8ok+JKdb2h4NVGkgWg1AfqV6MtgQGsCGFDvbjyGPf1qim4NkOy8 evjz0ZOJNWQ0ydZ02I30T1iqd07b261OCPEB9nBHIMoVoFNMpAzbOiKd4M1ddJxtS+U4 +dJ3z1euz6SZH8N3vDZ54xqiUf8gOVTfx64WcEkljAOpzV2PVoqK+biRKcNU1r/htjgX Osf2D0pxSYqgWPfLKLVx7uHR/g3Jmr56XUevWdzSEuCa/stIXUzt8eVQWu9+mbu2BcDC 8RNw== 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 a13si12246366pgb.412.2018.12.11.11.33.41; Tue, 11 Dec 2018 11:33:56 -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 S1726675AbeLKTbq (ORCPT + 99 others); Tue, 11 Dec 2018 14:31:46 -0500 Received: from mga12.intel.com ([192.55.52.136]:26804 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726340AbeLKTbp (ORCPT ); Tue, 11 Dec 2018 14:31:45 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2018 11:31:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,343,1539673200"; d="scan'208";a="301317081" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.154]) by fmsmga006.fm.intel.com with ESMTP; 11 Dec 2018 11:31:44 -0800 Date: Tue, 11 Dec 2018 11:31:44 -0800 From: Sean Christopherson To: Andy Lutomirski Cc: Andrew Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , Dave Hansen , Peter Zijlstra , "H. Peter Anvin" , LKML , Jarkko Sakkinen , Josh Triplett , linux-sgx@vger.kernel.org, haitao.huang@linux.intel.com, Jethro Beekman , "Dr. Greg Wettstein" Subject: Re: [RFC PATCH v2 4/4] x86/vdso: Add __vdso_sgx_enter_enclave() to wrap SGX enclave transitions Message-ID: <20181211193144.GG14731@linux.intel.com> References: <20181206221922.31012-5-sean.j.christopherson@intel.com> <20181207165145.GB10404@linux.intel.com> <20181207190257.GC10404@linux.intel.com> <20181207200935.GE10404@linux.intel.com> <4CEB5945-9562-40FA-8CCA-A1675D55B001@amacapital.net> <20181207212649.GG10404@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Fri, Dec 07, 2018 at 03:33:57PM -0800, Andy Lutomirski wrote: > On Fri, Dec 7, 2018 at 1:26 PM Sean Christopherson > wrote: > > > > Running a checksum on the stack for every exit doesn't seem like it'd > > be worth the effort, especially since this type of bug should be quite > > rare, at least in production environments. > > > > If we want to pursue the checksum idea I think the easiest approach > > would be to combine it with an exit_handler and do a simple check on > > the handler. It'd be minimal overhead in the fast path and would flag > > cases where invoking exit_handle() would explode, while deferring all > > other checks to the user. > > How about this variant? > > #define MAGIC 0xaaaabbbbccccddddul > #define RETADDR_HASH ((unsigned long)__builtin_return_address(0) ^ MAGIC) > > void foo(void) > { > volatile unsigned long hash = RETADDR_HASH; > > /* placeholder for your actual code */ > asm volatile ("nop"); > > if (hash != RETADDR_HASH) > asm volatile ("ud2"); > } > > But I have a real argument for dropping exit_handler: in this new age > of Spectre, the indirect call is a retpoline, and it's therefore quite > slow. Technically slower, but would the extra CALL+RET pair even be noticeable in the grand scheme of SGX? > So I'm not saying NAK, but I do think it's unnecessary. Ya, definitely not necessary, but it does allow userspace do things that are otherwise cumbersome or impossible to do with the vanilla vDSO. How much value that actually adds is another question...