]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/BaseLib.h
MdePkg/BaseLib: add support for PVALIDATE instruction
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
index 7253997a6f8c36fd69c73dd9fa5f9808495c7e36..a2cd134bea9a865b8cfe206cff42ec786b6983b0 100644 (file)
@@ -4813,6 +4813,56 @@ SpeculationBarrier (
   VOID\r
   );\r
 \r
+#if defined (MDE_CPU_X64)\r
+//\r
+// The page size for the PVALIDATE instruction\r
+//\r
+typedef enum {\r
+  PvalidatePageSize4K = 0,\r
+  PvalidatePageSize2MB,\r
+} PVALIDATE_PAGE_SIZE;\r
+\r
+//\r
+// PVALIDATE Return Code.\r
+//\r
+#define PVALIDATE_RET_SUCCESS         0\r
+#define PVALIDATE_RET_FAIL_INPUT      1\r
+#define PVALIDATE_RET_SIZE_MISMATCH   6\r
+\r
+//\r
+// The PVALIDATE instruction did not make any changes to the RMP entry.\r
+//\r
+#define PVALIDATE_RET_NO_RMPUPDATE    255\r
+\r
+/**\r
+ Execute a PVALIDATE instruction to validate or to rescinds validation of a guest\r
+ page's RMP entry.\r
+\r
+ The instruction is available only when CPUID Fn8000_001F_EAX[SNP]=1.\r
+\r
+ The function is available on X64.\r
+\r
+ @param[in]    PageSize         The page size to use.\r
+ @param[in]    Validate         If TRUE, validate the guest virtual address\r
+                                otherwise invalidate the guest virtual address.\r
+ @param[in]    Address          The guest virtual address.\r
+\r
+ @retval PVALIDATE_RET_SUCCESS        The PVALIDATE instruction succeeded, and\r
+                                      updated the RMP entry.\r
+ @retval PVALIDATE_RET_NO_RMPUPDATE   The PVALIDATE instruction succeeded, but\r
+                                      did not update the RMP entry.\r
+ @return                              Failure code from the PVALIDATE\r
+                                      instruction.\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmPvalidate (\r
+  IN   PVALIDATE_PAGE_SIZE     PageSize,\r
+  IN   BOOLEAN                 Validate,\r
+  IN   PHYSICAL_ADDRESS        Address\r
+  );\r
+#endif\r
+\r
 \r
 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
 ///\r