]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c
5c337ea0b820f0ea21d372b825e3fa8b22dcc67e
[mirror_edk2.git] / OvmfPkg / Library / BaseMemEncryptSevLib / X64 / SecVirtualMemory.c
1 /** @file
2
3 Virtual Memory Management Services to set or clear the memory encryption bit
4
5 Copyright (c) 2020, AMD Incorporated. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #include <Library/CpuLib.h>
12 #include <Library/MemEncryptSevLib.h>
13
14 #include "VirtualMemory.h"
15
16 /**
17 This function clears memory encryption bit for the memory region specified by
18 PhysicalAddress and Length from the current page table context.
19
20 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
21 current CR3)
22 @param[in] PhysicalAddress The physical address that is the start
23 address of a memory region.
24 @param[in] Length The length of memory region
25 @param[in] Flush Flush the caches before applying the
26 encryption mask
27
28 @retval RETURN_SUCCESS The attributes were cleared for the
29 memory region.
30 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
31 @retval RETURN_UNSUPPORTED Clearing the memory encyrption attribute
32 is not supported
33 **/
34 RETURN_STATUS
35 EFIAPI
36 InternalMemEncryptSevSetMemoryDecrypted (
37 IN PHYSICAL_ADDRESS Cr3BaseAddress,
38 IN PHYSICAL_ADDRESS PhysicalAddress,
39 IN UINTN Length,
40 IN BOOLEAN Flush
41 )
42 {
43 //
44 // This function is not available during SEC.
45 //
46 return RETURN_UNSUPPORTED;
47 }
48
49 /**
50 This function sets memory encryption bit for the memory region specified by
51 PhysicalAddress and Length from the current page table context.
52
53 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
54 current CR3)
55 @param[in] PhysicalAddress The physical address that is the start
56 address of a memory region.
57 @param[in] Length The length of memory region
58 @param[in] Flush Flush the caches before applying the
59 encryption mask
60
61 @retval RETURN_SUCCESS The attributes were set for the memory
62 region.
63 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
64 @retval RETURN_UNSUPPORTED Setting the memory encyrption attribute
65 is not supported
66 **/
67 RETURN_STATUS
68 EFIAPI
69 InternalMemEncryptSevSetMemoryEncrypted (
70 IN PHYSICAL_ADDRESS Cr3BaseAddress,
71 IN PHYSICAL_ADDRESS PhysicalAddress,
72 IN UINTN Length,
73 IN BOOLEAN Flush
74 )
75 {
76 //
77 // This function is not available during SEC.
78 //
79 return RETURN_UNSUPPORTED;
80 }