@samitouri / QOSamiQemu / commits / b5f7036a71

whpx: i386: inject exceptions

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260223233950.96076-26-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Mohamed Mediouni committed Feb 24, 2026 at 00:39 UTC b5f7036a71e6b109efeb4a9a709e6d3e25e6ba69
1 file changed +22
target/i386/whpx/whpx-all.c
+22
@@ -1506,6 +1506,26 @@ static void whpx_vcpu_process_async_events(CPUState *cpu)
1506 }
1507 }
1508
1509 +static void whpx_inject_exceptions(CPUState* cpu)
1510 +{
1511 + X86CPU *x86_cpu = X86_CPU(cpu);
1512 + CPUX86State *env = &x86_cpu->env;
1513 +
1514 + if (env->exception_injected) {
1515 + env->exception_injected = 0;
1516 + WHV_REGISTER_VALUE reg = {};
1517 + reg.ExceptionEvent.EventPending = 1;
1518 + reg.ExceptionEvent.EventType = WHvX64PendingEventException;
1519 + reg.ExceptionEvent.DeliverErrorCode = 1;
1520 + reg.ExceptionEvent.Vector = env->exception_nr;
1521 + reg.ExceptionEvent.ErrorCode = env->error_code;
1522 + if (env->exception_nr == EXCP0E_PAGE) {
1523 + reg.ExceptionEvent.ExceptionParameter = env->cr[2];
1524 + }
1525 + whpx_set_reg(cpu, WHvRegisterPendingEvent, reg);
1526 + }
1527 +}
1528 +
1529 int whpx_vcpu_run(CPUState *cpu)
1530 {
1531 HRESULT hr;
@@ -1600,6 +1620,8 @@ int whpx_vcpu_run(CPUState *cpu)
1620 whpx_vcpu_configure_single_stepping(cpu, true, NULL);
1621 }
1622
1623 + whpx_inject_exceptions(cpu);
1624 +
1625 hr = whp_dispatch.WHvRunVirtualProcessor(
1626 whpx->partition, cpu->cpu_index,
1627 &vcpu->exit_ctx, sizeof(vcpu->exit_ctx));