* [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices ().
@ 2016-11-03 23:10 Marvin Häuser
2016-11-04 1:34 ` Zeng, Star
2016-11-07 1:08 ` Tian, Feng
0 siblings, 2 replies; 4+ messages in thread
From: Marvin Häuser @ 2016-11-03 23:10 UTC (permalink / raw)
To: edk2-devel@lists.01.org; +Cc: feng.tian@intel.com, star.zeng@intel.com
During exiting Boot Services, there should be no changes made to the
Memory Map. This patch eliminates explicit and implicit calls to the
Memory Allocation Services and, where applicable, zeros the memory
instead.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
---
MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c | 11 +++++++++--
MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 12 ++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
index ae202c3fe24a..b5e36b8bec06 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
@@ -872,9 +872,16 @@ IScsiOnExitBootService (
ISCSI_DRIVER_DATA *Private;
Private = (ISCSI_DRIVER_DATA *) Context;
- gBS->CloseEvent (Private->ExitBootServiceEvent);
- IScsiSessionAbort (&Private->Session);
+ if (Private->Session.Signature != 0) {
+ IScsiSessionAbort (&Private->Session);
+
+ //
+ // Empty Session as it will not be freed.
+ // This will also prevent this code from being re-run.
+ //
+ ZeroMem (&Private->Session, sizeof (Private->Session));
+ }
}
/**
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
index 9f61aee05773..e15e79c7065f 100644
--- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
+++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
@@ -32,6 +32,18 @@ SnpNotifyExitBootServices (
Snp = (SNP_DRIVER *)Context;
+ if (Snp->TxRxBuffer != NULL) {
+ //
+ // Empty TxRxBuffer as it will not be freed.
+ //
+ ZeroMem (Snp->TxRxBuffer, Snp->TxRxBufferSize);
+
+ //
+ // Set TxRxBuffer to NULL so FreeBuffer () will not be called.
+ //
+ Snp->TxRxBuffer = NULL;
+ }
+
//
// Shutdown and stop UNDI driver
//
--
2.10.1.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices ().
2016-11-03 23:10 [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices () Marvin Häuser
@ 2016-11-04 1:34 ` Zeng, Star
2016-11-05 16:48 ` Marvin Häuser
2016-11-07 1:08 ` Tian, Feng
1 sibling, 1 reply; 4+ messages in thread
From: Zeng, Star @ 2016-11-04 1:34 UTC (permalink / raw)
To: Marvin.Haeuser@outlook.com, edk2-devel@lists.01.org
Cc: Tian, Feng, Zeng, Star
Reviewed-by: Star Zeng <star.zeng@intel.com>
-----Original Message-----
From: Marvin Häuser [mailto:Marvin.Haeuser@outlook.com]
Sent: Friday, November 4, 2016 7:10 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices ().
During exiting Boot Services, there should be no changes made to the Memory Map. This patch eliminates explicit and implicit calls to the Memory Allocation Services and, where applicable, zeros the memory instead.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
---
MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c | 11 +++++++++--
MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 12 ++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
index ae202c3fe24a..b5e36b8bec06 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
@@ -872,9 +872,16 @@ IScsiOnExitBootService (
ISCSI_DRIVER_DATA *Private;
Private = (ISCSI_DRIVER_DATA *) Context;
- gBS->CloseEvent (Private->ExitBootServiceEvent);
- IScsiSessionAbort (&Private->Session);
+ if (Private->Session.Signature != 0) {
+ IScsiSessionAbort (&Private->Session);
+
+ //
+ // Empty Session as it will not be freed.
+ // This will also prevent this code from being re-run.
+ //
+ ZeroMem (&Private->Session, sizeof (Private->Session)); }
}
/**
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
index 9f61aee05773..e15e79c7065f 100644
--- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
+++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
@@ -32,6 +32,18 @@ SnpNotifyExitBootServices (
Snp = (SNP_DRIVER *)Context;
+ if (Snp->TxRxBuffer != NULL) {
+ //
+ // Empty TxRxBuffer as it will not be freed.
+ //
+ ZeroMem (Snp->TxRxBuffer, Snp->TxRxBufferSize);
+
+ //
+ // Set TxRxBuffer to NULL so FreeBuffer () will not be called.
+ //
+ Snp->TxRxBuffer = NULL;
+ }
+
//
// Shutdown and stop UNDI driver
//
--
2.10.1.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices ().
2016-11-04 1:34 ` Zeng, Star
@ 2016-11-05 16:48 ` Marvin Häuser
0 siblings, 0 replies; 4+ messages in thread
From: Marvin Häuser @ 2016-11-05 16:48 UTC (permalink / raw)
To: edk2-devel@lists.01.org; +Cc: Zeng, Star, feng.tian@intel.com
I forgot to note that this patch is not everything needed to not call the Memory Allocation Services.
The event also calls a function which calls Tcp4IoDestroySocket() and NetbufQueFlush().
This should not be needed, should it? The first one calls the Memory Allocation Services.
Unfortunately I can't test not calling the function, hence I didn't include the change and hope you know the answer.
Regards,
Marvin.
> -----Original Message-----
> From: Zeng, Star [mailto:star.zeng@intel.com]
> Sent: Friday, November 4, 2016 2:34 AM
> To: Marvin.Haeuser@outlook.com; edk2-devel@lists.01.org
> Cc: Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: RE: [PATCH v2 1/2] MdeModulePkg: Do not free memory during
> ExitBootServices ().
>
> Reviewed-by: Star Zeng <star.zeng@intel.com>
>
> -----Original Message-----
> From: Marvin Häuser [mailto:Marvin.Haeuser@outlook.com]
> Sent: Friday, November 4, 2016 7:10 AM
> To: edk2-devel@lists.01.org
> Cc: Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: [PATCH v2 1/2] MdeModulePkg: Do not free memory during
> ExitBootServices ().
>
> During exiting Boot Services, there should be no changes made to the
> Memory Map. This patch eliminates explicit and implicit calls to the Memory
> Allocation Services and, where applicable, zeros the memory instead.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
> ---
> MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c | 11 +++++++++--
> MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 12 ++++++++++++
> 2 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
> index ae202c3fe24a..b5e36b8bec06 100644
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
> +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
> @@ -872,9 +872,16 @@ IScsiOnExitBootService (
> ISCSI_DRIVER_DATA *Private;
>
> Private = (ISCSI_DRIVER_DATA *) Context;
> - gBS->CloseEvent (Private->ExitBootServiceEvent);
>
> - IScsiSessionAbort (&Private->Session);
> + if (Private->Session.Signature != 0) {
> + IScsiSessionAbort (&Private->Session);
> +
> + //
> + // Empty Session as it will not be freed.
> + // This will also prevent this code from being re-run.
> + //
> + ZeroMem (&Private->Session, sizeof (Private->Session)); }
> }
>
> /**
> diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
> b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
> index 9f61aee05773..e15e79c7065f 100644
> --- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
> +++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
> @@ -32,6 +32,18 @@ SnpNotifyExitBootServices (
>
> Snp = (SNP_DRIVER *)Context;
>
> + if (Snp->TxRxBuffer != NULL) {
> + //
> + // Empty TxRxBuffer as it will not be freed.
> + //
> + ZeroMem (Snp->TxRxBuffer, Snp->TxRxBufferSize);
> +
> + //
> + // Set TxRxBuffer to NULL so FreeBuffer () will not be called.
> + //
> + Snp->TxRxBuffer = NULL;
> + }
> +
> //
> // Shutdown and stop UNDI driver
> //
> --
> 2.10.1.windows.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices ().
2016-11-03 23:10 [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices () Marvin Häuser
2016-11-04 1:34 ` Zeng, Star
@ 2016-11-07 1:08 ` Tian, Feng
1 sibling, 0 replies; 4+ messages in thread
From: Tian, Feng @ 2016-11-07 1:08 UTC (permalink / raw)
To: Marvin Häuser, edk2-devel@lists.01.org, Fu, Siyuan,
Wu, Jiaxin
Cc: Zeng, Star, Ye, Ting, Tian, Feng
Marvin,
The commit log is a little confusing. Please update the commit title to clarify it's only for Iscsi.
And I will leave this RB to network owner.
Thanks
Feng
-----Original Message-----
From: Marvin Häuser [mailto:Marvin.Haeuser@outlook.com]
Sent: Friday, November 4, 2016 7:10 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices ().
During exiting Boot Services, there should be no changes made to the Memory Map. This patch eliminates explicit and implicit calls to the Memory Allocation Services and, where applicable, zeros the memory instead.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
---
MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c | 11 +++++++++--
MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 12 ++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
index ae202c3fe24a..b5e36b8bec06 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
@@ -872,9 +872,16 @@ IScsiOnExitBootService (
ISCSI_DRIVER_DATA *Private;
Private = (ISCSI_DRIVER_DATA *) Context;
- gBS->CloseEvent (Private->ExitBootServiceEvent);
- IScsiSessionAbort (&Private->Session);
+ if (Private->Session.Signature != 0) {
+ IScsiSessionAbort (&Private->Session);
+
+ //
+ // Empty Session as it will not be freed.
+ // This will also prevent this code from being re-run.
+ //
+ ZeroMem (&Private->Session, sizeof (Private->Session)); }
}
/**
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
index 9f61aee05773..e15e79c7065f 100644
--- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
+++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
@@ -32,6 +32,18 @@ SnpNotifyExitBootServices (
Snp = (SNP_DRIVER *)Context;
+ if (Snp->TxRxBuffer != NULL) {
+ //
+ // Empty TxRxBuffer as it will not be freed.
+ //
+ ZeroMem (Snp->TxRxBuffer, Snp->TxRxBufferSize);
+
+ //
+ // Set TxRxBuffer to NULL so FreeBuffer () will not be called.
+ //
+ Snp->TxRxBuffer = NULL;
+ }
+
//
// Shutdown and stop UNDI driver
//
--
2.10.1.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-07 1:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-03 23:10 [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices () Marvin Häuser
2016-11-04 1:34 ` Zeng, Star
2016-11-05 16:48 ` Marvin Häuser
2016-11-07 1:08 ` Tian, Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox