#! /opt/bin/dash # # os/prog/paging-multilevel-translate/post.sh # works best with paging-multilevel-translate.py modified to: # - print page numbers and PDBR in hex # - print memory dump column headings export PATH="/opt/bin:/bin:/usr/bin"; s="123456789" #echo "Content-type: text/plain\n"; in=$(cat); echo "in = \"$in\""; exit echo "Content-type: text/html\n\n
$in\n" if [ -n "$useed" ]; then seed="$useed" msg="- seed = $seed" else x=$(perl -e "print unpack(\"C*\",$user);"); seed="${s}${x}" #echo "
s = $s, x = $x, seed = $seed" msg="" fi echo "$user - paging-multilevel-translate results $msg
green = correct |
red = wrong |
" #echo "
" #python3 ./paging-multilevel-translate.py -s "$seed" -c | grep '^Virtual' #echo "" #exit # Virtual Address 2c03: # --> pde index:0xb [decimal 11] pde contents:0xc4 (valid 1, pfn 0x44 [decimal 68]) # --> pte index:0x0 [decimal 0] pte contents:0xd7 (valid 1, pfn 0x57 [decimal 87]) # --> Translates to Physical Address 0xae3 --> Value: 16 # Virtual Address 7fd7: # --> pde index:0x1f [decimal 31] pde contents:0x92 (valid 1, pfn 0x12 [decimal 18]) # --> pte index:0x1e [decimal 30] pte contents:0x7f (valid 0, pfn 0x7f [decimal 127]) # --> Fault (page table entry not valid) # Virtual Address 390f: # --> pde index:0xe [decimal 14] pde contents:0x7f (valid 0, pfn 0x7f [decimal 127]) # --> Fault (page directory entry not valid) out=$( (echo "$in"; python3 ./paging-multilevel-translate.py -s "$seed" -c) | awk 'function hex(h) { if( index(h,"0x") == 1) h=substr(h,3); # remove leading 0x while(length(h)>3 && index(h,"0") == 1) h=substr(h,2); # remove excess leading zeros while(length(h)<3) h = "0"h; return "0x"h; } # add leading zeros to make length 3 BEGIN { v=0; print "
\ | PDE | PTE | \|||||
---|---|---|---|---|---|---|---|
# | \VA | index | contents | \index | contents | \PA | value |
"v" | "va" | "; x=u["d"v"di"]; if( x != "" && hex(x) == di) color="#90EE90"; else color="#FF6347"; print ""x" | "; x=u["d"v"dc"]; if( x != "" && hex(x) == dc) color="#90EE90"; else color="#FF6347"; print ""x" | "; x=u["t"v"ti"]; if( x != "" && hex(x) == ti) color="#90EE90"; else color="#FF6347"; print ""x" | "; x=u["t"v"tc"]; #-- bug if valid ti is 0: #-- if( (x != "" && hex(x) == tc) || (x == "" && ti == "0x000" && color == "#90EE90") ) if( (x != "" && hex(x) == tc) || (x == "" && tv == 0 && color == "#90EE90") ) color="#90EE90"; else color="#FF6347"; print ""x" | "; x=u["p"v"pa"]; if( x != "" && hex(x) == pa) color="#90EE90"; else color="#FF6347"; print ""x" | "; x=u["p"v"pv"]; if( (x != "" && hex(x) == pv) || (x == "" && pa == "0x000" && color == "#90EE90") ) color="#90EE90"; else color="#FF6347"; print ""x" | "; print "