Commit 016dd86d89 for qemu.org
commit 016dd86d896733d83485baef953c8b600b383b60
Author: Mohamed Mediouni <mohamed@unpredictable.fr>
Date: Tue Mar 24 16:13:20 2026 +0100
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>
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index b97dc9fd51..71b33a632a 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -905,12 +905,42 @@ static bool is_user_mode(CPUState *cpu)
return vcpu->exit_ctx.VpContext.ExecutionState.Cpl == 3;
}
+static target_ulong read_cr(CPUState *cpu, int cr)
+{
+ WHV_REGISTER_NAME whv_cr;
+ WHV_REGISTER_VALUE val;
+
+ switch (cr) {
+ case 0:
+ whv_cr = WHvX64RegisterCr0;
+ break;
+ case 2:
+ whv_cr = WHvX64RegisterCr2;
+ break;
+ case 3:
+ whv_cr = WHvX64RegisterCr3;
+ break;
+ case 4:
+ whv_cr = WHvX64RegisterCr4;
+ break;
+ case 8:
+ whv_cr = WHvX64RegisterCr8;
+ break;
+ default:
+ abort();
+ }
+ whpx_get_reg(cpu, whv_cr, &val);
+
+ return val.Reg64;
+}
+
static const struct x86_emul_ops whpx_x86_emul_ops = {
.read_segment_descriptor = read_segment_descriptor,
.handle_io = handle_io,
.is_protected_mode = is_protected_mode,
.is_long_mode = is_long_mode,
- .is_user_mode = is_user_mode
+ .is_user_mode = is_user_mode,
+ .read_cr = read_cr
};
static void whpx_init_emu(void)