2 Define the module hooks used while probing the QEMU flash device.
4 Copyright (C) 2018, Advanced Micro Devices. All rights reserved.
6 This program and the accompanying materials are licensed and made available
7 under the terms and conditions of the BSD License which accompanies this
8 distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/MemEncryptSevLib.h>
21 #include "QemuFlash.h"
24 QemuFlashBeforeProbe (
25 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
32 ASSERT (FeaturePcdGet (PcdSmmSmramRequire
));
34 if (!MemEncryptSevIsEnabled ()) {
39 // When SEV is enabled, AmdSevDxe runs early in DXE phase and clears the
40 // C-bit from the NonExistent entry -- which is later split and accommodate
41 // the flash MMIO but the driver runs in non SMM context hence it cleared the
42 // flash ranges from non SMM page table. When SMM is enabled, the flash
43 // services are accessed from the SMM mode hence we explicitly clear the
44 // C-bit on flash ranges from SMM page table.
47 Status
= MemEncryptSevClearPageEncMask (
50 EFI_SIZE_TO_PAGES (FdBlockSize
* FdBlockCount
),
53 ASSERT_EFI_ERROR (Status
);