2 Define the module hooks used while probing the QEMU flash device.
4 Copyright (C) 2018, Advanced Micro Devices. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/BaseMemoryLib.h>
11 #include <Library/DebugLib.h>
12 #include <Library/PcdLib.h>
13 #include <Library/MemEncryptSevLib.h>
15 #include "QemuFlash.h"
18 QemuFlashBeforeProbe (
19 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
26 ASSERT (FeaturePcdGet (PcdSmmSmramRequire
));
28 if (!MemEncryptSevIsEnabled ()) {
33 // When SEV is enabled, AmdSevDxe runs early in DXE phase and clears the
34 // C-bit from the NonExistent entry -- which is later split and accommodate
35 // the flash MMIO but the driver runs in non SMM context hence it cleared the
36 // flash ranges from non SMM page table. When SMM is enabled, the flash
37 // services are accessed from the SMM mode hence we explicitly clear the
38 // C-bit on flash ranges from SMM page table.
41 Status
= MemEncryptSevClearPageEncMask (
44 EFI_SIZE_TO_PAGES (FdBlockSize
* FdBlockCount
),
47 ASSERT_EFI_ERROR (Status
);