Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p59rc-0007Ef-Gh for mharc-grub-devel@gnu.org; Tue, 13 Dec 2022 13:18:48 -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 1p59ra-0007BN-Gn for grub-devel@gnu.org; Tue, 13 Dec 2022 13:18:46 -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 1p59rY-0006Hl-Al for grub-devel@gnu.org; Tue, 13 Dec 2022 13:18:46 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDHigCl025970; Tue, 13 Dec 2022 18:18:39 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=a+3j6Yfw+F2CxqT14PnEliwtEoAMQfrlu5UFgxTjVek=; b=JD8aSIk+UeOBqESkRfQ4G9fdj/xrzu2ATzV+JEZi47osvVCL831rCsqAfnS0qTacSfzy /ocOjDtPk9hSbazWQyUn7OWZuhgXXTMyOwdrbGv155LAowARwyRSlH3al+qCpMcb8VIn 0o93hzmcb0ARq3NMuGgqkxq9azrMT0mL3x/Nv2Cv2xc/7XTVeI8Yl0Yv8vxiHB288nP/ jZrgetANsKwuOuikZx41hsg9F8Mfxeb29dUUlPSQUSYDX7fZt+5lB8kpgPl+OHAEVIc3 MLP6E0bwUfdQGZEmmrWVvTLPUaFnJtvbMbPW/uQ55QBaSExzPgWDQSHGnv2G/oeuEAnO 0w== Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mex2hgw28-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 18:18:38 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDGPewR032042; Tue, 13 Dec 2022 18:18:37 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([9.208.129.113]) by ppma01wdc.us.ibm.com (PPS) with ESMTPS id 3mchr6d1g9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 18:18:37 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2BDIIZUw5505640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2022 18:18:36 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9F5358055; Tue, 13 Dec 2022 18:18:35 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D808858043; Tue, 13 Dec 2022 18:18:34 +0000 (GMT) Received: from [9.47.158.152] (unknown [9.47.158.152]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 13 Dec 2022 18:18:34 +0000 (GMT) Message-ID: Date: Tue, 13 Dec 2022 13:18:34 -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> From: Stefan Berger In-Reply-To: <20221213163525.z3iywp4ti3abfwwp@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: yzUVebOnlvahth_Ct43fTkLVSzF0TxPp X-Proofpoint-ORIG-GUID: yzUVebOnlvahth_Ct43fTkLVSzF0TxPp 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-13_03,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 phishscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212130158 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: Tue, 13 Dec 2022 18:18:46 -0000 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. 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); } Stefan > >> + /* Absence of a TPM isn't a failure. */ >> + if (err != GRUB_ERR_NONE) >> + return GRUB_ERR_NONE; >> + >> + grub_dprintf ("tpm", "log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE ", %s\n", >> + pcr, size, description); >> + >> + if (tpm_version == 2) >> + return tpm2_log_event (buf, size, pcr, description); >> + >> + return GRUB_ERR_NONE; >> +} > > Daniel