Re: [edk2] [PATCH] ArmPkg: Bug fix for UncachedMemoryAllocationLib

2015-08-28 Thread Heyi Guo

Hi Ard,

Would you help to commit the patch? Sorry I didn't see it upstreamed.

Thanks.

On 08/17/2015 06:25 PM, Ard Biesheuvel wrote:

On 13 August 2015 at 16:37, Heyi Guo  wrote:

NewNode is the node we found, while Node is the last node in the
list. Also update mFreedBufferSize.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo 
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
---
  .../UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c  | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)


Reviewed-by: Ard Biesheuvel 



diff --git 
a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c 
b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c
index e70d877..b859f63 100644
--- a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c
+++ b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c
@@ -125,9 +125,10 @@ AllocatePagesFromList (
}
// Check if we have found a node that could contain our new allocation
if (NewNode != NULL) {
-NewNode->Allocated = TRUE;
-Node->Allocation   = (VOID*)(UINTN)Node->Base;
-*Allocation= Node->Allocation;
+NewNode->Allocated  = TRUE;
+NewNode->Allocation = (VOID*)(UINTN)NewNode->Base;
+*Allocation = NewNode->Allocation;
+mFreedBufferSize-= NewNode->Pages * EFI_PAGE_SIZE;
  return EFI_SUCCESS;
}

--
2.1.4



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch 1/3] MdePkg: Add the missing module UNI files

2015-08-28 Thread Kirkendall, Garrett
I thought the Base Tools were modified to support UNI files in the UTF-8 file 
format.  Shouldn't the UNI files have been UTF-8?

GARRETT KIRKENDALL   
SMTS Firmware Engineer | CTE
7171 Southwest Parkway, Austin, TX 78735 USA 
   facebook  |  amd.com

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Qiu, Shumin
> Sent: Thursday, August 27, 2015 9:45 PM
> To: Gao, Liming; edk2-devel@lists.01.org
> Subject: Re: [edk2] [Patch 1/3] MdePkg: Add the missing module UNI files
> 
> Reviewed-by: Qiu Shumin 
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Liming Gao
> Sent: Thursday, August 27, 2015 3:53 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [Patch 1/3] MdePkg: Add the missing module UNI files
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao 
> ---
>  MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf |   1 +
>  MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.uni | Bin 0 -> 1942
> bytes
>  2 files changed, 1 insertion(+)
>  create mode 100644
> MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.uni
> 
> diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
> b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
> index f813eae..811d769 100644
> --- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
> +++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
> @@ -12,10 +12,11 @@
>  ##
> 
>  [Defines]
>INF_VERSION= 0x00010006
>BASE_NAME  = UefiFileHandleLib
> +  MODULE_UNI_FILE= UefiFileHandleLib.uni
>FILE_GUID  = 9495D344-9D8A-41f3-8D17-E2FD238C4E71
>MODULE_TYPE= UEFI_DRIVER
>VERSION_STRING = 1.0
>LIBRARY_CLASS  = FileHandleLib|DXE_DRIVER UEFI_APPLICATION
> UEFI_DRIVER DXE_RUNTIME_DRIVER
> 
> diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.uni
> b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.uni
> new file mode 100644
> index
> ..616f131a410e15d895a75111e
> 6a02ad07be6e274
> GIT binary patch
> literal 1942
> zcmds%OK;Oq5QS%r#DB2T4WKpwBsK^k5^BH#ny5(xtg6H*t)(Q6Y!m38r~S@
> cJEox<
> zc7U#YAM-r-%v@jp>{-tuzDJD6UfEa6Y-#6q-
> |iumZe)e!wne@`ULwhCZ58_h>zSqO
> zBF;H;X_uUqj0oK~>{2utx;2(dc9mVZF30<}eTvnJF~fG@dBQG2vSG+OW#7art-
> C|{
> zucCd;oi{L2aJLJ%tKj4Tw|vO@)E?UtduE61lbUhyDxU%`%`F>UH2s?SHkztcc-
> 2&`
> zExQG*y|96u+RHoGn}8v6?l;)yU{a11QJPv*USXY6hAOsk-
> 4%Xo>?5yW=#C7{l4xyp
> zW{xJRYk7`G>6qI1s=xY7k}aRQab|O7$<$HOs&^VBA=m0w#|W7$)o-
> Eu#6(U{wtfQ}
> z+cD=4Sg3~smKN)G=OShP{k9qQiYN?$FXbvZi~Bh^o4l%vSQUD`i10Rq`3E-
> pm_m;?
> zSOS-NFZ0?zuNe@c>K9(sITe+7?r&B-
> 6=KM~@Y{8{eL;PCd)${u<{)3#(VnJDluN#b
> zk!IC>-dPN)5nVL2x6FO}$T@-
> 02u`(5kS6rmlwIsRPwj*?M&3qfYmm^_F&1NwJY=VS
> z*4$xLTt)4$4*aas;SO75pU?}}&@<}XCzFt!AWw*@7(>r~%1PKIQ_cxivQgGx^#
> )sc
> zeqnu&M#%LJ<2p;YMQopUaoXq!T#V={ DUo73
> z1C6*6t9_W7xc31S)4RN&$}?v5nCgCn*VrvOAo+X$-
> km?>K;1Lu_Uf$Bu3~}1|Ah(N
> F<_2&%JK6vM
> 
> literal 0
> HcmV?d1
> 
> --
> 1.9.5.msysgit.0
> 
> ___
> 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
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] ArmPkg/CpuDxe: Disable interrupt before restoring context

2015-08-28 Thread Heyi Guo

Hi Ard,

Sorry for the late reply. However I think you've got what I meant :)

In my opinion, UEFI actually needs timer interrupt nesting, e.g. we have 
a timer event with low TPL and long execution time, UEFI should support 
a higher TPL timer event interrupt the execution of this low TPL event, 
isn't it?


Also, I took a look at the code of Linux kernel for ARM64 interrupt 
handler; it also disables IRQ before restoring context.


And, thanks for your comments; I'll send another version of the patch.

Heyi Guo

On 08/24/2015 07:05 PM, Ard Biesheuvel wrote:

On 23 August 2015 at 17:59, Ard Biesheuvel  wrote:

On 23 August 2015 at 15:39, Heyi Guo  wrote:


On 08/17/2015 05:52 PM, Ard Biesheuvel wrote:

On 13 August 2015 at 05:10, Heyi Guo  wrote:

Interrupt must be disabled before we storing ELR and other system
registers, or else ELR will be overridden by interrupt reentrance.

This bug is critical as we may get occasional exception or dead loop
when interrupt reentrance occurs:

After increasing SP ... Before popping out registers
Or
After restoring ELR

The 1st circumstance could also be resolved by optimizing SP operation
(Pop out registers before adding SP back), but the 2nd could not be
resolved by disabling interrupt.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo
Cc: Leif Lindholm
Cc: Ard Biesheuvel
---
   ArmPkg/Drivers/CpuDxe/AArch64/ExceptionSupport.S | 8 
   1 file changed, 8 insertions(+)

diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/ExceptionSupport.S
b/ArmPkg/Drivers/CpuDxe/AArch64/ExceptionSupport.S
index 2682f4f..ca6c9a1 100644
--- a/ArmPkg/Drivers/CpuDxe/AArch64/ExceptionSupport.S
+++ b/ArmPkg/Drivers/CpuDxe/AArch64/ExceptionSupport.S
@@ -358,6 +358,14 @@ ASM_PFX(AsmCommonExceptionEntry):
   #define REG_PAIR(REG1, REG2, OFFSET, CONTEXT_SIZE)ldp  REG1, REG2,
[sp, #(OFFSET-CONTEXT_SIZE)]
   #define REG_ONE(REG1, OFFSET, CONTEXT_SIZE)   ldur REG1, [sp,
#(OFFSET-CONTEXT_SIZE)]

+  //
+  // Disable interrupt(IRQ and FIQ) before restoring context,
+  // or else the context will be corrupted by interrupt reentrance.
+  // Interrupt mask will be restored from spsr by hardware when we call
eret
+  //
+  msr   daifset, #3
+  isb
+

Are you sure this is necessary? According to the ARM ARM

"""
On taking any exception to an Exception level using AArch64, all of
PSTATE.{A, I, F} are set to 1, masking all
interrupts that target that Exception level.
"""

Yes. However, in timer interrupt handler, we will raise TPL to HIGH_LEVEL
and then restore TPL, while restore TPL will enable interrupt.


Is that in the generic ARM timer code? Perhaps we should raise and
lower the TPL in the common interrupt entry/exit path, since the
architecture implicitly raises the TPL by entering the interrupt
handler with interrupts disabled. In general, I don't think it is
correct for TPL lowering code to enable interrupts if it did not find
the enabled when it raised the TPL.


So I think we can't avoid interrupt reentering in UEFI architecture and need
protection when restoring interrupt context.


Yes, it seems you are right. Even though I am not happy with the idea
that we are supporting nested interrupts without exactly understanding
the implication and without there being a real need (since we use
interrupts for the timer tick only), the core does not really allow us
to change that for AARCH64 only.

So I think your patch is correct. There are still two issues to resolve, though:

1. Could you update the comment in the code to mention that interrupts
have been re-enabled by the TPL lowering code, and that we need to
disable them again only to protect the critical section that restores
the interrupted context from the stack?
2. The 32-bit ARM code appears to suffer from the same problem, so we
should fix that as well.



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] OvmfPkg: AcpiTables: serialize control methods that create named objects

2015-08-28 Thread Laszlo Ersek
Bruce Cran reported the following issue:

  With iasl version 20150410-64 building OvmfX64 (using OvmfPkg/build.sh
  -a X64 -t GCC49 -b RELEASE) results in a couple of warnings about
  methods that should be serialized:

  .../OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Dsdt.
  95:   Method (_CRS, 0) {
  Remark   2120 - Control Method should be made Serialized ^  (due to
  creation of named objects within)

  .../OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Dsdt.
  235: Method (PCRS, 1, NotSerialized) {
  Remark   2120 - Control Method should be made Serialized ^  (due to
  creation of named objects within)

The ACPI 6.0 spec justifies the above warnings in "19.6.82 Method (Declare
Control Method)":

  [...] The serialize rule can be used to prevent reentering of a method.
  This is especially useful if the method creates namespace objects.
  Without the serialize rule, the reentering of a method will fail when it
  attempts to create the same namespace object. [...]

Cc: Bruce Cran 
Reported-by: Bruce Cran 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/AcpiTables/Dsdt.asl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/OvmfPkg/AcpiTables/Dsdt.asl b/OvmfPkg/AcpiTables/Dsdt.asl
index 519a312..2c3a314 100644
--- a/OvmfPkg/AcpiTables/Dsdt.asl
+++ b/OvmfPkg/AcpiTables/Dsdt.asl
@@ -130,7 +130,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 1, "INTEL ", "OVMF
", 4) {
 )
   })
 
-  Method (_CRS, 0) {
+  Method (_CRS, 0, Serialized) {
 //
 // see the FIRMWARE_DATA structure in "OvmfPkg/AcpiPlatformDxe/Qemu.c"
 //
@@ -360,7 +360,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 1, "INTEL ", "OVMF
", 4) {
 // _CRS method for LNKA, LNKB, LNKC, LNKD
 // Arg0[in]: value of PIRA / PIRB / PIRC / PIRD
 //
-Method (PCRS, 1, NotSerialized) {
+Method (PCRS, 1, Serialized) {
   //
   // create temporary buffer with an Extended Interrupt Descriptor
   // whose single vector defaults to zero
-- 
1.8.3.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] ShellPkg: Get media status in ifconfig command

2015-08-28 Thread Wu, Jiaxin
Attach patch and UNI file. 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jiaxin Wu
Sent: Friday, August 28, 2015 4:55 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting; Carsey, Jaben; Fu, Siyuan
Subject: [edk2] [Patch] ShellPkg: Get media status in ifconfig command

This patch is used to get media status in ifconfig command.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 .../UefiShellNetwork1CommandsLib/Ifconfig.c|  85 +++--
 .../UefiShellNetwork1CommandsLib.uni   | Bin 20910 -> 21094 bytes
 2 files changed, 80 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 273f1a8..4637f28 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -378,10 +378,68 @@ IfConfigPrintMacAddr (
   }
 
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_NEWLINE), 
gShellNetwork1HiiHandle);  }
 
+/**
+  Get network physical device NIC information.
+
+  @param[in] Handle The network physical device handle.
+  @param[out] MediaPresent  Upon successful return, TRUE is media present 
+is enabled.  FALSE otherwise.
+
+  @retval EFI_SUCCESS   The operation was successful.
+  @retval othersGet media status failed.
+**/
+EFI_STATUS
+EFIAPI
+IfConfigGetNicMediaStatus (
+  IN  EFI_HANDLEServiceHandle,
+  OUT BOOLEAN   *MediaPresent
+  )
+  
+{
+  EFI_STATUS   Status;
+  EFI_HANDLE   SnpHandle;
+  EFI_SIMPLE_NETWORK_PROTOCOL  *Snp;
+  UINT32   InterruptStatus;
+
+  ASSERT (MediaPresent != NULL);
+
+  //
+  // Get SNP handle
+  //
+  Snp = NULL;
+  SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp);  if (SnpHandle 
+ == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Check whether SNP support media detection  //  if 
+ (!Snp->Mode->MediaPresentSupported) {
+return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Invoke Snp->GetStatus() to refresh MediaPresent field in SNP mode 
+ data  //  Status = Snp->GetStatus (Snp, &InterruptStatus, NULL);  if 
+ (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  if (Snp->Mode->MediaPresent) {
+*MediaPresent = TRUE;
+  } else {
+*MediaPresent = FALSE;
+  }
+
+  return EFI_SUCCESS;
+}
+
 
 /**
   The get current status of all handles.
 
   @param[in]   IfName The pointer of IfName(interface name).
@@ -594,15 +652,18 @@ ON_ERROR:
 EFI_STATUS
 IfConfigShowInterfaceInfo (
   IN LIST_ENTRY*IfList
   )
 {
-  LIST_ENTRY*Entry;
-  LIST_ENTRY*Next;
-  IFCONFIG_INTERFACE_CB *IfCb;
-  EFI_IPv4_ADDRESS  Gateway;
-  UINT32Index;
+  LIST_ENTRY   *Entry;
+  LIST_ENTRY   *Next;
+  IFCONFIG_INTERFACE_CB*IfCb;
+  BOOLEAN   MediaPresent;
+  EFI_IPv4_ADDRESS  Gateway;
+  UINT32Index;
+  
+  MediaPresent = TRUE;
 
   if (IsListEmpty (IfList)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle);
   }
 
@@ -618,10 +679,24 @@ IfConfigShowInterfaceInfo (
 // Print interface name.
 //
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_IF_NAME), 
gShellNetwork1HiiHandle, IfCb->IfInfo->Name);
 
 //
+// Get media state.
+//
+IfConfigGetNicMediaStatus (IfCb->NicHandle, &MediaPresent);
+
+//
+// Print media state.
+//
+if (!MediaPresent) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media 
disconnected");
+} else {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media present");
+}
+
+//
 // Print interface config policy.
 //
 if (IfCb->Policy == Ip4Config2PolicyDhcp) {
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_POLICY_DHCP), gShellNetwork1HiiHandle);
 } else {
diff --git 
a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index 
7cc7b7d672246a62ef97a8b002a780003d3da330..43259591820582cc38937ad680739fcff21b96c5
 100644 GIT binary patch delta 66 
zcmZ3tnDN;X#toCSgnb!Y8C)1V85|kn8G;!?fON>@hnk|30}QmpJs5l$QW;VhG8qyX
S6o9fNK)Qq>b+fZpwmJY$n-Ez5

delta 14
WcmaF1gmK+s#toCSHhXEyr~?2phttps://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] ShellPkg: Get media status in ifconfig command

2015-08-28 Thread Fu, Siyuan
Hi, Jiaxin

The Snp->Getstatus may not support media present report, please use NetLib 
interface NetLibDetectMedia() instead.

-Original Message-
From: Wu, Jiaxin 
Sent: Friday, August 28, 2015 4:55 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Carsey, 
Jaben 
Subject: [Patch] ShellPkg: Get media status in ifconfig command

This patch is used to get media status in ifconfig command.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 .../UefiShellNetwork1CommandsLib/Ifconfig.c|  85 +++--
 .../UefiShellNetwork1CommandsLib.uni   | Bin 20910 -> 21094 bytes
 2 files changed, 80 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 273f1a8..4637f28 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -378,10 +378,68 @@ IfConfigPrintMacAddr (
   }
 
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_NEWLINE), 
gShellNetwork1HiiHandle);  }
 
+/**
+  Get network physical device NIC information.
+
+  @param[in] Handle The network physical device handle.
+  @param[out] MediaPresent  Upon successful return, TRUE is media present 
+is enabled.  FALSE otherwise.
+
+  @retval EFI_SUCCESS   The operation was successful.
+  @retval othersGet media status failed.
+**/
+EFI_STATUS
+EFIAPI
+IfConfigGetNicMediaStatus (
+  IN  EFI_HANDLEServiceHandle,
+  OUT BOOLEAN   *MediaPresent
+  )
+  
+{
+  EFI_STATUS   Status;
+  EFI_HANDLE   SnpHandle;
+  EFI_SIMPLE_NETWORK_PROTOCOL  *Snp;
+  UINT32   InterruptStatus;
+
+  ASSERT (MediaPresent != NULL);
+
+  //
+  // Get SNP handle
+  //
+  Snp = NULL;
+  SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp);  if (SnpHandle 
+ == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Check whether SNP support media detection  //  if 
+ (!Snp->Mode->MediaPresentSupported) {
+return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Invoke Snp->GetStatus() to refresh MediaPresent field in SNP mode 
+ data  //  Status = Snp->GetStatus (Snp, &InterruptStatus, NULL);  if 
+ (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  if (Snp->Mode->MediaPresent) {
+*MediaPresent = TRUE;
+  } else {
+*MediaPresent = FALSE;
+  }
+
+  return EFI_SUCCESS;
+}
+
 
 /**
   The get current status of all handles.
 
   @param[in]   IfName The pointer of IfName(interface name).
@@ -594,15 +652,18 @@ ON_ERROR:
 EFI_STATUS
 IfConfigShowInterfaceInfo (
   IN LIST_ENTRY*IfList
   )
 {
-  LIST_ENTRY*Entry;
-  LIST_ENTRY*Next;
-  IFCONFIG_INTERFACE_CB *IfCb;
-  EFI_IPv4_ADDRESS  Gateway;
-  UINT32Index;
+  LIST_ENTRY   *Entry;
+  LIST_ENTRY   *Next;
+  IFCONFIG_INTERFACE_CB*IfCb;
+  BOOLEAN   MediaPresent;
+  EFI_IPv4_ADDRESS  Gateway;
+  UINT32Index;
+  
+  MediaPresent = TRUE;
 
   if (IsListEmpty (IfList)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle);
   }
 
@@ -618,10 +679,24 @@ IfConfigShowInterfaceInfo (
 // Print interface name.
 //
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_IF_NAME), 
gShellNetwork1HiiHandle, IfCb->IfInfo->Name);
 
 //
+// Get media state.
+//
+IfConfigGetNicMediaStatus (IfCb->NicHandle, &MediaPresent);
+
+//
+// Print media state.
+//
+if (!MediaPresent) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media 
disconnected");
+} else {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media present");
+}
+
+//
 // Print interface config policy.
 //
 if (IfCb->Policy == Ip4Config2PolicyDhcp) {
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_POLICY_DHCP), gShellNetwork1HiiHandle);
 } else {
diff --git 
a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index 
7cc7b7d672246a62ef97a8b002a780003d3da330..43259591820582cc38937ad680739fcff21b96c5
 100644 GIT binary patch delta 66 
zcmZ3tnDN;X#toCSgnb!Y8C)1V85|kn8G;!?fON>@hnk|30}QmpJs5l$QW;VhG8qyX
S6o9fNK)Qq>b+fZpwmJY$n-Ez5

delta 14
WcmaF1gmK+s#toCSHhXEyr~?2phttps://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] ShellPkg: Get media status in ifconfig command

2015-08-28 Thread Jiaxin Wu
This patch is used to get media status in ifconfig command.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 .../UefiShellNetwork1CommandsLib/Ifconfig.c|  85 +++--
 .../UefiShellNetwork1CommandsLib.uni   | Bin 20910 -> 21094 bytes
 2 files changed, 80 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 273f1a8..4637f28 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -378,10 +378,68 @@ IfConfigPrintMacAddr (
   }
 
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_NEWLINE), 
gShellNetwork1HiiHandle);
 }
 
+/**
+  Get network physical device NIC information.
+
+  @param[in] Handle The network physical device handle.
+  @param[out] MediaPresent  Upon successful return, TRUE is media present 
+is enabled.  FALSE otherwise.
+
+  @retval EFI_SUCCESS   The operation was successful.
+  @retval othersGet media status failed.
+**/
+EFI_STATUS
+EFIAPI
+IfConfigGetNicMediaStatus (
+  IN  EFI_HANDLEServiceHandle,
+  OUT BOOLEAN   *MediaPresent
+  )
+  
+{
+  EFI_STATUS   Status;
+  EFI_HANDLE   SnpHandle;
+  EFI_SIMPLE_NETWORK_PROTOCOL  *Snp;
+  UINT32   InterruptStatus;
+
+  ASSERT (MediaPresent != NULL);
+
+  //
+  // Get SNP handle
+  //
+  Snp = NULL;
+  SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp);
+  if (SnpHandle == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Check whether SNP support media detection
+  //
+  if (!Snp->Mode->MediaPresentSupported) {
+return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Invoke Snp->GetStatus() to refresh MediaPresent field in SNP mode data
+  //
+  Status = Snp->GetStatus (Snp, &InterruptStatus, NULL);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  if (Snp->Mode->MediaPresent) {
+*MediaPresent = TRUE;
+  } else {
+*MediaPresent = FALSE;
+  }
+
+  return EFI_SUCCESS;
+}
+
 
 /**
   The get current status of all handles.
 
   @param[in]   IfName The pointer of IfName(interface name).
@@ -594,15 +652,18 @@ ON_ERROR:
 EFI_STATUS
 IfConfigShowInterfaceInfo (
   IN LIST_ENTRY*IfList
   )
 {
-  LIST_ENTRY*Entry;
-  LIST_ENTRY*Next;
-  IFCONFIG_INTERFACE_CB *IfCb;
-  EFI_IPv4_ADDRESS  Gateway;
-  UINT32Index;
+  LIST_ENTRY   *Entry;
+  LIST_ENTRY   *Next;
+  IFCONFIG_INTERFACE_CB*IfCb;
+  BOOLEAN   MediaPresent;
+  EFI_IPv4_ADDRESS  Gateway;
+  UINT32Index;
+  
+  MediaPresent = TRUE;
 
   if (IsListEmpty (IfList)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle);
   }
 
@@ -618,10 +679,24 @@ IfConfigShowInterfaceInfo (
 // Print interface name.
 //
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_IF_NAME), 
gShellNetwork1HiiHandle, IfCb->IfInfo->Name);
 
 //
+// Get media state.
+//
+IfConfigGetNicMediaStatus (IfCb->NicHandle, &MediaPresent);  
+
+//
+// Print media state.
+//
+if (!MediaPresent) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media 
disconnected");
+} else {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media present");
+}
+
+//
 // Print interface config policy.
 //
 if (IfCb->Policy == Ip4Config2PolicyDhcp) {
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INFO_POLICY_DHCP), gShellNetwork1HiiHandle);
 } else {
diff --git 
a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index 
7cc7b7d672246a62ef97a8b002a780003d3da330..43259591820582cc38937ad680739fcff21b96c5
 100644
GIT binary patch
delta 66
zcmZ3tnDN;X#toCSgnb!Y8C)1V85|kn8G;!?fON>@hnk|30}QmpJs5l$QW;VhG8qyX
S6o9fNK)Qq>b+fZpwmJY$n-Ez5

delta 14
WcmaF1gmK+s#toCSHhXEyr~?2phttps://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] OvmfPkg: prevent code execution from DXE stack

2015-08-28 Thread Laszlo Ersek
On 08/08/15 02:02, Zeng, Star wrote:
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>> Laszlo Ersek
>> Sent: Saturday, August 8, 2015 12:00 AM
>> To: edk2-devel-01
>> Cc: Paolo Bonzini; Zeng, Star; Justen, Jordan L
>> Subject: [edk2] [PATCH] OvmfPkg: prevent code execution from DXE stack
>>
>> SVN rev 18166 ("MdeModulePkg DxeIpl: Add stack NX support") enables
>> platforms to request non-executable stack for the DXE phase, by setting
>> PcdSetNxForStack to TRUE.
>>
>> The PCD defaults to FALSE, because:
>>
>> (a) A non-executable DXE stack is a new feature and causes changes in
>> behavior. Some platform could rely on executing code from the stack.
>>
>> (b) The code enabling NX in the DXE IPL PEIM enforces the
>>
>>   PcdSetNxForStack ==> PcdDxeIplBuildPageTables
>>
>> implication for "64-bit PEI + 64-bit DXE" platforms, with a new
>> ASSERT(). Some platform might not comply with this requirement
>> immediately.
>>
>> Regarding (a), in none of the OVMF builds do we try to execute code from
>> the stack.
>>
>> Regarding (b):
>>
>> - In the OvmfPkgX64.dsc build (which is where (b) applies) we simply
>>   inherit the PcdDxeIplBuildPageTables|TRUE default from
>>   "MdeModulePkg/MdeModulePkg.dec". Therefore we can set
>> PcdSetNxForStack
>>   to TRUE.
>>
>> - In OvmfPkgIa32X64.dsc, page tables are built by default for DXE. Hence
>>   we can set PcdSetNxForStack to TRUE.
>>
>> - In OvmfPkgIa32.dsc, page tables used not to be necessary until now.
>>   After we set PcdSetNxForStack to TRUE in this patch, the DXE IPL will
>>   construct page tables even when it is built as part of OvmfPkgIa32.dsc,
>>   provided the (virtual) hardware supports both PAE mode and the XD bit.
>>
>> Should this setting cause problems in a GPU (or other device) passthru
>> scenario, with a UEFI_DRIVER in the PCI option rom attempting to execute
>> code from the stack, the feature can be dynamically disabled on the QEMU
>> command line, with "-cpu ,-nx".
>>
>> Cc: Paolo Bonzini 
>> Cc: Jordan Justen 
>> Cc: "Zeng, Star" 
>> Suggested-by: Paolo Bonzini 
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek 
> 
> Reviewed by: Star Zeng 

Committed as SVN r18360. Thanks!
Laszlo

> 
>> ---
>>
>> Notes:
>> - This patch depends on Star's
>>
>>   [edk2] [PATCH] UefiCpuPkg CpuDxe: Sync up the settings of Execute
>>  Disable to APs
>>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/960
>>
>>   and should be applied only after that patch.
>>
>>  OvmfPkg/OvmfPkgIa32.dsc| 1 +
>>  OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
>>  OvmfPkg/OvmfPkgX64.dsc | 1 +
>>  3 files changed, 3 insertions(+)
>>
>> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index
>> 48118cc..38954109 100644
>> --- a/OvmfPkg/OvmfPkgIa32.dsc
>> +++ b/OvmfPkg/OvmfPkgIa32.dsc
>> @@ -303,6 +303,7 @@ [PcdsFeatureFlag]
>>  !endif
>>
>>  [PcdsFixedAtBuild]
>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
>>gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
>>
>> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
>> hange|FALSE
>>gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
>> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
>> index 6860ad7..6f6517c 100644
>> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
>> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
>> @@ -308,6 +308,7 @@ [PcdsFeatureFlag]
>>  !endif
>>
>>  [PcdsFixedAtBuild]
>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
>>gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
>>
>> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
>> hange|FALSE
>>gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
>> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index
>> f877fda..6b7f955 100644
>> --- a/OvmfPkg/OvmfPkgX64.dsc
>> +++ b/OvmfPkg/OvmfPkgX64.dsc
>> @@ -308,6 +308,7 @@ [PcdsFeatureFlag]
>>  !endif
>>
>>  [PcdsFixedAtBuild]
>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
>>gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
>>
>> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
>> hange|FALSE
>>gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
>> --
>> 1.8.3.1
>>
>> ___
>> 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
> 

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] OvmfPkg: Build HTTP utilities driver

2015-08-28 Thread Laszlo Ersek
On 08/28/15 03:58, Gary Ching-Pang Lin wrote:
> On Thu, Aug 27, 2015 at 12:54:13PM +0200, Laszlo Ersek wrote:
>> Gary,
>>
>> On 08/27/15 05:41, Gary Ching-Pang Lin wrote:
>>> The HTTP driver now needs the HTTP utilities driver to parse the
>>> headers of HTTP requests.
>>
>> Can you point out the SVN rev / git commit that makes this necessary?
>> I'd like to reference that patch in this commit message.
>>
> It's r18316 / 5ca29abe5297. That commit removed HttpUtilities.* from
> HttpDxe and make the driver consume EFI_HTTP_UTILITIES_PROTOCOL instead.

Committed as r18359. Thanks.

> 
> Gary Lin
> 
>> You don't need to resubmit, I can edit the reference into the commit
>> message when I commit the patch.
>>
>> Thanks
>> Laszlo
>>
>>
>>> Add the driver into OVMF so that the
>>> HTTP driver can work properly.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Gary Ching-Pang Lin 
>>> ---
>>>  OvmfPkg/OvmfPkgIa32.dsc| 1 +
>>>  OvmfPkg/OvmfPkgIa32.fdf| 1 +
>>>  OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
>>>  OvmfPkg/OvmfPkgIa32X64.fdf | 1 +
>>>  OvmfPkg/OvmfPkgX64.dsc | 1 +
>>>  OvmfPkg/OvmfPkgX64.fdf | 1 +
>>>  6 files changed, 6 insertions(+)
>>>
>>> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
>>> index 5741eac..d92a327 100644
>>> --- a/OvmfPkg/OvmfPkgIa32.dsc
>>> +++ b/OvmfPkg/OvmfPkgIa32.dsc
>>> @@ -562,6 +562,7 @@ [Components]
>>>  !endif
>>>  !if $(HTTP_BOOT_ENABLE) == TRUE
>>>NetworkPkg/DnsDxe/DnsDxe.inf
>>> +  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
>>>NetworkPkg/HttpDxe/HttpDxe.inf
>>>NetworkPkg/HttpBootDxe/HttpBootDxe.inf
>>>  !endif
>>> diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
>>> index 0e4ee49..f3dcfff 100644
>>> --- a/OvmfPkg/OvmfPkgIa32.fdf
>>> +++ b/OvmfPkg/OvmfPkgIa32.fdf
>>> @@ -326,6 +326,7 @@ [FV.DXEFV]
>>>  !endif
>>>  !if $(HTTP_BOOT_ENABLE) == TRUE
>>>INF  NetworkPkg/DnsDxe/DnsDxe.inf
>>> +  INF  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
>>>INF  NetworkPkg/HttpDxe/HttpDxe.inf
>>>INF  NetworkPkg/HttpBootDxe/HttpBootDxe.inf
>>>  !endif
>>> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
>>> index 753ab27..1c39cc7 100644
>>> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
>>> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
>>> @@ -569,6 +569,7 @@ [Components.X64]
>>>  !endif
>>>  !if $(HTTP_BOOT_ENABLE) == TRUE
>>>NetworkPkg/DnsDxe/DnsDxe.inf
>>> +  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
>>>NetworkPkg/HttpDxe/HttpDxe.inf
>>>NetworkPkg/HttpBootDxe/HttpBootDxe.inf
>>>  !endif
>>> diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
>>> index 74412d4..3a509da 100644
>>> --- a/OvmfPkg/OvmfPkgIa32X64.fdf
>>> +++ b/OvmfPkg/OvmfPkgIa32X64.fdf
>>> @@ -326,6 +326,7 @@ [FV.DXEFV]
>>>  !endif
>>>  !if $(HTTP_BOOT_ENABLE) == TRUE
>>>INF  NetworkPkg/DnsDxe/DnsDxe.inf
>>> +  INF  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
>>>INF  NetworkPkg/HttpDxe/HttpDxe.inf
>>>INF  NetworkPkg/HttpBootDxe/HttpBootDxe.inf
>>>  !endif
>>> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
>>> index 540333d..778ea28 100644
>>> --- a/OvmfPkg/OvmfPkgX64.dsc
>>> +++ b/OvmfPkg/OvmfPkgX64.dsc
>>> @@ -567,6 +567,7 @@ [Components]
>>>  !endif
>>>  !if $(HTTP_BOOT_ENABLE) == TRUE
>>>NetworkPkg/DnsDxe/DnsDxe.inf
>>> +  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
>>>NetworkPkg/HttpDxe/HttpDxe.inf
>>>NetworkPkg/HttpBootDxe/HttpBootDxe.inf
>>>  !endif
>>> diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
>>> index e9ba97b..153dd82 100644
>>> --- a/OvmfPkg/OvmfPkgX64.fdf
>>> +++ b/OvmfPkg/OvmfPkgX64.fdf
>>> @@ -326,6 +326,7 @@ [FV.DXEFV]
>>>  !endif
>>>  !if $(HTTP_BOOT_ENABLE) == TRUE
>>>INF  NetworkPkg/DnsDxe/DnsDxe.inf
>>> +  INF  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
>>>INF  NetworkPkg/HttpDxe/HttpDxe.inf
>>>INF  NetworkPkg/HttpBootDxe/HttpBootDxe.inf
>>>  !endif
>>>
>>
>>
> ___
> 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


[edk2] Network disconnected after NBP was loaded

2015-08-28 Thread Gary Ching-Pang Lin
Hi,

I was under the impression that the UEFI firmware would maintain the network
connection unless a EFI program or OS determine to create a new connection.
Take PXE for example. After the bootloader is loaded, it can utilize the
PxeBaseCode protocol to download the OS image with the existed connection
without starting the DHCP process again. However, the current implementation
of HttpBoot seems to be another case.

In HttpBootDxeLoadFile() in NetworkPkg/HttpBootDxe/HttpBootImpl.c, the driver
closes the DHCP4 connection right after the file is loaded. This means the
bootloader has to set up the network connection on its own if it needs to load
a remote file.

My question is: what's the expection for a bootloader/Network Boot Program?
Should the bootloader always create its own connection for HTTP Boot?

Thanks,

Gary Lin
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 11/15] OvmfPkg: Link separated VarCheckUefiLib NULL class library instance

2015-08-28 Thread Laszlo Ersek
On 08/28/15 04:37, Zeng, Star wrote:
> On 2015/8/26 18:57, Laszlo Ersek wrote:
>> On 08/26/15 12:27, Laszlo Ersek wrote:
>>> Star,
>>>
>>> On 08/17/15 10:24, Star Zeng wrote:
 Cc: Jordan Justen 
 Cc: Laszlo Ersek 
 Contributed-under: TianoCore Contribution Agreement 1.0
 Signed-off-by: Star Zeng 
 ---
   OvmfPkg/OvmfPkgIa32.dsc| 5 -
   OvmfPkg/OvmfPkgIa32X64.dsc | 5 -
   OvmfPkg/OvmfPkgX64.dsc | 5 -
   3 files changed, 12 insertions(+), 3 deletions(-)

 diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
 index df00011..e55f0db 100644
 --- a/OvmfPkg/OvmfPkgIa32.dsc
 +++ b/OvmfPkg/OvmfPkgIa32.dsc
 @@ -461,7 +461,10 @@ [Components]

 PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
 }

 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
 -  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
 +  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
 +
 +  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
 +  }
 MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf

 MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf

 MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>>>
>>> should we use the same library instance with
>>>
>>>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
>>>
>>> as well?
>>>
>>> That driver is not part of the OVMF build just yet, but I'm rebasing my
>>> SMM series on current master, and I'm thinking that the same library
>>> should *probably* be hooked into the non-privileged part of the
>>> SMM-flavored variable driver, ie. VariableSmmRuntimeDxe. Can you please
>>> confirm?
>>
>>  actually I think it should be hooked into the privileged half:
>>
>>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
>>
>> The theoretical part of the reason is that variable checking should
>> occur in the protected part of the driver.
>>
>> The practical part of the reason is that the constructor of the
>> VarCheckUefiLib "plugin", VarCheckUefiLibNullClassConstructor(), calls
>> VarCheckLibRegisterSetVariableCheckHandler(), which is defined in
>> "MdeModulePkg/Library/VarCheckLib/VarCheckLib.c", ie. an implementation
>> of the VarCheckLib class. Ie. the "plugin" requires the receiving module
>> to link against VarCheckLib in the first place.
>>
>> And, VariableSmmRuntimeDxe does not use that library class, only
>> VariableSmm.inf does.
> 
> Yes, you are right.
> VariableSmmRuntimeDxe is a wrapper based on VariableSmm, it does not do
> real variable check/get/set work.
> Vlv2TbltDevicePkg/PlatformPkgX64.dsc has the example.

Thanks!
Laszlo

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] USB hot swap support

2015-08-28 Thread Laszlo Ersek
On 08/27/15 19:10, Andrew Fish wrote:
> 
>> On Aug 27, 2015, at 9:02 AM, Robinson, Keith  
>> wrote:
>>
>>
>> Hello,
>>
>> I am trying to determine if it is possible to write a UEFI
>> application that allows the user to swap USB mass storage devices
>> and re-enumerate the new device inserted.
>>
> 
> The USB stack is hot plug, and the EFI Driver model is basically hot
> plug via the Driver Binding protocol (Support, Start, and Stop). The
> USB bus driver will call Stop we a device is removed, and Start when
> a device is added.
> 
> Generally the problem is the Application does not follow the EFI
> Driver Model and it end sup hanging on to some protocol that “goes
> away”.  I think I posted an example library, SafeProtocolOpenLib, to
> the mailing list a while back with an example of how to make BlockIo
> safe.

That patch has been very hard to find, traditionally, in the list
archive(s). So I make it a point to provide a pointer whenever this
comes up. (I think keeping it in a public git repo somewhere would be
more useful.)

So, the patch is called "safe.patch", and it is attached to the message
in .

Thanks
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel