07 drivers
TRANSCRIPT
-
7/25/2019 07 Drivers
1/72
COMP9242
2010/S2 Week 7
Device Drivers
-
7/25/2019 07 Drivers
2/72
Lecture outline
Part 1: Introduction to device drivers
Part 2: Overview of research on device driver reliability
Part 3: Device drivers research at ERO!
-
7/25/2019 07 Drivers
3/72
User app
OS
driver driver driver driver
User app User app
-
7/25/2019 07 Drivers
4/72
!o"e statistics
#$% of O! code is in device drivers
& 3'(()'$$$ out of ('**#'$$$ loc in Linu+ 2,-,2#
. ty/ical Linu+ la/to/ runs 02($'$$$ lines of ernel code'
includin 0#2'$$$ loc in 3- different device drivers
Drivers contain 3# ti"es "ore bus /er loc than the rest ofthe ernel
#$% of O! failures are caused by driver bus
-
7/25/2019 07 Drivers
5/72
Part 1: Introduction to device drivers
-
7/25/2019 07 Drivers
6/72
O! archeoloy
he first 456 device drivers: I7O libraries for the I89#$* batch /rocessin syste" 1*;)level view
#us inter"ace
interna$ $oic
reister "i$e
8/O #us
e'terna$ !ediu!
8/O
dev
ice
-
7/25/2019 07 Drivers
15/72
I7O devices in a ty/ical desto/ syste"
-
7/25/2019 07 Drivers
16/72
P?I bus overview
P?I bus& ?onventional P?I
Develo/ed and standardised in early *$Cs
32 or -( bit shared /arallel bus
@/ to --9B 4;33987s6
& P?I> @/ to 1339B 41$--987s6
& P?I E+/ress
?onsists of serial /2/ lins
!oftware>co"/atible with conventional P?I
@/ to 1-=87s /er device
-
7/25/2019 07 Drivers
17/72
P?I bus overview: "e"ory s/ace
CPU
MPC8
contro$$er
Dev1 Dev
Dev1 Dev2 Dev
Dev2
P%+sica$ address space S3
PC8 !e!or+ space
-
7/25/2019 07 Drivers
18/72
P?I bus overview: D9.
CPU
MPC8
contro$$er
Dev1 Dev
Dev1 Dev2 Dev
Dev2
P%+sica$ address space S3
PC8 !e!or+ space
-
7/25/2019 07 Drivers
19/72
P?I bus overview: D9.
CPU
MPC8
contro$$er
Dev1 Dev
Dev1 Dev2 Dev
Dev2
P%+sica$ address space S3
PC8 !e!or+ space
8OMMU
-
7/25/2019 07 Drivers
20/72
D9. descri/tors
M
Device
Driver
Per!anent DM !appins
Set up durin driver initia$isationData !ust #e copied to/"ro! DM #u""ers
M
Device
Driver
Strea!in !appins
Created "or eac% trans"erData is accessed inp$ace
DM descriptors
-
7/25/2019 07 Drivers
21/72
P?I bus overview: interru/ts
CPU
MPC8
contro$$er
Dev1 Dev
Dev1 Dev2 Dev
8;
contro$$er
Dev2
P%+sica$ address space S3
PC8 !e!or+ space
-
7/25/2019 07 Drivers
22/72
P?I bus overview: confi s/ace
P?I confiuration s/ace
& @sed for device enu"eration and confiuration& ?ontains standardised device descri/tors
-
7/25/2019 07 Drivers
23/72
P?I bus overview: I7O s/ace
I7O s/ace
& obsolete
-
7/25/2019 07 Drivers
24/72
Fritin a driver for a P?I device
Reistration
& ell the O! which P?I device IDCs the driver su//orts
Instantiation
& Done by the O! when it finds a driver with a "atchin ID
Initialisation
& .llocate P?I resources: "e"ory reions' IRGCs
& Enable bus "asterin
Power "anae"ent
& Pre/are the device for a transition into a low>/ower state
& Restore device confiuration durin wae>u/
-
7/25/2019 07 Drivers
25/72
Fritin a driver for a P?I device
Interru/t handler
& Return .!.P to re>enable interru/tsH /erfor" heavy>weiht/rocessin in a se/arate thread
D9.
& Per"anent "a//ins: disable cachin
& !trea"in "a//ins: "ay reuire bounce buffers& Returns buffer address in the bus address s/ace
-
7/25/2019 07 Drivers
26/72
@!8 bus overview
@!8 bus& Bost>centric
& Distributed>syste">style architecture
& Bot /lu
& Power "anae"ent
8us>/owered and self>/owered devices& @!8 1,+
@/ to 129b7s
& @!8 2,$
@/ to ()$9b7s
& @!8 3,$ @/ to (,)=b7s
-
7/25/2019 07 Drivers
27/72
@!8 bus overview
US #us
contro$$er
oot %u#
Device 1 Device 2
-
7/25/2019 07 Drivers
28/72
I7O devices in a ty/ical desto/ syste"
-
7/25/2019 07 Drivers
29/72
Driver stacin
-
7/25/2019 07 Drivers
30/72
Driver stacin
=CP/8P stack
>??772
@t%ernet
driver
%ardAstartA'!itpkt3
-
7/25/2019 07 Drivers
31/72
Driver stacin
=CP/8P stack
>??772
@t%ernet
driver
US @
-
7/25/2019 07 Drivers
32/72
Driver stacin
=CP/8P stack
>??772
@t%ernet
driver
US @
-
7/25/2019 07 Drivers
33/72
Driver stacin
=CP/8P stack
>??772
@t%ernet
driver
US @
-
7/25/2019 07 Drivers
34/72
Driver fra"ewor desin /atterns
=%e driver pattern =%e #us pattern
-
7/25/2019 07 Drivers
35/72
Driver fra"ewor software architecture
-
7/25/2019 07 Drivers
36/72
Guestions5
-
7/25/2019 07 Drivers
37/72
Part 2: Overview of research on device driverreliability
-
7/25/2019 07 Drivers
38/72
!o"e statistics
#$% of O! code is in device drivers
& 3'(()'$$$ out of ('**#'$$$ loc in Linu+ 2,-,2#
. ty/ical Linu+ la/to/ runs 02($'$$$ lines of ernel code'includin 0#2'$$$ loc in 3- different device drivers
Drivers contain 3# ti"es "ore bus /er loc than the rest ofthe ernel
#$% of O! failures are caused by driver bus
-
7/25/2019 07 Drivers
39/72
@nderstandin driver bus
Driver failures
-
7/25/2019 07 Drivers
40/72
@nderstandin driver bus
Driver failures
& 9e"ory access violations
& O! /rotocol violations
Orderin violations
Data for"at violations
E+cessive use of resources e"/oral failure
& Device /rotocol violations
Incorrect use of the device state "achine
Runaway D9.
Interru/t stor"s& ?oncurrency bus
Race conditions
Deadlocs
-
7/25/2019 07 Drivers
41/72
@ser>level device drivers
@ser>level drivers
& Each driver is enca/sulated inside a se/arate hardware/rotection do"ain
& ?o""unication between the driver and its client is based on IP?
& Device "e"ory is "a//ed into the virtual address s/ace of thedriver
& Interru/ts are delivered to the driver via IP?Cs
-
7/25/2019 07 Drivers
42/72
@ser>level drivers in J>ernel O!s
pp$ication=CP/8PDriver
8PC8PC
DM
User $and
Berne$
-
7/25/2019 07 Drivers
43/72
@ser>level drivers in J>ernel O!s
pp$ication=CP/8PDriver
8PC8PC
8PC
8;
User $and
Berne$
-
7/25/2019 07 Drivers
44/72
@ser>level drivers in J>ernel O!s
pp$ication
=CP/8PDriver
8PC
et "i$ter
User $and
Berne$
-
7/25/2019 07 Drivers
45/72
@ser>level drivers in J>ernel O!s
pp$icationDriver
8PC
=CP/8P
User $and
Berne$
-
7/25/2019 07 Drivers
46/72
Driver /erfor"ance characteristics
-
7/25/2019 07 Drivers
47/72
Driver /erfor"ance characteristics
I7O throuh/ut
& ?an the driver saturate the device5
I7O latency
& Bow does the driver affect the latency of a sinle I7O reuest5
?P@ utilisation
& Bow "uch ?P@ overhead does the driver introduce5
-
7/25/2019 07 Drivers
48/72
I"/rovin the /erfor"ance of @LD
-
7/25/2019 07 Drivers
49/72
I"/rovin the /erfor"ance of @LD
Fays to i"/rove user>level driver /erfor"ance
& !hared>"e"ory co""unication& Reuest ueuein
& Interru/t coalescin
I"/le"entin efficient shared "e"ory
-
7/25/2019 07 Drivers
50/72
I"/le"entin efficient shared>"e"oryco""unication
Issues:
& Resource accountin& !afety
& .synchronous notifications
Consu!erProducer
User $and
Berne$ noti"ications
s%ared !e!or+
-
7/25/2019 07 Drivers
51/72
Rbufs
Pro/osed in the Ke"esis "icroernel>based "ulti"edia O!
Consu!erProducer data reion
r(ro
ror(re)uest descriptors
response descriptors
%ead pointer
tai$ pointer
%ead pointer
tai$ pointer
-
7/25/2019 07 Drivers
52/72
Early i"/le"entations
9ichian er"inal !yste" 1*#$Cs/ersonality J>ernel>based "ulti>server O!
& Bih IP? overhead
& Eventually' "oved drivers bac into the ernel
L3 1*)#>1**3ernel>based O!
& Bih IP? overhead& I"/roved IP? desin: 2$>fold /erfor"ance i"/rove"ent
& Ko data on driver /erfor"ance available
-
7/25/2019 07 Drivers
53/72
9ore recent i"/le"entations
!aw"ill 02$$$ti"e O!
& 01$$% ?P@ overhead due to user>level drivers
Alue 1**-s/ace distributed L(>based O!
& Low>overhead user>level I7O de"onstrated for a dis driver
-
7/25/2019 07 Drivers
54/72
?urrently active syste"s
Research
& seL(
& 9IKI3
& Ke+us
?o""ercial
& OL(
& GK
& =reenBills IKE=RIM
-
7/25/2019 07 Drivers
55/72
@ser>level drivers in a "onolithic O!
pp$icationDriver
=CP/8P
User $and
inu' Berne$
en es$ie et a$- User$eve$ device drivers: c%ieved per"or!ance* 2006
-
7/25/2019 07 Drivers
56/72
@ser>level drivers in a "onolithic O!
pp$icationDriver
=CP/8P
User $and
inu' Berne$
en es$ie et a$- User$eve$ device drivers: c%ieved per"or!ance* 2006
send3
read3
Me!!apped 8/O
-
7/25/2019 07 Drivers
57/72
@ser>level drivers in a "onolithic O!
pp$icationDriver
=CP/8P
User $and
inu' Berne$
en es$ie et a$- User$eve$ device drivers: c%ieved per"or!ance* 2006
recv3
8;
read3
-
7/25/2019 07 Drivers
58/72
@ser>level drivers in a "onolithic O!
pp$icationDriver
=CP/8P
User $and
inu' Berne$
en es$ie et a$- User$eve$ device drivers: c%ieved per"or!ance* 2006
pciA!apAxxx3 s+sca$$PC8 #us address
-
7/25/2019 07 Drivers
59/72
@ser>level drivers in a "onolithic O!
en es$ie et a$- User$eve$ device drivers: c%ieved per"or!ance* 2006
Perfor"ance
& @/ to #% throuh/ut deradation
& @/ to 1#% ?P@ overhead
& .ressive use of interru/t rate li"itin /otentially affects
latency 4not "easured6,
-
7/25/2019 07 Drivers
60/72
Koos
. co"/lete device>driver reliability solution for Linu+:
& Aault isolation& Aault detection
& Recovery
inu' kerne$
readon$+ "or t%e driver3
Driver
PCECop+in/rep$ication
EC%eckin
-
7/25/2019 07 Drivers
61/72
Koos
. co"/lete device>driver reliability solution for Linu+:
& Aault isolation& Aault detection
& Recovery
inu' kerne$
readon$+ "or t%e driver3
Driver
PCECop+in/rep$ication
EC%eckin
Driver
-
7/25/2019 07 Drivers
62/72
K
-
7/25/2019 07 Drivers
63/72
Koos
. co"/lete device>driver reliability solution for Linu+:
& Aault isolation& Aault detection
& Recovery
Proble"s
& he driver interface in Linu+ is not well defined, Koos "ustsi"ulate the behaviour of hundreds of ernel and driver entry/oints,
Perfor"ance
& 1$% throuh/ut deradation
& )$% ?P@ overhead
Ni t li ti d l l d i
-
7/25/2019 07 Drivers
64/72
Nirtualisation and user>level drivers
Direct I7O
-
7/25/2019 07 Drivers
65/72
Nirtualisation and user>level drivers
Paravirtualised I7O
-
7/25/2019 07 Drivers
66/72
Paravirtualised I7O in en
>en %+pervisor
Driver do!ain Guest do!ain
net"rontnet#ack
Driver
8/O c%anne$s
=>t' #u"
"ree #u"
> r' #u"r' packet
en I7O channels are si"ilar to rbufs' but use a sinlecircular buffer for both reuests and co"/letions and rely on
"a//in rather than sharin
I7O h l
-
7/25/2019 07 Drivers
67/72
en I7O channels
P i t li d I7O i
-
7/25/2019 07 Drivers
68/72
Paravirtualised I7O in en
Perfor"ance overhead of the oriinal i"/le"entation: 3$$%
& Lon critical /ath 4increased instructions /er /acet6
& Biher L8 and cache "iss rates 4"ore cycles /er instructions6
& Overhead of "a//in
O/ti"isations
& .void "a//in on the send /ath 4the driver does not need tosee the /acet content6
& Re/lace "a//in with co/yin on the receive /ath
& .void unalined co/ies
& O/ti"ised i"/le"entation of /ae "a//in
& ?P@ overhead down to *#% 4worst>case receive /ath6
Other driver reliability techniues
-
7/25/2019 07 Drivers
69/72
Other driver reliability techniues
I"/le"entin drivers usin safe lanuaes
& Qava O!s: affeO!' Q
Every /rocess runs in a se/arate /rotection do"ain with a/rivate hea/, Process boundaries are enforced by thelanuae runti"e, ?o""unication is based on sharedhea/s,
& Bouse 4Basell O!6 8are>"etal Basell runti"e, he ernel and drivers are in
Basell,
@ser /rora"s can be written in any lanuae,
& !afeDrive
E+tends ? with /ointer ty/e annotations enforced via staticand runti"e checin
unsigned n;
struct e1000 buffer * count(n) bufinfo;
Other driver reliability techniues
-
7/25/2019 07 Drivers
70/72
Other driver reliability techniues
I"/le"entin drivers usin safe lanuaes
& !inularity O!
he entire O! is i"/le"ented in !in
Every driver is enca/sulated in a se/arate software>isolated/rocess
Processes co""unicated via "essaes sent across channels
!in /rovides "eans to s/ecify and statically enforcechannel /rotocols
Other driver reliability techniues
-
7/25/2019 07 Drivers
71/72
Other driver reliability techniues
!tatic analysis
& !L.9' 8last' ?overity
& =eneric /rora""in faults
Release acuired locsH do not acuire a loc twice
Do not dereference user /ointers
?hec /otentially K@LL>/ointers returned fro" routine
& Driver>s/ecific /ro/erties
if a driver calls another driver that is lower in the stac'then the dis/atch routine returns the sa"e status that wasreturned by the lower driver
drivers "ar I7O reuest /acets as /endin while ueuin
the"& Li"itations
9any /ro/erties are beyond reach of current tools or aretheoretically undecidable 4e,,' "e"ory safety6
-
7/25/2019 07 Drivers
72/72
Guestions5