From patchwork Mon Oct 28 13:51:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 2003285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=azUV9N6O; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XcZZ961Cnz1xxV for ; Tue, 29 Oct 2024 00:52:01 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4XcZZ92dwjz2yxj for ; Tue, 29 Oct 2024 00:52:01 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1730123519; cv=none; b=NT1eKAMSAKs0AOqDiMgceZg0L+7X3ME37NVc9qq7cMTMmuzqmChRNqco2PDk6VzwGaQDFW0z8cDhExeBfwdM4OrKlgEwShXQGKAMngUbI+PE3Jm2AW2kw9ht4GvtHa9xC7tQwvk0vQffdYtiOrjis0ulgugo48HeNgjPynFStTlv6pnIQB3FNkcXV/fTJ37WGfMBI63eZvi/Da397e0igmKdiaU+B0w+yRS8P/Riwo/pXw8bVT81hkwpZG+Rqq0343fBobB1VAlvk4/tApswI1xbw0mYWAkGIDSvuy/DGs7JvIsS+Pd6hpD45sudxxVIru0BAbMSqFLkd5DafFYMBA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1730123519; c=relaxed/relaxed; bh=DmhIgPfnAZR7MTDWy1DrPPtkF88BTQ5V4Ahpoqbo72o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q14+Cv2rrBv40L9TdZ3eV/6Wj7gdYYemHpzwrcEBFDQuYgxoiYi5p3PwSB/3jRd/Xmtw3hINgK7hpFo33gFqR3YZhm62U1agI7bU9NkugFB8jCN6aD7AwtQfGdBgFeRNblPJN6ZFZIBJFOL1QxiA7Hidd1+RKBy4LExxbNY9xN+npTX5vPq+ZZueaG/E67S0NFuWO+kUzBnofcmCfviHV54PC5wkVo+Kp4QQCCewJEyYqDkUfR+kKNlULwUiuPZfHkizcCjqK09unyHA0plA3jyncE3mOXwmTcWe2Y53jUz3bm4KRR6tzdNuXMbrk33nvgkALXyoZGU8RylNggoZlA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=azUV9N6O; dkim-atps=neutral; spf=pass (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=stefanb@linux.ibm.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=azUV9N6O; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=stefanb@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4XcZZ604fKz2yPD for ; Tue, 29 Oct 2024 00:51:57 +1100 (AEDT) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49SCAEAd014843; Mon, 28 Oct 2024 13:51:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=DmhIgPfnAZR7MTDWy 1DrPPtkF88BTQ5V4Ahpoqbo72o=; b=azUV9N6OD0hnUFGmMpjRE4blnUfLu9af/ PaQPX2fr5ojwWlrrcAoYP2hLxJRO6Aogp44J/NFSAKaJiwd+oilw4KZSVfhFSedw ap5r1PB/tPkvznUTZRfEJGU9mFLE/4EMUMiE0B2Y4A98k8O0wavifUNRydHwjfYv p5ty3jJdTmKnbZ+J7S825+MBjZlNB6tRdTv7BrXDqkBdflqhhf/X7ORli5Rsx15X c7UYrTVZmn4H8LtWJgwnfb4z3tm9BeVRM5GrnLO8Vk0cgj29hHL6pAVVuzoUV5zr w3BrCmbT9uahQB2aZz1S2yRD0c/TyZQM26RyJmxa7Md+GZ+G/etag== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42j3nsjy00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2024 13:51:54 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49SCIvxU013553; Mon, 28 Oct 2024 13:51:53 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42hbrmpf4q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2024 13:51:53 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49SDpqpT57213240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Oct 2024 13:51:52 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D0E158067; Mon, 28 Oct 2024 13:51:52 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2FC9758065; Mon, 28 Oct 2024 13:51:52 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 28 Oct 2024 13:51:52 +0000 (GMT) From: Stefan Berger To: slof@lists.ozlabs.org, aik@ozlabs.ru Date: Mon, 28 Oct 2024 09:51:48 -0400 Message-ID: <20241028135149.3135243-2-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028135149.3135243-1-stefanb@linux.ibm.com> References: <20241028135149.3135243-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _6kACYG3F0o7mVpIvvzsRuHMssaNY7py X-Proofpoint-GUID: _6kACYG3F0o7mVpIvvzsRuHMssaNY7py X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 suspectscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410280109 X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on lists.ozlabs.org Subject: [SLOF] [PATCH 1/2] tpm: Implement firmware API call get-maximum-cmd-size X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" Implement the firmware API call get-maximum-cmd-size that returns a TPM's maximum command size. The caller should use the size returned by this function to allocate a buffer large enough for TPM commands and also responses. Signed-off-by: Stefan Berger --- board-qemu/slof/vio-vtpm-cdriver.fs | 8 ++++++++ lib/libtpm/tcgbios.c | 5 +++++ lib/libtpm/tcgbios.h | 1 + lib/libtpm/tpm.code | 10 ++++++++++ lib/libtpm/tpm.in | 1 + 5 files changed, 25 insertions(+) diff --git a/board-qemu/slof/vio-vtpm-cdriver.fs b/board-qemu/slof/vio-vtpm-cdriver.fs index df966a2..21c2190 100644 --- a/board-qemu/slof/vio-vtpm-cdriver.fs +++ b/board-qemu/slof/vio-vtpm-cdriver.fs @@ -57,6 +57,14 @@ LOG-SIZE BUFFER: log-base THEN ; +\ firmware API call +: get-maximum-cmd-size ( -- max-size ) + vtpm-debug? IF + ." Call to get-maximum-cmd-size" cr + THEN + tpm-get-maximum-cmd-size ( max-size ) +; + 0 0 s" ibm,sml-efi-reformat-supported" property \ firmware API call diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c index aefa865..a64afde 100644 --- a/lib/libtpm/tcgbios.c +++ b/lib/libtpm/tcgbios.c @@ -967,6 +967,11 @@ uint32_t tpm_2hash_ext_log(uint32_t pcrindex, return 0; // FALSE } +uint32_t tpm_get_maximum_cmd_size(void) +{ + return PAPR_VTPM_MAX_BUFFER_SIZE; +} + /* * Add an EV_ACTION measurement to the list of measurements */ diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h index 021e219..83148e0 100644 --- a/lib/libtpm/tcgbios.h +++ b/lib/libtpm/tcgbios.h @@ -41,5 +41,6 @@ uint32_t tpm_2hash_ext_log(uint32_t pcrindex, uint32_t eventtype, const char *info, uint32_t infolen, const void *data, uint64_t datalen); +uint32_t tpm_get_maximum_cmd_size(void); #endif /* TCGBIOS_H */ diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code index f5e1d39..23075b8 100644 --- a/lib/libtpm/tpm.code +++ b/lib/libtpm/tpm.code @@ -206,3 +206,13 @@ PRIM(tpm_X2d_2hash_X2d_ext_X2d_log) info, infolen, data, datalen); MIRP + +/****************************************************************************************/ +/* Firmware API */ +/* SLOF: tpm-get-maximum-cmd-size ( -- max-size ) */ +/* LIBTPM: maxsize = tpm-get-maximum-cmd-size */ +/****************************************************************************************/ +PRIM(tpm_X2d_get_X2d_maximum_X2d_cmd_X2d_size) + PUSH; + TOS.u = tpm_get_maximum_cmd_size(); +MIRP diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in index 2f80624..d76c479 100644 --- a/lib/libtpm/tpm.in +++ b/lib/libtpm/tpm.in @@ -30,3 +30,4 @@ cod(tpm-gpt-add-entry) cod(tpm-measure-gpt) cod(tpm-hash-log-extend-event-buffer) cod(tpm-2hash-ext-log) +cod(tpm-get-maximum-cmd-size)