Re: [PATCH] MIPS: mm: tlb-r4k: Uniquify TLB entries on init

From: Maciej W. Rozycki
Date: Fri Jun 06 2025 - 22:48:35 EST


On Thu, 5 Jun 2025, Jiaxun Yang wrote:

> +static unsigned long r4k_safe_entryhi(void)
> +{
> + int entry = current_cpu_data.tlbsize;
> + int old_index;
> +
> + old_index = read_c0_index();
> + while (entry >= 0) {
[...]
> + entry++;
> + }

Hmm, how is it supposed to work: you start from say 48 and then iterate
until 0x80000000 before giving up? Also a signed overflow condition is UB
pre-C23, so the compiler may well optimise the loop control away.

How did you verify this code?

Maciej