api.rst 283 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===================================================================
  3. The Definitive KVM (Kernel-based Virtual Machine) API Documentation
  4. ===================================================================
  5. 1. General description
  6. ======================
  7. The kvm API is a set of ioctls that are issued to control various aspects
  8. of a virtual machine. The ioctls belong to the following classes:
  9. - System ioctls: These query and set global attributes which affect the
  10. whole kvm subsystem. In addition a system ioctl is used to create
  11. virtual machines.
  12. - VM ioctls: These query and set attributes that affect an entire virtual
  13. machine, for example memory layout. In addition a VM ioctl is used to
  14. create virtual cpus (vcpus) and devices.
  15. VM ioctls must be issued from the same process (address space) that was
  16. used to create the VM.
  17. - vcpu ioctls: These query and set attributes that control the operation
  18. of a single virtual cpu.
  19. vcpu ioctls should be issued from the same thread that was used to create
  20. the vcpu, except for asynchronous vcpu ioctl that are marked as such in
  21. the documentation. Otherwise, the first ioctl after switching threads
  22. could see a performance impact.
  23. - device ioctls: These query and set attributes that control the operation
  24. of a single device.
  25. device ioctls must be issued from the same process (address space) that
  26. was used to create the VM.
  27. 2. File descriptors
  28. ===================
  29. The kvm API is centered around file descriptors. An initial
  30. open("/dev/kvm") obtains a handle to the kvm subsystem; this handle
  31. can be used to issue system ioctls. A KVM_CREATE_VM ioctl on this
  32. handle will create a VM file descriptor which can be used to issue VM
  33. ioctls. A KVM_CREATE_VCPU or KVM_CREATE_DEVICE ioctl on a VM fd will
  34. create a virtual cpu or device and return a file descriptor pointing to
  35. the new resource. Finally, ioctls on a vcpu or device fd can be used
  36. to control the vcpu or device. For vcpus, this includes the important
  37. task of actually running guest code.
  38. In general file descriptors can be migrated among processes by means
  39. of fork() and the SCM_RIGHTS facility of unix domain socket. These
  40. kinds of tricks are explicitly not supported by kvm. While they will
  41. not cause harm to the host, their actual behavior is not guaranteed by
  42. the API. See "General description" for details on the ioctl usage
  43. model that is supported by KVM.
  44. It is important to note that although VM ioctls may only be issued from
  45. the process that created the VM, a VM's lifecycle is associated with its
  46. file descriptor, not its creator (process). In other words, the VM and
  47. its resources, *including the associated address space*, are not freed
  48. until the last reference to the VM's file descriptor has been released.
  49. For example, if fork() is issued after ioctl(KVM_CREATE_VM), the VM will
  50. not be freed until both the parent (original) process and its child have
  51. put their references to the VM's file descriptor.
  52. Because a VM's resources are not freed until the last reference to its
  53. file descriptor is released, creating additional references to a VM
  54. via fork(), dup(), etc... without careful consideration is strongly
  55. discouraged and may have unwanted side effects, e.g. memory allocated
  56. by and on behalf of the VM's process may not be freed/unaccounted when
  57. the VM is shut down.
  58. 3. Extensions
  59. =============
  60. As of Linux 2.6.22, the KVM ABI has been stabilized: no backward
  61. incompatible change are allowed. However, there is an extension
  62. facility that allows backward-compatible extensions to the API to be
  63. queried and used.
  64. The extension mechanism is not based on the Linux version number.
  65. Instead, kvm defines extension identifiers and a facility to query
  66. whether a particular extension identifier is available. If it is, a
  67. set of ioctls is available for application use.
  68. 4. API description
  69. ==================
  70. This section describes ioctls that can be used to control kvm guests.
  71. For each ioctl, the following information is provided along with a
  72. description:
  73. Capability:
  74. which KVM extension provides this ioctl. Can be 'basic',
  75. which means that is will be provided by any kernel that supports
  76. API version 12 (see section 4.1), a KVM_CAP_xyz constant, which
  77. means availability needs to be checked with KVM_CHECK_EXTENSION
  78. (see section 4.4), or 'none' which means that while not all kernels
  79. support this ioctl, there's no capability bit to check its
  80. availability: for kernels that don't support the ioctl,
  81. the ioctl returns -ENOTTY.
  82. Architectures:
  83. which instruction set architectures provide this ioctl.
  84. x86 includes both i386 and x86_64.
  85. Type:
  86. system, vm, or vcpu.
  87. Parameters:
  88. what parameters are accepted by the ioctl.
  89. Returns:
  90. the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  91. are not detailed, but errors with specific meanings are.
  92. 4.1 KVM_GET_API_VERSION
  93. -----------------------
  94. :Capability: basic
  95. :Architectures: all
  96. :Type: system ioctl
  97. :Parameters: none
  98. :Returns: the constant KVM_API_VERSION (=12)
  99. This identifies the API version as the stable kvm API. It is not
  100. expected that this number will change. However, Linux 2.6.20 and
  101. 2.6.21 report earlier versions; these are not documented and not
  102. supported. Applications should refuse to run if KVM_GET_API_VERSION
  103. returns a value other than 12. If this check passes, all ioctls
  104. described as 'basic' will be available.
  105. 4.2 KVM_CREATE_VM
  106. -----------------
  107. :Capability: basic
  108. :Architectures: all
  109. :Type: system ioctl
  110. :Parameters: machine type identifier (KVM_VM_*)
  111. :Returns: a VM fd that can be used to control the new virtual machine.
  112. The new VM has no virtual cpus and no memory.
  113. You probably want to use 0 as machine type.
  114. In order to create user controlled virtual machines on S390, check
  115. KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as
  116. privileged user (CAP_SYS_ADMIN).
  117. On arm64, the physical address size for a VM (IPA Size limit) is limited
  118. to 40bits by default. The limit can be configured if the host supports the
  119. extension KVM_CAP_ARM_VM_IPA_SIZE. When supported, use
  120. KVM_VM_TYPE_ARM_IPA_SIZE(IPA_Bits) to set the size in the machine type
  121. identifier, where IPA_Bits is the maximum width of any physical
  122. address used by the VM. The IPA_Bits is encoded in bits[7-0] of the
  123. machine type identifier.
  124. e.g, to configure a guest to use 48bit physical address size::
  125. vm_fd = ioctl(dev_fd, KVM_CREATE_VM, KVM_VM_TYPE_ARM_IPA_SIZE(48));
  126. The requested size (IPA_Bits) must be:
  127. == =========================================================
  128. 0 Implies default size, 40bits (for backward compatibility)
  129. N Implies N bits, where N is a positive integer such that,
  130. 32 <= N <= Host_IPA_Limit
  131. == =========================================================
  132. Host_IPA_Limit is the maximum possible value for IPA_Bits on the host and
  133. is dependent on the CPU capability and the kernel configuration. The limit can
  134. be retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION
  135. ioctl() at run-time.
  136. Creation of the VM will fail if the requested IPA size (whether it is
  137. implicit or explicit) is unsupported on the host.
  138. Please note that configuring the IPA size does not affect the capability
  139. exposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects
  140. size of the address translated by the stage2 level (guest physical to
  141. host physical address translations).
  142. 4.3 KVM_GET_MSR_INDEX_LIST, KVM_GET_MSR_FEATURE_INDEX_LIST
  143. ----------------------------------------------------------
  144. :Capability: basic, KVM_CAP_GET_MSR_FEATURES for KVM_GET_MSR_FEATURE_INDEX_LIST
  145. :Architectures: x86
  146. :Type: system ioctl
  147. :Parameters: struct kvm_msr_list (in/out)
  148. :Returns: 0 on success; -1 on error
  149. Errors:
  150. ====== ============================================================
  151. EFAULT the msr index list cannot be read from or written to
  152. E2BIG the msr index list is too big to fit in the array specified by
  153. the user.
  154. ====== ============================================================
  155. ::
  156. struct kvm_msr_list {
  157. __u32 nmsrs; /* number of msrs in entries */
  158. __u32 indices[0];
  159. };
  160. The user fills in the size of the indices array in nmsrs, and in return
  161. kvm adjusts nmsrs to reflect the actual number of msrs and fills in the
  162. indices array with their numbers.
  163. KVM_GET_MSR_INDEX_LIST returns the guest msrs that are supported. The list
  164. varies by kvm version and host processor, but does not change otherwise.
  165. Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are
  166. not returned in the MSR list, as different vcpus can have a different number
  167. of banks, as set via the KVM_X86_SETUP_MCE ioctl.
  168. KVM_GET_MSR_FEATURE_INDEX_LIST returns the list of MSRs that can be passed
  169. to the KVM_GET_MSRS system ioctl. This lets userspace probe host capabilities
  170. and processor features that are exposed via MSRs (e.g., VMX capabilities).
  171. This list also varies by kvm version and host processor, but does not change
  172. otherwise.
  173. 4.4 KVM_CHECK_EXTENSION
  174. -----------------------
  175. :Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl
  176. :Architectures: all
  177. :Type: system ioctl, vm ioctl
  178. :Parameters: extension identifier (KVM_CAP_*)
  179. :Returns: 0 if unsupported; 1 (or some other positive integer) if supported
  180. The API allows the application to query about extensions to the core
  181. kvm API. Userspace passes an extension identifier (an integer) and
  182. receives an integer that describes the extension availability.
  183. Generally 0 means no and 1 means yes, but some extensions may report
  184. additional information in the integer return value.
  185. Based on their initialization different VMs may have different capabilities.
  186. It is thus encouraged to use the vm ioctl to query for capabilities (available
  187. with KVM_CAP_CHECK_EXTENSION_VM on the vm fd)
  188. 4.5 KVM_GET_VCPU_MMAP_SIZE
  189. --------------------------
  190. :Capability: basic
  191. :Architectures: all
  192. :Type: system ioctl
  193. :Parameters: none
  194. :Returns: size of vcpu mmap area, in bytes
  195. The KVM_RUN ioctl (cf.) communicates with userspace via a shared
  196. memory region. This ioctl returns the size of that region. See the
  197. KVM_RUN documentation for details.
  198. Besides the size of the KVM_RUN communication region, other areas of
  199. the VCPU file descriptor can be mmap-ed, including:
  200. - if KVM_CAP_COALESCED_MMIO is available, a page at
  201. KVM_COALESCED_MMIO_PAGE_OFFSET * PAGE_SIZE; for historical reasons,
  202. this page is included in the result of KVM_GET_VCPU_MMAP_SIZE.
  203. KVM_CAP_COALESCED_MMIO is not documented yet.
  204. - if KVM_CAP_DIRTY_LOG_RING is available, a number of pages at
  205. KVM_DIRTY_LOG_PAGE_OFFSET * PAGE_SIZE. For more information on
  206. KVM_CAP_DIRTY_LOG_RING, see section 8.3.
  207. 4.6 KVM_SET_MEMORY_REGION
  208. -------------------------
  209. :Capability: basic
  210. :Architectures: all
  211. :Type: vm ioctl
  212. :Parameters: struct kvm_memory_region (in)
  213. :Returns: 0 on success, -1 on error
  214. This ioctl is obsolete and has been removed.
  215. 4.7 KVM_CREATE_VCPU
  216. -------------------
  217. :Capability: basic
  218. :Architectures: all
  219. :Type: vm ioctl
  220. :Parameters: vcpu id (apic id on x86)
  221. :Returns: vcpu fd on success, -1 on error
  222. This API adds a vcpu to a virtual machine. No more than max_vcpus may be added.
  223. The vcpu id is an integer in the range [0, max_vcpu_id).
  224. The recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of
  225. the KVM_CHECK_EXTENSION ioctl() at run-time.
  226. The maximum possible value for max_vcpus can be retrieved using the
  227. KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time.
  228. If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4
  229. cpus max.
  230. If the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is
  231. same as the value returned from KVM_CAP_NR_VCPUS.
  232. The maximum possible value for max_vcpu_id can be retrieved using the
  233. KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
  234. If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that max_vcpu_id
  235. is the same as the value returned from KVM_CAP_MAX_VCPUS.
  236. On powerpc using book3s_hv mode, the vcpus are mapped onto virtual
  237. threads in one or more virtual CPU cores. (This is because the
  238. hardware requires all the hardware threads in a CPU core to be in the
  239. same partition.) The KVM_CAP_PPC_SMT capability indicates the number
  240. of vcpus per virtual core (vcore). The vcore id is obtained by
  241. dividing the vcpu id by the number of vcpus per vcore. The vcpus in a
  242. given vcore will always be in the same physical core as each other
  243. (though that might be a different physical core from time to time).
  244. Userspace can control the threading (SMT) mode of the guest by its
  245. allocation of vcpu ids. For example, if userspace wants
  246. single-threaded guest vcpus, it should make all vcpu ids be a multiple
  247. of the number of vcpus per vcore.
  248. For virtual cpus that have been created with S390 user controlled virtual
  249. machines, the resulting vcpu fd can be memory mapped at page offset
  250. KVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual
  251. cpu's hardware control block.
  252. 4.8 KVM_GET_DIRTY_LOG (vm ioctl)
  253. --------------------------------
  254. :Capability: basic
  255. :Architectures: all
  256. :Type: vm ioctl
  257. :Parameters: struct kvm_dirty_log (in/out)
  258. :Returns: 0 on success, -1 on error
  259. ::
  260. /* for KVM_GET_DIRTY_LOG */
  261. struct kvm_dirty_log {
  262. __u32 slot;
  263. __u32 padding;
  264. union {
  265. void __user *dirty_bitmap; /* one bit per page */
  266. __u64 padding;
  267. };
  268. };
  269. Given a memory slot, return a bitmap containing any pages dirtied
  270. since the last call to this ioctl. Bit 0 is the first page in the
  271. memory slot. Ensure the entire structure is cleared to avoid padding
  272. issues.
  273. If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of slot field specifies
  274. the address space for which you want to return the dirty bitmap. See
  275. KVM_SET_USER_MEMORY_REGION for details on the usage of slot field.
  276. The bits in the dirty bitmap are cleared before the ioctl returns, unless
  277. KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is enabled. For more information,
  278. see the description of the capability.
  279. Note that the Xen shared info page, if configured, shall always be assumed
  280. to be dirty. KVM will not explicitly mark it such.
  281. 4.9 KVM_SET_MEMORY_ALIAS
  282. ------------------------
  283. :Capability: basic
  284. :Architectures: x86
  285. :Type: vm ioctl
  286. :Parameters: struct kvm_memory_alias (in)
  287. :Returns: 0 (success), -1 (error)
  288. This ioctl is obsolete and has been removed.
  289. 4.10 KVM_RUN
  290. ------------
  291. :Capability: basic
  292. :Architectures: all
  293. :Type: vcpu ioctl
  294. :Parameters: none
  295. :Returns: 0 on success, -1 on error
  296. Errors:
  297. ======= ==============================================================
  298. EINTR an unmasked signal is pending
  299. ENOEXEC the vcpu hasn't been initialized or the guest tried to execute
  300. instructions from device memory (arm64)
  301. ENOSYS data abort outside memslots with no syndrome info and
  302. KVM_CAP_ARM_NISV_TO_USER not enabled (arm64)
  303. EPERM SVE feature set but not finalized (arm64)
  304. ======= ==============================================================
  305. This ioctl is used to run a guest virtual cpu. While there are no
  306. explicit parameters, there is an implicit parameter block that can be
  307. obtained by mmap()ing the vcpu fd at offset 0, with the size given by
  308. KVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct
  309. kvm_run' (see below).
  310. 4.11 KVM_GET_REGS
  311. -----------------
  312. :Capability: basic
  313. :Architectures: all except arm64
  314. :Type: vcpu ioctl
  315. :Parameters: struct kvm_regs (out)
  316. :Returns: 0 on success, -1 on error
  317. Reads the general purpose registers from the vcpu.
  318. ::
  319. /* x86 */
  320. struct kvm_regs {
  321. /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
  322. __u64 rax, rbx, rcx, rdx;
  323. __u64 rsi, rdi, rsp, rbp;
  324. __u64 r8, r9, r10, r11;
  325. __u64 r12, r13, r14, r15;
  326. __u64 rip, rflags;
  327. };
  328. /* mips */
  329. struct kvm_regs {
  330. /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
  331. __u64 gpr[32];
  332. __u64 hi;
  333. __u64 lo;
  334. __u64 pc;
  335. };
  336. 4.12 KVM_SET_REGS
  337. -----------------
  338. :Capability: basic
  339. :Architectures: all except arm64
  340. :Type: vcpu ioctl
  341. :Parameters: struct kvm_regs (in)
  342. :Returns: 0 on success, -1 on error
  343. Writes the general purpose registers into the vcpu.
  344. See KVM_GET_REGS for the data structure.
  345. 4.13 KVM_GET_SREGS
  346. ------------------
  347. :Capability: basic
  348. :Architectures: x86, ppc
  349. :Type: vcpu ioctl
  350. :Parameters: struct kvm_sregs (out)
  351. :Returns: 0 on success, -1 on error
  352. Reads special registers from the vcpu.
  353. ::
  354. /* x86 */
  355. struct kvm_sregs {
  356. struct kvm_segment cs, ds, es, fs, gs, ss;
  357. struct kvm_segment tr, ldt;
  358. struct kvm_dtable gdt, idt;
  359. __u64 cr0, cr2, cr3, cr4, cr8;
  360. __u64 efer;
  361. __u64 apic_base;
  362. __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
  363. };
  364. /* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */
  365. interrupt_bitmap is a bitmap of pending external interrupts. At most
  366. one bit may be set. This interrupt has been acknowledged by the APIC
  367. but not yet injected into the cpu core.
  368. 4.14 KVM_SET_SREGS
  369. ------------------
  370. :Capability: basic
  371. :Architectures: x86, ppc
  372. :Type: vcpu ioctl
  373. :Parameters: struct kvm_sregs (in)
  374. :Returns: 0 on success, -1 on error
  375. Writes special registers into the vcpu. See KVM_GET_SREGS for the
  376. data structures.
  377. 4.15 KVM_TRANSLATE
  378. ------------------
  379. :Capability: basic
  380. :Architectures: x86
  381. :Type: vcpu ioctl
  382. :Parameters: struct kvm_translation (in/out)
  383. :Returns: 0 on success, -1 on error
  384. Translates a virtual address according to the vcpu's current address
  385. translation mode.
  386. ::
  387. struct kvm_translation {
  388. /* in */
  389. __u64 linear_address;
  390. /* out */
  391. __u64 physical_address;
  392. __u8 valid;
  393. __u8 writeable;
  394. __u8 usermode;
  395. __u8 pad[5];
  396. };
  397. 4.16 KVM_INTERRUPT
  398. ------------------
  399. :Capability: basic
  400. :Architectures: x86, ppc, mips, riscv
  401. :Type: vcpu ioctl
  402. :Parameters: struct kvm_interrupt (in)
  403. :Returns: 0 on success, negative on failure.
  404. Queues a hardware interrupt vector to be injected.
  405. ::
  406. /* for KVM_INTERRUPT */
  407. struct kvm_interrupt {
  408. /* in */
  409. __u32 irq;
  410. };
  411. X86:
  412. ^^^^
  413. :Returns:
  414. ========= ===================================
  415. 0 on success,
  416. -EEXIST if an interrupt is already enqueued
  417. -EINVAL the irq number is invalid
  418. -ENXIO if the PIC is in the kernel
  419. -EFAULT if the pointer is invalid
  420. ========= ===================================
  421. Note 'irq' is an interrupt vector, not an interrupt pin or line. This
  422. ioctl is useful if the in-kernel PIC is not used.
  423. PPC:
  424. ^^^^
  425. Queues an external interrupt to be injected. This ioctl is overleaded
  426. with 3 different irq values:
  427. a) KVM_INTERRUPT_SET
  428. This injects an edge type external interrupt into the guest once it's ready
  429. to receive interrupts. When injected, the interrupt is done.
  430. b) KVM_INTERRUPT_UNSET
  431. This unsets any pending interrupt.
  432. Only available with KVM_CAP_PPC_UNSET_IRQ.
  433. c) KVM_INTERRUPT_SET_LEVEL
  434. This injects a level type external interrupt into the guest context. The
  435. interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET
  436. is triggered.
  437. Only available with KVM_CAP_PPC_IRQ_LEVEL.
  438. Note that any value for 'irq' other than the ones stated above is invalid
  439. and incurs unexpected behavior.
  440. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  441. MIPS:
  442. ^^^^^
  443. Queues an external interrupt to be injected into the virtual CPU. A negative
  444. interrupt number dequeues the interrupt.
  445. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  446. RISC-V:
  447. ^^^^^^^
  448. Queues an external interrupt to be injected into the virutal CPU. This ioctl
  449. is overloaded with 2 different irq values:
  450. a) KVM_INTERRUPT_SET
  451. This sets external interrupt for a virtual CPU and it will receive
  452. once it is ready.
  453. b) KVM_INTERRUPT_UNSET
  454. This clears pending external interrupt for a virtual CPU.
  455. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  456. 4.17 KVM_DEBUG_GUEST
  457. --------------------
  458. :Capability: basic
  459. :Architectures: none
  460. :Type: vcpu ioctl
  461. :Parameters: none)
  462. :Returns: -1 on error
  463. Support for this has been removed. Use KVM_SET_GUEST_DEBUG instead.
  464. 4.18 KVM_GET_MSRS
  465. -----------------
  466. :Capability: basic (vcpu), KVM_CAP_GET_MSR_FEATURES (system)
  467. :Architectures: x86
  468. :Type: system ioctl, vcpu ioctl
  469. :Parameters: struct kvm_msrs (in/out)
  470. :Returns: number of msrs successfully returned;
  471. -1 on error
  472. When used as a system ioctl:
  473. Reads the values of MSR-based features that are available for the VM. This
  474. is similar to KVM_GET_SUPPORTED_CPUID, but it returns MSR indices and values.
  475. The list of msr-based features can be obtained using KVM_GET_MSR_FEATURE_INDEX_LIST
  476. in a system ioctl.
  477. When used as a vcpu ioctl:
  478. Reads model-specific registers from the vcpu. Supported msr indices can
  479. be obtained using KVM_GET_MSR_INDEX_LIST in a system ioctl.
  480. ::
  481. struct kvm_msrs {
  482. __u32 nmsrs; /* number of msrs in entries */
  483. __u32 pad;
  484. struct kvm_msr_entry entries[0];
  485. };
  486. struct kvm_msr_entry {
  487. __u32 index;
  488. __u32 reserved;
  489. __u64 data;
  490. };
  491. Application code should set the 'nmsrs' member (which indicates the
  492. size of the entries array) and the 'index' member of each array entry.
  493. kvm will fill in the 'data' member.
  494. 4.19 KVM_SET_MSRS
  495. -----------------
  496. :Capability: basic
  497. :Architectures: x86
  498. :Type: vcpu ioctl
  499. :Parameters: struct kvm_msrs (in)
  500. :Returns: number of msrs successfully set (see below), -1 on error
  501. Writes model-specific registers to the vcpu. See KVM_GET_MSRS for the
  502. data structures.
  503. Application code should set the 'nmsrs' member (which indicates the
  504. size of the entries array), and the 'index' and 'data' members of each
  505. array entry.
  506. It tries to set the MSRs in array entries[] one by one. If setting an MSR
  507. fails, e.g., due to setting reserved bits, the MSR isn't supported/emulated
  508. by KVM, etc..., it stops processing the MSR list and returns the number of
  509. MSRs that have been set successfully.
  510. 4.20 KVM_SET_CPUID
  511. ------------------
  512. :Capability: basic
  513. :Architectures: x86
  514. :Type: vcpu ioctl
  515. :Parameters: struct kvm_cpuid (in)
  516. :Returns: 0 on success, -1 on error
  517. Defines the vcpu responses to the cpuid instruction. Applications
  518. should use the KVM_SET_CPUID2 ioctl if available.
  519. Caveat emptor:
  520. - If this IOCTL fails, KVM gives no guarantees that previous valid CPUID
  521. configuration (if there is) is not corrupted. Userspace can get a copy
  522. of the resulting CPUID configuration through KVM_GET_CPUID2 in case.
  523. - Using KVM_SET_CPUID{,2} after KVM_RUN, i.e. changing the guest vCPU model
  524. after running the guest, may cause guest instability.
  525. - Using heterogeneous CPUID configurations, modulo APIC IDs, topology, etc...
  526. may cause guest instability.
  527. ::
  528. struct kvm_cpuid_entry {
  529. __u32 function;
  530. __u32 eax;
  531. __u32 ebx;
  532. __u32 ecx;
  533. __u32 edx;
  534. __u32 padding;
  535. };
  536. /* for KVM_SET_CPUID */
  537. struct kvm_cpuid {
  538. __u32 nent;
  539. __u32 padding;
  540. struct kvm_cpuid_entry entries[0];
  541. };
  542. 4.21 KVM_SET_SIGNAL_MASK
  543. ------------------------
  544. :Capability: basic
  545. :Architectures: all
  546. :Type: vcpu ioctl
  547. :Parameters: struct kvm_signal_mask (in)
  548. :Returns: 0 on success, -1 on error
  549. Defines which signals are blocked during execution of KVM_RUN. This
  550. signal mask temporarily overrides the threads signal mask. Any
  551. unblocked signal received (except SIGKILL and SIGSTOP, which retain
  552. their traditional behaviour) will cause KVM_RUN to return with -EINTR.
  553. Note the signal will only be delivered if not blocked by the original
  554. signal mask.
  555. ::
  556. /* for KVM_SET_SIGNAL_MASK */
  557. struct kvm_signal_mask {
  558. __u32 len;
  559. __u8 sigset[0];
  560. };
  561. 4.22 KVM_GET_FPU
  562. ----------------
  563. :Capability: basic
  564. :Architectures: x86
  565. :Type: vcpu ioctl
  566. :Parameters: struct kvm_fpu (out)
  567. :Returns: 0 on success, -1 on error
  568. Reads the floating point state from the vcpu.
  569. ::
  570. /* for KVM_GET_FPU and KVM_SET_FPU */
  571. struct kvm_fpu {
  572. __u8 fpr[8][16];
  573. __u16 fcw;
  574. __u16 fsw;
  575. __u8 ftwx; /* in fxsave format */
  576. __u8 pad1;
  577. __u16 last_opcode;
  578. __u64 last_ip;
  579. __u64 last_dp;
  580. __u8 xmm[16][16];
  581. __u32 mxcsr;
  582. __u32 pad2;
  583. };
  584. 4.23 KVM_SET_FPU
  585. ----------------
  586. :Capability: basic
  587. :Architectures: x86
  588. :Type: vcpu ioctl
  589. :Parameters: struct kvm_fpu (in)
  590. :Returns: 0 on success, -1 on error
  591. Writes the floating point state to the vcpu.
  592. ::
  593. /* for KVM_GET_FPU and KVM_SET_FPU */
  594. struct kvm_fpu {
  595. __u8 fpr[8][16];
  596. __u16 fcw;
  597. __u16 fsw;
  598. __u8 ftwx; /* in fxsave format */
  599. __u8 pad1;
  600. __u16 last_opcode;
  601. __u64 last_ip;
  602. __u64 last_dp;
  603. __u8 xmm[16][16];
  604. __u32 mxcsr;
  605. __u32 pad2;
  606. };
  607. 4.24 KVM_CREATE_IRQCHIP
  608. -----------------------
  609. :Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390)
  610. :Architectures: x86, arm64, s390
  611. :Type: vm ioctl
  612. :Parameters: none
  613. :Returns: 0 on success, -1 on error
  614. Creates an interrupt controller model in the kernel.
  615. On x86, creates a virtual ioapic, a virtual PIC (two PICs, nested), and sets up
  616. future vcpus to have a local APIC. IRQ routing for GSIs 0-15 is set to both
  617. PIC and IOAPIC; GSI 16-23 only go to the IOAPIC.
  618. On arm64, a GICv2 is created. Any other GIC versions require the usage of
  619. KVM_CREATE_DEVICE, which also supports creating a GICv2. Using
  620. KVM_CREATE_DEVICE is preferred over KVM_CREATE_IRQCHIP for GICv2.
  621. On s390, a dummy irq routing table is created.
  622. Note that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled
  623. before KVM_CREATE_IRQCHIP can be used.
  624. 4.25 KVM_IRQ_LINE
  625. -----------------
  626. :Capability: KVM_CAP_IRQCHIP
  627. :Architectures: x86, arm64
  628. :Type: vm ioctl
  629. :Parameters: struct kvm_irq_level
  630. :Returns: 0 on success, -1 on error
  631. Sets the level of a GSI input to the interrupt controller model in the kernel.
  632. On some architectures it is required that an interrupt controller model has
  633. been previously created with KVM_CREATE_IRQCHIP. Note that edge-triggered
  634. interrupts require the level to be set to 1 and then back to 0.
  635. On real hardware, interrupt pins can be active-low or active-high. This
  636. does not matter for the level field of struct kvm_irq_level: 1 always
  637. means active (asserted), 0 means inactive (deasserted).
  638. x86 allows the operating system to program the interrupt polarity
  639. (active-low/active-high) for level-triggered interrupts, and KVM used
  640. to consider the polarity. However, due to bitrot in the handling of
  641. active-low interrupts, the above convention is now valid on x86 too.
  642. This is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED. Userspace
  643. should not present interrupts to the guest as active-low unless this
  644. capability is present (or unless it is not using the in-kernel irqchip,
  645. of course).
  646. arm64 can signal an interrupt either at the CPU level, or at the
  647. in-kernel irqchip (GIC), and for in-kernel irqchip can tell the GIC to
  648. use PPIs designated for specific cpus. The irq field is interpreted
  649. like this::
  650. bits: | 31 ... 28 | 27 ... 24 | 23 ... 16 | 15 ... 0 |
  651. field: | vcpu2_index | irq_type | vcpu_index | irq_id |
  652. The irq_type field has the following values:
  653. - irq_type[0]:
  654. out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ
  655. - irq_type[1]:
  656. in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.)
  657. (the vcpu_index field is ignored)
  658. - irq_type[2]:
  659. in-kernel GIC: PPI, irq_id between 16 and 31 (incl.)
  660. (The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs)
  661. In both cases, level is used to assert/deassert the line.
  662. When KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 is supported, the target vcpu is
  663. identified as (256 * vcpu2_index + vcpu_index). Otherwise, vcpu2_index
  664. must be zero.
  665. Note that on arm64, the KVM_CAP_IRQCHIP capability only conditions
  666. injection of interrupts for the in-kernel irqchip. KVM_IRQ_LINE can always
  667. be used for a userspace interrupt controller.
  668. ::
  669. struct kvm_irq_level {
  670. union {
  671. __u32 irq; /* GSI */
  672. __s32 status; /* not used for KVM_IRQ_LEVEL */
  673. };
  674. __u32 level; /* 0 or 1 */
  675. };
  676. 4.26 KVM_GET_IRQCHIP
  677. --------------------
  678. :Capability: KVM_CAP_IRQCHIP
  679. :Architectures: x86
  680. :Type: vm ioctl
  681. :Parameters: struct kvm_irqchip (in/out)
  682. :Returns: 0 on success, -1 on error
  683. Reads the state of a kernel interrupt controller created with
  684. KVM_CREATE_IRQCHIP into a buffer provided by the caller.
  685. ::
  686. struct kvm_irqchip {
  687. __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */
  688. __u32 pad;
  689. union {
  690. char dummy[512]; /* reserving space */
  691. struct kvm_pic_state pic;
  692. struct kvm_ioapic_state ioapic;
  693. } chip;
  694. };
  695. 4.27 KVM_SET_IRQCHIP
  696. --------------------
  697. :Capability: KVM_CAP_IRQCHIP
  698. :Architectures: x86
  699. :Type: vm ioctl
  700. :Parameters: struct kvm_irqchip (in)
  701. :Returns: 0 on success, -1 on error
  702. Sets the state of a kernel interrupt controller created with
  703. KVM_CREATE_IRQCHIP from a buffer provided by the caller.
  704. ::
  705. struct kvm_irqchip {
  706. __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */
  707. __u32 pad;
  708. union {
  709. char dummy[512]; /* reserving space */
  710. struct kvm_pic_state pic;
  711. struct kvm_ioapic_state ioapic;
  712. } chip;
  713. };
  714. 4.28 KVM_XEN_HVM_CONFIG
  715. -----------------------
  716. :Capability: KVM_CAP_XEN_HVM
  717. :Architectures: x86
  718. :Type: vm ioctl
  719. :Parameters: struct kvm_xen_hvm_config (in)
  720. :Returns: 0 on success, -1 on error
  721. Sets the MSR that the Xen HVM guest uses to initialize its hypercall
  722. page, and provides the starting address and size of the hypercall
  723. blobs in userspace. When the guest writes the MSR, kvm copies one
  724. page of a blob (32- or 64-bit, depending on the vcpu mode) to guest
  725. memory.
  726. ::
  727. struct kvm_xen_hvm_config {
  728. __u32 flags;
  729. __u32 msr;
  730. __u64 blob_addr_32;
  731. __u64 blob_addr_64;
  732. __u8 blob_size_32;
  733. __u8 blob_size_64;
  734. __u8 pad2[30];
  735. };
  736. If certain flags are returned from the KVM_CAP_XEN_HVM check, they may
  737. be set in the flags field of this ioctl:
  738. The KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL flag requests KVM to generate
  739. the contents of the hypercall page automatically; hypercalls will be
  740. intercepted and passed to userspace through KVM_EXIT_XEN. In this
  741. ase, all of the blob size and address fields must be zero.
  742. The KVM_XEN_HVM_CONFIG_EVTCHN_SEND flag indicates to KVM that userspace
  743. will always use the KVM_XEN_HVM_EVTCHN_SEND ioctl to deliver event
  744. channel interrupts rather than manipulating the guest's shared_info
  745. structures directly. This, in turn, may allow KVM to enable features
  746. such as intercepting the SCHEDOP_poll hypercall to accelerate PV
  747. spinlock operation for the guest. Userspace may still use the ioctl
  748. to deliver events if it was advertised, even if userspace does not
  749. send this indication that it will always do so
  750. No other flags are currently valid in the struct kvm_xen_hvm_config.
  751. 4.29 KVM_GET_CLOCK
  752. ------------------
  753. :Capability: KVM_CAP_ADJUST_CLOCK
  754. :Architectures: x86
  755. :Type: vm ioctl
  756. :Parameters: struct kvm_clock_data (out)
  757. :Returns: 0 on success, -1 on error
  758. Gets the current timestamp of kvmclock as seen by the current guest. In
  759. conjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios
  760. such as migration.
  761. When KVM_CAP_ADJUST_CLOCK is passed to KVM_CHECK_EXTENSION, it returns the
  762. set of bits that KVM can return in struct kvm_clock_data's flag member.
  763. The following flags are defined:
  764. KVM_CLOCK_TSC_STABLE
  765. If set, the returned value is the exact kvmclock
  766. value seen by all VCPUs at the instant when KVM_GET_CLOCK was called.
  767. If clear, the returned value is simply CLOCK_MONOTONIC plus a constant
  768. offset; the offset can be modified with KVM_SET_CLOCK. KVM will try
  769. to make all VCPUs follow this clock, but the exact value read by each
  770. VCPU could differ, because the host TSC is not stable.
  771. KVM_CLOCK_REALTIME
  772. If set, the `realtime` field in the kvm_clock_data
  773. structure is populated with the value of the host's real time
  774. clocksource at the instant when KVM_GET_CLOCK was called. If clear,
  775. the `realtime` field does not contain a value.
  776. KVM_CLOCK_HOST_TSC
  777. If set, the `host_tsc` field in the kvm_clock_data
  778. structure is populated with the value of the host's timestamp counter (TSC)
  779. at the instant when KVM_GET_CLOCK was called. If clear, the `host_tsc` field
  780. does not contain a value.
  781. ::
  782. struct kvm_clock_data {
  783. __u64 clock; /* kvmclock current value */
  784. __u32 flags;
  785. __u32 pad0;
  786. __u64 realtime;
  787. __u64 host_tsc;
  788. __u32 pad[4];
  789. };
  790. 4.30 KVM_SET_CLOCK
  791. ------------------
  792. :Capability: KVM_CAP_ADJUST_CLOCK
  793. :Architectures: x86
  794. :Type: vm ioctl
  795. :Parameters: struct kvm_clock_data (in)
  796. :Returns: 0 on success, -1 on error
  797. Sets the current timestamp of kvmclock to the value specified in its parameter.
  798. In conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios
  799. such as migration.
  800. The following flags can be passed:
  801. KVM_CLOCK_REALTIME
  802. If set, KVM will compare the value of the `realtime` field
  803. with the value of the host's real time clocksource at the instant when
  804. KVM_SET_CLOCK was called. The difference in elapsed time is added to the final
  805. kvmclock value that will be provided to guests.
  806. Other flags returned by ``KVM_GET_CLOCK`` are accepted but ignored.
  807. ::
  808. struct kvm_clock_data {
  809. __u64 clock; /* kvmclock current value */
  810. __u32 flags;
  811. __u32 pad0;
  812. __u64 realtime;
  813. __u64 host_tsc;
  814. __u32 pad[4];
  815. };
  816. 4.31 KVM_GET_VCPU_EVENTS
  817. ------------------------
  818. :Capability: KVM_CAP_VCPU_EVENTS
  819. :Extended by: KVM_CAP_INTR_SHADOW
  820. :Architectures: x86, arm64
  821. :Type: vcpu ioctl
  822. :Parameters: struct kvm_vcpu_event (out)
  823. :Returns: 0 on success, -1 on error
  824. X86:
  825. ^^^^
  826. Gets currently pending exceptions, interrupts, and NMIs as well as related
  827. states of the vcpu.
  828. ::
  829. struct kvm_vcpu_events {
  830. struct {
  831. __u8 injected;
  832. __u8 nr;
  833. __u8 has_error_code;
  834. __u8 pending;
  835. __u32 error_code;
  836. } exception;
  837. struct {
  838. __u8 injected;
  839. __u8 nr;
  840. __u8 soft;
  841. __u8 shadow;
  842. } interrupt;
  843. struct {
  844. __u8 injected;
  845. __u8 pending;
  846. __u8 masked;
  847. __u8 pad;
  848. } nmi;
  849. __u32 sipi_vector;
  850. __u32 flags;
  851. struct {
  852. __u8 smm;
  853. __u8 pending;
  854. __u8 smm_inside_nmi;
  855. __u8 latched_init;
  856. } smi;
  857. __u8 reserved[27];
  858. __u8 exception_has_payload;
  859. __u64 exception_payload;
  860. };
  861. The following bits are defined in the flags field:
  862. - KVM_VCPUEVENT_VALID_SHADOW may be set to signal that
  863. interrupt.shadow contains a valid state.
  864. - KVM_VCPUEVENT_VALID_SMM may be set to signal that smi contains a
  865. valid state.
  866. - KVM_VCPUEVENT_VALID_PAYLOAD may be set to signal that the
  867. exception_has_payload, exception_payload, and exception.pending
  868. fields contain a valid state. This bit will be set whenever
  869. KVM_CAP_EXCEPTION_PAYLOAD is enabled.
  870. - KVM_VCPUEVENT_VALID_TRIPLE_FAULT may be set to signal that the
  871. triple_fault_pending field contains a valid state. This bit will
  872. be set whenever KVM_CAP_X86_TRIPLE_FAULT_EVENT is enabled.
  873. ARM64:
  874. ^^^^^^
  875. If the guest accesses a device that is being emulated by the host kernel in
  876. such a way that a real device would generate a physical SError, KVM may make
  877. a virtual SError pending for that VCPU. This system error interrupt remains
  878. pending until the guest takes the exception by unmasking PSTATE.A.
  879. Running the VCPU may cause it to take a pending SError, or make an access that
  880. causes an SError to become pending. The event's description is only valid while
  881. the VPCU is not running.
  882. This API provides a way to read and write the pending 'event' state that is not
  883. visible to the guest. To save, restore or migrate a VCPU the struct representing
  884. the state can be read then written using this GET/SET API, along with the other
  885. guest-visible registers. It is not possible to 'cancel' an SError that has been
  886. made pending.
  887. A device being emulated in user-space may also wish to generate an SError. To do
  888. this the events structure can be populated by user-space. The current state
  889. should be read first, to ensure no existing SError is pending. If an existing
  890. SError is pending, the architecture's 'Multiple SError interrupts' rules should
  891. be followed. (2.5.3 of DDI0587.a "ARM Reliability, Availability, and
  892. Serviceability (RAS) Specification").
  893. SError exceptions always have an ESR value. Some CPUs have the ability to
  894. specify what the virtual SError's ESR value should be. These systems will
  895. advertise KVM_CAP_ARM_INJECT_SERROR_ESR. In this case exception.has_esr will
  896. always have a non-zero value when read, and the agent making an SError pending
  897. should specify the ISS field in the lower 24 bits of exception.serror_esr. If
  898. the system supports KVM_CAP_ARM_INJECT_SERROR_ESR, but user-space sets the events
  899. with exception.has_esr as zero, KVM will choose an ESR.
  900. Specifying exception.has_esr on a system that does not support it will return
  901. -EINVAL. Setting anything other than the lower 24bits of exception.serror_esr
  902. will return -EINVAL.
  903. It is not possible to read back a pending external abort (injected via
  904. KVM_SET_VCPU_EVENTS or otherwise) because such an exception is always delivered
  905. directly to the virtual CPU).
  906. ::
  907. struct kvm_vcpu_events {
  908. struct {
  909. __u8 serror_pending;
  910. __u8 serror_has_esr;
  911. __u8 ext_dabt_pending;
  912. /* Align it to 8 bytes */
  913. __u8 pad[5];
  914. __u64 serror_esr;
  915. } exception;
  916. __u32 reserved[12];
  917. };
  918. 4.32 KVM_SET_VCPU_EVENTS
  919. ------------------------
  920. :Capability: KVM_CAP_VCPU_EVENTS
  921. :Extended by: KVM_CAP_INTR_SHADOW
  922. :Architectures: x86, arm64
  923. :Type: vcpu ioctl
  924. :Parameters: struct kvm_vcpu_event (in)
  925. :Returns: 0 on success, -1 on error
  926. X86:
  927. ^^^^
  928. Set pending exceptions, interrupts, and NMIs as well as related states of the
  929. vcpu.
  930. See KVM_GET_VCPU_EVENTS for the data structure.
  931. Fields that may be modified asynchronously by running VCPUs can be excluded
  932. from the update. These fields are nmi.pending, sipi_vector, smi.smm,
  933. smi.pending. Keep the corresponding bits in the flags field cleared to
  934. suppress overwriting the current in-kernel state. The bits are:
  935. =============================== ==================================
  936. KVM_VCPUEVENT_VALID_NMI_PENDING transfer nmi.pending to the kernel
  937. KVM_VCPUEVENT_VALID_SIPI_VECTOR transfer sipi_vector
  938. KVM_VCPUEVENT_VALID_SMM transfer the smi sub-struct.
  939. =============================== ==================================
  940. If KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in
  941. the flags field to signal that interrupt.shadow contains a valid state and
  942. shall be written into the VCPU.
  943. KVM_VCPUEVENT_VALID_SMM can only be set if KVM_CAP_X86_SMM is available.
  944. If KVM_CAP_EXCEPTION_PAYLOAD is enabled, KVM_VCPUEVENT_VALID_PAYLOAD
  945. can be set in the flags field to signal that the
  946. exception_has_payload, exception_payload, and exception.pending fields
  947. contain a valid state and shall be written into the VCPU.
  948. If KVM_CAP_X86_TRIPLE_FAULT_EVENT is enabled, KVM_VCPUEVENT_VALID_TRIPLE_FAULT
  949. can be set in flags field to signal that the triple_fault field contains
  950. a valid state and shall be written into the VCPU.
  951. ARM64:
  952. ^^^^^^
  953. User space may need to inject several types of events to the guest.
  954. Set the pending SError exception state for this VCPU. It is not possible to
  955. 'cancel' an Serror that has been made pending.
  956. If the guest performed an access to I/O memory which could not be handled by
  957. userspace, for example because of missing instruction syndrome decode
  958. information or because there is no device mapped at the accessed IPA, then
  959. userspace can ask the kernel to inject an external abort using the address
  960. from the exiting fault on the VCPU. It is a programming error to set
  961. ext_dabt_pending after an exit which was not either KVM_EXIT_MMIO or
  962. KVM_EXIT_ARM_NISV. This feature is only available if the system supports
  963. KVM_CAP_ARM_INJECT_EXT_DABT. This is a helper which provides commonality in
  964. how userspace reports accesses for the above cases to guests, across different
  965. userspace implementations. Nevertheless, userspace can still emulate all Arm
  966. exceptions by manipulating individual registers using the KVM_SET_ONE_REG API.
  967. See KVM_GET_VCPU_EVENTS for the data structure.
  968. 4.33 KVM_GET_DEBUGREGS
  969. ----------------------
  970. :Capability: KVM_CAP_DEBUGREGS
  971. :Architectures: x86
  972. :Type: vm ioctl
  973. :Parameters: struct kvm_debugregs (out)
  974. :Returns: 0 on success, -1 on error
  975. Reads debug registers from the vcpu.
  976. ::
  977. struct kvm_debugregs {
  978. __u64 db[4];
  979. __u64 dr6;
  980. __u64 dr7;
  981. __u64 flags;
  982. __u64 reserved[9];
  983. };
  984. 4.34 KVM_SET_DEBUGREGS
  985. ----------------------
  986. :Capability: KVM_CAP_DEBUGREGS
  987. :Architectures: x86
  988. :Type: vm ioctl
  989. :Parameters: struct kvm_debugregs (in)
  990. :Returns: 0 on success, -1 on error
  991. Writes debug registers into the vcpu.
  992. See KVM_GET_DEBUGREGS for the data structure. The flags field is unused
  993. yet and must be cleared on entry.
  994. 4.35 KVM_SET_USER_MEMORY_REGION
  995. -------------------------------
  996. :Capability: KVM_CAP_USER_MEMORY
  997. :Architectures: all
  998. :Type: vm ioctl
  999. :Parameters: struct kvm_userspace_memory_region (in)
  1000. :Returns: 0 on success, -1 on error
  1001. ::
  1002. struct kvm_userspace_memory_region {
  1003. __u32 slot;
  1004. __u32 flags;
  1005. __u64 guest_phys_addr;
  1006. __u64 memory_size; /* bytes */
  1007. __u64 userspace_addr; /* start of the userspace allocated memory */
  1008. };
  1009. /* for kvm_memory_region::flags */
  1010. #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
  1011. #define KVM_MEM_READONLY (1UL << 1)
  1012. This ioctl allows the user to create, modify or delete a guest physical
  1013. memory slot. Bits 0-15 of "slot" specify the slot id and this value
  1014. should be less than the maximum number of user memory slots supported per
  1015. VM. The maximum allowed slots can be queried using KVM_CAP_NR_MEMSLOTS.
  1016. Slots may not overlap in guest physical address space.
  1017. If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot"
  1018. specifies the address space which is being modified. They must be
  1019. less than the value that KVM_CHECK_EXTENSION returns for the
  1020. KVM_CAP_MULTI_ADDRESS_SPACE capability. Slots in separate address spaces
  1021. are unrelated; the restriction on overlapping slots only applies within
  1022. each address space.
  1023. Deleting a slot is done by passing zero for memory_size. When changing
  1024. an existing slot, it may be moved in the guest physical memory space,
  1025. or its flags may be modified, but it may not be resized.
  1026. Memory for the region is taken starting at the address denoted by the
  1027. field userspace_addr, which must point at user addressable memory for
  1028. the entire memory slot size. Any object may back this memory, including
  1029. anonymous memory, ordinary files, and hugetlbfs.
  1030. On architectures that support a form of address tagging, userspace_addr must
  1031. be an untagged address.
  1032. It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr
  1033. be identical. This allows large pages in the guest to be backed by large
  1034. pages in the host.
  1035. The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and
  1036. KVM_MEM_READONLY. The former can be set to instruct KVM to keep track of
  1037. writes to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to
  1038. use it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it,
  1039. to make a new slot read-only. In this case, writes to this memory will be
  1040. posted to userspace as KVM_EXIT_MMIO exits.
  1041. When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of
  1042. the memory region are automatically reflected into the guest. For example, an
  1043. mmap() that affects the region will be made visible immediately. Another
  1044. example is madvise(MADV_DROP).
  1045. It is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl.
  1046. The KVM_SET_MEMORY_REGION does not allow fine grained control over memory
  1047. allocation and is deprecated.
  1048. 4.36 KVM_SET_TSS_ADDR
  1049. ---------------------
  1050. :Capability: KVM_CAP_SET_TSS_ADDR
  1051. :Architectures: x86
  1052. :Type: vm ioctl
  1053. :Parameters: unsigned long tss_address (in)
  1054. :Returns: 0 on success, -1 on error
  1055. This ioctl defines the physical address of a three-page region in the guest
  1056. physical address space. The region must be within the first 4GB of the
  1057. guest physical address space and must not conflict with any memory slot
  1058. or any mmio address. The guest may malfunction if it accesses this memory
  1059. region.
  1060. This ioctl is required on Intel-based hosts. This is needed on Intel hardware
  1061. because of a quirk in the virtualization implementation (see the internals
  1062. documentation when it pops into existence).
  1063. 4.37 KVM_ENABLE_CAP
  1064. -------------------
  1065. :Capability: KVM_CAP_ENABLE_CAP
  1066. :Architectures: mips, ppc, s390, x86
  1067. :Type: vcpu ioctl
  1068. :Parameters: struct kvm_enable_cap (in)
  1069. :Returns: 0 on success; -1 on error
  1070. :Capability: KVM_CAP_ENABLE_CAP_VM
  1071. :Architectures: all
  1072. :Type: vm ioctl
  1073. :Parameters: struct kvm_enable_cap (in)
  1074. :Returns: 0 on success; -1 on error
  1075. .. note::
  1076. Not all extensions are enabled by default. Using this ioctl the application
  1077. can enable an extension, making it available to the guest.
  1078. On systems that do not support this ioctl, it always fails. On systems that
  1079. do support it, it only works for extensions that are supported for enablement.
  1080. To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should
  1081. be used.
  1082. ::
  1083. struct kvm_enable_cap {
  1084. /* in */
  1085. __u32 cap;
  1086. The capability that is supposed to get enabled.
  1087. ::
  1088. __u32 flags;
  1089. A bitfield indicating future enhancements. Has to be 0 for now.
  1090. ::
  1091. __u64 args[4];
  1092. Arguments for enabling a feature. If a feature needs initial values to
  1093. function properly, this is the place to put them.
  1094. ::
  1095. __u8 pad[64];
  1096. };
  1097. The vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl
  1098. for vm-wide capabilities.
  1099. 4.38 KVM_GET_MP_STATE
  1100. ---------------------
  1101. :Capability: KVM_CAP_MP_STATE
  1102. :Architectures: x86, s390, arm64, riscv
  1103. :Type: vcpu ioctl
  1104. :Parameters: struct kvm_mp_state (out)
  1105. :Returns: 0 on success; -1 on error
  1106. ::
  1107. struct kvm_mp_state {
  1108. __u32 mp_state;
  1109. };
  1110. Returns the vcpu's current "multiprocessing state" (though also valid on
  1111. uniprocessor guests).
  1112. Possible values are:
  1113. ========================== ===============================================
  1114. KVM_MP_STATE_RUNNABLE the vcpu is currently running
  1115. [x86,arm64,riscv]
  1116. KVM_MP_STATE_UNINITIALIZED the vcpu is an application processor (AP)
  1117. which has not yet received an INIT signal [x86]
  1118. KVM_MP_STATE_INIT_RECEIVED the vcpu has received an INIT signal, and is
  1119. now ready for a SIPI [x86]
  1120. KVM_MP_STATE_HALTED the vcpu has executed a HLT instruction and
  1121. is waiting for an interrupt [x86]
  1122. KVM_MP_STATE_SIPI_RECEIVED the vcpu has just received a SIPI (vector
  1123. accessible via KVM_GET_VCPU_EVENTS) [x86]
  1124. KVM_MP_STATE_STOPPED the vcpu is stopped [s390,arm64,riscv]
  1125. KVM_MP_STATE_CHECK_STOP the vcpu is in a special error state [s390]
  1126. KVM_MP_STATE_OPERATING the vcpu is operating (running or halted)
  1127. [s390]
  1128. KVM_MP_STATE_LOAD the vcpu is in a special load/startup state
  1129. [s390]
  1130. KVM_MP_STATE_SUSPENDED the vcpu is in a suspend state and is waiting
  1131. for a wakeup event [arm64]
  1132. ========================== ===============================================
  1133. On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an
  1134. in-kernel irqchip, the multiprocessing state must be maintained by userspace on
  1135. these architectures.
  1136. For arm64:
  1137. ^^^^^^^^^^
  1138. If a vCPU is in the KVM_MP_STATE_SUSPENDED state, KVM will emulate the
  1139. architectural execution of a WFI instruction.
  1140. If a wakeup event is recognized, KVM will exit to userspace with a
  1141. KVM_SYSTEM_EVENT exit, where the event type is KVM_SYSTEM_EVENT_WAKEUP. If
  1142. userspace wants to honor the wakeup, it must set the vCPU's MP state to
  1143. KVM_MP_STATE_RUNNABLE. If it does not, KVM will continue to await a wakeup
  1144. event in subsequent calls to KVM_RUN.
  1145. .. warning::
  1146. If userspace intends to keep the vCPU in a SUSPENDED state, it is
  1147. strongly recommended that userspace take action to suppress the
  1148. wakeup event (such as masking an interrupt). Otherwise, subsequent
  1149. calls to KVM_RUN will immediately exit with a KVM_SYSTEM_EVENT_WAKEUP
  1150. event and inadvertently waste CPU cycles.
  1151. Additionally, if userspace takes action to suppress a wakeup event,
  1152. it is strongly recommended that it also restores the vCPU to its
  1153. original state when the vCPU is made RUNNABLE again. For example,
  1154. if userspace masked a pending interrupt to suppress the wakeup,
  1155. the interrupt should be unmasked before returning control to the
  1156. guest.
  1157. For riscv:
  1158. ^^^^^^^^^^
  1159. The only states that are valid are KVM_MP_STATE_STOPPED and
  1160. KVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not.
  1161. 4.39 KVM_SET_MP_STATE
  1162. ---------------------
  1163. :Capability: KVM_CAP_MP_STATE
  1164. :Architectures: x86, s390, arm64, riscv
  1165. :Type: vcpu ioctl
  1166. :Parameters: struct kvm_mp_state (in)
  1167. :Returns: 0 on success; -1 on error
  1168. Sets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for
  1169. arguments.
  1170. On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an
  1171. in-kernel irqchip, the multiprocessing state must be maintained by userspace on
  1172. these architectures.
  1173. For arm64/riscv:
  1174. ^^^^^^^^^^^^^^^^
  1175. The only states that are valid are KVM_MP_STATE_STOPPED and
  1176. KVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not.
  1177. 4.40 KVM_SET_IDENTITY_MAP_ADDR
  1178. ------------------------------
  1179. :Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR
  1180. :Architectures: x86
  1181. :Type: vm ioctl
  1182. :Parameters: unsigned long identity (in)
  1183. :Returns: 0 on success, -1 on error
  1184. This ioctl defines the physical address of a one-page region in the guest
  1185. physical address space. The region must be within the first 4GB of the
  1186. guest physical address space and must not conflict with any memory slot
  1187. or any mmio address. The guest may malfunction if it accesses this memory
  1188. region.
  1189. Setting the address to 0 will result in resetting the address to its default
  1190. (0xfffbc000).
  1191. This ioctl is required on Intel-based hosts. This is needed on Intel hardware
  1192. because of a quirk in the virtualization implementation (see the internals
  1193. documentation when it pops into existence).
  1194. Fails if any VCPU has already been created.
  1195. 4.41 KVM_SET_BOOT_CPU_ID
  1196. ------------------------
  1197. :Capability: KVM_CAP_SET_BOOT_CPU_ID
  1198. :Architectures: x86
  1199. :Type: vm ioctl
  1200. :Parameters: unsigned long vcpu_id
  1201. :Returns: 0 on success, -1 on error
  1202. Define which vcpu is the Bootstrap Processor (BSP). Values are the same
  1203. as the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default
  1204. is vcpu 0. This ioctl has to be called before vcpu creation,
  1205. otherwise it will return EBUSY error.
  1206. 4.42 KVM_GET_XSAVE
  1207. ------------------
  1208. :Capability: KVM_CAP_XSAVE
  1209. :Architectures: x86
  1210. :Type: vcpu ioctl
  1211. :Parameters: struct kvm_xsave (out)
  1212. :Returns: 0 on success, -1 on error
  1213. ::
  1214. struct kvm_xsave {
  1215. __u32 region[1024];
  1216. __u32 extra[0];
  1217. };
  1218. This ioctl would copy current vcpu's xsave struct to the userspace.
  1219. 4.43 KVM_SET_XSAVE
  1220. ------------------
  1221. :Capability: KVM_CAP_XSAVE and KVM_CAP_XSAVE2
  1222. :Architectures: x86
  1223. :Type: vcpu ioctl
  1224. :Parameters: struct kvm_xsave (in)
  1225. :Returns: 0 on success, -1 on error
  1226. ::
  1227. struct kvm_xsave {
  1228. __u32 region[1024];
  1229. __u32 extra[0];
  1230. };
  1231. This ioctl would copy userspace's xsave struct to the kernel. It copies
  1232. as many bytes as are returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2),
  1233. when invoked on the vm file descriptor. The size value returned by
  1234. KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will always be at least 4096.
  1235. Currently, it is only greater than 4096 if a dynamic feature has been
  1236. enabled with ``arch_prctl()``, but this may change in the future.
  1237. The offsets of the state save areas in struct kvm_xsave follow the
  1238. contents of CPUID leaf 0xD on the host.
  1239. 4.44 KVM_GET_XCRS
  1240. -----------------
  1241. :Capability: KVM_CAP_XCRS
  1242. :Architectures: x86
  1243. :Type: vcpu ioctl
  1244. :Parameters: struct kvm_xcrs (out)
  1245. :Returns: 0 on success, -1 on error
  1246. ::
  1247. struct kvm_xcr {
  1248. __u32 xcr;
  1249. __u32 reserved;
  1250. __u64 value;
  1251. };
  1252. struct kvm_xcrs {
  1253. __u32 nr_xcrs;
  1254. __u32 flags;
  1255. struct kvm_xcr xcrs[KVM_MAX_XCRS];
  1256. __u64 padding[16];
  1257. };
  1258. This ioctl would copy current vcpu's xcrs to the userspace.
  1259. 4.45 KVM_SET_XCRS
  1260. -----------------
  1261. :Capability: KVM_CAP_XCRS
  1262. :Architectures: x86
  1263. :Type: vcpu ioctl
  1264. :Parameters: struct kvm_xcrs (in)
  1265. :Returns: 0 on success, -1 on error
  1266. ::
  1267. struct kvm_xcr {
  1268. __u32 xcr;
  1269. __u32 reserved;
  1270. __u64 value;
  1271. };
  1272. struct kvm_xcrs {
  1273. __u32 nr_xcrs;
  1274. __u32 flags;
  1275. struct kvm_xcr xcrs[KVM_MAX_XCRS];
  1276. __u64 padding[16];
  1277. };
  1278. This ioctl would set vcpu's xcr to the value userspace specified.
  1279. 4.46 KVM_GET_SUPPORTED_CPUID
  1280. ----------------------------
  1281. :Capability: KVM_CAP_EXT_CPUID
  1282. :Architectures: x86
  1283. :Type: system ioctl
  1284. :Parameters: struct kvm_cpuid2 (in/out)
  1285. :Returns: 0 on success, -1 on error
  1286. ::
  1287. struct kvm_cpuid2 {
  1288. __u32 nent;
  1289. __u32 padding;
  1290. struct kvm_cpuid_entry2 entries[0];
  1291. };
  1292. #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
  1293. #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */
  1294. #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */
  1295. struct kvm_cpuid_entry2 {
  1296. __u32 function;
  1297. __u32 index;
  1298. __u32 flags;
  1299. __u32 eax;
  1300. __u32 ebx;
  1301. __u32 ecx;
  1302. __u32 edx;
  1303. __u32 padding[3];
  1304. };
  1305. This ioctl returns x86 cpuid features which are supported by both the
  1306. hardware and kvm in its default configuration. Userspace can use the
  1307. information returned by this ioctl to construct cpuid information (for
  1308. KVM_SET_CPUID2) that is consistent with hardware, kernel, and
  1309. userspace capabilities, and with user requirements (for example, the
  1310. user may wish to constrain cpuid to emulate older hardware, or for
  1311. feature consistency across a cluster).
  1312. Dynamically-enabled feature bits need to be requested with
  1313. ``arch_prctl()`` before calling this ioctl. Feature bits that have not
  1314. been requested are excluded from the result.
  1315. Note that certain capabilities, such as KVM_CAP_X86_DISABLE_EXITS, may
  1316. expose cpuid features (e.g. MONITOR) which are not supported by kvm in
  1317. its default configuration. If userspace enables such capabilities, it
  1318. is responsible for modifying the results of this ioctl appropriately.
  1319. Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure
  1320. with the 'nent' field indicating the number of entries in the variable-size
  1321. array 'entries'. If the number of entries is too low to describe the cpu
  1322. capabilities, an error (E2BIG) is returned. If the number is too high,
  1323. the 'nent' field is adjusted and an error (ENOMEM) is returned. If the
  1324. number is just right, the 'nent' field is adjusted to the number of valid
  1325. entries in the 'entries' array, which is then filled.
  1326. The entries returned are the host cpuid as returned by the cpuid instruction,
  1327. with unknown or unsupported features masked out. Some features (for example,
  1328. x2apic), may not be present in the host cpu, but are exposed by kvm if it can
  1329. emulate them efficiently. The fields in each entry are defined as follows:
  1330. function:
  1331. the eax value used to obtain the entry
  1332. index:
  1333. the ecx value used to obtain the entry (for entries that are
  1334. affected by ecx)
  1335. flags:
  1336. an OR of zero or more of the following:
  1337. KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
  1338. if the index field is valid
  1339. eax, ebx, ecx, edx:
  1340. the values returned by the cpuid instruction for
  1341. this function/index combination
  1342. The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
  1343. as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
  1344. support. Instead it is reported via::
  1345. ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
  1346. if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the
  1347. feature in userspace, then you can enable the feature for KVM_SET_CPUID2.
  1348. 4.47 KVM_PPC_GET_PVINFO
  1349. -----------------------
  1350. :Capability: KVM_CAP_PPC_GET_PVINFO
  1351. :Architectures: ppc
  1352. :Type: vm ioctl
  1353. :Parameters: struct kvm_ppc_pvinfo (out)
  1354. :Returns: 0 on success, !0 on error
  1355. ::
  1356. struct kvm_ppc_pvinfo {
  1357. __u32 flags;
  1358. __u32 hcall[4];
  1359. __u8 pad[108];
  1360. };
  1361. This ioctl fetches PV specific information that need to be passed to the guest
  1362. using the device tree or other means from vm context.
  1363. The hcall array defines 4 instructions that make up a hypercall.
  1364. If any additional field gets added to this structure later on, a bit for that
  1365. additional piece of information will be set in the flags bitmap.
  1366. The flags bitmap is defined as::
  1367. /* the host supports the ePAPR idle hcall
  1368. #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0)
  1369. 4.52 KVM_SET_GSI_ROUTING
  1370. ------------------------
  1371. :Capability: KVM_CAP_IRQ_ROUTING
  1372. :Architectures: x86 s390 arm64
  1373. :Type: vm ioctl
  1374. :Parameters: struct kvm_irq_routing (in)
  1375. :Returns: 0 on success, -1 on error
  1376. Sets the GSI routing table entries, overwriting any previously set entries.
  1377. On arm64, GSI routing has the following limitation:
  1378. - GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD.
  1379. ::
  1380. struct kvm_irq_routing {
  1381. __u32 nr;
  1382. __u32 flags;
  1383. struct kvm_irq_routing_entry entries[0];
  1384. };
  1385. No flags are specified so far, the corresponding field must be set to zero.
  1386. ::
  1387. struct kvm_irq_routing_entry {
  1388. __u32 gsi;
  1389. __u32 type;
  1390. __u32 flags;
  1391. __u32 pad;
  1392. union {
  1393. struct kvm_irq_routing_irqchip irqchip;
  1394. struct kvm_irq_routing_msi msi;
  1395. struct kvm_irq_routing_s390_adapter adapter;
  1396. struct kvm_irq_routing_hv_sint hv_sint;
  1397. struct kvm_irq_routing_xen_evtchn xen_evtchn;
  1398. __u32 pad[8];
  1399. } u;
  1400. };
  1401. /* gsi routing entry types */
  1402. #define KVM_IRQ_ROUTING_IRQCHIP 1
  1403. #define KVM_IRQ_ROUTING_MSI 2
  1404. #define KVM_IRQ_ROUTING_S390_ADAPTER 3
  1405. #define KVM_IRQ_ROUTING_HV_SINT 4
  1406. #define KVM_IRQ_ROUTING_XEN_EVTCHN 5
  1407. flags:
  1408. - KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI routing entry
  1409. type, specifies that the devid field contains a valid value. The per-VM
  1410. KVM_CAP_MSI_DEVID capability advertises the requirement to provide
  1411. the device ID. If this capability is not available, userspace should
  1412. never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
  1413. - zero otherwise
  1414. ::
  1415. struct kvm_irq_routing_irqchip {
  1416. __u32 irqchip;
  1417. __u32 pin;
  1418. };
  1419. struct kvm_irq_routing_msi {
  1420. __u32 address_lo;
  1421. __u32 address_hi;
  1422. __u32 data;
  1423. union {
  1424. __u32 pad;
  1425. __u32 devid;
  1426. };
  1427. };
  1428. If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
  1429. for the device that wrote the MSI message. For PCI, this is usually a
  1430. BFD identifier in the lower 16 bits.
  1431. On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
  1432. feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
  1433. address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
  1434. address_hi must be zero.
  1435. ::
  1436. struct kvm_irq_routing_s390_adapter {
  1437. __u64 ind_addr;
  1438. __u64 summary_addr;
  1439. __u64 ind_offset;
  1440. __u32 summary_offset;
  1441. __u32 adapter_id;
  1442. };
  1443. struct kvm_irq_routing_hv_sint {
  1444. __u32 vcpu;
  1445. __u32 sint;
  1446. };
  1447. struct kvm_irq_routing_xen_evtchn {
  1448. __u32 port;
  1449. __u32 vcpu;
  1450. __u32 priority;
  1451. };
  1452. When KVM_CAP_XEN_HVM includes the KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL bit
  1453. in its indication of supported features, routing to Xen event channels
  1454. is supported. Although the priority field is present, only the value
  1455. KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL is supported, which means delivery by
  1456. 2 level event channels. FIFO event channel support may be added in
  1457. the future.
  1458. 4.55 KVM_SET_TSC_KHZ
  1459. --------------------
  1460. :Capability: KVM_CAP_TSC_CONTROL / KVM_CAP_VM_TSC_CONTROL
  1461. :Architectures: x86
  1462. :Type: vcpu ioctl / vm ioctl
  1463. :Parameters: virtual tsc_khz
  1464. :Returns: 0 on success, -1 on error
  1465. Specifies the tsc frequency for the virtual machine. The unit of the
  1466. frequency is KHz.
  1467. If the KVM_CAP_VM_TSC_CONTROL capability is advertised, this can also
  1468. be used as a vm ioctl to set the initial tsc frequency of subsequently
  1469. created vCPUs.
  1470. 4.56 KVM_GET_TSC_KHZ
  1471. --------------------
  1472. :Capability: KVM_CAP_GET_TSC_KHZ / KVM_CAP_VM_TSC_CONTROL
  1473. :Architectures: x86
  1474. :Type: vcpu ioctl / vm ioctl
  1475. :Parameters: none
  1476. :Returns: virtual tsc-khz on success, negative value on error
  1477. Returns the tsc frequency of the guest. The unit of the return value is
  1478. KHz. If the host has unstable tsc this ioctl returns -EIO instead as an
  1479. error.
  1480. 4.57 KVM_GET_LAPIC
  1481. ------------------
  1482. :Capability: KVM_CAP_IRQCHIP
  1483. :Architectures: x86
  1484. :Type: vcpu ioctl
  1485. :Parameters: struct kvm_lapic_state (out)
  1486. :Returns: 0 on success, -1 on error
  1487. ::
  1488. #define KVM_APIC_REG_SIZE 0x400
  1489. struct kvm_lapic_state {
  1490. char regs[KVM_APIC_REG_SIZE];
  1491. };
  1492. Reads the Local APIC registers and copies them into the input argument. The
  1493. data format and layout are the same as documented in the architecture manual.
  1494. If KVM_X2APIC_API_USE_32BIT_IDS feature of KVM_CAP_X2APIC_API is
  1495. enabled, then the format of APIC_ID register depends on the APIC mode
  1496. (reported by MSR_IA32_APICBASE) of its VCPU. x2APIC stores APIC ID in
  1497. the APIC_ID register (bytes 32-35). xAPIC only allows an 8-bit APIC ID
  1498. which is stored in bits 31-24 of the APIC register, or equivalently in
  1499. byte 35 of struct kvm_lapic_state's regs field. KVM_GET_LAPIC must then
  1500. be called after MSR_IA32_APICBASE has been set with KVM_SET_MSR.
  1501. If KVM_X2APIC_API_USE_32BIT_IDS feature is disabled, struct kvm_lapic_state
  1502. always uses xAPIC format.
  1503. 4.58 KVM_SET_LAPIC
  1504. ------------------
  1505. :Capability: KVM_CAP_IRQCHIP
  1506. :Architectures: x86
  1507. :Type: vcpu ioctl
  1508. :Parameters: struct kvm_lapic_state (in)
  1509. :Returns: 0 on success, -1 on error
  1510. ::
  1511. #define KVM_APIC_REG_SIZE 0x400
  1512. struct kvm_lapic_state {
  1513. char regs[KVM_APIC_REG_SIZE];
  1514. };
  1515. Copies the input argument into the Local APIC registers. The data format
  1516. and layout are the same as documented in the architecture manual.
  1517. The format of the APIC ID register (bytes 32-35 of struct kvm_lapic_state's
  1518. regs field) depends on the state of the KVM_CAP_X2APIC_API capability.
  1519. See the note in KVM_GET_LAPIC.
  1520. 4.59 KVM_IOEVENTFD
  1521. ------------------
  1522. :Capability: KVM_CAP_IOEVENTFD
  1523. :Architectures: all
  1524. :Type: vm ioctl
  1525. :Parameters: struct kvm_ioeventfd (in)
  1526. :Returns: 0 on success, !0 on error
  1527. This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address
  1528. within the guest. A guest write in the registered address will signal the
  1529. provided event instead of triggering an exit.
  1530. ::
  1531. struct kvm_ioeventfd {
  1532. __u64 datamatch;
  1533. __u64 addr; /* legal pio/mmio address */
  1534. __u32 len; /* 0, 1, 2, 4, or 8 bytes */
  1535. __s32 fd;
  1536. __u32 flags;
  1537. __u8 pad[36];
  1538. };
  1539. For the special case of virtio-ccw devices on s390, the ioevent is matched
  1540. to a subchannel/virtqueue tuple instead.
  1541. The following flags are defined::
  1542. #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
  1543. #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
  1544. #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
  1545. #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \
  1546. (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
  1547. If datamatch flag is set, the event will be signaled only if the written value
  1548. to the registered address is equal to datamatch in struct kvm_ioeventfd.
  1549. For virtio-ccw devices, addr contains the subchannel id and datamatch the
  1550. virtqueue index.
  1551. With KVM_CAP_IOEVENTFD_ANY_LENGTH, a zero length ioeventfd is allowed, and
  1552. the kernel will ignore the length of guest write and may get a faster vmexit.
  1553. The speedup may only apply to specific architectures, but the ioeventfd will
  1554. work anyway.
  1555. 4.60 KVM_DIRTY_TLB
  1556. ------------------
  1557. :Capability: KVM_CAP_SW_TLB
  1558. :Architectures: ppc
  1559. :Type: vcpu ioctl
  1560. :Parameters: struct kvm_dirty_tlb (in)
  1561. :Returns: 0 on success, -1 on error
  1562. ::
  1563. struct kvm_dirty_tlb {
  1564. __u64 bitmap;
  1565. __u32 num_dirty;
  1566. };
  1567. This must be called whenever userspace has changed an entry in the shared
  1568. TLB, prior to calling KVM_RUN on the associated vcpu.
  1569. The "bitmap" field is the userspace address of an array. This array
  1570. consists of a number of bits, equal to the total number of TLB entries as
  1571. determined by the last successful call to KVM_CONFIG_TLB, rounded up to the
  1572. nearest multiple of 64.
  1573. Each bit corresponds to one TLB entry, ordered the same as in the shared TLB
  1574. array.
  1575. The array is little-endian: the bit 0 is the least significant bit of the
  1576. first byte, bit 8 is the least significant bit of the second byte, etc.
  1577. This avoids any complications with differing word sizes.
  1578. The "num_dirty" field is a performance hint for KVM to determine whether it
  1579. should skip processing the bitmap and just invalidate everything. It must
  1580. be set to the number of set bits in the bitmap.
  1581. 4.62 KVM_CREATE_SPAPR_TCE
  1582. -------------------------
  1583. :Capability: KVM_CAP_SPAPR_TCE
  1584. :Architectures: powerpc
  1585. :Type: vm ioctl
  1586. :Parameters: struct kvm_create_spapr_tce (in)
  1587. :Returns: file descriptor for manipulating the created TCE table
  1588. This creates a virtual TCE (translation control entry) table, which
  1589. is an IOMMU for PAPR-style virtual I/O. It is used to translate
  1590. logical addresses used in virtual I/O into guest physical addresses,
  1591. and provides a scatter/gather capability for PAPR virtual I/O.
  1592. ::
  1593. /* for KVM_CAP_SPAPR_TCE */
  1594. struct kvm_create_spapr_tce {
  1595. __u64 liobn;
  1596. __u32 window_size;
  1597. };
  1598. The liobn field gives the logical IO bus number for which to create a
  1599. TCE table. The window_size field specifies the size of the DMA window
  1600. which this TCE table will translate - the table will contain one 64
  1601. bit TCE entry for every 4kiB of the DMA window.
  1602. When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE
  1603. table has been created using this ioctl(), the kernel will handle it
  1604. in real mode, updating the TCE table. H_PUT_TCE calls for other
  1605. liobns will cause a vm exit and must be handled by userspace.
  1606. The return value is a file descriptor which can be passed to mmap(2)
  1607. to map the created TCE table into userspace. This lets userspace read
  1608. the entries written by kernel-handled H_PUT_TCE calls, and also lets
  1609. userspace update the TCE table directly which is useful in some
  1610. circumstances.
  1611. 4.63 KVM_ALLOCATE_RMA
  1612. ---------------------
  1613. :Capability: KVM_CAP_PPC_RMA
  1614. :Architectures: powerpc
  1615. :Type: vm ioctl
  1616. :Parameters: struct kvm_allocate_rma (out)
  1617. :Returns: file descriptor for mapping the allocated RMA
  1618. This allocates a Real Mode Area (RMA) from the pool allocated at boot
  1619. time by the kernel. An RMA is a physically-contiguous, aligned region
  1620. of memory used on older POWER processors to provide the memory which
  1621. will be accessed by real-mode (MMU off) accesses in a KVM guest.
  1622. POWER processors support a set of sizes for the RMA that usually
  1623. includes 64MB, 128MB, 256MB and some larger powers of two.
  1624. ::
  1625. /* for KVM_ALLOCATE_RMA */
  1626. struct kvm_allocate_rma {
  1627. __u64 rma_size;
  1628. };
  1629. The return value is a file descriptor which can be passed to mmap(2)
  1630. to map the allocated RMA into userspace. The mapped area can then be
  1631. passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the
  1632. RMA for a virtual machine. The size of the RMA in bytes (which is
  1633. fixed at host kernel boot time) is returned in the rma_size field of
  1634. the argument structure.
  1635. The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl
  1636. is supported; 2 if the processor requires all virtual machines to have
  1637. an RMA, or 1 if the processor can use an RMA but doesn't require it,
  1638. because it supports the Virtual RMA (VRMA) facility.
  1639. 4.64 KVM_NMI
  1640. ------------
  1641. :Capability: KVM_CAP_USER_NMI
  1642. :Architectures: x86
  1643. :Type: vcpu ioctl
  1644. :Parameters: none
  1645. :Returns: 0 on success, -1 on error
  1646. Queues an NMI on the thread's vcpu. Note this is well defined only
  1647. when KVM_CREATE_IRQCHIP has not been called, since this is an interface
  1648. between the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP
  1649. has been called, this interface is completely emulated within the kernel.
  1650. To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the
  1651. following algorithm:
  1652. - pause the vcpu
  1653. - read the local APIC's state (KVM_GET_LAPIC)
  1654. - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1)
  1655. - if so, issue KVM_NMI
  1656. - resume the vcpu
  1657. Some guests configure the LINT1 NMI input to cause a panic, aiding in
  1658. debugging.
  1659. 4.65 KVM_S390_UCAS_MAP
  1660. ----------------------
  1661. :Capability: KVM_CAP_S390_UCONTROL
  1662. :Architectures: s390
  1663. :Type: vcpu ioctl
  1664. :Parameters: struct kvm_s390_ucas_mapping (in)
  1665. :Returns: 0 in case of success
  1666. The parameter is defined like this::
  1667. struct kvm_s390_ucas_mapping {
  1668. __u64 user_addr;
  1669. __u64 vcpu_addr;
  1670. __u64 length;
  1671. };
  1672. This ioctl maps the memory at "user_addr" with the length "length" to
  1673. the vcpu's address space starting at "vcpu_addr". All parameters need to
  1674. be aligned by 1 megabyte.
  1675. 4.66 KVM_S390_UCAS_UNMAP
  1676. ------------------------
  1677. :Capability: KVM_CAP_S390_UCONTROL
  1678. :Architectures: s390
  1679. :Type: vcpu ioctl
  1680. :Parameters: struct kvm_s390_ucas_mapping (in)
  1681. :Returns: 0 in case of success
  1682. The parameter is defined like this::
  1683. struct kvm_s390_ucas_mapping {
  1684. __u64 user_addr;
  1685. __u64 vcpu_addr;
  1686. __u64 length;
  1687. };
  1688. This ioctl unmaps the memory in the vcpu's address space starting at
  1689. "vcpu_addr" with the length "length". The field "user_addr" is ignored.
  1690. All parameters need to be aligned by 1 megabyte.
  1691. 4.67 KVM_S390_VCPU_FAULT
  1692. ------------------------
  1693. :Capability: KVM_CAP_S390_UCONTROL
  1694. :Architectures: s390
  1695. :Type: vcpu ioctl
  1696. :Parameters: vcpu absolute address (in)
  1697. :Returns: 0 in case of success
  1698. This call creates a page table entry on the virtual cpu's address space
  1699. (for user controlled virtual machines) or the virtual machine's address
  1700. space (for regular virtual machines). This only works for minor faults,
  1701. thus it's recommended to access subject memory page via the user page
  1702. table upfront. This is useful to handle validity intercepts for user
  1703. controlled virtual machines to fault in the virtual cpu's lowcore pages
  1704. prior to calling the KVM_RUN ioctl.
  1705. 4.68 KVM_SET_ONE_REG
  1706. --------------------
  1707. :Capability: KVM_CAP_ONE_REG
  1708. :Architectures: all
  1709. :Type: vcpu ioctl
  1710. :Parameters: struct kvm_one_reg (in)
  1711. :Returns: 0 on success, negative value on failure
  1712. Errors:
  1713. ====== ============================================================
  1714. ENOENT no such register
  1715. EINVAL invalid register ID, or no such register or used with VMs in
  1716. protected virtualization mode on s390
  1717. EPERM (arm64) register access not allowed before vcpu finalization
  1718. ====== ============================================================
  1719. (These error codes are indicative only: do not rely on a specific error
  1720. code being returned in a specific situation.)
  1721. ::
  1722. struct kvm_one_reg {
  1723. __u64 id;
  1724. __u64 addr;
  1725. };
  1726. Using this ioctl, a single vcpu register can be set to a specific value
  1727. defined by user space with the passed in struct kvm_one_reg, where id
  1728. refers to the register identifier as described below and addr is a pointer
  1729. to a variable with the respective size. There can be architecture agnostic
  1730. and architecture specific registers. Each have their own range of operation
  1731. and their own constants and width. To keep track of the implemented
  1732. registers, find a list below:
  1733. ======= =============================== ============
  1734. Arch Register Width (bits)
  1735. ======= =============================== ============
  1736. PPC KVM_REG_PPC_HIOR 64
  1737. PPC KVM_REG_PPC_IAC1 64
  1738. PPC KVM_REG_PPC_IAC2 64
  1739. PPC KVM_REG_PPC_IAC3 64
  1740. PPC KVM_REG_PPC_IAC4 64
  1741. PPC KVM_REG_PPC_DAC1 64
  1742. PPC KVM_REG_PPC_DAC2 64
  1743. PPC KVM_REG_PPC_DABR 64
  1744. PPC KVM_REG_PPC_DSCR 64
  1745. PPC KVM_REG_PPC_PURR 64
  1746. PPC KVM_REG_PPC_SPURR 64
  1747. PPC KVM_REG_PPC_DAR 64
  1748. PPC KVM_REG_PPC_DSISR 32
  1749. PPC KVM_REG_PPC_AMR 64
  1750. PPC KVM_REG_PPC_UAMOR 64
  1751. PPC KVM_REG_PPC_MMCR0 64
  1752. PPC KVM_REG_PPC_MMCR1 64
  1753. PPC KVM_REG_PPC_MMCRA 64
  1754. PPC KVM_REG_PPC_MMCR2 64
  1755. PPC KVM_REG_PPC_MMCRS 64
  1756. PPC KVM_REG_PPC_MMCR3 64
  1757. PPC KVM_REG_PPC_SIAR 64
  1758. PPC KVM_REG_PPC_SDAR 64
  1759. PPC KVM_REG_PPC_SIER 64
  1760. PPC KVM_REG_PPC_SIER2 64
  1761. PPC KVM_REG_PPC_SIER3 64
  1762. PPC KVM_REG_PPC_PMC1 32
  1763. PPC KVM_REG_PPC_PMC2 32
  1764. PPC KVM_REG_PPC_PMC3 32
  1765. PPC KVM_REG_PPC_PMC4 32
  1766. PPC KVM_REG_PPC_PMC5 32
  1767. PPC KVM_REG_PPC_PMC6 32
  1768. PPC KVM_REG_PPC_PMC7 32
  1769. PPC KVM_REG_PPC_PMC8 32
  1770. PPC KVM_REG_PPC_FPR0 64
  1771. ...
  1772. PPC KVM_REG_PPC_FPR31 64
  1773. PPC KVM_REG_PPC_VR0 128
  1774. ...
  1775. PPC KVM_REG_PPC_VR31 128
  1776. PPC KVM_REG_PPC_VSR0 128
  1777. ...
  1778. PPC KVM_REG_PPC_VSR31 128
  1779. PPC KVM_REG_PPC_FPSCR 64
  1780. PPC KVM_REG_PPC_VSCR 32
  1781. PPC KVM_REG_PPC_VPA_ADDR 64
  1782. PPC KVM_REG_PPC_VPA_SLB 128
  1783. PPC KVM_REG_PPC_VPA_DTL 128
  1784. PPC KVM_REG_PPC_EPCR 32
  1785. PPC KVM_REG_PPC_EPR 32
  1786. PPC KVM_REG_PPC_TCR 32
  1787. PPC KVM_REG_PPC_TSR 32
  1788. PPC KVM_REG_PPC_OR_TSR 32
  1789. PPC KVM_REG_PPC_CLEAR_TSR 32
  1790. PPC KVM_REG_PPC_MAS0 32
  1791. PPC KVM_REG_PPC_MAS1 32
  1792. PPC KVM_REG_PPC_MAS2 64
  1793. PPC KVM_REG_PPC_MAS7_3 64
  1794. PPC KVM_REG_PPC_MAS4 32
  1795. PPC KVM_REG_PPC_MAS6 32
  1796. PPC KVM_REG_PPC_MMUCFG 32
  1797. PPC KVM_REG_PPC_TLB0CFG 32
  1798. PPC KVM_REG_PPC_TLB1CFG 32
  1799. PPC KVM_REG_PPC_TLB2CFG 32
  1800. PPC KVM_REG_PPC_TLB3CFG 32
  1801. PPC KVM_REG_PPC_TLB0PS 32
  1802. PPC KVM_REG_PPC_TLB1PS 32
  1803. PPC KVM_REG_PPC_TLB2PS 32
  1804. PPC KVM_REG_PPC_TLB3PS 32
  1805. PPC KVM_REG_PPC_EPTCFG 32
  1806. PPC KVM_REG_PPC_ICP_STATE 64
  1807. PPC KVM_REG_PPC_VP_STATE 128
  1808. PPC KVM_REG_PPC_TB_OFFSET 64
  1809. PPC KVM_REG_PPC_SPMC1 32
  1810. PPC KVM_REG_PPC_SPMC2 32
  1811. PPC KVM_REG_PPC_IAMR 64
  1812. PPC KVM_REG_PPC_TFHAR 64
  1813. PPC KVM_REG_PPC_TFIAR 64
  1814. PPC KVM_REG_PPC_TEXASR 64
  1815. PPC KVM_REG_PPC_FSCR 64
  1816. PPC KVM_REG_PPC_PSPB 32
  1817. PPC KVM_REG_PPC_EBBHR 64
  1818. PPC KVM_REG_PPC_EBBRR 64
  1819. PPC KVM_REG_PPC_BESCR 64
  1820. PPC KVM_REG_PPC_TAR 64
  1821. PPC KVM_REG_PPC_DPDES 64
  1822. PPC KVM_REG_PPC_DAWR 64
  1823. PPC KVM_REG_PPC_DAWRX 64
  1824. PPC KVM_REG_PPC_CIABR 64
  1825. PPC KVM_REG_PPC_IC 64
  1826. PPC KVM_REG_PPC_VTB 64
  1827. PPC KVM_REG_PPC_CSIGR 64
  1828. PPC KVM_REG_PPC_TACR 64
  1829. PPC KVM_REG_PPC_TCSCR 64
  1830. PPC KVM_REG_PPC_PID 64
  1831. PPC KVM_REG_PPC_ACOP 64
  1832. PPC KVM_REG_PPC_VRSAVE 32
  1833. PPC KVM_REG_PPC_LPCR 32
  1834. PPC KVM_REG_PPC_LPCR_64 64
  1835. PPC KVM_REG_PPC_PPR 64
  1836. PPC KVM_REG_PPC_ARCH_COMPAT 32
  1837. PPC KVM_REG_PPC_DABRX 32
  1838. PPC KVM_REG_PPC_WORT 64
  1839. PPC KVM_REG_PPC_SPRG9 64
  1840. PPC KVM_REG_PPC_DBSR 32
  1841. PPC KVM_REG_PPC_TIDR 64
  1842. PPC KVM_REG_PPC_PSSCR 64
  1843. PPC KVM_REG_PPC_DEC_EXPIRY 64
  1844. PPC KVM_REG_PPC_PTCR 64
  1845. PPC KVM_REG_PPC_DAWR1 64
  1846. PPC KVM_REG_PPC_DAWRX1 64
  1847. PPC KVM_REG_PPC_TM_GPR0 64
  1848. ...
  1849. PPC KVM_REG_PPC_TM_GPR31 64
  1850. PPC KVM_REG_PPC_TM_VSR0 128
  1851. ...
  1852. PPC KVM_REG_PPC_TM_VSR63 128
  1853. PPC KVM_REG_PPC_TM_CR 64
  1854. PPC KVM_REG_PPC_TM_LR 64
  1855. PPC KVM_REG_PPC_TM_CTR 64
  1856. PPC KVM_REG_PPC_TM_FPSCR 64
  1857. PPC KVM_REG_PPC_TM_AMR 64
  1858. PPC KVM_REG_PPC_TM_PPR 64
  1859. PPC KVM_REG_PPC_TM_VRSAVE 64
  1860. PPC KVM_REG_PPC_TM_VSCR 32
  1861. PPC KVM_REG_PPC_TM_DSCR 64
  1862. PPC KVM_REG_PPC_TM_TAR 64
  1863. PPC KVM_REG_PPC_TM_XER 64
  1864. MIPS KVM_REG_MIPS_R0 64
  1865. ...
  1866. MIPS KVM_REG_MIPS_R31 64
  1867. MIPS KVM_REG_MIPS_HI 64
  1868. MIPS KVM_REG_MIPS_LO 64
  1869. MIPS KVM_REG_MIPS_PC 64
  1870. MIPS KVM_REG_MIPS_CP0_INDEX 32
  1871. MIPS KVM_REG_MIPS_CP0_ENTRYLO0 64
  1872. MIPS KVM_REG_MIPS_CP0_ENTRYLO1 64
  1873. MIPS KVM_REG_MIPS_CP0_CONTEXT 64
  1874. MIPS KVM_REG_MIPS_CP0_CONTEXTCONFIG 32
  1875. MIPS KVM_REG_MIPS_CP0_USERLOCAL 64
  1876. MIPS KVM_REG_MIPS_CP0_XCONTEXTCONFIG 64
  1877. MIPS KVM_REG_MIPS_CP0_PAGEMASK 32
  1878. MIPS KVM_REG_MIPS_CP0_PAGEGRAIN 32
  1879. MIPS KVM_REG_MIPS_CP0_SEGCTL0 64
  1880. MIPS KVM_REG_MIPS_CP0_SEGCTL1 64
  1881. MIPS KVM_REG_MIPS_CP0_SEGCTL2 64
  1882. MIPS KVM_REG_MIPS_CP0_PWBASE 64
  1883. MIPS KVM_REG_MIPS_CP0_PWFIELD 64
  1884. MIPS KVM_REG_MIPS_CP0_PWSIZE 64
  1885. MIPS KVM_REG_MIPS_CP0_WIRED 32
  1886. MIPS KVM_REG_MIPS_CP0_PWCTL 32
  1887. MIPS KVM_REG_MIPS_CP0_HWRENA 32
  1888. MIPS KVM_REG_MIPS_CP0_BADVADDR 64
  1889. MIPS KVM_REG_MIPS_CP0_BADINSTR 32
  1890. MIPS KVM_REG_MIPS_CP0_BADINSTRP 32
  1891. MIPS KVM_REG_MIPS_CP0_COUNT 32
  1892. MIPS KVM_REG_MIPS_CP0_ENTRYHI 64
  1893. MIPS KVM_REG_MIPS_CP0_COMPARE 32
  1894. MIPS KVM_REG_MIPS_CP0_STATUS 32
  1895. MIPS KVM_REG_MIPS_CP0_INTCTL 32
  1896. MIPS KVM_REG_MIPS_CP0_CAUSE 32
  1897. MIPS KVM_REG_MIPS_CP0_EPC 64
  1898. MIPS KVM_REG_MIPS_CP0_PRID 32
  1899. MIPS KVM_REG_MIPS_CP0_EBASE 64
  1900. MIPS KVM_REG_MIPS_CP0_CONFIG 32
  1901. MIPS KVM_REG_MIPS_CP0_CONFIG1 32
  1902. MIPS KVM_REG_MIPS_CP0_CONFIG2 32
  1903. MIPS KVM_REG_MIPS_CP0_CONFIG3 32
  1904. MIPS KVM_REG_MIPS_CP0_CONFIG4 32
  1905. MIPS KVM_REG_MIPS_CP0_CONFIG5 32
  1906. MIPS KVM_REG_MIPS_CP0_CONFIG7 32
  1907. MIPS KVM_REG_MIPS_CP0_XCONTEXT 64
  1908. MIPS KVM_REG_MIPS_CP0_ERROREPC 64
  1909. MIPS KVM_REG_MIPS_CP0_KSCRATCH1 64
  1910. MIPS KVM_REG_MIPS_CP0_KSCRATCH2 64
  1911. MIPS KVM_REG_MIPS_CP0_KSCRATCH3 64
  1912. MIPS KVM_REG_MIPS_CP0_KSCRATCH4 64
  1913. MIPS KVM_REG_MIPS_CP0_KSCRATCH5 64
  1914. MIPS KVM_REG_MIPS_CP0_KSCRATCH6 64
  1915. MIPS KVM_REG_MIPS_CP0_MAAR(0..63) 64
  1916. MIPS KVM_REG_MIPS_COUNT_CTL 64
  1917. MIPS KVM_REG_MIPS_COUNT_RESUME 64
  1918. MIPS KVM_REG_MIPS_COUNT_HZ 64
  1919. MIPS KVM_REG_MIPS_FPR_32(0..31) 32
  1920. MIPS KVM_REG_MIPS_FPR_64(0..31) 64
  1921. MIPS KVM_REG_MIPS_VEC_128(0..31) 128
  1922. MIPS KVM_REG_MIPS_FCR_IR 32
  1923. MIPS KVM_REG_MIPS_FCR_CSR 32
  1924. MIPS KVM_REG_MIPS_MSA_IR 32
  1925. MIPS KVM_REG_MIPS_MSA_CSR 32
  1926. ======= =============================== ============
  1927. ARM registers are mapped using the lower 32 bits. The upper 16 of that
  1928. is the register group type, or coprocessor number:
  1929. ARM core registers have the following id bit patterns::
  1930. 0x4020 0000 0010 <index into the kvm_regs struct:16>
  1931. ARM 32-bit CP15 registers have the following id bit patterns::
  1932. 0x4020 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3>
  1933. ARM 64-bit CP15 registers have the following id bit patterns::
  1934. 0x4030 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3>
  1935. ARM CCSIDR registers are demultiplexed by CSSELR value::
  1936. 0x4020 0000 0011 00 <csselr:8>
  1937. ARM 32-bit VFP control registers have the following id bit patterns::
  1938. 0x4020 0000 0012 1 <regno:12>
  1939. ARM 64-bit FP registers have the following id bit patterns::
  1940. 0x4030 0000 0012 0 <regno:12>
  1941. ARM firmware pseudo-registers have the following bit pattern::
  1942. 0x4030 0000 0014 <regno:16>
  1943. arm64 registers are mapped using the lower 32 bits. The upper 16 of
  1944. that is the register group type, or coprocessor number:
  1945. arm64 core/FP-SIMD registers have the following id bit patterns. Note
  1946. that the size of the access is variable, as the kvm_regs structure
  1947. contains elements ranging from 32 to 128 bits. The index is a 32bit
  1948. value in the kvm_regs structure seen as a 32bit array::
  1949. 0x60x0 0000 0010 <index into the kvm_regs struct:16>
  1950. Specifically:
  1951. ======================= ========= ===== =======================================
  1952. Encoding Register Bits kvm_regs member
  1953. ======================= ========= ===== =======================================
  1954. 0x6030 0000 0010 0000 X0 64 regs.regs[0]
  1955. 0x6030 0000 0010 0002 X1 64 regs.regs[1]
  1956. ...
  1957. 0x6030 0000 0010 003c X30 64 regs.regs[30]
  1958. 0x6030 0000 0010 003e SP 64 regs.sp
  1959. 0x6030 0000 0010 0040 PC 64 regs.pc
  1960. 0x6030 0000 0010 0042 PSTATE 64 regs.pstate
  1961. 0x6030 0000 0010 0044 SP_EL1 64 sp_el1
  1962. 0x6030 0000 0010 0046 ELR_EL1 64 elr_el1
  1963. 0x6030 0000 0010 0048 SPSR_EL1 64 spsr[KVM_SPSR_EL1] (alias SPSR_SVC)
  1964. 0x6030 0000 0010 004a SPSR_ABT 64 spsr[KVM_SPSR_ABT]
  1965. 0x6030 0000 0010 004c SPSR_UND 64 spsr[KVM_SPSR_UND]
  1966. 0x6030 0000 0010 004e SPSR_IRQ 64 spsr[KVM_SPSR_IRQ]
  1967. 0x6060 0000 0010 0050 SPSR_FIQ 64 spsr[KVM_SPSR_FIQ]
  1968. 0x6040 0000 0010 0054 V0 128 fp_regs.vregs[0] [1]_
  1969. 0x6040 0000 0010 0058 V1 128 fp_regs.vregs[1] [1]_
  1970. ...
  1971. 0x6040 0000 0010 00d0 V31 128 fp_regs.vregs[31] [1]_
  1972. 0x6020 0000 0010 00d4 FPSR 32 fp_regs.fpsr
  1973. 0x6020 0000 0010 00d5 FPCR 32 fp_regs.fpcr
  1974. ======================= ========= ===== =======================================
  1975. .. [1] These encodings are not accepted for SVE-enabled vcpus. See
  1976. KVM_ARM_VCPU_INIT.
  1977. The equivalent register content can be accessed via bits [127:0] of
  1978. the corresponding SVE Zn registers instead for vcpus that have SVE
  1979. enabled (see below).
  1980. arm64 CCSIDR registers are demultiplexed by CSSELR value::
  1981. 0x6020 0000 0011 00 <csselr:8>
  1982. arm64 system registers have the following id bit patterns::
  1983. 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3>
  1984. .. warning::
  1985. Two system register IDs do not follow the specified pattern. These
  1986. are KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT, which map to
  1987. system registers CNTV_CVAL_EL0 and CNTVCT_EL0 respectively. These
  1988. two had their values accidentally swapped, which means TIMER_CVAL is
  1989. derived from the register encoding for CNTVCT_EL0 and TIMER_CNT is
  1990. derived from the register encoding for CNTV_CVAL_EL0. As this is
  1991. API, it must remain this way.
  1992. arm64 firmware pseudo-registers have the following bit pattern::
  1993. 0x6030 0000 0014 <regno:16>
  1994. arm64 SVE registers have the following bit patterns::
  1995. 0x6080 0000 0015 00 <n:5> <slice:5> Zn bits[2048*slice + 2047 : 2048*slice]
  1996. 0x6050 0000 0015 04 <n:4> <slice:5> Pn bits[256*slice + 255 : 256*slice]
  1997. 0x6050 0000 0015 060 <slice:5> FFR bits[256*slice + 255 : 256*slice]
  1998. 0x6060 0000 0015 ffff KVM_REG_ARM64_SVE_VLS pseudo-register
  1999. Access to register IDs where 2048 * slice >= 128 * max_vq will fail with
  2000. ENOENT. max_vq is the vcpu's maximum supported vector length in 128-bit
  2001. quadwords: see [2]_ below.
  2002. These registers are only accessible on vcpus for which SVE is enabled.
  2003. See KVM_ARM_VCPU_INIT for details.
  2004. In addition, except for KVM_REG_ARM64_SVE_VLS, these registers are not
  2005. accessible until the vcpu's SVE configuration has been finalized
  2006. using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE). See KVM_ARM_VCPU_INIT
  2007. and KVM_ARM_VCPU_FINALIZE for more information about this procedure.
  2008. KVM_REG_ARM64_SVE_VLS is a pseudo-register that allows the set of vector
  2009. lengths supported by the vcpu to be discovered and configured by
  2010. userspace. When transferred to or from user memory via KVM_GET_ONE_REG
  2011. or KVM_SET_ONE_REG, the value of this register is of type
  2012. __u64[KVM_ARM64_SVE_VLS_WORDS], and encodes the set of vector lengths as
  2013. follows::
  2014. __u64 vector_lengths[KVM_ARM64_SVE_VLS_WORDS];
  2015. if (vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX &&
  2016. ((vector_lengths[(vq - KVM_ARM64_SVE_VQ_MIN) / 64] >>
  2017. ((vq - KVM_ARM64_SVE_VQ_MIN) % 64)) & 1))
  2018. /* Vector length vq * 16 bytes supported */
  2019. else
  2020. /* Vector length vq * 16 bytes not supported */
  2021. .. [2] The maximum value vq for which the above condition is true is
  2022. max_vq. This is the maximum vector length available to the guest on
  2023. this vcpu, and determines which register slices are visible through
  2024. this ioctl interface.
  2025. (See Documentation/arm64/sve.rst for an explanation of the "vq"
  2026. nomenclature.)
  2027. KVM_REG_ARM64_SVE_VLS is only accessible after KVM_ARM_VCPU_INIT.
  2028. KVM_ARM_VCPU_INIT initialises it to the best set of vector lengths that
  2029. the host supports.
  2030. Userspace may subsequently modify it if desired until the vcpu's SVE
  2031. configuration is finalized using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE).
  2032. Apart from simply removing all vector lengths from the host set that
  2033. exceed some value, support for arbitrarily chosen sets of vector lengths
  2034. is hardware-dependent and may not be available. Attempting to configure
  2035. an invalid set of vector lengths via KVM_SET_ONE_REG will fail with
  2036. EINVAL.
  2037. After the vcpu's SVE configuration is finalized, further attempts to
  2038. write this register will fail with EPERM.
  2039. arm64 bitmap feature firmware pseudo-registers have the following bit pattern::
  2040. 0x6030 0000 0016 <regno:16>
  2041. The bitmap feature firmware registers exposes the hypercall services that
  2042. are available for userspace to configure. The set bits corresponds to the
  2043. services that are available for the guests to access. By default, KVM
  2044. sets all the supported bits during VM initialization. The userspace can
  2045. discover the available services via KVM_GET_ONE_REG, and write back the
  2046. bitmap corresponding to the features that it wishes guests to see via
  2047. KVM_SET_ONE_REG.
  2048. Note: These registers are immutable once any of the vCPUs of the VM has
  2049. run at least once. A KVM_SET_ONE_REG in such a scenario will return
  2050. a -EBUSY to userspace.
  2051. (See Documentation/virt/kvm/arm/hypercalls.rst for more details.)
  2052. MIPS registers are mapped using the lower 32 bits. The upper 16 of that is
  2053. the register group type:
  2054. MIPS core registers (see above) have the following id bit patterns::
  2055. 0x7030 0000 0000 <reg:16>
  2056. MIPS CP0 registers (see KVM_REG_MIPS_CP0_* above) have the following id bit
  2057. patterns depending on whether they're 32-bit or 64-bit registers::
  2058. 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit)
  2059. 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit)
  2060. Note: KVM_REG_MIPS_CP0_ENTRYLO0 and KVM_REG_MIPS_CP0_ENTRYLO1 are the MIPS64
  2061. versions of the EntryLo registers regardless of the word size of the host
  2062. hardware, host kernel, guest, and whether XPA is present in the guest, i.e.
  2063. with the RI and XI bits (if they exist) in bits 63 and 62 respectively, and
  2064. the PFNX field starting at bit 30.
  2065. MIPS MAARs (see KVM_REG_MIPS_CP0_MAAR(*) above) have the following id bit
  2066. patterns::
  2067. 0x7030 0000 0001 01 <reg:8>
  2068. MIPS KVM control registers (see above) have the following id bit patterns::
  2069. 0x7030 0000 0002 <reg:16>
  2070. MIPS FPU registers (see KVM_REG_MIPS_FPR_{32,64}() above) have the following
  2071. id bit patterns depending on the size of the register being accessed. They are
  2072. always accessed according to the current guest FPU mode (Status.FR and
  2073. Config5.FRE), i.e. as the guest would see them, and they become unpredictable
  2074. if the guest FPU mode is changed. MIPS SIMD Architecture (MSA) vector
  2075. registers (see KVM_REG_MIPS_VEC_128() above) have similar patterns as they
  2076. overlap the FPU registers::
  2077. 0x7020 0000 0003 00 <0:3> <reg:5> (32-bit FPU registers)
  2078. 0x7030 0000 0003 00 <0:3> <reg:5> (64-bit FPU registers)
  2079. 0x7040 0000 0003 00 <0:3> <reg:5> (128-bit MSA vector registers)
  2080. MIPS FPU control registers (see KVM_REG_MIPS_FCR_{IR,CSR} above) have the
  2081. following id bit patterns::
  2082. 0x7020 0000 0003 01 <0:3> <reg:5>
  2083. MIPS MSA control registers (see KVM_REG_MIPS_MSA_{IR,CSR} above) have the
  2084. following id bit patterns::
  2085. 0x7020 0000 0003 02 <0:3> <reg:5>
  2086. RISC-V registers are mapped using the lower 32 bits. The upper 8 bits of
  2087. that is the register group type.
  2088. RISC-V config registers are meant for configuring a Guest VCPU and it has
  2089. the following id bit patterns::
  2090. 0x8020 0000 01 <index into the kvm_riscv_config struct:24> (32bit Host)
  2091. 0x8030 0000 01 <index into the kvm_riscv_config struct:24> (64bit Host)
  2092. Following are the RISC-V config registers:
  2093. ======================= ========= =============================================
  2094. Encoding Register Description
  2095. ======================= ========= =============================================
  2096. 0x80x0 0000 0100 0000 isa ISA feature bitmap of Guest VCPU
  2097. ======================= ========= =============================================
  2098. The isa config register can be read anytime but can only be written before
  2099. a Guest VCPU runs. It will have ISA feature bits matching underlying host
  2100. set by default.
  2101. RISC-V core registers represent the general excution state of a Guest VCPU
  2102. and it has the following id bit patterns::
  2103. 0x8020 0000 02 <index into the kvm_riscv_core struct:24> (32bit Host)
  2104. 0x8030 0000 02 <index into the kvm_riscv_core struct:24> (64bit Host)
  2105. Following are the RISC-V core registers:
  2106. ======================= ========= =============================================
  2107. Encoding Register Description
  2108. ======================= ========= =============================================
  2109. 0x80x0 0000 0200 0000 regs.pc Program counter
  2110. 0x80x0 0000 0200 0001 regs.ra Return address
  2111. 0x80x0 0000 0200 0002 regs.sp Stack pointer
  2112. 0x80x0 0000 0200 0003 regs.gp Global pointer
  2113. 0x80x0 0000 0200 0004 regs.tp Task pointer
  2114. 0x80x0 0000 0200 0005 regs.t0 Caller saved register 0
  2115. 0x80x0 0000 0200 0006 regs.t1 Caller saved register 1
  2116. 0x80x0 0000 0200 0007 regs.t2 Caller saved register 2
  2117. 0x80x0 0000 0200 0008 regs.s0 Callee saved register 0
  2118. 0x80x0 0000 0200 0009 regs.s1 Callee saved register 1
  2119. 0x80x0 0000 0200 000a regs.a0 Function argument (or return value) 0
  2120. 0x80x0 0000 0200 000b regs.a1 Function argument (or return value) 1
  2121. 0x80x0 0000 0200 000c regs.a2 Function argument 2
  2122. 0x80x0 0000 0200 000d regs.a3 Function argument 3
  2123. 0x80x0 0000 0200 000e regs.a4 Function argument 4
  2124. 0x80x0 0000 0200 000f regs.a5 Function argument 5
  2125. 0x80x0 0000 0200 0010 regs.a6 Function argument 6
  2126. 0x80x0 0000 0200 0011 regs.a7 Function argument 7
  2127. 0x80x0 0000 0200 0012 regs.s2 Callee saved register 2
  2128. 0x80x0 0000 0200 0013 regs.s3 Callee saved register 3
  2129. 0x80x0 0000 0200 0014 regs.s4 Callee saved register 4
  2130. 0x80x0 0000 0200 0015 regs.s5 Callee saved register 5
  2131. 0x80x0 0000 0200 0016 regs.s6 Callee saved register 6
  2132. 0x80x0 0000 0200 0017 regs.s7 Callee saved register 7
  2133. 0x80x0 0000 0200 0018 regs.s8 Callee saved register 8
  2134. 0x80x0 0000 0200 0019 regs.s9 Callee saved register 9
  2135. 0x80x0 0000 0200 001a regs.s10 Callee saved register 10
  2136. 0x80x0 0000 0200 001b regs.s11 Callee saved register 11
  2137. 0x80x0 0000 0200 001c regs.t3 Caller saved register 3
  2138. 0x80x0 0000 0200 001d regs.t4 Caller saved register 4
  2139. 0x80x0 0000 0200 001e regs.t5 Caller saved register 5
  2140. 0x80x0 0000 0200 001f regs.t6 Caller saved register 6
  2141. 0x80x0 0000 0200 0020 mode Privilege mode (1 = S-mode or 0 = U-mode)
  2142. ======================= ========= =============================================
  2143. RISC-V csr registers represent the supervisor mode control/status registers
  2144. of a Guest VCPU and it has the following id bit patterns::
  2145. 0x8020 0000 03 <index into the kvm_riscv_csr struct:24> (32bit Host)
  2146. 0x8030 0000 03 <index into the kvm_riscv_csr struct:24> (64bit Host)
  2147. Following are the RISC-V csr registers:
  2148. ======================= ========= =============================================
  2149. Encoding Register Description
  2150. ======================= ========= =============================================
  2151. 0x80x0 0000 0300 0000 sstatus Supervisor status
  2152. 0x80x0 0000 0300 0001 sie Supervisor interrupt enable
  2153. 0x80x0 0000 0300 0002 stvec Supervisor trap vector base
  2154. 0x80x0 0000 0300 0003 sscratch Supervisor scratch register
  2155. 0x80x0 0000 0300 0004 sepc Supervisor exception program counter
  2156. 0x80x0 0000 0300 0005 scause Supervisor trap cause
  2157. 0x80x0 0000 0300 0006 stval Supervisor bad address or instruction
  2158. 0x80x0 0000 0300 0007 sip Supervisor interrupt pending
  2159. 0x80x0 0000 0300 0008 satp Supervisor address translation and protection
  2160. ======================= ========= =============================================
  2161. RISC-V timer registers represent the timer state of a Guest VCPU and it has
  2162. the following id bit patterns::
  2163. 0x8030 0000 04 <index into the kvm_riscv_timer struct:24>
  2164. Following are the RISC-V timer registers:
  2165. ======================= ========= =============================================
  2166. Encoding Register Description
  2167. ======================= ========= =============================================
  2168. 0x8030 0000 0400 0000 frequency Time base frequency (read-only)
  2169. 0x8030 0000 0400 0001 time Time value visible to Guest
  2170. 0x8030 0000 0400 0002 compare Time compare programmed by Guest
  2171. 0x8030 0000 0400 0003 state Time compare state (1 = ON or 0 = OFF)
  2172. ======================= ========= =============================================
  2173. RISC-V F-extension registers represent the single precision floating point
  2174. state of a Guest VCPU and it has the following id bit patterns::
  2175. 0x8020 0000 05 <index into the __riscv_f_ext_state struct:24>
  2176. Following are the RISC-V F-extension registers:
  2177. ======================= ========= =============================================
  2178. Encoding Register Description
  2179. ======================= ========= =============================================
  2180. 0x8020 0000 0500 0000 f[0] Floating point register 0
  2181. ...
  2182. 0x8020 0000 0500 001f f[31] Floating point register 31
  2183. 0x8020 0000 0500 0020 fcsr Floating point control and status register
  2184. ======================= ========= =============================================
  2185. RISC-V D-extension registers represent the double precision floating point
  2186. state of a Guest VCPU and it has the following id bit patterns::
  2187. 0x8020 0000 06 <index into the __riscv_d_ext_state struct:24> (fcsr)
  2188. 0x8030 0000 06 <index into the __riscv_d_ext_state struct:24> (non-fcsr)
  2189. Following are the RISC-V D-extension registers:
  2190. ======================= ========= =============================================
  2191. Encoding Register Description
  2192. ======================= ========= =============================================
  2193. 0x8030 0000 0600 0000 f[0] Floating point register 0
  2194. ...
  2195. 0x8030 0000 0600 001f f[31] Floating point register 31
  2196. 0x8020 0000 0600 0020 fcsr Floating point control and status register
  2197. ======================= ========= =============================================
  2198. 4.69 KVM_GET_ONE_REG
  2199. --------------------
  2200. :Capability: KVM_CAP_ONE_REG
  2201. :Architectures: all
  2202. :Type: vcpu ioctl
  2203. :Parameters: struct kvm_one_reg (in and out)
  2204. :Returns: 0 on success, negative value on failure
  2205. Errors include:
  2206. ======== ============================================================
  2207. ENOENT no such register
  2208. EINVAL invalid register ID, or no such register or used with VMs in
  2209. protected virtualization mode on s390
  2210. EPERM (arm64) register access not allowed before vcpu finalization
  2211. ======== ============================================================
  2212. (These error codes are indicative only: do not rely on a specific error
  2213. code being returned in a specific situation.)
  2214. This ioctl allows to receive the value of a single register implemented
  2215. in a vcpu. The register to read is indicated by the "id" field of the
  2216. kvm_one_reg struct passed in. On success, the register value can be found
  2217. at the memory location pointed to by "addr".
  2218. The list of registers accessible using this interface is identical to the
  2219. list in 4.68.
  2220. 4.70 KVM_KVMCLOCK_CTRL
  2221. ----------------------
  2222. :Capability: KVM_CAP_KVMCLOCK_CTRL
  2223. :Architectures: Any that implement pvclocks (currently x86 only)
  2224. :Type: vcpu ioctl
  2225. :Parameters: None
  2226. :Returns: 0 on success, -1 on error
  2227. This ioctl sets a flag accessible to the guest indicating that the specified
  2228. vCPU has been paused by the host userspace.
  2229. The host will set a flag in the pvclock structure that is checked from the
  2230. soft lockup watchdog. The flag is part of the pvclock structure that is
  2231. shared between guest and host, specifically the second bit of the flags
  2232. field of the pvclock_vcpu_time_info structure. It will be set exclusively by
  2233. the host and read/cleared exclusively by the guest. The guest operation of
  2234. checking and clearing the flag must be an atomic operation so
  2235. load-link/store-conditional, or equivalent must be used. There are two cases
  2236. where the guest will clear the flag: when the soft lockup watchdog timer resets
  2237. itself or when a soft lockup is detected. This ioctl can be called any time
  2238. after pausing the vcpu, but before it is resumed.
  2239. 4.71 KVM_SIGNAL_MSI
  2240. -------------------
  2241. :Capability: KVM_CAP_SIGNAL_MSI
  2242. :Architectures: x86 arm64
  2243. :Type: vm ioctl
  2244. :Parameters: struct kvm_msi (in)
  2245. :Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error
  2246. Directly inject a MSI message. Only valid with in-kernel irqchip that handles
  2247. MSI messages.
  2248. ::
  2249. struct kvm_msi {
  2250. __u32 address_lo;
  2251. __u32 address_hi;
  2252. __u32 data;
  2253. __u32 flags;
  2254. __u32 devid;
  2255. __u8 pad[12];
  2256. };
  2257. flags:
  2258. KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM
  2259. KVM_CAP_MSI_DEVID capability advertises the requirement to provide
  2260. the device ID. If this capability is not available, userspace
  2261. should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
  2262. If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
  2263. for the device that wrote the MSI message. For PCI, this is usually a
  2264. BFD identifier in the lower 16 bits.
  2265. On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
  2266. feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
  2267. address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
  2268. address_hi must be zero.
  2269. 4.71 KVM_CREATE_PIT2
  2270. --------------------
  2271. :Capability: KVM_CAP_PIT2
  2272. :Architectures: x86
  2273. :Type: vm ioctl
  2274. :Parameters: struct kvm_pit_config (in)
  2275. :Returns: 0 on success, -1 on error
  2276. Creates an in-kernel device model for the i8254 PIT. This call is only valid
  2277. after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following
  2278. parameters have to be passed::
  2279. struct kvm_pit_config {
  2280. __u32 flags;
  2281. __u32 pad[15];
  2282. };
  2283. Valid flags are::
  2284. #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */
  2285. PIT timer interrupts may use a per-VM kernel thread for injection. If it
  2286. exists, this thread will have a name of the following pattern::
  2287. kvm-pit/<owner-process-pid>
  2288. When running a guest with elevated priorities, the scheduling parameters of
  2289. this thread may have to be adjusted accordingly.
  2290. This IOCTL replaces the obsolete KVM_CREATE_PIT.
  2291. 4.72 KVM_GET_PIT2
  2292. -----------------
  2293. :Capability: KVM_CAP_PIT_STATE2
  2294. :Architectures: x86
  2295. :Type: vm ioctl
  2296. :Parameters: struct kvm_pit_state2 (out)
  2297. :Returns: 0 on success, -1 on error
  2298. Retrieves the state of the in-kernel PIT model. Only valid after
  2299. KVM_CREATE_PIT2. The state is returned in the following structure::
  2300. struct kvm_pit_state2 {
  2301. struct kvm_pit_channel_state channels[3];
  2302. __u32 flags;
  2303. __u32 reserved[9];
  2304. };
  2305. Valid flags are::
  2306. /* disable PIT in HPET legacy mode */
  2307. #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
  2308. /* speaker port data bit enabled */
  2309. #define KVM_PIT_FLAGS_SPEAKER_DATA_ON 0x00000002
  2310. This IOCTL replaces the obsolete KVM_GET_PIT.
  2311. 4.73 KVM_SET_PIT2
  2312. -----------------
  2313. :Capability: KVM_CAP_PIT_STATE2
  2314. :Architectures: x86
  2315. :Type: vm ioctl
  2316. :Parameters: struct kvm_pit_state2 (in)
  2317. :Returns: 0 on success, -1 on error
  2318. Sets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2.
  2319. See KVM_GET_PIT2 for details on struct kvm_pit_state2.
  2320. This IOCTL replaces the obsolete KVM_SET_PIT.
  2321. 4.74 KVM_PPC_GET_SMMU_INFO
  2322. --------------------------
  2323. :Capability: KVM_CAP_PPC_GET_SMMU_INFO
  2324. :Architectures: powerpc
  2325. :Type: vm ioctl
  2326. :Parameters: None
  2327. :Returns: 0 on success, -1 on error
  2328. This populates and returns a structure describing the features of
  2329. the "Server" class MMU emulation supported by KVM.
  2330. This can in turn be used by userspace to generate the appropriate
  2331. device-tree properties for the guest operating system.
  2332. The structure contains some global information, followed by an
  2333. array of supported segment page sizes::
  2334. struct kvm_ppc_smmu_info {
  2335. __u64 flags;
  2336. __u32 slb_size;
  2337. __u32 pad;
  2338. struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
  2339. };
  2340. The supported flags are:
  2341. - KVM_PPC_PAGE_SIZES_REAL:
  2342. When that flag is set, guest page sizes must "fit" the backing
  2343. store page sizes. When not set, any page size in the list can
  2344. be used regardless of how they are backed by userspace.
  2345. - KVM_PPC_1T_SEGMENTS
  2346. The emulated MMU supports 1T segments in addition to the
  2347. standard 256M ones.
  2348. - KVM_PPC_NO_HASH
  2349. This flag indicates that HPT guests are not supported by KVM,
  2350. thus all guests must use radix MMU mode.
  2351. The "slb_size" field indicates how many SLB entries are supported
  2352. The "sps" array contains 8 entries indicating the supported base
  2353. page sizes for a segment in increasing order. Each entry is defined
  2354. as follow::
  2355. struct kvm_ppc_one_seg_page_size {
  2356. __u32 page_shift; /* Base page shift of segment (or 0) */
  2357. __u32 slb_enc; /* SLB encoding for BookS */
  2358. struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
  2359. };
  2360. An entry with a "page_shift" of 0 is unused. Because the array is
  2361. organized in increasing order, a lookup can stop when encoutering
  2362. such an entry.
  2363. The "slb_enc" field provides the encoding to use in the SLB for the
  2364. page size. The bits are in positions such as the value can directly
  2365. be OR'ed into the "vsid" argument of the slbmte instruction.
  2366. The "enc" array is a list which for each of those segment base page
  2367. size provides the list of supported actual page sizes (which can be
  2368. only larger or equal to the base page size), along with the
  2369. corresponding encoding in the hash PTE. Similarly, the array is
  2370. 8 entries sorted by increasing sizes and an entry with a "0" shift
  2371. is an empty entry and a terminator::
  2372. struct kvm_ppc_one_page_size {
  2373. __u32 page_shift; /* Page shift (or 0) */
  2374. __u32 pte_enc; /* Encoding in the HPTE (>>12) */
  2375. };
  2376. The "pte_enc" field provides a value that can OR'ed into the hash
  2377. PTE's RPN field (ie, it needs to be shifted left by 12 to OR it
  2378. into the hash PTE second double word).
  2379. 4.75 KVM_IRQFD
  2380. --------------
  2381. :Capability: KVM_CAP_IRQFD
  2382. :Architectures: x86 s390 arm64
  2383. :Type: vm ioctl
  2384. :Parameters: struct kvm_irqfd (in)
  2385. :Returns: 0 on success, -1 on error
  2386. Allows setting an eventfd to directly trigger a guest interrupt.
  2387. kvm_irqfd.fd specifies the file descriptor to use as the eventfd and
  2388. kvm_irqfd.gsi specifies the irqchip pin toggled by this event. When
  2389. an event is triggered on the eventfd, an interrupt is injected into
  2390. the guest using the specified gsi pin. The irqfd is removed using
  2391. the KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd
  2392. and kvm_irqfd.gsi.
  2393. With KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify
  2394. mechanism allowing emulation of level-triggered, irqfd-based
  2395. interrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an
  2396. additional eventfd in the kvm_irqfd.resamplefd field. When operating
  2397. in resample mode, posting of an interrupt through kvm_irq.fd asserts
  2398. the specified gsi in the irqchip. When the irqchip is resampled, such
  2399. as from an EOI, the gsi is de-asserted and the user is notified via
  2400. kvm_irqfd.resamplefd. It is the user's responsibility to re-queue
  2401. the interrupt if the device making use of it still requires service.
  2402. Note that closing the resamplefd is not sufficient to disable the
  2403. irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
  2404. and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
  2405. On arm64, gsi routing being supported, the following can happen:
  2406. - in case no routing entry is associated to this gsi, injection fails
  2407. - in case the gsi is associated to an irqchip routing entry,
  2408. irqchip.pin + 32 corresponds to the injected SPI ID.
  2409. - in case the gsi is associated to an MSI routing entry, the MSI
  2410. message and device ID are translated into an LPI (support restricted
  2411. to GICv3 ITS in-kernel emulation).
  2412. 4.76 KVM_PPC_ALLOCATE_HTAB
  2413. --------------------------
  2414. :Capability: KVM_CAP_PPC_ALLOC_HTAB
  2415. :Architectures: powerpc
  2416. :Type: vm ioctl
  2417. :Parameters: Pointer to u32 containing hash table order (in/out)
  2418. :Returns: 0 on success, -1 on error
  2419. This requests the host kernel to allocate an MMU hash table for a
  2420. guest using the PAPR paravirtualization interface. This only does
  2421. anything if the kernel is configured to use the Book 3S HV style of
  2422. virtualization. Otherwise the capability doesn't exist and the ioctl
  2423. returns an ENOTTY error. The rest of this description assumes Book 3S
  2424. HV.
  2425. There must be no vcpus running when this ioctl is called; if there
  2426. are, it will do nothing and return an EBUSY error.
  2427. The parameter is a pointer to a 32-bit unsigned integer variable
  2428. containing the order (log base 2) of the desired size of the hash
  2429. table, which must be between 18 and 46. On successful return from the
  2430. ioctl, the value will not be changed by the kernel.
  2431. If no hash table has been allocated when any vcpu is asked to run
  2432. (with the KVM_RUN ioctl), the host kernel will allocate a
  2433. default-sized hash table (16 MB).
  2434. If this ioctl is called when a hash table has already been allocated,
  2435. with a different order from the existing hash table, the existing hash
  2436. table will be freed and a new one allocated. If this is ioctl is
  2437. called when a hash table has already been allocated of the same order
  2438. as specified, the kernel will clear out the existing hash table (zero
  2439. all HPTEs). In either case, if the guest is using the virtualized
  2440. real-mode area (VRMA) facility, the kernel will re-create the VMRA
  2441. HPTEs on the next KVM_RUN of any vcpu.
  2442. 4.77 KVM_S390_INTERRUPT
  2443. -----------------------
  2444. :Capability: basic
  2445. :Architectures: s390
  2446. :Type: vm ioctl, vcpu ioctl
  2447. :Parameters: struct kvm_s390_interrupt (in)
  2448. :Returns: 0 on success, -1 on error
  2449. Allows to inject an interrupt to the guest. Interrupts can be floating
  2450. (vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type.
  2451. Interrupt parameters are passed via kvm_s390_interrupt::
  2452. struct kvm_s390_interrupt {
  2453. __u32 type;
  2454. __u32 parm;
  2455. __u64 parm64;
  2456. };
  2457. type can be one of the following:
  2458. KVM_S390_SIGP_STOP (vcpu)
  2459. - sigp stop; optional flags in parm
  2460. KVM_S390_PROGRAM_INT (vcpu)
  2461. - program check; code in parm
  2462. KVM_S390_SIGP_SET_PREFIX (vcpu)
  2463. - sigp set prefix; prefix address in parm
  2464. KVM_S390_RESTART (vcpu)
  2465. - restart
  2466. KVM_S390_INT_CLOCK_COMP (vcpu)
  2467. - clock comparator interrupt
  2468. KVM_S390_INT_CPU_TIMER (vcpu)
  2469. - CPU timer interrupt
  2470. KVM_S390_INT_VIRTIO (vm)
  2471. - virtio external interrupt; external interrupt
  2472. parameters in parm and parm64
  2473. KVM_S390_INT_SERVICE (vm)
  2474. - sclp external interrupt; sclp parameter in parm
  2475. KVM_S390_INT_EMERGENCY (vcpu)
  2476. - sigp emergency; source cpu in parm
  2477. KVM_S390_INT_EXTERNAL_CALL (vcpu)
  2478. - sigp external call; source cpu in parm
  2479. KVM_S390_INT_IO(ai,cssid,ssid,schid) (vm)
  2480. - compound value to indicate an
  2481. I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel);
  2482. I/O interruption parameters in parm (subchannel) and parm64 (intparm,
  2483. interruption subclass)
  2484. KVM_S390_MCHK (vm, vcpu)
  2485. - machine check interrupt; cr 14 bits in parm, machine check interrupt
  2486. code in parm64 (note that machine checks needing further payload are not
  2487. supported by this ioctl)
  2488. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  2489. 4.78 KVM_PPC_GET_HTAB_FD
  2490. ------------------------
  2491. :Capability: KVM_CAP_PPC_HTAB_FD
  2492. :Architectures: powerpc
  2493. :Type: vm ioctl
  2494. :Parameters: Pointer to struct kvm_get_htab_fd (in)
  2495. :Returns: file descriptor number (>= 0) on success, -1 on error
  2496. This returns a file descriptor that can be used either to read out the
  2497. entries in the guest's hashed page table (HPT), or to write entries to
  2498. initialize the HPT. The returned fd can only be written to if the
  2499. KVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and
  2500. can only be read if that bit is clear. The argument struct looks like
  2501. this::
  2502. /* For KVM_PPC_GET_HTAB_FD */
  2503. struct kvm_get_htab_fd {
  2504. __u64 flags;
  2505. __u64 start_index;
  2506. __u64 reserved[2];
  2507. };
  2508. /* Values for kvm_get_htab_fd.flags */
  2509. #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1)
  2510. #define KVM_GET_HTAB_WRITE ((__u64)0x2)
  2511. The 'start_index' field gives the index in the HPT of the entry at
  2512. which to start reading. It is ignored when writing.
  2513. Reads on the fd will initially supply information about all
  2514. "interesting" HPT entries. Interesting entries are those with the
  2515. bolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise
  2516. all entries. When the end of the HPT is reached, the read() will
  2517. return. If read() is called again on the fd, it will start again from
  2518. the beginning of the HPT, but will only return HPT entries that have
  2519. changed since they were last read.
  2520. Data read or written is structured as a header (8 bytes) followed by a
  2521. series of valid HPT entries (16 bytes) each. The header indicates how
  2522. many valid HPT entries there are and how many invalid entries follow
  2523. the valid entries. The invalid entries are not represented explicitly
  2524. in the stream. The header format is::
  2525. struct kvm_get_htab_header {
  2526. __u32 index;
  2527. __u16 n_valid;
  2528. __u16 n_invalid;
  2529. };
  2530. Writes to the fd create HPT entries starting at the index given in the
  2531. header; first 'n_valid' valid entries with contents from the data
  2532. written, then 'n_invalid' invalid entries, invalidating any previously
  2533. valid entries found.
  2534. 4.79 KVM_CREATE_DEVICE
  2535. ----------------------
  2536. :Capability: KVM_CAP_DEVICE_CTRL
  2537. :Type: vm ioctl
  2538. :Parameters: struct kvm_create_device (in/out)
  2539. :Returns: 0 on success, -1 on error
  2540. Errors:
  2541. ====== =======================================================
  2542. ENODEV The device type is unknown or unsupported
  2543. EEXIST Device already created, and this type of device may not
  2544. be instantiated multiple times
  2545. ====== =======================================================
  2546. Other error conditions may be defined by individual device types or
  2547. have their standard meanings.
  2548. Creates an emulated device in the kernel. The file descriptor returned
  2549. in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR.
  2550. If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the
  2551. device type is supported (not necessarily whether it can be created
  2552. in the current vm).
  2553. Individual devices should not define flags. Attributes should be used
  2554. for specifying any behavior that is not implied by the device type
  2555. number.
  2556. ::
  2557. struct kvm_create_device {
  2558. __u32 type; /* in: KVM_DEV_TYPE_xxx */
  2559. __u32 fd; /* out: device handle */
  2560. __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */
  2561. };
  2562. 4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR
  2563. --------------------------------------------
  2564. :Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
  2565. KVM_CAP_VCPU_ATTRIBUTES for vcpu device
  2566. KVM_CAP_SYS_ATTRIBUTES for system (/dev/kvm) device (no set)
  2567. :Type: device ioctl, vm ioctl, vcpu ioctl
  2568. :Parameters: struct kvm_device_attr
  2569. :Returns: 0 on success, -1 on error
  2570. Errors:
  2571. ===== =============================================================
  2572. ENXIO The group or attribute is unknown/unsupported for this device
  2573. or hardware support is missing.
  2574. EPERM The attribute cannot (currently) be accessed this way
  2575. (e.g. read-only attribute, or attribute that only makes
  2576. sense when the device is in a different state)
  2577. ===== =============================================================
  2578. Other error conditions may be defined by individual device types.
  2579. Gets/sets a specified piece of device configuration and/or state. The
  2580. semantics are device-specific. See individual device documentation in
  2581. the "devices" directory. As with ONE_REG, the size of the data
  2582. transferred is defined by the particular attribute.
  2583. ::
  2584. struct kvm_device_attr {
  2585. __u32 flags; /* no flags currently defined */
  2586. __u32 group; /* device-defined */
  2587. __u64 attr; /* group-defined */
  2588. __u64 addr; /* userspace address of attr data */
  2589. };
  2590. 4.81 KVM_HAS_DEVICE_ATTR
  2591. ------------------------
  2592. :Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
  2593. KVM_CAP_VCPU_ATTRIBUTES for vcpu device
  2594. KVM_CAP_SYS_ATTRIBUTES for system (/dev/kvm) device
  2595. :Type: device ioctl, vm ioctl, vcpu ioctl
  2596. :Parameters: struct kvm_device_attr
  2597. :Returns: 0 on success, -1 on error
  2598. Errors:
  2599. ===== =============================================================
  2600. ENXIO The group or attribute is unknown/unsupported for this device
  2601. or hardware support is missing.
  2602. ===== =============================================================
  2603. Tests whether a device supports a particular attribute. A successful
  2604. return indicates the attribute is implemented. It does not necessarily
  2605. indicate that the attribute can be read or written in the device's
  2606. current state. "addr" is ignored.
  2607. 4.82 KVM_ARM_VCPU_INIT
  2608. ----------------------
  2609. :Capability: basic
  2610. :Architectures: arm64
  2611. :Type: vcpu ioctl
  2612. :Parameters: struct kvm_vcpu_init (in)
  2613. :Returns: 0 on success; -1 on error
  2614. Errors:
  2615. ====== =================================================================
  2616. EINVAL the target is unknown, or the combination of features is invalid.
  2617. ENOENT a features bit specified is unknown.
  2618. ====== =================================================================
  2619. This tells KVM what type of CPU to present to the guest, and what
  2620. optional features it should have. This will cause a reset of the cpu
  2621. registers to their initial values. If this is not called, KVM_RUN will
  2622. return ENOEXEC for that vcpu.
  2623. The initial values are defined as:
  2624. - Processor state:
  2625. * AArch64: EL1h, D, A, I and F bits set. All other bits
  2626. are cleared.
  2627. * AArch32: SVC, A, I and F bits set. All other bits are
  2628. cleared.
  2629. - General Purpose registers, including PC and SP: set to 0
  2630. - FPSIMD/NEON registers: set to 0
  2631. - SVE registers: set to 0
  2632. - System registers: Reset to their architecturally defined
  2633. values as for a warm reset to EL1 (resp. SVC)
  2634. Note that because some registers reflect machine topology, all vcpus
  2635. should be created before this ioctl is invoked.
  2636. Userspace can call this function multiple times for a given vcpu, including
  2637. after the vcpu has been run. This will reset the vcpu to its initial
  2638. state. All calls to this function after the initial call must use the same
  2639. target and same set of feature flags, otherwise EINVAL will be returned.
  2640. Possible features:
  2641. - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state.
  2642. Depends on KVM_CAP_ARM_PSCI. If not set, the CPU will be powered on
  2643. and execute guest code when KVM_RUN is called.
  2644. - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode.
  2645. Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only).
  2646. - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 (or a future revision
  2647. backward compatible with v0.2) for the CPU.
  2648. Depends on KVM_CAP_ARM_PSCI_0_2.
  2649. - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU.
  2650. Depends on KVM_CAP_ARM_PMU_V3.
  2651. - KVM_ARM_VCPU_PTRAUTH_ADDRESS: Enables Address Pointer authentication
  2652. for arm64 only.
  2653. Depends on KVM_CAP_ARM_PTRAUTH_ADDRESS.
  2654. If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are
  2655. both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and
  2656. KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be
  2657. requested.
  2658. - KVM_ARM_VCPU_PTRAUTH_GENERIC: Enables Generic Pointer authentication
  2659. for arm64 only.
  2660. Depends on KVM_CAP_ARM_PTRAUTH_GENERIC.
  2661. If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are
  2662. both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and
  2663. KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be
  2664. requested.
  2665. - KVM_ARM_VCPU_SVE: Enables SVE for the CPU (arm64 only).
  2666. Depends on KVM_CAP_ARM_SVE.
  2667. Requires KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
  2668. * After KVM_ARM_VCPU_INIT:
  2669. - KVM_REG_ARM64_SVE_VLS may be read using KVM_GET_ONE_REG: the
  2670. initial value of this pseudo-register indicates the best set of
  2671. vector lengths possible for a vcpu on this host.
  2672. * Before KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
  2673. - KVM_RUN and KVM_GET_REG_LIST are not available;
  2674. - KVM_GET_ONE_REG and KVM_SET_ONE_REG cannot be used to access
  2675. the scalable archietctural SVE registers
  2676. KVM_REG_ARM64_SVE_ZREG(), KVM_REG_ARM64_SVE_PREG() or
  2677. KVM_REG_ARM64_SVE_FFR;
  2678. - KVM_REG_ARM64_SVE_VLS may optionally be written using
  2679. KVM_SET_ONE_REG, to modify the set of vector lengths available
  2680. for the vcpu.
  2681. * After KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
  2682. - the KVM_REG_ARM64_SVE_VLS pseudo-register is immutable, and can
  2683. no longer be written using KVM_SET_ONE_REG.
  2684. 4.83 KVM_ARM_PREFERRED_TARGET
  2685. -----------------------------
  2686. :Capability: basic
  2687. :Architectures: arm64
  2688. :Type: vm ioctl
  2689. :Parameters: struct kvm_vcpu_init (out)
  2690. :Returns: 0 on success; -1 on error
  2691. Errors:
  2692. ====== ==========================================
  2693. ENODEV no preferred target available for the host
  2694. ====== ==========================================
  2695. This queries KVM for preferred CPU target type which can be emulated
  2696. by KVM on underlying host.
  2697. The ioctl returns struct kvm_vcpu_init instance containing information
  2698. about preferred CPU target type and recommended features for it. The
  2699. kvm_vcpu_init->features bitmap returned will have feature bits set if
  2700. the preferred target recommends setting these features, but this is
  2701. not mandatory.
  2702. The information returned by this ioctl can be used to prepare an instance
  2703. of struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in
  2704. VCPU matching underlying host.
  2705. 4.84 KVM_GET_REG_LIST
  2706. ---------------------
  2707. :Capability: basic
  2708. :Architectures: arm64, mips
  2709. :Type: vcpu ioctl
  2710. :Parameters: struct kvm_reg_list (in/out)
  2711. :Returns: 0 on success; -1 on error
  2712. Errors:
  2713. ===== ==============================================================
  2714. E2BIG the reg index list is too big to fit in the array specified by
  2715. the user (the number required will be written into n).
  2716. ===== ==============================================================
  2717. ::
  2718. struct kvm_reg_list {
  2719. __u64 n; /* number of registers in reg[] */
  2720. __u64 reg[0];
  2721. };
  2722. This ioctl returns the guest registers that are supported for the
  2723. KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.
  2724. 4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated)
  2725. -----------------------------------------
  2726. :Capability: KVM_CAP_ARM_SET_DEVICE_ADDR
  2727. :Architectures: arm64
  2728. :Type: vm ioctl
  2729. :Parameters: struct kvm_arm_device_address (in)
  2730. :Returns: 0 on success, -1 on error
  2731. Errors:
  2732. ====== ============================================
  2733. ENODEV The device id is unknown
  2734. ENXIO Device not supported on current system
  2735. EEXIST Address already set
  2736. E2BIG Address outside guest physical address space
  2737. EBUSY Address overlaps with other device range
  2738. ====== ============================================
  2739. ::
  2740. struct kvm_arm_device_addr {
  2741. __u64 id;
  2742. __u64 addr;
  2743. };
  2744. Specify a device address in the guest's physical address space where guests
  2745. can access emulated or directly exposed devices, which the host kernel needs
  2746. to know about. The id field is an architecture specific identifier for a
  2747. specific device.
  2748. arm64 divides the id field into two parts, a device id and an
  2749. address type id specific to the individual device::
  2750. bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 |
  2751. field: | 0x00000000 | device id | addr type id |
  2752. arm64 currently only require this when using the in-kernel GIC
  2753. support for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2
  2754. as the device id. When setting the base address for the guest's
  2755. mapping of the VGIC virtual CPU and distributor interface, the ioctl
  2756. must be called after calling KVM_CREATE_IRQCHIP, but before calling
  2757. KVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the
  2758. base addresses will return -EEXIST.
  2759. Note, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API
  2760. should be used instead.
  2761. 4.86 KVM_PPC_RTAS_DEFINE_TOKEN
  2762. ------------------------------
  2763. :Capability: KVM_CAP_PPC_RTAS
  2764. :Architectures: ppc
  2765. :Type: vm ioctl
  2766. :Parameters: struct kvm_rtas_token_args
  2767. :Returns: 0 on success, -1 on error
  2768. Defines a token value for a RTAS (Run Time Abstraction Services)
  2769. service in order to allow it to be handled in the kernel. The
  2770. argument struct gives the name of the service, which must be the name
  2771. of a service that has a kernel-side implementation. If the token
  2772. value is non-zero, it will be associated with that service, and
  2773. subsequent RTAS calls by the guest specifying that token will be
  2774. handled by the kernel. If the token value is 0, then any token
  2775. associated with the service will be forgotten, and subsequent RTAS
  2776. calls by the guest for that service will be passed to userspace to be
  2777. handled.
  2778. 4.87 KVM_SET_GUEST_DEBUG
  2779. ------------------------
  2780. :Capability: KVM_CAP_SET_GUEST_DEBUG
  2781. :Architectures: x86, s390, ppc, arm64
  2782. :Type: vcpu ioctl
  2783. :Parameters: struct kvm_guest_debug (in)
  2784. :Returns: 0 on success; -1 on error
  2785. ::
  2786. struct kvm_guest_debug {
  2787. __u32 control;
  2788. __u32 pad;
  2789. struct kvm_guest_debug_arch arch;
  2790. };
  2791. Set up the processor specific debug registers and configure vcpu for
  2792. handling guest debug events. There are two parts to the structure, the
  2793. first a control bitfield indicates the type of debug events to handle
  2794. when running. Common control bits are:
  2795. - KVM_GUESTDBG_ENABLE: guest debugging is enabled
  2796. - KVM_GUESTDBG_SINGLESTEP: the next run should single-step
  2797. The top 16 bits of the control field are architecture specific control
  2798. flags which can include the following:
  2799. - KVM_GUESTDBG_USE_SW_BP: using software breakpoints [x86, arm64]
  2800. - KVM_GUESTDBG_USE_HW_BP: using hardware breakpoints [x86, s390]
  2801. - KVM_GUESTDBG_USE_HW: using hardware debug events [arm64]
  2802. - KVM_GUESTDBG_INJECT_DB: inject DB type exception [x86]
  2803. - KVM_GUESTDBG_INJECT_BP: inject BP type exception [x86]
  2804. - KVM_GUESTDBG_EXIT_PENDING: trigger an immediate guest exit [s390]
  2805. - KVM_GUESTDBG_BLOCKIRQ: avoid injecting interrupts/NMI/SMI [x86]
  2806. For example KVM_GUESTDBG_USE_SW_BP indicates that software breakpoints
  2807. are enabled in memory so we need to ensure breakpoint exceptions are
  2808. correctly trapped and the KVM run loop exits at the breakpoint and not
  2809. running off into the normal guest vector. For KVM_GUESTDBG_USE_HW_BP
  2810. we need to ensure the guest vCPUs architecture specific registers are
  2811. updated to the correct (supplied) values.
  2812. The second part of the structure is architecture specific and
  2813. typically contains a set of debug registers.
  2814. For arm64 the number of debug registers is implementation defined and
  2815. can be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and
  2816. KVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number
  2817. indicating the number of supported registers.
  2818. For ppc, the KVM_CAP_PPC_GUEST_DEBUG_SSTEP capability indicates whether
  2819. the single-step debug event (KVM_GUESTDBG_SINGLESTEP) is supported.
  2820. Also when supported, KVM_CAP_SET_GUEST_DEBUG2 capability indicates the
  2821. supported KVM_GUESTDBG_* bits in the control field.
  2822. When debug events exit the main run loop with the reason
  2823. KVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run
  2824. structure containing architecture specific debug information.
  2825. 4.88 KVM_GET_EMULATED_CPUID
  2826. ---------------------------
  2827. :Capability: KVM_CAP_EXT_EMUL_CPUID
  2828. :Architectures: x86
  2829. :Type: system ioctl
  2830. :Parameters: struct kvm_cpuid2 (in/out)
  2831. :Returns: 0 on success, -1 on error
  2832. ::
  2833. struct kvm_cpuid2 {
  2834. __u32 nent;
  2835. __u32 flags;
  2836. struct kvm_cpuid_entry2 entries[0];
  2837. };
  2838. The member 'flags' is used for passing flags from userspace.
  2839. ::
  2840. #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
  2841. #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */
  2842. #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */
  2843. struct kvm_cpuid_entry2 {
  2844. __u32 function;
  2845. __u32 index;
  2846. __u32 flags;
  2847. __u32 eax;
  2848. __u32 ebx;
  2849. __u32 ecx;
  2850. __u32 edx;
  2851. __u32 padding[3];
  2852. };
  2853. This ioctl returns x86 cpuid features which are emulated by
  2854. kvm.Userspace can use the information returned by this ioctl to query
  2855. which features are emulated by kvm instead of being present natively.
  2856. Userspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2
  2857. structure with the 'nent' field indicating the number of entries in
  2858. the variable-size array 'entries'. If the number of entries is too low
  2859. to describe the cpu capabilities, an error (E2BIG) is returned. If the
  2860. number is too high, the 'nent' field is adjusted and an error (ENOMEM)
  2861. is returned. If the number is just right, the 'nent' field is adjusted
  2862. to the number of valid entries in the 'entries' array, which is then
  2863. filled.
  2864. The entries returned are the set CPUID bits of the respective features
  2865. which kvm emulates, as returned by the CPUID instruction, with unknown
  2866. or unsupported feature bits cleared.
  2867. Features like x2apic, for example, may not be present in the host cpu
  2868. but are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be
  2869. emulated efficiently and thus not included here.
  2870. The fields in each entry are defined as follows:
  2871. function:
  2872. the eax value used to obtain the entry
  2873. index:
  2874. the ecx value used to obtain the entry (for entries that are
  2875. affected by ecx)
  2876. flags:
  2877. an OR of zero or more of the following:
  2878. KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
  2879. if the index field is valid
  2880. eax, ebx, ecx, edx:
  2881. the values returned by the cpuid instruction for
  2882. this function/index combination
  2883. 4.89 KVM_S390_MEM_OP
  2884. --------------------
  2885. :Capability: KVM_CAP_S390_MEM_OP, KVM_CAP_S390_PROTECTED, KVM_CAP_S390_MEM_OP_EXTENSION
  2886. :Architectures: s390
  2887. :Type: vm ioctl, vcpu ioctl
  2888. :Parameters: struct kvm_s390_mem_op (in)
  2889. :Returns: = 0 on success,
  2890. < 0 on generic error (e.g. -EFAULT or -ENOMEM),
  2891. > 0 if an exception occurred while walking the page tables
  2892. Read or write data from/to the VM's memory.
  2893. The KVM_CAP_S390_MEM_OP_EXTENSION capability specifies what functionality is
  2894. supported.
  2895. Parameters are specified via the following structure::
  2896. struct kvm_s390_mem_op {
  2897. __u64 gaddr; /* the guest address */
  2898. __u64 flags; /* flags */
  2899. __u32 size; /* amount of bytes */
  2900. __u32 op; /* type of operation */
  2901. __u64 buf; /* buffer in userspace */
  2902. union {
  2903. struct {
  2904. __u8 ar; /* the access register number */
  2905. __u8 key; /* access key, ignored if flag unset */
  2906. };
  2907. __u32 sida_offset; /* offset into the sida */
  2908. __u8 reserved[32]; /* ignored */
  2909. };
  2910. };
  2911. The start address of the memory region has to be specified in the "gaddr"
  2912. field, and the length of the region in the "size" field (which must not
  2913. be 0). The maximum value for "size" can be obtained by checking the
  2914. KVM_CAP_S390_MEM_OP capability. "buf" is the buffer supplied by the
  2915. userspace application where the read data should be written to for
  2916. a read access, or where the data that should be written is stored for
  2917. a write access. The "reserved" field is meant for future extensions.
  2918. Reserved and unused values are ignored. Future extension that add members must
  2919. introduce new flags.
  2920. The type of operation is specified in the "op" field. Flags modifying
  2921. their behavior can be set in the "flags" field. Undefined flag bits must
  2922. be set to 0.
  2923. Possible operations are:
  2924. * ``KVM_S390_MEMOP_LOGICAL_READ``
  2925. * ``KVM_S390_MEMOP_LOGICAL_WRITE``
  2926. * ``KVM_S390_MEMOP_ABSOLUTE_READ``
  2927. * ``KVM_S390_MEMOP_ABSOLUTE_WRITE``
  2928. * ``KVM_S390_MEMOP_SIDA_READ``
  2929. * ``KVM_S390_MEMOP_SIDA_WRITE``
  2930. Logical read/write:
  2931. ^^^^^^^^^^^^^^^^^^^
  2932. Access logical memory, i.e. translate the given guest address to an absolute
  2933. address given the state of the VCPU and use the absolute address as target of
  2934. the access. "ar" designates the access register number to be used; the valid
  2935. range is 0..15.
  2936. Logical accesses are permitted for the VCPU ioctl only.
  2937. Logical accesses are permitted for non-protected guests only.
  2938. Supported flags:
  2939. * ``KVM_S390_MEMOP_F_CHECK_ONLY``
  2940. * ``KVM_S390_MEMOP_F_INJECT_EXCEPTION``
  2941. * ``KVM_S390_MEMOP_F_SKEY_PROTECTION``
  2942. The KVM_S390_MEMOP_F_CHECK_ONLY flag can be set to check whether the
  2943. corresponding memory access would cause an access exception; however,
  2944. no actual access to the data in memory at the destination is performed.
  2945. In this case, "buf" is unused and can be NULL.
  2946. In case an access exception occurred during the access (or would occur
  2947. in case of KVM_S390_MEMOP_F_CHECK_ONLY), the ioctl returns a positive
  2948. error number indicating the type of exception. This exception is also
  2949. raised directly at the corresponding VCPU if the flag
  2950. KVM_S390_MEMOP_F_INJECT_EXCEPTION is set.
  2951. On protection exceptions, unless specified otherwise, the injected
  2952. translation-exception identifier (TEID) indicates suppression.
  2953. If the KVM_S390_MEMOP_F_SKEY_PROTECTION flag is set, storage key
  2954. protection is also in effect and may cause exceptions if accesses are
  2955. prohibited given the access key designated by "key"; the valid range is 0..15.
  2956. KVM_S390_MEMOP_F_SKEY_PROTECTION is available if KVM_CAP_S390_MEM_OP_EXTENSION
  2957. is > 0.
  2958. Since the accessed memory may span multiple pages and those pages might have
  2959. different storage keys, it is possible that a protection exception occurs
  2960. after memory has been modified. In this case, if the exception is injected,
  2961. the TEID does not indicate suppression.
  2962. Absolute read/write:
  2963. ^^^^^^^^^^^^^^^^^^^^
  2964. Access absolute memory. This operation is intended to be used with the
  2965. KVM_S390_MEMOP_F_SKEY_PROTECTION flag, to allow accessing memory and performing
  2966. the checks required for storage key protection as one operation (as opposed to
  2967. user space getting the storage keys, performing the checks, and accessing
  2968. memory thereafter, which could lead to a delay between check and access).
  2969. Absolute accesses are permitted for the VM ioctl if KVM_CAP_S390_MEM_OP_EXTENSION
  2970. is > 0.
  2971. Currently absolute accesses are not permitted for VCPU ioctls.
  2972. Absolute accesses are permitted for non-protected guests only.
  2973. Supported flags:
  2974. * ``KVM_S390_MEMOP_F_CHECK_ONLY``
  2975. * ``KVM_S390_MEMOP_F_SKEY_PROTECTION``
  2976. The semantics of the flags are as for logical accesses.
  2977. SIDA read/write:
  2978. ^^^^^^^^^^^^^^^^
  2979. Access the secure instruction data area which contains memory operands necessary
  2980. for instruction emulation for protected guests.
  2981. SIDA accesses are available if the KVM_CAP_S390_PROTECTED capability is available.
  2982. SIDA accesses are permitted for the VCPU ioctl only.
  2983. SIDA accesses are permitted for protected guests only.
  2984. No flags are supported.
  2985. 4.90 KVM_S390_GET_SKEYS
  2986. -----------------------
  2987. :Capability: KVM_CAP_S390_SKEYS
  2988. :Architectures: s390
  2989. :Type: vm ioctl
  2990. :Parameters: struct kvm_s390_skeys
  2991. :Returns: 0 on success, KVM_S390_GET_SKEYS_NONE if guest is not using storage
  2992. keys, negative value on error
  2993. This ioctl is used to get guest storage key values on the s390
  2994. architecture. The ioctl takes parameters via the kvm_s390_skeys struct::
  2995. struct kvm_s390_skeys {
  2996. __u64 start_gfn;
  2997. __u64 count;
  2998. __u64 skeydata_addr;
  2999. __u32 flags;
  3000. __u32 reserved[9];
  3001. };
  3002. The start_gfn field is the number of the first guest frame whose storage keys
  3003. you want to get.
  3004. The count field is the number of consecutive frames (starting from start_gfn)
  3005. whose storage keys to get. The count field must be at least 1 and the maximum
  3006. allowed value is defined as KVM_S390_SKEYS_MAX. Values outside this range
  3007. will cause the ioctl to return -EINVAL.
  3008. The skeydata_addr field is the address to a buffer large enough to hold count
  3009. bytes. This buffer will be filled with storage key data by the ioctl.
  3010. 4.91 KVM_S390_SET_SKEYS
  3011. -----------------------
  3012. :Capability: KVM_CAP_S390_SKEYS
  3013. :Architectures: s390
  3014. :Type: vm ioctl
  3015. :Parameters: struct kvm_s390_skeys
  3016. :Returns: 0 on success, negative value on error
  3017. This ioctl is used to set guest storage key values on the s390
  3018. architecture. The ioctl takes parameters via the kvm_s390_skeys struct.
  3019. See section on KVM_S390_GET_SKEYS for struct definition.
  3020. The start_gfn field is the number of the first guest frame whose storage keys
  3021. you want to set.
  3022. The count field is the number of consecutive frames (starting from start_gfn)
  3023. whose storage keys to get. The count field must be at least 1 and the maximum
  3024. allowed value is defined as KVM_S390_SKEYS_MAX. Values outside this range
  3025. will cause the ioctl to return -EINVAL.
  3026. The skeydata_addr field is the address to a buffer containing count bytes of
  3027. storage keys. Each byte in the buffer will be set as the storage key for a
  3028. single frame starting at start_gfn for count frames.
  3029. Note: If any architecturally invalid key value is found in the given data then
  3030. the ioctl will return -EINVAL.
  3031. 4.92 KVM_S390_IRQ
  3032. -----------------
  3033. :Capability: KVM_CAP_S390_INJECT_IRQ
  3034. :Architectures: s390
  3035. :Type: vcpu ioctl
  3036. :Parameters: struct kvm_s390_irq (in)
  3037. :Returns: 0 on success, -1 on error
  3038. Errors:
  3039. ====== =================================================================
  3040. EINVAL interrupt type is invalid
  3041. type is KVM_S390_SIGP_STOP and flag parameter is invalid value,
  3042. type is KVM_S390_INT_EXTERNAL_CALL and code is bigger
  3043. than the maximum of VCPUs
  3044. EBUSY type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped,
  3045. type is KVM_S390_SIGP_STOP and a stop irq is already pending,
  3046. type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt
  3047. is already pending
  3048. ====== =================================================================
  3049. Allows to inject an interrupt to the guest.
  3050. Using struct kvm_s390_irq as a parameter allows
  3051. to inject additional payload which is not
  3052. possible via KVM_S390_INTERRUPT.
  3053. Interrupt parameters are passed via kvm_s390_irq::
  3054. struct kvm_s390_irq {
  3055. __u64 type;
  3056. union {
  3057. struct kvm_s390_io_info io;
  3058. struct kvm_s390_ext_info ext;
  3059. struct kvm_s390_pgm_info pgm;
  3060. struct kvm_s390_emerg_info emerg;
  3061. struct kvm_s390_extcall_info extcall;
  3062. struct kvm_s390_prefix_info prefix;
  3063. struct kvm_s390_stop_info stop;
  3064. struct kvm_s390_mchk_info mchk;
  3065. char reserved[64];
  3066. } u;
  3067. };
  3068. type can be one of the following:
  3069. - KVM_S390_SIGP_STOP - sigp stop; parameter in .stop
  3070. - KVM_S390_PROGRAM_INT - program check; parameters in .pgm
  3071. - KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix
  3072. - KVM_S390_RESTART - restart; no parameters
  3073. - KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters
  3074. - KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters
  3075. - KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg
  3076. - KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall
  3077. - KVM_S390_MCHK - machine check interrupt; parameters in .mchk
  3078. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  3079. 4.94 KVM_S390_GET_IRQ_STATE
  3080. ---------------------------
  3081. :Capability: KVM_CAP_S390_IRQ_STATE
  3082. :Architectures: s390
  3083. :Type: vcpu ioctl
  3084. :Parameters: struct kvm_s390_irq_state (out)
  3085. :Returns: >= number of bytes copied into buffer,
  3086. -EINVAL if buffer size is 0,
  3087. -ENOBUFS if buffer size is too small to fit all pending interrupts,
  3088. -EFAULT if the buffer address was invalid
  3089. This ioctl allows userspace to retrieve the complete state of all currently
  3090. pending interrupts in a single buffer. Use cases include migration
  3091. and introspection. The parameter structure contains the address of a
  3092. userspace buffer and its length::
  3093. struct kvm_s390_irq_state {
  3094. __u64 buf;
  3095. __u32 flags; /* will stay unused for compatibility reasons */
  3096. __u32 len;
  3097. __u32 reserved[4]; /* will stay unused for compatibility reasons */
  3098. };
  3099. Userspace passes in the above struct and for each pending interrupt a
  3100. struct kvm_s390_irq is copied to the provided buffer.
  3101. The structure contains a flags and a reserved field for future extensions. As
  3102. the kernel never checked for flags == 0 and QEMU never pre-zeroed flags and
  3103. reserved, these fields can not be used in the future without breaking
  3104. compatibility.
  3105. If -ENOBUFS is returned the buffer provided was too small and userspace
  3106. may retry with a bigger buffer.
  3107. 4.95 KVM_S390_SET_IRQ_STATE
  3108. ---------------------------
  3109. :Capability: KVM_CAP_S390_IRQ_STATE
  3110. :Architectures: s390
  3111. :Type: vcpu ioctl
  3112. :Parameters: struct kvm_s390_irq_state (in)
  3113. :Returns: 0 on success,
  3114. -EFAULT if the buffer address was invalid,
  3115. -EINVAL for an invalid buffer length (see below),
  3116. -EBUSY if there were already interrupts pending,
  3117. errors occurring when actually injecting the
  3118. interrupt. See KVM_S390_IRQ.
  3119. This ioctl allows userspace to set the complete state of all cpu-local
  3120. interrupts currently pending for the vcpu. It is intended for restoring
  3121. interrupt state after a migration. The input parameter is a userspace buffer
  3122. containing a struct kvm_s390_irq_state::
  3123. struct kvm_s390_irq_state {
  3124. __u64 buf;
  3125. __u32 flags; /* will stay unused for compatibility reasons */
  3126. __u32 len;
  3127. __u32 reserved[4]; /* will stay unused for compatibility reasons */
  3128. };
  3129. The restrictions for flags and reserved apply as well.
  3130. (see KVM_S390_GET_IRQ_STATE)
  3131. The userspace memory referenced by buf contains a struct kvm_s390_irq
  3132. for each interrupt to be injected into the guest.
  3133. If one of the interrupts could not be injected for some reason the
  3134. ioctl aborts.
  3135. len must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0
  3136. and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq),
  3137. which is the maximum number of possibly pending cpu-local interrupts.
  3138. 4.96 KVM_SMI
  3139. ------------
  3140. :Capability: KVM_CAP_X86_SMM
  3141. :Architectures: x86
  3142. :Type: vcpu ioctl
  3143. :Parameters: none
  3144. :Returns: 0 on success, -1 on error
  3145. Queues an SMI on the thread's vcpu.
  3146. 4.97 KVM_X86_SET_MSR_FILTER
  3147. ----------------------------
  3148. :Capability: KVM_CAP_X86_MSR_FILTER
  3149. :Architectures: x86
  3150. :Type: vm ioctl
  3151. :Parameters: struct kvm_msr_filter
  3152. :Returns: 0 on success, < 0 on error
  3153. ::
  3154. struct kvm_msr_filter_range {
  3155. #define KVM_MSR_FILTER_READ (1 << 0)
  3156. #define KVM_MSR_FILTER_WRITE (1 << 1)
  3157. __u32 flags;
  3158. __u32 nmsrs; /* number of msrs in bitmap */
  3159. __u32 base; /* MSR index the bitmap starts at */
  3160. __u8 *bitmap; /* a 1 bit allows the operations in flags, 0 denies */
  3161. };
  3162. #define KVM_MSR_FILTER_MAX_RANGES 16
  3163. struct kvm_msr_filter {
  3164. #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0)
  3165. #define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0)
  3166. __u32 flags;
  3167. struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES];
  3168. };
  3169. flags values for ``struct kvm_msr_filter_range``:
  3170. ``KVM_MSR_FILTER_READ``
  3171. Filter read accesses to MSRs using the given bitmap. A 0 in the bitmap
  3172. indicates that a read should immediately fail, while a 1 indicates that
  3173. a read for a particular MSR should be handled regardless of the default
  3174. filter action.
  3175. ``KVM_MSR_FILTER_WRITE``
  3176. Filter write accesses to MSRs using the given bitmap. A 0 in the bitmap
  3177. indicates that a write should immediately fail, while a 1 indicates that
  3178. a write for a particular MSR should be handled regardless of the default
  3179. filter action.
  3180. ``KVM_MSR_FILTER_READ | KVM_MSR_FILTER_WRITE``
  3181. Filter both read and write accesses to MSRs using the given bitmap. A 0
  3182. in the bitmap indicates that both reads and writes should immediately fail,
  3183. while a 1 indicates that reads and writes for a particular MSR are not
  3184. filtered by this range.
  3185. flags values for ``struct kvm_msr_filter``:
  3186. ``KVM_MSR_FILTER_DEFAULT_ALLOW``
  3187. If no filter range matches an MSR index that is getting accessed, KVM will
  3188. fall back to allowing access to the MSR.
  3189. ``KVM_MSR_FILTER_DEFAULT_DENY``
  3190. If no filter range matches an MSR index that is getting accessed, KVM will
  3191. fall back to rejecting access to the MSR. In this mode, all MSRs that should
  3192. be processed by KVM need to explicitly be marked as allowed in the bitmaps.
  3193. This ioctl allows user space to define up to 16 bitmaps of MSR ranges to
  3194. specify whether a certain MSR access should be explicitly filtered for or not.
  3195. If this ioctl has never been invoked, MSR accesses are not guarded and the
  3196. default KVM in-kernel emulation behavior is fully preserved.
  3197. Calling this ioctl with an empty set of ranges (all nmsrs == 0) disables MSR
  3198. filtering. In that mode, ``KVM_MSR_FILTER_DEFAULT_DENY`` is invalid and causes
  3199. an error.
  3200. As soon as the filtering is in place, every MSR access is processed through
  3201. the filtering except for accesses to the x2APIC MSRs (from 0x800 to 0x8ff);
  3202. x2APIC MSRs are always allowed, independent of the ``default_allow`` setting,
  3203. and their behavior depends on the ``X2APIC_ENABLE`` bit of the APIC base
  3204. register.
  3205. .. warning::
  3206. MSR accesses coming from nested vmentry/vmexit are not filtered.
  3207. This includes both writes to individual VMCS fields and reads/writes
  3208. through the MSR lists pointed to by the VMCS.
  3209. If a bit is within one of the defined ranges, read and write accesses are
  3210. guarded by the bitmap's value for the MSR index if the kind of access
  3211. is included in the ``struct kvm_msr_filter_range`` flags. If no range
  3212. cover this particular access, the behavior is determined by the flags
  3213. field in the kvm_msr_filter struct: ``KVM_MSR_FILTER_DEFAULT_ALLOW``
  3214. and ``KVM_MSR_FILTER_DEFAULT_DENY``.
  3215. Each bitmap range specifies a range of MSRs to potentially allow access on.
  3216. The range goes from MSR index [base .. base+nmsrs]. The flags field
  3217. indicates whether reads, writes or both reads and writes are filtered
  3218. by setting a 1 bit in the bitmap for the corresponding MSR index.
  3219. If an MSR access is not permitted through the filtering, it generates a
  3220. #GP inside the guest. When combined with KVM_CAP_X86_USER_SPACE_MSR, that
  3221. allows user space to deflect and potentially handle various MSR accesses
  3222. into user space.
  3223. Note, invoking this ioctl while a vCPU is running is inherently racy. However,
  3224. KVM does guarantee that vCPUs will see either the previous filter or the new
  3225. filter, e.g. MSRs with identical settings in both the old and new filter will
  3226. have deterministic behavior.
  3227. 4.98 KVM_CREATE_SPAPR_TCE_64
  3228. ----------------------------
  3229. :Capability: KVM_CAP_SPAPR_TCE_64
  3230. :Architectures: powerpc
  3231. :Type: vm ioctl
  3232. :Parameters: struct kvm_create_spapr_tce_64 (in)
  3233. :Returns: file descriptor for manipulating the created TCE table
  3234. This is an extension for KVM_CAP_SPAPR_TCE which only supports 32bit
  3235. windows, described in 4.62 KVM_CREATE_SPAPR_TCE
  3236. This capability uses extended struct in ioctl interface::
  3237. /* for KVM_CAP_SPAPR_TCE_64 */
  3238. struct kvm_create_spapr_tce_64 {
  3239. __u64 liobn;
  3240. __u32 page_shift;
  3241. __u32 flags;
  3242. __u64 offset; /* in pages */
  3243. __u64 size; /* in pages */
  3244. };
  3245. The aim of extension is to support an additional bigger DMA window with
  3246. a variable page size.
  3247. KVM_CREATE_SPAPR_TCE_64 receives a 64bit window size, an IOMMU page shift and
  3248. a bus offset of the corresponding DMA window, @size and @offset are numbers
  3249. of IOMMU pages.
  3250. @flags are not used at the moment.
  3251. The rest of functionality is identical to KVM_CREATE_SPAPR_TCE.
  3252. 4.99 KVM_REINJECT_CONTROL
  3253. -------------------------
  3254. :Capability: KVM_CAP_REINJECT_CONTROL
  3255. :Architectures: x86
  3256. :Type: vm ioctl
  3257. :Parameters: struct kvm_reinject_control (in)
  3258. :Returns: 0 on success,
  3259. -EFAULT if struct kvm_reinject_control cannot be read,
  3260. -ENXIO if KVM_CREATE_PIT or KVM_CREATE_PIT2 didn't succeed earlier.
  3261. i8254 (PIT) has two modes, reinject and !reinject. The default is reinject,
  3262. where KVM queues elapsed i8254 ticks and monitors completion of interrupt from
  3263. vector(s) that i8254 injects. Reinject mode dequeues a tick and injects its
  3264. interrupt whenever there isn't a pending interrupt from i8254.
  3265. !reinject mode injects an interrupt as soon as a tick arrives.
  3266. ::
  3267. struct kvm_reinject_control {
  3268. __u8 pit_reinject;
  3269. __u8 reserved[31];
  3270. };
  3271. pit_reinject = 0 (!reinject mode) is recommended, unless running an old
  3272. operating system that uses the PIT for timing (e.g. Linux 2.4.x).
  3273. 4.100 KVM_PPC_CONFIGURE_V3_MMU
  3274. ------------------------------
  3275. :Capability: KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3
  3276. :Architectures: ppc
  3277. :Type: vm ioctl
  3278. :Parameters: struct kvm_ppc_mmuv3_cfg (in)
  3279. :Returns: 0 on success,
  3280. -EFAULT if struct kvm_ppc_mmuv3_cfg cannot be read,
  3281. -EINVAL if the configuration is invalid
  3282. This ioctl controls whether the guest will use radix or HPT (hashed
  3283. page table) translation, and sets the pointer to the process table for
  3284. the guest.
  3285. ::
  3286. struct kvm_ppc_mmuv3_cfg {
  3287. __u64 flags;
  3288. __u64 process_table;
  3289. };
  3290. There are two bits that can be set in flags; KVM_PPC_MMUV3_RADIX and
  3291. KVM_PPC_MMUV3_GTSE. KVM_PPC_MMUV3_RADIX, if set, configures the guest
  3292. to use radix tree translation, and if clear, to use HPT translation.
  3293. KVM_PPC_MMUV3_GTSE, if set and if KVM permits it, configures the guest
  3294. to be able to use the global TLB and SLB invalidation instructions;
  3295. if clear, the guest may not use these instructions.
  3296. The process_table field specifies the address and size of the guest
  3297. process table, which is in the guest's space. This field is formatted
  3298. as the second doubleword of the partition table entry, as defined in
  3299. the Power ISA V3.00, Book III section 5.7.6.1.
  3300. 4.101 KVM_PPC_GET_RMMU_INFO
  3301. ---------------------------
  3302. :Capability: KVM_CAP_PPC_RADIX_MMU
  3303. :Architectures: ppc
  3304. :Type: vm ioctl
  3305. :Parameters: struct kvm_ppc_rmmu_info (out)
  3306. :Returns: 0 on success,
  3307. -EFAULT if struct kvm_ppc_rmmu_info cannot be written,
  3308. -EINVAL if no useful information can be returned
  3309. This ioctl returns a structure containing two things: (a) a list
  3310. containing supported radix tree geometries, and (b) a list that maps
  3311. page sizes to put in the "AP" (actual page size) field for the tlbie
  3312. (TLB invalidate entry) instruction.
  3313. ::
  3314. struct kvm_ppc_rmmu_info {
  3315. struct kvm_ppc_radix_geom {
  3316. __u8 page_shift;
  3317. __u8 level_bits[4];
  3318. __u8 pad[3];
  3319. } geometries[8];
  3320. __u32 ap_encodings[8];
  3321. };
  3322. The geometries[] field gives up to 8 supported geometries for the
  3323. radix page table, in terms of the log base 2 of the smallest page
  3324. size, and the number of bits indexed at each level of the tree, from
  3325. the PTE level up to the PGD level in that order. Any unused entries
  3326. will have 0 in the page_shift field.
  3327. The ap_encodings gives the supported page sizes and their AP field
  3328. encodings, encoded with the AP value in the top 3 bits and the log
  3329. base 2 of the page size in the bottom 6 bits.
  3330. 4.102 KVM_PPC_RESIZE_HPT_PREPARE
  3331. --------------------------------
  3332. :Capability: KVM_CAP_SPAPR_RESIZE_HPT
  3333. :Architectures: powerpc
  3334. :Type: vm ioctl
  3335. :Parameters: struct kvm_ppc_resize_hpt (in)
  3336. :Returns: 0 on successful completion,
  3337. >0 if a new HPT is being prepared, the value is an estimated
  3338. number of milliseconds until preparation is complete,
  3339. -EFAULT if struct kvm_reinject_control cannot be read,
  3340. -EINVAL if the supplied shift or flags are invalid,
  3341. -ENOMEM if unable to allocate the new HPT,
  3342. Used to implement the PAPR extension for runtime resizing of a guest's
  3343. Hashed Page Table (HPT). Specifically this starts, stops or monitors
  3344. the preparation of a new potential HPT for the guest, essentially
  3345. implementing the H_RESIZE_HPT_PREPARE hypercall.
  3346. ::
  3347. struct kvm_ppc_resize_hpt {
  3348. __u64 flags;
  3349. __u32 shift;
  3350. __u32 pad;
  3351. };
  3352. If called with shift > 0 when there is no pending HPT for the guest,
  3353. this begins preparation of a new pending HPT of size 2^(shift) bytes.
  3354. It then returns a positive integer with the estimated number of
  3355. milliseconds until preparation is complete.
  3356. If called when there is a pending HPT whose size does not match that
  3357. requested in the parameters, discards the existing pending HPT and
  3358. creates a new one as above.
  3359. If called when there is a pending HPT of the size requested, will:
  3360. * If preparation of the pending HPT is already complete, return 0
  3361. * If preparation of the pending HPT has failed, return an error
  3362. code, then discard the pending HPT.
  3363. * If preparation of the pending HPT is still in progress, return an
  3364. estimated number of milliseconds until preparation is complete.
  3365. If called with shift == 0, discards any currently pending HPT and
  3366. returns 0 (i.e. cancels any in-progress preparation).
  3367. flags is reserved for future expansion, currently setting any bits in
  3368. flags will result in an -EINVAL.
  3369. Normally this will be called repeatedly with the same parameters until
  3370. it returns <= 0. The first call will initiate preparation, subsequent
  3371. ones will monitor preparation until it completes or fails.
  3372. 4.103 KVM_PPC_RESIZE_HPT_COMMIT
  3373. -------------------------------
  3374. :Capability: KVM_CAP_SPAPR_RESIZE_HPT
  3375. :Architectures: powerpc
  3376. :Type: vm ioctl
  3377. :Parameters: struct kvm_ppc_resize_hpt (in)
  3378. :Returns: 0 on successful completion,
  3379. -EFAULT if struct kvm_reinject_control cannot be read,
  3380. -EINVAL if the supplied shift or flags are invalid,
  3381. -ENXIO is there is no pending HPT, or the pending HPT doesn't
  3382. have the requested size,
  3383. -EBUSY if the pending HPT is not fully prepared,
  3384. -ENOSPC if there was a hash collision when moving existing
  3385. HPT entries to the new HPT,
  3386. -EIO on other error conditions
  3387. Used to implement the PAPR extension for runtime resizing of a guest's
  3388. Hashed Page Table (HPT). Specifically this requests that the guest be
  3389. transferred to working with the new HPT, essentially implementing the
  3390. H_RESIZE_HPT_COMMIT hypercall.
  3391. ::
  3392. struct kvm_ppc_resize_hpt {
  3393. __u64 flags;
  3394. __u32 shift;
  3395. __u32 pad;
  3396. };
  3397. This should only be called after KVM_PPC_RESIZE_HPT_PREPARE has
  3398. returned 0 with the same parameters. In other cases
  3399. KVM_PPC_RESIZE_HPT_COMMIT will return an error (usually -ENXIO or
  3400. -EBUSY, though others may be possible if the preparation was started,
  3401. but failed).
  3402. This will have undefined effects on the guest if it has not already
  3403. placed itself in a quiescent state where no vcpu will make MMU enabled
  3404. memory accesses.
  3405. On succsful completion, the pending HPT will become the guest's active
  3406. HPT and the previous HPT will be discarded.
  3407. On failure, the guest will still be operating on its previous HPT.
  3408. 4.104 KVM_X86_GET_MCE_CAP_SUPPORTED
  3409. -----------------------------------
  3410. :Capability: KVM_CAP_MCE
  3411. :Architectures: x86
  3412. :Type: system ioctl
  3413. :Parameters: u64 mce_cap (out)
  3414. :Returns: 0 on success, -1 on error
  3415. Returns supported MCE capabilities. The u64 mce_cap parameter
  3416. has the same format as the MSR_IA32_MCG_CAP register. Supported
  3417. capabilities will have the corresponding bits set.
  3418. 4.105 KVM_X86_SETUP_MCE
  3419. -----------------------
  3420. :Capability: KVM_CAP_MCE
  3421. :Architectures: x86
  3422. :Type: vcpu ioctl
  3423. :Parameters: u64 mcg_cap (in)
  3424. :Returns: 0 on success,
  3425. -EFAULT if u64 mcg_cap cannot be read,
  3426. -EINVAL if the requested number of banks is invalid,
  3427. -EINVAL if requested MCE capability is not supported.
  3428. Initializes MCE support for use. The u64 mcg_cap parameter
  3429. has the same format as the MSR_IA32_MCG_CAP register and
  3430. specifies which capabilities should be enabled. The maximum
  3431. supported number of error-reporting banks can be retrieved when
  3432. checking for KVM_CAP_MCE. The supported capabilities can be
  3433. retrieved with KVM_X86_GET_MCE_CAP_SUPPORTED.
  3434. 4.106 KVM_X86_SET_MCE
  3435. ---------------------
  3436. :Capability: KVM_CAP_MCE
  3437. :Architectures: x86
  3438. :Type: vcpu ioctl
  3439. :Parameters: struct kvm_x86_mce (in)
  3440. :Returns: 0 on success,
  3441. -EFAULT if struct kvm_x86_mce cannot be read,
  3442. -EINVAL if the bank number is invalid,
  3443. -EINVAL if VAL bit is not set in status field.
  3444. Inject a machine check error (MCE) into the guest. The input
  3445. parameter is::
  3446. struct kvm_x86_mce {
  3447. __u64 status;
  3448. __u64 addr;
  3449. __u64 misc;
  3450. __u64 mcg_status;
  3451. __u8 bank;
  3452. __u8 pad1[7];
  3453. __u64 pad2[3];
  3454. };
  3455. If the MCE being reported is an uncorrected error, KVM will
  3456. inject it as an MCE exception into the guest. If the guest
  3457. MCG_STATUS register reports that an MCE is in progress, KVM
  3458. causes an KVM_EXIT_SHUTDOWN vmexit.
  3459. Otherwise, if the MCE is a corrected error, KVM will just
  3460. store it in the corresponding bank (provided this bank is
  3461. not holding a previously reported uncorrected error).
  3462. 4.107 KVM_S390_GET_CMMA_BITS
  3463. ----------------------------
  3464. :Capability: KVM_CAP_S390_CMMA_MIGRATION
  3465. :Architectures: s390
  3466. :Type: vm ioctl
  3467. :Parameters: struct kvm_s390_cmma_log (in, out)
  3468. :Returns: 0 on success, a negative value on error
  3469. Errors:
  3470. ====== =============================================================
  3471. ENOMEM not enough memory can be allocated to complete the task
  3472. ENXIO if CMMA is not enabled
  3473. EINVAL if KVM_S390_CMMA_PEEK is not set but migration mode was not enabled
  3474. EINVAL if KVM_S390_CMMA_PEEK is not set but dirty tracking has been
  3475. disabled (and thus migration mode was automatically disabled)
  3476. EFAULT if the userspace address is invalid or if no page table is
  3477. present for the addresses (e.g. when using hugepages).
  3478. ====== =============================================================
  3479. This ioctl is used to get the values of the CMMA bits on the s390
  3480. architecture. It is meant to be used in two scenarios:
  3481. - During live migration to save the CMMA values. Live migration needs
  3482. to be enabled via the KVM_REQ_START_MIGRATION VM property.
  3483. - To non-destructively peek at the CMMA values, with the flag
  3484. KVM_S390_CMMA_PEEK set.
  3485. The ioctl takes parameters via the kvm_s390_cmma_log struct. The desired
  3486. values are written to a buffer whose location is indicated via the "values"
  3487. member in the kvm_s390_cmma_log struct. The values in the input struct are
  3488. also updated as needed.
  3489. Each CMMA value takes up one byte.
  3490. ::
  3491. struct kvm_s390_cmma_log {
  3492. __u64 start_gfn;
  3493. __u32 count;
  3494. __u32 flags;
  3495. union {
  3496. __u64 remaining;
  3497. __u64 mask;
  3498. };
  3499. __u64 values;
  3500. };
  3501. start_gfn is the number of the first guest frame whose CMMA values are
  3502. to be retrieved,
  3503. count is the length of the buffer in bytes,
  3504. values points to the buffer where the result will be written to.
  3505. If count is greater than KVM_S390_SKEYS_MAX, then it is considered to be
  3506. KVM_S390_SKEYS_MAX. KVM_S390_SKEYS_MAX is re-used for consistency with
  3507. other ioctls.
  3508. The result is written in the buffer pointed to by the field values, and
  3509. the values of the input parameter are updated as follows.
  3510. Depending on the flags, different actions are performed. The only
  3511. supported flag so far is KVM_S390_CMMA_PEEK.
  3512. The default behaviour if KVM_S390_CMMA_PEEK is not set is:
  3513. start_gfn will indicate the first page frame whose CMMA bits were dirty.
  3514. It is not necessarily the same as the one passed as input, as clean pages
  3515. are skipped.
  3516. count will indicate the number of bytes actually written in the buffer.
  3517. It can (and very often will) be smaller than the input value, since the
  3518. buffer is only filled until 16 bytes of clean values are found (which
  3519. are then not copied in the buffer). Since a CMMA migration block needs
  3520. the base address and the length, for a total of 16 bytes, we will send
  3521. back some clean data if there is some dirty data afterwards, as long as
  3522. the size of the clean data does not exceed the size of the header. This
  3523. allows to minimize the amount of data to be saved or transferred over
  3524. the network at the expense of more roundtrips to userspace. The next
  3525. invocation of the ioctl will skip over all the clean values, saving
  3526. potentially more than just the 16 bytes we found.
  3527. If KVM_S390_CMMA_PEEK is set:
  3528. the existing storage attributes are read even when not in migration
  3529. mode, and no other action is performed;
  3530. the output start_gfn will be equal to the input start_gfn,
  3531. the output count will be equal to the input count, except if the end of
  3532. memory has been reached.
  3533. In both cases:
  3534. the field "remaining" will indicate the total number of dirty CMMA values
  3535. still remaining, or 0 if KVM_S390_CMMA_PEEK is set and migration mode is
  3536. not enabled.
  3537. mask is unused.
  3538. values points to the userspace buffer where the result will be stored.
  3539. 4.108 KVM_S390_SET_CMMA_BITS
  3540. ----------------------------
  3541. :Capability: KVM_CAP_S390_CMMA_MIGRATION
  3542. :Architectures: s390
  3543. :Type: vm ioctl
  3544. :Parameters: struct kvm_s390_cmma_log (in)
  3545. :Returns: 0 on success, a negative value on error
  3546. This ioctl is used to set the values of the CMMA bits on the s390
  3547. architecture. It is meant to be used during live migration to restore
  3548. the CMMA values, but there are no restrictions on its use.
  3549. The ioctl takes parameters via the kvm_s390_cmma_values struct.
  3550. Each CMMA value takes up one byte.
  3551. ::
  3552. struct kvm_s390_cmma_log {
  3553. __u64 start_gfn;
  3554. __u32 count;
  3555. __u32 flags;
  3556. union {
  3557. __u64 remaining;
  3558. __u64 mask;
  3559. };
  3560. __u64 values;
  3561. };
  3562. start_gfn indicates the starting guest frame number,
  3563. count indicates how many values are to be considered in the buffer,
  3564. flags is not used and must be 0.
  3565. mask indicates which PGSTE bits are to be considered.
  3566. remaining is not used.
  3567. values points to the buffer in userspace where to store the values.
  3568. This ioctl can fail with -ENOMEM if not enough memory can be allocated to
  3569. complete the task, with -ENXIO if CMMA is not enabled, with -EINVAL if
  3570. the count field is too large (e.g. more than KVM_S390_CMMA_SIZE_MAX) or
  3571. if the flags field was not 0, with -EFAULT if the userspace address is
  3572. invalid, if invalid pages are written to (e.g. after the end of memory)
  3573. or if no page table is present for the addresses (e.g. when using
  3574. hugepages).
  3575. 4.109 KVM_PPC_GET_CPU_CHAR
  3576. --------------------------
  3577. :Capability: KVM_CAP_PPC_GET_CPU_CHAR
  3578. :Architectures: powerpc
  3579. :Type: vm ioctl
  3580. :Parameters: struct kvm_ppc_cpu_char (out)
  3581. :Returns: 0 on successful completion,
  3582. -EFAULT if struct kvm_ppc_cpu_char cannot be written
  3583. This ioctl gives userspace information about certain characteristics
  3584. of the CPU relating to speculative execution of instructions and
  3585. possible information leakage resulting from speculative execution (see
  3586. CVE-2017-5715, CVE-2017-5753 and CVE-2017-5754). The information is
  3587. returned in struct kvm_ppc_cpu_char, which looks like this::
  3588. struct kvm_ppc_cpu_char {
  3589. __u64 character; /* characteristics of the CPU */
  3590. __u64 behaviour; /* recommended software behaviour */
  3591. __u64 character_mask; /* valid bits in character */
  3592. __u64 behaviour_mask; /* valid bits in behaviour */
  3593. };
  3594. For extensibility, the character_mask and behaviour_mask fields
  3595. indicate which bits of character and behaviour have been filled in by
  3596. the kernel. If the set of defined bits is extended in future then
  3597. userspace will be able to tell whether it is running on a kernel that
  3598. knows about the new bits.
  3599. The character field describes attributes of the CPU which can help
  3600. with preventing inadvertent information disclosure - specifically,
  3601. whether there is an instruction to flash-invalidate the L1 data cache
  3602. (ori 30,30,0 or mtspr SPRN_TRIG2,rN), whether the L1 data cache is set
  3603. to a mode where entries can only be used by the thread that created
  3604. them, whether the bcctr[l] instruction prevents speculation, and
  3605. whether a speculation barrier instruction (ori 31,31,0) is provided.
  3606. The behaviour field describes actions that software should take to
  3607. prevent inadvertent information disclosure, and thus describes which
  3608. vulnerabilities the hardware is subject to; specifically whether the
  3609. L1 data cache should be flushed when returning to user mode from the
  3610. kernel, and whether a speculation barrier should be placed between an
  3611. array bounds check and the array access.
  3612. These fields use the same bit definitions as the new
  3613. H_GET_CPU_CHARACTERISTICS hypercall.
  3614. 4.110 KVM_MEMORY_ENCRYPT_OP
  3615. ---------------------------
  3616. :Capability: basic
  3617. :Architectures: x86
  3618. :Type: vm
  3619. :Parameters: an opaque platform specific structure (in/out)
  3620. :Returns: 0 on success; -1 on error
  3621. If the platform supports creating encrypted VMs then this ioctl can be used
  3622. for issuing platform-specific memory encryption commands to manage those
  3623. encrypted VMs.
  3624. Currently, this ioctl is used for issuing Secure Encrypted Virtualization
  3625. (SEV) commands on AMD Processors. The SEV commands are defined in
  3626. Documentation/virt/kvm/x86/amd-memory-encryption.rst.
  3627. 4.111 KVM_MEMORY_ENCRYPT_REG_REGION
  3628. -----------------------------------
  3629. :Capability: basic
  3630. :Architectures: x86
  3631. :Type: system
  3632. :Parameters: struct kvm_enc_region (in)
  3633. :Returns: 0 on success; -1 on error
  3634. This ioctl can be used to register a guest memory region which may
  3635. contain encrypted data (e.g. guest RAM, SMRAM etc).
  3636. It is used in the SEV-enabled guest. When encryption is enabled, a guest
  3637. memory region may contain encrypted data. The SEV memory encryption
  3638. engine uses a tweak such that two identical plaintext pages, each at
  3639. different locations will have differing ciphertexts. So swapping or
  3640. moving ciphertext of those pages will not result in plaintext being
  3641. swapped. So relocating (or migrating) physical backing pages for the SEV
  3642. guest will require some additional steps.
  3643. Note: The current SEV key management spec does not provide commands to
  3644. swap or migrate (move) ciphertext pages. Hence, for now we pin the guest
  3645. memory region registered with the ioctl.
  3646. 4.112 KVM_MEMORY_ENCRYPT_UNREG_REGION
  3647. -------------------------------------
  3648. :Capability: basic
  3649. :Architectures: x86
  3650. :Type: system
  3651. :Parameters: struct kvm_enc_region (in)
  3652. :Returns: 0 on success; -1 on error
  3653. This ioctl can be used to unregister the guest memory region registered
  3654. with KVM_MEMORY_ENCRYPT_REG_REGION ioctl above.
  3655. 4.113 KVM_HYPERV_EVENTFD
  3656. ------------------------
  3657. :Capability: KVM_CAP_HYPERV_EVENTFD
  3658. :Architectures: x86
  3659. :Type: vm ioctl
  3660. :Parameters: struct kvm_hyperv_eventfd (in)
  3661. This ioctl (un)registers an eventfd to receive notifications from the guest on
  3662. the specified Hyper-V connection id through the SIGNAL_EVENT hypercall, without
  3663. causing a user exit. SIGNAL_EVENT hypercall with non-zero event flag number
  3664. (bits 24-31) still triggers a KVM_EXIT_HYPERV_HCALL user exit.
  3665. ::
  3666. struct kvm_hyperv_eventfd {
  3667. __u32 conn_id;
  3668. __s32 fd;
  3669. __u32 flags;
  3670. __u32 padding[3];
  3671. };
  3672. The conn_id field should fit within 24 bits::
  3673. #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
  3674. The acceptable values for the flags field are::
  3675. #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
  3676. :Returns: 0 on success,
  3677. -EINVAL if conn_id or flags is outside the allowed range,
  3678. -ENOENT on deassign if the conn_id isn't registered,
  3679. -EEXIST on assign if the conn_id is already registered
  3680. 4.114 KVM_GET_NESTED_STATE
  3681. --------------------------
  3682. :Capability: KVM_CAP_NESTED_STATE
  3683. :Architectures: x86
  3684. :Type: vcpu ioctl
  3685. :Parameters: struct kvm_nested_state (in/out)
  3686. :Returns: 0 on success, -1 on error
  3687. Errors:
  3688. ===== =============================================================
  3689. E2BIG the total state size exceeds the value of 'size' specified by
  3690. the user; the size required will be written into size.
  3691. ===== =============================================================
  3692. ::
  3693. struct kvm_nested_state {
  3694. __u16 flags;
  3695. __u16 format;
  3696. __u32 size;
  3697. union {
  3698. struct kvm_vmx_nested_state_hdr vmx;
  3699. struct kvm_svm_nested_state_hdr svm;
  3700. /* Pad the header to 128 bytes. */
  3701. __u8 pad[120];
  3702. } hdr;
  3703. union {
  3704. struct kvm_vmx_nested_state_data vmx[0];
  3705. struct kvm_svm_nested_state_data svm[0];
  3706. } data;
  3707. };
  3708. #define KVM_STATE_NESTED_GUEST_MODE 0x00000001
  3709. #define KVM_STATE_NESTED_RUN_PENDING 0x00000002
  3710. #define KVM_STATE_NESTED_EVMCS 0x00000004
  3711. #define KVM_STATE_NESTED_FORMAT_VMX 0
  3712. #define KVM_STATE_NESTED_FORMAT_SVM 1
  3713. #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000
  3714. #define KVM_STATE_NESTED_VMX_SMM_GUEST_MODE 0x00000001
  3715. #define KVM_STATE_NESTED_VMX_SMM_VMXON 0x00000002
  3716. #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001
  3717. struct kvm_vmx_nested_state_hdr {
  3718. __u64 vmxon_pa;
  3719. __u64 vmcs12_pa;
  3720. struct {
  3721. __u16 flags;
  3722. } smm;
  3723. __u32 flags;
  3724. __u64 preemption_timer_deadline;
  3725. };
  3726. struct kvm_vmx_nested_state_data {
  3727. __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
  3728. __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
  3729. };
  3730. This ioctl copies the vcpu's nested virtualization state from the kernel to
  3731. userspace.
  3732. The maximum size of the state can be retrieved by passing KVM_CAP_NESTED_STATE
  3733. to the KVM_CHECK_EXTENSION ioctl().
  3734. 4.115 KVM_SET_NESTED_STATE
  3735. --------------------------
  3736. :Capability: KVM_CAP_NESTED_STATE
  3737. :Architectures: x86
  3738. :Type: vcpu ioctl
  3739. :Parameters: struct kvm_nested_state (in)
  3740. :Returns: 0 on success, -1 on error
  3741. This copies the vcpu's kvm_nested_state struct from userspace to the kernel.
  3742. For the definition of struct kvm_nested_state, see KVM_GET_NESTED_STATE.
  3743. 4.116 KVM_(UN)REGISTER_COALESCED_MMIO
  3744. -------------------------------------
  3745. :Capability: KVM_CAP_COALESCED_MMIO (for coalesced mmio)
  3746. KVM_CAP_COALESCED_PIO (for coalesced pio)
  3747. :Architectures: all
  3748. :Type: vm ioctl
  3749. :Parameters: struct kvm_coalesced_mmio_zone
  3750. :Returns: 0 on success, < 0 on error
  3751. Coalesced I/O is a performance optimization that defers hardware
  3752. register write emulation so that userspace exits are avoided. It is
  3753. typically used to reduce the overhead of emulating frequently accessed
  3754. hardware registers.
  3755. When a hardware register is configured for coalesced I/O, write accesses
  3756. do not exit to userspace and their value is recorded in a ring buffer
  3757. that is shared between kernel and userspace.
  3758. Coalesced I/O is used if one or more write accesses to a hardware
  3759. register can be deferred until a read or a write to another hardware
  3760. register on the same device. This last access will cause a vmexit and
  3761. userspace will process accesses from the ring buffer before emulating
  3762. it. That will avoid exiting to userspace on repeated writes.
  3763. Coalesced pio is based on coalesced mmio. There is little difference
  3764. between coalesced mmio and pio except that coalesced pio records accesses
  3765. to I/O ports.
  3766. 4.117 KVM_CLEAR_DIRTY_LOG (vm ioctl)
  3767. ------------------------------------
  3768. :Capability: KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
  3769. :Architectures: x86, arm64, mips
  3770. :Type: vm ioctl
  3771. :Parameters: struct kvm_clear_dirty_log (in)
  3772. :Returns: 0 on success, -1 on error
  3773. ::
  3774. /* for KVM_CLEAR_DIRTY_LOG */
  3775. struct kvm_clear_dirty_log {
  3776. __u32 slot;
  3777. __u32 num_pages;
  3778. __u64 first_page;
  3779. union {
  3780. void __user *dirty_bitmap; /* one bit per page */
  3781. __u64 padding;
  3782. };
  3783. };
  3784. The ioctl clears the dirty status of pages in a memory slot, according to
  3785. the bitmap that is passed in struct kvm_clear_dirty_log's dirty_bitmap
  3786. field. Bit 0 of the bitmap corresponds to page "first_page" in the
  3787. memory slot, and num_pages is the size in bits of the input bitmap.
  3788. first_page must be a multiple of 64; num_pages must also be a multiple of
  3789. 64 unless first_page + num_pages is the size of the memory slot. For each
  3790. bit that is set in the input bitmap, the corresponding page is marked "clean"
  3791. in KVM's dirty bitmap, and dirty tracking is re-enabled for that page
  3792. (for example via write-protection, or by clearing the dirty bit in
  3793. a page table entry).
  3794. If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of slot field specifies
  3795. the address space for which you want to clear the dirty status. See
  3796. KVM_SET_USER_MEMORY_REGION for details on the usage of slot field.
  3797. This ioctl is mostly useful when KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
  3798. is enabled; for more information, see the description of the capability.
  3799. However, it can always be used as long as KVM_CHECK_EXTENSION confirms
  3800. that KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is present.
  3801. 4.118 KVM_GET_SUPPORTED_HV_CPUID
  3802. --------------------------------
  3803. :Capability: KVM_CAP_HYPERV_CPUID (vcpu), KVM_CAP_SYS_HYPERV_CPUID (system)
  3804. :Architectures: x86
  3805. :Type: system ioctl, vcpu ioctl
  3806. :Parameters: struct kvm_cpuid2 (in/out)
  3807. :Returns: 0 on success, -1 on error
  3808. ::
  3809. struct kvm_cpuid2 {
  3810. __u32 nent;
  3811. __u32 padding;
  3812. struct kvm_cpuid_entry2 entries[0];
  3813. };
  3814. struct kvm_cpuid_entry2 {
  3815. __u32 function;
  3816. __u32 index;
  3817. __u32 flags;
  3818. __u32 eax;
  3819. __u32 ebx;
  3820. __u32 ecx;
  3821. __u32 edx;
  3822. __u32 padding[3];
  3823. };
  3824. This ioctl returns x86 cpuid features leaves related to Hyper-V emulation in
  3825. KVM. Userspace can use the information returned by this ioctl to construct
  3826. cpuid information presented to guests consuming Hyper-V enlightenments (e.g.
  3827. Windows or Hyper-V guests).
  3828. CPUID feature leaves returned by this ioctl are defined by Hyper-V Top Level
  3829. Functional Specification (TLFS). These leaves can't be obtained with
  3830. KVM_GET_SUPPORTED_CPUID ioctl because some of them intersect with KVM feature
  3831. leaves (0x40000000, 0x40000001).
  3832. Currently, the following list of CPUID leaves are returned:
  3833. - HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS
  3834. - HYPERV_CPUID_INTERFACE
  3835. - HYPERV_CPUID_VERSION
  3836. - HYPERV_CPUID_FEATURES
  3837. - HYPERV_CPUID_ENLIGHTMENT_INFO
  3838. - HYPERV_CPUID_IMPLEMENT_LIMITS
  3839. - HYPERV_CPUID_NESTED_FEATURES
  3840. - HYPERV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS
  3841. - HYPERV_CPUID_SYNDBG_INTERFACE
  3842. - HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES
  3843. Userspace invokes KVM_GET_SUPPORTED_HV_CPUID by passing a kvm_cpuid2 structure
  3844. with the 'nent' field indicating the number of entries in the variable-size
  3845. array 'entries'. If the number of entries is too low to describe all Hyper-V
  3846. feature leaves, an error (E2BIG) is returned. If the number is more or equal
  3847. to the number of Hyper-V feature leaves, the 'nent' field is adjusted to the
  3848. number of valid entries in the 'entries' array, which is then filled.
  3849. 'index' and 'flags' fields in 'struct kvm_cpuid_entry2' are currently reserved,
  3850. userspace should not expect to get any particular value there.
  3851. Note, vcpu version of KVM_GET_SUPPORTED_HV_CPUID is currently deprecated. Unlike
  3852. system ioctl which exposes all supported feature bits unconditionally, vcpu
  3853. version has the following quirks:
  3854. - HYPERV_CPUID_NESTED_FEATURES leaf and HV_X64_ENLIGHTENED_VMCS_RECOMMENDED
  3855. feature bit are only exposed when Enlightened VMCS was previously enabled
  3856. on the corresponding vCPU (KVM_CAP_HYPERV_ENLIGHTENED_VMCS).
  3857. - HV_STIMER_DIRECT_MODE_AVAILABLE bit is only exposed with in-kernel LAPIC.
  3858. (presumes KVM_CREATE_IRQCHIP has already been called).
  3859. 4.119 KVM_ARM_VCPU_FINALIZE
  3860. ---------------------------
  3861. :Architectures: arm64
  3862. :Type: vcpu ioctl
  3863. :Parameters: int feature (in)
  3864. :Returns: 0 on success, -1 on error
  3865. Errors:
  3866. ====== ==============================================================
  3867. EPERM feature not enabled, needs configuration, or already finalized
  3868. EINVAL feature unknown or not present
  3869. ====== ==============================================================
  3870. Recognised values for feature:
  3871. ===== ===========================================
  3872. arm64 KVM_ARM_VCPU_SVE (requires KVM_CAP_ARM_SVE)
  3873. ===== ===========================================
  3874. Finalizes the configuration of the specified vcpu feature.
  3875. The vcpu must already have been initialised, enabling the affected feature, by
  3876. means of a successful KVM_ARM_VCPU_INIT call with the appropriate flag set in
  3877. features[].
  3878. For affected vcpu features, this is a mandatory step that must be performed
  3879. before the vcpu is fully usable.
  3880. Between KVM_ARM_VCPU_INIT and KVM_ARM_VCPU_FINALIZE, the feature may be
  3881. configured by use of ioctls such as KVM_SET_ONE_REG. The exact configuration
  3882. that should be performaned and how to do it are feature-dependent.
  3883. Other calls that depend on a particular feature being finalized, such as
  3884. KVM_RUN, KVM_GET_REG_LIST, KVM_GET_ONE_REG and KVM_SET_ONE_REG, will fail with
  3885. -EPERM unless the feature has already been finalized by means of a
  3886. KVM_ARM_VCPU_FINALIZE call.
  3887. See KVM_ARM_VCPU_INIT for details of vcpu features that require finalization
  3888. using this ioctl.
  3889. 4.120 KVM_SET_PMU_EVENT_FILTER
  3890. ------------------------------
  3891. :Capability: KVM_CAP_PMU_EVENT_FILTER
  3892. :Architectures: x86
  3893. :Type: vm ioctl
  3894. :Parameters: struct kvm_pmu_event_filter (in)
  3895. :Returns: 0 on success, -1 on error
  3896. ::
  3897. struct kvm_pmu_event_filter {
  3898. __u32 action;
  3899. __u32 nevents;
  3900. __u32 fixed_counter_bitmap;
  3901. __u32 flags;
  3902. __u32 pad[4];
  3903. __u64 events[0];
  3904. };
  3905. This ioctl restricts the set of PMU events that the guest can program.
  3906. The argument holds a list of events which will be allowed or denied.
  3907. The eventsel+umask of each event the guest attempts to program is compared
  3908. against the events field to determine whether the guest should have access.
  3909. The events field only controls general purpose counters; fixed purpose
  3910. counters are controlled by the fixed_counter_bitmap.
  3911. No flags are defined yet, the field must be zero.
  3912. Valid values for 'action'::
  3913. #define KVM_PMU_EVENT_ALLOW 0
  3914. #define KVM_PMU_EVENT_DENY 1
  3915. 4.121 KVM_PPC_SVM_OFF
  3916. ---------------------
  3917. :Capability: basic
  3918. :Architectures: powerpc
  3919. :Type: vm ioctl
  3920. :Parameters: none
  3921. :Returns: 0 on successful completion,
  3922. Errors:
  3923. ====== ================================================================
  3924. EINVAL if ultravisor failed to terminate the secure guest
  3925. ENOMEM if hypervisor failed to allocate new radix page tables for guest
  3926. ====== ================================================================
  3927. This ioctl is used to turn off the secure mode of the guest or transition
  3928. the guest from secure mode to normal mode. This is invoked when the guest
  3929. is reset. This has no effect if called for a normal guest.
  3930. This ioctl issues an ultravisor call to terminate the secure guest,
  3931. unpins the VPA pages and releases all the device pages that are used to
  3932. track the secure pages by hypervisor.
  3933. 4.122 KVM_S390_NORMAL_RESET
  3934. ---------------------------
  3935. :Capability: KVM_CAP_S390_VCPU_RESETS
  3936. :Architectures: s390
  3937. :Type: vcpu ioctl
  3938. :Parameters: none
  3939. :Returns: 0
  3940. This ioctl resets VCPU registers and control structures according to
  3941. the cpu reset definition in the POP (Principles Of Operation).
  3942. 4.123 KVM_S390_INITIAL_RESET
  3943. ----------------------------
  3944. :Capability: none
  3945. :Architectures: s390
  3946. :Type: vcpu ioctl
  3947. :Parameters: none
  3948. :Returns: 0
  3949. This ioctl resets VCPU registers and control structures according to
  3950. the initial cpu reset definition in the POP. However, the cpu is not
  3951. put into ESA mode. This reset is a superset of the normal reset.
  3952. 4.124 KVM_S390_CLEAR_RESET
  3953. --------------------------
  3954. :Capability: KVM_CAP_S390_VCPU_RESETS
  3955. :Architectures: s390
  3956. :Type: vcpu ioctl
  3957. :Parameters: none
  3958. :Returns: 0
  3959. This ioctl resets VCPU registers and control structures according to
  3960. the clear cpu reset definition in the POP. However, the cpu is not put
  3961. into ESA mode. This reset is a superset of the initial reset.
  3962. 4.125 KVM_S390_PV_COMMAND
  3963. -------------------------
  3964. :Capability: KVM_CAP_S390_PROTECTED
  3965. :Architectures: s390
  3966. :Type: vm ioctl
  3967. :Parameters: struct kvm_pv_cmd
  3968. :Returns: 0 on success, < 0 on error
  3969. ::
  3970. struct kvm_pv_cmd {
  3971. __u32 cmd; /* Command to be executed */
  3972. __u16 rc; /* Ultravisor return code */
  3973. __u16 rrc; /* Ultravisor return reason code */
  3974. __u64 data; /* Data or address */
  3975. __u32 flags; /* flags for future extensions. Must be 0 for now */
  3976. __u32 reserved[3];
  3977. };
  3978. **Ultravisor return codes**
  3979. The Ultravisor return (reason) codes are provided by the kernel if a
  3980. Ultravisor call has been executed to achieve the results expected by
  3981. the command. Therefore they are independent of the IOCTL return
  3982. code. If KVM changes `rc`, its value will always be greater than 0
  3983. hence setting it to 0 before issuing a PV command is advised to be
  3984. able to detect a change of `rc`.
  3985. **cmd values:**
  3986. KVM_PV_ENABLE
  3987. Allocate memory and register the VM with the Ultravisor, thereby
  3988. donating memory to the Ultravisor that will become inaccessible to
  3989. KVM. All existing CPUs are converted to protected ones. After this
  3990. command has succeeded, any CPU added via hotplug will become
  3991. protected during its creation as well.
  3992. Errors:
  3993. ===== =============================
  3994. EINTR an unmasked signal is pending
  3995. ===== =============================
  3996. KVM_PV_DISABLE
  3997. Deregister the VM from the Ultravisor and reclaim the memory that
  3998. had been donated to the Ultravisor, making it usable by the kernel
  3999. again. All registered VCPUs are converted back to non-protected
  4000. ones.
  4001. KVM_PV_VM_SET_SEC_PARMS
  4002. Pass the image header from VM memory to the Ultravisor in
  4003. preparation of image unpacking and verification.
  4004. KVM_PV_VM_UNPACK
  4005. Unpack (protect and decrypt) a page of the encrypted boot image.
  4006. KVM_PV_VM_VERIFY
  4007. Verify the integrity of the unpacked image. Only if this succeeds,
  4008. KVM is allowed to start protected VCPUs.
  4009. KVM_PV_INFO
  4010. :Capability: KVM_CAP_S390_PROTECTED_DUMP
  4011. Presents an API that provides Ultravisor related data to userspace
  4012. via subcommands. len_max is the size of the user space buffer,
  4013. len_written is KVM's indication of how much bytes of that buffer
  4014. were actually written to. len_written can be used to determine the
  4015. valid fields if more response fields are added in the future.
  4016. ::
  4017. enum pv_cmd_info_id {
  4018. KVM_PV_INFO_VM,
  4019. KVM_PV_INFO_DUMP,
  4020. };
  4021. struct kvm_s390_pv_info_header {
  4022. __u32 id;
  4023. __u32 len_max;
  4024. __u32 len_written;
  4025. __u32 reserved;
  4026. };
  4027. struct kvm_s390_pv_info {
  4028. struct kvm_s390_pv_info_header header;
  4029. struct kvm_s390_pv_info_dump dump;
  4030. struct kvm_s390_pv_info_vm vm;
  4031. };
  4032. **subcommands:**
  4033. KVM_PV_INFO_VM
  4034. This subcommand provides basic Ultravisor information for PV
  4035. hosts. These values are likely also exported as files in the sysfs
  4036. firmware UV query interface but they are more easily available to
  4037. programs in this API.
  4038. The installed calls and feature_indication members provide the
  4039. installed UV calls and the UV's other feature indications.
  4040. The max_* members provide information about the maximum number of PV
  4041. vcpus, PV guests and PV guest memory size.
  4042. ::
  4043. struct kvm_s390_pv_info_vm {
  4044. __u64 inst_calls_list[4];
  4045. __u64 max_cpus;
  4046. __u64 max_guests;
  4047. __u64 max_guest_addr;
  4048. __u64 feature_indication;
  4049. };
  4050. KVM_PV_INFO_DUMP
  4051. This subcommand provides information related to dumping PV guests.
  4052. ::
  4053. struct kvm_s390_pv_info_dump {
  4054. __u64 dump_cpu_buffer_len;
  4055. __u64 dump_config_mem_buffer_per_1m;
  4056. __u64 dump_config_finalize_len;
  4057. };
  4058. KVM_PV_DUMP
  4059. :Capability: KVM_CAP_S390_PROTECTED_DUMP
  4060. Presents an API that provides calls which facilitate dumping a
  4061. protected VM.
  4062. ::
  4063. struct kvm_s390_pv_dmp {
  4064. __u64 subcmd;
  4065. __u64 buff_addr;
  4066. __u64 buff_len;
  4067. __u64 gaddr; /* For dump storage state */
  4068. };
  4069. **subcommands:**
  4070. KVM_PV_DUMP_INIT
  4071. Initializes the dump process of a protected VM. If this call does
  4072. not succeed all other subcommands will fail with -EINVAL. This
  4073. subcommand will return -EINVAL if a dump process has not yet been
  4074. completed.
  4075. Not all PV vms can be dumped, the owner needs to set `dump
  4076. allowed` PCF bit 34 in the SE header to allow dumping.
  4077. KVM_PV_DUMP_CONFIG_STOR_STATE
  4078. Stores `buff_len` bytes of tweak component values starting with
  4079. the 1MB block specified by the absolute guest address
  4080. (`gaddr`). `buff_len` needs to be `conf_dump_storage_state_len`
  4081. aligned and at least >= the `conf_dump_storage_state_len` value
  4082. provided by the dump uv_info data. buff_user might be written to
  4083. even if an error rc is returned. For instance if we encounter a
  4084. fault after writing the first page of data.
  4085. KVM_PV_DUMP_COMPLETE
  4086. If the subcommand succeeds it completes the dump process and lets
  4087. KVM_PV_DUMP_INIT be called again.
  4088. On success `conf_dump_finalize_len` bytes of completion data will be
  4089. stored to the `buff_addr`. The completion data contains a key
  4090. derivation seed, IV, tweak nonce and encryption keys as well as an
  4091. authentication tag all of which are needed to decrypt the dump at a
  4092. later time.
  4093. 4.126 KVM_XEN_HVM_SET_ATTR
  4094. --------------------------
  4095. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO
  4096. :Architectures: x86
  4097. :Type: vm ioctl
  4098. :Parameters: struct kvm_xen_hvm_attr
  4099. :Returns: 0 on success, < 0 on error
  4100. ::
  4101. struct kvm_xen_hvm_attr {
  4102. __u16 type;
  4103. __u16 pad[3];
  4104. union {
  4105. __u8 long_mode;
  4106. __u8 vector;
  4107. struct {
  4108. __u64 gfn;
  4109. } shared_info;
  4110. struct {
  4111. __u32 send_port;
  4112. __u32 type; /* EVTCHNSTAT_ipi / EVTCHNSTAT_interdomain */
  4113. __u32 flags;
  4114. union {
  4115. struct {
  4116. __u32 port;
  4117. __u32 vcpu;
  4118. __u32 priority;
  4119. } port;
  4120. struct {
  4121. __u32 port; /* Zero for eventfd */
  4122. __s32 fd;
  4123. } eventfd;
  4124. __u32 padding[4];
  4125. } deliver;
  4126. } evtchn;
  4127. __u32 xen_version;
  4128. __u64 pad[8];
  4129. } u;
  4130. };
  4131. type values:
  4132. KVM_XEN_ATTR_TYPE_LONG_MODE
  4133. Sets the ABI mode of the VM to 32-bit or 64-bit (long mode). This
  4134. determines the layout of the shared info pages exposed to the VM.
  4135. KVM_XEN_ATTR_TYPE_SHARED_INFO
  4136. Sets the guest physical frame number at which the Xen "shared info"
  4137. page resides. Note that although Xen places vcpu_info for the first
  4138. 32 vCPUs in the shared_info page, KVM does not automatically do so
  4139. and instead requires that KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO be used
  4140. explicitly even when the vcpu_info for a given vCPU resides at the
  4141. "default" location in the shared_info page. This is because KVM is
  4142. not aware of the Xen CPU id which is used as the index into the
  4143. vcpu_info[] array, so cannot know the correct default location.
  4144. Note that the shared info page may be constantly written to by KVM;
  4145. it contains the event channel bitmap used to deliver interrupts to
  4146. a Xen guest, amongst other things. It is exempt from dirty tracking
  4147. mechanisms — KVM will not explicitly mark the page as dirty each
  4148. time an event channel interrupt is delivered to the guest! Thus,
  4149. userspace should always assume that the designated GFN is dirty if
  4150. any vCPU has been running or any event channel interrupts can be
  4151. routed to the guest.
  4152. KVM_XEN_ATTR_TYPE_UPCALL_VECTOR
  4153. Sets the exception vector used to deliver Xen event channel upcalls.
  4154. This is the HVM-wide vector injected directly by the hypervisor
  4155. (not through the local APIC), typically configured by a guest via
  4156. HVM_PARAM_CALLBACK_IRQ.
  4157. KVM_XEN_ATTR_TYPE_EVTCHN
  4158. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4159. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It configures
  4160. an outbound port number for interception of EVTCHNOP_send requests
  4161. from the guest. A given sending port number may be directed back
  4162. to a specified vCPU (by APIC ID) / port / priority on the guest,
  4163. or to trigger events on an eventfd. The vCPU and priority can be
  4164. changed by setting KVM_XEN_EVTCHN_UPDATE in a subsequent call,
  4165. but other fields cannot change for a given sending port. A port
  4166. mapping is removed by using KVM_XEN_EVTCHN_DEASSIGN in the flags
  4167. field.
  4168. KVM_XEN_ATTR_TYPE_XEN_VERSION
  4169. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4170. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It configures
  4171. the 32-bit version code returned to the guest when it invokes the
  4172. XENVER_version call; typically (XEN_MAJOR << 16 | XEN_MINOR). PV
  4173. Xen guests will often use this to as a dummy hypercall to trigger
  4174. event channel delivery, so responding within the kernel without
  4175. exiting to userspace is beneficial.
  4176. 4.127 KVM_XEN_HVM_GET_ATTR
  4177. --------------------------
  4178. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO
  4179. :Architectures: x86
  4180. :Type: vm ioctl
  4181. :Parameters: struct kvm_xen_hvm_attr
  4182. :Returns: 0 on success, < 0 on error
  4183. Allows Xen VM attributes to be read. For the structure and types,
  4184. see KVM_XEN_HVM_SET_ATTR above. The KVM_XEN_ATTR_TYPE_EVTCHN
  4185. attribute cannot be read.
  4186. 4.128 KVM_XEN_VCPU_SET_ATTR
  4187. ---------------------------
  4188. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO
  4189. :Architectures: x86
  4190. :Type: vcpu ioctl
  4191. :Parameters: struct kvm_xen_vcpu_attr
  4192. :Returns: 0 on success, < 0 on error
  4193. ::
  4194. struct kvm_xen_vcpu_attr {
  4195. __u16 type;
  4196. __u16 pad[3];
  4197. union {
  4198. __u64 gpa;
  4199. __u64 pad[4];
  4200. struct {
  4201. __u64 state;
  4202. __u64 state_entry_time;
  4203. __u64 time_running;
  4204. __u64 time_runnable;
  4205. __u64 time_blocked;
  4206. __u64 time_offline;
  4207. } runstate;
  4208. __u32 vcpu_id;
  4209. struct {
  4210. __u32 port;
  4211. __u32 priority;
  4212. __u64 expires_ns;
  4213. } timer;
  4214. __u8 vector;
  4215. } u;
  4216. };
  4217. type values:
  4218. KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO
  4219. Sets the guest physical address of the vcpu_info for a given vCPU.
  4220. As with the shared_info page for the VM, the corresponding page may be
  4221. dirtied at any time if event channel interrupt delivery is enabled, so
  4222. userspace should always assume that the page is dirty without relying
  4223. on dirty logging.
  4224. KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO
  4225. Sets the guest physical address of an additional pvclock structure
  4226. for a given vCPU. This is typically used for guest vsyscall support.
  4227. KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR
  4228. Sets the guest physical address of the vcpu_runstate_info for a given
  4229. vCPU. This is how a Xen guest tracks CPU state such as steal time.
  4230. KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT
  4231. Sets the runstate (RUNSTATE_running/_runnable/_blocked/_offline) of
  4232. the given vCPU from the .u.runstate.state member of the structure.
  4233. KVM automatically accounts running and runnable time but blocked
  4234. and offline states are only entered explicitly.
  4235. KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA
  4236. Sets all fields of the vCPU runstate data from the .u.runstate member
  4237. of the structure, including the current runstate. The state_entry_time
  4238. must equal the sum of the other four times.
  4239. KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST
  4240. This *adds* the contents of the .u.runstate members of the structure
  4241. to the corresponding members of the given vCPU's runstate data, thus
  4242. permitting atomic adjustments to the runstate times. The adjustment
  4243. to the state_entry_time must equal the sum of the adjustments to the
  4244. other four times. The state field must be set to -1, or to a valid
  4245. runstate value (RUNSTATE_running, RUNSTATE_runnable, RUNSTATE_blocked
  4246. or RUNSTATE_offline) to set the current accounted state as of the
  4247. adjusted state_entry_time.
  4248. KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID
  4249. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4250. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the Xen
  4251. vCPU ID of the given vCPU, to allow timer-related VCPU operations to
  4252. be intercepted by KVM.
  4253. KVM_XEN_VCPU_ATTR_TYPE_TIMER
  4254. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4255. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the
  4256. event channel port/priority for the VIRQ_TIMER of the vCPU, as well
  4257. as allowing a pending timer to be saved/restored.
  4258. KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR
  4259. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4260. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the
  4261. per-vCPU local APIC upcall vector, configured by a Xen guest with
  4262. the HVMOP_set_evtchn_upcall_vector hypercall. This is typically
  4263. used by Windows guests, and is distinct from the HVM-wide upcall
  4264. vector configured with HVM_PARAM_CALLBACK_IRQ.
  4265. 4.129 KVM_XEN_VCPU_GET_ATTR
  4266. ---------------------------
  4267. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO
  4268. :Architectures: x86
  4269. :Type: vcpu ioctl
  4270. :Parameters: struct kvm_xen_vcpu_attr
  4271. :Returns: 0 on success, < 0 on error
  4272. Allows Xen vCPU attributes to be read. For the structure and types,
  4273. see KVM_XEN_VCPU_SET_ATTR above.
  4274. The KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST type may not be used
  4275. with the KVM_XEN_VCPU_GET_ATTR ioctl.
  4276. 4.130 KVM_ARM_MTE_COPY_TAGS
  4277. ---------------------------
  4278. :Capability: KVM_CAP_ARM_MTE
  4279. :Architectures: arm64
  4280. :Type: vm ioctl
  4281. :Parameters: struct kvm_arm_copy_mte_tags
  4282. :Returns: number of bytes copied, < 0 on error (-EINVAL for incorrect
  4283. arguments, -EFAULT if memory cannot be accessed).
  4284. ::
  4285. struct kvm_arm_copy_mte_tags {
  4286. __u64 guest_ipa;
  4287. __u64 length;
  4288. void __user *addr;
  4289. __u64 flags;
  4290. __u64 reserved[2];
  4291. };
  4292. Copies Memory Tagging Extension (MTE) tags to/from guest tag memory. The
  4293. ``guest_ipa`` and ``length`` fields must be ``PAGE_SIZE`` aligned. The ``addr``
  4294. field must point to a buffer which the tags will be copied to or from.
  4295. ``flags`` specifies the direction of copy, either ``KVM_ARM_TAGS_TO_GUEST`` or
  4296. ``KVM_ARM_TAGS_FROM_GUEST``.
  4297. The size of the buffer to store the tags is ``(length / 16)`` bytes
  4298. (granules in MTE are 16 bytes long). Each byte contains a single tag
  4299. value. This matches the format of ``PTRACE_PEEKMTETAGS`` and
  4300. ``PTRACE_POKEMTETAGS``.
  4301. If an error occurs before any data is copied then a negative error code is
  4302. returned. If some tags have been copied before an error occurs then the number
  4303. of bytes successfully copied is returned. If the call completes successfully
  4304. then ``length`` is returned.
  4305. 4.131 KVM_GET_SREGS2
  4306. --------------------
  4307. :Capability: KVM_CAP_SREGS2
  4308. :Architectures: x86
  4309. :Type: vcpu ioctl
  4310. :Parameters: struct kvm_sregs2 (out)
  4311. :Returns: 0 on success, -1 on error
  4312. Reads special registers from the vcpu.
  4313. This ioctl (when supported) replaces the KVM_GET_SREGS.
  4314. ::
  4315. struct kvm_sregs2 {
  4316. /* out (KVM_GET_SREGS2) / in (KVM_SET_SREGS2) */
  4317. struct kvm_segment cs, ds, es, fs, gs, ss;
  4318. struct kvm_segment tr, ldt;
  4319. struct kvm_dtable gdt, idt;
  4320. __u64 cr0, cr2, cr3, cr4, cr8;
  4321. __u64 efer;
  4322. __u64 apic_base;
  4323. __u64 flags;
  4324. __u64 pdptrs[4];
  4325. };
  4326. flags values for ``kvm_sregs2``:
  4327. ``KVM_SREGS2_FLAGS_PDPTRS_VALID``
  4328. Indicates thats the struct contain valid PDPTR values.
  4329. 4.132 KVM_SET_SREGS2
  4330. --------------------
  4331. :Capability: KVM_CAP_SREGS2
  4332. :Architectures: x86
  4333. :Type: vcpu ioctl
  4334. :Parameters: struct kvm_sregs2 (in)
  4335. :Returns: 0 on success, -1 on error
  4336. Writes special registers into the vcpu.
  4337. See KVM_GET_SREGS2 for the data structures.
  4338. This ioctl (when supported) replaces the KVM_SET_SREGS.
  4339. 4.133 KVM_GET_STATS_FD
  4340. ----------------------
  4341. :Capability: KVM_CAP_STATS_BINARY_FD
  4342. :Architectures: all
  4343. :Type: vm ioctl, vcpu ioctl
  4344. :Parameters: none
  4345. :Returns: statistics file descriptor on success, < 0 on error
  4346. Errors:
  4347. ====== ======================================================
  4348. ENOMEM if the fd could not be created due to lack of memory
  4349. EMFILE if the number of opened files exceeds the limit
  4350. ====== ======================================================
  4351. The returned file descriptor can be used to read VM/vCPU statistics data in
  4352. binary format. The data in the file descriptor consists of four blocks
  4353. organized as follows:
  4354. +-------------+
  4355. | Header |
  4356. +-------------+
  4357. | id string |
  4358. +-------------+
  4359. | Descriptors |
  4360. +-------------+
  4361. | Stats Data |
  4362. +-------------+
  4363. Apart from the header starting at offset 0, please be aware that it is
  4364. not guaranteed that the four blocks are adjacent or in the above order;
  4365. the offsets of the id, descriptors and data blocks are found in the
  4366. header. However, all four blocks are aligned to 64 bit offsets in the
  4367. file and they do not overlap.
  4368. All blocks except the data block are immutable. Userspace can read them
  4369. only one time after retrieving the file descriptor, and then use ``pread`` or
  4370. ``lseek`` to read the statistics repeatedly.
  4371. All data is in system endianness.
  4372. The format of the header is as follows::
  4373. struct kvm_stats_header {
  4374. __u32 flags;
  4375. __u32 name_size;
  4376. __u32 num_desc;
  4377. __u32 id_offset;
  4378. __u32 desc_offset;
  4379. __u32 data_offset;
  4380. };
  4381. The ``flags`` field is not used at the moment. It is always read as 0.
  4382. The ``name_size`` field is the size (in byte) of the statistics name string
  4383. (including trailing '\0') which is contained in the "id string" block and
  4384. appended at the end of every descriptor.
  4385. The ``num_desc`` field is the number of descriptors that are included in the
  4386. descriptor block. (The actual number of values in the data block may be
  4387. larger, since each descriptor may comprise more than one value).
  4388. The ``id_offset`` field is the offset of the id string from the start of the
  4389. file indicated by the file descriptor. It is a multiple of 8.
  4390. The ``desc_offset`` field is the offset of the Descriptors block from the start
  4391. of the file indicated by the file descriptor. It is a multiple of 8.
  4392. The ``data_offset`` field is the offset of the Stats Data block from the start
  4393. of the file indicated by the file descriptor. It is a multiple of 8.
  4394. The id string block contains a string which identifies the file descriptor on
  4395. which KVM_GET_STATS_FD was invoked. The size of the block, including the
  4396. trailing ``'\0'``, is indicated by the ``name_size`` field in the header.
  4397. The descriptors block is only needed to be read once for the lifetime of the
  4398. file descriptor contains a sequence of ``struct kvm_stats_desc``, each followed
  4399. by a string of size ``name_size``.
  4400. ::
  4401. #define KVM_STATS_TYPE_SHIFT 0
  4402. #define KVM_STATS_TYPE_MASK (0xF << KVM_STATS_TYPE_SHIFT)
  4403. #define KVM_STATS_TYPE_CUMULATIVE (0x0 << KVM_STATS_TYPE_SHIFT)
  4404. #define KVM_STATS_TYPE_INSTANT (0x1 << KVM_STATS_TYPE_SHIFT)
  4405. #define KVM_STATS_TYPE_PEAK (0x2 << KVM_STATS_TYPE_SHIFT)
  4406. #define KVM_STATS_TYPE_LINEAR_HIST (0x3 << KVM_STATS_TYPE_SHIFT)
  4407. #define KVM_STATS_TYPE_LOG_HIST (0x4 << KVM_STATS_TYPE_SHIFT)
  4408. #define KVM_STATS_TYPE_MAX KVM_STATS_TYPE_LOG_HIST
  4409. #define KVM_STATS_UNIT_SHIFT 4
  4410. #define KVM_STATS_UNIT_MASK (0xF << KVM_STATS_UNIT_SHIFT)
  4411. #define KVM_STATS_UNIT_NONE (0x0 << KVM_STATS_UNIT_SHIFT)
  4412. #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT)
  4413. #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
  4414. #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
  4415. #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)
  4416. #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN
  4417. #define KVM_STATS_BASE_SHIFT 8
  4418. #define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT)
  4419. #define KVM_STATS_BASE_POW10 (0x0 << KVM_STATS_BASE_SHIFT)
  4420. #define KVM_STATS_BASE_POW2 (0x1 << KVM_STATS_BASE_SHIFT)
  4421. #define KVM_STATS_BASE_MAX KVM_STATS_BASE_POW2
  4422. struct kvm_stats_desc {
  4423. __u32 flags;
  4424. __s16 exponent;
  4425. __u16 size;
  4426. __u32 offset;
  4427. __u32 bucket_size;
  4428. char name[];
  4429. };
  4430. The ``flags`` field contains the type and unit of the statistics data described
  4431. by this descriptor. Its endianness is CPU native.
  4432. The following flags are supported:
  4433. Bits 0-3 of ``flags`` encode the type:
  4434. * ``KVM_STATS_TYPE_CUMULATIVE``
  4435. The statistics reports a cumulative count. The value of data can only be increased.
  4436. Most of the counters used in KVM are of this type.
  4437. The corresponding ``size`` field for this type is always 1.
  4438. All cumulative statistics data are read/write.
  4439. * ``KVM_STATS_TYPE_INSTANT``
  4440. The statistics reports an instantaneous value. Its value can be increased or
  4441. decreased. This type is usually used as a measurement of some resources,
  4442. like the number of dirty pages, the number of large pages, etc.
  4443. All instant statistics are read only.
  4444. The corresponding ``size`` field for this type is always 1.
  4445. * ``KVM_STATS_TYPE_PEAK``
  4446. The statistics data reports a peak value, for example the maximum number
  4447. of items in a hash table bucket, the longest time waited and so on.
  4448. The value of data can only be increased.
  4449. The corresponding ``size`` field for this type is always 1.
  4450. * ``KVM_STATS_TYPE_LINEAR_HIST``
  4451. The statistic is reported as a linear histogram. The number of
  4452. buckets is specified by the ``size`` field. The size of buckets is specified
  4453. by the ``hist_param`` field. The range of the Nth bucket (1 <= N < ``size``)
  4454. is [``hist_param``*(N-1), ``hist_param``*N), while the range of the last
  4455. bucket is [``hist_param``*(``size``-1), +INF). (+INF means positive infinity
  4456. value.)
  4457. * ``KVM_STATS_TYPE_LOG_HIST``
  4458. The statistic is reported as a logarithmic histogram. The number of
  4459. buckets is specified by the ``size`` field. The range of the first bucket is
  4460. [0, 1), while the range of the last bucket is [pow(2, ``size``-2), +INF).
  4461. Otherwise, The Nth bucket (1 < N < ``size``) covers
  4462. [pow(2, N-2), pow(2, N-1)).
  4463. Bits 4-7 of ``flags`` encode the unit:
  4464. * ``KVM_STATS_UNIT_NONE``
  4465. There is no unit for the value of statistics data. This usually means that
  4466. the value is a simple counter of an event.
  4467. * ``KVM_STATS_UNIT_BYTES``
  4468. It indicates that the statistics data is used to measure memory size, in the
  4469. unit of Byte, KiByte, MiByte, GiByte, etc. The unit of the data is
  4470. determined by the ``exponent`` field in the descriptor.
  4471. * ``KVM_STATS_UNIT_SECONDS``
  4472. It indicates that the statistics data is used to measure time or latency.
  4473. * ``KVM_STATS_UNIT_CYCLES``
  4474. It indicates that the statistics data is used to measure CPU clock cycles.
  4475. * ``KVM_STATS_UNIT_BOOLEAN``
  4476. It indicates that the statistic will always be either 0 or 1. Boolean
  4477. statistics of "peak" type will never go back from 1 to 0. Boolean
  4478. statistics can be linear histograms (with two buckets) but not logarithmic
  4479. histograms.
  4480. Note that, in the case of histograms, the unit applies to the bucket
  4481. ranges, while the bucket value indicates how many samples fell in the
  4482. bucket's range.
  4483. Bits 8-11 of ``flags``, together with ``exponent``, encode the scale of the
  4484. unit:
  4485. * ``KVM_STATS_BASE_POW10``
  4486. The scale is based on power of 10. It is used for measurement of time and
  4487. CPU clock cycles. For example, an exponent of -9 can be used with
  4488. ``KVM_STATS_UNIT_SECONDS`` to express that the unit is nanoseconds.
  4489. * ``KVM_STATS_BASE_POW2``
  4490. The scale is based on power of 2. It is used for measurement of memory size.
  4491. For example, an exponent of 20 can be used with ``KVM_STATS_UNIT_BYTES`` to
  4492. express that the unit is MiB.
  4493. The ``size`` field is the number of values of this statistics data. Its
  4494. value is usually 1 for most of simple statistics. 1 means it contains an
  4495. unsigned 64bit data.
  4496. The ``offset`` field is the offset from the start of Data Block to the start of
  4497. the corresponding statistics data.
  4498. The ``bucket_size`` field is used as a parameter for histogram statistics data.
  4499. It is only used by linear histogram statistics data, specifying the size of a
  4500. bucket in the unit expressed by bits 4-11 of ``flags`` together with ``exponent``.
  4501. The ``name`` field is the name string of the statistics data. The name string
  4502. starts at the end of ``struct kvm_stats_desc``. The maximum length including
  4503. the trailing ``'\0'``, is indicated by ``name_size`` in the header.
  4504. The Stats Data block contains an array of 64-bit values in the same order
  4505. as the descriptors in Descriptors block.
  4506. 4.134 KVM_GET_XSAVE2
  4507. --------------------
  4508. :Capability: KVM_CAP_XSAVE2
  4509. :Architectures: x86
  4510. :Type: vcpu ioctl
  4511. :Parameters: struct kvm_xsave (out)
  4512. :Returns: 0 on success, -1 on error
  4513. ::
  4514. struct kvm_xsave {
  4515. __u32 region[1024];
  4516. __u32 extra[0];
  4517. };
  4518. This ioctl would copy current vcpu's xsave struct to the userspace. It
  4519. copies as many bytes as are returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)
  4520. when invoked on the vm file descriptor. The size value returned by
  4521. KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will always be at least 4096.
  4522. Currently, it is only greater than 4096 if a dynamic feature has been
  4523. enabled with ``arch_prctl()``, but this may change in the future.
  4524. The offsets of the state save areas in struct kvm_xsave follow the contents
  4525. of CPUID leaf 0xD on the host.
  4526. 4.135 KVM_XEN_HVM_EVTCHN_SEND
  4527. -----------------------------
  4528. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND
  4529. :Architectures: x86
  4530. :Type: vm ioctl
  4531. :Parameters: struct kvm_irq_routing_xen_evtchn
  4532. :Returns: 0 on success, < 0 on error
  4533. ::
  4534. struct kvm_irq_routing_xen_evtchn {
  4535. __u32 port;
  4536. __u32 vcpu;
  4537. __u32 priority;
  4538. };
  4539. This ioctl injects an event channel interrupt directly to the guest vCPU.
  4540. 4.136 KVM_S390_PV_CPU_COMMAND
  4541. -----------------------------
  4542. :Capability: KVM_CAP_S390_PROTECTED_DUMP
  4543. :Architectures: s390
  4544. :Type: vcpu ioctl
  4545. :Parameters: none
  4546. :Returns: 0 on success, < 0 on error
  4547. This ioctl closely mirrors `KVM_S390_PV_COMMAND` but handles requests
  4548. for vcpus. It re-uses the kvm_s390_pv_dmp struct and hence also shares
  4549. the command ids.
  4550. **command:**
  4551. KVM_PV_DUMP
  4552. Presents an API that provides calls which facilitate dumping a vcpu
  4553. of a protected VM.
  4554. **subcommand:**
  4555. KVM_PV_DUMP_CPU
  4556. Provides encrypted dump data like register values.
  4557. The length of the returned data is provided by uv_info.guest_cpu_stor_len.
  4558. 4.137 KVM_S390_ZPCI_OP
  4559. ----------------------
  4560. :Capability: KVM_CAP_S390_ZPCI_OP
  4561. :Architectures: s390
  4562. :Type: vm ioctl
  4563. :Parameters: struct kvm_s390_zpci_op (in)
  4564. :Returns: 0 on success, <0 on error
  4565. Used to manage hardware-assisted virtualization features for zPCI devices.
  4566. Parameters are specified via the following structure::
  4567. struct kvm_s390_zpci_op {
  4568. /* in */
  4569. __u32 fh; /* target device */
  4570. __u8 op; /* operation to perform */
  4571. __u8 pad[3];
  4572. union {
  4573. /* for KVM_S390_ZPCIOP_REG_AEN */
  4574. struct {
  4575. __u64 ibv; /* Guest addr of interrupt bit vector */
  4576. __u64 sb; /* Guest addr of summary bit */
  4577. __u32 flags;
  4578. __u32 noi; /* Number of interrupts */
  4579. __u8 isc; /* Guest interrupt subclass */
  4580. __u8 sbo; /* Offset of guest summary bit vector */
  4581. __u16 pad;
  4582. } reg_aen;
  4583. __u64 reserved[8];
  4584. } u;
  4585. };
  4586. The type of operation is specified in the "op" field.
  4587. KVM_S390_ZPCIOP_REG_AEN is used to register the VM for adapter event
  4588. notification interpretation, which will allow firmware delivery of adapter
  4589. events directly to the vm, with KVM providing a backup delivery mechanism;
  4590. KVM_S390_ZPCIOP_DEREG_AEN is used to subsequently disable interpretation of
  4591. adapter event notifications.
  4592. The target zPCI function must also be specified via the "fh" field. For the
  4593. KVM_S390_ZPCIOP_REG_AEN operation, additional information to establish firmware
  4594. delivery must be provided via the "reg_aen" struct.
  4595. The "pad" and "reserved" fields may be used for future extensions and should be
  4596. set to 0s by userspace.
  4597. 5. The kvm_run structure
  4598. ========================
  4599. Application code obtains a pointer to the kvm_run structure by
  4600. mmap()ing a vcpu fd. From that point, application code can control
  4601. execution by changing fields in kvm_run prior to calling the KVM_RUN
  4602. ioctl, and obtain information about the reason KVM_RUN returned by
  4603. looking up structure members.
  4604. ::
  4605. struct kvm_run {
  4606. /* in */
  4607. __u8 request_interrupt_window;
  4608. Request that KVM_RUN return when it becomes possible to inject external
  4609. interrupts into the guest. Useful in conjunction with KVM_INTERRUPT.
  4610. ::
  4611. __u8 immediate_exit;
  4612. This field is polled once when KVM_RUN starts; if non-zero, KVM_RUN
  4613. exits immediately, returning -EINTR. In the common scenario where a
  4614. signal is used to "kick" a VCPU out of KVM_RUN, this field can be used
  4615. to avoid usage of KVM_SET_SIGNAL_MASK, which has worse scalability.
  4616. Rather than blocking the signal outside KVM_RUN, userspace can set up
  4617. a signal handler that sets run->immediate_exit to a non-zero value.
  4618. This field is ignored if KVM_CAP_IMMEDIATE_EXIT is not available.
  4619. ::
  4620. __u8 padding1[6];
  4621. /* out */
  4622. __u32 exit_reason;
  4623. When KVM_RUN has returned successfully (return value 0), this informs
  4624. application code why KVM_RUN has returned. Allowable values for this
  4625. field are detailed below.
  4626. ::
  4627. __u8 ready_for_interrupt_injection;
  4628. If request_interrupt_window has been specified, this field indicates
  4629. an interrupt can be injected now with KVM_INTERRUPT.
  4630. ::
  4631. __u8 if_flag;
  4632. The value of the current interrupt flag. Only valid if in-kernel
  4633. local APIC is not used.
  4634. ::
  4635. __u16 flags;
  4636. More architecture-specific flags detailing state of the VCPU that may
  4637. affect the device's behavior. Current defined flags::
  4638. /* x86, set if the VCPU is in system management mode */
  4639. #define KVM_RUN_X86_SMM (1 << 0)
  4640. /* x86, set if bus lock detected in VM */
  4641. #define KVM_RUN_BUS_LOCK (1 << 1)
  4642. /* arm64, set for KVM_EXIT_DEBUG */
  4643. #define KVM_DEBUG_ARCH_HSR_HIGH_VALID (1 << 0)
  4644. ::
  4645. /* in (pre_kvm_run), out (post_kvm_run) */
  4646. __u64 cr8;
  4647. The value of the cr8 register. Only valid if in-kernel local APIC is
  4648. not used. Both input and output.
  4649. ::
  4650. __u64 apic_base;
  4651. The value of the APIC BASE msr. Only valid if in-kernel local
  4652. APIC is not used. Both input and output.
  4653. ::
  4654. union {
  4655. /* KVM_EXIT_UNKNOWN */
  4656. struct {
  4657. __u64 hardware_exit_reason;
  4658. } hw;
  4659. If exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown
  4660. reasons. Further architecture-specific information is available in
  4661. hardware_exit_reason.
  4662. ::
  4663. /* KVM_EXIT_FAIL_ENTRY */
  4664. struct {
  4665. __u64 hardware_entry_failure_reason;
  4666. __u32 cpu; /* if KVM_LAST_CPU */
  4667. } fail_entry;
  4668. If exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due
  4669. to unknown reasons. Further architecture-specific information is
  4670. available in hardware_entry_failure_reason.
  4671. ::
  4672. /* KVM_EXIT_EXCEPTION */
  4673. struct {
  4674. __u32 exception;
  4675. __u32 error_code;
  4676. } ex;
  4677. Unused.
  4678. ::
  4679. /* KVM_EXIT_IO */
  4680. struct {
  4681. #define KVM_EXIT_IO_IN 0
  4682. #define KVM_EXIT_IO_OUT 1
  4683. __u8 direction;
  4684. __u8 size; /* bytes */
  4685. __u16 port;
  4686. __u32 count;
  4687. __u64 data_offset; /* relative to kvm_run start */
  4688. } io;
  4689. If exit_reason is KVM_EXIT_IO, then the vcpu has
  4690. executed a port I/O instruction which could not be satisfied by kvm.
  4691. data_offset describes where the data is located (KVM_EXIT_IO_OUT) or
  4692. where kvm expects application code to place the data for the next
  4693. KVM_RUN invocation (KVM_EXIT_IO_IN). Data format is a packed array.
  4694. ::
  4695. /* KVM_EXIT_DEBUG */
  4696. struct {
  4697. struct kvm_debug_exit_arch arch;
  4698. } debug;
  4699. If the exit_reason is KVM_EXIT_DEBUG, then a vcpu is processing a debug event
  4700. for which architecture specific information is returned.
  4701. ::
  4702. /* KVM_EXIT_MMIO */
  4703. struct {
  4704. __u64 phys_addr;
  4705. __u8 data[8];
  4706. __u32 len;
  4707. __u8 is_write;
  4708. } mmio;
  4709. If exit_reason is KVM_EXIT_MMIO, then the vcpu has
  4710. executed a memory-mapped I/O instruction which could not be satisfied
  4711. by kvm. The 'data' member contains the written data if 'is_write' is
  4712. true, and should be filled by application code otherwise.
  4713. The 'data' member contains, in its first 'len' bytes, the value as it would
  4714. appear if the VCPU performed a load or store of the appropriate width directly
  4715. to the byte array.
  4716. .. note::
  4717. For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR, KVM_EXIT_XEN,
  4718. KVM_EXIT_EPR, KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR the corresponding
  4719. operations are complete (and guest state is consistent) only after userspace
  4720. has re-entered the kernel with KVM_RUN. The kernel side will first finish
  4721. incomplete operations and then check for pending signals.
  4722. The pending state of the operation is not preserved in state which is
  4723. visible to userspace, thus userspace should ensure that the operation is
  4724. completed before performing a live migration. Userspace can re-enter the
  4725. guest with an unmasked signal pending or with the immediate_exit field set
  4726. to complete pending operations without allowing any further instructions
  4727. to be executed.
  4728. ::
  4729. /* KVM_EXIT_HYPERCALL */
  4730. struct {
  4731. __u64 nr;
  4732. __u64 args[6];
  4733. __u64 ret;
  4734. __u32 longmode;
  4735. __u32 pad;
  4736. } hypercall;
  4737. Unused. This was once used for 'hypercall to userspace'. To implement
  4738. such functionality, use KVM_EXIT_IO (x86) or KVM_EXIT_MMIO (all except s390).
  4739. .. note:: KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO.
  4740. ::
  4741. /* KVM_EXIT_TPR_ACCESS */
  4742. struct {
  4743. __u64 rip;
  4744. __u32 is_write;
  4745. __u32 pad;
  4746. } tpr_access;
  4747. To be documented (KVM_TPR_ACCESS_REPORTING).
  4748. ::
  4749. /* KVM_EXIT_S390_SIEIC */
  4750. struct {
  4751. __u8 icptcode;
  4752. __u64 mask; /* psw upper half */
  4753. __u64 addr; /* psw lower half */
  4754. __u16 ipa;
  4755. __u32 ipb;
  4756. } s390_sieic;
  4757. s390 specific.
  4758. ::
  4759. /* KVM_EXIT_S390_RESET */
  4760. #define KVM_S390_RESET_POR 1
  4761. #define KVM_S390_RESET_CLEAR 2
  4762. #define KVM_S390_RESET_SUBSYSTEM 4
  4763. #define KVM_S390_RESET_CPU_INIT 8
  4764. #define KVM_S390_RESET_IPL 16
  4765. __u64 s390_reset_flags;
  4766. s390 specific.
  4767. ::
  4768. /* KVM_EXIT_S390_UCONTROL */
  4769. struct {
  4770. __u64 trans_exc_code;
  4771. __u32 pgm_code;
  4772. } s390_ucontrol;
  4773. s390 specific. A page fault has occurred for a user controlled virtual
  4774. machine (KVM_VM_S390_UNCONTROL) on it's host page table that cannot be
  4775. resolved by the kernel.
  4776. The program code and the translation exception code that were placed
  4777. in the cpu's lowcore are presented here as defined by the z Architecture
  4778. Principles of Operation Book in the Chapter for Dynamic Address Translation
  4779. (DAT)
  4780. ::
  4781. /* KVM_EXIT_DCR */
  4782. struct {
  4783. __u32 dcrn;
  4784. __u32 data;
  4785. __u8 is_write;
  4786. } dcr;
  4787. Deprecated - was used for 440 KVM.
  4788. ::
  4789. /* KVM_EXIT_OSI */
  4790. struct {
  4791. __u64 gprs[32];
  4792. } osi;
  4793. MOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch
  4794. hypercalls and exit with this exit struct that contains all the guest gprs.
  4795. If exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall.
  4796. Userspace can now handle the hypercall and when it's done modify the gprs as
  4797. necessary. Upon guest entry all guest GPRs will then be replaced by the values
  4798. in this struct.
  4799. ::
  4800. /* KVM_EXIT_PAPR_HCALL */
  4801. struct {
  4802. __u64 nr;
  4803. __u64 ret;
  4804. __u64 args[9];
  4805. } papr_hcall;
  4806. This is used on 64-bit PowerPC when emulating a pSeries partition,
  4807. e.g. with the 'pseries' machine type in qemu. It occurs when the
  4808. guest does a hypercall using the 'sc 1' instruction. The 'nr' field
  4809. contains the hypercall number (from the guest R3), and 'args' contains
  4810. the arguments (from the guest R4 - R12). Userspace should put the
  4811. return code in 'ret' and any extra returned values in args[].
  4812. The possible hypercalls are defined in the Power Architecture Platform
  4813. Requirements (PAPR) document available from www.power.org (free
  4814. developer registration required to access it).
  4815. ::
  4816. /* KVM_EXIT_S390_TSCH */
  4817. struct {
  4818. __u16 subchannel_id;
  4819. __u16 subchannel_nr;
  4820. __u32 io_int_parm;
  4821. __u32 io_int_word;
  4822. __u32 ipb;
  4823. __u8 dequeued;
  4824. } s390_tsch;
  4825. s390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled
  4826. and TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O
  4827. interrupt for the target subchannel has been dequeued and subchannel_id,
  4828. subchannel_nr, io_int_parm and io_int_word contain the parameters for that
  4829. interrupt. ipb is needed for instruction parameter decoding.
  4830. ::
  4831. /* KVM_EXIT_EPR */
  4832. struct {
  4833. __u32 epr;
  4834. } epr;
  4835. On FSL BookE PowerPC chips, the interrupt controller has a fast patch
  4836. interrupt acknowledge path to the core. When the core successfully
  4837. delivers an interrupt, it automatically populates the EPR register with
  4838. the interrupt vector number and acknowledges the interrupt inside
  4839. the interrupt controller.
  4840. In case the interrupt controller lives in user space, we need to do
  4841. the interrupt acknowledge cycle through it to fetch the next to be
  4842. delivered interrupt vector using this exit.
  4843. It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an
  4844. external interrupt has just been delivered into the guest. User space
  4845. should put the acknowledged interrupt vector into the 'epr' field.
  4846. ::
  4847. /* KVM_EXIT_SYSTEM_EVENT */
  4848. struct {
  4849. #define KVM_SYSTEM_EVENT_SHUTDOWN 1
  4850. #define KVM_SYSTEM_EVENT_RESET 2
  4851. #define KVM_SYSTEM_EVENT_CRASH 3
  4852. #define KVM_SYSTEM_EVENT_WAKEUP 4
  4853. #define KVM_SYSTEM_EVENT_SUSPEND 5
  4854. #define KVM_SYSTEM_EVENT_SEV_TERM 6
  4855. __u32 type;
  4856. __u32 ndata;
  4857. __u64 data[16];
  4858. } system_event;
  4859. If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered
  4860. a system-level event using some architecture specific mechanism (hypercall
  4861. or some special instruction). In case of ARM64, this is triggered using
  4862. HVC instruction based PSCI call from the vcpu.
  4863. The 'type' field describes the system-level event type.
  4864. Valid values for 'type' are:
  4865. - KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the
  4866. VM. Userspace is not obliged to honour this, and if it does honour
  4867. this does not need to destroy the VM synchronously (ie it may call
  4868. KVM_RUN again before shutdown finally occurs).
  4869. - KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM.
  4870. As with SHUTDOWN, userspace can choose to ignore the request, or
  4871. to schedule the reset to occur in the future and may call KVM_RUN again.
  4872. - KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest
  4873. has requested a crash condition maintenance. Userspace can choose
  4874. to ignore the request, or to gather VM memory core dump and/or
  4875. reset/shutdown of the VM.
  4876. - KVM_SYSTEM_EVENT_SEV_TERM -- an AMD SEV guest requested termination.
  4877. The guest physical address of the guest's GHCB is stored in `data[0]`.
  4878. - KVM_SYSTEM_EVENT_WAKEUP -- the exiting vCPU is in a suspended state and
  4879. KVM has recognized a wakeup event. Userspace may honor this event by
  4880. marking the exiting vCPU as runnable, or deny it and call KVM_RUN again.
  4881. - KVM_SYSTEM_EVENT_SUSPEND -- the guest has requested a suspension of
  4882. the VM.
  4883. If KVM_CAP_SYSTEM_EVENT_DATA is present, the 'data' field can contain
  4884. architecture specific information for the system-level event. Only
  4885. the first `ndata` items (possibly zero) of the data array are valid.
  4886. - for arm64, data[0] is set to KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 if
  4887. the guest issued a SYSTEM_RESET2 call according to v1.1 of the PSCI
  4888. specification.
  4889. - for RISC-V, data[0] is set to the value of the second argument of the
  4890. ``sbi_system_reset`` call.
  4891. Previous versions of Linux defined a `flags` member in this struct. The
  4892. field is now aliased to `data[0]`. Userspace can assume that it is only
  4893. written if ndata is greater than 0.
  4894. For arm/arm64:
  4895. --------------
  4896. KVM_SYSTEM_EVENT_SUSPEND exits are enabled with the
  4897. KVM_CAP_ARM_SYSTEM_SUSPEND VM capability. If a guest invokes the PSCI
  4898. SYSTEM_SUSPEND function, KVM will exit to userspace with this event
  4899. type.
  4900. It is the sole responsibility of userspace to implement the PSCI
  4901. SYSTEM_SUSPEND call according to ARM DEN0022D.b 5.19 "SYSTEM_SUSPEND".
  4902. KVM does not change the vCPU's state before exiting to userspace, so
  4903. the call parameters are left in-place in the vCPU registers.
  4904. Userspace is _required_ to take action for such an exit. It must
  4905. either:
  4906. - Honor the guest request to suspend the VM. Userspace can request
  4907. in-kernel emulation of suspension by setting the calling vCPU's
  4908. state to KVM_MP_STATE_SUSPENDED. Userspace must configure the vCPU's
  4909. state according to the parameters passed to the PSCI function when
  4910. the calling vCPU is resumed. See ARM DEN0022D.b 5.19.1 "Intended use"
  4911. for details on the function parameters.
  4912. - Deny the guest request to suspend the VM. See ARM DEN0022D.b 5.19.2
  4913. "Caller responsibilities" for possible return values.
  4914. ::
  4915. /* KVM_EXIT_IOAPIC_EOI */
  4916. struct {
  4917. __u8 vector;
  4918. } eoi;
  4919. Indicates that the VCPU's in-kernel local APIC received an EOI for a
  4920. level-triggered IOAPIC interrupt. This exit only triggers when the
  4921. IOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled);
  4922. the userspace IOAPIC should process the EOI and retrigger the interrupt if
  4923. it is still asserted. Vector is the LAPIC interrupt vector for which the
  4924. EOI was received.
  4925. ::
  4926. struct kvm_hyperv_exit {
  4927. #define KVM_EXIT_HYPERV_SYNIC 1
  4928. #define KVM_EXIT_HYPERV_HCALL 2
  4929. #define KVM_EXIT_HYPERV_SYNDBG 3
  4930. __u32 type;
  4931. __u32 pad1;
  4932. union {
  4933. struct {
  4934. __u32 msr;
  4935. __u32 pad2;
  4936. __u64 control;
  4937. __u64 evt_page;
  4938. __u64 msg_page;
  4939. } synic;
  4940. struct {
  4941. __u64 input;
  4942. __u64 result;
  4943. __u64 params[2];
  4944. } hcall;
  4945. struct {
  4946. __u32 msr;
  4947. __u32 pad2;
  4948. __u64 control;
  4949. __u64 status;
  4950. __u64 send_page;
  4951. __u64 recv_page;
  4952. __u64 pending_page;
  4953. } syndbg;
  4954. } u;
  4955. };
  4956. /* KVM_EXIT_HYPERV */
  4957. struct kvm_hyperv_exit hyperv;
  4958. Indicates that the VCPU exits into userspace to process some tasks
  4959. related to Hyper-V emulation.
  4960. Valid values for 'type' are:
  4961. - KVM_EXIT_HYPERV_SYNIC -- synchronously notify user-space about
  4962. Hyper-V SynIC state change. Notification is used to remap SynIC
  4963. event/message pages and to enable/disable SynIC messages/events processing
  4964. in userspace.
  4965. - KVM_EXIT_HYPERV_SYNDBG -- synchronously notify user-space about
  4966. Hyper-V Synthetic debugger state change. Notification is used to either update
  4967. the pending_page location or to send a control command (send the buffer located
  4968. in send_page or recv a buffer to recv_page).
  4969. ::
  4970. /* KVM_EXIT_ARM_NISV */
  4971. struct {
  4972. __u64 esr_iss;
  4973. __u64 fault_ipa;
  4974. } arm_nisv;
  4975. Used on arm64 systems. If a guest accesses memory not in a memslot,
  4976. KVM will typically return to userspace and ask it to do MMIO emulation on its
  4977. behalf. However, for certain classes of instructions, no instruction decode
  4978. (direction, length of memory access) is provided, and fetching and decoding
  4979. the instruction from the VM is overly complicated to live in the kernel.
  4980. Historically, when this situation occurred, KVM would print a warning and kill
  4981. the VM. KVM assumed that if the guest accessed non-memslot memory, it was
  4982. trying to do I/O, which just couldn't be emulated, and the warning message was
  4983. phrased accordingly. However, what happened more often was that a guest bug
  4984. caused access outside the guest memory areas which should lead to a more
  4985. meaningful warning message and an external abort in the guest, if the access
  4986. did not fall within an I/O window.
  4987. Userspace implementations can query for KVM_CAP_ARM_NISV_TO_USER, and enable
  4988. this capability at VM creation. Once this is done, these types of errors will
  4989. instead return to userspace with KVM_EXIT_ARM_NISV, with the valid bits from
  4990. the ESR_EL2 in the esr_iss field, and the faulting IPA in the fault_ipa field.
  4991. Userspace can either fix up the access if it's actually an I/O access by
  4992. decoding the instruction from guest memory (if it's very brave) and continue
  4993. executing the guest, or it can decide to suspend, dump, or restart the guest.
  4994. Note that KVM does not skip the faulting instruction as it does for
  4995. KVM_EXIT_MMIO, but userspace has to emulate any change to the processing state
  4996. if it decides to decode and emulate the instruction.
  4997. This feature isn't available to protected VMs, as userspace does not
  4998. have access to the state that is required to perform the emulation.
  4999. Instead, a data abort exception is directly injected in the guest.
  5000. Note that although KVM_CAP_ARM_NISV_TO_USER will be reported if
  5001. queried outside of a protected VM context, the feature will not be
  5002. exposed if queried on a protected VM file descriptor.
  5003. ::
  5004. /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */
  5005. struct {
  5006. __u8 error; /* user -> kernel */
  5007. __u8 pad[7];
  5008. __u32 reason; /* kernel -> user */
  5009. __u32 index; /* kernel -> user */
  5010. __u64 data; /* kernel <-> user */
  5011. } msr;
  5012. Used on x86 systems. When the VM capability KVM_CAP_X86_USER_SPACE_MSR is
  5013. enabled, MSR accesses to registers that would invoke a #GP by KVM kernel code
  5014. will instead trigger a KVM_EXIT_X86_RDMSR exit for reads and KVM_EXIT_X86_WRMSR
  5015. exit for writes.
  5016. The "reason" field specifies why the MSR trap occurred. User space will only
  5017. receive MSR exit traps when a particular reason was requested during through
  5018. ENABLE_CAP. Currently valid exit reasons are:
  5019. KVM_MSR_EXIT_REASON_UNKNOWN - access to MSR that is unknown to KVM
  5020. KVM_MSR_EXIT_REASON_INVAL - access to invalid MSRs or reserved bits
  5021. KVM_MSR_EXIT_REASON_FILTER - access blocked by KVM_X86_SET_MSR_FILTER
  5022. For KVM_EXIT_X86_RDMSR, the "index" field tells user space which MSR the guest
  5023. wants to read. To respond to this request with a successful read, user space
  5024. writes the respective data into the "data" field and must continue guest
  5025. execution to ensure the read data is transferred into guest register state.
  5026. If the RDMSR request was unsuccessful, user space indicates that with a "1" in
  5027. the "error" field. This will inject a #GP into the guest when the VCPU is
  5028. executed again.
  5029. For KVM_EXIT_X86_WRMSR, the "index" field tells user space which MSR the guest
  5030. wants to write. Once finished processing the event, user space must continue
  5031. vCPU execution. If the MSR write was unsuccessful, user space also sets the
  5032. "error" field to "1".
  5033. ::
  5034. struct kvm_xen_exit {
  5035. #define KVM_EXIT_XEN_HCALL 1
  5036. __u32 type;
  5037. union {
  5038. struct {
  5039. __u32 longmode;
  5040. __u32 cpl;
  5041. __u64 input;
  5042. __u64 result;
  5043. __u64 params[6];
  5044. } hcall;
  5045. } u;
  5046. };
  5047. /* KVM_EXIT_XEN */
  5048. struct kvm_hyperv_exit xen;
  5049. Indicates that the VCPU exits into userspace to process some tasks
  5050. related to Xen emulation.
  5051. Valid values for 'type' are:
  5052. - KVM_EXIT_XEN_HCALL -- synchronously notify user-space about Xen hypercall.
  5053. Userspace is expected to place the hypercall result into the appropriate
  5054. field before invoking KVM_RUN again.
  5055. ::
  5056. /* KVM_EXIT_RISCV_SBI */
  5057. struct {
  5058. unsigned long extension_id;
  5059. unsigned long function_id;
  5060. unsigned long args[6];
  5061. unsigned long ret[2];
  5062. } riscv_sbi;
  5063. If exit reason is KVM_EXIT_RISCV_SBI then it indicates that the VCPU has
  5064. done a SBI call which is not handled by KVM RISC-V kernel module. The details
  5065. of the SBI call are available in 'riscv_sbi' member of kvm_run structure. The
  5066. 'extension_id' field of 'riscv_sbi' represents SBI extension ID whereas the
  5067. 'function_id' field represents function ID of given SBI extension. The 'args'
  5068. array field of 'riscv_sbi' represents parameters for the SBI call and 'ret'
  5069. array field represents return values. The userspace should update the return
  5070. values of SBI call before resuming the VCPU. For more details on RISC-V SBI
  5071. spec refer, https://github.com/riscv/riscv-sbi-doc.
  5072. ::
  5073. /* KVM_EXIT_NOTIFY */
  5074. struct {
  5075. #define KVM_NOTIFY_CONTEXT_INVALID (1 << 0)
  5076. __u32 flags;
  5077. } notify;
  5078. Used on x86 systems. When the VM capability KVM_CAP_X86_NOTIFY_VMEXIT is
  5079. enabled, a VM exit generated if no event window occurs in VM non-root mode
  5080. for a specified amount of time. Once KVM_X86_NOTIFY_VMEXIT_USER is set when
  5081. enabling the cap, it would exit to userspace with the exit reason
  5082. KVM_EXIT_NOTIFY for further handling. The "flags" field contains more
  5083. detailed info.
  5084. The valid value for 'flags' is:
  5085. - KVM_NOTIFY_CONTEXT_INVALID -- the VM context is corrupted and not valid
  5086. in VMCS. It would run into unknown result if resume the target VM.
  5087. ::
  5088. /* Fix the size of the union. */
  5089. char padding[256];
  5090. };
  5091. /*
  5092. * shared registers between kvm and userspace.
  5093. * kvm_valid_regs specifies the register classes set by the host
  5094. * kvm_dirty_regs specified the register classes dirtied by userspace
  5095. * struct kvm_sync_regs is architecture specific, as well as the
  5096. * bits for kvm_valid_regs and kvm_dirty_regs
  5097. */
  5098. __u64 kvm_valid_regs;
  5099. __u64 kvm_dirty_regs;
  5100. union {
  5101. struct kvm_sync_regs regs;
  5102. char padding[SYNC_REGS_SIZE_BYTES];
  5103. } s;
  5104. If KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access
  5105. certain guest registers without having to call SET/GET_*REGS. Thus we can
  5106. avoid some system call overhead if userspace has to handle the exit.
  5107. Userspace can query the validity of the structure by checking
  5108. kvm_valid_regs for specific bits. These bits are architecture specific
  5109. and usually define the validity of a groups of registers. (e.g. one bit
  5110. for general purpose registers)
  5111. Please note that the kernel is allowed to use the kvm_run structure as the
  5112. primary storage for certain register types. Therefore, the kernel may use the
  5113. values in kvm_run even if the corresponding bit in kvm_dirty_regs is not set.
  5114. ::
  5115. };
  5116. 6. Capabilities that can be enabled on vCPUs
  5117. ============================================
  5118. There are certain capabilities that change the behavior of the virtual CPU or
  5119. the virtual machine when enabled. To enable them, please see section 4.37.
  5120. Below you can find a list of capabilities and what their effect on the vCPU or
  5121. the virtual machine is when enabling them.
  5122. The following information is provided along with the description:
  5123. Architectures:
  5124. which instruction set architectures provide this ioctl.
  5125. x86 includes both i386 and x86_64.
  5126. Target:
  5127. whether this is a per-vcpu or per-vm capability.
  5128. Parameters:
  5129. what parameters are accepted by the capability.
  5130. Returns:
  5131. the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  5132. are not detailed, but errors with specific meanings are.
  5133. 6.1 KVM_CAP_PPC_OSI
  5134. -------------------
  5135. :Architectures: ppc
  5136. :Target: vcpu
  5137. :Parameters: none
  5138. :Returns: 0 on success; -1 on error
  5139. This capability enables interception of OSI hypercalls that otherwise would
  5140. be treated as normal system calls to be injected into the guest. OSI hypercalls
  5141. were invented by Mac-on-Linux to have a standardized communication mechanism
  5142. between the guest and the host.
  5143. When this capability is enabled, KVM_EXIT_OSI can occur.
  5144. 6.2 KVM_CAP_PPC_PAPR
  5145. --------------------
  5146. :Architectures: ppc
  5147. :Target: vcpu
  5148. :Parameters: none
  5149. :Returns: 0 on success; -1 on error
  5150. This capability enables interception of PAPR hypercalls. PAPR hypercalls are
  5151. done using the hypercall instruction "sc 1".
  5152. It also sets the guest privilege level to "supervisor" mode. Usually the guest
  5153. runs in "hypervisor" privilege mode with a few missing features.
  5154. In addition to the above, it changes the semantics of SDR1. In this mode, the
  5155. HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
  5156. HTAB invisible to the guest.
  5157. When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
  5158. 6.3 KVM_CAP_SW_TLB
  5159. ------------------
  5160. :Architectures: ppc
  5161. :Target: vcpu
  5162. :Parameters: args[0] is the address of a struct kvm_config_tlb
  5163. :Returns: 0 on success; -1 on error
  5164. ::
  5165. struct kvm_config_tlb {
  5166. __u64 params;
  5167. __u64 array;
  5168. __u32 mmu_type;
  5169. __u32 array_len;
  5170. };
  5171. Configures the virtual CPU's TLB array, establishing a shared memory area
  5172. between userspace and KVM. The "params" and "array" fields are userspace
  5173. addresses of mmu-type-specific data structures. The "array_len" field is an
  5174. safety mechanism, and should be set to the size in bytes of the memory that
  5175. userspace has reserved for the array. It must be at least the size dictated
  5176. by "mmu_type" and "params".
  5177. While KVM_RUN is active, the shared region is under control of KVM. Its
  5178. contents are undefined, and any modification by userspace results in
  5179. boundedly undefined behavior.
  5180. On return from KVM_RUN, the shared region will reflect the current state of
  5181. the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB
  5182. to tell KVM which entries have been changed, prior to calling KVM_RUN again
  5183. on this vcpu.
  5184. For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
  5185. - The "params" field is of type "struct kvm_book3e_206_tlb_params".
  5186. - The "array" field points to an array of type "struct
  5187. kvm_book3e_206_tlb_entry".
  5188. - The array consists of all entries in the first TLB, followed by all
  5189. entries in the second TLB.
  5190. - Within a TLB, entries are ordered first by increasing set number. Within a
  5191. set, entries are ordered by way (increasing ESEL).
  5192. - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
  5193. where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
  5194. - The tsize field of mas1 shall be set to 4K on TLB0, even though the
  5195. hardware ignores this value for TLB0.
  5196. 6.4 KVM_CAP_S390_CSS_SUPPORT
  5197. ----------------------------
  5198. :Architectures: s390
  5199. :Target: vcpu
  5200. :Parameters: none
  5201. :Returns: 0 on success; -1 on error
  5202. This capability enables support for handling of channel I/O instructions.
  5203. TEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are
  5204. handled in-kernel, while the other I/O instructions are passed to userspace.
  5205. When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST
  5206. SUBCHANNEL intercepts.
  5207. Note that even though this capability is enabled per-vcpu, the complete
  5208. virtual machine is affected.
  5209. 6.5 KVM_CAP_PPC_EPR
  5210. -------------------
  5211. :Architectures: ppc
  5212. :Target: vcpu
  5213. :Parameters: args[0] defines whether the proxy facility is active
  5214. :Returns: 0 on success; -1 on error
  5215. This capability enables or disables the delivery of interrupts through the
  5216. external proxy facility.
  5217. When enabled (args[0] != 0), every time the guest gets an external interrupt
  5218. delivered, it automatically exits into user space with a KVM_EXIT_EPR exit
  5219. to receive the topmost interrupt vector.
  5220. When disabled (args[0] == 0), behavior is as if this facility is unsupported.
  5221. When this capability is enabled, KVM_EXIT_EPR can occur.
  5222. 6.6 KVM_CAP_IRQ_MPIC
  5223. --------------------
  5224. :Architectures: ppc
  5225. :Parameters: args[0] is the MPIC device fd;
  5226. args[1] is the MPIC CPU number for this vcpu
  5227. This capability connects the vcpu to an in-kernel MPIC device.
  5228. 6.7 KVM_CAP_IRQ_XICS
  5229. --------------------
  5230. :Architectures: ppc
  5231. :Target: vcpu
  5232. :Parameters: args[0] is the XICS device fd;
  5233. args[1] is the XICS CPU number (server ID) for this vcpu
  5234. This capability connects the vcpu to an in-kernel XICS device.
  5235. 6.8 KVM_CAP_S390_IRQCHIP
  5236. ------------------------
  5237. :Architectures: s390
  5238. :Target: vm
  5239. :Parameters: none
  5240. This capability enables the in-kernel irqchip for s390. Please refer to
  5241. "4.24 KVM_CREATE_IRQCHIP" for details.
  5242. 6.9 KVM_CAP_MIPS_FPU
  5243. --------------------
  5244. :Architectures: mips
  5245. :Target: vcpu
  5246. :Parameters: args[0] is reserved for future use (should be 0).
  5247. This capability allows the use of the host Floating Point Unit by the guest. It
  5248. allows the Config1.FP bit to be set to enable the FPU in the guest. Once this is
  5249. done the ``KVM_REG_MIPS_FPR_*`` and ``KVM_REG_MIPS_FCR_*`` registers can be
  5250. accessed (depending on the current guest FPU register mode), and the Status.FR,
  5251. Config5.FRE bits are accessible via the KVM API and also from the guest,
  5252. depending on them being supported by the FPU.
  5253. 6.10 KVM_CAP_MIPS_MSA
  5254. ---------------------
  5255. :Architectures: mips
  5256. :Target: vcpu
  5257. :Parameters: args[0] is reserved for future use (should be 0).
  5258. This capability allows the use of the MIPS SIMD Architecture (MSA) by the guest.
  5259. It allows the Config3.MSAP bit to be set to enable the use of MSA by the guest.
  5260. Once this is done the ``KVM_REG_MIPS_VEC_*`` and ``KVM_REG_MIPS_MSA_*``
  5261. registers can be accessed, and the Config5.MSAEn bit is accessible via the
  5262. KVM API and also from the guest.
  5263. 6.74 KVM_CAP_SYNC_REGS
  5264. ----------------------
  5265. :Architectures: s390, x86
  5266. :Target: s390: always enabled, x86: vcpu
  5267. :Parameters: none
  5268. :Returns: x86: KVM_CHECK_EXTENSION returns a bit-array indicating which register
  5269. sets are supported
  5270. (bitfields defined in arch/x86/include/uapi/asm/kvm.h).
  5271. As described above in the kvm_sync_regs struct info in section 5 (kvm_run):
  5272. KVM_CAP_SYNC_REGS "allow[s] userspace to access certain guest registers
  5273. without having to call SET/GET_*REGS". This reduces overhead by eliminating
  5274. repeated ioctl calls for setting and/or getting register values. This is
  5275. particularly important when userspace is making synchronous guest state
  5276. modifications, e.g. when emulating and/or intercepting instructions in
  5277. userspace.
  5278. For s390 specifics, please refer to the source code.
  5279. For x86:
  5280. - the register sets to be copied out to kvm_run are selectable
  5281. by userspace (rather that all sets being copied out for every exit).
  5282. - vcpu_events are available in addition to regs and sregs.
  5283. For x86, the 'kvm_valid_regs' field of struct kvm_run is overloaded to
  5284. function as an input bit-array field set by userspace to indicate the
  5285. specific register sets to be copied out on the next exit.
  5286. To indicate when userspace has modified values that should be copied into
  5287. the vCPU, the all architecture bitarray field, 'kvm_dirty_regs' must be set.
  5288. This is done using the same bitflags as for the 'kvm_valid_regs' field.
  5289. If the dirty bit is not set, then the register set values will not be copied
  5290. into the vCPU even if they've been modified.
  5291. Unused bitfields in the bitarrays must be set to zero.
  5292. ::
  5293. struct kvm_sync_regs {
  5294. struct kvm_regs regs;
  5295. struct kvm_sregs sregs;
  5296. struct kvm_vcpu_events events;
  5297. };
  5298. 6.75 KVM_CAP_PPC_IRQ_XIVE
  5299. -------------------------
  5300. :Architectures: ppc
  5301. :Target: vcpu
  5302. :Parameters: args[0] is the XIVE device fd;
  5303. args[1] is the XIVE CPU number (server ID) for this vcpu
  5304. This capability connects the vcpu to an in-kernel XIVE device.
  5305. 7. Capabilities that can be enabled on VMs
  5306. ==========================================
  5307. There are certain capabilities that change the behavior of the virtual
  5308. machine when enabled. To enable them, please see section 4.37. Below
  5309. you can find a list of capabilities and what their effect on the VM
  5310. is when enabling them.
  5311. The following information is provided along with the description:
  5312. Architectures:
  5313. which instruction set architectures provide this ioctl.
  5314. x86 includes both i386 and x86_64.
  5315. Parameters:
  5316. what parameters are accepted by the capability.
  5317. Returns:
  5318. the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  5319. are not detailed, but errors with specific meanings are.
  5320. 7.1 KVM_CAP_PPC_ENABLE_HCALL
  5321. ----------------------------
  5322. :Architectures: ppc
  5323. :Parameters: args[0] is the sPAPR hcall number;
  5324. args[1] is 0 to disable, 1 to enable in-kernel handling
  5325. This capability controls whether individual sPAPR hypercalls (hcalls)
  5326. get handled by the kernel or not. Enabling or disabling in-kernel
  5327. handling of an hcall is effective across the VM. On creation, an
  5328. initial set of hcalls are enabled for in-kernel handling, which
  5329. consists of those hcalls for which in-kernel handlers were implemented
  5330. before this capability was implemented. If disabled, the kernel will
  5331. not to attempt to handle the hcall, but will always exit to userspace
  5332. to handle it. Note that it may not make sense to enable some and
  5333. disable others of a group of related hcalls, but KVM does not prevent
  5334. userspace from doing that.
  5335. If the hcall number specified is not one that has an in-kernel
  5336. implementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL
  5337. error.
  5338. 7.2 KVM_CAP_S390_USER_SIGP
  5339. --------------------------
  5340. :Architectures: s390
  5341. :Parameters: none
  5342. This capability controls which SIGP orders will be handled completely in user
  5343. space. With this capability enabled, all fast orders will be handled completely
  5344. in the kernel:
  5345. - SENSE
  5346. - SENSE RUNNING
  5347. - EXTERNAL CALL
  5348. - EMERGENCY SIGNAL
  5349. - CONDITIONAL EMERGENCY SIGNAL
  5350. All other orders will be handled completely in user space.
  5351. Only privileged operation exceptions will be checked for in the kernel (or even
  5352. in the hardware prior to interception). If this capability is not enabled, the
  5353. old way of handling SIGP orders is used (partially in kernel and user space).
  5354. 7.3 KVM_CAP_S390_VECTOR_REGISTERS
  5355. ---------------------------------
  5356. :Architectures: s390
  5357. :Parameters: none
  5358. :Returns: 0 on success, negative value on error
  5359. Allows use of the vector registers introduced with z13 processor, and
  5360. provides for the synchronization between host and user space. Will
  5361. return -EINVAL if the machine does not support vectors.
  5362. 7.4 KVM_CAP_S390_USER_STSI
  5363. --------------------------
  5364. :Architectures: s390
  5365. :Parameters: none
  5366. This capability allows post-handlers for the STSI instruction. After
  5367. initial handling in the kernel, KVM exits to user space with
  5368. KVM_EXIT_S390_STSI to allow user space to insert further data.
  5369. Before exiting to userspace, kvm handlers should fill in s390_stsi field of
  5370. vcpu->run::
  5371. struct {
  5372. __u64 addr;
  5373. __u8 ar;
  5374. __u8 reserved;
  5375. __u8 fc;
  5376. __u8 sel1;
  5377. __u16 sel2;
  5378. } s390_stsi;
  5379. @addr - guest address of STSI SYSIB
  5380. @fc - function code
  5381. @sel1 - selector 1
  5382. @sel2 - selector 2
  5383. @ar - access register number
  5384. KVM handlers should exit to userspace with rc = -EREMOTE.
  5385. 7.5 KVM_CAP_SPLIT_IRQCHIP
  5386. -------------------------
  5387. :Architectures: x86
  5388. :Parameters: args[0] - number of routes reserved for userspace IOAPICs
  5389. :Returns: 0 on success, -1 on error
  5390. Create a local apic for each processor in the kernel. This can be used
  5391. instead of KVM_CREATE_IRQCHIP if the userspace VMM wishes to emulate the
  5392. IOAPIC and PIC (and also the PIT, even though this has to be enabled
  5393. separately).
  5394. This capability also enables in kernel routing of interrupt requests;
  5395. when KVM_CAP_SPLIT_IRQCHIP only routes of KVM_IRQ_ROUTING_MSI type are
  5396. used in the IRQ routing table. The first args[0] MSI routes are reserved
  5397. for the IOAPIC pins. Whenever the LAPIC receives an EOI for these routes,
  5398. a KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace.
  5399. Fails if VCPU has already been created, or if the irqchip is already in the
  5400. kernel (i.e. KVM_CREATE_IRQCHIP has already been called).
  5401. 7.6 KVM_CAP_S390_RI
  5402. -------------------
  5403. :Architectures: s390
  5404. :Parameters: none
  5405. Allows use of runtime-instrumentation introduced with zEC12 processor.
  5406. Will return -EINVAL if the machine does not support runtime-instrumentation.
  5407. Will return -EBUSY if a VCPU has already been created.
  5408. 7.7 KVM_CAP_X2APIC_API
  5409. ----------------------
  5410. :Architectures: x86
  5411. :Parameters: args[0] - features that should be enabled
  5412. :Returns: 0 on success, -EINVAL when args[0] contains invalid features
  5413. Valid feature flags in args[0] are::
  5414. #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
  5415. #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
  5416. Enabling KVM_X2APIC_API_USE_32BIT_IDS changes the behavior of
  5417. KVM_SET_GSI_ROUTING, KVM_SIGNAL_MSI, KVM_SET_LAPIC, and KVM_GET_LAPIC,
  5418. allowing the use of 32-bit APIC IDs. See KVM_CAP_X2APIC_API in their
  5419. respective sections.
  5420. KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK must be enabled for x2APIC to work
  5421. in logical mode or with more than 255 VCPUs. Otherwise, KVM treats 0xff
  5422. as a broadcast even in x2APIC mode in order to support physical x2APIC
  5423. without interrupt remapping. This is undesirable in logical mode,
  5424. where 0xff represents CPUs 0-7 in cluster 0.
  5425. 7.8 KVM_CAP_S390_USER_INSTR0
  5426. ----------------------------
  5427. :Architectures: s390
  5428. :Parameters: none
  5429. With this capability enabled, all illegal instructions 0x0000 (2 bytes) will
  5430. be intercepted and forwarded to user space. User space can use this
  5431. mechanism e.g. to realize 2-byte software breakpoints. The kernel will
  5432. not inject an operating exception for these instructions, user space has
  5433. to take care of that.
  5434. This capability can be enabled dynamically even if VCPUs were already
  5435. created and are running.
  5436. 7.9 KVM_CAP_S390_GS
  5437. -------------------
  5438. :Architectures: s390
  5439. :Parameters: none
  5440. :Returns: 0 on success; -EINVAL if the machine does not support
  5441. guarded storage; -EBUSY if a VCPU has already been created.
  5442. Allows use of guarded storage for the KVM guest.
  5443. 7.10 KVM_CAP_S390_AIS
  5444. ---------------------
  5445. :Architectures: s390
  5446. :Parameters: none
  5447. Allow use of adapter-interruption suppression.
  5448. :Returns: 0 on success; -EBUSY if a VCPU has already been created.
  5449. 7.11 KVM_CAP_PPC_SMT
  5450. --------------------
  5451. :Architectures: ppc
  5452. :Parameters: vsmt_mode, flags
  5453. Enabling this capability on a VM provides userspace with a way to set
  5454. the desired virtual SMT mode (i.e. the number of virtual CPUs per
  5455. virtual core). The virtual SMT mode, vsmt_mode, must be a power of 2
  5456. between 1 and 8. On POWER8, vsmt_mode must also be no greater than
  5457. the number of threads per subcore for the host. Currently flags must
  5458. be 0. A successful call to enable this capability will result in
  5459. vsmt_mode being returned when the KVM_CAP_PPC_SMT capability is
  5460. subsequently queried for the VM. This capability is only supported by
  5461. HV KVM, and can only be set before any VCPUs have been created.
  5462. The KVM_CAP_PPC_SMT_POSSIBLE capability indicates which virtual SMT
  5463. modes are available.
  5464. 7.12 KVM_CAP_PPC_FWNMI
  5465. ----------------------
  5466. :Architectures: ppc
  5467. :Parameters: none
  5468. With this capability a machine check exception in the guest address
  5469. space will cause KVM to exit the guest with NMI exit reason. This
  5470. enables QEMU to build error log and branch to guest kernel registered
  5471. machine check handling routine. Without this capability KVM will
  5472. branch to guests' 0x200 interrupt vector.
  5473. 7.13 KVM_CAP_X86_DISABLE_EXITS
  5474. ------------------------------
  5475. :Architectures: x86
  5476. :Parameters: args[0] defines which exits are disabled
  5477. :Returns: 0 on success, -EINVAL when args[0] contains invalid exits
  5478. Valid bits in args[0] are::
  5479. #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0)
  5480. #define KVM_X86_DISABLE_EXITS_HLT (1 << 1)
  5481. #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2)
  5482. #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3)
  5483. Enabling this capability on a VM provides userspace with a way to no
  5484. longer intercept some instructions for improved latency in some
  5485. workloads, and is suggested when vCPUs are associated to dedicated
  5486. physical CPUs. More bits can be added in the future; userspace can
  5487. just pass the KVM_CHECK_EXTENSION result to KVM_ENABLE_CAP to disable
  5488. all such vmexits.
  5489. Do not enable KVM_FEATURE_PV_UNHALT if you disable HLT exits.
  5490. 7.14 KVM_CAP_S390_HPAGE_1M
  5491. --------------------------
  5492. :Architectures: s390
  5493. :Parameters: none
  5494. :Returns: 0 on success, -EINVAL if hpage module parameter was not set
  5495. or cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL
  5496. flag set
  5497. With this capability the KVM support for memory backing with 1m pages
  5498. through hugetlbfs can be enabled for a VM. After the capability is
  5499. enabled, cmma can't be enabled anymore and pfmfi and the storage key
  5500. interpretation are disabled. If cmma has already been enabled or the
  5501. hpage module parameter is not set to 1, -EINVAL is returned.
  5502. While it is generally possible to create a huge page backed VM without
  5503. this capability, the VM will not be able to run.
  5504. 7.15 KVM_CAP_MSR_PLATFORM_INFO
  5505. ------------------------------
  5506. :Architectures: x86
  5507. :Parameters: args[0] whether feature should be enabled or not
  5508. With this capability, a guest may read the MSR_PLATFORM_INFO MSR. Otherwise,
  5509. a #GP would be raised when the guest tries to access. Currently, this
  5510. capability does not enable write permissions of this MSR for the guest.
  5511. 7.16 KVM_CAP_PPC_NESTED_HV
  5512. --------------------------
  5513. :Architectures: ppc
  5514. :Parameters: none
  5515. :Returns: 0 on success, -EINVAL when the implementation doesn't support
  5516. nested-HV virtualization.
  5517. HV-KVM on POWER9 and later systems allows for "nested-HV"
  5518. virtualization, which provides a way for a guest VM to run guests that
  5519. can run using the CPU's supervisor mode (privileged non-hypervisor
  5520. state). Enabling this capability on a VM depends on the CPU having
  5521. the necessary functionality and on the facility being enabled with a
  5522. kvm-hv module parameter.
  5523. 7.17 KVM_CAP_EXCEPTION_PAYLOAD
  5524. ------------------------------
  5525. :Architectures: x86
  5526. :Parameters: args[0] whether feature should be enabled or not
  5527. With this capability enabled, CR2 will not be modified prior to the
  5528. emulated VM-exit when L1 intercepts a #PF exception that occurs in
  5529. L2. Similarly, for kvm-intel only, DR6 will not be modified prior to
  5530. the emulated VM-exit when L1 intercepts a #DB exception that occurs in
  5531. L2. As a result, when KVM_GET_VCPU_EVENTS reports a pending #PF (or
  5532. #DB) exception for L2, exception.has_payload will be set and the
  5533. faulting address (or the new DR6 bits*) will be reported in the
  5534. exception_payload field. Similarly, when userspace injects a #PF (or
  5535. #DB) into L2 using KVM_SET_VCPU_EVENTS, it is expected to set
  5536. exception.has_payload and to put the faulting address - or the new DR6
  5537. bits\ [#]_ - in the exception_payload field.
  5538. This capability also enables exception.pending in struct
  5539. kvm_vcpu_events, which allows userspace to distinguish between pending
  5540. and injected exceptions.
  5541. .. [#] For the new DR6 bits, note that bit 16 is set iff the #DB exception
  5542. will clear DR6.RTM.
  5543. 7.18 KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
  5544. :Architectures: x86, arm64, mips
  5545. :Parameters: args[0] whether feature should be enabled or not
  5546. Valid flags are::
  5547. #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
  5548. #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
  5549. With KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE is set, KVM_GET_DIRTY_LOG will not
  5550. automatically clear and write-protect all pages that are returned as dirty.
  5551. Rather, userspace will have to do this operation separately using
  5552. KVM_CLEAR_DIRTY_LOG.
  5553. At the cost of a slightly more complicated operation, this provides better
  5554. scalability and responsiveness for two reasons. First,
  5555. KVM_CLEAR_DIRTY_LOG ioctl can operate on a 64-page granularity rather
  5556. than requiring to sync a full memslot; this ensures that KVM does not
  5557. take spinlocks for an extended period of time. Second, in some cases a
  5558. large amount of time can pass between a call to KVM_GET_DIRTY_LOG and
  5559. userspace actually using the data in the page. Pages can be modified
  5560. during this time, which is inefficient for both the guest and userspace:
  5561. the guest will incur a higher penalty due to write protection faults,
  5562. while userspace can see false reports of dirty pages. Manual reprotection
  5563. helps reducing this time, improving guest performance and reducing the
  5564. number of dirty log false positives.
  5565. With KVM_DIRTY_LOG_INITIALLY_SET set, all the bits of the dirty bitmap
  5566. will be initialized to 1 when created. This also improves performance because
  5567. dirty logging can be enabled gradually in small chunks on the first call
  5568. to KVM_CLEAR_DIRTY_LOG. KVM_DIRTY_LOG_INITIALLY_SET depends on
  5569. KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (it is also only available on
  5570. x86 and arm64 for now).
  5571. KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 was previously available under the name
  5572. KVM_CAP_MANUAL_DIRTY_LOG_PROTECT, but the implementation had bugs that make
  5573. it hard or impossible to use it correctly. The availability of
  5574. KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 signals that those bugs are fixed.
  5575. Userspace should not try to use KVM_CAP_MANUAL_DIRTY_LOG_PROTECT.
  5576. 7.19 KVM_CAP_PPC_SECURE_GUEST
  5577. ------------------------------
  5578. :Architectures: ppc
  5579. This capability indicates that KVM is running on a host that has
  5580. ultravisor firmware and thus can support a secure guest. On such a
  5581. system, a guest can ask the ultravisor to make it a secure guest,
  5582. one whose memory is inaccessible to the host except for pages which
  5583. are explicitly requested to be shared with the host. The ultravisor
  5584. notifies KVM when a guest requests to become a secure guest, and KVM
  5585. has the opportunity to veto the transition.
  5586. If present, this capability can be enabled for a VM, meaning that KVM
  5587. will allow the transition to secure guest mode. Otherwise KVM will
  5588. veto the transition.
  5589. 7.20 KVM_CAP_HALT_POLL
  5590. ----------------------
  5591. :Architectures: all
  5592. :Target: VM
  5593. :Parameters: args[0] is the maximum poll time in nanoseconds
  5594. :Returns: 0 on success; -1 on error
  5595. KVM_CAP_HALT_POLL overrides the kvm.halt_poll_ns module parameter to set the
  5596. maximum halt-polling time for all vCPUs in the target VM. This capability can
  5597. be invoked at any time and any number of times to dynamically change the
  5598. maximum halt-polling time.
  5599. See Documentation/virt/kvm/halt-polling.rst for more information on halt
  5600. polling.
  5601. 7.21 KVM_CAP_X86_USER_SPACE_MSR
  5602. -------------------------------
  5603. :Architectures: x86
  5604. :Target: VM
  5605. :Parameters: args[0] contains the mask of KVM_MSR_EXIT_REASON_* events to report
  5606. :Returns: 0 on success; -1 on error
  5607. This capability enables trapping of #GP invoking RDMSR and WRMSR instructions
  5608. into user space.
  5609. When a guest requests to read or write an MSR, KVM may not implement all MSRs
  5610. that are relevant to a respective system. It also does not differentiate by
  5611. CPU type.
  5612. To allow more fine grained control over MSR handling, user space may enable
  5613. this capability. With it enabled, MSR accesses that match the mask specified in
  5614. args[0] and trigger a #GP event inside the guest by KVM will instead trigger
  5615. KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR exit notifications which user space
  5616. can then handle to implement model specific MSR handling and/or user notifications
  5617. to inform a user that an MSR was not handled.
  5618. 7.22 KVM_CAP_X86_BUS_LOCK_EXIT
  5619. -------------------------------
  5620. :Architectures: x86
  5621. :Target: VM
  5622. :Parameters: args[0] defines the policy used when bus locks detected in guest
  5623. :Returns: 0 on success, -EINVAL when args[0] contains invalid bits
  5624. Valid bits in args[0] are::
  5625. #define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
  5626. #define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
  5627. Enabling this capability on a VM provides userspace with a way to select
  5628. a policy to handle the bus locks detected in guest. Userspace can obtain
  5629. the supported modes from the result of KVM_CHECK_EXTENSION and define it
  5630. through the KVM_ENABLE_CAP.
  5631. KVM_BUS_LOCK_DETECTION_OFF and KVM_BUS_LOCK_DETECTION_EXIT are supported
  5632. currently and mutually exclusive with each other. More bits can be added in
  5633. the future.
  5634. With KVM_BUS_LOCK_DETECTION_OFF set, bus locks in guest will not cause vm exits
  5635. so that no additional actions are needed. This is the default mode.
  5636. With KVM_BUS_LOCK_DETECTION_EXIT set, vm exits happen when bus lock detected
  5637. in VM. KVM just exits to userspace when handling them. Userspace can enforce
  5638. its own throttling or other policy based mitigations.
  5639. This capability is aimed to address the thread that VM can exploit bus locks to
  5640. degree the performance of the whole system. Once the userspace enable this
  5641. capability and select the KVM_BUS_LOCK_DETECTION_EXIT mode, KVM will set the
  5642. KVM_RUN_BUS_LOCK flag in vcpu-run->flags field and exit to userspace. Concerning
  5643. the bus lock vm exit can be preempted by a higher priority VM exit, the exit
  5644. notifications to userspace can be KVM_EXIT_BUS_LOCK or other reasons.
  5645. KVM_RUN_BUS_LOCK flag is used to distinguish between them.
  5646. 7.23 KVM_CAP_PPC_DAWR1
  5647. ----------------------
  5648. :Architectures: ppc
  5649. :Parameters: none
  5650. :Returns: 0 on success, -EINVAL when CPU doesn't support 2nd DAWR
  5651. This capability can be used to check / enable 2nd DAWR feature provided
  5652. by POWER10 processor.
  5653. 7.24 KVM_CAP_VM_COPY_ENC_CONTEXT_FROM
  5654. -------------------------------------
  5655. Architectures: x86 SEV enabled
  5656. Type: vm
  5657. Parameters: args[0] is the fd of the source vm
  5658. Returns: 0 on success; ENOTTY on error
  5659. This capability enables userspace to copy encryption context from the vm
  5660. indicated by the fd to the vm this is called on.
  5661. This is intended to support in-guest workloads scheduled by the host. This
  5662. allows the in-guest workload to maintain its own NPTs and keeps the two vms
  5663. from accidentally clobbering each other with interrupts and the like (separate
  5664. APIC/MSRs/etc).
  5665. 7.25 KVM_CAP_SGX_ATTRIBUTE
  5666. --------------------------
  5667. :Architectures: x86
  5668. :Target: VM
  5669. :Parameters: args[0] is a file handle of a SGX attribute file in securityfs
  5670. :Returns: 0 on success, -EINVAL if the file handle is invalid or if a requested
  5671. attribute is not supported by KVM.
  5672. KVM_CAP_SGX_ATTRIBUTE enables a userspace VMM to grant a VM access to one or
  5673. more priveleged enclave attributes. args[0] must hold a file handle to a valid
  5674. SGX attribute file corresponding to an attribute that is supported/restricted
  5675. by KVM (currently only PROVISIONKEY).
  5676. The SGX subsystem restricts access to a subset of enclave attributes to provide
  5677. additional security for an uncompromised kernel, e.g. use of the PROVISIONKEY
  5678. is restricted to deter malware from using the PROVISIONKEY to obtain a stable
  5679. system fingerprint. To prevent userspace from circumventing such restrictions
  5680. by running an enclave in a VM, KVM prevents access to privileged attributes by
  5681. default.
  5682. See Documentation/x86/sgx.rst for more details.
  5683. 7.26 KVM_CAP_PPC_RPT_INVALIDATE
  5684. -------------------------------
  5685. :Capability: KVM_CAP_PPC_RPT_INVALIDATE
  5686. :Architectures: ppc
  5687. :Type: vm
  5688. This capability indicates that the kernel is capable of handling
  5689. H_RPT_INVALIDATE hcall.
  5690. In order to enable the use of H_RPT_INVALIDATE in the guest,
  5691. user space might have to advertise it for the guest. For example,
  5692. IBM pSeries (sPAPR) guest starts using it if "hcall-rpt-invalidate" is
  5693. present in the "ibm,hypertas-functions" device-tree property.
  5694. This capability is enabled for hypervisors on platforms like POWER9
  5695. that support radix MMU.
  5696. 7.27 KVM_CAP_EXIT_ON_EMULATION_FAILURE
  5697. --------------------------------------
  5698. :Architectures: x86
  5699. :Parameters: args[0] whether the feature should be enabled or not
  5700. When this capability is enabled, an emulation failure will result in an exit
  5701. to userspace with KVM_INTERNAL_ERROR (except when the emulator was invoked
  5702. to handle a VMware backdoor instruction). Furthermore, KVM will now provide up
  5703. to 15 instruction bytes for any exit to userspace resulting from an emulation
  5704. failure. When these exits to userspace occur use the emulation_failure struct
  5705. instead of the internal struct. They both have the same layout, but the
  5706. emulation_failure struct matches the content better. It also explicitly
  5707. defines the 'flags' field which is used to describe the fields in the struct
  5708. that are valid (ie: if KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES is
  5709. set in the 'flags' field then both 'insn_size' and 'insn_bytes' have valid data
  5710. in them.)
  5711. 7.28 KVM_CAP_ARM_MTE
  5712. --------------------
  5713. :Architectures: arm64
  5714. :Parameters: none
  5715. This capability indicates that KVM (and the hardware) supports exposing the
  5716. Memory Tagging Extensions (MTE) to the guest. It must also be enabled by the
  5717. VMM before creating any VCPUs to allow the guest access. Note that MTE is only
  5718. available to a guest running in AArch64 mode and enabling this capability will
  5719. cause attempts to create AArch32 VCPUs to fail.
  5720. When enabled the guest is able to access tags associated with any memory given
  5721. to the guest. KVM will ensure that the tags are maintained during swap or
  5722. hibernation of the host; however the VMM needs to manually save/restore the
  5723. tags as appropriate if the VM is migrated.
  5724. When this capability is enabled all memory in memslots must be mapped as
  5725. not-shareable (no MAP_SHARED), attempts to create a memslot with a
  5726. MAP_SHARED mmap will result in an -EINVAL return.
  5727. When enabled the VMM may make use of the ``KVM_ARM_MTE_COPY_TAGS`` ioctl to
  5728. perform a bulk copy of tags to/from the guest.
  5729. 7.29 KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM
  5730. -------------------------------------
  5731. Architectures: x86 SEV enabled
  5732. Type: vm
  5733. Parameters: args[0] is the fd of the source vm
  5734. Returns: 0 on success
  5735. This capability enables userspace to migrate the encryption context from the VM
  5736. indicated by the fd to the VM this is called on.
  5737. This is intended to support intra-host migration of VMs between userspace VMMs,
  5738. upgrading the VMM process without interrupting the guest.
  5739. 7.30 KVM_CAP_PPC_AIL_MODE_3
  5740. -------------------------------
  5741. :Capability: KVM_CAP_PPC_AIL_MODE_3
  5742. :Architectures: ppc
  5743. :Type: vm
  5744. This capability indicates that the kernel supports the mode 3 setting for the
  5745. "Address Translation Mode on Interrupt" aka "Alternate Interrupt Location"
  5746. resource that is controlled with the H_SET_MODE hypercall.
  5747. This capability allows a guest kernel to use a better-performance mode for
  5748. handling interrupts and system calls.
  5749. 7.31 KVM_CAP_DISABLE_QUIRKS2
  5750. ----------------------------
  5751. :Capability: KVM_CAP_DISABLE_QUIRKS2
  5752. :Parameters: args[0] - set of KVM quirks to disable
  5753. :Architectures: x86
  5754. :Type: vm
  5755. This capability, if enabled, will cause KVM to disable some behavior
  5756. quirks.
  5757. Calling KVM_CHECK_EXTENSION for this capability returns a bitmask of
  5758. quirks that can be disabled in KVM.
  5759. The argument to KVM_ENABLE_CAP for this capability is a bitmask of
  5760. quirks to disable, and must be a subset of the bitmask returned by
  5761. KVM_CHECK_EXTENSION.
  5762. The valid bits in cap.args[0] are:
  5763. =================================== ============================================
  5764. KVM_X86_QUIRK_LINT0_REENABLED By default, the reset value for the LVT
  5765. LINT0 register is 0x700 (APIC_MODE_EXTINT).
  5766. When this quirk is disabled, the reset value
  5767. is 0x10000 (APIC_LVT_MASKED).
  5768. KVM_X86_QUIRK_CD_NW_CLEARED By default, KVM clears CR0.CD and CR0.NW.
  5769. When this quirk is disabled, KVM does not
  5770. change the value of CR0.CD and CR0.NW.
  5771. KVM_X86_QUIRK_LAPIC_MMIO_HOLE By default, the MMIO LAPIC interface is
  5772. available even when configured for x2APIC
  5773. mode. When this quirk is disabled, KVM
  5774. disables the MMIO LAPIC interface if the
  5775. LAPIC is in x2APIC mode.
  5776. KVM_X86_QUIRK_OUT_7E_INC_RIP By default, KVM pre-increments %rip before
  5777. exiting to userspace for an OUT instruction
  5778. to port 0x7e. When this quirk is disabled,
  5779. KVM does not pre-increment %rip before
  5780. exiting to userspace.
  5781. KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT When this quirk is disabled, KVM sets
  5782. CPUID.01H:ECX[bit 3] (MONITOR/MWAIT) if
  5783. IA32_MISC_ENABLE[bit 18] (MWAIT) is set.
  5784. Additionally, when this quirk is disabled,
  5785. KVM clears CPUID.01H:ECX[bit 3] if
  5786. IA32_MISC_ENABLE[bit 18] is cleared.
  5787. KVM_X86_QUIRK_FIX_HYPERCALL_INSN By default, KVM rewrites guest
  5788. VMMCALL/VMCALL instructions to match the
  5789. vendor's hypercall instruction for the
  5790. system. When this quirk is disabled, KVM
  5791. will no longer rewrite invalid guest
  5792. hypercall instructions. Executing the
  5793. incorrect hypercall instruction will
  5794. generate a #UD within the guest.
  5795. KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS By default, KVM emulates MONITOR/MWAIT (if
  5796. they are intercepted) as NOPs regardless of
  5797. whether or not MONITOR/MWAIT are supported
  5798. according to guest CPUID. When this quirk
  5799. is disabled and KVM_X86_DISABLE_EXITS_MWAIT
  5800. is not set (MONITOR/MWAIT are intercepted),
  5801. KVM will inject a #UD on MONITOR/MWAIT if
  5802. they're unsupported per guest CPUID. Note,
  5803. KVM will modify MONITOR/MWAIT support in
  5804. guest CPUID on writes to MISC_ENABLE if
  5805. KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT is
  5806. disabled.
  5807. =================================== ============================================
  5808. 7.32 KVM_CAP_MAX_VCPU_ID
  5809. ------------------------
  5810. :Architectures: x86
  5811. :Target: VM
  5812. :Parameters: args[0] - maximum APIC ID value set for current VM
  5813. :Returns: 0 on success, -EINVAL if args[0] is beyond KVM_MAX_VCPU_IDS
  5814. supported in KVM or if it has been set.
  5815. This capability allows userspace to specify maximum possible APIC ID
  5816. assigned for current VM session prior to the creation of vCPUs, saving
  5817. memory for data structures indexed by the APIC ID. Userspace is able
  5818. to calculate the limit to APIC ID values from designated
  5819. CPU topology.
  5820. The value can be changed only until KVM_ENABLE_CAP is set to a nonzero
  5821. value or until a vCPU is created. Upon creation of the first vCPU,
  5822. if the value was set to zero or KVM_ENABLE_CAP was not invoked, KVM
  5823. uses the return value of KVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPU_ID) as
  5824. the maximum APIC ID.
  5825. 7.33 KVM_CAP_X86_NOTIFY_VMEXIT
  5826. ------------------------------
  5827. :Architectures: x86
  5828. :Target: VM
  5829. :Parameters: args[0] is the value of notify window as well as some flags
  5830. :Returns: 0 on success, -EINVAL if args[0] contains invalid flags or notify
  5831. VM exit is unsupported.
  5832. Bits 63:32 of args[0] are used for notify window.
  5833. Bits 31:0 of args[0] are for some flags. Valid bits are::
  5834. #define KVM_X86_NOTIFY_VMEXIT_ENABLED (1 << 0)
  5835. #define KVM_X86_NOTIFY_VMEXIT_USER (1 << 1)
  5836. This capability allows userspace to configure the notify VM exit on/off
  5837. in per-VM scope during VM creation. Notify VM exit is disabled by default.
  5838. When userspace sets KVM_X86_NOTIFY_VMEXIT_ENABLED bit in args[0], VMM will
  5839. enable this feature with the notify window provided, which will generate
  5840. a VM exit if no event window occurs in VM non-root mode for a specified of
  5841. time (notify window).
  5842. If KVM_X86_NOTIFY_VMEXIT_USER is set in args[0], upon notify VM exits happen,
  5843. KVM would exit to userspace for handling.
  5844. This capability is aimed to mitigate the threat that malicious VMs can
  5845. cause CPU stuck (due to event windows don't open up) and make the CPU
  5846. unavailable to host or other VMs.
  5847. 8. Other capabilities.
  5848. ======================
  5849. This section lists capabilities that give information about other
  5850. features of the KVM implementation.
  5851. 8.1 KVM_CAP_PPC_HWRNG
  5852. ---------------------
  5853. :Architectures: ppc
  5854. This capability, if KVM_CHECK_EXTENSION indicates that it is
  5855. available, means that the kernel has an implementation of the
  5856. H_RANDOM hypercall backed by a hardware random-number generator.
  5857. If present, the kernel H_RANDOM handler can be enabled for guest use
  5858. with the KVM_CAP_PPC_ENABLE_HCALL capability.
  5859. 8.2 KVM_CAP_HYPERV_SYNIC
  5860. ------------------------
  5861. :Architectures: x86
  5862. This capability, if KVM_CHECK_EXTENSION indicates that it is
  5863. available, means that the kernel has an implementation of the
  5864. Hyper-V Synthetic interrupt controller(SynIC). Hyper-V SynIC is
  5865. used to support Windows Hyper-V based guest paravirt drivers(VMBus).
  5866. In order to use SynIC, it has to be activated by setting this
  5867. capability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this
  5868. will disable the use of APIC hardware virtualization even if supported
  5869. by the CPU, as it's incompatible with SynIC auto-EOI behavior.
  5870. 8.3 KVM_CAP_PPC_RADIX_MMU
  5871. -------------------------
  5872. :Architectures: ppc
  5873. This capability, if KVM_CHECK_EXTENSION indicates that it is
  5874. available, means that the kernel can support guests using the
  5875. radix MMU defined in Power ISA V3.00 (as implemented in the POWER9
  5876. processor).
  5877. 8.4 KVM_CAP_PPC_HASH_MMU_V3
  5878. ---------------------------
  5879. :Architectures: ppc
  5880. This capability, if KVM_CHECK_EXTENSION indicates that it is
  5881. available, means that the kernel can support guests using the
  5882. hashed page table MMU defined in Power ISA V3.00 (as implemented in
  5883. the POWER9 processor), including in-memory segment tables.
  5884. 8.5 KVM_CAP_MIPS_VZ
  5885. -------------------
  5886. :Architectures: mips
  5887. This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that
  5888. it is available, means that full hardware assisted virtualization capabilities
  5889. of the hardware are available for use through KVM. An appropriate
  5890. KVM_VM_MIPS_* type must be passed to KVM_CREATE_VM to create a VM which
  5891. utilises it.
  5892. If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is
  5893. available, it means that the VM is using full hardware assisted virtualization
  5894. capabilities of the hardware. This is useful to check after creating a VM with
  5895. KVM_VM_MIPS_DEFAULT.
  5896. The value returned by KVM_CHECK_EXTENSION should be compared against known
  5897. values (see below). All other values are reserved. This is to allow for the
  5898. possibility of other hardware assisted virtualization implementations which
  5899. may be incompatible with the MIPS VZ ASE.
  5900. == ==========================================================================
  5901. 0 The trap & emulate implementation is in use to run guest code in user
  5902. mode. Guest virtual memory segments are rearranged to fit the guest in the
  5903. user mode address space.
  5904. 1 The MIPS VZ ASE is in use, providing full hardware assisted
  5905. virtualization, including standard guest virtual memory segments.
  5906. == ==========================================================================
  5907. 8.6 KVM_CAP_MIPS_TE
  5908. -------------------
  5909. :Architectures: mips
  5910. This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that
  5911. it is available, means that the trap & emulate implementation is available to
  5912. run guest code in user mode, even if KVM_CAP_MIPS_VZ indicates that hardware
  5913. assisted virtualisation is also available. KVM_VM_MIPS_TE (0) must be passed
  5914. to KVM_CREATE_VM to create a VM which utilises it.
  5915. If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is
  5916. available, it means that the VM is using trap & emulate.
  5917. 8.7 KVM_CAP_MIPS_64BIT
  5918. ----------------------
  5919. :Architectures: mips
  5920. This capability indicates the supported architecture type of the guest, i.e. the
  5921. supported register and address width.
  5922. The values returned when this capability is checked by KVM_CHECK_EXTENSION on a
  5923. kvm VM handle correspond roughly to the CP0_Config.AT register field, and should
  5924. be checked specifically against known values (see below). All other values are
  5925. reserved.
  5926. == ========================================================================
  5927. 0 MIPS32 or microMIPS32.
  5928. Both registers and addresses are 32-bits wide.
  5929. It will only be possible to run 32-bit guest code.
  5930. 1 MIPS64 or microMIPS64 with access only to 32-bit compatibility segments.
  5931. Registers are 64-bits wide, but addresses are 32-bits wide.
  5932. 64-bit guest code may run but cannot access MIPS64 memory segments.
  5933. It will also be possible to run 32-bit guest code.
  5934. 2 MIPS64 or microMIPS64 with access to all address segments.
  5935. Both registers and addresses are 64-bits wide.
  5936. It will be possible to run 64-bit or 32-bit guest code.
  5937. == ========================================================================
  5938. 8.9 KVM_CAP_ARM_USER_IRQ
  5939. ------------------------
  5940. :Architectures: arm64
  5941. This capability, if KVM_CHECK_EXTENSION indicates that it is available, means
  5942. that if userspace creates a VM without an in-kernel interrupt controller, it
  5943. will be notified of changes to the output level of in-kernel emulated devices,
  5944. which can generate virtual interrupts, presented to the VM.
  5945. For such VMs, on every return to userspace, the kernel
  5946. updates the vcpu's run->s.regs.device_irq_level field to represent the actual
  5947. output level of the device.
  5948. Whenever kvm detects a change in the device output level, kvm guarantees at
  5949. least one return to userspace before running the VM. This exit could either
  5950. be a KVM_EXIT_INTR or any other exit event, like KVM_EXIT_MMIO. This way,
  5951. userspace can always sample the device output level and re-compute the state of
  5952. the userspace interrupt controller. Userspace should always check the state
  5953. of run->s.regs.device_irq_level on every kvm exit.
  5954. The value in run->s.regs.device_irq_level can represent both level and edge
  5955. triggered interrupt signals, depending on the device. Edge triggered interrupt
  5956. signals will exit to userspace with the bit in run->s.regs.device_irq_level
  5957. set exactly once per edge signal.
  5958. The field run->s.regs.device_irq_level is available independent of
  5959. run->kvm_valid_regs or run->kvm_dirty_regs bits.
  5960. If KVM_CAP_ARM_USER_IRQ is supported, the KVM_CHECK_EXTENSION ioctl returns a
  5961. number larger than 0 indicating the version of this capability is implemented
  5962. and thereby which bits in run->s.regs.device_irq_level can signal values.
  5963. Currently the following bits are defined for the device_irq_level bitmap::
  5964. KVM_CAP_ARM_USER_IRQ >= 1:
  5965. KVM_ARM_DEV_EL1_VTIMER - EL1 virtual timer
  5966. KVM_ARM_DEV_EL1_PTIMER - EL1 physical timer
  5967. KVM_ARM_DEV_PMU - ARM PMU overflow interrupt signal
  5968. Future versions of kvm may implement additional events. These will get
  5969. indicated by returning a higher number from KVM_CHECK_EXTENSION and will be
  5970. listed above.
  5971. 8.10 KVM_CAP_PPC_SMT_POSSIBLE
  5972. -----------------------------
  5973. :Architectures: ppc
  5974. Querying this capability returns a bitmap indicating the possible
  5975. virtual SMT modes that can be set using KVM_CAP_PPC_SMT. If bit N
  5976. (counting from the right) is set, then a virtual SMT mode of 2^N is
  5977. available.
  5978. 8.11 KVM_CAP_HYPERV_SYNIC2
  5979. --------------------------
  5980. :Architectures: x86
  5981. This capability enables a newer version of Hyper-V Synthetic interrupt
  5982. controller (SynIC). The only difference with KVM_CAP_HYPERV_SYNIC is that KVM
  5983. doesn't clear SynIC message and event flags pages when they are enabled by
  5984. writing to the respective MSRs.
  5985. 8.12 KVM_CAP_HYPERV_VP_INDEX
  5986. ----------------------------
  5987. :Architectures: x86
  5988. This capability indicates that userspace can load HV_X64_MSR_VP_INDEX msr. Its
  5989. value is used to denote the target vcpu for a SynIC interrupt. For
  5990. compatibilty, KVM initializes this msr to KVM's internal vcpu index. When this
  5991. capability is absent, userspace can still query this msr's value.
  5992. 8.13 KVM_CAP_S390_AIS_MIGRATION
  5993. -------------------------------
  5994. :Architectures: s390
  5995. :Parameters: none
  5996. This capability indicates if the flic device will be able to get/set the
  5997. AIS states for migration via the KVM_DEV_FLIC_AISM_ALL attribute and allows
  5998. to discover this without having to create a flic device.
  5999. 8.14 KVM_CAP_S390_PSW
  6000. ---------------------
  6001. :Architectures: s390
  6002. This capability indicates that the PSW is exposed via the kvm_run structure.
  6003. 8.15 KVM_CAP_S390_GMAP
  6004. ----------------------
  6005. :Architectures: s390
  6006. This capability indicates that the user space memory used as guest mapping can
  6007. be anywhere in the user memory address space, as long as the memory slots are
  6008. aligned and sized to a segment (1MB) boundary.
  6009. 8.16 KVM_CAP_S390_COW
  6010. ---------------------
  6011. :Architectures: s390
  6012. This capability indicates that the user space memory used as guest mapping can
  6013. use copy-on-write semantics as well as dirty pages tracking via read-only page
  6014. tables.
  6015. 8.17 KVM_CAP_S390_BPB
  6016. ---------------------
  6017. :Architectures: s390
  6018. This capability indicates that kvm will implement the interfaces to handle
  6019. reset, migration and nested KVM for branch prediction blocking. The stfle
  6020. facility 82 should not be provided to the guest without this capability.
  6021. 8.18 KVM_CAP_HYPERV_TLBFLUSH
  6022. ----------------------------
  6023. :Architectures: x86
  6024. This capability indicates that KVM supports paravirtualized Hyper-V TLB Flush
  6025. hypercalls:
  6026. HvFlushVirtualAddressSpace, HvFlushVirtualAddressSpaceEx,
  6027. HvFlushVirtualAddressList, HvFlushVirtualAddressListEx.
  6028. 8.19 KVM_CAP_ARM_INJECT_SERROR_ESR
  6029. ----------------------------------
  6030. :Architectures: arm64
  6031. This capability indicates that userspace can specify (via the
  6032. KVM_SET_VCPU_EVENTS ioctl) the syndrome value reported to the guest when it
  6033. takes a virtual SError interrupt exception.
  6034. If KVM advertises this capability, userspace can only specify the ISS field for
  6035. the ESR syndrome. Other parts of the ESR, such as the EC are generated by the
  6036. CPU when the exception is taken. If this virtual SError is taken to EL1 using
  6037. AArch64, this value will be reported in the ISS field of ESR_ELx.
  6038. See KVM_CAP_VCPU_EVENTS for more details.
  6039. 8.20 KVM_CAP_HYPERV_SEND_IPI
  6040. ----------------------------
  6041. :Architectures: x86
  6042. This capability indicates that KVM supports paravirtualized Hyper-V IPI send
  6043. hypercalls:
  6044. HvCallSendSyntheticClusterIpi, HvCallSendSyntheticClusterIpiEx.
  6045. 8.21 KVM_CAP_HYPERV_DIRECT_TLBFLUSH
  6046. -----------------------------------
  6047. :Architectures: x86
  6048. This capability indicates that KVM running on top of Hyper-V hypervisor
  6049. enables Direct TLB flush for its guests meaning that TLB flush
  6050. hypercalls are handled by Level 0 hypervisor (Hyper-V) bypassing KVM.
  6051. Due to the different ABI for hypercall parameters between Hyper-V and
  6052. KVM, enabling this capability effectively disables all hypercall
  6053. handling by KVM (as some KVM hypercall may be mistakenly treated as TLB
  6054. flush hypercalls by Hyper-V) so userspace should disable KVM identification
  6055. in CPUID and only exposes Hyper-V identification. In this case, guest
  6056. thinks it's running on Hyper-V and only use Hyper-V hypercalls.
  6057. 8.22 KVM_CAP_S390_VCPU_RESETS
  6058. -----------------------------
  6059. :Architectures: s390
  6060. This capability indicates that the KVM_S390_NORMAL_RESET and
  6061. KVM_S390_CLEAR_RESET ioctls are available.
  6062. 8.23 KVM_CAP_S390_PROTECTED
  6063. ---------------------------
  6064. :Architectures: s390
  6065. This capability indicates that the Ultravisor has been initialized and
  6066. KVM can therefore start protected VMs.
  6067. This capability governs the KVM_S390_PV_COMMAND ioctl and the
  6068. KVM_MP_STATE_LOAD MP_STATE. KVM_SET_MP_STATE can fail for protected
  6069. guests when the state change is invalid.
  6070. 8.24 KVM_CAP_STEAL_TIME
  6071. -----------------------
  6072. :Architectures: arm64, x86
  6073. This capability indicates that KVM supports steal time accounting.
  6074. When steal time accounting is supported it may be enabled with
  6075. architecture-specific interfaces. This capability and the architecture-
  6076. specific interfaces must be consistent, i.e. if one says the feature
  6077. is supported, than the other should as well and vice versa. For arm64
  6078. see Documentation/virt/kvm/devices/vcpu.rst "KVM_ARM_VCPU_PVTIME_CTRL".
  6079. For x86 see Documentation/virt/kvm/x86/msr.rst "MSR_KVM_STEAL_TIME".
  6080. 8.25 KVM_CAP_S390_DIAG318
  6081. -------------------------
  6082. :Architectures: s390
  6083. This capability enables a guest to set information about its control program
  6084. (i.e. guest kernel type and version). The information is helpful during
  6085. system/firmware service events, providing additional data about the guest
  6086. environments running on the machine.
  6087. The information is associated with the DIAGNOSE 0x318 instruction, which sets
  6088. an 8-byte value consisting of a one-byte Control Program Name Code (CPNC) and
  6089. a 7-byte Control Program Version Code (CPVC). The CPNC determines what
  6090. environment the control program is running in (e.g. Linux, z/VM...), and the
  6091. CPVC is used for information specific to OS (e.g. Linux version, Linux
  6092. distribution...)
  6093. If this capability is available, then the CPNC and CPVC can be synchronized
  6094. between KVM and userspace via the sync regs mechanism (KVM_SYNC_DIAG318).
  6095. 8.26 KVM_CAP_X86_USER_SPACE_MSR
  6096. -------------------------------
  6097. :Architectures: x86
  6098. This capability indicates that KVM supports deflection of MSR reads and
  6099. writes to user space. It can be enabled on a VM level. If enabled, MSR
  6100. accesses that would usually trigger a #GP by KVM into the guest will
  6101. instead get bounced to user space through the KVM_EXIT_X86_RDMSR and
  6102. KVM_EXIT_X86_WRMSR exit notifications.
  6103. 8.27 KVM_CAP_X86_MSR_FILTER
  6104. ---------------------------
  6105. :Architectures: x86
  6106. This capability indicates that KVM supports that accesses to user defined MSRs
  6107. may be rejected. With this capability exposed, KVM exports new VM ioctl
  6108. KVM_X86_SET_MSR_FILTER which user space can call to specify bitmaps of MSR
  6109. ranges that KVM should reject access to.
  6110. In combination with KVM_CAP_X86_USER_SPACE_MSR, this allows user space to
  6111. trap and emulate MSRs that are outside of the scope of KVM as well as
  6112. limit the attack surface on KVM's MSR emulation code.
  6113. 8.28 KVM_CAP_ENFORCE_PV_FEATURE_CPUID
  6114. -------------------------------------
  6115. Architectures: x86
  6116. When enabled, KVM will disable paravirtual features provided to the
  6117. guest according to the bits in the KVM_CPUID_FEATURES CPUID leaf
  6118. (0x40000001). Otherwise, a guest may use the paravirtual features
  6119. regardless of what has actually been exposed through the CPUID leaf.
  6120. 8.29 KVM_CAP_DIRTY_LOG_RING/KVM_CAP_DIRTY_LOG_RING_ACQ_REL
  6121. ----------------------------------------------------------
  6122. :Architectures: x86
  6123. :Parameters: args[0] - size of the dirty log ring
  6124. KVM is capable of tracking dirty memory using ring buffers that are
  6125. mmaped into userspace; there is one dirty ring per vcpu.
  6126. The dirty ring is available to userspace as an array of
  6127. ``struct kvm_dirty_gfn``. Each dirty entry it's defined as::
  6128. struct kvm_dirty_gfn {
  6129. __u32 flags;
  6130. __u32 slot; /* as_id | slot_id */
  6131. __u64 offset;
  6132. };
  6133. The following values are defined for the flags field to define the
  6134. current state of the entry::
  6135. #define KVM_DIRTY_GFN_F_DIRTY BIT(0)
  6136. #define KVM_DIRTY_GFN_F_RESET BIT(1)
  6137. #define KVM_DIRTY_GFN_F_MASK 0x3
  6138. Userspace should call KVM_ENABLE_CAP ioctl right after KVM_CREATE_VM
  6139. ioctl to enable this capability for the new guest and set the size of
  6140. the rings. Enabling the capability is only allowed before creating any
  6141. vCPU, and the size of the ring must be a power of two. The larger the
  6142. ring buffer, the less likely the ring is full and the VM is forced to
  6143. exit to userspace. The optimal size depends on the workload, but it is
  6144. recommended that it be at least 64 KiB (4096 entries).
  6145. Just like for dirty page bitmaps, the buffer tracks writes to
  6146. all user memory regions for which the KVM_MEM_LOG_DIRTY_PAGES flag was
  6147. set in KVM_SET_USER_MEMORY_REGION. Once a memory region is registered
  6148. with the flag set, userspace can start harvesting dirty pages from the
  6149. ring buffer.
  6150. An entry in the ring buffer can be unused (flag bits ``00``),
  6151. dirty (flag bits ``01``) or harvested (flag bits ``1X``). The
  6152. state machine for the entry is as follows::
  6153. dirtied harvested reset
  6154. 00 -----------> 01 -------------> 1X -------+
  6155. ^ |
  6156. | |
  6157. +------------------------------------------+
  6158. To harvest the dirty pages, userspace accesses the mmaped ring buffer
  6159. to read the dirty GFNs. If the flags has the DIRTY bit set (at this stage
  6160. the RESET bit must be cleared), then it means this GFN is a dirty GFN.
  6161. The userspace should harvest this GFN and mark the flags from state
  6162. ``01b`` to ``1Xb`` (bit 0 will be ignored by KVM, but bit 1 must be set
  6163. to show that this GFN is harvested and waiting for a reset), and move
  6164. on to the next GFN. The userspace should continue to do this until the
  6165. flags of a GFN have the DIRTY bit cleared, meaning that it has harvested
  6166. all the dirty GFNs that were available.
  6167. Note that on weakly ordered architectures, userspace accesses to the
  6168. ring buffer (and more specifically the 'flags' field) must be ordered,
  6169. using load-acquire/store-release accessors when available, or any
  6170. other memory barrier that will ensure this ordering.
  6171. It's not necessary for userspace to harvest the all dirty GFNs at once.
  6172. However it must collect the dirty GFNs in sequence, i.e., the userspace
  6173. program cannot skip one dirty GFN to collect the one next to it.
  6174. After processing one or more entries in the ring buffer, userspace
  6175. calls the VM ioctl KVM_RESET_DIRTY_RINGS to notify the kernel about
  6176. it, so that the kernel will reprotect those collected GFNs.
  6177. Therefore, the ioctl must be called *before* reading the content of
  6178. the dirty pages.
  6179. The dirty ring can get full. When it happens, the KVM_RUN of the
  6180. vcpu will return with exit reason KVM_EXIT_DIRTY_LOG_FULL.
  6181. The dirty ring interface has a major difference comparing to the
  6182. KVM_GET_DIRTY_LOG interface in that, when reading the dirty ring from
  6183. userspace, it's still possible that the kernel has not yet flushed the
  6184. processor's dirty page buffers into the kernel buffer (with dirty bitmaps, the
  6185. flushing is done by the KVM_GET_DIRTY_LOG ioctl). To achieve that, one
  6186. needs to kick the vcpu out of KVM_RUN using a signal. The resulting
  6187. vmexit ensures that all dirty GFNs are flushed to the dirty rings.
  6188. NOTE: the capability KVM_CAP_DIRTY_LOG_RING and the corresponding
  6189. ioctl KVM_RESET_DIRTY_RINGS are mutual exclusive to the existing ioctls
  6190. KVM_GET_DIRTY_LOG and KVM_CLEAR_DIRTY_LOG. After enabling
  6191. KVM_CAP_DIRTY_LOG_RING with an acceptable dirty ring size, the virtual
  6192. machine will switch to ring-buffer dirty page tracking and further
  6193. KVM_GET_DIRTY_LOG or KVM_CLEAR_DIRTY_LOG ioctls will fail.
  6194. NOTE: KVM_CAP_DIRTY_LOG_RING_ACQ_REL is the only capability that
  6195. should be exposed by weakly ordered architecture, in order to indicate
  6196. the additional memory ordering requirements imposed on userspace when
  6197. reading the state of an entry and mutating it from DIRTY to HARVESTED.
  6198. Architecture with TSO-like ordering (such as x86) are allowed to
  6199. expose both KVM_CAP_DIRTY_LOG_RING and KVM_CAP_DIRTY_LOG_RING_ACQ_REL
  6200. to userspace.
  6201. 8.30 KVM_CAP_XEN_HVM
  6202. --------------------
  6203. :Architectures: x86
  6204. This capability indicates the features that Xen supports for hosting Xen
  6205. PVHVM guests. Valid flags are::
  6206. #define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0)
  6207. #define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1)
  6208. #define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2)
  6209. #define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3)
  6210. #define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4)
  6211. #define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5)
  6212. The KVM_XEN_HVM_CONFIG_HYPERCALL_MSR flag indicates that the KVM_XEN_HVM_CONFIG
  6213. ioctl is available, for the guest to set its hypercall page.
  6214. If KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL is also set, the same flag may also be
  6215. provided in the flags to KVM_XEN_HVM_CONFIG, without providing hypercall page
  6216. contents, to request that KVM generate hypercall page content automatically
  6217. and also enable interception of guest hypercalls with KVM_EXIT_XEN.
  6218. The KVM_XEN_HVM_CONFIG_SHARED_INFO flag indicates the availability of the
  6219. KVM_XEN_HVM_SET_ATTR, KVM_XEN_HVM_GET_ATTR, KVM_XEN_VCPU_SET_ATTR and
  6220. KVM_XEN_VCPU_GET_ATTR ioctls, as well as the delivery of exception vectors
  6221. for event channel upcalls when the evtchn_upcall_pending field of a vcpu's
  6222. vcpu_info is set.
  6223. The KVM_XEN_HVM_CONFIG_RUNSTATE flag indicates that the runstate-related
  6224. features KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR/_CURRENT/_DATA/_ADJUST are
  6225. supported by the KVM_XEN_VCPU_SET_ATTR/KVM_XEN_VCPU_GET_ATTR ioctls.
  6226. The KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL flag indicates that IRQ routing entries
  6227. of the type KVM_IRQ_ROUTING_XEN_EVTCHN are supported, with the priority
  6228. field set to indicate 2 level event channel delivery.
  6229. The KVM_XEN_HVM_CONFIG_EVTCHN_SEND flag indicates that KVM supports
  6230. injecting event channel events directly into the guest with the
  6231. KVM_XEN_HVM_EVTCHN_SEND ioctl. It also indicates support for the
  6232. KVM_XEN_ATTR_TYPE_EVTCHN/XEN_VERSION HVM attributes and the
  6233. KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID/TIMER/UPCALL_VECTOR vCPU attributes.
  6234. related to event channel delivery, timers, and the XENVER_version
  6235. interception.
  6236. 8.31 KVM_CAP_PPC_MULTITCE
  6237. -------------------------
  6238. :Capability: KVM_CAP_PPC_MULTITCE
  6239. :Architectures: ppc
  6240. :Type: vm
  6241. This capability means the kernel is capable of handling hypercalls
  6242. H_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user
  6243. space. This significantly accelerates DMA operations for PPC KVM guests.
  6244. User space should expect that its handlers for these hypercalls
  6245. are not going to be called if user space previously registered LIOBN
  6246. in KVM (via KVM_CREATE_SPAPR_TCE or similar calls).
  6247. In order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest,
  6248. user space might have to advertise it for the guest. For example,
  6249. IBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is
  6250. present in the "ibm,hypertas-functions" device-tree property.
  6251. The hypercalls mentioned above may or may not be processed successfully
  6252. in the kernel based fast path. If they can not be handled by the kernel,
  6253. they will get passed on to user space. So user space still has to have
  6254. an implementation for these despite the in kernel acceleration.
  6255. This capability is always enabled.
  6256. 8.32 KVM_CAP_PTP_KVM
  6257. --------------------
  6258. :Architectures: arm64
  6259. This capability indicates that the KVM virtual PTP service is
  6260. supported in the host. A VMM can check whether the service is
  6261. available to the guest on migration.
  6262. 8.33 KVM_CAP_HYPERV_ENFORCE_CPUID
  6263. ---------------------------------
  6264. Architectures: x86
  6265. When enabled, KVM will disable emulated Hyper-V features provided to the
  6266. guest according to the bits Hyper-V CPUID feature leaves. Otherwise, all
  6267. currently implmented Hyper-V features are provided unconditionally when
  6268. Hyper-V identification is set in the HYPERV_CPUID_INTERFACE (0x40000001)
  6269. leaf.
  6270. 8.34 KVM_CAP_EXIT_HYPERCALL
  6271. ---------------------------
  6272. :Capability: KVM_CAP_EXIT_HYPERCALL
  6273. :Architectures: x86
  6274. :Type: vm
  6275. This capability, if enabled, will cause KVM to exit to userspace
  6276. with KVM_EXIT_HYPERCALL exit reason to process some hypercalls.
  6277. Calling KVM_CHECK_EXTENSION for this capability will return a bitmask
  6278. of hypercalls that can be configured to exit to userspace.
  6279. Right now, the only such hypercall is KVM_HC_MAP_GPA_RANGE.
  6280. The argument to KVM_ENABLE_CAP is also a bitmask, and must be a subset
  6281. of the result of KVM_CHECK_EXTENSION. KVM will forward to userspace
  6282. the hypercalls whose corresponding bit is in the argument, and return
  6283. ENOSYS for the others.
  6284. 8.35 KVM_CAP_PMU_CAPABILITY
  6285. ---------------------------
  6286. :Capability KVM_CAP_PMU_CAPABILITY
  6287. :Architectures: x86
  6288. :Type: vm
  6289. :Parameters: arg[0] is bitmask of PMU virtualization capabilities.
  6290. :Returns 0 on success, -EINVAL when arg[0] contains invalid bits
  6291. This capability alters PMU virtualization in KVM.
  6292. Calling KVM_CHECK_EXTENSION for this capability returns a bitmask of
  6293. PMU virtualization capabilities that can be adjusted on a VM.
  6294. The argument to KVM_ENABLE_CAP is also a bitmask and selects specific
  6295. PMU virtualization capabilities to be applied to the VM. This can
  6296. only be invoked on a VM prior to the creation of VCPUs.
  6297. At this time, KVM_PMU_CAP_DISABLE is the only capability. Setting
  6298. this capability will disable PMU virtualization for that VM. Usermode
  6299. should adjust CPUID leaf 0xA to reflect that the PMU is disabled.
  6300. 8.36 KVM_CAP_ARM_SYSTEM_SUSPEND
  6301. -------------------------------
  6302. :Capability: KVM_CAP_ARM_SYSTEM_SUSPEND
  6303. :Architectures: arm64
  6304. :Type: vm
  6305. When enabled, KVM will exit to userspace with KVM_EXIT_SYSTEM_EVENT of
  6306. type KVM_SYSTEM_EVENT_SUSPEND to process the guest suspend request.
  6307. 8.37 KVM_CAP_S390_PROTECTED_DUMP
  6308. --------------------------------
  6309. :Capability: KVM_CAP_S390_PROTECTED_DUMP
  6310. :Architectures: s390
  6311. :Type: vm
  6312. This capability indicates that KVM and the Ultravisor support dumping
  6313. PV guests. The `KVM_PV_DUMP` command is available for the
  6314. `KVM_S390_PV_COMMAND` ioctl and the `KVM_PV_INFO` command provides
  6315. dump related UV data. Also the vcpu ioctl `KVM_S390_PV_CPU_COMMAND` is
  6316. available and supports the `KVM_PV_DUMP_CPU` subcommand.
  6317. 8.38 KVM_CAP_VM_DISABLE_NX_HUGE_PAGES
  6318. -------------------------------------
  6319. :Capability: KVM_CAP_VM_DISABLE_NX_HUGE_PAGES
  6320. :Architectures: x86
  6321. :Type: vm
  6322. :Parameters: arg[0] must be 0.
  6323. :Returns: 0 on success, -EPERM if the userspace process does not
  6324. have CAP_SYS_BOOT, -EINVAL if args[0] is not 0 or any vCPUs have been
  6325. created.
  6326. This capability disables the NX huge pages mitigation for iTLB MULTIHIT.
  6327. The capability has no effect if the nx_huge_pages module parameter is not set.
  6328. This capability may only be set before any vCPUs are created.
  6329. 8.39 KVM_CAP_S390_CPU_TOPOLOGY
  6330. ------------------------------
  6331. :Capability: KVM_CAP_S390_CPU_TOPOLOGY
  6332. :Architectures: s390
  6333. :Type: vm
  6334. This capability indicates that KVM will provide the S390 CPU Topology
  6335. facility which consist of the interpretation of the PTF instruction for
  6336. the function code 2 along with interception and forwarding of both the
  6337. PTF instruction with function codes 0 or 1 and the STSI(15,1,x)
  6338. instruction to the userland hypervisor.
  6339. The stfle facility 11, CPU Topology facility, should not be indicated
  6340. to the guest without this capability.
  6341. When this capability is present, KVM provides a new attribute group
  6342. on vm fd, KVM_S390_VM_CPU_TOPOLOGY.
  6343. This new attribute allows to get, set or clear the Modified Change
  6344. Topology Report (MTCR) bit of the SCA through the kvm_device_attr
  6345. structure.
  6346. When getting the Modified Change Topology Report value, the attr->addr
  6347. must point to a byte where the value will be stored or retrieved from.
  6348. 9. Known KVM API problems
  6349. =========================
  6350. In some cases, KVM's API has some inconsistencies or common pitfalls
  6351. that userspace need to be aware of. This section details some of
  6352. these issues.
  6353. Most of them are architecture specific, so the section is split by
  6354. architecture.
  6355. 9.1. x86
  6356. --------
  6357. ``KVM_GET_SUPPORTED_CPUID`` issues
  6358. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6359. In general, ``KVM_GET_SUPPORTED_CPUID`` is designed so that it is possible
  6360. to take its result and pass it directly to ``KVM_SET_CPUID2``. This section
  6361. documents some cases in which that requires some care.
  6362. Local APIC features
  6363. ~~~~~~~~~~~~~~~~~~~
  6364. CPU[EAX=1]:ECX[21] (X2APIC) is reported by ``KVM_GET_SUPPORTED_CPUID``,
  6365. but it can only be enabled if ``KVM_CREATE_IRQCHIP`` or
  6366. ``KVM_ENABLE_CAP(KVM_CAP_IRQCHIP_SPLIT)`` are used to enable in-kernel emulation of
  6367. the local APIC.
  6368. The same is true for the ``KVM_FEATURE_PV_UNHALT`` paravirtualized feature.
  6369. CPU[EAX=1]:ECX[24] (TSC_DEADLINE) is not reported by ``KVM_GET_SUPPORTED_CPUID``.
  6370. It can be enabled if ``KVM_CAP_TSC_DEADLINE_TIMER`` is present and the kernel
  6371. has enabled in-kernel emulation of the local APIC.
  6372. CPU topology
  6373. ~~~~~~~~~~~~
  6374. Several CPUID values include topology information for the host CPU:
  6375. 0x0b and 0x1f for Intel systems, 0x8000001e for AMD systems. Different
  6376. versions of KVM return different values for this information and userspace
  6377. should not rely on it. Currently they return all zeroes.
  6378. If userspace wishes to set up a guest topology, it should be careful that
  6379. the values of these three leaves differ for each CPU. In particular,
  6380. the APIC ID is found in EDX for all subleaves of 0x0b and 0x1f, and in EAX
  6381. for 0x8000001e; the latter also encodes the core id and node id in bits
  6382. 7:0 of EBX and ECX respectively.
  6383. Obsolete ioctls and capabilities
  6384. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6385. KVM_CAP_DISABLE_QUIRKS does not let userspace know which quirks are actually
  6386. available. Use ``KVM_CHECK_EXTENSION(KVM_CAP_DISABLE_QUIRKS2)`` instead if
  6387. available.
  6388. Ordering of KVM_GET_*/KVM_SET_* ioctls
  6389. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6390. TBD