Abendless Software · Technical Note

Reading z/OS Virtual Storage with VSMLIST in Problem State

How ztop inspects subpools and address spaces without APF authorization

· 2 min read

z/OSHLASMCztop

One of the fastest ways to stall adoption of a new utility in a z/OS shop is to require APF authorization. Putting a binary in an APF-authorized library—or setting the +a extended attribute on an OMVS executable—triggers change-control reviews, security audits, and rightfully skeptical systems programmers.

When designing ztop, the first question was simple: how much useful virtual storage and address-space visibility can we get in ordinary problem state?

Why VSMLIST works without APF

IBM provides the VSMLIST macro specifically to inspect allocated and free virtual storage across subpools, regions, and address spaces. Because VSMLIST has no direct C library equivalent, ztop keeps a small assembler routine (src/zvslist.S) that invokes VSMLIST with the default LINKAGE=SYSTEM path:

system CBT  host CBT  os OS/390 29.00  machine 3932  address spaces 105/355

asid job          ascb
   1 *MASTER* 00FD7400
   2 PCAUTH   00FC7780
   3 RASP     00FC7600

Using LINKAGE=SYSTEM keeps the caller in problem state and key 8—no APF bit, no supervisor-state SVC, and no special RACF profiles beyond normal read access to documented storage areas.

Similarly, the system name and active address space list come directly from the CVT (Communications Vector Table) and ASVT (Address Space Vector Table), both of which are documented programming interfaces that can be traversed safely from C (src/sys.c).

Separating collection from parsing

A recurring challenge in z/OS systems programming is fast iteration. Compiling and testing every parser tweak on a shared LPAR adds friction. In ztop, the boundary is deliberately narrow:

Layer Language Runs on Linux/macOS? Responsibility
src/zvslist.S HLASM No (z/OS only) Issues VSMLIST into a caller-supplied work area
src/vsm.c C23 Yes Parses raw VSMLIST work-area descriptors into structured records
src/sys.c C23 Structurally tested Walks CVT and ASVT chains
tui/ C23 Yes Diffing cell buffer and Elm/Bubble-Tea-style event loop

Because src/vsm.c and tui/ have zero z/OS header dependencies, the entire parser and screen library can be verified on any POSIX workstation with synthetic VSMLIST buffers:

# On Linux or macOS
make test TESTCC=cc

# On z/OS with IBM Open XL C/C++
make tag
make && make check && make leakcheck

Takeaways

Keeping the HLASM layer tiny—just enough to bridge the macro interface into a flat byte buffer—yields two wins at once: you avoid APF authorization entirely, and you can fuzz and unit-test the binary parser locally before ever transferring a build to z/OS.

Comments

Loading comments…

Leave a comment

Comments are moderated before appearing. Your email is never published.

← All posts