VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/XenPlatformPei/AmdSev.c@ 85716

Last change on this file since 85716 was 80721, checked in by vboxsync, 5 years ago

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1/**@file
2 Initialize Secure Encrypted Virtualization (SEV) support
3
4 Copyright (c) 2017, Advanced Micro Devices. All rights reserved.<BR>
5 Copyright (c) 2019, Citrix Systems, Inc.
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9**/
10//
11// The package level header files this module uses
12//
13#include <Library/DebugLib.h>
14#include <Library/MemEncryptSevLib.h>
15#include <Library/PcdLib.h>
16#include <PiPei.h>
17#include <Register/Amd/Cpuid.h>
18#include <Register/Cpuid.h>
19
20#include "Platform.h"
21
22/**
23
24 Function checks if SEV support is available, if present then it sets
25 the dynamic PcdPteMemoryEncryptionAddressOrMask with memory encryption mask.
26
27 **/
28VOID
29AmdSevInitialize (
30 VOID
31 )
32{
33 CPUID_MEMORY_ENCRYPTION_INFO_EBX Ebx;
34 UINT64 EncryptionMask;
35 RETURN_STATUS PcdStatus;
36
37 //
38 // Check if SEV is enabled
39 //
40 if (!MemEncryptSevIsEnabled ()) {
41 return;
42 }
43
44 //
45 // CPUID Fn8000_001F[EBX] Bit 0:5 (memory encryption bit position)
46 //
47 AsmCpuid (CPUID_MEMORY_ENCRYPTION_INFO, NULL, &Ebx.Uint32, NULL, NULL);
48 EncryptionMask = LShiftU64 (1, Ebx.Bits.PtePosBits);
49
50 //
51 // Set Memory Encryption Mask PCD
52 //
53 PcdStatus = PcdSet64S (PcdPteMemoryEncryptionAddressOrMask, EncryptionMask);
54 ASSERT_RETURN_ERROR (PcdStatus);
55
56 DEBUG ((DEBUG_INFO, "SEV is enabled (mask 0x%lx)\n", EncryptionMask));
57
58 //
59 // Set Pcd to Deny the execution of option ROM when security
60 // violation.
61 //
62 PcdStatus = PcdSet32S (PcdOptionRomImageVerificationPolicy, 0x4);
63 ASSERT_RETURN_ERROR (PcdStatus);
64}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette