mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
DynamicTablesPkg: Check Rd Address Space field combination
Some combination of fields of Rd Address Space descriptors are not valid. Check them when updating a Rd Address Space descriptor. Cf. ACPI 6.4 Table 6.44: "Valid Combination of Address Space Descriptor Fields" Also check that the input length is not 0 to avoid potential integer underflow. Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This commit is contained in:
parent
10aef94c8b
commit
d3a7acfff9
1 changed files with 22 additions and 1 deletions
|
|
@ -20,6 +20,12 @@
|
|||
#include <AmlInclude.h>
|
||||
#include <Api/AmlApiHelper.h>
|
||||
#include <CodeGen/AmlResourceDataCodeGen.h>
|
||||
#include <Utils/AmlUtility.h>
|
||||
|
||||
/* Macros to read General flags of a Resource Data Address Descriptors */
|
||||
#define IS_RD_ADDR_POS_DECODE(GenFlag) (((GenFlag) & BIT1) == 0)
|
||||
#define IS_RD_ADDR_MIN_FIXED(GenFlag) (((GenFlag) & BIT2) == BIT2)
|
||||
#define IS_RD_ADDR_MAX_FIXED(GenFlag) (((GenFlag) & BIT3) == BIT3)
|
||||
|
||||
/** Update the first interrupt of an Interrupt resource data node.
|
||||
|
||||
|
|
@ -271,7 +277,8 @@ AmlUpdateRdQWord (
|
|||
AML_RD_BUILD_LARGE_DESC_ID (
|
||||
ACPI_LARGE_QWORD_ADDRESS_SPACE_DESCRIPTOR_NAME
|
||||
)
|
||||
)))
|
||||
)) ||
|
||||
(BaseAddressLength == 0))
|
||||
{
|
||||
ASSERT (0);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
|
@ -313,6 +320,20 @@ AmlUpdateRdQWord (
|
|||
RdQWord->AddrRangeMax = BaseAddress + BaseAddressLength - 1;
|
||||
RdQWord->AddrLen = BaseAddressLength;
|
||||
|
||||
Status = CheckAddressSpaceFields (
|
||||
IS_RD_ADDR_MIN_FIXED (RdQWord->GenFlag),
|
||||
IS_RD_ADDR_MAX_FIXED (RdQWord->GenFlag),
|
||||
RdQWord->AddrSpaceGranularity,
|
||||
RdQWord->AddrRangeMin,
|
||||
RdQWord->AddrRangeMax,
|
||||
RdQWord->AddrTranslationOffset,
|
||||
RdQWord->AddrLen
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ASSERT (0);
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
// Update Base Address Resource Data node.
|
||||
Status = AmlUpdateDataNode (
|
||||
QWordRdNode,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue