Commit Graph

5361 Commits

Author SHA1 Message Date
Hao Wu d374f2cdf9 MdeModulePkg/AtaPassThru: Add missing NULL ptr check in BindingStart
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=916

Within function AtaAtapiPassThruStart():
Add missing NULL pointer check for variable 'Instance' under the
'ErrorExit' code logic.

Cc: Steven Shi <steven.shi@intel.com>
Cc: Eric Dong <eric.dong@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>
2018-06-29 16:52:43 +08:00
Dandan Bi 981b7edc0e MdeModulePkg/PerformanceLib: Add NULL pointer check
1. Add NULL pointer check for the "Guid" parameter
   when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE.
2. Make the code logic in DxeCore/SmmCore/PeiPerformanceLib
   aligned when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
2018-06-28 19:46:07 +08:00
Dandan Bi 3408526e86 MdeModulePkg/PiSmmCore: Remove SMM Perf entry
The perf measurement entry in SmmEntryPoint function
doesn't have significant meaning. So remove it now.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-06-28 19:46:07 +08:00
Fu Siyuan a5f525fc48 MdeModulePkg: Update IP4 driver to check for NULL pointer before using.
Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2018-06-28 15:29:56 +08:00
Liming Gao d1102dba72 MdeModulePkg: Clean up source files
1. Do not use tab characters
2. No trailing white space in one line
3. All files must end with CRLF

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-28 11:19:45 +08:00
Star Zeng 72750e3bf9 MdeModulePkg UsbBusPei: Fix wrong buffer length used to read hub desc
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=973

Bug 973 just mentions UsbBusDxe, but UsbBusPei has similar issue.

HUB descriptor has variable length.
But the code uses stack (HubDescriptor in PeiDoHubConfig) with fixed
length sizeof(EFI_USB_HUB_DESCRIPTOR) to hold HUB descriptor data.
It uses hard code length value (12) for SuperSpeed path.
And it uses HubDesc->Length for none SuperSpeed path, then there will
be stack overflow when HubDesc->Length is greater than
sizeof(EFI_USB_HUB_DESCRIPTOR).

The patch updates the code to use a big enough buffer to hold the
descriptor data.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Bret Barkelew <bret.barkelew@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
2018-06-27 12:38:52 +08:00
Star Zeng acebdf14c9 MdeModulePkg UsbBusDxe: Fix wrong buffer length used to read hub desc
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=973

HUB descriptor has variable length.
But the code uses stack (HubDesc in UsbHubInit) with fixed length
sizeof(EFI_USB_HUB_DESCRIPTOR) to hold HUB descriptor data.
It uses hard code length value (32 that is greater than
sizeof(EFI_USB_HUB_DESCRIPTOR)) for SuperSpeed path, then there will
be stack overflow when IOMMU is enabled because the Unmap operation
will copy the data from device buffer to host buffer.
And it uses HubDesc->Length for none SuperSpeed path, then there will
be stack overflow when HubDesc->Length is greater than
sizeof(EFI_USB_HUB_DESCRIPTOR).

The patch updates the code to use a big enough buffer to hold the
descriptor data.
The definition EFI_USB_SUPER_SPEED_HUB_DESCRIPTOR is wrong (HubDelay
field should be UINT16 type) and no code is using it, the patch
removes it.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Bret Barkelew <bret.barkelew@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
2018-06-27 12:38:47 +08:00
Bi, Dandan 67e9ab84ef MdeModulePkg: Use new added Perf macros
Replace old Perf macros with the new added ones.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-06-26 15:36:59 +08:00
Bi, Dandan 6b4d58a10c MdeModulePkg: Update performance library instances
Update the performance library instances in MdeModulePkg
to implement the APIs used for new added Perf macros.

V2:
Share the common logics of creating FPDT record for
new added Perf macros and existing Perf macros.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-06-26 15:36:51 +08:00
Bi, Dandan a08cbb95d6 MdeModulePkg/ExtendedFirmwarePerf: Remove PerfId definitions
Remove the definitions of performance identifier since they
have been added into PerformanceLib.h.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-06-26 15:36:47 +08:00
Bi, Dandan 137fb13deb MdeModulePkg: Update Performance instances to use new protocol
Update Performance instances in MdeModulePkg to use new
PerformanceMeasurement protocol.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-06-26 15:36:39 +08:00
Bi, Dandan 56f7741e27 MdeModulePkg: Add PERFORMANCE_MEASUREMENT_PROTOCOL
Add PerformanceMeasurement protocol to log performance info.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-06-26 15:36:35 +08:00
Dandan Bi 4e8ee0a08e MdeModulePkg/CapsuleRuntimeDxe: Fix ECC issue
Add guard macro for new added header file.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-26 15:34:04 +08:00
Liming Gao 14923c1a6b MdeModulePkg BootMaintenanceManagerUiLib: Move refresh boot option later
Constructor is too early that ConnectAll() may not do. Move refresh boot
option in form open.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Xu WeiX <weix.xu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2018-06-25 11:17:01 +08:00
Liming Gao 363c3fe253 MdeModulePkg BdsDxe: Correct VariableLockProtocol usage to match code logic
BdsEntry marks the read-only variables if the Variable Lock protocol exists.
So, this protocol usage is updated from CONSUMES to SOMETIMES_CONSUMES.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-06-25 11:16:50 +08:00
Hao Wu 73ca09d2f1 MdeModulePkg: Add GUID for recovery capsule on NVM Express devices
Cc: Eric Dong <eric.dong@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: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-25 09:13:12 +08:00
Hao Wu b8b6943393 MdeModulePkg/NvmExpressPei: Add the NVME device PEI BlockIo support
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=256

This commit adds the PEI BlockIo support for NVM Express devices.

The driver will consume the EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI for NVM
Express host controllers within the system. And then produces the
BlockIo(2) PPIs for each controller.

The implementation of this driver is currently based on the NVM Express 1.1
Specification, which is available at:
http://nvmexpress.org/resources/specifications/

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
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: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-25 09:13:12 +08:00
Hao Wu 508acb5f6c MdeModulePkg: Add definitions for EDKII PEI NVME host controller PPI
Introduces the below PPI:

struct EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI {
  EDKII_NVM_EXPRESS_HC_GET_MMIO_BAR       GetNvmeHcMmioBar;
  EDKII_NVM_EXPRESS_HC_GET_DEVICE_PATH    GetNvmeHcDevicePath;
};

The GetNvmeHcMmioBar service will provide the caller with the MMIO BAR
address of each NVMe HC within the system;

The GetNvmeHcDevicePath service will provide the caller with the device
path information of each NVMe HC.

Cc: Eric Dong <eric.dong@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>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-06-25 09:13:12 +08:00
Sami Mujawar 24fee0528c MdeModulePkg: Enable SATA Controller PCI mem space
The SATA controller driver crashes while accessing the
PCI memory [AHCI Base Registers (ABAR)], as the PCI memory
space is not enabled.

Enable the PCI memory space access to prevent the SATA
Controller driver from crashing.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-21 09:08:19 +08:00
Fu Siyuan 1e0db7b119 MdeModulePkg/NetworkPkg: Checking for NULL pointer before use.
Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: Sivaraman Nainar <sivaramann@amiindia.co.in>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2018-06-21 08:49:47 +08:00
Jian J Wang 855abe0204 MdeModulePkg/Core: remove SMM check for Heap Guard feature detection
CpuDxe driver is updated to be able to access DXE page table in SMM mode,
which means Heap Guard can get correct memory paging attributes in what
environment. It's not necessary to exclude SMM from detecting Heap Guard
feature support.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.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: Star Zeng <star.zeng@intel.com>
2018-06-19 13:44:56 +08:00
Ruiyu Ni 4e738cd408 MdeModulePkg/AtaAtapiPassThru: Fix VS2010/VS2012 build failure
The patch doesn't have functionality impact. It is just to make
VS2010/VS2012 happy.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
2018-06-19 11:00:42 +08:00
Ard Biesheuvel 1342bd4486 MdeModulePkg/DxeCapsuleLibFmp: pass progress callback only if it works
If the first call to UpdateImageProgress() fails, there is no point
in passing a pointer to it to Fmp->SetImage(), since it is highly
unlikely to succeed on any subsequent calls.

This permits the FMP implementation to fall back to an alternate means
of providing feedback to the user, e.g., via the console.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-15 18:18:17 +02:00
Ard Biesheuvel e077a93dc6 MdeModulePkg/CapsuleRuntimeDxe: clean the capsule payload to DRAM
When capsule updates are staged for processing after a warm reboot,
they are copied into memory with the MMU and caches enabled. When
the capsule PEI gets around to coalescing the capsule, the MMU and
caches may still be disabled, and so on architectures where uncached
accesses are incoherent with the caches (such as ARM and AARCH64),
we need to ensure that the data passed into UpdateCapsule() is
written back to main memory before performing the warm reboot.

Unfortunately, on ARM, the only type of cache maintenance instructions
that are suitable for this purpose operate on virtual addresses only,
and given that the UpdateCapsule() prototype includes the physical
address of a linked list of scatter/gather data structures that are
mapped at an address that is unknown to the firmware (and may not even
be mapped at all when UpdateCapsule() is invoked), we can only perform
this cache maintenance at boot time. Fortunately, both Windows and Linux
only invoke UpdateCapsule() before calling ExitBootServices(), so this
is not a problem in practice.

In the future, we may propose adding a secure firmware service that
permits performing the cache maintenance at OS runtime, in which case
this code may be enhanced to call that service if available. For now,
we just fail any UpdateCapsule() calls performed at OS runtime on ARM.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-06-15 18:17:44 +02:00
Ruiyu Ni e03a460f06 MdeModulePkg/IncompPciDeviceSupport: Use correct descriptor length
Per PI spec, the Length value is the length of the ACPI descriptor
in bytes, excluding the first two fields.
The patch fixes the code to report the correct descriptor length
by excluding 3-byte first two fields.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-14 16:38:15 +08:00
Hao Wu 0f4387e5c8 MdeModulePkg/SdDxe: Demote DEBUG print to DEBUG_BLKIO
Similar to commit 9dca2105ad, lower the
priority of the DEBUG print in SDReadWrite() to DEBUG_BLKIO.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Eric Dong <eric.dong@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>
2018-06-13 11:19:45 +08:00
Hao Wu 47dad47583 MdeModulePkg/NvmExpressDxe: Adjust R/W DEBUG prints to BLKIO level
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=980

Adjust the DEBUG prints within function:
NvmeRead(), NvmeWrite(), AsyncNvmeRead() and AsyncNvmeWrite()

to DEBUG_BLKIO for the consistency with other storage device drivers
(e.g. ATA, USB and etc.).

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Eric Dong <eric.dong@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>
2018-06-13 11:19:22 +08:00
Liming Gao 051bf6e0af MdeModulePkg Variable: Use comparison logic to check UINTN parameter
Commit 180ac200da changes the input parameter
from BOOLEAN to UINTN. Its comparison logic should be updated.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-12 09:23:14 +08:00
Ard Biesheuvel 9dca2105ad MdeModulePkg/EmmcDxe: demote DEBUG print to DEBUG_BLKIO
Lower the priority of the DEBUG print in EmmcReadWrite(), which
is emitted for each read or write operation to the eMMC device,
which clutters up the log output of builds created with DEBUG_INFO
enabled.

Suggested-by: Pipat Methavanitpong <methavanitpong.pipat@socionext.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-11 11:39:55 +02:00
Leo Duran a05a8a5aa1 MdeModulePkg/Library/BaseSerialPortLib16550: Ensure FIFO Polled Mode
Put the UART in FIFO Polled Mode by clearing IER after setting FCR.
Also, add comments to show DLAB state for registers 0 and 1.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leo Duran <leo.duran@amd.com>
Cc: Star Zeng <star.zeng@intel.com>
CC: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-11 10:40:20 +08:00
Kinney, Michael D 5747610657 MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
https://bugzilla.tianocore.org/show_bug.cgi?id=801

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

* Change Update_Image_Progress() to UpdateImageProcess()
* Call DisplayUpdateProgressLib from UpdateImageProgress().
* Split out a boot service and runtime version of
  UpdateImageProgress() so the DisplayUpdateProgressLib is
  not used at runtime.
* If gEdkiiFirmwareManagementProgressProtocolGuid is present,
  then use its progress bar color and watchdog timer value.
* If gEdkiiFirmwareManagementProgressProtocolGuid is not present,
  then use default progress bar color and 5 min watchdog timer.
* Remove Print() calls during capsule processing.  Instead,
  the DisplayUpdateProgressLib is used to inform the user
  of progress during a capsule update.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-08 15:40:54 -07:00
Ruiyu Ni f3100a1a2f MdeModulePkg/Ata/AtaAtapiPassThru: Enable/disable DEVSLP per policy
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-08 17:46:46 +08:00
Ruiyu Ni 06766c0e19 MdeModulePkg/AtaAtapiPassThru: enable/disable PUIS per policy
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2018-06-08 17:46:45 +08:00
Ruiyu Ni f87a1e4158 MdeModulePkg: Add AtaAtapiPolicy protocol definition
The patch adds AtaAtapiPolicy protocol which is produced by platform
and consumed by AtaAtapiPassThruDxe driver.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-08 17:46:45 +08:00
Ruiyu Ni 8d3c4b552f MdeModulePkg/AtaAtapiPassThru: Spin up Power up in Standby devices
The patch adds support to certain devices that support PUIS (Power
up in Standby).
For those devices that supports SET_FEATURE spin up, SW needs to
send SET_FEATURE subcommand to spin up the devices.
For those devices that doesn't support SET_FEATURE spin up, SW needs
to send read sectors command to spin up the devices.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2018-06-08 17:46:44 +08:00
Liming Gao 6d614649ab MdeModulePkg: Remove X86 ASM and S files
NASM has replaced ASM and S files.
1. Remove ASM from all modules.
2. Remove S files from the drivers only.
3. https://bugzilla.tianocore.org/show_bug.cgi?id=881
After NASM is updated, S files can be removed from Library.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-07 15:26:27 +08:00
Dandan Bi ec50f7535b MdeModulePkg/DisplayUpdateProgressLib: Fix ECC issues
Make the comment align with Edk2 coding style.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-07 10:55:38 +08:00
Liming Gao 31f70606c6 MdeModulePkg BootManagerMenuApp: Update usage info for BootLogo protocol
BootLogo protocol is not always required. If it not is installed,
BootManagerMenuApp can work.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-05 14:23:48 +08:00
Ruiyu Ni 6c2d935d1d MdeModulePkg: Make sure ResetSystemRuntimeDxe uses ResetSystemLibNull
Because the DxeResetSystemLib calls gRT->ResetSystem(), make sure
the gRT->ResetSystem() implementation doesn't call into
DxeResetSystemLib to avoid chicken-egg issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
2018-06-05 13:49:18 +08:00
Ruiyu Ni 6c252691c3 MdeModulePkg/DxeResetSystemLib: Avoid depending on UefiRuntimeLib
Current DxeResetSystemLib depends on UefiRuntimeLib because it calls
EfiResetSystem() API exposed by UefiRuntimeLib.

Due to the commit:
"MdePkg/UefiRuntimeLib: Do not allow to be linked by DXE driver"
which reverts UefiRuntimeLib to only support DXE_RUNTIME_DRIVER,
removing UefiRuntimeLib dependency makes the DxeResetSystemLib
can be used by DXE drivers.

The patch also disallows the DxeResetSystemLib to be linked by
runtime driver, SMM drivers.
Runtime driver cannot link to this library because the gRT is not
converted when entering to RT.
SMM driver cannot link to this library because calling RT services
from SMM after EndOfDxe violates security guideline.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
2018-06-05 13:49:17 +08:00
Marcin Wojtas 38c977c148 MdeModulePkg PeiCore: Check error status when processing boot FV
Until now the possible errors returned from processing
boot firmware volume were not checked, which could cause
misbehavior in further booting stages. Add relevant assert.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Signed-off-by: Jan Dabros <jsd@semihalf.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-06-04 13:27:55 +08:00
Ard Biesheuvel 65e984cd8a MdeModulePkg/FirmwarePerformanceDataTableDxe: use AllocatePeiAccessiblePages
Replace the call to and implementation of the function
FpdtAllocateReservedMemoryBelow4G() with a call to
AllocatePeiAccessiblePages, which boils down to the same on X64,
but does not crash non-X64 systems that lack memory below 4 GB.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-29 10:47:18 +02:00
Ard Biesheuvel d79d7b5860 MdeModulePkg/DxeCorePerformanceLib: use AllocatePeiAccessiblePages
Replace the call to and implementation of the function
FpdtAllocateReservedMemoryBelow4G() with a call to
AllocatePeiAccessiblePages, which boils down to the same on X64,
but does not crash non-X64 systems that lack memory below 4 GB.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-29 10:47:18 +02:00
Michael D Kinney 72b0a9bed9 MdeModulePkg: Add DisplayUpdateProgressLib instances
https://bugzilla.tianocore.org/show_bug.cgi?id=801

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

Add DisplayUpdateProgressLib instances for text consoles
and graphical consoles.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-05-28 09:30:10 -07:00
Michael D Kinney 825d138f83 MdeModulePkg: Add DisplayUpdateProgressLib class
https://bugzilla.tianocore.org/show_bug.cgi?id=801

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

Add the DisplayUpdateProgressLib class that is used
to inform the user of progress during updates of
firmware images in firmware devices.  A platform
specific instance of this library can be used to
customize how the user is informed of progress.

Add the EDK II Firmware Management Progress Protocol.
This is an optional protocol that must be installed
onto the same handle as a Firmware Management Protocol.
This new protocol provides the color of a progress
bar that allows different firmware devices to use
different colors during a firmware update.  It also
provides a watchdog timer value in seconds that is
armed each time the Progress() service passed
into Firmware Management Protocol SetImage()
is called.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-05-28 09:30:10 -07:00
Ruiyu Ni d923365417 MdeModulePkg/PciBus: Do not enable MemWriteAndInvalidate bit for PCIE
Per PCIE spec, Memory Write and Invalidate is hardwired to 0b so
PciBus driver shouldn't write 1b to it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
2018-05-28 16:33:55 +08:00
Ruiyu Ni 2b5f0daa6c MdeModulePkg/PciBus: Remove unnecessary PCIE detection
CreatePciIoDevice() detects whether the PCI device is a PCI Express
device and remembers the device type in PciIoDevice->IsPciExp.

RegisterPciDevice() detects the device type again which is
unnecessary. The detection logic can be removed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
2018-05-28 16:33:54 +08:00
Ruiyu Ni 03ac238b1f MdeModulePkg/PciBus: Use actual max bus # for subordinary bus #
Current code assumes the max bus(0xFF) is under this P2P bridge and
temporarily set it as subordinate bus.
It may cause silicon hangs during PCI enumeration in some specific
case.

Instead, it should get the max bus number from the bus number
resources returned from
PCI_HOST_BRIDGE_RESOURCE_ALLOCATION.StartBusEnumeration() and set it
as subordinate bus.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-25 16:51:17 +08:00
Liming Gao 180ac200da MdeModulePkg Variable: Fix XCODE5 varargs warning
https://bugzilla.tianocore.org/show_bug.cgi?id=741
Change VariableGetBestLanguage() parameter type from BOOLEAN to UINTN

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Steven Shi <steven.shi@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-05-23 10:37:49 +08:00
Liming Gao b22d093101 MdeModulePkg PeiCore: FvCount to be checked for the registered for shadow PEIM
The PEIM in all cached FV image may be in registered for shadow status.
Current logic CurrentPeimFvCount is not enough.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-17 15:22:27 +08:00
cinnamon shia 989f7a2cf0 MdeModulePkg Variable: Fix the returned status in UpdateVariableStore
If Fvb is a NULL, return EFI_UNSUPPORTED.
If the remaining size is not enough, return EFI_OUT_OF_RESOURCES.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: cinnamon shia <cinnamon.shia@hpe.com>
Signed-off-by: Ansen Huang <ansen.huang@hpe.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-14 10:04:55 +08:00
cinnamon shia d741d14193 MdeModulePkg Variable: Fix a corner case issue about setting a variable
Fix the issue that failed to update or add a UEFI variable if the remaining size is equal to the data size
of the variable.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: cinnamon shia <cinnamon.shia@hpe.com>
Signed-off-by: Ansen Huang <ansen.huang@hpe.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-14 10:04:50 +08:00
Ruiyu Ni 0edb7ec5ce MdeModulePkg/PciHostBridge: Count the (mm)io overhead when polling
RootBridgeIo.PollMem()/PollIo() originally don't count the IO/MMIO
access overhead when delaying.
The patch changes the implementation to count the access overhead
so that the actually delay equals to user required delay.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
2018-05-09 14:03:09 +08:00
Marvin.Haeuser@outlook.com d9476a7ef1 MdeModulePkg/AcpiPlatformDxe: Unload after execution.
AcpiPlatformDxe solely performs one-time tasks and does not expose
any services or create any events. Hence it can safely be unloaded
after the Entry Point execution by returning an error code.

V2: Return EFI_REQUEST_UNLOAD_IMAGE.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-08 11:18:18 +08:00
Star Zeng 2e3032b4aa MdeModulePkg CapsuleApp: Check Buffer against NULL before freeing it
If the capsule from command line is not present,
Buffer will be random value when freeing it in DumpCapsule(),
then ASSERT will happen or other memory pool may be freed.

Cc: Jiewen Yao <jiewen.yao@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>
2018-05-08 11:16:49 +08:00
Ruiyu Ni ebafede928 MdeModulePkg/Terminal: Check status of OpenProtocol in BindingStart
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=917

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-03 11:29:49 +08:00
Thomas Palmer 54b7f3cfc1 MdeModulePkg/DriverHealthManagerDxe: Update RouteConfig function
According to UEFI spec, the RouteConfig protocol function should populate
the Progress pointer with an address inside Configuration.  This patch
ensures that these functions are compliant when EFI_NOT_FOUND is returned.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Thomas Palmer <thomas.palmer@hpe.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2018-05-03 10:49:46 +08:00
Thomas Palmer 124b18cfb3 MdeModulePkg/RamDiskDxe: Update RouteConfig function
According to UEFI spec, the RouteConfig protocol function should populate
the Progress pointer with an address inside Configuration.  This patch
ensures that these functions are compliant when EFI_NOT_FOUND is returned.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Thomas Palmer <thomas.palmer@hpe.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2018-05-03 10:49:44 +08:00
Thomas Palmer e00cd95590 MdeModulePkg/UiApp: Update RouteConfig function
According to UEFI spec, the RouteConfig protocol function should populate
the Progress pointer with an address inside Configuration.  This patch
ensures that these functions are compliant when EFI_NOT_FOUND is returned.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Thomas Palmer <thomas.palmer@hpe.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2018-05-03 10:49:41 +08:00
Star Zeng 67d3e63c2c MdeModulePkg NvmExpressDxe: return error code in error path
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=937

In NvmeExpressPassthru.c near line 659:
    Prp = NvmeCreatePrpList (
            PciIo,
            PhyAddr,
            EFI_SIZE_TO_PAGES(Offset + Bytes) - 1,
            &PrpListHost,
            &PrpListNo,
            &MapPrpList
            );
    if (Prp == NULL) {
      goto EXIT;
    }
Status is not set to an error code - Status is initialized to
EFI_SUCCESS, or set by a PciIo->Map to EFI_SUCCESS above this
code. This error path should set Status to an error code before
goto EXIT.

Change-Id: I8a5cdf981aa609534c205d3676395805ac60a003
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
2018-04-25 15:55:45 +08:00
Star Zeng 3545488dd6 MdeModulePkg EsrtFmpDxe: Use EfiBootServicesData for ESRT table
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=933

We see UEFI spec is saying to use EfiBootServicesData for ESRT table.

UEFI 2.7 chapter 23.3:
The ESRT shall be stored in memory of type EfiBootServicesData.

And we see EsrtDxe is using AllocatePool for ESRT table, but
EsrtFmpDxe is using AllocateRuntimeZeroPool for ESRT table.

This patch updates code to use EfiBootServicesData for ESRT table
in EsrtFmpDxe.

Change-Id: I72a73e0cc0a37e429cc262d68eb284fb268cb5ef
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.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>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-04-25 15:50:55 +08:00
Ruiyu Ni 8b5c80e029 MdeModulePkg/UefiBootManagerLib: fix AddLoadOptionVariable docs/prototype
Clean up the leading comment and the prototype of
EfiBootManagerAddLoadOptionVariable():

- the function may modify Option on output, annotate the parameter with
  OUT and update the documentation;

- "@retval EFI_STATUS" and "@retval Others" are not idiomatic
  documentation, use @return instead;

- sync comment and prototype between lib instance and lib class header.

Change-Id: I8a609d6502b6f8929b2f568acaa147065003b6f4
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-04-23 17:49:40 +08:00
Star Zeng 0f3cd8a92b MdeModulePkg DxeCapsuleLibFmp: Fix wrong Index is used
DEBUG((
  DEBUG_ERROR,
  "ItemOffsetList[%d](0x%lx) < ItemOffsetList[%d](0x%x)\n",
  Index,
  ItemOffsetList[Index],
  Index,                       // Should be Index - 1
  ItemOffsetList[Index - 1]
  ));

Cc: Jiewen Yao <jiewen.yao@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>
2018-04-20 14:28:45 +08:00
Dandan Bi d4ee449d1d MdeModulePkg/FPDT: Add error message for unsupported case
We have updated performance infrastructure in previous commits:
between
73fef64f14
and
115eae650b
Update FPDT drivers to collect the performance data reported by
gEdkiiFpdtExtendedFirmwarePerformanceGuid.
The old implementation which collected performance data through
gEfiFirmwarePerformanceGuid is not supported now.
We should add error message to remind user for this unsupported
case in case anyone use it by mistake.

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: Liming Gao <liming.gao@intel.com>
2018-04-16 14:37:59 +08:00
Jian J Wang 54ec85dd29 MdeModulePkg/PiSmmIpl: fix non-executable SMM RAM
This patch fixes an issue introduced by commit

  5b91bf82c6

and

  0c9f2cb10b

This issue will only happen if PcdDxeNxMemoryProtectionPolicy is
enabled for reserved memory, which will mark SMM RAM as NX (non-
executable) during DXE core initialization. SMM IPL driver will
unset the NX attribute for SMM RAM to allow loading and running
SMM core/drivers.

But above commit will fail the unset operation of the NX attribute
due to a fact that SMM RAM has zero cache attribute (MRC code always
sets 0 attribute to reserved memory), which will cause GCD internal
method ConverToCpuArchAttributes() to return 0 attribute, which is
taken as invalid CPU paging attribute and skip the calling of
gCpu->SetMemoryAttributes().

The solution is to make use of existing functionality in PiSmmIpl
to make sure one cache attribute is set for SMM RAM. For performance
consideration, PiSmmIpl will always try to set SMM RAM to write-back.
But there's a hole in the code which will fail the setting write-back
attribute because of no corresponding cache capabilities. This patch
will add necessary cache capabilities before setting corresponding
attributes.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-04-13 13:05:00 +08:00
Jian J Wang 5fef2c7069 MdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes
Heap Guard feature needs enough memory and paging to work. Otherwise
calling SetMemoryAttributes to change page attribute will fail. This
patch add necessary check of result of calling SetMemoryAttributes.
This can help users to debug their problem in enabling this feature.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.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: Star Zeng <star.zeng@intel.com>
2018-04-13 13:04:59 +08:00
Jian J Wang a5cd613cdb MdeModulePkg/DxeCore: add sanity check for SetMemoryAttributes
Heap Guard feature needs enough memory and paging to work. Otherwise
calling SetMemoryAttributes to change page attribute will fail. This
patch add necessary check of result of calling SetMemoryAttributes.
This can help users to debug their problem in enabling this feature.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.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: Star Zeng <star.zeng@intel.com>
2018-04-13 13:04:59 +08:00
Star Zeng e037e88cd8 MdeModulePkg/Gcd: Suppress incorrect compiler/analyzer warnings
It is caused by 0c9f2cb10b
and false positive.
Initialize CpuArchAttributes to suppress incorrect
compiler/analyzer warnings.

Cc: Dandan Bi <dandan.bi@intel.com>
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: Star Zeng <star.zeng@intel.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
2018-04-08 16:39:49 +08:00
Kinney, Michael D 0c9f2cb10b MdeModulePkg/Gcd: Filter gCpu->SetMemoryAttributes() calls
This patch fixes an issue with VlvTbltDevicePkg introduced
by commit 5b91bf82c6.

The history is as below.
To support heap guard feature, 14dde9e903
added support for SetMemorySpaceAttributes() to handle page attributes,
but after that, a combination of CPU arch attributes and other attributes
was not allowed anymore, for example, UC + RUNTIME. It is a regression.
Then 5b91bf82c6 was to fix the regression,
and we thought 0 CPU arch attributes may be used to clear CPU arch
attributes, so 0 CPU arch attributes was allowed to be sent to
gCpu->SetMemoryAttributes().

But some implementation of CPU driver may return error for 0 CPU arch
attributes. That fails the case that caller just calls
SetMemorySpaceAttributes() with none CPU arch attributes (for example,
RUNTIME), and the purpose of the case is not to clear CPU arch attributes.

This patch filters the call to gCpu->SetMemoryAttributes()
if the requested attributes is 0.  It also removes the #define
INVALID_CPU_ARCH_ATTRIBUTES that is no longer used.

Cc: Heyi Guo <heyi.guo@linaro.org>
Cc: Yi Li <phoenix.liyi@huawei.com>
Cc: Renhao Liang <liangrenhao@huawei.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-04-05 09:04:58 +08:00
Star Zeng 5942b32e79 MdeModulePkg SmmMemoryAttribute.h: Refine some comments
1. Fix some "support" to "supported".
2. Fix some "set" to "clear" in ClearMemoryAttributes interface.
3. Remove redundant comments for GetMemoryAttributes interface.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2018-04-04 10:43:33 +08:00
Heyi Guo 5b91bf82c6 MdeModulePkg/Gcd: Fix bug of attribute conversion
For gDS->SetMemorySpaceAttributes(), when user passes a combined
memory attribute including CPU arch attribute and other attributes,
like EFI_MEMORY_RUNTIME, ConverToCpuArchAttributes() will return
INVALID_CPU_ARCH_ATTRIBUTES and skip setting page/cache attribute for
the specified memory space.

We don't see any reason to forbid combining CPU arch attributes and
non-CPU-arch attributes when calling gDS->SetMemorySpaceAttributes(),
so we remove the check code in ConverToCpuArchAttributes(); the
remaining code is enough to grab the interested bits for
Cpu->SetMemoryAttributes().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Signed-off-by: Renhao Liang <liangrenhao@huawei.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
2018-04-02 13:57:28 +08:00
Laszlo Ersek 9b4a20321e MdeModulePkg/Variable/RuntimeDxe: introduce PcdMaxVolatileVariableSize
The variable driver doesn't distinguish "non-volatile non-authenticated"
variables from "volatile non-authenticated" variables, when checking
individual variable sizes against the permitted maximum.
PcdMaxVariableSize covers both kinds.

This prevents volatile non-authenticated variables from carrying large
data between UEFI drivers, despite having no flash impact. One example is
EFI_TLS_CA_CERTIFICATE_VARIABLE, which platforms might want to create as
volatile on every boot: the certificate list can be several hundred KB in
size.

Introduce PcdMaxVolatileVariableSize to represent the limit on individual
volatile non-authenticated variables. The default value is zero, which
makes Variable/RuntimeDxe fall back to PcdMaxVariableSize (i.e. the
current behavior). This is similar to the PcdMaxAuthVariableSize fallback.

Whenever the size limit is enforced, consult MaxVolatileVariableSize as
the last option, after checking
- MaxAuthVariableSize for VARIABLE_ATTRIBUTE_AT_AW,
- and MaxVariableSize for EFI_VARIABLE_NON_VOLATILE.

EFI_VARIABLE_HARDWARE_ERROR_RECORD is always handled separately; it always
takes priority over the three cases listed above.

Introduce the GetMaxVariableSize() helper to consider
PcdMaxVolatileVariableSize, in addition to
GetNonVolatileMaxVariableSize(). GetNonVolatileMaxVariableSize() is
currently called at three sites, and two of those need to start using
GetMaxVariableSize() instead:
- VariableServiceInitialize() [VariableSmm.c]: the SMM comms buffer must
  accommodate all kinds of variables,
- VariableCommonInitialize() [Variable.c]: the preallocated scratch space
  must also accommodate all kinds of variables,
- InitNonVolatileVariableStore() [Variable.c] can continue using
  GetNonVolatileMaxVariableSize().

Don't modify the ReclaimForOS() function as it is specific to non-volatile
variables and should ignore PcdMaxVolatileVariableSize.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Gary Lin <glin@suse.com>
Tested-by: Gary Lin <glin@suse.com>
[lersek@redhat.com: set MaxVolatileVariableSize where Star suggested]
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-30 21:17:07 +02:00
Star Zeng 3d7ebd6434 MdeModulePkg Variable: Align TPL level for (Smm)EndOfDxe callback
VariableRuntimeDxe will have OnEndOfDxe() callback function at
TPL_NOTIFY level on EndOfDxe event when DXE variable solution is
used.
  Status = gBS->CreateEventEx (
                  EVT_NOTIFY_SIGNAL,
                  TPL_NOTIFY,
                  OnEndOfDxe,
                  NULL,
                  &gEfiEndOfDxeEventGroupGuid,
                  &EndOfDxeEvent
                  );

VariableSmm will have SmmEndOfDxeCallback() callback function at
TPL_CALLBACK level on SmmEndOfDxe event when SMM variable solution
is used.
SmmIplGuidedEventNotify()  -  PiSmmIpl.c TPL_CALLBACK on EndOfDxe
->
SmmEndOfDxeHandler()  -  PiSmmCore.c install SmmEndOfDxe protocol
->
SmmEndOfDxeCallback() - VariableSmm.c

The TPL level for (Smm)EndOfDxe callback between VariableRuntimeDxe
and VariableSmm is inconsistent, it will make the unified platform
code could not make sure its TPL_NOTIFY EndOfDxe callback function
(to use variable lock/check) executed before (Smm)EndOfDxe callback
function in variable driver. The variable lock/check will start to
protect after (Smm)EndOfDxe callback function in variable driver is
executed.

This patch is to algin the TPL level to TPL_CALLBACK for (Smm)EndOfDxe
callback between VariableRuntimeDxe and VariableSmm.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
2018-03-30 14:14:25 +08:00
Jeff Brasen 709c9fd56b MdeModulePkg/PartitionDxe: Add partition type guid to installed handle
Add the partition type GUID for every partition to the installed handle,
this is required per the UEFI specification.

"The firmware must add the PartitionTypeGuid to the handle of every
active GPT partition using EFI_BOOT_SERVICES.InstallProtocolInterface()."

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jeff Brasen <jbrasen.qdt@qualcommdatacenter.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-29 13:05:19 +08:00
Ming Huang 824b6e3b5f MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS
Booting from USB may fail while the macro USB_BOOT_IO_BLOCKS
set to 128 because the block size of some USB devices are exceeded
512, like some virtual CD-ROM from BMC, the block size is 2048.
So,the count blocks to transfer should be calculated by block
size of the USB devices.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang <ming.huang@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-26 11:02:43 +08:00
Ruiyu Ni dd190645eb MdeModulePkg/UsbKb: fix shell edit cannot read '!@#$%^&*' characters
Commit 5563281fa2
* ShellPkg/[hex]edit: use SimpleTextInEx to read console
changes shell edit and hexedit to read input through SimpleTextInEx.

It exposes a issue in UsbKeyboard driver:
Per UEFI Spec,
When interpreting the data from this function (ReadKeyStrokeEx), it
should be noted that if a class of printable characters that are
normally adjusted by shift modifiers (e.g. Shift Key + "f" key) would
be presented solely as a KeyData.Key.UnicodeChar without the
associated shift state. So in the previous example of a Shift Key +
"f" key being pressed, the only pertinent data returned would be
KeyData.Key.UnicodeChar with the value of "F".

UsbKeyboard driver does convert Shift Key + "f" to "F" without the
shift state. But it doesn't do the conversion for all printable
characters, e.g.: Shift Key + "1" --> "!".

The root cause is today's logic to check whether a character is
printable or not is as below:
  if ((KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_CAPS_LOCK)
      != 0) {

So it only converts Shift + "a"-"z", but doesn't for Shift + "0"-"9",
and Shift + "["...

The patch updates the check logic as below to fix the issue:
  if ((KeyDescriptor->Unicode != CHAR_NULL) &&
      (KeyDescriptor->ShiftedUnicode != CHAR_NULL) &&
      (KeyDescriptor->Unicode != KeyDescriptor->ShiftedUnicode)) {

The above check is TRUE when the character is printable and
it's *really* affected by Shift key.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-26 09:28:58 +08:00
Michael D Kinney bf9b044e67 MdeModulePkg/CapsuleApp: Center bitmap at bottom of screen
https://bugzilla.tianocore.org/show_bug.cgi?id=907

When -G option is used to convert a BMP file to a UX capsule,
the bitmap is centered horizontally and placed in the lower
half of the screen below the boot logo.

This matches examples shown in the following pages:

https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/user-experience-for-uefi-firmware-updates
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/boot-screen-components

Checks are also made to make sure the bitmap provided
fits in the current GOP mode.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-03-21 20:55:27 -07:00
Michael D Kinney 845f7cfef2 MdeModulePkg/CapsuleApp: Fix logic bug in CleanGatherList()
https://bugzilla.tianocore.org/show_bug.cgi?id=905

Fix pointer math when more than one capsule is passed
to the CapsuleApp.  Use the ContinuationPointer from
the last array entry instead of the first array entry.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-03-21 20:55:27 -07:00
Hao Wu bce776a5b6 MdeModulePkg/DxeMain: Fix BSP interrupts reenabled in ExitBootServices
Within function CoreExitBootServices(), this commit will move the call
of:

MemoryProtectionExitBootServicesCallback();

before:

SaveAndSetDebugTimerInterrupt (FALSE);
and
gCpu->DisableInterrupt (gCpu);

The reason is that, within MemoryProtectionExitBootServicesCallback(),
APIs like RaiseTpl and RestoreTpl maybe called. An example will be:

DebugLib (using PeiDxeDebugLibReportStatusCode instance)
 |
 v
ReportStatusCodeLib (using DxeReportStatusCodeLib instance)
 |
 v
Raise/RestoreTpl

The call of Raise/RestoreTpl APIs will re-enable BSP interrupts. Hence,
this commit refine the calling sequence to ensure BSP interrupts before
leaving CoreExitBootServices().

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-20 15:54:15 +08:00
Dandan Bi ae38c9765a MdeModulePkg: Fix coding style issues in file/function comments
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-19 09:57:22 +08:00
Ruiyu Ni d0976b9acc MdeModulePkg/DxeCapsuleLibFmp: Add more check for the UX capsule
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-03-16 17:34:42 +08:00
Jian J Wang a2f32ef6ff MdeModulePkg/PiSmmCore: fix #PF caused by freeing read-only memory
SMM core will add a HEADER before each allocated pool memory and clean
up this header once it's freed. If a block of allocated pool is marked
as read-only after allocation (EfiRuntimeServicesCode type of pool in
SMM will always be marked as read-only), #PF exception will be triggered
during memory pool freeing.

Normally EfiRuntimeServicesCode type of pool should not be freed in the
real world. But some test suites will actually do memory free for all
types of memory for the purpose of functionality and conformance test.
So this issue should be fixed anyway.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.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: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-16 15:01:59 +08:00
Jian J Wang 36f2f049a8 MdeModulePkg/Core: fix bits operation error on a boundary condition
If given address is on 64K boundary and the requested bit number is 64,
all SetBits(), ClearBits() and GetBits() will encounter ASSERT problem
in trying to do a 64 bits of shift, which is not allowed by LShift() and
RShift(). This patch tries to fix this issue by turning bits operation
into whole integer operation in such situation.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.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: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-16 15:01:12 +08:00
Jian J Wang 883787a2c6 MdeModulePkg/PiSmmCore: fix bits operation error on a boundary condition
If given address is on 64K boundary and the requested bit number is 64,
all SetBits(), ClearBits() and GetBits() will encounter ASSERT problem
in trying to do a 64 bits of shift, which is not allowed by LShift() and
RShift(). This patch tries to fix this issue by turning bits operation
into whole integer operation in such situation.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.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: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-16 15:01:12 +08:00
Jian J Wang 7fef06af4e MdeModulePkg/Core: allow HeapGuard even before CpuArchProtocol installed
Due to the fact that HeapGuard needs CpuArchProtocol to update page
attributes, the feature is normally enabled after CpuArchProtocol is
installed. Since there're some drivers are loaded before CpuArchProtocl,
they cannot make use HeapGuard feature to detect potential issues.

This patch fixes above situation by updating the DXE core to skip the
NULL check against global gCpu in the IsMemoryTypeToGuard(), and adding
NULL check against gCpu in SetGuardPage() and UnsetGuardPage() to make
sure that they can be called but do nothing. This will allow HeapGuard to
record all guarded memory without setting the related Guard pages to not-
present.

Once the CpuArchProtocol is installed, a protocol notify will be called
to complete the work of setting Guard pages to not-present.

Please note that above changes will cause a #PF in GCD code during cleanup
of map entries, which is initiated by CpuDxe driver to update real mtrr
and paging attributes back to GCD. During that time, CpuDxe doesn't allow
GCD to update memory attributes and then any Guard page cannot be unset.
As a result, this will prevent Guarded memory from freeing during memory
map cleanup.

The solution is to avoid allocating guarded memory as memory map entries
in GCD code. It's done by setting global mOnGuarding to TRUE before memory
allocation and setting it back to FALSE afterwards in GCD function
CoreAllocateGcdMapEntry().

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-16 15:01:11 +08:00
Liming Gao 792ace0ac3 MdeModulePkg BrotliLib: Rename function with the specific lib name
This change is to avoid the function conflict.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-16 14:34:43 +08:00
Heyi Guo dc080d3b61 MdeModulePkg/PciBus: return CPU address for GetBarAttributes
According to UEFI spec 2.7, PciIo->GetBarAttributes should return host
address (CPU view ddress) rather than device address (PCI view
address), and
device address = host address + address translation offset,
so we subtract translation from device address before returning.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Reviewed-by: Ni Ruiyu <ruiyu.ni@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2018-03-15 08:26:06 +00:00
Heyi Guo c03860d052 MdeModulePkg/PciBus: convert host address to device address
According to UEFI spec 2.7, PciRootBridgeIo->Configuration() should
return host address (CPU view ddress) rather than device address
(PCI view address), so in function GetMmioAddressTranslationOffset we
need to convert the range to device address before comparing.

And device address = host address + translation offset.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Reviewed-by: Ni Ruiyu <ruiyu.ni@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2018-03-15 08:26:05 +00:00
Heyi Guo 74d0a339b8 MdeModulePkg/PciHostBridgeDxe: Add support for address translation
PCI address translation is necessary for some non-x86 platforms. On
such platforms, address value (denoted as "device address" or "address
in PCI view") set to PCI BAR registers in configuration space might be
different from the address which is used by CPU to access the
registers in memory BAR or IO BAR spaces (denoted as "host address" or
"address in CPU view"). The difference between the two addresses is
called "Address Translation Offset" or simply "translation", and can
be represented by "Address Translation Offset" in ACPI QWORD Address
Space Descriptor (Offset 0x1E). However UEFI and ACPI differs on the
definitions of QWORD Address Space Descriptor, and we will follow UEFI
definition on UEFI protocols, such as PCI root bridge IO protocol and
PCI IO protocol. In UEFI 2.7, "Address Translation Offset" is "Offset
to apply to the Starting address to convert it to a PCI address". This
means:

1. Translation = device address - host address.

2. PciRootBridgeIo->Configuration should return CPU view address, as
well as PciIo->GetBarAttributes.

Summary of addresses used in protocol interfaces and internal
implementations:

1. *Only* the following protocol interfaces assume Address is Device
   Address:
(1). PciHostBridgeResourceAllocation.GetProposedResources()
     Otherwise PCI bus driver cannot set correct address into PCI
     BARs.
(2). PciRootBridgeIo.Mem.Read() and PciRootBridgeIo.Mem.Write()
(3). PciRootBridgeIo.CopyMem()
UEFI and PI spec have clear statements for all other protocol
interfaces about the address type.

2. Library interfaces and internal implementation:
(1). Base and Limit in PCI_ROOT_BRIDGE_APERTURE are device address.
     It is easy to check whether the address is below 4G or above 4G.
(2). Addresses in PCI_ROOT_BRIDGE_INSTANCE.ResAllocNode are host
     address, for they are allocated from GCD.
(3). Address passed to PciHostBridgeResourceConflict is host address,
     for it comes from PCI_ROOT_BRIDGE_INSTANCE.ResAllocNode.

RESTRICTION: to simplify the situation, we require the alignment of
Translation must be larger than any BAR alignment in the same root
bridge, so that resource allocation alignment can be applied to both
device address and host address.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Reviewed-by: Ni Ruiyu <ruiyu.ni@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2018-03-15 08:26:05 +00:00
Heyi Guo 5bb1866e53 MdeModulePkg/PciHostBridgeLib.h: add address Translation
Add Translation field to PCI_ROOT_BRIDGE_APERTURE. Translation is used
to represent the difference between device address and host address,
if they are not the same on some platforms.

In UEFI 2.7, "Address Translation Offset" is "Offset to apply to the
Starting address to convert it to a PCI address".  This means:

  Translation = device address - host address

So we also use the above calculation for this Translation field to
keep consistent.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Reviewed-by: Ni Ruiyu <ruiyu.ni@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2018-03-15 08:26:05 +00:00
Jian J Wang 12957e56d2 MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard
This patch fixes the same issues in Heap Guard in DXE core, which is fixed
in another patch.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-03-14 16:15:27 +08:00
Jian J Wang dd12683e1f MdeModulePkg/Core: fix mem alloc issues in heap guard
There're two ASSERT issues which will be triggered by boot loader of
Windows 10.

The first is caused by allocating memory in heap guard during another
memory allocation, which is not allowed in DXE core. Avoiding reentry
of memory allocation has been considered in heap guard feature. But
there's a hole in the code of function FindGuardedMemoryMap(). The fix
is adding AllocMapUnit parameter in the condition of while(), which
will prevent memory allocation from happenning during Guard page
check operation.

The second is caused by the core trying to allocate page 0 with Guard
page, which will cause the start address rolling back to the end of
supported system address. According to the requirement of heap guard,
the fix is just simply skipping the free memory at page 0 and let
the core continue searching free memory after it.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-03-14 16:15:27 +08:00
Star Zeng d154a4dfae MdeModulePkg PCD: Remove PCD_TYPE_SKU_ENABLED in PCD_TYPE_ALL_SET
Remove PCD_TYPE_SKU_ENABLED in PCD_TYPE_ALL_SET.
This change was missing at e8d2a98052.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Thomas Lamprecht <t.lamprecht@proxmox.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Tested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2018-03-13 20:50:20 +08:00
Jiaxin Wu c8e342e00b MdeModulePkg/Mtftp4Dxe: Fix the incorrect return status.
The incorrect return status was caused by the commit of 39b0867d, which
was to resolve the token status error that does not compliance with spec
definition, but it results the protocol status not compliance with spec
definition.

This patch is to resolve above issue.

Cc: Wang Fan <fan.wang@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wang, Fan <fan.wang@intel.com>
2018-03-13 16:55:18 +08:00
Gao, Liming e8d2a98052 MdeModulePkg PCD: Remove unused PCD attribute PCD_TYPE_SKU_ENABLED
PcdDb optimization has handled PCD DB for each SKU, not for single PCD.
So, this PCD attribute is not used any more.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-13 15:57:05 +08:00
Marc-André Lureau c2c4199bc2 MdeModulePkg/Core/Pei: fix REGISITER -> REGISTER typo
No functional changes.

Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-09 18:08:59 +01:00
Star Zeng 6bd4af305d MdeModulePkg LockBoxLib: Support LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY
With this flag, the LockBox can be restored in S3 resume only.
The LockBox can not be restored after SmmReadyToLock in normal boot
and after EndOfS3Resume in S3 resume.
It can not be set together with LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE.

Cc: Jiewen Yao <jiewen.yao@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>
2018-03-08 21:33:48 +08:00
Jian J Wang 8b13bca9b8 MdeModulePkg/Core: fix too many available pages between BS_Data
The root cause is an unnecessary check to Size parameter in function
AdjustMemoryS(). It will cause one standalone free page (happen to have
Guard page around) in the free memory list cannot be allocated, even if
the requested memory size is less than a page.

  //
  // At least one more page needed for Guard page.
  //
  if (Size < (SizeRequested + EFI_PAGES_TO_SIZE (1))) {
    return 0;
  }

The following code in the same function actually covers above check
implicitly. So the fix is simply removing above check.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-03-08 12:37:28 +08:00
Dandan Bi f7d05bddd7 MdeModulePkg/DriverSampleDxe: Refine the sample case for UNION type
The example of UNION storage is not good, now update it.

Cc: Eric Dong <eric.dong@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: Liming Gao <liming.gao@intel.com>
2018-03-08 08:58:47 +08:00
Hao Wu 7db1458f75 MdeModulePkg/Core: Fix feature conflict between NX and Stack guard
If enabled, NX memory protection feature will mark some types of active
memory as NX (non-executable), which includes the first page of the stack.
This will overwrite the attributes of the first page of the stack if the
stack guard feature is also enabled.

The solution is to override the attributes setting to the first page of
the stack by adding back the 'EFI_MEMORY_RP' attribute when the stack
guard feature is enabled.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-07 20:56:42 +08:00
Hao Wu a10acf0e20 MdeModulePkg/Core: Refine handling NULL detection in NX setting
The commit rewrites the logic in function
InitializeDxeNxMemoryProtectionPolicy() for handling the first page
(page 0) when NULL pointer detection feature is enabled.

Instead of skip setting the page 0, the codes will now override the
attribute setting of page 0 by adding the 'EFI_MEMORY_RP' attribute.

The purpose is to make it easy for other special handling of pages
(e.g. the first page of the stack when stack guard feature is enabled).

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-03-07 20:56:42 +08:00
Heyi Guo 72208a9a90 MdeModulePkg/UefiBootManagerLib: limit recursive call depth
Function BmRepairAllControllers may recursively call itself if some
driver health protocol returns EfiDriverHealthStatusReconnectRequired.
However, driver health protocol of some buggy third party driver may
always return such status even after one and another reconnect. The
endless iteration will cause stack overflow and then system exception,
and it may be not easy to find that the exception is actually caused
by stack overflow.

So we limit the number of reconnect retry to 10 to improve code
robustness, and DEBUG_CODE is moved ahead before recursive repair to
track the repair result.

We also remove a duplicated declaration of BmRepairAllControllers() in
InternalBm.h in this patch, for it is only a trivial change.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
2018-03-07 14:26:04 +08:00
Ruiyu Ni 61c1742ba1 MdeModulePkg/NullMemoryTest: Fix bug in CompatibleRangeTest
CompatibleRangeTest() contains two bugs:
1. It doesn't reject the memory above 16MB
2. it cannot handle the case when the partial or whole range of
   requested memory is already tested.

The patch fixes the two bugs.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-07 12:36:14 +08:00
Ruiyu Ni ee37e96479 MdeModulePkg/NullMemoryTest: Change prototype of ConvertToTestedMemory
The patch should not impact the functionality.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-07 12:36:13 +08:00
Ruiyu Ni 66f2329446 MdeModulePkg/Terminal: ReadKeyStrokeEx always return key state
Because terminal doesn't support shift and toggle key state,
ReadKeyStrokeEx just sets the two states to 0.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-06 12:14:29 +08:00
Star Zeng b77e1a240e MdeModulePkg UsbMass: Correct comment about TPL for BLOCK IO APIs
Current BLOCK IO API code is using TPL_CALLBACK,
but comment is saying TPL_NOTIFY.

Cc: Ruiyu Ni <ruiyu.ni@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>
2018-03-04 14:47:14 +08:00
Ruiyu Ni 06e2409667 MdeModulePkg/UsbMass: Retry CMD for MediaChanged sense key
When a USB device reports failure for a CMD and REQUEST SENSE returns
Media Changed key, UsbBootExecCmdWithRetry() stops to retry CMD and
returns EFI_MEDIA_CHANGED to caller.

For this case, the CMD should be retried until success, getting
NoMedia sense key or timeout.
The patch updates UsbBootExecCmdWithRetry() to follow the above
rule so EFI_MEDIA_CHANGED is no longer returned.

UsbBootDetectMedia() is updated accordingly.

Because UsbBootGetParams() is called for new plugged USB storage,
and some USB storage devices may report Media Changed key,
UsbBootGetParams() is updated to treat it as a Success.
This change could fix the issue that some USB storage devices
cannot be detected.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-03 15:49:24 +08:00
Ruiyu Ni cd626ef0fb MdeModulePkg/UsbMass: remove unnecessary RestoreTPL() call
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-03 15:49:15 +08:00
Ruiyu Ni e149055310 MdeModulePkg/UsbMass: Add more debug message
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-03 15:49:10 +08:00
Ruiyu Ni 19d76ae608 MdeModulePkg/UsbMass: Revert "map -r" media change detection fix
This reverts commit a662afb5b0.
* MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change

The above commit fixed the following issue:
When system boots to Shell without CDROM inside USB CDROM drive,
and then user inserts the CDROM with Eltorito file system,
"map -r" cannot show the new ELtorito file system.
The commit caused EFI_MEDIA_CHANGED status returned from
UsbBootDetectMedia().

But that fix exposes another issue:
When issuing ReadCapacity command to certain USB key
(Kingston DataTraveler G3 8GB) after it's hot-plugged, USB device
returns STALL error and RequestSense command returns media changed
sense data. (Most of the USB keys return SUCCESS for ReadCapacity
command after hot-plug.)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-03 15:49:04 +08:00
Ruiyu Ni 1bc5d2b3c7 MdeModulePkg/UsbMass: Revert POWER_ON(29h) ASC handling logic
This reverts commit 6461344c31.
* MdeModulePkg/UsbMass: Fix hot-plug USB CDROM can't be recognized

UsbBootExecCmd() only calls UsbBootRequestSense() to get sense key
when CMD fails.
When POWER ON (29h) ASC returns from REQUEST SENSE, implementation
should retry the CMD, instead of treating this as a SUCCESS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-03 15:48:59 +08:00
Star Zeng 1bae3e0ed1 MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone
Cc: Jiewen Yao <jiewen.yao@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>
2018-03-03 14:20:38 +08:00
Star Zeng 8f558d8aca MdeModulePkg: Add S3SmmInitDone definition
Add gEdkiiS3SmmInitDoneGuid, after S3 SMM initialization is done and
before S3 boot script is executed, this GUID is installed as PPI in
PEI and protocol in SMM environment. It allows for PEIMs or SMM
drivers to hook this point and do the required tasks.

Cc: Jiewen Yao <jiewen.yao@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>
2018-03-03 14:20:34 +08:00
Fu Siyuan 0e2a5749d8 MdeModulePkg/Mtftp4Dxe: Separate the timer ticking to calculate the packet live time.
TPL deadlock issue was enrolled by the commit of 39b0867d. To resolve the issue,
this patch separated the timer ticking for all the MTFTP clients to calculate the
packet live time in TPL_NOTIFY level.

Cc: Wang Fan <fan.wang@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2018-03-03 09:35:51 +08:00
Dandan Bi 52b68f7d45 MdeModulePkg: Fix incorrect commit introduced by commit SHA-1:052c98
The default value of PcdExtFpdtBootRecordPadSize is 0x20000
But the following commit in master update it to 0 by mistake.
SHA-1: 052c98ce24
Subject: MdeModulePkg: Add ResetSystemPei PEIM

This patch is to restore the value.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-02 16:16:33 +08:00
Dandan Bi c9f02a96d8 MdeModulePkg/DxeCorePerfLib: Add status check instead of ASSERT
Currently DxeCorePerformanceLib will get SMM performance data based
on SMM communication handler. If SMM communication handler returns error,
the library will ASSERT. In fact, if SMM perf data is not found.
DXE perf data can still be dumped. So using status check instead of
ASSERT is better.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-02 16:16:32 +08:00
Ruiyu Ni a7119c8152 MdeModulePkg/DebugLibReportStatusCode: Fix hang if format is too long
The previous commit 137ed15511
* MdeModulePkg/DebugLib: Print partial when format string is too long
copies partial format string to DEBUG_INFO buffer but when parsing
the format modifier, the original format string is still used.

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-02 13:41:33 +08:00
Kinney, Michael D 90f7f19ae7 MdeModulePkg/BootLogoLib: Use Boot Logo 2 Protocol
https://bugzilla.tianocore.org/show_bug.cgi?id=799

Based on content from the following branch/commit:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
33bab4031a

Add check to see if the Boot Logo 2 Protocol is available
and attempt to set the location and size of the boot logo
using both the Boot Logo Protocol and the Boot Logo 2
Protocol.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
2018-02-28 11:59:31 -08:00
Michael D Kinney 7777360637 MdeModulePkg/BootGraphicsResourceDxe: Add Boot Logo 2 Protocol
https://bugzilla.tianocore.org/show_bug.cgi?id=799

Based on content from the following branch/commit:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
33bab4031a

Update BootGraphicsResourceDxe to produce both the Boot Logo
Protocol and the Boot Logo 2 Protocol.

The Boot Logo 2 Protocol service GetBootLogo() is amended
to return the pointer to the GOP BLT buffer previously
registered with the SetBootLogo() service.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
2018-02-28 11:58:27 -08:00
Kinney, Michael D b7c7ec8c17 MdeModulePkg: Add Boot Logo 2 Protocol
https://bugzilla.tianocore.org/show_bug.cgi?id=799

Based on content from the following branch/commit:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
33bab4031a

Add new Boot Logo 2 Protocol that adds a GetBootLogo()
service that can be used to retrieve the GOP BLT buffer,
location, and size of the boot logo that was previously
registered with the SetBootLogo() service.

The Boot Logo 2 Protocol service GetBootLogo() is amended
to return the pointer to the GOP BLT buffer previously
registered with the SetBootLogo() service.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
2018-02-28 11:57:02 -08:00
Ruiyu Ni de707b0866 MdeModulePkg/PlatformLogo.h: Correct function header comments
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-28 15:30:25 +08:00
Ruiyu Ni 25184ec33c MdeModulePkg/Logo.idf: Remove incorrect comments.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-28 15:30:23 +08:00
Liming Gao f0c69b614c MdeModulePkg PCD: Fix the issue to set the big SkuId
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-27 18:43:31 +08:00
Liming Gao f71503c37c MdeModulePkg PCD: Add more debug message to show SkuId update
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-27 18:43:30 +08:00
Ruiyu Ni 1c06bd485e MdeModulePkg/NullMemoryTest: Handle more reliable memory
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=650

Today's implementation converts the untested more reliable memory
from reserved GCD type to system memory GCD type.
Though it doesn't impact the return result of gBS->GetMemoryMap().
But it impacts the return result of gDS->GetMemorySpaceDescriptor().
The patch fixes the bug to convert the untested more reliable memory
from reserved GCD type to more reliable memory GCD type.

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: Liming Gao <liming.gao@intel.com>
2018-02-27 13:56:03 +08:00
Ruiyu Ni 2e5fb984ed MdeModulePkg/GenericMemoryTest: Handle more reliable memory
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=650
Today's implementation converts the untested more reliable memory
from reserved GCD type to system memory GCD type.
Though it doesn't impact the return result of gBS->GetMemoryMap().
But it impacts the return result of gDS->GetMemorySpaceDescriptor().
The patch fixes the bug to convert the untested more reliable memory
from reserved GCD type to more reliable memory GCD type.

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: Liming Gao <liming.gao@intel.com>
2018-02-27 13:56:00 +08:00
Star Zeng f068aa038d MdeModulePkg SmmLockBox: Return updated Length for EFI_BUFFER_TOO_SMALL
The updated Length value should be returned
for EFI_BUFFER_TOO_SMALL case.

Cc: Jiewen Yao <jiewen.yao@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>
2018-02-26 14:03:23 +08:00
Liming Gao 63c677e20f MdeModulePkg PeiCore: Add error message to describe PEIM load failure
If PEIM image address doesn't meet with its section alignment, it will
load fail. PeiCore adds more debug message to report it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-26 13:18:40 +08:00
Hao Wu 0feca62c7a MdeModulePkg/RamDiskDxe: Perform MediaId check first in BlkIo services
The commit places the check for MediaId at the beginning of Block IO
services:
RamDiskBlkIoReadBlocks and
RamDiskBlkIoWriteBlocks

This aligns with the Block IO protocol implementations for other
devices.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-02-26 08:45:57 +08:00
Hao Wu 8bdb022115 MdeModulePkg/RecoveryDevice.h: Remove semicolon after GUID definitions
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=877

Cc: Eric Dong <eric.dong@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>
2018-02-24 08:27:00 +08:00
Leif Lindholm a9b7e035ba MdeModulePkg: use central variable definitions in DriverSampleDxe
Use UefiMultiPhase.h in Vfr.vfr instead of duplicating EFI_VARIABLE_*
definitions.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-23 14:23:20 +00:00
Ruiyu Ni 6461344c31 MdeModulePkg/UsbMass: Fix hot-plug USB CDROM can't be recognized
In below calling stack:
UsbBootIsUnitReady()
 UsbBootExecCmdWithRetry()
  UsbBootExecCmd()
    UsbBootRequestSense()
When USB CDROM is hot-plugged, UsbBootRequestSense() retrieves sense
key (6 = UnitAttention), additional sense code (29h = Power ON).
But it wrongly maps such sense data to Device Error status.
It causes UsbBootExecCmd() executed again.
In the second time call to UsbBootExecCmd(), UsbBootRequestSense()
retrieves sense key (6 = UnitAttention), additional sense code
(28h = media changed).

The above analysis explains why hot-plug USB CDROM cannot be
recognized after below commit:
SHA1 a662afb5b0
* MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change,
which removes the media changed status check in UsbBootDetectMedia().

The proper fix to this problem is to map the ASC (additional sense
code 29h) properly to success status so that no second call to
UsbBootExecCmd() is made.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
2018-02-15 14:17:22 +08:00
Ruiyu Ni 5eecb45af0 MdeModulePkg/ResetUtilityLib: Fix GCC build failure
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-02-14 09:13:48 +08:00
Hao Wu 99576ee3fd MdeModulePkg/BmpSupportLib: Refine type cast for pointer subtraction
Since the pointer subtraction here is not performed by pointers to
elements of the same array object. This might lead to potential issues,
such behavior is undefined according to C11 standard.

Refine the pointer subtraction expressions by casting each pointer to
UINTN first and then perform the subtraction.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
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: Star Zeng <star.zeng@intel.com>
2018-02-14 08:19:47 +08:00
Laszlo Ersek bad0b5e871 MdeModulePkg/UefiBootManagerLib: remove superfluous TimerLib dependency
In commit 3a039a567a ("MdeModulePkg/UefiBootManagerLib: Remove the
useless perf codes", 2018-02-12), the BmWriteBootToOsPerformanceData()
function was removed. No TimerLib API calls are left, thus remove the
TimerLib class dependency from "InternalBm.h" and "UefiBootManagerLib.inf"
as well.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2018-02-13 13:29:33 +01:00
Dandan Bi ae957a59f7 MdeModulePkg/Performance.h: Remove the useless definition
Remove the definitions related to old perf codes.

Cc: Star Zeng <star.zeng@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: Star Zeng <star.zeng@intel.com>
2018-02-12 11:36:16 +08:00
Dandan Bi 3a039a567a MdeModulePkg/UefiBootManagerLib: Remove the useless perf codes
V2: Just update the commit message to reference the hash value of
new performance infrastructure.

Our new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14 ~
SHA-1: 115eae650b) can support to
dump performance date form ACPI table in OS. So we can remove
the old perf code to write performance data to OS.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@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>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-12 11:36:14 +08:00
Dandan Bi 9f0d7651b3 MdeModulePkg/BdsDxe: Remove useless perf Code
V2: Just update the commit message to reference the hash value of
new performance infrastructure.

Our new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14 ~
SHA-1: 115eae650b) can support to
dump performance date form ACPI table in OS. So we can remove
the old perf code to write performance data to OS.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@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>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-12 11:36:14 +08:00
Kinney, Michael D 7f0301e39a MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP
https://bugzilla.tianocore.org/show_bug.cgi?id=873

Update IsNestedFmpCapsule() to verify the CapsuleGuid in
the CapsuleHeader against the installed Firmware Management
Protocol instances.  The current logic that uses the ESRT
Table does not work because capsules are processed before
the ESRT Table is published at the Ready To Boot event.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
2018-02-11 16:35:15 -08:00
Michael D Kinney 53be772103 MdeModulePkg/BootGraphicsResourceTableDxe: Use BmpSupportLib
https://bugzilla.tianocore.org/show_bug.cgi?id=800

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
33bab4031a
ca516b1a61
2b9f111f2e

Use BmpSupportLib to convert a GOP BLT Buffer to the BMP graphics
image that is published in an ACPI BGRT table.

* Remove use of IndustryStandard/Bmp.h include file
* Remove mBmpImageHeaderTemplate.  This is handled by BmpSupportLib
* Clean up code style with function prototypes at top
  and all module global variables together
* Update SetBootLogo() to use SafeIntLib to check input parameters
  for overflows.
* Remove internal function BgrtAcpiTableChecksum().  Use
  CalculateCheckSum8() directly from BgrtReadyToBootEventNotify()
* Remove InstallBootGraphicsResourceTable().  Move all the code into
  BgrtReadyToBootEventNotify() that is signaled at ready to boot.
* Remove all logic that converts a GOP BLT buffer to a BMP graphics image
  and use BmpSupportLib function TranslateGopBltToBmp() instead.
* Use AllocatePool() instead of AllocatePages() to allocate copy of
  BMP image that is provided by BGRT.  This is required to be compatible
  with BmpSupportLib function TranslateGopBltToBmp() that uses
  AllocatePool().
* Zero OemId in BGRT header before filling in value from PCD.
* Get size of PcdAcpiDefaultOemId and only copy the the size of the PCD
  if it is smaller than the size of the OemId field in the BGRT header.
* Use WriteUnaligned24() instead of CopyMem() for the OemTableId field
  of the BGRT header.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
2018-02-11 16:05:23 -08:00
Michael D Kinney 1ec2e7d0e8 MdeModulePkg/DxeCapsuleLibFmp: Use BmpSupportLib
https://bugzilla.tianocore.org/show_bug.cgi?id=800

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
33bab4031a
ca516b1a61
2b9f111f2e

Use BmpSupportLib to convert a BMP graphics image to a
GOP BLT buffer.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
2018-02-11 16:05:15 -08:00
Kinney, Michael D 4123d6da70 MdeModulePkg: Add BmpSupportLib class and instance
https://bugzilla.tianocore.org/show_bug.cgi?id=800

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
33bab4031a
ca516b1a61
2b9f111f2e

Add BmpSupportLib class and instances that provides services to
convert a BMP graphics image to a GOP BLT buffer and to convert
a GOP BLT buffer to a BMP graphics image.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
2018-02-11 16:04:54 -08:00
Michael D Kinney 4184aabda2 MdeModulePkg/EsrtFmpDxe: Add EsrtFmpDxe module
https://bugzilla.tianocore.org/show_bug.cgi?id=802

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

The EsrtFmpDxe module is a lightweight version of the EsrtDxe
module that produces ESRT entries based only on FMP Protocol
instances.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
2018-02-11 15:32:29 -08:00
Dandan Bi c9faac275b MdeModulePkg/PerfLib: Add NULL pointer check for "Token"
"Token" is passed through the perf entry, it's may be NULL.
So we need to add NULL pointer check before reference it.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-11 09:56:01 +08:00
Bi, Dandan 6b86f6f336 MdeModulePkg/DriverSampleDxe: Make bit fields aligned in C structure
For a structure with a series of bit fields and used as a storage
in vfr file, and if the bit fields do not add up to the size of
the defined type.In the C code use sizeof() to get size of the
structure, the results may vary form the compiler(VS,GCC...).
But the size of the storage calculated by VfrCompiler is fixed
(calculate with alignment).To avoid the issue cased by above case,
we need to make the total width of the bit fields in the structure
aligned with the size of the defined type for these bit fields.

Cc: Eric Dong <eric.dong@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: Liming Gao <liming.gao@intel.com>
2018-02-09 17:04:15 +08:00
Bret Barkelew ce2697abeb MdeModulePkg/ResetSystemPei: Add reset notifications in PEI
The Reset Notification protocol is added in UEFI spec to support
reset notification mechanism in the DXE phase.
This patch adds similar EDKII specific Reset Notification PPI to PEI
phase to provide the same support.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-02-09 15:30:01 +08:00
Ruiyu Ni 052c98ce24 MdeModulePkg: Add ResetSystemPei PEIM
This driver implements Reset2, ResetFilter and ResetHandler PPIs.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-02-09 15:30:00 +08:00
Michael D Kinney e12ceb40ce MdeModulePkg: Add ResetUtility library class and BASE instance
The library class that provides services to generate a GUID specific
reset, parse the GUID from a GUID specific reset, and build the
ResetData buffer for any type of reset that requires extra data.

Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-02-09 15:29:58 +08:00
Michael D Kinney ce3cd892c8 MdeModulePkg: Add ResetSystemLib instances that call core services
Add a PEI instance of ResetSystemLib that calls the ResetSystem2()
service in the PEI Services Table.

Add a DXE instance of ResetSystemLib that calls the ResetSystem()
service in the UEFI Runtime Services Table.

These 2 library instances should be the default ResetSystemLib
mapping for most PEIMs and DXE drivers so all reset system requests
go through the core service.

Only the implementation of the core servies should use the
platform specific instance of the ResetSystemLib that actually
performs the hardware actions to reset the platform.

Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-02-09 15:29:58 +08:00
Ruiyu Ni 4bf95a9f36 MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message
The patch adds more debug message in ResetSystem().
It also removes unnecessary check of mResetNotifyDepth.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-02-09 15:29:57 +08:00