Patch "KVM: x86: Fix emulation in writing cr8" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    KVM: x86: Fix emulation in writing cr8

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-x86-fix-emulation-in-writing-cr8.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0e19cb2ec36d62e7272cdde6c1461540dfe728ee
Author: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxx>
Date:   Thu Feb 10 17:45:06 2022 +0800

    KVM: x86: Fix emulation in writing cr8
    
    [ Upstream commit f66af9f222f08d5b11ea41c1bd6c07a0f12daa07 ]
    
    In emulation of writing to cr8, one of the lowest four bits in TPR[3:0]
    is kept.
    
    According to Intel SDM 10.8.6.1(baremetal scenario):
    "APIC.TPR[bits 7:4] = CR8[bits 3:0], APIC.TPR[bits 3:0] = 0";
    
    and SDM 28.3(use TPR shadow):
    "MOV to CR8. The instruction stores bits 3:0 of its source operand into
    bits 7:4 of VTPR; the remainder of VTPR (bits 3:0 and bits 31:8) are
    cleared.";
    
    and AMD's APM 16.6.4:
    "Task Priority Sub-class (TPS)-Bits 3 : 0. The TPS field indicates the
    current sub-priority to be used when arbitrating lowest-priority messages.
    This field is written with zero when TPR is written using the architectural
    CR8 register.";
    
    so in KVM emulated scenario, clear TPR[3:0] to make a consistent behavior
    as in other scenarios.
    
    This doesn't impact evaluation and delivery of pending virtual interrupts
    because processor does not use the processor-priority sub-class to
    determine which interrupts to delivery and which to inhibit.
    
    Sub-class is used by hardware to arbitrate lowest priority interrupts,
    but KVM just does a round-robin style delivery.
    
    Fixes: b93463aa59d6 ("KVM: Accelerated apic support")
    Signed-off-by: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxx>
    Reviewed-by: Sean Christopherson <seanjc@xxxxxxxxxx>
    Message-Id: <20220210094506.20181-1-zhenzhong.duan@xxxxxxxxx>
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 91c2dc9f198d..d790337613aa 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2242,10 +2242,7 @@ void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data)
 
 void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8)
 {
-	struct kvm_lapic *apic = vcpu->arch.apic;
-
-	apic_set_tpr(apic, ((cr8 & 0x0f) << 4)
-		     | (kvm_lapic_get_reg(apic, APIC_TASKPRI) & 4));
+	apic_set_tpr(vcpu->arch.apic, (cr8 & 0x0f) << 4);
 }
 
 u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux