Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4965018ybg; Mon, 21 Oct 2019 17:59:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNeOOTSQW71KQOXraQ8cmnbTmV4n8uc9Tm+SyYSpMyNMXhpZZsYe5a2bdrSKv2zRJVhYzt X-Received: by 2002:a05:6402:8c2:: with SMTP id d2mr9337883edz.217.1571705961241; Mon, 21 Oct 2019 17:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571705961; cv=none; d=google.com; s=arc-20160816; b=j0zAjOdJY5sqo7C99u95j+L3TAlU+QOVDfToIDVhPbwJ4guMj/XLYwTu/bkizCPeoM n7b8By4/nOFgXRvCAW9vktZDBeHCM/qbO4YTJrQXvNKLxitKHp2xmGuDAlLa6D7oOCVo 9pV0KtJPr6gJ1wpX7K7vkjUe5JCgHUik7OZ00hmh0XaTkyS0mYWzuTP4Uc0yGuNpDoA4 rIIWiaJl0fFyhiuh9VGSZg38oBYlxsT9IUMMzqZ8PjTl1mPGJBOVYfrRHaJVswftC0g9 FNPXLzbA02Q9D1sAWg6c4o4bGRE9sdbB3JVIztHUCfmkUHtvbFIicGXWJIr1aV/OeuId Stfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=P6RcNi5uOd1zBKqkT/UxYCKGepqZ9mx8RKHu653+b60=; b=pLVa5E+1XQTVLOxGQ0QMw/s0SYT537eBdC6gtzT8nPXH5Jud1IFP9SG1zAqyDRh2HE FgkqBLx/S4LiWgGYOI424znQLlie1PD5nDjlOxo6hNYDAN2/pIvb5D5fVHVIll6tPgn9 +fFoxRFt71tWX+/4S+zeobLjwehnLCBEkD8mbJYLLbGUdE1yLeR5hnUv3pBxfKzafk9c v6JJCGzbZvLg9J1KL345uDWYohzwhBVDfzuEKU/OpiZXGy+pLkrTCOa8Ybv5HJZqg5y/ +29oGO3AIph/6zPrE5jaUD9OQ/hFlWSCM0wog+y2EuDbmo0j6MZM601e8h3ivf8u3c/O 5cYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Mgrj/IV/"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si3810924edd.8.2019.10.21.17.58.45; Mon, 21 Oct 2019 17:59:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Mgrj/IV/"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730603AbfJVA5e (ORCPT + 99 others); Mon, 21 Oct 2019 20:57:34 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42130 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730601AbfJVA5e (ORCPT ); Mon, 21 Oct 2019 20:57:34 -0400 Received: by mail-pf1-f193.google.com with SMTP id q12so9515948pff.9 for ; Mon, 21 Oct 2019 17:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=P6RcNi5uOd1zBKqkT/UxYCKGepqZ9mx8RKHu653+b60=; b=Mgrj/IV/UOMgU2MuVVtmPeMxX+dYKZehrsDmNUOFzEVphmGX8rFvKNLhq5ICaXO+Gr TlNU9BVZZvKUASmDXgCyYGkdw2CoS4vLSV/y4e4nVY+03URTQVGbjD8u86Ie24bDhj3Z 7t33zWaB0wWQK9vrnndS28gEgeiCK/hMWqJ4uT86ToJq8VkljiNyfG9ED+xfdxjRTuYT Bw6ycj92HqJK1Tt6OaPZfrwnPu0OrDIusjxpPaRBZ53XhbDq80yCVxPHoNje1Y/gEJit J3SQ6qzfWayU6N65dUYvUFa+GDQ/2I/MwtsYR7n2a/VCPZgyvmaTEsmNnX/Ua7IKw7O4 6ZFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=P6RcNi5uOd1zBKqkT/UxYCKGepqZ9mx8RKHu653+b60=; b=JYElzSLt8tkR/OZ5LJOSF05H7kevT1LqQk2i2go8LM431+kbDAqFLtSnOvhy5Jj/FM 8Eja01arnjJXdTJiTx9Q7HxP5i+vaQUoSYyVfzuOKjvrmDkh/4RU9EJCrX2hJFKpJVek 0v+Lv6Xpre4P7P8T+eIckIqIJ1gMdha0XoutrLrEsaTt9FL1tlygXsmpRtdiQbJ1/t0Z I9I9ttMsVjLqaX5cMpsyXSWNkyzWfTRrScPt1TquEhnORrcjrIHOF7jlSqg4RdnuEycb S35kFAGz3v0ppWS6BVSgkM5rWBsSanBtN4fzGC8vV5936NkQeAr5vXW+UNL400+fTLx1 F55w== X-Gm-Message-State: APjAAAUoqiK8ZIoQ4eSt2lrU5Y8oqdd3owZzHt5EX0jv00kpCw42bmTP gsEtXVKkl5CeiaxiIgTSdHIQZw== X-Received: by 2002:a62:1ccf:: with SMTP id c198mr1035187pfc.156.1571705853073; Mon, 21 Oct 2019 17:57:33 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id f21sm14561089pgh.85.2019.10.21.17.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 17:57:32 -0700 (PDT) Date: Mon, 21 Oct 2019 17:57:31 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: "Singh, Brijesh" cc: "Kalra, Ashish" , "Lendacky, Thomas" , "Hook, Gary" , "herbert@gondor.apana.org.au" , "davem@davemloft.net" , "gregkh@linuxfoundation.org" , "tglx@linutronix.de" , "allison@lohutok.net" , "info@metux.net" , "yamada.masahiro@socionext.com" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" Subject: Re: [PATCH] crypto: ccp - Retry SEV INIT command in case of integrity check failure. In-Reply-To: <29887804-ecab-ae83-8d3f-52ea83e44b4e@amd.com> Message-ID: References: <20191017223459.64281-1-Ashish.Kalra@amd.com> <29887804-ecab-ae83-8d3f-52ea83e44b4e@amd.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, 21 Oct 2019, Singh, Brijesh wrote: > >> From: Ashish Kalra > >> > >> SEV INIT command loads the SEV related persistent data from NVS > >> and initializes the platform context. The firmware validates the > >> persistent state. If validation fails, the firmware will reset > >> the persisent state and return an integrity check failure status. > >> > >> At this point, a subsequent INIT command should succeed, so retry > >> the command. The INIT command retry is only done during driver > >> initialization. > >> > >> Additional enums along with SEV_RET_SECURE_DATA_INVALID are added > >> to sev_ret_code to maintain continuity and relevance of enum values. > >> > >> Signed-off-by: Ashish Kalra > >> --- > >> drivers/crypto/ccp/psp-dev.c | 12 ++++++++++++ > >> include/uapi/linux/psp-sev.h | 3 +++ > >> 2 files changed, 15 insertions(+) > >> > >> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c > >> index 6b17d179ef8a..f9318d4482f2 100644 > >> --- a/drivers/crypto/ccp/psp-dev.c > >> +++ b/drivers/crypto/ccp/psp-dev.c > >> @@ -1064,6 +1064,18 @@ void psp_pci_init(void) > >> > >> /* Initialize the platform */ > >> rc = sev_platform_init(&error); > >> + if (rc && (error == SEV_RET_SECURE_DATA_INVALID)) { > >> + /* > >> + * INIT command returned an integrity check failure > >> + * status code, meaning that firmware load and > >> + * validation of SEV related persistent data has > >> + * failed and persistent state has been erased. > >> + * Retrying INIT command here should succeed. > >> + */ > >> + dev_dbg(sp->dev, "SEV: retrying INIT command"); > >> + rc = sev_platform_init(&error); > >> + } > >> + > >> if (rc) { > >> dev_err(sp->dev, "SEV: failed to INIT error %#x\n", error); > >> return; > > > > Curious why this isn't done in __sev_platform_init_locked() since > > sev_platform_init() can be called when loading the kvm module and the same > > init failure can happen that way. > > > > The FW initialization (aka PLATFORM_INIT) is called in the following > code paths: > > 1. During system boot up > > and > > 2. After the platform reset command is issued > > The patch takes care of #1. Based on the spec, platform reset command > should erase the persistent data and the PLATFORM_INIT should *not* fail > with SEV_RET_SECURE_DATA_INVALID error code. So, I am not able to see > any strong reason to move the retry code in > __sev_platform_init_locked(). > Hmm, is the sev_platform_init() call in sev_guest_init() intended to do SEV_CMD_INIT only after platform reset? I was under the impression it was done in case any previous init failed.