Skip to content

Commit 649d686

Browse files
joergroedelavikivity
authored andcommitted
KVM: SVM: sync TPR value to V_TPR field in the VMCB
This patch adds syncing of the lapic.tpr field to the V_TPR field of the VMCB. With this change we can safely remove the CR8 read intercept. Signed-off-by: Joerg Roedel <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent bbf45ba commit 649d686

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

arch/x86/kvm/svm.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,7 @@ static void init_vmcb(struct vcpu_svm *svm)
486486

487487
control->intercept_cr_read = INTERCEPT_CR0_MASK |
488488
INTERCEPT_CR3_MASK |
489-
INTERCEPT_CR4_MASK |
490-
INTERCEPT_CR8_MASK;
489+
INTERCEPT_CR4_MASK;
491490

492491
control->intercept_cr_write = INTERCEPT_CR0_MASK |
493492
INTERCEPT_CR3_MASK |
@@ -1621,6 +1620,19 @@ static void svm_prepare_guest_switch(struct kvm_vcpu *vcpu)
16211620
{
16221621
}
16231622

1623+
static inline void sync_lapic_to_cr8(struct kvm_vcpu *vcpu)
1624+
{
1625+
struct vcpu_svm *svm = to_svm(vcpu);
1626+
u64 cr8;
1627+
1628+
if (!irqchip_in_kernel(vcpu->kvm))
1629+
return;
1630+
1631+
cr8 = kvm_get_cr8(vcpu);
1632+
svm->vmcb->control.int_ctl &= ~V_TPR_MASK;
1633+
svm->vmcb->control.int_ctl |= cr8 & V_TPR_MASK;
1634+
}
1635+
16241636
static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
16251637
{
16261638
struct vcpu_svm *svm = to_svm(vcpu);
@@ -1630,6 +1642,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
16301642

16311643
pre_svm_run(svm);
16321644

1645+
sync_lapic_to_cr8(vcpu);
1646+
16331647
save_host_msrs(vcpu);
16341648
fs_selector = read_fs();
16351649
gs_selector = read_gs();

0 commit comments

Comments
 (0)