Patch "KVM: PPC: Book3S HV P9: Restore host CTRL SPR after guest exit" has been added to the 5.10-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: PPC: Book3S HV P9: Restore host CTRL SPR after guest exit

to the 5.10-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-ppc-book3s-hv-p9-restore-host-ctrl-spr-after-gue.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 029d73359cbe0f635c5b39e09850005ddb5c540a
Author: Nicholas Piggin <npiggin@xxxxxxxxx>
Date:   Mon Apr 12 11:48:34 2021 +1000

    KVM: PPC: Book3S HV P9: Restore host CTRL SPR after guest exit
    
    [ Upstream commit 5088eb4092df12d701af8e0e92860b7186365279 ]
    
    The host CTRL (runlatch) value is not restored after guest exit. The
    host CTRL should always be 1 except in CPU idle code, so this can result
    in the host running with runlatch clear, and potentially switching to
    a different vCPU which then runs with runlatch clear as well.
    
    This has little effect on P9 machines, CTRL is only responsible for some
    PMU counter logic in the host and so other than corner cases of software
    relying on that, or explicitly reading the runlatch value (Linux does
    not appear to be affected but it's possible non-Linux guests could be),
    there should be no execution correctness problem, though it could be
    used as a covert channel between guests.
    
    There may be microcontrollers, firmware or monitoring tools that sample
    the runlatch value out-of-band, however since the register is writable
    by guests, these values would (should) not be relied upon for correct
    operation of the host, so suboptimal performance or incorrect reporting
    should be the worst problem.
    
    Fixes: 95a6432ce9038 ("KVM: PPC: Book3S HV: Streamlined guest entry/exit path on P9 for radix guests")
    Signed-off-by: Nicholas Piggin <npiggin@xxxxxxxxx>
    Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20210412014845.1517916-2-npiggin@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index e3b1839fc251..280f7992ae99 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3697,7 +3697,10 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
 	vcpu->arch.dec_expires = dec + tb;
 	vcpu->cpu = -1;
 	vcpu->arch.thread_cpu = -1;
+	/* Save guest CTRL register, set runlatch to 1 */
 	vcpu->arch.ctrl = mfspr(SPRN_CTRLF);
+	if (!(vcpu->arch.ctrl & 1))
+		mtspr(SPRN_CTRLT, vcpu->arch.ctrl | 1);
 
 	vcpu->arch.iamr = mfspr(SPRN_IAMR);
 	vcpu->arch.pspb = mfspr(SPRN_PSPB);



[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