Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jdINO-0005Bb-EH for mharc-grub-devel@gnu.org; Mon, 25 May 2020 15:03:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdINL-00055C-5r for grub-devel@gnu.org; Mon, 25 May 2020 15:03:03 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:33426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdINJ-0000Yw-Us for grub-devel@gnu.org; Mon, 25 May 2020 15:03:02 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04PJ1YDa095112; Mon, 25 May 2020 19:02:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=W22kgBrVZDqlZO1LhrePQa3RmbUltvbGio7Shj36q+0=; b=Hjypev9e57f/ak2rOzfVhPck9Qms7O35PNUuOU48gKkfabXarO+IhKF+ACctugPKk6B2 2MlUkEhyLWxZtwMXufMAudaTFSc/JpgbVroCjrU24zOroegFw9LyrXR+jJEWal4zrdun d5tuAdVVjKbwHzvmNS39t1Gwlw8bh/JRjzIjBlPDS9oeBtc3QVJga7yD/12snERO7Zdd wWEK9Ep0X7NwDg9at/BJ8RTCWhO+ozhWbzs+TS2ANxxjeBkS2g6/WPG8lNeryu/RHy1z orNwVo9wgBE1BqozG9rvnUFk0YOE73XGTgFRZ+g3pmC49b0EGTMWV0MREFryO/HkqpuR 6Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 316u8qpgvg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 May 2020 19:02:53 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04PIrT0q167107; Mon, 25 May 2020 19:02:52 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 317dkr23kj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 May 2020 19:02:52 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 04PJ2m0H020290; Mon, 25 May 2020 19:02:50 GMT Received: from tomti.i.net-space.pl (/10.175.171.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 25 May 2020 12:02:48 -0700 From: Daniel Kiper To: grub-devel@gnu.org Cc: cjwatson@ubuntu.com, higgi1pt@gmail.com, javierm@redhat.com, fsf@martin-whitaker.me.uk, mailing-lists@martin-whitaker.me.uk, mjg59@srcf.ucam.org, olaf@aepfle.de, phcoder@gmail.com Subject: [PATCH 4/6] tpm: Drop unneeded code Date: Mon, 25 May 2020 21:02:13 +0200 Message-Id: <20200525190215.16390-5-daniel.kiper@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200525190215.16390-1-daniel.kiper@oracle.com> References: <20200525190215.16390-1-daniel.kiper@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9632 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 suspectscore=1 mlxscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005250150 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9632 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 priorityscore=1501 spamscore=0 cotscore=-2147483648 suspectscore=1 phishscore=0 clxscore=1011 mlxlogscore=999 bulkscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005250151 Received-SPF: pass client-ip=156.151.31.86; envelope-from=daniel.kiper@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/25 15:02:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 May 2020 19:03:03 -0000 Drop unused grub_tpm*_execute() and declaration of nonexistent grub_tpm_init(). Signed-off-by: Daniel Kiper --- grub-core/commands/efi/tpm.c | 97 -------------------------------------------- include/grub/tpm.h | 3 -- 2 files changed, 100 deletions(-) diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c index 3ea37a15e..b03b6b296 100644 --- a/grub-core/commands/efi/tpm.c +++ b/grub-core/commands/efi/tpm.c @@ -120,103 +120,6 @@ grub_tpm_handle_find (grub_efi_handle_t *tpm_handle, } static grub_err_t -grub_tpm1_execute (grub_efi_handle_t tpm_handle, - PassThroughToTPM_InputParamBlock *inbuf, - PassThroughToTPM_OutputParamBlock *outbuf) -{ - grub_efi_status_t status; - grub_efi_tpm_protocol_t *tpm; - grub_uint32_t inhdrsize = sizeof (*inbuf) - sizeof (inbuf->TPMOperandIn); - grub_uint32_t outhdrsize = - sizeof (*outbuf) - sizeof (outbuf->TPMOperandOut); - - tpm = grub_efi_open_protocol (tpm_handle, &tpm_guid, - GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); - - if (!grub_tpm1_present (tpm)) - return 0; - - /* UEFI TPM protocol takes the raw operand block, no param block header. */ - status = efi_call_5 (tpm->pass_through_to_tpm, tpm, - inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, - outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); - - switch (status) - { - case GRUB_EFI_SUCCESS: - return 0; - case GRUB_EFI_DEVICE_ERROR: - return grub_error (GRUB_ERR_IO, N_("Command failed")); - case GRUB_EFI_INVALID_PARAMETER: - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); - case GRUB_EFI_BUFFER_TOO_SMALL: - return grub_error (GRUB_ERR_BAD_ARGUMENT, - N_("Output buffer too small")); - case GRUB_EFI_NOT_FOUND: - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); - default: - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); - } -} - -static grub_err_t -grub_tpm2_execute (grub_efi_handle_t tpm_handle, - PassThroughToTPM_InputParamBlock *inbuf, - PassThroughToTPM_OutputParamBlock *outbuf) -{ - grub_efi_status_t status; - grub_efi_tpm2_protocol_t *tpm; - grub_uint32_t inhdrsize = sizeof (*inbuf) - sizeof (inbuf->TPMOperandIn); - grub_uint32_t outhdrsize = - sizeof (*outbuf) - sizeof (outbuf->TPMOperandOut); - - tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid, - GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); - - if (!grub_tpm2_present (tpm)) - return 0; - - /* UEFI TPM protocol takes the raw operand block, no param block header. */ - status = efi_call_5 (tpm->submit_command, tpm, - inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, - outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); - - switch (status) - { - case GRUB_EFI_SUCCESS: - return 0; - case GRUB_EFI_DEVICE_ERROR: - return grub_error (GRUB_ERR_IO, N_("Command failed")); - case GRUB_EFI_INVALID_PARAMETER: - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); - case GRUB_EFI_BUFFER_TOO_SMALL: - return grub_error (GRUB_ERR_BAD_ARGUMENT, - N_("Output buffer too small")); - case GRUB_EFI_NOT_FOUND: - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); - default: - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); - } -} - -grub_err_t -grub_tpm_execute (PassThroughToTPM_InputParamBlock *inbuf, - PassThroughToTPM_OutputParamBlock *outbuf) -{ - grub_efi_handle_t tpm_handle; - grub_uint8_t protocol_version; - - /* Absence of a TPM isn't a failure. */ - if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) - return 0; - - if (protocol_version == 1) - return grub_tpm1_execute (tpm_handle, inbuf, outbuf); - else - return grub_tpm2_execute (tpm_handle, inbuf, outbuf); -} - -static grub_err_t grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf, grub_size_t size, grub_uint8_t pcr, const char *description) diff --git a/include/grub/tpm.h b/include/grub/tpm.h index 304507957..49fe76e81 100644 --- a/include/grub/tpm.h +++ b/include/grub/tpm.h @@ -74,7 +74,4 @@ typedef struct grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, const char *description); -grub_err_t grub_tpm_init (void); -grub_err_t grub_tpm_execute (PassThroughToTPM_InputParamBlock *inbuf, - PassThroughToTPM_OutputParamBlock *outbuf); #endif -- 2.11.0