@samitouri / QOSamiQemu / commits / 56bd0977df

target/i386: emulate: use exception_payload for fault address

Instead of directly putting it in cr[2], put it in exception_payload. Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260422214225.2242-27-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Mohamed Mediouni committed Apr 22, 2026 at 23:42 UTC 56bd0977df6102f9c04ab2a92176ff250bbe9711
2 files changed +5 -4
target/i386/emulate/x86_mmu.c
+2 -1
@@ -277,7 +277,8 @@ static MMUTranslateResult x86_write_mem_ex(CPUState *cpu, void *data, target_ulo
277 translate_res = mmu_gva_to_gpa(cpu, gva, &gpa, translate_flags);
278 if (translate_res) {
279 int error_code = translate_res_to_error_code(translate_res, true, is_user(cpu));
280 - env->cr[2] = gva;
280 + env->exception_has_payload = 1;
281 + env->exception_payload = gva;
282 x86_emul_raise_exception(env, EXCP0E_PAGE, error_code);
283 return translate_res;
284 }
target/i386/whpx/whpx-all.c
+3 -3
@@ -1891,11 +1891,11 @@ static void whpx_inject_exceptions(CPUState* cpu)
1891 WHV_REGISTER_VALUE reg = {};
1892 reg.ExceptionEvent.EventPending = 1;
1893 reg.ExceptionEvent.EventType = WHvX64PendingEventException;
1894 - reg.ExceptionEvent.DeliverErrorCode = 1;
1894 + reg.ExceptionEvent.DeliverErrorCode = env->has_error_code;
1895 reg.ExceptionEvent.Vector = env->exception_nr;
1896 reg.ExceptionEvent.ErrorCode = env->error_code;
1897 - if (env->exception_nr == EXCP0E_PAGE) {
1898 - reg.ExceptionEvent.ExceptionParameter = env->cr[2];
1897 + if (env->exception_has_payload) {
1898 + reg.ExceptionEvent.ExceptionParameter = env->exception_payload;
1899 }
1900 whpx_set_reg(cpu, WHvRegisterPendingEvent, reg);
1901 }