[PATCH 4/5] i386/hvf: Raise exception on error setting APICBASE

Phil Dennis-Jordan posted 5 patches 2 weeks, 4 days ago
[PATCH 4/5] i386/hvf: Raise exception on error setting APICBASE
Posted by Phil Dennis-Jordan 2 weeks, 4 days ago
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>
---
 target/i386/hvf/x86_emu.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c
index be675bcfb71..015f760acb3 100644
--- a/target/i386/hvf/x86_emu.c
+++ b/target/i386/hvf/x86_emu.c
@@ -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;
-- 
2.39.3 (Apple Git-145)
Re: [PATCH 4/5] i386/hvf: Raise exception on error setting APICBASE
Posted by Roman Bolshakov 2 weeks, 3 days ago
On Tue, Nov 05, 2024 at 04:57:59PM +0100, Phil Dennis-Jordan wrote:
> 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.
> 

Reviewed-by: Roman Bolshakov <rbolshakov@ddn.com>

Thanks,
Roman