# DF-5535 — minidump PDP-walk off-by-one: pages in the last KVA slot silently missing from every crash dump

## Target
`sys/platform/pc64/x86_64/minidump_machdep.c` (pass 2)

## Build
On the guest (root):

    mkdir -p /root/mddiag && cp Makefile mddiag.c dumpchk.c /root/mddiag/
    cd /root/mddiag && make obj >/dev/null 2>&1; make
    cc -O -o dumpchk dumpchk.c

Makefile:
    KMOD=  mddiag
    SRCS=  mddiag.c
    .include <bsd.kmod.mk>

## Run (baseline, unpatched kernel)

    kldload /root/mddiag/mddiag.ko
    sysctl debug.debugger_on_panic=0
    sysctl debug.mddiag=maptest          # maps 2 fresh pages (slot 8191 + slot 8190 control), then panics
    # after the dump completes, force reset via QEMU monitor if wedged, wait for savecore
    /root/mddiag/dumpchk /var/crash/vmcore.N 0xaa603000 0xaae01000

## Expected (baseline)
`pa 0xaa603000` (mapped at va 0xffffffffd0000000, PDP slot 8191): **CLEAR (MISSING from dump)**
`pa 0xaae01000` (mapped at va 0xffffffffa0000000, PDP slot 8190): **SET (in dump)**

## Run (patched kernel, fix.diff applied)
Same as above; expected: BOTH pages SET (dump complete).

## Files
- `mddiag.c`    — KLD rig: report() (PDP layout facts), maptest(), booby(), panic trigger via `sysctl debug.mddiag=<mode>`
- `dumpchk.c`   — parses the savecore vmcore, checks bitmap bits for given physical addresses
- `run.log`     — baseline console + dumpchk output
- `fix.diff`    — the fix (index correction + panic-time hardening)
