whpx: i386: indirect access to CRs
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260324151323.74473-10-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Mohamed Mediouni committed
Mar 24, 2026 at 16:13 UTC
016dd86d896733d83485baef953c8b600b383b60
1 file changed
+31
-1
target/i386/whpx/whpx-all.c
+31
-1
@@ -905,12 +905,42 @@ static bool is_user_mode(CPUState *cpu)
905
return vcpu->exit_ctx.VpContext.ExecutionState.Cpl == 3;
906
}
907
908
+static target_ulong read_cr(CPUState *cpu, int cr)
909
+{
910
+ WHV_REGISTER_NAME whv_cr;
911
+ WHV_REGISTER_VALUE val;
912
+
913
+ switch (cr) {
914
+ case 0:
915
+ whv_cr = WHvX64RegisterCr0;
916
+ break;
917
+ case 2:
918
+ whv_cr = WHvX64RegisterCr2;
919
+ break;
920
+ case 3:
921
+ whv_cr = WHvX64RegisterCr3;
922
+ break;
923
+ case 4:
924
+ whv_cr = WHvX64RegisterCr4;
925
+ break;
926
+ case 8:
927
+ whv_cr = WHvX64RegisterCr8;
928
+ break;
929
+ default:
930
+ abort();
931
+ }
932
+ whpx_get_reg(cpu, whv_cr, &val);
933
+
934
+ return val.Reg64;
935
+}
936
+
937
static const struct x86_emul_ops whpx_x86_emul_ops = {
938
.read_segment_descriptor = read_segment_descriptor,
939
.handle_io = handle_io,
940
.is_protected_mode = is_protected_mode,
941
.is_long_mode = is_long_mode,
913
- .is_user_mode = is_user_mode
942
+ .is_user_mode = is_user_mode,
943
+ .read_cr = read_cr
944
};
945
946
static void whpx_init_emu(void)