From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in21.apple.com (mail-out21.apple.com [17.171.2.31]) (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 26A9A2007D1F3 for ; Thu, 10 Aug 2017 13:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1502398393; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CZWEAOEbqBU4aZi2V4nn54cdwpD+MGwVwKhOvTdCR6Q=; b=GKuf0IJEcTAaM9v0PjIpZdj4riB2Qmd2YY9tDbl3vYq8gFOYbh4tE4bw+H4vnlu3 kX0SXgh/zihx0Fu76SzNSWOWgGHblvHiiEF1jUnRyL9T951QOBIk7zHJ3WKR9S6f h2/J4wMM356K3/vGwUDBmZ89mlZHdhJoETBTTHIUfPBcj/BPgNISMxK8jnwCEKE3 RPEHt7eM4huxO+VveSPSmgJ+/vGrHiunjp2Ll0/XyFpMqlx01t1C1gDY6INdSLXl Ftb4lP8Nis1lQ4kdPQLX+TAR256nWOhhLwLTbDly9jA4xo2fSwY8zYbhOuNBsqIZ 7GJfZgMuI+BngQ7Lc/uQeA==; Received: from relay23.apple.com (relay23.apple.com [17.171.128.104]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in21.apple.com (Apple Secure Mail Relay) with SMTP id A1.9D.07017.9B7CC895; Thu, 10 Aug 2017 13:53:13 -0700 (PDT) X-AuditID: 11ab0215-43f899c000001b69-ff-598cc7b90449 Received: from ma1-mmpp-sz10.apple.com (ma1-mmpp-sz10.apple.com [17.171.128.150]) by relay23.apple.com (Apple SCV relay) with SMTP id A6.70.07952.8B7CC895; Thu, 10 Aug 2017 13:53:13 -0700 (PDT) MIME-version: 1.0 Received: from [17.234.197.209] by ma1-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170621 64bit (built Jun 21 2017)) with ESMTPSA id <0OUH00HDOM0LK320@ma1-mmpp-sz10.apple.com>; Thu, 10 Aug 2017 13:53:12 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish Date: Thu, 10 Aug 2017 13:53:08 -0700 References: <41A7B048-4140-4889-AE7C-36A0ED3B8C1C@apple.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9159A6@shsmsx102.ccr.corp.intel.com> To: "Zeng, Star" , edk2-devel In-reply-to: <0C09AFA07DD0434D9E2A0C6AEB0483103B9159A6@shsmsx102.ccr.corp.intel.com> Message-id: X-Mailer: Apple Mail (2.3273) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRmVeSWpSXmKPExsUiuLohQ3fn8Z5Ig5drmS32HDrKbLGv19qB yWPxnpdMHt2z/7EEMEVx2aSk5mSWpRbp2yVwZXy6uZ2tYI9PxavXLSwNjBOcuhg5OSQETCQO fzjM1sXIxSEksJ5J4v/NNWwwiWVrf7JAJA4zStxe9ZcRJMErICjxY/I9FhCbWSBM4tT2DVBF 3xglviybDZYQFhCXeHdmEzOIzSagLLFi/gd2iHilxJ623WCDWARUJa6+/8II0dzGKHF/zQSw 1SICPhKHni8EK+IE2nBg/nSozTYSG143QJ0nK3Fr9iVmkGYJgUY2iQ2XJrNPYBScheTCWUgu nMXIAWSrS0yZkgsR1pZ48u4CK4StKfHs3id2ZPEFjGyrGIVzEzNzdDPzjAz1EgsKclL1kvNz NzGCw55JdAfj/FeGhxgFOBiVeHg9DvVECrEmlhVX5h5ilOZgURLndT3fHSkkkJ5YkpqdmlqQ WhRfVJqTWnyIkYmDU6qBMelR7oxjUZKS1gmld2byfzhlMo15mkdGeXmCvy+r4ezmj8VXcmfG B3Z9zf/Z5h9w/o3kixkyHzoXV8zzXM+5ePFR8TVmV7uzBTZb+5gZX0i9s3g1+/vV60tT8vUC fq/SrfTf/+excfEfoabihcVcf9+eFJZLdti9+MoUuzRmXu4pUgdrBX/uVGIpzkg01GIuKk4E AM6LYMlcAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNLMWRmVeSWpSXmKPExsUiuLphmu7O4z2RBo3mFnsOHWW22Ndr7cDk sXjPSyaP7tn/WAKYorhsUlJzMstSi/TtErgyPt3czlawx6fi1esWlgbGCU5djJwcEgImEsvW /mTpYuTiEBI4zChxe9VfRpAEr4CgxI/J91hAbGaBMIlT2zdAFX1jlPiybDZYQlhAXOLdmU3M IDabgLLEivkf2CHilRJ72naDDWIRUJW4+v4LI0RzG6PE/TUT2EASIgI+EoeeLwQr4gTacGD+ dKjNNhIbXjewQZwnK3Fr9iXmCYx8s5AcNQvJUbMYOYBsdYkpU3IhwtoST95dYIWwNSWe3fvE jiy+gJFtFaNgUWpOYqWRsV5iQUFOql5yfu4mRkiQZuxgvH7T7BCjAAejEg+vx6GeSCHWxLLi ytxDjBIczEoivC67gUK8KYmVValF+fFFpTmpxYcYpTlYlMR5f3R0RwoJpCeWpGanphakFsFk mTg4pRoYd2oW7xdPPPrT3P3/6ZWzLO/oR/xJORjnyzdh/5PrzR/fbzj79M766J1hlcfuRLE9 qMrUuPTtw3mzSdeZS5+df377J8+NfF4xvsrH1jGaEdzy6/LvMq88F3qn4XPvNP4Dz/fUu7Wo 3l48OfzZMxnvmZ53NvDOP7TdpWWVuX6jgg2HE4tMTdPtICWW4oxEQy3mouJEAIDZzrBOAgAA X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: Does a double Page free report "ConvertPages: Incompatible memory types", maybe we could do better. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Aug 2017 20:50:54 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Also I forgot to mention the double page free was in the DXE Core = LoadImage() on an error path.=20 CoreLoadPeImage() ... return EFI_SUCCESS; Done: // // Free memory. // if (DstBufAlocated) { CoreFreePages (Image->ImageContext.ImageAddress, = Image->NumberOfPages); } ... CoreUnloadAndCloseImage() ... if ((Image->ImageBasePage !=3D 0) && FreePage) { CoreFreePages (Image->ImageBasePage, Image->NumberOfPages); } ... I fixed by setting Image->ImageContext.ImageAddress and = Image->ImageBasePage to 0 after the free in CoreLoadPeImage(). Bug=C2=A0667 Thanks, Andrew Fish > On Aug 9, 2017, at 6:33 PM, Zeng, Star wrote: >=20 > Andrew, >=20 > Another path may hit this DEBUG message is AllocatePages() by = AllocateAddress type. > I think it is a good suggestion to enhance the DEBUG message. How = about the update like below? >=20 > - DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible = memory types\n")); > + DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible = memory types, ")); > + if (Entry->Type =3D=3D EfiConventionalMemory) { > + DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "the pages to free have = been freed\n")); > + } else { > + DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "the pages to allocate = have been allocated\n")); > + } >=20 >=20 > Thanks, > Star > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of = Andrew Fish > Sent: Thursday, August 10, 2017 9:04 AM > To: edk2-devel > Subject: [edk2] Does a double Page free report "ConvertPages: = Incompatible memory types", maybe we could do better. >=20 > It looks to me like if you Free pages, after you free pages you hit = this DEBUG message.=20 >=20 >=20 > = https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Mem/Pa= ge.c#L790 >=20 > if (!(NewType =3D=3D EfiConventionalMemory ? 1 : 0) ^ = (Entry->Type =3D=3D EfiConventionalMemory ? 1 : 0)) { > DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible = memory types\n")); > return EFI_NOT_FOUND; > } >=20 > I'm not sure I've thought out all the paths, but would it make more = sense if you are trying to convert EfiConventionalMemory to = EfiConventionalMemory that you are trying to free pages that are already = freed. That is not very obvious from the above DEBUG print. Could there = be an if in the error path to print a better DEBUG message for a free = pages bug?=20 >=20 > Also to be pedantic the function change names to: = CoreConvertPagesEx().=20 >=20 > Thanks, >=20 >=20 > Andrew Fish >=20 >=20 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel