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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1C20EC25B06 for ; Sun, 14 Aug 2022 23:30:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA5DB84099; Mon, 15 Aug 2022 01:29:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jchPvhac"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 66E4C84084; Mon, 15 Aug 2022 01:29:46 +0200 (CEST) Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) (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 EC55B84099 for ; Mon, 15 Aug 2022 01:29:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-yb1-xb2a.google.com with SMTP id 204so9919334yba.1 for ; Sun, 14 Aug 2022 16:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=m/OSu5Zx1Wz0EFW3OvTOOtme9/vJi3wk0l42+xjUa00=; b=jchPvhacWBcEq4MILJfIfjoTIyNQraz6vKz86p1afevzhRyiqUDCA+N/67V5dRE0Lp 7RMVsaH2fpKCqEQPWKwt0hFY+Gt+qTwnDFR56m8eEni3ciIsXKAHsctntbVJb1OHd/WR 7FUjekB7hejozpowEUZ6hoSB9qskbqCbFxaL0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=m/OSu5Zx1Wz0EFW3OvTOOtme9/vJi3wk0l42+xjUa00=; b=chOCWlOVJg0eZ7d2xFZkoXd6vFaRXjc1LjJUlJ7tfiT1PdHuevA8zOHjgPFq94P6rN R8FBPk6wZosC0sgL/lFa9/otvtr9a6pg5XzYOs46ZZgsf/jHITwPQXh9O5IjQSfdOSbn K9v3dFSM9GuhjPhZG6ji6eCbqXLTio7iKiZwffWx3mwmcpvMiQ99EP8nFi5d8Gvzq+lK R6bQ4b2we6Ctoh8UI3vjWbzWci12T07/XMkwTWovTn/HTC438gRsCJ2AjPDuEYkRR2KU cstOzJoxtHZ5+dn7VDsJoy/n74GP3bDglbBd8OZ1OjVmxv3pha2UOMq45WPL2yJFndt0 OFwg== X-Gm-Message-State: ACgBeo3wuw4uT6Wkrh6pUw1+oT0qTC10RWO4zGRQwpSIffOnxIoTSe7i n1MbD9Ra+qQaoJAv13sCvjD3W8C9yJJTa2PYw1Z9ow== X-Google-Smtp-Source: AA6agR7AwgdsYA2zECJCC59mQT+FT1ZxMylDWazv2ldoiejTOkgVwFvpBbFPPC1Fl0uCxZWWnvo6Vu3y9/ZgMLlKB6g= X-Received: by 2002:a25:3cc4:0:b0:67a:6a00:dbf2 with SMTP id j187-20020a253cc4000000b0067a6a00dbf2mr9600677yba.58.1660519782350; Sun, 14 Aug 2022 16:29:42 -0700 (PDT) MIME-Version: 1.0 References: <20220301001125.1554442-1-sjg@chromium.org> <20220301001125.1554442-4-sjg@chromium.org> In-Reply-To: From: Simon Glass Date: Sun, 14 Aug 2022 17:29:31 -0600 Message-ID: Subject: Re: [PATCH 3/8] tpm: Correct the permissions command in TPMv1 To: Ilias Apalodimas Cc: U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Hi Ilias, On Tue, 7 Jun 2022 at 02:44, Ilias Apalodimas wrote: > > Hi Simon, > > On Mon, Feb 28, 2022 at 05:11:20PM -0700, Simon Glass wrote: > > The offset here is incorrect. Fix it. > > > > Signed-off-by: Simon Glass > > --- > > > > lib/tpm-v1.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c > > index 22a769c587..d0e3ab1b21 100644 > > --- a/lib/tpm-v1.c > > +++ b/lib/tpm-v1.c > > @@ -456,12 +456,13 @@ u32 tpm1_get_permissions(struct udevice *dev, u32 index, u32 *perm) > > 0x0, 0x0, 0x0, 0x4, > > }; > > const size_t index_offset = 18; > > - const size_t perm_offset = 60; > > + const size_t perm_offset = 74; > > This is fine, but I hate all these magic values sprinkled around the TPM > APIs. Starting with this patch can we do the right thing and at lease have > those in a #define with a names that makes some sense? Er, isn't this what I am doing? See the const values which have sensible names. It really doesn't make sense to put them in a #define in a distant header file since we don't use these in most commands. There are just local to the function and determined by the format used with pack_byte_string(), etc. (see below). > > > u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE]; > > size_t response_length = sizeof(response); > > u32 err; > > > > - if (pack_byte_string(buf, sizeof(buf), "d", 0, command, sizeof(command), > > + if (pack_byte_string(buf, sizeof(buf), "sd", > > + 0, command, sizeof(command), > > index_offset, index)) > > return TPM_LIB_ERROR; > > err = tpm_sendrecv_command(dev, buf, response, &response_length); > > -- > > 2.35.1.574.g5d30c73bfb-goog > > > > Thanks > /Ilias Regards, SImon