]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
5 years agoIntelSiliconPkg VTdDxe: Report status code for VTd error
Star Zeng [Wed, 24 Oct 2018 02:27:48 +0000 (10:27 +0800)]
IntelSiliconPkg VTdDxe: Report status code for VTd error

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1273

Current code only uses DEBUG() for VTd error.
This patch updates to also report status code for VTd error.

Test done:
Created case that has VTd error and confirmed the error
status code could be reported as expected.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
5 years agoIntelSiliconPkg VTdDxe: Option to force no early access attr request
Star Zeng [Wed, 17 Oct 2018 09:43:28 +0000 (17:43 +0800)]
IntelSiliconPkg VTdDxe: Option to force no early access attr request

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1272

To have high confidence in usage for platform, add option (BIT2 of
PcdVTdPolicyPropertyMask) to force no IOMMU access attribute request
recording before DMAR table is installed.

Check PcdVTdPolicyPropertyMask BIT2 before RequestAccessAttribute()
and ProcessRequestedAccessAttribute(), then RequestAccessAttribute(),
ProcessRequestedAccessAttribute() and mAccessRequestXXX variables
could be optimized by compiler when PcdVTdPolicyPropertyMask BIT2 = 1.

Test done:
1: Created case that has IOMMU access attribute request before DMAR
   table is installed, ASSERT was triggered after setting
   PcdVTdPolicyPropertyMask BIT2 to 1.

2. Confirmed RequestAccessAttribute(), ProcessRequestedAccessAttribute()
   and mAccessRequestXXX variables were optimized by compiler after
   setting PcdVTdPolicyPropertyMask BIT2 to 1.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
5 years agoMdeModulePkg/UsbBus: Removing trailing spaces
Ruiyu Ni [Thu, 25 Oct 2018 03:19:14 +0000 (11:19 +0800)]
MdeModulePkg/UsbBus: Removing trailing spaces

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoBaseTools: Move PcdValueInit to platform build folder
BobCF [Mon, 22 Oct 2018 03:24:13 +0000 (11:24 +0800)]
BaseTools: Move PcdValueInit to platform build folder

PcdValueInit tool is platform scope.
It should be generated into Platform output directory.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob C Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTool: Filter out unused structure pcds
BobCF [Fri, 19 Oct 2018 12:00:09 +0000 (20:00 +0800)]
BaseTool: Filter out unused structure pcds

The current code handle all the structure pcds
even if there is no module or library use them.
This patch is going to filter out the unused structure pcds.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools: Remove Arch specific build options for PcdValueInit tool.
BobCF [Thu, 18 Oct 2018 05:32:40 +0000 (13:32 +0800)]
BaseTools: Remove Arch specific build options for PcdValueInit tool.

PcdValueInit tool is Arch independent, the Arch specific
build options should be removed from PcdValueInit makefile.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob C Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools:Translate the StructurePCD value in field to correct format.
Zhaozh1x [Thu, 18 Oct 2018 09:46:40 +0000 (17:46 +0800)]
BaseTools:Translate the StructurePCD value in field to correct format.

For StructurePCD value got from DSC file, translate its field value in to
correct format in report.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
5 years agoBaseTools: Not convert the void* pcd string in command line to array.
Zhaozh1x [Fri, 19 Oct 2018 12:11:01 +0000 (20:11 +0800)]
BaseTools: Not convert the void* pcd string in command line to array.

For void* type pcd in command line, if its value is string, code should
not convert the void* pcd string in command line to array, otherwise it
will make the pcd value in report not match its real raw value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
5 years agoBaseTools: add ASSERT checker for array buffer in fdf and command line
Zhaozh1x [Mon, 22 Oct 2018 08:23:18 +0000 (16:23 +0800)]
BaseTools: add ASSERT checker for array buffer in fdf and command line

For structure PCD in fdf file and command line,
1. use compiler time assert to check the array index, report error
if array index exceeds the array number.
2. use compiler time assert to check the array size, report error
if the user declared size in header file is smaller than the user
used in fdf file and command line.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
5 years agoMdePkg: Handle AcpiExp device path when optional para is not specified
Dandan Bi [Fri, 12 Oct 2018 02:18:28 +0000 (10:18 +0800)]
MdePkg: Handle AcpiExp device path when optional para is not specified

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

AcpiExp text device path: AcpiExp(HID,CID,UIDSTR)
And according to UEFI spec, the CID parameter is optional
and has a default value of 0. But current implementation
miss to check following cases for the AcpiExp.
FromText:when text device is AcpiExp(HID,,UIDSTR)/AcpiExp(HID,0,UIDSTR)
ToText: when the CID is 0 in the node structure

This commit is to do the enhancement.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoMdePkg: Handle USBxxx device path when optional para is not specified
Dandan Bi [Fri, 12 Oct 2018 02:18:27 +0000 (10:18 +0800)]
MdePkg: Handle USBxxx device path when optional para is not specified

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

According to UEFI spec,
for the Messaging Device Path with USB Class SubType, some paras
are optional in the text device path.
Take UsbClass(VID,PID,Class,SubClass,Protocol) for example,
The VID is an integer between 0 and 65535 and is optional. The
default value is 0xFFFF.
The PID is an integer between 0 and 65535 and is optional. The
default value is 0xFFFF.
The Class is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The SubClass is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The Protocol is an integer between 0 and 255 and is optional. The
default value is 0xFF.
So if any the optional para is not specified in the text device,
we should set related para in the node structure to default value.

This commit is to do the enhancement for USB Class device path
when optional para is not specified

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoMdePkg: Handle Sata device path when optional para is not specified
Dandan Bi [Fri, 12 Oct 2018 02:18:26 +0000 (10:18 +0800)]
MdePkg: Handle Sata device path when optional para is not specified

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

Sata device path format:Sata(HPN, PMPN, LUN)
According to UEFI Spec, the PMPN is an integer between
0 and 65535 and is optional. If not provided, the default is 0xFFFF.

This commit is to do the enhancement for Sata device path
when optional para is not specified.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoFatPkg: Correct the line ending to CRLF
Ruiyu Ni [Wed, 24 Oct 2018 07:22:31 +0000 (15:22 +0800)]
FatPkg: Correct the line ending to CRLF

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoMdePkg-BaseLib: Fix PathCleanUpDirectories() issue with "\\..\\.."
Jim.Dailey@dell.com [Fri, 5 Oct 2018 19:14:56 +0000 (03:14 +0800)]
MdePkg-BaseLib: Fix PathCleanUpDirectories() issue with "\\..\\.."

Replace multiple, consecutive "\" characters prior to other processing
involving "\" characters.  This fixes an issue where "\\..\\..",
"//..//..", and similar input paths are not cleaned properly.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
Reviewed-by: Ruiyu Ni <Ruiyu.ni@Intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoFatPkg/EnhancedFatDxe Fix Double Cluster Allocation
Robinson, Herbie [Fri, 7 Sep 2018 00:07:09 +0000 (08:07 +0800)]
FatPkg/EnhancedFatDxe Fix Double Cluster Allocation

This is a fix for a double cluster allocation when the disk is full.
The double allocation happens because FatGrowEof calls
FatAllocateCluster without immediately marking the each returned
cluster as allocated. The fix is to move the FatSetFatEntry call
inside the loop.
I've also include some improvements to the sanity checks that I added
while tracking this down. They are optional.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Herbie Robinson <Herbie.Robinson@stratus.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoFatBinPkg: Remove FatBinPkg and refresh document
shenglei [Tue, 16 Oct 2018 05:55:51 +0000 (13:55 +0800)]
FatBinPkg: Remove FatBinPkg and refresh document

Remove FatBinPkg and refresh Maintainers.txt.
https://bugzilla.tianocore.org/show_bug.cgi?id=1105

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Andrew Fish <afish@apple.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
5 years agoShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST
Ruiyu Ni [Thu, 11 Oct 2018 07:51:45 +0000 (15:51 +0800)]
ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1236

When "dmem" runs without additional arguments, it dumps the memory
content of EFI_SYSTEM_TABLE. But today's implementation dumps 512
bytes. It's not correct because sizeof (EFI_SYSTEM_TABLE) is less
than 512, the 512-read causes page fault exception in a heap-guard
enabled environment.

The patch changes the implementation to only dump
sizeof (EFI_SYSTEM_TABLE) bytes for gST.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Jim Dailey <jim_dailey@.com>
5 years agoMdeModulePkg/UsbMass: Fix USB key write failure
Ruiyu Ni [Tue, 23 Oct 2018 02:26:01 +0000 (10:26 +0800)]
MdeModulePkg/UsbMass: Fix USB key write failure

Commit e59db6a732dbbb064b1e39a288a25edc90adac5d
* MdeModulePkg/UsbMass: Merge UsbBoot(Read|Write)Blocks(16)
introduces a bug that causes writing to USB key always fails.

When that patch is verified, only reading was verified.

The root cause is when the writing operation is performed,
the data direction EfiUsbDataIn is wrongly used. Instead, it
should be EfiUsbDataOut.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoBaseTools/UPT: Fix an issue of UNI string checking.
Hess Chen [Tue, 16 Oct 2018 06:04:00 +0000 (14:04 +0800)]
BaseTools/UPT: Fix an issue of UNI string checking.

The tool now can detect the error that the content between double
quotes contains another double quotes or enter key.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
5 years agoBaseTools/Ecc: Update a checkpoint criteria.
Hess Chen [Tue, 16 Oct 2018 05:49:35 +0000 (13:49 +0800)]
BaseTools/Ecc: Update a checkpoint criteria.

Change the criteria of the checkpoint of "#ifndef" to remove the requirement of prefix '_'.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
5 years agoBaseTools/ECC: Fix an identification issue of typedef function.
Hess Chen [Tue, 16 Oct 2018 08:21:48 +0000 (16:21 +0800)]
BaseTools/ECC: Fix an identification issue of typedef function.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
5 years agoBaseTools/ECC: Add a checkpoint to check no usage for deprecated functions.
Hess Chen [Wed, 17 Oct 2018 02:22:04 +0000 (10:22 +0800)]
BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
5 years agoBaseTools: Add more checker in Decompress algorithm to access the valid buffer (CVE...
Liming Gao [Tue, 16 Oct 2018 02:06:13 +0000 (10:06 +0800)]
BaseTools: Add more checker in Decompress algorithm to access the valid buffer (CVE FIX)

Fix CVE-2017-5731,CVE-2017-5732,CVE-2017-5733,CVE-2017-5734,CVE-2017-5735
https://bugzilla.tianocore.org/show_bug.cgi?id=686

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Holtsclaw Brent <brent.holtsclaw@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
5 years agoIntelFrameworkModulePkg: Add more checker in UefiTianoDecompressLib (CVE FIX)
Liming Gao [Tue, 16 Oct 2018 02:06:12 +0000 (10:06 +0800)]
IntelFrameworkModulePkg: Add more checker in UefiTianoDecompressLib (CVE FIX)

Fix CVE-2017-5731,CVE-2017-5732,CVE-2017-5733,CVE-2017-5734,CVE-2017-5735
https://bugzilla.tianocore.org/show_bug.cgi?id=686
To make sure the valid buffer be accessed only.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Holtsclaw Brent <brent.holtsclaw@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
5 years agoMdePkg: Add more checker in UefiDecompressLib to access the valid buffer only (CVE...
Liming Gao [Tue, 16 Oct 2018 02:06:11 +0000 (10:06 +0800)]
MdePkg: Add more checker in UefiDecompressLib to access the valid buffer only (CVE FIX)

Fix CVE-2017-5731,CVE-2017-5732,CVE-2017-5733,CVE-2017-5734,CVE-2017-5735
https://bugzilla.tianocore.org/show_bug.cgi?id=686

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Holtsclaw Brent <brent.holtsclaw@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
5 years agoMdeModulePkg/UdfDxe: Avoid possible use of already-freed data
Hao Wu [Tue, 16 Oct 2018 05:09:43 +0000 (13:09 +0800)]
MdeModulePkg/UdfDxe: Avoid possible use of already-freed data

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1255

For function ReadFile():

If the line

  Status = GetAedAdsData (
   ...
   );

is reached multiple times during the 'for' loop, freeing the data pointed
by variable 'Data' may potentially lead to variable 'Ad' referencing the
already-freed data.

After calling function GetAllocationDescriptor(), 'Data' and 'Ad' may
point to the same memory (with some possible offset). Hence, this commit
will move the FreePool() call backwards to ensure the data will no longer
be used.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Add more check when getting PD from LongAd
Hao Wu [Tue, 16 Oct 2018 04:16:02 +0000 (12:16 +0800)]
MdeModulePkg/UdfDxe: Add more check when getting PD from LongAd

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1254

This commit will add an additional check within function GetPdFromLongAd()
when getting a Partition Descriptor from given a Long Allocation
Descriptor.

According to UDF 2.60 Spec, Section 2.2.13:

> The partition reference numbers used are determined by the order of the
> Partition Maps in the LVD.

(Also the picture comes before the above contents)

And a more detailed explanation of the partition reference numbers is at
https://sites.google.com/site/udfintro/ (seems not a formal documentation
though), Section 5.3.6.

Based on the above findings, the 'PartitionReferenceNumber' field in a
Long Allocation Descriptor is used as an index to access the Partition
Maps data within a Logical Volume Descriptor.

Hence, the new check focuses on the validity of this
'PartitionReferenceNumber' field in a Long Allocation Descriptor. Since
the current implementation of UdfDxe driver supports only one partition on
a Logical Volume, so the value of 'PartitionReferenceNumber' should be 0.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Update GetInfo() for FS VolumeLabel info request
Hao Wu [Fri, 12 Oct 2018 06:49:41 +0000 (14:49 +0800)]
MdeModulePkg/UdfDxe: Update GetInfo() for FS VolumeLabel info request

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1175

This commit will update the UdfGetInfo() function with the support of
EFI_FILE_SYSTEM_VOLUME_LABEL data information request.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Fix a typo within SetFileInfo()
Hao Wu [Mon, 8 Oct 2018 06:34:19 +0000 (14:34 +0800)]
MdeModulePkg/UdfDxe: Fix a typo within SetFileInfo()

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1253

Within function SetFileInfo():
This commit will fix a typo where 'Minute' should be used instead of
'Second'.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Correct behavior for UdfSetPosition()
Hao Wu [Mon, 8 Oct 2018 06:04:48 +0000 (14:04 +0800)]
MdeModulePkg/UdfDxe: Correct behavior for UdfSetPosition()

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1252

Calling the 'SetPosition' service of the EFI_FILE_PROTOCOL with 'Position'
equals to 0xFFFFFFFFFFFFFFFF for a file is to set the current position to
the end of the file. But the current implementation of function
UdfSetPosition() is to set it to the last byte (not EOF).

This commit will resolve this issue.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Add boundary check for getting volume (free) size
Hao Wu [Wed, 13 Dec 2017 08:28:33 +0000 (16:28 +0800)]
MdeModulePkg/UdfDxe: Add boundary check for getting volume (free) size

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828

Within GetVolumeSize():

The boundary check will validate the 'NumberOfPartitions' field of a
Logical Volume Integrity Descriptor matches the data within the relating
Logical Volume Descriptor.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Add boundary check for ComponentIdentifier decode
Hao Wu [Wed, 13 Dec 2017 06:39:07 +0000 (14:39 +0800)]
MdeModulePkg/UdfDxe: Add boundary check for ComponentIdentifier decode

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828

Within ResolveSymlink():

The boundary check will validate the 'LengthofComponentIdentifier' field
of a Path Component matches the data within the relating (Extended) File
Entry.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Add boundary check the read of FE/EFE
Hao Wu [Wed, 13 Dec 2017 02:23:41 +0000 (10:23 +0800)]
MdeModulePkg/UdfDxe: Add boundary check the read of FE/EFE

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828

Within ReadFile():

Add checks to ensure that when getting the raw data or the Allocation
Descriptors' data from a FE/EFE, it will not consume data beyond the
size of a FE/EFE.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Refine boundary checks for file/path name string
Hao Wu [Tue, 12 Dec 2017 08:30:18 +0000 (16:30 +0800)]
MdeModulePkg/UdfDxe: Refine boundary checks for file/path name string

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828

The commit refines the boundary checks for file/path name string to
prevent possible buffer overrun.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/PartitionDxe: Add check for underlying device block size
Hao Wu [Fri, 15 Dec 2017 03:22:16 +0000 (11:22 +0800)]
MdeModulePkg/PartitionDxe: Add check for underlying device block size

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828

Within FindAnchorVolumeDescriptorPointer():

Add a check for the underlying device block size to ensure it is greater
than the size of an Anchor Volume Descriptor Pointer.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Acked-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg Xhci: Handle value 5 in Port Speed field of PORTSC
Star Zeng [Sun, 21 Oct 2018 03:12:01 +0000 (11:12 +0800)]
MdeModulePkg Xhci: Handle value 5 in Port Speed field of PORTSC

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1267

The value 5 Port Speed field of PORTSC is new defined in
XHCI 1.1 spec November 2017.

This patch updates XhciDxe and XhciPei to handle it, otherwise
the USB 3.1 device may not be recognized with the XHCI controller
following XHCI 1.1 spec November 2017.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoMdeModulePkg XhciDxe: Assign Usb2Hc.XXXRevision based on SBRN
Star Zeng [Sun, 21 Oct 2018 04:12:39 +0000 (12:12 +0800)]
MdeModulePkg XhciDxe: Assign Usb2Hc.XXXRevision based on SBRN

Current hard code Usb2Hc.XXXRevision may be not accurate.
This patch updates code to assign Usb2Hc.XXXRevision based on
SBRN (Serial Bus Release Number, PCI configuration space offset
0x60) although there is no code consuming them.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoBaseTools: Fix the *B and *F Flag display for Structure Pcd
Yonghong Zhu [Fri, 19 Oct 2018 07:10:30 +0000 (15:10 +0800)]
BaseTools: Fix the *B and *F Flag display for Structure Pcd

Because of we newly add the PcdFieldValueFromComm and
PcdFieldValueFromFdf in early parser phase, so in the report we use
the saved value in this two variables to print it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoMdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly
Hao Wu [Fri, 19 Oct 2018 02:29:36 +0000 (10:29 +0800)]
MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properly

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1262

Current implementation of BaseLib APIs:

AsciiStrToUnicodeStr()
AsciiStrToUnicodeStrS()
AsciiStrnToUnicodeStrS()

do not handle EASCII properly.

More specifically, if the value of ASCII character is larger than 0x7F,
then the converted Unicode character will have all '1's in the higher 8
bits.

An example:
  0xC9 => 0xFFC9 (current implementations)
and it should be:
  0xC9 => 0x00C9

This commit will address this issue.

Cc: Bin.Lain <bin_601@mail2000.com.tw>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools: Convert "Unicode string" to "byte array" if value type diff
Zhaozh1x [Thu, 18 Oct 2018 02:42:34 +0000 (10:42 +0800)]
BaseTools: Convert "Unicode string" to "byte array" if value type diff

V2:
Fixed 3 typo.
Use startswith(('L"',"L'")) to check if a string is Unicode string.
Use a set PcdValueTypeSet instead of a list PcdValueTypeList to save
memory.

V1:
For the same one VOID* pcd, if the default value type of one SKU is
"Unicode string", the other SKUs are "OtherVOID*"(ASCII string or
byte array),Then convert "Unicode string" to "byte array".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
5 years agoBaseTool: Support different PCDs that refers to the same EFI variable.
Zhaozh1x [Wed, 10 Oct 2018 08:27:02 +0000 (16:27 +0800)]
BaseTool: Support different PCDs that refers to the same EFI variable.

V2:
Make the code of patch both compatible for Python2 and Python3.

V1:
If different PCDs refer to the same EFI variable, then do EFI variable
combination, according to the VariableOffset of different PCDS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
5 years agoUefiCpuPkg/CpuCommonFeaturesLib: Register MSR base on scope Info.
Eric Dong [Wed, 17 Oct 2018 01:24:05 +0000 (09:24 +0800)]
UefiCpuPkg/CpuCommonFeaturesLib: Register MSR base on scope Info.

Because MSR has scope attribute, driver has no needs to set
MSR for all APs if MSR scope is core or package type. This patch
updates code to base on the MSR scope value to add MSR to the register
table.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoUefiCpuPkg/CpuS3DataDxe: Keep old data if value already existed.
Eric Dong [Wed, 17 Oct 2018 01:01:15 +0000 (09:01 +0800)]
UefiCpuPkg/CpuS3DataDxe: Keep old data if value already existed.

AcpiCpuData add new fields, keep these fields if old data already existed.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
5 years agoUefiCpuPkg/PiSmmCpuDxeSmm: Add logic to support semaphore type.
Eric Dong [Mon, 15 Oct 2018 02:34:59 +0000 (10:34 +0800)]
UefiCpuPkg/PiSmmCpuDxeSmm: Add logic to support semaphore type.

V4 changes:
1. Serial console log for different threads when program register table.
2. Check the AcpiCpuData before use it to avoid potential ASSERT.

V3 changes:
1. Use global variable instead of internal function to return string for register type
   and dependence type.
2. Add comments for some complicated logic.

V1 changes:
Because this driver needs to set MSRs saved in normal boot phase, sync
semaphore logic from RegisterCpuFeaturesLib code which used for normal boot phase.

Detail see below change for RegisterCpuFeaturesLib:
  UefiCpuPkg/RegisterCpuFeaturesLib: Add logic to support semaphore type.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
5 years agoUefiCpuPkg/RegisterCpuFeaturesLib: Add logic to support semaphore type.
Eric Dong [Wed, 17 Oct 2018 01:31:03 +0000 (09:31 +0800)]
UefiCpuPkg/RegisterCpuFeaturesLib: Add logic to support semaphore type.

V4 changes include:
1. Serial debug message for different threads when program the register table.

V3 changes include:
1. Use global variable instead of internal function to return string for register type
   and dependence type.
2. Add comments for some complicated logic.

V2 changes include:
1. Add more description for the code part which need easy to understand.
2. Refine some code base on feedback for V1 changes.

V1 changes include:
In a system which has multiple cores, current set register value task costs huge times.
After investigation, current set MSR task costs most of the times. Current logic uses
SpinLock to let set MSR task as an single thread task for all cores. Because MSR has
scope attribute which may cause GP fault if multiple APs set MSR at the same time,
current logic use an easiest solution (use SpinLock) to avoid this issue, but it will
cost huge times.

In order to fix this performance issue, new solution will set MSRs base on their scope
attribute. After this, the SpinLock will not needed. Without SpinLock, new issue raised
which is caused by MSR dependence. For example, MSR A depends on MSR B which means MSR A
must been set after MSR B has been set. Also MSR B is package scope level and MSR A is
thread scope level. If system has multiple threads, Thread 1 needs to set the thread level
MSRs and thread 2 needs to set thread and package level MSRs. Set MSRs task for thread 1
and thread 2 like below:

            Thread 1                 Thread 2
MSR B          N                        Y
MSR A          Y                        Y

If driver don't control execute MSR order, for thread 1, it will execute MSR A first, but
at this time, MSR B not been executed yet by thread 2. system may trig exception at this
time.

In order to fix the above issue, driver introduces semaphore logic to control the MSR
execute sequence. For the above case, a semaphore will be add between MSR A and B for
all threads. Semaphore has scope info for it. The possible scope value is core or package.
For each thread, when it meets a semaphore during it set registers, it will 1) release
semaphore (+1) for each threads in this core or package(based on the scope info for this
semaphore) 2) acquire semaphore (-1) for all the threads in this core or package(based
on the scope info for this semaphore). With these two steps, driver can control MSR
sequence. Sample code logic like below:

  //
  // First increase semaphore count by 1 for processors in this package.
  //
  for (ProcessorIndex = 0; ProcessorIndex < PackageThreadsCount ; ProcessorIndex ++) {
    LibReleaseSemaphore ((UINT32 *) &SemaphorePtr[PackageOffset + ProcessorIndex]);
  }
  //
  // Second, check whether the count has reach the check number.
  //
  for (ProcessorIndex = 0; ProcessorIndex < ValidApCount; ProcessorIndex ++) {
    LibWaitForSemaphore (&SemaphorePtr[ApOffset]);
  }

Platform Requirement:
1. This change requires register MSR setting base on MSR scope info. If still register MSR
   for all threads, exception may raised.

Known limitation:
1. Current CpuFeatures driver supports DXE instance and PEI instance. But semaphore logic
   requires Aps execute in async mode which is not supported by PEI driver. So CpuFeature
   PEI instance not works after this change. We plan to support async mode for PEI in phase
   2 for this task.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoUefiCpuPkg/RegisterCpuFeaturesLib.h: Add new dependence types.
Eric Dong [Mon, 15 Oct 2018 01:21:06 +0000 (09:21 +0800)]
UefiCpuPkg/RegisterCpuFeaturesLib.h: Add new dependence types.

V4 changes:
  1. Update comments.

v3 changes:
  1. Move CPU_FEATURE_DEPENDENCE_TYPE definition to AcpiCpuData.h.
  2. Add comments for CPU_FEATURE_BEFORE/CPU_FEATURE_AFTER.

v1 changes:
Add new core/package dependence types which consumed by different MSRs.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoUefiCpuPkg/Include/AcpiCpuData.h: Add Semaphore related Information.
Eric Dong [Mon, 15 Oct 2018 01:19:18 +0000 (09:19 +0800)]
UefiCpuPkg/Include/AcpiCpuData.h: Add Semaphore related Information.

v3 changes:
1. Move CPU_FEATURE_DEPENDENCE_TYPE definition here from RegisterCpuFeaturesLib.h file.
2. Add Invalid type for REGISTER_TYPE which will be used in code.

v2 changes:
1. Add more description about why we do this change.
2. Change structure field type from pointer to EFI_PHYSICAL_ADDRESS because it will
   be share between PEI and DXE.

v1 Changes:
In order to support semaphore related logic, add new definition for it.

In a system which has multiple cores, current set register value task costs huge times.
After investigation, current set MSR task costs most of the times. Current logic uses
SpinLock to let set MSR task as an single thread task for all cores. Because MSR has
scope attribute which may cause GP fault if multiple APs set MSR at the same time,
current logic use an easiest solution (use SpinLock) to avoid this issue, but it will
cost huge times.

In order to fix this performance issue, new solution will set MSRs base on their scope
attribute. After this, the SpinLock will not needed. Without SpinLock, new issue raised
which is caused by MSR dependence. For example, MSR A depends on MSR B which means MSR A
must been set after MSR B has been set. Also MSR B is package scope level and MSR A is
thread scope level. If system has multiple threads, Thread 1 needs to set the thread level
MSRs and thread 2 needs to set thread and package level MSRs. Set MSRs task for thread 1
and thread 2 like below:

            Thread 1                 Thread 2
MSR B          N                        Y
MSR A          Y                        Y

If driver don't control execute MSR order, for thread 1, it will execute MSR A first, but
at this time, MSR B not been executed yet by thread 2. system may trig exception at this
time.

In order to fix the above issue, driver introduces semaphore logic to control the MSR
execute sequence. For the above case, a semaphore will be add between MSR A and B for
all threads. Semaphore has scope info for it. The possible scope value is core or package.
For each thread, when it meets a semaphore during it set registers, it will 1) release
semaphore (+1) for each threads in this core or package(based on the scope info for this
semaphore) 2) acquire semaphore (-1) for all the threads in this core or package(based
on the scope info for this semaphore). With these two steps, driver can control MSR
sequence. Sample code logic like below:

  //
  // First increase semaphore count by 1 for processors in this package.
  //
  for (ProcessorIndex = 0; ProcessorIndex < PackageThreadsCount ; ProcessorIndex ++) {
    LibReleaseSemaphore ((UINT32 *) &SemaphorePtr[PackageOffset + ProcessorIndex]);
  }
  //
  // Second, check whether the count has reach the check number.
  //
  for (ProcessorIndex = 0; ProcessorIndex < ValidApCount; ProcessorIndex ++) {
    LibWaitForSemaphore (&SemaphorePtr[ApOffset]);
  }

Platform Requirement:
1. This change requires register MSR setting base on MSR scope info. If still register MSR
   for all threads, exception may raised.

Known limitation:
1. Current CpuFeatures driver supports DXE instance and PEI instance. But semaphore logic
   requires Aps execute in async mode which is not supported by PEI driver. So CpuFeature
   PEI instance not works after this change. We plan to support async mode for PEI in phase
   2 for this task.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
5 years agoNetworkPkg/IpSecDxe: Fix issue to parse SA Payload.
Jiaxin Wu [Fri, 12 Oct 2018 08:00:57 +0000 (16:00 +0800)]
NetworkPkg/IpSecDxe: Fix issue to parse SA Payload.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1251

*v2: Correct the type of parameters in Ikev2ParseProposalData(), and refined
the corresponding description.

IpSecDxe failed to create the Child SA during parsing SA Payload, the issue
was caused by the below commit:

SHA-1: 1e0db7b11987d0ec93be7dfe26102a327860fdbd
* MdeModulePkg/NetworkPkg: Checking for NULL pointer before use.

In above commit, it changed the value of IsMatch in Ikev2ChildSaParseSaPayload()
to FALSE. That's correct but it exposed the potential bug in to match the correct
proposal Data, which will cause the issue happen.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
5 years agoNetworkPkg: Correct the time stamp and fix the integer overflow issue.
Jiaxin Wu [Tue, 16 Oct 2018 05:34:00 +0000 (13:34 +0800)]
NetworkPkg: Correct the time stamp and fix the integer overflow issue.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=883.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
5 years agoNetworkPkg/TlsDxe: Remove the redundant library class.
Jiaxin Wu [Tue, 16 Oct 2018 01:52:13 +0000 (09:52 +0800)]
NetworkPkg/TlsDxe: Remove the redundant library class.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1018.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
5 years agoBaseTools: Fix one crash bug in the report for Fixed structure Pcd
Yonghong Zhu [Thu, 18 Oct 2018 14:12:20 +0000 (22:12 +0800)]
BaseTools: Fix one crash bug in the report for Fixed structure Pcd

The case is:
in the DSC file:
SKUID_IDENTIFIER               = ALL

[SkuIds]
  0|DEFAULT
  1|A

[PcdsFixedAtBuild.common.A]
  TokenSpaceGuid.Test401|{0x0F, 0x12}
  TokenSpaceGuid.Test401.TEST401INT8ARRAY[0]|'B'

in the build report, Data = OverrideValues[Keys[0]], but the Keys[0]
is the keyword "DEFAULT", and in this case the "DEFAULT" SKU doesn't
save any value, then it cause the Data is empty, in the next code
when we use the code it cause crash.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
5 years agoBaseTools: delete unused file
Carsey, Jaben [Wed, 10 Oct 2018 23:30:06 +0000 (07:30 +0800)]
BaseTools: delete unused file

this file is not imported/used.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
5 years agoBaseTools: Fix the crash issue when Dynamic structure Pcd use in FDF
Yonghong Zhu [Fri, 19 Oct 2018 07:15:02 +0000 (15:15 +0800)]
BaseTools: Fix the crash issue when Dynamic structure Pcd use in FDF

The case is use Dynamic structure Pcd in the FDF file.
Current code already save the  Guid, Name and Filed info for those Pcd,
but it directly use the dict key as [Name, Guid] and cause this crash
issue.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=1264
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
5 years agoBaseTools: Fix the bug that PcdValueFromComm is not set
Yonghong Zhu [Fri, 19 Oct 2018 07:25:39 +0000 (15:25 +0800)]
BaseTools: Fix the bug that PcdValueFromComm is not set

the bug is PcdValueFromComm is not set, but the Pcd have been override
by the command line option.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
5 years agoMdePkg UefiLib: Check Table against NULL in ScanTableInSDT
Star Zeng [Fri, 19 Oct 2018 07:56:57 +0000 (15:56 +0800)]
MdePkg UefiLib: Check Table against NULL in ScanTableInSDT

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1266

af5e95215928e052445c473f1244412dadea8252 abstracted generic functions
from different modules (IntelVTdDxe, S3SaveStateDxe, PcRtc,
DpDynamicCommand and PiSmmCpuDxeSmm). Some of them (IntelVTdDxe and
PcRtc) checked Table against NULL before accessing Table->Signature,
some (S3SaveStateDxe, DpDynamicCommand and PiSmmCpuDxeSmm did not.

The ScanTableInSDT() in Acpi.c of UefiLib was mainly from
S3SaveStateDxe, so it does not check Table against NULL before
accessing Table->Signature.

This patch updates ScanTableInSDT() to check Table against NULL first
before accessing Table->Signature.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
5 years agoIntelFsp2Pkg: Support FSP Dispatch mode
Chasel, Chiu [Thu, 11 Oct 2018 13:22:12 +0000 (21:22 +0800)]
IntelFsp2Pkg: Support FSP Dispatch mode

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1241

Add support for both API (original mode) and DISPATCH mode:
1. Add FspMode field from reserved byte of Global
   Data Structure to tell which mode is selected by boot
   loader. If boot loader invoking FSP-M API this field
   will remain as default 0 (API mode), otherwise platform
   FSP should set this field to 1 (Dispatch mode) when
   initializing Global Data Structure.
2. gFspInApiModePpiGuid will be instaled when FSP running in API
   mode and modules only for API mode should have this in depex.
3. If it is DISPATCH mode, FSP will return to PEI dispatcher,
   not directly return to boot loader.
4. DISPATCH mode supports DXE NotifyPhase drivers so FSP
   will not wait for PEI NotifyPhase callbacks, instead it
   will install gFspReadyForNotifyPhasePpiGuid PPI for
   platform to complete late initialization before transferring
   to DXE.

Test: Verified FSP API and DISPATCH modes on 2 internal
      platforms and both boot successfully.

Cc: Jiewen Yao <Jiewen.yao@intel.com>
Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
5 years agoBaseTools: Remove the step to freeze python tool
Liming Gao [Tue, 16 Oct 2018 15:08:46 +0000 (23:08 +0800)]
BaseTools: Remove the step to freeze python tool

https://bugzilla.tianocore.org/show_bug.cgi?id=1257
Binary python tool is not supported anymore. So, the freeze python tool
step is not required.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
5 years agoMdeModulePkg BrotliDecompressLib: Add the checker to avoid array out of bound
Liming Gao [Tue, 16 Oct 2018 07:27:15 +0000 (15:27 +0800)]
MdeModulePkg BrotliDecompressLib: Add the checker to avoid array out of bound

This change is to pass static analysis.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoUefiCpuPkg/CpuExceptionHandlerLib: always clear descriptor data in advance
Jian J Wang [Wed, 17 Oct 2018 04:49:57 +0000 (12:49 +0800)]
UefiCpuPkg/CpuExceptionHandlerLib: always clear descriptor data in advance

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1237

Sometimes the memory will be contaminated by random data left in last
boot (warm reset). The code should not assume the allocated memory is
always filled with zero. This patch add code to clear data structure
used for stack switch to prevent such problem from happening.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
5 years agoBaseTools: Fix bug caused by 03c36c36a3
Yonghong Zhu [Wed, 17 Oct 2018 12:15:07 +0000 (20:15 +0800)]
BaseTools: Fix bug caused by 03c36c36a3

In the expression for unicode string and general string compare, it
should check whether it startswith "L'" or 'L"', but not "L".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools: Fix a bug --pcd option enable and use the pcd in expression
Yonghong Zhu [Tue, 16 Oct 2018 08:10:24 +0000 (16:10 +0800)]
BaseTools: Fix a bug --pcd option enable and use the pcd in expression

the case is:
in the DSC:
[PcdsFixedAtBuild.common]
 TokenSpaceGuid.TestFixedPcd|0xFFEAA000

[PcdsDynamicExDefault.common.DEFAULT]
!if TokenSpaceGuid.PcdFlag == TRUE
TokenSpaceGuid.PcdTest|TokenSpaceGuid.TestFixedPcd
!endif

Then build with --pcd TokenSpaceGuid.PcdFlag=TRUE, it report failure,
but if we build without this --pcd option, it could build success.
we found when the --pcd is enabled, the fixedatbuild pcds are not be
collected into expression to calculate.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=1256
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoMdeModulePkg/UdfDxe: Handle dead codes in FileSystemOperations.c
Hao Wu [Mon, 15 Oct 2018 02:26:08 +0000 (10:26 +0800)]
MdeModulePkg/UdfDxe: Handle dead codes in FileSystemOperations.c

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1249

We found potential dead codes within File.c during the code coverage test.

After manual review, we think the below ones are positive reports:

A. For function GetAllocationDescriptor():
Due to the all the calling places for this function, the input parameter
'RecordingFlags' can only with value 'LongAdsSequence' or
'ShortAdsSequence'. Moreover, this is also mentioned in the function
description comments for GetAllocationDescriptor().

So the below code will never be reached:

  return EFI_DEVICE_ERROR;

This commit will add "ASSERT (FALSE);" before the above line to indicate
this and thus matching the function description comments.

B. For function GetAllocationDescriptorLsn():
Due to the all the calling places for this function, the input parameter
'RecordingFlags' can only with value 'LongAdsSequence' or
'ShortAdsSequence'. Moreover, this is also mentioned in the function
description comments for GetAllocationDescriptorLsn().

So the below code will never be reached:

  return EFI_UNSUPPORTED;

This commit will add "ASSERT (FALSE);" before the above line to indicate
this and thus matching the function description comments.

Cc: Paulo Alcantara <palcantara@suse.de>
Cc: Paulo Alcantara <paulo@paulo.ac>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Handle dead codes in File.c
Hao Wu [Wed, 10 Oct 2018 13:00:20 +0000 (21:00 +0800)]
MdeModulePkg/UdfDxe: Handle dead codes in File.c

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1249

We found potential dead codes within File.c during the code coverage test.

After manual review, we think the below ones are positive reports:

A. In function UdfRead():
  else if (IS_FID_DELETED_FILE (Parent->FileIdentifierDesc)) {
    Status = EFI_DEVICE_ERROR;
  }

A File Identifier Descriptor will be get from the UDF media only by
function ReadDirectoryEntry(). And within this function, all the File
Identifier Descriptor with 'DELETED_FILE' characteristics will be skipped
and will not be returned. Hence, the above codes in function UdfRead()
will never be hit.

This commit will add "ASSERT (FALSE);" before the above line to indicate
this.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Use debug msg instead of ASSERT in UdfOpen()
Hao Wu [Mon, 8 Oct 2018 06:30:14 +0000 (14:30 +0800)]
MdeModulePkg/UdfDxe: Use debug msg instead of ASSERT in UdfOpen()

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1248

Within function UdfOpen():
This commit will use debug messages instead of using ASSERT when an error
occurs after calling GetFileSize().

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Use error handling when fail to return LSN
Hao Wu [Sat, 29 Sep 2018 05:03:50 +0000 (13:03 +0800)]
MdeModulePkg/UdfDxe: Use error handling when fail to return LSN

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1248

This commit will refine the ASSERTs in function GetLongAdLsn() and
GetAllocationDescriptorLsn() when the logical sector number cannot be
returned due to unrecognized media format.

Error handling logic will be used for those ASSERTs.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: ASSERT for false positives of NULL ptr deref
Hao Wu [Tue, 9 Oct 2018 03:03:27 +0000 (11:03 +0800)]
MdeModulePkg/UdfDxe: ASSERT for false positives of NULL ptr deref

This commit adds ASSERTs to address false positive reports of NULL
pointer dereference issues raised from static analysis with regard to
function ReadDirectoryEntry().

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UdfDxe: Use error handling for memory allocation failure
Hao Wu [Fri, 28 Sep 2018 12:12:23 +0000 (20:12 +0800)]
MdeModulePkg/UdfDxe: Use error handling for memory allocation failure

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1247

For functions DuplicateFid() and DuplicateFe(), this commit will use error
handling logic instead of ASSERTs for memory allocation failure.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdePkg/BaseSynchronizationLib GCC: simplify IA32 InternalSyncCompareExchange64()
Laszlo Ersek [Sat, 29 Sep 2018 21:13:47 +0000 (23:13 +0200)]
MdePkg/BaseSynchronizationLib GCC: simplify IA32 InternalSyncCompareExchange64()

The IA32 variant of InternalSyncCompareExchange64() is correct, but we can
simplify it. We don't need to load the lower 32 bits of ExchangeValue into
EBX in two steps (first into a general register, then into EBX); we can
ask GCC to populate EBX like that itself.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoMdePkg/BaseSynchronizationLib GCC: fix X64 InternalSyncCompareExchange64()
Laszlo Ersek [Sat, 29 Sep 2018 19:22:57 +0000 (21:22 +0200)]
MdePkg/BaseSynchronizationLib GCC: fix X64 InternalSyncCompareExchange64()

(This patch is identical to the X64 half of the last one, except for the
InternalSyncCompareExchange32() -> InternalSyncCompareExchange64() and
"cmpxchgl" -> "cmpxchgq" replacements.)

The CMPXCHG instruction has the following operands:
- AX (implicit, CompareValue):    input and output
- destination operand (*Value):   input and output
- source operand (ExchangeValue): input

The X64 version of InternalSyncCompareExchange64() attempts to mark both
CompareValue and (*Value) as input/output, but it doesn't use the
appropriate constraints for either operand.

Fix these issues. Furthermore, prefer the short "+" constraint for I/O
operands over the <output-operand-number> constraint that can be applied
to the input instances of I/O operands.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoMdePkg/BaseSynchronizationLib GCC: fix InternalSyncCompareExchange32()
Laszlo Ersek [Sat, 29 Sep 2018 19:22:57 +0000 (21:22 +0200)]
MdePkg/BaseSynchronizationLib GCC: fix InternalSyncCompareExchange32()

(This patch is identical to the last one, except for the
InternalSyncCompareExchange16() -> InternalSyncCompareExchange32() and
"cmpxchgw" -> "cmpxchgl" replacements.)

The CMPXCHG instruction has the following operands:
- AX (implicit, CompareValue):    input and output
- destination operand (*Value):   input and output
- source operand (ExchangeValue): input

The IA32 version of InternalSyncCompareExchange32() correctly marks
CompareValue as input/output, but it marks (*Value) only as input.

The X64 version of InternalSyncCompareExchange32() attempts to mark both
CompareValue and (*Value) as input/output, but it doesn't use the
appropriate constraints for either operand.

Fix these issues. Furthermore, prefer the short "+" constraint for I/O
operands over the <output-operand-number> constraint that can be applied
to the input instances of I/O operands.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoMdePkg/BaseSynchronizationLib GCC: fix InternalSyncCompareExchange16()
Laszlo Ersek [Sat, 29 Sep 2018 19:22:57 +0000 (21:22 +0200)]
MdePkg/BaseSynchronizationLib GCC: fix InternalSyncCompareExchange16()

The CMPXCHG instruction has the following operands:
- AX (implicit, CompareValue):    input and output
- destination operand (*Value):   input and output
- source operand (ExchangeValue): input

The IA32 version of InternalSyncCompareExchange16() correctly marks
CompareValue as input/output, but it marks (*Value) only as input.

The X64 version of InternalSyncCompareExchange16() attempts to mark both
CompareValue and (*Value) as input/output, but it doesn't use the
appropriate constraints for either operand.

Fix these issues. Furthermore, prefer the short "+" constraint for I/O
operands over the <output-operand-number> constraint that can be applied
to the input instances of I/O operands.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoMdePkg/BaseSynchronizationLib GCC: fix whitespace and comments
Laszlo Ersek [Sat, 29 Sep 2018 18:18:34 +0000 (20:18 +0200)]
MdePkg/BaseSynchronizationLib GCC: fix whitespace and comments

The "GccInline.c" files have some inconsistent whitespace, and missing (or
incorrect) operand comments. Fix and unify them.

This patch doesn't change behavior.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoMdeModulePkg Variable: Fix Timestamp zeroing issue on APPEND_WRITE
Star Zeng [Tue, 28 Feb 2017 06:01:47 +0000 (14:01 +0800)]
MdeModulePkg Variable: Fix Timestamp zeroing issue on APPEND_WRITE

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=415

When SetVariable() to a time based auth variable with APPEND_WRITE
attribute, and if the EFI_VARIABLE_AUTHENTICATION_2.TimeStamp in
the input Data is earlier than current value, it will cause timestamp
zeroing.

This issue may bring time based auth variable downgrade problem.
For example:
A vendor released three certs at 2014, 2015, and 2016, and system
integrated the 2016 cert. User can SetVariable() with 2015 cert and
APPEND_WRITE attribute to cause timestamp zeroing first, then
SetVariable() with 2014 cert to downgrade the cert.

This patch fixes this issue.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
5 years agoMdeModulePkg/UsbMass: Reject device whose block size is 0 or > 64K
Ruiyu Ni [Tue, 16 Oct 2018 04:40:13 +0000 (12:40 +0800)]
MdeModulePkg/UsbMass: Reject device whose block size is 0 or > 64K

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/Bus/Ufs: Ensure device not return more data than expected
Hao Wu [Thu, 20 Sep 2018 05:48:02 +0000 (13:48 +0800)]
MdeModulePkg/Bus/Ufs: Ensure device not return more data than expected

This commit adds checks to make sure the UFS devices do not return more
data than the driver expected.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UsbBus: Deny when the string descriptor length is odd
Ruiyu Ni [Mon, 17 Sep 2018 08:05:26 +0000 (16:05 +0800)]
MdeModulePkg/UsbBus: Deny when the string descriptor length is odd

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UsbMouse: Don't access key codes when length is wrong
Ruiyu Ni [Thu, 13 Sep 2018 08:09:10 +0000 (16:09 +0800)]
MdeModulePkg/UsbMouse: Don't access key codes when length is wrong

Per USB HID spec, the buffer holding key codes should at least 3-byte
long.
Today's code assumes that the key codes buffer length is longer than
3-byte and unconditionally accesses the key codes buffer.
It's incorrect.
The patch fixes the issue by returning Device Error when the
length is less than 3-byte.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/AbsPointer: Don't access key codes when length is wrong
Ruiyu Ni [Thu, 13 Sep 2018 08:06:52 +0000 (16:06 +0800)]
MdeModulePkg/AbsPointer: Don't access key codes when length is wrong

Per USB HID spec, the buffer holding key codes should at least 3-byte
long.
Today's code assumes that the key codes buffer length is longer than
3-byte and unconditionally accesses the key codes buffer.
It's incorrect.
The patch fixes the issue by returning Device Error when the
length is less than 3-byte.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UsbKb: Don't access key codes when length is wrong
Ruiyu Ni [Thu, 13 Sep 2018 07:49:23 +0000 (15:49 +0800)]
MdeModulePkg/UsbKb: Don't access key codes when length is wrong

Per USB HID spec, the buffer holding key codes should be 8-byte
long.
Today's code assumes that the key codes buffer length is 8-byte
long and unconditionally accesses the key codes buffer.
It's incorrect.
The patch fixes the issue by returning Device Error when the
length is less than 8-byte.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoSourceLevelDebugPkg/Usb3: Make sure data from HW can fit in buffer
Ruiyu Ni [Thu, 2 Aug 2018 07:48:52 +0000 (15:48 +0800)]
SourceLevelDebugPkg/Usb3: Make sure data from HW can fit in buffer

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/Usb: Make sure data from HW is no more than expected
Ruiyu Ni [Thu, 2 Aug 2018 01:57:17 +0000 (09:57 +0800)]
MdeModulePkg/Usb: Make sure data from HW is no more than expected

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UsbBus: Reject descriptor whose length is bad
Ruiyu Ni [Thu, 27 Sep 2018 08:36:05 +0000 (16:36 +0800)]
MdeModulePkg/UsbBus: Reject descriptor whose length is bad

Today's implementation doesn't check whether the length of
descriptor is valid before using it.

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UsbBus: Fix out-of-bound read access to descriptors
Ruiyu Ni [Thu, 27 Sep 2018 08:34:36 +0000 (16:34 +0800)]
MdeModulePkg/UsbBus: Fix out-of-bound read access to descriptors

Today's implementation reads the Type/Length field in the USB
descriptors data without checking whether the offset to read is
beyond the data boundary.

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UsbMass: Fix integer overflow when BlockSize is 1
Ruiyu Ni [Tue, 11 Sep 2018 10:13:05 +0000 (18:13 +0800)]
MdeModulePkg/UsbMass: Fix integer overflow when BlockSize is 1

UsbBootReadWriteBlocks() and UsbBootReadWriteBlocks16() use a UINT16
local variable to hold the value of
USB_BOOT_MAX_CARRY_SIZE (=0x10000) / BlockSize.
When BlockSize is 1, the UINT16 local variable is set to 0x10000
but the high-16 bits are truncated resulting the final value be 0.

It causes the while-loop in the two functions accesses 0 block in
each loop, resulting the loop never ends.

The patch fixes the two functions to make sure no integer overflow
happens.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg/UsbMass: Merge UsbBoot(Read|Write)Blocks(16)
Ruiyu Ni [Tue, 11 Sep 2018 10:08:02 +0000 (18:08 +0800)]
MdeModulePkg/UsbMass: Merge UsbBoot(Read|Write)Blocks(16)

The change doesn't have functionality impact.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoCorebootPayloadPkg: don't use serial output for Release build
Wonkyu Kim [Mon, 15 Oct 2018 22:44:45 +0000 (06:44 +0800)]
CorebootPayloadPkg: don't use serial output for Release build

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wonkyu Kim <wonkyu.kim@intel.com>
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
Reviewed-by: Benjamin You <benjamin.you@intel.com>
5 years agoMdeModulePkg/RegularExpressionDxe: Add null pointer check
Dongao Guo [Thu, 11 Oct 2018 06:57:03 +0000 (14:57 +0800)]
MdeModulePkg/RegularExpressionDxe: Add null pointer check

This is the part of commit 3948c510edad901bb9f8d23f7bf0f4ae91b5fcde.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dongao Guo <dongao.guo@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools/EOT: Change to call a program instead of calling Python API.
Hess Chen [Mon, 15 Oct 2018 08:29:09 +0000 (16:29 +0800)]
BaseTools/EOT: Change to call a program instead of calling Python API.

Update the EOT tool to call the program itself instead of calling the Python API when parsing FV images.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Acked-by: Jaben Carsey <jaben.carsey@intel.com>
5 years agoBaseTools: Support to use struct name as datum type before max size
Yonghong Zhu [Mon, 15 Oct 2018 13:20:00 +0000 (21:20 +0800)]
BaseTools: Support to use struct name as datum type before max size

Original it hard code to use "VOID*", this patch extend it to both
support VOID* and valid struct name.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools: Fix bugs use special character in the --pcd option
Yonghong Zhu [Mon, 15 Oct 2018 12:43:47 +0000 (20:43 +0800)]
BaseTools: Fix bugs use special character in the --pcd option

Cases:
--pcd Token.Name="!"
--pcd Token.Name="\'W&\'"
--pcd Token.Name="2*h"

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
5 years agoBaseTools: Add check for the string type whether is same
zhijufan [Mon, 15 Oct 2018 01:02:31 +0000 (09:02 +0800)]
BaseTools: Add check for the string type whether is same

Relational and equality operators require both operands to be of
the same type.
Treat the string 'A' and "A" as same type, but for "A" and L"A"
are not same type since one is general string, another is unicode
string.

True:'A'<'B', "A"<"B" 'A'<"B", L'A'<L'B', L"A"<L"B", L'A'<L"B"
Error:'A'<L'B', 'A'<L"B", "A'<L'B'

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
5 years agoBaseTools:Fix issue caused by 84a52d4d030185a44f2d8736142c6f0b19c6e9b1
Zhaozh1x [Wed, 26 Sep 2018 08:04:06 +0000 (16:04 +0800)]
BaseTools:Fix issue caused by 84a52d4d030185a44f2d8736142c6f0b19c6e9b1

The commit 84a52d4d030185a44f2d8736142c6f0b19c6e9b1 will introduce
the new issue "Invalid offset value for Dynamic Vpd PCD". This patch
will fix the new issue, add 'DEFAULT' sku in to the AvailableSkuIdSet
variable.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools: Convert string value of void* pcd in command line to array.
Zhaozh1x [Wed, 26 Sep 2018 09:53:49 +0000 (17:53 +0800)]
BaseTools: Convert string value of void* pcd in command line to array.

For void* type pcd in command line, if its value is string, then
convert the string value to array format. For example,
build --pcd gUefiOvmfPkgTokenSpaceGuid.PcdTest="c",
convert the pcd value from "c" to "{0x63,0x00}".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools: Code should not update the variable that save the raw data.
Zhaozh1x [Tue, 11 Sep 2018 10:31:36 +0000 (18:31 +0800)]
BaseTools: Code should not update the variable that save the raw data.

Code should not update the value of variable which save the original
raw content of meta file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools: add ASSERT checker for array buffer value assignment.
Zhaozh1x [Tue, 4 Sep 2018 09:26:11 +0000 (17:26 +0800)]
BaseTools: add ASSERT checker for array buffer value assignment.

V3:
Update the error message for array checker.
V2:
1. Add comments for each ASSERT.
2. ASSERT need to skip the case of array size of array as zero. For
example, TestArray[] in struct in header file.
V1:
For structure PCD,
1. use compiler time assert to check the array index, report error
if array index exceeds the array number.
2. use compiler time assert to check the array size, report error
if the user declared size in header file is smaller than the user
defined in DEC/DSC file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoBaseTools: Fix regression boot hang issue by commit 0e982cf03dd5
Feng, YunhuaX [Mon, 15 Oct 2018 09:03:51 +0000 (17:03 +0800)]
BaseTools: Fix regression boot hang issue by commit 0e982cf03dd5

Fix regression boot hang issue by commit
0e982cf03dd5023b90def60c3656e5e18135ebac

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
5 years agoMdeModulePkg BrotliCustomDecompressLib: Don't build it for EBC arch
Liming Gao [Thu, 11 Oct 2018 05:53:01 +0000 (13:53 +0800)]
MdeModulePkg BrotliCustomDecompressLib: Don't build it for EBC arch

BrotliCustomDecompressLib has the definition with float type. But,
Floating-point types are not supported by EBC compiler.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Bi Dandan <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
5 years agoMdeModulePkg RegularExpressionDxe: Enable STDARG for variable arguments
Liming Gao [Mon, 8 Oct 2018 04:22:38 +0000 (12:22 +0800)]
MdeModulePkg RegularExpressionDxe: Enable STDARG for variable arguments

Set macro for variable arguments, and remove the hard code definition
to avoid the potential duplicated definition.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Dongao Guo <dongao.guo@intel.com>
5 years agoMdeModulePkg/RegularExpressionDxe: Add null pointer check
Dongao Guo [Thu, 11 Oct 2018 06:57:03 +0000 (14:57 +0800)]
MdeModulePkg/RegularExpressionDxe: Add null pointer check

There are five check not necessary in logic ,just for pass static
analysis. More detail please refer to comment in code.
And the rest changes are all accepted by owner, they are reasonable.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dongao Guo <dongao.guo@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
5 years agoMdeModulePkg/RegularExpressionDxe: Miss null pointer check
Dongao Guo [Thu, 11 Oct 2018 06:57:02 +0000 (14:57 +0800)]
MdeModulePkg/RegularExpressionDxe: Miss null pointer check

Oniguruma https://github.com/kkos/oniguruma
this change is merged from oniguruma develop branch.
from commit 1db8a2726dfad0401f928cb8474bd770f07040a7.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dongao Guo <dongao.guo@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>