Index: /trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp	(revision 46807)
+++ /trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp	(revision 46808)
@@ -32,5 +32,5 @@
 
 #ifdef DEBUG_ramshankar
-# define HMVMX_SYNC_FULL_GUEST_STATE
+# define HMSVM_SYNC_FULL_GUEST_STATE
 # define HMSVM_ALWAYS_TRAP_ALL_XCPTS
 # define HMSVM_ALWAYS_TRAP_PF
@@ -2561,5 +2561,5 @@
     pVmcb->ctrl.NestedPaging.n.u1NestedPaging = pVM->hm.s.fNestedPaging;
 
-#ifdef HMVMX_SYNC_FULL_GUEST_STATE
+#ifdef HMSVM_SYNC_FULL_GUEST_STATE
     pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_ALL_GUEST;
 #endif
@@ -2716,6 +2716,7 @@
             else if ((uint8_t)(pSvmTransient->u8GuestTpr >> 4) != pVmcb->ctrl.IntCtrl.n.u8VTPR)
             {
-                int rc = PDMApicSetTPR(pVCpu, (pVmcb->ctrl.IntCtrl.n.u8VTPR << 4));
+                int rc = PDMApicSetTPR(pVCpu, pVmcb->ctrl.IntCtrl.n.u8VTPR << 4);
                 AssertRC(rc);
+                pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_SVM_GUEST_APIC_STATE;
             }
         }
@@ -3759,5 +3760,14 @@
             AssertMsg(rc == VERR_EM_INTERPRETER, ("hmR0SvmExitMsr: EMInterpretWrmsr failed rc=%Rrc\n", rc));
 
-        if (pCtx->ecx == MSR_K6_EFER)
+        /* If this is an X2APIC WRMSR access, update the APIC state as well. */
+        if (   pCtx->ecx >= MSR_IA32_X2APIC_START
+            && pCtx->ecx <= MSR_IA32_X2APIC_END)
+        {
+            /* We've already saved the APIC related guest-state (TPR) in hmR0SvmPostRunGuest(). When full APIC register
+             * virtualization is implemented we'll have to make sure APIC state is saved from the VMCB before
+               EMInterpretWrmsr() changes it. */
+            pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_SVM_GUEST_APIC_STATE;
+        }
+        else if (pCtx->ecx == MSR_K6_EFER)
             pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_SVM_GUEST_EFER_MSR;
         else if (pCtx->ecx == MSR_IA32_TSC)
@@ -4261,4 +4271,5 @@
         TRPMResetTrap(pVCpu);
         STAM_COUNTER_INC(&pVCpu->hm.s.StatExitShadowPF);
+        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_SVM_GUEST_APIC_STATE;
         return rc;
     }
