Andrew,

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?

-        DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible memory 
types\n"));
+        DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible memory 
types, "));
+        if (Entry->Type == 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"));
+        }


Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Andrew 
Fish
Sent: Thursday, August 10, 2017 9:04 AM
To: edk2-devel <edk2-devel@lists.01.org>
Subject: [edk2] Does a double Page free report "ConvertPages: Incompatible 
memory types", maybe we could do better.

It looks to me like if you Free pages, after you free pages you hit this DEBUG 
message. 


https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Mem/Page.c#L790

      if (!(NewType == EfiConventionalMemory ? 1 : 0) ^ (Entry->Type == 
EfiConventionalMemory ? 1 : 0)) {
        DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible memory 
types\n"));
        return EFI_NOT_FOUND;
      }

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? 

Also to be pedantic the function change names to: CoreConvertPagesEx(). 

Thanks,


Andrew Fish



_______________________________________________
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

Reply via email to