Last change
on this file since 105381 was 99404, checked in by vboxsync, 20 months ago |
Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643
|
-
Property svn:eol-style
set to
native
|
File size:
1.5 KB
|
Line | |
---|
1 | /** @file
|
---|
2 | Define the module hooks used while probing the QEMU flash device.
|
---|
3 |
|
---|
4 | Copyright (C) 2018, Advanced Micro Devices. All rights reserved.
|
---|
5 |
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #include <Library/BaseMemoryLib.h>
|
---|
11 | #include <Library/DebugLib.h>
|
---|
12 | #include <Library/PcdLib.h>
|
---|
13 | #include <Library/MemEncryptSevLib.h>
|
---|
14 |
|
---|
15 | #include "QemuFlash.h"
|
---|
16 |
|
---|
17 | VOID
|
---|
18 | QemuFlashBeforeProbe (
|
---|
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 |
|
---|
41 | Status = MemEncryptSevClearMmioPageEncMask (
|
---|
42 | 0,
|
---|
43 | BaseAddress,
|
---|
44 | EFI_SIZE_TO_PAGES (FdBlockSize * FdBlockCount)
|
---|
45 | );
|
---|
46 | ASSERT_EFI_ERROR (Status);
|
---|
47 | }
|
---|
48 |
|
---|
49 | /**
|
---|
50 | Write to QEMU Flash
|
---|
51 |
|
---|
52 | @param[in] Ptr Pointer to the location to write.
|
---|
53 | @param[in] Value The value to write.
|
---|
54 |
|
---|
55 | **/
|
---|
56 | VOID
|
---|
57 | QemuFlashPtrWrite (
|
---|
58 | IN volatile UINT8 *Ptr,
|
---|
59 | IN UINT8 Value
|
---|
60 | )
|
---|
61 | {
|
---|
62 | *Ptr = Value;
|
---|
63 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.