Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3436380pxk; Mon, 28 Sep 2020 18:23:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzg+YGYRywMBhT5SlP0MSkX++K4dmN3vQXOeapjJxnIHCeEBfiS33yKAacy58L1crhRNm99 X-Received: by 2002:a50:9e6a:: with SMTP id z97mr813661ede.32.1601342623548; Mon, 28 Sep 2020 18:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601342623; cv=none; d=google.com; s=arc-20160816; b=q1y5j4fBg3O8CHRYUYE6acWE7O+Q6e8P10Eq9kFFZZvPjz8DHK23phdu/Tu7Too4Re Gf8Vdo6FBW2G+7ZTr7Lhy0ileGTAskJxROxXSkapQkdD3tiGVNAyvLq6EVw0/+CyvQ2g jihM8wwyhWyTgidZHP4Gickw8F/pxPoxNIIYeGiha9921Z8dwdyzjHTdHifZyZ8W9x3N 4gTbGp1S529dZHivYvwfr405ScmdULDlaeH8krZvdiOvk3YcPhs79fcHc2/UnBWmI+vS puXLoQlWnqb10w37OtzXSmmVU3d66AD6VsaHvYZwFl729Ni/9o4WnmkUNhdqLDlZEVfs cjDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=zy0cjXApYTQkoXTBcHhyGWRqvpAJT3EoWclNHDYlWMY=; b=ZPC5GbiD8jRABH4K0V0+2pif28nhkzWVNXMsaswYlXkP+CFp0zTSv/igPHHLMzqBTu wdO3zF4HA/FQ4GZEi7SstRMxNeSKDH9nnS3fxp8g3rZDHgj6yBRWhiirnrZ6OYRXR2YJ GUVAiYfxyNapWvn0XkozVvHodadh4PZmPP/8icCAiuIQDWbrjhWFiFedqoUP3UtreVg2 IpIxfq0N0ZZEx13X5r/9y+Anm1PmeEKmEjCrJbBsiCf3AnYQ+QbhRQJL8rasVCo0ir1+ H2yn6KM9y0YRFT2QlR3yL8uq3sf6E2xWKZPhTizHa4bpuINmtn29HDeXRXE/B3Y4oWkd CqFw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bl4si1808174ejb.190.2020.09.28.18.23.13; Mon, 28 Sep 2020 18:23:43 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727185AbgI2BSd (ORCPT + 99 others); Mon, 28 Sep 2020 21:18:33 -0400 Received: from mga12.intel.com ([192.55.52.136]:35482 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbgI2BSd (ORCPT ); Mon, 28 Sep 2020 21:18:33 -0400 IronPort-SDR: iFNby29po1uDWdFmL5AOwkFICJfoq/W/fdd2ALkX//pWWc3TW4pMCPq08/nnv/xy1lf3vo0yIH wxb2mq985A+g== X-IronPort-AV: E=McAfee;i="6000,8403,9758"; a="141475111" X-IronPort-AV: E=Sophos;i="5.77,315,1596524400"; d="scan'208";a="141475111" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2020 15:07:49 -0700 IronPort-SDR: QlGRTqEN4d8qtBxrb2skgkdPLBIZM2kFqgtNC1yKwoS0Zp6q+/PfjONCBSwsAQL+HfayEcCDz5 SNVLTsJ6l8EQ== X-IronPort-AV: E=Sophos;i="5.77,315,1596524400"; d="scan'208";a="488780374" Received: from jlasecki-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.49.78]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2020 15:07:42 -0700 Date: Tue, 29 Sep 2020 01:07:40 +0300 From: Jarkko Sakkinen To: Dave Hansen Cc: Andy Lutomirski , "H.J. Lu" , Andrew Cooper , the arch/x86 maintainers , linux-sgx@vger.kernel.org, LKML , Sean Christopherson , Jethro Beekman , Cedric Xing , Andrew Morton , Andy Shevchenko , asapek@google.com, Borislav Petkov , chenalexchen@google.com, Conrad Parker , cyhanish@google.com, "Huang, Haitao" , Josh Triplett , "Huang, Kai" , "Svahn, Kai" , Keith Moyer , Christian Ludloff , Neil Horman , Nathaniel McCallum , Patrick Uiterwijk , David Rientjes , Thomas Gleixner , yaozhangx@google.com, Yu-cheng Yu Subject: Re: [PATCH v38 21/24] x86/vdso: Implement a vDSO for Intel SGX enclave call Message-ID: <20200928220740.GG2705@linux.intel.com> References: <20200915112842.897265-1-jarkko.sakkinen@linux.intel.com> <20200915112842.897265-22-jarkko.sakkinen@linux.intel.com> <721ca14e-21df-3df1-7bef-0b00d0ff90c3@citrix.com> <20200928005842.GC6704@linux.intel.com> <85bc15d5-93cd-e332-ae9a-1e1e66e1181d@citrix.com> <0edfbf96-32db-3565-0d07-7d4a4118dbe6@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0edfbf96-32db-3565-0d07-7d4a4118dbe6@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2020 at 11:17:42AM -0700, Dave Hansen wrote: > On 9/28/20 11:12 AM, Andy Lutomirski wrote: > >> endbr64 > >> /* Check if shadow stack is in use. NB: R11 is the only usable > >> scratch register for function calls. */ > >> xorl %r11d, %r11d > >> rdsspq %r11 > >> testq %r11, %r11 > >> jnz 3f > >> call 2f > >> 1: > >> pause > >> lfence > >> jmp 1b > >> 2: > >> mov %rax, (%rsp) > >> ret > >> 3: > >> /* Shadow stack is in use. Make the indirect call. */ > >> call *%rax > >> ret > > What do we expect user programs to do on CET systems? It would be > > nice if we could instead ALTERNATIVE this out if X86_FEATURE_SHSTK. > > Shouldn't we just be able to use X86_FEATURE_RETPOLINE? > > We probably need a mechanism to force X86_FEATURE_SHSTK and > X86_FEATURE_RETPOLINE to be mutually exclusive if we don't have one already. First of all: lets go with boot time patching instead of dynamic detection. It's both easier to implement and by all other merits makes a lot more sense. It was just a thing that I've not used before. That sorted out, does it matter which direction I look it at? I could use either feature flag as basis (and I do not have a personal preference here). /Jarkko