pmap_demote_l2_locked contains two bad assertions:
- The check for PTE_A can never fire: the series of conditionals immediately prior will certainly return from this function if PTE_A is not asserted.
- The check for PTE_D can fire in legitimate circumstances; see the attached test program for a simple reproducer which creates fully materialized and writeable yet clean large pages.
Just remove both of these assertions.