Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bec6e03b authored by Suraj Jitindar Singh's avatar Suraj Jitindar Singh Committed by Paul Mackerras
Browse files

KVM: PPC: Book3S HV: Hold kvm->mmu_lock across updating nested pte rc bits



We already hold the kvm->mmu_lock spin lock across updating the rc bits
in the pte for the L1 guest. Continue to hold the lock across updating
the rc bits in the pte for the nested guest as well to prevent
invalidations from occurring.

Signed-off-by: default avatarSuraj Jitindar Singh <sjitindarsingh@gmail.com>
Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
parent 95d386c2
Loading
Loading
Loading
Loading
+12 −6
Original line number Original line Diff line number Diff line
@@ -1150,7 +1150,7 @@ static long kvmhv_handle_nested_set_rc(struct kvm_vcpu *vcpu,
	struct kvm *kvm = vcpu->kvm;
	struct kvm *kvm = vcpu->kvm;
	bool writing = !!(dsisr & DSISR_ISSTORE);
	bool writing = !!(dsisr & DSISR_ISSTORE);
	u64 pgflags;
	u64 pgflags;
	bool ret;
	long ret;


	/* Are the rc bits set in the L1 partition scoped pte? */
	/* Are the rc bits set in the L1 partition scoped pte? */
	pgflags = _PAGE_ACCESSED;
	pgflags = _PAGE_ACCESSED;
@@ -1163,16 +1163,22 @@ static long kvmhv_handle_nested_set_rc(struct kvm_vcpu *vcpu,
	/* Set the rc bit in the pte of our (L0) pgtable for the L1 guest */
	/* Set the rc bit in the pte of our (L0) pgtable for the L1 guest */
	ret = kvmppc_hv_handle_set_rc(kvm, kvm->arch.pgtable, writing,
	ret = kvmppc_hv_handle_set_rc(kvm, kvm->arch.pgtable, writing,
				     gpte.raddr, kvm->arch.lpid);
				     gpte.raddr, kvm->arch.lpid);
	spin_unlock(&kvm->mmu_lock);
	if (!ret) {
	if (!ret)
		ret = -EINVAL;
		return -EINVAL;
		goto out_unlock;
	}


	/* Set the rc bit in the pte of the shadow_pgtable for the nest guest */
	/* Set the rc bit in the pte of the shadow_pgtable for the nest guest */
	ret = kvmppc_hv_handle_set_rc(kvm, gp->shadow_pgtable, writing, n_gpa,
	ret = kvmppc_hv_handle_set_rc(kvm, gp->shadow_pgtable, writing, n_gpa,
				      gp->shadow_lpid);
				      gp->shadow_lpid);
	if (!ret)
	if (!ret)
		return -EINVAL;
		ret = -EINVAL;
	return 0;
	else
		ret = 0;

out_unlock:
	spin_unlock(&kvm->mmu_lock);
	return ret;
}
}


static inline int kvmppc_radix_level_to_shift(int level)
static inline int kvmppc_radix_level_to_shift(int level)