From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49730C433F5 for ; Thu, 4 Nov 2021 10:58:40 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C18C61108 for ; Thu, 4 Nov 2021 10:58:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6C18C61108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EF24F83684; Thu, 4 Nov 2021 11:58:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="cWJR5cIG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F181983692; Thu, 4 Nov 2021 11:58:34 +0100 (CET) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 77E9D8367E for ; Thu, 4 Nov 2021 11:58:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wr1-x42a.google.com with SMTP id d27so7942444wrb.6 for ; Thu, 04 Nov 2021 03:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RyK+X8HjyW/mFXYXhVr+W0jC3rAnD2mmNjQWq63xDhc=; b=cWJR5cIGOFt5yx955BAh/m9uf4U5a7yUn9SMfLDxh2LtdIstkmwQeiGrL2wkTU3ZoH 7jdUmogme5DfJoTeITk5ZT9lMCeNPSkSMumDB+tBS6mnLL6BSVDRb2Kq+oy6AX/KCl2L DUIcIZrb88MjHNfSZFZ4sagg10Cz4S8Sy1KFZzqkX4DjXeOc/xYHkPBnh9mIlk4AEM4C Gp2fFHItUcnlPh2e0rE3vISEKzAynU3Ts8C7qNyU+7LMhDtVUUuyRRgZ5YccZugGANtL SemcSSOvEoqlcogl60OvHHyp00D5+aV7RsjocaYrxpDPjfMGjaSqVBXIOhSB0ufZn7Dy LRXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RyK+X8HjyW/mFXYXhVr+W0jC3rAnD2mmNjQWq63xDhc=; b=5hGE5ZxkXJQeNH7sgjdrRLu9GEPBr9rb49SpKj8/0BghxbX/ripIjIhZBkOT36t9fd +xIG/CIdex11HgbhkpZPFyMCIATVNrhkCA5hJ4d6erZf2tr+cU0tH2I6EfoQLlE7B6g0 WYxBwV6su7YhxS/2n8hBMgGBkH7y3PqKGATWE39q/sYiWBk39UFf2Vvabm06wb1ILIH4 QmJ7GlItlSUtdqpvTLczkdBmMFP0p2FadzJmcSPMsRlEo+g9Q6LbkQ3vpBaxcp4euUIO gZjCWnL5ifzojYKp8ja8OdRwl9swZK2BTumIiltphFQl+o6hjEZtfPZ541knfzK+f0BS Tqdw== X-Gm-Message-State: AOAM5323LFOvG4Sm/HvRiQyVMDgRO/CMW7E6Xy1UZN82OpLHnl6ZVwiW dHV+Q0z6OjJ5opqluuZrg1lGog== X-Google-Smtp-Source: ABdhPJxBjrvmc6CkG/toq2CO3W2mfmGLhfJIZESrU0t9YdLYLLOks2peUYtFzuQ2e2JxGLUhrbaCtA== X-Received: by 2002:adf:eb4b:: with SMTP id u11mr49545830wrn.49.1636023510856; Thu, 04 Nov 2021 03:58:30 -0700 (PDT) Received: from apalos.home (ppp-94-66-220-13.home.otenet.gr. [94.66.220.13]) by smtp.gmail.com with ESMTPSA id t8sm4559131wrv.30.2021.11.04.03.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Nov 2021 03:58:30 -0700 (PDT) Date: Thu, 4 Nov 2021 12:58:28 +0200 From: Ilias Apalodimas To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Alexander Graf , Simon Glass Subject: Re: [PATCH v2] efi_loader: add EFI_TCG2_PROTOCOL.SubmitCommand Message-ID: References: <20211102054852.11235-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211102054852.11235-1-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Tue, Nov 02, 2021 at 02:48:52PM +0900, Masahisa Kojima wrote: > This commit adds the EFI_TCG2_PROTOCOL.SubmitCommand > required in the TCG PC Client PFP spec. > SubmitCommand enables to send the raw command to the TPM device. > > To implement this api, tpm2_submit_command() is added > into tpm-v2.c. > > Signed-off-by: Masahisa Kojima > --- > Changes in v2: > - return EFI_OUT_OF_RESOURCES if the recv buffer is small > - remove unused argument of tpm2_submit_command() > > include/tpm-v2.h | 14 +++++++++++++ > lib/efi_loader/efi_tcg2.c | 41 +++++++++++++++++++++++++++++++++------ > lib/tpm-v2.c | 6 ++++++ > 3 files changed, 55 insertions(+), 6 deletions(-) > > diff --git a/include/tpm-v2.h b/include/tpm-v2.h > index e6b68769f3..39c8c0897b 100644 > --- a/include/tpm-v2.h > +++ b/include/tpm-v2.h > @@ -642,4 +642,18 @@ u32 tpm2_write_lock(struct udevice *dev, u32 index); > */ > u32 tpm2_disable_platform_hierarchy(struct udevice *dev); > > +/** > + * submit user specified data to the TPM and get response > + * > + * @dev TPM device > + * @sendbuf: Buffer of the data to send > + * @recvbuf: Buffer to save the response to > + * @recv_size: Pointer to the size of the response buffer > + * > + * Returns 0 on success (and places the number of response bytes at > + * recv_size) or -ve on failure. > + */ > +u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf, > + u8 *recvbuf, size_t *recv_size); > + > #endif /* __TPM_V2_H */ > diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c > index ec20530b6b..cb67006b14 100644 > --- a/lib/efi_loader/efi_tcg2.c > +++ b/lib/efi_loader/efi_tcg2.c > @@ -1033,13 +1033,42 @@ out: > * Return: status code > */ > static efi_status_t EFIAPI > -efi_tcg2_submit_command(__maybe_unused struct efi_tcg2_protocol *this, > - u32 __maybe_unused input_param_block_size, > - u8 __maybe_unused *input_param_block, > - u32 __maybe_unused output_param_block_size, > - u8 __maybe_unused *output_param_block) > +efi_tcg2_submit_command(struct efi_tcg2_protocol *this, > + u32 input_param_block_size, > + u8 *input_param_block, > + u32 output_param_block_size, > + u8 *output_param_block) > { > - return EFI_UNSUPPORTED; > + struct udevice *dev; > + efi_status_t ret; > + u32 rc; > + size_t resp_buf_size = output_param_block_size; > + > + EFI_ENTRY("%p, %u, %p, %u, %p", this, input_param_block_size, > + input_param_block, output_param_block_size, output_param_block); > + > + if (!this || !input_param_block || !input_param_block_size) { > + ret = EFI_INVALID_PARAMETER; > + goto out; > + } > + > + ret = platform_get_tpm2_device(&dev); > + if (ret != EFI_SUCCESS) > + goto out; > + > + rc = tpm2_submit_command(dev, input_param_block, > + output_param_block, &resp_buf_size); > + if (rc) { nit pick but can you send a new version with and replace this with a ternary operation? if (rc) { ret = (rc == -ENOSPC) ? EFI_OUT_OF_RESOURCES : EFI_DEVICE_ERROR; goto out; } > + if (rc == -ENOSPC) > + ret = EFI_OUT_OF_RESOURCES; > + else > + ret = EFI_DEVICE_ERROR; > + > + goto out; > + } > + > +out: > + return EFI_EXIT(ret); > } > > /** > diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c > index 235f8c20d4..2e7b27bd6b 100644 > --- a/lib/tpm-v2.c > +++ b/lib/tpm-v2.c > @@ -659,3 +659,9 @@ u32 tpm2_disable_platform_hierarchy(struct udevice *dev) > > return 0; > } > + > +u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf, > + u8 *recvbuf, size_t *recv_size) > +{ > + return tpm_sendrecv_command(dev, sendbuf, recvbuf, recv_size); > +} > -- > 2.17.1 > Other than that Reviewed-by: Ilias Apalodimas