Thank you for the review!

On Wed, Nov 18, 2026 at 8:20 AM Tanushree Shah <[email protected]> wrote:
> Thanks, v2 looks right. One concern: the rule infers user vs kernel
> from SIAR's address, but a real-mode address (translation off) is also
> low, so it can look like a user address. The 0xc00 samples in the
> results come out right only because the regs are kernel there. If a
> real-mode SIAR ever pairs with user regs, the rule would trust a bogus
> address.

It does pair with user regs. On the hash MMU CPUs, a DSI or ISI for a
page whose PTE is present but not in the hash table goes to
hash_page_dsi/hash_page_isi, which call hash_page() with translation
still off and return to user space from fast_hash_page_return. EE is
clear the whole way, so if a counter overflows in there, the exception
is taken at the first user instruction with SIAR holding the real
address of the hash code.

I reproduced it on the 7448 with a loop that mprotect()s 2048 pages
read-only and back, which flushes their hash PTEs, then reads one word
from each page. With -c 10007, 1674 of 2659 user samples landed on the
real addresses of DataAccess, hash_page_dsi, hash_page, create_hpte and
fast_hash_page_return. My syscall test couldn't have caught this, since
it counted those as user addresses in user mode.

> This rule avoids it and still fixes the interrupts-off case:
> regs->result = siar && !user_mode(regs) && is_kernel_addr(siar);
> User samples then use regs->nip, which loses little (SIAR was only ~4
> instructions closer in your table).

Agreed. With that, the same test has no user samples at kernel
addresses, and 99.9% of the kernel samples still get their address
from SIAR. I'll use it in v3 with your Suggested-by.

Thanks,
Matt

Reply via email to