Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2693828imm; Tue, 4 Sep 2018 08:32:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbcvhzQeO5gF0MOEO3+tiJgtZPD2a0gZfMJ0HZ7NEYHGBKOozyW3UtSG7YCHGwhvlRjD7oq X-Received: by 2002:a63:7058:: with SMTP id a24-v6mr25835373pgn.206.1536075141383; Tue, 04 Sep 2018 08:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536075141; cv=none; d=google.com; s=arc-20160816; b=xdhIr9XJWNqd/9dk7QgaPVaGxc9O94eiwTy7nv42Fqum07xOO3n5lgqNVp6ozbH9xv SEqPFHZ8bT5GIvLqTLQg7Yekv7bqZhE37g4frCyvdl9RnGi3VhuDj2ipACzPcbEX6f/o 9MlFX/Y/5+zDpe/y//iqvszsyIewMgokY10+xHqQA5xAJ2eUFRywT+EbZ1sMNn230H9T Jei3bzjuk78bDtAdKImOnKJi/ii9OpkIQuMdKxbUJfOa5FwnNpRwelaJ9VyQC/prtzdC 5lyfL9wR8BHB4pOuExo2qQbW7g2jGw0+vNtx5U2Jcoh4XsT3xsS1YvTLIL/dJnaX0ChD T5EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=xe0VG6aR6y/SOSHMiniwh/v/B4TJNfh/X/WYkoB8dCc=; b=QTu2F1xLEgQMcqg8iLbZIrsC/U7bKTuv13UXqIn5hU66cjmHbGhzIqc7bf1K/ChnZh A+nJOCF8nOz8Q1NFuWuIlR7OegTYl07XiNP0DbDHb4EjtGNG2/+w3c4usEOSnfyMab7Y HxugEycNaYoOdrErcY4dAUt5UyZxvkRL+HMYKugR2sjnpxqQjdnWZ6vNOVz9OxFAsnoP 8KKGUm0KY/eEgbx4JWsL/gcMh37mMmw1aBqeDIS7KBaGoEPymBjCdR/QYsRO1w7yIm00 MNgthKSDM1X3BRyg0uLfnCPmb1Ku2bmPNN2yH1RJMvv1LW8rDaG1YudJgMTJBaCx4Aip NPkA== 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 d13-v6si21159799pll.337.2018.09.04.08.32.06; Tue, 04 Sep 2018 08:32:21 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727628AbeIDT4G (ORCPT + 99 others); Tue, 4 Sep 2018 15:56:06 -0400 Received: from mga01.intel.com ([192.55.52.88]:16423 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbeIDT4F (ORCPT ); Tue, 4 Sep 2018 15:56:05 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2018 08:30:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,329,1531810800"; d="scan'208";a="230117360" Received: from schoebin-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.35.203]) by orsmga004.jf.intel.com with ESMTP; 04 Sep 2018 08:30:23 -0700 Date: Tue, 4 Sep 2018 18:30:21 +0300 From: Jarkko Sakkinen To: Sean Christopherson Cc: "Huang, Kai" , "platform-driver-x86@vger.kernel.org" , "x86@kernel.org" , "nhorman@redhat.com" , "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "suresh.b.siddha@intel.com" , "Ayoun, Serge" , "hpa@zytor.com" , "npmccallum@redhat.com" , "mingo@redhat.com" , "linux-sgx@vger.kernel.org" , "Hansen, Dave" Subject: Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves Message-ID: <20180904153021.GB8344@linux.intel.com> References: <20180827185507.17087-1-jarkko.sakkinen@linux.intel.com> <20180827185507.17087-11-jarkko.sakkinen@linux.intel.com> <1535406078.3416.9.camel@intel.com> <20180828070129.GA5301@linux.intel.com> <105F7BF4D0229846AF094488D65A09893541037C@PGSMSX112.gar.corp.intel.com> <20180831121645.GA18075@linux.intel.com> <20180831181509.GB21555@linux.intel.com> <20180903191926.GC13497@linux.intel.com> <105F7BF4D0229846AF094488D65A09893541970F@PGSMSX112.gar.corp.intel.com> <20180904145451.GA5233@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180904145451.GA5233@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 04, 2018 at 07:54:51AM -0700, Sean Christopherson wrote: > I don't see any value in trying to rule out specific causes of > INVALID_TOKEN, but we should only retry EINIT if ret==INVALID_TOKEN > and RDMSR(HASH0) != sgx_lepubkeyhash[0]. Only the first MSR needs to > be checked for validity as they're a package deal, i.e. they'll all be > valid or all be reset. There shouldn't be a limit on retry attempts, > e.g. the MSRs could theoretically be reset between WRMSR and EINIT. Why is doing rdmsrs necessary? With the INVALID_TOKEN error we know we are out-of-sync i.e. have been sleeping and then one just needs to do wrmsrs. I think one retry should be enough given that VMM traps EINIT. One retry is needed to take care of the guest itself (or host if we are running on bare metal) having been in a sleep state. /Jarkko