]>
Commit | Line | Data |
---|---|---|
e4a1d5a7 BS |
1 | /** @file\r |
2 | Define the module hooks used while probing the QEMU flash device.\r | |
3 | \r | |
4 | Copyright (C) 2018, Advanced Micro Devices. All rights reserved.\r | |
5 | \r | |
b26f0cf9 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
e4a1d5a7 BS |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include <Library/BaseMemoryLib.h>\r | |
11 | #include <Library/DebugLib.h>\r | |
12 | #include <Library/PcdLib.h>\r | |
13 | #include <Library/MemEncryptSevLib.h>\r | |
14 | \r | |
15 | #include "QemuFlash.h"\r | |
16 | \r | |
17 | VOID\r | |
18 | QemuFlashBeforeProbe (\r | |
19 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
20 | IN UINTN FdBlockSize,\r | |
21 | IN UINTN FdBlockCount\r | |
22 | )\r | |
23 | {\r | |
24 | EFI_STATUS Status;\r | |
25 | \r | |
26 | ASSERT (FeaturePcdGet (PcdSmmSmramRequire));\r | |
27 | \r | |
28 | if (!MemEncryptSevIsEnabled ()) {\r | |
29 | return;\r | |
30 | }\r | |
31 | \r | |
32 | //\r | |
33 | // When SEV is enabled, AmdSevDxe runs early in DXE phase and clears the\r | |
34 | // C-bit from the NonExistent entry -- which is later split and accommodate\r | |
35 | // the flash MMIO but the driver runs in non SMM context hence it cleared the\r | |
36 | // flash ranges from non SMM page table. When SMM is enabled, the flash\r | |
37 | // services are accessed from the SMM mode hence we explicitly clear the\r | |
38 | // C-bit on flash ranges from SMM page table.\r | |
39 | //\r | |
40 | \r | |
41 | Status = MemEncryptSevClearPageEncMask (\r | |
42 | 0,\r | |
43 | BaseAddress,\r | |
44 | EFI_SIZE_TO_PAGES (FdBlockSize * FdBlockCount),\r | |
45 | FALSE\r | |
46 | );\r | |
47 | ASSERT_EFI_ERROR (Status);\r | |
48 | }\r |