m68k target TLB filler may miss page modification events
Host environment
- Operating system: NetBSD
- OS/kernel version: NetBSD 10.99.10
- Architecture: x86
- QEMU flavor: qemu-system-m68k
- QEMU version: QEMU emulator version 11.0.0
- QEMU command line: (any invocation of a 68040 virt machine)
Emulated/Virtualized environment
- Operating system: NetBSD
- OS/kernel version: NetBSD 11.99.6
- Architecture: m68k (68040)
Description of problem
The m68k TLB filler does not properly account for pages that have not been modified. As such a page that is referenced before being modified may not update the PTE to indicate a write to the page, which can lead to problems when the guest OS decides it's time to start swapping under memory pressure.
Steps to reproduce
I constructed a test case inside the NetBSD kernel:
pt_entry_t *ptep = pmap_kernel_pte(va);
pt_entry_t ref_pte, mod_pte;
int s = splhigh();
val = *loc;
ref_pte = pte_load(ptep);
*loc = 0;
mod_pte = pte_load(ptep);
splx(s);After running this code, a faulty Qemu will not have the M bit set in mod_pte even though it obviously should be (and on a real 68040, it is).