Patch "KVM: arm64: Handle PSCI resets before userspace touches vCPU state" 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: arm64: Handle PSCI resets before userspace touches vCPU state

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-arm64-handle-psci-resets-before-userspace-touche.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 4868bd1fc77a5d2b5b59ff42b15dda0bcfce6256
Author: Oliver Upton <oupton@xxxxxxxxxx>
Date:   Wed Aug 18 20:21:31 2021 +0000

    KVM: arm64: Handle PSCI resets before userspace touches vCPU state
    
    [ Upstream commit 6826c6849b46aaa91300201213701eb861af4ba0 ]
    
    The CPU_ON PSCI call takes a payload that KVM uses to configure a
    destination vCPU to run. This payload is non-architectural state and not
    exposed through any existing UAPI. Effectively, we have a race between
    CPU_ON and userspace saving/restoring a guest: if the target vCPU isn't
    ran again before the VMM saves its state, the requested PC and context
    ID are lost. When restored, the target vCPU will be runnable and start
    executing at its old PC.
    
    We can avoid this race by making sure the reset payload is serviced
    before userspace can access a vCPU's state.
    
    Fixes: 358b28f09f0a ("arm/arm64: KVM: Allow a VCPU to fully reset itself")
    Signed-off-by: Oliver Upton <oupton@xxxxxxxxxx>
    Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20210818202133.1106786-3-oupton@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 5e5dd99e8cee..5bc978be8043 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1143,6 +1143,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
 		if (copy_from_user(&reg, argp, sizeof(reg)))
 			break;
 
+		/*
+		 * We could owe a reset due to PSCI. Handle the pending reset
+		 * here to ensure userspace register accesses are ordered after
+		 * the reset.
+		 */
+		if (kvm_check_request(KVM_REQ_VCPU_RESET, vcpu))
+			kvm_reset_vcpu(vcpu);
+
 		if (ioctl == KVM_SET_ONE_REG)
 			r = kvm_arm_set_reg(vcpu, &reg);
 		else



[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