First: The Old Way • Compile plugin code on NetBSD • Copy plugin directory onto File System destined for SPC The New MSR • Boot SPC Plugin Download • Log in to SPC Environment – requires user space and serial line or telnet access • Use modload(1) on SPC to load plugin – links plugin against kernel in /netbsd on SPC • Use modstat(1) on SPC to see list of loaded plugins Washington Washington jdd@arl.wustl.edu http://www.arl.wustl.edu/~jdd John DeHart - 6/24/2003 2 WASHINGTON UNIVERSITY IN ST LOUIS WASHINGTON UNIVERSITY IN ST LOUIS The New Way Exposed Functions • Compile plugin code on NetBSD • Kernel functions • Verify plugin has no undefined symbols – assert() – There is no link against running kernel anymore – MALLOC() – wu_arl/msr/usr/src/sys/msr/msr_lkm.h provides macros to needed – FREE() kernel functions and structures • Clock Functions • We can add more as we need them. • Plugins do need to be recompiled if msr_lkm.* changes – cpu_clock_1usec() • But if msr_lkm.* is stable, even if rest of kernel changes, plugin does – cpu_clock_10usec() not need to be recompiled. • Use pluginDownload utility from CP (Linux) to download – cpu_clock_1msec() plugin to SPC • LKM Functions – Only runs on Linux right now… – lkm_nofunc() • Use instantiatePlugin utility from CP to config plugin, – lkmdispatch() filters, etc – lkmexists() • Use pluginStat utility from CP to view list of loaded plugins Washington Washington John DeHart - 6/24/2003 3 John DeHart - 6/24/2003 4 WASHINGTON UNIVERSITY IN ST LOUIS WASHINGTON UNIVERSITY IN ST LOUIS 1
Exposed Functions (continued) pluginDownload • Uses gnu binary utilities cross-linker • MSR Plugin Control Unit – Runs on Linux, builds a NetBSD binary – pcu_deregister_class() – Used to: • prelink to get size information – pcu_free_all_instances() • final link to relocate – pcu_register_class() • Uses new AAL5 control data channels to download plugin directly into kernel memory. – pcu_list_all_classes() – uses sendcmd API to: • allocate kernel memory for plugin • set up AAL5 data channel • call plugin entry function to complete load operation • Side Note: sendcmd API – should be expanded to include all of sendcmd, but right now we have about 15 “commands”. • Source files: wu_arl/utilities/SPC/plugDownload Washington Washington John DeHart - 6/24/2003 5 John DeHart - 6/24/2003 6 WASHINGTON UNIVERSITY IN ST LOUIS WASHINGTON UNIVERSITY IN ST LOUIS pluginDownload: steps it takes USAGE: pluginDownload – pre-link object file so we can get sizes pluginDownload [-h] [-d] [-V <vpivci>] [-D <fileDchan#> -D <symtabDchan#>] [-s] -p <port#> -e <entry> <input file> • use a bogus kernel address to force a.out file to have valid sizes -h : get this usage message – open pre-linked plugin file to get size -d : turn on debug output – allocate two chunks of kernel memory -V <vpivci> : specify the VPI/VCI to use for download. • 1: plugin code • 2: plugin symbols : overrides default of 164 + port# • returns addresses of two chunks and slot in lkm table -D <chan#> : specify the MSR Control Data Channel ids to use. – re-link plugin to relocate : First use of -D is for file channel – open two dchans into MSR kernel : second use of -D is for symbol table channel • plugin code : if they aren’t specified, they’ll be allocated • plugin symbols -p <port#> : specify the port to be downloaded to – download plugin code and symbols -e <entry> : specify the symbol name that should be called – finish plugin loading by calling its entry function : when module is loaded • sendcmd -c rp_pcu –s load causes kernel to call entry function -s : include symbols in the plugin download – release dchans Washington Washington John DeHart - 6/24/2003 7 John DeHart - 6/24/2003 8 WASHINGTON UNIVERSITY IN ST LOUIS WASHINGTON UNIVERSITY IN ST LOUIS 2
USAGE: instantiatePlugin Example � ../../../utilities/bin/$MYOS/pluginDownload -p 4 -e wvplugin -s combined.o instantiatePlugin -p port [-h] [-ge] [-f filterId] pluginId flags # Gen plugin src src src dst dst dst srcAddr srcMask srcPort dstAddr dstMask dstPort protocol # Port Cfy Fid Id flags addr mask port addr mask port prot � instantiatePlugin -d -p 4 -g -f 0 200 0 0 0 0 192.168.220.2 255.255.255.255 5555 17 -p port : MSR Port to query -g : bind to general match classifier -e : bind to exact match classifier -f filterId : use this filter table entry (gen match classifier only) -h : Get this usage message Washington Washington John DeHart - 6/24/2003 9 John DeHart - 6/24/2003 10 WASHINGTON UNIVERSITY IN ST LOUIS WASHINGTON UNIVERSITY IN ST LOUIS Data Transfer Extra Supporting Notes MSR Kernel Dchannel Table Vaddr Length Next Addr Seq # Start of Virtual Length of block in Where next frame Next expected address block bytes (32b) should go. Initially frame sequence where data frames set to <Vaddr> number (first frame should go (32b) (32b) should be 1) (16b) Index(dchan#) 0 1 . . . DCHAN_MAX Washington Washington John DeHart - 6/24/2003 11 John DeHart - 6/24/2003 12 WASHINGTON UNIVERSITY IN ST LOUIS WASHINGTON UNIVERSITY IN ST LOUIS 3
Data Transfer (continued) MSR Control Data Channel RATM AAL5 Frame Format (as it appears in the MSR Kernel) Shim Reserved space (8 Bytes) APIC Rx desc flags (8bits) dchan#(8bits) seq# (16bits) points here flags: framelength (16bits) pad (16bits) 1: Data 2016 B 2: Ack 2000 B 4: Nack 1992 B AAL5 Frame Data (<= 1992 Bytes) AAL5 Trailer (8 Bytes) Washington John DeHart - 6/24/2003 13 WASHINGTON UNIVERSITY IN ST LOUIS 4
Recommend
More recommend