TianoCore EDK2 master
Loading...
Searching...
No Matches
QemuQ35.c
Go to the documentation of this file.
1
7#include <Library/BaseLib.h>
8#include <Library/DebugLib.h>
9#include <Library/HstiLib.h>
10#include <Library/PcdLib.h>
11#include <Library/PciLib.h>
12
15
16#include "VirtHstiDxe.h"
17
19 PLATFORM_SECURITY_VERSION_VNEXTCS,
20 PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE,
21 { L"OVMF (Qemu Q35)" },
22 VIRT_HSTI_SECURITY_FEATURE_SIZE,
23};
24
26VirtHstiQemuQ35Init (
27 VOID
28 )
29{
30 if (FeaturePcdGet (PcdSmmSmramRequire)) {
31 VirtHstiSetSupported (&mHstiQ35, 0, VIRT_HSTI_BYTE0_SMM_SMRAM_LOCK);
32 VirtHstiSetSupported (&mHstiQ35, 0, VIRT_HSTI_BYTE0_SMM_SECURE_VARS_FLASH);
33 }
34
35 return &mHstiQ35;
36}
37
38VOID
39VirtHstiQemuQ35Verify (
40 VOID
41 )
42{
43 if (VirtHstiIsSupported (&mHstiQ35, 0, VIRT_HSTI_BYTE0_SMM_SMRAM_LOCK)) {
44 CHAR16 *ErrorMsg = NULL;
45 UINT8 SmramVal;
46 UINT8 EsmramcVal;
47
48 SmramVal = PciRead8 (DRAMC_REGISTER_Q35 (MCH_SMRAM));
49 EsmramcVal = PciRead8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC));
50
51 if (!(EsmramcVal & MCH_ESMRAMC_T_EN)) {
52 ErrorMsg = L"q35 smram access is open";
53 } else if (!(SmramVal & MCH_SMRAM_D_LCK)) {
54 ErrorMsg = L"q35 smram config is not locked";
55 }
56
57 VirtHstiTestResult (ErrorMsg, 0, VIRT_HSTI_BYTE0_SMM_SMRAM_LOCK);
58 }
59
60 if (VirtHstiIsSupported (&mHstiQ35, 0, VIRT_HSTI_BYTE0_SMM_SECURE_VARS_FLASH)) {
61 CHAR16 *ErrorMsg = NULL;
62
63 switch (VirtHstiQemuFirmwareFlashCheck (PcdGet32 (PcdOvmfFlashNvStorageVariableBase))) {
64 case QEMU_FIRMWARE_FLASH_WRITABLE:
65 ErrorMsg = L"qemu vars pflash is not secure";
66 break;
67 }
68
69 VirtHstiTestResult (ErrorMsg, 0, VIRT_HSTI_BYTE0_SMM_SECURE_VARS_FLASH);
70 }
71}
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
UINT8 EFIAPI PciRead8(IN UINTN Address)
Definition: PciLib.c:62
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50