The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* Re: [TUHS] Accessing the PDP-11/70 MMU registers and the kernel's u area
@ 2020-06-14 14:46 Noel Chiappa
  2020-06-14 15:52 ` Warner Losh
  2020-06-14 16:13 ` Diomidis Spinellis
  0 siblings, 2 replies; 4+ messages in thread
From: Noel Chiappa @ 2020-06-14 14:46 UTC (permalink / raw)
  To: tuhs; +Cc: jnc

    > From: Diomidis Spinellis

    > From the 2.11 BSD sources I understand that the PDP-11/70 MMU address
    > and data registers, KDSA and KDSD, start at 0172360 and 0172320
    > respectively ...

Expressed as 16-bit addreses, on a PDP-11 with mapping disabled, yes.

    > I checked this by looking at /dev/mem. 

I don't know about 2.11, but in other PDP-11 Unixes, /dev/mem gives access to
the actual CPU memory bus (which on a /34, etc, is the 18-bit address UNIBUS;
on a /70 it's a separate 22-bit address bus).  In the /70 memory address
space, the 'I/O page' (which is where the PxR's live) is at the top end of it,
i.e. the registers are at 017772360 (KDSAR0), etc.

    > What am I missing?

PDP-11's have a plethora of address spaces, of different sizes. You need to
always be aware of which one you're working in.

    > My goal is to access from the console the kernel's u area.  According to
    > mem(4) and the symbols in /unix, this should be at address 0140000.

In the kernel virtual address space, yes.

    > Indeed, accessing it through /dev/kmem I get the expected results for
    > e.g. u_comm and u_uid.

Because /dev/kmem gives access to kernel address space for the _current_
process.

    > I have been unable to find it in the machine's physical memory

By far and away the easiest thing, for the _current_ process, is to
use /dev/kmem, which automagally applies the correct mapping.

For other processes, if the process is swapped in, there's some field in the
proc structure which says where in physical memory it us. IIRC, the user
struct and the kernel stack are stored in the very bottom of that.

(This article:

    http://gunkies.org/wiki/Unix_V6_dump_analysis#Memory_layouts

goes into some detail for V6. Not sure how different 2.11 is; I know it uses
one block of kernel address space to map in code overlays, but I don't know
all the details of how it works.)

Anyway, using that, one could read the user area in /dev/mem, at the
appropriate location.

For swapped-out processes, a similar algorithm applies, but you'll
have to look in the swap device (obviously).

     Noel

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [TUHS] Accessing the PDP-11/70 MMU registers and the kernel's u area
@ 2020-06-14  8:33 Diomidis Spinellis
  0 siblings, 0 replies; 4+ messages in thread
From: Diomidis Spinellis @ 2020-06-14  8:33 UTC (permalink / raw)
  To: TUHS main list

 From the 2.11 BSD sources I understand that the PDP-11/70 MMU address 
and data registers, KDSA and KDSD, start at 0172360 and 0172320 
respectively [1].  Yet, when I read the register contents I don't get 
what I would expect to see: increasing by 0200 memory values for KDSA 
and the same constant value for KDSD [2].  I checked this by looking at 
/dev/mem.

# od -o /dev/mem 0172360 | head -1
0172360  000002 000016 001403 012700 000400 000402 012700 000200

# od /dev/mem 0172320 | head -1
0172320  101016 005064 000026 005067 175456 016467 000006 175430

I get the same results when I examine the memory through SIMH:

sim> examine 172360
172360: 000002
sim> examine 172362
172362: 000016
sim> examine 172364
172364: 001403

sim> examine 172320
172320: 101016
sim> examine 172322
172322: 005064

The MMU kernel instruction registers, KISA and KISD, contain similarly 
nonsensical values as do the registers located at a different memory 
location (077320, 0772360) indicated in another source [3].  What am I 
missing?

My goal is to access from the console the kernel's u area.  According to 
mem(4) and the symbols in /unix, this should be at address 0140000. 
Indeed, accessing it through /dev/kmem I get the expected results for 
e.g. u_comm and u_uid.  However, I have been unable to find it in the 
machine's physical memory, hence my question regarding the MMU's operation.

[1] 
https://github.com/RetroBSD/2.11BSD/blob/master/usr/sys/pdpstand/M.s#L346
[2] 
https://github.com/RetroBSD/2.11BSD/blob/master/usr/sys/pdpstand/M.s#L247
[3] https://gunkies.org/wiki/PDP-11_Memory_Management

Diomidis

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-14 16:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-14 14:46 [TUHS] Accessing the PDP-11/70 MMU registers and the kernel's u area Noel Chiappa
2020-06-14 15:52 ` Warner Losh
2020-06-14 16:13 ` Diomidis Spinellis
  -- strict thread matches above, loose matches on Subject: below --
2020-06-14  8:33 Diomidis Spinellis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).