VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/PlatformPei/AmdSev.c@ 77662

Last change on this file since 77662 was 77662, checked in by vboxsync, 6 years ago

EFI: First step in UDK2018 merge. Does not build yet.

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

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