TianoCore EDK2 master
Loading...
Searching...
No Matches
QemuFlashSmm.c
Go to the documentation of this file.
1
11#include <Library/DebugLib.h>
12#include <Library/PcdLib.h>
14
15#include "QemuFlash.h"
16
17VOID
18QemuFlashBeforeProbe (
19 IN EFI_PHYSICAL_ADDRESS BaseAddress,
20 IN UINTN FdBlockSize,
21 IN UINTN FdBlockCount
22 )
23{
24 EFI_STATUS Status;
25
26 ASSERT (FeaturePcdGet (PcdSmmSmramRequire));
27
28 if (!MemEncryptSevIsEnabled ()) {
29 return;
30 }
31
32 //
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.
39 //
40
42 0,
43 BaseAddress,
44 EFI_SIZE_TO_PAGES (FdBlockSize * FdBlockCount)
45 );
46 ASSERT_EFI_ERROR (Status);
47}
48
56VOID
58 IN volatile UINT8 *Ptr,
59 IN UINT8 Value
60 )
61{
62 *Ptr = Value;
63}
UINT64 UINTN
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
BOOLEAN EFIAPI MemEncryptSevIsEnabled(VOID)
RETURN_STATUS EFIAPI MemEncryptSevClearMmioPageEncMask(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
VOID QemuFlashPtrWrite(IN volatile UINT8 *Ptr, IN UINT8 Value)
Definition: QemuFlashSmm.c:57
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SIZE_TO_PAGES(Size)
Definition: UefiBaseType.h:200