On 5/20/25 13:30, Magnus Kulke wrote:
Write CPU register state to MSHV vCPUs. Various mapping functions to
prepare the payload for the HV call have been implemented.
Signed-off-by: Magnus Kulke <magnusku...@linux.microsoft.com>
---
include/system/mshv.h | 41 ++++++
target/i386/mshv/mshv-cpu.c | 249 ++++++++++++++++++++++++++++++++++++
2 files changed, 290 insertions(+)
diff --git a/include/system/mshv.h b/include/system/mshv.h
index 055489a6f3..76a3b0010e 100644
--- a/include/system/mshv.h
+++ b/include/system/mshv.h
@@ -99,6 +99,46 @@ typedef struct MshvMsiControl {
#define EFER_LMA ((uint64_t)0x400)
#define EFER_LME ((uint64_t)0x100)
+/* CR0 bits */
+#define CR0_PE ((uint64_t)0x1)
+#define CR0_PG ((uint64_t)0x80000000)
+
+/* CR4 bits */
+#define CR4_PAE ((uint64_t)0x20)
+#define CR4_LA57 ((uint64_t)0x1000)
+
+/* rflags bits (shift values) */
+#define CF_SHIFT 0
+#define PF_SHIFT 2
+#define AF_SHIFT 4
+#define ZF_SHIFT 6
+#define SF_SHIFT 7
+#define DF_SHIFT 10
+#define OF_SHIFT 11
+
+/* rflags bits (bit masks) */
+#define CF ((uint64_t)1 << CF_SHIFT)
+#define PF ((uint64_t)1 << PF_SHIFT)
+#define AF ((uint64_t)1 << AF_SHIFT)
+#define ZF ((uint64_t)1 << ZF_SHIFT)
+#define SF ((uint64_t)1 << SF_SHIFT)
+#define DF ((uint64_t)1 << DF_SHIFT)
+#define OF ((uint64_t)1 << OF_SHIFT)
All of these are either duplicate or unused.
Paolo