Received: from list by lists.gnu.org with archive (Exim 4.71) id 1dNe5W-0003ZY-M9 for mharc-grub-devel@gnu.org; Wed, 21 Jun 2017 07:46:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNe5U-0003Ye-5H for grub-devel@gnu.org; Wed, 21 Jun 2017 07:46:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNe5R-0000t6-0V for grub-devel@gnu.org; Wed, 21 Jun 2017 07:46:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48330) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNe5Q-0000sd-OK for grub-devel@gnu.org; Wed, 21 Jun 2017 07:46:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B76E7C04B303; Wed, 21 Jun 2017 11:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B76E7C04B303 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=javierm@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B76E7C04B303 Received: from [10.36.117.190] (ovpn-117-190.ams2.redhat.com [10.36.117.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9E136C1EA; Wed, 21 Jun 2017 11:46:13 +0000 (UTC) Subject: Re: [PATCH 3/3] Core TPM support From: Javier Martinez Canillas To: The development of GNU GRUB , Matthew Garrett References: <20170615002102.123757-1-mjg59@google.com> <20170615002102.123757-4-mjg59@google.com> <88a4eb73-a76b-0afe-c3d6-8be2a2fa0e2c@redhat.com> Message-ID: <98e18103-21c0-e380-31b3-3abae6ab5326@redhat.com> Date: Wed, 21 Jun 2017 13:46:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <88a4eb73-a76b-0afe-c3d6-8be2a2fa0e2c@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 21 Jun 2017 11:46:14 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 11:46:21 -0000 Hello Matthew, On 06/16/2017 03:51 PM, Javier Martinez Canillas wrote: >=20 > I've tested your patches (plus the verify framework) today on a Lenovo > Thinkpad X1 Carbon with 2 different setups: >=20 I've tested today building your patches --with-platform=3Dpc instead of e= fi, and found a build error due the grub_tpm_init() function being defined tw= ice. I'm using the following patch [0] on top of yours to avoid this issue. But I noticed that you have a new verifier_tpm_module branch [1], that in= stead of having the TPM support in-kernel, has it as an external module. And is= only enabled for efi, so this problem won't happen on that new branch. You should remove though the grub_tpm_init() prototype, stub and in fact = all the GRUB_MACHINE_EFI #ifdefery in that new branch since it's unused now I= IUC. [0]: From 8e8ae3d0fb3b9b5a914359b48bb9e893b6113aa4 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 21 Jun 2017 12:29:38 +0200 Subject: [PATCH 1/1] Only build TPM support for x86 EFI platforms MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit There's only TPM support for x86 EFI platforms for now. So instead of unconditionally add the TPM headers and source files, add it on a per platform basis if TPM is supported. This also prevents the following compile error when building a x86 pc platform: In file included from kern/tpm.c:5:0: ../include/grub/tpm.h: In function =E2=80=98grub_tpm_init=E2=80=99: ../include/grub/tpm.h:76:1: warning: no return statement in function retu= rning non-void [-Wreturn-type] static inline grub_err_t grub_tpm_init(void) {}; ^~~~~~ kern/tpm.c: At top level: kern/tpm.c:77:1: error: redefinition of =E2=80=98grub_tpm_init=E2=80=99 grub_tpm_init (void) ^~~~~~~~~~~~~ In file included from kern/tpm.c:5:0: ../include/grub/tpm.h:76:26: note: previous definition of =E2=80=98grub_t= pm_init=E2=80=99 was here static inline grub_err_t grub_tpm_init(void) {}; Signed-off-by: Javier Martinez Canillas --- grub-core/Makefile.am | 3 ++- grub-core/Makefile.core.def | 2 +- include/grub/tpm.h | 20 -------------------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index cc641bc36a0f..36f006f135a8 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -92,7 +92,6 @@ KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/ter= m.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/time.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/mm_private.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/net.h -KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/tpm.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/memory.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/verify.h =20 @@ -110,6 +109,7 @@ KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/i= 386/tsc.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/acpi.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/pci.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/i386/pmtimer.h +KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/tpm.h endif =20 if COND_i386_coreboot @@ -166,6 +166,7 @@ KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/i= 386/tsc.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/pci.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/acpi.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/i386/pmtimer.h +KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/tpm.h endif =20 if COND_ia64_efi diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2bdb6cafde2d..bfbe7c97a6cb 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -129,7 +129,6 @@ kernel =3D { common =3D kern/rescue_parser.c; common =3D kern/rescue_reader.c; common =3D kern/term.c; - common =3D kern/tpm.c; common =3D kern/verifiers.c; =20 noemu =3D kern/compiler-rt.c; @@ -194,6 +193,7 @@ kernel =3D { efi =3D kern/acpi.c; efi =3D kern/efi/acpi.c; efi =3D kern/efi/tpm.c; + efi =3D kern/tpm.c; i386_coreboot =3D kern/i386/pc/acpi.c; i386_multiboot =3D kern/i386/pc/acpi.c; i386_coreboot =3D kern/acpi.c; diff --git a/include/grub/tpm.h b/include/grub/tpm.h index dd905b8299d9..320b6d0a5897 100644 --- a/include/grub/tpm.h +++ b/include/grub/tpm.h @@ -66,29 +66,9 @@ typedef struct { grub_err_t EXPORT_FUNC(grub_tpm_measure) (unsigned char *buf, grub_size_= t size, grub_uint8_t pcr, const char *description); -#if defined (GRUB_MACHINE_EFI) grub_err_t grub_tpm_init(void); grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, PassThroughToTPM_OutputParamBlock *outbuf); grub_err_t grub_tpm_log_event(unsigned char *buf, grub_size_t size, grub_uint8_t pcr, const char *description); -#else -static inline grub_err_t grub_tpm_init(void) {}; - -static inline grub_err_t grub_tpm_execute( - PassThroughToTPM_InputParamBlock *inbuf __attribute__ ((unused)), - PassThroughToTPM_OutputParamBlock *outbuf __attribute__ ((unused))) -{ - return 0; -}; -static inline grub_err_t grub_tpm_log_event( - unsigned char *buf __attribute__ ((unused)), - grub_size_t size __attribute__ ((unused)), - grub_uint8_t pcr __attribute__ ((unused)), - const char *description __attribute__ ((unused))) -{ - return 0; -}; -#endif - #endif --=20 2.13.0 [1]: https://github.com/mjg59/grub/commits/verifier_tpm_module Best regards, --=20 Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat