modus
Menu
On this page

The entry extended_state

The source src/modules/demonstrations/extended_state built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.

The registers of the vector unit of each thread, which the kernel keeps apart. The design: Architecture: The extended state of the processor.

The process starts as many threads as the machine has processors, plus two, so that threads share processors and move between them. Each thread fills every register of the widest level that it can use (zmm0 to zmm31 and k0 to k7, or ymm0 to ymm15, or xmm0 to xmm15), the x87 stack, the x87 control word and MXCSR with a pattern of its own, new at each pass; then it spins, enters the kernel, and gives its processor away, many times; then it compares each register with its pattern. A wrong bit is a failed check that names the thread, the register and the pass.

Each thread also checks the start state that the kernel gave it: the high halves of its ymm and zmm registers and its opmask registers are zero, the x87 control word is 0x037F and MXCSR is 0x1F80. A kernel that did not save the high halves would give a new thread the registers of another thread.

Then the main thread measures one empty kernel entry with each level of registers in use.

What it is for. The kernel keeps the extended state of each thread (the vector registers, the x87 and MXCSR) and saves it only at a switch of threads. A fault there leaks the registers of one process into another, or changes the result of a computation in silence. This process puts that work under load, with a pattern in each register, and checks every bit.

What a reader sees. Start it from the start menu, or with start("extended_state") in the console. The window shows the level of registers that the threads use, the threads, the passes and the checks. The log gets extended_state: ok, <count> threads on <count> processors, <count> passes, <count> kernel entries ..., or extended_state: failed: <count> wrong registers after a pass, <count> parts of a start state wrong, then the cost of one empty kernel entry with each level.

Its grants: none. Its budget holds 32 threads: the main thread and up to 31 threads that hold their registers.

What it does not prove. The widest level that it uses is the level of the processor of the run: under QEMU with no AVX-512, the zmm and k registers are not checked. The rules are in Vector forms: SSE2.

extended_state module with an entry

Hash
7283488a3ce363aeef32766b3b10af2d41d5ea602fc321fe99db2f4522df12c0
Size
183447 bytes
Exports
0
Imports
1
Imported by
0
License
MIT

The registers of the vector unit of each thread, which the kernel keeps apart

FactValue
KindModules with an entry
Sourcesrc/modules/demonstrations/extended_state
Boot imageyes: in the boot image, 183447 bytes in this build
Build settings
  • DRAWING_THROUGH_MODULE=true
Imports
Imported bynone

Neighbours

What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.

extended_state drawing

Exports

ExportWhat it does
entry()starts the threads that fill and check the registers (registers.asm holds the code that touches each register), waits for their passes, writes the summary line, measures the empty kernel entry with each level of registers in use, then keeps the window open until the process is stopped

entry

entry()

entry starts the threads that fill and check the registers (registers.asm holds the code that touches each register), waits for their passes, writes the summary line, measures the empty kernel entry with each level of registers in use, then keeps the window open until the process is stopped.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/demonstrations/extended_state/main.odin:735

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsnoneThe extended state of its own threads.
Other terms of its start grant setnone
Budget that it asks for
  • working memory pages 1282
  • pages of its threads 661
  • pages of the pictures of its window 5500
  • pages of the module and its imports from the files of the build
  • processes 1
  • threads 32
The main thread and up to 31 threads that hold their registers: 928 pages. And the glyph memory of the copy of the text rendering of the drawing module, which draws its text: 354 pages (display.TEXT_MEMORY_PAGES). 928 + 354 = 1282.

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).