Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p5eYt-0007eO-E2 for mharc-grub-devel@gnu.org; Wed, 14 Dec 2022 22:05:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5eYr-0007ct-0a for grub-devel@gnu.org; Wed, 14 Dec 2022 22:05:29 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5eYo-0004UN-7b for grub-devel@gnu.org; Wed, 14 Dec 2022 22:05:28 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BF2kQjc016307; Thu, 15 Dec 2022 03:05:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=gTh/87lDmaLf2lzJB1jFUiyP4bGlQcFY/zAUJOtZu98=; b=CkeZKXD3amniQI86jHD8R8I/euBcg0/X2KNVzomf9GoI6f5tKAkQQu3InP92C3E8XEhW KxGm/dtpu9us2ZufTH/BaSi3FV16skCOn9rUK8wqLppQPKO4WfjQx7s1T0qjBdSpqqgI U7stxGISd6i3kKYMPx/xi+SAtUN9G7kP83Q1dH/9NheYMmtuVKaU95QkGVutO6jQfXu+ lQQhR77Gty+ebgOGQGJWlFpvBSD1gshYE+x7hEKvxCSlM2zr2AxGgCK712yxdljxjNuK ITfD3eVLuAGCcClDCpch4kUbqT4VDqmka2SbPDo3a0wnrMXRCAfUl7NBxQDBrECFdwSC Gw== Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mfu3f8b9v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 03:05:21 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2BF2xtYa019314; Thu, 15 Dec 2022 03:05:20 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([9.208.129.117]) by ppma04dal.us.ibm.com (PPS) with ESMTPS id 3mf03aah2j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 03:05:20 +0000 Received: from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com [10.39.53.233]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2BF35ITp9437812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Dec 2022 03:05:18 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20D0958060; Thu, 15 Dec 2022 03:05:18 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10CBE5804E; Thu, 15 Dec 2022 03:05:17 +0000 (GMT) Received: from [9.47.158.152] (unknown [9.47.158.152]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 15 Dec 2022 03:05:16 +0000 (GMT) Message-ID: Date: Wed, 14 Dec 2022 22:05:16 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v2 6/6] ibmvtpm: Add support for trusted boot using a vTPM 2.0 Content-Language: en-US To: Daniel Kiper Cc: grub-devel@gnu.org, development@efficientek.com, diegodo@linux.vnet.ibm.com, dja@axtens.net, sudhakar@linux.ibm.com, nasastry@in.ibm.com, Eric Snowberg References: <20221201211201.2915206-1-stefanb@linux.ibm.com> <20221201211201.2915206-7-stefanb@linux.ibm.com> <20221213163525.z3iywp4ti3abfwwp@tomti.i.net-space.pl> <20221214142039.cj26xn7sl6l2f2xl@tomti.i.net-space.pl> From: Stefan Berger In-Reply-To: <20221214142039.cj26xn7sl6l2f2xl@tomti.i.net-space.pl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qyA1jAQ1yh4qauV_Xd4K-JEf1zHTHZ9Q X-Proofpoint-ORIG-GUID: qyA1jAQ1yh4qauV_Xd4K-JEf1zHTHZ9Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-14_12,2022-12-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212150019 Received-SPF: pass client-ip=148.163.156.1; envelope-from=stefanb@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2022 03:05:29 -0000 On 12/14/22 09:20, Daniel Kiper wrote: > On Tue, Dec 13, 2022 at 01:18:34PM -0500, Stefan Berger wrote: >> On 12/13/22 11:35, Daniel Kiper wrote: >>> On Thu, Dec 01, 2022 at 04:12:01PM -0500, Stefan Berger wrote: >>>> Add support for trusted boot using a vTPM 2.0 on the IBM IEEE1275 >>>> PowerPC platform. With this patch grub now measures text and binary data >>>> into the TPM's PCRs 8 and 9 in the same way as the x86_64 platform >>>> does. >>>> +} >>>> + >>>> +grub_err_t >>>> +grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, >>>> + const char *description) >>>> +{ >>>> + grub_err_t err = tpm_init (); >>> >>> This should happen on module load. Then code in tpm_init() and here should >>> be much simpler. >> >> I tried moving this into GRUB_MOD_INIT() but at that point it doesn't >> succeed to find the device it seems. I have to repeat the tpm_init () >> call then later on in this function here when an actual measurement is >> to be done and then it is able to find the device. I'd rather leave it >> as-is now. > > Hmmm... It looks like a bug in a firmware or initial TPM communication > fails/timeouts for some reason. Do not you loose some initial tpm_init() , which also calls tpm_get_tpm_version(), don't even talk to the TPM but they only access the OpenFirmware device tree and don't seem to find what they are looking for when run that early. > measurements this way? Could you check what will happen when you call No measurements are lost from what I can tell. The late initialization seems to find the OF node it needs. > tpm_init() from GRUB_MOD_INIT 10, 50, 100 times? I tried it now with this loop here. Well, not unexpected but the loop doesn't change anything in this case since no timing is involved -- 'found', which I print later on, stays at 0. Something related to the OpenFirmware tree seems to not be initialized at this point. GRUB_MOD_INIT (ibmvtpm) { grub_ieee1275_phandle_t vtpm; int i; for (i = 0; i < 100; i++) { if (!grub_ieee1275_finddevice ("/vdevice/vtpm", &vtpm)) found++; } } Stefan > >> It looked like this: >> >> GRUB_MOD_INIT (ibmvtpm) >> { >> init_success = tpm_init (); >> } >> >> GRUB_MOD_FINI (ibmvtpm) >> { >> if (tpm_ihandle != IEEE1275_IHANDLE_INVALID) >> grub_ieee1275_close (tpm_ihandle); >> } > > LGTM... Weird... > > Daniel