From patchwork Wed Dec 11 20:27:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 1207908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (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 47Y7p73yzDz9sR8 for ; Thu, 12 Dec 2019 07:29:51 +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 47Y7p72wmnzDqpd for ; Thu, 12 Dec 2019 07:29:51 +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.156.1; 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 (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 47Y7lm1VDwzDqPN for ; Thu, 12 Dec 2019 07:27:44 +1100 (AEDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBBKGiu3020672; Wed, 11 Dec 2019 15:27:42 -0500 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wtfbxur4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Dec 2019 15:27:42 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id xBBKLNbh020702; Wed, 11 Dec 2019 20:27:41 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma02dal.us.ibm.com with ESMTP id 2wr3q723tw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Dec 2019 20:27:41 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xBBKReaO22216970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Dec 2019 20:27:40 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C82D4B2065; Wed, 11 Dec 2019 20:27:40 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BAB44B2064; Wed, 11 Dec 2019 20:27:40 +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:40 +0000 (GMT) From: Stefan Berger To: slof@lists.ozlabs.org Date: Wed, 11 Dec 2019 15:27:13 -0500 Message-Id: <20191211202728.127996-19-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 suspectscore=15 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912110168 Subject: [SLOF] [PATCH v4 18/33] tpm: Add function to for getting version of TPM 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" Signed-off-by: Stefan Berger --- board-qemu/slof/vtpm-sml.fs | 6 +++++- lib/libtpm/tcgbios.c | 7 +++++++ lib/libtpm/tcgbios.h | 1 + lib/libtpm/tpm.code | 10 ++++++++++ lib/libtpm/tpm.in | 1 + lib/libtpm/tpm_drivers.c | 5 +++++ lib/libtpm/tpm_drivers.h | 5 +++++ 7 files changed, 34 insertions(+), 1 deletion(-) diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs index 3752700..25918b8 100644 --- a/board-qemu/slof/vtpm-sml.fs +++ b/board-qemu/slof/vtpm-sml.fs @@ -364,7 +364,11 @@ log-base LOG-SIZE tpm-set-log-parameters ; : vtpm-menu - vtpm12-menu + tpm-get-tpm-version CASE + 1 OF + vtpm12-menu + ENDOF + ENDCASE ; : open true ; diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c index b7f86d4..7554bd3 100644 --- a/lib/libtpm/tcgbios.c +++ b/lib/libtpm/tcgbios.c @@ -60,6 +60,8 @@ static struct tpm_state tpm_state; typedef uint8_t tpm_ppi_op; +#define TPM_version spapr_get_tpm_version() + /******************************************************** Extensions for TCG-enabled BIOS *******************************************************/ @@ -926,3 +928,8 @@ void tpm_driver_set_failure_reason(uint32_t errcode) spapr_vtpm_set_error(errcode); } + +uint32_t tpm_get_tpm_version(void) +{ + return TPM_version; +} diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h index e37d075..398834a 100644 --- a/lib/libtpm/tcgbios.h +++ b/lib/libtpm/tcgbios.h @@ -39,6 +39,7 @@ uint32_t tpm_pass_through_to_tpm(unsigned char *buf, uint32_t cmdlen); uint32_t tpm_driver_get_state(void); uint32_t tpm_driver_get_failure_reason(void); void tpm_driver_set_failure_reason(uint32_t errcode); +uint32_t tpm_get_tpm_version(void); /* flags returned by tpm_get_state */ #define TPM_STATE_ENABLED 1 diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code index 235f368..c63b21c 100644 --- a/lib/libtpm/tpm.code +++ b/lib/libtpm/tpm.code @@ -213,3 +213,13 @@ PRIM(tpm_X2d_pass_X2d_through_X2d_to_X2d_tpm) void *buf = TOS.a; TOS.n = tpm_pass_through_to_tpm(buf, cmdsize); MIRP + +/*******************************************************************/ +/* Firmware API */ +/* SLOF: tpm-get-tpm-version ( -- tpm-version ) */ +/* LIBTPM: tpm_version = tpm_get_tpm_version() */ +/*******************************************************************/ +PRIM(tpm_X2d_get_X2d_tpm_X2d_version) + PUSH; + TOS.n = tpm_get_tpm_version(); +MIRP diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in index 3c3b745..1261ac8 100644 --- a/lib/libtpm/tpm.in +++ b/lib/libtpm/tpm.in @@ -32,3 +32,4 @@ cod(tpm-pass-through-to-tpm) cod(tpm-driver-get-state) cod(tpm-driver-get-failure-reason) cod(tpm-driver-set-failure-reason) +cod(tpm-get-tpm-version) diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c index 4384f7f..78d0adc 100644 --- a/lib/libtpm/tpm_drivers.c +++ b/lib/libtpm/tpm_drivers.c @@ -469,6 +469,11 @@ void spapr_vtpm_set_error(vtpm_drv_error errcode) spapr_vtpm.driver_error = errcode; } +uint32_t spapr_get_tpm_version(void) +{ + return spapr_vtpm.tpm_version; +} + /**** higher layer interface ****/ bool spapr_is_vtpm_present(void) diff --git a/lib/libtpm/tpm_drivers.h b/lib/libtpm/tpm_drivers.h index 38976d0..5b7f84d 100644 --- a/lib/libtpm/tpm_drivers.h +++ b/lib/libtpm/tpm_drivers.h @@ -73,6 +73,10 @@ typedef enum { /* the max. buffer size by the external TPM is 4k */ #define PAPR_VTPM_MAX_BUFFER_SIZE 4096 +/* TPM version */ +#define TPM_VERSION_1_2 1 +#define TPM_VERSION_2 2 + /* exported functions */ bool spapr_is_vtpm_present(void); void spapr_vtpm_finalize(void); @@ -81,6 +85,7 @@ uint32_t spapr_vtpm_get_buffersize(void); vtpm_drv_state spapr_vtpm_get_state(void); vtpm_drv_error spapr_vtpm_get_error(void); void spapr_vtpm_set_error(vtpm_drv_error errcode); +uint32_t spapr_get_tpm_version(void); struct tpm_req_header; int tpmhw_transmit(uint8_t locty, struct tpm_req_header *req,