NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-riscv/59696: pte_make_enter() appears to have bug vis a vis already-modified managed pages



>Number:         59696
>Category:       port-riscv
>Synopsis:       pte_make_enter() appears to have bug vis a vis already-modified managed pages
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-riscv-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 06 22:05:00 +0000 2025
>Originator:     Jason Thorpe
>Release:        NetBSD-current as of 20251006
>Organization:
RISCy Business
>Environment:
N/A
>Description:
pmap_make_enter() has the following block of code to skip mod/ref emulation for managed pages that are already modified and/or referenced:

                if ((prot & VM_PROT_WRITE) != 0 &&
                    ((flags & VM_PROT_WRITE) != 0 || VM_PAGEMD_MODIFIED_P(mdpg))) {
                        /*
                        * This is a writable mapping, and the page's mod state
                        * indicates it has already been modified.  No need for
                        * modified emulation.
                        */
                        pte |= PTE_A;
                } else if ((flags & VM_PROT_ALL) || VM_PAGEMD_REFERENCED_P(mdpg)) {             
                        /*
                        * - The access type indicates that we don't need to do
                        *   referenced emulation.
                        * OR
                        * - The physical page has already been referenced so no need    
                        *   to re-do referenced emulation here.
                        */
                        pte |= PTE_A;
                }

In the first block, handling the VM_PAGEMD_MODIFIED_P(), the new PTE does not get the Dirty bit, meaning that a write fault will have to be processed.  That line should almost certainly be:

                        pte |= PTE_A | PTE_D;

>How-To-Repeat:
Code observation.
>Fix:
See above.



Home | Main Index | Thread Index | Old Index