From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 13BDE210FB9F8 for ; Wed, 22 Aug 2018 00:45:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA14E4000783; Wed, 22 Aug 2018 07:45:12 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-77.rdu2.redhat.com [10.10.120.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0104D63538; Wed, 22 Aug 2018 07:45:11 +0000 (UTC) To: "Wang, Jian J" , "edk2-devel@lists.01.org" Cc: "Ni, Ruiyu" , "Dong, Eric" References: <20180821030515.10156-1-jian.j.wang@intel.com> <20180821030515.10156-4-jian.j.wang@intel.com> From: Laszlo Ersek Message-ID: <6622884d-8e5f-b1ab-2abf-34de7cda200c@redhat.com> Date: Wed, 22 Aug 2018 09:45:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 22 Aug 2018 07:45:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 22 Aug 2018 07:45:12 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [PATCH v2 3/4] UefiCpuPkg/CpuDxe: implement non-stop mode for uefi X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Aug 2018 07:45:14 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 08/22/18 09:13, Wang, Jian J wrote: > Hi Laszlo, > > Regards, > Jian > > From: Laszlo Ersek [mailto:lersek@redhat.com] > Sent: Tuesday, August 21, 2018 10:59 PM > To: Wang, Jian J ; edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Dong, Eric > Subject: Re: [edk2] [PATCH v2 3/4] UefiCpuPkg/CpuDxe: implement non-stop mode for uefi >> +/** >> + Find and display image base address and return image base and its entry point. >> + >> + @param CurrentIp Current instruction pointer. >> + >> +**/ >> +STATIC >> +VOID >> +DumpModuleImageInfo ( >> + IN UINTN CurrentIp >> + ) >> +{ >> + EFI_STATUS Status; >> + UINTN Pe32Data; >> + VOID *PdbPointer; >> + VOID *EntryPoint; >> + >> + Pe32Data = PeCoffSearchImageBase (CurrentIp); >> + if (Pe32Data == 0) { >> + InternalPrintMessage ("!!!! Can't find image information. !!!!\n"); >> + } else { >> + // >> + // Find Image Base entry point >> + // >> + Status = PeCoffLoaderGetEntryPoint ((VOID *) Pe32Data, &EntryPoint); >> + if (EFI_ERROR (Status)) { >> + EntryPoint = NULL; >> + } >> + InternalPrintMessage ("!!!! Find image based on IP(0x%x) ", CurrentIp); >> + PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data); >> + if (PdbPointer != NULL) { >> + InternalPrintMessage ("%a", PdbPointer); >> + } else { >> + InternalPrintMessage ("(No PDB) " ); >> + } >> + InternalPrintMessage ( >> + " (ImageBase=%016lp, EntryPoint=%016p) !!!!\n", >> + (VOID *) Pe32Data, >> + EntryPoint >> + ); >> + } >> +} > > (4) Why is this function copied here? From a quick check, it looks > identical to DumpModuleImageInfo() in > "UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c". > > And, DumpModuleImageInfo() is an extern function in > "UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h", and we > are (likely) already linking against that library instance. As a result > we'll have the same function twice in CpuDxe, once as STATIC, and > another time as extern. > > If this is a useful utility function, then it should be elevated to a > public library API, and used from there. (I don't know where to add it, > I just find this code duplication regrettable.) > > [Jian] I reviewed the whole working model again. I think we don’t need to dump > the image information here, because, if there’s an issue detected, the developers > will disable the non-stop mode anyway in order to find the root cause. Then the > image information can be dumped (normal mode). So we can just dump cpu > information to tell the user that there’s an exception here. And dumping cpu > information is already a public interface so we don’t need to duplicate any code > here. Oh cool. If we can eliminate the function altogether, that's best. Thanks! Laszlo