mirror-linux/arch/x86/kvm/svm
Maciej S. Szmigiero d02e48830e KVM: SVM: Sync TPR from LAPIC into VMCB::V_TPR even if AVIC is active
Commit 3bbf3565f4 ("svm: Do not intercept CR8 when enable AVIC")
inhibited pre-VMRUN sync of TPR from LAPIC into VMCB::V_TPR in
sync_lapic_to_cr8() when AVIC is active.

AVIC does automatically sync between these two fields, however it does
so only on explicit guest writes to one of these fields, not on a bare
VMRUN.

This meant that when AVIC is enabled host changes to TPR in the LAPIC
state might not get automatically copied into the V_TPR field of VMCB.

This is especially true when it is the userspace setting LAPIC state via
KVM_SET_LAPIC ioctl() since userspace does not have access to the guest
VMCB.

Practice shows that it is the V_TPR that is actually used by the AVIC to
decide whether to issue pending interrupts to the CPU (not TPR in TASKPRI),
so any leftover value in V_TPR will cause serious interrupt delivery issues
in the guest when AVIC is enabled.

Fix this issue by doing pre-VMRUN TPR sync from LAPIC into VMCB::V_TPR
even when AVIC is enabled.

Fixes: 3bbf3565f4 ("svm: Do not intercept CR8 when enable AVIC")
Cc: stable@vger.kernel.org
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Reviewed-by: Naveen N Rao (AMD) <naveen@kernel.org>
Link: https://lore.kernel.org/r/c231be64280b1461e854e1ce3595d70cde3a2e9d.1756139678.git.maciej.szmigiero@oracle.com
[sean: tag for stable@]
Signed-off-by: Sean Christopherson <seanjc@google.com>
2025-09-10 12:04:16 -07:00
..
avic.c KVM: SVM: Generate GA log IRQs only if the associated vCPUs is blocking 2025-06-23 09:50:52 -07:00
hyperv.c KVM: nSVM: hyper-v: Enable L2 TLB flush 2022-11-18 12:59:18 -05:00
hyperv.h KVM: x86: Make Hyper-V emulation optional 2023-12-07 09:34:57 -08:00
nested.c KVM: x86: Provide a capability to disable APERF/MPERF read intercepts 2025-07-09 09:33:37 -07:00
pmu.c KVM: x86: Replace (almost) all guest CPUID feature queries with cpu_caps 2024-12-18 14:20:15 -08:00
sev.c KVM: SEV: don't check have_run_cpus in sev_writeback_caches() 2025-08-18 14:31:27 -07:00
svm.c KVM: SVM: Sync TPR from LAPIC into VMCB::V_TPR even if AVIC is active 2025-09-10 12:04:16 -07:00
svm.h Merge tag 'kvm-x86-sev-6.17' of https://github.com/kvm-x86/linux into HEAD 2025-07-29 08:36:46 -04:00
svm_onhyperv.c KVM: x86: Move Hyper-V partition assist page out of Hyper-V emulation context 2023-12-07 09:34:01 -08:00
svm_onhyperv.h s390: 2023-05-01 12:06:20 -07:00
svm_ops.h work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
vmenter.S x86/bugs: Add a Transient Scheduler Attacks mitigation 2025-06-17 17:17:02 +02:00