Commit fc670ad5 authored by Oliver Upton's avatar Oliver Upton
Browse files

Revert "KVM: arm64: Reschedule as needed when destroying the stage-2 page-tables"

This reverts commit e9abe311.

syzkaller has managed to tease out multiple bugs in this change and
fixing-forward didn't remedy the situation. Considering newly-introduced
memory safety issues the potential for scheduler stalls don't seem that
bad in comparison

Link: https://lore.kernel.org/kvmarm/68c09802.050a0220.3c6139.000d.GAE@google.com/


Message-ID: <20250910180930.3679473-2-oliver.upton@linux.dev>
Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
parent c04f1741
Loading
Loading
Loading
Loading
+1 −25
Original line number Diff line number Diff line
@@ -904,35 +904,11 @@ static int kvm_init_ipa_range(struct kvm_s2_mmu *mmu, unsigned long type)
	return 0;
}

/*
 * Assume that @pgt is valid and unlinked from the KVM MMU to free the
 * page-table without taking the kvm_mmu_lock and without performing any
 * TLB invalidations.
 *
 * Also, the range of addresses can be large enough to cause need_resched
 * warnings, for instance on CONFIG_PREEMPT_NONE kernels. Hence, invoke
 * cond_resched() periodically to prevent hogging the CPU for a long time
 * and schedule something else, if required.
 */
static void stage2_destroy_range(struct kvm_pgtable *pgt, phys_addr_t addr,
				   phys_addr_t end)
{
	u64 next;

	do {
		next = stage2_range_addr_end(addr, end);
		KVM_PGT_FN(kvm_pgtable_stage2_destroy_range)(pgt, addr,
								next - addr);
		if (next != end)
			cond_resched();
	} while (addr = next, addr != end);
}

static void kvm_stage2_destroy(struct kvm_pgtable *pgt)
{
	unsigned int ia_bits = VTCR_EL2_IPA(pgt->mmu->vtcr);

	stage2_destroy_range(pgt, 0, BIT(ia_bits));
	KVM_PGT_FN(kvm_pgtable_stage2_destroy_range)(pgt, 0, BIT(ia_bits));
	KVM_PGT_FN(kvm_pgtable_stage2_destroy_pgd)(pgt);
}