From patchwork Wed Dec 11 20:26:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 1207897 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Y7mn3ZBgz9sR7 for ; Thu, 12 Dec 2019 07:28:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47Y7mn2BzYzDqgd for ; Thu, 12 Dec 2019 07:28:41 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=stefanb@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 47Y7ll2Cy0zDqLs for ; Thu, 12 Dec 2019 07:27:43 +1100 (AEDT) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBBKGfIe131174; Wed, 11 Dec 2019 15:27:41 -0500 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wtbt2hyem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Dec 2019 15:27:41 -0500 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id xBBKIIk7026632; Wed, 11 Dec 2019 20:27:40 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma04dal.us.ibm.com with ESMTP id 2wr3q723hg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Dec 2019 20:27:40 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xBBKRdJV38273316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Dec 2019 20:27:39 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86F43B2067; Wed, 11 Dec 2019 20:27:39 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A873B2066; Wed, 11 Dec 2019 20:27:39 +0000 (GMT) Received: from newfield.pok.ibm.com (unknown [9.47.158.66]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 11 Dec 2019 20:27:39 +0000 (GMT) From: Stefan Berger To: slof@lists.ozlabs.org Date: Wed, 11 Dec 2019 15:26:59 -0500 Message-Id: <20191211202728.127996-5-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211202728.127996-1-stefanb@linux.vnet.ibm.com> References: <20191211202728.127996-1-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95, 18.0.572 definitions=2019-12-11_06:2019-12-11, 2019-12-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 suspectscore=15 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 clxscore=1015 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912110168 Subject: [SLOF] [PATCH v4 04/33] tpm: Add initial support for logging 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: kevin@koconnor.net MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" This patch adds initial support for the logging that will be done following measurements done by further code added to SLOF. Signed-off-by: Stefan Berger Reviewed-by: Nikunj A Dadhania --- board-qemu/slof/vtpm-sml.fs | 3 +++ lib/libtpm/tcgbios.c | 18 ++++++++++++++++++ lib/libtpm/tcgbios.h | 1 + lib/libtpm/tpm.code | 11 +++++++++++ lib/libtpm/tpm.in | 1 + 5 files changed, 34 insertions(+) diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs index 7cd3729..51c3db5 100644 --- a/board-qemu/slof/vtpm-sml.fs +++ b/board-qemu/slof/vtpm-sml.fs @@ -25,6 +25,9 @@ LOG-SIZE BUFFER: log-base \ create /ibm,vtpm s" ibm,vtpm" 2dup device-name device-type +\ convey logbase and size to the C driver +log-base LOG-SIZE tpm-set-log-parameters + : sml-get-allocated-size ( -- buffer-size) vtpm-debug? IF ." Call to sml-get-allocated-size; size = 0x" LOG-SIZE . cr diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c index 5b12461..31d3eb0 100644 --- a/lib/libtpm/tcgbios.c +++ b/lib/libtpm/tcgbios.c @@ -39,6 +39,12 @@ struct tpm_state { unsigned tpm_found:1; unsigned tpm_working:1; unsigned has_physical_presence:1; + + /* base address of the log area */ + uint8_t *log_base; + + /* size of the logging area */ + uint32_t log_area_size; }; static struct tpm_state tpm_state; @@ -269,3 +275,15 @@ uint32_t tpm_unassert_physical_presence(void) return 0; } + +/**************************************************************** + * Forth interface + ****************************************************************/ + +void tpm_set_log_parameters(void *addr, unsigned int size) +{ + dprintf("Log is at 0x%llx; size is %u bytes\n", + (uint64_t)addr, size); + tpm_state.log_base = addr; + tpm_state.log_area_size = size; +} diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h index 5b5e481..7f7691a 100644 --- a/lib/libtpm/tcgbios.h +++ b/lib/libtpm/tcgbios.h @@ -18,5 +18,6 @@ uint32_t tpm_start(void); void tpm_finalize(void); uint32_t tpm_unassert_physical_presence(void); +void tpm_set_log_parameters(void *address, unsigned int size); #endif /* TCGBIOS_H */ diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code index 08f52e9..2f3e198 100644 --- a/lib/libtpm/tpm.code +++ b/lib/libtpm/tpm.code @@ -44,3 +44,14 @@ PRIM(tpm_X2d_unassert_X2d_physical_X2d_presence) PUSH; TOS.n = tpm_unassert_physical_presence(); MIRP + +/*************************************************************/ +/* Convey log address and size */ +/* SLOF: tpm-set-log-parameters ( addr size -- ) */ +/* LIBTPM: tpm_set_log_parameters(void *addr, uint64_t size) */ +/*************************************************************/ +PRIM(tpm_X2d_set_X2d_log_X2d_parameters) + int size = TOS.u; POP; + void *addr = TOS.a; POP; + tpm_set_log_parameters(addr, size); +MIRP diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in index e212483..c6ad91c 100644 --- a/lib/libtpm/tpm.in +++ b/lib/libtpm/tpm.in @@ -16,3 +16,4 @@ cod(tpm-start) cod(tpm-finalize) cod(tpm-unassert-physical-presence) +cod(tpm-set-log-parameters)