IntelFrameworkModulePkg/Csm: Add code to bypass NULL pointer detection
Legacy has to access interrupt vector, BDA, etc. located in memory between 0-4095. To allow as much code as possible to be monitored by NULL pointer detection, we add code to temporarily disable this feature right before those memory access and enable it again afterwards. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Ayellet Wolman <ayellet.wolman@intel.com> Suggested-by: Ayellet Wolman <ayellet.wolman@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> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
@@ -57,7 +57,11 @@ LegacyBiosInt86 (
|
||||
IN EFI_IA32_REGISTER_SET *Regs
|
||||
)
|
||||
{
|
||||
UINT32 *VectorBase;
|
||||
UINT16 Segment;
|
||||
UINT16 Offset;
|
||||
LEGACY_BIOS_INSTANCE *Private;
|
||||
|
||||
Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);
|
||||
|
||||
Regs->X.Flags.Reserved1 = 1;
|
||||
Regs->X.Flags.Reserved2 = 0;
|
||||
@@ -72,12 +76,15 @@ LegacyBiosInt86 (
|
||||
// The base address of legacy interrupt vector table is 0.
|
||||
// We use this base address to get the legacy interrupt handler.
|
||||
//
|
||||
VectorBase = 0;
|
||||
DisableNullDetection ();
|
||||
Segment = (UINT16)(((UINT32 *)0)[BiosInt] >> 16);
|
||||
Offset = (UINT16)((UINT32 *)0)[BiosInt];
|
||||
EnableNullDetection ();
|
||||
|
||||
return InternalLegacyBiosFarCall (
|
||||
This,
|
||||
(UINT16) ((VectorBase)[BiosInt] >> 16),
|
||||
(UINT16) (VectorBase)[BiosInt],
|
||||
Segment,
|
||||
Offset,
|
||||
Regs,
|
||||
&Regs->X.Flags,
|
||||
sizeof (Regs->X.Flags)
|
||||
@@ -293,9 +300,15 @@ InternalLegacyBiosFarCall (
|
||||
UINTN EbdaBaseAddress;
|
||||
UINTN ReservedEbdaBaseAddress;
|
||||
|
||||
EbdaBaseAddress = (*(UINT16 *) (UINTN) 0x40E) << 4;
|
||||
ReservedEbdaBaseAddress = CONVENTIONAL_MEMORY_TOP - PcdGet32 (PcdEbdaReservedMemorySize);
|
||||
ASSERT (ReservedEbdaBaseAddress <= EbdaBaseAddress);
|
||||
//
|
||||
// Skip this part of debug code if NULL pointer detection is enabled
|
||||
//
|
||||
if ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT0) == 0) {
|
||||
EbdaBaseAddress = (*(UINT16 *) (UINTN) 0x40E) << 4;
|
||||
ReservedEbdaBaseAddress = CONVENTIONAL_MEMORY_TOP
|
||||
- PcdGet32 (PcdEbdaReservedMemorySize);
|
||||
ASSERT (ReservedEbdaBaseAddress <= EbdaBaseAddress);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user