summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* UefiCpuPkg/RegisterCpuFeaturesLib: Add logic to support semaphore type.Eric Dong2018-10-226-133/+939
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | V4 changes include: 1. Serial debug message for different threads when program the register table. V3 changes include: 1. Use global variable instead of internal function to return string for register type and dependence type. 2. Add comments for some complicated logic. V2 changes include: 1. Add more description for the code part which need easy to understand. 2. Refine some code base on feedback for V1 changes. V1 changes include: In a system which has multiple cores, current set register value task costs huge times. After investigation, current set MSR task costs most of the times. Current logic uses SpinLock to let set MSR task as an single thread task for all cores. Because MSR has scope attribute which may cause GP fault if multiple APs set MSR at the same time, current logic use an easiest solution (use SpinLock) to avoid this issue, but it will cost huge times. In order to fix this performance issue, new solution will set MSRs base on their scope attribute. After this, the SpinLock will not needed. Without SpinLock, new issue raised which is caused by MSR dependence. For example, MSR A depends on MSR B which means MSR A must been set after MSR B has been set. Also MSR B is package scope level and MSR A is thread scope level. If system has multiple threads, Thread 1 needs to set the thread level MSRs and thread 2 needs to set thread and package level MSRs. Set MSRs task for thread 1 and thread 2 like below: Thread 1 Thread 2 MSR B N Y MSR A Y Y If driver don't control execute MSR order, for thread 1, it will execute MSR A first, but at this time, MSR B not been executed yet by thread 2. system may trig exception at this time. In order to fix the above issue, driver introduces semaphore logic to control the MSR execute sequence. For the above case, a semaphore will be add between MSR A and B for all threads. Semaphore has scope info for it. The possible scope value is core or package. For each thread, when it meets a semaphore during it set registers, it will 1) release semaphore (+1) for each threads in this core or package(based on the scope info for this semaphore) 2) acquire semaphore (-1) for all the threads in this core or package(based on the scope info for this semaphore). With these two steps, driver can control MSR sequence. Sample code logic like below: // // First increase semaphore count by 1 for processors in this package. // for (ProcessorIndex = 0; ProcessorIndex < PackageThreadsCount ; ProcessorIndex ++) { LibReleaseSemaphore ((UINT32 *) &SemaphorePtr[PackageOffset + ProcessorIndex]); } // // Second, check whether the count has reach the check number. // for (ProcessorIndex = 0; ProcessorIndex < ValidApCount; ProcessorIndex ++) { LibWaitForSemaphore (&SemaphorePtr[ApOffset]); } Platform Requirement: 1. This change requires register MSR setting base on MSR scope info. If still register MSR for all threads, exception may raised. Known limitation: 1. Current CpuFeatures driver supports DXE instance and PEI instance. But semaphore logic requires Aps execute in async mode which is not supported by PEI driver. So CpuFeature PEI instance not works after this change. We plan to support async mode for PEI in phase 2 for this task. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* UefiCpuPkg/RegisterCpuFeaturesLib.h: Add new dependence types.Eric Dong2018-10-221-4/+17
| | | | | | | | | | | | | | | | | | V4 changes: 1. Update comments. v3 changes: 1. Move CPU_FEATURE_DEPENDENCE_TYPE definition to AcpiCpuData.h. 2. Add comments for CPU_FEATURE_BEFORE/CPU_FEATURE_AFTER. v1 changes: Add new core/package dependence types which consumed by different MSRs. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* UefiCpuPkg/Include/AcpiCpuData.h: Add Semaphore related Information.Eric Dong2018-10-221-1/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | v3 changes: 1. Move CPU_FEATURE_DEPENDENCE_TYPE definition here from RegisterCpuFeaturesLib.h file. 2. Add Invalid type for REGISTER_TYPE which will be used in code. v2 changes: 1. Add more description about why we do this change. 2. Change structure field type from pointer to EFI_PHYSICAL_ADDRESS because it will be share between PEI and DXE. v1 Changes: In order to support semaphore related logic, add new definition for it. In a system which has multiple cores, current set register value task costs huge times. After investigation, current set MSR task costs most of the times. Current logic uses SpinLock to let set MSR task as an single thread task for all cores. Because MSR has scope attribute which may cause GP fault if multiple APs set MSR at the same time, current logic use an easiest solution (use SpinLock) to avoid this issue, but it will cost huge times. In order to fix this performance issue, new solution will set MSRs base on their scope attribute. After this, the SpinLock will not needed. Without SpinLock, new issue raised which is caused by MSR dependence. For example, MSR A depends on MSR B which means MSR A must been set after MSR B has been set. Also MSR B is package scope level and MSR A is thread scope level. If system has multiple threads, Thread 1 needs to set the thread level MSRs and thread 2 needs to set thread and package level MSRs. Set MSRs task for thread 1 and thread 2 like below: Thread 1 Thread 2 MSR B N Y MSR A Y Y If driver don't control execute MSR order, for thread 1, it will execute MSR A first, but at this time, MSR B not been executed yet by thread 2. system may trig exception at this time. In order to fix the above issue, driver introduces semaphore logic to control the MSR execute sequence. For the above case, a semaphore will be add between MSR A and B for all threads. Semaphore has scope info for it. The possible scope value is core or package. For each thread, when it meets a semaphore during it set registers, it will 1) release semaphore (+1) for each threads in this core or package(based on the scope info for this semaphore) 2) acquire semaphore (-1) for all the threads in this core or package(based on the scope info for this semaphore). With these two steps, driver can control MSR sequence. Sample code logic like below: // // First increase semaphore count by 1 for processors in this package. // for (ProcessorIndex = 0; ProcessorIndex < PackageThreadsCount ; ProcessorIndex ++) { LibReleaseSemaphore ((UINT32 *) &SemaphorePtr[PackageOffset + ProcessorIndex]); } // // Second, check whether the count has reach the check number. // for (ProcessorIndex = 0; ProcessorIndex < ValidApCount; ProcessorIndex ++) { LibWaitForSemaphore (&SemaphorePtr[ApOffset]); } Platform Requirement: 1. This change requires register MSR setting base on MSR scope info. If still register MSR for all threads, exception may raised. Known limitation: 1. Current CpuFeatures driver supports DXE instance and PEI instance. But semaphore logic requires Aps execute in async mode which is not supported by PEI driver. So CpuFeature PEI instance not works after this change. We plan to support async mode for PEI in phase 2 for this task. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
* NetworkPkg/IpSecDxe: Fix issue to parse SA Payload.Jiaxin Wu2018-10-221-21/+39
| | | | | | | | | | | | | | | | | | | | | | | Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1251 *v2: Correct the type of parameters in Ikev2ParseProposalData(), and refined the corresponding description. IpSecDxe failed to create the Child SA during parsing SA Payload, the issue was caused by the below commit: SHA-1: 1e0db7b11987d0ec93be7dfe26102a327860fdbd * MdeModulePkg/NetworkPkg: Checking for NULL pointer before use. In above commit, it changed the value of IsMatch in Ikev2ChildSaParseSaPayload() to FALSE. That's correct but it exposed the potential bug in to match the correct proposal Data, which will cause the issue happen. Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Ye Ting <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com>
* NetworkPkg: Correct the time stamp and fix the integer overflow issue.Jiaxin Wu2018-10-222-17/+17
| | | | | | | | | | Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=883. Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Ye Ting <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com>
* NetworkPkg/TlsDxe: Remove the redundant library class.Jiaxin Wu2018-10-221-2/+1
| | | | | | | | | | | Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1018. Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Ye Ting <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com>
* BaseTools: Fix one crash bug in the report for Fixed structure PcdYonghong Zhu2018-10-211-10/+11
| | | | | | | | | | | | | | | | | | | | | | | The case is: in the DSC file: SKUID_IDENTIFIER = ALL [SkuIds] 0|DEFAULT 1|A [PcdsFixedAtBuild.common.A] TokenSpaceGuid.Test401|{0x0F, 0x12} TokenSpaceGuid.Test401.TEST401INT8ARRAY[0]|'B' in the build report, Data = OverrideValues[Keys[0]], but the Keys[0] is the keyword "DEFAULT", and in this case the "DEFAULT" SKU doesn't save any value, then it cause the Data is empty, in the next code when we use the code it cause crash. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* BaseTools: delete unused fileCarsey, Jaben2018-10-211-120/+0
| | | | | | | | | | this file is not imported/used. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Fix the crash issue when Dynamic structure Pcd use in FDFYonghong Zhu2018-10-211-4/+4
| | | | | | | | | | | | The case is use Dynamic structure Pcd in the FDF file. Current code already save the Guid, Name and Filed info for those Pcd, but it directly use the dict key as [Name, Guid] and cause this crash issue. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=1264 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* BaseTools: Fix the bug that PcdValueFromComm is not setYonghong Zhu2018-10-211-0/+1
| | | | | | | | | the bug is PcdValueFromComm is not set, but the Pcd have been override by the command line option. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* MdePkg UefiLib: Check Table against NULL in ScanTableInSDTStar Zeng2018-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1266 af5e95215928e052445c473f1244412dadea8252 abstracted generic functions from different modules (IntelVTdDxe, S3SaveStateDxe, PcRtc, DpDynamicCommand and PiSmmCpuDxeSmm). Some of them (IntelVTdDxe and PcRtc) checked Table against NULL before accessing Table->Signature, some (S3SaveStateDxe, DpDynamicCommand and PiSmmCpuDxeSmm did not. The ScanTableInSDT() in Acpi.c of UefiLib was mainly from S3SaveStateDxe, so it does not check Table against NULL before accessing Table->Signature. This patch updates ScanTableInSDT() to check Table against NULL first before accessing Table->Signature. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* IntelFsp2Pkg: Support FSP Dispatch modeChasel, Chiu2018-10-198-67/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1241 Add support for both API (original mode) and DISPATCH mode: 1. Add FspMode field from reserved byte of Global Data Structure to tell which mode is selected by boot loader. If boot loader invoking FSP-M API this field will remain as default 0 (API mode), otherwise platform FSP should set this field to 1 (Dispatch mode) when initializing Global Data Structure. 2. gFspInApiModePpiGuid will be instaled when FSP running in API mode and modules only for API mode should have this in depex. 3. If it is DISPATCH mode, FSP will return to PEI dispatcher, not directly return to boot loader. 4. DISPATCH mode supports DXE NotifyPhase drivers so FSP will not wait for PEI NotifyPhase callbacks, instead it will install gFspReadyForNotifyPhasePpiGuid PPI for platform to complete late initialization before transferring to DXE. Test: Verified FSP API and DISPATCH modes on 2 internal platforms and both boot successfully. Cc: Jiewen Yao <Jiewen.yao@intel.com> Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chasel Chiu <chasel.chiu@intel.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
* BaseTools: Remove the step to freeze python toolLiming Gao2018-10-197-397/+4
| | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=1257 Binary python tool is not supported anymore. So, the freeze python tool step is not required. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* MdeModulePkg BrotliDecompressLib: Add the checker to avoid array out of boundLiming Gao2018-10-191-5/+8
| | | | | | | | This change is to pass static analysis. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* UefiCpuPkg/CpuExceptionHandlerLib: always clear descriptor data in advanceJian J Wang2018-10-182-0/+6
| | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1237 Sometimes the memory will be contaminated by random data left in last boot (warm reset). The code should not assume the allocated memory is always filled with zero. This patch add code to clear data structure used for stack switch to prevent such problem from happening. Cc: Eric Dong <eric.dong@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* BaseTools: Fix bug caused by 03c36c36a3Yonghong Zhu2018-10-181-2/+2
| | | | | | | | | In the expression for unicode string and general string compare, it should check whether it startswith "L'" or 'L"', but not "L". Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Fix a bug --pcd option enable and use the pcd in expressionYonghong Zhu2018-10-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | the case is: in the DSC: [PcdsFixedAtBuild.common] TokenSpaceGuid.TestFixedPcd|0xFFEAA000 [PcdsDynamicExDefault.common.DEFAULT] !if TokenSpaceGuid.PcdFlag == TRUE TokenSpaceGuid.PcdTest|TokenSpaceGuid.TestFixedPcd !endif Then build with --pcd TokenSpaceGuid.PcdFlag=TRUE, it report failure, but if we build without this --pcd option, it could build success. we found when the --pcd is enabled, the fixedatbuild pcds are not be collected into expression to calculate. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=1256 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdeModulePkg/UdfDxe: Handle dead codes in FileSystemOperations.cHao Wu2018-10-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1249 We found potential dead codes within File.c during the code coverage test. After manual review, we think the below ones are positive reports: A. For function GetAllocationDescriptor(): Due to the all the calling places for this function, the input parameter 'RecordingFlags' can only with value 'LongAdsSequence' or 'ShortAdsSequence'. Moreover, this is also mentioned in the function description comments for GetAllocationDescriptor(). So the below code will never be reached: return EFI_DEVICE_ERROR; This commit will add "ASSERT (FALSE);" before the above line to indicate this and thus matching the function description comments. B. For function GetAllocationDescriptorLsn(): Due to the all the calling places for this function, the input parameter 'RecordingFlags' can only with value 'LongAdsSequence' or 'ShortAdsSequence'. Moreover, this is also mentioned in the function description comments for GetAllocationDescriptorLsn(). So the below code will never be reached: return EFI_UNSUPPORTED; This commit will add "ASSERT (FALSE);" before the above line to indicate this and thus matching the function description comments. Cc: Paulo Alcantara <palcantara@suse.de> Cc: Paulo Alcantara <paulo@paulo.ac> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UdfDxe: Handle dead codes in File.cHao Wu2018-10-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1249 We found potential dead codes within File.c during the code coverage test. After manual review, we think the below ones are positive reports: A. In function UdfRead(): else if (IS_FID_DELETED_FILE (Parent->FileIdentifierDesc)) { Status = EFI_DEVICE_ERROR; } A File Identifier Descriptor will be get from the UDF media only by function ReadDirectoryEntry(). And within this function, all the File Identifier Descriptor with 'DELETED_FILE' characteristics will be skipped and will not be returned. Hence, the above codes in function UdfRead() will never be hit. This commit will add "ASSERT (FALSE);" before the above line to indicate this. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UdfDxe: Use debug msg instead of ASSERT in UdfOpen()Hao Wu2018-10-181-1/+5
| | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1248 Within function UdfOpen(): This commit will use debug messages instead of using ASSERT when an error occurs after calling GetFileSize(). Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UdfDxe: Use error handling when fail to return LSNHao Wu2018-10-181-32/+69
| | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1248 This commit will refine the ASSERTs in function GetLongAdLsn() and GetAllocationDescriptorLsn() when the logical sector number cannot be returned due to unrecognized media format. Error handling logic will be used for those ASSERTs. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UdfDxe: ASSERT for false positives of NULL ptr derefHao Wu2018-10-182-0/+18
| | | | | | | | | | | | This commit adds ASSERTs to address false positive reports of NULL pointer dereference issues raised from static analysis with regard to function ReadDirectoryEntry(). Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UdfDxe: Use error handling for memory allocation failureHao Wu2018-10-181-6/+34
| | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1247 For functions DuplicateFid() and DuplicateFe(), this commit will use error handling logic instead of ASSERTs for memory allocation failure. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdePkg/BaseSynchronizationLib GCC: simplify IA32 InternalSyncCompareExchange64()Laszlo Ersek2018-10-171-4/+1
| | | | | | | | | | | | | | | | The IA32 variant of InternalSyncCompareExchange64() is correct, but we can simplify it. We don't need to load the lower 32 bits of ExchangeValue into EBX in two steps (first into a general register, then into EBX); we can ask GCC to populate EBX like that itself. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdePkg/BaseSynchronizationLib GCC: fix X64 InternalSyncCompareExchange64()Laszlo Ersek2018-10-171-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (This patch is identical to the X64 half of the last one, except for the InternalSyncCompareExchange32() -> InternalSyncCompareExchange64() and "cmpxchgl" -> "cmpxchgq" replacements.) The CMPXCHG instruction has the following operands: - AX (implicit, CompareValue): input and output - destination operand (*Value): input and output - source operand (ExchangeValue): input The X64 version of InternalSyncCompareExchange64() attempts to mark both CompareValue and (*Value) as input/output, but it doesn't use the appropriate constraints for either operand. Fix these issues. Furthermore, prefer the short "+" constraint for I/O operands over the <output-operand-number> constraint that can be applied to the input instances of I/O operands. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdePkg/BaseSynchronizationLib GCC: fix InternalSyncCompareExchange32()Laszlo Ersek2018-10-172-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (This patch is identical to the last one, except for the InternalSyncCompareExchange16() -> InternalSyncCompareExchange32() and "cmpxchgw" -> "cmpxchgl" replacements.) The CMPXCHG instruction has the following operands: - AX (implicit, CompareValue): input and output - destination operand (*Value): input and output - source operand (ExchangeValue): input The IA32 version of InternalSyncCompareExchange32() correctly marks CompareValue as input/output, but it marks (*Value) only as input. The X64 version of InternalSyncCompareExchange32() attempts to mark both CompareValue and (*Value) as input/output, but it doesn't use the appropriate constraints for either operand. Fix these issues. Furthermore, prefer the short "+" constraint for I/O operands over the <output-operand-number> constraint that can be applied to the input instances of I/O operands. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdePkg/BaseSynchronizationLib GCC: fix InternalSyncCompareExchange16()Laszlo Ersek2018-10-172-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | The CMPXCHG instruction has the following operands: - AX (implicit, CompareValue): input and output - destination operand (*Value): input and output - source operand (ExchangeValue): input The IA32 version of InternalSyncCompareExchange16() correctly marks CompareValue as input/output, but it marks (*Value) only as input. The X64 version of InternalSyncCompareExchange16() attempts to mark both CompareValue and (*Value) as input/output, but it doesn't use the appropriate constraints for either operand. Fix these issues. Furthermore, prefer the short "+" constraint for I/O operands over the <output-operand-number> constraint that can be applied to the input instances of I/O operands. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdePkg/BaseSynchronizationLib GCC: fix whitespace and commentsLaszlo Ersek2018-10-172-49/+39
| | | | | | | | | | | | | | | | The "GccInline.c" files have some inconsistent whitespace, and missing (or incorrect) operand comments. Fix and unify them. This patch doesn't change behavior. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdeModulePkg Variable: Fix Timestamp zeroing issue on APPEND_WRITEStar Zeng2018-10-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=415 When SetVariable() to a time based auth variable with APPEND_WRITE attribute, and if the EFI_VARIABLE_AUTHENTICATION_2.TimeStamp in the input Data is earlier than current value, it will cause timestamp zeroing. This issue may bring time based auth variable downgrade problem. For example: A vendor released three certs at 2014, 2015, and 2016, and system integrated the 2016 cert. User can SetVariable() with 2015 cert and APPEND_WRITE attribute to cause timestamp zeroing first, then SetVariable() with 2014 cert to downgrade the cert. This patch fixes this issue. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Chao Zhang <chao.b.zhang@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
* MdeModulePkg/UsbMass: Reject device whose block size is 0 or > 64KRuiyu Ni2018-10-171-0/+7
| | | | | | | Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/Bus/Ufs: Ensure device not return more data than expectedHao Wu2018-10-172-6/+43
| | | | | | | | | | | | This commit adds checks to make sure the UFS devices do not return more data than the driver expected. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UsbBus: Deny when the string descriptor length is oddRuiyu Ni2018-10-171-1/+7
| | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UsbMouse: Don't access key codes when length is wrongRuiyu Ni2018-10-171-2/+6
| | | | | | | | | | | | | | | | | Per USB HID spec, the buffer holding key codes should at least 3-byte long. Today's code assumes that the key codes buffer length is longer than 3-byte and unconditionally accesses the key codes buffer. It's incorrect. The patch fixes the issue by returning Device Error when the length is less than 3-byte. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Steven Shi <steven.shi@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/AbsPointer: Don't access key codes when length is wrongRuiyu Ni2018-10-171-2/+6
| | | | | | | | | | | | | | | | | Per USB HID spec, the buffer holding key codes should at least 3-byte long. Today's code assumes that the key codes buffer length is longer than 3-byte and unconditionally accesses the key codes buffer. It's incorrect. The patch fixes the issue by returning Device Error when the length is less than 3-byte. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Steven Shi <steven.shi@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UsbKb: Don't access key codes when length is wrongRuiyu Ni2018-10-171-0/+4
| | | | | | | | | | | | | | | | | Per USB HID spec, the buffer holding key codes should be 8-byte long. Today's code assumes that the key codes buffer length is 8-byte long and unconditionally accesses the key codes buffer. It's incorrect. The patch fixes the issue by returning Device Error when the length is less than 8-byte. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Steven Shi <steven.shi@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* SourceLevelDebugPkg/Usb3: Make sure data from HW can fit in bufferRuiyu Ni2018-10-171-0/+7
| | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/Usb: Make sure data from HW is no more than expectedRuiyu Ni2018-10-173-9/+16
| | | | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UsbBus: Reject descriptor whose length is badRuiyu Ni2018-10-171-0/+7
| | | | | | | | | | | | | Today's implementation doesn't check whether the length of descriptor is valid before using it. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UsbBus: Fix out-of-bound read access to descriptorsRuiyu Ni2018-10-171-12/+43
| | | | | | | | | | | | | | Today's implementation reads the Type/Length field in the USB descriptors data without checking whether the offset to read is beyond the data boundary. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UsbMass: Fix integer overflow when BlockSize is 1Ruiyu Ni2018-10-171-13/+14
| | | | | | | | | | | | | | | | | | | | UsbBootReadWriteBlocks() and UsbBootReadWriteBlocks16() use a UINT16 local variable to hold the value of USB_BOOT_MAX_CARRY_SIZE (=0x10000) / BlockSize. When BlockSize is 1, the UINT16 local variable is set to 0x10000 but the high-16 bits are truncated resulting the final value be 0. It causes the while-loop in the two functions accesses 0 block in each loop, resulting the loop never ends. The patch fixes the two functions to make sure no integer overflow happens. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Steven Shi <steven.shi@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/UsbMass: Merge UsbBoot(Read|Write)Blocks(16)Ruiyu Ni2018-10-173-252/+80
| | | | | | | | | The change doesn't have functionality impact. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* CorebootPayloadPkg: don't use serial output for Release buildWonkyu Kim2018-10-172-0/+8
| | | | | | | Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wonkyu Kim <wonkyu.kim@intel.com> Reviewed-by: Maurice Ma <maurice.ma@intel.com> Reviewed-by: Benjamin You <benjamin.you@intel.com>
* MdeModulePkg/RegularExpressionDxe: Add null pointer checkDongao Guo2018-10-161-0/+1
| | | | | | | | | This is the part of commit 3948c510edad901bb9f8d23f7bf0f4ae91b5fcde. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dongao Guo <dongao.guo@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools/EOT: Change to call a program instead of calling Python API.Hess Chen2018-10-165-443/+84
| | | | | | | | | Update the EOT tool to call the program itself instead of calling the Python API when parsing FV images. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> Acked-by: Jaben Carsey <jaben.carsey@intel.com>
* BaseTools: Support to use struct name as datum type before max sizeYonghong Zhu2018-10-162-4/+6
| | | | | | | | | Original it hard code to use "VOID*", this patch extend it to both support VOID* and valid struct name. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Fix bugs use special character in the --pcd optionYonghong Zhu2018-10-161-0/+2
| | | | | | | | | | | Cases: --pcd Token.Name="!" --pcd Token.Name="\'W&\'" --pcd Token.Name="2*h" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* BaseTools: Add check for the string type whether is samezhijufan2018-10-161-2/+4
| | | | | | | | | | | | | | | | | Relational and equality operators require both operands to be of the same type. Treat the string 'A' and "A" as same type, but for "A" and L"A" are not same type since one is general string, another is unicode string. True:'A'<'B', "A"<"B" 'A'<"B", L'A'<L'B', L"A"<L"B", L'A'<L"B" Error:'A'<L'B', 'A'<L"B", "A'<L'B' Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* BaseTools:Fix issue caused by 84a52d4d030185a44f2d8736142c6f0b19c6e9b1Zhaozh1x2018-10-161-0/+1
| | | | | | | | | | | | | | The commit 84a52d4d030185a44f2d8736142c6f0b19c6e9b1 will introduce the new issue "Invalid offset value for Dynamic Vpd PCD". This patch will fix the new issue, add 'DEFAULT' sku in to the AvailableSkuIdSet variable. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Bob Feng <bob.c.feng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Convert string value of void* pcd in command line to array.Zhaozh1x2018-10-161-8/+30
| | | | | | | | | | | | | | For void* type pcd in command line, if its value is string, then convert the string value to array format. For example, build --pcd gUefiOvmfPkgTokenSpaceGuid.PcdTest="c", convert the pcd value from "c" to "{0x63,0x00}". Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Bob Feng <bob.c.feng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Code should not update the variable that save the raw data.Zhaozh1x2018-10-161-2/+5
| | | | | | | | | | | | Code should not update the value of variable which save the original raw content of meta file. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Bob Feng <bob.c.feng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>