Re: [edk2] help

2018-01-11 Thread Gao, Liming
Could you type build --version to get its build version? 

And, please let me know your build command and step. 

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 赵彦峰
> Sent: Thursday, January 11, 2018 1:52 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] help
> 
> build...
>  : error C0DE: Unknown fatal error when processing 
> [c:\edk2\Nt32Pkg\Nt32Pkg.dsc]
> 
> 
> (Please send email to edk2-devel@lists.01.org for help, attaching following 
> call stack trace!)
> 
> 
> (Python 2.7.3 on win32) Traceback (most recent call last):
>   File "build\build.py", line 2477, in Main
>   File "build\build.py", line 2211, in Launch
>   File "build\build.py", line 1986, in _MultiThreadBuildPlatform
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\AutoGen\AutoGen.py",
>  line 184, in __new__
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\AutoGen\AutoGen.py",
>  line 497, in _Init
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\DscBuildData.py",
>  line 888, in _GetPcds
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\DscBuildData.py",
>  line 1156, in _GetPcd
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\DscBuildData.py",
>  line 803, in _ValidatePcd
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceCommon.py",
>  line 49, in
> GetDeclaredPcd
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceCommon.py",
>  line 34, in
> GetPackageList
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceCommon.py",
>  line 81, in
> GetLiabraryInstances
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceCommon.py",
>  line 126, in
> _GetModuleLibraryInstances
>   File 
> "c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceDatabase.py",
>  line 108, in
> __getitem__
> AttributeError: 'str' object has no attribute 'Type'
> 
> 
> 
> - Failed -
> Build end time: 13:41:05, Jan.11 2018
> Build total time: 00:00:04
> ___
> 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/VirtioScsiDxe: Allocate all required vrings at VirtioScsiInit

2018-01-11 Thread Maxime Coquelin

Hi Xiang,

On 12/14/2017 02:25 PM, zhengxiang (A) wrote:



On 2017/12/14 17:06, Paolo Bonzini wrote:

On 14/12/2017 07:55, zhengxiang (A) wrote:

Hello Laszlo and Paolo,

Thanks for your review!

On 2017/12/13 19:16, Laszlo Ersek wrote:

On 12/13/17 10:29, Paolo Bonzini wrote:

On 13/12/2017 09:35, Laszlo Ersek wrote:

Perhaps you can update vhost-scsi similarly to the last patch of
Maxime's v4 series, even without "VIRTIO_SCSI_F_MQ" -- in the
SET_FEATURES request handler, just destroy the unused virtqueues that
have not been configured by the guest driver until that time?

Yes, this is the right solution.  We can assume that if the descriptor
address is equal to zero, the queue is not in use.  This is not in the
spec as far as I can see, but it is QEMU's assumption.  I will send a
patch to the virtio specification.


I would try this solution! However, is there any possibility that the allocated
descriptor address is exactly equal to zero and the queue is in use?


That would break QEMU's virtio implementation, so it's pretty unlikely.

Paolo



So could I judge the not-in-use queues by adding the below sentence in order
to skip calling vhost_virtqueue_start?

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e4290ce..05c3322 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1532,6 +1532,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice 
*vdev)
  goto fail_mem;
  }
  for (i = 0; i < hdev->nvqs; ++i) {
+if (virtio_queue_get_desc_addr(vdev, i) == 0) continue;
  r = vhost_virtqueue_start(hdev,
vdev,
hdev->vqs + i,



I think it should work, or you could detect it by checking that desc,
used and avail rings have the same address.

We would need this also for virtio-net, as Windows guest only setup as
much queue pairs as vcpus, but vhost_virtqueue_start is called for all
queue pairs declred in QEMU. With DPDK Vhost-user backend, it turns out
that it uses these uninitialized queues, corrupting guest's physical
address 0.

Do you plan to post the fix, or you'd like me to propose it?

Thanks,
Maxime

Thanks,
Xiang


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


[edk2] [Patch v2] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().

2018-01-11 Thread Wang Fan
V2
* Added an ASSERT check for the case PrefixLength equals to IP6_PREFIX_MAX.
* Synced some code descriptions to head file.

Cc: Fu Siyuan 
Cc: Jiaxin Wu 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan 
---
 MdeModulePkg/Include/Library/NetLib.h  | 50 +++---
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c |  8 +++--
 2 files changed, 52 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Include/Library/NetLib.h 
b/MdeModulePkg/Include/Library/NetLib.h
index 7862df9..b0bbaf2 100644
--- a/MdeModulePkg/Include/Library/NetLib.h
+++ b/MdeModulePkg/Include/Library/NetLib.h
@@ -1,10 +1,10 @@
 /** @file
   This library is only intended to be used by UEFI network stack modules.
   It provides basic functions for the UEFI network stack.
 
-Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -438,10 +438,12 @@ NetIp4IsUnicast (
   );
 
 /**
   Check whether the incoming IPv6 address is a valid unicast address.
 
+  ASSERT if Ip6 is NULL.
+
   If the address is a multicast address has binary 0xFF at the start, it is not
   a valid unicast address. If the address is unspecified ::, it is not a valid
   unicast address to be assigned to any node. If the address is loopback 
address
   ::1, it is also not a valid unicast address to be assigned to any physical
   interface.
@@ -459,10 +461,12 @@ NetIp6IsValidUnicast (
 
 
 /**
   Check whether the incoming Ipv6 address is the unspecified address or not.
 
+  ASSERT if Ip6 is NULL.
+
   @param[in] Ip6   - Ip6 address, in network order.
 
   @retval TRUE - Yes, incoming Ipv6 address is the unspecified address.
   @retval FALSE- The incoming Ipv6 address is not the unspecified address
 
@@ -474,10 +478,12 @@ NetIp6IsUnspecifiedAddr (
   );
 
 /**
   Check whether the incoming Ipv6 address is a link-local address.
 
+  ASSERT if Ip6 is NULL.
+
   @param[in] Ip6   - Ip6 address, in network order.
 
   @retval TRUE  - The incoming Ipv6 address is a link-local address.
   @retval FALSE - The incoming Ipv6 address is not a link-local address.
 
@@ -489,10 +495,13 @@ NetIp6IsLinkLocalAddr (
   );
 
 /**
   Check whether the Ipv6 address1 and address2 are on the connected network.
 
+  ASSERT if Ip1 or Ip2 is NULL.
+  ASSERT if PrefixLength exceeds or equals to IP6_PREFIX_MAX.
+
   @param[in] Ip1  - Ip6 address1, in network order.
   @param[in] Ip2  - Ip6 address2, in network order.
   @param[in] PrefixLength - The prefix length of the checking net.
 
   @retval TRUE- Yes, the Ipv6 address1 and address2 are connected.
@@ -508,10 +517,12 @@ NetIp6IsNetEqual (
   );
 
 /**
   Switches the endianess of an IPv6 address.
 
+  ASSERT if Ip6 is NULL.
+
   This function swaps the bytes in a 128-bit IPv6 address to switch the value
   from little endian to big endian or vice versa. The byte swapped value is
   returned.
 
   @param  Ip6 Points to an IPv6 address.
@@ -542,10 +553,12 @@ extern EFI_IPv4_ADDRESS  mZeroIp4Addr;
 #define NET_RANDOM(Seed)((UINT32) ((UINT32) (Seed) * 1103515245UL + 
12345) % 4294967295UL)
 
 /**
   Extract a UINT32 from a byte stream.
 
+  ASSERT if Buf is NULL.
+
   This function copies a UINT32 from a byte stream, and then converts it from 
Network
   byte order to host byte order. Use this function to avoid alignment error.
 
   @param[in]  Buf The buffer to extract the UINT32.
 
@@ -559,10 +572,12 @@ NetGetUint32 (
   );
 
 /**
   Puts a UINT32 into the byte stream in network byte order.
 
+  ASSERT if Buf is NULL.
+
   Converts a UINT32 from host byte order to network byte order, then copies it 
to the
   byte stream.
 
   @param[in, out]  Buf  The buffer in which to put the UINT32.
   @param[in]   Data The data to be converted and put into the byte 
stream.
@@ -675,10 +690,12 @@ NetListRemoveTail (
   );
 
 /**
   Insert a new node entry after a designated node entry of a doubly linked 
list.
 
+  ASSERT if PrevEntry or NewEntry is NULL.
+
   Inserts a new node entry designated by NewEntry after the node entry 
designated by PrevEntry
   of the doubly linked list.
 
   @param[in, out]  PrevEntry The entry after which to insert.
   @param[in, out]  NewEntry  The new entry to insert.
@@ -692,10 +709,12 @@ NetListInsertAfter (
   );
 
 /**
   Insert a new node entry before a designated node entry of a doubly linked 
list.
 
+  ASSERT if PostEntry or NewEntry is NULL.
+
   Inserts a new node entry designated by NewEntry before the node entry 
designated by 

Re: [edk2] [Patch] Edk2: Retire Edk2Setup.bat

2018-01-11 Thread Laszlo Ersek
On 01/11/18 09:21, Liming Gao wrote:
> Edk2Setup.bat is out of maintain. It is a draft version batch file, and not
> implement all features listed in its header file. To avoid the confuse,
> drop it from edk2 project, and keep edksetup.bat only.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Liming Gao 
> ---
>  Edk2Setup.bat | 541 
> --
>  1 file changed, 541 deletions(-)
>  delete mode 100755 Edk2Setup.bat

Meta-question: who is supposed to review such (top-level) patches?

FWIW, I'm fine with the proposal.

Reviewed-by: Laszlo Ersek 

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


[edk2] [Patch] MdeModulePkg/Ip4Dxe: Add an independent timer for reconfig checking

2018-01-11 Thread Wang Fan
* Since wireless network can switch at very short time, the time interval
  of reconfig event checking is too long for this case. To achieve better
  performance and scalability, separate this task from Ip4 tick timer.

Cc: Jiaxin Wu 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c | 28 +-
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c   | 47 +++
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h   | 30 ---
 3 files changed, 83 insertions(+), 22 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
index 49b7dc5..552c4e1 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
@@ -1,9 +1,9 @@
 /** @file
   The driver binding and service binding protocol for IP4 driver.
 
-Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -251,10 +251,11 @@ Ip4CreateService (
   IpSb->MnpConfigData.DisableBackgroundPolling  = FALSE;
 
   ZeroMem (>SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE));
 
   IpSb->Timer = NULL;
+  IpSb->ReconfigCheckTimer = NULL;
 
   IpSb->ReconfigEvent = NULL;
 
   IpSb->Reconfig = FALSE;
   
@@ -283,10 +284,22 @@ Ip4CreateService (
   if (EFI_ERROR (Status)) {
 goto ON_ERROR;
   }
 
   Status = gBS->CreateEvent (
+  EVT_NOTIFY_SIGNAL | EVT_TIMER,
+  TPL_CALLBACK,
+  Ip4TimerReconfigChecking,
+  IpSb,
+  >ReconfigCheckTimer
+  );
+
+  if (EFI_ERROR (Status)) {
+goto ON_ERROR;
+  }
+
+  Status = gBS->CreateEvent (
   EVT_NOTIFY_SIGNAL,
   TPL_NOTIFY,
   Ip4AutoReconfigCallBack,
   IpSb,
   >ReconfigEvent
@@ -408,10 +421,17 @@ Ip4CleanService (
 gBS->CloseEvent (IpSb->Timer);
 
 IpSb->Timer = NULL;
   }
 
+  if (IpSb->ReconfigCheckTimer != NULL) {
+gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerCancel, 0);
+gBS->CloseEvent (IpSb->ReconfigCheckTimer);
+
+IpSb->ReconfigCheckTimer = NULL;
+  }
+
   if (IpSb->DefaultInterface != NULL) {
 Status = Ip4FreeInterface (IpSb->DefaultInterface, NULL);
 
 if (EFI_ERROR (Status)) {
   return Status;
@@ -628,10 +648,16 @@ Ip4DriverBindingStart (
 
   if (EFI_ERROR (Status)) {
 goto UNINSTALL_PROTOCOL;
   }
 
+  Status = gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerPeriodic, 500 * 
TICKS_PER_MS);
+
+  if (EFI_ERROR (Status)) {
+goto UNINSTALL_PROTOCOL;
+  }
+
   //
   // Initialize the IP4 ID
   //
   mIp4Id = (UINT16)NET_RANDOM (NetRandomInitSeed ());
 
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index ac48ad2..b5cd7b7 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -1,8 +1,8 @@
 /** @file
 
-Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -2247,22 +2247,14 @@ Ip4SentPacketTicking (
   }
 
   return EFI_SUCCESS;
 }
 
-
 /**
-  There are two steps for this the heart beat timer of IP4 service instance. 
-  First, it times out all of its IP4 children's received-but-not-delivered 
-  and transmitted-but-not-recycle packets, and provides time input for its 
-  IGMP protocol.
-  Second, a dedicated timer is used to poll underlying media status. In case 
-  of cable swap, a new round auto configuration will be initiated. The timer 
-  will signal the IP4 to run DHCP configuration again. IP4 driver will free
-  old IP address related resource, such as route table and Interface, then
-  initiate a DHCP process to acquire new IP, eventually create route table 
-  for new IP address.
+  This heart beat timer of IP4 service instance times out all of its IP4 
children's 
+  received-but-not-delivered and transmitted-but-not-recycle packets, and 
provides 
+  time input for its IGMP protocol.
 
   @param[in]  Event  The IP4 service instance's heart beat 
timer.
   @param[in]  ContextThe IP4 service instance.
 
 **/

Re: [edk2] [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds

2018-01-11 Thread Ard Biesheuvel
On 10 January 2018 at 16:26, Pete Batard  wrote:
> Introduce CRT assembly replacements for __rt_sdiv, __rt_udiv,
> __rt_udiv64, __rt_sdiv64, __rt_srsh (by reusing the RVCT code)
> as well as memcpy and memset.
> For MSFT compatibility, some of the code needs to be explicitly
> forced to ARM, and the /oldit assembly flag needs to be added.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Pete Batard 

This looks fine to me but I haven't been able to test it.

Reviewed-by: Ard Biesheuvel 

Eugene: any comments regarding the changes to RVCT code?


> ---
>  ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm   | 43 
> +---
>  ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm   | 40 
> +-
>  ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm  | 22 
> +-
>  ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29 
> +++--
>  ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16 +++-
>  ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c   | 34 
> 
>  ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c   | 33 
> +++
>  7 files changed, 185 insertions(+), 32 deletions(-)
>
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm 
> b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> index b539e516892d..f9e0107395f2 100644
> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> @@ -1,6 +1,7 @@
>  
> //--
>  //
>  // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> +// Copyright (c) 2018, Pete Batard. All rights reserved.
>  //
>  // This program and the accompanying materials
>  // are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -17,18 +18,19 @@
>  EXPORT  __aeabi_uidivmod
>  EXPORT  __aeabi_idiv
>  EXPORT  __aeabi_idivmod
> +EXPORT  __rt_udiv
> +EXPORT  __rt_sdiv
>
>  AREA  Math, CODE, READONLY
>
>  ;
>  ;UINT32
>  ;EFIAPI
> -;__aeabi_uidivmode (
> -;  IN UINT32  Dividen
> +;__aeabi_uidivmod (
> +;  IN UINT32  Dividend
>  ;  IN UINT32  Divisor
>  ;  );
>  ;
> -
>  __aeabi_uidiv
>  __aeabi_uidivmod
>  RSBSr12, r1, r0, LSR #4
> @@ -40,10 +42,40 @@ __aeabi_uidivmod
>  B   __arm_div_large
>
>  ;
> +;UINT64
> +;EFIAPI
> +;__rt_udiv (
> +;  IN UINT32  Divisor,
> +;  IN UINT32  Dividend
> +;  );
> +;
> +__rt_udiv
> +; Swap R0 and R1
> +MOV r12, r0
> +MOV r0, r1
> +MOV r1, r12
> +B   __aeabi_uidivmod
> +
> +;
> +;UINT64
> +;EFIAPI
> +;__rt_sdiv (
> +;  IN INT32  Divisor,
> +;  IN INT32  Dividend
> +;  );
> +;
> +__rt_sdiv
> +; Swap R0 and R1
> +MOV r12, r0
> +MOV r0, r1
> +MOV r1, r12
> +B   __aeabi_idivmod
> +
> +;
>  ;INT32
>  ;EFIAPI
> -;__aeabi_idivmode (
> -;  IN INT32  Dividen
> +;__aeabi_idivmod (
> +;  IN INT32  Dividend
>  ;  IN INT32  Divisor
>  ;  );
>  ;
> @@ -152,4 +184,3 @@ __aeabi_idiv0
>  BX  r14
>
>  END
> -
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm 
> b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> index c71bd59e4520..3794cac35eed 100644
> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> @@ -1,6 +1,7 @@
>  
> //--
>  //
>  // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> +// Copyright (c) 2018, Pete Batard. All rights reserved.
>  //
>  // This program and the accompanying materials
>  // are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -13,20 +14,41 @@
>  
> //--
>
>
> -EXTERN  __aeabi_uldivmod
> +IMPORT  __aeabi_uldivmod
> +EXPORT  __aeabi_ldivmod
> +EXPORT  __rt_sdiv64
>
> -INCLUDE AsmMacroExport.inc
> +AREA  Math, CODE, READONLY, ARM
> +
> +ARM
>
>  ;
> -;UINT32
> +;INT64
>  ;EFIAPI
> -;__aeabi_uidivmode (
> -;  IN UINT32  Dividen
> -;  IN UINT32  Divisor
> +;__rt_sdiv64 (
> +;  IN  INT64  Divisor
> +;  IN  INT64  Dividend
>  ;  );
>  ;
> +__rt_sdiv64
> +; Swap r0-r1 and r2-r3
> +MOV r12, r0
> +MOV r0, r2
> +MOV r2, r12
> +MOV r12, r1
> +MOV r1, r3
> +MOV r3, r12
> +B   __aeabi_ldivmod
>
> - RVCT_ASM_EXPORT __aeabi_ldivmod
> +;
> +;INT64
> +;EFIAPI
> +;__aeabi_ldivmod (
> +;  IN  INT64  Dividend
> +;  IN  INT64  Divisor
> +;  );
> +;
> +__aeabi_ldivmod
>  PUSH {r4,lr}
>  ASRS r4,r1,#1
>  EOR  r4,r4,r3,LSR #1
> @@ -39,7 +61,7 @@ L_Test1
>  RSBS r2,r2,#0
>  RSC  r3,r3,#0
>  L_Test2
> -BL   __aeabi_uldivmod  ;

[edk2] help

2018-01-11 Thread 赵彦峰
build...
 : error C0DE: Unknown fatal error when processing [c:\edk2\Nt32Pkg\Nt32Pkg.dsc]


(Please send email to edk2-devel@lists.01.org for help, attaching following 
call stack trace!)


(Python 2.7.3 on win32) Traceback (most recent call last):
  File "build\build.py", line 2477, in Main
  File "build\build.py", line 2211, in Launch
  File "build\build.py", line 1986, in _MultiThreadBuildPlatform
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\AutoGen\AutoGen.py",
 line 184, in __new__
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\AutoGen\AutoGen.py",
 line 497, in _Init
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\DscBuildData.py",
 line 888, in _GetPcds
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\DscBuildData.py",
 line 1156, in _GetPcd
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\DscBuildData.py",
 line 803, in _ValidatePcd
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceCommon.py",
 line 49, in GetDeclaredPcd
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceCommon.py",
 line 34, in GetPackageList
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceCommon.py",
 line 81, in GetLiabraryInstances
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceCommon.py",
 line 126, in _GetModuleLibraryInstances
  File 
"c:\Users\Public\Documents\BuildPool\BaseTools\build\Source\Python\Workspace\WorkspaceDatabase.py",
 line 108, in __getitem__
AttributeError: 'str' object has no attribute 'Type'



- Failed -
Build end time: 13:41:05, Jan.11 2018
Build total time: 00:00:04
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().

2018-01-11 Thread Wang, Fan
Thanks, Jiaxin, I will revise it.

Best Regards
Fan

-Original Message-
From: Wu, Jiaxin 
Sent: Thursday, January 11, 2018 3:48 PM
To: Wang, Fan ; edk2-devel@lists.01.org
Cc: Fu, Siyuan ; Wu, Hao A 
Subject: RE: [Patch] MdeModulePkg/DxeNetLib: Add array range check in 
NetIp6IsNetEqual().

Hi Fan,

I think we need to update the below ASSERT if apply you patch:

ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength <= 
IP6_PREFIX_MAX));

Update To: 

ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength < 
IP6_PREFIX_MAX));


If PrefixLength is IP6_PREFIX_MAX(128), then the Byte can be 16:

Byte = (UINT8) (PrefixLength / 8);

So, it will conflict with your patch ASSERT:

ASSERT (Byte < 16);

Thanks,
Jiaxin

> -Original Message-
> From: Wang, Fan
> Sent: Thursday, January 11, 2018 10:39 AM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan ; Wu, Jiaxin 
> ; Wu, Hao A 
> Subject: [Patch] MdeModulePkg/DxeNetLib: Add array range check in 
> NetIp6IsNetEqual().
> 
> * The library API use array elements without any index range check, this
>   patch is to fix this issue to avoid null pointer reference.
> 
> Cc: Fu Siyuan 
> Cc: Jiaxin Wu 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan 
> ---
>  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> index cbce28f..34e11a8 100644
> --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> @@ -840,10 +840,14 @@ NetIp6IsNetEqual (
>}
> 
>if (Bit > 0) {
>  Mask = (UINT8) (0xFF << (8 - Bit));
> 
> +ASSERT (Byte < 16);
> +if (Byte >= 16) {
> +  return FALSE;
> +}
>  if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
>return FALSE;
>  }
>}
> 
> --
> 1.9.5.msysgit.1

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


[edk2] [Patch] Edk2: Retire Edk2Setup.bat

2018-01-11 Thread Liming Gao
Edk2Setup.bat is out of maintain. It is a draft version batch file, and not
implement all features listed in its header file. To avoid the confuse,
drop it from edk2 project, and keep edksetup.bat only.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 Edk2Setup.bat | 541 --
 1 file changed, 541 deletions(-)
 delete mode 100755 Edk2Setup.bat

diff --git a/Edk2Setup.bat b/Edk2Setup.bat
deleted file mode 100755
index 017e88d..000
--- a/Edk2Setup.bat
+++ /dev/null
@@ -1,541 +0,0 @@
-@REM @file
-@REM Windows batch file, Edk2Setup.bat, to set up an EDK II build environment
-@REM
-@REM This script will be renamed to edksetup.bat after initial testing and
-@REM acceptance by the open source community.
-@REM
-@REM This script will set the following system environment variables:
-@REM   WORKSPACE, EDK_TOOLS_PATH, PATH
-@REM If rebuilding the tools:
-@REM   BASE_TOOLS_PATH, PYTHON_FREEZER_PATH, PYTHONPATH
-@REM It will also create a Conf/target.txt, tools_def.txt and build_rule.txt 
files
-@REM if they do not exist
-@REM If the reset flag is set, all environment variables will be reset and 
-@REM the Conf/target.txt, tools_def.txt and build_rule.txt files will be 
overwritten
-@REM
-@REM Three other scripts, located in the BaseTools\Scripts directory, may be 
called
-@REM by this script.
-@REM SetVisualStudio.bat- will set the Visual Studio environment based on 
the --vs* flags
-@REM  it is also used to build the Win32 binaries, 
calling nmake 
-@REM  using the WORKSPACE\BaseTools\Makefile
-@REM ShowEnvironment.bat- will display the current EDK II Build environment
-@REM UpdateBuildVersions.py - script is called prior to building the EDK II 
BaseTools from
-@REM  Sources. This tool will modify the 
BuildVersion.* files so that
-@REM  when the tools get built, they will have a 
custom version entry
-@REM  similar to the following:
-@REM e:\edk2>build --version
-@REM build.exe Version 0.51 Developer Build based on Revision: 15668
-@REM
-@REM Copyright (c) 2014, Intel Corporation. All rights reserved.
-@REM (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-@REM This program and the accompanying materials
-@REM are licensed and made available under the terms and conditions of the BSD 
License
-@REM which accompanies this distribution.  The full text of the license may be 
found at
-@REM http://opensource.org/licenses/bsd-license.php
-@REM
-@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
-@REM
-@REM
-@REM usage:
-@REM   Edk2Setup.bat [--help | -h] [-v | --version] [-r | --reset] 
-@REM [--reconfig] [--edk-tools-path DirName]
-@REM [--pull [Directory]| --rebuild [Directory]]
-@REM [--nt32 [X64]]
-
-@REM ##
-@REM # You should not have to modify anything below this line
-@REM #
-@echo off
-@set SCRIPT_NAME=%0
-@set SCRIPT_VERSION=0.9.2.
-@set SVN_REVISION=$Revision$
-@set RESET_ENVIRONMENT=FALSE
-@set NT32PKG=FALSE
-@set NT32_X64=
-@set BUILD_TOOLS_WITH=
-@set LOCATION=
-@set REBUILD_TOOLS=
-@set SVN_PULL=
-@set SRC_CONF=
-@set ARGUMENT=
-@set SCRIPT=EDKSETUP_BAT
-@set PYTHON_BUILD=
-
-@if not defined ORIGINAL_PATH set "ORIGINAL_PATH=%PATH%"
-@REM Always set the WORKSPACE environment variable to the current directory
-@if not defined WORKSPACE (
-  @set "WORKSPACE=%CD%"
-)
-@if not exist "%BASE_TOOLS_PATH%" (
-  @if exist "%WORKSPACE%\BaseTools" (
-set "BASE_TOOLS_PATH=%WORKSPACE%\BaseTools"
-  ) else (
-@if defined PACKAGES_PATH (
-  @for %%i IN (%PACKAGES_PATH%) DO (
-@if exist %%~fi\BaseTools (
-  @set BASE_TOOLS_PATH=%%~fi\BaseTools
-  @goto checkBaseTools
-)
-  )
-)
-  )
-)
-:checkBaseTools
-@if not defined BASE_TOOLS_PATH (
-  @echo.
-  @echo !!! ERROR !!! The BaseTools Package was not found !!!
-  @echo.
-  @goto ExitFailure
-)
-@if not exist "%WORKSPACE%\Conf" @mkdir "%WORKSPACE%\Conf"
-
-@@if not defined EDK_TOOLS_PATH @set "EDK_TOOLS_PATH=%BASE_TOOLS_PATH%"
-
-@REM Keep the existing EDK_TOOLS_PATH value, the --reset flag will set it
-@REM back to WORKSPACE\BaseTools while the --location DIRECTORY flag will
-@REM still take precedence if the location option follows the reset option
-@REM on the command line.
-@if defined EDK_TOOLS_PATH @set "LOCATION=%EDK_TOOLS_PATH%"
-
-:parse_cmd_line
-@if "%1"=="" @goto MainRoutine
-@if /I "%1"=="-h" @goto Usage
-@if /I "%1"=="--help" @goto Usage
-@if /I "%1"=="/?" @goto Usage
-@if /I "%1"=="--version" @goto Version
-
-@REM These options will reset the system environment
-@if /I "%1"=="-r" (
-@setlocal EnableDelayedExpansion
-@set 

Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement GetElapsedTime function of TimerLib

2018-01-11 Thread Laszlo Ersek
On 01/11/18 07:28, Pankaj Bansal wrote:
> Hi Laszlo,
> 
>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Wednesday, January 10, 2018 10:34 PM
>> To: Pankaj Bansal ; edk2-devel@lists.01.org
>> Cc: Leif Lindholm ; Ard Biesheuvel
>> ; Michael Kinney 
>> Subject: Re: [edk2] [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement
>> GetElapsedTime function of TimerLib

>> (1) Please feel free to pick up my code and work on upstreaming it -- just
>> please preserve my S-o-b on the patch(es) (in addition to yours), and the Red
>> Hat copyright notice (in addition to your company's) in the new files.
>>
>> (2) Last time I counted (reading up on the original thread), there were
>> 21 TimerLib instances in edk2. Adding the same function to every one of
>> them looks terrible. In edk2, I know of only two ways to avoid this:
>>
>> - introduce a new library class (with class header file), and a simple 
>> library
>> instance (implementation)
>>
>> - collect (=move) as many as possible of the existing library instances under
>> common subdirectories, so that their INF files are basically in the same
>> subdirectory. Then the new code can be implemented in a new C file, under
>> the same subdirectory, and then all INF files can refer to the new C file
>> directly. This kind of code sharing works very well if the library instances 
>> are
>> otherwise closely related. It does not work at all if the library instances 
>> live in
>> separate top-level packages (which is BTW the case here).
>>
>>
>> It seems that Mike wasn't opposed to introducing a TimerTickDiffLib class (or
>> something similar) to MdePkg. However, more work looked necessary than I
>> had expected, esp. with regard to the caching of timer hardware
>> characteristics (please see the last few messages in the thread
>> -- either the code has to add its own caching, or all existing, suitable 
>> TimerLib
>> instances have to be verified about caching). Again, please feel free to pick
>> up the code and rework it as Mike suggests -- it's basically the
>> GetTickDifference() function only that adds value. Feel free to hammer it 
>> into
>> any shape or form necessary.
> 
> Thank you. I will try to work on this problem of integrating these changes in 
> multiple
> TimerLib instances, when I have some room on my plate.
> For now, I guess I will just add wrapper functions on top of TimerLib APIs 
> for my Platform only.

Sure, that works as well -- feel free to scavenge the code as you see fit.

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


Re: [edk2] [PATCH] UefiCpuPkg/MpInitLib: fix 32-bit build error

2018-01-11 Thread Laszlo Ersek
On 01/11/18 02:02, Jian J Wang wrote:
> Cc: Dandan Bi 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
> b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> index e832c16eca..d2bcef53d6 100644
> --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> @@ -326,7 +326,7 @@ InitMpGlobalData (
>  CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
>  for (Index = 0; Index < CpuMpData->CpuCount; ++Index) {
>if (CpuInfoInHob != NULL && CpuInfoInHob[Index].ApTopOfStack != 0) {
> -StackBase = CpuInfoInHob[Index].ApTopOfStack - 
> CpuMpData->CpuApStackSize;
> +StackBase = (UINTN)CpuInfoInHob[Index].ApTopOfStack - 
> CpuMpData->CpuApStackSize;
>} else {
>  StackBase = CpuMpData->Buffer + Index * CpuMpData->CpuApStackSize;
>}
> 

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


[edk2] [Patch] NetworkPkg: Fix incorrect parameter check in PXE.Mtftp() function.

2018-01-11 Thread Fu Siyuan
According to UEFI spec, the PXE.Mtftp() should return invalid parameter if the
BufferPtr parameter was NULL and the DontUseBuffer parameter was FALSE.
The DontUseBuffer is only used when perform MTFTP/TFTP read operation.

Cc: Ye Ting 
Cc: Wu Jiaxin 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index 93f3bfa5ba..9068e0686c 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -855,11 +855,19 @@ EfiPxeBcMtftp (
   (Filename == NULL) ||
   (BufferSize == NULL) ||
   (ServerIp == NULL) ||
-  ((BufferPtr == NULL) && DontUseBuffer) ||
   ((BlockSize != NULL) && (*BlockSize < PXE_MTFTP_DEFAULT_BLOCK_SIZE))) {
 return EFI_INVALID_PARAMETER;
   }
 
+  if (Operation == EFI_PXE_BASE_CODE_TFTP_READ_FILE ||
+  Operation == EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY ||
+  Operation == EFI_PXE_BASE_CODE_MTFTP_READ_FILE ||
+  Operation == EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY) {
+if (BufferPtr == NULL && !DontUseBuffer) {
+  return EFI_INVALID_PARAMETER;
+}
+  }
+
   Config= NULL;
   Status= EFI_DEVICE_ERROR;
   Private   = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
-- 
2.13.0.windows.1

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


Re: [edk2] [RFC] SATA : Implemented NXP errata A008402

2018-01-11 Thread Ard Biesheuvel
On 11 January 2018 at 02:25, Ni, Ruiyu  wrote:
> On 1/10/2018 5:52 PM, Ard Biesheuvel wrote:
>>
>> On 10 January 2018 at 09:43, Udit Kumar  wrote:
>>>
>>> Hi Ruiyu,
>>>
 -Original Message-
>
>
> And this change will not impact any other hardware so no one is
> basically

 impacted by this change.

 Your buggy HW only need the value zero. But the addition of PCD exposes
 an interface that can use any size of PRD.
 I am not sure the AtaAtapiPassThru can work if some platform sets the
 PCD
 value to others than 0 or 3F_h.
>>>
>>>
>>> I don't see someone using this driver will set Pcd randomly, but I agree
>>> on this
>>> point other value should be handled.
>>> Error or Assert could be added, if Pcd value is not 0 or 3F_h.
>>>
 Can you please
just duplicate the AtaAtapiPassThru in your platform?
 Because the driver is very stable today, not much code sync effort will
 be
 needed if core version is changed.
>>>
>>>
>>> Duplicating is always a possibility :), but When we will push this
>>> duplicated driver
>>> (just for one line change) for upstreaming.
>>> will this be acceptable ??
>>
>>
>> My main concern with this (and with using a PCD) is that the setting
>> affects all SATA controllers in the system, including ones the you
>> stick into a PCIe slot.
>>
>> So I think forking the driver is the only possible solution, but it
>> will not be a one-line change: you need to ensure that you apply the
>> workaround only to the SATA controllers in the SoC.
>>
>
> Depending on the new driver's location. The package owner decides
> whether forking is acceptable :)
>

I think forking is reasonable in this case: the workaround does not
belong in generic code, and it seems only early silicon is affected
anyway.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/2] BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature

2018-01-11 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Feng, YunhuaX 
Sent: Tuesday, January 09, 2018 6:38 PM
To: edk2-devel@lists.01.org
Cc: Feng, YunhuaX ; Zhu, Yonghong 
; Gao, Liming 
Subject: [PATCH 1/2] BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature

when set 'MAX_CONCURRENT_THREAD_NUMBER=0',  will auto-detect number of 
processor threads for MAX_CONCURRENT_THREAD_NUMBER

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/Python/build/build.py | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git BaseTools/Source/Python/build/build.py 
BaseTools/Source/Python/build/build.py
index 38498046d7..de19756d99 100644
--- BaseTools/Source/Python/build/build.py
+++ BaseTools/Source/Python/build/build.py
@@ -2,7 +2,7 @@
 # build a platform or a module
 #
 #  Copyright (c) 2014, Hewlett-Packard Development Company, L.P. -#  
Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights 
+reserved.
 #
 #  This program and the accompanying materials  #  are licensed and made 
available under the terms and conditions of the BSD License @@ -26,6 +26,7 @@ 
import platform  import traceback  import encodings.ascii  import itertools
+import multiprocessing
 
 from struct import *
 from threading import *
@@ -936,7 +937,10 @@ class Build():
 self.ThreadNumber = int(self.ThreadNumber, 0)
 
 if self.ThreadNumber == 0:
-self.ThreadNumber = 1
+try:
+self.ThreadNumber = multiprocessing.cpu_count()
+except (ImportError, NotImplementedError):
+self.ThreadNumber = 1
 
 if not self.PlatformFile:
 PlatformFile = 
self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM]
--
2.12.2.windows.2

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


[edk2] [PATCH v2 5/7] UefiCpuPkg: Update SmmCpuFeatureLib pass XCODE5 tool chain

2018-01-11 Thread Liming Gao
In V2, use "mov rax, strict qword 0" to replace the hard code db.

1. Use lea instruction to get the address instead of mov instruction.
2. Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Jiewen Yao 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Michael Kinney 
---
 .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm   |  6 +++-
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c  |  8 +++--
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h  | 11 +-
 .../Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm| 39 ++
 .../SmmCpuFeaturesLib/X64/SmiException.nasm| 10 +++---
 5 files changed, 52 insertions(+), 22 deletions(-)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
index 00c0f067..057ec6d 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD 
License
 ; which accompanies this distribution.  The full text of the license may be 
found at
@@ -273,3 +273,7 @@ _StmSmiHandler:
 
 ASM_PFX(gcStmSmiHandlerSize)   : DW$ - _StmSmiEntryPoint
 ASM_PFX(gcStmSmiHandlerOffset) : DW_StmSmiHandler - _StmSmiEntryPoint
+
+global ASM_PFX(SmmCpuFeaturesLibStmSmiEntryFixupAddress)
+ASM_PFX(SmmCpuFeaturesLibStmSmiEntryFixupAddress):
+ret
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
index 45015b8..8dc2d70 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
@@ -1,7 +1,7 @@
 /** @file
   SMM STM support functions
 
-  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -116,7 +116,6 @@ UINTN  mMsegSize = 0;
 
 BOOLEAN  mStmConfigurationTableInitialized = FALSE;
 
-
 /**
   The constructor function
 
@@ -139,6 +138,11 @@ SmmCpuFeaturesLibStmConstructor (
   EFI_SMRAM_DESCRIPTOR*SmramDescriptor;
 
   //
+  // Initialize address fixup
+  //
+  SmmCpuFeaturesLibStmSmiEntryFixupAddress ();
+
+  //
   // Call the common constructor function
   //
   Status = SmmCpuFeaturesLibConstructor (ImageHandle, SystemTable);
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h
index 92a4dc0..c98b660 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h
@@ -1,7 +1,7 @@
 /** @file
   SMM STM support
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -173,4 +173,13 @@ GetStmResource (
   VOID
   );
 
+/**
+  This function fixes up the address of the global variable or function
+  referred in SmiEntry assembly files to be the absoute address.
+**/
+VOID
+EFIAPI
+SmmCpuFeaturesLibStmSmiEntryFixupAddress (
+ );
+
 #endif
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm
index ea2d297..90a9fd4 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD 
License
 ; which accompanies this distribution.  The full text of the license may be 
found at
@@ -164,7 +164,8 @@ Base:
 mov cr0, rbx
 retf
 @LongMode:  ; long mode (64-bit code) starts here
-mov rax, ASM_PFX(gStmSmiHandlerIdtr)
+mov rax, strict qword 0   

[edk2] [PATCH v2 4/7] UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain

2018-01-11 Thread Liming Gao
In V2, use mov rax, strict qword 0 to replace the hard code db.

Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Jiewen Yao 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Michael Kinney 
---
 .../X64/ExceptionHandlerAsm.nasm   | 27 --
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index ba8993d..7b97810 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
+; Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD 
License
 ; which accompanies this distribution.  The full text of the license may be 
found at
@@ -40,7 +40,7 @@ AsmIdtVectorBegin:
 db  0x6a; push  #VectorNum
 db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 
32) ; VectorNum
 pushrax
-mov rax, ASM_PFX(CommonInterruptEntry)
+mov rax, strict qword 0 ;mov rax, ASM_PFX(CommonInterruptEntry)
 jmp rax
 %endrep
 AsmIdtVectorEnd:
@@ -50,7 +50,8 @@ HookAfterStubHeaderBegin:
 @VectorNum:
 db  0  ; 0 will be fixed
 pushrax
-mov rax, HookAfterStubHeaderEnd
+mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd
+JmpAbsoluteAddress:
 jmp rax
 HookAfterStubHeaderEnd:
 mov rax, rsp
@@ -260,8 +261,7 @@ HasErrorCode:
 ; and make sure RSP is 16-byte aligned
 ;
 sub rsp, 4 * 8 + 8
-mov rax, ASM_PFX(CommonExceptionHandler)
-callrax
+callASM_PFX(CommonExceptionHandler)
 add rsp, 4 * 8 + 8
 
 cli
@@ -369,11 +369,24 @@ DoIret:
 ; comments here for definition of address map
 global ASM_PFX(AsmGetTemplateAddressMap)
 ASM_PFX(AsmGetTemplateAddressMap):
-mov rax, AsmIdtVectorBegin
+lea rax, [AsmIdtVectorBegin]
 mov qword [rcx], rax
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-mov rax, HookAfterStubHeaderBegin
+lea rax, [HookAfterStubHeaderBegin]
 mov qword [rcx + 0x10], rax
+
+; Fix up CommonInterruptEntry address
+learax, [ASM_PFX(CommonInterruptEntry)]
+learcx, [AsmIdtVectorBegin]
+%rep  32
+movqword [rcx + (JmpAbsoluteAddress - 8 - HookAfterStubHeaderBegin)], 
rax
+addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
+%endrep
+; Fix up HookAfterStubHeaderEnd
+learax, [HookAfterStubHeaderEnd]
+learcx, [JmpAbsoluteAddress]
+movqword [rcx - 8], rax
+
 ret
 
 
;-
-- 
2.8.0.windows.1

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


[edk2] [PATCH v2 6/7] UefiCpuPkg: Update PiSmmCpuDxeSmm pass XCODE5 tool chain

2018-01-11 Thread Liming Gao
In V2, use "mov rax, strict qword 0" to replace the hard code db.

1. Use lea instruction to get the address instead of mov instruction.
2. Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.
3. On MpFuncs.nasm, use ExchangeInfo to record InitializeFloatingPointUnits.
This way is same to MpInitLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Andrew Fish 
Cc: Jiewen Yao 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Michael Kinney 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c   |  6 -
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm|  5 -
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm |  6 -
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c  |  8 ++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h  | 20 -
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm  |  9 
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm | 30 -
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm |  4 ++--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm  | 17 +++---
 9 files changed, 80 insertions(+), 25 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 94e5ab2..5546295 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -1,7 +1,7 @@
 /** @file
 Code for Processor S3 restoration
 
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #include "PiSmmCpuDxeSmm.h"
 
+#pragma pack(1)
 typedef struct {
   UINTN Lock;
   VOID  *StackStart;
@@ -23,7 +24,9 @@ typedef struct {
   IA32_DESCRIPTOR   IdtrProfile;
   UINT32BufferStart;
   UINT32Cr3;
+  UINTN InitializeFloatingPointUnitsAddress;
 } MP_CPU_EXCHANGE_INFO;
+#pragma pack()
 
 typedef struct {
   UINT8 *RendezvousFunnelAddress;
@@ -456,6 +459,7 @@ PrepareApStartupVector (
   mExchangeInfo->StackSize   = mAcpiCpuData.StackSize;
   mExchangeInfo->BufferStart = (UINT32) StartupVector;
   mExchangeInfo->Cr3 = (UINT32) (AsmReadCr3 ());
+  mExchangeInfo->InitializeFloatingPointUnitsAddress = 
(UINTN)InitializeFloatingPointUnits;
 }
 
 /**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
index 4d2383f..a8324a7 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD 
License
 ; which accompanies this distribution.  The full text of the license may be 
found at
@@ -207,3 +207,6 @@ ASM_PFX(SmiHandler):
 
 ASM_PFX(gcSmiHandlerSize): DW $ - _SmiEntryPoint
 
+global ASM_PFX(PiSmmCpuSmiEntryFixupAddress)
+ASM_PFX(PiSmmCpuSmiEntryFixupAddress):
+ret
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm
index d9df362..a5c62e7 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD 
License
 ; which accompanies this distribution.  The full text of the license may be 
found at
@@ -85,3 +85,7 @@ ASM_PFX(SmmRelocationSemaphoreComplete):
 mov byte [eax], 1
 pop eax
 jmp [ASM_PFX(mSmmRelocationOriginalAddress)]
+
+global ASM_PFX(PiSmmCpuSmmInitFixupAddress)
+ASM_PFX(PiSmmCpuSmmInitFixupAddress):
+ret
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index 4b66a0d..a27d1f4 100755
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -1,7 +1,7 @@
 /** @file
 Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU.
 
-Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2018, 

Re: [edk2] [Patch 0/7] EDK2: Enable XCODE5 tool chain with NASM source

2018-01-11 Thread Laszlo Ersek
On 01/11/18 10:54, Laszlo Ersek wrote:
> Liming,
> 
> On 01/10/18 16:24, Liming Gao wrote:
>> 1. Use nasm source file for X86 tool chain, then ASM and S file can be 
>> removed.
>> 2. Update Nasm source file to resolve the absolute addressing.
>> 3. Verify OVMF IA32, IA32X64 and X64 boot to shell functionality with XCODE5
>>Here is build command.
>>build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE 
>>-DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
>>build -p OvmfPkg\OvmfPkgIa32.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE 
>>-DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
>>build -p OvmfPkg\OvmfPkgX64.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE 
>>-DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
>> 4. Known limitation is XCODE5 doesn't support HII resource section 
>> generation. 
>>So, new UEFI shell application tftp can't be used. Old shell is used.
> 
> After sleeping on this, I got a question: is there a public bug report
> in the clang / llvm bug tracker about this shortcoming? It would be nice
> to reference it in the commit messages.
> 
> The main reason I'm asking this is because these workarounds include
> more and more DB / DW / DD / DQ mnemonics in the NASM source files. One
> of the original promises of NASM was that we could cut down on the
> binary representation of x86 instructions, just write real assembly
> code. This was in part enabled by NASM supporting multi-mode assembly
> files, such that mode transitions (e.g. from real mode to protected mode
> to long mode) could still be implemented in a human-readable assembly file.
> 
> So this workaround is a step back in that regard (i.e., for readability
> and future updates). I agree we are sometimes forced to do such things
> to support all the toolchains we target, but it would be nice to have
> proof that the clang / llvm developers *intend* to fix this (possibly in
> the next major release of XCODE -- I'm not sure). So a public bug report
> that we could reference in the commit messages would be great.

Nevermind, I just read Mike's comments and the new approach; it's much
better!

(Still, if we have an XCODE bug report, it would be nice to reference
that in the commit messages.)

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


Re: [edk2] [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds

2018-01-11 Thread Cohen, Eugene

> > Introduce CRT assembly replacements for __rt_sdiv, __rt_udiv,
> > __rt_udiv64, __rt_sdiv64, __rt_srsh (by reusing the RVCT code) as well
> > as memcpy and memset.
> > For MSFT compatibility, some of the code needs to be explicitly forced
> > to ARM, and the /oldit assembly flag needs to be added.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Pete Batard 
> 
> This looks fine to me but I haven't been able to test it.
> 
> Reviewed-by: Ard Biesheuvel 
> 
> Eugene: any comments regarding the changes to RVCT code?

I've been away in Linux land for a while, it's nice that the day I catch up on 
my edk2-devel backlog I see my name! :)

One concern for RVCT is that every function is in its own section to enable 
proper dead code removal.  This is addressed with this macro:

  MACRO
  RVCT_ASM_EXPORT $func
EXPORT  $func
AREA s_$func, CODE, READONLY
$func
  MEND

note the AREA directive - this makes a section per function.

Pete's patchset removes these macros which breaks dead code removal.

Please restore these macros for at least RVCT and please verify that the VS2017 
path does appropriate dead code removal for these assembly functions.

Thanks!

Eugene

> 
> 
> > ---
> >  ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm   | 43
> +---
> >  ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm   | 40
> +-
> >  ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm  | 22 
> > +
> -
> >  ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29
> +++--
> >  ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16
> +++-
> >  ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c   | 34
> 
> >  ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c   | 33
> +++
> >  7 files changed, 185 insertions(+), 32 deletions(-)
> >
> > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> > b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> > index b539e516892d..f9e0107395f2 100644
> > --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> > @@ -1,6 +1,7 @@
> >
> > //
> > --
> >  //
> >  // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > +// Copyright (c) 2018, Pete Batard. All rights reserved.
> >  //
> >  // This program and the accompanying materials  // are licensed and
> > made available under the terms and conditions of the BSD License @@
> > -17,18 +18,19 @@
> >  EXPORT  __aeabi_uidivmod
> >  EXPORT  __aeabi_idiv
> >  EXPORT  __aeabi_idivmod
> > +EXPORT  __rt_udiv
> > +EXPORT  __rt_sdiv
> >
> >  AREA  Math, CODE, READONLY
> >
> >  ;
> >  ;UINT32
> >  ;EFIAPI
> > -;__aeabi_uidivmode (
> > -;  IN UINT32  Dividen
> > +;__aeabi_uidivmod (
> > +;  IN UINT32  Dividend
> >  ;  IN UINT32  Divisor
> >  ;  );
> >  ;
> > -
> >  __aeabi_uidiv
> >  __aeabi_uidivmod
> >  RSBSr12, r1, r0, LSR #4
> > @@ -40,10 +42,40 @@ __aeabi_uidivmod
> >  B   __arm_div_large
> >
> >  ;
> > +;UINT64
> > +;EFIAPI
> > +;__rt_udiv (
> > +;  IN UINT32  Divisor,
> > +;  IN UINT32  Dividend
> > +;  );
> > +;
> > +__rt_udiv
> > +; Swap R0 and R1
> > +MOV r12, r0
> > +MOV r0, r1
> > +MOV r1, r12
> > +B   __aeabi_uidivmod
> > +
> > +;
> > +;UINT64
> > +;EFIAPI
> > +;__rt_sdiv (
> > +;  IN INT32  Divisor,
> > +;  IN INT32  Dividend
> > +;  );
> > +;
> > +__rt_sdiv
> > +; Swap R0 and R1
> > +MOV r12, r0
> > +MOV r0, r1
> > +MOV r1, r12
> > +B   __aeabi_idivmod
> > +
> > +;
> >  ;INT32
> >  ;EFIAPI
> > -;__aeabi_idivmode (
> > -;  IN INT32  Dividen
> > +;__aeabi_idivmod (
> > +;  IN INT32  Dividend
> >  ;  IN INT32  Divisor
> >  ;  );
> >  ;
> > @@ -152,4 +184,3 @@ __aeabi_idiv0
> >  BX  r14
> >
> >  END
> > -
> > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> > b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> > index c71bd59e4520..3794cac35eed 100644
> > --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> > @@ -1,6 +1,7 @@
> >
> > //
> > --
> >  //
> >  // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > +// Copyright (c) 2018, Pete Batard. All rights reserved.
> >  //
> >  // This program and the accompanying materials  // are licensed and
> > made available under the terms and conditions of the BSD License @@
> > -13,20 +14,41 @@
> >
> > //
> > --
> >
> >
> > -EXTERN  __aeabi_uldivmod
> > +IMPORT  __aeabi_uldivmod
> > +EXPORT  __aeabi_ldivmod
> > +EXPORT  __rt_sdiv64
> >

Re: [edk2] [PATCH] OvmfPkg/VirtioScsiDxe: Allocate all required vrings at VirtioScsiInit

2018-01-11 Thread Maxime Coquelin



On 01/11/2018 02:23 PM, Maxime Coquelin wrote:

Hi Xiang,

On 12/14/2017 02:25 PM, zhengxiang (A) wrote:



On 2017/12/14 17:06, Paolo Bonzini wrote:

On 14/12/2017 07:55, zhengxiang (A) wrote:

Hello Laszlo and Paolo,

Thanks for your review!

On 2017/12/13 19:16, Laszlo Ersek wrote:

On 12/13/17 10:29, Paolo Bonzini wrote:

On 13/12/2017 09:35, Laszlo Ersek wrote:

Perhaps you can update vhost-scsi similarly to the last patch of
Maxime's v4 series, even without "VIRTIO_SCSI_F_MQ" -- in the
SET_FEATURES request handler, just destroy the unused virtqueues 
that

have not been configured by the guest driver until that time?
Yes, this is the right solution.  We can assume that if the 
descriptor
address is equal to zero, the queue is not in use.  This is not in 
the

spec as far as I can see, but it is QEMU's assumption.  I will send a
patch to the virtio specification.


I would try this solution! However, is there any possibility that 
the allocated

descriptor address is exactly equal to zero and the queue is in use?


That would break QEMU's virtio implementation, so it's pretty unlikely.

Paolo



So could I judge the not-in-use queues by adding the below sentence in 
order

to skip calling vhost_virtqueue_start?

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e4290ce..05c3322 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1532,6 +1532,7 @@ int vhost_dev_start(struct vhost_dev *hdev, 
VirtIODevice *vdev)

  goto fail_mem;
  }
  for (i = 0; i < hdev->nvqs; ++i) {
+    if (virtio_queue_get_desc_addr(vdev, i) == 0) continue;


BTW, the queue index is wrong here, it should be:

if (virtio_queue_get_desc_addr(vdev, hdev->vq_index + i) == 0)
continue;


  r = vhost_virtqueue_start(hdev,
    vdev,
    hdev->vqs + i,





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


Re: [edk2] [PATCH] MdeModulePkg/DebugLib: Print partial when format string is too long

2018-01-11 Thread Gao, Liming
Ray:
  Could you keep total size to point the real used size instead of full size? 
It can reduce the copy action in ReportStatusCodeLib.

> -Original Message-
> From: Ni, Ruiyu
> Sent: Thursday, January 11, 2018 11:36 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [PATCH] MdeModulePkg/DebugLib: Print partial when format string is 
> too long
> 
> Today's implementation prints nothing when the format string cannot
> fit in the report status extended data buffer.
> It confuses user.
> The patch changes to print partial message by truncating the format
> string when it's too long.
> 
> The missing enhancement is the extended data buffer only reserves 96
> bytes for the var-args. When the format string is not very long but
> contains 13 %lx or %p, the var-args buffer is too small. Today's
> implementation prints nothing for this case.
> This patch doesn't change such behavior.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni 
> Cc: Liming Gao 
> ---
>  .../PeiDxeDebugLibReportStatusCode/DebugLib.c   | 21 
> +++--
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> index 163d530ae5..785e231cf2 100644
> --- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> +++ b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
> @@ -4,7 +4,7 @@
>Note that if the debug message length is larger than the maximum allowable
>record length, then the debug message will be ignored directly.
> 
> -  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
> +  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>This program and the accompanying materials
>are licensed and made available under the terms and conditions of the BSD 
> License
>which accompanies this distribution.  The full text of the license may be 
> found at
> @@ -55,7 +55,6 @@ DebugPrint (
>  {
>UINT64  Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 
> 1];
>EFI_DEBUG_INFO  *DebugInfo;
> -  UINTN   TotalSize;
>VA_LIST VaListMarker;
>BASE_LIST   BaseListMarker;
>CHAR8   *FormatString;
> @@ -74,7 +73,6 @@ DebugPrint (
>}
> 
>//
> -  // Compute the total size of the record.
>// Note that the passing-in format string and variable parameters will be 
> constructed to
>// the following layout:
>//
> @@ -90,14 +88,6 @@ DebugPrint (
>// |   Format String|
>// ||<- (UINT8 *)Buffer + 
> sizeof(Buffer)
>//
> -  TotalSize = 4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + 
> AsciiStrSize (Format);
> -
> -  //
> -  // If the TotalSize is larger than the maximum record size, then return
> -  //
> -  if (TotalSize > sizeof (Buffer)) {
> -return;
> -  }
> 
>//
>// Fill in EFI_DEBUG_INFO
> @@ -113,9 +103,12 @@ DebugPrint (
>FormatString  = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
> 
>//
> -  // Copy the Format string into the record
> +  // Copy the Format string into the record. It will be truncated if it's 
> too long.
>//
> -  AsciiStrCpyS (FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 
> 12 * sizeof(UINT64)), Format);
> +  AsciiStrnCpyS (
> +FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * 
> sizeof(UINT64)),
> +Format,   sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * 
> sizeof(UINT64)) - 1
> +);
> 
>//
>// The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for 
> variable arguments
> @@ -223,7 +216,7 @@ DebugPrint (
>  NULL,
>  ,
>  DebugInfo,
> -TotalSize
> +sizeof (Buffer)
>  );
>  }
> 
> --
> 2.15.1.windows.2

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


Re: [edk2] [PATCH v2 13/13] ArmPlatformPkg: Introduce SCMI protocol

2018-01-11 Thread Evan Lloyd


> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: 23 December 2017 14:06
> To: Evan Lloyd 
> Cc: edk2-devel@lists.01.org; "ard.biesheu...@linaro.org"@arm.com;
> "leif.lindh...@linaro.org"@arm.com;
> "matteo.carl...@arm.com"@arm.com; "n...@arm.com"@arm.com
> Subject: Re: [PATCH v2 13/13] ArmPlatformPkg: Introduce SCMI protocol
>
> , couOn 22 December 2017 at 18:34,   wrote:
> > From: Girish Pathak 
> >
> > This change introduces a new SCMI protocol driver for
> > Arm Platforms. The driver currently supports only clock
> > and performance management protocols. Other protocols
> > will be added as and when needed.
> >
> > Clock management protocol is used to configure the HDLCD clock
> > on Juno platforms.
> >
> > Whereas performance management protocol allows adjustment
> > of various performance domains to evaluate performance of the
> > Juno platform.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Girish Pathak 
> > ---
...
> > +
> > +#ifndef ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
> > +#define ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
> > +
> > +// Return values of BASE_DISCOVER_LIST_PROTOCOLS command.
> > +typedef struct {
> > +  UINT32 NumProtocols;
> > +  // Array of four protocols in each element
> > +  // Total elements = 1 + (NumProtocols-1)/4
> > +  UINT8 Protocols[];
>
> For paleontological reasons, EDK2 code does not allow arrays of
> unspecified length at the end of a struct. I don't know which version
> of which toolchain used to be the issue here, and I would be surprised
> if anyone went through the trouble of writing that down, but it is the
> reason that EDK2 only allows a [1] array, and hence care needs to be
> taken to add/substract 1 as appropriate when sizing the variable.

 [[Evan Lloyd]] Whilst not disputing your claim, we have failed to find any 
such restriction in the coding standard.  Do you have a reference?

>
> So now, it's my turn to cut /you/ a deal here. If you stop whingeing
> about frivolous patches that only move whitespace around or change //
> for /*, or move ASSERT()s into if () conditions on cold-as-ice code
> paths, I am not going to complain about the arrays of unspecified
> length in this patch, simply because I don't take the coding standard
> as gospel, and feel that the Tianocore could do with a bit more
> pragmatism when it comes to matters like these.

 [[Evan Lloyd]] I'm happy to take the deal.  You know why some of the 
formatting changes are there, and why the ASSERT moves are relevant, so I can't 
promise we'll stop doing it.

>
>
> > +} BASE_DISCOVER_LIST;
> > +
> > +#endif /* ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_ */
> > diff --git
> a/ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> b/ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> > new file mode 100644
> > index
> ..2807b6b476ac1b8cf8
> 21a29ca7a59a78e9188c52
> > --- /dev/null
> > +++
> b/ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h

> > +
> > +#endif /* SCMI_PRIVATE_H_ */
> > diff --git a/ArmPlatformPkg/Include/Drivers/ArmScmi.h
> b/ArmPlatformPkg/Include/Drivers/ArmScmi.h
>
> Please don't put stuff in Include/Drivers.
>
> Things derived from industry specs belong in Include/IndustryStandard,
> but given that this header only defines SCMI_MAX_STR_LEN, could you
> move it into the protocol header instead?

 [[Evan Lloyd]] Can do.  However, this point raises some interesting thoughts.
e.g. Does SBBR count as an "Industry" standard?  How about SCMI?
Also, I believe we aim to eventually put ArmPlatformPkg out of our misery.
So, would the SCMI driver belong in ArmPkg (as an arm ATG standard), or should 
it be in edk2-platforms?

>
>
> > new file mode 100644
> > index
> ..04ea3de5b34157ed45
> 9ee47440abbcaa7114e93a
> > --- /dev/null
> > +++ b/ArmPlatformPkg/Include/Drivers/ArmScmi.h
> > @@ -0,0 +1,27 @@
...
> > diff --git a/ArmPlatformPkg/Include/Drivers/ArmScmiBaseProtocol.h
> b/ArmPlatformPkg/Include/Drivers/ArmScmiBaseProtocol.h
>
> This belongs in Include/Protocol, and needs to be declared in the
> package .dec file as well, along with its GUID.
>

 [[Evan Lloyd]]   We can do that, but can I check that is actually what you 
want.
This file relates to an SCMI (communications) protocol definition, not a UEFI 
protocol (although Girish has used the familiar style).
Also, is that Include/Protocol in ArmPkg, ArmPlatformsPkg, or 
edk2-platforms/Platform/ARM ?

>
...
> > +#define ARM_SCMI_BASE_PROTOCOL_GUID  { 0xd7e5abe9, 0x33ab,
> 0x418e, { 0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f } }
> > +
>
> Please wrap this line
[[Evan Lloyd]] Can do, but I don't think it needs to be in the .h file at all.
>
> > +extern EFI_GUID gArmScmiBaseProtocolGuid;
> > +
...
> > +/** Initialize Base protocol and install protocol on a given 

Re: [edk2] [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds

2018-01-11 Thread Cohen, Eugene
Pete,

> How about I modify the patch to use "AREA s_"
> instead of "AREA Math" as per the current proposal?

That's how it used to work before the macro was introduced, per commit 
dcb2e4bb61931e2dee1739bb76aba315002f0a82 two years ago.

I personally have no problem going back to the individual AREA s_  
approach now that we have a good reason to do so.

> Also, you'll notice that the current div.asm [1], which is used by RVCT does
> *not* rely on the macro, so, unless this is intentional, there already seems
> to exist inconsistencies with regards to using the RVCT_ASM_EXPORT
> macro to ensure the removal of dead code...

I think this was likely an oversight.

> So, to summarise, I would much prefer if we could keep most of the
> current patch, and simply use the following where needed:
> 
> AREA  s___aeabi_ldivmod, CODE, READONLY, ARM AREA  s___aeabi_llsr,
> CODE, READONLY, ARM AREA  s___aeabi_uldivmod, CODE, READONLY,
> ARM
>

Agreed, this is fine so long as we agree on the definition of "where needed".  
In general I would expect each independent assembly function to have its own 
AREA directive (e.g. math functions).  In some cases there will clearly be a 
collection of dependent functions that would be better served by a single area 
directive (e.g. MMU initialization functions).

Much Thanks!

Eugene

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


[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 1/2] Add support for Sony camera imx219

2018-01-11 Thread Teemu Rytkonen
Adds support for two ACPI entries for imx219 as front
and back camera of IPU. Both camera entries can be configured
from the Front, Back camera of the BIOS menu settings.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Teemu Rytkonen 
---
 .../BensonGlacier/BoardInitPostMem/BoardGpios.h|   4 +-
 .../PlatformSsdt/Camera/Camera_Sony219A.asl| 223 +
 .../PlatformSsdt/Camera/Camera_Sony219B.asl| 223 +
 .../AcpiTablesPCAT/PlatformSsdt/PlatformSsdt.asl   |   3 +
 .../PlatformSettings/PlatformSetupDxe/UnCore.vfi   |   8 +-
 .../PlatformSetupDxe/VfrStrings.uni| Bin 305886 -> 306044 bytes
 6 files changed, 456 insertions(+), 5 deletions(-)
 create mode 100644 
Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/PlatformSsdt/Camera/Camera_Sony219A.asl
 create mode 100644 
Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/PlatformSsdt/Camera/Camera_Sony219B.asl

diff --git 
a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardGpios.h 
b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardGpios.h
index e4c1c2ee1..f636852b8 100644
--- 
a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardGpios.h
+++ 
b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardGpios.h
@@ -73,7 +73,7 @@ BXT_GPIO_PAD_INIT  mBenson_GpioInitData_N[] =
   BXT_GPIO_PAD_CONF(L"GPIO_7",   M1   ,NA,  NA   ,  NA 
   ,   NA   , Wake_Disabled, P_20K_L,   NA,NA,   HizRx0I,   SAME, 
GPIO_PADBAR+0x0038,  NORTH),//Mux with DISP1_TOUCH_INT_N based on the SW3 switch
   BXT_GPIO_PAD_CONF(L"GPIO_8",   M1   ,NA,  NA   ,  NA 
   ,   NA   , Wake_Disabled, P_20K_L,   NA,NA,   HizRx0I,   SAME, 
GPIO_PADBAR+0x0040,  NORTH),//Mux with DISP1_TOUCH_RST_N based on the SW3 switch
   BXT_GPIO_PAD_CONF(L"GPIO_9",   M0   ,GPO   ,  NA   ,  NA 
   ,   NA   , Wake_Disabled, P_20K_L,NA,   NA ,NA   , NA, 
GPIO_PADBAR+0x0048,  NORTH),//Feature: LB
-  BXT_GPIO_PAD_CONF(L"GPIO_10",  M0   ,GPO   ,  NA   ,  NA 
   ,   NA, Wake_Enabled , P_20K_L, Inverted,IOAPIC,   TxDRxE , NA, 
GPIO_PADBAR+0x0050,  NORTH),//Feature: LB 
+  BXT_GPIO_PAD_CONF(L"GPIO_10",  M0   ,GPO   ,  NA   ,  NA 
   ,   NA, Wake_Enabled , P_20K_L, Inverted,IOAPIC,   TxDRxE , NA, 
GPIO_PADBAR+0x0050,  NORTH),//Feature: CAM0_POWEREN
   BXT_GPIO_PAD_CONF(L"GPIO_11",  M1   ,NA, NA,  NA 
   ,   NA   , Wake_Disabled, P_20K_L,NA   ,NA ,NA   , NA, 
GPIO_PADBAR+0x0058,  NORTH),//Feature: LB
   BXT_GPIO_PAD_CONF(L"GPIO_12",  M1   ,NA, NA,  NA 
   ,   NA   , Wake_Enabled , P_20K_L,NA   ,NA ,NA   , NA, 
GPIO_PADBAR+0x0060,  NORTH),//Feature: LB
   BXT_GPIO_PAD_CONF(L"GPIO_13",  M1   ,NA, NA,  NA 
   ,   NA   , Wake_Disabled, P_20K_L,NA   ,NA ,NA   , NA, 
GPIO_PADBAR+0x0068,  NORTH),//Feature: LB
@@ -82,7 +82,7 @@ BXT_GPIO_PAD_INIT  mBenson_GpioInitData_N[] =
   BXT_GPIO_PAD_CONF(L"GPIO_16",  M0   ,GPI   ,  NA   ,  NA 
   ,   Edge , Wake_Disabled, P_20K_H, Inverted,IOAPIC,  HizRx0I ,DisPuPd, 
GPIO_PADBAR+0x0080,  NORTH),//Feature:SIM Card DetectNet in Sch: 
SIM_CON_CD1, falling edge trigger
   BXT_GPIO_PAD_CONF(L"GPIO_17",  M0   ,GPI   , GPIO_D,  NA 
   ,   Edge , Wake_Disabled, P_NONE ,NA   ,IOAPIC, NA   ,DisPuPd, 
GPIO_PADBAR+0x0088, NORTH), // SOC_LSE_HOST_IRQ_N
   BXT_GPIO_PAD_CONF(L"GPIO_18",  M1   ,NA, NA,  NA 
   ,   NA   , Wake_Disabled, P_20K_H,NA   ,NA, NA   , NA, 
GPIO_PADBAR+0x0090,  NORTH),//Feature: LB
-  BXT_GPIO_PAD_CONF(L"GPIO_19",  M1   ,NA, NA,  NA 
   ,   NA   , Wake_Disabled, P_20K_H,NA   ,NA, NA   , NA, 
GPIO_PADBAR+0x0098,  NORTH),//Feature: LB
+  BXT_GPIO_PAD_CONF(L"GPIO_19",  M0   ,NA, NA,  NA 
   ,   NA   , Wake_Disabled, P_20K_H,NA   ,NA, NA   , NA, 
GPIO_PADBAR+0x0098,  NORTH),//Feature: CAM0_POWEREN
   BXT_GPIO_PAD_CONF(L"GPIO_20",  M1   ,NA, NA,  NA 
   ,   NA   , Wake_Disabled, P_20K_L,NA   ,NA, NA   , NA, 
GPIO_PADBAR+0x00A0,  NORTH),//Feature: LB
   BXT_GPIO_PAD_CONF(L"GPIO_21",  M1   ,NA, NA,  NA 
   ,   NA   , Wake_Disabled, P_20K_L,NA   ,NA, NA   , NA, 
GPIO_PADBAR+0x00A8,  NORTH),//Feature: LB
   BXT_GPIO_PAD_CONF(L"GPIO_22",  M0   ,GPIO  ,GPIO_D ,  NA 
   ,   NA   , Wake_Disabled, P_20K_L,NA   ,NA, NA   , NA, 
GPIO_PADBAR+0x00B0,  NORTH),//Feature: LB
diff --git 

[edk2] [PATCH v2 1/1] OvmfPkg/BaseMemEncryptSevLib: Enable protection for newly added page table

2018-01-11 Thread Brijesh Singh
Commit 2ac1730bf2a5 (MdeModulePkg/DxeIpl: Mark page table as read-only)
sets the memory pages used for page table as read-only after paging is
setup and sets CR0.WP to protect CPU modifying the read-only pages.
The commit causes #PF when MemEncryptSevClearPageEncMask() or
MemEncryptSevSetPageEncMask() tries to change the page-table attributes.

This patch takes the similar approach as Commit 147fd35c3e38
(UefiCpuPkg/CpuDxe: Enable protection for newly added page table).
When page table protection is enabled, we disable it temporarily before
changing the page table attributes.

This patch makes use of the same approach as Commit 2ac1730bf2a5
(MdeModulePkg/DxeIpl: Mark page table as read-only)) for allocating
page table memory from reserved memory pool, which helps to reduce a
potential "split" operation.

The patch duplicates code from commit 147fd35c3e38. The code duplication
will be removed after we implement page table manipulation library. See
bugzilla https://bugzilla.tianocore.org/show_bug.cgi?id=847.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Brijesh Singh 
---
 .../BaseMemEncryptSevLib/X64/VirtualMemory.c   | 378 -
 .../BaseMemEncryptSevLib/X64/VirtualMemory.h   |  28 ++
 2 files changed, 399 insertions(+), 7 deletions(-)

diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c 
b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
index e1e705c34626..4185874c99b8 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
@@ -25,6 +25,7 @@ Code is derived from 
MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
 
 STATIC BOOLEAN mAddressEncMaskChecked = FALSE;
 STATIC UINT64  mAddressEncMask;
+STATIC PAGE_TABLE_POOL   *mPageTablePool = NULL;
 
 typedef enum {
SetCBit,
@@ -63,6 +64,123 @@ GetMemEncryptionAddressMask (
 }
 
 /**
+  Initialize a buffer pool for page table use only.
+
+  To reduce the potential split operation on page table, the pages reserved for
+  page table should be allocated in the times of PAGE_TABLE_POOL_UNIT_PAGES and
+  at the boundary of PAGE_TABLE_POOL_ALIGNMENT. So the page pool is always
+  initialized with number of pages greater than or equal to the given 
PoolPages.
+
+  Once the pages in the pool are used up, this method should be called again to
+  reserve at least another PAGE_TABLE_POOL_UNIT_PAGES. Usually this won't 
happen
+  often in practice.
+
+  @param[in] PoolPages  The least page number of the pool to be created.
+
+  @retval TRUEThe pool is initialized successfully.
+  @retval FALSE   The memory is out of resource.
+**/
+STATIC
+BOOLEAN
+InitializePageTablePool (
+  IN  UINTN   PoolPages
+  )
+{
+  VOID  *Buffer;
+
+  //
+  // Always reserve at least PAGE_TABLE_POOL_UNIT_PAGES, including one page for
+  // header.
+  //
+  PoolPages += 1;   // Add one page for header.
+  PoolPages = ((PoolPages - 1) / PAGE_TABLE_POOL_UNIT_PAGES + 1) *
+  PAGE_TABLE_POOL_UNIT_PAGES;
+  Buffer = AllocateAlignedPages (PoolPages, PAGE_TABLE_POOL_ALIGNMENT);
+  if (Buffer == NULL) {
+DEBUG ((DEBUG_ERROR, "ERROR: Out of aligned pages\r\n"));
+return FALSE;
+  }
+
+  //
+  // Link all pools into a list for easier track later.
+  //
+  if (mPageTablePool == NULL) {
+mPageTablePool = Buffer;
+mPageTablePool->NextPool = mPageTablePool;
+  } else {
+((PAGE_TABLE_POOL *)Buffer)->NextPool = mPageTablePool->NextPool;
+mPageTablePool->NextPool = Buffer;
+mPageTablePool = Buffer;
+  }
+
+  //
+  // Reserve one page for pool header.
+  //
+  mPageTablePool->FreePages  = PoolPages - 1;
+  mPageTablePool->Offset = EFI_PAGES_TO_SIZE (1);
+
+  return TRUE;
+}
+
+/**
+  This API provides a way to allocate memory for page table.
+
+  This API can be called more than once to allocate memory for page tables.
+
+  Allocates the number of 4KB pages and returns a pointer to the allocated
+  buffer. The buffer returned is aligned on a 4KB boundary.
+
+  If Pages is 0, then NULL is returned.
+  If there is not enough memory remaining to satisfy the request, then NULL is
+  returned.
+
+  @param  Pages The number of 4 KB pages to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+STATIC
+VOID *
+EFIAPI
+AllocatePageTableMemory (
+  IN UINTN   Pages
+  )
+{
+  VOID*Buffer;
+
+  if (Pages == 0) {
+return NULL;
+  }
+
+  //
+  // Renew the pool if necessary.
+  //
+  if (mPageTablePool == NULL ||
+  Pages > mPageTablePool->FreePages) {
+if (!InitializePageTablePool (Pages)) {
+  return NULL;
+}
+  }
+
+  Buffer = (UINT8 

Re: [edk2] [Patch v2] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().

2018-01-11 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 



> -Original Message-
> From: Wang, Fan
> Sent: Thursday, January 11, 2018 6:14 PM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan ; Wu, Jiaxin ; Wu,
> Hao A 
> Subject: [Patch v2] MdeModulePkg/DxeNetLib: Add array range check in
> NetIp6IsNetEqual().
> 
> V2
> * Added an ASSERT check for the case PrefixLength equals to IP6_PREFIX_MAX.
> * Synced some code descriptions to head file.
> 
> Cc: Fu Siyuan 
> Cc: Jiaxin Wu 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan 
> ---
>  MdeModulePkg/Include/Library/NetLib.h  | 50
> +++---
>  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c |  8 +++--
>  2 files changed, 52 insertions(+), 6 deletions(-)
> 
> diff --git a/MdeModulePkg/Include/Library/NetLib.h
> b/MdeModulePkg/Include/Library/NetLib.h
> index 7862df9..b0bbaf2 100644
> --- a/MdeModulePkg/Include/Library/NetLib.h
> +++ b/MdeModulePkg/Include/Library/NetLib.h
> @@ -1,10 +1,10 @@
>  /** @file
>This library is only intended to be used by UEFI network stack modules.
>It provides basic functions for the UEFI network stack.
> 
> -Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -438,10 +438,12 @@ NetIp4IsUnicast (
>);
> 
>  /**
>Check whether the incoming IPv6 address is a valid unicast address.
> 
> +  ASSERT if Ip6 is NULL.
> +
>If the address is a multicast address has binary 0xFF at the start, it
> is not
>a valid unicast address. If the address is unspecified ::, it is not a
> valid
>unicast address to be assigned to any node. If the address is loopback
> address
>::1, it is also not a valid unicast address to be assigned to any
> physical
>interface.
> @@ -459,10 +461,12 @@ NetIp6IsValidUnicast (
> 
> 
>  /**
>Check whether the incoming Ipv6 address is the unspecified address or
> not.
> 
> +  ASSERT if Ip6 is NULL.
> +
>@param[in] Ip6   - Ip6 address, in network order.
> 
>@retval TRUE - Yes, incoming Ipv6 address is the unspecified
> address.
>@retval FALSE- The incoming Ipv6 address is not the unspecified
> address
> 
> @@ -474,10 +478,12 @@ NetIp6IsUnspecifiedAddr (
>);
> 
>  /**
>Check whether the incoming Ipv6 address is a link-local address.
> 
> +  ASSERT if Ip6 is NULL.
> +
>@param[in] Ip6   - Ip6 address, in network order.
> 
>@retval TRUE  - The incoming Ipv6 address is a link-local address.
>@retval FALSE - The incoming Ipv6 address is not a link-local address.
> 
> @@ -489,10 +495,13 @@ NetIp6IsLinkLocalAddr (
>);
> 
>  /**
>Check whether the Ipv6 address1 and address2 are on the connected
> network.
> 
> +  ASSERT if Ip1 or Ip2 is NULL.
> +  ASSERT if PrefixLength exceeds or equals to IP6_PREFIX_MAX.
> +
>@param[in] Ip1  - Ip6 address1, in network order.
>@param[in] Ip2  - Ip6 address2, in network order.
>@param[in] PrefixLength - The prefix length of the checking net.
> 
>@retval TRUE- Yes, the Ipv6 address1 and address2 are
> connected.
> @@ -508,10 +517,12 @@ NetIp6IsNetEqual (
>);
> 
>  /**
>Switches the endianess of an IPv6 address.
> 
> +  ASSERT if Ip6 is NULL.
> +
>This function swaps the bytes in a 128-bit IPv6 address to switch the
> value
>from little endian to big endian or vice versa. The byte swapped value
> is
>returned.
> 
>@param  Ip6 Points to an IPv6 address.
> @@ -542,10 +553,12 @@ extern EFI_IPv4_ADDRESS  mZeroIp4Addr;
>  #define NET_RANDOM(Seed)((UINT32) ((UINT32) (Seed) * 1103515245UL
> + 12345) % 4294967295UL)
> 
>  /**
>Extract a UINT32 from a byte stream.
> 
> +  ASSERT if Buf is NULL.
> +
>This function copies a UINT32 from a byte stream, and then converts it
> from Network
>byte order to host byte order. Use this function to avoid alignment
> error.
> 
>@param[in]  Buf The buffer to extract the UINT32.
> 
> @@ -559,10 +572,12 @@ NetGetUint32 (
>);
> 
>  /**
>Puts a UINT32 into the byte stream in network byte order.
> 
> +  ASSERT if Buf is NULL.
> +
>Converts a UINT32 from host byte order to network byte order, then
> copies it to the
>byte stream.
> 
>@param[in, out]  Buf  The buffer in which to put the UINT32.
>@param[in]   Data The data to be converted and put into the
> byte stream.
> @@ -675,10 +690,12 @@ NetListRemoveTail (
>);
> 
>  /**
>Insert a new node entry after a designated node 

[edk2] [PATCH] UefiCpuPkg: Enhance feature dependency check

2018-01-11 Thread Song, BinX
Enhance MCA feature dependency check base on SDM pseudocode example 15-1.

Cc: Eric Dong 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
index b012c69..58dc45a 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
@@ -105,6 +105,9 @@ McaSupport (
   IN VOID  *ConfigData  OPTIONAL
   )
 {
+  if (!MceSupport (ProcessorNumber, CpuInfo, ConfigData)) {
+return FALSE;
+  }
   return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1);
 }
 
-- 
2.10.2.windows.1

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


Re: [edk2] [PATCH] OvmfPkg/VirtioScsiDxe: Allocate all required vrings at VirtioScsiInit

2018-01-11 Thread zhengxiang (A)
Hi Maxime,

On 2018/1/11 22:46, Maxime Coquelin wrote:
> 
> 
> On 01/11/2018 02:23 PM, Maxime Coquelin wrote:
>> Hi Xiang,
>>
>> On 12/14/2017 02:25 PM, zhengxiang (A) wrote:
>>>
>>>
>>> On 2017/12/14 17:06, Paolo Bonzini wrote:
 On 14/12/2017 07:55, zhengxiang (A) wrote:
> Hello Laszlo and Paolo,
>
> Thanks for your review!
>
> On 2017/12/13 19:16, Laszlo Ersek wrote:
>> On 12/13/17 10:29, Paolo Bonzini wrote:
>>> On 13/12/2017 09:35, Laszlo Ersek wrote:
 Perhaps you can update vhost-scsi similarly to the last patch of
 Maxime's v4 series, even without "VIRTIO_SCSI_F_MQ" -- in the
 SET_FEATURES request handler, just destroy the unused virtqueues that
 have not been configured by the guest driver until that time?
>>> Yes, this is the right solution.  We can assume that if the descriptor
>>> address is equal to zero, the queue is not in use.  This is not in the
>>> spec as far as I can see, but it is QEMU's assumption.  I will send a
>>> patch to the virtio specification.
>
> I would try this solution! However, is there any possibility that the 
> allocated
> descriptor address is exactly equal to zero and the queue is in use?

 That would break QEMU's virtio implementation, so it's pretty unlikely.

 Paolo

>>>
>>> So could I judge the not-in-use queues by adding the below sentence in order
>>> to skip calling vhost_virtqueue_start?
>>>
>>> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>>> index e4290ce..05c3322 100644
>>> --- a/hw/virtio/vhost.c
>>> +++ b/hw/virtio/vhost.c
>>> @@ -1532,6 +1532,7 @@ int vhost_dev_start(struct vhost_dev *hdev, 
>>> VirtIODevice *vdev)
>>>   goto fail_mem;
>>>   }
>>>   for (i = 0; i < hdev->nvqs; ++i) {
>>> +    if (virtio_queue_get_desc_addr(vdev, i) == 0) continue;
> 
> BTW, the queue index is wrong here, it should be:
> 
> if (virtio_queue_get_desc_addr(vdev, hdev->vq_index + i) == 0)
>     continue;
> 
Thank you for correcting my mistake. I will post this patch for more 
discussions.
>>>   r = vhost_virtqueue_start(hdev,
>>>     vdev,
>>>     hdev->vqs + i,
>>>
>>
> 
> Maxime
> 
> .
> 

Thanks,
Xiang

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


[edk2] [PATCH] CryptoPkg/OpensslLib: Suppress format warning with extra flag.

2018-01-11 Thread Long Qin
Under a certain [outdated] GCC482 compiler, the new-added "-Wno-format"
flag will not take effect, and break the x86_64 build.
This is one known issue in some Ubuntu/GCC-4.8.2 environment, which will
overwrite "-Wno-format" with some default setting.  see more information
and discussion from:
  https://gcc.gnu.org/ml/gcc-help/2014-03/msg3.html
  https://wiki.ubuntu.com/ToolChain/CompilerFlags
This patch adds one extra "-Wno-error=format" for gcc x86_64 builds to
suppress this warning.

Cc: Ard Biesheuvel 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Long Qin 
---
 CryptoPkg/Library/OpensslLib/OpensslLib.inf   | 2 +-
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf 
b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
index f3eb19afd3..10021f8503 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
@@ -557,7 +557,7 @@
   #   types appropriate to the format string specified.
   #
   GCC:*_*_IA32_CC_FLAGS= -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
-Wno-error=maybe-uninitialized
-  GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
-Wno-error=maybe-uninitialized -Wno-format -DNO_MSABI_VA_FUNCS
+  GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
-Wno-error=maybe-uninitialized -Wno-error=format -Wno-format -DNO_MSABI_VA_FUNCS
   GCC:*_*_IPF_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
-Wno-error=maybe-uninitialized -Wno-format
   GCC:*_*_ARM_CC_FLAGS = $(OPENSSL_FLAGS)
   GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-format
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf 
b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
index 88134b5b5f..ff598e7d43 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
@@ -518,7 +518,7 @@
   #   types appropriate to the format string specified.
   #
   GCC:*_*_IA32_CC_FLAGS= -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
-Wno-error=maybe-uninitialized
-  GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
-Wno-error=maybe-uninitialized -Wno-format -DNO_MSABI_VA_FUNCS
+  GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
-Wno-error=maybe-uninitialized -Wno-error=format -Wno-format -DNO_MSABI_VA_FUNCS
   GCC:*_*_IPF_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
-Wno-error=maybe-uninitialized -Wno-format
   GCC:*_*_ARM_CC_FLAGS = $(OPENSSL_FLAGS)
   GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-format
-- 
2.15.1.windows.2

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


Re: [edk2] [Patch v2] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().

2018-01-11 Thread Wu, Jiaxin
Reviewed-by: Jiaxin Wu 


> -Original Message-
> From: Wang, Fan
> Sent: Thursday, January 11, 2018 6:14 PM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan ; Wu, Jiaxin ; Wu,
> Hao A 
> Subject: [Patch v2] MdeModulePkg/DxeNetLib: Add array range check in
> NetIp6IsNetEqual().
> 
> V2
> * Added an ASSERT check for the case PrefixLength equals to
> IP6_PREFIX_MAX.
> * Synced some code descriptions to head file.
> 
> Cc: Fu Siyuan 
> Cc: Jiaxin Wu 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan 
> ---
>  MdeModulePkg/Include/Library/NetLib.h  | 50
> +++---
>  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c |  8 +++--
>  2 files changed, 52 insertions(+), 6 deletions(-)
> 
> diff --git a/MdeModulePkg/Include/Library/NetLib.h
> b/MdeModulePkg/Include/Library/NetLib.h
> index 7862df9..b0bbaf2 100644
> --- a/MdeModulePkg/Include/Library/NetLib.h
> +++ b/MdeModulePkg/Include/Library/NetLib.h
> @@ -1,10 +1,10 @@
>  /** @file
>This library is only intended to be used by UEFI network stack modules.
>It provides basic functions for the UEFI network stack.
> 
> -Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -438,10 +438,12 @@ NetIp4IsUnicast (
>);
> 
>  /**
>Check whether the incoming IPv6 address is a valid unicast address.
> 
> +  ASSERT if Ip6 is NULL.
> +
>If the address is a multicast address has binary 0xFF at the start, it is 
> not
>a valid unicast address. If the address is unspecified ::, it is not a 
> valid
>unicast address to be assigned to any node. If the address is loopback
> address
>::1, it is also not a valid unicast address to be assigned to any physical
>interface.
> @@ -459,10 +461,12 @@ NetIp6IsValidUnicast (
> 
> 
>  /**
>Check whether the incoming Ipv6 address is the unspecified address or not.
> 
> +  ASSERT if Ip6 is NULL.
> +
>@param[in] Ip6   - Ip6 address, in network order.
> 
>@retval TRUE - Yes, incoming Ipv6 address is the unspecified address.
>@retval FALSE- The incoming Ipv6 address is not the unspecified address
> 
> @@ -474,10 +478,12 @@ NetIp6IsUnspecifiedAddr (
>);
> 
>  /**
>Check whether the incoming Ipv6 address is a link-local address.
> 
> +  ASSERT if Ip6 is NULL.
> +
>@param[in] Ip6   - Ip6 address, in network order.
> 
>@retval TRUE  - The incoming Ipv6 address is a link-local address.
>@retval FALSE - The incoming Ipv6 address is not a link-local address.
> 
> @@ -489,10 +495,13 @@ NetIp6IsLinkLocalAddr (
>);
> 
>  /**
>Check whether the Ipv6 address1 and address2 are on the connected
> network.
> 
> +  ASSERT if Ip1 or Ip2 is NULL.
> +  ASSERT if PrefixLength exceeds or equals to IP6_PREFIX_MAX.
> +
>@param[in] Ip1  - Ip6 address1, in network order.
>@param[in] Ip2  - Ip6 address2, in network order.
>@param[in] PrefixLength - The prefix length of the checking net.
> 
>@retval TRUE- Yes, the Ipv6 address1 and address2 are 
> connected.
> @@ -508,10 +517,12 @@ NetIp6IsNetEqual (
>);
> 
>  /**
>Switches the endianess of an IPv6 address.
> 
> +  ASSERT if Ip6 is NULL.
> +
>This function swaps the bytes in a 128-bit IPv6 address to switch the value
>from little endian to big endian or vice versa. The byte swapped value is
>returned.
> 
>@param  Ip6 Points to an IPv6 address.
> @@ -542,10 +553,12 @@ extern EFI_IPv4_ADDRESS  mZeroIp4Addr;
>  #define NET_RANDOM(Seed)((UINT32) ((UINT32) (Seed) *
> 1103515245UL + 12345) % 4294967295UL)
> 
>  /**
>Extract a UINT32 from a byte stream.
> 
> +  ASSERT if Buf is NULL.
> +
>This function copies a UINT32 from a byte stream, and then converts it from
> Network
>byte order to host byte order. Use this function to avoid alignment error.
> 
>@param[in]  Buf The buffer to extract the UINT32.
> 
> @@ -559,10 +572,12 @@ NetGetUint32 (
>);
> 
>  /**
>Puts a UINT32 into the byte stream in network byte order.
> 
> +  ASSERT if Buf is NULL.
> +
>Converts a UINT32 from host byte order to network byte order, then copies
> it to the
>byte stream.
> 
>@param[in, out]  Buf  The buffer in which to put the UINT32.
>@param[in]   Data The data to be converted and put into the 
> byte
> stream.
> @@ -675,10 +690,12 @@ NetListRemoveTail (
>);
> 
>  /**
>Insert a new node entry after a designated node entry of 

Re: [edk2] [PATCH 0/5] BaseTools/Common & DevicePath: Code refinements

2018-01-11 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Wu, Hao A
> Sent: Monday, January 8, 2018 1:31 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Ni, Ruiyu ; Zhu, 
> Yonghong ; Gao, Liming
> 
> Subject: [PATCH 0/5] BaseTools/Common & DevicePath: Code refinements
> 
> The series refines the C/C++ source codes within
> BaseTools/C/Source/Common/ and BaseTools/Source/C/DevicePath/ for the
> below catagories:
> 
> * Resolve possible resource/memory leaks
> 
> * Resolve possible NULL pointer dereferences
> 
> Cc: Ruiyu Ni 
> Cc: Yonghong Zhu 
> Cc: Liming Gao 
> 
> Hao Wu (5):
>   BaseTools/C/Common: Fix code to be more readable
>   BaseTools/C/Common: Fix potential memory leak
>   BaseTools/DevicePath: Fix potential memory leak
>   BaseTools/C/Common: Fix potential null pointer dereference
>   BaseTools/DevicePath: Fix potential null pointer dereference
> 
>  BaseTools/Source/C/Common/CommonLib.c  |  2 +-
>  BaseTools/Source/C/Common/PcdValueCommon.c | 10 ++
>  BaseTools/Source/C/DevicePath/DevicePath.c |  6 ++
>  BaseTools/Source/C/DevicePath/DevicePathFromText.c | 11 +++
>  4 files changed, 28 insertions(+), 1 deletion(-)
> 
> --
> 2.12.0.windows.1

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


Re: [edk2] [PATCH] CryptoPkg/OpensslLib: Suppress format warning with extra flag.

2018-01-11 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Long, Qin
> Sent: Friday, January 12, 2018 11:20 AM
> To: edk2-devel@lists.01.org
> Cc: ard.biesheu...@linaro.org; Gao, Liming 
> Subject: [PATCH] CryptoPkg/OpensslLib: Suppress format warning with extra 
> flag.
> 
> Under a certain [outdated] GCC482 compiler, the new-added "-Wno-format"
> flag will not take effect, and break the x86_64 build.
> This is one known issue in some Ubuntu/GCC-4.8.2 environment, which will
> overwrite "-Wno-format" with some default setting.  see more information
> and discussion from:
>   https://gcc.gnu.org/ml/gcc-help/2014-03/msg3.html
>   https://wiki.ubuntu.com/ToolChain/CompilerFlags
> This patch adds one extra "-Wno-error=format" for gcc x86_64 builds to
> suppress this warning.
> 
> Cc: Ard Biesheuvel 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Long Qin 
> ---
>  CryptoPkg/Library/OpensslLib/OpensslLib.inf   | 2 +-
>  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf 
> b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
> index f3eb19afd3..10021f8503 100644
> --- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf
> +++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
> @@ -557,7 +557,7 @@
>#   types appropriate to the format string specified.
>#
>GCC:*_*_IA32_CC_FLAGS= -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
> -Wno-error=maybe-uninitialized
> -  GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
> -Wno-error=maybe-uninitialized -Wno-format
> -DNO_MSABI_VA_FUNCS
> +  GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
> -Wno-error=maybe-uninitialized -Wno-error=format
> -Wno-format -DNO_MSABI_VA_FUNCS
>GCC:*_*_IPF_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
> -Wno-error=maybe-uninitialized -Wno-format
>GCC:*_*_ARM_CC_FLAGS = $(OPENSSL_FLAGS)
>GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-format
> diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf 
> b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
> index 88134b5b5f..ff598e7d43 100644
> --- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
> +++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
> @@ -518,7 +518,7 @@
>#   types appropriate to the format string specified.
>#
>GCC:*_*_IA32_CC_FLAGS= -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
> -Wno-error=maybe-uninitialized
> -  GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
> -Wno-error=maybe-uninitialized -Wno-format
> -DNO_MSABI_VA_FUNCS
> +  GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
> -Wno-error=maybe-uninitialized -Wno-error=format
> -Wno-format -DNO_MSABI_VA_FUNCS
>GCC:*_*_IPF_CC_FLAGS = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
> -Wno-error=maybe-uninitialized -Wno-format
>GCC:*_*_ARM_CC_FLAGS = $(OPENSSL_FLAGS)
>GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-format
> --
> 2.15.1.windows.2

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


Re: [edk2] [Patch] MdeModulePkg/Ip4Dxe: Add an independent timer for reconfig checking

2018-01-11 Thread Wu, Jiaxin
Reviewed-by: Jiaxin Wu 


> -Original Message-
> From: Wang, Fan
> Sent: Thursday, January 11, 2018 6:20 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin ; Ye, Ting ; Fu,
> Siyuan 
> Subject: [Patch] MdeModulePkg/Ip4Dxe: Add an independent timer for
> reconfig checking
> 
> * Since wireless network can switch at very short time, the time interval
>   of reconfig event checking is too long for this case. To achieve better
>   performance and scalability, separate this task from Ip4 tick timer.
> 
> Cc: Jiaxin Wu 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan 
> ---
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c | 28
> +-
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c   | 47
> +++
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h   | 30
> ---
>  3 files changed, 83 insertions(+), 22 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
> b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
> index 49b7dc5..552c4e1 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
> @@ -1,9 +1,9 @@
>  /** @file
>The driver binding and service binding protocol for IP4 driver.
> 
> -Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
>  (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
> 
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -251,10 +251,11 @@ Ip4CreateService (
>IpSb->MnpConfigData.DisableBackgroundPolling  = FALSE;
> 
>ZeroMem (>SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE));
> 
>IpSb->Timer = NULL;
> +  IpSb->ReconfigCheckTimer = NULL;
> 
>IpSb->ReconfigEvent = NULL;
> 
>IpSb->Reconfig = FALSE;
> 
> @@ -283,10 +284,22 @@ Ip4CreateService (
>if (EFI_ERROR (Status)) {
>  goto ON_ERROR;
>}
> 
>Status = gBS->CreateEvent (
> +  EVT_NOTIFY_SIGNAL | EVT_TIMER,
> +  TPL_CALLBACK,
> +  Ip4TimerReconfigChecking,
> +  IpSb,
> +  >ReconfigCheckTimer
> +  );
> +
> +  if (EFI_ERROR (Status)) {
> +goto ON_ERROR;
> +  }
> +
> +  Status = gBS->CreateEvent (
>EVT_NOTIFY_SIGNAL,
>TPL_NOTIFY,
>Ip4AutoReconfigCallBack,
>IpSb,
>>ReconfigEvent
> @@ -408,10 +421,17 @@ Ip4CleanService (
>  gBS->CloseEvent (IpSb->Timer);
> 
>  IpSb->Timer = NULL;
>}
> 
> +  if (IpSb->ReconfigCheckTimer != NULL) {
> +gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerCancel, 0);
> +gBS->CloseEvent (IpSb->ReconfigCheckTimer);
> +
> +IpSb->ReconfigCheckTimer = NULL;
> +  }
> +
>if (IpSb->DefaultInterface != NULL) {
>  Status = Ip4FreeInterface (IpSb->DefaultInterface, NULL);
> 
>  if (EFI_ERROR (Status)) {
>return Status;
> @@ -628,10 +648,16 @@ Ip4DriverBindingStart (
> 
>if (EFI_ERROR (Status)) {
>  goto UNINSTALL_PROTOCOL;
>}
> 
> +  Status = gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerPeriodic, 500 *
> TICKS_PER_MS);
> +
> +  if (EFI_ERROR (Status)) {
> +goto UNINSTALL_PROTOCOL;
> +  }
> +
>//
>// Initialize the IP4 ID
>//
>mIp4Id = (UINT16)NET_RANDOM (NetRandomInitSeed ());
> 
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> index ac48ad2..b5cd7b7 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> @@ -1,8 +1,8 @@
>  /** @file
> 
> -Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -2247,22 +2247,14 @@ Ip4SentPacketTicking (
>}
> 
>return EFI_SUCCESS;
>  }
> 
> -
>  /**
> -  There are two steps for this the heart beat timer of IP4 service instance.
> -  First, it times out all of its IP4 children's received-but-not-delivered
> -  and transmitted-but-not-recycle packets, and provides time input for its
> -  IGMP protocol.
> -  Second, a dedicated timer is used to poll underlying media status. In case
> -  of cable swap, a new round auto configuration will be initiated. The timer
> -  will 

Re: [edk2] [Patch] NetworkPkg: Fix incorrect parameter check in PXE.Mtftp() function.

2018-01-11 Thread Wu, Jiaxin
Reviewed-by: Jiaxin Wu 


> -Original Message-
> From: Fu, Siyuan
> Sent: Thursday, January 11, 2018 5:19 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Wu, Jiaxin ; Wang,
> Fan 
> Subject: [Patch] NetworkPkg: Fix incorrect parameter check in PXE.Mtftp()
> function.
> 
> According to UEFI spec, the PXE.Mtftp() should return invalid parameter if
> the
> BufferPtr parameter was NULL and the DontUseBuffer parameter was FALSE.
> The DontUseBuffer is only used when perform MTFTP/TFTP read operation.
> 
> Cc: Ye Ting 
> Cc: Wu Jiaxin 
> Cc: Wang Fan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Fu Siyuan 
> ---
>  NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
> b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
> index 93f3bfa5ba..9068e0686c 100644
> --- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
> +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
> @@ -855,11 +855,19 @@ EfiPxeBcMtftp (
>(Filename == NULL) ||
>(BufferSize == NULL) ||
>(ServerIp == NULL) ||
> -  ((BufferPtr == NULL) && DontUseBuffer) ||
>((BlockSize != NULL) && (*BlockSize <
> PXE_MTFTP_DEFAULT_BLOCK_SIZE))) {
>  return EFI_INVALID_PARAMETER;
>}
> 
> +  if (Operation == EFI_PXE_BASE_CODE_TFTP_READ_FILE ||
> +  Operation == EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY ||
> +  Operation == EFI_PXE_BASE_CODE_MTFTP_READ_FILE ||
> +  Operation == EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY) {
> +if (BufferPtr == NULL && !DontUseBuffer) {
> +  return EFI_INVALID_PARAMETER;
> +}
> +  }
> +
>Config= NULL;
>Status= EFI_DEVICE_ERROR;
>Private   = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> --
> 2.13.0.windows.1

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


Re: [edk2] [Patch] MdeModulePkg/Ip4Dxe: Add an independent timer for reconfig checking

2018-01-11 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Wang Fan
> Sent: Thursday, January 11, 2018 6:20 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Wu,
> Jiaxin 
> Subject: [edk2] [Patch] MdeModulePkg/Ip4Dxe: Add an independent timer for
> reconfig checking
> 
> * Since wireless network can switch at very short time, the time interval
>   of reconfig event checking is too long for this case. To achieve better
>   performance and scalability, separate this task from Ip4 tick timer.
> 
> Cc: Jiaxin Wu 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan 
> ---
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c | 28 +-
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c   | 47 +++---
> -
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h   | 30 ---
>  3 files changed, 83 insertions(+), 22 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
> b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
> index 49b7dc5..552c4e1 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
> @@ -1,9 +1,9 @@
>  /** @file
>The driver binding and service binding protocol for IP4 driver.
> 
> -Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
>  (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
> 
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -251,10 +251,11 @@ Ip4CreateService (
>IpSb->MnpConfigData.DisableBackgroundPolling  = FALSE;
> 
>ZeroMem (>SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE));
> 
>IpSb->Timer = NULL;
> +  IpSb->ReconfigCheckTimer = NULL;
> 
>IpSb->ReconfigEvent = NULL;
> 
>IpSb->Reconfig = FALSE;
> 
> @@ -283,10 +284,22 @@ Ip4CreateService (
>if (EFI_ERROR (Status)) {
>  goto ON_ERROR;
>}
> 
>Status = gBS->CreateEvent (
> +  EVT_NOTIFY_SIGNAL | EVT_TIMER,
> +  TPL_CALLBACK,
> +  Ip4TimerReconfigChecking,
> +  IpSb,
> +  >ReconfigCheckTimer
> +  );
> +
> +  if (EFI_ERROR (Status)) {
> +goto ON_ERROR;
> +  }
> +
> +  Status = gBS->CreateEvent (
>EVT_NOTIFY_SIGNAL,
>TPL_NOTIFY,
>Ip4AutoReconfigCallBack,
>IpSb,
>>ReconfigEvent
> @@ -408,10 +421,17 @@ Ip4CleanService (
>  gBS->CloseEvent (IpSb->Timer);
> 
>  IpSb->Timer = NULL;
>}
> 
> +  if (IpSb->ReconfigCheckTimer != NULL) {
> +gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerCancel, 0);
> +gBS->CloseEvent (IpSb->ReconfigCheckTimer);
> +
> +IpSb->ReconfigCheckTimer = NULL;
> +  }
> +
>if (IpSb->DefaultInterface != NULL) {
>  Status = Ip4FreeInterface (IpSb->DefaultInterface, NULL);
> 
>  if (EFI_ERROR (Status)) {
>return Status;
> @@ -628,10 +648,16 @@ Ip4DriverBindingStart (
> 
>if (EFI_ERROR (Status)) {
>  goto UNINSTALL_PROTOCOL;
>}
> 
> +  Status = gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerPeriodic, 500 *
> TICKS_PER_MS);
> +
> +  if (EFI_ERROR (Status)) {
> +goto UNINSTALL_PROTOCOL;
> +  }
> +
>//
>// Initialize the IP4 ID
>//
>mIp4Id = (UINT16)NET_RANDOM (NetRandomInitSeed ());
> 
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> index ac48ad2..b5cd7b7 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> @@ -1,8 +1,8 @@
>  /** @file
> 
> -Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -2247,22 +2247,14 @@ Ip4SentPacketTicking (
>}
> 
>return EFI_SUCCESS;
>  }
> 
> -
>  /**
> -  There are two steps for this the heart beat timer of IP4 service
> instance.
> -  First, it times out all of its IP4 children's received-but-not-
> delivered
> -  and transmitted-but-not-recycle packets, and provides time input for
> its
> -  IGMP protocol.
> -  Second, a dedicated timer is used to poll underlying media status. In
> case
> -  of 

Re: [edk2] [Patch 0/7] EDK2: Enable XCODE5 tool chain with NASM source

2018-01-11 Thread Gao, Liming
Laszlo:
  Thanks for comments. I submit two bugs. One is for UefiCpuPkg, another is for 
BaseTools. 

https://bugzilla.tianocore.org/show_bug.cgi?id=849
https://bugzilla.tianocore.org/show_bug.cgi?id=850

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
> Ersek
> Sent: Thursday, January 11, 2018 6:03 PM
> To: Gao, Liming 
> Cc: edk2-devel@lists.01.org; Andrew Fish 
> Subject: Re: [edk2] [Patch 0/7] EDK2: Enable XCODE5 tool chain with NASM 
> source
> 
> On 01/11/18 10:54, Laszlo Ersek wrote:
> > Liming,
> >
> > On 01/10/18 16:24, Liming Gao wrote:
> >> 1. Use nasm source file for X86 tool chain, then ASM and S file can be 
> >> removed.
> >> 2. Update Nasm source file to resolve the absolute addressing.
> >> 3. Verify OVMF IA32, IA32X64 and X64 boot to shell functionality with 
> >> XCODE5
> >>Here is build command.
> >>build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE
> >>-DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
> >>build -p OvmfPkg\OvmfPkgIa32.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE
> >>-DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
> >>build -p OvmfPkg\OvmfPkgX64.dsc -a IA32 -a X64 -DSMM_REQUIRE=TRUE
> >>-DSECURE_BOOT_ENABLE=TRUE -DUSE_OLD_SHELL
> >> 4. Known limitation is XCODE5 doesn't support HII resource section 
> >> generation.
> >>So, new UEFI shell application tftp can't be used. Old shell is used.
> >
> > After sleeping on this, I got a question: is there a public bug report
> > in the clang / llvm bug tracker about this shortcoming? It would be nice
> > to reference it in the commit messages.
> >
> > The main reason I'm asking this is because these workarounds include
> > more and more DB / DW / DD / DQ mnemonics in the NASM source files. One
> > of the original promises of NASM was that we could cut down on the
> > binary representation of x86 instructions, just write real assembly
> > code. This was in part enabled by NASM supporting multi-mode assembly
> > files, such that mode transitions (e.g. from real mode to protected mode
> > to long mode) could still be implemented in a human-readable assembly file.
> >
> > So this workaround is a step back in that regard (i.e., for readability
> > and future updates). I agree we are sometimes forced to do such things
> > to support all the toolchains we target, but it would be nice to have
> > proof that the clang / llvm developers *intend* to fix this (possibly in
> > the next major release of XCODE -- I'm not sure). So a public bug report
> > that we could reference in the commit messages would be great.
> 
> Nevermind, I just read Mike's comments and the new approach; it's much
> better!
> 
> (Still, if we have an XCODE bug report, it would be nice to reference
> that in the commit messages.)
> 
> Thanks!
> Laszlo
> ___
> 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] [PATCH] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted

2018-01-11 Thread Ruiyu Ni
The Graphics Output Protocol's mode information specifies the
PixelsPerScanLine property. Most of the time this is identical to
HorizontalResolution. However, due to alignment requirements etc. it
may be slightly larger. I.e. each scan line will have some "pixels"
that are not visible on the screen but consume space in the frame
buffer.

If the graphics output protocol correctly initializes
HorizontalResolution to 1366 and PixelsPerScanLine to 1376. As a
result the graphics output is broken.

If setting HorizontalResolution to 1376 instead, the output is fine
(except for 10 invisible pixels on the right of the screen).

The patch fixes this bug by using PixelsPerScanLine when calculating
the line width.

Contributed-under: TianoCore Contribution Agreement 1.1
Reported-by: Christian Ehrhardt 
Signed-off-by: Ruiyu Ni 
Cc: Star Zeng 
Cc: Christian Ehrhardt 
---
 MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c 
b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
index 011d9c52cd..3e323fe3f0 100644
--- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
+++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
@@ -1,7 +1,7 @@
 /** @file
   FrameBufferBltLib - Library to perform blt operations on a frame buffer.
 
-  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -148,9 +148,9 @@ FrameBufferBltConfigure (
   FrameBufferBltLibConfigurePixelFormat (BitMask, , PixelShl, 
PixelShr);
 
   if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE)
- + FrameBufferInfo->HorizontalResolution * BytesPerPixel) {
+ + FrameBufferInfo->PixelsPerScanLine * BytesPerPixel) {
 *ConfigureSize = sizeof (FRAME_BUFFER_CONFIGURE)
-   + FrameBufferInfo->HorizontalResolution * BytesPerPixel;
+   + FrameBufferInfo->PixelsPerScanLine * BytesPerPixel;
 return RETURN_BUFFER_TOO_SMALL;
   }
 
@@ -164,7 +164,7 @@ FrameBufferBltConfigure (
   Configure->BytesPerPixel = BytesPerPixel;
   Configure->PixelFormat   = FrameBufferInfo->PixelFormat;
   Configure->FrameBuffer   = (UINT8*) FrameBuffer;
-  Configure->WidthInPixels = (UINTN) FrameBufferInfo->HorizontalResolution;
+  Configure->WidthInPixels = (UINTN) FrameBufferInfo->PixelsPerScanLine;
   Configure->Height= (UINTN) FrameBufferInfo->VerticalResolution;
   Configure->WidthInBytes  = Configure->WidthInPixels * 
Configure->BytesPerPixel;
 
-- 
2.15.1.windows.2

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


[edk2] [PATCH] UefiCpuPkg PiSmmCpuDxeSmm: Fixed #double fault on #page fault for IA32

2018-01-11 Thread Star Zeng
When StackGuard is enabled on IA32, the #double fault exception
is reported instead of #page fault.

This issue does not exist on X64, or IA32 without StackGuard.

The fix at e4435f710cea2d2f10cd7343d545920867780086 was incomplete.

It is because AllocateCodePages() is used to allocate buffer for
GDT and TSS, the code pages will be set to RO in SetMemMapAttributes().
But IA32 Stack Guard need use task switch to switch stack that need
write GDT and TSS, so AllocateCodePages() could not be used.

This patch uses AllocatePages() instead of AllocateCodePages() to
allocate buffer for GDT and TSS if StackGuard is enabled on IA32.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c  | 64 +++---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 10 +---
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 49 -
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c   | 50 +
 4 files changed, 57 insertions(+), 116 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
index 3c68c970245f..4c1499939b1b 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
@@ -1,7 +1,7 @@
 /** @file
   SMM CPU misc functions for Ia32 arch specific.
   
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -77,7 +77,12 @@ InitGdt (
 
 GdtTssTableSize = (gcSmiGdtr.Limit + 1 + TSS_SIZE * 2 + 7) & ~7; // 8 
bytes aligned
 mGdtBufferSize = GdtTssTableSize * 
gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
-GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES 
(mGdtBufferSize));
+//
+// IA32 Stack Guard need use task switch to switch stack that need
+// write GDT and TSS, so AllocateCodePages() could not be used here
+// as code pages will be set to RO. 
+//
+GdtTssTables = (UINT8*)AllocatePages (EFI_SIZE_TO_PAGES (mGdtBufferSize));
 ASSERT (GdtTssTables != NULL);
 mGdtBuffer = (UINTN)GdtTssTables;
 GdtTableStepSize = GdtTssTableSize;
@@ -127,61 +132,6 @@ InitGdt (
 }
 
 /**
-  This function sets GDT/IDT buffer to be RO and XP.
-**/
-VOID
-PatchGdtIdtMap (
-  VOID
-  )
-{
-  EFI_PHYSICAL_ADDRESS   BaseAddress;
-  UINTN  Size;
-
-  //
-  // GDT
-  //
-  DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - GDT:\n"));
-
-  BaseAddress = mGdtBuffer;
-  Size = ALIGN_VALUE(mGdtBufferSize, SIZE_4KB);
-  if (!FeaturePcdGet (PcdCpuSmmStackGuard)) {
-//
-// Do not set RO for IA32 when stack guard feature is enabled.
-// Stack Guard need use task switch to switch stack.
-// It need write GDT and TSS.
-//
-SmmSetMemoryAttributes (
-  BaseAddress,
-  Size,
-  EFI_MEMORY_RO
-  );
-  }
-  SmmSetMemoryAttributes (
-BaseAddress,
-Size,
-EFI_MEMORY_XP
-);
-
-  //
-  // IDT
-  //
-  DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - IDT:\n"));
-
-  BaseAddress = gcSmiIdtr.Base;
-  Size = ALIGN_VALUE(gcSmiIdtr.Limit + 1, SIZE_4KB);
-  SmmSetMemoryAttributes (
-BaseAddress,
-Size,
-EFI_MEMORY_RO
-);
-  SmmSetMemoryAttributes (
-BaseAddress,
-Size,
-EFI_MEMORY_XP
-);
-}
-
-/**
   Transfer AP to safe hlt-loop after it finished restore CPU features on S3 
patch.
 
   @param[in] ApHltLoopCode  The address of the safe hlt-loop function.
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index ef32f1767665..cbaa513244d5 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -1,7 +1,7 @@
 /** @file
 Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU.
 
-Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
 Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
 This program and the accompanying materials
@@ -510,14 +510,6 @@ InitGdt (
   );
 
 /**
-  This function sets GDT/IDT buffer to be RO and XP.
-**/
-VOID
-PatchGdtIdtMap (
-  VOID
-  );
-
-/**
 
   Register the SMM Foundation entry point.
 
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
index 2d7dba59bf30..16664f304cde 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
@@ -1,6 +1,6 @@
 /** @file