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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 EDF8AC07E99 for ; Mon, 5 Jul 2021 15:49:53 +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 77818613D1 for ; Mon, 5 Jul 2021 15:49:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77818613D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.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 8393C82C1D; Mon, 5 Jul 2021 17:49:17 +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="KkhrjPLm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E0C3382BD6; Mon, 5 Jul 2021 17:49:06 +0200 (CEST) Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) (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 B2FFC82BE2 for ; Mon, 5 Jul 2021 17:48:59 +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@chromium.org Received: by mail-oi1-x22d.google.com with SMTP id u11so21197025oiv.1 for ; Mon, 05 Jul 2021 08:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/lVEd0q5lNNgs8Oy88tXBZInNOuO5k8PL/wxZof8AnA=; b=KkhrjPLmqiIcXLvHU7G0Wy9qrZqC4xiVuCnhEt/+0Vr3HXY17FA9UjdZst9ZLz8rcC R5KYoODj83sPkx2umZFGJl1TSqzQmvLesZ3n8G+5EeSJLYZqIhHaCuggpOu9VYmFd7gz 3gXi9CUsWV3lDYfzkkB0NNCZ9ttknmEXHa+aM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/lVEd0q5lNNgs8Oy88tXBZInNOuO5k8PL/wxZof8AnA=; b=i99s3G1ntg8S2fGTOgzo40ype8ksgZn1hwgYyYsGn01lNEzg+S95LKA1IUK0zi+Zzr /E3mL1d6S4D8QDuBKSiu509R7M4zDBmvaTGxOWrFIRk2ykBiaQh1UVKy/jnTYp5Ci5vl mOLnn/uZSpxIVC1+O/qFbX1fo5Z8U4LSsu7nv7OLorEQTOAi7NPQgNv6DyCp/NCuHRIz XC4Gki2YvDiUENCxhJFRTSEzbufa4rs8IiVpmGxBKRwX5lnFWNegxeuo1jH3zbNaDIIB d5OJT9iEKDpeFRwLFwTN4sjtwILrgLZw26rRxbmyHCKcma1Ag/SDUn7uXcSZ+wZoW2qg 71Yg== X-Gm-Message-State: AOAM530M9H+v32UkViypUDxNBebzK1hviI+0fWMCtw++irJlI90vt9EG vBlQEb/YCDm28IjF3w6FGbRIA0o0XpvwZke3 X-Google-Smtp-Source: ABdhPJxijokFWo6V15YtG7z1aE8MTi16cGhW+s3qxmZsgqorop7Dh96WJYAhggWjxEyUMsvaVNzzbw== X-Received: by 2002:aca:3285:: with SMTP id y127mr10465083oiy.115.1625500137872; Mon, 05 Jul 2021 08:48:57 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id n65sm2652038ota.37.2021.07.05.08.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 08:48:57 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Thirupathaiah Annapureddy , Ilias Apalodimas , Simon Glass , Walter Lozano Subject: [PATCH 4/9] sandbox: tpm: Correct handling of get-capability Date: Mon, 5 Jul 2021 09:48:44 -0600 Message-Id: <20210705154849.2083972-5-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210705154849.2083972-1-sjg@chromium.org> References: <20210705154849.2083972-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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; 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