i386/hvf: Raise exception on error setting APICBASE
authorPhil Dennis-Jordan <phil@philjordan.eu>
Tue, 5 Nov 2024 15:57:59 +0000 (16:57 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 9 Nov 2024 07:34:07 +0000 (08:34 +0100)
When setting the APICBASE MSR to an illegal value, the APIC
implementation will return an error. This change forwards that report
to the guest as an exception rather than ignoring it when using the hvf
accelerator.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Link: https://lore.kernel.org/r/20241105155800.5461-5-phil@philjordan.eu
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/hvf/x86_emu.c

index be675bcfb7162fddd4ea9a1004c6b87aec39b7dc..015f760acb39f5e15d59d03a8933b5e862aa9458 100644 (file)
@@ -794,9 +794,16 @@ void simulate_wrmsr(CPUX86State *env)
     switch (msr) {
     case MSR_IA32_TSC:
         break;
-    case MSR_IA32_APICBASE:
-        cpu_set_apic_base(cpu->apic_state, data);
+    case MSR_IA32_APICBASE: {
+        int r;
+
+        r = cpu_set_apic_base(cpu->apic_state, data);
+        if (r < 0) {
+            raise_exception(env, EXCP0D_GPF, 0);
+        }
+
         break;
+    }
     case MSR_APIC_START ... MSR_APIC_END: {
         int ret;
         int index = (uint32_t)env->regs[R_ECX] - MSR_APIC_START;