Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756915AbcKXHyi (ORCPT ); Thu, 24 Nov 2016 02:54:38 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39517 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755309AbcKXHyh (ORCPT ); Thu, 24 Nov 2016 02:54:37 -0500 Subject: Re: [PATCH v5 2/3] tpm: enhance read_log_of() to support Physical TPM event log To: Jason Gunthorpe References: <1479922057-8752-1-git-send-email-nayna@linux.vnet.ibm.com> <1479922057-8752-3-git-send-email-nayna@linux.vnet.ibm.com> <20161123193700.GA13927@obsidianresearch.com> Cc: tpmdd-devel@lists.sourceforge.net, peterhuewe@gmx.de, tpmdd@selhorst.net, jarkko.sakkinen@linux.intel.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org From: Nayna Date: Thu, 24 Nov 2016 13:23:51 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20161123193700.GA13927@obsidianresearch.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16112407-0004-0000-0000-000010F08038 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006132; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000191; SDB=6.00784721; UDB=6.00379114; IPR=6.00562330; BA=6.00004908; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013424; XFM=3.00000011; UTC=2016-11-24 07:54:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16112407-0005-0000-0000-00007ADC2969 Message-Id: <58369C8F.5000800@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-11-24_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611240136 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1607 Lines: 60 On 11/24/2016 01:07 AM, Jason Gunthorpe wrote: > On Wed, Nov 23, 2016 at 12:27:36PM -0500, Nayna Jain wrote: >> sizep = of_get_property(np, "linux,sml-size", NULL); >> + if (of_property_match_string(np, "compatible", "IBM,vtpm") < 0) >> + log_size = be32_to_cpup(sizep); >> + else >> + log_size = *sizep; >> + > > Uh, no, sizep can be null at this point: Oops !! Missed the basic. Will fix it. Sorry, and Thanks for noticing. > >> basep = of_get_property(np, "linux,sml-base", NULL); >> if (sizep == NULL && basep == NULL) >> return -ENODEV; >> if (sizep == NULL || basep == NULL) >> return -EIO; > > Move the if here. Yeah.. > >> - if (*sizep == 0) { >> + if (log_size == 0) { >> dev_warn(&chip->dev, "%s: Event log area empty\n", __func__); >> return -EIO; >> } >> >> - log->bios_event_log = kmalloc(*sizep, GFP_KERNEL); >> + log->bios_event_log = kmalloc(log_size, GFP_KERNEL); >> if (!log->bios_event_log) >> return -ENOMEM; >> >> - log->bios_event_log_end = log->bios_event_log + *sizep; >> + log->bios_event_log_end = log->bios_event_log + log_size; >> >> - memcpy(log->bios_event_log, __va(*basep), *sizep); >> + if (of_property_match_string(np, "compatible", "IBM,vtpm") < 0) >> + memcpy(chip->log.bios_event_log, __va(be64_to_cpup(basep)), >> + log_size); >> + else >> + memcpy(chip->log.bios_event_log, __va(*basep), >> log_size); > > And move the conditional swap of basep up to be along side sizep as > well (ie get rid of the second of_property_match_string) > Yeah.. true.. Will fix this also. Thanks & Regards, - Nayna > Jason >