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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F1A0C636C7 for ; Thu, 15 Jul 2021 18:07:50 +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 933F860551 for ; Thu, 15 Jul 2021 18:07:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 933F860551 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4976A81D6C; Thu, 15 Jul 2021 20:07:47 +0200 (CEST) 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="g/Jda1Pf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A85B081E1C; Thu, 15 Jul 2021 20:07:45 +0200 (CEST) Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (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 4A46F81668 for ; Thu, 15 Jul 2021 20:07:42 +0200 (CEST) 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-ej1-x636.google.com with SMTP id qb4so10725628ejc.11 for ; Thu, 15 Jul 2021 11:07:42 -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=Bv7gLD4Vmig+akZEyY2maFV2j3TF0/kkHditMmvYFgQ=; b=g/Jda1Pfb8GAjabLuKiMhR0j64+cPZUbpzZlgq8re95zZJpHBfO4NvpNISJCuVPAqm iYZI3/NyWYv+FbbQl1i2sPM14/HDblaUzaUzqPQJWefInnAtDaEBX7nDK2h79R0ibwRy mWm/+aECq1qO1AKf3rMcLZe+aYBA0kvyqxheaRbZeJ02d1nMWRv0K97xxdULA5cgG0Bl IZw+oaLDhFXrdXzX7Ic0sD/yTIEScdaSPsEQMiZq8G4LpTJh/THfOKj+uibYi7+BpYx9 XvI1I1jNEHJ1pE/Iik/DWfPTBTgk+Lc8ncXswiu3bRd5OT6OPAawTM9QLY1m9PhiKVkB DdIg== 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bv7gLD4Vmig+akZEyY2maFV2j3TF0/kkHditMmvYFgQ=; b=sqBnPzGRXOaeIiVNA8bGV3fNs+rxGvLFzZyrZl8GOVfRucQR81aUUCZKJ1lETUB84b P0dla8A8BKzzjaOyR6z35/42+z/ImA8+RKvTkUTFaOczewDNEt3NfcZX9D0jldExc7AX uXVIhNwrDXIJ04rBrXDmod93jNoLBHJyQANuMBOOLve7gomgkTgpJ20Mt64sz+8wR5bS 6KU6Gs3FEeUM2dEh8pdhIW8VQtJjaRKOcrgZIP43EbUIbnUJ1zJvE89x8xLKXM7tgdez Pt0oUkzHCX7UChwBHf209SUNjUl/wb4KvHZtmV0u7hgdlv8ONfDzlzsbffiq26tjVJ7d lZsQ== X-Gm-Message-State: AOAM533+HOvJYG/+PJ1dwZWhD625BNmtM8zDuIIzjNp7u4gz0Q9TiK5M P1p4fYyRuKu7GWG0bNjdGn2n7Q== X-Google-Smtp-Source: ABdhPJypJgzUWHMmMJkaG5zX6mkgK2d6c0JvsnPb+5yriZESVFbH/ILUOShced8GOhNl4NL8JMMHzA== X-Received: by 2002:a17:906:2a08:: with SMTP id j8mr6835040eje.449.1626372461770; Thu, 15 Jul 2021 11:07:41 -0700 (PDT) Received: from enceladus (ppp-94-66-243-35.home.otenet.gr. [94.66.243.35]) by smtp.gmail.com with ESMTPSA id n2sm2792691edi.32.2021.07.15.11.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 11:07:41 -0700 (PDT) Date: Thu, 15 Jul 2021 21:07:38 +0300 From: Ilias Apalodimas To: Simon Glass Cc: U-Boot Mailing List , Thirupathaiah Annapureddy , Walter Lozano Subject: Re: [PATCH 4/9] sandbox: tpm: Correct handling of get-capability Message-ID: References: <20210705154849.2083972-1-sjg@chromium.org> <20210705154849.2083972-5-sjg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210705154849.2083972-5-sjg@chromium.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 Hi Simon, On Mon, Jul 05, 2021 at 09:48:44AM -0600, Simon Glass wrote: > This function current handles the kernel case incorrectly. Fix it, and > use the shorter TPM_HDR_LEN while we are here. > > Signed-off-by: Simon Glass > --- > > drivers/tpm/tpm_tis_sandbox.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c > index 85b22afa4d9..efbeb00ab63 100644 > --- a/drivers/tpm/tpm_tis_sandbox.c > +++ b/drivers/tpm/tpm_tis_sandbox.c > @@ -140,16 +140,13 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, > printf("Get flags index %#02x\n", index); > *recv_len = 22; > memset(recvbuf, '\0', *recv_len); > - data = recvbuf + TPM_RESPONSE_HEADER_LENGTH + > - sizeof(uint32_t); > + data = recvbuf + TPM_HDR_LEN + sizeof(uint32_t); > switch (index) { > case FIRMWARE_NV_INDEX: > break; > case KERNEL_NV_INDEX: > handle_cap_flag_space(&data, index); > - *recv_len = data - recvbuf - > - TPM_RESPONSE_HEADER_LENGTH - > - sizeof(uint32_t); > + *recv_len = data - recvbuf; This is the only actual fix right? TPM_RESPONSE_HEADER_LENGTH and TPM_HDR_LEN are both defined to 10? Is it worth updating the commit message with exactly the problem that was fixed? > break; > case TPM_CAP_FLAG_PERMANENT: { > struct tpm_permanent_flags *pflags; > @@ -166,15 +163,12 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, > printf(" ** Unknown flags index %x\n", index); > return -ENOSYS; > } > - put_unaligned_be32(*recv_len, > - recvbuf + > - TPM_RESPONSE_HEADER_LENGTH); > + put_unaligned_be32(*recv_len, recvbuf + TPM_HDR_LEN); > break; > case TPM_CAP_NV_INDEX: > index = get_unaligned_be32(sendbuf + 18); > printf("Get cap nv index %#02x\n", index); > - put_unaligned_be32(22, recvbuf + > - TPM_RESPONSE_HEADER_LENGTH); > + put_unaligned_be32(22, recvbuf + TPM_HDR_LEN); > break; > default: > printf(" ** Unknown 0x65 command type %#02x\n", > -- > 2.32.0.93.g670b81a890-goog >