summaryrefslogtreecommitdiff
path: root/MdePkg
AgeCommit message (Collapse)AuthorFilesLines
2018-06-07MdePkg: Remove X86 ASM and S filesLiming Gao308-15375/+8
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: Michael Kinney <michael.d.kinney@intel.com>
2018-06-05MdePkg UefiLib: Fix in EfiLocateProtocolBuffer()Star Zeng1-0/+4
Free HandleBuffer for error path in EfiLocateProtocolBuffer(). Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-06-05MdePkg/UefiRuntimeLib: Do not allow to be linked by DXE driverRuiyu Ni1-2/+2
When UefiRuntimeLib links to a DXE driver, its constructor still registers a Virtual Address Change event. The event callback will get called when RT.SetVirtualAddressMap() is called from OS. But when the driver is a DXE driver, the memory occupied by the callback function might be zeroed or used by OS since the BS type memory is free memory when entering to RT phase. The patch reverts commit 97511979b4fdd84cf7cd51e43c22dc03e79bd4f3 "MdePkg/UefiRuntimeLib: Support more module types." It makes sure that DXE driver cannot link to this library. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-29MdePkg/DxeServicesLib: introduce AllocatePeiAccessiblePages routineArd Biesheuvel4-2/+155
Add a routine to DxeServicesLib that abstracts the allocation of memory that should be accessible by PEI after resuming from S3. We will use it to replace open coded implementations that limit the address to < 4 GB, which may not be possible on non-Intel systems that have no 32-bit addressable memory at all. 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: Liming Gao <liming.gao@intel.com>
2018-05-28MdePkg: Update MmSwDispatch.h's references to SmmSw2Dispatch.Marvin.Haeuser@outlook.com1-3/+3
MmSwDispatch.h current refers to the deprecated SmmSw2Dispatch protocol. Replace those references with the new MmSwDispatch name. V2: - Do not change the copyright date as requested. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-05-28MdePkg/Hpet: Add Event Timer Block ID definition.Marvin.Haeuser@outlook.com1-0/+16
This patch adds the HPET Event Timer Block ID definition that can be found in the IA-PC HPET Specification, section 3.2.4. V2: - Do not change the copyright date as requested. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-05-24MdePkg/TcgStorage*.h: Fixed ECC reported issues.Eric Dong2-5/+5
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
2018-05-23MdePkg/IndustryStandard: Add header file for SPMI ACPI tableHao Wu1-0/+104
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=840 Add the header file for Service Processor Management Interface ACPI table definition. Cc: Younas Khan <pmdyounaskhan786@gmail.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@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>
2018-05-23MdePkg UefiLib: Fix XCODE5 varargs warningLiming Gao2-2/+2
https://bugzilla.tianocore.org/show_bug.cgi?id=741 Change GetBestLanguage() 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-21MdePkg/SmmPeriodicSmiLib: Get Periodic SMI Context More RobustlyRuiyu Ni1-23/+15
The PeriodicSmiDispatchFunction() in SmmPeriodicSmiLib may assert with "Bad CR signature". Currently, the SetActivePeriodicSmiLibraryHandler() function (invoked at the beginning of the PeriodicSmiDispatchFunction() function) attempts to locate the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure pointer for the current periodic SMI from a given EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT (RegiserContext) structure pointer (using the CR macro). The RegisterContext structure pointer passed to the PeriodicSmiDispatchFunction() is assumed to point to the same RegisterContext structure address given to the SmmPeriodicTimerDispatch2 protocol Register() API in PeriodicSmiEnable(). However, certain SmmPeriodicTimerDispatch2 implementation may copy the RegisterContext to a local buffer and pass that address as the context to PeriodicSmiDispatchFunction() in which case usage of the CR macro to find the parent structure base fails. The patch uses the LookupPeriodicSmiLibraryHandler() function to find the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure pointer. This works even in this scenario since the DispatchHandle returned from the SmmPeriodicTimerDispatch2 Register() function uniquely identifies that registration. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-05-17MdePkg/UefiLib: Add 'OUT' decorator where necessary.Marvin.Haeuser@outlook.com2-18/+18
The functions AddUnicodeString() and AddUnicodeString2() might return a new value into their parameter UnicodeStringTable, hence add the appropiate 'OUT' decorator. V2: Update FrameworkUefiLib as well. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-05-17MdePkg/PeiServicesLib: Decorate 'PpiDescriptor' as OPTIONAL for LocatePpi().Marvin.Haeuser@outlook.com2-4/+4
The UEFI PI specification defines PpiDescriptor to be OPTIONAL for the LocatePpi PEI Service. This patch reflects this in the function declaration and definition of the corresponding PeiServices library function. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-05-17MdePkg/TcgStorage*.h: Add referenced spec information.Eric Dong2-2/+21
Add link and version info for the referenced spec. Cc: Jiewen yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
2018-05-07MdePkg: Add Feature definitions added in pyrite 2.0 spec.Eric Dong2-0/+56
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
2018-05-02MdePkg/DevicePathToText: Fix iSCSI.Lun byte order issueRuiyu Ni1-6/+8
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-04-25MdePkg FirmwareManagement.h: Fix typo EFI_SECURITY_VIOLATIOStar Zeng1-6/+7
Fix typo EFI_SECURITY_VIOLATIO to EFI_SECURITY_VIOLATION. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-04-17MdePkg/Library/BaseCpuLib: Enable VS2017/ARM64 buildsPete Batard3-3/+84
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-04-17MdePkg/Library/BaseSynchronizationLib: Enable VS2017/ARM64 buildsPete Batard2-1/+207
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-04-13MdePkg/Include/Protocol/Tls.h: pack structures from the TLS RFCLaszlo Ersek1-0/+10
The structures defined in RFC 5246 are not to have any padding between fields or at the end; use the "pack" pragma as necessary. Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Long Qin <qin.long@intel.com> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-04-13MdePkg DxeHstiLib: Fix ErrorString pointer incorrectly calculatedStar Zeng1-2/+2
Fix ErrorString pointer is incorrectly calculated in InternalHstiIsValidTable(). Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2018-04-04MdePkg/BaseLib: add PatchInstructionX86()Laszlo Ersek3-0/+147
Some edk2 modules generate X86 machine code at module execution time by: - compiling "template" code with NASM at module build time, - linking the object code into the module, - and patching the immediate (constant) operands of some instructions when the module is executed. Add a helper function to BaseLib so that the C code performing the patching is easier to read and maintain. The implementation in this patch is taken mainly from Mike Kinney's mailing list messages at <http://mid.mail-archive.com/E92EE9817A31E24EB0585FDF735412F5B895C360@ORSMSX113.amr.corp.intel.com>, <http://mid.mail-archive.com/E92EE9817A31E24EB0585FDF735412F5B898BF66@ORSMSX112.amr.corp.intel.com>. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=866 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-04-04MdePkg/BaseLib.h: state preprocessing conditions in comments after #endifsLaszlo Ersek1-13/+11
"#endif" preprocessing directives near the top of "BaseLib.h" helpfully repeat the preprocessing conditions from their matching "#if", "#ifdef", and "#ifndef" directives. This practice has been less followed recently; supplement the missing comments. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=866 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-22MdePkg/Tls1.h: Add TLS record header length and max payload length.Jiaxin Wu1-1/+15
Cc: Karunakar P <karunakarp@amiindia.co.in> 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: Karunakar p <karunakarp@amiindia.co.in> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2018-03-20MdePkg BaseStackCheckLib: Correct style of file headerLiming Gao1-5/+2
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Bi Dandan <dandan.bi@intel.com>
2018-03-20MdePkg/Library/BaseLib/AArch64: Comment style harmonizationPete Batard2-94/+98
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-19MdePkg/Include: Add VA list support for VS2017/ARM64Pete Batard1-4/+3
We need to explicitly call the built-in __va_start() for ARM64, otherwise the variable parameters are not properly enqueued for the next function calls. Also do the same for ARM, as as it doesn't harm us. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-19MdePkg/Library/BaseLib: Enable VS2017/ARM64 buildsPete Batard8-0/+378
Required GCC assembly files are converted for the MSFT assembler Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-19MdePkg: Disable some Level 4 warnings for VS2017/ARM64Pete Batard1-2/+51
We disable the exact same warnings as IA32 and X64. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-03MdePkg/DevicePathFromText: Fix byte orders of iSCSI.LunRuiyu Ni1-1/+3
Per UEFI spec, iSCSI.Lun is a 8-byte array with byte #0 in the left. It means "0102030405060708" should be converted to: UINT8[8] = {01, 02, 03, 04, 05, 06, 07, 08} or UINT64 = {0807060504030201} Today's implementation wrongly uses the reversed order. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jie Lin <jie.lin@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
2018-03-03MdePkg/DevicePathFromText: Fix bug when converting iSCSI nodeRuiyu Ni1-2/+2
If protocol string is not specified, default TCP(0) should be used. Today's implementation wrongly sets to 1 for this case. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-03MdePkg/Include/IndustryStandard: Add PCI Express 4.0 header fileFelix Polyudov1-0/+89
v3: LaneEqualizationControl is changed to be an array. v2: The structure is updated to include all the fields defined in the PCI-E specification. The header includes Physical Layer PCI Express Extended Capability definitions described in section 7.7.5 of PCI Express Base Specification rev. 4.0. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Felix Polyudov <felixp@ami.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-28MdePkg/BaseSafeIntLib: Fix VS2015 IA32 NOOPT build failureDandan Bi3-5/+10
v2: Add [LibraryClasses] section in INF file and refine coding style. There are VS2015 NOOPT IA32 build failure like below in BaseSafeIntLib. XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allmul XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allshl XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __aullshr This patch replaces direct shift/multiplication of 64-bit integer with related function call to fix these failure. Cc: Laszlo Ersek <lersek@redhat.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael Kinney <michael.d.kinney@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: Laszlo Ersek <lersek@redhat.com>
2018-02-26MdePkg BaseCpuLib: Make it pass VS ARM buildLiming Gao1-1/+3
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Pete Batard <pete@akeo.ie>
2018-02-24MdePkg: introduce DxeRuntimeDebugLibSerialPortArd Biesheuvel3-0/+422
Introduce a variant of BaseDebugLibSerialPort that behaves correctly with regards to the use of the serial port after ExitBootServices(). At boot time, all DEBUG() prints and ASSERT() invocations are executed normally. At runtime, DEBUG() prints are dropped entirely, and ASSERT()s omit the serial output as well, and only perform the configured post-ASSERT() action, i.e., issue a CPU breakpoint or enter a deadloop. 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: Michael D Kinney <michael.d.kinney@intel.com>
2018-02-23MdePkg: restrict UefiMultiPhase.h contents if VFRCOMPILE definedLeif Lindholm1-21/+23
Turns out all .vfr files in the tree interacting with DynamicPcds manually copy the same set of EFI_VARIABLE_* definitions, since the rest of UefiMultiPhase.h is incompatible with VfrCompile. For now, reshuffle these definitions to the start of the file, and put the rest of the file behind #ifndef VFRCOMPILE to permit direct inclusion in .vfr source files. https://bugzilla.tianocore.org/show_bug.cgi?id=878 has been raised to request VfrCompile is extended to support the original format. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-21MdePkg/BaseSafeIntLib: fix undefined behavior in SafeInt64Mult()Laszlo Ersek1-0/+2
If we have to negate UnsignedResult (due to exactly one of Multiplicand and Multiplier being negative), and UnsignedResult is exactly MIN_INT64_MAGNITUDE (value 2^63), then the statement *Result = - ((INT64)UnsignedResult); invokes both implementation-defined behavior and undefined behavior. First, MIN_INT64_MAGNITUDE is not representable as INT64, therefore the result of the (inner) conversion (INT64)MIN_INT64_MAGNITUDE is implementation-defined, or an implementation-defined signal is raised, according to ISO C99 6.3.1.3p3. Second, if we assume that the C language implementation defines the conversion to INT64 simply as reinterpreting the bit pattern 0x8000_0000_0000_0000 as a signed integer in two's complement representation, then the conversion immediately produces the negative value MIN_INT64 (value -(2^63)). In turn, the (outer) negation -(MIN_INT64) invokes undefined behavior, because the mathematical result of the negation, namely 2^63, cannot be represented in an INT64 object. (Not even mentioning the fact that the mathematical result would be incorrect.) In practice, the undefined negation of MIN_INT64 happens to produce an unchanged, valid-looking result on x86, i.e. (-(MIN_INT64)) == MIN_INT64. We can summarize this as the undefined -- effectless -- negation canceling out the botched -- auto-negating -- implementation-defined conversion. Instead of relying on such behavior, dedicate a branch to this situation: assign MIN_INT64 directly. The branch can be triggered e.g. by multiplying (2^62) by (-2). Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@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: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-02-21MdePkg/BaseSafeIntLib: clean up parentheses in MIN_INT64_MAGNITUDELaszlo Ersek1-1/+1
The definition of the MIN_INT64_MAGNITUDE macro is correct, but it's harder to read than necessary: the sub-expression (( (UINT64) - (MIN_INT64 + 1) )) is doubly parenthesized. Reusing one pair of the outer parens, rewrite the sub-expression (without change in meaning) so that the minus sign cannot be mistaken for subtraction: ( (UINT64)(- (MIN_INT64 + 1)) ) The resultant macro definition matches the following expressions in SafeInt64Mult(): > // > // Avoid negating the most negative number. > // > UnsignedMultiplicand = ((UINT64)(- (Multiplicand + 1))) + 1; and > // > // Avoid negating the most negative number. > // > UnsignedMultiplier = ((UINT64)(- (Multiplier + 1))) + 1; Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@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: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-02-21MdePkg/BaseSafeIntLib: fix undefined behavior in SafeInt64Add()Laszlo Ersek1-10/+46
The addition in the assignment SignedResult = Augend + Addend; is performed with unchecked INT64 operands. According to ISO C, if the mathematical result of signed integer addition cannot be represented in the result type, the behavior is undefined. (Refer to ISO C99 6.5p5. 6.2.5p9 only exempts unsigned integers, and 6.3.1.3p3 does not apply because it treats the conversion of integers that have been successfully evaluated first.) Replace the after-the-fact result checking with checks on the operands, and only perform the addition if it is safe. Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@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: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-02-21MdePkg/BaseSafeIntLib: fix undefined behavior in SafeInt64Sub()Laszlo Ersek1-11/+39
The subtraction in the assignment SignedResult = Minuend - Subtrahend; is performed with unchecked INT64 operands. According to ISO C, if the mathematical result of signed integer subtraction cannot be represented in the result type, the behavior is undefined. (Refer to ISO C99 6.5p5. 6.2.5p9 only exempts unsigned integers, and 6.3.1.3p3 does not apply because it treats the conversion of integers that have been successfully evaluated first.) Replace the after-the-fact result checking with checks on the operands, and only perform the subtraction if it is safe. Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@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: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Michael D Kinney <michael.d.kinney@intel.com>
2018-02-11MdePkg/UefiLib: Add EfiLocateProtocolBuffer()Michael D Kinney2-2/+142
https://bugzilla.tianocore.org/show_bug.cgi?id=838 Add new API to the UefiLib that locates and returns an array of protocols instances that match a given protocol. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Liming Gao <liming.gao@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-09MdePkg/UefiRuntimeLib: Support more module types.Ruiyu Ni1-2/+2
Because DxeResetSystemLib links to this library to provide reset system services, change UefiRuntimeLib to support the same set of module types as what DxeResetSystemLib does. 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-09MdePkg/PeiServicesLib: Add PeiServicesResetSystem2()Michael D Kinney2-0/+50
Add the PeiServicesResetSytstem2() function to the PeiServiesLib to call the ResetSystem2() services in the PEI Services Table. Cc: Liming Gao <liming.gao@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> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-02-09MdePkg/Include: Add management mode FV file type and depex.Supreeth Venkatesh1-4/+10
As per PI specification v1.6, As per section 2.1.4.1, The following file types exist: Table 3. Defined File Types Name Value EFI_FV_FILETYPE_RAW 0x01 EFI_FV_FILETYPE_FREEFORM 0x02 EFI_FV_FILETYPE_SECURITY_CORE 0x03 EFI_FV_FILETYPE_PEI_CORE 0x04 EFI_FV_FILETYPE_DXE_CORE 0x05 EFI_FV_FILETYPE_PEIM 0x06 EFI_FV_FILETYPE_DRIVER 0x07 EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08 EFI_FV_FILETYPE_APPLICATION 0x09 EFI_FV_FILETYPE_MM 0x0A EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B EFI_FV_FILETYPE_COMBINED_MM_DXE 0x0C EFI_FV_FILETYPE_MM_CORE 0x0D EFI_FV_FILETYPE_MM_STANDALONE 0x0E EFI_FV_FILETYPE_MM_CORE_STANDALONE 0x0F The following new section type is added: EFI_SECTION_MM_DEPEX This patch adds the management mode FV file type and depex. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Achin Gupta <achin.gupta@arm.com> Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-07MdePkg/Include: Add VA list support for VS2017/ARMPete Batard1-0/+13
VA_START, VA_END and VA_COPY are the same as the generic macros. VA_ARG was reverse engineered from MS ARM assembly output. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-07MdePkg/Library/BaseLib: Enable VS2017/ARM buildsPete Batard2-4/+17
Most of the RVCT assembly can be reused as is for MSFT except for CpuBreakpoint.asm, which we need to force to Arm mode. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-07MdePkg/Library/BaseStackCheckLib: Add Null handler for VS2017/ARMPete Batard2-2/+21
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-07MdePkg: Disable some Level 4 warnings for VS2017/ARMLiming Gao1-21/+75
We disable the exact same warnings as IA32 and X64. Also create a dummy macro for PRESERVE8, as this is not supported by the Microsoft ARM assembler. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-07MdePkg ACPI: Add some macros for PPTTHeyi Guo1-0/+18
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ming Huang <huangming23@huawei.com> Signed-off-by: Heyi Guo <heyi.guo@linaro.org> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-02-06MdePkg/SafeString: Fix potential out-of-bound memory accessRuiyu Ni1-9/+9
Today's implementation of [Ascii]StrnCpyS/[Ascii]StrnCatS calls StrnLenS () to get the length of source string but supplies the destination buffer size as max size. It's a bug that may cause out-of-bound memory access. For example: StrnCpyS (Dest[10], 10, "hello", 6) -> StrnLenS ("hello", 10) //< cause out-of bound memory access In a pool guard enabled environment, when using shell to edit an existing file which contains empty line, the page fault is met. The patch fixes the four library functions to avoid such out-of-bound memory access. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com>
2018-02-01MdePkg/SimpleTextInEx.h: Fix comments alignmentRuiyu Ni1-8/+5
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>