From patchwork Wed Dec 11 20:27:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 1207909 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 47Y7pD46YHz9sRH for ; Thu, 12 Dec 2019 07:29:56 +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 47Y7pC1wcwzDqnZ for ; Thu, 12 Dec 2019 07:29:55 +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 47Y7lm0CBrzDqJ3 for ; Thu, 12 Dec 2019 07:27:44 +1100 (AEDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBBKGgFH027867; Wed, 11 Dec 2019 15:27:41 -0500 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wu1fmpjnj-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 (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id xBBKIKdM016878; 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 ppma03wdc.us.ibm.com with ESMTP id 2wr3q6r3x8-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 xBBKRe5H21234120 (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 AF226B205F; 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 A23A4B2065; 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:12 -0500 Message-Id: <20191211202728.127996-18-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 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 adultscore=0 suspectscore=15 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912110168 Subject: [SLOF] [PATCH v4 17/33] tpm: Set the driver in pseudo failure state after handover 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" Once sml-handover has been called, set the driver into pseudo failure state. Signed-off-by: Stefan Berger Reviewed-by: Thomas Huth --- board-qemu/slof/vtpm-sml.fs | 4 ++++ lib/libtpm/tcgbios.c | 12 ++++++++++++ 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 | 1 + 7 files changed, 34 insertions(+) diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs index 8d57c22..3752700 100644 --- a/board-qemu/slof/vtpm-sml.fs +++ b/board-qemu/slof/vtpm-sml.fs @@ -20,6 +20,8 @@ false VALUE vtpm-debug? 0 VALUE log-base 40000 CONSTANT LOG-SIZE \ 256k per VTPM FW spec. +e CONSTANT VTPM_DRV_ERROR_SML_HANDED_OVER + LOG-SIZE BUFFER: log-base \ create /ibm,vtpm @@ -50,6 +52,8 @@ log-base LOG-SIZE tpm-set-log-parameters log-base ( dest size src ) -rot ( src dest size ) move + + VTPM_DRV_ERROR_SML_HANDED_OVER tpm-driver-set-failure-reason ; : get-state ( -- state ) diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c index 66b1cca..b7f86d4 100644 --- a/lib/libtpm/tcgbios.c +++ b/lib/libtpm/tcgbios.c @@ -914,3 +914,15 @@ uint32_t tpm_driver_get_failure_reason(void) return spapr_vtpm_get_error(); } + +/* + * tpm_driver_set_failure_reason: Function for interfacing with the firmware + * API + */ +void tpm_driver_set_failure_reason(uint32_t errcode) +{ + if (!tpm_state.tpm_found) + return; + + spapr_vtpm_set_error(errcode); +} diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h index 0ddd537..e37d075 100644 --- a/lib/libtpm/tcgbios.h +++ b/lib/libtpm/tcgbios.h @@ -38,6 +38,7 @@ uint32_t tpm_get_maximum_cmd_size(void); 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); /* flags returned by tpm_get_state */ #define TPM_STATE_ENABLED 1 diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code index 3f2bd7f..235f368 100644 --- a/lib/libtpm/tpm.code +++ b/lib/libtpm/tpm.code @@ -97,6 +97,16 @@ PRIM(tpm_X2d_driver_X2d_get_X2d_failure_X2d_reason) TOS.n = tpm_driver_get_failure_reason(); MIRP +/********************************************************/ +/* Firmware API */ +/* SLOF: tpm-driver-set-failure_reason ( errcode -- ) */ +/* LIBTPM: tpm_driver_set_failure_reason(errcode) */ +/********************************************************/ +PRIM(tpm_X2d_driver_X2d_set_X2d_failure_X2d_reason) + int errcode = TOS.u; POP; + tpm_driver_set_failure_reason(errcode); +MIRP + /*****************************************************************/ /* Firmware API */ /* SLOF: tpm-hash-all ( data-ptr data-len hash-ptr -- errcode) */ diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in index 88d8a14..3c3b745 100644 --- a/lib/libtpm/tpm.in +++ b/lib/libtpm/tpm.in @@ -31,3 +31,4 @@ cod(tpm-get-maximum-cmd-size) cod(tpm-pass-through-to-tpm) cod(tpm-driver-get-state) cod(tpm-driver-get-failure-reason) +cod(tpm-driver-set-failure-reason) diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c index 7b1c9c8..4384f7f 100644 --- a/lib/libtpm/tpm_drivers.c +++ b/lib/libtpm/tpm_drivers.c @@ -464,6 +464,11 @@ vtpm_drv_error spapr_vtpm_get_error(void) return vtpm_drv_error_get(); } +void spapr_vtpm_set_error(vtpm_drv_error errcode) +{ + spapr_vtpm.driver_error = errcode; +} + /**** higher layer interface ****/ bool spapr_is_vtpm_present(void) diff --git a/lib/libtpm/tpm_drivers.h b/lib/libtpm/tpm_drivers.h index 96bd32d..38976d0 100644 --- a/lib/libtpm/tpm_drivers.h +++ b/lib/libtpm/tpm_drivers.h @@ -80,6 +80,7 @@ void spapr_vtpm_set_durations(const uint32_t durations[TPM_NUM_DURATIONS]); 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); struct tpm_req_header; int tpmhw_transmit(uint8_t locty, struct tpm_req_header *req,