From patchwork Fri Jul 9 15:38:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 1503244 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=ZetZbJTm; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GLy543jzyz9sRN for ; Sat, 10 Jul 2021 01:39:20 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GLy536849z307g for ; Sat, 10 Jul 2021 01:39:19 +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=ZetZbJTm; 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.158.5; 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=ZetZbJTm; dkim-atps=neutral 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 4GLy4y3C1Xz2yft for ; Sat, 10 Jul 2021 01:39:13 +1000 (AEST) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 169FYCFn063636; Fri, 9 Jul 2021 11:39:11 -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=XUBLkGPAERVi4txPDZkxlOyjtfyGTZeX3jlC+i7iEFU=; b=ZetZbJTmAPOINmIDve1Mahx/gzkd4exUcHO33as/qgYRKaIbbKYJcM+NsUOqbSn73zHs itl0wmrJca4BJk0zgRODx9wysvy0EMbID1BO5IureTCiEGamF31Y7l0AA+fOPQDLZKwG v65lv/x86CUgiFZ6zq6gqbSDEfmNixJUJ1WV6Lo+40HWoNWJqnbsizAp8j2qWY9uV9c+ yoEqyqmGwNGvvMG1dAsgiNm3/F9loTkbFW8BWE6fYxoCJxzZI3VTnnTk6w4JDl5NGO9U N+G0DJXZkLLEjgaakFKsxLWWCUoLJAw/6+TYZhpiEkysbeg0ienpP90ddKI9tMZHA1HM Ow== Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com with ESMTP id 39pmd4r4fm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Jul 2021 11:39:11 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 169FRB2J014543; Fri, 9 Jul 2021 15:39:10 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma05wdc.us.ibm.com with ESMTP id 39jfhe3u6u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Jul 2021 15:39:10 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 169Fd9pW24642046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Jul 2021 15:39:09 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14A7778066; Fri, 9 Jul 2021 15:39:09 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF0BB78069; Fri, 9 Jul 2021 15:39:08 +0000 (GMT) Received: from localhost.localdomain (unknown [9.47.158.152]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 9 Jul 2021 15:39:08 +0000 (GMT) From: Stefan Berger To: slof@lists.ozlabs.org Date: Fri, 9 Jul 2021 11:38:59 -0400 Message-Id: <20210709153903.691945-2-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210709153903.691945-1-stefanb@linux.vnet.ibm.com> References: <20210709153903.691945-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vd1PgLpl6GgrYEtuviKavX7_YScdU3Yx X-Proofpoint-ORIG-GUID: vd1PgLpl6GgrYEtuviKavX7_YScdU3Yx X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-09_09:2021-07-09, 2021-07-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 spamscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107090078 Subject: [SLOF] [PATCH v4 1/5] tcgbios: Change format of S_CRTM_VERSION string to ucs-2 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 Change the format of the S_CRTM_VERSION string to ucs-2 since this is what seems to be commonly used by other firmwares following insight from a TCG work group member. Signed-off-by: Alexey Kardashevskiy Tested-by: Stefan Berger Signed-off-by: Stefan Berger --- Makefile.gen | 2 +- lib/libtpm/Makefile | 1 + lib/libtpm/tcgbios.c | 23 ++++++++++++----------- make.rules | 3 ++- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Makefile.gen b/Makefile.gen index f18c57a..6f78829 100644 --- a/Makefile.gen +++ b/Makefile.gen @@ -164,7 +164,7 @@ distclean_gen: clean_top common-libs: @echo " ====== Building common libraries ======" - $(MAKE) -C $(LIBCMNDIR) $(COMMON_LIBS) + $(MAKE) -C $(LIBCMNDIR) $(COMMON_LIBS) RELEASE=-DRELEASE=\"\\\"$(RELEASE)\\\"\" board-libs: $(MAKE) -C lib $(MAKEARG) diff --git a/lib/libtpm/Makefile b/lib/libtpm/Makefile index 9d32dfc..895dbfd 100644 --- a/lib/libtpm/Makefile +++ b/lib/libtpm/Makefile @@ -15,6 +15,7 @@ TOPCMNDIR ?= ../.. CPPFLAGS = -I../libc/include $(CPUARCHDEF) -I$(INCLBRDDIR) \ -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) -I$(SLOFCMNDIR) CPPFLAGS += -I../libhvcall +CPPFLAGS += $(RELEASE) LDFLAGS = -nostdlib diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c index dcf0cc6..24ac83c 100644 --- a/lib/libtpm/tcgbios.c +++ b/lib/libtpm/tcgbios.c @@ -1108,24 +1108,25 @@ uint32_t tpm_measure_gpt(void) uint32_t tpm_measure_scrtm(void) { - uint32_t rc; - char *version_start = strstr((char *)&print_version, "FW Version"); - char *version_end; - uint32_t version_length; + uint32_t rc, i; char *slof_text_start = (char *)&_slof_text; uint32_t slof_text_length = (long)&_slof_text_end - (long)&_slof_text; const char *scrtm = "S-CRTM Contents"; - - version_end = strchr(version_start, '\r'); - version_length = version_end - version_start; +#define _TT(a, x) a##x +#define _T(a, x) _TT(a, x) + unsigned short ucs2_version[] = _T(L, RELEASE); dprintf("Measure S-CRTM Version: addr = %p, length = %d\n", - version_start, version_length); + ucs2_version, ucs2_length); + + for (i = 0; i < ARRAY_SIZE(ucs2_version); ++i) + ucs2_version[i] = cpu_to_le16(ucs2_version[i]); rc = tpm_add_measurement_to_log(0, EV_S_CRTM_VERSION, - version_start, version_length, - (uint8_t *)version_start, - version_length); + (char *)ucs2_version, + sizeof(ucs2_version), + (uint8_t *)ucs2_version, + sizeof(ucs2_version)); if (rc) return rc; diff --git a/make.rules b/make.rules index 885eea3..d37c365 100644 --- a/make.rules +++ b/make.rules @@ -79,6 +79,7 @@ CPP ?= $(CROSS)cpp WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \ -fno-strict-aliasing -mno-altivec -mabi=no-altivec \ - -fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS) + -fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS) \ + -fshort-wchar export CC AS LD CLEAN OBJCOPY OBJDUMP STRIP AR RANLIB CFLAGS