From patchwork Fri Jul 9 02:53:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 1502827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: 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=JZgyMdg9; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 4GLd5N0Rsbz9sXV for ; Fri, 9 Jul 2021 12:53:28 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GLd5M6B9zz3bWZ for ; Fri, 9 Jul 2021 12:53:27 +1000 (AEST) Authentication-Results: lists.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=JZgyMdg9; dkim-atps=neutral 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; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=JZgyMdg9; dkim-atps=neutral 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 4GLd5F4W7kz306s for ; Fri, 9 Jul 2021 12:53:21 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1692XbAB087991; Thu, 8 Jul 2021 22:53:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=paKl0+w2I690+VOrmnlhErvsisR3n7cVuYxS0ynVLng=; b=JZgyMdg9gIrq9PcBZLi8Vifm2sGXIAYHm7iPEiVY7NNPtlwQvcMOu2QW70PQUmzVW6sv u1e9K8P2IAG90jnQAczFugfodhMdx4ZtJhjksX+JY0yhR1eqMbFw7xOVYvdOisqn3GPn EnNlog29VOrfCN3gViLwYHmdpv/UEv2iaarKQg3JauDw+bFFGJR/6dKusptDerAMB1mI qXVXhmY2HzVnDDcc1GR2/aavTL7emKp9tHiRMKFwJbE1QeLNLuw2jfOT4s6+kkjGFgpB gnnVP7Sa+l83KOPsqytlBkBnN8hZ7XciFJfzs6xqRsm4VM+jJjkqbblPT/2ZqYdNAcs5 4Q== Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 39pcsahjv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Jul 2021 22:53:19 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1692qArr008693; Fri, 9 Jul 2021 02:53:18 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma04wdc.us.ibm.com with ESMTP id 39ju3d4f75-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Jul 2021 02:53:18 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1692rGL635127570 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Jul 2021 02:53:17 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D717AC6057; Fri, 9 Jul 2021 02:53:16 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D29AC605A; Fri, 9 Jul 2021 02:53:16 +0000 (GMT) Received: from localhost.localdomain (unknown [9.47.158.152]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 9 Jul 2021 02:53:16 +0000 (GMT) From: Stefan Berger To: slof@lists.ozlabs.org Date: Thu, 8 Jul 2021 22:53:08 -0400 Message-Id: <20210709025313.674287-3-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210709025313.674287-1-stefanb@linux.vnet.ibm.com> References: <20210709025313.674287-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6MAedDaFVlgoCKB378IzdSmn_TnoW1RX X-Proofpoint-GUID: 6MAedDaFVlgoCKB378IzdSmn_TnoW1RX X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-09_01:2021-07-09, 2021-07-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107090010 Subject: [SLOF] [PATCH v3 2/7] tcgbios: Use assembly for 32 bit rotr in sha256 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" From: Stefan Berger Use assembly for the 32 bit rotr in the sha256 implementation. Signed-off-by: Stefan Berger --- lib/libtpm/sha256.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/libtpm/sha256.c b/lib/libtpm/sha256.c index fb67e19..292e54e 100644 --- a/lib/libtpm/sha256.c +++ b/lib/libtpm/sha256.c @@ -22,10 +22,16 @@ typedef struct _sha256_ctx { uint32_t h[8]; } sha256_ctx; -static inline uint32_t rotr(uint32_t x, uint8_t n) -{ - return (x >> n) | (x << (32 - n)); -} +#define rotr(VAL, N) \ +({ \ + uint32_t res; \ + __asm__ ( \ + "rotrwi %0, %1, %2\n\t" \ + : "=r" (res) \ + : "r" (VAL), "i" (N) \ + ); \ + res; \ +}) static inline uint32_t Ch(uint32_t x, uint32_t y, uint32_t z) {