@samitouri / QOSamiQemu / commits / e2a11aea4e

whpx: i386: add implementation of new x86_emul_ops

target/i386/emulate now has new ops for fetching whether the guest is in protected mode, long mode or user mode without fetching control registers. Use those for faster vmexits. Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260324151323.74473-8-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Mohamed Mediouni committed Mar 24, 2026 at 16:13 UTC e2a11aea4e6e4046f1686acaa07c16ef903989c9
1 file changed +23 -1
target/i386/whpx/whpx-all.c
+23 -1
@@ -885,10 +885,32 @@ static void read_segment_descriptor(CPUState *cpu,
885 }
886 }
887
888 +static bool is_protected_mode(CPUState *cpu)
889 +{
890 + AccelCPUState *vcpu = cpu->accel;
891 +
892 + return vcpu->exit_ctx.VpContext.ExecutionState.Cr0Pe == 1;
893 +}
894 +
895 +static bool is_long_mode(CPUState *cpu)
896 +{
897 + AccelCPUState *vcpu = cpu->accel;
898 +
899 + return vcpu->exit_ctx.VpContext.ExecutionState.EferLma == 1;
900 +}
901 +
902 +static bool is_user_mode(CPUState *cpu)
903 +{
904 + AccelCPUState *vcpu = cpu->accel;
905 + return vcpu->exit_ctx.VpContext.ExecutionState.Cpl == 3;
906 +}
907
908 static const struct x86_emul_ops whpx_x86_emul_ops = {
909 .read_segment_descriptor = read_segment_descriptor,
891 - .handle_io = handle_io
910 + .handle_io = handle_io,
911 + .is_protected_mode = is_protected_mode,
912 + .is_long_mode = is_long_mode,
913 + .is_user_mode = is_user_mode
914 };
915
916 static void whpx_init_emu(void)