Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8523056rwl; Sat, 31 Dec 2022 07:12:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXtca1c0FAOSrWwEP8tRhTGFLSe0lwIGn0N91ZZ0SgYwolP1hr4pk7B5VS/4tMAHaGeCkW+c X-Received: by 2002:a05:6a20:2a09:b0:ac:44ab:33fa with SMTP id e9-20020a056a202a0900b000ac44ab33famr40650937pzh.37.1672499558928; Sat, 31 Dec 2022 07:12:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672499558; cv=none; d=google.com; s=arc-20160816; b=p+qhQN2espdaoSrDYbHhGasvVUyuyFmCLPTh1No6bmkN9ch+9JRsOaeZojkqwm68WD hFLrqA4XhZHpb3CeJmAhpRpjf3xszTQF/cM7l3NIMAT6lwJ19KAPx7gEsk28MvUXMMOg WersWfeIM+UdELiawBnu3lG9zeABBb7yF4ZVhfc5N2JxW7quz6azWISMLflNnDJYS2vM vjrwdBSg5pyDVS4q4xZwDEySCgG1xfwmnZEkhjddeaNp7X+gzTeKO3ZH1lz70NES6jJh mcFIdWd8gkb4JWpbV6AlfUXUZHTXsowZbNPoP/ksOXfhBDJsU/YeuRo/b2ICWS080vpz 5+yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zOGMiLTaD/ff59Zq6QF9yZlPHAdc4cQYNGmMJ/5IKpI=; b=CcMql9wGVtU382EZe1IKMQ+1WggNeYBa8cCBkBwlCwzagf18kMse1PVhMfoOUxHhMl veNDuE0dVq6sSAKVwh7MUFk3dIfaB7em19S+Y9LWueZvWvjH5vn0CAXBvCYtn8h//TPu A+pMUKx+t1I3mq17tT+mpE9H8na4IRxkRfY+k/f2CE5QIK6e1quKmlwPHCEMdlpGz88z 4zWiMI8PF/xRf14FzPioLKg67VN5HIblTnPv9PmIsOImtFiFfKnrZ3LHJLqeLijh1uFp MWyLIO+1h+ryy6XRCExUgeMooiwb6Z4iNIx3TqMU752SRZKuV5rdb6jiHqNnlaRVY4mi WR1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@profian-com.20210112.gappssmtp.com header.s=20210112 header.b=jmDeKlzi; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h184-20020a6383c1000000b0049dc6720a96si8261497pge.65.2022.12.31.07.12.23; Sat, 31 Dec 2022 07:12:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@profian-com.20210112.gappssmtp.com header.s=20210112 header.b=jmDeKlzi; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbiLaPL2 (ORCPT + 99 others); Sat, 31 Dec 2022 10:11:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235769AbiLaPLM (ORCPT ); Sat, 31 Dec 2022 10:11:12 -0500 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 299AB62FF for ; Sat, 31 Dec 2022 07:11:11 -0800 (PST) Received: by mail-lj1-x235.google.com with SMTP id g14so24806023ljh.10 for ; Sat, 31 Dec 2022 07:11:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profian-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zOGMiLTaD/ff59Zq6QF9yZlPHAdc4cQYNGmMJ/5IKpI=; b=jmDeKlzi/wQxFVcNgcstF7XUmY7Ghr2l6PD8MtLnUH+iyUul0nFn5XopqdIyaoS/ed sTDoDjzBz1o2Bx4/57G9oU+gW6j+g3BdFHJStYfjpWoepOFnESibkoUFtF9jIbHR4atg OffUA0LAatZei3U1yh4Q94IF2UJjeEn6+7OrXI0WoK6r95o6yC3ZzWFPMGpnO+nOLWzR cKsNCMq5b6UfYjfhvtfxSJfC57zAlS77Mpq2hv0/MScWtnhxsG84W4e52TE+HZQWHQG+ CtBT46WXyTs+k2sQMnmd2+DfT6Cod9aU/qLkHHWlQV22s2DgSzVZnSuKwmP7ZvJwuaG0 1kPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zOGMiLTaD/ff59Zq6QF9yZlPHAdc4cQYNGmMJ/5IKpI=; b=VbSN2k4fUgyobw3hqRsG7efgnDzhERf2ixM5mL6cpHecffqbnOOWYZZvM2e6C2BAs7 wq404xH66qUHNpgPE4rerhPfhBvA0NPPwvTUaNnLYkzot4mXcBop8CtDFx4X+3UULlIX HiJbaqqjV8V6PkgtYVyN0Jl8JyfzK67Nwv9B3yvJuneX49Fz3aw6YQK1FfNMIDh7TGcG kAVLFUMsbrMBwIoqVrHgJIZkQQ6gyeVYYkVZCaLwMtOJShMIDlPKLzsBzXCZbpPgAaZ6 H3yBFgUimyK8n/3hLrsvS/vUm0C2dxjU3zG31zaLiq/j+5WGZPxB+WzOwibCq+8phGaW 2/ig== X-Gm-Message-State: AFqh2kppaRWRH/M1e1wTs4FB79Y0weW9TnQiLvHtkpfWEbXoWEjOCZHe hpT51har7cOomqSvK4/G7BvYJOaQCCP9CrioVrw= X-Received: by 2002:a05:651c:38f:b0:27f:d2d2:cef2 with SMTP id e15-20020a05651c038f00b0027fd2d2cef2mr3195192ljp.46.1672499468984; Sat, 31 Dec 2022 07:11:08 -0800 (PST) Received: from localhost (83-245-197-49.elisa-laajakaista.fi. [83.245.197.49]) by smtp.gmail.com with ESMTPSA id z4-20020a2ebe04000000b0027fd65e4faesm927131ljq.108.2022.12.31.07.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Dec 2022 07:11:08 -0800 (PST) From: Jarkko Sakkinen To: linux-crypto@vger.kernel.org, Brijesh Singh , Tom Lendacky , John Allen , Herbert Xu , "David S. Miller" Cc: Jarkko Sakkinen , linux-kernel@vger.kernel.org Subject: [PATCH] crypto: ccp: Improve sev_platform_init() error messages Date: Sat, 31 Dec 2022 15:11:06 +0000 Message-Id: <20221231151106.143121-1-jarkko@profian.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The following functions end up calling sev_platform_init() or __sev_platform_init_locked(): * sev_guest_init() * sev_ioctl_do_pek_csr * sev_ioctl_do_pdh_export() * sev_ioctl_do_pek_import() * sev_ioctl_do_pek_pdh_gen() * sev_pci_init() However, only sev_pci_init() prints out the failed command error code, and even there the error message does not specify, SEV which command failed. Address this by printing out the SEV command errors inside __sev_platform_init_locked(), and differentiate between DF_FLUSH, INIT and INIT_EX commands. This extra information is particularly useful if firmware loading and/or initialization is going to be made more robust, e.g. by allowing firmware loading to be postponed. Signed-off-by: Jarkko Sakkinen --- drivers/crypto/ccp/sev-dev.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 5350eacaba3a..ac7385c12091 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -963,6 +963,7 @@ static int __sev_init_ex_locked(int *error) static int __sev_platform_init_locked(int *error) { + const char *cmd = sev_init_ex_buffer ? "SEV_CMD_INIT_EX" : "SEV_CMD_INIT"; struct psp_device *psp = psp_master; struct sev_device *sev; int rc = 0, psp_ret = -1; @@ -1008,18 +1009,23 @@ static int __sev_platform_init_locked(int *error) if (error) *error = psp_ret; - if (rc) + if (rc) { + dev_err(sev->dev, "SEV: %s failed error %#x", cmd, psp_ret); return rc; + } sev->state = SEV_STATE_INIT; /* Prepare for first SEV guest launch after INIT */ wbinvd_on_all_cpus(); - rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, error); - if (rc) - return rc; + rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, &psp_ret); + if (error) + *error = psp_ret; - dev_dbg(sev->dev, "SEV firmware initialized\n"); + if (rc) { + dev_err(sev->dev, "SEV: SEV_CMD_DF_FLUSH failed error %#x", psp_ret); + return rc; + } dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major, sev->api_minor, sev->build); @@ -2354,8 +2360,7 @@ void sev_pci_init(void) /* Initialize the platform */ rc = sev_platform_init(&error); if (rc) - dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n", - error, rc); + dev_err(sev->dev, "SEV: failed to INIT rc %d\n", rc); skip_legacy: dev_info(sev->dev, "SEV%s API:%d.%d build:%d\n", sev->snp_initialized ? -- 2.38.1