open-simh / simh

The Open SIMH simulators package
https://opensimh.org/
Other
485 stars 93 forks source link

PDP-11: PDR_A (access) bits not set by relocR (whereas PDR_W *is* set by relocW) #296

Closed outofmbufs closed 1 year ago

outofmbufs commented 1 year ago

context

The MMU sets the PDR_W bit in a segment for writes to normal read/write segments (the optimized path in relocW). The same path in relocR, however, does not set the PDR_A (access) bit. Here are the two comparable code snippets:

relocR:

    if (PLF_test (va, apr))                             /* pg lnt error? */
        reloc_abort (MMR0_PL, apridx);
    pa = ((va & VA_DF) + ((apr >> 10) & 017777700)) & PAMASK;

relocW (with comment annotation XXX .. XXX by me):

    if (PLF_test (va, apr))                             /* pg lnt error? */
        reloc_abort (MMR0_PL, apridx);
    APRFILE[apridx] |= PDR_W;                           /* XXX THIS (w/PDR_A) IS MISSING IN relocR XXX */
    pa = ((va & VA_DF) + ((apr >> 10) & 017777700)) & PAMASK;

simh> SHOW VERSION

PDP-11 simulator Open SIMH V4.1-0 Current
    Simulator Framework Capabilities:
        32b data
        32b addresses
        Threaded Ethernet Packet transports:PCAP:NAT:UDP
        Idle/Throttling support is available
        Virtual Hard Disk (VHD) support
        RAW disk and CD/DVD ROM support
        Asynchronous I/O support (Lock free asynchronous event queue)
        Asynchronous Clock support
        FrontPanel API Version 12
    Host Platform:
        Compiler: GCC Apple LLVM 12.0.5 (clang-1205.0.22.9)
        Simulator Compiled as C arch: x64 (Release Build) on Feb 25 2023 at 17:57:07
        Build Tool: simh-makefile
        Memory Access: Little Endian
        Memory Pointer Size: 64 bits
        Large File (>2GB) support
        SDL Video support: No Video Support
        No RegEx support for EXPECT commands
        OS clock resolution: 1ms
        Time taken by msleep(1): 1ms
        Ethernet packet info: libpcap version 1.10.1
        OS: Darwin nwair.nw 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:17:35 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8112 x86_64
        Processor Name: Apple M2
        tar tool: bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8
        curl tool: curl 8.1.2 (x86_64-apple-darwin22.0) libcurl/8.1.2 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.0
        git commit id: 4e159a04
        git commit time: 2023-01-04T13:22:12-0700

reproduction code

I have attached a .INI file that can be run to show the bug. Sample (annotated) session:

PDP-11 simulator Open SIMH V4.1-0 Current        git commit id: 4e159a04
sim> do pdrbug.ini

HALT instruction, PC: 010124 (HALT)
7760:   077506              PDR0 has mod bit (0200) set because stack writes happened here
7762:   077406              PDR1 does NOT have access bit (0100) set, but should
7764:   077506              PDR2 has mod bit set because the test wrote a location in this segment
7766:   077506              PDR3 has the mod bit, but not the access bit, set. it should have both
7770:   077406
7772:   077406
7774:   077406
7776:   077406
10000:  012706
sim> 

The attached archive has two files:

Archive.zip

pkoning2 commented 1 year ago

PDR_A isn't "access" but rather "attention". It's an 11/70 only (according to the PDP-11 Architecture Handbook) feature associated with the "trap" flavors of the access bits; if an access causes a trap then the A bit is set.

outofmbufs commented 1 year ago

Well, how about that. Not sure how I got that one confused ("expectation" / confirmation bias I guess).

pkoning2 commented 1 year ago

No problem, and not a strange mistake because "access" and "write" tracking are commonly seen together.

outofmbufs commented 1 year ago

I will say that this comment didn't help disabuse me of my mistaken understanding (in pdp11_defs.h):

define PDR_A 0000200 / access flag /

pkoning2 commented 1 year ago

Interesting, yes that is misleading.