]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Include/Library/MemEncryptSevLib.h
b6753762423e4dd0ccd86b074d29fe58a9ea042d
[mirror_edk2.git] / OvmfPkg / Include / Library / MemEncryptSevLib.h
1 /** @file
2
3 Define Secure Encrypted Virtualization (SEV) base library helper function
4
5 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
6
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef _MEM_ENCRYPT_SEV_LIB_H_
18 #define _MEM_ENCRYPT_SEV_LIB_H_
19
20 #include <Base.h>
21
22 /**
23 Returns a boolean to indicate whether SEV is enabled
24
25 @retval TRUE SEV is active
26 @retval FALSE SEV is not enabled
27 **/
28 BOOLEAN
29 EFIAPI
30 MemEncryptSevIsEnabled (
31 VOID
32 );
33
34 /**
35 This function clears memory encryption bit for the memory region specified
36 by BaseAddress and Number of pages from the current page table context.
37
38 @param[in] BaseAddress The physical address that is the start address
39 of a memory region.
40 @param[in] NumberOfPages The number of pages from start memory region.
41 @param[in] Flush Flush the caches before clearing the bit
42 (mostly TRUE except MMIO addresses)
43
44 @retval RETURN_SUCCESS The attributes were cleared for the memory region.
45 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
46 @retval RETURN_UNSUPPORTED Clearing memory encryption attribute is not
47 supported
48 **/
49 RETURN_STATUS
50 EFIAPI
51 MemEncryptSevClearPageEncMask (
52 IN PHYSICAL_ADDRESS Cr3BaseAddress,
53 IN PHYSICAL_ADDRESS BaseAddress,
54 IN UINTN NumberOfPages,
55 IN BOOLEAN CacheFlush
56 );
57
58 /**
59 This function sets memory encryption bit for the memory region specified by
60 BaseAddress and Number of pages from the current page table context.
61
62 @param[in] BaseAddress The physical address that is the start address
63 of a memory region.
64 @param[in] NumberOfPages The number of pages from start memory region.
65 @param[in] Flush Flush the caches before clearing the bit
66 (mostly TRUE except MMIO addresses)
67
68 @retval RETURN_SUCCESS The attributes were set for the memory region.
69 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
70 @retval RETURN_UNSUPPORTED Clearing memory encryption attribute is not
71 supported
72 **/
73 RETURN_STATUS
74 EFIAPI
75 MemEncryptSevSetPageEncMask (
76 IN PHYSICAL_ADDRESS Cr3BaseAddress,
77 IN PHYSICAL_ADDRESS BaseAddress,
78 IN UINTN NumberOfPages,
79 IN BOOLEAN CacheFlush
80 );
81 #endif // _MEM_ENCRYPT_SEV_LIB_H_