Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4293801pxb; Tue, 2 Nov 2021 07:24:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvlrH7Jj61ET+ZeTtJgHCg7XN3UqN7sEtuiK8Qvrmk2D/6yujWc/IvZMKsr4rm4bECu4BC X-Received: by 2002:a05:6e02:144b:: with SMTP id p11mr15120607ilo.70.1635863045142; Tue, 02 Nov 2021 07:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635863045; cv=none; d=google.com; s=arc-20160816; b=vCMILovyts9aZvep1aS87auuNjSZI2G/AsfskrATESUMVfOp2jtnDpUFxNUeq4DbyS 8xeFCaGvyz9H8jyta/qfRP8OVLHIDfUJ+zgDHZkBOcu6oSVclmjDk8d/pr8jfTot2P+X SgzalIpLwiBKLPP7rnuG1QSd0nbl7PgCevXfsBxXJmzWfPJKvA6b74oUeA+oTQv9aM75 ap6RQ/WyKAZKDjZSzLBt97PxPC//cgHRzCN5GJwU3x5hjnk176Xb0tGx5sXdrbbo+ib3 Ryzx1bx5vX494qTF0gfh+2m2yubW8+PyEMpA7ao65al1K8Fpc9qc7pbrJTCNkiT/RC7w l4Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=qXnwABhA26FtcwRiOkwwItakkHsn0lTvM03+FEbDB6Y=; b=whJIIuDAlcAEiasycOn9b8vd7XoA2jhFbYiO3P0j2/6s1qsR+EYWpxtK+VYoi0eDCJ o46NeaBghhHpHfIyb3GGbQ7+NMZL/0ykqAHnqeyvv6VKoUXymY7W6jEbQMR54zh6TQB4 Qk9XY9dEML4gaHoST2wAVJnNR2CJzG0CltLmzuYkSN2Bu8ij+dcGuSigov1zFMDrBDXD Fv36UQAs9gVfEU3LvtyUID1UAzSuDmtyfnPY5Y18SiWiktnNTnYYJ6FBnUQnr+TCDJy7 O9aI6ULOZwQ6sZk7+kVgJ35uYg5o2b7Nh9UNM3G93uDm+0mQjxcvNN9/JOk3K0HzX+7I 4fCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YYnVCEW2; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id l15si6813195ilv.18.2021.11.02.07.23.52; Tue, 02 Nov 2021 07:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YYnVCEW2; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 S231392AbhKBO0T (ORCPT + 99 others); Tue, 2 Nov 2021 10:26:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbhKBO0P (ORCPT ); Tue, 2 Nov 2021 10:26:15 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7134EC061205 for ; Tue, 2 Nov 2021 07:23:37 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id y3-20020a170902d64300b0013fc50eb97eso8344277plh.17 for ; Tue, 02 Nov 2021 07:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qXnwABhA26FtcwRiOkwwItakkHsn0lTvM03+FEbDB6Y=; b=YYnVCEW2r4hHwMzOIxQTSzlv652l5c9dHtPufSOWZtNfEThh5O1mMSabauac5msWvh va1NieZjuSXPW0TY5zrbeh1jnhAZQaHvewJGt51pZLSKeQRrx7prSAR/CqTtYAx22Olb YKR8ixWvMg/aSK1YzchrZV9ZdnyPGIBP7Gfw1Cj3t2kw4DTbl0TDdBFklcaty9TG2Oz7 ZdN31vJy3T1N0YH1DGWMl88ASVIWa9PXuz/J3HyyykbFpBvbzF03om/8g67ELQ+A9TIi LVQfZJLTdxlTNBM8uylEHE/mHGesX+MKkRFUt81qrvFPH1X/j9W3X4juEd8BEEAheFGs +PVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qXnwABhA26FtcwRiOkwwItakkHsn0lTvM03+FEbDB6Y=; b=kl6qd2FB1DDRrHjr3Z2cRaAqtEXQeP4eW/E8F/6/CxyUtztjIXYTJB+h5GhTC4OQoa kjlyTN22fku7CKvAo5ubQggZigsLFJedODNW5MwJyscxiTyn4bWbSFk6nFztrY0eR3I3 VL8xN0g8itU0YKgg7tGtv96FaWMqwk0PmuGgyMD1uPh1NArSCd8f7p2/EM7M9VLRt2UG SFK48xbtFFKa5wpt6NrWWRF5rvRukoZg1U/w0QfIMQYFVohaVGWdGE6czBNOZPvoAAhm pMJCc+OKz85Kv7VQjQLhOXrTUUG+obByWbG316Vhdu8qVTuZXTVt39toKEW1DdDCTVEa rThw== X-Gm-Message-State: AOAM530I/jbQToFTNwnzRLav9382RZy4fmpfYj2hLMCdLfYbAbNIMQg3 sT/CPq1eAL3Etq2VhXxzRr9kN2uH4Oo= X-Received: from pgonda1.kir.corp.google.com ([2620:15c:29:204:3109:8497:f59d:9150]) (user=pgonda job=sendgmr) by 2002:a17:90a:5285:: with SMTP id w5mr37602pjh.1.1635863016596; Tue, 02 Nov 2021 07:23:36 -0700 (PDT) Date: Tue, 2 Nov 2021 07:23:29 -0700 In-Reply-To: <20211102142331.3753798-1-pgonda@google.com> Message-Id: <20211102142331.3753798-3-pgonda@google.com> Mime-Version: 1.0 References: <20211102142331.3753798-1-pgonda@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH V3 2/4] crypto: ccp - Move SEV_INIT retry for corrupted data From: Peter Gonda To: thomas.lendacky@amd.com Cc: Peter Gonda , Marc Orr , David Rientjes , Brijesh Singh , Joerg Roedel , Herbert Xu , John Allen , "David S. Miller" , Paolo Bonzini , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This change moves the data corrupted retry of SEV_INIT into the __sev_platform_init_locked() function. This is for upcoming INIT_EX support as well as helping direct callers of __sev_platform_init_locked() which currently do not support the retry. Signed-off-by: Peter Gonda Reviewed-by: Marc Orr Acked-by: David Rientjes Acked-by: Tom Lendacky Cc: Tom Lendacky Cc: Brijesh Singh Cc: Marc Orr Cc: Joerg Roedel Cc: Herbert Xu Cc: David Rientjes Cc: John Allen Cc: "David S. Miller" Cc: Paolo Bonzini Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/ccp/sev-dev.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index ec89a82ba267..e4bc833949a0 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -267,6 +267,18 @@ static int __sev_platform_init_locked(int *error) } rc = __sev_do_cmd_locked(SEV_CMD_INIT, &data, 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(sev->dev, "SEV: retrying INIT command"); + rc = __sev_do_cmd_locked(SEV_CMD_INIT, &data, error); + } + if (rc) return rc; @@ -1091,18 +1103,6 @@ void sev_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(sev->dev, "SEV: retrying INIT command"); - rc = sev_platform_init(&error); - } - if (rc) { dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n", error, rc); -- 2.33.1.1089.g2158813163f-goog