From: "Zeng, Star" <star.zeng@intel.com>
To: Wasim Khan <wasim.khan@nxp.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Zeng, Star" <star.zeng@intel.com>, "Gao, Liming" <liming.gao@intel.com>
Subject: Re: Memory space entry is not removed after calling FreeMemorySpace and RemoveMemorySpace
Date: Fri, 5 Jan 2018 11:04:30 +0000 [thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9F8894@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <DB6PR0401MB23427AE3B74749F3EC756203901C0@DB6PR0401MB2342.eurprd04.prod.outlook.com>
PI spec has clear description below in AddMemorySpace().
"If the memory range specified by BaseAddress and Length is of type EfiGcdMemoryTypeSystemMemory or EfiGcdMemoryTypeMoreReliable, then the
memory range may be *automatically allocated for use by the UEFI memory services*."
But PI spec has no clear description about removing the use from the UEFI memory services in FreeMemorySpace() and RemoveMemorySpace().
I think it is very hard (may be not possible) as the added memory space may have been used by UEFI memory (page) services for drivers after the memory space is added by AddMemorySpace().
What is the usage that the memory space needs to be added first and removed later?
Could the memory space be added as EfiGcdMemoryTypeReserved type instead of EfiGcdMemoryTypeSystemMemory type?
Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Wasim Khan
Sent: Friday, January 5, 2018 5:59 PM
To: edk2-devel@lists.01.org
Subject: [edk2] Memory space entry is not removed after calling FreeMemorySpace and RemoveMemorySpace
Hi All,
I am facing a problem that if a add a memory space using 'gDS->AddMemorySpace' and then remove it using 'gDS->FreeMemorySpace' followed by 'gDS->RemoveMemorySpace'.
I can still see the entry of added memory space in the table shown by 'memmap' command.
I enabled DEBUG_GCD and as per logs , the entry is removed from GcdMemorySpaceMap , but when I run 'memmap' command which gets the memory map using 'gBS->GetMemoryMap', I can see that entry for the added memory space is still present. Steps and Logs are below for reference
Do I need to perform any other steps in order to cleanly remove the memory space entry ?
Regards,
Wasim
Below are the steps and GCD debug logs.
Steps 1 : Add a memory space . We can see that an entry from system memory is added.
Status = gDS->AddMemorySpace (
EfiGcdMemoryTypeSystemMemory,
FixedPcdGet64(PcdSystemMemoryExBase),
SystemMemoryExSize,
EFI_MEMORY_WC | EFI_MEMORY_WT |
EFI_MEMORY_WB
);
Logs:
GCD:AddMemorySpace(Base=0000008080000000,Length=0000000380000000)
GcdMemoryType = SystemMem
Capabilities = 000000000000000E
CoreConvertSpace 774
Status = Success
GCDMemType Range Capabilities Attributes
========== ================================= ================ ================
NonExist 0000000000000000-000000009FFFFFFF 0000000000000000 0000000000000000
SystemMem 00000000A0000000-00000000DFFFFFFF 800000000000000E 0000000000000008*
NonExist 00000000E0000000-00000000E01BFFFF 0000000000000000 0000000000000000
SystemMem 00000000E01C0000-00000000FFFFFFFF 800000000000000E 0000000000000008*
NonExist 0000000100000000-000000807FFFFFFF 0000000000000000 0000000000000000
SystemMem 0000008080000000-00000083FFFFFFFF 800000000000000E 0000000000000000
NonExist 0000008400000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000000
GCD:AllocateMemorySpace(Base=0000008080000000,Length=0000000380000000)
GcdAllocateType = AtAddress
GcdMemoryType = SystemMem
Alignment = 0000000000001000
ImageHandle = FED1FF98
DeviceHandle = 0
Status = Success (BaseAddress = 0000008080000000)
GCDMemType Range Capabilities Attributes
========== ================================= ================ ================
NonExist 0000000000000000-000000009FFFFFFF 0000000000000000 0000000000000000
SystemMem 00000000A0000000-00000000DFFFFFFF 800000000000000E 0000000000000008*
NonExist 00000000E0000000-00000000E01BFFFF 0000000000000000 0000000000000000
SystemMem 00000000E01C0000-00000000FFFFFFFF 800000000000000E 0000000000000008*
NonExist 0000000100000000-000000807FFFFFFF 0000000000000000 0000000000000000
SystemMem 0000008080000000-00000083FFFFFFFF 800000000000000E 0000000000000000*
NonExist 0000008400000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000000
Step2: Free the memory space
Status = gDS->FreeMemorySpace (
FixedPcdGet64(PcdSystemMemoryExBase),
SystemMemoryExSize
);
Logs:
GCD:FreeMemorySpace(Base=0000008080000000,Length=0000000380000000)
Status = Success
GCDMemType Range Capabilities Attributes
========== ================================= ================ ================
NonExist 0000000000000000-000000009FFFFFFF 0000000000000000 0000000000000000
SystemMem 00000000A0000000-00000000DFFFFFFF 800000000000000E 0000000000000008*
NonExist 00000000E0000000-00000000E01BFFFF 0000000000000000 0000000000000000
SystemMem 00000000E01C0000-00000000FFFFFFFF 800000000000000E 0000000000000008*
NonExist 0000000100000000-000000807FFFFFFF 0000000000000000 0000000000000000
SystemMem 0000008080000000-00000083FFFFFFFF 800000000000000E 0000000000000000
NonExist 0000008400000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000000
Step3: Remove the memory space , As we can see that entry 'SystemMem 0000008080000000-00000083FFFFFFFF' is removed.
Status = gDS->RemoveMemorySpace (
FixedPcdGet64(PcdSystemMemoryExBase),
SystemMemoryExSize
);
Logs:
GCD:RemoveMemorySpace(Base=0000008080000000,Length=0000000380000000)
Status = Success
GCDMemType Range Capabilities Attributes
========== ================================= ================ ================
NonExist 0000000000000000-000000009FFFFFFF 0000000000000000 0000000000000000
SystemMem 00000000A0000000-00000000DFFFFFFF 800000000000000E 0000000000000008*
NonExist 00000000E0000000-00000000E01BFFFF 0000000000000000 0000000000000000
SystemMem 00000000E01C0000-00000000FFFFFFFF 800000000000000E 0000000000000008*
NonExist 0000000100000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000000
Step4 : Run the 'memmap' command. As we can see that entry is still present.
Shell> memmap
Type Start End # Pages Attributes
Available 00000000A0000000-00000000DFFFFFFF 0000000000040000 000000000000000E Available 00000000E01C0000-00000000E53C0FFF 0000000000005201 000000000000000E
BS_Data 00000000E53C1000-00000000E5D99FFF 00000000000009D9 000000000000000E
...
Available 0000008080000000-00000083FFFFFFFF 0000000000380000 000000000000000E
...
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
next prev parent reply other threads:[~2018-01-05 10:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-05 9:59 Memory space entry is not removed after calling FreeMemorySpace and RemoveMemorySpace Wasim Khan
2018-01-05 11:04 ` Zeng, Star [this message]
2018-01-07 19:03 ` Wasim Khan
2018-01-08 1:07 ` Zeng, Star
2018-01-08 12:48 ` Wasim Khan
2018-01-08 13:45 ` Zeng, Star
2018-01-09 6:58 ` Wasim Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0C09AFA07DD0434D9E2A0C6AEB0483103B9F8894@shsmsx102.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox