ia64/xen-unstable

changeset 12904:aabceba1dbc5

Merge.
author ssmith@localhost.localdomain
date Mon Dec 11 11:17:11 2006 -0800 (2006-12-11)
parents 3e2b6365ba75 4ae4bdee00e6
children 6b68a3688509
files patches/linux-2.6.16.33/kexec-generic.patch patches/linux-2.6.16.33/linux-2.6.19-rc1-kexec-xen-i386.patch patches/linux-2.6.16.33/linux-2.6.19-rc1-kexec-xen-x86_64.patch xen/arch/x86/mm.c xen/arch/x86/mm/shadow/common.c xen/include/asm-ia64/linux/asm-generic/pgtable-nopud.h
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Mon Dec 11 11:16:29 2006 -0800
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Mon Dec 11 11:17:11 2006 -0800
     1.3 @@ -23,7 +23,7 @@ The following classes are defined:
     1.4  Name & Description \\
     1.5  \hline
     1.6  {\tt session} & A session \\
     1.7 -{\tt task} & A longrunning asynchronous task \\
     1.8 +{\tt task} & A long-running asynchronous task \\
     1.9  {\tt VM} & A virtual machine (or 'guest') \\
    1.10  {\tt host} & A physical host \\
    1.11  {\tt host\_cpu} & A physical CPU \\
    1.12 @@ -109,6 +109,7 @@ The following enumeration types are used
    1.13  \hline
    1.14  \end{longtable}
    1.15  
    1.16 +\vspace{1cm}
    1.17  \begin{longtable}{|ll|}
    1.18  \hline
    1.19  {\tt enum vdi\_type} & \\
    1.20 @@ -136,6 +137,17 @@ The following enumeration types are used
    1.21  \vspace{1cm}
    1.22  \begin{longtable}{|ll|}
    1.23  \hline
    1.24 +{\tt enum task\_status\_type} & \\
    1.25 +\hline
    1.26 +\hspace{0.5cm}{\tt pending} & task is in progress \\
    1.27 +\hspace{0.5cm}{\tt success} & task was completed successfully \\
    1.28 +\hspace{0.5cm}{\tt failure} & task has failed \\
    1.29 +\hline
    1.30 +\end{longtable}
    1.31 +
    1.32 +\vspace{1cm}
    1.33 +\begin{longtable}{|ll|}
    1.34 +\hline
    1.35  {\tt enum cpu\_feature} & \\
    1.36  \hline
    1.37  \hspace{0.5cm}{\tt FPU} &  Onboard FPU  \\
    1.38 @@ -254,6 +266,16 @@ The following enumeration types are used
    1.39  \vspace{1cm}
    1.40  \begin{longtable}{|ll|}
    1.41  \hline
    1.42 +{\tt enum vbd\_type} & \\
    1.43 +\hline
    1.44 +\hspace{0.5cm}{\tt CD} & VBD will appear to guest as CD \\
    1.45 +\hspace{0.5cm}{\tt Disk} & VBD will appear to guest as disk \\
    1.46 +\hline
    1.47 +\end{longtable}
    1.48 +
    1.49 +\vspace{1cm}
    1.50 +\begin{longtable}{|ll|}
    1.51 +\hline
    1.52  {\tt enum driver\_type} & \\
    1.53  \hline
    1.54  \hspace{0.5cm}{\tt ioemu} & use hardware emulation \\
    1.55 @@ -273,6 +295,7 @@ The following enumeration types are used
    1.56  \hline
    1.57  Quals & Field & Type & Description \\
    1.58  \hline
    1.59 +$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
    1.60  $\mathit{RO}_\mathit{ins}$ &  {\tt this\_host} & host ref & Currently connected host \\
    1.61  $\mathit{RO}_\mathit{ins}$ &  {\tt this\_user} & user ref & Currently connected user \\
    1.62  \hline
    1.63 @@ -333,10 +356,42 @@ void
    1.64  \vspace{0.3cm}
    1.65  \vspace{0.3cm}
    1.66  \vspace{0.3cm}
    1.67 +\subsubsection{RPC name:~get\_uuid}
    1.68 +
    1.69 +{\bf Overview:} 
    1.70 +Get the uuid field of the given session.
    1.71 +
    1.72 + \noindent {\bf Signature:} 
    1.73 +\begin{verbatim} string get_uuid (session_id s, session ref self)\end{verbatim}
    1.74 +
    1.75 +
    1.76 +\noindent{\bf Arguments:}
    1.77 +
    1.78 + 
    1.79 +\vspace{0.3cm}
    1.80 +\begin{tabular}{|c|c|p{7cm}|}
    1.81 + \hline
    1.82 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.83 +{\tt session ref } & self & reference to the object \\ \hline 
    1.84 +
    1.85 +\end{tabular}
    1.86 +
    1.87 +\vspace{0.3cm}
    1.88 +
    1.89 + \noindent {\bf Return Type:} 
    1.90 +{\tt 
    1.91 +string
    1.92 +}
    1.93 +
    1.94 +
    1.95 +value of the field
    1.96 +\vspace{0.3cm}
    1.97 +\vspace{0.3cm}
    1.98 +\vspace{0.3cm}
    1.99  \subsubsection{RPC name:~get\_this\_host}
   1.100  
   1.101  {\bf Overview:} 
   1.102 -get accessor message derived from field this\_host of object session
   1.103 +Get the this\_host field of the given session.
   1.104  
   1.105   \noindent {\bf Signature:} 
   1.106  \begin{verbatim} (host ref) get_this_host (session_id s, session ref self)\end{verbatim}
   1.107 @@ -349,7 +404,7 @@ get accessor message derived from field 
   1.108  \begin{tabular}{|c|c|p{7cm}|}
   1.109   \hline
   1.110  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.111 -{\tt session ref } & self & object instance \\ \hline 
   1.112 +{\tt session ref } & self & reference to the object \\ \hline 
   1.113  
   1.114  \end{tabular}
   1.115  
   1.116 @@ -368,7 +423,7 @@ value of the field
   1.117  \subsubsection{RPC name:~get\_this\_user}
   1.118  
   1.119  {\bf Overview:} 
   1.120 -get accessor message derived from field this\_user of object session
   1.121 +Get the this\_user field of the given session.
   1.122  
   1.123   \noindent {\bf Signature:} 
   1.124  \begin{verbatim} (user ref) get_this_user (session_id s, session ref self)\end{verbatim}
   1.125 @@ -381,7 +436,7 @@ get accessor message derived from field 
   1.126  \begin{tabular}{|c|c|p{7cm}|}
   1.127   \hline
   1.128  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.129 -{\tt session ref } & self & object instance \\ \hline 
   1.130 +{\tt session ref } & self & reference to the object \\ \hline 
   1.131  
   1.132  \end{tabular}
   1.133  
   1.134 @@ -400,7 +455,7 @@ value of the field
   1.135  \subsubsection{RPC name:~create}
   1.136  
   1.137  {\bf Overview:} 
   1.138 -constructor for class session
   1.139 +Create a new session instance, and return its handle.
   1.140  
   1.141   \noindent {\bf Signature:} 
   1.142  \begin{verbatim} (session ref) create (session_id s, session record args)\end{verbatim}
   1.143 @@ -432,7 +487,7 @@ reference to the newly created object
   1.144  \subsubsection{RPC name:~destroy}
   1.145  
   1.146  {\bf Overview:} 
   1.147 -destructor for class session
   1.148 +Destroy the specified session instance.
   1.149  
   1.150   \noindent {\bf Signature:} 
   1.151  \begin{verbatim} void destroy (session_id s, session ref self)\end{verbatim}
   1.152 @@ -445,7 +500,7 @@ destructor for class session
   1.153  \begin{tabular}{|c|c|p{7cm}|}
   1.154   \hline
   1.155  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.156 -{\tt session ref } & self & object instance \\ \hline 
   1.157 +{\tt session ref } & self & reference to the object \\ \hline 
   1.158  
   1.159  \end{tabular}
   1.160  
   1.161 @@ -464,7 +519,7 @@ void
   1.162  \subsubsection{RPC name:~get\_by\_uuid}
   1.163  
   1.164  {\bf Overview:} 
   1.165 -returns the session instance with a particular uuid
   1.166 +Get a reference to the session instance with the specified UUID.
   1.167  
   1.168   \noindent {\bf Signature:} 
   1.169  \begin{verbatim} (session ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
   1.170 @@ -496,7 +551,7 @@ reference to the object
   1.171  \subsubsection{RPC name:~get\_record}
   1.172  
   1.173  {\bf Overview:} 
   1.174 -returns a record containing the state of an instance of class session
   1.175 +Get a record containing the current state of the given session.
   1.176  
   1.177   \noindent {\bf Signature:} 
   1.178  \begin{verbatim} (session record) get_record (session_id s, session ref self)\end{verbatim}
   1.179 @@ -533,55 +588,30 @@ all fields from the object
   1.180  \begin{longtable}{|lllp{0.38\textwidth}|}
   1.181  \hline
   1.182  \multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf task} \\
   1.183 -\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A longrunning asynchronous task}} \\
   1.184 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A long-running asynchronous task}} \\
   1.185  \hline
   1.186  Quals & Field & Type & Description \\
   1.187  \hline
   1.188  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   1.189  $\mathit{RW}$ &  {\tt name/label} & string & a human-readable name \\
   1.190  $\mathit{RW}$ &  {\tt name/description} & string & a notes field containg human-readable description \\
   1.191 +$\mathit{RO}_\mathit{run}$ &  {\tt status} & task\_status\_type & current status of the task \\
   1.192 +$\mathit{RO}_\mathit{run}$ &  {\tt progress} & int & if the task is still pending, this field contains the estimated percentage complete (0-100). If task has completed (successfully or unsuccessfully) this should be 100. \\
   1.193 +$\mathit{RO}_\mathit{run}$ &  {\tt eta} & datetime & if the task is still pending, this field contains the estimated completion time. If the task has finished (successfully or not) it contains the time the task finished. \\
   1.194 +$\mathit{RO}_\mathit{run}$ &  {\tt type} & string & if the task has completed successfully, this field contains the type of the encoded result (i.e. name of the class whose reference is in the result field). Undefined otherwise. \\
   1.195 +$\mathit{RO}_\mathit{run}$ &  {\tt result} & string & if the task has completed successfully, this field contains the result value (either Void or an object reference). Undefined otherwise. \\
   1.196 +$\mathit{RO}_\mathit{run}$ &  {\tt error\_code} & int & if the task has failed, this field contains the error code. Undefined otherwise. \\
   1.197 +$\mathit{RO}_\mathit{run}$ &  {\tt error\_info} & string Set & if the task has failed, this field contains the set of associated error strings. Undefined otherwise. \\
   1.198  \hline
   1.199  \end{longtable}
   1.200  \subsection{Additional RPCs associated with class: task}
   1.201 -\subsubsection{RPC name:~get\_status}
   1.202 -
   1.203 -{\bf Overview:} 
   1.204 -Poll a running asynchronous RPC invocation and query its status
   1.205 -
   1.206 - \noindent {\bf Signature:} 
   1.207 -\begin{verbatim} (uuid ref) get_status (session_id s, task ref task)\end{verbatim}
   1.208 -
   1.209 -
   1.210 -\noindent{\bf Arguments:}
   1.211 -
   1.212 - 
   1.213 -\vspace{0.3cm}
   1.214 -\begin{tabular}{|c|c|p{7cm}|}
   1.215 - \hline
   1.216 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.217 -{\tt task ref } & task & The ID of the RPC call to poll \\ \hline 
   1.218 -
   1.219 -\end{tabular}
   1.220 -
   1.221 -\vspace{0.3cm}
   1.222 -
   1.223 - \noindent {\bf Return Type:} 
   1.224 -{\tt 
   1.225 -uuid ref
   1.226 -}
   1.227 -
   1.228 -
   1.229 -String describing status of specified asynchronous RPC invocation, including estimated completion time
   1.230 -\vspace{0.3cm}
   1.231 -\vspace{0.3cm}
   1.232 -\vspace{0.3cm}
   1.233 -\subsubsection{RPC name:~get\_all\_tasks}
   1.234 -
   1.235 -{\bf Overview:} 
   1.236 -List all asynchronous RPC calls currently executing
   1.237 -
   1.238 - \noindent {\bf Signature:} 
   1.239 -\begin{verbatim} ((task ref) Set) get_all_tasks (session_id s)\end{verbatim}
   1.240 +\subsubsection{RPC name:~get\_all}
   1.241 +
   1.242 +{\bf Overview:} 
   1.243 +Return a list of all the tasks known to the system
   1.244 +
   1.245 + \noindent {\bf Signature:} 
   1.246 +\begin{verbatim} ((task ref) Set) get_all (session_id s)\end{verbatim}
   1.247  
   1.248  
   1.249  \vspace{0.3cm}
   1.250 @@ -592,17 +622,14 @@ List all asynchronous RPC calls currentl
   1.251  }
   1.252  
   1.253  
   1.254 -A list of tasks currently executing. Note that
   1.255 -tasks are associated with users rather than sessions. Thus, if you logout and
   1.256 -login again with a different session but the same user, this function will still
   1.257 -return the user's running tasks.
   1.258 +references to all objects
   1.259  \vspace{0.3cm}
   1.260  \vspace{0.3cm}
   1.261  \vspace{0.3cm}
   1.262  \subsubsection{RPC name:~get\_uuid}
   1.263  
   1.264  {\bf Overview:} 
   1.265 -get accessor message derived from field uuid of object task
   1.266 +Get the uuid field of the given task.
   1.267  
   1.268   \noindent {\bf Signature:} 
   1.269  \begin{verbatim} string get_uuid (session_id s, task ref self)\end{verbatim}
   1.270 @@ -615,7 +642,7 @@ get accessor message derived from field 
   1.271  \begin{tabular}{|c|c|p{7cm}|}
   1.272   \hline
   1.273  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.274 -{\tt task ref } & self & object instance \\ \hline 
   1.275 +{\tt task ref } & self & reference to the object \\ \hline 
   1.276  
   1.277  \end{tabular}
   1.278  
   1.279 @@ -634,7 +661,7 @@ value of the field
   1.280  \subsubsection{RPC name:~get\_name\_label}
   1.281  
   1.282  {\bf Overview:} 
   1.283 -get accessor message derived from field name/label of object task
   1.284 +Get the name/label field of the given task.
   1.285  
   1.286   \noindent {\bf Signature:} 
   1.287  \begin{verbatim} string get_name_label (session_id s, task ref self)\end{verbatim}
   1.288 @@ -647,7 +674,7 @@ get accessor message derived from field 
   1.289  \begin{tabular}{|c|c|p{7cm}|}
   1.290   \hline
   1.291  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.292 -{\tt task ref } & self & object instance \\ \hline 
   1.293 +{\tt task ref } & self & reference to the object \\ \hline 
   1.294  
   1.295  \end{tabular}
   1.296  
   1.297 @@ -666,7 +693,7 @@ value of the field
   1.298  \subsubsection{RPC name:~set\_name\_label}
   1.299  
   1.300  {\bf Overview:} 
   1.301 -set accessor message derived from field name/label of object task
   1.302 +Set the name/label field of the given task.
   1.303  
   1.304   \noindent {\bf Signature:} 
   1.305  \begin{verbatim} void set_name_label (session_id s, task ref self, string value)\end{verbatim}
   1.306 @@ -679,7 +706,7 @@ set accessor message derived from field 
   1.307  \begin{tabular}{|c|c|p{7cm}|}
   1.308   \hline
   1.309  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.310 -{\tt task ref } & self & object instance \\ \hline 
   1.311 +{\tt task ref } & self & reference to the object \\ \hline 
   1.312  
   1.313  {\tt string } & value & New value to set \\ \hline 
   1.314  
   1.315 @@ -700,7 +727,7 @@ void
   1.316  \subsubsection{RPC name:~get\_name\_description}
   1.317  
   1.318  {\bf Overview:} 
   1.319 -get accessor message derived from field name/description of object task
   1.320 +Get the name/description field of the given task.
   1.321  
   1.322   \noindent {\bf Signature:} 
   1.323  \begin{verbatim} string get_name_description (session_id s, task ref self)\end{verbatim}
   1.324 @@ -713,7 +740,7 @@ get accessor message derived from field 
   1.325  \begin{tabular}{|c|c|p{7cm}|}
   1.326   \hline
   1.327  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.328 -{\tt task ref } & self & object instance \\ \hline 
   1.329 +{\tt task ref } & self & reference to the object \\ \hline 
   1.330  
   1.331  \end{tabular}
   1.332  
   1.333 @@ -732,7 +759,7 @@ value of the field
   1.334  \subsubsection{RPC name:~set\_name\_description}
   1.335  
   1.336  {\bf Overview:} 
   1.337 -set accessor message derived from field name/description of object task
   1.338 +Set the name/description field of the given task.
   1.339  
   1.340   \noindent {\bf Signature:} 
   1.341  \begin{verbatim} void set_name_description (session_id s, task ref self, string value)\end{verbatim}
   1.342 @@ -745,7 +772,7 @@ set accessor message derived from field 
   1.343  \begin{tabular}{|c|c|p{7cm}|}
   1.344   \hline
   1.345  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.346 -{\tt task ref } & self & object instance \\ \hline 
   1.347 +{\tt task ref } & self & reference to the object \\ \hline 
   1.348  
   1.349  {\tt string } & value & New value to set \\ \hline 
   1.350  
   1.351 @@ -763,10 +790,234 @@ void
   1.352  \vspace{0.3cm}
   1.353  \vspace{0.3cm}
   1.354  \vspace{0.3cm}
   1.355 +\subsubsection{RPC name:~get\_status}
   1.356 +
   1.357 +{\bf Overview:} 
   1.358 +Get the status field of the given task.
   1.359 +
   1.360 + \noindent {\bf Signature:} 
   1.361 +\begin{verbatim} (task_status_type) get_status (session_id s, task ref self)\end{verbatim}
   1.362 +
   1.363 +
   1.364 +\noindent{\bf Arguments:}
   1.365 +
   1.366 + 
   1.367 +\vspace{0.3cm}
   1.368 +\begin{tabular}{|c|c|p{7cm}|}
   1.369 + \hline
   1.370 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.371 +{\tt task ref } & self & reference to the object \\ \hline 
   1.372 +
   1.373 +\end{tabular}
   1.374 +
   1.375 +\vspace{0.3cm}
   1.376 +
   1.377 + \noindent {\bf Return Type:} 
   1.378 +{\tt 
   1.379 +task\_status\_type
   1.380 +}
   1.381 +
   1.382 +
   1.383 +value of the field
   1.384 +\vspace{0.3cm}
   1.385 +\vspace{0.3cm}
   1.386 +\vspace{0.3cm}
   1.387 +\subsubsection{RPC name:~get\_progress}
   1.388 +
   1.389 +{\bf Overview:} 
   1.390 +Get the progress field of the given task.
   1.391 +
   1.392 + \noindent {\bf Signature:} 
   1.393 +\begin{verbatim} int get_progress (session_id s, task ref self)\end{verbatim}
   1.394 +
   1.395 +
   1.396 +\noindent{\bf Arguments:}
   1.397 +
   1.398 + 
   1.399 +\vspace{0.3cm}
   1.400 +\begin{tabular}{|c|c|p{7cm}|}
   1.401 + \hline
   1.402 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.403 +{\tt task ref } & self & reference to the object \\ \hline 
   1.404 +
   1.405 +\end{tabular}
   1.406 +
   1.407 +\vspace{0.3cm}
   1.408 +
   1.409 + \noindent {\bf Return Type:} 
   1.410 +{\tt 
   1.411 +int
   1.412 +}
   1.413 +
   1.414 +
   1.415 +value of the field
   1.416 +\vspace{0.3cm}
   1.417 +\vspace{0.3cm}
   1.418 +\vspace{0.3cm}
   1.419 +\subsubsection{RPC name:~get\_eta}
   1.420 +
   1.421 +{\bf Overview:} 
   1.422 +Get the eta field of the given task.
   1.423 +
   1.424 + \noindent {\bf Signature:} 
   1.425 +\begin{verbatim} datetime get_eta (session_id s, task ref self)\end{verbatim}
   1.426 +
   1.427 +
   1.428 +\noindent{\bf Arguments:}
   1.429 +
   1.430 + 
   1.431 +\vspace{0.3cm}
   1.432 +\begin{tabular}{|c|c|p{7cm}|}
   1.433 + \hline
   1.434 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.435 +{\tt task ref } & self & reference to the object \\ \hline 
   1.436 +
   1.437 +\end{tabular}
   1.438 +
   1.439 +\vspace{0.3cm}
   1.440 +
   1.441 + \noindent {\bf Return Type:} 
   1.442 +{\tt 
   1.443 +datetime
   1.444 +}
   1.445 +
   1.446 +
   1.447 +value of the field
   1.448 +\vspace{0.3cm}
   1.449 +\vspace{0.3cm}
   1.450 +\vspace{0.3cm}
   1.451 +\subsubsection{RPC name:~get\_type}
   1.452 +
   1.453 +{\bf Overview:} 
   1.454 +Get the type field of the given task.
   1.455 +
   1.456 + \noindent {\bf Signature:} 
   1.457 +\begin{verbatim} string get_type (session_id s, task ref self)\end{verbatim}
   1.458 +
   1.459 +
   1.460 +\noindent{\bf Arguments:}
   1.461 +
   1.462 + 
   1.463 +\vspace{0.3cm}
   1.464 +\begin{tabular}{|c|c|p{7cm}|}
   1.465 + \hline
   1.466 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.467 +{\tt task ref } & self & reference to the object \\ \hline 
   1.468 +
   1.469 +\end{tabular}
   1.470 +
   1.471 +\vspace{0.3cm}
   1.472 +
   1.473 + \noindent {\bf Return Type:} 
   1.474 +{\tt 
   1.475 +string
   1.476 +}
   1.477 +
   1.478 +
   1.479 +value of the field
   1.480 +\vspace{0.3cm}
   1.481 +\vspace{0.3cm}
   1.482 +\vspace{0.3cm}
   1.483 +\subsubsection{RPC name:~get\_result}
   1.484 +
   1.485 +{\bf Overview:} 
   1.486 +Get the result field of the given task.
   1.487 +
   1.488 + \noindent {\bf Signature:} 
   1.489 +\begin{verbatim} string get_result (session_id s, task ref self)\end{verbatim}
   1.490 +
   1.491 +
   1.492 +\noindent{\bf Arguments:}
   1.493 +
   1.494 + 
   1.495 +\vspace{0.3cm}
   1.496 +\begin{tabular}{|c|c|p{7cm}|}
   1.497 + \hline
   1.498 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.499 +{\tt task ref } & self & reference to the object \\ \hline 
   1.500 +
   1.501 +\end{tabular}
   1.502 +
   1.503 +\vspace{0.3cm}
   1.504 +
   1.505 + \noindent {\bf Return Type:} 
   1.506 +{\tt 
   1.507 +string
   1.508 +}
   1.509 +
   1.510 +
   1.511 +value of the field
   1.512 +\vspace{0.3cm}
   1.513 +\vspace{0.3cm}
   1.514 +\vspace{0.3cm}
   1.515 +\subsubsection{RPC name:~get\_error\_code}
   1.516 +
   1.517 +{\bf Overview:} 
   1.518 +Get the error\_code field of the given task.
   1.519 +
   1.520 + \noindent {\bf Signature:} 
   1.521 +\begin{verbatim} int get_error_code (session_id s, task ref self)\end{verbatim}
   1.522 +
   1.523 +
   1.524 +\noindent{\bf Arguments:}
   1.525 +
   1.526 + 
   1.527 +\vspace{0.3cm}
   1.528 +\begin{tabular}{|c|c|p{7cm}|}
   1.529 + \hline
   1.530 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.531 +{\tt task ref } & self & reference to the object \\ \hline 
   1.532 +
   1.533 +\end{tabular}
   1.534 +
   1.535 +\vspace{0.3cm}
   1.536 +
   1.537 + \noindent {\bf Return Type:} 
   1.538 +{\tt 
   1.539 +int
   1.540 +}
   1.541 +
   1.542 +
   1.543 +value of the field
   1.544 +\vspace{0.3cm}
   1.545 +\vspace{0.3cm}
   1.546 +\vspace{0.3cm}
   1.547 +\subsubsection{RPC name:~get\_error\_info}
   1.548 +
   1.549 +{\bf Overview:} 
   1.550 +Get the error\_info field of the given task.
   1.551 +
   1.552 + \noindent {\bf Signature:} 
   1.553 +\begin{verbatim} (string Set) get_error_info (session_id s, task ref self)\end{verbatim}
   1.554 +
   1.555 +
   1.556 +\noindent{\bf Arguments:}
   1.557 +
   1.558 + 
   1.559 +\vspace{0.3cm}
   1.560 +\begin{tabular}{|c|c|p{7cm}|}
   1.561 + \hline
   1.562 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.563 +{\tt task ref } & self & reference to the object \\ \hline 
   1.564 +
   1.565 +\end{tabular}
   1.566 +
   1.567 +\vspace{0.3cm}
   1.568 +
   1.569 + \noindent {\bf Return Type:} 
   1.570 +{\tt 
   1.571 +string Set
   1.572 +}
   1.573 +
   1.574 +
   1.575 +value of the field
   1.576 +\vspace{0.3cm}
   1.577 +\vspace{0.3cm}
   1.578 +\vspace{0.3cm}
   1.579  \subsubsection{RPC name:~create}
   1.580  
   1.581  {\bf Overview:} 
   1.582 -constructor for class task
   1.583 +Create a new task instance, and return its handle.
   1.584  
   1.585   \noindent {\bf Signature:} 
   1.586  \begin{verbatim} (task ref) create (session_id s, task record args)\end{verbatim}
   1.587 @@ -798,7 +1049,7 @@ reference to the newly created object
   1.588  \subsubsection{RPC name:~destroy}
   1.589  
   1.590  {\bf Overview:} 
   1.591 -destructor for class task
   1.592 +Destroy the specified task instance.
   1.593  
   1.594   \noindent {\bf Signature:} 
   1.595  \begin{verbatim} void destroy (session_id s, task ref self)\end{verbatim}
   1.596 @@ -811,7 +1062,7 @@ destructor for class task
   1.597  \begin{tabular}{|c|c|p{7cm}|}
   1.598   \hline
   1.599  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.600 -{\tt task ref } & self & object instance \\ \hline 
   1.601 +{\tt task ref } & self & reference to the object \\ \hline 
   1.602  
   1.603  \end{tabular}
   1.604  
   1.605 @@ -830,7 +1081,7 @@ void
   1.606  \subsubsection{RPC name:~get\_by\_uuid}
   1.607  
   1.608  {\bf Overview:} 
   1.609 -returns the task instance with a particular uuid
   1.610 +Get a reference to the task instance with the specified UUID.
   1.611  
   1.612   \noindent {\bf Signature:} 
   1.613  \begin{verbatim} (task ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
   1.614 @@ -862,7 +1113,7 @@ reference to the object
   1.615  \subsubsection{RPC name:~get\_record}
   1.616  
   1.617  {\bf Overview:} 
   1.618 -returns a record containing the state of an instance of class task
   1.619 +Get a record containing the current state of the given task.
   1.620  
   1.621   \noindent {\bf Signature:} 
   1.622  \begin{verbatim} (task record) get_record (session_id s, task ref self)\end{verbatim}
   1.623 @@ -894,7 +1145,7 @@ all fields from the object
   1.624  \subsubsection{RPC name:~get\_by\_name\_label}
   1.625  
   1.626  {\bf Overview:} 
   1.627 -returns the task instance with a particular name label
   1.628 +Get all the task instances with the given label.
   1.629  
   1.630   \noindent {\bf Signature:} 
   1.631  \begin{verbatim} ((task ref) Set) get_by_name_label (session_id s, string label)\end{verbatim}
   1.632 @@ -941,15 +1192,16 @@ Quals & Field & Type & Description \\
   1.633  $\mathit{RW}$ &  {\tt name/description} & string & a notes field containg human-readable description \\
   1.634  $\mathit{RW}$ &  {\tt user\_version} & int & a user version number for this machine \\
   1.635  $\mathit{RW}$ &  {\tt is\_a\_template} & bool & true if this is a template. Template VMs can never be started, they are used only for cloning other VMs \\
   1.636 +$\mathit{RW}$ &  {\tt auto\_power\_on} & bool & true if this VM should be started automatically after host boot \\
   1.637  $\mathit{RO}_\mathit{run}$ &  {\tt resident\_on} & host ref & the host the VM is currently resident on \\
   1.638 -$\mathit{RO}_\mathit{ins}$ &  {\tt memory/static\_max} & int & Statically-set (i.e. absolute) maximum \\
   1.639 -$\mathit{RW}$ &  {\tt memory/dynamic\_max} & int & Dynamic maximum \\
   1.640 -$\mathit{RO}_\mathit{run}$ &  {\tt memory/actual} & int & Guest's actual usage \\
   1.641 -$\mathit{RW}$ &  {\tt memory/dynamic\_min} & int & Dynamic minimum \\
   1.642 -$\mathit{RO}_\mathit{ins}$ &  {\tt memory/static\_min} & int & Statically-set (i.e. absolute) mininum \\
   1.643 +$\mathit{RO}_\mathit{ins}$ &  {\tt memory/static\_max} & int & Statically-set (i.e. absolute) maximum (bytes) \\
   1.644 +$\mathit{RW}$ &  {\tt memory/dynamic\_max} & int & Dynamic maximum (bytes) \\
   1.645 +$\mathit{RO}_\mathit{run}$ &  {\tt memory/actual} & int & Guest's actual usage (bytes) \\
   1.646 +$\mathit{RW}$ &  {\tt memory/dynamic\_min} & int & Dynamic minimum (bytes) \\
   1.647 +$\mathit{RO}_\mathit{ins}$ &  {\tt memory/static\_min} & int & Statically-set (i.e. absolute) mininum (bytes) \\
   1.648  $\mathit{RW}$ &  {\tt VCPUs/policy} & string & the name of the VCPU scheduling policy to be applied \\
   1.649  $\mathit{RW}$ &  {\tt VCPUs/params} & string & string-encoded parameters passed to selected VCPU policy \\
   1.650 -$\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/number} & int & Current number of VCPUs \\
   1.651 +$\mathit{RW}$ &  {\tt VCPUs/number} & int & Current number of VCPUs \\
   1.652  $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
   1.653  $\mathit{RO}_\mathit{ins}$ &  {\tt VCPUs/features/required} & (cpu\_feature) Set & CPU features the guest demands the host supports \\
   1.654  $\mathit{RO}_\mathit{ins}$ &  {\tt VCPUs/features/can\_use} & (cpu\_feature) Set & CPU features the guest can use if available \\
   1.655 @@ -1335,7 +1587,7 @@ A list of all the IDs of all the VMs
   1.656  \subsubsection{RPC name:~get\_uuid}
   1.657  
   1.658  {\bf Overview:} 
   1.659 -get accessor message derived from field uuid of object VM
   1.660 +Get the uuid field of the given VM.
   1.661  
   1.662   \noindent {\bf Signature:} 
   1.663  \begin{verbatim} string get_uuid (session_id s, VM ref self)\end{verbatim}
   1.664 @@ -1348,7 +1600,7 @@ get accessor message derived from field 
   1.665  \begin{tabular}{|c|c|p{7cm}|}
   1.666   \hline
   1.667  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.668 -{\tt VM ref } & self & object instance \\ \hline 
   1.669 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.670  
   1.671  \end{tabular}
   1.672  
   1.673 @@ -1367,7 +1619,7 @@ value of the field
   1.674  \subsubsection{RPC name:~get\_power\_state}
   1.675  
   1.676  {\bf Overview:} 
   1.677 -get accessor message derived from field power\_state of object VM
   1.678 +Get the power\_state field of the given VM.
   1.679  
   1.680   \noindent {\bf Signature:} 
   1.681  \begin{verbatim} (vm_power_state) get_power_state (session_id s, VM ref self)\end{verbatim}
   1.682 @@ -1380,7 +1632,7 @@ get accessor message derived from field 
   1.683  \begin{tabular}{|c|c|p{7cm}|}
   1.684   \hline
   1.685  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.686 -{\tt VM ref } & self & object instance \\ \hline 
   1.687 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.688  
   1.689  \end{tabular}
   1.690  
   1.691 @@ -1399,7 +1651,7 @@ value of the field
   1.692  \subsubsection{RPC name:~get\_name\_label}
   1.693  
   1.694  {\bf Overview:} 
   1.695 -get accessor message derived from field name/label of object VM
   1.696 +Get the name/label field of the given VM.
   1.697  
   1.698   \noindent {\bf Signature:} 
   1.699  \begin{verbatim} string get_name_label (session_id s, VM ref self)\end{verbatim}
   1.700 @@ -1412,7 +1664,7 @@ get accessor message derived from field 
   1.701  \begin{tabular}{|c|c|p{7cm}|}
   1.702   \hline
   1.703  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.704 -{\tt VM ref } & self & object instance \\ \hline 
   1.705 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.706  
   1.707  \end{tabular}
   1.708  
   1.709 @@ -1431,7 +1683,7 @@ value of the field
   1.710  \subsubsection{RPC name:~set\_name\_label}
   1.711  
   1.712  {\bf Overview:} 
   1.713 -set accessor message derived from field name/label of object VM
   1.714 +Set the name/label field of the given VM.
   1.715  
   1.716   \noindent {\bf Signature:} 
   1.717  \begin{verbatim} void set_name_label (session_id s, VM ref self, string value)\end{verbatim}
   1.718 @@ -1444,7 +1696,7 @@ set accessor message derived from field 
   1.719  \begin{tabular}{|c|c|p{7cm}|}
   1.720   \hline
   1.721  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.722 -{\tt VM ref } & self & object instance \\ \hline 
   1.723 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.724  
   1.725  {\tt string } & value & New value to set \\ \hline 
   1.726  
   1.727 @@ -1465,7 +1717,7 @@ void
   1.728  \subsubsection{RPC name:~get\_name\_description}
   1.729  
   1.730  {\bf Overview:} 
   1.731 -get accessor message derived from field name/description of object VM
   1.732 +Get the name/description field of the given VM.
   1.733  
   1.734   \noindent {\bf Signature:} 
   1.735  \begin{verbatim} string get_name_description (session_id s, VM ref self)\end{verbatim}
   1.736 @@ -1478,7 +1730,7 @@ get accessor message derived from field 
   1.737  \begin{tabular}{|c|c|p{7cm}|}
   1.738   \hline
   1.739  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.740 -{\tt VM ref } & self & object instance \\ \hline 
   1.741 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.742  
   1.743  \end{tabular}
   1.744  
   1.745 @@ -1497,7 +1749,7 @@ value of the field
   1.746  \subsubsection{RPC name:~set\_name\_description}
   1.747  
   1.748  {\bf Overview:} 
   1.749 -set accessor message derived from field name/description of object VM
   1.750 +Set the name/description field of the given VM.
   1.751  
   1.752   \noindent {\bf Signature:} 
   1.753  \begin{verbatim} void set_name_description (session_id s, VM ref self, string value)\end{verbatim}
   1.754 @@ -1510,7 +1762,7 @@ set accessor message derived from field 
   1.755  \begin{tabular}{|c|c|p{7cm}|}
   1.756   \hline
   1.757  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.758 -{\tt VM ref } & self & object instance \\ \hline 
   1.759 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.760  
   1.761  {\tt string } & value & New value to set \\ \hline 
   1.762  
   1.763 @@ -1531,7 +1783,7 @@ void
   1.764  \subsubsection{RPC name:~get\_user\_version}
   1.765  
   1.766  {\bf Overview:} 
   1.767 -get accessor message derived from field user\_version of object VM
   1.768 +Get the user\_version field of the given VM.
   1.769  
   1.770   \noindent {\bf Signature:} 
   1.771  \begin{verbatim} int get_user_version (session_id s, VM ref self)\end{verbatim}
   1.772 @@ -1544,7 +1796,7 @@ get accessor message derived from field 
   1.773  \begin{tabular}{|c|c|p{7cm}|}
   1.774   \hline
   1.775  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.776 -{\tt VM ref } & self & object instance \\ \hline 
   1.777 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.778  
   1.779  \end{tabular}
   1.780  
   1.781 @@ -1563,7 +1815,7 @@ value of the field
   1.782  \subsubsection{RPC name:~set\_user\_version}
   1.783  
   1.784  {\bf Overview:} 
   1.785 -set accessor message derived from field user\_version of object VM
   1.786 +Set the user\_version field of the given VM.
   1.787  
   1.788   \noindent {\bf Signature:} 
   1.789  \begin{verbatim} void set_user_version (session_id s, VM ref self, int value)\end{verbatim}
   1.790 @@ -1576,7 +1828,7 @@ set accessor message derived from field 
   1.791  \begin{tabular}{|c|c|p{7cm}|}
   1.792   \hline
   1.793  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.794 -{\tt VM ref } & self & object instance \\ \hline 
   1.795 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.796  
   1.797  {\tt int } & value & New value to set \\ \hline 
   1.798  
   1.799 @@ -1597,7 +1849,7 @@ void
   1.800  \subsubsection{RPC name:~get\_is\_a\_template}
   1.801  
   1.802  {\bf Overview:} 
   1.803 -get accessor message derived from field is\_a\_template of object VM
   1.804 +Get the is\_a\_template field of the given VM.
   1.805  
   1.806   \noindent {\bf Signature:} 
   1.807  \begin{verbatim} bool get_is_a_template (session_id s, VM ref self)\end{verbatim}
   1.808 @@ -1610,7 +1862,7 @@ get accessor message derived from field 
   1.809  \begin{tabular}{|c|c|p{7cm}|}
   1.810   \hline
   1.811  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.812 -{\tt VM ref } & self & object instance \\ \hline 
   1.813 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.814  
   1.815  \end{tabular}
   1.816  
   1.817 @@ -1629,7 +1881,7 @@ value of the field
   1.818  \subsubsection{RPC name:~set\_is\_a\_template}
   1.819  
   1.820  {\bf Overview:} 
   1.821 -set accessor message derived from field is\_a\_template of object VM
   1.822 +Set the is\_a\_template field of the given VM.
   1.823  
   1.824   \noindent {\bf Signature:} 
   1.825  \begin{verbatim} void set_is_a_template (session_id s, VM ref self, bool value)\end{verbatim}
   1.826 @@ -1642,7 +1894,73 @@ set accessor message derived from field 
   1.827  \begin{tabular}{|c|c|p{7cm}|}
   1.828   \hline
   1.829  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.830 -{\tt VM ref } & self & object instance \\ \hline 
   1.831 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.832 +
   1.833 +{\tt bool } & value & New value to set \\ \hline 
   1.834 +
   1.835 +\end{tabular}
   1.836 +
   1.837 +\vspace{0.3cm}
   1.838 +
   1.839 + \noindent {\bf Return Type:} 
   1.840 +{\tt 
   1.841 +void
   1.842 +}
   1.843 +
   1.844 +
   1.845 +
   1.846 +\vspace{0.3cm}
   1.847 +\vspace{0.3cm}
   1.848 +\vspace{0.3cm}
   1.849 +\subsubsection{RPC name:~get\_auto\_power\_on}
   1.850 +
   1.851 +{\bf Overview:} 
   1.852 +Get the auto\_power\_on field of the given VM.
   1.853 +
   1.854 + \noindent {\bf Signature:} 
   1.855 +\begin{verbatim} bool get_auto_power_on (session_id s, VM ref self)\end{verbatim}
   1.856 +
   1.857 +
   1.858 +\noindent{\bf Arguments:}
   1.859 +
   1.860 + 
   1.861 +\vspace{0.3cm}
   1.862 +\begin{tabular}{|c|c|p{7cm}|}
   1.863 + \hline
   1.864 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.865 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.866 +
   1.867 +\end{tabular}
   1.868 +
   1.869 +\vspace{0.3cm}
   1.870 +
   1.871 + \noindent {\bf Return Type:} 
   1.872 +{\tt 
   1.873 +bool
   1.874 +}
   1.875 +
   1.876 +
   1.877 +value of the field
   1.878 +\vspace{0.3cm}
   1.879 +\vspace{0.3cm}
   1.880 +\vspace{0.3cm}
   1.881 +\subsubsection{RPC name:~set\_auto\_power\_on}
   1.882 +
   1.883 +{\bf Overview:} 
   1.884 +Set the auto\_power\_on field of the given VM.
   1.885 +
   1.886 + \noindent {\bf Signature:} 
   1.887 +\begin{verbatim} void set_auto_power_on (session_id s, VM ref self, bool value)\end{verbatim}
   1.888 +
   1.889 +
   1.890 +\noindent{\bf Arguments:}
   1.891 +
   1.892 + 
   1.893 +\vspace{0.3cm}
   1.894 +\begin{tabular}{|c|c|p{7cm}|}
   1.895 + \hline
   1.896 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.897 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.898  
   1.899  {\tt bool } & value & New value to set \\ \hline 
   1.900  
   1.901 @@ -1663,7 +1981,7 @@ void
   1.902  \subsubsection{RPC name:~get\_resident\_on}
   1.903  
   1.904  {\bf Overview:} 
   1.905 -get accessor message derived from field resident\_on of object VM
   1.906 +Get the resident\_on field of the given VM.
   1.907  
   1.908   \noindent {\bf Signature:} 
   1.909  \begin{verbatim} (host ref) get_resident_on (session_id s, VM ref self)\end{verbatim}
   1.910 @@ -1676,7 +1994,7 @@ get accessor message derived from field 
   1.911  \begin{tabular}{|c|c|p{7cm}|}
   1.912   \hline
   1.913  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.914 -{\tt VM ref } & self & object instance \\ \hline 
   1.915 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.916  
   1.917  \end{tabular}
   1.918  
   1.919 @@ -1695,7 +2013,7 @@ value of the field
   1.920  \subsubsection{RPC name:~get\_memory\_static\_max}
   1.921  
   1.922  {\bf Overview:} 
   1.923 -get accessor message derived from field memory/static\_max of object VM
   1.924 +Get the memory/static\_max field of the given VM.
   1.925  
   1.926   \noindent {\bf Signature:} 
   1.927  \begin{verbatim} int get_memory_static_max (session_id s, VM ref self)\end{verbatim}
   1.928 @@ -1708,7 +2026,7 @@ get accessor message derived from field 
   1.929  \begin{tabular}{|c|c|p{7cm}|}
   1.930   \hline
   1.931  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.932 -{\tt VM ref } & self & object instance \\ \hline 
   1.933 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.934  
   1.935  \end{tabular}
   1.936  
   1.937 @@ -1727,7 +2045,7 @@ value of the field
   1.938  \subsubsection{RPC name:~get\_memory\_dynamic\_max}
   1.939  
   1.940  {\bf Overview:} 
   1.941 -get accessor message derived from field memory/dynamic\_max of object VM
   1.942 +Get the memory/dynamic\_max field of the given VM.
   1.943  
   1.944   \noindent {\bf Signature:} 
   1.945  \begin{verbatim} int get_memory_dynamic_max (session_id s, VM ref self)\end{verbatim}
   1.946 @@ -1740,7 +2058,7 @@ get accessor message derived from field 
   1.947  \begin{tabular}{|c|c|p{7cm}|}
   1.948   \hline
   1.949  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.950 -{\tt VM ref } & self & object instance \\ \hline 
   1.951 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.952  
   1.953  \end{tabular}
   1.954  
   1.955 @@ -1759,7 +2077,7 @@ value of the field
   1.956  \subsubsection{RPC name:~set\_memory\_dynamic\_max}
   1.957  
   1.958  {\bf Overview:} 
   1.959 -set accessor message derived from field memory/dynamic\_max of object VM
   1.960 +Set the memory/dynamic\_max field of the given VM.
   1.961  
   1.962   \noindent {\bf Signature:} 
   1.963  \begin{verbatim} void set_memory_dynamic_max (session_id s, VM ref self, int value)\end{verbatim}
   1.964 @@ -1772,7 +2090,7 @@ set accessor message derived from field 
   1.965  \begin{tabular}{|c|c|p{7cm}|}
   1.966   \hline
   1.967  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.968 -{\tt VM ref } & self & object instance \\ \hline 
   1.969 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.970  
   1.971  {\tt int } & value & New value to set \\ \hline 
   1.972  
   1.973 @@ -1793,7 +2111,7 @@ void
   1.974  \subsubsection{RPC name:~get\_memory\_actual}
   1.975  
   1.976  {\bf Overview:} 
   1.977 -get accessor message derived from field memory/actual of object VM
   1.978 +Get the memory/actual field of the given VM.
   1.979  
   1.980   \noindent {\bf Signature:} 
   1.981  \begin{verbatim} int get_memory_actual (session_id s, VM ref self)\end{verbatim}
   1.982 @@ -1806,7 +2124,7 @@ get accessor message derived from field 
   1.983  \begin{tabular}{|c|c|p{7cm}|}
   1.984   \hline
   1.985  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.986 -{\tt VM ref } & self & object instance \\ \hline 
   1.987 +{\tt VM ref } & self & reference to the object \\ \hline 
   1.988  
   1.989  \end{tabular}
   1.990  
   1.991 @@ -1825,7 +2143,7 @@ value of the field
   1.992  \subsubsection{RPC name:~get\_memory\_dynamic\_min}
   1.993  
   1.994  {\bf Overview:} 
   1.995 -get accessor message derived from field memory/dynamic\_min of object VM
   1.996 +Get the memory/dynamic\_min field of the given VM.
   1.997  
   1.998   \noindent {\bf Signature:} 
   1.999  \begin{verbatim} int get_memory_dynamic_min (session_id s, VM ref self)\end{verbatim}
  1.1000 @@ -1838,7 +2156,7 @@ get accessor message derived from field 
  1.1001  \begin{tabular}{|c|c|p{7cm}|}
  1.1002   \hline
  1.1003  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1004 -{\tt VM ref } & self & object instance \\ \hline 
  1.1005 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1006  
  1.1007  \end{tabular}
  1.1008  
  1.1009 @@ -1857,7 +2175,7 @@ value of the field
  1.1010  \subsubsection{RPC name:~set\_memory\_dynamic\_min}
  1.1011  
  1.1012  {\bf Overview:} 
  1.1013 -set accessor message derived from field memory/dynamic\_min of object VM
  1.1014 +Set the memory/dynamic\_min field of the given VM.
  1.1015  
  1.1016   \noindent {\bf Signature:} 
  1.1017  \begin{verbatim} void set_memory_dynamic_min (session_id s, VM ref self, int value)\end{verbatim}
  1.1018 @@ -1870,7 +2188,7 @@ set accessor message derived from field 
  1.1019  \begin{tabular}{|c|c|p{7cm}|}
  1.1020   \hline
  1.1021  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1022 -{\tt VM ref } & self & object instance \\ \hline 
  1.1023 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1024  
  1.1025  {\tt int } & value & New value to set \\ \hline 
  1.1026  
  1.1027 @@ -1891,7 +2209,7 @@ void
  1.1028  \subsubsection{RPC name:~get\_memory\_static\_min}
  1.1029  
  1.1030  {\bf Overview:} 
  1.1031 -get accessor message derived from field memory/static\_min of object VM
  1.1032 +Get the memory/static\_min field of the given VM.
  1.1033  
  1.1034   \noindent {\bf Signature:} 
  1.1035  \begin{verbatim} int get_memory_static_min (session_id s, VM ref self)\end{verbatim}
  1.1036 @@ -1904,7 +2222,7 @@ get accessor message derived from field 
  1.1037  \begin{tabular}{|c|c|p{7cm}|}
  1.1038   \hline
  1.1039  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1040 -{\tt VM ref } & self & object instance \\ \hline 
  1.1041 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1042  
  1.1043  \end{tabular}
  1.1044  
  1.1045 @@ -1923,7 +2241,7 @@ value of the field
  1.1046  \subsubsection{RPC name:~get\_VCPUs\_policy}
  1.1047  
  1.1048  {\bf Overview:} 
  1.1049 -get accessor message derived from field VCPUs/policy of object VM
  1.1050 +Get the VCPUs/policy field of the given VM.
  1.1051  
  1.1052   \noindent {\bf Signature:} 
  1.1053  \begin{verbatim} string get_VCPUs_policy (session_id s, VM ref self)\end{verbatim}
  1.1054 @@ -1936,7 +2254,7 @@ get accessor message derived from field 
  1.1055  \begin{tabular}{|c|c|p{7cm}|}
  1.1056   \hline
  1.1057  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1058 -{\tt VM ref } & self & object instance \\ \hline 
  1.1059 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1060  
  1.1061  \end{tabular}
  1.1062  
  1.1063 @@ -1955,7 +2273,7 @@ value of the field
  1.1064  \subsubsection{RPC name:~set\_VCPUs\_policy}
  1.1065  
  1.1066  {\bf Overview:} 
  1.1067 -set accessor message derived from field VCPUs/policy of object VM
  1.1068 +Set the VCPUs/policy field of the given VM.
  1.1069  
  1.1070   \noindent {\bf Signature:} 
  1.1071  \begin{verbatim} void set_VCPUs_policy (session_id s, VM ref self, string value)\end{verbatim}
  1.1072 @@ -1968,7 +2286,7 @@ set accessor message derived from field 
  1.1073  \begin{tabular}{|c|c|p{7cm}|}
  1.1074   \hline
  1.1075  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1076 -{\tt VM ref } & self & object instance \\ \hline 
  1.1077 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1078  
  1.1079  {\tt string } & value & New value to set \\ \hline 
  1.1080  
  1.1081 @@ -1989,7 +2307,7 @@ void
  1.1082  \subsubsection{RPC name:~get\_VCPUs\_params}
  1.1083  
  1.1084  {\bf Overview:} 
  1.1085 -get accessor message derived from field VCPUs/params of object VM
  1.1086 +Get the VCPUs/params field of the given VM.
  1.1087  
  1.1088   \noindent {\bf Signature:} 
  1.1089  \begin{verbatim} string get_VCPUs_params (session_id s, VM ref self)\end{verbatim}
  1.1090 @@ -2002,7 +2320,7 @@ get accessor message derived from field 
  1.1091  \begin{tabular}{|c|c|p{7cm}|}
  1.1092   \hline
  1.1093  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1094 -{\tt VM ref } & self & object instance \\ \hline 
  1.1095 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1096  
  1.1097  \end{tabular}
  1.1098  
  1.1099 @@ -2021,7 +2339,7 @@ value of the field
  1.1100  \subsubsection{RPC name:~set\_VCPUs\_params}
  1.1101  
  1.1102  {\bf Overview:} 
  1.1103 -set accessor message derived from field VCPUs/params of object VM
  1.1104 +Set the VCPUs/params field of the given VM.
  1.1105  
  1.1106   \noindent {\bf Signature:} 
  1.1107  \begin{verbatim} void set_VCPUs_params (session_id s, VM ref self, string value)\end{verbatim}
  1.1108 @@ -2034,7 +2352,7 @@ set accessor message derived from field 
  1.1109  \begin{tabular}{|c|c|p{7cm}|}
  1.1110   \hline
  1.1111  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1112 -{\tt VM ref } & self & object instance \\ \hline 
  1.1113 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1114  
  1.1115  {\tt string } & value & New value to set \\ \hline 
  1.1116  
  1.1117 @@ -2055,7 +2373,7 @@ void
  1.1118  \subsubsection{RPC name:~get\_VCPUs\_number}
  1.1119  
  1.1120  {\bf Overview:} 
  1.1121 -get accessor message derived from field VCPUs/number of object VM
  1.1122 +Get the VCPUs/number field of the given VM.
  1.1123  
  1.1124   \noindent {\bf Signature:} 
  1.1125  \begin{verbatim} int get_VCPUs_number (session_id s, VM ref self)\end{verbatim}
  1.1126 @@ -2068,7 +2386,7 @@ get accessor message derived from field 
  1.1127  \begin{tabular}{|c|c|p{7cm}|}
  1.1128   \hline
  1.1129  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1130 -{\tt VM ref } & self & object instance \\ \hline 
  1.1131 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1132  
  1.1133  \end{tabular}
  1.1134  
  1.1135 @@ -2084,10 +2402,44 @@ value of the field
  1.1136  \vspace{0.3cm}
  1.1137  \vspace{0.3cm}
  1.1138  \vspace{0.3cm}
  1.1139 +\subsubsection{RPC name:~set\_VCPUs\_number}
  1.1140 +
  1.1141 +{\bf Overview:} 
  1.1142 +Set the VCPUs/number field of the given VM.
  1.1143 +
  1.1144 + \noindent {\bf Signature:} 
  1.1145 +\begin{verbatim} void set_VCPUs_number (session_id s, VM ref self, int value)\end{verbatim}
  1.1146 +
  1.1147 +
  1.1148 +\noindent{\bf Arguments:}
  1.1149 +
  1.1150 + 
  1.1151 +\vspace{0.3cm}
  1.1152 +\begin{tabular}{|c|c|p{7cm}|}
  1.1153 + \hline
  1.1154 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1155 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1156 +
  1.1157 +{\tt int } & value & New value to set \\ \hline 
  1.1158 +
  1.1159 +\end{tabular}
  1.1160 +
  1.1161 +\vspace{0.3cm}
  1.1162 +
  1.1163 + \noindent {\bf Return Type:} 
  1.1164 +{\tt 
  1.1165 +void
  1.1166 +}
  1.1167 +
  1.1168 +
  1.1169 +
  1.1170 +\vspace{0.3cm}
  1.1171 +\vspace{0.3cm}
  1.1172 +\vspace{0.3cm}
  1.1173  \subsubsection{RPC name:~get\_VCPUs\_utilisation}
  1.1174  
  1.1175  {\bf Overview:} 
  1.1176 -get accessor message derived from field VCPUs/utilisation of object VM
  1.1177 +Get the VCPUs/utilisation field of the given VM.
  1.1178  
  1.1179   \noindent {\bf Signature:} 
  1.1180  \begin{verbatim} ((int -> float) Map) get_VCPUs_utilisation (session_id s, VM ref self)\end{verbatim}
  1.1181 @@ -2100,7 +2452,7 @@ get accessor message derived from field 
  1.1182  \begin{tabular}{|c|c|p{7cm}|}
  1.1183   \hline
  1.1184  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1185 -{\tt VM ref } & self & object instance \\ \hline 
  1.1186 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1187  
  1.1188  \end{tabular}
  1.1189  
  1.1190 @@ -2119,7 +2471,7 @@ value of the field
  1.1191  \subsubsection{RPC name:~get\_VCPUs\_features\_required}
  1.1192  
  1.1193  {\bf Overview:} 
  1.1194 -get accessor message derived from field VCPUs/features/required of object VM
  1.1195 +Get the VCPUs/features/required field of the given VM.
  1.1196  
  1.1197   \noindent {\bf Signature:} 
  1.1198  \begin{verbatim} ((cpu_feature) Set) get_VCPUs_features_required (session_id s, VM ref self)\end{verbatim}
  1.1199 @@ -2132,7 +2484,7 @@ get accessor message derived from field 
  1.1200  \begin{tabular}{|c|c|p{7cm}|}
  1.1201   \hline
  1.1202  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1203 -{\tt VM ref } & self & object instance \\ \hline 
  1.1204 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1205  
  1.1206  \end{tabular}
  1.1207  
  1.1208 @@ -2151,7 +2503,7 @@ value of the field
  1.1209  \subsubsection{RPC name:~get\_VCPUs\_features\_can\_use}
  1.1210  
  1.1211  {\bf Overview:} 
  1.1212 -get accessor message derived from field VCPUs/features/can\_use of object VM
  1.1213 +Get the VCPUs/features/can\_use field of the given VM.
  1.1214  
  1.1215   \noindent {\bf Signature:} 
  1.1216  \begin{verbatim} ((cpu_feature) Set) get_VCPUs_features_can_use (session_id s, VM ref self)\end{verbatim}
  1.1217 @@ -2164,7 +2516,7 @@ get accessor message derived from field 
  1.1218  \begin{tabular}{|c|c|p{7cm}|}
  1.1219   \hline
  1.1220  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1221 -{\tt VM ref } & self & object instance \\ \hline 
  1.1222 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1223  
  1.1224  \end{tabular}
  1.1225  
  1.1226 @@ -2183,7 +2535,7 @@ value of the field
  1.1227  \subsubsection{RPC name:~get\_VCPUs\_features\_force\_on}
  1.1228  
  1.1229  {\bf Overview:} 
  1.1230 -get accessor message derived from field VCPUs/features/force\_on of object VM
  1.1231 +Get the VCPUs/features/force\_on field of the given VM.
  1.1232  
  1.1233   \noindent {\bf Signature:} 
  1.1234  \begin{verbatim} ((cpu_feature) Set) get_VCPUs_features_force_on (session_id s, VM ref self)\end{verbatim}
  1.1235 @@ -2196,7 +2548,7 @@ get accessor message derived from field 
  1.1236  \begin{tabular}{|c|c|p{7cm}|}
  1.1237   \hline
  1.1238  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1239 -{\tt VM ref } & self & object instance \\ \hline 
  1.1240 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1241  
  1.1242  \end{tabular}
  1.1243  
  1.1244 @@ -2212,6 +2564,40 @@ value of the field
  1.1245  \vspace{0.3cm}
  1.1246  \vspace{0.3cm}
  1.1247  \vspace{0.3cm}
  1.1248 +\subsubsection{RPC name:~set\_VCPUs\_features\_force\_on}
  1.1249 +
  1.1250 +{\bf Overview:} 
  1.1251 +Set the VCPUs/features/force\_on field of the given VM.
  1.1252 +
  1.1253 + \noindent {\bf Signature:} 
  1.1254 +\begin{verbatim} void set_VCPUs_features_force_on (session_id s, VM ref self, (cpu_feature) Set value)\end{verbatim}
  1.1255 +
  1.1256 +
  1.1257 +\noindent{\bf Arguments:}
  1.1258 +
  1.1259 + 
  1.1260 +\vspace{0.3cm}
  1.1261 +\begin{tabular}{|c|c|p{7cm}|}
  1.1262 + \hline
  1.1263 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1264 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1265 +
  1.1266 +{\tt (cpu\_feature) Set } & value & New value to set \\ \hline 
  1.1267 +
  1.1268 +\end{tabular}
  1.1269 +
  1.1270 +\vspace{0.3cm}
  1.1271 +
  1.1272 + \noindent {\bf Return Type:} 
  1.1273 +{\tt 
  1.1274 +void
  1.1275 +}
  1.1276 +
  1.1277 +
  1.1278 +
  1.1279 +\vspace{0.3cm}
  1.1280 +\vspace{0.3cm}
  1.1281 +\vspace{0.3cm}
  1.1282  \subsubsection{RPC name:~add\_VCPUs\_features\_force\_on}
  1.1283  
  1.1284  {\bf Overview:} 
  1.1285 @@ -2228,7 +2614,7 @@ set add message derived from field VCPUs
  1.1286  \begin{tabular}{|c|c|p{7cm}|}
  1.1287   \hline
  1.1288  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1289 -{\tt VM ref } & self & object instance \\ \hline 
  1.1290 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1291  
  1.1292  {\tt cpu\_feature } & value & New value to add \\ \hline 
  1.1293  
  1.1294 @@ -2262,7 +2648,7 @@ set remove message derived from field VC
  1.1295  \begin{tabular}{|c|c|p{7cm}|}
  1.1296   \hline
  1.1297  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1298 -{\tt VM ref } & self & object instance \\ \hline 
  1.1299 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1300  
  1.1301  {\tt cpu\_feature } & value & Value to remove \\ \hline 
  1.1302  
  1.1303 @@ -2283,7 +2669,7 @@ void
  1.1304  \subsubsection{RPC name:~get\_VCPUs\_features\_force\_off}
  1.1305  
  1.1306  {\bf Overview:} 
  1.1307 -get accessor message derived from field VCPUs/features/force\_off of object VM
  1.1308 +Get the VCPUs/features/force\_off field of the given VM.
  1.1309  
  1.1310   \noindent {\bf Signature:} 
  1.1311  \begin{verbatim} ((cpu_feature) Set) get_VCPUs_features_force_off (session_id s, VM ref self)\end{verbatim}
  1.1312 @@ -2296,7 +2682,7 @@ get accessor message derived from field 
  1.1313  \begin{tabular}{|c|c|p{7cm}|}
  1.1314   \hline
  1.1315  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1316 -{\tt VM ref } & self & object instance \\ \hline 
  1.1317 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1318  
  1.1319  \end{tabular}
  1.1320  
  1.1321 @@ -2312,6 +2698,40 @@ value of the field
  1.1322  \vspace{0.3cm}
  1.1323  \vspace{0.3cm}
  1.1324  \vspace{0.3cm}
  1.1325 +\subsubsection{RPC name:~set\_VCPUs\_features\_force\_off}
  1.1326 +
  1.1327 +{\bf Overview:} 
  1.1328 +Set the VCPUs/features/force\_off field of the given VM.
  1.1329 +
  1.1330 + \noindent {\bf Signature:} 
  1.1331 +\begin{verbatim} void set_VCPUs_features_force_off (session_id s, VM ref self, (cpu_feature) Set value)\end{verbatim}
  1.1332 +
  1.1333 +
  1.1334 +\noindent{\bf Arguments:}
  1.1335 +
  1.1336 + 
  1.1337 +\vspace{0.3cm}
  1.1338 +\begin{tabular}{|c|c|p{7cm}|}
  1.1339 + \hline
  1.1340 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1341 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1342 +
  1.1343 +{\tt (cpu\_feature) Set } & value & New value to set \\ \hline 
  1.1344 +
  1.1345 +\end{tabular}
  1.1346 +
  1.1347 +\vspace{0.3cm}
  1.1348 +
  1.1349 + \noindent {\bf Return Type:} 
  1.1350 +{\tt 
  1.1351 +void
  1.1352 +}
  1.1353 +
  1.1354 +
  1.1355 +
  1.1356 +\vspace{0.3cm}
  1.1357 +\vspace{0.3cm}
  1.1358 +\vspace{0.3cm}
  1.1359  \subsubsection{RPC name:~add\_VCPUs\_features\_force\_off}
  1.1360  
  1.1361  {\bf Overview:} 
  1.1362 @@ -2328,7 +2748,7 @@ set add message derived from field VCPUs
  1.1363  \begin{tabular}{|c|c|p{7cm}|}
  1.1364   \hline
  1.1365  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1366 -{\tt VM ref } & self & object instance \\ \hline 
  1.1367 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1368  
  1.1369  {\tt cpu\_feature } & value & New value to add \\ \hline 
  1.1370  
  1.1371 @@ -2362,7 +2782,7 @@ set remove message derived from field VC
  1.1372  \begin{tabular}{|c|c|p{7cm}|}
  1.1373   \hline
  1.1374  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1375 -{\tt VM ref } & self & object instance \\ \hline 
  1.1376 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1377  
  1.1378  {\tt cpu\_feature } & value & Value to remove \\ \hline 
  1.1379  
  1.1380 @@ -2383,7 +2803,7 @@ void
  1.1381  \subsubsection{RPC name:~get\_actions\_after\_shutdown}
  1.1382  
  1.1383  {\bf Overview:} 
  1.1384 -get accessor message derived from field actions/after\_shutdown of object VM
  1.1385 +Get the actions/after\_shutdown field of the given VM.
  1.1386  
  1.1387   \noindent {\bf Signature:} 
  1.1388  \begin{verbatim} (on_normal_exit) get_actions_after_shutdown (session_id s, VM ref self)\end{verbatim}
  1.1389 @@ -2396,7 +2816,7 @@ get accessor message derived from field 
  1.1390  \begin{tabular}{|c|c|p{7cm}|}
  1.1391   \hline
  1.1392  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1393 -{\tt VM ref } & self & object instance \\ \hline 
  1.1394 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1395  
  1.1396  \end{tabular}
  1.1397  
  1.1398 @@ -2415,7 +2835,7 @@ value of the field
  1.1399  \subsubsection{RPC name:~set\_actions\_after\_shutdown}
  1.1400  
  1.1401  {\bf Overview:} 
  1.1402 -set accessor message derived from field actions/after\_shutdown of object VM
  1.1403 +Set the actions/after\_shutdown field of the given VM.
  1.1404  
  1.1405   \noindent {\bf Signature:} 
  1.1406  \begin{verbatim} void set_actions_after_shutdown (session_id s, VM ref self, on_normal_exit value)\end{verbatim}
  1.1407 @@ -2428,7 +2848,7 @@ set accessor message derived from field 
  1.1408  \begin{tabular}{|c|c|p{7cm}|}
  1.1409   \hline
  1.1410  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1411 -{\tt VM ref } & self & object instance \\ \hline 
  1.1412 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1413  
  1.1414  {\tt on\_normal\_exit } & value & New value to set \\ \hline 
  1.1415  
  1.1416 @@ -2449,7 +2869,7 @@ void
  1.1417  \subsubsection{RPC name:~get\_actions\_after\_reboot}
  1.1418  
  1.1419  {\bf Overview:} 
  1.1420 -get accessor message derived from field actions/after\_reboot of object VM
  1.1421 +Get the actions/after\_reboot field of the given VM.
  1.1422  
  1.1423   \noindent {\bf Signature:} 
  1.1424  \begin{verbatim} (on_normal_exit) get_actions_after_reboot (session_id s, VM ref self)\end{verbatim}
  1.1425 @@ -2462,7 +2882,7 @@ get accessor message derived from field 
  1.1426  \begin{tabular}{|c|c|p{7cm}|}
  1.1427   \hline
  1.1428  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1429 -{\tt VM ref } & self & object instance \\ \hline 
  1.1430 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1431  
  1.1432  \end{tabular}
  1.1433  
  1.1434 @@ -2481,7 +2901,7 @@ value of the field
  1.1435  \subsubsection{RPC name:~set\_actions\_after\_reboot}
  1.1436  
  1.1437  {\bf Overview:} 
  1.1438 -set accessor message derived from field actions/after\_reboot of object VM
  1.1439 +Set the actions/after\_reboot field of the given VM.
  1.1440  
  1.1441   \noindent {\bf Signature:} 
  1.1442  \begin{verbatim} void set_actions_after_reboot (session_id s, VM ref self, on_normal_exit value)\end{verbatim}
  1.1443 @@ -2494,7 +2914,7 @@ set accessor message derived from field 
  1.1444  \begin{tabular}{|c|c|p{7cm}|}
  1.1445   \hline
  1.1446  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1447 -{\tt VM ref } & self & object instance \\ \hline 
  1.1448 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1449  
  1.1450  {\tt on\_normal\_exit } & value & New value to set \\ \hline 
  1.1451  
  1.1452 @@ -2515,7 +2935,7 @@ void
  1.1453  \subsubsection{RPC name:~get\_actions\_after\_suspend}
  1.1454  
  1.1455  {\bf Overview:} 
  1.1456 -get accessor message derived from field actions/after\_suspend of object VM
  1.1457 +Get the actions/after\_suspend field of the given VM.
  1.1458  
  1.1459   \noindent {\bf Signature:} 
  1.1460  \begin{verbatim} (on_normal_exit) get_actions_after_suspend (session_id s, VM ref self)\end{verbatim}
  1.1461 @@ -2528,7 +2948,7 @@ get accessor message derived from field 
  1.1462  \begin{tabular}{|c|c|p{7cm}|}
  1.1463   \hline
  1.1464  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1465 -{\tt VM ref } & self & object instance \\ \hline 
  1.1466 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1467  
  1.1468  \end{tabular}
  1.1469  
  1.1470 @@ -2547,7 +2967,7 @@ value of the field
  1.1471  \subsubsection{RPC name:~set\_actions\_after\_suspend}
  1.1472  
  1.1473  {\bf Overview:} 
  1.1474 -set accessor message derived from field actions/after\_suspend of object VM
  1.1475 +Set the actions/after\_suspend field of the given VM.
  1.1476  
  1.1477   \noindent {\bf Signature:} 
  1.1478  \begin{verbatim} void set_actions_after_suspend (session_id s, VM ref self, on_normal_exit value)\end{verbatim}
  1.1479 @@ -2560,7 +2980,7 @@ set accessor message derived from field 
  1.1480  \begin{tabular}{|c|c|p{7cm}|}
  1.1481   \hline
  1.1482  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1483 -{\tt VM ref } & self & object instance \\ \hline 
  1.1484 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1485  
  1.1486  {\tt on\_normal\_exit } & value & New value to set \\ \hline 
  1.1487  
  1.1488 @@ -2581,7 +3001,7 @@ void
  1.1489  \subsubsection{RPC name:~get\_actions\_after\_crash}
  1.1490  
  1.1491  {\bf Overview:} 
  1.1492 -get accessor message derived from field actions/after\_crash of object VM
  1.1493 +Get the actions/after\_crash field of the given VM.
  1.1494  
  1.1495   \noindent {\bf Signature:} 
  1.1496  \begin{verbatim} (on_crash_behaviour) get_actions_after_crash (session_id s, VM ref self)\end{verbatim}
  1.1497 @@ -2594,7 +3014,7 @@ get accessor message derived from field 
  1.1498  \begin{tabular}{|c|c|p{7cm}|}
  1.1499   \hline
  1.1500  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1501 -{\tt VM ref } & self & object instance \\ \hline 
  1.1502 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1503  
  1.1504  \end{tabular}
  1.1505  
  1.1506 @@ -2613,7 +3033,7 @@ value of the field
  1.1507  \subsubsection{RPC name:~set\_actions\_after\_crash}
  1.1508  
  1.1509  {\bf Overview:} 
  1.1510 -set accessor message derived from field actions/after\_crash of object VM
  1.1511 +Set the actions/after\_crash field of the given VM.
  1.1512  
  1.1513   \noindent {\bf Signature:} 
  1.1514  \begin{verbatim} void set_actions_after_crash (session_id s, VM ref self, on_crash_behaviour value)\end{verbatim}
  1.1515 @@ -2626,7 +3046,7 @@ set accessor message derived from field 
  1.1516  \begin{tabular}{|c|c|p{7cm}|}
  1.1517   \hline
  1.1518  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1519 -{\tt VM ref } & self & object instance \\ \hline 
  1.1520 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1521  
  1.1522  {\tt on\_crash\_behaviour } & value & New value to set \\ \hline 
  1.1523  
  1.1524 @@ -2660,7 +3080,7 @@ Get the consoles field of the given VM.
  1.1525  \begin{tabular}{|c|c|p{7cm}|}
  1.1526   \hline
  1.1527  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1528 -{\tt VM ref } & self & object instance \\ \hline 
  1.1529 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1530  
  1.1531  \end{tabular}
  1.1532  
  1.1533 @@ -2679,7 +3099,7 @@ value of the field
  1.1534  \subsubsection{RPC name:~get\_VIFs}
  1.1535  
  1.1536  {\bf Overview:} 
  1.1537 -get accessor message derived from field VIFs of object VM
  1.1538 +Get the VIFs field of the given VM.
  1.1539  
  1.1540   \noindent {\bf Signature:} 
  1.1541  \begin{verbatim} ((VIF ref) Set) get_VIFs (session_id s, VM ref self)\end{verbatim}
  1.1542 @@ -2692,7 +3112,7 @@ get accessor message derived from field 
  1.1543  \begin{tabular}{|c|c|p{7cm}|}
  1.1544   \hline
  1.1545  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1546 -{\tt VM ref } & self & object instance \\ \hline 
  1.1547 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1548  
  1.1549  \end{tabular}
  1.1550  
  1.1551 @@ -2711,7 +3131,7 @@ value of the field
  1.1552  \subsubsection{RPC name:~get\_VBDs}
  1.1553  
  1.1554  {\bf Overview:} 
  1.1555 -get accessor message derived from field VBDs of object VM
  1.1556 +Get the VBDs field of the given VM.
  1.1557  
  1.1558   \noindent {\bf Signature:} 
  1.1559  \begin{verbatim} ((VBD ref) Set) get_VBDs (session_id s, VM ref self)\end{verbatim}
  1.1560 @@ -2724,7 +3144,7 @@ get accessor message derived from field 
  1.1561  \begin{tabular}{|c|c|p{7cm}|}
  1.1562   \hline
  1.1563  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1564 -{\tt VM ref } & self & object instance \\ \hline 
  1.1565 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1566  
  1.1567  \end{tabular}
  1.1568  
  1.1569 @@ -2743,7 +3163,7 @@ value of the field
  1.1570  \subsubsection{RPC name:~get\_VTPMs}
  1.1571  
  1.1572  {\bf Overview:} 
  1.1573 -get accessor message derived from field VTPMs of object VM
  1.1574 +Get the VTPMs field of the given VM.
  1.1575  
  1.1576   \noindent {\bf Signature:} 
  1.1577  \begin{verbatim} ((VTPM ref) Set) get_VTPMs (session_id s, VM ref self)\end{verbatim}
  1.1578 @@ -2756,7 +3176,7 @@ get accessor message derived from field 
  1.1579  \begin{tabular}{|c|c|p{7cm}|}
  1.1580   \hline
  1.1581  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1582 -{\tt VM ref } & self & object instance \\ \hline 
  1.1583 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1584  
  1.1585  \end{tabular}
  1.1586  
  1.1587 @@ -2775,7 +3195,7 @@ value of the field
  1.1588  \subsubsection{RPC name:~get\_bios\_boot}
  1.1589  
  1.1590  {\bf Overview:} 
  1.1591 -get accessor message derived from field bios/boot of object VM
  1.1592 +Get the bios/boot field of the given VM.
  1.1593  
  1.1594   \noindent {\bf Signature:} 
  1.1595  \begin{verbatim} string get_bios_boot (session_id s, VM ref self)\end{verbatim}
  1.1596 @@ -2788,7 +3208,7 @@ get accessor message derived from field 
  1.1597  \begin{tabular}{|c|c|p{7cm}|}
  1.1598   \hline
  1.1599  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1600 -{\tt VM ref } & self & object instance \\ \hline 
  1.1601 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1602  
  1.1603  \end{tabular}
  1.1604  
  1.1605 @@ -2807,7 +3227,7 @@ value of the field
  1.1606  \subsubsection{RPC name:~set\_bios\_boot}
  1.1607  
  1.1608  {\bf Overview:} 
  1.1609 -set accessor message derived from field bios/boot of object VM
  1.1610 +Set the bios/boot field of the given VM.
  1.1611  
  1.1612   \noindent {\bf Signature:} 
  1.1613  \begin{verbatim} void set_bios_boot (session_id s, VM ref self, string value)\end{verbatim}
  1.1614 @@ -2820,7 +3240,7 @@ set accessor message derived from field 
  1.1615  \begin{tabular}{|c|c|p{7cm}|}
  1.1616   \hline
  1.1617  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1618 -{\tt VM ref } & self & object instance \\ \hline 
  1.1619 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1620  
  1.1621  {\tt string } & value & New value to set \\ \hline 
  1.1622  
  1.1623 @@ -2841,7 +3261,7 @@ void
  1.1624  \subsubsection{RPC name:~get\_platform\_std\_VGA}
  1.1625  
  1.1626  {\bf Overview:} 
  1.1627 -get accessor message derived from field platform/std\_VGA of object VM
  1.1628 +Get the platform/std\_VGA field of the given VM.
  1.1629  
  1.1630   \noindent {\bf Signature:} 
  1.1631  \begin{verbatim} bool get_platform_std_VGA (session_id s, VM ref self)\end{verbatim}
  1.1632 @@ -2854,7 +3274,7 @@ get accessor message derived from field 
  1.1633  \begin{tabular}{|c|c|p{7cm}|}
  1.1634   \hline
  1.1635  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1636 -{\tt VM ref } & self & object instance \\ \hline 
  1.1637 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1638  
  1.1639  \end{tabular}
  1.1640  
  1.1641 @@ -2873,7 +3293,7 @@ value of the field
  1.1642  \subsubsection{RPC name:~set\_platform\_std\_VGA}
  1.1643  
  1.1644  {\bf Overview:} 
  1.1645 -set accessor message derived from field platform/std\_VGA of object VM
  1.1646 +Set the platform/std\_VGA field of the given VM.
  1.1647  
  1.1648   \noindent {\bf Signature:} 
  1.1649  \begin{verbatim} void set_platform_std_VGA (session_id s, VM ref self, bool value)\end{verbatim}
  1.1650 @@ -2886,7 +3306,7 @@ set accessor message derived from field 
  1.1651  \begin{tabular}{|c|c|p{7cm}|}
  1.1652   \hline
  1.1653  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1654 -{\tt VM ref } & self & object instance \\ \hline 
  1.1655 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1656  
  1.1657  {\tt bool } & value & New value to set \\ \hline 
  1.1658  
  1.1659 @@ -2907,7 +3327,7 @@ void
  1.1660  \subsubsection{RPC name:~get\_platform\_serial}
  1.1661  
  1.1662  {\bf Overview:} 
  1.1663 -get accessor message derived from field platform/serial of object VM
  1.1664 +Get the platform/serial field of the given VM.
  1.1665  
  1.1666   \noindent {\bf Signature:} 
  1.1667  \begin{verbatim} string get_platform_serial (session_id s, VM ref self)\end{verbatim}
  1.1668 @@ -2920,7 +3340,7 @@ get accessor message derived from field 
  1.1669  \begin{tabular}{|c|c|p{7cm}|}
  1.1670   \hline
  1.1671  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1672 -{\tt VM ref } & self & object instance \\ \hline 
  1.1673 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1674  
  1.1675  \end{tabular}
  1.1676  
  1.1677 @@ -2939,7 +3359,7 @@ value of the field
  1.1678  \subsubsection{RPC name:~set\_platform\_serial}
  1.1679  
  1.1680  {\bf Overview:} 
  1.1681 -set accessor message derived from field platform/serial of object VM
  1.1682 +Set the platform/serial field of the given VM.
  1.1683  
  1.1684   \noindent {\bf Signature:} 
  1.1685  \begin{verbatim} void set_platform_serial (session_id s, VM ref self, string value)\end{verbatim}
  1.1686 @@ -2952,7 +3372,7 @@ set accessor message derived from field 
  1.1687  \begin{tabular}{|c|c|p{7cm}|}
  1.1688   \hline
  1.1689  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1690 -{\tt VM ref } & self & object instance \\ \hline 
  1.1691 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1692  
  1.1693  {\tt string } & value & New value to set \\ \hline 
  1.1694  
  1.1695 @@ -2973,7 +3393,7 @@ void
  1.1696  \subsubsection{RPC name:~get\_platform\_localtime}
  1.1697  
  1.1698  {\bf Overview:} 
  1.1699 -get accessor message derived from field platform/localtime of object VM
  1.1700 +Get the platform/localtime field of the given VM.
  1.1701  
  1.1702   \noindent {\bf Signature:} 
  1.1703  \begin{verbatim} bool get_platform_localtime (session_id s, VM ref self)\end{verbatim}
  1.1704 @@ -2986,7 +3406,7 @@ get accessor message derived from field 
  1.1705  \begin{tabular}{|c|c|p{7cm}|}
  1.1706   \hline
  1.1707  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1708 -{\tt VM ref } & self & object instance \\ \hline 
  1.1709 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1710  
  1.1711  \end{tabular}
  1.1712  
  1.1713 @@ -3005,7 +3425,7 @@ value of the field
  1.1714  \subsubsection{RPC name:~set\_platform\_localtime}
  1.1715  
  1.1716  {\bf Overview:} 
  1.1717 -set accessor message derived from field platform/localtime of object VM
  1.1718 +Set the platform/localtime field of the given VM.
  1.1719  
  1.1720   \noindent {\bf Signature:} 
  1.1721  \begin{verbatim} void set_platform_localtime (session_id s, VM ref self, bool value)\end{verbatim}
  1.1722 @@ -3018,7 +3438,7 @@ set accessor message derived from field 
  1.1723  \begin{tabular}{|c|c|p{7cm}|}
  1.1724   \hline
  1.1725  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1726 -{\tt VM ref } & self & object instance \\ \hline 
  1.1727 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1728  
  1.1729  {\tt bool } & value & New value to set \\ \hline 
  1.1730  
  1.1731 @@ -3039,7 +3459,7 @@ void
  1.1732  \subsubsection{RPC name:~get\_platform\_clock\_offset}
  1.1733  
  1.1734  {\bf Overview:} 
  1.1735 -get accessor message derived from field platform/clock\_offset of object VM
  1.1736 +Get the platform/clock\_offset field of the given VM.
  1.1737  
  1.1738   \noindent {\bf Signature:} 
  1.1739  \begin{verbatim} bool get_platform_clock_offset (session_id s, VM ref self)\end{verbatim}
  1.1740 @@ -3052,7 +3472,7 @@ get accessor message derived from field 
  1.1741  \begin{tabular}{|c|c|p{7cm}|}
  1.1742   \hline
  1.1743  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1744 -{\tt VM ref } & self & object instance \\ \hline 
  1.1745 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1746  
  1.1747  \end{tabular}
  1.1748  
  1.1749 @@ -3071,7 +3491,7 @@ value of the field
  1.1750  \subsubsection{RPC name:~set\_platform\_clock\_offset}
  1.1751  
  1.1752  {\bf Overview:} 
  1.1753 -set accessor message derived from field platform/clock\_offset of object VM
  1.1754 +Set the platform/clock\_offset field of the given VM.
  1.1755  
  1.1756   \noindent {\bf Signature:} 
  1.1757  \begin{verbatim} void set_platform_clock_offset (session_id s, VM ref self, bool value)\end{verbatim}
  1.1758 @@ -3084,7 +3504,7 @@ set accessor message derived from field 
  1.1759  \begin{tabular}{|c|c|p{7cm}|}
  1.1760   \hline
  1.1761  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1762 -{\tt VM ref } & self & object instance \\ \hline 
  1.1763 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1764  
  1.1765  {\tt bool } & value & New value to set \\ \hline 
  1.1766  
  1.1767 @@ -3105,7 +3525,7 @@ void
  1.1768  \subsubsection{RPC name:~get\_platform\_enable\_audio}
  1.1769  
  1.1770  {\bf Overview:} 
  1.1771 -get accessor message derived from field platform/enable\_audio of object VM
  1.1772 +Get the platform/enable\_audio field of the given VM.
  1.1773  
  1.1774   \noindent {\bf Signature:} 
  1.1775  \begin{verbatim} bool get_platform_enable_audio (session_id s, VM ref self)\end{verbatim}
  1.1776 @@ -3118,7 +3538,7 @@ get accessor message derived from field 
  1.1777  \begin{tabular}{|c|c|p{7cm}|}
  1.1778   \hline
  1.1779  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1780 -{\tt VM ref } & self & object instance \\ \hline 
  1.1781 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1782  
  1.1783  \end{tabular}
  1.1784  
  1.1785 @@ -3137,7 +3557,7 @@ value of the field
  1.1786  \subsubsection{RPC name:~set\_platform\_enable\_audio}
  1.1787  
  1.1788  {\bf Overview:} 
  1.1789 -set accessor message derived from field platform/enable\_audio of object VM
  1.1790 +Set the platform/enable\_audio field of the given VM.
  1.1791  
  1.1792   \noindent {\bf Signature:} 
  1.1793  \begin{verbatim} void set_platform_enable_audio (session_id s, VM ref self, bool value)\end{verbatim}
  1.1794 @@ -3150,7 +3570,7 @@ set accessor message derived from field 
  1.1795  \begin{tabular}{|c|c|p{7cm}|}
  1.1796   \hline
  1.1797  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1798 -{\tt VM ref } & self & object instance \\ \hline 
  1.1799 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1800  
  1.1801  {\tt bool } & value & New value to set \\ \hline 
  1.1802  
  1.1803 @@ -3171,7 +3591,7 @@ void
  1.1804  \subsubsection{RPC name:~get\_builder}
  1.1805  
  1.1806  {\bf Overview:} 
  1.1807 -get accessor message derived from field builder of object VM
  1.1808 +Get the builder field of the given VM.
  1.1809  
  1.1810   \noindent {\bf Signature:} 
  1.1811  \begin{verbatim} string get_builder (session_id s, VM ref self)\end{verbatim}
  1.1812 @@ -3184,7 +3604,7 @@ get accessor message derived from field 
  1.1813  \begin{tabular}{|c|c|p{7cm}|}
  1.1814   \hline
  1.1815  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1816 -{\tt VM ref } & self & object instance \\ \hline 
  1.1817 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1818  
  1.1819  \end{tabular}
  1.1820  
  1.1821 @@ -3203,7 +3623,7 @@ value of the field
  1.1822  \subsubsection{RPC name:~set\_builder}
  1.1823  
  1.1824  {\bf Overview:} 
  1.1825 -set accessor message derived from field builder of object VM
  1.1826 +Set the builder field of the given VM.
  1.1827  
  1.1828   \noindent {\bf Signature:} 
  1.1829  \begin{verbatim} void set_builder (session_id s, VM ref self, string value)\end{verbatim}
  1.1830 @@ -3216,7 +3636,7 @@ set accessor message derived from field 
  1.1831  \begin{tabular}{|c|c|p{7cm}|}
  1.1832   \hline
  1.1833  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1834 -{\tt VM ref } & self & object instance \\ \hline 
  1.1835 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1836  
  1.1837  {\tt string } & value & New value to set \\ \hline 
  1.1838  
  1.1839 @@ -3237,7 +3657,7 @@ void
  1.1840  \subsubsection{RPC name:~get\_boot\_method}
  1.1841  
  1.1842  {\bf Overview:} 
  1.1843 -get accessor message derived from field boot\_method of object VM
  1.1844 +Get the boot\_method field of the given VM.
  1.1845  
  1.1846   \noindent {\bf Signature:} 
  1.1847  \begin{verbatim} (boot_type) get_boot_method (session_id s, VM ref self)\end{verbatim}
  1.1848 @@ -3250,7 +3670,7 @@ get accessor message derived from field 
  1.1849  \begin{tabular}{|c|c|p{7cm}|}
  1.1850   \hline
  1.1851  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1852 -{\tt VM ref } & self & object instance \\ \hline 
  1.1853 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1854  
  1.1855  \end{tabular}
  1.1856  
  1.1857 @@ -3269,7 +3689,7 @@ value of the field
  1.1858  \subsubsection{RPC name:~set\_boot\_method}
  1.1859  
  1.1860  {\bf Overview:} 
  1.1861 -set accessor message derived from field boot\_method of object VM
  1.1862 +Set the boot\_method field of the given VM.
  1.1863  
  1.1864   \noindent {\bf Signature:} 
  1.1865  \begin{verbatim} void set_boot_method (session_id s, VM ref self, boot_type value)\end{verbatim}
  1.1866 @@ -3282,7 +3702,7 @@ set accessor message derived from field 
  1.1867  \begin{tabular}{|c|c|p{7cm}|}
  1.1868   \hline
  1.1869  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1870 -{\tt VM ref } & self & object instance \\ \hline 
  1.1871 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1872  
  1.1873  {\tt boot\_type } & value & New value to set \\ \hline 
  1.1874  
  1.1875 @@ -3303,7 +3723,7 @@ void
  1.1876  \subsubsection{RPC name:~get\_kernel\_kernel}
  1.1877  
  1.1878  {\bf Overview:} 
  1.1879 -get accessor message derived from field kernel/kernel of object VM
  1.1880 +Get the kernel/kernel field of the given VM.
  1.1881  
  1.1882   \noindent {\bf Signature:} 
  1.1883  \begin{verbatim} string get_kernel_kernel (session_id s, VM ref self)\end{verbatim}
  1.1884 @@ -3316,7 +3736,7 @@ get accessor message derived from field 
  1.1885  \begin{tabular}{|c|c|p{7cm}|}
  1.1886   \hline
  1.1887  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1888 -{\tt VM ref } & self & object instance \\ \hline 
  1.1889 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1890  
  1.1891  \end{tabular}
  1.1892  
  1.1893 @@ -3335,7 +3755,7 @@ value of the field
  1.1894  \subsubsection{RPC name:~set\_kernel\_kernel}
  1.1895  
  1.1896  {\bf Overview:} 
  1.1897 -set accessor message derived from field kernel/kernel of object VM
  1.1898 +Set the kernel/kernel field of the given VM.
  1.1899  
  1.1900   \noindent {\bf Signature:} 
  1.1901  \begin{verbatim} void set_kernel_kernel (session_id s, VM ref self, string value)\end{verbatim}
  1.1902 @@ -3348,7 +3768,7 @@ set accessor message derived from field 
  1.1903  \begin{tabular}{|c|c|p{7cm}|}
  1.1904   \hline
  1.1905  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1906 -{\tt VM ref } & self & object instance \\ \hline 
  1.1907 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1908  
  1.1909  {\tt string } & value & New value to set \\ \hline 
  1.1910  
  1.1911 @@ -3369,7 +3789,7 @@ void
  1.1912  \subsubsection{RPC name:~get\_kernel\_initrd}
  1.1913  
  1.1914  {\bf Overview:} 
  1.1915 -get accessor message derived from field kernel/initrd of object VM
  1.1916 +Get the kernel/initrd field of the given VM.
  1.1917  
  1.1918   \noindent {\bf Signature:} 
  1.1919  \begin{verbatim} string get_kernel_initrd (session_id s, VM ref self)\end{verbatim}
  1.1920 @@ -3382,7 +3802,7 @@ get accessor message derived from field 
  1.1921  \begin{tabular}{|c|c|p{7cm}|}
  1.1922   \hline
  1.1923  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1924 -{\tt VM ref } & self & object instance \\ \hline 
  1.1925 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1926  
  1.1927  \end{tabular}
  1.1928  
  1.1929 @@ -3401,7 +3821,7 @@ value of the field
  1.1930  \subsubsection{RPC name:~set\_kernel\_initrd}
  1.1931  
  1.1932  {\bf Overview:} 
  1.1933 -set accessor message derived from field kernel/initrd of object VM
  1.1934 +Set the kernel/initrd field of the given VM.
  1.1935  
  1.1936   \noindent {\bf Signature:} 
  1.1937  \begin{verbatim} void set_kernel_initrd (session_id s, VM ref self, string value)\end{verbatim}
  1.1938 @@ -3414,7 +3834,7 @@ set accessor message derived from field 
  1.1939  \begin{tabular}{|c|c|p{7cm}|}
  1.1940   \hline
  1.1941  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1942 -{\tt VM ref } & self & object instance \\ \hline 
  1.1943 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1944  
  1.1945  {\tt string } & value & New value to set \\ \hline 
  1.1946  
  1.1947 @@ -3435,7 +3855,7 @@ void
  1.1948  \subsubsection{RPC name:~get\_kernel\_args}
  1.1949  
  1.1950  {\bf Overview:} 
  1.1951 -get accessor message derived from field kernel/args of object VM
  1.1952 +Get the kernel/args field of the given VM.
  1.1953  
  1.1954   \noindent {\bf Signature:} 
  1.1955  \begin{verbatim} string get_kernel_args (session_id s, VM ref self)\end{verbatim}
  1.1956 @@ -3448,7 +3868,7 @@ get accessor message derived from field 
  1.1957  \begin{tabular}{|c|c|p{7cm}|}
  1.1958   \hline
  1.1959  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1960 -{\tt VM ref } & self & object instance \\ \hline 
  1.1961 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1962  
  1.1963  \end{tabular}
  1.1964  
  1.1965 @@ -3467,7 +3887,7 @@ value of the field
  1.1966  \subsubsection{RPC name:~set\_kernel\_args}
  1.1967  
  1.1968  {\bf Overview:} 
  1.1969 -set accessor message derived from field kernel/args of object VM
  1.1970 +Set the kernel/args field of the given VM.
  1.1971  
  1.1972   \noindent {\bf Signature:} 
  1.1973  \begin{verbatim} void set_kernel_args (session_id s, VM ref self, string value)\end{verbatim}
  1.1974 @@ -3480,7 +3900,7 @@ set accessor message derived from field 
  1.1975  \begin{tabular}{|c|c|p{7cm}|}
  1.1976   \hline
  1.1977  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1978 -{\tt VM ref } & self & object instance \\ \hline 
  1.1979 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1980  
  1.1981  {\tt string } & value & New value to set \\ \hline 
  1.1982  
  1.1983 @@ -3501,7 +3921,7 @@ void
  1.1984  \subsubsection{RPC name:~get\_grub\_cmdline}
  1.1985  
  1.1986  {\bf Overview:} 
  1.1987 -get accessor message derived from field grub/cmdline of object VM
  1.1988 +Get the grub/cmdline field of the given VM.
  1.1989  
  1.1990   \noindent {\bf Signature:} 
  1.1991  \begin{verbatim} string get_grub_cmdline (session_id s, VM ref self)\end{verbatim}
  1.1992 @@ -3514,7 +3934,7 @@ get accessor message derived from field 
  1.1993  \begin{tabular}{|c|c|p{7cm}|}
  1.1994   \hline
  1.1995  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.1996 -{\tt VM ref } & self & object instance \\ \hline 
  1.1997 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.1998  
  1.1999  \end{tabular}
  1.2000  
  1.2001 @@ -3533,7 +3953,7 @@ value of the field
  1.2002  \subsubsection{RPC name:~set\_grub\_cmdline}
  1.2003  
  1.2004  {\bf Overview:} 
  1.2005 -set accessor message derived from field grub/cmdline of object VM
  1.2006 +Set the grub/cmdline field of the given VM.
  1.2007  
  1.2008   \noindent {\bf Signature:} 
  1.2009  \begin{verbatim} void set_grub_cmdline (session_id s, VM ref self, string value)\end{verbatim}
  1.2010 @@ -3546,7 +3966,7 @@ set accessor message derived from field 
  1.2011  \begin{tabular}{|c|c|p{7cm}|}
  1.2012   \hline
  1.2013  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2014 -{\tt VM ref } & self & object instance \\ \hline 
  1.2015 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.2016  
  1.2017  {\tt string } & value & New value to set \\ \hline 
  1.2018  
  1.2019 @@ -3567,7 +3987,7 @@ void
  1.2020  \subsubsection{RPC name:~get\_PCI\_bus}
  1.2021  
  1.2022  {\bf Overview:} 
  1.2023 -get accessor message derived from field PCI\_bus of object VM
  1.2024 +Get the PCI\_bus field of the given VM.
  1.2025  
  1.2026   \noindent {\bf Signature:} 
  1.2027  \begin{verbatim} string get_PCI_bus (session_id s, VM ref self)\end{verbatim}
  1.2028 @@ -3580,7 +4000,7 @@ get accessor message derived from field 
  1.2029  \begin{tabular}{|c|c|p{7cm}|}
  1.2030   \hline
  1.2031  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2032 -{\tt VM ref } & self & object instance \\ \hline 
  1.2033 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.2034  
  1.2035  \end{tabular}
  1.2036  
  1.2037 @@ -3599,7 +4019,7 @@ value of the field
  1.2038  \subsubsection{RPC name:~get\_tools\_version}
  1.2039  
  1.2040  {\bf Overview:} 
  1.2041 -get accessor message derived from field tools\_version of object VM
  1.2042 +Get the tools\_version field of the given VM.
  1.2043  
  1.2044   \noindent {\bf Signature:} 
  1.2045  \begin{verbatim} ((string -> string) Map) get_tools_version (session_id s, VM ref self)\end{verbatim}
  1.2046 @@ -3612,7 +4032,7 @@ get accessor message derived from field 
  1.2047  \begin{tabular}{|c|c|p{7cm}|}
  1.2048   \hline
  1.2049  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2050 -{\tt VM ref } & self & object instance \\ \hline 
  1.2051 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.2052  
  1.2053  \end{tabular}
  1.2054  
  1.2055 @@ -3631,7 +4051,7 @@ value of the field
  1.2056  \subsubsection{RPC name:~get\_otherConfig}
  1.2057  
  1.2058  {\bf Overview:} 
  1.2059 -get accessor message derived from field otherConfig of object VM
  1.2060 +Get the otherConfig field of the given VM.
  1.2061  
  1.2062   \noindent {\bf Signature:} 
  1.2063  \begin{verbatim} ((string -> string) Map) get_otherConfig (session_id s, VM ref self)\end{verbatim}
  1.2064 @@ -3644,7 +4064,7 @@ get accessor message derived from field 
  1.2065  \begin{tabular}{|c|c|p{7cm}|}
  1.2066   \hline
  1.2067  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2068 -{\tt VM ref } & self & object instance \\ \hline 
  1.2069 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.2070  
  1.2071  \end{tabular}
  1.2072  
  1.2073 @@ -3660,6 +4080,40 @@ value of the field
  1.2074  \vspace{0.3cm}
  1.2075  \vspace{0.3cm}
  1.2076  \vspace{0.3cm}
  1.2077 +\subsubsection{RPC name:~set\_otherConfig}
  1.2078 +
  1.2079 +{\bf Overview:} 
  1.2080 +Set the otherConfig field of the given VM.
  1.2081 +
  1.2082 + \noindent {\bf Signature:} 
  1.2083 +\begin{verbatim} void set_otherConfig (session_id s, VM ref self, (string -> string) Map value)\end{verbatim}
  1.2084 +
  1.2085 +
  1.2086 +\noindent{\bf Arguments:}
  1.2087 +
  1.2088 + 
  1.2089 +\vspace{0.3cm}
  1.2090 +\begin{tabular}{|c|c|p{7cm}|}
  1.2091 + \hline
  1.2092 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2093 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.2094 +
  1.2095 +{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline 
  1.2096 +
  1.2097 +\end{tabular}
  1.2098 +
  1.2099 +\vspace{0.3cm}
  1.2100 +
  1.2101 + \noindent {\bf Return Type:} 
  1.2102 +{\tt 
  1.2103 +void
  1.2104 +}
  1.2105 +
  1.2106 +
  1.2107 +
  1.2108 +\vspace{0.3cm}
  1.2109 +\vspace{0.3cm}
  1.2110 +\vspace{0.3cm}
  1.2111  \subsubsection{RPC name:~add\_to\_otherConfig}
  1.2112  
  1.2113  {\bf Overview:} 
  1.2114 @@ -3676,7 +4130,7 @@ map add message derived from field other
  1.2115  \begin{tabular}{|c|c|p{7cm}|}
  1.2116   \hline
  1.2117  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2118 -{\tt VM ref } & self & object instance \\ \hline 
  1.2119 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.2120  
  1.2121  {\tt string } & key & Key to add \\ \hline 
  1.2122  
  1.2123 @@ -3712,7 +4166,7 @@ map remove message derived from field ot
  1.2124  \begin{tabular}{|c|c|p{7cm}|}
  1.2125   \hline
  1.2126  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2127 -{\tt VM ref } & self & object instance \\ \hline 
  1.2128 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.2129  
  1.2130  {\tt string } & key & Key to remove \\ \hline 
  1.2131  
  1.2132 @@ -3733,7 +4187,7 @@ void
  1.2133  \subsubsection{RPC name:~create}
  1.2134  
  1.2135  {\bf Overview:} 
  1.2136 -constructor for class VM
  1.2137 +Create a new VM instance, and return its handle.
  1.2138  
  1.2139   \noindent {\bf Signature:} 
  1.2140  \begin{verbatim} (VM ref) create (session_id s, VM record args)\end{verbatim}
  1.2141 @@ -3765,7 +4219,7 @@ reference to the newly created object
  1.2142  \subsubsection{RPC name:~destroy}
  1.2143  
  1.2144  {\bf Overview:} 
  1.2145 -destructor for class VM
  1.2146 +Destroy the specified VM.  The VM is completely removed from the system.  This function can only be called when the VM is in the Halted State.
  1.2147  
  1.2148   \noindent {\bf Signature:} 
  1.2149  \begin{verbatim} void destroy (session_id s, VM ref self)\end{verbatim}
  1.2150 @@ -3778,7 +4232,7 @@ destructor for class VM
  1.2151  \begin{tabular}{|c|c|p{7cm}|}
  1.2152   \hline
  1.2153  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2154 -{\tt VM ref } & self & object instance \\ \hline 
  1.2155 +{\tt VM ref } & self & reference to the object \\ \hline 
  1.2156  
  1.2157  \end{tabular}
  1.2158  
  1.2159 @@ -3797,7 +4251,7 @@ void
  1.2160  \subsubsection{RPC name:~get\_by\_uuid}
  1.2161  
  1.2162  {\bf Overview:} 
  1.2163 -returns the VM instance with a particular uuid
  1.2164 +Get a reference to the VM instance with the specified UUID.
  1.2165  
  1.2166   \noindent {\bf Signature:} 
  1.2167  \begin{verbatim} (VM ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.2168 @@ -3829,7 +4283,7 @@ reference to the object
  1.2169  \subsubsection{RPC name:~get\_record}
  1.2170  
  1.2171  {\bf Overview:} 
  1.2172 -returns a record containing the state of an instance of class VM
  1.2173 +Get a record containing the current state of the given VM.
  1.2174  
  1.2175   \noindent {\bf Signature:} 
  1.2176  \begin{verbatim} (VM record) get_record (session_id s, VM ref self)\end{verbatim}
  1.2177 @@ -3861,7 +4315,7 @@ all fields from the object
  1.2178  \subsubsection{RPC name:~get\_by\_name\_label}
  1.2179  
  1.2180  {\bf Overview:} 
  1.2181 -returns the VM instance with a particular name label
  1.2182 +Get all the VM instances with the given label.
  1.2183  
  1.2184   \noindent {\bf Signature:} 
  1.2185  \begin{verbatim} ((VM ref) Set) get_by_name_label (session_id s, string label)\end{verbatim}
  1.2186 @@ -4064,7 +4518,7 @@ A list of all the IDs of all the hosts
  1.2187  \subsubsection{RPC name:~get\_uuid}
  1.2188  
  1.2189  {\bf Overview:} 
  1.2190 -get accessor message derived from field uuid of object host
  1.2191 +Get the uuid field of the given host.
  1.2192  
  1.2193   \noindent {\bf Signature:} 
  1.2194  \begin{verbatim} string get_uuid (session_id s, host ref self)\end{verbatim}
  1.2195 @@ -4077,7 +4531,7 @@ get accessor message derived from field 
  1.2196  \begin{tabular}{|c|c|p{7cm}|}
  1.2197   \hline
  1.2198  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2199 -{\tt host ref } & self & object instance \\ \hline 
  1.2200 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2201  
  1.2202  \end{tabular}
  1.2203  
  1.2204 @@ -4096,7 +4550,7 @@ value of the field
  1.2205  \subsubsection{RPC name:~get\_name\_label}
  1.2206  
  1.2207  {\bf Overview:} 
  1.2208 -get accessor message derived from field name/label of object host
  1.2209 +Get the name/label field of the given host.
  1.2210  
  1.2211   \noindent {\bf Signature:} 
  1.2212  \begin{verbatim} string get_name_label (session_id s, host ref self)\end{verbatim}
  1.2213 @@ -4109,7 +4563,7 @@ get accessor message derived from field 
  1.2214  \begin{tabular}{|c|c|p{7cm}|}
  1.2215   \hline
  1.2216  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2217 -{\tt host ref } & self & object instance \\ \hline 
  1.2218 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2219  
  1.2220  \end{tabular}
  1.2221  
  1.2222 @@ -4128,7 +4582,7 @@ value of the field
  1.2223  \subsubsection{RPC name:~set\_name\_label}
  1.2224  
  1.2225  {\bf Overview:} 
  1.2226 -set accessor message derived from field name/label of object host
  1.2227 +Set the name/label field of the given host.
  1.2228  
  1.2229   \noindent {\bf Signature:} 
  1.2230  \begin{verbatim} void set_name_label (session_id s, host ref self, string value)\end{verbatim}
  1.2231 @@ -4141,7 +4595,7 @@ set accessor message derived from field 
  1.2232  \begin{tabular}{|c|c|p{7cm}|}
  1.2233   \hline
  1.2234  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2235 -{\tt host ref } & self & object instance \\ \hline 
  1.2236 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2237  
  1.2238  {\tt string } & value & New value to set \\ \hline 
  1.2239  
  1.2240 @@ -4162,7 +4616,7 @@ void
  1.2241  \subsubsection{RPC name:~get\_name\_description}
  1.2242  
  1.2243  {\bf Overview:} 
  1.2244 -get accessor message derived from field name/description of object host
  1.2245 +Get the name/description field of the given host.
  1.2246  
  1.2247   \noindent {\bf Signature:} 
  1.2248  \begin{verbatim} string get_name_description (session_id s, host ref self)\end{verbatim}
  1.2249 @@ -4175,7 +4629,7 @@ get accessor message derived from field 
  1.2250  \begin{tabular}{|c|c|p{7cm}|}
  1.2251   \hline
  1.2252  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2253 -{\tt host ref } & self & object instance \\ \hline 
  1.2254 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2255  
  1.2256  \end{tabular}
  1.2257  
  1.2258 @@ -4194,7 +4648,7 @@ value of the field
  1.2259  \subsubsection{RPC name:~set\_name\_description}
  1.2260  
  1.2261  {\bf Overview:} 
  1.2262 -set accessor message derived from field name/description of object host
  1.2263 +Set the name/description field of the given host.
  1.2264  
  1.2265   \noindent {\bf Signature:} 
  1.2266  \begin{verbatim} void set_name_description (session_id s, host ref self, string value)\end{verbatim}
  1.2267 @@ -4207,7 +4661,7 @@ set accessor message derived from field 
  1.2268  \begin{tabular}{|c|c|p{7cm}|}
  1.2269   \hline
  1.2270  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2271 -{\tt host ref } & self & object instance \\ \hline 
  1.2272 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2273  
  1.2274  {\tt string } & value & New value to set \\ \hline 
  1.2275  
  1.2276 @@ -4228,7 +4682,7 @@ void
  1.2277  \subsubsection{RPC name:~get\_software\_version}
  1.2278  
  1.2279  {\bf Overview:} 
  1.2280 -get accessor message derived from field software\_version of object host
  1.2281 +Get the software\_version field of the given host.
  1.2282  
  1.2283   \noindent {\bf Signature:} 
  1.2284  \begin{verbatim} ((string -> string) Map) get_software_version (session_id s, host ref self)\end{verbatim}
  1.2285 @@ -4241,7 +4695,7 @@ get accessor message derived from field 
  1.2286  \begin{tabular}{|c|c|p{7cm}|}
  1.2287   \hline
  1.2288  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2289 -{\tt host ref } & self & object instance \\ \hline 
  1.2290 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2291  
  1.2292  \end{tabular}
  1.2293  
  1.2294 @@ -4260,7 +4714,7 @@ value of the field
  1.2295  \subsubsection{RPC name:~get\_resident\_VMs}
  1.2296  
  1.2297  {\bf Overview:} 
  1.2298 -get accessor message derived from field resident\_VMs of object host
  1.2299 +Get the resident\_VMs field of the given host.
  1.2300  
  1.2301   \noindent {\bf Signature:} 
  1.2302  \begin{verbatim} ((VM ref) Set) get_resident_VMs (session_id s, host ref self)\end{verbatim}
  1.2303 @@ -4273,7 +4727,7 @@ get accessor message derived from field 
  1.2304  \begin{tabular}{|c|c|p{7cm}|}
  1.2305   \hline
  1.2306  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2307 -{\tt host ref } & self & object instance \\ \hline 
  1.2308 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2309  
  1.2310  \end{tabular}
  1.2311  
  1.2312 @@ -4292,7 +4746,7 @@ value of the field
  1.2313  \subsubsection{RPC name:~get\_PIFs}
  1.2314  
  1.2315  {\bf Overview:} 
  1.2316 -get accessor message derived from field PIFs of object host
  1.2317 +Get the PIFs field of the given host.
  1.2318  
  1.2319   \noindent {\bf Signature:} 
  1.2320  \begin{verbatim} ((PIF ref) Set) get_PIFs (session_id s, host ref self)\end{verbatim}
  1.2321 @@ -4305,7 +4759,7 @@ get accessor message derived from field 
  1.2322  \begin{tabular}{|c|c|p{7cm}|}
  1.2323   \hline
  1.2324  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2325 -{\tt host ref } & self & object instance \\ \hline 
  1.2326 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2327  
  1.2328  \end{tabular}
  1.2329  
  1.2330 @@ -4324,7 +4778,7 @@ value of the field
  1.2331  \subsubsection{RPC name:~get\_host\_CPUs}
  1.2332  
  1.2333  {\bf Overview:} 
  1.2334 -get accessor message derived from field host\_CPUs of object host
  1.2335 +Get the host\_CPUs field of the given host.
  1.2336  
  1.2337   \noindent {\bf Signature:} 
  1.2338  \begin{verbatim} ((host_cpu ref) Set) get_host_CPUs (session_id s, host ref self)\end{verbatim}
  1.2339 @@ -4337,7 +4791,7 @@ get accessor message derived from field 
  1.2340  \begin{tabular}{|c|c|p{7cm}|}
  1.2341   \hline
  1.2342  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2343 -{\tt host ref } & self & object instance \\ \hline 
  1.2344 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2345  
  1.2346  \end{tabular}
  1.2347  
  1.2348 @@ -4356,7 +4810,7 @@ value of the field
  1.2349  \subsubsection{RPC name:~create}
  1.2350  
  1.2351  {\bf Overview:} 
  1.2352 -constructor for class host
  1.2353 +Create a new host instance, and return its handle.
  1.2354  
  1.2355   \noindent {\bf Signature:} 
  1.2356  \begin{verbatim} (host ref) create (session_id s, host record args)\end{verbatim}
  1.2357 @@ -4388,7 +4842,7 @@ reference to the newly created object
  1.2358  \subsubsection{RPC name:~destroy}
  1.2359  
  1.2360  {\bf Overview:} 
  1.2361 -destructor for class host
  1.2362 +Destroy the specified host instance.
  1.2363  
  1.2364   \noindent {\bf Signature:} 
  1.2365  \begin{verbatim} void destroy (session_id s, host ref self)\end{verbatim}
  1.2366 @@ -4401,7 +4855,7 @@ destructor for class host
  1.2367  \begin{tabular}{|c|c|p{7cm}|}
  1.2368   \hline
  1.2369  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2370 -{\tt host ref } & self & object instance \\ \hline 
  1.2371 +{\tt host ref } & self & reference to the object \\ \hline 
  1.2372  
  1.2373  \end{tabular}
  1.2374  
  1.2375 @@ -4420,7 +4874,7 @@ void
  1.2376  \subsubsection{RPC name:~get\_by\_uuid}
  1.2377  
  1.2378  {\bf Overview:} 
  1.2379 -returns the host instance with a particular uuid
  1.2380 +Get a reference to the host instance with the specified UUID.
  1.2381  
  1.2382   \noindent {\bf Signature:} 
  1.2383  \begin{verbatim} (host ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.2384 @@ -4452,7 +4906,7 @@ reference to the object
  1.2385  \subsubsection{RPC name:~get\_record}
  1.2386  
  1.2387  {\bf Overview:} 
  1.2388 -returns a record containing the state of an instance of class host
  1.2389 +Get a record containing the current state of the given host.
  1.2390  
  1.2391   \noindent {\bf Signature:} 
  1.2392  \begin{verbatim} (host record) get_record (session_id s, host ref self)\end{verbatim}
  1.2393 @@ -4484,7 +4938,7 @@ all fields from the object
  1.2394  \subsubsection{RPC name:~get\_by\_name\_label}
  1.2395  
  1.2396  {\bf Overview:} 
  1.2397 -returns the host instance with a particular name label
  1.2398 +Get all the host instances with the given label.
  1.2399  
  1.2400   \noindent {\bf Signature:} 
  1.2401  \begin{verbatim} ((host ref) Set) get_by_name_label (session_id s, string label)\end{verbatim}
  1.2402 @@ -4539,7 +4993,7 @@ Quals & Field & Type & Description \\
  1.2403  \subsubsection{RPC name:~get\_uuid}
  1.2404  
  1.2405  {\bf Overview:} 
  1.2406 -get accessor message derived from field uuid of object host\_cpu
  1.2407 +Get the uuid field of the given host\_cpu.
  1.2408  
  1.2409   \noindent {\bf Signature:} 
  1.2410  \begin{verbatim} string get_uuid (session_id s, host_cpu ref self)\end{verbatim}
  1.2411 @@ -4552,7 +5006,7 @@ get accessor message derived from field 
  1.2412  \begin{tabular}{|c|c|p{7cm}|}
  1.2413   \hline
  1.2414  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2415 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2416 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2417  
  1.2418  \end{tabular}
  1.2419  
  1.2420 @@ -4571,7 +5025,7 @@ value of the field
  1.2421  \subsubsection{RPC name:~get\_host}
  1.2422  
  1.2423  {\bf Overview:} 
  1.2424 -get accessor message derived from field host of object host\_cpu
  1.2425 +Get the host field of the given host\_cpu.
  1.2426  
  1.2427   \noindent {\bf Signature:} 
  1.2428  \begin{verbatim} (host ref) get_host (session_id s, host_cpu ref self)\end{verbatim}
  1.2429 @@ -4584,7 +5038,7 @@ get accessor message derived from field 
  1.2430  \begin{tabular}{|c|c|p{7cm}|}
  1.2431   \hline
  1.2432  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2433 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2434 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2435  
  1.2436  \end{tabular}
  1.2437  
  1.2438 @@ -4603,7 +5057,7 @@ value of the field
  1.2439  \subsubsection{RPC name:~get\_number}
  1.2440  
  1.2441  {\bf Overview:} 
  1.2442 -get accessor message derived from field number of object host\_cpu
  1.2443 +Get the number field of the given host\_cpu.
  1.2444  
  1.2445   \noindent {\bf Signature:} 
  1.2446  \begin{verbatim} int get_number (session_id s, host_cpu ref self)\end{verbatim}
  1.2447 @@ -4616,7 +5070,7 @@ get accessor message derived from field 
  1.2448  \begin{tabular}{|c|c|p{7cm}|}
  1.2449   \hline
  1.2450  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2451 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2452 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2453  
  1.2454  \end{tabular}
  1.2455  
  1.2456 @@ -4635,7 +5089,7 @@ value of the field
  1.2457  \subsubsection{RPC name:~get\_vendor}
  1.2458  
  1.2459  {\bf Overview:} 
  1.2460 -get accessor message derived from field vendor of object host\_cpu
  1.2461 +Get the vendor field of the given host\_cpu.
  1.2462  
  1.2463   \noindent {\bf Signature:} 
  1.2464  \begin{verbatim} string get_vendor (session_id s, host_cpu ref self)\end{verbatim}
  1.2465 @@ -4648,7 +5102,7 @@ get accessor message derived from field 
  1.2466  \begin{tabular}{|c|c|p{7cm}|}
  1.2467   \hline
  1.2468  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2469 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2470 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2471  
  1.2472  \end{tabular}
  1.2473  
  1.2474 @@ -4667,7 +5121,7 @@ value of the field
  1.2475  \subsubsection{RPC name:~get\_speed}
  1.2476  
  1.2477  {\bf Overview:} 
  1.2478 -get accessor message derived from field speed of object host\_cpu
  1.2479 +Get the speed field of the given host\_cpu.
  1.2480  
  1.2481   \noindent {\bf Signature:} 
  1.2482  \begin{verbatim} int get_speed (session_id s, host_cpu ref self)\end{verbatim}
  1.2483 @@ -4680,7 +5134,7 @@ get accessor message derived from field 
  1.2484  \begin{tabular}{|c|c|p{7cm}|}
  1.2485   \hline
  1.2486  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2487 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2488 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2489  
  1.2490  \end{tabular}
  1.2491  
  1.2492 @@ -4699,7 +5153,7 @@ value of the field
  1.2493  \subsubsection{RPC name:~get\_modelname}
  1.2494  
  1.2495  {\bf Overview:} 
  1.2496 -get accessor message derived from field modelname of object host\_cpu
  1.2497 +Get the modelname field of the given host\_cpu.
  1.2498  
  1.2499   \noindent {\bf Signature:} 
  1.2500  \begin{verbatim} string get_modelname (session_id s, host_cpu ref self)\end{verbatim}
  1.2501 @@ -4712,7 +5166,7 @@ get accessor message derived from field 
  1.2502  \begin{tabular}{|c|c|p{7cm}|}
  1.2503   \hline
  1.2504  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2505 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2506 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2507  
  1.2508  \end{tabular}
  1.2509  
  1.2510 @@ -4731,7 +5185,7 @@ value of the field
  1.2511  \subsubsection{RPC name:~get\_features}
  1.2512  
  1.2513  {\bf Overview:} 
  1.2514 -get accessor message derived from field features of object host\_cpu
  1.2515 +Get the features field of the given host\_cpu.
  1.2516  
  1.2517   \noindent {\bf Signature:} 
  1.2518  \begin{verbatim} ((cpu_feature) Set) get_features (session_id s, host_cpu ref self)\end{verbatim}
  1.2519 @@ -4744,7 +5198,7 @@ get accessor message derived from field 
  1.2520  \begin{tabular}{|c|c|p{7cm}|}
  1.2521   \hline
  1.2522  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2523 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2524 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2525  
  1.2526  \end{tabular}
  1.2527  
  1.2528 @@ -4763,7 +5217,7 @@ value of the field
  1.2529  \subsubsection{RPC name:~get\_utilisation}
  1.2530  
  1.2531  {\bf Overview:} 
  1.2532 -get accessor message derived from field utilisation of object host\_cpu
  1.2533 +Get the utilisation field of the given host\_cpu.
  1.2534  
  1.2535   \noindent {\bf Signature:} 
  1.2536  \begin{verbatim} float get_utilisation (session_id s, host_cpu ref self)\end{verbatim}
  1.2537 @@ -4776,7 +5230,7 @@ get accessor message derived from field 
  1.2538  \begin{tabular}{|c|c|p{7cm}|}
  1.2539   \hline
  1.2540  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2541 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2542 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2543  
  1.2544  \end{tabular}
  1.2545  
  1.2546 @@ -4795,7 +5249,7 @@ value of the field
  1.2547  \subsubsection{RPC name:~create}
  1.2548  
  1.2549  {\bf Overview:} 
  1.2550 -constructor for class host\_cpu
  1.2551 +Create a new host\_cpu instance, and return its handle.
  1.2552  
  1.2553   \noindent {\bf Signature:} 
  1.2554  \begin{verbatim} (host_cpu ref) create (session_id s, host_cpu record args)\end{verbatim}
  1.2555 @@ -4827,7 +5281,7 @@ reference to the newly created object
  1.2556  \subsubsection{RPC name:~destroy}
  1.2557  
  1.2558  {\bf Overview:} 
  1.2559 -destructor for class host\_cpu
  1.2560 +Destroy the specified host\_cpu instance.
  1.2561  
  1.2562   \noindent {\bf Signature:} 
  1.2563  \begin{verbatim} void destroy (session_id s, host_cpu ref self)\end{verbatim}
  1.2564 @@ -4840,7 +5294,7 @@ destructor for class host\_cpu
  1.2565  \begin{tabular}{|c|c|p{7cm}|}
  1.2566   \hline
  1.2567  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2568 -{\tt host\_cpu ref } & self & object instance \\ \hline 
  1.2569 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
  1.2570  
  1.2571  \end{tabular}
  1.2572  
  1.2573 @@ -4859,7 +5313,7 @@ void
  1.2574  \subsubsection{RPC name:~get\_by\_uuid}
  1.2575  
  1.2576  {\bf Overview:} 
  1.2577 -returns the host\_cpu instance with a particular uuid
  1.2578 +Get a reference to the host\_cpu instance with the specified UUID.
  1.2579  
  1.2580   \noindent {\bf Signature:} 
  1.2581  \begin{verbatim} (host_cpu ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.2582 @@ -4891,7 +5345,7 @@ reference to the object
  1.2583  \subsubsection{RPC name:~get\_record}
  1.2584  
  1.2585  {\bf Overview:} 
  1.2586 -returns a record containing the state of an instance of class host\_cpu
  1.2587 +Get a record containing the current state of the given host\_cpu.
  1.2588  
  1.2589   \noindent {\bf Signature:} 
  1.2590  \begin{verbatim} (host_cpu record) get_record (session_id s, host_cpu ref self)\end{verbatim}
  1.2591 @@ -4966,7 +5420,7 @@ A list of all the IDs of all the network
  1.2592  \subsubsection{RPC name:~get\_uuid}
  1.2593  
  1.2594  {\bf Overview:} 
  1.2595 -get accessor message derived from field uuid of object network
  1.2596 +Get the uuid field of the given network.
  1.2597  
  1.2598   \noindent {\bf Signature:} 
  1.2599  \begin{verbatim} string get_uuid (session_id s, network ref self)\end{verbatim}
  1.2600 @@ -4979,7 +5433,7 @@ get accessor message derived from field 
  1.2601  \begin{tabular}{|c|c|p{7cm}|}
  1.2602   \hline
  1.2603  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2604 -{\tt network ref } & self & object instance \\ \hline 
  1.2605 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2606  
  1.2607  \end{tabular}
  1.2608  
  1.2609 @@ -4998,7 +5452,7 @@ value of the field
  1.2610  \subsubsection{RPC name:~get\_name\_label}
  1.2611  
  1.2612  {\bf Overview:} 
  1.2613 -get accessor message derived from field name/label of object network
  1.2614 +Get the name/label field of the given network.
  1.2615  
  1.2616   \noindent {\bf Signature:} 
  1.2617  \begin{verbatim} string get_name_label (session_id s, network ref self)\end{verbatim}
  1.2618 @@ -5011,7 +5465,7 @@ get accessor message derived from field 
  1.2619  \begin{tabular}{|c|c|p{7cm}|}
  1.2620   \hline
  1.2621  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2622 -{\tt network ref } & self & object instance \\ \hline 
  1.2623 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2624  
  1.2625  \end{tabular}
  1.2626  
  1.2627 @@ -5030,7 +5484,7 @@ value of the field
  1.2628  \subsubsection{RPC name:~set\_name\_label}
  1.2629  
  1.2630  {\bf Overview:} 
  1.2631 -set accessor message derived from field name/label of object network
  1.2632 +Set the name/label field of the given network.
  1.2633  
  1.2634   \noindent {\bf Signature:} 
  1.2635  \begin{verbatim} void set_name_label (session_id s, network ref self, string value)\end{verbatim}
  1.2636 @@ -5043,7 +5497,7 @@ set accessor message derived from field 
  1.2637  \begin{tabular}{|c|c|p{7cm}|}
  1.2638   \hline
  1.2639  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2640 -{\tt network ref } & self & object instance \\ \hline 
  1.2641 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2642  
  1.2643  {\tt string } & value & New value to set \\ \hline 
  1.2644  
  1.2645 @@ -5064,7 +5518,7 @@ void
  1.2646  \subsubsection{RPC name:~get\_name\_description}
  1.2647  
  1.2648  {\bf Overview:} 
  1.2649 -get accessor message derived from field name/description of object network
  1.2650 +Get the name/description field of the given network.
  1.2651  
  1.2652   \noindent {\bf Signature:} 
  1.2653  \begin{verbatim} string get_name_description (session_id s, network ref self)\end{verbatim}
  1.2654 @@ -5077,7 +5531,7 @@ get accessor message derived from field 
  1.2655  \begin{tabular}{|c|c|p{7cm}|}
  1.2656   \hline
  1.2657  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2658 -{\tt network ref } & self & object instance \\ \hline 
  1.2659 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2660  
  1.2661  \end{tabular}
  1.2662  
  1.2663 @@ -5096,7 +5550,7 @@ value of the field
  1.2664  \subsubsection{RPC name:~set\_name\_description}
  1.2665  
  1.2666  {\bf Overview:} 
  1.2667 -set accessor message derived from field name/description of object network
  1.2668 +Set the name/description field of the given network.
  1.2669  
  1.2670   \noindent {\bf Signature:} 
  1.2671  \begin{verbatim} void set_name_description (session_id s, network ref self, string value)\end{verbatim}
  1.2672 @@ -5109,7 +5563,7 @@ set accessor message derived from field 
  1.2673  \begin{tabular}{|c|c|p{7cm}|}
  1.2674   \hline
  1.2675  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2676 -{\tt network ref } & self & object instance \\ \hline 
  1.2677 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2678  
  1.2679  {\tt string } & value & New value to set \\ \hline 
  1.2680  
  1.2681 @@ -5130,7 +5584,7 @@ void
  1.2682  \subsubsection{RPC name:~get\_VIFs}
  1.2683  
  1.2684  {\bf Overview:} 
  1.2685 -get accessor message derived from field VIFs of object network
  1.2686 +Get the VIFs field of the given network.
  1.2687  
  1.2688   \noindent {\bf Signature:} 
  1.2689  \begin{verbatim} ((VIF ref) Set) get_VIFs (session_id s, network ref self)\end{verbatim}
  1.2690 @@ -5143,7 +5597,7 @@ get accessor message derived from field 
  1.2691  \begin{tabular}{|c|c|p{7cm}|}
  1.2692   \hline
  1.2693  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2694 -{\tt network ref } & self & object instance \\ \hline 
  1.2695 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2696  
  1.2697  \end{tabular}
  1.2698  
  1.2699 @@ -5162,7 +5616,7 @@ value of the field
  1.2700  \subsubsection{RPC name:~get\_PIFs}
  1.2701  
  1.2702  {\bf Overview:} 
  1.2703 -get accessor message derived from field PIFs of object network
  1.2704 +Get the PIFs field of the given network.
  1.2705  
  1.2706   \noindent {\bf Signature:} 
  1.2707  \begin{verbatim} ((PIF ref) Set) get_PIFs (session_id s, network ref self)\end{verbatim}
  1.2708 @@ -5175,7 +5629,7 @@ get accessor message derived from field 
  1.2709  \begin{tabular}{|c|c|p{7cm}|}
  1.2710   \hline
  1.2711  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2712 -{\tt network ref } & self & object instance \\ \hline 
  1.2713 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2714  
  1.2715  \end{tabular}
  1.2716  
  1.2717 @@ -5194,7 +5648,7 @@ value of the field
  1.2718  \subsubsection{RPC name:~get\_default\_gateway}
  1.2719  
  1.2720  {\bf Overview:} 
  1.2721 -get accessor message derived from field default\_gateway of object network
  1.2722 +Get the default\_gateway field of the given network.
  1.2723  
  1.2724   \noindent {\bf Signature:} 
  1.2725  \begin{verbatim} string get_default_gateway (session_id s, network ref self)\end{verbatim}
  1.2726 @@ -5207,7 +5661,7 @@ get accessor message derived from field 
  1.2727  \begin{tabular}{|c|c|p{7cm}|}
  1.2728   \hline
  1.2729  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2730 -{\tt network ref } & self & object instance \\ \hline 
  1.2731 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2732  
  1.2733  \end{tabular}
  1.2734  
  1.2735 @@ -5226,7 +5680,7 @@ value of the field
  1.2736  \subsubsection{RPC name:~set\_default\_gateway}
  1.2737  
  1.2738  {\bf Overview:} 
  1.2739 -set accessor message derived from field default\_gateway of object network
  1.2740 +Set the default\_gateway field of the given network.
  1.2741  
  1.2742   \noindent {\bf Signature:} 
  1.2743  \begin{verbatim} void set_default_gateway (session_id s, network ref self, string value)\end{verbatim}
  1.2744 @@ -5239,7 +5693,7 @@ set accessor message derived from field 
  1.2745  \begin{tabular}{|c|c|p{7cm}|}
  1.2746   \hline
  1.2747  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2748 -{\tt network ref } & self & object instance \\ \hline 
  1.2749 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2750  
  1.2751  {\tt string } & value & New value to set \\ \hline 
  1.2752  
  1.2753 @@ -5260,7 +5714,7 @@ void
  1.2754  \subsubsection{RPC name:~get\_default\_netmask}
  1.2755  
  1.2756  {\bf Overview:} 
  1.2757 -get accessor message derived from field default\_netmask of object network
  1.2758 +Get the default\_netmask field of the given network.
  1.2759  
  1.2760   \noindent {\bf Signature:} 
  1.2761  \begin{verbatim} string get_default_netmask (session_id s, network ref self)\end{verbatim}
  1.2762 @@ -5273,7 +5727,7 @@ get accessor message derived from field 
  1.2763  \begin{tabular}{|c|c|p{7cm}|}
  1.2764   \hline
  1.2765  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2766 -{\tt network ref } & self & object instance \\ \hline 
  1.2767 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2768  
  1.2769  \end{tabular}
  1.2770  
  1.2771 @@ -5292,7 +5746,7 @@ value of the field
  1.2772  \subsubsection{RPC name:~set\_default\_netmask}
  1.2773  
  1.2774  {\bf Overview:} 
  1.2775 -set accessor message derived from field default\_netmask of object network
  1.2776 +Set the default\_netmask field of the given network.
  1.2777  
  1.2778   \noindent {\bf Signature:} 
  1.2779  \begin{verbatim} void set_default_netmask (session_id s, network ref self, string value)\end{verbatim}
  1.2780 @@ -5305,7 +5759,7 @@ set accessor message derived from field 
  1.2781  \begin{tabular}{|c|c|p{7cm}|}
  1.2782   \hline
  1.2783  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2784 -{\tt network ref } & self & object instance \\ \hline 
  1.2785 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2786  
  1.2787  {\tt string } & value & New value to set \\ \hline 
  1.2788  
  1.2789 @@ -5326,7 +5780,7 @@ void
  1.2790  \subsubsection{RPC name:~create}
  1.2791  
  1.2792  {\bf Overview:} 
  1.2793 -constructor for class network
  1.2794 +Create a new network instance, and return its handle.
  1.2795  
  1.2796   \noindent {\bf Signature:} 
  1.2797  \begin{verbatim} (network ref) create (session_id s, network record args)\end{verbatim}
  1.2798 @@ -5358,7 +5812,7 @@ reference to the newly created object
  1.2799  \subsubsection{RPC name:~destroy}
  1.2800  
  1.2801  {\bf Overview:} 
  1.2802 -destructor for class network
  1.2803 +Destroy the specified network instance.
  1.2804  
  1.2805   \noindent {\bf Signature:} 
  1.2806  \begin{verbatim} void destroy (session_id s, network ref self)\end{verbatim}
  1.2807 @@ -5371,7 +5825,7 @@ destructor for class network
  1.2808  \begin{tabular}{|c|c|p{7cm}|}
  1.2809   \hline
  1.2810  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2811 -{\tt network ref } & self & object instance \\ \hline 
  1.2812 +{\tt network ref } & self & reference to the object \\ \hline 
  1.2813  
  1.2814  \end{tabular}
  1.2815  
  1.2816 @@ -5390,7 +5844,7 @@ void
  1.2817  \subsubsection{RPC name:~get\_by\_uuid}
  1.2818  
  1.2819  {\bf Overview:} 
  1.2820 -returns the network instance with a particular uuid
  1.2821 +Get a reference to the network instance with the specified UUID.
  1.2822  
  1.2823   \noindent {\bf Signature:} 
  1.2824  \begin{verbatim} (network ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.2825 @@ -5422,7 +5876,7 @@ reference to the object
  1.2826  \subsubsection{RPC name:~get\_record}
  1.2827  
  1.2828  {\bf Overview:} 
  1.2829 -returns a record containing the state of an instance of class network
  1.2830 +Get a record containing the current state of the given network.
  1.2831  
  1.2832   \noindent {\bf Signature:} 
  1.2833  \begin{verbatim} (network record) get_record (session_id s, network ref self)\end{verbatim}
  1.2834 @@ -5454,7 +5908,7 @@ all fields from the object
  1.2835  \subsubsection{RPC name:~get\_by\_name\_label}
  1.2836  
  1.2837  {\bf Overview:} 
  1.2838 -returns the network instance with a particular name label
  1.2839 +Get all the network instances with the given label.
  1.2840  
  1.2841   \noindent {\bf Signature:} 
  1.2842  \begin{verbatim} ((network ref) Set) get_by_name_label (session_id s, string label)\end{verbatim}
  1.2843 @@ -5511,7 +5965,7 @@ Quals & Field & Type & Description \\
  1.2844  \subsubsection{RPC name:~get\_uuid}
  1.2845  
  1.2846  {\bf Overview:} 
  1.2847 -get accessor message derived from field uuid of object VIF
  1.2848 +Get the uuid field of the given VIF.
  1.2849  
  1.2850   \noindent {\bf Signature:} 
  1.2851  \begin{verbatim} string get_uuid (session_id s, VIF ref self)\end{verbatim}
  1.2852 @@ -5524,7 +5978,7 @@ get accessor message derived from field 
  1.2853  \begin{tabular}{|c|c|p{7cm}|}
  1.2854   \hline
  1.2855  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2856 -{\tt VIF ref } & self & object instance \\ \hline 
  1.2857 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.2858  
  1.2859  \end{tabular}
  1.2860  
  1.2861 @@ -5543,7 +5997,7 @@ value of the field
  1.2862  \subsubsection{RPC name:~get\_name}
  1.2863  
  1.2864  {\bf Overview:} 
  1.2865 -get accessor message derived from field name of object VIF
  1.2866 +Get the name field of the given VIF.
  1.2867  
  1.2868   \noindent {\bf Signature:} 
  1.2869  \begin{verbatim} string get_name (session_id s, VIF ref self)\end{verbatim}
  1.2870 @@ -5556,7 +6010,7 @@ get accessor message derived from field 
  1.2871  \begin{tabular}{|c|c|p{7cm}|}
  1.2872   \hline
  1.2873  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2874 -{\tt VIF ref } & self & object instance \\ \hline 
  1.2875 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.2876  
  1.2877  \end{tabular}
  1.2878  
  1.2879 @@ -5575,7 +6029,7 @@ value of the field
  1.2880  \subsubsection{RPC name:~set\_name}
  1.2881  
  1.2882  {\bf Overview:} 
  1.2883 -set accessor message derived from field name of object VIF
  1.2884 +Set the name field of the given VIF.
  1.2885  
  1.2886   \noindent {\bf Signature:} 
  1.2887  \begin{verbatim} void set_name (session_id s, VIF ref self, string value)\end{verbatim}
  1.2888 @@ -5588,7 +6042,7 @@ set accessor message derived from field 
  1.2889  \begin{tabular}{|c|c|p{7cm}|}
  1.2890   \hline
  1.2891  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2892 -{\tt VIF ref } & self & object instance \\ \hline 
  1.2893 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.2894  
  1.2895  {\tt string } & value & New value to set \\ \hline 
  1.2896  
  1.2897 @@ -5609,7 +6063,7 @@ void
  1.2898  \subsubsection{RPC name:~get\_type}
  1.2899  
  1.2900  {\bf Overview:} 
  1.2901 -get accessor message derived from field type of object VIF
  1.2902 +Get the type field of the given VIF.
  1.2903  
  1.2904   \noindent {\bf Signature:} 
  1.2905  \begin{verbatim} (driver_type) get_type (session_id s, VIF ref self)\end{verbatim}
  1.2906 @@ -5622,7 +6076,7 @@ get accessor message derived from field 
  1.2907  \begin{tabular}{|c|c|p{7cm}|}
  1.2908   \hline
  1.2909  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2910 -{\tt VIF ref } & self & object instance \\ \hline 
  1.2911 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.2912  
  1.2913  \end{tabular}
  1.2914  
  1.2915 @@ -5641,7 +6095,7 @@ value of the field
  1.2916  \subsubsection{RPC name:~set\_type}
  1.2917  
  1.2918  {\bf Overview:} 
  1.2919 -set accessor message derived from field type of object VIF
  1.2920 +Set the type field of the given VIF.
  1.2921  
  1.2922   \noindent {\bf Signature:} 
  1.2923  \begin{verbatim} void set_type (session_id s, VIF ref self, driver_type value)\end{verbatim}
  1.2924 @@ -5654,7 +6108,7 @@ set accessor message derived from field 
  1.2925  \begin{tabular}{|c|c|p{7cm}|}
  1.2926   \hline
  1.2927  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2928 -{\tt VIF ref } & self & object instance \\ \hline 
  1.2929 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.2930  
  1.2931  {\tt driver\_type } & value & New value to set \\ \hline 
  1.2932  
  1.2933 @@ -5675,7 +6129,7 @@ void
  1.2934  \subsubsection{RPC name:~get\_device}
  1.2935  
  1.2936  {\bf Overview:} 
  1.2937 -get accessor message derived from field device of object VIF
  1.2938 +Get the device field of the given VIF.
  1.2939  
  1.2940   \noindent {\bf Signature:} 
  1.2941  \begin{verbatim} string get_device (session_id s, VIF ref self)\end{verbatim}
  1.2942 @@ -5688,7 +6142,7 @@ get accessor message derived from field 
  1.2943  \begin{tabular}{|c|c|p{7cm}|}
  1.2944   \hline
  1.2945  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2946 -{\tt VIF ref } & self & object instance \\ \hline 
  1.2947 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.2948  
  1.2949  \end{tabular}
  1.2950  
  1.2951 @@ -5707,7 +6161,7 @@ value of the field
  1.2952  \subsubsection{RPC name:~set\_device}
  1.2953  
  1.2954  {\bf Overview:} 
  1.2955 -set accessor message derived from field device of object VIF
  1.2956 +Set the device field of the given VIF.
  1.2957  
  1.2958   \noindent {\bf Signature:} 
  1.2959  \begin{verbatim} void set_device (session_id s, VIF ref self, string value)\end{verbatim}
  1.2960 @@ -5720,7 +6174,7 @@ set accessor message derived from field 
  1.2961  \begin{tabular}{|c|c|p{7cm}|}
  1.2962   \hline
  1.2963  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2964 -{\tt VIF ref } & self & object instance \\ \hline 
  1.2965 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.2966  
  1.2967  {\tt string } & value & New value to set \\ \hline 
  1.2968  
  1.2969 @@ -5741,7 +6195,7 @@ void
  1.2970  \subsubsection{RPC name:~get\_network}
  1.2971  
  1.2972  {\bf Overview:} 
  1.2973 -get accessor message derived from field network of object VIF
  1.2974 +Get the network field of the given VIF.
  1.2975  
  1.2976   \noindent {\bf Signature:} 
  1.2977  \begin{verbatim} (network ref) get_network (session_id s, VIF ref self)\end{verbatim}
  1.2978 @@ -5754,7 +6208,7 @@ get accessor message derived from field 
  1.2979  \begin{tabular}{|c|c|p{7cm}|}
  1.2980   \hline
  1.2981  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.2982 -{\tt VIF ref } & self & object instance \\ \hline 
  1.2983 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.2984  
  1.2985  \end{tabular}
  1.2986  
  1.2987 @@ -5773,7 +6227,7 @@ value of the field
  1.2988  \subsubsection{RPC name:~set\_network}
  1.2989  
  1.2990  {\bf Overview:} 
  1.2991 -set accessor message derived from field network of object VIF
  1.2992 +Set the network field of the given VIF.
  1.2993  
  1.2994   \noindent {\bf Signature:} 
  1.2995  \begin{verbatim} void set_network (session_id s, VIF ref self, network ref value)\end{verbatim}
  1.2996 @@ -5786,7 +6240,7 @@ set accessor message derived from field 
  1.2997  \begin{tabular}{|c|c|p{7cm}|}
  1.2998   \hline
  1.2999  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3000 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3001 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3002  
  1.3003  {\tt network ref } & value & New value to set \\ \hline 
  1.3004  
  1.3005 @@ -5807,7 +6261,7 @@ void
  1.3006  \subsubsection{RPC name:~get\_VM}
  1.3007  
  1.3008  {\bf Overview:} 
  1.3009 -get accessor message derived from field VM of object VIF
  1.3010 +Get the VM field of the given VIF.
  1.3011  
  1.3012   \noindent {\bf Signature:} 
  1.3013  \begin{verbatim} (VM ref) get_VM (session_id s, VIF ref self)\end{verbatim}
  1.3014 @@ -5820,7 +6274,7 @@ get accessor message derived from field 
  1.3015  \begin{tabular}{|c|c|p{7cm}|}
  1.3016   \hline
  1.3017  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3018 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3019 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3020  
  1.3021  \end{tabular}
  1.3022  
  1.3023 @@ -5839,7 +6293,7 @@ value of the field
  1.3024  \subsubsection{RPC name:~set\_VM}
  1.3025  
  1.3026  {\bf Overview:} 
  1.3027 -set accessor message derived from field VM of object VIF
  1.3028 +Set the VM field of the given VIF.
  1.3029  
  1.3030   \noindent {\bf Signature:} 
  1.3031  \begin{verbatim} void set_VM (session_id s, VIF ref self, VM ref value)\end{verbatim}
  1.3032 @@ -5852,7 +6306,7 @@ set accessor message derived from field 
  1.3033  \begin{tabular}{|c|c|p{7cm}|}
  1.3034   \hline
  1.3035  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3036 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3037 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3038  
  1.3039  {\tt VM ref } & value & New value to set \\ \hline 
  1.3040  
  1.3041 @@ -5873,7 +6327,7 @@ void
  1.3042  \subsubsection{RPC name:~get\_MAC}
  1.3043  
  1.3044  {\bf Overview:} 
  1.3045 -get accessor message derived from field MAC of object VIF
  1.3046 +Get the MAC field of the given VIF.
  1.3047  
  1.3048   \noindent {\bf Signature:} 
  1.3049  \begin{verbatim} string get_MAC (session_id s, VIF ref self)\end{verbatim}
  1.3050 @@ -5886,7 +6340,7 @@ get accessor message derived from field 
  1.3051  \begin{tabular}{|c|c|p{7cm}|}
  1.3052   \hline
  1.3053  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3054 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3055 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3056  
  1.3057  \end{tabular}
  1.3058  
  1.3059 @@ -5905,7 +6359,7 @@ value of the field
  1.3060  \subsubsection{RPC name:~set\_MAC}
  1.3061  
  1.3062  {\bf Overview:} 
  1.3063 -set accessor message derived from field MAC of object VIF
  1.3064 +Set the MAC field of the given VIF.
  1.3065  
  1.3066   \noindent {\bf Signature:} 
  1.3067  \begin{verbatim} void set_MAC (session_id s, VIF ref self, string value)\end{verbatim}
  1.3068 @@ -5918,7 +6372,7 @@ set accessor message derived from field 
  1.3069  \begin{tabular}{|c|c|p{7cm}|}
  1.3070   \hline
  1.3071  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3072 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3073 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3074  
  1.3075  {\tt string } & value & New value to set \\ \hline 
  1.3076  
  1.3077 @@ -5939,7 +6393,7 @@ void
  1.3078  \subsubsection{RPC name:~get\_MTU}
  1.3079  
  1.3080  {\bf Overview:} 
  1.3081 -get accessor message derived from field MTU of object VIF
  1.3082 +Get the MTU field of the given VIF.
  1.3083  
  1.3084   \noindent {\bf Signature:} 
  1.3085  \begin{verbatim} int get_MTU (session_id s, VIF ref self)\end{verbatim}
  1.3086 @@ -5952,7 +6406,7 @@ get accessor message derived from field 
  1.3087  \begin{tabular}{|c|c|p{7cm}|}
  1.3088   \hline
  1.3089  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3090 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3091 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3092  
  1.3093  \end{tabular}
  1.3094  
  1.3095 @@ -5971,7 +6425,7 @@ value of the field
  1.3096  \subsubsection{RPC name:~set\_MTU}
  1.3097  
  1.3098  {\bf Overview:} 
  1.3099 -set accessor message derived from field MTU of object VIF
  1.3100 +Set the MTU field of the given VIF.
  1.3101  
  1.3102   \noindent {\bf Signature:} 
  1.3103  \begin{verbatim} void set_MTU (session_id s, VIF ref self, int value)\end{verbatim}
  1.3104 @@ -5984,7 +6438,7 @@ set accessor message derived from field 
  1.3105  \begin{tabular}{|c|c|p{7cm}|}
  1.3106   \hline
  1.3107  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3108 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3109 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3110  
  1.3111  {\tt int } & value & New value to set \\ \hline 
  1.3112  
  1.3113 @@ -6005,7 +6459,7 @@ void
  1.3114  \subsubsection{RPC name:~get\_io\_read\_kbs}
  1.3115  
  1.3116  {\bf Overview:} 
  1.3117 -get accessor message derived from field io/read\_kbs of object VIF
  1.3118 +Get the io/read\_kbs field of the given VIF.
  1.3119  
  1.3120   \noindent {\bf Signature:} 
  1.3121  \begin{verbatim} float get_io_read_kbs (session_id s, VIF ref self)\end{verbatim}
  1.3122 @@ -6018,7 +6472,7 @@ get accessor message derived from field 
  1.3123  \begin{tabular}{|c|c|p{7cm}|}
  1.3124   \hline
  1.3125  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3126 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3127 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3128  
  1.3129  \end{tabular}
  1.3130  
  1.3131 @@ -6037,7 +6491,7 @@ value of the field
  1.3132  \subsubsection{RPC name:~get\_io\_write\_kbs}
  1.3133  
  1.3134  {\bf Overview:} 
  1.3135 -get accessor message derived from field io/write\_kbs of object VIF
  1.3136 +Get the io/write\_kbs field of the given VIF.
  1.3137  
  1.3138   \noindent {\bf Signature:} 
  1.3139  \begin{verbatim} float get_io_write_kbs (session_id s, VIF ref self)\end{verbatim}
  1.3140 @@ -6050,7 +6504,7 @@ get accessor message derived from field 
  1.3141  \begin{tabular}{|c|c|p{7cm}|}
  1.3142   \hline
  1.3143  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3144 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3145 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3146  
  1.3147  \end{tabular}
  1.3148  
  1.3149 @@ -6069,7 +6523,7 @@ value of the field
  1.3150  \subsubsection{RPC name:~create}
  1.3151  
  1.3152  {\bf Overview:} 
  1.3153 -constructor for class VIF
  1.3154 +Create a new VIF instance, and return its handle.
  1.3155  
  1.3156   \noindent {\bf Signature:} 
  1.3157  \begin{verbatim} (VIF ref) create (session_id s, VIF record args)\end{verbatim}
  1.3158 @@ -6101,7 +6555,7 @@ reference to the newly created object
  1.3159  \subsubsection{RPC name:~destroy}
  1.3160  
  1.3161  {\bf Overview:} 
  1.3162 -destructor for class VIF
  1.3163 +Destroy the specified VIF instance.
  1.3164  
  1.3165   \noindent {\bf Signature:} 
  1.3166  \begin{verbatim} void destroy (session_id s, VIF ref self)\end{verbatim}
  1.3167 @@ -6114,7 +6568,7 @@ destructor for class VIF
  1.3168  \begin{tabular}{|c|c|p{7cm}|}
  1.3169   \hline
  1.3170  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3171 -{\tt VIF ref } & self & object instance \\ \hline 
  1.3172 +{\tt VIF ref } & self & reference to the object \\ \hline 
  1.3173  
  1.3174  \end{tabular}
  1.3175  
  1.3176 @@ -6133,7 +6587,7 @@ void
  1.3177  \subsubsection{RPC name:~get\_by\_uuid}
  1.3178  
  1.3179  {\bf Overview:} 
  1.3180 -returns the VIF instance with a particular uuid
  1.3181 +Get a reference to the VIF instance with the specified UUID.
  1.3182  
  1.3183   \noindent {\bf Signature:} 
  1.3184  \begin{verbatim} (VIF ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.3185 @@ -6165,7 +6619,7 @@ reference to the object
  1.3186  \subsubsection{RPC name:~get\_record}
  1.3187  
  1.3188  {\bf Overview:} 
  1.3189 -returns a record containing the state of an instance of class VIF
  1.3190 +Get a record containing the current state of the given VIF.
  1.3191  
  1.3192   \noindent {\bf Signature:} 
  1.3193  \begin{verbatim} (VIF record) get_record (session_id s, VIF ref self)\end{verbatim}
  1.3194 @@ -6221,7 +6675,7 @@ Quals & Field & Type & Description \\
  1.3195  \subsubsection{RPC name:~get\_uuid}
  1.3196  
  1.3197  {\bf Overview:} 
  1.3198 -get accessor message derived from field uuid of object PIF
  1.3199 +Get the uuid field of the given PIF.
  1.3200  
  1.3201   \noindent {\bf Signature:} 
  1.3202  \begin{verbatim} string get_uuid (session_id s, PIF ref self)\end{verbatim}
  1.3203 @@ -6234,7 +6688,7 @@ get accessor message derived from field 
  1.3204  \begin{tabular}{|c|c|p{7cm}|}
  1.3205   \hline
  1.3206  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3207 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3208 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3209  
  1.3210  \end{tabular}
  1.3211  
  1.3212 @@ -6253,7 +6707,7 @@ value of the field
  1.3213  \subsubsection{RPC name:~get\_name}
  1.3214  
  1.3215  {\bf Overview:} 
  1.3216 -get accessor message derived from field name of object PIF
  1.3217 +Get the name field of the given PIF.
  1.3218  
  1.3219   \noindent {\bf Signature:} 
  1.3220  \begin{verbatim} string get_name (session_id s, PIF ref self)\end{verbatim}
  1.3221 @@ -6266,7 +6720,7 @@ get accessor message derived from field 
  1.3222  \begin{tabular}{|c|c|p{7cm}|}
  1.3223   \hline
  1.3224  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3225 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3226 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3227  
  1.3228  \end{tabular}
  1.3229  
  1.3230 @@ -6285,7 +6739,7 @@ value of the field
  1.3231  \subsubsection{RPC name:~set\_name}
  1.3232  
  1.3233  {\bf Overview:} 
  1.3234 -set accessor message derived from field name of object PIF
  1.3235 +Set the name field of the given PIF.
  1.3236  
  1.3237   \noindent {\bf Signature:} 
  1.3238  \begin{verbatim} void set_name (session_id s, PIF ref self, string value)\end{verbatim}
  1.3239 @@ -6298,7 +6752,7 @@ set accessor message derived from field 
  1.3240  \begin{tabular}{|c|c|p{7cm}|}
  1.3241   \hline
  1.3242  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3243 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3244 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3245  
  1.3246  {\tt string } & value & New value to set \\ \hline 
  1.3247  
  1.3248 @@ -6319,7 +6773,7 @@ void
  1.3249  \subsubsection{RPC name:~get\_network}
  1.3250  
  1.3251  {\bf Overview:} 
  1.3252 -get accessor message derived from field network of object PIF
  1.3253 +Get the network field of the given PIF.
  1.3254  
  1.3255   \noindent {\bf Signature:} 
  1.3256  \begin{verbatim} (network ref) get_network (session_id s, PIF ref self)\end{verbatim}
  1.3257 @@ -6332,7 +6786,7 @@ get accessor message derived from field 
  1.3258  \begin{tabular}{|c|c|p{7cm}|}
  1.3259   \hline
  1.3260  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3261 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3262 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3263  
  1.3264  \end{tabular}
  1.3265  
  1.3266 @@ -6351,7 +6805,7 @@ value of the field
  1.3267  \subsubsection{RPC name:~set\_network}
  1.3268  
  1.3269  {\bf Overview:} 
  1.3270 -set accessor message derived from field network of object PIF
  1.3271 +Set the network field of the given PIF.
  1.3272  
  1.3273   \noindent {\bf Signature:} 
  1.3274  \begin{verbatim} void set_network (session_id s, PIF ref self, network ref value)\end{verbatim}
  1.3275 @@ -6364,7 +6818,7 @@ set accessor message derived from field 
  1.3276  \begin{tabular}{|c|c|p{7cm}|}
  1.3277   \hline
  1.3278  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3279 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3280 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3281  
  1.3282  {\tt network ref } & value & New value to set \\ \hline 
  1.3283  
  1.3284 @@ -6385,7 +6839,7 @@ void
  1.3285  \subsubsection{RPC name:~get\_host}
  1.3286  
  1.3287  {\bf Overview:} 
  1.3288 -get accessor message derived from field host of object PIF
  1.3289 +Get the host field of the given PIF.
  1.3290  
  1.3291   \noindent {\bf Signature:} 
  1.3292  \begin{verbatim} (host ref) get_host (session_id s, PIF ref self)\end{verbatim}
  1.3293 @@ -6398,7 +6852,7 @@ get accessor message derived from field 
  1.3294  \begin{tabular}{|c|c|p{7cm}|}
  1.3295   \hline
  1.3296  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3297 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3298 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3299  
  1.3300  \end{tabular}
  1.3301  
  1.3302 @@ -6417,7 +6871,7 @@ value of the field
  1.3303  \subsubsection{RPC name:~set\_host}
  1.3304  
  1.3305  {\bf Overview:} 
  1.3306 -set accessor message derived from field host of object PIF
  1.3307 +Set the host field of the given PIF.
  1.3308  
  1.3309   \noindent {\bf Signature:} 
  1.3310  \begin{verbatim} void set_host (session_id s, PIF ref self, host ref value)\end{verbatim}
  1.3311 @@ -6430,7 +6884,7 @@ set accessor message derived from field 
  1.3312  \begin{tabular}{|c|c|p{7cm}|}
  1.3313   \hline
  1.3314  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3315 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3316 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3317  
  1.3318  {\tt host ref } & value & New value to set \\ \hline 
  1.3319  
  1.3320 @@ -6451,7 +6905,7 @@ void
  1.3321  \subsubsection{RPC name:~get\_MAC}
  1.3322  
  1.3323  {\bf Overview:} 
  1.3324 -get accessor message derived from field MAC of object PIF
  1.3325 +Get the MAC field of the given PIF.
  1.3326  
  1.3327   \noindent {\bf Signature:} 
  1.3328  \begin{verbatim} string get_MAC (session_id s, PIF ref self)\end{verbatim}
  1.3329 @@ -6464,7 +6918,7 @@ get accessor message derived from field 
  1.3330  \begin{tabular}{|c|c|p{7cm}|}
  1.3331   \hline
  1.3332  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3333 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3334 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3335  
  1.3336  \end{tabular}
  1.3337  
  1.3338 @@ -6483,7 +6937,7 @@ value of the field
  1.3339  \subsubsection{RPC name:~set\_MAC}
  1.3340  
  1.3341  {\bf Overview:} 
  1.3342 -set accessor message derived from field MAC of object PIF
  1.3343 +Set the MAC field of the given PIF.
  1.3344  
  1.3345   \noindent {\bf Signature:} 
  1.3346  \begin{verbatim} void set_MAC (session_id s, PIF ref self, string value)\end{verbatim}
  1.3347 @@ -6496,7 +6950,7 @@ set accessor message derived from field 
  1.3348  \begin{tabular}{|c|c|p{7cm}|}
  1.3349   \hline
  1.3350  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3351 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3352 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3353  
  1.3354  {\tt string } & value & New value to set \\ \hline 
  1.3355  
  1.3356 @@ -6517,7 +6971,7 @@ void
  1.3357  \subsubsection{RPC name:~get\_MTU}
  1.3358  
  1.3359  {\bf Overview:} 
  1.3360 -get accessor message derived from field MTU of object PIF
  1.3361 +Get the MTU field of the given PIF.
  1.3362  
  1.3363   \noindent {\bf Signature:} 
  1.3364  \begin{verbatim} int get_MTU (session_id s, PIF ref self)\end{verbatim}
  1.3365 @@ -6530,7 +6984,7 @@ get accessor message derived from field 
  1.3366  \begin{tabular}{|c|c|p{7cm}|}
  1.3367   \hline
  1.3368  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3369 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3370 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3371  
  1.3372  \end{tabular}
  1.3373  
  1.3374 @@ -6549,7 +7003,7 @@ value of the field
  1.3375  \subsubsection{RPC name:~set\_MTU}
  1.3376  
  1.3377  {\bf Overview:} 
  1.3378 -set accessor message derived from field MTU of object PIF
  1.3379 +Set the MTU field of the given PIF.
  1.3380  
  1.3381   \noindent {\bf Signature:} 
  1.3382  \begin{verbatim} void set_MTU (session_id s, PIF ref self, int value)\end{verbatim}
  1.3383 @@ -6562,7 +7016,7 @@ set accessor message derived from field 
  1.3384  \begin{tabular}{|c|c|p{7cm}|}
  1.3385   \hline
  1.3386  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3387 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3388 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3389  
  1.3390  {\tt int } & value & New value to set \\ \hline 
  1.3391  
  1.3392 @@ -6583,7 +7037,7 @@ void
  1.3393  \subsubsection{RPC name:~get\_VLAN}
  1.3394  
  1.3395  {\bf Overview:} 
  1.3396 -get accessor message derived from field VLAN of object PIF
  1.3397 +Get the VLAN field of the given PIF.
  1.3398  
  1.3399   \noindent {\bf Signature:} 
  1.3400  \begin{verbatim} string get_VLAN (session_id s, PIF ref self)\end{verbatim}
  1.3401 @@ -6596,7 +7050,7 @@ get accessor message derived from field 
  1.3402  \begin{tabular}{|c|c|p{7cm}|}
  1.3403   \hline
  1.3404  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3405 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3406 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3407  
  1.3408  \end{tabular}
  1.3409  
  1.3410 @@ -6615,7 +7069,7 @@ value of the field
  1.3411  \subsubsection{RPC name:~set\_VLAN}
  1.3412  
  1.3413  {\bf Overview:} 
  1.3414 -set accessor message derived from field VLAN of object PIF
  1.3415 +Set the VLAN field of the given PIF.
  1.3416  
  1.3417   \noindent {\bf Signature:} 
  1.3418  \begin{verbatim} void set_VLAN (session_id s, PIF ref self, string value)\end{verbatim}
  1.3419 @@ -6628,7 +7082,7 @@ set accessor message derived from field 
  1.3420  \begin{tabular}{|c|c|p{7cm}|}
  1.3421   \hline
  1.3422  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3423 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3424 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3425  
  1.3426  {\tt string } & value & New value to set \\ \hline 
  1.3427  
  1.3428 @@ -6649,7 +7103,7 @@ void
  1.3429  \subsubsection{RPC name:~get\_io\_read\_kbs}
  1.3430  
  1.3431  {\bf Overview:} 
  1.3432 -get accessor message derived from field io/read\_kbs of object PIF
  1.3433 +Get the io/read\_kbs field of the given PIF.
  1.3434  
  1.3435   \noindent {\bf Signature:} 
  1.3436  \begin{verbatim} float get_io_read_kbs (session_id s, PIF ref self)\end{verbatim}
  1.3437 @@ -6662,7 +7116,7 @@ get accessor message derived from field 
  1.3438  \begin{tabular}{|c|c|p{7cm}|}
  1.3439   \hline
  1.3440  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3441 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3442 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3443  
  1.3444  \end{tabular}
  1.3445  
  1.3446 @@ -6681,7 +7135,7 @@ value of the field
  1.3447  \subsubsection{RPC name:~get\_io\_write\_kbs}
  1.3448  
  1.3449  {\bf Overview:} 
  1.3450 -get accessor message derived from field io/write\_kbs of object PIF
  1.3451 +Get the io/write\_kbs field of the given PIF.
  1.3452  
  1.3453   \noindent {\bf Signature:} 
  1.3454  \begin{verbatim} float get_io_write_kbs (session_id s, PIF ref self)\end{verbatim}
  1.3455 @@ -6694,7 +7148,7 @@ get accessor message derived from field 
  1.3456  \begin{tabular}{|c|c|p{7cm}|}
  1.3457   \hline
  1.3458  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3459 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3460 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3461  
  1.3462  \end{tabular}
  1.3463  
  1.3464 @@ -6713,7 +7167,7 @@ value of the field
  1.3465  \subsubsection{RPC name:~create}
  1.3466  
  1.3467  {\bf Overview:} 
  1.3468 -constructor for class PIF
  1.3469 +Create a new PIF instance, and return its handle.
  1.3470  
  1.3471   \noindent {\bf Signature:} 
  1.3472  \begin{verbatim} (PIF ref) create (session_id s, PIF record args)\end{verbatim}
  1.3473 @@ -6745,7 +7199,7 @@ reference to the newly created object
  1.3474  \subsubsection{RPC name:~destroy}
  1.3475  
  1.3476  {\bf Overview:} 
  1.3477 -destructor for class PIF
  1.3478 +Destroy the specified PIF instance.
  1.3479  
  1.3480   \noindent {\bf Signature:} 
  1.3481  \begin{verbatim} void destroy (session_id s, PIF ref self)\end{verbatim}
  1.3482 @@ -6758,7 +7212,7 @@ destructor for class PIF
  1.3483  \begin{tabular}{|c|c|p{7cm}|}
  1.3484   \hline
  1.3485  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3486 -{\tt PIF ref } & self & object instance \\ \hline 
  1.3487 +{\tt PIF ref } & self & reference to the object \\ \hline 
  1.3488  
  1.3489  \end{tabular}
  1.3490  
  1.3491 @@ -6777,7 +7231,7 @@ void
  1.3492  \subsubsection{RPC name:~get\_by\_uuid}
  1.3493  
  1.3494  {\bf Overview:} 
  1.3495 -returns the PIF instance with a particular uuid
  1.3496 +Get a reference to the PIF instance with the specified UUID.
  1.3497  
  1.3498   \noindent {\bf Signature:} 
  1.3499  \begin{verbatim} (PIF ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.3500 @@ -6809,7 +7263,7 @@ reference to the object
  1.3501  \subsubsection{RPC name:~get\_record}
  1.3502  
  1.3503  {\bf Overview:} 
  1.3504 -returns a record containing the state of an instance of class PIF
  1.3505 +Get a record containing the current state of the given PIF.
  1.3506  
  1.3507   \noindent {\bf Signature:} 
  1.3508  \begin{verbatim} (PIF record) get_record (session_id s, PIF ref self)\end{verbatim}
  1.3509 @@ -6923,7 +7377,7 @@ A list of all the IDs of all the Storage
  1.3510  \subsubsection{RPC name:~get\_uuid}
  1.3511  
  1.3512  {\bf Overview:} 
  1.3513 -get accessor message derived from field uuid of object SR
  1.3514 +Get the uuid field of the given SR.
  1.3515  
  1.3516   \noindent {\bf Signature:} 
  1.3517  \begin{verbatim} string get_uuid (session_id s, SR ref self)\end{verbatim}
  1.3518 @@ -6936,7 +7390,7 @@ get accessor message derived from field 
  1.3519  \begin{tabular}{|c|c|p{7cm}|}
  1.3520   \hline
  1.3521  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3522 -{\tt SR ref } & self & object instance \\ \hline 
  1.3523 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3524  
  1.3525  \end{tabular}
  1.3526  
  1.3527 @@ -6955,7 +7409,7 @@ value of the field
  1.3528  \subsubsection{RPC name:~get\_name\_label}
  1.3529  
  1.3530  {\bf Overview:} 
  1.3531 -get accessor message derived from field name/label of object SR
  1.3532 +Get the name/label field of the given SR.
  1.3533  
  1.3534   \noindent {\bf Signature:} 
  1.3535  \begin{verbatim} string get_name_label (session_id s, SR ref self)\end{verbatim}
  1.3536 @@ -6968,7 +7422,7 @@ get accessor message derived from field 
  1.3537  \begin{tabular}{|c|c|p{7cm}|}
  1.3538   \hline
  1.3539  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3540 -{\tt SR ref } & self & object instance \\ \hline 
  1.3541 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3542  
  1.3543  \end{tabular}
  1.3544  
  1.3545 @@ -6987,7 +7441,7 @@ value of the field
  1.3546  \subsubsection{RPC name:~set\_name\_label}
  1.3547  
  1.3548  {\bf Overview:} 
  1.3549 -set accessor message derived from field name/label of object SR
  1.3550 +Set the name/label field of the given SR.
  1.3551  
  1.3552   \noindent {\bf Signature:} 
  1.3553  \begin{verbatim} void set_name_label (session_id s, SR ref self, string value)\end{verbatim}
  1.3554 @@ -7000,7 +7454,7 @@ set accessor message derived from field 
  1.3555  \begin{tabular}{|c|c|p{7cm}|}
  1.3556   \hline
  1.3557  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3558 -{\tt SR ref } & self & object instance \\ \hline 
  1.3559 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3560  
  1.3561  {\tt string } & value & New value to set \\ \hline 
  1.3562  
  1.3563 @@ -7021,7 +7475,7 @@ void
  1.3564  \subsubsection{RPC name:~get\_name\_description}
  1.3565  
  1.3566  {\bf Overview:} 
  1.3567 -get accessor message derived from field name/description of object SR
  1.3568 +Get the name/description field of the given SR.
  1.3569  
  1.3570   \noindent {\bf Signature:} 
  1.3571  \begin{verbatim} string get_name_description (session_id s, SR ref self)\end{verbatim}
  1.3572 @@ -7034,7 +7488,7 @@ get accessor message derived from field 
  1.3573  \begin{tabular}{|c|c|p{7cm}|}
  1.3574   \hline
  1.3575  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3576 -{\tt SR ref } & self & object instance \\ \hline 
  1.3577 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3578  
  1.3579  \end{tabular}
  1.3580  
  1.3581 @@ -7053,7 +7507,7 @@ value of the field
  1.3582  \subsubsection{RPC name:~set\_name\_description}
  1.3583  
  1.3584  {\bf Overview:} 
  1.3585 -set accessor message derived from field name/description of object SR
  1.3586 +Set the name/description field of the given SR.
  1.3587  
  1.3588   \noindent {\bf Signature:} 
  1.3589  \begin{verbatim} void set_name_description (session_id s, SR ref self, string value)\end{verbatim}
  1.3590 @@ -7066,7 +7520,7 @@ set accessor message derived from field 
  1.3591  \begin{tabular}{|c|c|p{7cm}|}
  1.3592   \hline
  1.3593  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3594 -{\tt SR ref } & self & object instance \\ \hline 
  1.3595 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3596  
  1.3597  {\tt string } & value & New value to set \\ \hline 
  1.3598  
  1.3599 @@ -7087,7 +7541,7 @@ void
  1.3600  \subsubsection{RPC name:~get\_VDIs}
  1.3601  
  1.3602  {\bf Overview:} 
  1.3603 -get accessor message derived from field VDIs of object SR
  1.3604 +Get the VDIs field of the given SR.
  1.3605  
  1.3606   \noindent {\bf Signature:} 
  1.3607  \begin{verbatim} ((VDI ref) Set) get_VDIs (session_id s, SR ref self)\end{verbatim}
  1.3608 @@ -7100,7 +7554,7 @@ get accessor message derived from field 
  1.3609  \begin{tabular}{|c|c|p{7cm}|}
  1.3610   \hline
  1.3611  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3612 -{\tt SR ref } & self & object instance \\ \hline 
  1.3613 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3614  
  1.3615  \end{tabular}
  1.3616  
  1.3617 @@ -7119,7 +7573,7 @@ value of the field
  1.3618  \subsubsection{RPC name:~get\_virtual\_allocation}
  1.3619  
  1.3620  {\bf Overview:} 
  1.3621 -get accessor message derived from field virtual\_allocation of object SR
  1.3622 +Get the virtual\_allocation field of the given SR.
  1.3623  
  1.3624   \noindent {\bf Signature:} 
  1.3625  \begin{verbatim} int get_virtual_allocation (session_id s, SR ref self)\end{verbatim}
  1.3626 @@ -7132,7 +7586,7 @@ get accessor message derived from field 
  1.3627  \begin{tabular}{|c|c|p{7cm}|}
  1.3628   \hline
  1.3629  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3630 -{\tt SR ref } & self & object instance \\ \hline 
  1.3631 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3632  
  1.3633  \end{tabular}
  1.3634  
  1.3635 @@ -7151,7 +7605,7 @@ value of the field
  1.3636  \subsubsection{RPC name:~get\_physical\_utilisation}
  1.3637  
  1.3638  {\bf Overview:} 
  1.3639 -get accessor message derived from field physical\_utilisation of object SR
  1.3640 +Get the physical\_utilisation field of the given SR.
  1.3641  
  1.3642   \noindent {\bf Signature:} 
  1.3643  \begin{verbatim} int get_physical_utilisation (session_id s, SR ref self)\end{verbatim}
  1.3644 @@ -7164,7 +7618,7 @@ get accessor message derived from field 
  1.3645  \begin{tabular}{|c|c|p{7cm}|}
  1.3646   \hline
  1.3647  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3648 -{\tt SR ref } & self & object instance \\ \hline 
  1.3649 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3650  
  1.3651  \end{tabular}
  1.3652  
  1.3653 @@ -7183,7 +7637,7 @@ value of the field
  1.3654  \subsubsection{RPC name:~get\_physical\_size}
  1.3655  
  1.3656  {\bf Overview:} 
  1.3657 -get accessor message derived from field physical\_size of object SR
  1.3658 +Get the physical\_size field of the given SR.
  1.3659  
  1.3660   \noindent {\bf Signature:} 
  1.3661  \begin{verbatim} int get_physical_size (session_id s, SR ref self)\end{verbatim}
  1.3662 @@ -7196,7 +7650,7 @@ get accessor message derived from field 
  1.3663  \begin{tabular}{|c|c|p{7cm}|}
  1.3664   \hline
  1.3665  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3666 -{\tt SR ref } & self & object instance \\ \hline 
  1.3667 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3668  
  1.3669  \end{tabular}
  1.3670  
  1.3671 @@ -7215,7 +7669,7 @@ value of the field
  1.3672  \subsubsection{RPC name:~get\_type}
  1.3673  
  1.3674  {\bf Overview:} 
  1.3675 -get accessor message derived from field type of object SR
  1.3676 +Get the type field of the given SR.
  1.3677  
  1.3678   \noindent {\bf Signature:} 
  1.3679  \begin{verbatim} string get_type (session_id s, SR ref self)\end{verbatim}
  1.3680 @@ -7228,7 +7682,7 @@ get accessor message derived from field 
  1.3681  \begin{tabular}{|c|c|p{7cm}|}
  1.3682   \hline
  1.3683  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3684 -{\tt SR ref } & self & object instance \\ \hline 
  1.3685 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3686  
  1.3687  \end{tabular}
  1.3688  
  1.3689 @@ -7247,7 +7701,7 @@ value of the field
  1.3690  \subsubsection{RPC name:~get\_location}
  1.3691  
  1.3692  {\bf Overview:} 
  1.3693 -get accessor message derived from field location of object SR
  1.3694 +Get the location field of the given SR.
  1.3695  
  1.3696   \noindent {\bf Signature:} 
  1.3697  \begin{verbatim} string get_location (session_id s, SR ref self)\end{verbatim}
  1.3698 @@ -7260,7 +7714,7 @@ get accessor message derived from field 
  1.3699  \begin{tabular}{|c|c|p{7cm}|}
  1.3700   \hline
  1.3701  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3702 -{\tt SR ref } & self & object instance \\ \hline 
  1.3703 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3704  
  1.3705  \end{tabular}
  1.3706  
  1.3707 @@ -7279,7 +7733,7 @@ value of the field
  1.3708  \subsubsection{RPC name:~create}
  1.3709  
  1.3710  {\bf Overview:} 
  1.3711 -constructor for class SR
  1.3712 +Create a new SR instance, and return its handle.
  1.3713  
  1.3714   \noindent {\bf Signature:} 
  1.3715  \begin{verbatim} (SR ref) create (session_id s, SR record args)\end{verbatim}
  1.3716 @@ -7311,7 +7765,7 @@ reference to the newly created object
  1.3717  \subsubsection{RPC name:~destroy}
  1.3718  
  1.3719  {\bf Overview:} 
  1.3720 -destructor for class SR
  1.3721 +Destroy the specified SR instance.
  1.3722  
  1.3723   \noindent {\bf Signature:} 
  1.3724  \begin{verbatim} void destroy (session_id s, SR ref self)\end{verbatim}
  1.3725 @@ -7324,7 +7778,7 @@ destructor for class SR
  1.3726  \begin{tabular}{|c|c|p{7cm}|}
  1.3727   \hline
  1.3728  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3729 -{\tt SR ref } & self & object instance \\ \hline 
  1.3730 +{\tt SR ref } & self & reference to the object \\ \hline 
  1.3731  
  1.3732  \end{tabular}
  1.3733  
  1.3734 @@ -7343,7 +7797,7 @@ void
  1.3735  \subsubsection{RPC name:~get\_by\_uuid}
  1.3736  
  1.3737  {\bf Overview:} 
  1.3738 -returns the SR instance with a particular uuid
  1.3739 +Get a reference to the SR instance with the specified UUID.
  1.3740  
  1.3741   \noindent {\bf Signature:} 
  1.3742  \begin{verbatim} (SR ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.3743 @@ -7375,7 +7829,7 @@ reference to the object
  1.3744  \subsubsection{RPC name:~get\_record}
  1.3745  
  1.3746  {\bf Overview:} 
  1.3747 -returns a record containing the state of an instance of class SR
  1.3748 +Get a record containing the current state of the given SR.
  1.3749  
  1.3750   \noindent {\bf Signature:} 
  1.3751  \begin{verbatim} (SR record) get_record (session_id s, SR ref self)\end{verbatim}
  1.3752 @@ -7407,7 +7861,7 @@ all fields from the object
  1.3753  \subsubsection{RPC name:~get\_by\_name\_label}
  1.3754  
  1.3755  {\bf Overview:} 
  1.3756 -returns the SR instance with a particular name label
  1.3757 +Get all the SR instances with the given label.
  1.3758  
  1.3759   \noindent {\bf Signature:} 
  1.3760  \begin{verbatim} ((SR ref) Set) get_by_name_label (session_id s, string label)\end{verbatim}
  1.3761 @@ -7533,7 +7987,7 @@ void
  1.3762  \subsubsection{RPC name:~get\_uuid}
  1.3763  
  1.3764  {\bf Overview:} 
  1.3765 -get accessor message derived from field uuid of object VDI
  1.3766 +Get the uuid field of the given VDI.
  1.3767  
  1.3768   \noindent {\bf Signature:} 
  1.3769  \begin{verbatim} string get_uuid (session_id s, VDI ref self)\end{verbatim}
  1.3770 @@ -7546,7 +8000,7 @@ get accessor message derived from field 
  1.3771  \begin{tabular}{|c|c|p{7cm}|}
  1.3772   \hline
  1.3773  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3774 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3775 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3776  
  1.3777  \end{tabular}
  1.3778  
  1.3779 @@ -7565,7 +8019,7 @@ value of the field
  1.3780  \subsubsection{RPC name:~get\_name\_label}
  1.3781  
  1.3782  {\bf Overview:} 
  1.3783 -get accessor message derived from field name/label of object VDI
  1.3784 +Get the name/label field of the given VDI.
  1.3785  
  1.3786   \noindent {\bf Signature:} 
  1.3787  \begin{verbatim} string get_name_label (session_id s, VDI ref self)\end{verbatim}
  1.3788 @@ -7578,7 +8032,7 @@ get accessor message derived from field 
  1.3789  \begin{tabular}{|c|c|p{7cm}|}
  1.3790   \hline
  1.3791  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3792 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3793 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3794  
  1.3795  \end{tabular}
  1.3796  
  1.3797 @@ -7597,7 +8051,7 @@ value of the field
  1.3798  \subsubsection{RPC name:~set\_name\_label}
  1.3799  
  1.3800  {\bf Overview:} 
  1.3801 -set accessor message derived from field name/label of object VDI
  1.3802 +Set the name/label field of the given VDI.
  1.3803  
  1.3804   \noindent {\bf Signature:} 
  1.3805  \begin{verbatim} void set_name_label (session_id s, VDI ref self, string value)\end{verbatim}
  1.3806 @@ -7610,7 +8064,7 @@ set accessor message derived from field 
  1.3807  \begin{tabular}{|c|c|p{7cm}|}
  1.3808   \hline
  1.3809  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3810 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3811 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3812  
  1.3813  {\tt string } & value & New value to set \\ \hline 
  1.3814  
  1.3815 @@ -7631,7 +8085,7 @@ void
  1.3816  \subsubsection{RPC name:~get\_name\_description}
  1.3817  
  1.3818  {\bf Overview:} 
  1.3819 -get accessor message derived from field name/description of object VDI
  1.3820 +Get the name/description field of the given VDI.
  1.3821  
  1.3822   \noindent {\bf Signature:} 
  1.3823  \begin{verbatim} string get_name_description (session_id s, VDI ref self)\end{verbatim}
  1.3824 @@ -7644,7 +8098,7 @@ get accessor message derived from field 
  1.3825  \begin{tabular}{|c|c|p{7cm}|}
  1.3826   \hline
  1.3827  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3828 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3829 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3830  
  1.3831  \end{tabular}
  1.3832  
  1.3833 @@ -7663,7 +8117,7 @@ value of the field
  1.3834  \subsubsection{RPC name:~set\_name\_description}
  1.3835  
  1.3836  {\bf Overview:} 
  1.3837 -set accessor message derived from field name/description of object VDI
  1.3838 +Set the name/description field of the given VDI.
  1.3839  
  1.3840   \noindent {\bf Signature:} 
  1.3841  \begin{verbatim} void set_name_description (session_id s, VDI ref self, string value)\end{verbatim}
  1.3842 @@ -7676,7 +8130,7 @@ set accessor message derived from field 
  1.3843  \begin{tabular}{|c|c|p{7cm}|}
  1.3844   \hline
  1.3845  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3846 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3847 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3848  
  1.3849  {\tt string } & value & New value to set \\ \hline 
  1.3850  
  1.3851 @@ -7697,7 +8151,7 @@ void
  1.3852  \subsubsection{RPC name:~get\_SR}
  1.3853  
  1.3854  {\bf Overview:} 
  1.3855 -get accessor message derived from field SR of object VDI
  1.3856 +Get the SR field of the given VDI.
  1.3857  
  1.3858   \noindent {\bf Signature:} 
  1.3859  \begin{verbatim} (SR ref) get_SR (session_id s, VDI ref self)\end{verbatim}
  1.3860 @@ -7710,7 +8164,7 @@ get accessor message derived from field 
  1.3861  \begin{tabular}{|c|c|p{7cm}|}
  1.3862   \hline
  1.3863  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3864 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3865 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3866  
  1.3867  \end{tabular}
  1.3868  
  1.3869 @@ -7729,7 +8183,7 @@ value of the field
  1.3870  \subsubsection{RPC name:~set\_SR}
  1.3871  
  1.3872  {\bf Overview:} 
  1.3873 -set accessor message derived from field SR of object VDI
  1.3874 +Set the SR field of the given VDI.
  1.3875  
  1.3876   \noindent {\bf Signature:} 
  1.3877  \begin{verbatim} void set_SR (session_id s, VDI ref self, SR ref value)\end{verbatim}
  1.3878 @@ -7742,7 +8196,7 @@ set accessor message derived from field 
  1.3879  \begin{tabular}{|c|c|p{7cm}|}
  1.3880   \hline
  1.3881  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3882 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3883 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3884  
  1.3885  {\tt SR ref } & value & New value to set \\ \hline 
  1.3886  
  1.3887 @@ -7763,7 +8217,7 @@ void
  1.3888  \subsubsection{RPC name:~get\_VBDs}
  1.3889  
  1.3890  {\bf Overview:} 
  1.3891 -get accessor message derived from field VBDs of object VDI
  1.3892 +Get the VBDs field of the given VDI.
  1.3893  
  1.3894   \noindent {\bf Signature:} 
  1.3895  \begin{verbatim} ((VBD ref) Set) get_VBDs (session_id s, VDI ref self)\end{verbatim}
  1.3896 @@ -7776,7 +8230,7 @@ get accessor message derived from field 
  1.3897  \begin{tabular}{|c|c|p{7cm}|}
  1.3898   \hline
  1.3899  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3900 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3901 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3902  
  1.3903  \end{tabular}
  1.3904  
  1.3905 @@ -7795,7 +8249,7 @@ value of the field
  1.3906  \subsubsection{RPC name:~get\_virtual\_size}
  1.3907  
  1.3908  {\bf Overview:} 
  1.3909 -get accessor message derived from field virtual\_size of object VDI
  1.3910 +Get the virtual\_size field of the given VDI.
  1.3911  
  1.3912   \noindent {\bf Signature:} 
  1.3913  \begin{verbatim} int get_virtual_size (session_id s, VDI ref self)\end{verbatim}
  1.3914 @@ -7808,7 +8262,7 @@ get accessor message derived from field 
  1.3915  \begin{tabular}{|c|c|p{7cm}|}
  1.3916   \hline
  1.3917  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3918 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3919 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3920  
  1.3921  \end{tabular}
  1.3922  
  1.3923 @@ -7827,7 +8281,7 @@ value of the field
  1.3924  \subsubsection{RPC name:~set\_virtual\_size}
  1.3925  
  1.3926  {\bf Overview:} 
  1.3927 -set accessor message derived from field virtual\_size of object VDI
  1.3928 +Set the virtual\_size field of the given VDI.
  1.3929  
  1.3930   \noindent {\bf Signature:} 
  1.3931  \begin{verbatim} void set_virtual_size (session_id s, VDI ref self, int value)\end{verbatim}
  1.3932 @@ -7840,7 +8294,7 @@ set accessor message derived from field 
  1.3933  \begin{tabular}{|c|c|p{7cm}|}
  1.3934   \hline
  1.3935  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3936 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3937 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3938  
  1.3939  {\tt int } & value & New value to set \\ \hline 
  1.3940  
  1.3941 @@ -7861,7 +8315,7 @@ void
  1.3942  \subsubsection{RPC name:~get\_physical\_utilisation}
  1.3943  
  1.3944  {\bf Overview:} 
  1.3945 -get accessor message derived from field physical\_utilisation of object VDI
  1.3946 +Get the physical\_utilisation field of the given VDI.
  1.3947  
  1.3948   \noindent {\bf Signature:} 
  1.3949  \begin{verbatim} int get_physical_utilisation (session_id s, VDI ref self)\end{verbatim}
  1.3950 @@ -7874,7 +8328,7 @@ get accessor message derived from field 
  1.3951  \begin{tabular}{|c|c|p{7cm}|}
  1.3952   \hline
  1.3953  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3954 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3955 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3956  
  1.3957  \end{tabular}
  1.3958  
  1.3959 @@ -7893,7 +8347,7 @@ value of the field
  1.3960  \subsubsection{RPC name:~get\_sector\_size}
  1.3961  
  1.3962  {\bf Overview:} 
  1.3963 -get accessor message derived from field sector\_size of object VDI
  1.3964 +Get the sector\_size field of the given VDI.
  1.3965  
  1.3966   \noindent {\bf Signature:} 
  1.3967  \begin{verbatim} int get_sector_size (session_id s, VDI ref self)\end{verbatim}
  1.3968 @@ -7906,7 +8360,7 @@ get accessor message derived from field 
  1.3969  \begin{tabular}{|c|c|p{7cm}|}
  1.3970   \hline
  1.3971  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3972 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3973 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3974  
  1.3975  \end{tabular}
  1.3976  
  1.3977 @@ -7925,7 +8379,7 @@ value of the field
  1.3978  \subsubsection{RPC name:~get\_type}
  1.3979  
  1.3980  {\bf Overview:} 
  1.3981 -get accessor message derived from field type of object VDI
  1.3982 +Get the type field of the given VDI.
  1.3983  
  1.3984   \noindent {\bf Signature:} 
  1.3985  \begin{verbatim} (vdi_type) get_type (session_id s, VDI ref self)\end{verbatim}
  1.3986 @@ -7938,7 +8392,7 @@ get accessor message derived from field 
  1.3987  \begin{tabular}{|c|c|p{7cm}|}
  1.3988   \hline
  1.3989  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.3990 -{\tt VDI ref } & self & object instance \\ \hline 
  1.3991 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.3992  
  1.3993  \end{tabular}
  1.3994  
  1.3995 @@ -7957,7 +8411,7 @@ value of the field
  1.3996  \subsubsection{RPC name:~get\_parent}
  1.3997  
  1.3998  {\bf Overview:} 
  1.3999 -get accessor message derived from field parent of object VDI
  1.4000 +Get the parent field of the given VDI.
  1.4001  
  1.4002   \noindent {\bf Signature:} 
  1.4003  \begin{verbatim} (VDI ref) get_parent (session_id s, VDI ref self)\end{verbatim}
  1.4004 @@ -7970,7 +8424,7 @@ get accessor message derived from field 
  1.4005  \begin{tabular}{|c|c|p{7cm}|}
  1.4006   \hline
  1.4007  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4008 -{\tt VDI ref } & self & object instance \\ \hline 
  1.4009 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.4010  
  1.4011  \end{tabular}
  1.4012  
  1.4013 @@ -7989,7 +8443,7 @@ value of the field
  1.4014  \subsubsection{RPC name:~get\_children}
  1.4015  
  1.4016  {\bf Overview:} 
  1.4017 -get accessor message derived from field children of object VDI
  1.4018 +Get the children field of the given VDI.
  1.4019  
  1.4020   \noindent {\bf Signature:} 
  1.4021  \begin{verbatim} ((VDI ref) Set) get_children (session_id s, VDI ref self)\end{verbatim}
  1.4022 @@ -8002,7 +8456,7 @@ get accessor message derived from field 
  1.4023  \begin{tabular}{|c|c|p{7cm}|}
  1.4024   \hline
  1.4025  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4026 -{\tt VDI ref } & self & object instance \\ \hline 
  1.4027 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.4028  
  1.4029  \end{tabular}
  1.4030  
  1.4031 @@ -8021,7 +8475,7 @@ value of the field
  1.4032  \subsubsection{RPC name:~get\_sharable}
  1.4033  
  1.4034  {\bf Overview:} 
  1.4035 -get accessor message derived from field sharable of object VDI
  1.4036 +Get the sharable field of the given VDI.
  1.4037  
  1.4038   \noindent {\bf Signature:} 
  1.4039  \begin{verbatim} bool get_sharable (session_id s, VDI ref self)\end{verbatim}
  1.4040 @@ -8034,7 +8488,7 @@ get accessor message derived from field 
  1.4041  \begin{tabular}{|c|c|p{7cm}|}
  1.4042   \hline
  1.4043  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4044 -{\tt VDI ref } & self & object instance \\ \hline 
  1.4045 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.4046  
  1.4047  \end{tabular}
  1.4048  
  1.4049 @@ -8053,7 +8507,7 @@ value of the field
  1.4050  \subsubsection{RPC name:~set\_sharable}
  1.4051  
  1.4052  {\bf Overview:} 
  1.4053 -set accessor message derived from field sharable of object VDI
  1.4054 +Set the sharable field of the given VDI.
  1.4055  
  1.4056   \noindent {\bf Signature:} 
  1.4057  \begin{verbatim} void set_sharable (session_id s, VDI ref self, bool value)\end{verbatim}
  1.4058 @@ -8066,7 +8520,7 @@ set accessor message derived from field 
  1.4059  \begin{tabular}{|c|c|p{7cm}|}
  1.4060   \hline
  1.4061  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4062 -{\tt VDI ref } & self & object instance \\ \hline 
  1.4063 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.4064  
  1.4065  {\tt bool } & value & New value to set \\ \hline 
  1.4066  
  1.4067 @@ -8087,7 +8541,7 @@ void
  1.4068  \subsubsection{RPC name:~get\_read\_only}
  1.4069  
  1.4070  {\bf Overview:} 
  1.4071 -get accessor message derived from field read\_only of object VDI
  1.4072 +Get the read\_only field of the given VDI.
  1.4073  
  1.4074   \noindent {\bf Signature:} 
  1.4075  \begin{verbatim} bool get_read_only (session_id s, VDI ref self)\end{verbatim}
  1.4076 @@ -8100,7 +8554,7 @@ get accessor message derived from field 
  1.4077  \begin{tabular}{|c|c|p{7cm}|}
  1.4078   \hline
  1.4079  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4080 -{\tt VDI ref } & self & object instance \\ \hline 
  1.4081 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.4082  
  1.4083  \end{tabular}
  1.4084  
  1.4085 @@ -8119,7 +8573,7 @@ value of the field
  1.4086  \subsubsection{RPC name:~set\_read\_only}
  1.4087  
  1.4088  {\bf Overview:} 
  1.4089 -set accessor message derived from field read\_only of object VDI
  1.4090 +Set the read\_only field of the given VDI.
  1.4091  
  1.4092   \noindent {\bf Signature:} 
  1.4093  \begin{verbatim} void set_read_only (session_id s, VDI ref self, bool value)\end{verbatim}
  1.4094 @@ -8132,7 +8586,7 @@ set accessor message derived from field 
  1.4095  \begin{tabular}{|c|c|p{7cm}|}
  1.4096   \hline
  1.4097  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4098 -{\tt VDI ref } & self & object instance \\ \hline 
  1.4099 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.4100  
  1.4101  {\tt bool } & value & New value to set \\ \hline 
  1.4102  
  1.4103 @@ -8153,7 +8607,7 @@ void
  1.4104  \subsubsection{RPC name:~create}
  1.4105  
  1.4106  {\bf Overview:} 
  1.4107 -constructor for class VDI
  1.4108 +Create a new VDI instance, and return its handle.
  1.4109  
  1.4110   \noindent {\bf Signature:} 
  1.4111  \begin{verbatim} (VDI ref) create (session_id s, VDI record args)\end{verbatim}
  1.4112 @@ -8185,7 +8639,7 @@ reference to the newly created object
  1.4113  \subsubsection{RPC name:~destroy}
  1.4114  
  1.4115  {\bf Overview:} 
  1.4116 -destructor for class VDI
  1.4117 +Destroy the specified VDI instance.
  1.4118  
  1.4119   \noindent {\bf Signature:} 
  1.4120  \begin{verbatim} void destroy (session_id s, VDI ref self)\end{verbatim}
  1.4121 @@ -8198,7 +8652,7 @@ destructor for class VDI
  1.4122  \begin{tabular}{|c|c|p{7cm}|}
  1.4123   \hline
  1.4124  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4125 -{\tt VDI ref } & self & object instance \\ \hline 
  1.4126 +{\tt VDI ref } & self & reference to the object \\ \hline 
  1.4127  
  1.4128  \end{tabular}
  1.4129  
  1.4130 @@ -8217,7 +8671,7 @@ void
  1.4131  \subsubsection{RPC name:~get\_by\_uuid}
  1.4132  
  1.4133  {\bf Overview:} 
  1.4134 -returns the VDI instance with a particular uuid
  1.4135 +Get a reference to the VDI instance with the specified UUID.
  1.4136  
  1.4137   \noindent {\bf Signature:} 
  1.4138  \begin{verbatim} (VDI ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.4139 @@ -8249,7 +8703,7 @@ reference to the object
  1.4140  \subsubsection{RPC name:~get\_record}
  1.4141  
  1.4142  {\bf Overview:} 
  1.4143 -returns a record containing the state of an instance of class VDI
  1.4144 +Get a record containing the current state of the given VDI.
  1.4145  
  1.4146   \noindent {\bf Signature:} 
  1.4147  \begin{verbatim} (VDI record) get_record (session_id s, VDI ref self)\end{verbatim}
  1.4148 @@ -8281,7 +8735,7 @@ all fields from the object
  1.4149  \subsubsection{RPC name:~get\_by\_name\_label}
  1.4150  
  1.4151  {\bf Overview:} 
  1.4152 -returns the VDI instance with a particular name label
  1.4153 +Get all the VDI instances with the given label.
  1.4154  
  1.4155   \noindent {\bf Signature:} 
  1.4156  \begin{verbatim} ((VDI ref) Set) get_by_name_label (session_id s, string label)\end{verbatim}
  1.4157 @@ -8327,6 +8781,7 @@ Quals & Field & Type & Description \\
  1.4158  $\mathit{RW}$ &  {\tt VDI} & VDI ref & the virtual disk \\
  1.4159  $\mathit{RW}$ &  {\tt device} & string & device seen by the guest e.g. hda1 \\
  1.4160  $\mathit{RW}$ &  {\tt mode} & vbd\_mode & the mode the disk should be mounted with \\
  1.4161 +$\mathit{RW}$ &  {\tt type} & vbd\_type & how the VBD will appear to the guest (e.g. disk or CD) \\
  1.4162  $\mathit{RW}$ &  {\tt driver} & driver\_type & the style of driver \\
  1.4163  $\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
  1.4164  $\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
  1.4165 @@ -8370,7 +8825,7 @@ void
  1.4166  \subsubsection{RPC name:~get\_uuid}
  1.4167  
  1.4168  {\bf Overview:} 
  1.4169 -get accessor message derived from field uuid of object VBD
  1.4170 +Get the uuid field of the given VBD.
  1.4171  
  1.4172   \noindent {\bf Signature:} 
  1.4173  \begin{verbatim} string get_uuid (session_id s, VBD ref self)\end{verbatim}
  1.4174 @@ -8383,7 +8838,7 @@ get accessor message derived from field 
  1.4175  \begin{tabular}{|c|c|p{7cm}|}
  1.4176   \hline
  1.4177  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4178 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4179 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4180  
  1.4181  \end{tabular}
  1.4182  
  1.4183 @@ -8402,7 +8857,7 @@ value of the field
  1.4184  \subsubsection{RPC name:~get\_VM}
  1.4185  
  1.4186  {\bf Overview:} 
  1.4187 -get accessor message derived from field VM of object VBD
  1.4188 +Get the VM field of the given VBD.
  1.4189  
  1.4190   \noindent {\bf Signature:} 
  1.4191  \begin{verbatim} (VM ref) get_VM (session_id s, VBD ref self)\end{verbatim}
  1.4192 @@ -8415,7 +8870,7 @@ get accessor message derived from field 
  1.4193  \begin{tabular}{|c|c|p{7cm}|}
  1.4194   \hline
  1.4195  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4196 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4197 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4198  
  1.4199  \end{tabular}
  1.4200  
  1.4201 @@ -8434,7 +8889,7 @@ value of the field
  1.4202  \subsubsection{RPC name:~set\_VM}
  1.4203  
  1.4204  {\bf Overview:} 
  1.4205 -set accessor message derived from field VM of object VBD
  1.4206 +Set the VM field of the given VBD.
  1.4207  
  1.4208   \noindent {\bf Signature:} 
  1.4209  \begin{verbatim} void set_VM (session_id s, VBD ref self, VM ref value)\end{verbatim}
  1.4210 @@ -8447,7 +8902,7 @@ set accessor message derived from field 
  1.4211  \begin{tabular}{|c|c|p{7cm}|}
  1.4212   \hline
  1.4213  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4214 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4215 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4216  
  1.4217  {\tt VM ref } & value & New value to set \\ \hline 
  1.4218  
  1.4219 @@ -8468,7 +8923,7 @@ void
  1.4220  \subsubsection{RPC name:~get\_VDI}
  1.4221  
  1.4222  {\bf Overview:} 
  1.4223 -get accessor message derived from field VDI of object VBD
  1.4224 +Get the VDI field of the given VBD.
  1.4225  
  1.4226   \noindent {\bf Signature:} 
  1.4227  \begin{verbatim} (VDI ref) get_VDI (session_id s, VBD ref self)\end{verbatim}
  1.4228 @@ -8481,7 +8936,7 @@ get accessor message derived from field 
  1.4229  \begin{tabular}{|c|c|p{7cm}|}
  1.4230   \hline
  1.4231  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4232 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4233 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4234  
  1.4235  \end{tabular}
  1.4236  
  1.4237 @@ -8500,7 +8955,7 @@ value of the field
  1.4238  \subsubsection{RPC name:~set\_VDI}
  1.4239  
  1.4240  {\bf Overview:} 
  1.4241 -set accessor message derived from field VDI of object VBD
  1.4242 +Set the VDI field of the given VBD.
  1.4243  
  1.4244   \noindent {\bf Signature:} 
  1.4245  \begin{verbatim} void set_VDI (session_id s, VBD ref self, VDI ref value)\end{verbatim}
  1.4246 @@ -8513,7 +8968,7 @@ set accessor message derived from field 
  1.4247  \begin{tabular}{|c|c|p{7cm}|}
  1.4248   \hline
  1.4249  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4250 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4251 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4252  
  1.4253  {\tt VDI ref } & value & New value to set \\ \hline 
  1.4254  
  1.4255 @@ -8534,7 +8989,7 @@ void
  1.4256  \subsubsection{RPC name:~get\_device}
  1.4257  
  1.4258  {\bf Overview:} 
  1.4259 -get accessor message derived from field device of object VBD
  1.4260 +Get the device field of the given VBD.
  1.4261  
  1.4262   \noindent {\bf Signature:} 
  1.4263  \begin{verbatim} string get_device (session_id s, VBD ref self)\end{verbatim}
  1.4264 @@ -8547,7 +9002,7 @@ get accessor message derived from field 
  1.4265  \begin{tabular}{|c|c|p{7cm}|}
  1.4266   \hline
  1.4267  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4268 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4269 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4270  
  1.4271  \end{tabular}
  1.4272  
  1.4273 @@ -8566,7 +9021,7 @@ value of the field
  1.4274  \subsubsection{RPC name:~set\_device}
  1.4275  
  1.4276  {\bf Overview:} 
  1.4277 -set accessor message derived from field device of object VBD
  1.4278 +Set the device field of the given VBD.
  1.4279  
  1.4280   \noindent {\bf Signature:} 
  1.4281  \begin{verbatim} void set_device (session_id s, VBD ref self, string value)\end{verbatim}
  1.4282 @@ -8579,7 +9034,7 @@ set accessor message derived from field 
  1.4283  \begin{tabular}{|c|c|p{7cm}|}
  1.4284   \hline
  1.4285  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4286 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4287 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4288  
  1.4289  {\tt string } & value & New value to set \\ \hline 
  1.4290  
  1.4291 @@ -8600,7 +9055,7 @@ void
  1.4292  \subsubsection{RPC name:~get\_mode}
  1.4293  
  1.4294  {\bf Overview:} 
  1.4295 -get accessor message derived from field mode of object VBD
  1.4296 +Get the mode field of the given VBD.
  1.4297  
  1.4298   \noindent {\bf Signature:} 
  1.4299  \begin{verbatim} (vbd_mode) get_mode (session_id s, VBD ref self)\end{verbatim}
  1.4300 @@ -8613,7 +9068,7 @@ get accessor message derived from field 
  1.4301  \begin{tabular}{|c|c|p{7cm}|}
  1.4302   \hline
  1.4303  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4304 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4305 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4306  
  1.4307  \end{tabular}
  1.4308  
  1.4309 @@ -8632,7 +9087,7 @@ value of the field
  1.4310  \subsubsection{RPC name:~set\_mode}
  1.4311  
  1.4312  {\bf Overview:} 
  1.4313 -set accessor message derived from field mode of object VBD
  1.4314 +Set the mode field of the given VBD.
  1.4315  
  1.4316   \noindent {\bf Signature:} 
  1.4317  \begin{verbatim} void set_mode (session_id s, VBD ref self, vbd_mode value)\end{verbatim}
  1.4318 @@ -8645,7 +9100,7 @@ set accessor message derived from field 
  1.4319  \begin{tabular}{|c|c|p{7cm}|}
  1.4320   \hline
  1.4321  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4322 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4323 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4324  
  1.4325  {\tt vbd\_mode } & value & New value to set \\ \hline 
  1.4326  
  1.4327 @@ -8663,10 +9118,76 @@ void
  1.4328  \vspace{0.3cm}
  1.4329  \vspace{0.3cm}
  1.4330  \vspace{0.3cm}
  1.4331 +\subsubsection{RPC name:~get\_type}
  1.4332 +
  1.4333 +{\bf Overview:} 
  1.4334 +Get the type field of the given VBD.
  1.4335 +
  1.4336 + \noindent {\bf Signature:} 
  1.4337 +\begin{verbatim} (vbd_type) get_type (session_id s, VBD ref self)\end{verbatim}
  1.4338 +
  1.4339 +
  1.4340 +\noindent{\bf Arguments:}
  1.4341 +
  1.4342 + 
  1.4343 +\vspace{0.3cm}
  1.4344 +\begin{tabular}{|c|c|p{7cm}|}
  1.4345 + \hline
  1.4346 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4347 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4348 +
  1.4349 +\end{tabular}
  1.4350 +
  1.4351 +\vspace{0.3cm}
  1.4352 +
  1.4353 + \noindent {\bf Return Type:} 
  1.4354 +{\tt 
  1.4355 +vbd\_type
  1.4356 +}
  1.4357 +
  1.4358 +
  1.4359 +value of the field
  1.4360 +\vspace{0.3cm}
  1.4361 +\vspace{0.3cm}
  1.4362 +\vspace{0.3cm}
  1.4363 +\subsubsection{RPC name:~set\_type}
  1.4364 +
  1.4365 +{\bf Overview:} 
  1.4366 +Set the type field of the given VBD.
  1.4367 +
  1.4368 + \noindent {\bf Signature:} 
  1.4369 +\begin{verbatim} void set_type (session_id s, VBD ref self, vbd_type value)\end{verbatim}
  1.4370 +
  1.4371 +
  1.4372 +\noindent{\bf Arguments:}
  1.4373 +
  1.4374 + 
  1.4375 +\vspace{0.3cm}
  1.4376 +\begin{tabular}{|c|c|p{7cm}|}
  1.4377 + \hline
  1.4378 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4379 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4380 +
  1.4381 +{\tt vbd\_type } & value & New value to set \\ \hline 
  1.4382 +
  1.4383 +\end{tabular}
  1.4384 +
  1.4385 +\vspace{0.3cm}
  1.4386 +
  1.4387 + \noindent {\bf Return Type:} 
  1.4388 +{\tt 
  1.4389 +void
  1.4390 +}
  1.4391 +
  1.4392 +
  1.4393 +
  1.4394 +\vspace{0.3cm}
  1.4395 +\vspace{0.3cm}
  1.4396 +\vspace{0.3cm}
  1.4397  \subsubsection{RPC name:~get\_driver}
  1.4398  
  1.4399  {\bf Overview:} 
  1.4400 -get accessor message derived from field driver of object VBD
  1.4401 +Get the driver field of the given VBD.
  1.4402  
  1.4403   \noindent {\bf Signature:} 
  1.4404  \begin{verbatim} (driver_type) get_driver (session_id s, VBD ref self)\end{verbatim}
  1.4405 @@ -8679,7 +9200,7 @@ get accessor message derived from field 
  1.4406  \begin{tabular}{|c|c|p{7cm}|}
  1.4407   \hline
  1.4408  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4409 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4410 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4411  
  1.4412  \end{tabular}
  1.4413  
  1.4414 @@ -8698,7 +9219,7 @@ value of the field
  1.4415  \subsubsection{RPC name:~set\_driver}
  1.4416  
  1.4417  {\bf Overview:} 
  1.4418 -set accessor message derived from field driver of object VBD
  1.4419 +Set the driver field of the given VBD.
  1.4420  
  1.4421   \noindent {\bf Signature:} 
  1.4422  \begin{verbatim} void set_driver (session_id s, VBD ref self, driver_type value)\end{verbatim}
  1.4423 @@ -8711,7 +9232,7 @@ set accessor message derived from field 
  1.4424  \begin{tabular}{|c|c|p{7cm}|}
  1.4425   \hline
  1.4426  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4427 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4428 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4429  
  1.4430  {\tt driver\_type } & value & New value to set \\ \hline 
  1.4431  
  1.4432 @@ -8732,7 +9253,7 @@ void
  1.4433  \subsubsection{RPC name:~get\_io\_read\_kbs}
  1.4434  
  1.4435  {\bf Overview:} 
  1.4436 -get accessor message derived from field io/read\_kbs of object VBD
  1.4437 +Get the io/read\_kbs field of the given VBD.
  1.4438  
  1.4439   \noindent {\bf Signature:} 
  1.4440  \begin{verbatim} float get_io_read_kbs (session_id s, VBD ref self)\end{verbatim}
  1.4441 @@ -8745,7 +9266,7 @@ get accessor message derived from field 
  1.4442  \begin{tabular}{|c|c|p{7cm}|}
  1.4443   \hline
  1.4444  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4445 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4446 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4447  
  1.4448  \end{tabular}
  1.4449  
  1.4450 @@ -8764,7 +9285,7 @@ value of the field
  1.4451  \subsubsection{RPC name:~get\_io\_write\_kbs}
  1.4452  
  1.4453  {\bf Overview:} 
  1.4454 -get accessor message derived from field io/write\_kbs of object VBD
  1.4455 +Get the io/write\_kbs field of the given VBD.
  1.4456  
  1.4457   \noindent {\bf Signature:} 
  1.4458  \begin{verbatim} float get_io_write_kbs (session_id s, VBD ref self)\end{verbatim}
  1.4459 @@ -8777,7 +9298,7 @@ get accessor message derived from field 
  1.4460  \begin{tabular}{|c|c|p{7cm}|}
  1.4461   \hline
  1.4462  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4463 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4464 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4465  
  1.4466  \end{tabular}
  1.4467  
  1.4468 @@ -8796,7 +9317,7 @@ value of the field
  1.4469  \subsubsection{RPC name:~create}
  1.4470  
  1.4471  {\bf Overview:} 
  1.4472 -constructor for class VBD
  1.4473 +Create a new VBD instance, and return its handle.
  1.4474  
  1.4475   \noindent {\bf Signature:} 
  1.4476  \begin{verbatim} (VBD ref) create (session_id s, VBD record args)\end{verbatim}
  1.4477 @@ -8828,7 +9349,7 @@ reference to the newly created object
  1.4478  \subsubsection{RPC name:~destroy}
  1.4479  
  1.4480  {\bf Overview:} 
  1.4481 -destructor for class VBD
  1.4482 +Destroy the specified VBD instance.
  1.4483  
  1.4484   \noindent {\bf Signature:} 
  1.4485  \begin{verbatim} void destroy (session_id s, VBD ref self)\end{verbatim}
  1.4486 @@ -8841,7 +9362,7 @@ destructor for class VBD
  1.4487  \begin{tabular}{|c|c|p{7cm}|}
  1.4488   \hline
  1.4489  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4490 -{\tt VBD ref } & self & object instance \\ \hline 
  1.4491 +{\tt VBD ref } & self & reference to the object \\ \hline 
  1.4492  
  1.4493  \end{tabular}
  1.4494  
  1.4495 @@ -8860,7 +9381,7 @@ void
  1.4496  \subsubsection{RPC name:~get\_by\_uuid}
  1.4497  
  1.4498  {\bf Overview:} 
  1.4499 -returns the VBD instance with a particular uuid
  1.4500 +Get a reference to the VBD instance with the specified UUID.
  1.4501  
  1.4502   \noindent {\bf Signature:} 
  1.4503  \begin{verbatim} (VBD ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.4504 @@ -8892,7 +9413,7 @@ reference to the object
  1.4505  \subsubsection{RPC name:~get\_record}
  1.4506  
  1.4507  {\bf Overview:} 
  1.4508 -returns a record containing the state of an instance of class VBD
  1.4509 +Get a record containing the current state of the given VBD.
  1.4510  
  1.4511   \noindent {\bf Signature:} 
  1.4512  \begin{verbatim} (VBD record) get_record (session_id s, VBD ref self)\end{verbatim}
  1.4513 @@ -8944,7 +9465,7 @@ Quals & Field & Type & Description \\
  1.4514  \subsubsection{RPC name:~get\_uuid}
  1.4515  
  1.4516  {\bf Overview:} 
  1.4517 -get accessor message derived from field uuid of object VTPM
  1.4518 +Get the uuid field of the given VTPM.
  1.4519  
  1.4520   \noindent {\bf Signature:} 
  1.4521  \begin{verbatim} string get_uuid (session_id s, VTPM ref self)\end{verbatim}
  1.4522 @@ -8957,7 +9478,7 @@ get accessor message derived from field 
  1.4523  \begin{tabular}{|c|c|p{7cm}|}
  1.4524   \hline
  1.4525  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4526 -{\tt VTPM ref } & self & object instance \\ \hline 
  1.4527 +{\tt VTPM ref } & self & reference to the object \\ \hline 
  1.4528  
  1.4529  \end{tabular}
  1.4530  
  1.4531 @@ -8976,7 +9497,7 @@ value of the field
  1.4532  \subsubsection{RPC name:~get\_VM}
  1.4533  
  1.4534  {\bf Overview:} 
  1.4535 -get accessor message derived from field VM of object VTPM
  1.4536 +Get the VM field of the given VTPM.
  1.4537  
  1.4538   \noindent {\bf Signature:} 
  1.4539  \begin{verbatim} (VM ref) get_VM (session_id s, VTPM ref self)\end{verbatim}
  1.4540 @@ -8989,7 +9510,7 @@ get accessor message derived from field 
  1.4541  \begin{tabular}{|c|c|p{7cm}|}
  1.4542   \hline
  1.4543  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4544 -{\tt VTPM ref } & self & object instance \\ \hline 
  1.4545 +{\tt VTPM ref } & self & reference to the object \\ \hline 
  1.4546  
  1.4547  \end{tabular}
  1.4548  
  1.4549 @@ -9008,7 +9529,7 @@ value of the field
  1.4550  \subsubsection{RPC name:~get\_backend}
  1.4551  
  1.4552  {\bf Overview:} 
  1.4553 -get accessor message derived from field backend of object VTPM
  1.4554 +Get the backend field of the given VTPM.
  1.4555  
  1.4556   \noindent {\bf Signature:} 
  1.4557  \begin{verbatim} (VM ref) get_backend (session_id s, VTPM ref self)\end{verbatim}
  1.4558 @@ -9021,7 +9542,7 @@ get accessor message derived from field 
  1.4559  \begin{tabular}{|c|c|p{7cm}|}
  1.4560   \hline
  1.4561  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4562 -{\tt VTPM ref } & self & object instance \\ \hline 
  1.4563 +{\tt VTPM ref } & self & reference to the object \\ \hline 
  1.4564  
  1.4565  \end{tabular}
  1.4566  
  1.4567 @@ -9040,7 +9561,7 @@ value of the field
  1.4568  \subsubsection{RPC name:~get\_driver}
  1.4569  
  1.4570  {\bf Overview:} 
  1.4571 -get accessor message derived from field driver of object VTPM
  1.4572 +Get the driver field of the given VTPM.
  1.4573  
  1.4574   \noindent {\bf Signature:} 
  1.4575  \begin{verbatim} (driver_type) get_driver (session_id s, VTPM ref self)\end{verbatim}
  1.4576 @@ -9053,7 +9574,7 @@ get accessor message derived from field 
  1.4577  \begin{tabular}{|c|c|p{7cm}|}
  1.4578   \hline
  1.4579  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4580 -{\tt VTPM ref } & self & object instance \\ \hline 
  1.4581 +{\tt VTPM ref } & self & reference to the object \\ \hline 
  1.4582  
  1.4583  \end{tabular}
  1.4584  
  1.4585 @@ -9072,7 +9593,7 @@ value of the field
  1.4586  \subsubsection{RPC name:~get\_instance}
  1.4587  
  1.4588  {\bf Overview:} 
  1.4589 -get accessor message derived from field instance of object VTPM
  1.4590 +Get the instance field of the given VTPM.
  1.4591  
  1.4592   \noindent {\bf Signature:} 
  1.4593  \begin{verbatim} int get_instance (session_id s, VTPM ref self)\end{verbatim}
  1.4594 @@ -9085,7 +9606,7 @@ get accessor message derived from field 
  1.4595  \begin{tabular}{|c|c|p{7cm}|}
  1.4596   \hline
  1.4597  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4598 -{\tt VTPM ref } & self & object instance \\ \hline 
  1.4599 +{\tt VTPM ref } & self & reference to the object \\ \hline 
  1.4600  
  1.4601  \end{tabular}
  1.4602  
  1.4603 @@ -9104,7 +9625,7 @@ value of the field
  1.4604  \subsubsection{RPC name:~create}
  1.4605  
  1.4606  {\bf Overview:} 
  1.4607 -constructor for class VTPM
  1.4608 +Create a new VTPM instance, and return its handle.
  1.4609  
  1.4610   \noindent {\bf Signature:} 
  1.4611  \begin{verbatim} (VTPM ref) create (session_id s, VTPM record args)\end{verbatim}
  1.4612 @@ -9136,7 +9657,7 @@ reference to the newly created object
  1.4613  \subsubsection{RPC name:~destroy}
  1.4614  
  1.4615  {\bf Overview:} 
  1.4616 -destructor for class VTPM
  1.4617 +Destroy the specified VTPM instance.
  1.4618  
  1.4619   \noindent {\bf Signature:} 
  1.4620  \begin{verbatim} void destroy (session_id s, VTPM ref self)\end{verbatim}
  1.4621 @@ -9149,7 +9670,7 @@ destructor for class VTPM
  1.4622  \begin{tabular}{|c|c|p{7cm}|}
  1.4623   \hline
  1.4624  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4625 -{\tt VTPM ref } & self & object instance \\ \hline 
  1.4626 +{\tt VTPM ref } & self & reference to the object \\ \hline 
  1.4627  
  1.4628  \end{tabular}
  1.4629  
  1.4630 @@ -9168,7 +9689,7 @@ void
  1.4631  \subsubsection{RPC name:~get\_by\_uuid}
  1.4632  
  1.4633  {\bf Overview:} 
  1.4634 -returns the VTPM instance with a particular uuid
  1.4635 +Get a reference to the VTPM instance with the specified UUID.
  1.4636  
  1.4637   \noindent {\bf Signature:} 
  1.4638  \begin{verbatim} (VTPM ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.4639 @@ -9200,7 +9721,7 @@ reference to the object
  1.4640  \subsubsection{RPC name:~get\_record}
  1.4641  
  1.4642  {\bf Overview:} 
  1.4643 -returns a record containing the state of an instance of class VTPM
  1.4644 +Get a record containing the current state of the given VTPM.
  1.4645  
  1.4646   \noindent {\bf Signature:} 
  1.4647  \begin{verbatim} (VTPM record) get_record (session_id s, VTPM ref self)\end{verbatim}
  1.4648 @@ -9360,7 +9881,7 @@ Destroy the specified console instance.
  1.4649  \begin{tabular}{|c|c|p{7cm}|}
  1.4650   \hline
  1.4651  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4652 -{\tt console ref } & self & object instance \\ \hline 
  1.4653 +{\tt console ref } & self & reference to the object \\ \hline 
  1.4654  
  1.4655  \end{tabular}
  1.4656  
  1.4657 @@ -9392,7 +9913,7 @@ Get the uuid field of the given console.
  1.4658  \begin{tabular}{|c|c|p{7cm}|}
  1.4659   \hline
  1.4660  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4661 -{\tt console ref } & self & object instance \\ \hline 
  1.4662 +{\tt console ref } & self & reference to the object \\ \hline 
  1.4663  
  1.4664  \end{tabular}
  1.4665  
  1.4666 @@ -9424,7 +9945,7 @@ Get the protocol field of the given cons
  1.4667  \begin{tabular}{|c|c|p{7cm}|}
  1.4668   \hline
  1.4669  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4670 -{\tt console ref } & self & object instance \\ \hline 
  1.4671 +{\tt console ref } & self & reference to the object \\ \hline 
  1.4672  
  1.4673  \end{tabular}
  1.4674  
  1.4675 @@ -9456,7 +9977,7 @@ Get the uri field of the given console.
  1.4676  \begin{tabular}{|c|c|p{7cm}|}
  1.4677   \hline
  1.4678  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4679 -{\tt console ref } & self & object instance \\ \hline 
  1.4680 +{\tt console ref } & self & reference to the object \\ \hline 
  1.4681  
  1.4682  \end{tabular}
  1.4683  
  1.4684 @@ -9488,7 +10009,7 @@ Get the VM field of the given console.
  1.4685  \begin{tabular}{|c|c|p{7cm}|}
  1.4686   \hline
  1.4687  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4688 -{\tt console ref } & self & object instance \\ \hline 
  1.4689 +{\tt console ref } & self & reference to the object \\ \hline 
  1.4690  
  1.4691  \end{tabular}
  1.4692  
  1.4693 @@ -9525,7 +10046,7 @@ Quals & Field & Type & Description \\
  1.4694  \subsubsection{RPC name:~get\_uuid}
  1.4695  
  1.4696  {\bf Overview:} 
  1.4697 -get accessor message derived from field uuid of object user
  1.4698 +Get the uuid field of the given user.
  1.4699  
  1.4700   \noindent {\bf Signature:} 
  1.4701  \begin{verbatim} string get_uuid (session_id s, user ref self)\end{verbatim}
  1.4702 @@ -9538,7 +10059,7 @@ get accessor message derived from field 
  1.4703  \begin{tabular}{|c|c|p{7cm}|}
  1.4704   \hline
  1.4705  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4706 -{\tt user ref } & self & object instance \\ \hline 
  1.4707 +{\tt user ref } & self & reference to the object \\ \hline 
  1.4708  
  1.4709  \end{tabular}
  1.4710  
  1.4711 @@ -9557,7 +10078,7 @@ value of the field
  1.4712  \subsubsection{RPC name:~get\_short\_name}
  1.4713  
  1.4714  {\bf Overview:} 
  1.4715 -get accessor message derived from field short\_name of object user
  1.4716 +Get the short\_name field of the given user.
  1.4717  
  1.4718   \noindent {\bf Signature:} 
  1.4719  \begin{verbatim} string get_short_name (session_id s, user ref self)\end{verbatim}
  1.4720 @@ -9570,7 +10091,7 @@ get accessor message derived from field 
  1.4721  \begin{tabular}{|c|c|p{7cm}|}
  1.4722   \hline
  1.4723  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4724 -{\tt user ref } & self & object instance \\ \hline 
  1.4725 +{\tt user ref } & self & reference to the object \\ \hline 
  1.4726  
  1.4727  \end{tabular}
  1.4728  
  1.4729 @@ -9589,7 +10110,7 @@ value of the field
  1.4730  \subsubsection{RPC name:~get\_fullname}
  1.4731  
  1.4732  {\bf Overview:} 
  1.4733 -get accessor message derived from field fullname of object user
  1.4734 +Get the fullname field of the given user.
  1.4735  
  1.4736   \noindent {\bf Signature:} 
  1.4737  \begin{verbatim} string get_fullname (session_id s, user ref self)\end{verbatim}
  1.4738 @@ -9602,7 +10123,7 @@ get accessor message derived from field 
  1.4739  \begin{tabular}{|c|c|p{7cm}|}
  1.4740   \hline
  1.4741  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4742 -{\tt user ref } & self & object instance \\ \hline 
  1.4743 +{\tt user ref } & self & reference to the object \\ \hline 
  1.4744  
  1.4745  \end{tabular}
  1.4746  
  1.4747 @@ -9621,7 +10142,7 @@ value of the field
  1.4748  \subsubsection{RPC name:~set\_fullname}
  1.4749  
  1.4750  {\bf Overview:} 
  1.4751 -set accessor message derived from field fullname of object user
  1.4752 +Set the fullname field of the given user.
  1.4753  
  1.4754   \noindent {\bf Signature:} 
  1.4755  \begin{verbatim} void set_fullname (session_id s, user ref self, string value)\end{verbatim}
  1.4756 @@ -9634,7 +10155,7 @@ set accessor message derived from field 
  1.4757  \begin{tabular}{|c|c|p{7cm}|}
  1.4758   \hline
  1.4759  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4760 -{\tt user ref } & self & object instance \\ \hline 
  1.4761 +{\tt user ref } & self & reference to the object \\ \hline 
  1.4762  
  1.4763  {\tt string } & value & New value to set \\ \hline 
  1.4764  
  1.4765 @@ -9655,7 +10176,7 @@ void
  1.4766  \subsubsection{RPC name:~create}
  1.4767  
  1.4768  {\bf Overview:} 
  1.4769 -constructor for class user
  1.4770 +Create a new user instance, and return its handle.
  1.4771  
  1.4772   \noindent {\bf Signature:} 
  1.4773  \begin{verbatim} (user ref) create (session_id s, user record args)\end{verbatim}
  1.4774 @@ -9687,7 +10208,7 @@ reference to the newly created object
  1.4775  \subsubsection{RPC name:~destroy}
  1.4776  
  1.4777  {\bf Overview:} 
  1.4778 -destructor for class user
  1.4779 +Destroy the specified user instance.
  1.4780  
  1.4781   \noindent {\bf Signature:} 
  1.4782  \begin{verbatim} void destroy (session_id s, user ref self)\end{verbatim}
  1.4783 @@ -9700,7 +10221,7 @@ destructor for class user
  1.4784  \begin{tabular}{|c|c|p{7cm}|}
  1.4785   \hline
  1.4786  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4787 -{\tt user ref } & self & object instance \\ \hline 
  1.4788 +{\tt user ref } & self & reference to the object \\ \hline 
  1.4789  
  1.4790  \end{tabular}
  1.4791  
  1.4792 @@ -9719,7 +10240,7 @@ void
  1.4793  \subsubsection{RPC name:~get\_by\_uuid}
  1.4794  
  1.4795  {\bf Overview:} 
  1.4796 -returns the user instance with a particular uuid
  1.4797 +Get a reference to the user instance with the specified UUID.
  1.4798  
  1.4799   \noindent {\bf Signature:} 
  1.4800  \begin{verbatim} (user ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.4801 @@ -9751,7 +10272,7 @@ reference to the object
  1.4802  \subsubsection{RPC name:~get\_record}
  1.4803  
  1.4804  {\bf Overview:} 
  1.4805 -returns a record containing the state of an instance of class user
  1.4806 +Get a record containing the current state of the given user.
  1.4807  
  1.4808   \noindent {\bf Signature:} 
  1.4809  \begin{verbatim} (user record) get_record (session_id s, user ref self)\end{verbatim}
  1.4810 @@ -9832,7 +10353,7 @@ void
  1.4811  \subsubsection{RPC name:~create}
  1.4812  
  1.4813  {\bf Overview:} 
  1.4814 -constructor for class debug
  1.4815 +Create a new debug instance, and return its handle.
  1.4816  
  1.4817   \noindent {\bf Signature:} 
  1.4818  \begin{verbatim} (debug ref) create (session_id s, debug record args)\end{verbatim}
  1.4819 @@ -9864,7 +10385,7 @@ reference to the newly created object
  1.4820  \subsubsection{RPC name:~destroy}
  1.4821  
  1.4822  {\bf Overview:} 
  1.4823 -destructor for class debug
  1.4824 +Destroy the specified debug instance.
  1.4825  
  1.4826   \noindent {\bf Signature:} 
  1.4827  \begin{verbatim} void destroy (session_id s, debug ref self)\end{verbatim}
  1.4828 @@ -9877,7 +10398,7 @@ destructor for class debug
  1.4829  \begin{tabular}{|c|c|p{7cm}|}
  1.4830   \hline
  1.4831  {\bf type} & {\bf name} & {\bf description} \\ \hline
  1.4832 -{\tt debug ref } & self & object instance \\ \hline 
  1.4833 +{\tt debug ref } & self & reference to the object \\ \hline 
  1.4834  
  1.4835  \end{tabular}
  1.4836  
  1.4837 @@ -9896,7 +10417,7 @@ void
  1.4838  \subsubsection{RPC name:~get\_by\_uuid}
  1.4839  
  1.4840  {\bf Overview:} 
  1.4841 -returns the debug instance with a particular uuid
  1.4842 +Get a reference to the debug instance with the specified UUID.
  1.4843  
  1.4844   \noindent {\bf Signature:} 
  1.4845  \begin{verbatim} (debug ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  1.4846 @@ -9928,7 +10449,7 @@ reference to the object
  1.4847  \subsubsection{RPC name:~get\_record}
  1.4848  
  1.4849  {\bf Overview:} 
  1.4850 -returns a record containing the state of an instance of class debug
  1.4851 +Get a record containing the current state of the given debug.
  1.4852  
  1.4853   \noindent {\bf Signature:} 
  1.4854  \begin{verbatim} (debug record) get_record (session_id s, debug ref self)\end{verbatim}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/crash.c	Mon Dec 11 11:17:11 2006 -0800
     2.3 @@ -0,0 +1,187 @@
     2.4 +/*
     2.5 + * Architecture specific (i386) functions for kexec based crash dumps.
     2.6 + *
     2.7 + * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
     2.8 + *
     2.9 + * Copyright (C) IBM Corporation, 2004. All rights reserved.
    2.10 + *
    2.11 + */
    2.12 +
    2.13 +#include <linux/init.h>
    2.14 +#include <linux/types.h>
    2.15 +#include <linux/kernel.h>
    2.16 +#include <linux/smp.h>
    2.17 +#include <linux/reboot.h>
    2.18 +#include <linux/kexec.h>
    2.19 +#include <linux/delay.h>
    2.20 +#include <linux/elf.h>
    2.21 +#include <linux/elfcore.h>
    2.22 +
    2.23 +#include <asm/processor.h>
    2.24 +#include <asm/hardirq.h>
    2.25 +#include <asm/nmi.h>
    2.26 +#include <asm/hw_irq.h>
    2.27 +#include <asm/apic.h>
    2.28 +#include <mach_ipi.h>
    2.29 +
    2.30 +
    2.31 +/* This keeps a track of which one is crashing cpu. */
    2.32 +static int crashing_cpu;
    2.33 +
    2.34 +static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
    2.35 +							       size_t data_len)
    2.36 +{
    2.37 +	struct elf_note note;
    2.38 +
    2.39 +	note.n_namesz = strlen(name) + 1;
    2.40 +	note.n_descsz = data_len;
    2.41 +	note.n_type   = type;
    2.42 +	memcpy(buf, &note, sizeof(note));
    2.43 +	buf += (sizeof(note) +3)/4;
    2.44 +	memcpy(buf, name, note.n_namesz);
    2.45 +	buf += (note.n_namesz + 3)/4;
    2.46 +	memcpy(buf, data, note.n_descsz);
    2.47 +	buf += (note.n_descsz + 3)/4;
    2.48 +
    2.49 +	return buf;
    2.50 +}
    2.51 +
    2.52 +static void final_note(u32 *buf)
    2.53 +{
    2.54 +	struct elf_note note;
    2.55 +
    2.56 +	note.n_namesz = 0;
    2.57 +	note.n_descsz = 0;
    2.58 +	note.n_type   = 0;
    2.59 +	memcpy(buf, &note, sizeof(note));
    2.60 +}
    2.61 +
    2.62 +static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
    2.63 +{
    2.64 +	struct elf_prstatus prstatus;
    2.65 +	u32 *buf;
    2.66 +
    2.67 +	if ((cpu < 0) || (cpu >= NR_CPUS))
    2.68 +		return;
    2.69 +
    2.70 +	/* Using ELF notes here is opportunistic.
    2.71 +	 * I need a well defined structure format
    2.72 +	 * for the data I pass, and I need tags
    2.73 +	 * on the data to indicate what information I have
    2.74 +	 * squirrelled away.  ELF notes happen to provide
    2.75 +	 * all of that that no need to invent something new.
    2.76 +	 */
    2.77 +	buf = (u32*)per_cpu_ptr(crash_notes, cpu);
    2.78 +	if (!buf)
    2.79 +		return;
    2.80 +	memset(&prstatus, 0, sizeof(prstatus));
    2.81 +	prstatus.pr_pid = current->pid;
    2.82 +	elf_core_copy_regs(&prstatus.pr_reg, regs);
    2.83 +	buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
    2.84 +				sizeof(prstatus));
    2.85 +	final_note(buf);
    2.86 +}
    2.87 +
    2.88 +static void crash_save_self(struct pt_regs *regs)
    2.89 +{
    2.90 +	int cpu;
    2.91 +
    2.92 +	cpu = smp_processor_id();
    2.93 +	crash_save_this_cpu(regs, cpu);
    2.94 +}
    2.95 +
    2.96 +#ifndef CONFIG_XEN
    2.97 +#ifdef CONFIG_SMP
    2.98 +static atomic_t waiting_for_crash_ipi;
    2.99 +
   2.100 +static int crash_nmi_callback(struct pt_regs *regs, int cpu)
   2.101 +{
   2.102 +	struct pt_regs fixed_regs;
   2.103 +
   2.104 +	/* Don't do anything if this handler is invoked on crashing cpu.
   2.105 +	 * Otherwise, system will completely hang. Crashing cpu can get
   2.106 +	 * an NMI if system was initially booted with nmi_watchdog parameter.
   2.107 +	 */
   2.108 +	if (cpu == crashing_cpu)
   2.109 +		return 1;
   2.110 +	local_irq_disable();
   2.111 +
   2.112 +	if (!user_mode(regs)) {
   2.113 +		crash_fixup_ss_esp(&fixed_regs, regs);
   2.114 +		regs = &fixed_regs;
   2.115 +	}
   2.116 +	crash_save_this_cpu(regs, cpu);
   2.117 +	disable_local_APIC();
   2.118 +	atomic_dec(&waiting_for_crash_ipi);
   2.119 +	/* Assume hlt works */
   2.120 +	halt();
   2.121 +	for(;;);
   2.122 +
   2.123 +	return 1;
   2.124 +}
   2.125 +
   2.126 +/*
   2.127 + * By using the NMI code instead of a vector we just sneak thru the
   2.128 + * word generator coming out with just what we want.  AND it does
   2.129 + * not matter if clustered_apic_mode is set or not.
   2.130 + */
   2.131 +static void smp_send_nmi_allbutself(void)
   2.132 +{
   2.133 +	send_IPI_allbutself(APIC_DM_NMI);
   2.134 +}
   2.135 +
   2.136 +static void nmi_shootdown_cpus(void)
   2.137 +{
   2.138 +	unsigned long msecs;
   2.139 +
   2.140 +	atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
   2.141 +	/* Would it be better to replace the trap vector here? */
   2.142 +	set_nmi_callback(crash_nmi_callback);
   2.143 +	/* Ensure the new callback function is set before sending
   2.144 +	 * out the NMI
   2.145 +	 */
   2.146 +	wmb();
   2.147 +
   2.148 +	smp_send_nmi_allbutself();
   2.149 +
   2.150 +	msecs = 1000; /* Wait at most a second for the other cpus to stop */
   2.151 +	while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) {
   2.152 +		mdelay(1);
   2.153 +		msecs--;
   2.154 +	}
   2.155 +
   2.156 +	/* Leave the nmi callback set */
   2.157 +	disable_local_APIC();
   2.158 +}
   2.159 +#else
   2.160 +static void nmi_shootdown_cpus(void)
   2.161 +{
   2.162 +	/* There are no cpus to shootdown */
   2.163 +}
   2.164 +#endif
   2.165 +#endif /* CONFIG_XEN */
   2.166 +
   2.167 +void machine_crash_shutdown(struct pt_regs *regs)
   2.168 +{
   2.169 +	/* This function is only called after the system
   2.170 +	 * has paniced or is otherwise in a critical state.
   2.171 +	 * The minimum amount of code to allow a kexec'd kernel
   2.172 +	 * to run successfully needs to happen here.
   2.173 +	 *
   2.174 +	 * In practice this means shooting down the other cpus in
   2.175 +	 * an SMP system.
   2.176 +	 */
   2.177 +	/* The kernel is broken so disable interrupts */
   2.178 +	local_irq_disable();
   2.179 +
   2.180 +	/* Make a note of crashing cpu. Will be used in NMI callback.*/
   2.181 +	crashing_cpu = smp_processor_id();
   2.182 +#ifndef CONFIG_XEN
   2.183 +	nmi_shootdown_cpus();
   2.184 +	lapic_shutdown();
   2.185 +#if defined(CONFIG_X86_IO_APIC)
   2.186 +	disable_IO_APIC();
   2.187 +#endif
   2.188 +#endif /* CONFIG_XEN */
   2.189 +	crash_save_self(regs);
   2.190 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/machine_kexec.c	Mon Dec 11 11:17:11 2006 -0800
     3.3 @@ -0,0 +1,129 @@
     3.4 +/*
     3.5 + * machine_kexec.c - handle transition of Linux booting another kernel
     3.6 + * Copyright (C) 2002-2005 Eric Biederman  <ebiederm@xmission.com>
     3.7 + *
     3.8 + * This source code is licensed under the GNU General Public License,
     3.9 + * Version 2.  See the file COPYING for more details.
    3.10 + */
    3.11 +
    3.12 +#include <linux/mm.h>
    3.13 +#include <linux/kexec.h>
    3.14 +#include <linux/delay.h>
    3.15 +#include <asm/pgtable.h>
    3.16 +#include <asm/pgalloc.h>
    3.17 +#include <asm/tlbflush.h>
    3.18 +#include <asm/mmu_context.h>
    3.19 +#include <asm/io.h>
    3.20 +#include <asm/apic.h>
    3.21 +#include <asm/cpufeature.h>
    3.22 +#include <asm/desc.h>
    3.23 +#include <asm/system.h>
    3.24 +
    3.25 +#ifdef CONFIG_XEN
    3.26 +#include <xen/interface/kexec.h>
    3.27 +#endif
    3.28 +
    3.29 +#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
    3.30 +static u32 kexec_pgd[1024] PAGE_ALIGNED;
    3.31 +#ifdef CONFIG_X86_PAE
    3.32 +static u32 kexec_pmd0[1024] PAGE_ALIGNED;
    3.33 +static u32 kexec_pmd1[1024] PAGE_ALIGNED;
    3.34 +#endif
    3.35 +static u32 kexec_pte0[1024] PAGE_ALIGNED;
    3.36 +static u32 kexec_pte1[1024] PAGE_ALIGNED;
    3.37 +
    3.38 +#ifdef CONFIG_XEN
    3.39 +
    3.40 +#define __ma(x) (pfn_to_mfn(__pa((x)) >> PAGE_SHIFT) << PAGE_SHIFT)
    3.41 +
    3.42 +#if PAGES_NR > KEXEC_XEN_NO_PAGES
    3.43 +#error PAGES_NR is greater than KEXEC_XEN_NO_PAGES - Xen support will break
    3.44 +#endif
    3.45 +
    3.46 +#if PA_CONTROL_PAGE != 0
    3.47 +#error PA_CONTROL_PAGE is non zero - Xen support will break
    3.48 +#endif
    3.49 +
    3.50 +void machine_kexec_setup_load_arg(xen_kexec_image_t *xki, struct kimage *image)
    3.51 +{
    3.52 +	void *control_page;
    3.53 +
    3.54 +	memset(xki->page_list, 0, sizeof(xki->page_list));
    3.55 +
    3.56 +	control_page = page_address(image->control_code_page);
    3.57 +	memcpy(control_page, relocate_kernel, PAGE_SIZE);
    3.58 +
    3.59 +	xki->page_list[PA_CONTROL_PAGE] = __ma(control_page);
    3.60 +	xki->page_list[PA_PGD] = __ma(kexec_pgd);
    3.61 +#ifdef CONFIG_X86_PAE
    3.62 +	xki->page_list[PA_PMD_0] = __ma(kexec_pmd0);
    3.63 +	xki->page_list[PA_PMD_1] = __ma(kexec_pmd1);
    3.64 +#endif
    3.65 +	xki->page_list[PA_PTE_0] = __ma(kexec_pte0);
    3.66 +	xki->page_list[PA_PTE_1] = __ma(kexec_pte1);
    3.67 +
    3.68 +}
    3.69 +
    3.70 +#endif /* CONFIG_XEN */
    3.71 +
    3.72 +/*
    3.73 + * A architecture hook called to validate the
    3.74 + * proposed image and prepare the control pages
    3.75 + * as needed.  The pages for KEXEC_CONTROL_CODE_SIZE
    3.76 + * have been allocated, but the segments have yet
    3.77 + * been copied into the kernel.
    3.78 + *
    3.79 + * Do what every setup is needed on image and the
    3.80 + * reboot code buffer to allow us to avoid allocations
    3.81 + * later.
    3.82 + *
    3.83 + * Currently nothing.
    3.84 + */
    3.85 +int machine_kexec_prepare(struct kimage *image)
    3.86 +{
    3.87 +	return 0;
    3.88 +}
    3.89 +
    3.90 +/*
    3.91 + * Undo anything leftover by machine_kexec_prepare
    3.92 + * when an image is freed.
    3.93 + */
    3.94 +void machine_kexec_cleanup(struct kimage *image)
    3.95 +{
    3.96 +}
    3.97 +
    3.98 +#ifndef CONFIG_XEN
    3.99 +/*
   3.100 + * Do not allocate memory (or fail in any way) in machine_kexec().
   3.101 + * We are past the point of no return, committed to rebooting now.
   3.102 + */
   3.103 +NORET_TYPE void machine_kexec(struct kimage *image)
   3.104 +{
   3.105 +	unsigned long page_list[PAGES_NR];
   3.106 +	void *control_page;
   3.107 +
   3.108 +	/* Interrupts aren't acceptable while we reboot */
   3.109 +	local_irq_disable();
   3.110 +
   3.111 +	control_page = page_address(image->control_code_page);
   3.112 +	memcpy(control_page, relocate_kernel, PAGE_SIZE);
   3.113 +
   3.114 +	page_list[PA_CONTROL_PAGE] = __pa(control_page);
   3.115 +	page_list[VA_CONTROL_PAGE] = (unsigned long)relocate_kernel;
   3.116 +	page_list[PA_PGD] = __pa(kexec_pgd);
   3.117 +	page_list[VA_PGD] = (unsigned long)kexec_pgd;
   3.118 +#ifdef CONFIG_X86_PAE
   3.119 +	page_list[PA_PMD_0] = __pa(kexec_pmd0);
   3.120 +	page_list[VA_PMD_0] = (unsigned long)kexec_pmd0;
   3.121 +	page_list[PA_PMD_1] = __pa(kexec_pmd1);
   3.122 +	page_list[VA_PMD_1] = (unsigned long)kexec_pmd1;
   3.123 +#endif
   3.124 +	page_list[PA_PTE_0] = __pa(kexec_pte0);
   3.125 +	page_list[VA_PTE_0] = (unsigned long)kexec_pte0;
   3.126 +	page_list[PA_PTE_1] = __pa(kexec_pte1);
   3.127 +	page_list[VA_PTE_1] = (unsigned long)kexec_pte1;
   3.128 +
   3.129 +	relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
   3.130 +			image->start, cpu_has_pae);
   3.131 +}
   3.132 +#endif
     4.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Mon Dec 11 11:16:29 2006 -0800
     4.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Mon Dec 11 11:17:11 2006 -0800
     4.3 @@ -1047,9 +1047,9 @@ void time_resume(void)
     4.4  #ifdef CONFIG_SMP
     4.5  static char timer_name[NR_CPUS][15];
     4.6  
     4.7 -void local_setup_timer(unsigned int cpu)
     4.8 +int local_setup_timer(unsigned int cpu)
     4.9  {
    4.10 -	int seq;
    4.11 +	int seq, irq;
    4.12  
    4.13  	BUG_ON(cpu == 0);
    4.14  
    4.15 @@ -1062,15 +1062,17 @@ void local_setup_timer(unsigned int cpu)
    4.16  	} while (read_seqretry(&xtime_lock, seq));
    4.17  
    4.18  	sprintf(timer_name[cpu], "timer%d", cpu);
    4.19 -	per_cpu(timer_irq, cpu) =
    4.20 -		bind_virq_to_irqhandler(
    4.21 -			VIRQ_TIMER,
    4.22 -			cpu,
    4.23 -			timer_interrupt,
    4.24 -			SA_INTERRUPT,
    4.25 -			timer_name[cpu],
    4.26 -			NULL);
    4.27 -	BUG_ON(per_cpu(timer_irq, cpu) < 0);
    4.28 +	irq = bind_virq_to_irqhandler(VIRQ_TIMER,
    4.29 +				      cpu,
    4.30 +				      timer_interrupt,
    4.31 +				      SA_INTERRUPT,
    4.32 +				      timer_name[cpu],
    4.33 +				      NULL);
    4.34 +	if (irq < 0)
    4.35 +		return irq;
    4.36 +	per_cpu(timer_irq, cpu) = irq;
    4.37 +
    4.38 +	return 0;
    4.39  }
    4.40  
    4.41  void local_teardown_timer(unsigned int cpu)
     5.1 --- a/linux-2.6-xen-sparse/arch/ia64/Kconfig	Mon Dec 11 11:16:29 2006 -0800
     5.2 +++ b/linux-2.6-xen-sparse/arch/ia64/Kconfig	Mon Dec 11 11:17:11 2006 -0800
     5.3 @@ -533,9 +533,6 @@ config XEN_BALLOON
     5.4  config XEN_SKBUFF
     5.5  	default y
     5.6  
     5.7 -config XEN_DEVMEM
     5.8 -	default n
     5.9 -
    5.10  config XEN_REBOOT
    5.11  	default y
    5.12  
     6.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/entry.S	Mon Dec 11 11:16:29 2006 -0800
     6.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/entry.S	Mon Dec 11 11:17:11 2006 -0800
     6.3 @@ -602,7 +602,7 @@ GLOBAL_ENTRY(ia64_strace_leave_kernel)
     6.4  .ret4:	br.cond.sptk ia64_leave_kernel
     6.5  END(ia64_strace_leave_kernel)
     6.6  
     6.7 -GLOBAL_ENTRY(ia64_ret_from_clone)
     6.8 +GLOBAL_ENTRY(__ia64_ret_from_clone)
     6.9  	PT_REGS_UNWIND_INFO(0)
    6.10  {	/*
    6.11  	 * Some versions of gas generate bad unwind info if the first instruction of a
    6.12 @@ -628,7 +628,7 @@ GLOBAL_ENTRY(ia64_ret_from_clone)
    6.13  	cmp.ne p6,p0=r2,r0
    6.14  (p6)	br.cond.spnt .strace_check_retval
    6.15  	;;					// added stop bits to prevent r8 dependency
    6.16 -END(ia64_ret_from_clone)
    6.17 +END(__ia64_ret_from_clone)
    6.18  	// fall through
    6.19  GLOBAL_ENTRY(ia64_ret_from_syscall)
    6.20  	PT_REGS_UNWIND_INFO(0)
     7.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/iosapic.c	Mon Dec 11 11:16:29 2006 -0800
     7.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/iosapic.c	Mon Dec 11 11:17:11 2006 -0800
     7.3 @@ -197,6 +197,16 @@ int xen_assign_irq_vector(int irq)
     7.4  
     7.5  	return irq_op.vector;
     7.6  }
     7.7 +
     7.8 +void xen_free_irq_vector(int vector)
     7.9 +{
    7.10 +	struct physdev_irq irq_op;
    7.11 +
    7.12 +	irq_op.vector = vector;
    7.13 +	if (HYPERVISOR_physdev_op(PHYSDEVOP_free_irq_vector, &irq_op))
    7.14 +		printk(KERN_WARNING "%s: xen_free_irq_vecotr fail vector=%d\n",
    7.15 +		       __FUNCTION__, vector);
    7.16 +}
    7.17  #endif /* XEN */
    7.18  
    7.19  /*
     8.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/irq_ia64.c	Mon Dec 11 11:16:29 2006 -0800
     8.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/irq_ia64.c	Mon Dec 11 11:17:11 2006 -0800
     8.3 @@ -94,6 +94,13 @@ free_irq_vector (int vector)
     8.4  	if (vector < IA64_FIRST_DEVICE_VECTOR || vector > IA64_LAST_DEVICE_VECTOR)
     8.5  		return;
     8.6  
     8.7 +#ifdef CONFIG_XEN
     8.8 +	if (is_running_on_xen()) {
     8.9 +		extern void xen_free_irq_vector(int);
    8.10 +		xen_free_irq_vector(vector);
    8.11 +		return;
    8.12 +	}
    8.13 +#endif
    8.14  	pos = vector - IA64_FIRST_DEVICE_VECTOR;
    8.15  	if (!test_and_clear_bit(pos, ia64_vector_mask))
    8.16  		printk(KERN_WARNING "%s: double free!\n", __FUNCTION__);
    8.17 @@ -241,9 +248,15 @@ static struct irqaction ipi_irqaction = 
    8.18  static DEFINE_PER_CPU(int, timer_irq) = -1;
    8.19  static DEFINE_PER_CPU(int, ipi_irq) = -1;
    8.20  static DEFINE_PER_CPU(int, resched_irq) = -1;
    8.21 +static DEFINE_PER_CPU(int, cmc_irq) = -1;
    8.22 +static DEFINE_PER_CPU(int, cmcp_irq) = -1;
    8.23 +static DEFINE_PER_CPU(int, cpep_irq) = -1;
    8.24  static char timer_name[NR_CPUS][15];
    8.25  static char ipi_name[NR_CPUS][15];
    8.26  static char resched_name[NR_CPUS][15];
    8.27 +static char cmc_name[NR_CPUS][15];
    8.28 +static char cmcp_name[NR_CPUS][15];
    8.29 +static char cpep_name[NR_CPUS][15];
    8.30  
    8.31  struct saved_irq {
    8.32  	unsigned int irq;
    8.33 @@ -323,6 +336,43 @@ xen_register_percpu_irq (unsigned int ir
    8.34  			break;
    8.35  		case IA64_SPURIOUS_INT_VECTOR:
    8.36  			break;
    8.37 +		case IA64_CMC_VECTOR:
    8.38 +			sprintf(cmc_name[cpu], "%s%d", action->name, cpu);
    8.39 +			ret = bind_virq_to_irqhandler(VIRQ_MCA_CMC, cpu,
    8.40 +			                              action->handler,
    8.41 +			                              action->flags,
    8.42 +			                              cmc_name[cpu],
    8.43 +			                              action->dev_id);
    8.44 +			per_cpu(cmc_irq,cpu) = ret;
    8.45 +			printk(KERN_INFO "register VIRQ_MCA_CMC (%s) to xen "
    8.46 +			       "irq (%d)\n", cmc_name[cpu], ret);
    8.47 +			break;
    8.48 +		case IA64_CMCP_VECTOR:
    8.49 +			sprintf(cmcp_name[cpu], "%s%d", action->name, cpu);
    8.50 +			ret = bind_ipi_to_irqhandler(CMCP_VECTOR, cpu,
    8.51 +			                             action->handler,
    8.52 +			                             action->flags,
    8.53 +			                             cmcp_name[cpu],
    8.54 +			                             action->dev_id);
    8.55 +			per_cpu(cmcp_irq,cpu) = ret;
    8.56 +			printk(KERN_INFO "register CMCP_VECTOR (%s) to xen "
    8.57 +			       "irq (%d)\n", cmcp_name[cpu], ret);
    8.58 +			break;
    8.59 +		case IA64_CPEP_VECTOR:
    8.60 +			sprintf(cpep_name[cpu], "%s%d", action->name, cpu);
    8.61 +			ret = bind_ipi_to_irqhandler(CPEP_VECTOR, cpu,
    8.62 +			                             action->handler,
    8.63 +			                             action->flags,
    8.64 +			                             cpep_name[cpu],
    8.65 +			                             action->dev_id);
    8.66 +			per_cpu(cpep_irq,cpu) = ret;
    8.67 +			printk(KERN_INFO "register CPEP_VECTOR (%s) to xen "
    8.68 +			       "irq (%d)\n", cpep_name[cpu], ret);
    8.69 +			break;
    8.70 +		case IA64_CPE_VECTOR:
    8.71 +			printk(KERN_WARNING "register IA64_CPE_VECTOR "
    8.72 +			       "IGNORED\n");
    8.73 +			break;
    8.74  		default:
    8.75  			printk(KERN_WARNING "Percpu irq %d is unsupported by xen!\n", irq);
    8.76  			break;
    8.77 @@ -373,6 +423,18 @@ unbind_evtchn_callback(struct notifier_b
    8.78  
    8.79  	if (action == CPU_DEAD) {
    8.80  		/* Unregister evtchn.  */
    8.81 +		if (per_cpu(cpep_irq,cpu) >= 0) {
    8.82 +			unbind_from_irqhandler(per_cpu(cpep_irq, cpu), NULL);
    8.83 +			per_cpu(cpep_irq, cpu) = -1;
    8.84 +		}
    8.85 +		if (per_cpu(cmcp_irq,cpu) >= 0) {
    8.86 +			unbind_from_irqhandler(per_cpu(cmcp_irq, cpu), NULL);
    8.87 +			per_cpu(cmcp_irq, cpu) = -1;
    8.88 +		}
    8.89 +		if (per_cpu(cmc_irq,cpu) >= 0) {
    8.90 +			unbind_from_irqhandler(per_cpu(cmc_irq, cpu), NULL);
    8.91 +			per_cpu(cmc_irq, cpu) = -1;
    8.92 +		}
    8.93  		if (per_cpu(ipi_irq,cpu) >= 0) {
    8.94  			unbind_from_irqhandler (per_cpu(ipi_irq, cpu), NULL);
    8.95  			per_cpu(ipi_irq, cpu) = -1;
    8.96 @@ -503,6 +565,12 @@ ia64_send_ipi (int cpu, int vector, int 
    8.97  		case IA64_IPI_RESCHEDULE:
    8.98  			irq = per_cpu(ipi_to_irq, cpu)[RESCHEDULE_VECTOR];
    8.99  			break;
   8.100 +		case IA64_CMCP_VECTOR:
   8.101 +			irq = per_cpu(ipi_to_irq, cpu)[CMCP_VECTOR];
   8.102 +			break;
   8.103 +		case IA64_CPEP_VECTOR:
   8.104 +			irq = per_cpu(ipi_to_irq, cpu)[CPEP_VECTOR];
   8.105 +			break;
   8.106  		default:
   8.107  			printk(KERN_WARNING"Unsupported IPI type 0x%x\n", vector);
   8.108  			irq = 0;
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/perfmon.c	Mon Dec 11 11:17:11 2006 -0800
     9.3 @@ -0,0 +1,6941 @@
     9.4 +/*
     9.5 + * This file implements the perfmon-2 subsystem which is used
     9.6 + * to program the IA-64 Performance Monitoring Unit (PMU).
     9.7 + *
     9.8 + * The initial version of perfmon.c was written by
     9.9 + * Ganesh Venkitachalam, IBM Corp.
    9.10 + *
    9.11 + * Then it was modified for perfmon-1.x by Stephane Eranian and
    9.12 + * David Mosberger, Hewlett Packard Co.
    9.13 + *
    9.14 + * Version Perfmon-2.x is a rewrite of perfmon-1.x
    9.15 + * by Stephane Eranian, Hewlett Packard Co.
    9.16 + *
    9.17 + * Copyright (C) 1999-2005  Hewlett Packard Co
    9.18 + *               Stephane Eranian <eranian@hpl.hp.com>
    9.19 + *               David Mosberger-Tang <davidm@hpl.hp.com>
    9.20 + *
    9.21 + * More information about perfmon available at:
    9.22 + * 	http://www.hpl.hp.com/research/linux/perfmon
    9.23 + */
    9.24 +
    9.25 +#include <linux/config.h>
    9.26 +#include <linux/module.h>
    9.27 +#include <linux/kernel.h>
    9.28 +#include <linux/sched.h>
    9.29 +#include <linux/interrupt.h>
    9.30 +#include <linux/smp_lock.h>
    9.31 +#include <linux/proc_fs.h>
    9.32 +#include <linux/seq_file.h>
    9.33 +#include <linux/init.h>
    9.34 +#include <linux/vmalloc.h>
    9.35 +#include <linux/mm.h>
    9.36 +#include <linux/sysctl.h>
    9.37 +#include <linux/list.h>
    9.38 +#include <linux/file.h>
    9.39 +#include <linux/poll.h>
    9.40 +#include <linux/vfs.h>
    9.41 +#include <linux/pagemap.h>
    9.42 +#include <linux/mount.h>
    9.43 +#include <linux/bitops.h>
    9.44 +#include <linux/capability.h>
    9.45 +#include <linux/rcupdate.h>
    9.46 +#include <linux/completion.h>
    9.47 +
    9.48 +#include <asm/errno.h>
    9.49 +#include <asm/intrinsics.h>
    9.50 +#include <asm/page.h>
    9.51 +#include <asm/perfmon.h>
    9.52 +#include <asm/processor.h>
    9.53 +#include <asm/signal.h>
    9.54 +#include <asm/system.h>
    9.55 +#include <asm/uaccess.h>
    9.56 +#include <asm/delay.h>
    9.57 +
    9.58 +#ifdef CONFIG_PERFMON
    9.59 +#ifdef CONFIG_XEN
    9.60 +//#include <xen/xenoprof.h>
    9.61 +#include <xen/interface/xenoprof.h>
    9.62 +
    9.63 +static int xenoprof_is_primary = 0;
    9.64 +#define init_xenoprof_primary(is_primary)  (xenoprof_is_primary = (is_primary))
    9.65 +#define is_xenoprof_primary()	(xenoprof_is_primary)
    9.66 +#define XEN_NOT_SUPPORTED_YET						\
    9.67 +	do {								\
    9.68 +		if (is_running_on_xen()) {				\
    9.69 +			printk("%s is not supported yet under xen.\n",	\
    9.70 +			       __func__);				\
    9.71 +			return -ENOSYS;					\
    9.72 +		}							\
    9.73 +	} while (0)
    9.74 +#else
    9.75 +#define init_xenoprof_primary(is_primary)	do { } while (0)
    9.76 +#define is_xenoprof_primary()			(0)
    9.77 +#define XEN_NOT_SUPPORTED_YET			do { } while (0)
    9.78 +#define HYPERVISOR_perfmon_op(cmd, arg, count)	do { } while (0)
    9.79 +#endif
    9.80 +
    9.81 +/*
    9.82 + * perfmon context state
    9.83 + */
    9.84 +#define PFM_CTX_UNLOADED	1	/* context is not loaded onto any task */
    9.85 +#define PFM_CTX_LOADED		2	/* context is loaded onto a task */
    9.86 +#define PFM_CTX_MASKED		3	/* context is loaded but monitoring is masked due to overflow */
    9.87 +#define PFM_CTX_ZOMBIE		4	/* owner of the context is closing it */
    9.88 +
    9.89 +#define PFM_INVALID_ACTIVATION	(~0UL)
    9.90 +
    9.91 +/*
    9.92 + * depth of message queue
    9.93 + */
    9.94 +#define PFM_MAX_MSGS		32
    9.95 +#define PFM_CTXQ_EMPTY(g)	((g)->ctx_msgq_head == (g)->ctx_msgq_tail)
    9.96 +
    9.97 +/*
    9.98 + * type of a PMU register (bitmask).
    9.99 + * bitmask structure:
   9.100 + * 	bit0   : register implemented
   9.101 + * 	bit1   : end marker
   9.102 + * 	bit2-3 : reserved
   9.103 + * 	bit4   : pmc has pmc.pm
   9.104 + * 	bit5   : pmc controls a counter (has pmc.oi), pmd is used as counter
   9.105 + * 	bit6-7 : register type
   9.106 + * 	bit8-31: reserved
   9.107 + */
   9.108 +#define PFM_REG_NOTIMPL		0x0 /* not implemented at all */
   9.109 +#define PFM_REG_IMPL		0x1 /* register implemented */
   9.110 +#define PFM_REG_END		0x2 /* end marker */
   9.111 +#define PFM_REG_MONITOR		(0x1<<4|PFM_REG_IMPL) /* a PMC with a pmc.pm field only */
   9.112 +#define PFM_REG_COUNTING	(0x2<<4|PFM_REG_MONITOR) /* a monitor + pmc.oi+ PMD used as a counter */
   9.113 +#define PFM_REG_CONTROL		(0x4<<4|PFM_REG_IMPL) /* PMU control register */
   9.114 +#define	PFM_REG_CONFIG		(0x8<<4|PFM_REG_IMPL) /* configuration register */
   9.115 +#define PFM_REG_BUFFER	 	(0xc<<4|PFM_REG_IMPL) /* PMD used as buffer */
   9.116 +
   9.117 +#define PMC_IS_LAST(i)	(pmu_conf->pmc_desc[i].type & PFM_REG_END)
   9.118 +#define PMD_IS_LAST(i)	(pmu_conf->pmd_desc[i].type & PFM_REG_END)
   9.119 +
   9.120 +#define PMC_OVFL_NOTIFY(ctx, i)	((ctx)->ctx_pmds[i].flags &  PFM_REGFL_OVFL_NOTIFY)
   9.121 +
   9.122 +/* i assumed unsigned */
   9.123 +#define PMC_IS_IMPL(i)	  (i< PMU_MAX_PMCS && (pmu_conf->pmc_desc[i].type & PFM_REG_IMPL))
   9.124 +#define PMD_IS_IMPL(i)	  (i< PMU_MAX_PMDS && (pmu_conf->pmd_desc[i].type & PFM_REG_IMPL))
   9.125 +
   9.126 +/* XXX: these assume that register i is implemented */
   9.127 +#define PMD_IS_COUNTING(i) ((pmu_conf->pmd_desc[i].type & PFM_REG_COUNTING) == PFM_REG_COUNTING)
   9.128 +#define PMC_IS_COUNTING(i) ((pmu_conf->pmc_desc[i].type & PFM_REG_COUNTING) == PFM_REG_COUNTING)
   9.129 +#define PMC_IS_MONITOR(i)  ((pmu_conf->pmc_desc[i].type & PFM_REG_MONITOR)  == PFM_REG_MONITOR)
   9.130 +#define PMC_IS_CONTROL(i)  ((pmu_conf->pmc_desc[i].type & PFM_REG_CONTROL)  == PFM_REG_CONTROL)
   9.131 +
   9.132 +#define PMC_DFL_VAL(i)     pmu_conf->pmc_desc[i].default_value
   9.133 +#define PMC_RSVD_MASK(i)   pmu_conf->pmc_desc[i].reserved_mask
   9.134 +#define PMD_PMD_DEP(i)	   pmu_conf->pmd_desc[i].dep_pmd[0]
   9.135 +#define PMC_PMD_DEP(i)	   pmu_conf->pmc_desc[i].dep_pmd[0]
   9.136 +
   9.137 +#define PFM_NUM_IBRS	  IA64_NUM_DBG_REGS
   9.138 +#define PFM_NUM_DBRS	  IA64_NUM_DBG_REGS
   9.139 +
   9.140 +#define CTX_OVFL_NOBLOCK(c)	((c)->ctx_fl_block == 0)
   9.141 +#define CTX_HAS_SMPL(c)		((c)->ctx_fl_is_sampling)
   9.142 +#define PFM_CTX_TASK(h)		(h)->ctx_task
   9.143 +
   9.144 +#define PMU_PMC_OI		5 /* position of pmc.oi bit */
   9.145 +
   9.146 +/* XXX: does not support more than 64 PMDs */
   9.147 +#define CTX_USED_PMD(ctx, mask) (ctx)->ctx_used_pmds[0] |= (mask)
   9.148 +#define CTX_IS_USED_PMD(ctx, c) (((ctx)->ctx_used_pmds[0] & (1UL << (c))) != 0UL)
   9.149 +
   9.150 +#define CTX_USED_MONITOR(ctx, mask) (ctx)->ctx_used_monitors[0] |= (mask)
   9.151 +
   9.152 +#define CTX_USED_IBR(ctx,n) 	(ctx)->ctx_used_ibrs[(n)>>6] |= 1UL<< ((n) % 64)
   9.153 +#define CTX_USED_DBR(ctx,n) 	(ctx)->ctx_used_dbrs[(n)>>6] |= 1UL<< ((n) % 64)
   9.154 +#define CTX_USES_DBREGS(ctx)	(((pfm_context_t *)(ctx))->ctx_fl_using_dbreg==1)
   9.155 +#define PFM_CODE_RR	0	/* requesting code range restriction */
   9.156 +#define PFM_DATA_RR	1	/* requestion data range restriction */
   9.157 +
   9.158 +#define PFM_CPUINFO_CLEAR(v)	pfm_get_cpu_var(pfm_syst_info) &= ~(v)
   9.159 +#define PFM_CPUINFO_SET(v)	pfm_get_cpu_var(pfm_syst_info) |= (v)
   9.160 +#define PFM_CPUINFO_GET()	pfm_get_cpu_var(pfm_syst_info)
   9.161 +
   9.162 +#define RDEP(x)	(1UL<<(x))
   9.163 +
   9.164 +/*
   9.165 + * context protection macros
   9.166 + * in SMP:
   9.167 + * 	- we need to protect against CPU concurrency (spin_lock)
   9.168 + * 	- we need to protect against PMU overflow interrupts (local_irq_disable)
   9.169 + * in UP:
   9.170 + * 	- we need to protect against PMU overflow interrupts (local_irq_disable)
   9.171 + *
   9.172 + * spin_lock_irqsave()/spin_lock_irqrestore():
   9.173 + * 	in SMP: local_irq_disable + spin_lock
   9.174 + * 	in UP : local_irq_disable
   9.175 + *
   9.176 + * spin_lock()/spin_lock():
   9.177 + * 	in UP : removed automatically
   9.178 + * 	in SMP: protect against context accesses from other CPU. interrupts
   9.179 + * 	        are not masked. This is useful for the PMU interrupt handler
   9.180 + * 	        because we know we will not get PMU concurrency in that code.
   9.181 + */
   9.182 +#define PROTECT_CTX(c, f) \
   9.183 +	do {  \
   9.184 +		DPRINT(("spinlock_irq_save ctx %p by [%d]\n", c, current->pid)); \
   9.185 +		spin_lock_irqsave(&(c)->ctx_lock, f); \
   9.186 +		DPRINT(("spinlocked ctx %p  by [%d]\n", c, current->pid)); \
   9.187 +	} while(0)
   9.188 +
   9.189 +#define UNPROTECT_CTX(c, f) \
   9.190 +	do { \
   9.191 +		DPRINT(("spinlock_irq_restore ctx %p by [%d]\n", c, current->pid)); \
   9.192 +		spin_unlock_irqrestore(&(c)->ctx_lock, f); \
   9.193 +	} while(0)
   9.194 +
   9.195 +#define PROTECT_CTX_NOPRINT(c, f) \
   9.196 +	do {  \
   9.197 +		spin_lock_irqsave(&(c)->ctx_lock, f); \
   9.198 +	} while(0)
   9.199 +
   9.200 +
   9.201 +#define UNPROTECT_CTX_NOPRINT(c, f) \
   9.202 +	do { \
   9.203 +		spin_unlock_irqrestore(&(c)->ctx_lock, f); \
   9.204 +	} while(0)
   9.205 +
   9.206 +
   9.207 +#define PROTECT_CTX_NOIRQ(c) \
   9.208 +	do {  \
   9.209 +		spin_lock(&(c)->ctx_lock); \
   9.210 +	} while(0)
   9.211 +
   9.212 +#define UNPROTECT_CTX_NOIRQ(c) \
   9.213 +	do { \
   9.214 +		spin_unlock(&(c)->ctx_lock); \
   9.215 +	} while(0)
   9.216 +
   9.217 +
   9.218 +#ifdef CONFIG_SMP
   9.219 +
   9.220 +#define GET_ACTIVATION()	pfm_get_cpu_var(pmu_activation_number)
   9.221 +#define INC_ACTIVATION()	pfm_get_cpu_var(pmu_activation_number)++
   9.222 +#define SET_ACTIVATION(c)	(c)->ctx_last_activation = GET_ACTIVATION()
   9.223 +
   9.224 +#else /* !CONFIG_SMP */
   9.225 +#define SET_ACTIVATION(t) 	do {} while(0)
   9.226 +#define GET_ACTIVATION(t) 	do {} while(0)
   9.227 +#define INC_ACTIVATION(t) 	do {} while(0)
   9.228 +#endif /* CONFIG_SMP */
   9.229 +
   9.230 +#define SET_PMU_OWNER(t, c)	do { pfm_get_cpu_var(pmu_owner) = (t); pfm_get_cpu_var(pmu_ctx) = (c); } while(0)
   9.231 +#define GET_PMU_OWNER()		pfm_get_cpu_var(pmu_owner)
   9.232 +#define GET_PMU_CTX()		pfm_get_cpu_var(pmu_ctx)
   9.233 +
   9.234 +#define LOCK_PFS(g)	    	spin_lock_irqsave(&pfm_sessions.pfs_lock, g)
   9.235 +#define UNLOCK_PFS(g)	    	spin_unlock_irqrestore(&pfm_sessions.pfs_lock, g)
   9.236 +
   9.237 +#define PFM_REG_RETFLAG_SET(flags, val)	do { flags &= ~PFM_REG_RETFL_MASK; flags |= (val); } while(0)
   9.238 +
   9.239 +/*
   9.240 + * cmp0 must be the value of pmc0
   9.241 + */
   9.242 +#define PMC0_HAS_OVFL(cmp0)  (cmp0 & ~0x1UL)
   9.243 +
   9.244 +#define PFMFS_MAGIC 0xa0b4d889
   9.245 +
   9.246 +/*
   9.247 + * debugging
   9.248 + */
   9.249 +#define PFM_DEBUGGING 1
   9.250 +#ifdef PFM_DEBUGGING
   9.251 +#define DPRINT(a) \
   9.252 +	do { \
   9.253 +		if (unlikely(pfm_sysctl.debug >0)) { printk("%s.%d: CPU%d [%d] ", __FUNCTION__, __LINE__, smp_processor_id(), current->pid); printk a; } \
   9.254 +	} while (0)
   9.255 +
   9.256 +#define DPRINT_ovfl(a) \
   9.257 +	do { \
   9.258 +		if (unlikely(pfm_sysctl.debug > 0 && pfm_sysctl.debug_ovfl >0)) { printk("%s.%d: CPU%d [%d] ", __FUNCTION__, __LINE__, smp_processor_id(), current->pid); printk a; } \
   9.259 +	} while (0)
   9.260 +#endif
   9.261 +
   9.262 +/*
   9.263 + * 64-bit software counter structure
   9.264 + *
   9.265 + * the next_reset_type is applied to the next call to pfm_reset_regs()
   9.266 + */
   9.267 +typedef struct {
   9.268 +	unsigned long	val;		/* virtual 64bit counter value */
   9.269 +	unsigned long	lval;		/* last reset value */
   9.270 +	unsigned long	long_reset;	/* reset value on sampling overflow */
   9.271 +	unsigned long	short_reset;    /* reset value on overflow */
   9.272 +	unsigned long	reset_pmds[4];  /* which other pmds to reset when this counter overflows */
   9.273 +	unsigned long	smpl_pmds[4];   /* which pmds are accessed when counter overflow */
   9.274 +	unsigned long	seed;		/* seed for random-number generator */
   9.275 +	unsigned long	mask;		/* mask for random-number generator */
   9.276 +	unsigned int 	flags;		/* notify/do not notify */
   9.277 +	unsigned long	eventid;	/* overflow event identifier */
   9.278 +} pfm_counter_t;
   9.279 +
   9.280 +/*
   9.281 + * context flags
   9.282 + */
   9.283 +typedef struct {
   9.284 +	unsigned int block:1;		/* when 1, task will blocked on user notifications */
   9.285 +	unsigned int system:1;		/* do system wide monitoring */
   9.286 +	unsigned int using_dbreg:1;	/* using range restrictions (debug registers) */
   9.287 +	unsigned int is_sampling:1;	/* true if using a custom format */
   9.288 +	unsigned int excl_idle:1;	/* exclude idle task in system wide session */
   9.289 +	unsigned int going_zombie:1;	/* context is zombie (MASKED+blocking) */
   9.290 +	unsigned int trap_reason:2;	/* reason for going into pfm_handle_work() */
   9.291 +	unsigned int no_msg:1;		/* no message sent on overflow */
   9.292 +	unsigned int can_restart:1;	/* allowed to issue a PFM_RESTART */
   9.293 +	unsigned int reserved:22;
   9.294 +} pfm_context_flags_t;
   9.295 +
   9.296 +#define PFM_TRAP_REASON_NONE		0x0	/* default value */
   9.297 +#define PFM_TRAP_REASON_BLOCK		0x1	/* we need to block on overflow */
   9.298 +#define PFM_TRAP_REASON_RESET		0x2	/* we need to reset PMDs */
   9.299 +
   9.300 +
   9.301 +/*
   9.302 + * perfmon context: encapsulates all the state of a monitoring session
   9.303 + */
   9.304 +
   9.305 +typedef struct pfm_context {
   9.306 +	spinlock_t		ctx_lock;		/* context protection */
   9.307 +
   9.308 +	pfm_context_flags_t	ctx_flags;		/* bitmask of flags  (block reason incl.) */
   9.309 +	unsigned int		ctx_state;		/* state: active/inactive (no bitfield) */
   9.310 +
   9.311 +	struct task_struct 	*ctx_task;		/* task to which context is attached */
   9.312 +
   9.313 +	unsigned long		ctx_ovfl_regs[4];	/* which registers overflowed (notification) */
   9.314 +
   9.315 +	struct completion	ctx_restart_done;  	/* use for blocking notification mode */
   9.316 +
   9.317 +	unsigned long		ctx_used_pmds[4];	/* bitmask of PMD used            */
   9.318 +	unsigned long		ctx_all_pmds[4];	/* bitmask of all accessible PMDs */
   9.319 +	unsigned long		ctx_reload_pmds[4];	/* bitmask of force reload PMD on ctxsw in */
   9.320 +
   9.321 +	unsigned long		ctx_all_pmcs[4];	/* bitmask of all accessible PMCs */
   9.322 +	unsigned long		ctx_reload_pmcs[4];	/* bitmask of force reload PMC on ctxsw in */
   9.323 +	unsigned long		ctx_used_monitors[4];	/* bitmask of monitor PMC being used */
   9.324 +
   9.325 +	unsigned long		ctx_pmcs[IA64_NUM_PMC_REGS];	/*  saved copies of PMC values */
   9.326 +
   9.327 +	unsigned int		ctx_used_ibrs[1];		/* bitmask of used IBR (speedup ctxsw in) */
   9.328 +	unsigned int		ctx_used_dbrs[1];		/* bitmask of used DBR (speedup ctxsw in) */
   9.329 +	unsigned long		ctx_dbrs[IA64_NUM_DBG_REGS];	/* DBR values (cache) when not loaded */
   9.330 +	unsigned long		ctx_ibrs[IA64_NUM_DBG_REGS];	/* IBR values (cache) when not loaded */
   9.331 +
   9.332 +	pfm_counter_t		ctx_pmds[IA64_NUM_PMD_REGS]; /* software state for PMDS */
   9.333 +
   9.334 +	u64			ctx_saved_psr_up;	/* only contains psr.up value */
   9.335 +
   9.336 +	unsigned long		ctx_last_activation;	/* context last activation number for last_cpu */
   9.337 +	unsigned int		ctx_last_cpu;		/* CPU id of current or last CPU used (SMP only) */
   9.338 +	unsigned int		ctx_cpu;		/* cpu to which perfmon is applied (system wide) */
   9.339 +
   9.340 +	int			ctx_fd;			/* file descriptor used my this context */
   9.341 +	pfm_ovfl_arg_t		ctx_ovfl_arg;		/* argument to custom buffer format handler */
   9.342 +
   9.343 +	pfm_buffer_fmt_t	*ctx_buf_fmt;		/* buffer format callbacks */
   9.344 +	void			*ctx_smpl_hdr;		/* points to sampling buffer header kernel vaddr */
   9.345 +	unsigned long		ctx_smpl_size;		/* size of sampling buffer */
   9.346 +	void			*ctx_smpl_vaddr;	/* user level virtual address of smpl buffer */
   9.347 +
   9.348 +	wait_queue_head_t 	ctx_msgq_wait;
   9.349 +	pfm_msg_t		ctx_msgq[PFM_MAX_MSGS];
   9.350 +	int			ctx_msgq_head;
   9.351 +	int			ctx_msgq_tail;
   9.352 +	struct fasync_struct	*ctx_async_queue;
   9.353 +
   9.354 +	wait_queue_head_t 	ctx_zombieq;		/* termination cleanup wait queue */
   9.355 +} pfm_context_t;
   9.356 +
   9.357 +/*
   9.358 + * magic number used to verify that structure is really
   9.359 + * a perfmon context
   9.360 + */
   9.361 +#define PFM_IS_FILE(f)		((f)->f_op == &pfm_file_ops)
   9.362 +
   9.363 +#define PFM_GET_CTX(t)	 	((pfm_context_t *)(t)->thread.pfm_context)
   9.364 +
   9.365 +#ifdef CONFIG_SMP
   9.366 +#define SET_LAST_CPU(ctx, v)	(ctx)->ctx_last_cpu = (v)
   9.367 +#define GET_LAST_CPU(ctx)	(ctx)->ctx_last_cpu
   9.368 +#else
   9.369 +#define SET_LAST_CPU(ctx, v)	do {} while(0)
   9.370 +#define GET_LAST_CPU(ctx)	do {} while(0)
   9.371 +#endif
   9.372 +
   9.373 +
   9.374 +#define ctx_fl_block		ctx_flags.block
   9.375 +#define ctx_fl_system		ctx_flags.system
   9.376 +#define ctx_fl_using_dbreg	ctx_flags.using_dbreg
   9.377 +#define ctx_fl_is_sampling	ctx_flags.is_sampling
   9.378 +#define ctx_fl_excl_idle	ctx_flags.excl_idle
   9.379 +#define ctx_fl_going_zombie	ctx_flags.going_zombie
   9.380 +#define ctx_fl_trap_reason	ctx_flags.trap_reason
   9.381 +#define ctx_fl_no_msg		ctx_flags.no_msg
   9.382 +#define ctx_fl_can_restart	ctx_flags.can_restart
   9.383 +
   9.384 +#define PFM_SET_WORK_PENDING(t, v)	do { (t)->thread.pfm_needs_checking = v; } while(0);
   9.385 +#define PFM_GET_WORK_PENDING(t)		(t)->thread.pfm_needs_checking
   9.386 +
   9.387 +/*
   9.388 + * global information about all sessions
   9.389 + * mostly used to synchronize between system wide and per-process
   9.390 + */
   9.391 +typedef struct {
   9.392 +	spinlock_t		pfs_lock;		   /* lock the structure */
   9.393 +
   9.394 +	unsigned int		pfs_task_sessions;	   /* number of per task sessions */
   9.395 +	unsigned int		pfs_sys_sessions;	   /* number of per system wide sessions */
   9.396 +	unsigned int		pfs_sys_use_dbregs;	   /* incremented when a system wide session uses debug regs */
   9.397 +	unsigned int		pfs_ptrace_use_dbregs;	   /* incremented when a process uses debug regs */
   9.398 +	struct task_struct	*pfs_sys_session[NR_CPUS]; /* point to task owning a system-wide session */
   9.399 +} pfm_session_t;
   9.400 +
   9.401 +/*
   9.402 + * information about a PMC or PMD.
   9.403 + * dep_pmd[]: a bitmask of dependent PMD registers
   9.404 + * dep_pmc[]: a bitmask of dependent PMC registers
   9.405 + */
   9.406 +typedef int (*pfm_reg_check_t)(struct task_struct *task, pfm_context_t *ctx, unsigned int cnum, unsigned long *val, struct pt_regs *regs);
   9.407 +typedef struct {
   9.408 +	unsigned int		type;
   9.409 +	int			pm_pos;
   9.410 +	unsigned long		default_value;	/* power-on default value */
   9.411 +	unsigned long		reserved_mask;	/* bitmask of reserved bits */
   9.412 +	pfm_reg_check_t		read_check;
   9.413 +	pfm_reg_check_t		write_check;
   9.414 +	unsigned long		dep_pmd[4];
   9.415 +	unsigned long		dep_pmc[4];
   9.416 +} pfm_reg_desc_t;
   9.417 +
   9.418 +/* assume cnum is a valid monitor */
   9.419 +#define PMC_PM(cnum, val)	(((val) >> (pmu_conf->pmc_desc[cnum].pm_pos)) & 0x1)
   9.420 +
   9.421 +/*
   9.422 + * This structure is initialized at boot time and contains
   9.423 + * a description of the PMU main characteristics.
   9.424 + *
   9.425 + * If the probe function is defined, detection is based
   9.426 + * on its return value: 
   9.427 + * 	- 0 means recognized PMU
   9.428 + * 	- anything else means not supported
   9.429 + * When the probe function is not defined, then the pmu_family field
   9.430 + * is used and it must match the host CPU family such that:
   9.431 + * 	- cpu->family & config->pmu_family != 0
   9.432 + */
   9.433 +typedef struct {
   9.434 +	unsigned long  ovfl_val;	/* overflow value for counters */
   9.435 +
   9.436 +	pfm_reg_desc_t *pmc_desc;	/* detailed PMC register dependencies descriptions */
   9.437 +	pfm_reg_desc_t *pmd_desc;	/* detailed PMD register dependencies descriptions */
   9.438 +
   9.439 +	unsigned int   num_pmcs;	/* number of PMCS: computed at init time */
   9.440 +	unsigned int   num_pmds;	/* number of PMDS: computed at init time */
   9.441 +	unsigned long  impl_pmcs[4];	/* bitmask of implemented PMCS */
   9.442 +	unsigned long  impl_pmds[4];	/* bitmask of implemented PMDS */
   9.443 +
   9.444 +	char	      *pmu_name;	/* PMU family name */
   9.445 +	unsigned int  pmu_family;	/* cpuid family pattern used to identify pmu */
   9.446 +	unsigned int  flags;		/* pmu specific flags */
   9.447 +	unsigned int  num_ibrs;		/* number of IBRS: computed at init time */
   9.448 +	unsigned int  num_dbrs;		/* number of DBRS: computed at init time */
   9.449 +	unsigned int  num_counters;	/* PMC/PMD counting pairs : computed at init time */
   9.450 +	int           (*probe)(void);   /* customized probe routine */
   9.451 +	unsigned int  use_rr_dbregs:1;	/* set if debug registers used for range restriction */
   9.452 +} pmu_config_t;
   9.453 +/*
   9.454 + * PMU specific flags
   9.455 + */
   9.456 +#define PFM_PMU_IRQ_RESEND	1	/* PMU needs explicit IRQ resend */
   9.457 +
   9.458 +/*
   9.459 + * debug register related type definitions
   9.460 + */
   9.461 +typedef struct {
   9.462 +	unsigned long ibr_mask:56;
   9.463 +	unsigned long ibr_plm:4;
   9.464 +	unsigned long ibr_ig:3;
   9.465 +	unsigned long ibr_x:1;
   9.466 +} ibr_mask_reg_t;
   9.467 +
   9.468 +typedef struct {
   9.469 +	unsigned long dbr_mask:56;
   9.470 +	unsigned long dbr_plm:4;
   9.471 +	unsigned long dbr_ig:2;
   9.472 +	unsigned long dbr_w:1;
   9.473 +	unsigned long dbr_r:1;
   9.474 +} dbr_mask_reg_t;
   9.475 +
   9.476 +typedef union {
   9.477 +	unsigned long  val;
   9.478 +	ibr_mask_reg_t ibr;
   9.479 +	dbr_mask_reg_t dbr;
   9.480 +} dbreg_t;
   9.481 +
   9.482 +
   9.483 +/*
   9.484 + * perfmon command descriptions
   9.485 + */
   9.486 +typedef struct {
   9.487 +	int		(*cmd_func)(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs);
   9.488 +	char		*cmd_name;
   9.489 +	int		cmd_flags;
   9.490 +	unsigned int	cmd_narg;
   9.491 +	size_t		cmd_argsize;
   9.492 +	int		(*cmd_getsize)(void *arg, size_t *sz);
   9.493 +} pfm_cmd_desc_t;
   9.494 +
   9.495 +#define PFM_CMD_FD		0x01	/* command requires a file descriptor */
   9.496 +#define PFM_CMD_ARG_READ	0x02	/* command must read argument(s) */
   9.497 +#define PFM_CMD_ARG_RW		0x04	/* command must read/write argument(s) */
   9.498 +#define PFM_CMD_STOP		0x08	/* command does not work on zombie context */
   9.499 +
   9.500 +
   9.501 +#define PFM_CMD_NAME(cmd)	pfm_cmd_tab[(cmd)].cmd_name
   9.502 +#define PFM_CMD_READ_ARG(cmd)	(pfm_cmd_tab[(cmd)].cmd_flags & PFM_CMD_ARG_READ)
   9.503 +#define PFM_CMD_RW_ARG(cmd)	(pfm_cmd_tab[(cmd)].cmd_flags & PFM_CMD_ARG_RW)
   9.504 +#define PFM_CMD_USE_FD(cmd)	(pfm_cmd_tab[(cmd)].cmd_flags & PFM_CMD_FD)
   9.505 +#define PFM_CMD_STOPPED(cmd)	(pfm_cmd_tab[(cmd)].cmd_flags & PFM_CMD_STOP)
   9.506 +
   9.507 +#define PFM_CMD_ARG_MANY	-1 /* cannot be zero */
   9.508 +
   9.509 +typedef struct {
   9.510 +	unsigned long pfm_spurious_ovfl_intr_count;	/* keep track of spurious ovfl interrupts */
   9.511 +	unsigned long pfm_replay_ovfl_intr_count;	/* keep track of replayed ovfl interrupts */
   9.512 +	unsigned long pfm_ovfl_intr_count; 		/* keep track of ovfl interrupts */
   9.513 +	unsigned long pfm_ovfl_intr_cycles;		/* cycles spent processing ovfl interrupts */
   9.514 +	unsigned long pfm_ovfl_intr_cycles_min;		/* min cycles spent processing ovfl interrupts */
   9.515 +	unsigned long pfm_ovfl_intr_cycles_max;		/* max cycles spent processing ovfl interrupts */
   9.516 +	unsigned long pfm_smpl_handler_calls;
   9.517 +	unsigned long pfm_smpl_handler_cycles;
   9.518 +	char pad[SMP_CACHE_BYTES] ____cacheline_aligned;
   9.519 +} pfm_stats_t;
   9.520 +
   9.521 +/*
   9.522 + * perfmon internal variables
   9.523 + */
   9.524 +static pfm_stats_t		pfm_stats[NR_CPUS];
   9.525 +static pfm_session_t		pfm_sessions;	/* global sessions information */
   9.526 +
   9.527 +static DEFINE_SPINLOCK(pfm_alt_install_check);
   9.528 +static pfm_intr_handler_desc_t  *pfm_alt_intr_handler;
   9.529 +
   9.530 +static struct proc_dir_entry 	*perfmon_dir;
   9.531 +static pfm_uuid_t		pfm_null_uuid = {0,};
   9.532 +
   9.533 +static spinlock_t		pfm_buffer_fmt_lock;
   9.534 +static LIST_HEAD(pfm_buffer_fmt_list);
   9.535 +
   9.536 +static pmu_config_t		*pmu_conf;
   9.537 +
   9.538 +/* sysctl() controls */
   9.539 +pfm_sysctl_t pfm_sysctl;
   9.540 +EXPORT_SYMBOL(pfm_sysctl);
   9.541 +
   9.542 +static ctl_table pfm_ctl_table[]={
   9.543 +	{1, "debug", &pfm_sysctl.debug, sizeof(int), 0666, NULL, &proc_dointvec, NULL,},
   9.544 +	{2, "debug_ovfl", &pfm_sysctl.debug_ovfl, sizeof(int), 0666, NULL, &proc_dointvec, NULL,},
   9.545 +	{3, "fastctxsw", &pfm_sysctl.fastctxsw, sizeof(int), 0600, NULL, &proc_dointvec, NULL,},
   9.546 +	{4, "expert_mode", &pfm_sysctl.expert_mode, sizeof(int), 0600, NULL, &proc_dointvec, NULL,},
   9.547 +	{ 0, },
   9.548 +};
   9.549 +static ctl_table pfm_sysctl_dir[] = {
   9.550 +	{1, "perfmon", NULL, 0, 0755, pfm_ctl_table, },
   9.551 + 	{0,},
   9.552 +};
   9.553 +static ctl_table pfm_sysctl_root[] = {
   9.554 +	{1, "kernel", NULL, 0, 0755, pfm_sysctl_dir, },
   9.555 + 	{0,},
   9.556 +};
   9.557 +static struct ctl_table_header *pfm_sysctl_header;
   9.558 +
   9.559 +static int pfm_context_unload(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs);
   9.560 +static int pfm_flush(struct file *filp);
   9.561 +
   9.562 +#define pfm_get_cpu_var(v)		__ia64_per_cpu_var(v)
   9.563 +#define pfm_get_cpu_data(a,b)		per_cpu(a, b)
   9.564 +
   9.565 +static inline void
   9.566 +pfm_put_task(struct task_struct *task)
   9.567 +{
   9.568 +	if (task != current) put_task_struct(task);
   9.569 +}
   9.570 +
   9.571 +static inline void
   9.572 +pfm_set_task_notify(struct task_struct *task)
   9.573 +{
   9.574 +	struct thread_info *info;
   9.575 +
   9.576 +	info = (struct thread_info *) ((char *) task + IA64_TASK_SIZE);
   9.577 +	set_bit(TIF_NOTIFY_RESUME, &info->flags);
   9.578 +}
   9.579 +
   9.580 +static inline void
   9.581 +pfm_clear_task_notify(void)
   9.582 +{
   9.583 +	clear_thread_flag(TIF_NOTIFY_RESUME);
   9.584 +}
   9.585 +
   9.586 +static inline void
   9.587 +pfm_reserve_page(unsigned long a)
   9.588 +{
   9.589 +	SetPageReserved(vmalloc_to_page((void *)a));
   9.590 +}
   9.591 +static inline void
   9.592 +pfm_unreserve_page(unsigned long a)
   9.593 +{
   9.594 +	ClearPageReserved(vmalloc_to_page((void*)a));
   9.595 +}
   9.596 +
   9.597 +static inline unsigned long
   9.598 +pfm_protect_ctx_ctxsw(pfm_context_t *x)
   9.599 +{
   9.600 +	spin_lock(&(x)->ctx_lock);
   9.601 +	return 0UL;
   9.602 +}
   9.603 +
   9.604 +static inline void
   9.605 +pfm_unprotect_ctx_ctxsw(pfm_context_t *x, unsigned long f)
   9.606 +{
   9.607 +	spin_unlock(&(x)->ctx_lock);
   9.608 +}
   9.609 +
   9.610 +static inline unsigned int
   9.611 +pfm_do_munmap(struct mm_struct *mm, unsigned long addr, size_t len, int acct)
   9.612 +{
   9.613 +	return do_munmap(mm, addr, len);
   9.614 +}
   9.615 +
   9.616 +static inline unsigned long 
   9.617 +pfm_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, unsigned long exec)
   9.618 +{
   9.619 +	return get_unmapped_area(file, addr, len, pgoff, flags);
   9.620 +}
   9.621 +
   9.622 +
   9.623 +static struct super_block *
   9.624 +pfmfs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
   9.625 +{
   9.626 +	return get_sb_pseudo(fs_type, "pfm:", NULL, PFMFS_MAGIC);
   9.627 +}
   9.628 +
   9.629 +static struct file_system_type pfm_fs_type = {
   9.630 +	.name     = "pfmfs",
   9.631 +	.get_sb   = pfmfs_get_sb,
   9.632 +	.kill_sb  = kill_anon_super,
   9.633 +};
   9.634 +
   9.635 +DEFINE_PER_CPU(unsigned long, pfm_syst_info);
   9.636 +DEFINE_PER_CPU(struct task_struct *, pmu_owner);
   9.637 +DEFINE_PER_CPU(pfm_context_t  *, pmu_ctx);
   9.638 +DEFINE_PER_CPU(unsigned long, pmu_activation_number);
   9.639 +EXPORT_PER_CPU_SYMBOL_GPL(pfm_syst_info);
   9.640 +
   9.641 +
   9.642 +/* forward declaration */
   9.643 +static struct file_operations pfm_file_ops;
   9.644 +
   9.645 +/*
   9.646 + * forward declarations
   9.647 + */
   9.648 +#ifndef CONFIG_SMP
   9.649 +static void pfm_lazy_save_regs (struct task_struct *ta);
   9.650 +#endif
   9.651 +
   9.652 +void dump_pmu_state(const char *);
   9.653 +static int pfm_write_ibr_dbr(int mode, pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs);
   9.654 +
   9.655 +#include "perfmon_itanium.h"
   9.656 +#include "perfmon_mckinley.h"
   9.657 +#include "perfmon_montecito.h"
   9.658 +#include "perfmon_generic.h"
   9.659 +
   9.660 +static pmu_config_t *pmu_confs[]={
   9.661 +	&pmu_conf_mont,
   9.662 +	&pmu_conf_mck,
   9.663 +	&pmu_conf_ita,
   9.664 +	&pmu_conf_gen, /* must be last */
   9.665 +	NULL
   9.666 +};
   9.667 +
   9.668 +
   9.669 +static int pfm_end_notify_user(pfm_context_t *ctx);
   9.670 +
   9.671 +static inline void
   9.672 +pfm_clear_psr_pp(void)
   9.673 +{
   9.674 +	ia64_rsm(IA64_PSR_PP);
   9.675 +	ia64_srlz_i();
   9.676 +}
   9.677 +
   9.678 +static inline void
   9.679 +pfm_set_psr_pp(void)
   9.680 +{
   9.681 +	ia64_ssm(IA64_PSR_PP);
   9.682 +	ia64_srlz_i();
   9.683 +}
   9.684 +
   9.685 +static inline void
   9.686 +pfm_clear_psr_up(void)
   9.687 +{
   9.688 +	ia64_rsm(IA64_PSR_UP);
   9.689 +	ia64_srlz_i();
   9.690 +}
   9.691 +
   9.692 +static inline void
   9.693 +pfm_set_psr_up(void)
   9.694 +{
   9.695 +	ia64_ssm(IA64_PSR_UP);
   9.696 +	ia64_srlz_i();
   9.697 +}
   9.698 +
   9.699 +static inline unsigned long
   9.700 +pfm_get_psr(void)
   9.701 +{
   9.702 +	unsigned long tmp;
   9.703 +	tmp = ia64_getreg(_IA64_REG_PSR);
   9.704 +	ia64_srlz_i();
   9.705 +	return tmp;
   9.706 +}
   9.707 +
   9.708 +static inline void
   9.709 +pfm_set_psr_l(unsigned long val)
   9.710 +{
   9.711 +	ia64_setreg(_IA64_REG_PSR_L, val);
   9.712 +	ia64_srlz_i();
   9.713 +}
   9.714 +
   9.715 +static inline void
   9.716 +pfm_freeze_pmu(void)
   9.717 +{
   9.718 +	ia64_set_pmc(0,1UL);
   9.719 +	ia64_srlz_d();
   9.720 +}
   9.721 +
   9.722 +static inline void
   9.723 +pfm_unfreeze_pmu(void)
   9.724 +{
   9.725 +	ia64_set_pmc(0,0UL);
   9.726 +	ia64_srlz_d();
   9.727 +}
   9.728 +
   9.729 +static inline void
   9.730 +pfm_restore_ibrs(unsigned long *ibrs, unsigned int nibrs)
   9.731 +{
   9.732 +	int i;
   9.733 +
   9.734 +	for (i=0; i < nibrs; i++) {
   9.735 +		ia64_set_ibr(i, ibrs[i]);
   9.736 +		ia64_dv_serialize_instruction();
   9.737 +	}
   9.738 +	ia64_srlz_i();
   9.739 +}
   9.740 +
   9.741 +static inline void
   9.742 +pfm_restore_dbrs(unsigned long *dbrs, unsigned int ndbrs)
   9.743 +{
   9.744 +	int i;
   9.745 +
   9.746 +	for (i=0; i < ndbrs; i++) {
   9.747 +		ia64_set_dbr(i, dbrs[i]);
   9.748 +		ia64_dv_serialize_data();
   9.749 +	}
   9.750 +	ia64_srlz_d();
   9.751 +}
   9.752 +
   9.753 +/*
   9.754 + * PMD[i] must be a counter. no check is made
   9.755 + */
   9.756 +static inline unsigned long
   9.757 +pfm_read_soft_counter(pfm_context_t *ctx, int i)
   9.758 +{
   9.759 +	return ctx->ctx_pmds[i].val + (ia64_get_pmd(i) & pmu_conf->ovfl_val);
   9.760 +}
   9.761 +
   9.762 +/*
   9.763 + * PMD[i] must be a counter. no check is made
   9.764 + */
   9.765 +static inline void
   9.766 +pfm_write_soft_counter(pfm_context_t *ctx, int i, unsigned long val)
   9.767 +{
   9.768 +	unsigned long ovfl_val = pmu_conf->ovfl_val;
   9.769 +
   9.770 +	ctx->ctx_pmds[i].val = val  & ~ovfl_val;
   9.771 +	/*
   9.772 +	 * writing to unimplemented part is ignore, so we do not need to
   9.773 +	 * mask off top part
   9.774 +	 */
   9.775 +	ia64_set_pmd(i, val & ovfl_val);
   9.776 +}
   9.777 +
   9.778 +static pfm_msg_t *
   9.779 +pfm_get_new_msg(pfm_context_t *ctx)
   9.780 +{
   9.781 +	int idx, next;
   9.782 +
   9.783 +	next = (ctx->ctx_msgq_tail+1) % PFM_MAX_MSGS;
   9.784 +
   9.785 +	DPRINT(("ctx_fd=%p head=%d tail=%d\n", ctx, ctx->ctx_msgq_head, ctx->ctx_msgq_tail));
   9.786 +	if (next == ctx->ctx_msgq_head) return NULL;
   9.787 +
   9.788 + 	idx = 	ctx->ctx_msgq_tail;
   9.789 +	ctx->ctx_msgq_tail = next;
   9.790 +
   9.791 +	DPRINT(("ctx=%p head=%d tail=%d msg=%d\n", ctx, ctx->ctx_msgq_head, ctx->ctx_msgq_tail, idx));
   9.792 +
   9.793 +	return ctx->ctx_msgq+idx;
   9.794 +}
   9.795 +
   9.796 +static pfm_msg_t *
   9.797 +pfm_get_next_msg(pfm_context_t *ctx)
   9.798 +{
   9.799 +	pfm_msg_t *msg;
   9.800 +
   9.801 +	DPRINT(("ctx=%p head=%d tail=%d\n", ctx, ctx->ctx_msgq_head, ctx->ctx_msgq_tail));
   9.802 +
   9.803 +	if (PFM_CTXQ_EMPTY(ctx)) return NULL;
   9.804 +
   9.805 +	/*
   9.806 +	 * get oldest message
   9.807 +	 */
   9.808 +	msg = ctx->ctx_msgq+ctx->ctx_msgq_head;
   9.809 +
   9.810 +	/*
   9.811 +	 * and move forward
   9.812 +	 */
   9.813 +	ctx->ctx_msgq_head = (ctx->ctx_msgq_head+1) % PFM_MAX_MSGS;
   9.814 +
   9.815 +	DPRINT(("ctx=%p head=%d tail=%d type=%d\n", ctx, ctx->ctx_msgq_head, ctx->ctx_msgq_tail, msg->pfm_gen_msg.msg_type));
   9.816 +
   9.817 +	return msg;
   9.818 +}
   9.819 +
   9.820 +static void
   9.821 +pfm_reset_msgq(pfm_context_t *ctx)
   9.822 +{
   9.823 +	ctx->ctx_msgq_head = ctx->ctx_msgq_tail = 0;
   9.824 +	DPRINT(("ctx=%p msgq reset\n", ctx));
   9.825 +}
   9.826 +
   9.827 +static void *
   9.828 +pfm_rvmalloc(unsigned long size)
   9.829 +{
   9.830 +	void *mem;
   9.831 +	unsigned long addr;
   9.832 +
   9.833 +	size = PAGE_ALIGN(size);
   9.834 +	mem  = vmalloc(size);
   9.835 +	if (mem) {
   9.836 +		//printk("perfmon: CPU%d pfm_rvmalloc(%ld)=%p\n", smp_processor_id(), size, mem);
   9.837 +		memset(mem, 0, size);
   9.838 +		addr = (unsigned long)mem;
   9.839 +		while (size > 0) {
   9.840 +			pfm_reserve_page(addr);
   9.841 +			addr+=PAGE_SIZE;
   9.842 +			size-=PAGE_SIZE;
   9.843 +		}
   9.844 +	}
   9.845 +	return mem;
   9.846 +}
   9.847 +
   9.848 +static void
   9.849 +pfm_rvfree(void *mem, unsigned long size)
   9.850 +{
   9.851 +	unsigned long addr;
   9.852 +
   9.853 +	if (mem) {
   9.854 +		DPRINT(("freeing physical buffer @%p size=%lu\n", mem, size));
   9.855 +		addr = (unsigned long) mem;
   9.856 +		while ((long) size > 0) {
   9.857 +			pfm_unreserve_page(addr);
   9.858 +			addr+=PAGE_SIZE;
   9.859 +			size-=PAGE_SIZE;
   9.860 +		}
   9.861 +		vfree(mem);
   9.862 +	}
   9.863 +	return;
   9.864 +}
   9.865 +
   9.866 +static pfm_context_t *
   9.867 +pfm_context_alloc(void)
   9.868 +{
   9.869 +	pfm_context_t *ctx;
   9.870 +
   9.871 +	/* 
   9.872 +	 * allocate context descriptor 
   9.873 +	 * must be able to free with interrupts disabled
   9.874 +	 */
   9.875 +	ctx = kmalloc(sizeof(pfm_context_t), GFP_KERNEL);
   9.876 +	if (ctx) {
   9.877 +		memset(ctx, 0, sizeof(pfm_context_t));
   9.878 +		DPRINT(("alloc ctx @%p\n", ctx));
   9.879 +	}
   9.880 +	return ctx;
   9.881 +}
   9.882 +
   9.883 +static void
   9.884 +pfm_context_free(pfm_context_t *ctx)
   9.885 +{
   9.886 +	if (ctx) {
   9.887 +		DPRINT(("free ctx @%p\n", ctx));
   9.888 +		kfree(ctx);
   9.889 +	}
   9.890 +}
   9.891 +
   9.892 +static void
   9.893 +pfm_mask_monitoring(struct task_struct *task)
   9.894 +{
   9.895 +	pfm_context_t *ctx = PFM_GET_CTX(task);
   9.896 +	struct thread_struct *th = &task->thread;
   9.897 +	unsigned long mask, val, ovfl_mask;
   9.898 +	int i;
   9.899 +
   9.900 +	DPRINT_ovfl(("masking monitoring for [%d]\n", task->pid));
   9.901 +
   9.902 +	ovfl_mask = pmu_conf->ovfl_val;
   9.903 +	/*
   9.904 +	 * monitoring can only be masked as a result of a valid
   9.905 +	 * counter overflow. In UP, it means that the PMU still
   9.906 +	 * has an owner. Note that the owner can be different
   9.907 +	 * from the current task. However the PMU state belongs
   9.908 +	 * to the owner.
   9.909 +	 * In SMP, a valid overflow only happens when task is
   9.910 +	 * current. Therefore if we come here, we know that
   9.911 +	 * the PMU state belongs to the current task, therefore
   9.912 +	 * we can access the live registers.
   9.913 +	 *
   9.914 +	 * So in both cases, the live register contains the owner's
   9.915 +	 * state. We can ONLY touch the PMU registers and NOT the PSR.
   9.916 +	 *
   9.917 +	 * As a consequence to this call, the thread->pmds[] array
   9.918 +	 * contains stale information which must be ignored
   9.919 +	 * when context is reloaded AND monitoring is active (see
   9.920 +	 * pfm_restart).
   9.921 +	 */
   9.922 +	mask = ctx->ctx_used_pmds[0];
   9.923 +	for (i = 0; mask; i++, mask>>=1) {
   9.924 +		/* skip non used pmds */
   9.925 +		if ((mask & 0x1) == 0) continue;
   9.926 +		val = ia64_get_pmd(i);
   9.927 +
   9.928 +		if (PMD_IS_COUNTING(i)) {
   9.929 +			/*
   9.930 +		 	 * we rebuild the full 64 bit value of the counter
   9.931 +		 	 */
   9.932 +			ctx->ctx_pmds[i].val += (val & ovfl_mask);
   9.933 +		} else {
   9.934 +			ctx->ctx_pmds[i].val = val;
   9.935 +		}
   9.936 +		DPRINT_ovfl(("pmd[%d]=0x%lx hw_pmd=0x%lx\n",
   9.937 +			i,
   9.938 +			ctx->ctx_pmds[i].val,
   9.939 +			val & ovfl_mask));
   9.940 +	}
   9.941 +	/*
   9.942 +	 * mask monitoring by setting the privilege level to 0
   9.943 +	 * we cannot use psr.pp/psr.up for this, it is controlled by
   9.944 +	 * the user
   9.945 +	 *
   9.946 +	 * if task is current, modify actual registers, otherwise modify
   9.947 +	 * thread save state, i.e., what will be restored in pfm_load_regs()
   9.948 +	 */
   9.949 +	mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER;
   9.950 +	for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) {
   9.951 +		if ((mask & 0x1) == 0UL) continue;
   9.952 +		ia64_set_pmc(i, th->pmcs[i] & ~0xfUL);
   9.953 +		th->pmcs[i] &= ~0xfUL;
   9.954 +		DPRINT_ovfl(("pmc[%d]=0x%lx\n", i, th->pmcs[i]));
   9.955 +	}
   9.956 +	/*
   9.957 +	 * make all of this visible
   9.958 +	 */
   9.959 +	ia64_srlz_d();
   9.960 +}
   9.961 +
   9.962 +/*
   9.963 + * must always be done with task == current
   9.964 + *
   9.965 + * context must be in MASKED state when calling
   9.966 + */
   9.967 +static void
   9.968 +pfm_restore_monitoring(struct task_struct *task)
   9.969 +{
   9.970 +	pfm_context_t *ctx = PFM_GET_CTX(task);
   9.971 +	struct thread_struct *th = &task->thread;
   9.972 +	unsigned long mask, ovfl_mask;
   9.973 +	unsigned long psr, val;
   9.974 +	int i, is_system;
   9.975 +
   9.976 +	is_system = ctx->ctx_fl_system;
   9.977 +	ovfl_mask = pmu_conf->ovfl_val;
   9.978 +
   9.979 +	if (task != current) {
   9.980 +		printk(KERN_ERR "perfmon.%d: invalid task[%d] current[%d]\n", __LINE__, task->pid, current->pid);
   9.981 +		return;
   9.982 +	}
   9.983 +	if (ctx->ctx_state != PFM_CTX_MASKED) {
   9.984 +		printk(KERN_ERR "perfmon.%d: task[%d] current[%d] invalid state=%d\n", __LINE__,
   9.985 +			task->pid, current->pid, ctx->ctx_state);
   9.986 +		return;
   9.987 +	}
   9.988 +	psr = pfm_get_psr();
   9.989 +	/*
   9.990 +	 * monitoring is masked via the PMC.
   9.991 +	 * As we restore their value, we do not want each counter to
   9.992 +	 * restart right away. We stop monitoring using the PSR,
   9.993 +	 * restore the PMC (and PMD) and then re-establish the psr
   9.994 +	 * as it was. Note that there can be no pending overflow at
   9.995 +	 * this point, because monitoring was MASKED.
   9.996 +	 *
   9.997 +	 * system-wide session are pinned and self-monitoring
   9.998 +	 */
   9.999 +	if (is_system && (PFM_CPUINFO_GET() & PFM_CPUINFO_DCR_PP)) {
  9.1000 +		/* disable dcr pp */
  9.1001 +		ia64_setreg(_IA64_REG_CR_DCR, ia64_getreg(_IA64_REG_CR_DCR) & ~IA64_DCR_PP);
  9.1002 +		pfm_clear_psr_pp();
  9.1003 +	} else {
  9.1004 +		pfm_clear_psr_up();
  9.1005 +	}
  9.1006 +	/*
  9.1007 +	 * first, we restore the PMD
  9.1008 +	 */
  9.1009 +	mask = ctx->ctx_used_pmds[0];
  9.1010 +	for (i = 0; mask; i++, mask>>=1) {
  9.1011 +		/* skip non used pmds */
  9.1012 +		if ((mask & 0x1) == 0) continue;
  9.1013 +
  9.1014 +		if (PMD_IS_COUNTING(i)) {
  9.1015 +			/*
  9.1016 +			 * we split the 64bit value according to
  9.1017 +			 * counter width
  9.1018 +			 */
  9.1019 +			val = ctx->ctx_pmds[i].val & ovfl_mask;
  9.1020 +			ctx->ctx_pmds[i].val &= ~ovfl_mask;
  9.1021 +		} else {
  9.1022 +			val = ctx->ctx_pmds[i].val;
  9.1023 +		}
  9.1024 +		ia64_set_pmd(i, val);
  9.1025 +
  9.1026 +		DPRINT(("pmd[%d]=0x%lx hw_pmd=0x%lx\n",
  9.1027 +			i,
  9.1028 +			ctx->ctx_pmds[i].val,
  9.1029 +			val));
  9.1030 +	}
  9.1031 +	/*
  9.1032 +	 * restore the PMCs
  9.1033 +	 */
  9.1034 +	mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER;
  9.1035 +	for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) {
  9.1036 +		if ((mask & 0x1) == 0UL) continue;
  9.1037 +		th->pmcs[i] = ctx->ctx_pmcs[i];
  9.1038 +		ia64_set_pmc(i, th->pmcs[i]);
  9.1039 +		DPRINT(("[%d] pmc[%d]=0x%lx\n", task->pid, i, th->pmcs[i]));
  9.1040 +	}
  9.1041 +	ia64_srlz_d();
  9.1042 +
  9.1043 +	/*
  9.1044 +	 * must restore DBR/IBR because could be modified while masked
  9.1045 +	 * XXX: need to optimize 
  9.1046 +	 */
  9.1047 +	if (ctx->ctx_fl_using_dbreg) {
  9.1048 +		pfm_restore_ibrs(ctx->ctx_ibrs, pmu_conf->num_ibrs);
  9.1049 +		pfm_restore_dbrs(ctx->ctx_dbrs, pmu_conf->num_dbrs);
  9.1050 +	}
  9.1051 +
  9.1052 +	/*
  9.1053 +	 * now restore PSR
  9.1054 +	 */
  9.1055 +	if (is_system && (PFM_CPUINFO_GET() & PFM_CPUINFO_DCR_PP)) {
  9.1056 +		/* enable dcr pp */
  9.1057 +		ia64_setreg(_IA64_REG_CR_DCR, ia64_getreg(_IA64_REG_CR_DCR) | IA64_DCR_PP);
  9.1058 +		ia64_srlz_i();
  9.1059 +	}
  9.1060 +	pfm_set_psr_l(psr);
  9.1061 +}
  9.1062 +
  9.1063 +static inline void
  9.1064 +pfm_save_pmds(unsigned long *pmds, unsigned long mask)
  9.1065 +{
  9.1066 +	int i;
  9.1067 +
  9.1068 +	ia64_srlz_d();
  9.1069 +
  9.1070 +	for (i=0; mask; i++, mask>>=1) {
  9.1071 +		if (mask & 0x1) pmds[i] = ia64_get_pmd(i);
  9.1072 +	}
  9.1073 +}
  9.1074 +
  9.1075 +/*
  9.1076 + * reload from thread state (used for ctxw only)
  9.1077 + */
  9.1078 +static inline void
  9.1079 +pfm_restore_pmds(unsigned long *pmds, unsigned long mask)
  9.1080 +{
  9.1081 +	int i;
  9.1082 +	unsigned long val, ovfl_val = pmu_conf->ovfl_val;
  9.1083 +
  9.1084 +	for (i=0; mask; i++, mask>>=1) {
  9.1085 +		if ((mask & 0x1) == 0) continue;
  9.1086 +		val = PMD_IS_COUNTING(i) ? pmds[i] & ovfl_val : pmds[i];
  9.1087 +		ia64_set_pmd(i, val);
  9.1088 +	}
  9.1089 +	ia64_srlz_d();
  9.1090 +}
  9.1091 +
  9.1092 +/*
  9.1093 + * propagate PMD from context to thread-state
  9.1094 + */
  9.1095 +static inline void
  9.1096 +pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx)
  9.1097 +{
  9.1098 +	struct thread_struct *thread = &task->thread;
  9.1099 +	unsigned long ovfl_val = pmu_conf->ovfl_val;
  9.1100 +	unsigned long mask = ctx->ctx_all_pmds[0];
  9.1101 +	unsigned long val;
  9.1102 +	int i;
  9.1103 +
  9.1104 +	DPRINT(("mask=0x%lx\n", mask));
  9.1105 +
  9.1106 +	for (i=0; mask; i++, mask>>=1) {
  9.1107 +
  9.1108 +		val = ctx->ctx_pmds[i].val;
  9.1109 +
  9.1110 +		/*
  9.1111 +		 * We break up the 64 bit value into 2 pieces
  9.1112 +		 * the lower bits go to the machine state in the
  9.1113 +		 * thread (will be reloaded on ctxsw in).
  9.1114 +		 * The upper part stays in the soft-counter.
  9.1115 +		 */
  9.1116 +		if (PMD_IS_COUNTING(i)) {
  9.1117 +			ctx->ctx_pmds[i].val = val & ~ovfl_val;
  9.1118 +			 val &= ovfl_val;
  9.1119 +		}
  9.1120 +		thread->pmds[i] = val;
  9.1121 +
  9.1122 +		DPRINT(("pmd[%d]=0x%lx soft_val=0x%lx\n",
  9.1123 +			i,
  9.1124 +			thread->pmds[i],
  9.1125 +			ctx->ctx_pmds[i].val));
  9.1126 +	}
  9.1127 +}
  9.1128 +
  9.1129 +/*
  9.1130 + * propagate PMC from context to thread-state
  9.1131 + */
  9.1132 +static inline void
  9.1133 +pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx)
  9.1134 +{
  9.1135 +	struct thread_struct *thread = &task->thread;
  9.1136 +	unsigned long mask = ctx->ctx_all_pmcs[0];
  9.1137 +	int i;
  9.1138 +
  9.1139 +	DPRINT(("mask=0x%lx\n", mask));
  9.1140 +
  9.1141 +	for (i=0; mask; i++, mask>>=1) {
  9.1142 +		/* masking 0 with ovfl_val yields 0 */
  9.1143 +		thread->pmcs[i] = ctx->ctx_pmcs[i];
  9.1144 +		DPRINT(("pmc[%d]=0x%lx\n", i, thread->pmcs[i]));
  9.1145 +	}
  9.1146 +}
  9.1147 +
  9.1148 +
  9.1149 +
  9.1150 +static inline void
  9.1151 +pfm_restore_pmcs(unsigned long *pmcs, unsigned long mask)
  9.1152 +{
  9.1153 +	int i;
  9.1154 +
  9.1155 +	for (i=0; mask; i++, mask>>=1) {
  9.1156 +		if ((mask & 0x1) == 0) continue;
  9.1157 +		ia64_set_pmc(i, pmcs[i]);
  9.1158 +	}
  9.1159 +	ia64_srlz_d();
  9.1160 +}
  9.1161 +
  9.1162 +static inline int
  9.1163 +pfm_uuid_cmp(pfm_uuid_t a, pfm_uuid_t b)
  9.1164 +{
  9.1165 +	return memcmp(a, b, sizeof(pfm_uuid_t));
  9.1166 +}
  9.1167 +
  9.1168 +static inline int
  9.1169 +pfm_buf_fmt_exit(pfm_buffer_fmt_t *fmt, struct task_struct *task, void *buf, struct pt_regs *regs)
  9.1170 +{
  9.1171 +	int ret = 0;
  9.1172 +	if (fmt->fmt_exit) ret = (*fmt->fmt_exit)(task, buf, regs);
  9.1173 +	return ret;
  9.1174 +}
  9.1175 +
  9.1176 +static inline int
  9.1177 +pfm_buf_fmt_getsize(pfm_buffer_fmt_t *fmt, struct task_struct *task, unsigned int flags, int cpu, void *arg, unsigned long *size)
  9.1178 +{
  9.1179 +	int ret = 0;
  9.1180 +	if (fmt->fmt_getsize) ret = (*fmt->fmt_getsize)(task, flags, cpu, arg, size);
  9.1181 +	return ret;
  9.1182 +}
  9.1183 +
  9.1184 +
  9.1185 +static inline int
  9.1186 +pfm_buf_fmt_validate(pfm_buffer_fmt_t *fmt, struct task_struct *task, unsigned int flags,
  9.1187 +		     int cpu, void *arg)
  9.1188 +{
  9.1189 +	int ret = 0;
  9.1190 +	if (fmt->fmt_validate) ret = (*fmt->fmt_validate)(task, flags, cpu, arg);
  9.1191 +	return ret;
  9.1192 +}
  9.1193 +
  9.1194 +static inline int
  9.1195 +pfm_buf_fmt_init(pfm_buffer_fmt_t *fmt, struct task_struct *task, void *buf, unsigned int flags,
  9.1196 +		     int cpu, void *arg)
  9.1197 +{
  9.1198 +	int ret = 0;
  9.1199 +	if (fmt->fmt_init) ret = (*fmt->fmt_init)(task, buf, flags, cpu, arg);
  9.1200 +	return ret;
  9.1201 +}
  9.1202 +
  9.1203 +static inline int
  9.1204 +pfm_buf_fmt_restart(pfm_buffer_fmt_t *fmt, struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs)
  9.1205 +{
  9.1206 +	int ret = 0;
  9.1207 +	if (fmt->fmt_restart) ret = (*fmt->fmt_restart)(task, ctrl, buf, regs);
  9.1208 +	return ret;
  9.1209 +}
  9.1210 +
  9.1211 +static inline int
  9.1212 +pfm_buf_fmt_restart_active(pfm_buffer_fmt_t *fmt, struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs)
  9.1213 +{
  9.1214 +	int ret = 0;
  9.1215 +	if (fmt->fmt_restart_active) ret = (*fmt->fmt_restart_active)(task, ctrl, buf, regs);
  9.1216 +	return ret;
  9.1217 +}
  9.1218 +
  9.1219 +static pfm_buffer_fmt_t *
  9.1220 +__pfm_find_buffer_fmt(pfm_uuid_t uuid)
  9.1221 +{
  9.1222 +	struct list_head * pos;
  9.1223 +	pfm_buffer_fmt_t * entry;
  9.1224 +
  9.1225 +	list_for_each(pos, &pfm_buffer_fmt_list) {
  9.1226 +		entry = list_entry(pos, pfm_buffer_fmt_t, fmt_list);
  9.1227 +		if (pfm_uuid_cmp(uuid, entry->fmt_uuid) == 0)
  9.1228 +			return entry;
  9.1229 +	}
  9.1230 +	return NULL;
  9.1231 +}
  9.1232 + 
  9.1233 +/*
  9.1234 + * find a buffer format based on its uuid
  9.1235 + */
  9.1236 +static pfm_buffer_fmt_t *
  9.1237 +pfm_find_buffer_fmt(pfm_uuid_t uuid)
  9.1238 +{
  9.1239 +	pfm_buffer_fmt_t * fmt;
  9.1240 +	spin_lock(&pfm_buffer_fmt_lock);
  9.1241 +	fmt = __pfm_find_buffer_fmt(uuid);
  9.1242 +	spin_unlock(&pfm_buffer_fmt_lock);
  9.1243 +	return fmt;
  9.1244 +}
  9.1245 + 
  9.1246 +int
  9.1247 +pfm_register_buffer_fmt(pfm_buffer_fmt_t *fmt)
  9.1248 +{
  9.1249 +	int ret = 0;
  9.1250 +
  9.1251 +	/* some sanity checks */
  9.1252 +	if (fmt == NULL || fmt->fmt_name == NULL) return -EINVAL;
  9.1253 +
  9.1254 +	/* we need at least a handler */
  9.1255 +	if (fmt->fmt_handler == NULL) return -EINVAL;
  9.1256 +
  9.1257 +	/*
  9.1258 +	 * XXX: need check validity of fmt_arg_size
  9.1259 +	 */
  9.1260 +
  9.1261 +	spin_lock(&pfm_buffer_fmt_lock);
  9.1262 +
  9.1263 +	if (__pfm_find_buffer_fmt(fmt->fmt_uuid)) {
  9.1264 +		printk(KERN_ERR "perfmon: duplicate sampling format: %s\n", fmt->fmt_name);
  9.1265 +		ret = -EBUSY;
  9.1266 +		goto out;
  9.1267 +	} 
  9.1268 +	list_add(&fmt->fmt_list, &pfm_buffer_fmt_list);
  9.1269 +	printk(KERN_INFO "perfmon: added sampling format %s\n", fmt->fmt_name);
  9.1270 +
  9.1271 +out:
  9.1272 +	spin_unlock(&pfm_buffer_fmt_lock);
  9.1273 + 	return ret;
  9.1274 +}
  9.1275 +EXPORT_SYMBOL(pfm_register_buffer_fmt);
  9.1276 +
  9.1277 +int
  9.1278 +pfm_unregister_buffer_fmt(pfm_uuid_t uuid)
  9.1279 +{
  9.1280 +	pfm_buffer_fmt_t *fmt;
  9.1281 +	int ret = 0;
  9.1282 +
  9.1283 +	spin_lock(&pfm_buffer_fmt_lock);
  9.1284 +
  9.1285 +	fmt = __pfm_find_buffer_fmt(uuid);
  9.1286 +	if (!fmt) {
  9.1287 +		printk(KERN_ERR "perfmon: cannot unregister format, not found\n");
  9.1288 +		ret = -EINVAL;
  9.1289 +		goto out;
  9.1290 +	}
  9.1291 +	list_del_init(&fmt->fmt_list);
  9.1292 +	printk(KERN_INFO "perfmon: removed sampling format: %s\n", fmt->fmt_name);
  9.1293 +
  9.1294 +out:
  9.1295 +	spin_unlock(&pfm_buffer_fmt_lock);
  9.1296 +	return ret;
  9.1297 +
  9.1298 +}
  9.1299 +EXPORT_SYMBOL(pfm_unregister_buffer_fmt);
  9.1300 +
  9.1301 +extern void update_pal_halt_status(int);
  9.1302 +
  9.1303 +static int
  9.1304 +pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu)
  9.1305 +{
  9.1306 +	unsigned long flags;
  9.1307 +	/*
  9.1308 +	 * validy checks on cpu_mask have been done upstream
  9.1309 +	 */
  9.1310 +	LOCK_PFS(flags);
  9.1311 +
  9.1312 +	DPRINT(("in sys_sessions=%u task_sessions=%u dbregs=%u syswide=%d cpu=%u\n",
  9.1313 +		pfm_sessions.pfs_sys_sessions,
  9.1314 +		pfm_sessions.pfs_task_sessions,
  9.1315 +		pfm_sessions.pfs_sys_use_dbregs,
  9.1316 +		is_syswide,
  9.1317 +		cpu));
  9.1318 +
  9.1319 +	if (is_syswide) {
  9.1320 +		/*
  9.1321 +		 * cannot mix system wide and per-task sessions
  9.1322 +		 */
  9.1323 +		if (pfm_sessions.pfs_task_sessions > 0UL) {
  9.1324 +			DPRINT(("system wide not possible, %u conflicting task_sessions\n",
  9.1325 +			  	pfm_sessions.pfs_task_sessions));
  9.1326 +			goto abort;
  9.1327 +		}
  9.1328 +
  9.1329 +		if (pfm_sessions.pfs_sys_session[cpu]) goto error_conflict;
  9.1330 +
  9.1331 +		DPRINT(("reserving system wide session on CPU%u currently on CPU%u\n", cpu, smp_processor_id()));
  9.1332 +
  9.1333 +		pfm_sessions.pfs_sys_session[cpu] = task;
  9.1334 +
  9.1335 +		pfm_sessions.pfs_sys_sessions++ ;
  9.1336 +
  9.1337 +	} else {
  9.1338 +		if (pfm_sessions.pfs_sys_sessions) goto abort;
  9.1339 +		pfm_sessions.pfs_task_sessions++;
  9.1340 +	}
  9.1341 +
  9.1342 +	DPRINT(("out sys_sessions=%u task_sessions=%u dbregs=%u syswide=%d cpu=%u\n",
  9.1343 +		pfm_sessions.pfs_sys_sessions,
  9.1344 +		pfm_sessions.pfs_task_sessions,
  9.1345 +		pfm_sessions.pfs_sys_use_dbregs,
  9.1346 +		is_syswide,
  9.1347 +		cpu));
  9.1348 +
  9.1349 +	/*
  9.1350 +	 * disable default_idle() to go to PAL_HALT
  9.1351 +	 */
  9.1352 +	update_pal_halt_status(0);
  9.1353 +
  9.1354 +	UNLOCK_PFS(flags);
  9.1355 +
  9.1356 +	return 0;
  9.1357 +
  9.1358 +error_conflict:
  9.1359 +	DPRINT(("system wide not possible, conflicting session [%d] on CPU%d\n",
  9.1360 +  		pfm_sessions.pfs_sys_session[cpu]->pid,
  9.1361 +		cpu));
  9.1362 +abort:
  9.1363 +	UNLOCK_PFS(flags);
  9.1364 +
  9.1365 +	return -EBUSY;
  9.1366 +
  9.1367 +}
  9.1368 +
  9.1369 +static int
  9.1370 +pfm_unreserve_session(pfm_context_t *ctx, int is_syswide, unsigned int cpu)
  9.1371 +{
  9.1372 +	unsigned long flags;
  9.1373 +	/*
  9.1374 +	 * validy checks on cpu_mask have been done upstream
  9.1375 +	 */
  9.1376 +	LOCK_PFS(flags);
  9.1377 +
  9.1378 +	DPRINT(("in sys_sessions=%u task_sessions=%u dbregs=%u syswide=%d cpu=%u\n",
  9.1379 +		pfm_sessions.pfs_sys_sessions,
  9.1380 +		pfm_sessions.pfs_task_sessions,
  9.1381 +		pfm_sessions.pfs_sys_use_dbregs,
  9.1382 +		is_syswide,
  9.1383 +		cpu));
  9.1384 +
  9.1385 +
  9.1386 +	if (is_syswide) {
  9.1387 +		pfm_sessions.pfs_sys_session[cpu] = NULL;
  9.1388 +		/*
  9.1389 +		 * would not work with perfmon+more than one bit in cpu_mask
  9.1390 +		 */
  9.1391 +		if (ctx && ctx->ctx_fl_using_dbreg) {
  9.1392 +			if (pfm_sessions.pfs_sys_use_dbregs == 0) {
  9.1393 +				printk(KERN_ERR "perfmon: invalid release for ctx %p sys_use_dbregs=0\n", ctx);
  9.1394 +			} else {
  9.1395 +				pfm_sessions.pfs_sys_use_dbregs--;
  9.1396 +			}
  9.1397 +		}
  9.1398 +		pfm_sessions.pfs_sys_sessions--;
  9.1399 +	} else {
  9.1400 +		pfm_sessions.pfs_task_sessions--;
  9.1401 +	}
  9.1402 +	DPRINT(("out sys_sessions=%u task_sessions=%u dbregs=%u syswide=%d cpu=%u\n",
  9.1403 +		pfm_sessions.pfs_sys_sessions,
  9.1404 +		pfm_sessions.pfs_task_sessions,
  9.1405 +		pfm_sessions.pfs_sys_use_dbregs,
  9.1406 +		is_syswide,
  9.1407 +		cpu));
  9.1408 +
  9.1409 +	/*
  9.1410 +	 * if possible, enable default_idle() to go into PAL_HALT
  9.1411 +	 */
  9.1412 +	if (pfm_sessions.pfs_task_sessions == 0 && pfm_sessions.pfs_sys_sessions == 0)
  9.1413 +		update_pal_halt_status(1);
  9.1414 +
  9.1415 +	UNLOCK_PFS(flags);
  9.1416 +
  9.1417 +	return 0;
  9.1418 +}
  9.1419 +
  9.1420 +/*
  9.1421 + * removes virtual mapping of the sampling buffer.
  9.1422 + * IMPORTANT: cannot be called with interrupts disable, e.g. inside
  9.1423 + * a PROTECT_CTX() section.
  9.1424 + */
  9.1425 +static int
  9.1426 +pfm_remove_smpl_mapping(struct task_struct *task, void *vaddr, unsigned long size)
  9.1427 +{
  9.1428 +	int r;
  9.1429 +
  9.1430 +	/* sanity checks */
  9.1431 +	if (task->mm == NULL || size == 0UL || vaddr == NULL) {
  9.1432 +		printk(KERN_ERR "perfmon: pfm_remove_smpl_mapping [%d] invalid context mm=%p\n", task->pid, task->mm);
  9.1433 +		return -EINVAL;
  9.1434 +	}
  9.1435 +
  9.1436 +	DPRINT(("smpl_vaddr=%p size=%lu\n", vaddr, size));
  9.1437 +
  9.1438 +	/*
  9.1439 +	 * does the actual unmapping
  9.1440 +	 */
  9.1441 +	down_write(&task->mm->mmap_sem);
  9.1442 +
  9.1443 +	DPRINT(("down_write done smpl_vaddr=%p size=%lu\n", vaddr, size));
  9.1444 +
  9.1445 +	r = pfm_do_munmap(task->mm, (unsigned long)vaddr, size, 0);
  9.1446 +
  9.1447 +	up_write(&task->mm->mmap_sem);
  9.1448 +	if (r !=0) {
  9.1449 +		printk(KERN_ERR "perfmon: [%d] unable to unmap sampling buffer @%p size=%lu\n", task->pid, vaddr, size);
  9.1450 +	}
  9.1451 +
  9.1452 +	DPRINT(("do_unmap(%p, %lu)=%d\n", vaddr, size, r));
  9.1453 +
  9.1454 +	return 0;
  9.1455 +}
  9.1456 +
  9.1457 +/*
  9.1458 + * free actual physical storage used by sampling buffer
  9.1459 + */
  9.1460 +#if 0
  9.1461 +static int
  9.1462 +pfm_free_smpl_buffer(pfm_context_t *ctx)
  9.1463 +{
  9.1464 +	pfm_buffer_fmt_t *fmt;
  9.1465 +
  9.1466 +	if (ctx->ctx_smpl_hdr == NULL) goto invalid_free;
  9.1467 +
  9.1468 +	/*
  9.1469 +	 * we won't use the buffer format anymore
  9.1470 +	 */
  9.1471 +	fmt = ctx->ctx_buf_fmt;
  9.1472 +
  9.1473 +	DPRINT(("sampling buffer @%p size %lu vaddr=%p\n",
  9.1474 +		ctx->ctx_smpl_hdr,
  9.1475 +		ctx->ctx_smpl_size,
  9.1476 +		ctx->ctx_smpl_vaddr));
  9.1477 +
  9.1478 +	pfm_buf_fmt_exit(fmt, current, NULL, NULL);
  9.1479 +
  9.1480 +	/*
  9.1481 +	 * free the buffer
  9.1482 +	 */
  9.1483 +	pfm_rvfree(ctx->ctx_smpl_hdr, ctx->ctx_smpl_size);
  9.1484 +
  9.1485 +	ctx->ctx_smpl_hdr  = NULL;
  9.1486 +	ctx->ctx_smpl_size = 0UL;
  9.1487 +
  9.1488 +	return 0;
  9.1489 +
  9.1490 +invalid_free:
  9.1491 +	printk(KERN_ERR "perfmon: pfm_free_smpl_buffer [%d] no buffer\n", current->pid);
  9.1492 +	return -EINVAL;
  9.1493 +}
  9.1494 +#endif
  9.1495 +
  9.1496 +static inline void
  9.1497 +pfm_exit_smpl_buffer(pfm_buffer_fmt_t *fmt)
  9.1498 +{
  9.1499 +	if (fmt == NULL) return;
  9.1500 +
  9.1501 +	pfm_buf_fmt_exit(fmt, current, NULL, NULL);
  9.1502 +
  9.1503 +}
  9.1504 +
  9.1505 +/*
  9.1506 + * pfmfs should _never_ be mounted by userland - too much of security hassle,
  9.1507 + * no real gain from having the whole whorehouse mounted. So we don't need
  9.1508 + * any operations on the root directory. However, we need a non-trivial
  9.1509 + * d_name - pfm: will go nicely and kill the special-casing in procfs.
  9.1510 + */
  9.1511 +static struct vfsmount *pfmfs_mnt;
  9.1512 +
  9.1513 +static int __init
  9.1514 +init_pfm_fs(void)
  9.1515 +{
  9.1516 +	int err = register_filesystem(&pfm_fs_type);
  9.1517 +	if (!err) {
  9.1518 +		pfmfs_mnt = kern_mount(&pfm_fs_type);
  9.1519 +		err = PTR_ERR(pfmfs_mnt);
  9.1520 +		if (IS_ERR(pfmfs_mnt))
  9.1521 +			unregister_filesystem(&pfm_fs_type);
  9.1522 +		else
  9.1523 +			err = 0;
  9.1524 +	}
  9.1525 +	return err;
  9.1526 +}
  9.1527 +
  9.1528 +static void __exit
  9.1529 +exit_pfm_fs(void)
  9.1530 +{
  9.1531 +	unregister_filesystem(&pfm_fs_type);
  9.1532 +	mntput(pfmfs_mnt);
  9.1533 +}
  9.1534 +
  9.1535 +static ssize_t
  9.1536 +pfm_read(struct file *filp, char __user *buf, size_t size, loff_t *ppos)
  9.1537 +{
  9.1538 +	pfm_context_t *ctx;
  9.1539 +	pfm_msg_t *msg;
  9.1540 +	ssize_t ret;
  9.1541 +	unsigned long flags;
  9.1542 +  	DECLARE_WAITQUEUE(wait, current);
  9.1543 +	XEN_NOT_SUPPORTED_YET;
  9.1544 +	if (PFM_IS_FILE(filp) == 0) {
  9.1545 +		printk(KERN_ERR "perfmon: pfm_poll: bad magic [%d]\n", current->pid);
  9.1546 +		return -EINVAL;
  9.1547 +	}
  9.1548 +
  9.1549 +	ctx = (pfm_context_t *)filp->private_data;
  9.1550 +	if (ctx == NULL) {
  9.1551 +		printk(KERN_ERR "perfmon: pfm_read: NULL ctx [%d]\n", current->pid);
  9.1552 +		return -EINVAL;
  9.1553 +	}
  9.1554 +
  9.1555 +	/*
  9.1556 +	 * check even when there is no message
  9.1557 +	 */
  9.1558 +	if (size < sizeof(pfm_msg_t)) {
  9.1559 +		DPRINT(("message is too small ctx=%p (>=%ld)\n", ctx, sizeof(pfm_msg_t)));
  9.1560 +		return -EINVAL;
  9.1561 +	}
  9.1562 +
  9.1563 +	PROTECT_CTX(ctx, flags);
  9.1564 +
  9.1565 +  	/*
  9.1566 +	 * put ourselves on the wait queue
  9.1567 +	 */
  9.1568 +  	add_wait_queue(&ctx->ctx_msgq_wait, &wait);
  9.1569 +
  9.1570 +
  9.1571 +  	for(;;) {
  9.1572 +		/*
  9.1573 +		 * check wait queue
  9.1574 +		 */
  9.1575 +
  9.1576 +  		set_current_state(TASK_INTERRUPTIBLE);
  9.1577 +
  9.1578 +		DPRINT(("head=%d tail=%d\n", ctx->ctx_msgq_head, ctx->ctx_msgq_tail));
  9.1579 +
  9.1580 +		ret = 0;
  9.1581 +		if(PFM_CTXQ_EMPTY(ctx) == 0) break;
  9.1582 +
  9.1583 +		UNPROTECT_CTX(ctx, flags);
  9.1584 +
  9.1585 +		/*
  9.1586 +		 * check non-blocking read
  9.1587 +		 */
  9.1588 +      		ret = -EAGAIN;
  9.1589 +		if(filp->f_flags & O_NONBLOCK) break;
  9.1590 +
  9.1591 +		/*
  9.1592 +		 * check pending signals
  9.1593 +		 */
  9.1594 +		if(signal_pending(current)) {
  9.1595 +			ret = -EINTR;
  9.1596 +			break;
  9.1597 +		}
  9.1598 +      		/*
  9.1599 +		 * no message, so wait
  9.1600 +		 */
  9.1601 +      		schedule();
  9.1602 +
  9.1603 +		PROTECT_CTX(ctx, flags);
  9.1604 +	}
  9.1605 +	DPRINT(("[%d] back to running ret=%ld\n", current->pid, ret));
  9.1606 +  	set_current_state(TASK_RUNNING);
  9.1607 +	remove_wait_queue(&ctx->ctx_msgq_wait, &wait);
  9.1608 +
  9.1609 +	if (ret < 0) goto abort;
  9.1610 +
  9.1611 +	ret = -EINVAL;
  9.1612 +	msg = pfm_get_next_msg(ctx);
  9.1613 +	if (msg == NULL) {
  9.1614 +		printk(KERN_ERR "perfmon: pfm_read no msg for ctx=%p [%d]\n", ctx, current->pid);
  9.1615 +		goto abort_locked;
  9.1616 +	}
  9.1617 +
  9.1618 +	DPRINT(("fd=%d type=%d\n", msg->pfm_gen_msg.msg_ctx_fd, msg->pfm_gen_msg.msg_type));
  9.1619 +
  9.1620 +	ret = -EFAULT;
  9.1621 +  	if(copy_to_user(buf, msg, sizeof(pfm_msg_t)) == 0) ret = sizeof(pfm_msg_t);
  9.1622 +
  9.1623 +abort_locked:
  9.1624 +	UNPROTECT_CTX(ctx, flags);
  9.1625 +abort:
  9.1626 +	return ret;
  9.1627 +}
  9.1628 +
  9.1629 +static ssize_t
  9.1630 +pfm_write(struct file *file, const char __user *ubuf,
  9.1631 +			  size_t size, loff_t *ppos)
  9.1632 +{
  9.1633 +	DPRINT(("pfm_write called\n"));
  9.1634 +	return -EINVAL;
  9.1635 +}
  9.1636 +
  9.1637 +static unsigned int
  9.1638 +pfm_poll(struct file *filp, poll_table * wait)
  9.1639 +{
  9.1640 +	pfm_context_t *ctx;
  9.1641 +	unsigned long flags;
  9.1642 +	unsigned int mask = 0;
  9.1643 +
  9.1644 +	if (PFM_IS_FILE(filp) == 0) {
  9.1645 +		printk(KERN_ERR "perfmon: pfm_poll: bad magic [%d]\n", current->pid);
  9.1646 +		return 0;
  9.1647 +	}
  9.1648 +
  9.1649 +	ctx = (pfm_context_t *)filp->private_data;
  9.1650 +	if (ctx == NULL) {
  9.1651 +		printk(KERN_ERR "perfmon: pfm_poll: NULL ctx [%d]\n", current->pid);
  9.1652 +		return 0;
  9.1653 +	}
  9.1654 +
  9.1655 +
  9.1656 +	DPRINT(("pfm_poll ctx_fd=%d before poll_wait\n", ctx->ctx_fd));
  9.1657 +
  9.1658 +	poll_wait(filp, &ctx->ctx_msgq_wait, wait);
  9.1659 +
  9.1660 +	PROTECT_CTX(ctx, flags);
  9.1661 +
  9.1662 +	if (PFM_CTXQ_EMPTY(ctx) == 0)
  9.1663 +		mask =  POLLIN | POLLRDNORM;
  9.1664 +
  9.1665 +	UNPROTECT_CTX(ctx, flags);
  9.1666 +
  9.1667 +	DPRINT(("pfm_poll ctx_fd=%d mask=0x%x\n", ctx->ctx_fd, mask));
  9.1668 +
  9.1669 +	return mask;
  9.1670 +}
  9.1671 +
  9.1672 +static int
  9.1673 +pfm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
  9.1674 +{
  9.1675 +	DPRINT(("pfm_ioctl called\n"));
  9.1676 +	return -EINVAL;
  9.1677 +}
  9.1678 +
  9.1679 +/*
  9.1680 + * interrupt cannot be masked when coming here
  9.1681 + */
  9.1682 +static inline int
  9.1683 +pfm_do_fasync(int fd, struct file *filp, pfm_context_t *ctx, int on)
  9.1684 +{
  9.1685 +	int ret;
  9.1686 +
  9.1687 +	ret = fasync_helper (fd, filp, on, &ctx->ctx_async_queue);
  9.1688 +
  9.1689 +	DPRINT(("pfm_fasync called by [%d] on ctx_fd=%d on=%d async_queue=%p ret=%d\n",
  9.1690 +		current->pid,
  9.1691 +		fd,
  9.1692 +		on,
  9.1693 +		ctx->ctx_async_queue, ret));
  9.1694 +
  9.1695 +	return ret;
  9.1696 +}
  9.1697 +
  9.1698 +static int
  9.1699 +pfm_fasync(int fd, struct file *filp, int on)
  9.1700 +{
  9.1701 +	pfm_context_t *ctx;
  9.1702 +	int ret;
  9.1703 +
  9.1704 +	if (PFM_IS_FILE(filp) == 0) {
  9.1705 +		printk(KERN_ERR "perfmon: pfm_fasync bad magic [%d]\n", current->pid);
  9.1706 +		return -EBADF;
  9.1707 +	}
  9.1708 +
  9.1709 +	ctx = (pfm_context_t *)filp->private_data;
  9.1710 +	if (ctx == NULL) {
  9.1711 +		printk(KERN_ERR "perfmon: pfm_fasync NULL ctx [%d]\n", current->pid);
  9.1712 +		return -EBADF;
  9.1713 +	}
  9.1714 +	/*
  9.1715 +	 * we cannot mask interrupts during this call because this may
  9.1716 +	 * may go to sleep if memory is not readily avalaible.
  9.1717 +	 *
  9.1718 +	 * We are protected from the conetxt disappearing by the get_fd()/put_fd()
  9.1719 +	 * done in caller. Serialization of this function is ensured by caller.
  9.1720 +	 */
  9.1721 +	ret = pfm_do_fasync(fd, filp, ctx, on);
  9.1722 +
  9.1723 +
  9.1724 +	DPRINT(("pfm_fasync called on ctx_fd=%d on=%d async_queue=%p ret=%d\n",
  9.1725 +		fd,
  9.1726 +		on,
  9.1727 +		ctx->ctx_async_queue, ret));
  9.1728 +
  9.1729 +	return ret;
  9.1730 +}
  9.1731 +
  9.1732 +#ifdef CONFIG_SMP
  9.1733 +/*
  9.1734 + * this function is exclusively called from pfm_close().
  9.1735 + * The context is not protected at that time, nor are interrupts
  9.1736 + * on the remote CPU. That's necessary to avoid deadlocks.
  9.1737 + */
  9.1738 +static void
  9.1739 +pfm_syswide_force_stop(void *info)
  9.1740 +{
  9.1741 +	pfm_context_t   *ctx = (pfm_context_t *)info;
  9.1742 +	struct pt_regs *regs = task_pt_regs(current);
  9.1743 +	struct task_struct *owner;
  9.1744 +	unsigned long flags;
  9.1745 +	int ret;
  9.1746 +
  9.1747 +	if (ctx->ctx_cpu != smp_processor_id()) {
  9.1748 +		printk(KERN_ERR "perfmon: pfm_syswide_force_stop for CPU%d  but on CPU%d\n",
  9.1749 +			ctx->ctx_cpu,
  9.1750 +			smp_processor_id());
  9.1751 +		return;
  9.1752 +	}
  9.1753 +	owner = GET_PMU_OWNER();
  9.1754 +	if (owner != ctx->ctx_task) {
  9.1755 +		printk(KERN_ERR "perfmon: pfm_syswide_force_stop CPU%d unexpected owner [%d] instead of [%d]\n",
  9.1756 +			smp_processor_id(),
  9.1757 +			owner->pid, ctx->ctx_task->pid);
  9.1758 +		return;
  9.1759 +	}
  9.1760 +	if (GET_PMU_CTX() != ctx) {
  9.1761 +		printk(KERN_ERR "perfmon: pfm_syswide_force_stop CPU%d unexpected ctx %p instead of %p\n",
  9.1762 +			smp_processor_id(),
  9.1763 +			GET_PMU_CTX(), ctx);
  9.1764 +		return;
  9.1765 +	}
  9.1766 +
  9.1767 +	DPRINT(("on CPU%d forcing system wide stop for [%d]\n", smp_processor_id(), ctx->ctx_task->pid));	
  9.1768 +	/*
  9.1769 +	 * the context is already protected in pfm_close(), we simply
  9.1770 +	 * need to mask interrupts to avoid a PMU interrupt race on
  9.1771 +	 * this CPU
  9.1772 +	 */
  9.1773 +	local_irq_save(flags);
  9.1774 +
  9.1775 +	ret = pfm_context_unload(ctx, NULL, 0, regs);
  9.1776 +	if (ret) {
  9.1777 +		DPRINT(("context_unload returned %d\n", ret));
  9.1778 +	}
  9.1779 +
  9.1780 +	/*
  9.1781 +	 * unmask interrupts, PMU interrupts are now spurious here
  9.1782 +	 */
  9.1783 +	local_irq_restore(flags);
  9.1784 +}
  9.1785 +
  9.1786 +static void
  9.1787 +pfm_syswide_cleanup_other_cpu(pfm_context_t *ctx)
  9.1788 +{
  9.1789 +	int ret;
  9.1790 +
  9.1791 +	DPRINT(("calling CPU%d for cleanup\n", ctx->ctx_cpu));
  9.1792 +	ret = smp_call_function_single(ctx->ctx_cpu, pfm_syswide_force_stop, ctx, 0, 1);
  9.1793 +	DPRINT(("called CPU%d for cleanup ret=%d\n", ctx->ctx_cpu, ret));
  9.1794 +}
  9.1795 +#endif /* CONFIG_SMP */
  9.1796 +
  9.1797 +/*
  9.1798 + * called for each close(). Partially free resources.
  9.1799 + * When caller is self-monitoring, the context is unloaded.
  9.1800 + */
  9.1801 +static int
  9.1802 +pfm_flush(struct file *filp)
  9.1803 +{
  9.1804 +	pfm_context_t *ctx;
  9.1805 +	struct task_struct *task;
  9.1806 +	struct pt_regs *regs;
  9.1807 +	unsigned long flags;
  9.1808 +	unsigned long smpl_buf_size = 0UL;
  9.1809 +	void *smpl_buf_vaddr = NULL;
  9.1810 +	int state, is_system;
  9.1811 +
  9.1812 +	if (PFM_IS_FILE(filp) == 0) {
  9.1813 +		DPRINT(("bad magic for\n"));
  9.1814 +		return -EBADF;
  9.1815 +	}
  9.1816 +
  9.1817 +	ctx = (pfm_context_t *)filp->private_data;
  9.1818 +	if (ctx == NULL) {
  9.1819 +		printk(KERN_ERR "perfmon: pfm_flush: NULL ctx [%d]\n", current->pid);
  9.1820 +		return -EBADF;
  9.1821 +	}
  9.1822 +
  9.1823 +	/*
  9.1824 +	 * remove our file from the async queue, if we use this mode.
  9.1825 +	 * This can be done without the context being protected. We come
  9.1826 +	 * here when the context has become unreacheable by other tasks.
  9.1827 +	 *
  9.1828 +	 * We may still have active monitoring at this point and we may
  9.1829 +	 * end up in pfm_overflow_handler(). However, fasync_helper()
  9.1830 +	 * operates with interrupts disabled and it cleans up the
  9.1831 +	 * queue. If the PMU handler is called prior to entering
  9.1832 +	 * fasync_helper() then it will send a signal. If it is
  9.1833 +	 * invoked after, it will find an empty queue and no
  9.1834 +	 * signal will be sent. In both case, we are safe
  9.1835 +	 */
  9.1836 +	if (filp->f_flags & FASYNC) {
  9.1837 +		DPRINT(("cleaning up async_queue=%p\n", ctx->ctx_async_queue));
  9.1838 +		pfm_do_fasync (-1, filp, ctx, 0);
  9.1839 +	}
  9.1840 +
  9.1841 +	PROTECT_CTX(ctx, flags);
  9.1842 +
  9.1843 +	state     = ctx->ctx_state;
  9.1844 +	is_system = ctx->ctx_fl_system;
  9.1845 +
  9.1846 +	task = PFM_CTX_TASK(ctx);
  9.1847 +	regs = task_pt_regs(task);
  9.1848 +
  9.1849 +	DPRINT(("ctx_state=%d is_current=%d\n",
  9.1850 +		state,
  9.1851 +		task == current ? 1 : 0));
  9.1852 +
  9.1853 +	/*
  9.1854 +	 * if state == UNLOADED, then task is NULL
  9.1855 +	 */
  9.1856 +
  9.1857 +	/*
  9.1858 +	 * we must stop and unload because we are losing access to the context.
  9.1859 +	 */
  9.1860 +	if (task == current) {
  9.1861 +#ifdef CONFIG_SMP
  9.1862 +		/*
  9.1863 +		 * the task IS the owner but it migrated to another CPU: that's bad
  9.1864 +		 * but we must handle this cleanly. Unfortunately, the kernel does
  9.1865 +		 * not provide a mechanism to block migration (while the context is loaded).
  9.1866 +		 *
  9.1867 +		 * We need to release the resource on the ORIGINAL cpu.
  9.1868 +		 */
  9.1869 +		if (is_system && ctx->ctx_cpu != smp_processor_id()) {
  9.1870 +
  9.1871 +			DPRINT(("should be running on CPU%d\n", ctx->ctx_cpu));
  9.1872 +			/*
  9.1873 +			 * keep context protected but unmask interrupt for IPI
  9.1874 +			 */
  9.1875 +			local_irq_restore(flags);
  9.1876 +
  9.1877 +			pfm_syswide_cleanup_other_cpu(ctx);
  9.1878 +
  9.1879 +			/*
  9.1880 +			 * restore interrupt masking
  9.1881 +			 */
  9.1882 +			local_irq_save(flags);
  9.1883 +
  9.1884 +			/*
  9.1885 +			 * context is unloaded at this point
  9.1886 +			 */
  9.1887 +		} else
  9.1888 +#endif /* CONFIG_SMP */
  9.1889 +		{
  9.1890 +
  9.1891 +			DPRINT(("forcing unload\n"));
  9.1892 +			/*
  9.1893 +		 	* stop and unload, returning with state UNLOADED
  9.1894 +		 	* and session unreserved.
  9.1895 +		 	*/
  9.1896 +			pfm_context_unload(ctx, NULL, 0, regs);
  9.1897 +
  9.1898 +			DPRINT(("ctx_state=%d\n", ctx->ctx_state));
  9.1899 +		}
  9.1900 +	}
  9.1901 +
  9.1902 +	/*
  9.1903 +	 * remove virtual mapping, if any, for the calling task.
  9.1904 +	 * cannot reset ctx field until last user is calling close().
  9.1905 +	 *
  9.1906 +	 * ctx_smpl_vaddr must never be cleared because it is needed
  9.1907 +	 * by every task with access to the context
  9.1908 +	 *
  9.1909 +	 * When called from do_exit(), the mm context is gone already, therefore
  9.1910 +	 * mm is NULL, i.e., the VMA is already gone  and we do not have to
  9.1911 +	 * do anything here
  9.1912 +	 */
  9.1913 +	if (ctx->ctx_smpl_vaddr && current->mm) {
  9.1914 +		smpl_buf_vaddr = ctx->ctx_smpl_vaddr;
  9.1915 +		smpl_buf_size  = ctx->ctx_smpl_size;
  9.1916 +	}
  9.1917 +
  9.1918 +	UNPROTECT_CTX(ctx, flags);
  9.1919 +
  9.1920 +	/*
  9.1921 +	 * if there was a mapping, then we systematically remove it
  9.1922 +	 * at this point. Cannot be done inside critical section
  9.1923 +	 * because some VM function reenables interrupts.
  9.1924 +	 *
  9.1925 +	 */
  9.1926 +	if (smpl_buf_vaddr) pfm_remove_smpl_mapping(current, smpl_buf_vaddr, smpl_buf_size);
  9.1927 +
  9.1928 +	return 0;
  9.1929 +}
  9.1930 +/*
  9.1931 + * called either on explicit close() or from exit_files(). 
  9.1932 + * Only the LAST user of the file gets to this point, i.e., it is
  9.1933 + * called only ONCE.
  9.1934 + *
  9.1935 + * IMPORTANT: we get called ONLY when the refcnt on the file gets to zero 
  9.1936 + * (fput()),i.e, last task to access the file. Nobody else can access the 
  9.1937 + * file at this point.
  9.1938 + *
  9.1939 + * When called from exit_files(), the VMA has been freed because exit_mm()
  9.1940 + * is executed before exit_files().
  9.1941 + *
  9.1942 + * When called from exit_files(), the current task is not yet ZOMBIE but we
  9.1943 + * flush the PMU state to the context. 
  9.1944 + */
  9.1945 +static int
  9.1946 +pfm_close(struct inode *inode, struct file *filp)
  9.1947 +{
  9.1948 +	pfm_context_t *ctx;
  9.1949 +	struct task_struct *task;
  9.1950 +	struct pt_regs *regs;
  9.1951 +  	DECLARE_WAITQUEUE(wait, current);
  9.1952 +	unsigned long flags;
  9.1953 +	unsigned long smpl_buf_size = 0UL;
  9.1954 +	void *smpl_buf_addr = NULL;
  9.1955 +	int free_possible = 1;
  9.1956 +	int state, is_system;
  9.1957 +
  9.1958 +	DPRINT(("pfm_close called private=%p\n", filp->private_data));
  9.1959 +
  9.1960 +	if (PFM_IS_FILE(filp) == 0) {
  9.1961 +		DPRINT(("bad magic\n"));
  9.1962 +		return -EBADF;
  9.1963 +	}
  9.1964 +	
  9.1965 +	ctx = (pfm_context_t *)filp->private_data;
  9.1966 +	if (ctx == NULL) {
  9.1967 +		printk(KERN_ERR "perfmon: pfm_close: NULL ctx [%d]\n", current->pid);
  9.1968 +		return -EBADF;
  9.1969 +	}
  9.1970 +
  9.1971 +	PROTECT_CTX(ctx, flags);
  9.1972 +
  9.1973 +	state     = ctx->ctx_state;
  9.1974 +	is_system = ctx->ctx_fl_system;
  9.1975 +
  9.1976 +	task = PFM_CTX_TASK(ctx);
  9.1977 +	regs = task_pt_regs(task);
  9.1978 +
  9.1979 +	DPRINT(("ctx_state=%d is_current=%d\n", 
  9.1980 +		state,
  9.1981 +		task == current ? 1 : 0));
  9.1982 +
  9.1983 +	/*
  9.1984 +	 * if task == current, then pfm_flush() unloaded the context
  9.1985 +	 */
  9.1986 +	if (state == PFM_CTX_UNLOADED) goto doit;
  9.1987 +
  9.1988 +	/*
  9.1989 +	 * context is loaded/masked and task != current, we need to
  9.1990 +	 * either force an unload or go zombie
  9.1991 +	 */
  9.1992 +
  9.1993 +	/*
  9.1994 +	 * The task is currently blocked or will block after an overflow.
  9.1995 +	 * we must force it to wakeup to get out of the
  9.1996 +	 * MASKED state and transition to the unloaded state by itself.
  9.1997 +	 *
  9.1998 +	 * This situation is only possible for per-task mode
  9.1999 +	 */
  9.2000 +	if (state == PFM_CTX_MASKED && CTX_OVFL_NOBLOCK(ctx) == 0) {
  9.2001 +
  9.2002 +		/*
  9.2003 +		 * set a "partial" zombie state to be checked
  9.2004 +		 * upon return from down() in pfm_handle_work().
  9.2005 +		 *
  9.2006 +		 * We cannot use the ZOMBIE state, because it is checked
  9.2007 +		 * by pfm_load_regs() which is called upon wakeup from down().
  9.2008 +		 * In such case, it would free the context and then we would
  9.2009 +		 * return to pfm_handle_work() which would access the
  9.2010 +		 * stale context. Instead, we set a flag invisible to pfm_load_regs()
  9.2011 +		 * but visible to pfm_handle_work().
  9.2012 +		 *
  9.2013 +		 * For some window of time, we have a zombie context with
  9.2014 +		 * ctx_state = MASKED  and not ZOMBIE
  9.2015 +		 */
  9.2016 +		ctx->ctx_fl_going_zombie = 1;
  9.2017 +
  9.2018 +		/*
  9.2019 +		 * force task to wake up from MASKED state
  9.2020 +		 */
  9.2021 +		complete(&ctx->ctx_restart_done);
  9.2022 +
  9.2023 +		DPRINT(("waking up ctx_state=%d\n", state));
  9.2024 +
  9.2025 +		/*
  9.2026 +		 * put ourself to sleep waiting for the other
  9.2027 +		 * task to report completion
  9.2028 +		 *
  9.2029 +		 * the context is protected by mutex, therefore there
  9.2030 +		 * is no risk of being notified of completion before
  9.2031 +		 * begin actually on the waitq.
  9.2032 +		 */
  9.2033 +  		set_current_state(TASK_INTERRUPTIBLE);
  9.2034 +  		add_wait_queue(&ctx->ctx_zombieq, &wait);
  9.2035 +
  9.2036 +		UNPROTECT_CTX(ctx, flags);
  9.2037 +
  9.2038 +		/*
  9.2039 +		 * XXX: check for signals :
  9.2040 +		 * 	- ok for explicit close
  9.2041 +		 * 	- not ok when coming from exit_files()
  9.2042 +		 */
  9.2043 +      		schedule();
  9.2044 +
  9.2045 +
  9.2046 +		PROTECT_CTX(ctx, flags);
  9.2047 +
  9.2048 +
  9.2049 +		remove_wait_queue(&ctx->ctx_zombieq, &wait);
  9.2050 +  		set_current_state(TASK_RUNNING);
  9.2051 +
  9.2052 +		/*
  9.2053 +		 * context is unloaded at this point
  9.2054 +		 */
  9.2055 +		DPRINT(("after zombie wakeup ctx_state=%d for\n", state));
  9.2056 +	}
  9.2057 +	else if (task != current) {
  9.2058 +#ifdef CONFIG_SMP
  9.2059 +		/*
  9.2060 +	 	 * switch context to zombie state
  9.2061 +	 	 */
  9.2062 +		ctx->ctx_state = PFM_CTX_ZOMBIE;
  9.2063 +
  9.2064 +		DPRINT(("zombie ctx for [%d]\n", task->pid));
  9.2065 +		/*
  9.2066 +		 * cannot free the context on the spot. deferred until
  9.2067 +		 * the task notices the ZOMBIE state
  9.2068 +		 */
  9.2069 +		free_possible = 0;
  9.2070 +#else
  9.2071 +		pfm_context_unload(ctx, NULL, 0, regs);
  9.2072 +#endif
  9.2073 +	}
  9.2074 +
  9.2075 +doit:
  9.2076 +	/* reload state, may have changed during  opening of critical section */
  9.2077 +	state = ctx->ctx_state;
  9.2078 +
  9.2079 +	/*
  9.2080 +	 * the context is still attached to a task (possibly current)
  9.2081 +	 * we cannot destroy it right now
  9.2082 +	 */
  9.2083 +
  9.2084 +	/*
  9.2085 +	 * we must free the sampling buffer right here because
  9.2086 +	 * we cannot rely on it being cleaned up later by the
  9.2087 +	 * monitored task. It is not possible to free vmalloc'ed
  9.2088 +	 * memory in pfm_load_regs(). Instead, we remove the buffer
  9.2089 +	 * now. should there be subsequent PMU overflow originally
  9.2090 +	 * meant for sampling, the will be converted to spurious
  9.2091 +	 * and that's fine because the monitoring tools is gone anyway.
  9.2092 +	 */
  9.2093 +	if (ctx->ctx_smpl_hdr) {
  9.2094 +		smpl_buf_addr = ctx->ctx_smpl_hdr;
  9.2095 +		smpl_buf_size = ctx->ctx_smpl_size;
  9.2096 +		/* no more sampling */
  9.2097 +		ctx->ctx_smpl_hdr = NULL;
  9.2098 +		ctx->ctx_fl_is_sampling = 0;
  9.2099 +	}
  9.2100 +
  9.2101 +	DPRINT(("ctx_state=%d free_possible=%d addr=%p size=%lu\n",
  9.2102 +		state,
  9.2103 +		free_possible,
  9.2104 +		smpl_buf_addr,
  9.2105 +		smpl_buf_size));
  9.2106 +
  9.2107 +	if (smpl_buf_addr) pfm_exit_smpl_buffer(ctx->ctx_buf_fmt);
  9.2108 +
  9.2109 +	/*
  9.2110 +	 * UNLOADED that the session has already been unreserved.
  9.2111 +	 */
  9.2112 +	if (state == PFM_CTX_ZOMBIE) {
  9.2113 +		pfm_unreserve_session(ctx, ctx->ctx_fl_system , ctx->ctx_cpu);
  9.2114 +	}
  9.2115 +
  9.2116 +	/*
  9.2117 +	 * disconnect file descriptor from context must be done
  9.2118 +	 * before we unlock.
  9.2119 +	 */
  9.2120 +	filp->private_data = NULL;
  9.2121 +
  9.2122 +	/*
  9.2123 +	 * if we free on the spot, the context is now completely unreacheable
  9.2124 +	 * from the callers side. The monitored task side is also cut, so we
  9.2125 +	 * can freely cut.
  9.2126 +	 *
  9.2127 +	 * If we have a deferred free, only the caller side is disconnected.
  9.2128 +	 */
  9.2129 +	UNPROTECT_CTX(ctx, flags);
  9.2130 +
  9.2131 +	/*
  9.2132 +	 * All memory free operations (especially for vmalloc'ed memory)
  9.2133 +	 * MUST be done with interrupts ENABLED.
  9.2134 +	 */
  9.2135 +	if (smpl_buf_addr)  pfm_rvfree(smpl_buf_addr, smpl_buf_size);
  9.2136 +
  9.2137 +	/*
  9.2138 +	 * return the memory used by the context
  9.2139 +	 */
  9.2140 +	if (free_possible) pfm_context_free(ctx);
  9.2141 +
  9.2142 +	if (is_running_on_xen()) {
  9.2143 +		if (is_xenoprof_primary()) {
  9.2144 +			int ret = HYPERVISOR_perfmon_op(PFM_DESTROY_CONTEXT,
  9.2145 +			                                NULL, 0);
  9.2146 +			if (ret)
  9.2147 +				printk("%s:%d PFM_DESTROY_CONTEXT hypercall "
  9.2148 +				       "failed\n", __func__, __LINE__);
  9.2149 +		}
  9.2150 +	}
  9.2151 +	return 0;
  9.2152 +}
  9.2153 +
  9.2154 +static int
  9.2155 +pfm_no_open(struct inode *irrelevant, struct file *dontcare)
  9.2156 +{
  9.2157 +	DPRINT(("pfm_no_open called\n"));
  9.2158 +	return -ENXIO;
  9.2159 +}
  9.2160 +
  9.2161 +
  9.2162 +
  9.2163 +static struct file_operations pfm_file_ops = {
  9.2164 +	.llseek   = no_llseek,
  9.2165 +	.read     = pfm_read,
  9.2166 +	.write    = pfm_write,
  9.2167 +	.poll     = pfm_poll,
  9.2168 +	.ioctl    = pfm_ioctl,
  9.2169 +	.open     = pfm_no_open,	/* special open code to disallow open via /proc */
  9.2170 +	.fasync   = pfm_fasync,
  9.2171 +	.release  = pfm_close,
  9.2172 +	.flush	  = pfm_flush
  9.2173 +};
  9.2174 +
  9.2175 +static int
  9.2176 +pfmfs_delete_dentry(struct dentry *dentry)
  9.2177 +{
  9.2178 +	return 1;
  9.2179 +}
  9.2180 +
  9.2181 +static struct dentry_operations pfmfs_dentry_operations = {
  9.2182 +	.d_delete = pfmfs_delete_dentry,
  9.2183 +};
  9.2184 +
  9.2185 +
  9.2186 +static int
  9.2187 +pfm_alloc_fd(struct file **cfile)
  9.2188 +{
  9.2189 +	int fd, ret = 0;
  9.2190 +	struct file *file = NULL;
  9.2191 +	struct inode * inode;
  9.2192 +	char name[32];
  9.2193 +	struct qstr this;
  9.2194 +
  9.2195 +	fd = get_unused_fd();
  9.2196 +	if (fd < 0) return -ENFILE;
  9.2197 +
  9.2198 +	ret = -ENFILE;
  9.2199 +
  9.2200 +	file = get_empty_filp();
  9.2201 +	if (!file) goto out;
  9.2202 +
  9.2203 +	/*
  9.2204 +	 * allocate a new inode
  9.2205 +	 */
  9.2206 +	inode = new_inode(pfmfs_mnt->mnt_sb);
  9.2207 +	if (!inode) goto out;
  9.2208 +
  9.2209 +	DPRINT(("new inode ino=%ld @%p\n", inode->i_ino, inode));
  9.2210 +
  9.2211 +	inode->i_mode = S_IFCHR|S_IRUGO;
  9.2212 +	inode->i_uid  = current->fsuid;
  9.2213 +	inode->i_gid  = current->fsgid;
  9.2214 +
  9.2215 +	sprintf(name, "[%lu]", inode->i_ino);
  9.2216 +	this.name = name;
  9.2217 +	this.len  = strlen(name);
  9.2218 +	this.hash = inode->i_ino;
  9.2219 +
  9.2220 +	ret = -ENOMEM;
  9.2221 +
  9.2222 +	/*
  9.2223 +	 * allocate a new dcache entry
  9.2224 +	 */
  9.2225 +	file->f_dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this);
  9.2226 +	if (!file->f_dentry) goto out;
  9.2227 +
  9.2228 +	file->f_dentry->d_op = &pfmfs_dentry_operations;
  9.2229 +
  9.2230 +	d_add(file->f_dentry, inode);
  9.2231 +	file->f_vfsmnt = mntget(pfmfs_mnt);
  9.2232 +	file->f_mapping = inode->i_mapping;
  9.2233 +
  9.2234 +	file->f_op    = &pfm_file_ops;
  9.2235 +	file->f_mode  = FMODE_READ;
  9.2236 +	file->f_flags = O_RDONLY;
  9.2237 +	file->f_pos   = 0;
  9.2238 +
  9.2239 +	/*
  9.2240 +	 * may have to delay until context is attached?
  9.2241 +	 */
  9.2242 +	fd_install(fd, file);
  9.2243 +
  9.2244 +	/*
  9.2245 +	 * the file structure we will use
  9.2246 +	 */
  9.2247 +	*cfile = file;
  9.2248 +
  9.2249 +	return fd;
  9.2250 +out:
  9.2251 +	if (file) put_filp(file);
  9.2252 +	put_unused_fd(fd);
  9.2253 +	return ret;
  9.2254 +}
  9.2255 +
  9.2256 +static void
  9.2257 +pfm_free_fd(int fd, struct file *file)
  9.2258 +{
  9.2259 +	struct files_struct *files = current->files;
  9.2260 +	struct fdtable *fdt;
  9.2261 +
  9.2262 +	/* 
  9.2263 +	 * there ie no fd_uninstall(), so we do it here
  9.2264 +	 */
  9.2265 +	spin_lock(&files->file_lock);
  9.2266 +	fdt = files_fdtable(files);
  9.2267 +	rcu_assign_pointer(fdt->fd[fd], NULL);
  9.2268 +	spin_unlock(&files->file_lock);
  9.2269 +
  9.2270 +	if (file)
  9.2271 +		put_filp(file);
  9.2272 +	put_unused_fd(fd);
  9.2273 +}
  9.2274 +
  9.2275 +static int
  9.2276 +pfm_remap_buffer(struct vm_area_struct *vma, unsigned long buf, unsigned long addr, unsigned long size)
  9.2277 +{
  9.2278 +	DPRINT(("CPU%d buf=0x%lx addr=0x%lx size=%ld\n", smp_processor_id(), buf, addr, size));
  9.2279 +
  9.2280 +	while (size > 0) {
  9.2281 +		unsigned long pfn = ia64_tpa(buf) >> PAGE_SHIFT;
  9.2282 +
  9.2283 +
  9.2284 +		if (remap_pfn_range(vma, addr, pfn, PAGE_SIZE, PAGE_READONLY))
  9.2285 +			return -ENOMEM;
  9.2286 +
  9.2287 +		addr  += PAGE_SIZE;
  9.2288 +		buf   += PAGE_SIZE;
  9.2289 +		size  -= PAGE_SIZE;
  9.2290 +	}
  9.2291 +	return 0;
  9.2292 +}
  9.2293 +
  9.2294 +/*
  9.2295 + * allocate a sampling buffer and remaps it into the user address space of the task
  9.2296 + */
  9.2297 +static int
  9.2298 +pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned long rsize, void **user_vaddr)
  9.2299 +{
  9.2300 +	struct mm_struct *mm = task->mm;
  9.2301 +	struct vm_area_struct *vma = NULL;
  9.2302 +	unsigned long size;
  9.2303 +	void *smpl_buf;
  9.2304 +
  9.2305 +
  9.2306 +	/*
  9.2307 +	 * the fixed header + requested size and align to page boundary
  9.2308 +	 */
  9.2309 +	size = PAGE_ALIGN(rsize);
  9.2310 +
  9.2311 +	DPRINT(("sampling buffer rsize=%lu size=%lu bytes\n", rsize, size));
  9.2312 +
  9.2313 +	/*
  9.2314 +	 * check requested size to avoid Denial-of-service attacks
  9.2315 +	 * XXX: may have to refine this test
  9.2316 +	 * Check against address space limit.
  9.2317 +	 *
  9.2318 +	 * if ((mm->total_vm << PAGE_SHIFT) + len> task->rlim[RLIMIT_AS].rlim_cur)
  9.2319 +	 * 	return -ENOMEM;
  9.2320 +	 */
  9.2321 +	if (size > task->signal->rlim[RLIMIT_MEMLOCK].rlim_cur)
  9.2322 +		return -ENOMEM;
  9.2323 +
  9.2324 +	/*
  9.2325 +	 * We do the easy to undo allocations first.
  9.2326 + 	 *
  9.2327 +	 * pfm_rvmalloc(), clears the buffer, so there is no leak
  9.2328 +	 */
  9.2329 +	smpl_buf = pfm_rvmalloc(size);
  9.2330 +	if (smpl_buf == NULL) {
  9.2331 +		DPRINT(("Can't allocate sampling buffer\n"));
  9.2332 +		return -ENOMEM;
  9.2333 +	}
  9.2334 +
  9.2335 +	DPRINT(("smpl_buf @%p\n", smpl_buf));
  9.2336 +
  9.2337 +	/* allocate vma */
  9.2338 +	vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
  9.2339 +	if (!vma) {
  9.2340 +		DPRINT(("Cannot allocate vma\n"));
  9.2341 +		goto error_kmem;
  9.2342 +	}
  9.2343 +	memset(vma, 0, sizeof(*vma));
  9.2344 +
  9.2345 +	/*
  9.2346 +	 * partially initialize the vma for the sampling buffer
  9.2347 +	 */
  9.2348 +	vma->vm_mm	     = mm;
  9.2349 +	vma->vm_flags	     = VM_READ| VM_MAYREAD |VM_RESERVED;
  9.2350 +	vma->vm_page_prot    = PAGE_READONLY; /* XXX may need to change */
  9.2351 +
  9.2352 +	/*
  9.2353 +	 * Now we have everything we need and we can initialize
  9.2354 +	 * and connect all the data structures
  9.2355 +	 */
  9.2356 +
  9.2357 +	ctx->ctx_smpl_hdr   = smpl_buf;
  9.2358 +	ctx->ctx_smpl_size  = size; /* aligned size */
  9.2359 +
  9.2360 +	/*
  9.2361 +	 * Let's do the difficult operations next.
  9.2362 +	 *
  9.2363 +	 * now we atomically find some area in the address space and
  9.2364 +	 * remap the buffer in it.
  9.2365 +	 */
  9.2366 +	down_write(&task->mm->mmap_sem);
  9.2367 +
  9.2368 +	/* find some free area in address space, must have mmap sem held */
  9.2369 +	vma->vm_start = pfm_get_unmapped_area(NULL, 0, size, 0, MAP_PRIVATE|MAP_ANONYMOUS, 0);
  9.2370 +	if (vma->vm_start == 0UL) {
  9.2371 +		DPRINT(("Cannot find unmapped area for size %ld\n", size));
  9.2372 +		up_write(&task->mm->mmap_sem);
  9.2373 +		goto error;
  9.2374 +	}
  9.2375 +	vma->vm_end = vma->vm_start + size;
  9.2376 +	vma->vm_pgoff = vma->vm_start >> PAGE_SHIFT;
  9.2377 +
  9.2378 +	DPRINT(("aligned size=%ld, hdr=%p mapped @0x%lx\n", size, ctx->ctx_smpl_hdr, vma->vm_start));
  9.2379 +
  9.2380 +	/* can only be applied to current task, need to have the mm semaphore held when called */
  9.2381 +	if (pfm_remap_buffer(vma, (unsigned long)smpl_buf, vma->vm_start, size)) {
  9.2382 +		DPRINT(("Can't remap buffer\n"));
  9.2383 +		up_write(&task->mm->mmap_sem);
  9.2384 +		goto error;
  9.2385 +	}
  9.2386 +
  9.2387 +	/*
  9.2388 +	 * now insert the vma in the vm list for the process, must be
  9.2389 +	 * done with mmap lock held
  9.2390 +	 */
  9.2391 +	insert_vm_struct(mm, vma);
  9.2392 +
  9.2393 +	mm->total_vm  += size >> PAGE_SHIFT;
  9.2394 +	vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
  9.2395 +							vma_pages(vma));
  9.2396 +	up_write(&task->mm->mmap_sem);
  9.2397 +
  9.2398 +	/*
  9.2399 +	 * keep track of user level virtual address
  9.2400 +	 */
  9.2401 +	ctx->ctx_smpl_vaddr = (void *)vma->vm_start;
  9.2402 +	*(unsigned long *)user_vaddr = vma->vm_start;
  9.2403 +
  9.2404 +	return 0;
  9.2405 +
  9.2406 +error:
  9.2407 +	kmem_cache_free(vm_area_cachep, vma);
  9.2408 +error_kmem:
  9.2409 +	pfm_rvfree(smpl_buf, size);
  9.2410 +
  9.2411 +	return -ENOMEM;
  9.2412 +}
  9.2413 +
  9.2414 +/*
  9.2415 + * XXX: do something better here
  9.2416 + */
  9.2417 +static int
  9.2418 +pfm_bad_permissions(struct task_struct *task)
  9.2419 +{
  9.2420 +	/* inspired by ptrace_attach() */
  9.2421 +	DPRINT(("cur: uid=%d gid=%d task: euid=%d suid=%d uid=%d egid=%d sgid=%d\n",
  9.2422 +		current->uid,
  9.2423 +		current->gid,
  9.2424 +		task->euid,
  9.2425 +		task->suid,
  9.2426 +		task->uid,
  9.2427 +		task->egid,
  9.2428 +		task->sgid));
  9.2429 +
  9.2430 +	return ((current->uid != task->euid)
  9.2431 +	    || (current->uid != task->suid)
  9.2432 +	    || (current->uid != task->uid)
  9.2433 +	    || (current->gid != task->egid)
  9.2434 +	    || (current->gid != task->sgid)
  9.2435 +	    || (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE);
  9.2436 +}
  9.2437 +
  9.2438 +static int
  9.2439 +pfarg_is_sane(struct task_struct *task, pfarg_context_t *pfx)
  9.2440 +{
  9.2441 +	int ctx_flags;
  9.2442 +
  9.2443 +	/* valid signal */
  9.2444 +
  9.2445 +	ctx_flags = pfx->ctx_flags;
  9.2446 +
  9.2447 +	if (ctx_flags & PFM_FL_SYSTEM_WIDE) {
  9.2448 +
  9.2449 +		/*
  9.2450 +		 * cannot block in this mode
  9.2451 +		 */
  9.2452 +		if (ctx_flags & PFM_FL_NOTIFY_BLOCK) {
  9.2453 +			DPRINT(("cannot use blocking mode when in system wide monitoring\n"));
  9.2454 +			return -EINVAL;
  9.2455 +		}
  9.2456 +	} else {
  9.2457 +	}
  9.2458 +	/* probably more to add here */
  9.2459 +
  9.2460 +	return 0;
  9.2461 +}
  9.2462 +
  9.2463 +static int
  9.2464 +pfm_setup_buffer_fmt(struct task_struct *task, pfm_context_t *ctx, unsigned int ctx_flags,
  9.2465 +		     unsigned int cpu, pfarg_context_t *arg)
  9.2466 +{
  9.2467 +	pfm_buffer_fmt_t *fmt = NULL;
  9.2468 +	unsigned long size = 0UL;
  9.2469 +	void *uaddr = NULL;
  9.2470 +	void *fmt_arg = NULL;
  9.2471 +	int ret = 0;
  9.2472 +#define PFM_CTXARG_BUF_ARG(a)	(pfm_buffer_fmt_t *)(a+1)
  9.2473 +
  9.2474 +	/* invoke and lock buffer format, if found */
  9.2475 +	fmt = pfm_find_buffer_fmt(arg->ctx_smpl_buf_id);
  9.2476 +	if (fmt == NULL) {
  9.2477 +		DPRINT(("[%d] cannot find buffer format\n", task->pid));
  9.2478 +		return -EINVAL;
  9.2479 +	}
  9.2480 +
  9.2481 +	/*
  9.2482 +	 * buffer argument MUST be contiguous to pfarg_context_t
  9.2483 +	 */
  9.2484 +	if (fmt->fmt_arg_size) fmt_arg = PFM_CTXARG_BUF_ARG(arg);
  9.2485 +
  9.2486 +	ret = pfm_buf_fmt_validate(fmt, task, ctx_flags, cpu, fmt_arg);
  9.2487 +
  9.2488 +	DPRINT(("[%d] after validate(0x%x,%d,%p)=%d\n", task->pid, ctx_flags, cpu, fmt_arg, ret));
  9.2489 +
  9.2490 +	if (ret) goto error;
  9.2491 +
  9.2492 +	/* link buffer format and context */
  9.2493 +	ctx->ctx_buf_fmt = fmt;
  9.2494 +
  9.2495 +	/*
  9.2496 +	 * check if buffer format wants to use perfmon buffer allocation/mapping service
  9.2497 +	 */
  9.2498 +	ret = pfm_buf_fmt_getsize(fmt, task, ctx_flags, cpu, fmt_arg, &size);
  9.2499 +	if (ret) goto error;
  9.2500 +
  9.2501 +	if (size) {
  9.2502 +		/*
  9.2503 +		 * buffer is always remapped into the caller's address space
  9.2504 +		 */
  9.2505 +		ret = pfm_smpl_buffer_alloc(current, ctx, size, &uaddr);
  9.2506 +		if (ret) goto error;
  9.2507 +
  9.2508 +		/* keep track of user address of buffer */
  9.2509 +		arg->ctx_smpl_vaddr = uaddr;
  9.2510 +	}
  9.2511 +	ret = pfm_buf_fmt_init(fmt, task, ctx->ctx_smpl_hdr, ctx_flags, cpu, fmt_arg);
  9.2512 +
  9.2513 +error:
  9.2514 +	return ret;
  9.2515 +}
  9.2516 +
  9.2517 +static void
  9.2518 +pfm_reset_pmu_state(pfm_context_t *ctx)
  9.2519 +{
  9.2520 +	int i;
  9.2521 +
  9.2522 +	/*
  9.2523 +	 * install reset values for PMC.
  9.2524 +	 */
  9.2525 +	for (i=1; PMC_IS_LAST(i) == 0; i++) {
  9.2526 +		if (PMC_IS_IMPL(i) == 0) continue;
  9.2527 +		ctx->ctx_pmcs[i] = PMC_DFL_VAL(i);
  9.2528 +		DPRINT(("pmc[%d]=0x%lx\n", i, ctx->ctx_pmcs[i]));
  9.2529 +	}
  9.2530 +	/*
  9.2531 +	 * PMD registers are set to 0UL when the context in memset()
  9.2532 +	 */
  9.2533 +
  9.2534 +	/*
  9.2535 +	 * On context switched restore, we must restore ALL pmc and ALL pmd even
  9.2536 +	 * when they are not actively used by the task. In UP, the incoming process
  9.2537 +	 * may otherwise pick up left over PMC, PMD state from the previous process.
  9.2538 +	 * As opposed to PMD, stale PMC can cause harm to the incoming
  9.2539 +	 * process because they may change what is being measured.
  9.2540 +	 * Therefore, we must systematically reinstall the entire
  9.2541 +	 * PMC state. In SMP, the same thing is possible on the
  9.2542 +	 * same CPU but also on between 2 CPUs.
  9.2543 +	 *
  9.2544 +	 * The problem with PMD is information leaking especially
  9.2545 +	 * to user level when psr.sp=0
  9.2546 +	 *
  9.2547 +	 * There is unfortunately no easy way to avoid this problem
  9.2548 +	 * on either UP or SMP. This definitively slows down the
  9.2549 +	 * pfm_load_regs() function.
  9.2550 +	 */
  9.2551 +
  9.2552 +	 /*
  9.2553 +	  * bitmask of all PMCs accessible to this context
  9.2554 +	  *
  9.2555 +	  * PMC0 is treated differently.
  9.2556 +	  */
  9.2557 +	ctx->ctx_all_pmcs[0] = pmu_conf->impl_pmcs[0] & ~0x1;
  9.2558 +
  9.2559 +	/*
  9.2560 +	 * bitmask of all PMDs that are accesible to this context
  9.2561 +	 */
  9.2562 +	ctx->ctx_all_pmds[0] = pmu_conf->impl_pmds[0];
  9.2563 +
  9.2564 +	DPRINT(("<%d> all_pmcs=0x%lx all_pmds=0x%lx\n", ctx->ctx_fd, ctx->ctx_all_pmcs[0],ctx->ctx_all_pmds[0]));
  9.2565 +
  9.2566 +	/*
  9.2567 +	 * useful in case of re-enable after disable
  9.2568 +	 */
  9.2569 +	ctx->ctx_used_ibrs[0] = 0UL;
  9.2570 +	ctx->ctx_used_dbrs[0] = 0UL;
  9.2571 +}
  9.2572 +
  9.2573 +static int
  9.2574 +pfm_ctx_getsize(void *arg, size_t *sz)
  9.2575 +{
  9.2576 +	pfarg_context_t *req = (pfarg_context_t *)arg;
  9.2577 +	pfm_buffer_fmt_t *fmt;
  9.2578 +
  9.2579 +	*sz = 0;
  9.2580 +
  9.2581 +	if (!pfm_uuid_cmp(req->ctx_smpl_buf_id, pfm_null_uuid)) return 0;
  9.2582 +
  9.2583 +	fmt = pfm_find_buffer_fmt(req->ctx_smpl_buf_id);
  9.2584 +	if (fmt == NULL) {
  9.2585 +		DPRINT(("cannot find buffer format\n"));
  9.2586 +		return -EINVAL;
  9.2587 +	}
  9.2588 +	/* get just enough to copy in user parameters */
  9.2589 +	*sz = fmt->fmt_arg_size;
  9.2590 +	DPRINT(("arg_size=%lu\n", *sz));
  9.2591 +
  9.2592 +	return 0;
  9.2593 +}
  9.2594 +
  9.2595 +
  9.2596 +
  9.2597 +/*
  9.2598 + * cannot attach if :
  9.2599 + * 	- kernel task
  9.2600 + * 	- task not owned by caller
  9.2601 + * 	- task incompatible with context mode
  9.2602 + */
  9.2603 +static int
  9.2604 +pfm_task_incompatible(pfm_context_t *ctx, struct task_struct *task)
  9.2605 +{
  9.2606 +	/*
  9.2607 +	 * no kernel task or task not owner by caller
  9.2608 +	 */
  9.2609 +	if (task->mm == NULL) {
  9.2610 +		DPRINT(("task [%d] has not memory context (kernel thread)\n", task->pid));
  9.2611 +		return -EPERM;
  9.2612 +	}
  9.2613 +	if (pfm_bad_permissions(task)) {
  9.2614 +		DPRINT(("no permission to attach to  [%d]\n", task->pid));
  9.2615 +		return -EPERM;
  9.2616 +	}
  9.2617 +	/*
  9.2618 +	 * cannot block in self-monitoring mode
  9.2619 +	 */
  9.2620 +	if (CTX_OVFL_NOBLOCK(ctx) == 0 && task == current) {
  9.2621 +		DPRINT(("cannot load a blocking context on self for [%d]\n", task->pid));
  9.2622 +		return -EINVAL;
  9.2623 +	}
  9.2624 +
  9.2625 +	if (task->exit_state == EXIT_ZOMBIE) {
  9.2626 +		DPRINT(("cannot attach to  zombie task [%d]\n", task->pid));
  9.2627 +		return -EBUSY;
  9.2628 +	}
  9.2629 +
  9.2630 +	/*
  9.2631 +	 * always ok for self
  9.2632 +	 */
  9.2633 +	if (task == current) return 0;
  9.2634 +
  9.2635 +	if ((task->state != TASK_STOPPED) && (task->state != TASK_TRACED)) {
  9.2636 +		DPRINT(("cannot attach to non-stopped task [%d] state=%ld\n", task->pid, task->state));
  9.2637 +		return -EBUSY;
  9.2638 +	}
  9.2639 +	/*
  9.2640 +	 * make sure the task is off any CPU
  9.2641 +	 */
  9.2642 +	wait_task_inactive(task);
  9.2643 +
  9.2644 +	/* more to come... */
  9.2645 +
  9.2646 +	return 0;
  9.2647 +}
  9.2648 +
  9.2649 +static int
  9.2650 +pfm_get_task(pfm_context_t *ctx, pid_t pid, struct task_struct **task)
  9.2651 +{
  9.2652 +	struct task_struct *p = current;
  9.2653 +	int ret;
  9.2654 +
  9.2655 +	/* XXX: need to add more checks here */
  9.2656 +	if (pid < 2) return -EPERM;
  9.2657 +
  9.2658 +	if (pid != current->pid) {
  9.2659 +
  9.2660 +		read_lock(&tasklist_lock);
  9.2661 +
  9.2662 +		p = find_task_by_pid(pid);
  9.2663 +
  9.2664 +		/* make sure task cannot go away while we operate on it */
  9.2665 +		if (p) get_task_struct(p);
  9.2666 +
  9.2667 +		read_unlock(&tasklist_lock);
  9.2668 +
  9.2669 +		if (p == NULL) return -ESRCH;
  9.2670 +	}
  9.2671 +
  9.2672 +	ret = pfm_task_incompatible(ctx, p);
  9.2673 +	if (ret == 0) {
  9.2674 +		*task = p;
  9.2675 +	} else if (p != current) {
  9.2676 +		pfm_put_task(p);
  9.2677 +	}
  9.2678 +	return ret;
  9.2679 +}
  9.2680 +
  9.2681 +
  9.2682 +
  9.2683 +static int
  9.2684 +pfm_context_create(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.2685 +{
  9.2686 +	pfarg_context_t *req = (pfarg_context_t *)arg;
  9.2687 +	struct file *filp;
  9.2688 +	int ctx_flags;
  9.2689 +	int ret;
  9.2690 +
  9.2691 +	/* let's check the arguments first */
  9.2692 +	ret = pfarg_is_sane(current, req);
  9.2693 +	if (ret < 0) return ret;
  9.2694 +
  9.2695 +	ctx_flags = req->ctx_flags;
  9.2696 +
  9.2697 +	ret = -ENOMEM;
  9.2698 +
  9.2699 +	ctx = pfm_context_alloc();
  9.2700 +	if (!ctx) goto error;
  9.2701 +
  9.2702 +	ret = pfm_alloc_fd(&filp);
  9.2703 +	if (ret < 0) goto error_file;
  9.2704 +
  9.2705 +	req->ctx_fd = ctx->ctx_fd = ret;
  9.2706 +
  9.2707 +	/*
  9.2708 +	 * attach context to file
  9.2709 +	 */
  9.2710 +	filp->private_data = ctx;
  9.2711 +
  9.2712 +	/*
  9.2713 +	 * does the user want to sample?
  9.2714 +	 */
  9.2715 +	if (pfm_uuid_cmp(req->ctx_smpl_buf_id, pfm_null_uuid)) {
  9.2716 +		ret = pfm_setup_buffer_fmt(current, ctx, ctx_flags, 0, req);
  9.2717 +		if (ret) goto buffer_error;
  9.2718 +	}
  9.2719 +
  9.2720 +	/*
  9.2721 +	 * init context protection lock
  9.2722 +	 */
  9.2723 +	spin_lock_init(&ctx->ctx_lock);
  9.2724 +
  9.2725 +	/*
  9.2726 +	 * context is unloaded
  9.2727 +	 */
  9.2728 +	ctx->ctx_state = PFM_CTX_UNLOADED;
  9.2729 +
  9.2730 +	/*
  9.2731 +	 * initialization of context's flags
  9.2732 +	 */
  9.2733 +	ctx->ctx_fl_block       = (ctx_flags & PFM_FL_NOTIFY_BLOCK) ? 1 : 0;
  9.2734 +	ctx->ctx_fl_system      = (ctx_flags & PFM_FL_SYSTEM_WIDE) ? 1: 0;
  9.2735 +	ctx->ctx_fl_is_sampling = ctx->ctx_buf_fmt ? 1 : 0; /* assume record() is defined */
  9.2736 +	ctx->ctx_fl_no_msg      = (ctx_flags & PFM_FL_OVFL_NO_MSG) ? 1: 0;
  9.2737 +	/*
  9.2738 +	 * will move to set properties
  9.2739 +	 * ctx->ctx_fl_excl_idle   = (ctx_flags & PFM_FL_EXCL_IDLE) ? 1: 0;
  9.2740 +	 */
  9.2741 +
  9.2742 +	/*
  9.2743 +	 * init restart semaphore to locked
  9.2744 +	 */
  9.2745 +	init_completion(&ctx->ctx_restart_done);
  9.2746 +
  9.2747 +	/*
  9.2748 +	 * activation is used in SMP only
  9.2749 +	 */
  9.2750 +	ctx->ctx_last_activation = PFM_INVALID_ACTIVATION;
  9.2751 +	SET_LAST_CPU(ctx, -1);
  9.2752 +
  9.2753 +	/*
  9.2754 +	 * initialize notification message queue
  9.2755 +	 */
  9.2756 +	ctx->ctx_msgq_head = ctx->ctx_msgq_tail = 0;
  9.2757 +	init_waitqueue_head(&ctx->ctx_msgq_wait);
  9.2758 +	init_waitqueue_head(&ctx->ctx_zombieq);
  9.2759 +
  9.2760 +	DPRINT(("ctx=%p flags=0x%x system=%d notify_block=%d excl_idle=%d no_msg=%d ctx_fd=%d \n",
  9.2761 +		ctx,
  9.2762 +		ctx_flags,
  9.2763 +		ctx->ctx_fl_system,
  9.2764 +		ctx->ctx_fl_block,
  9.2765 +		ctx->ctx_fl_excl_idle,
  9.2766 +		ctx->ctx_fl_no_msg,
  9.2767 +		ctx->ctx_fd));
  9.2768 +
  9.2769 +	/*
  9.2770 +	 * initialize soft PMU state
  9.2771 +	 */
  9.2772 +	pfm_reset_pmu_state(ctx);
  9.2773 +
  9.2774 +	if (is_running_on_xen()) {
  9.2775 +		/*
  9.2776 +		 * kludge to get xenoprof.is_primary.
  9.2777 +		 * XENOPROF_init/ia64 is nop. so it is safe to call it here.
  9.2778 +		 */
  9.2779 +		struct xenoprof_init init;
  9.2780 +		ret = HYPERVISOR_xenoprof_op(XENOPROF_init, &init);
  9.2781 +		if (ret)
  9.2782 +			goto buffer_error;
  9.2783 +		init_xenoprof_primary(init.is_primary);
  9.2784 +
  9.2785 +		if (is_xenoprof_primary()) {
  9.2786 +			ret = HYPERVISOR_perfmon_op(PFM_CREATE_CONTEXT, arg, 0);
  9.2787 +			if (ret)
  9.2788 +				goto buffer_error;
  9.2789 +		}
  9.2790 +	}
  9.2791 +	return 0;
  9.2792 +
  9.2793 +buffer_error:
  9.2794 +	pfm_free_fd(ctx->ctx_fd, filp);
  9.2795 +
  9.2796 +	if (ctx->ctx_buf_fmt) {
  9.2797 +		pfm_buf_fmt_exit(ctx->ctx_buf_fmt, current, NULL, regs);
  9.2798 +	}
  9.2799 +error_file:
  9.2800 +	pfm_context_free(ctx);
  9.2801 +
  9.2802 +error:
  9.2803 +	return ret;
  9.2804 +}
  9.2805 +
  9.2806 +static inline unsigned long
  9.2807 +pfm_new_counter_value (pfm_counter_t *reg, int is_long_reset)
  9.2808 +{
  9.2809 +	unsigned long val = is_long_reset ? reg->long_reset : reg->short_reset;
  9.2810 +	unsigned long new_seed, old_seed = reg->seed, mask = reg->mask;
  9.2811 +	extern unsigned long carta_random32 (unsigned long seed);
  9.2812 +
  9.2813 +	if (reg->flags & PFM_REGFL_RANDOM) {
  9.2814 +		new_seed = carta_random32(old_seed);
  9.2815 +		val -= (old_seed & mask);	/* counter values are negative numbers! */
  9.2816 +		if ((mask >> 32) != 0)
  9.2817 +			/* construct a full 64-bit random value: */
  9.2818 +			new_seed |= carta_random32(old_seed >> 32) << 32;
  9.2819 +		reg->seed = new_seed;
  9.2820 +	}
  9.2821 +	reg->lval = val;
  9.2822 +	return val;
  9.2823 +}
  9.2824 +
  9.2825 +static void
  9.2826 +pfm_reset_regs_masked(pfm_context_t *ctx, unsigned long *ovfl_regs, int is_long_reset)
  9.2827 +{
  9.2828 +	unsigned long mask = ovfl_regs[0];
  9.2829 +	unsigned long reset_others = 0UL;
  9.2830 +	unsigned long val;
  9.2831 +	int i;
  9.2832 +
  9.2833 +	/*
  9.2834 +	 * now restore reset value on sampling overflowed counters
  9.2835 +	 */
  9.2836 +	mask >>= PMU_FIRST_COUNTER;
  9.2837 +	for(i = PMU_FIRST_COUNTER; mask; i++, mask >>= 1) {
  9.2838 +
  9.2839 +		if ((mask & 0x1UL) == 0UL) continue;
  9.2840 +
  9.2841 +		ctx->ctx_pmds[i].val = val = pfm_new_counter_value(ctx->ctx_pmds+ i, is_long_reset);
  9.2842 +		reset_others        |= ctx->ctx_pmds[i].reset_pmds[0];
  9.2843 +
  9.2844 +		DPRINT_ovfl((" %s reset ctx_pmds[%d]=%lx\n", is_long_reset ? "long" : "short", i, val));
  9.2845 +	}
  9.2846 +
  9.2847 +	/*
  9.2848 +	 * Now take care of resetting the other registers
  9.2849 +	 */
  9.2850 +	for(i = 0; reset_others; i++, reset_others >>= 1) {
  9.2851 +
  9.2852 +		if ((reset_others & 0x1) == 0) continue;
  9.2853 +
  9.2854 +		ctx->ctx_pmds[i].val = val = pfm_new_counter_value(ctx->ctx_pmds + i, is_long_reset);
  9.2855 +
  9.2856 +		DPRINT_ovfl(("%s reset_others pmd[%d]=%lx\n",
  9.2857 +			  is_long_reset ? "long" : "short", i, val));
  9.2858 +	}
  9.2859 +}
  9.2860 +
  9.2861 +static void
  9.2862 +pfm_reset_regs(pfm_context_t *ctx, unsigned long *ovfl_regs, int is_long_reset)
  9.2863 +{
  9.2864 +	unsigned long mask = ovfl_regs[0];
  9.2865 +	unsigned long reset_others = 0UL;
  9.2866 +	unsigned long val;
  9.2867 +	int i;
  9.2868 +
  9.2869 +	DPRINT_ovfl(("ovfl_regs=0x%lx is_long_reset=%d\n", ovfl_regs[0], is_long_reset));
  9.2870 +
  9.2871 +	if (ctx->ctx_state == PFM_CTX_MASKED) {
  9.2872 +		pfm_reset_regs_masked(ctx, ovfl_regs, is_long_reset);
  9.2873 +		return;
  9.2874 +	}
  9.2875 +
  9.2876 +	/*
  9.2877 +	 * now restore reset value on sampling overflowed counters
  9.2878 +	 */
  9.2879 +	mask >>= PMU_FIRST_COUNTER;
  9.2880 +	for(i = PMU_FIRST_COUNTER; mask; i++, mask >>= 1) {
  9.2881 +
  9.2882 +		if ((mask & 0x1UL) == 0UL) continue;
  9.2883 +
  9.2884 +		val           = pfm_new_counter_value(ctx->ctx_pmds+ i, is_long_reset);
  9.2885 +		reset_others |= ctx->ctx_pmds[i].reset_pmds[0];
  9.2886 +
  9.2887 +		DPRINT_ovfl((" %s reset ctx_pmds[%d]=%lx\n", is_long_reset ? "long" : "short", i, val));
  9.2888 +
  9.2889 +		pfm_write_soft_counter(ctx, i, val);
  9.2890 +	}
  9.2891 +
  9.2892 +	/*
  9.2893 +	 * Now take care of resetting the other registers
  9.2894 +	 */
  9.2895 +	for(i = 0; reset_others; i++, reset_others >>= 1) {
  9.2896 +
  9.2897 +		if ((reset_others & 0x1) == 0) continue;
  9.2898 +
  9.2899 +		val = pfm_new_counter_value(ctx->ctx_pmds + i, is_long_reset);
  9.2900 +
  9.2901 +		if (PMD_IS_COUNTING(i)) {
  9.2902 +			pfm_write_soft_counter(ctx, i, val);
  9.2903 +		} else {
  9.2904 +			ia64_set_pmd(i, val);
  9.2905 +		}
  9.2906 +		DPRINT_ovfl(("%s reset_others pmd[%d]=%lx\n",
  9.2907 +			  is_long_reset ? "long" : "short", i, val));
  9.2908 +	}
  9.2909 +	ia64_srlz_d();
  9.2910 +}
  9.2911 +
  9.2912 +static int
  9.2913 +pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.2914 +{
  9.2915 +	struct thread_struct *thread = NULL;
  9.2916 +	struct task_struct *task;
  9.2917 +	pfarg_reg_t *req = (pfarg_reg_t *)arg;
  9.2918 +	unsigned long value, pmc_pm;
  9.2919 +	unsigned long smpl_pmds, reset_pmds, impl_pmds;
  9.2920 +	unsigned int cnum, reg_flags, flags, pmc_type;
  9.2921 +	int i, can_access_pmu = 0, is_loaded, is_system, expert_mode;
  9.2922 +	int is_monitor, is_counting, state;
  9.2923 +	int ret = -EINVAL;
  9.2924 +	pfm_reg_check_t	wr_func;
  9.2925 +#define PFM_CHECK_PMC_PM(x, y, z) ((x)->ctx_fl_system ^ PMC_PM(y, z))
  9.2926 +
  9.2927 +  	if (is_running_on_xen()) {
  9.2928 +		if (is_xenoprof_primary())
  9.2929 +			return HYPERVISOR_perfmon_op(PFM_WRITE_PMCS,
  9.2930 +			                             arg, count);
  9.2931 +		return 0;
  9.2932 +  	}
  9.2933 +	state     = ctx->ctx_state;
  9.2934 +	is_loaded = state == PFM_CTX_LOADED ? 1 : 0;
  9.2935 +	is_system = ctx->ctx_fl_system;
  9.2936 +	task      = ctx->ctx_task;
  9.2937 +	impl_pmds = pmu_conf->impl_pmds[0];
  9.2938 +
  9.2939 +	if (state == PFM_CTX_ZOMBIE) return -EINVAL;
  9.2940 +
  9.2941 +	if (is_loaded) {
  9.2942 +		thread = &task->thread;
  9.2943 +		/*
  9.2944 +		 * In system wide and when the context is loaded, access can only happen
  9.2945 +		 * when the caller is running on the CPU being monitored by the session.
  9.2946 +		 * It does not have to be the owner (ctx_task) of the context per se.
  9.2947 +		 */
  9.2948 +		if (is_system && ctx->ctx_cpu != smp_processor_id()) {
  9.2949 +			DPRINT(("should be running on CPU%d\n", ctx->ctx_cpu));
  9.2950 +			return -EBUSY;
  9.2951 +		}
  9.2952 +		can_access_pmu = GET_PMU_OWNER() == task || is_system ? 1 : 0;
  9.2953 +	}
  9.2954 +	expert_mode = pfm_sysctl.expert_mode; 
  9.2955 +
  9.2956 +	for (i = 0; i < count; i++, req++) {
  9.2957 +
  9.2958 +		cnum       = req->reg_num;
  9.2959 +		reg_flags  = req->reg_flags;
  9.2960 +		value      = req->reg_value;
  9.2961 +		smpl_pmds  = req->reg_smpl_pmds[0];
  9.2962 +		reset_pmds = req->reg_reset_pmds[0];
  9.2963 +		flags      = 0;
  9.2964 +
  9.2965 +
  9.2966 +		if (cnum >= PMU_MAX_PMCS) {
  9.2967 +			DPRINT(("pmc%u is invalid\n", cnum));
  9.2968 +			goto error;
  9.2969 +		}
  9.2970 +
  9.2971 +		pmc_type   = pmu_conf->pmc_desc[cnum].type;
  9.2972 +		pmc_pm     = (value >> pmu_conf->pmc_desc[cnum].pm_pos) & 0x1;
  9.2973 +		is_counting = (pmc_type & PFM_REG_COUNTING) == PFM_REG_COUNTING ? 1 : 0;
  9.2974 +		is_monitor  = (pmc_type & PFM_REG_MONITOR) == PFM_REG_MONITOR ? 1 : 0;
  9.2975 +
  9.2976 +		/*
  9.2977 +		 * we reject all non implemented PMC as well
  9.2978 +		 * as attempts to modify PMC[0-3] which are used
  9.2979 +		 * as status registers by the PMU
  9.2980 +		 */
  9.2981 +		if ((pmc_type & PFM_REG_IMPL) == 0 || (pmc_type & PFM_REG_CONTROL) == PFM_REG_CONTROL) {
  9.2982 +			DPRINT(("pmc%u is unimplemented or no-access pmc_type=%x\n", cnum, pmc_type));
  9.2983 +			goto error;
  9.2984 +		}
  9.2985 +		wr_func = pmu_conf->pmc_desc[cnum].write_check;
  9.2986 +		/*
  9.2987 +		 * If the PMC is a monitor, then if the value is not the default:
  9.2988 +		 * 	- system-wide session: PMCx.pm=1 (privileged monitor)
  9.2989 +		 * 	- per-task           : PMCx.pm=0 (user monitor)
  9.2990 +		 */
  9.2991 +		if (is_monitor && value != PMC_DFL_VAL(cnum) && is_system ^ pmc_pm) {
  9.2992 +			DPRINT(("pmc%u pmc_pm=%lu is_system=%d\n",
  9.2993 +				cnum,
  9.2994 +				pmc_pm,
  9.2995 +				is_system));
  9.2996 +			goto error;
  9.2997 +		}
  9.2998 +
  9.2999 +		if (is_counting) {
  9.3000 +			/*
  9.3001 +		 	 * enforce generation of overflow interrupt. Necessary on all
  9.3002 +		 	 * CPUs.
  9.3003 +		 	 */
  9.3004 +			value |= 1 << PMU_PMC_OI;
  9.3005 +
  9.3006 +			if (reg_flags & PFM_REGFL_OVFL_NOTIFY) {
  9.3007 +				flags |= PFM_REGFL_OVFL_NOTIFY;
  9.3008 +			}
  9.3009 +
  9.3010 +			if (reg_flags & PFM_REGFL_RANDOM) flags |= PFM_REGFL_RANDOM;
  9.3011 +
  9.3012 +			/* verify validity of smpl_pmds */
  9.3013 +			if ((smpl_pmds & impl_pmds) != smpl_pmds) {
  9.3014 +				DPRINT(("invalid smpl_pmds 0x%lx for pmc%u\n", smpl_pmds, cnum));
  9.3015 +				goto error;
  9.3016 +			}
  9.3017 +
  9.3018 +			/* verify validity of reset_pmds */
  9.3019 +			if ((reset_pmds & impl_pmds) != reset_pmds) {
  9.3020 +				DPRINT(("invalid reset_pmds 0x%lx for pmc%u\n", reset_pmds, cnum));
  9.3021 +				goto error;
  9.3022 +			}
  9.3023 +		} else {
  9.3024 +			if (reg_flags & (PFM_REGFL_OVFL_NOTIFY|PFM_REGFL_RANDOM)) {
  9.3025 +				DPRINT(("cannot set ovfl_notify or random on pmc%u\n", cnum));
  9.3026 +				goto error;
  9.3027 +			}
  9.3028 +			/* eventid on non-counting monitors are ignored */
  9.3029 +		}
  9.3030 +
  9.3031 +		/*
  9.3032 +		 * execute write checker, if any
  9.3033 +		 */
  9.3034 +		if (likely(expert_mode == 0 && wr_func)) {
  9.3035 +			ret = (*wr_func)(task, ctx, cnum, &value, regs);
  9.3036 +			if (ret) goto error;
  9.3037 +			ret = -EINVAL;
  9.3038 +		}
  9.3039 +
  9.3040 +		/*
  9.3041 +		 * no error on this register
  9.3042 +		 */
  9.3043 +		PFM_REG_RETFLAG_SET(req->reg_flags, 0);
  9.3044 +
  9.3045 +		/*
  9.3046 +		 * Now we commit the changes to the software state
  9.3047 +		 */
  9.3048 +
  9.3049 +		/*
  9.3050 +		 * update overflow information
  9.3051 +		 */
  9.3052 +		if (is_counting) {
  9.3053 +			/*
  9.3054 +		 	 * full flag update each time a register is programmed
  9.3055 +		 	 */
  9.3056 +			ctx->ctx_pmds[cnum].flags = flags;
  9.3057 +
  9.3058 +			ctx->ctx_pmds[cnum].reset_pmds[0] = reset_pmds;
  9.3059 +			ctx->ctx_pmds[cnum].smpl_pmds[0]  = smpl_pmds;
  9.3060 +			ctx->ctx_pmds[cnum].eventid       = req->reg_smpl_eventid;
  9.3061 +
  9.3062 +			/*
  9.3063 +			 * Mark all PMDS to be accessed as used.
  9.3064 +			 *
  9.3065 +			 * We do not keep track of PMC because we have to
  9.3066 +			 * systematically restore ALL of them.
  9.3067 +			 *
  9.3068 +			 * We do not update the used_monitors mask, because
  9.3069 +			 * if we have not programmed them, then will be in
  9.3070 +			 * a quiescent state, therefore we will not need to
  9.3071 +			 * mask/restore then when context is MASKED.
  9.3072 +			 */
  9.3073 +			CTX_USED_PMD(ctx, reset_pmds);
  9.3074 +			CTX_USED_PMD(ctx, smpl_pmds);
  9.3075 +			/*
  9.3076 +		 	 * make sure we do not try to reset on
  9.3077 +		 	 * restart because we have established new values
  9.3078 +		 	 */
  9.3079 +			if (state == PFM_CTX_MASKED) ctx->ctx_ovfl_regs[0] &= ~1UL << cnum;
  9.3080 +		}
  9.3081 +		/*
  9.3082 +		 * Needed in case the user does not initialize the equivalent
  9.3083 +		 * PMD. Clearing is done indirectly via pfm_reset_pmu_state() so there is no
  9.3084 +		 * possible leak here.
  9.3085 +		 */
  9.3086 +		CTX_USED_PMD(ctx, pmu_conf->pmc_desc[cnum].dep_pmd[0]);
  9.3087 +
  9.3088 +		/*
  9.3089 +		 * keep track of the monitor PMC that we are using.
  9.3090 +		 * we save the value of the pmc in ctx_pmcs[] and if
  9.3091 +		 * the monitoring is not stopped for the context we also
  9.3092 +		 * place it in the saved state area so that it will be
  9.3093 +		 * picked up later by the context switch code.
  9.3094 +		 *
  9.3095 +		 * The value in ctx_pmcs[] can only be changed in pfm_write_pmcs().
  9.3096 +		 *
  9.3097 +		 * The value in thread->pmcs[] may be modified on overflow, i.e.,  when
  9.3098 +		 * monitoring needs to be stopped.
  9.3099 +		 */
  9.3100 +		if (is_monitor) CTX_USED_MONITOR(ctx, 1UL << cnum);
  9.3101 +
  9.3102 +		/*
  9.3103 +		 * update context state
  9.3104 +		 */
  9.3105 +		ctx->ctx_pmcs[cnum] = value;
  9.3106 +
  9.3107 +		if (is_loaded) {
  9.3108 +			/*
  9.3109 +			 * write thread state
  9.3110 +			 */
  9.3111 +			if (is_system == 0) thread->pmcs[cnum] = value;
  9.3112 +
  9.3113 +			/*
  9.3114 +			 * write hardware register if we can
  9.3115 +			 */
  9.3116 +			if (can_access_pmu) {
  9.3117 +				ia64_set_pmc(cnum, value);
  9.3118 +			}
  9.3119 +#ifdef CONFIG_SMP
  9.3120 +			else {
  9.3121 +				/*
  9.3122 +				 * per-task SMP only here
  9.3123 +				 *
  9.3124 +			 	 * we are guaranteed that the task is not running on the other CPU,
  9.3125 +			 	 * we indicate that this PMD will need to be reloaded if the task
  9.3126 +			 	 * is rescheduled on the CPU it ran last on.
  9.3127 +			 	 */
  9.3128 +				ctx->ctx_reload_pmcs[0] |= 1UL << cnum;
  9.3129 +			}
  9.3130 +#endif
  9.3131 +		}
  9.3132 +
  9.3133 +		DPRINT(("pmc[%u]=0x%lx ld=%d apmu=%d flags=0x%x all_pmcs=0x%lx used_pmds=0x%lx eventid=%ld smpl_pmds=0x%lx reset_pmds=0x%lx reloads_pmcs=0x%lx used_monitors=0x%lx ovfl_regs=0x%lx\n",
  9.3134 +			  cnum,
  9.3135 +			  value,
  9.3136 +			  is_loaded,
  9.3137 +			  can_access_pmu,
  9.3138 +			  flags,
  9.3139 +			  ctx->ctx_all_pmcs[0],
  9.3140 +			  ctx->ctx_used_pmds[0],
  9.3141 +			  ctx->ctx_pmds[cnum].eventid,
  9.3142 +			  smpl_pmds,
  9.3143 +			  reset_pmds,
  9.3144 +			  ctx->ctx_reload_pmcs[0],
  9.3145 +			  ctx->ctx_used_monitors[0],
  9.3146 +			  ctx->ctx_ovfl_regs[0]));
  9.3147 +	}
  9.3148 +
  9.3149 +	/*
  9.3150 +	 * make sure the changes are visible
  9.3151 +	 */
  9.3152 +	if (can_access_pmu) ia64_srlz_d();
  9.3153 +
  9.3154 +	return 0;
  9.3155 +error:
  9.3156 +	PFM_REG_RETFLAG_SET(req->reg_flags, PFM_REG_RETFL_EINVAL);
  9.3157 +	return ret;
  9.3158 +}
  9.3159 +
  9.3160 +static int
  9.3161 +pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.3162 +{
  9.3163 +	struct thread_struct *thread = NULL;
  9.3164 +	struct task_struct *task;
  9.3165 +	pfarg_reg_t *req = (pfarg_reg_t *)arg;
  9.3166 +	unsigned long value, hw_value, ovfl_mask;
  9.3167 +	unsigned int cnum;
  9.3168 +	int i, can_access_pmu = 0, state;
  9.3169 +	int is_counting, is_loaded, is_system, expert_mode;
  9.3170 +	int ret = -EINVAL;
  9.3171 +	pfm_reg_check_t wr_func;
  9.3172 +
  9.3173 +  	if (is_running_on_xen()) {
  9.3174 +		if (is_xenoprof_primary())
  9.3175 +			return HYPERVISOR_perfmon_op(PFM_WRITE_PMDS,
  9.3176 +			                             arg, count);
  9.3177 +		return 0;
  9.3178 +  	}
  9.3179 +
  9.3180 +	state     = ctx->ctx_state;
  9.3181 +	is_loaded = state == PFM_CTX_LOADED ? 1 : 0;
  9.3182 +	is_system = ctx->ctx_fl_system;
  9.3183 +	ovfl_mask = pmu_conf->ovfl_val;
  9.3184 +	task      = ctx->ctx_task;
  9.3185 +
  9.3186 +	if (unlikely(state == PFM_CTX_ZOMBIE)) return -EINVAL;
  9.3187 +
  9.3188 +	/*
  9.3189 +	 * on both UP and SMP, we can only write to the PMC when the task is
  9.3190 +	 * the owner of the local PMU.
  9.3191 +	 */
  9.3192 +	if (likely(is_loaded)) {
  9.3193 +		thread = &task->thread;
  9.3194 +		/*
  9.3195 +		 * In system wide and when the context is loaded, access can only happen
  9.3196 +		 * when the caller is running on the CPU being monitored by the session.
  9.3197 +		 * It does not have to be the owner (ctx_task) of the context per se.
  9.3198 +		 */
  9.3199 +		if (unlikely(is_system && ctx->ctx_cpu != smp_processor_id())) {
  9.3200 +			DPRINT(("should be running on CPU%d\n", ctx->ctx_cpu));
  9.3201 +			return -EBUSY;
  9.3202 +		}
  9.3203 +		can_access_pmu = GET_PMU_OWNER() == task || is_system ? 1 : 0;
  9.3204 +	}
  9.3205 +	expert_mode = pfm_sysctl.expert_mode; 
  9.3206 +
  9.3207 +	for (i = 0; i < count; i++, req++) {
  9.3208 +
  9.3209 +		cnum  = req->reg_num;
  9.3210 +		value = req->reg_value;
  9.3211 +
  9.3212 +		if (!PMD_IS_IMPL(cnum)) {
  9.3213 +			DPRINT(("pmd[%u] is unimplemented or invalid\n", cnum));
  9.3214 +			goto abort_mission;
  9.3215 +		}
  9.3216 +		is_counting = PMD_IS_COUNTING(cnum);
  9.3217 +		wr_func     = pmu_conf->pmd_desc[cnum].write_check;
  9.3218 +
  9.3219 +		/*
  9.3220 +		 * execute write checker, if any
  9.3221 +		 */
  9.3222 +		if (unlikely(expert_mode == 0 && wr_func)) {
  9.3223 +			unsigned long v = value;
  9.3224 +
  9.3225 +			ret = (*wr_func)(task, ctx, cnum, &v, regs);
  9.3226 +			if (ret) goto abort_mission;
  9.3227 +
  9.3228 +			value = v;
  9.3229 +			ret   = -EINVAL;
  9.3230 +		}
  9.3231 +
  9.3232 +		/*
  9.3233 +		 * no error on this register
  9.3234 +		 */
  9.3235 +		PFM_REG_RETFLAG_SET(req->reg_flags, 0);
  9.3236 +
  9.3237 +		/*
  9.3238 +		 * now commit changes to software state
  9.3239 +		 */
  9.3240 +		hw_value = value;
  9.3241 +
  9.3242 +		/*
  9.3243 +		 * update virtualized (64bits) counter
  9.3244 +		 */
  9.3245 +		if (is_counting) {
  9.3246 +			/*
  9.3247 +			 * write context state
  9.3248 +			 */
  9.3249 +			ctx->ctx_pmds[cnum].lval = value;
  9.3250 +
  9.3251 +			/*
  9.3252 +			 * when context is load we use the split value
  9.3253 +			 */
  9.3254 +			if (is_loaded) {
  9.3255 +				hw_value = value &  ovfl_mask;
  9.3256 +				value    = value & ~ovfl_mask;
  9.3257 +			}
  9.3258 +		}
  9.3259 +		/*
  9.3260 +		 * update reset values (not just for counters)
  9.3261 +		 */
  9.3262 +		ctx->ctx_pmds[cnum].long_reset  = req->reg_long_reset;
  9.3263 +		ctx->ctx_pmds[cnum].short_reset = req->reg_short_reset;
  9.3264 +
  9.3265 +		/*
  9.3266 +		 * update randomization parameters (not just for counters)
  9.3267 +		 */
  9.3268 +		ctx->ctx_pmds[cnum].seed = req->reg_random_seed;
  9.3269 +		ctx->ctx_pmds[cnum].mask = req->reg_random_mask;
  9.3270 +
  9.3271 +		/*
  9.3272 +		 * update context value
  9.3273 +		 */
  9.3274 +		ctx->ctx_pmds[cnum].val  = value;
  9.3275 +
  9.3276 +		/*
  9.3277 +		 * Keep track of what we use
  9.3278 +		 *
  9.3279 +		 * We do not keep track of PMC because we have to
  9.3280 +		 * systematically restore ALL of them.
  9.3281 +		 */
  9.3282 +		CTX_USED_PMD(ctx, PMD_PMD_DEP(cnum));
  9.3283 +
  9.3284 +		/*
  9.3285 +		 * mark this PMD register used as well
  9.3286 +		 */
  9.3287 +		CTX_USED_PMD(ctx, RDEP(cnum));
  9.3288 +
  9.3289 +		/*
  9.3290 +		 * make sure we do not try to reset on
  9.3291 +		 * restart because we have established new values
  9.3292 +		 */
  9.3293 +		if (is_counting && state == PFM_CTX_MASKED) {
  9.3294 +			ctx->ctx_ovfl_regs[0] &= ~1UL << cnum;
  9.3295 +		}
  9.3296 +
  9.3297 +		if (is_loaded) {
  9.3298 +			/*
  9.3299 +		 	 * write thread state
  9.3300 +		 	 */
  9.3301 +			if (is_system == 0) thread->pmds[cnum] = hw_value;
  9.3302 +
  9.3303 +			/*
  9.3304 +			 * write hardware register if we can
  9.3305 +			 */
  9.3306 +			if (can_access_pmu) {
  9.3307 +				ia64_set_pmd(cnum, hw_value);
  9.3308 +			} else {
  9.3309 +#ifdef CONFIG_SMP
  9.3310 +				/*
  9.3311 +			 	 * we are guaranteed that the task is not running on the other CPU,
  9.3312 +			 	 * we indicate that this PMD will need to be reloaded if the task
  9.3313 +			 	 * is rescheduled on the CPU it ran last on.
  9.3314 +			 	 */
  9.3315 +				ctx->ctx_reload_pmds[0] |= 1UL << cnum;
  9.3316 +#endif
  9.3317 +			}
  9.3318 +		}
  9.3319 +
  9.3320 +		DPRINT(("pmd[%u]=0x%lx ld=%d apmu=%d, hw_value=0x%lx ctx_pmd=0x%lx  short_reset=0x%lx "
  9.3321 +			  "long_reset=0x%lx notify=%c seed=0x%lx mask=0x%lx used_pmds=0x%lx reset_pmds=0x%lx reload_pmds=0x%lx all_pmds=0x%lx ovfl_regs=0x%lx\n",
  9.3322 +			cnum,
  9.3323 +			value,
  9.3324 +			is_loaded,
  9.3325 +			can_access_pmu,
  9.3326 +			hw_value,
  9.3327 +			ctx->ctx_pmds[cnum].val,
  9.3328 +			ctx->ctx_pmds[cnum].short_reset,
  9.3329 +			ctx->ctx_pmds[cnum].long_reset,
  9.3330 +			PMC_OVFL_NOTIFY(ctx, cnum) ? 'Y':'N',
  9.3331 +			ctx->ctx_pmds[cnum].seed,
  9.3332 +			ctx->ctx_pmds[cnum].mask,
  9.3333 +			ctx->ctx_used_pmds[0],
  9.3334 +			ctx->ctx_pmds[cnum].reset_pmds[0],
  9.3335 +			ctx->ctx_reload_pmds[0],
  9.3336 +			ctx->ctx_all_pmds[0],
  9.3337 +			ctx->ctx_ovfl_regs[0]));
  9.3338 +	}
  9.3339 +
  9.3340 +	/*
  9.3341 +	 * make changes visible
  9.3342 +	 */
  9.3343 +	if (can_access_pmu) ia64_srlz_d();
  9.3344 +
  9.3345 +	return 0;
  9.3346 +
  9.3347 +abort_mission:
  9.3348 +	/*
  9.3349 +	 * for now, we have only one possibility for error
  9.3350 +	 */
  9.3351 +	PFM_REG_RETFLAG_SET(req->reg_flags, PFM_REG_RETFL_EINVAL);
  9.3352 +	return ret;
  9.3353 +}
  9.3354 +
  9.3355 +/*
  9.3356 + * By the way of PROTECT_CONTEXT(), interrupts are masked while we are in this function.
  9.3357 + * Therefore we know, we do not have to worry about the PMU overflow interrupt. If an
  9.3358 + * interrupt is delivered during the call, it will be kept pending until we leave, making
  9.3359 + * it appears as if it had been generated at the UNPROTECT_CONTEXT(). At least we are
  9.3360 + * guaranteed to return consistent data to the user, it may simply be old. It is not
  9.3361 + * trivial to treat the overflow while inside the call because you may end up in
  9.3362 + * some module sampling buffer code causing deadlocks.
  9.3363 + */
  9.3364 +static int
  9.3365 +pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.3366 +{
  9.3367 +	struct thread_struct *thread = NULL;
  9.3368 +	struct task_struct *task;
  9.3369 +	unsigned long val = 0UL, lval, ovfl_mask, sval;
  9.3370 +	pfarg_reg_t *req = (pfarg_reg_t *)arg;
  9.3371 +	unsigned int cnum, reg_flags = 0;
  9.3372 +	int i, can_access_pmu = 0, state;
  9.3373 +	int is_loaded, is_system, is_counting, expert_mode;
  9.3374 +	int ret = -EINVAL;
  9.3375 +	pfm_reg_check_t rd_func;
  9.3376 +	XEN_NOT_SUPPORTED_YET;
  9.3377 +
  9.3378 +	/*
  9.3379 +	 * access is possible when loaded only for
  9.3380 +	 * self-monitoring tasks or in UP mode
  9.3381 +	 */
  9.3382 +
  9.3383 +	state     = ctx->ctx_state;
  9.3384 +	is_loaded = state == PFM_CTX_LOADED ? 1 : 0;
  9.3385 +	is_system = ctx->ctx_fl_system;
  9.3386 +	ovfl_mask = pmu_conf->ovfl_val;
  9.3387 +	task      = ctx->ctx_task;
  9.3388 +
  9.3389 +	if (state == PFM_CTX_ZOMBIE) return -EINVAL;
  9.3390 +
  9.3391 +	if (likely(is_loaded)) {
  9.3392 +		thread = &task->thread;
  9.3393 +		/*
  9.3394 +		 * In system wide and when the context is loaded, access can only happen
  9.3395 +		 * when the caller is running on the CPU being monitored by the session.
  9.3396 +		 * It does not have to be the owner (ctx_task) of the context per se.
  9.3397 +		 */
  9.3398 +		if (unlikely(is_system && ctx->ctx_cpu != smp_processor_id())) {
  9.3399 +			DPRINT(("should be running on CPU%d\n", ctx->ctx_cpu));
  9.3400 +			return -EBUSY;
  9.3401 +		}
  9.3402 +		/*
  9.3403 +		 * this can be true when not self-monitoring only in UP
  9.3404 +		 */
  9.3405 +		can_access_pmu = GET_PMU_OWNER() == task || is_system ? 1 : 0;
  9.3406 +
  9.3407 +		if (can_access_pmu) ia64_srlz_d();
  9.3408 +	}
  9.3409 +	expert_mode = pfm_sysctl.expert_mode; 
  9.3410 +
  9.3411 +	DPRINT(("ld=%d apmu=%d ctx_state=%d\n",
  9.3412 +		is_loaded,
  9.3413 +		can_access_pmu,
  9.3414 +		state));
  9.3415 +
  9.3416 +	/*
  9.3417 +	 * on both UP and SMP, we can only read the PMD from the hardware register when
  9.3418 +	 * the task is the owner of the local PMU.
  9.3419 +	 */
  9.3420 +
  9.3421 +	for (i = 0; i < count; i++, req++) {
  9.3422 +
  9.3423 +		cnum        = req->reg_num;
  9.3424 +		reg_flags   = req->reg_flags;
  9.3425 +
  9.3426 +		if (unlikely(!PMD_IS_IMPL(cnum))) goto error;
  9.3427 +		/*
  9.3428 +		 * we can only read the register that we use. That includes
  9.3429 +		 * the one we explicitely initialize AND the one we want included
  9.3430 +		 * in the sampling buffer (smpl_regs).
  9.3431 +		 *
  9.3432 +		 * Having this restriction allows optimization in the ctxsw routine
  9.3433 +		 * without compromising security (leaks)
  9.3434 +		 */
  9.3435 +		if (unlikely(!CTX_IS_USED_PMD(ctx, cnum))) goto error;
  9.3436 +
  9.3437 +		sval        = ctx->ctx_pmds[cnum].val;
  9.3438 +		lval        = ctx->ctx_pmds[cnum].lval;
  9.3439 +		is_counting = PMD_IS_COUNTING(cnum);
  9.3440 +
  9.3441 +		/*
  9.3442 +		 * If the task is not the current one, then we check if the
  9.3443 +		 * PMU state is still in the local live register due to lazy ctxsw.
  9.3444 +		 * If true, then we read directly from the registers.
  9.3445 +		 */
  9.3446 +		if (can_access_pmu){
  9.3447 +			val = ia64_get_pmd(cnum);
  9.3448 +		} else {
  9.3449 +			/*
  9.3450 +			 * context has been saved
  9.3451 +			 * if context is zombie, then task does not exist anymore.
  9.3452 +			 * In this case, we use the full value saved in the context (pfm_flush_regs()).
  9.3453 +			 */
  9.3454 +			val = is_loaded ? thread->pmds[cnum] : 0UL;
  9.3455 +		}
  9.3456 +		rd_func = pmu_conf->pmd_desc[cnum].read_check;
  9.3457 +
  9.3458 +		if (is_counting) {
  9.3459 +			/*
  9.3460 +			 * XXX: need to check for overflow when loaded
  9.3461 +			 */
  9.3462 +			val &= ovfl_mask;
  9.3463 +			val += sval;
  9.3464 +		}
  9.3465 +
  9.3466 +		/*
  9.3467 +		 * execute read checker, if any
  9.3468 +		 */
  9.3469 +		if (unlikely(expert_mode == 0 && rd_func)) {
  9.3470 +			unsigned long v = val;
  9.3471 +			ret = (*rd_func)(ctx->ctx_task, ctx, cnum, &v, regs);
  9.3472 +			if (ret) goto error;
  9.3473 +			val = v;
  9.3474 +			ret = -EINVAL;
  9.3475 +		}
  9.3476 +
  9.3477 +		PFM_REG_RETFLAG_SET(reg_flags, 0);
  9.3478 +
  9.3479 +		DPRINT(("pmd[%u]=0x%lx\n", cnum, val));
  9.3480 +
  9.3481 +		/*
  9.3482 +		 * update register return value, abort all if problem during copy.
  9.3483 +		 * we only modify the reg_flags field. no check mode is fine because
  9.3484 +		 * access has been verified upfront in sys_perfmonctl().
  9.3485 +		 */
  9.3486 +		req->reg_value            = val;
  9.3487 +		req->reg_flags            = reg_flags;
  9.3488 +		req->reg_last_reset_val   = lval;
  9.3489 +	}
  9.3490 +
  9.3491 +	return 0;
  9.3492 +
  9.3493 +error:
  9.3494 +	PFM_REG_RETFLAG_SET(req->reg_flags, PFM_REG_RETFL_EINVAL);
  9.3495 +	return ret;
  9.3496 +}
  9.3497 +
  9.3498 +int
  9.3499 +pfm_mod_write_pmcs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs)
  9.3500 +{
  9.3501 +	pfm_context_t *ctx;
  9.3502 +
  9.3503 +	if (req == NULL) return -EINVAL;
  9.3504 +
  9.3505 + 	ctx = GET_PMU_CTX();
  9.3506 +
  9.3507 +	if (ctx == NULL) return -EINVAL;
  9.3508 +
  9.3509 +	/*
  9.3510 +	 * for now limit to current task, which is enough when calling
  9.3511 +	 * from overflow handler
  9.3512 +	 */
  9.3513 +	if (task != current && ctx->ctx_fl_system == 0) return -EBUSY;
  9.3514 +
  9.3515 +	return pfm_write_pmcs(ctx, req, nreq, regs);
  9.3516 +}
  9.3517 +EXPORT_SYMBOL(pfm_mod_write_pmcs);
  9.3518 +
  9.3519 +int
  9.3520 +pfm_mod_read_pmds(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs)
  9.3521 +{
  9.3522 +	pfm_context_t *ctx;
  9.3523 +
  9.3524 +	if (req == NULL) return -EINVAL;
  9.3525 +
  9.3526 + 	ctx = GET_PMU_CTX();
  9.3527 +
  9.3528 +	if (ctx == NULL) return -EINVAL;
  9.3529 +
  9.3530 +	/*
  9.3531 +	 * for now limit to current task, which is enough when calling
  9.3532 +	 * from overflow handler
  9.3533 +	 */
  9.3534 +	if (task != current && ctx->ctx_fl_system == 0) return -EBUSY;
  9.3535 +
  9.3536 +	return pfm_read_pmds(ctx, req, nreq, regs);
  9.3537 +}
  9.3538 +EXPORT_SYMBOL(pfm_mod_read_pmds);
  9.3539 +
  9.3540 +/*
  9.3541 + * Only call this function when a process it trying to
  9.3542 + * write the debug registers (reading is always allowed)
  9.3543 + */
  9.3544 +int
  9.3545 +pfm_use_debug_registers(struct task_struct *task)
  9.3546 +{
  9.3547 +	pfm_context_t *ctx = task->thread.pfm_context;
  9.3548 +	unsigned long flags;
  9.3549 +	int ret = 0;
  9.3550 +
  9.3551 +	if (pmu_conf->use_rr_dbregs == 0) return 0;
  9.3552 +
  9.3553 +	DPRINT(("called for [%d]\n", task->pid));
  9.3554 +
  9.3555 +	/*
  9.3556 +	 * do it only once
  9.3557 +	 */
  9.3558 +	if (task->thread.flags & IA64_THREAD_DBG_VALID) return 0;
  9.3559 +
  9.3560 +	/*
  9.3561 +	 * Even on SMP, we do not need to use an atomic here because
  9.3562 +	 * the only way in is via ptrace() and this is possible only when the
  9.3563 +	 * process is stopped. Even in the case where the ctxsw out is not totally
  9.3564 +	 * completed by the time we come here, there is no way the 'stopped' process
  9.3565 +	 * could be in the middle of fiddling with the pfm_write_ibr_dbr() routine.
  9.3566 +	 * So this is always safe.
  9.3567 +	 */
  9.3568 +	if (ctx && ctx->ctx_fl_using_dbreg == 1) return -1;
  9.3569 +
  9.3570 +	LOCK_PFS(flags);
  9.3571 +
  9.3572 +	/*
  9.3573 +	 * We cannot allow setting breakpoints when system wide monitoring
  9.3574 +	 * sessions are using the debug registers.
  9.3575 +	 */
  9.3576 +	if (pfm_sessions.pfs_sys_use_dbregs> 0)
  9.3577 +		ret = -1;
  9.3578 +	else
  9.3579 +		pfm_sessions.pfs_ptrace_use_dbregs++;
  9.3580 +
  9.3581 +	DPRINT(("ptrace_use_dbregs=%u  sys_use_dbregs=%u by [%d] ret = %d\n",
  9.3582 +		  pfm_sessions.pfs_ptrace_use_dbregs,
  9.3583 +		  pfm_sessions.pfs_sys_use_dbregs,
  9.3584 +		  task->pid, ret));
  9.3585 +
  9.3586 +	UNLOCK_PFS(flags);
  9.3587 +
  9.3588 +	return ret;
  9.3589 +}
  9.3590 +
  9.3591 +/*
  9.3592 + * This function is called for every task that exits with the
  9.3593 + * IA64_THREAD_DBG_VALID set. This indicates a task which was
  9.3594 + * able to use the debug registers for debugging purposes via
  9.3595 + * ptrace(). Therefore we know it was not using them for
  9.3596 + * perfmormance monitoring, so we only decrement the number
  9.3597 + * of "ptraced" debug register users to keep the count up to date
  9.3598 + */
  9.3599 +int
  9.3600 +pfm_release_debug_registers(struct task_struct *task)
  9.3601 +{
  9.3602 +	unsigned long flags;
  9.3603 +	int ret;
  9.3604 +
  9.3605 +	if (pmu_conf->use_rr_dbregs == 0) return 0;
  9.3606 +
  9.3607 +	LOCK_PFS(flags);
  9.3608 +	if (pfm_sessions.pfs_ptrace_use_dbregs == 0) {
  9.3609 +		printk(KERN_ERR "perfmon: invalid release for [%d] ptrace_use_dbregs=0\n", task->pid);
  9.3610 +		ret = -1;
  9.3611 +	}  else {
  9.3612 +		pfm_sessions.pfs_ptrace_use_dbregs--;
  9.3613 +		ret = 0;
  9.3614 +	}
  9.3615 +	UNLOCK_PFS(flags);
  9.3616 +
  9.3617 +	return ret;
  9.3618 +}
  9.3619 +
  9.3620 +static int
  9.3621 +pfm_restart(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.3622 +{
  9.3623 +	struct task_struct *task;
  9.3624 +	pfm_buffer_fmt_t *fmt;
  9.3625 +	pfm_ovfl_ctrl_t rst_ctrl;
  9.3626 +	int state, is_system;
  9.3627 +	int ret = 0;
  9.3628 +	XEN_NOT_SUPPORTED_YET;
  9.3629 +
  9.3630 +	state     = ctx->ctx_state;
  9.3631 +	fmt       = ctx->ctx_buf_fmt;
  9.3632 +	is_system = ctx->ctx_fl_system;
  9.3633 +	task      = PFM_CTX_TASK(ctx);
  9.3634 +
  9.3635 +	switch(state) {
  9.3636 +		case PFM_CTX_MASKED:
  9.3637 +			break;
  9.3638 +		case PFM_CTX_LOADED: 
  9.3639 +			if (CTX_HAS_SMPL(ctx) && fmt->fmt_restart_active) break;
  9.3640 +			/* fall through */
  9.3641 +		case PFM_CTX_UNLOADED:
  9.3642 +		case PFM_CTX_ZOMBIE:
  9.3643 +			DPRINT(("invalid state=%d\n", state));
  9.3644 +			return -EBUSY;
  9.3645 +		default:
  9.3646 +			DPRINT(("state=%d, cannot operate (no active_restart handler)\n", state));
  9.3647 +			return -EINVAL;
  9.3648 +	}
  9.3649 +
  9.3650 +	/*
  9.3651 + 	 * In system wide and when the context is loaded, access can only happen
  9.3652 + 	 * when the caller is running on the CPU being monitored by the session.
  9.3653 + 	 * It does not have to be the owner (ctx_task) of the context per se.
  9.3654 + 	 */
  9.3655 +	if (is_system && ctx->ctx_cpu != smp_processor_id()) {
  9.3656 +		DPRINT(("should be running on CPU%d\n", ctx->ctx_cpu));
  9.3657 +		return -EBUSY;
  9.3658 +	}
  9.3659 +
  9.3660 +	/* sanity check */
  9.3661 +	if (unlikely(task == NULL)) {
  9.3662 +		printk(KERN_ERR "perfmon: [%d] pfm_restart no task\n", current->pid);
  9.3663 +		return -EINVAL;
  9.3664 +	}
  9.3665 +
  9.3666 +	if (task == current || is_system) {
  9.3667 +
  9.3668 +		fmt = ctx->ctx_buf_fmt;
  9.3669 +
  9.3670 +		DPRINT(("restarting self %d ovfl=0x%lx\n",
  9.3671 +			task->pid,
  9.3672 +			ctx->ctx_ovfl_regs[0]));
  9.3673 +
  9.3674 +		if (CTX_HAS_SMPL(ctx)) {
  9.3675 +
  9.3676 +			prefetch(ctx->ctx_smpl_hdr);
  9.3677 +
  9.3678 +			rst_ctrl.bits.mask_monitoring = 0;
  9.3679 +			rst_ctrl.bits.reset_ovfl_pmds = 0;
  9.3680 +
  9.3681 +			if (state == PFM_CTX_LOADED)
  9.3682 +				ret = pfm_buf_fmt_restart_active(fmt, task, &rst_ctrl, ctx->ctx_smpl_hdr, regs);
  9.3683 +			else
  9.3684 +				ret = pfm_buf_fmt_restart(fmt, task, &rst_ctrl, ctx->ctx_smpl_hdr, regs);
  9.3685 +		} else {
  9.3686 +			rst_ctrl.bits.mask_monitoring = 0;
  9.3687 +			rst_ctrl.bits.reset_ovfl_pmds = 1;
  9.3688 +		}
  9.3689 +
  9.3690 +		if (ret == 0) {
  9.3691 +			if (rst_ctrl.bits.reset_ovfl_pmds)
  9.3692 +				pfm_reset_regs(ctx, ctx->ctx_ovfl_regs, PFM_PMD_LONG_RESET);
  9.3693 +
  9.3694 +			if (rst_ctrl.bits.mask_monitoring == 0) {
  9.3695 +				DPRINT(("resuming monitoring for [%d]\n", task->pid));
  9.3696 +
  9.3697 +				if (state == PFM_CTX_MASKED) pfm_restore_monitoring(task);
  9.3698 +			} else {
  9.3699 +				DPRINT(("keeping monitoring stopped for [%d]\n", task->pid));
  9.3700 +
  9.3701 +				// cannot use pfm_stop_monitoring(task, regs);
  9.3702 +			}
  9.3703 +		}
  9.3704 +		/*
  9.3705 +		 * clear overflowed PMD mask to remove any stale information
  9.3706 +		 */
  9.3707 +		ctx->ctx_ovfl_regs[0] = 0UL;
  9.3708 +
  9.3709 +		/*
  9.3710 +		 * back to LOADED state
  9.3711 +		 */
  9.3712 +		ctx->ctx_state = PFM_CTX_LOADED;
  9.3713 +
  9.3714 +		/*
  9.3715 +		 * XXX: not really useful for self monitoring
  9.3716 +		 */
  9.3717 +		ctx->ctx_fl_can_restart = 0;
  9.3718 +
  9.3719 +		return 0;
  9.3720 +	}
  9.3721 +
  9.3722 +	/* 
  9.3723 +	 * restart another task
  9.3724 +	 */
  9.3725 +
  9.3726 +	/*
  9.3727 +	 * When PFM_CTX_MASKED, we cannot issue a restart before the previous 
  9.3728 +	 * one is seen by the task.
  9.3729 +	 */
  9.3730 +	if (state == PFM_CTX_MASKED) {
  9.3731 +		if (ctx->ctx_fl_can_restart == 0) return -EINVAL;
  9.3732 +		/*
  9.3733 +		 * will prevent subsequent restart before this one is
  9.3734 +		 * seen by other task
  9.3735 +		 */
  9.3736 +		ctx->ctx_fl_can_restart = 0;
  9.3737 +	}
  9.3738 +
  9.3739 +	/*
  9.3740 +	 * if blocking, then post the semaphore is PFM_CTX_MASKED, i.e.
  9.3741 +	 * the task is blocked or on its way to block. That's the normal
  9.3742 +	 * restart path. If the monitoring is not masked, then the task
  9.3743 +	 * can be actively monitoring and we cannot directly intervene.
  9.3744 +	 * Therefore we use the trap mechanism to catch the task and
  9.3745 +	 * force it to reset the buffer/reset PMDs.
  9.3746 +	 *
  9.3747 +	 * if non-blocking, then we ensure that the task will go into
  9.3748 +	 * pfm_handle_work() before returning to user mode.
  9.3749 +	 *
  9.3750 +	 * We cannot explicitely reset another task, it MUST always
  9.3751 +	 * be done by the task itself. This works for system wide because
  9.3752 +	 * the tool that is controlling the session is logically doing 
  9.3753 +	 * "self-monitoring".
  9.3754 +	 */
  9.3755 +	if (CTX_OVFL_NOBLOCK(ctx) == 0 && state == PFM_CTX_MASKED) {
  9.3756 +		DPRINT(("unblocking [%d] \n", task->pid));
  9.3757 +		complete(&ctx->ctx_restart_done);
  9.3758 +	} else {
  9.3759 +		DPRINT(("[%d] armed exit trap\n", task->pid));
  9.3760 +
  9.3761 +		ctx->ctx_fl_trap_reason = PFM_TRAP_REASON_RESET;
  9.3762 +
  9.3763 +		PFM_SET_WORK_PENDING(task, 1);
  9.3764 +
  9.3765 +		pfm_set_task_notify(task);
  9.3766 +
  9.3767 +		/*
  9.3768 +		 * XXX: send reschedule if task runs on another CPU
  9.3769 +		 */
  9.3770 +	}
  9.3771 +	return 0;
  9.3772 +}
  9.3773 +
  9.3774 +static int
  9.3775 +pfm_debug(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.3776 +{
  9.3777 +	unsigned int m = *(unsigned int *)arg;
  9.3778 +	XEN_NOT_SUPPORTED_YET;
  9.3779 +
  9.3780 +	pfm_sysctl.debug = m == 0 ? 0 : 1;
  9.3781 +
  9.3782 +	printk(KERN_INFO "perfmon debugging %s (timing reset)\n", pfm_sysctl.debug ? "on" : "off");
  9.3783 +
  9.3784 +	if (m == 0) {
  9.3785 +		memset(pfm_stats, 0, sizeof(pfm_stats));
  9.3786 +		for(m=0; m < NR_CPUS; m++) pfm_stats[m].pfm_ovfl_intr_cycles_min = ~0UL;
  9.3787 +	}
  9.3788 +	return 0;
  9.3789 +}
  9.3790 +
  9.3791 +/*
  9.3792 + * arg can be NULL and count can be zero for this function
  9.3793 + */
  9.3794 +static int
  9.3795 +pfm_write_ibr_dbr(int mode, pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.3796 +{
  9.3797 +	struct thread_struct *thread = NULL;
  9.3798 +	struct task_struct *task;
  9.3799 +	pfarg_dbreg_t *req = (pfarg_dbreg_t *)arg;
  9.3800 +	unsigned long flags;
  9.3801 +	dbreg_t dbreg;
  9.3802 +	unsigned int rnum;
  9.3803 +	int first_time;
  9.3804 +	int ret = 0, state;
  9.3805 +	int i, can_access_pmu = 0;
  9.3806 +	int is_system, is_loaded;
  9.3807 +
  9.3808 +	if (pmu_conf->use_rr_dbregs == 0) return -EINVAL;
  9.3809 +
  9.3810 +	state     = ctx->ctx_state;
  9.3811 +	is_loaded = state == PFM_CTX_LOADED ? 1 : 0;
  9.3812 +	is_system = ctx->ctx_fl_system;
  9.3813 +	task      = ctx->ctx_task;
  9.3814 +
  9.3815 +	if (state == PFM_CTX_ZOMBIE) return -EINVAL;
  9.3816 +
  9.3817 +	/*
  9.3818 +	 * on both UP and SMP, we can only write to the PMC when the task is
  9.3819 +	 * the owner of the local PMU.
  9.3820 +	 */
  9.3821 +	if (is_loaded) {
  9.3822 +		thread = &task->thread;
  9.3823 +		/*
  9.3824 +		 * In system wide and when the context is loaded, access can only happen
  9.3825 +		 * when the caller is running on the CPU being monitored by the session.
  9.3826 +		 * It does not have to be the owner (ctx_task) of the context per se.
  9.3827 +		 */
  9.3828 +		if (unlikely(is_system && ctx->ctx_cpu != smp_processor_id())) {
  9.3829 +			DPRINT(("should be running on CPU%d\n", ctx->ctx_cpu));
  9.3830 +			return -EBUSY;
  9.3831 +		}
  9.3832 +		can_access_pmu = GET_PMU_OWNER() == task || is_system ? 1 : 0;
  9.3833 +	}
  9.3834 +
  9.3835 +	/*
  9.3836 +	 * we do not need to check for ipsr.db because we do clear ibr.x, dbr.r, and dbr.w
  9.3837 +	 * ensuring that no real breakpoint can be installed via this call.
  9.3838 +	 *
  9.3839 +	 * IMPORTANT: regs can be NULL in this function
  9.3840 +	 */
  9.3841 +
  9.3842 +	first_time = ctx->ctx_fl_using_dbreg == 0;
  9.3843 +
  9.3844 +	/*
  9.3845 +	 * don't bother if we are loaded and task is being debugged
  9.3846 +	 */
  9.3847 +	if (is_loaded && (thread->flags & IA64_THREAD_DBG_VALID) != 0) {
  9.3848 +		DPRINT(("debug registers already in use for [%d]\n", task->pid));
  9.3849 +		return -EBUSY;
  9.3850 +	}
  9.3851 +
  9.3852 +	/*
  9.3853 +	 * check for debug registers in system wide mode
  9.3854 +	 *
  9.3855 +	 * If though a check is done in pfm_context_load(),
  9.3856 +	 * we must repeat it here, in case the registers are
  9.3857 +	 * written after the context is loaded
  9.3858 +	 */
  9.3859 +	if (is_loaded) {
  9.3860 +		LOCK_PFS(flags);
  9.3861 +
  9.3862 +		if (first_time && is_system) {
  9.3863 +			if (pfm_sessions.pfs_ptrace_use_dbregs)
  9.3864 +				ret = -EBUSY;
  9.3865 +			else
  9.3866 +				pfm_sessions.pfs_sys_use_dbregs++;
  9.3867 +		}
  9.3868 +		UNLOCK_PFS(flags);
  9.3869 +	}
  9.3870 +
  9.3871 +	if (ret != 0) return ret;
  9.3872 +
  9.3873 +	/*
  9.3874 +	 * mark ourself as user of the debug registers for
  9.3875 +	 * perfmon purposes.
  9.3876 +	 */
  9.3877 +	ctx->ctx_fl_using_dbreg = 1;
  9.3878 +
  9.3879 +	/*
  9.3880 + 	 * clear hardware registers to make sure we don't
  9.3881 + 	 * pick up stale state.
  9.3882 +	 *
  9.3883 +	 * for a system wide session, we do not use
  9.3884 +	 * thread.dbr, thread.ibr because this process
  9.3885 +	 * never leaves the current CPU and the state
  9.3886 +	 * is shared by all processes running on it
  9.3887 + 	 */
  9.3888 +	if (first_time && can_access_pmu) {
  9.3889 +		DPRINT(("[%d] clearing ibrs, dbrs\n", task->pid));
  9.3890 +		for (i=0; i < pmu_conf->num_ibrs; i++) {
  9.3891 +			ia64_set_ibr(i, 0UL);
  9.3892 +			ia64_dv_serialize_instruction();
  9.3893 +		}
  9.3894 +		ia64_srlz_i();
  9.3895 +		for (i=0; i < pmu_conf->num_dbrs; i++) {
  9.3896 +			ia64_set_dbr(i, 0UL);
  9.3897 +			ia64_dv_serialize_data();
  9.3898 +		}
  9.3899 +		ia64_srlz_d();
  9.3900 +	}
  9.3901 +
  9.3902 +	/*
  9.3903 +	 * Now install the values into the registers
  9.3904 +	 */
  9.3905 +	for (i = 0; i < count; i++, req++) {
  9.3906 +
  9.3907 +		rnum      = req->dbreg_num;
  9.3908 +		dbreg.val = req->dbreg_value;
  9.3909 +
  9.3910 +		ret = -EINVAL;
  9.3911 +
  9.3912 +		if ((mode == PFM_CODE_RR && rnum >= PFM_NUM_IBRS) || ((mode == PFM_DATA_RR) && rnum >= PFM_NUM_DBRS)) {
  9.3913 +			DPRINT(("invalid register %u val=0x%lx mode=%d i=%d count=%d\n",
  9.3914 +				  rnum, dbreg.val, mode, i, count));
  9.3915 +
  9.3916 +			goto abort_mission;
  9.3917 +		}
  9.3918 +
  9.3919 +		/*
  9.3920 +		 * make sure we do not install enabled breakpoint
  9.3921 +		 */
  9.3922 +		if (rnum & 0x1) {
  9.3923 +			if (mode == PFM_CODE_RR)
  9.3924 +				dbreg.ibr.ibr_x = 0;
  9.3925 +			else
  9.3926 +				dbreg.dbr.dbr_r = dbreg.dbr.dbr_w = 0;
  9.3927 +		}
  9.3928 +
  9.3929 +		PFM_REG_RETFLAG_SET(req->dbreg_flags, 0);
  9.3930 +
  9.3931 +		/*
  9.3932 +		 * Debug registers, just like PMC, can only be modified
  9.3933 +		 * by a kernel call. Moreover, perfmon() access to those
  9.3934 +		 * registers are centralized in this routine. The hardware
  9.3935 +		 * does not modify the value of these registers, therefore,
  9.3936 +		 * if we save them as they are written, we can avoid having
  9.3937 +		 * to save them on context switch out. This is made possible
  9.3938 +		 * by the fact that when perfmon uses debug registers, ptrace()
  9.3939 +		 * won't be able to modify them concurrently.
  9.3940 +		 */
  9.3941 +		if (mode == PFM_CODE_RR) {
  9.3942 +			CTX_USED_IBR(ctx, rnum);
  9.3943 +
  9.3944 +			if (can_access_pmu) {
  9.3945 +				ia64_set_ibr(rnum, dbreg.val);
  9.3946 +				ia64_dv_serialize_instruction();
  9.3947 +			}
  9.3948 +
  9.3949 +			ctx->ctx_ibrs[rnum] = dbreg.val;
  9.3950 +
  9.3951 +			DPRINT(("write ibr%u=0x%lx used_ibrs=0x%x ld=%d apmu=%d\n",
  9.3952 +				rnum, dbreg.val, ctx->ctx_used_ibrs[0], is_loaded, can_access_pmu));
  9.3953 +		} else {
  9.3954 +			CTX_USED_DBR(ctx, rnum);
  9.3955 +
  9.3956 +			if (can_access_pmu) {
  9.3957 +				ia64_set_dbr(rnum, dbreg.val);
  9.3958 +				ia64_dv_serialize_data();
  9.3959 +			}
  9.3960 +			ctx->ctx_dbrs[rnum] = dbreg.val;
  9.3961 +
  9.3962 +			DPRINT(("write dbr%u=0x%lx used_dbrs=0x%x ld=%d apmu=%d\n",
  9.3963 +				rnum, dbreg.val, ctx->ctx_used_dbrs[0], is_loaded, can_access_pmu));
  9.3964 +		}
  9.3965 +	}
  9.3966 +
  9.3967 +	return 0;
  9.3968 +
  9.3969 +abort_mission:
  9.3970 +	/*
  9.3971 +	 * in case it was our first attempt, we undo the global modifications
  9.3972 +	 */
  9.3973 +	if (first_time) {
  9.3974 +		LOCK_PFS(flags);
  9.3975 +		if (ctx->ctx_fl_system) {
  9.3976 +			pfm_sessions.pfs_sys_use_dbregs--;
  9.3977 +		}
  9.3978 +		UNLOCK_PFS(flags);
  9.3979 +		ctx->ctx_fl_using_dbreg = 0;
  9.3980 +	}
  9.3981 +	/*
  9.3982 +	 * install error return flag
  9.3983 +	 */
  9.3984 +	PFM_REG_RETFLAG_SET(req->dbreg_flags, PFM_REG_RETFL_EINVAL);
  9.3985 +
  9.3986 +	return ret;
  9.3987 +}
  9.3988 +
  9.3989 +static int
  9.3990 +pfm_write_ibrs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.3991 +{
  9.3992 +	return pfm_write_ibr_dbr(PFM_CODE_RR, ctx, arg, count, regs);
  9.3993 +}
  9.3994 +
  9.3995 +static int
  9.3996 +pfm_write_dbrs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.3997 +{
  9.3998 +	return pfm_write_ibr_dbr(PFM_DATA_RR, ctx, arg, count, regs);
  9.3999 +}
  9.4000 +
  9.4001 +int
  9.4002 +pfm_mod_write_ibrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs)
  9.4003 +{
  9.4004 +	pfm_context_t *ctx;
  9.4005 +
  9.4006 +	if (req == NULL) return -EINVAL;
  9.4007 +
  9.4008 + 	ctx = GET_PMU_CTX();
  9.4009 +
  9.4010 +	if (ctx == NULL) return -EINVAL;
  9.4011 +
  9.4012 +	/*
  9.4013 +	 * for now limit to current task, which is enough when calling
  9.4014 +	 * from overflow handler
  9.4015 +	 */
  9.4016 +	if (task != current && ctx->ctx_fl_system == 0) return -EBUSY;
  9.4017 +
  9.4018 +	return pfm_write_ibrs(ctx, req, nreq, regs);
  9.4019 +}
  9.4020 +EXPORT_SYMBOL(pfm_mod_write_ibrs);
  9.4021 +
  9.4022 +int
  9.4023 +pfm_mod_write_dbrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs)
  9.4024 +{
  9.4025 +	pfm_context_t *ctx;
  9.4026 +
  9.4027 +	if (req == NULL) return -EINVAL;
  9.4028 +
  9.4029 + 	ctx = GET_PMU_CTX();
  9.4030 +
  9.4031 +	if (ctx == NULL) return -EINVAL;
  9.4032 +
  9.4033 +	/*
  9.4034 +	 * for now limit to current task, which is enough when calling
  9.4035 +	 * from overflow handler
  9.4036 +	 */
  9.4037 +	if (task != current && ctx->ctx_fl_system == 0) return -EBUSY;
  9.4038 +
  9.4039 +	return pfm_write_dbrs(ctx, req, nreq, regs);
  9.4040 +}
  9.4041 +EXPORT_SYMBOL(pfm_mod_write_dbrs);
  9.4042 +
  9.4043 +
  9.4044 +static int
  9.4045 +pfm_get_features(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.4046 +{
  9.4047 +	pfarg_features_t *req = (pfarg_features_t *)arg;
  9.4048 +
  9.4049 +	if (is_running_on_xen())
  9.4050 +		return HYPERVISOR_perfmon_op(PFM_GET_FEATURES, &arg, 0);
  9.4051 +	req->ft_version = PFM_VERSION;
  9.4052 +	return 0;
  9.4053 +}
  9.4054 +
  9.4055 +static int
  9.4056 +pfm_stop(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.4057 +{
  9.4058 +	struct pt_regs *tregs;
  9.4059 +	struct task_struct *task = PFM_CTX_TASK(ctx);
  9.4060 +	int state, is_system;
  9.4061 +
  9.4062 +  	if (is_running_on_xen()) {
  9.4063 +		if (is_xenoprof_primary())
  9.4064 +			return HYPERVISOR_perfmon_op(PFM_STOP, NULL, 0);
  9.4065 +		return 0;
  9.4066 +  	}
  9.4067 +
  9.4068 +	state     = ctx->ctx_state;
  9.4069 +	is_system = ctx->ctx_fl_system;
  9.4070 +
  9.4071 +	/*
  9.4072 +	 * context must be attached to issue the stop command (includes LOADED,MASKED,ZOMBIE)
  9.4073 +	 */
  9.4074 +	if (state == PFM_CTX_UNLOADED) return -EINVAL;
  9.4075 +
  9.4076 +	/*
  9.4077 + 	 * In system wide and when the context is loaded, access can only happen
  9.4078 + 	 * when the caller is running on the CPU being monitored by the session.
  9.4079 + 	 * It does not have to be the owner (ctx_task) of the context per se.
  9.4080 + 	 */
  9.4081 +	if (is_system && ctx->ctx_cpu != smp_processor_id()) {
  9.4082 +		DPRINT(("should be running on CPU%d\n", ctx->ctx_cpu));
  9.4083 +		return -EBUSY;
  9.4084 +	}
  9.4085 +	DPRINT(("task [%d] ctx_state=%d is_system=%d\n",
  9.4086 +		PFM_CTX_TASK(ctx)->pid,
  9.4087 +		state,
  9.4088 +		is_system));
  9.4089 +	/*
  9.4090 +	 * in system mode, we need to update the PMU directly
  9.4091 +	 * and the user level state of the caller, which may not
  9.4092 +	 * necessarily be the creator of the context.
  9.4093 +	 */
  9.4094 +	if (is_system) {
  9.4095 +		/*
  9.4096 +		 * Update local PMU first
  9.4097 +		 *
  9.4098 +		 * disable dcr pp
  9.4099 +		 */
  9.4100 +		ia64_setreg(_IA64_REG_CR_DCR, ia64_getreg(_IA64_REG_CR_DCR) & ~IA64_DCR_PP);
  9.4101 +		ia64_srlz_i();
  9.4102 +
  9.4103 +		/*
  9.4104 +		 * update local cpuinfo
  9.4105 +		 */
  9.4106 +		PFM_CPUINFO_CLEAR(PFM_CPUINFO_DCR_PP);
  9.4107 +
  9.4108 +		/*
  9.4109 +		 * stop monitoring, does srlz.i
  9.4110 +		 */
  9.4111 +		pfm_clear_psr_pp();
  9.4112 +
  9.4113 +		/*
  9.4114 +		 * stop monitoring in the caller
  9.4115 +		 */
  9.4116 +		ia64_psr(regs)->pp = 0;
  9.4117 +
  9.4118 +		return 0;
  9.4119 +	}
  9.4120 +	/*
  9.4121 +	 * per-task mode
  9.4122 +	 */
  9.4123 +
  9.4124 +	if (task == current) {
  9.4125 +		/* stop monitoring  at kernel level */
  9.4126 +		pfm_clear_psr_up();
  9.4127 +
  9.4128 +		/*
  9.4129 +	 	 * stop monitoring at the user level
  9.4130 +	 	 */
  9.4131 +		ia64_psr(regs)->up = 0;
  9.4132 +	} else {
  9.4133 +		tregs = task_pt_regs(task);
  9.4134 +
  9.4135 +		/*
  9.4136 +	 	 * stop monitoring at the user level
  9.4137 +	 	 */
  9.4138 +		ia64_psr(tregs)->up = 0;
  9.4139 +
  9.4140 +		/*
  9.4141 +		 * monitoring disabled in kernel at next reschedule
  9.4142 +		 */
  9.4143 +		ctx->ctx_saved_psr_up = 0;
  9.4144 +		DPRINT(("task=[%d]\n", task->pid));
  9.4145 +	}
  9.4146 +	return 0;
  9.4147 +}
  9.4148 +
  9.4149 +
  9.4150 +static int
  9.4151 +pfm_start(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.4152 +{
  9.4153 +	struct pt_regs *tregs;
  9.4154 +	int state, is_system;
  9.4155 +
  9.4156 +  	if (is_running_on_xen()) {
  9.4157 +		if (is_xenoprof_primary())
  9.4158 +			return HYPERVISOR_perfmon_op(PFM_START, NULL, 0);
  9.4159 +		return 0;
  9.4160 +  	}
  9.4161 +	state     = ctx->ctx_state;
  9.4162 +	is_system = ctx->ctx_fl_system;
  9.4163 +
  9.4164 +	if (state != PFM_CTX_LOADED) return -EINVAL;
  9.4165 +
  9.4166 +	/*
  9.4167 + 	 * In system wide and when the context is loaded, access can only happen
  9.4168 + 	 * when the caller is running on the CPU being monitored by the session.
  9.4169 + 	 * It does not have to be the owner (ctx_task) of the context per se.
  9.4170 + 	 */
  9.4171 +	if (is_system && ctx->ctx_cpu != smp_processor_id()) {
  9.4172 +		DPRINT(("should be running on CPU%d\n", ctx->ctx_cpu));
  9.4173 +		return -EBUSY;
  9.4174 +	}
  9.4175 +
  9.4176 +	/*
  9.4177 +	 * in system mode, we need to update the PMU directly
  9.4178 +	 * and the user level state of the caller, which may not
  9.4179 +	 * necessarily be the creator of the context.
  9.4180 +	 */
  9.4181 +	if (is_system) {
  9.4182 +
  9.4183 +		/*
  9.4184 +		 * set user level psr.pp for the caller
  9.4185 +		 */
  9.4186 +		ia64_psr(regs)->pp = 1;
  9.4187 +
  9.4188 +		/*
  9.4189 +		 * now update the local PMU and cpuinfo
  9.4190 +		 */
  9.4191 +		PFM_CPUINFO_SET(PFM_CPUINFO_DCR_PP);
  9.4192 +
  9.4193 +		/*
  9.4194 +		 * start monitoring at kernel level
  9.4195 +		 */
  9.4196 +		pfm_set_psr_pp();
  9.4197 +
  9.4198 +		/* enable dcr pp */
  9.4199 +		ia64_setreg(_IA64_REG_CR_DCR, ia64_getreg(_IA64_REG_CR_DCR) | IA64_DCR_PP);
  9.4200 +		ia64_srlz_i();
  9.4201 +
  9.4202 +		return 0;
  9.4203 +	}
  9.4204 +
  9.4205 +	/*
  9.4206 +	 * per-process mode
  9.4207 +	 */
  9.4208 +
  9.4209 +	if (ctx->ctx_task == current) {
  9.4210 +
  9.4211 +		/* start monitoring at kernel level */
  9.4212 +		pfm_set_psr_up();
  9.4213 +
  9.4214 +		/*
  9.4215 +		 * activate monitoring at user level
  9.4216 +		 */
  9.4217 +		ia64_psr(regs)->up = 1;
  9.4218 +
  9.4219 +	} else {
  9.4220 +		tregs = task_pt_regs(ctx->ctx_task);
  9.4221 +
  9.4222 +		/*
  9.4223 +		 * start monitoring at the kernel level the next
  9.4224 +		 * time the task is scheduled
  9.4225 +		 */
  9.4226 +		ctx->ctx_saved_psr_up = IA64_PSR_UP;
  9.4227 +
  9.4228 +		/*
  9.4229 +		 * activate monitoring at user level
  9.4230 +		 */
  9.4231 +		ia64_psr(tregs)->up = 1;
  9.4232 +	}
  9.4233 +	return 0;
  9.4234 +}
  9.4235 +
  9.4236 +static int
  9.4237 +pfm_get_pmc_reset(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.4238 +{
  9.4239 +	pfarg_reg_t *req = (pfarg_reg_t *)arg;
  9.4240 +	unsigned int cnum;
  9.4241 +	int i;
  9.4242 +	int ret = -EINVAL;
  9.4243 +	XEN_NOT_SUPPORTED_YET;
  9.4244 +
  9.4245 +	for (i = 0; i < count; i++, req++) {
  9.4246 +
  9.4247 +		cnum = req->reg_num;
  9.4248 +
  9.4249 +		if (!PMC_IS_IMPL(cnum)) goto abort_mission;
  9.4250 +
  9.4251 +		req->reg_value = PMC_DFL_VAL(cnum);
  9.4252 +
  9.4253 +		PFM_REG_RETFLAG_SET(req->reg_flags, 0);
  9.4254 +
  9.4255 +		DPRINT(("pmc_reset_val pmc[%u]=0x%lx\n", cnum, req->reg_value));
  9.4256 +	}
  9.4257 +	return 0;
  9.4258 +
  9.4259 +abort_mission:
  9.4260 +	PFM_REG_RETFLAG_SET(req->reg_flags, PFM_REG_RETFL_EINVAL);
  9.4261 +	return ret;
  9.4262 +}
  9.4263 +
  9.4264 +static int
  9.4265 +pfm_check_task_exist(pfm_context_t *ctx)
  9.4266 +{
  9.4267 +	struct task_struct *g, *t;
  9.4268 +	int ret = -ESRCH;
  9.4269 +
  9.4270 +	read_lock(&tasklist_lock);
  9.4271 +
  9.4272 +	do_each_thread (g, t) {
  9.4273 +		if (t->thread.pfm_context == ctx) {
  9.4274 +			ret = 0;
  9.4275 +			break;
  9.4276 +		}
  9.4277 +	} while_each_thread (g, t);
  9.4278 +
  9.4279 +	read_unlock(&tasklist_lock);
  9.4280 +
  9.4281 +	DPRINT(("pfm_check_task_exist: ret=%d ctx=%p\n", ret, ctx));
  9.4282 +
  9.4283 +	return ret;
  9.4284 +}
  9.4285 +
  9.4286 +static int
  9.4287 +pfm_context_load(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.4288 +{
  9.4289 +	struct task_struct *task;
  9.4290 +	struct thread_struct *thread;
  9.4291 +	struct pfm_context_t *old;
  9.4292 +	unsigned long flags;
  9.4293 +#ifndef CONFIG_SMP
  9.4294 +	struct task_struct *owner_task = NULL;
  9.4295 +#endif
  9.4296 +	pfarg_load_t *req = (pfarg_load_t *)arg;
  9.4297 +	unsigned long *pmcs_source, *pmds_source;
  9.4298 +	int the_cpu;
  9.4299 +	int ret = 0;
  9.4300 +	int state, is_system, set_dbregs = 0;
  9.4301 +
  9.4302 +  	if (is_running_on_xen()) {
  9.4303 +		if (is_xenoprof_primary())
  9.4304 +			return HYPERVISOR_perfmon_op(PFM_LOAD_CONTEXT, arg, 0);
  9.4305 +		return 0;
  9.4306 +  	}
  9.4307 +	state     = ctx->ctx_state;
  9.4308 +	is_system = ctx->ctx_fl_system;
  9.4309 +	/*
  9.4310 +	 * can only load from unloaded or terminated state
  9.4311 +	 */
  9.4312 +	if (state != PFM_CTX_UNLOADED) {
  9.4313 +		DPRINT(("cannot load to [%d], invalid ctx_state=%d\n",
  9.4314 +			req->load_pid,
  9.4315 +			ctx->ctx_state));
  9.4316 +		return -EBUSY;
  9.4317 +	}
  9.4318 +
  9.4319 +	DPRINT(("load_pid [%d] using_dbreg=%d\n", req->load_pid, ctx->ctx_fl_using_dbreg));
  9.4320 +
  9.4321 +	if (CTX_OVFL_NOBLOCK(ctx) == 0 && req->load_pid == current->pid) {
  9.4322 +		DPRINT(("cannot use blocking mode on self\n"));
  9.4323 +		return -EINVAL;
  9.4324 +	}
  9.4325 +
  9.4326 +	ret = pfm_get_task(ctx, req->load_pid, &task);
  9.4327 +	if (ret) {
  9.4328 +		DPRINT(("load_pid [%d] get_task=%d\n", req->load_pid, ret));
  9.4329 +		return ret;
  9.4330 +	}
  9.4331 +
  9.4332 +	ret = -EINVAL;
  9.4333 +
  9.4334 +	/*
  9.4335 +	 * system wide is self monitoring only
  9.4336 +	 */
  9.4337 +	if (is_system && task != current) {
  9.4338 +		DPRINT(("system wide is self monitoring only load_pid=%d\n",
  9.4339 +			req->load_pid));
  9.4340 +		goto error;
  9.4341 +	}
  9.4342 +
  9.4343 +	thread = &task->thread;
  9.4344 +
  9.4345 +	ret = 0;
  9.4346 +	/*
  9.4347 +	 * cannot load a context which is using range restrictions,
  9.4348 +	 * into a task that is being debugged.
  9.4349 +	 */
  9.4350 +	if (ctx->ctx_fl_using_dbreg) {
  9.4351 +		if (thread->flags & IA64_THREAD_DBG_VALID) {
  9.4352 +			ret = -EBUSY;
  9.4353 +			DPRINT(("load_pid [%d] task is debugged, cannot load range restrictions\n", req->load_pid));
  9.4354 +			goto error;
  9.4355 +		}
  9.4356 +		LOCK_PFS(flags);
  9.4357 +
  9.4358 +		if (is_system) {
  9.4359 +			if (pfm_sessions.pfs_ptrace_use_dbregs) {
  9.4360 +				DPRINT(("cannot load [%d] dbregs in use\n", task->pid));
  9.4361 +				ret = -EBUSY;
  9.4362 +			} else {
  9.4363 +				pfm_sessions.pfs_sys_use_dbregs++;
  9.4364 +				DPRINT(("load [%d] increased sys_use_dbreg=%u\n", task->pid, pfm_sessions.pfs_sys_use_dbregs));
  9.4365 +				set_dbregs = 1;
  9.4366 +			}
  9.4367 +		}
  9.4368 +
  9.4369 +		UNLOCK_PFS(flags);
  9.4370 +
  9.4371 +		if (ret) goto error;
  9.4372 +	}
  9.4373 +
  9.4374 +	/*
  9.4375 +	 * SMP system-wide monitoring implies self-monitoring.
  9.4376 +	 *
  9.4377 +	 * The programming model expects the task to
  9.4378 +	 * be pinned on a CPU throughout the session.
  9.4379 +	 * Here we take note of the current CPU at the
  9.4380 +	 * time the context is loaded. No call from
  9.4381 +	 * another CPU will be allowed.
  9.4382 +	 *
  9.4383 +	 * The pinning via shed_setaffinity()
  9.4384 +	 * must be done by the calling task prior
  9.4385 +	 * to this call.
  9.4386 +	 *
  9.4387 +	 * systemwide: keep track of CPU this session is supposed to run on
  9.4388 +	 */
  9.4389 +	the_cpu = ctx->ctx_cpu = smp_processor_id();
  9.4390 +
  9.4391 +	ret = -EBUSY;
  9.4392 +	/*
  9.4393 +	 * now reserve the session
  9.4394 +	 */
  9.4395 +	ret = pfm_reserve_session(current, is_system, the_cpu);
  9.4396 +	if (ret) goto error;
  9.4397 +
  9.4398 +	/*
  9.4399 +	 * task is necessarily stopped at this point.
  9.4400 +	 *
  9.4401 +	 * If the previous context was zombie, then it got removed in
  9.4402 +	 * pfm_save_regs(). Therefore we should not see it here.
  9.4403 +	 * If we see a context, then this is an active context
  9.4404 +	 *
  9.4405 +	 * XXX: needs to be atomic
  9.4406 +	 */
  9.4407 +	DPRINT(("before cmpxchg() old_ctx=%p new_ctx=%p\n",
  9.4408 +		thread->pfm_context, ctx));
  9.4409 +
  9.4410 +	ret = -EBUSY;
  9.4411 +	old = ia64_cmpxchg(acq, &thread->pfm_context, NULL, ctx, sizeof(pfm_context_t *));
  9.4412 +	if (old != NULL) {
  9.4413 +		DPRINT(("load_pid [%d] already has a context\n", req->load_pid));
  9.4414 +		goto error_unres;
  9.4415 +	}
  9.4416 +
  9.4417 +	pfm_reset_msgq(ctx);
  9.4418 +
  9.4419 +	ctx->ctx_state = PFM_CTX_LOADED;
  9.4420 +
  9.4421 +	/*
  9.4422 +	 * link context to task
  9.4423 +	 */
  9.4424 +	ctx->ctx_task = task;
  9.4425 +
  9.4426 +	if (is_system) {
  9.4427 +		/*
  9.4428 +		 * we load as stopped
  9.4429 +		 */
  9.4430 +		PFM_CPUINFO_SET(PFM_CPUINFO_SYST_WIDE);
  9.4431 +		PFM_CPUINFO_CLEAR(PFM_CPUINFO_DCR_PP);
  9.4432 +
  9.4433 +		if (ctx->ctx_fl_excl_idle) PFM_CPUINFO_SET(PFM_CPUINFO_EXCL_IDLE);
  9.4434 +	} else {
  9.4435 +		thread->flags |= IA64_THREAD_PM_VALID;
  9.4436 +	}
  9.4437 +
  9.4438 +	/*
  9.4439 +	 * propagate into thread-state
  9.4440 +	 */
  9.4441 +	pfm_copy_pmds(task, ctx);
  9.4442 +	pfm_copy_pmcs(task, ctx);
  9.4443 +
  9.4444 +	pmcs_source = thread->pmcs;
  9.4445 +	pmds_source = thread->pmds;
  9.4446 +
  9.4447 +	/*
  9.4448 +	 * always the case for system-wide
  9.4449 +	 */
  9.4450 +	if (task == current) {
  9.4451 +
  9.4452 +		if (is_system == 0) {
  9.4453 +
  9.4454 +			/* allow user level control */
  9.4455 +			ia64_psr(regs)->sp = 0;
  9.4456 +			DPRINT(("clearing psr.sp for [%d]\n", task->pid));
  9.4457 +
  9.4458 +			SET_LAST_CPU(ctx, smp_processor_id());
  9.4459 +			INC_ACTIVATION();
  9.4460 +			SET_ACTIVATION(ctx);
  9.4461 +#ifndef CONFIG_SMP
  9.4462 +			/*
  9.4463 +			 * push the other task out, if any
  9.4464 +			 */
  9.4465 +			owner_task = GET_PMU_OWNER();
  9.4466 +			if (owner_task) pfm_lazy_save_regs(owner_task);
  9.4467 +#endif
  9.4468 +		}
  9.4469 +		/*
  9.4470 +		 * load all PMD from ctx to PMU (as opposed to thread state)
  9.4471 +		 * restore all PMC from ctx to PMU
  9.4472 +		 */
  9.4473 +		pfm_restore_pmds(pmds_source, ctx->ctx_all_pmds[0]);
  9.4474 +		pfm_restore_pmcs(pmcs_source, ctx->ctx_all_pmcs[0]);
  9.4475 +
  9.4476 +		ctx->ctx_reload_pmcs[0] = 0UL;
  9.4477 +		ctx->ctx_reload_pmds[0] = 0UL;
  9.4478 +
  9.4479 +		/*
  9.4480 +		 * guaranteed safe by earlier check against DBG_VALID
  9.4481 +		 */
  9.4482 +		if (ctx->ctx_fl_using_dbreg) {
  9.4483 +			pfm_restore_ibrs(ctx->ctx_ibrs, pmu_conf->num_ibrs);
  9.4484 +			pfm_restore_dbrs(ctx->ctx_dbrs, pmu_conf->num_dbrs);
  9.4485 +		}
  9.4486 +		/*
  9.4487 +		 * set new ownership
  9.4488 +		 */
  9.4489 +		SET_PMU_OWNER(task, ctx);
  9.4490 +
  9.4491 +		DPRINT(("context loaded on PMU for [%d]\n", task->pid));
  9.4492 +	} else {
  9.4493 +		/*
  9.4494 +		 * when not current, task MUST be stopped, so this is safe
  9.4495 +		 */
  9.4496 +		regs = task_pt_regs(task);
  9.4497 +
  9.4498 +		/* force a full reload */
  9.4499 +		ctx->ctx_last_activation = PFM_INVALID_ACTIVATION;
  9.4500 +		SET_LAST_CPU(ctx, -1);
  9.4501 +
  9.4502 +		/* initial saved psr (stopped) */
  9.4503 +		ctx->ctx_saved_psr_up = 0UL;
  9.4504 +		ia64_psr(regs)->up = ia64_psr(regs)->pp = 0;
  9.4505 +	}
  9.4506 +
  9.4507 +	ret = 0;
  9.4508 +
  9.4509 +error_unres:
  9.4510 +	if (ret) pfm_unreserve_session(ctx, ctx->ctx_fl_system, the_cpu);
  9.4511 +error:
  9.4512 +	/*
  9.4513 +	 * we must undo the dbregs setting (for system-wide)
  9.4514 +	 */
  9.4515 +	if (ret && set_dbregs) {
  9.4516 +		LOCK_PFS(flags);
  9.4517 +		pfm_sessions.pfs_sys_use_dbregs--;
  9.4518 +		UNLOCK_PFS(flags);
  9.4519 +	}
  9.4520 +	/*
  9.4521 +	 * release task, there is now a link with the context
  9.4522 +	 */
  9.4523 +	if (is_system == 0 && task != current) {
  9.4524 +		pfm_put_task(task);
  9.4525 +
  9.4526 +		if (ret == 0) {
  9.4527 +			ret = pfm_check_task_exist(ctx);
  9.4528 +			if (ret) {
  9.4529 +				ctx->ctx_state = PFM_CTX_UNLOADED;
  9.4530 +				ctx->ctx_task  = NULL;
  9.4531 +			}
  9.4532 +		}
  9.4533 +	}
  9.4534 +	return ret;
  9.4535 +}
  9.4536 +
  9.4537 +/*
  9.4538 + * in this function, we do not need to increase the use count
  9.4539 + * for the task via get_task_struct(), because we hold the
  9.4540 + * context lock. If the task were to disappear while having
  9.4541 + * a context attached, it would go through pfm_exit_thread()
  9.4542 + * which also grabs the context lock  and would therefore be blocked
  9.4543 + * until we are here.
  9.4544 + */
  9.4545 +static void pfm_flush_pmds(struct task_struct *, pfm_context_t *ctx);
  9.4546 +
  9.4547 +static int
  9.4548 +pfm_context_unload(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
  9.4549 +{
  9.4550 +	struct task_struct *task = PFM_CTX_TASK(ctx);
  9.4551 +	struct pt_regs *tregs;
  9.4552 +	int prev_state, is_system;
  9.4553 +	int ret;
  9.4554 +
  9.4555 +  	if (is_running_on_xen()) {
  9.4556 +		if (is_xenoprof_primary())
  9.4557 +			return HYPERVISOR_perfmon_op(PFM_UNLOAD_CONTEXT,
  9.4558 +			                             NULL, 0);
  9.4559 +		return 0;
  9.4560 +  	}
  9.4561 +	DPRINT(("ctx_state=%d task [%d]\n", ctx->ctx_state, task ? task->pid : -1));
  9.4562 +
  9.4563 +	prev_state = ctx->ctx_state;
  9.4564 +	is_system  = ctx->ctx_fl_system;
  9.4565 +
  9.4566 +	/*
  9.4567 +	 * unload only when necessary
  9.4568 +	 */
  9.4569 +	if (prev_state == PFM_CTX_UNLOADED) {
  9.4570 +		DPRINT(("ctx_state=%d, nothing to do\n", prev_state));
  9.4571 +		return 0;
  9.4572 +	}
  9.4573 +
  9.4574 +	/*
  9.4575 +	 * clear psr and dcr bits
  9.4576 +	 */
  9.4577 +	ret = pfm_stop(ctx, NULL, 0, regs);
  9.4578 +	if (ret) return ret;
  9.4579 +
  9.4580 +	ctx->ctx_state = PFM_CTX_UNLOADED;
  9.4581 +
  9.4582 +	/*
  9.4583 +	 * in system mode, we need to update the PMU directly
  9.4584 +	 * and the user level state of the caller, which may not
  9.4585 +	 * necessarily be the creator of the context.
  9.4586 +	 */
  9.4587 +	if (is_system) {
  9.4588 +
  9.4589 +		/*
  9.4590 +		 * Update cpuinfo
  9.4591 +		 *
  9.4592 +		 * local PMU is taken care of in pfm_stop()
  9.4593 +		 */
  9.4594 +		PFM_CPUINFO_CLEAR(PFM_CPUINFO_SYST_WIDE);
  9.4595 +		PFM_CPUINFO_CLEAR(PFM_CPUINFO_EXCL_IDLE);
  9.4596 +
  9.4597 +		/*
  9.4598 +		 * save PMDs in context
  9.4599 +		 * release ownership
  9.4600 +		 */
  9.4601 +		pfm_flush_pmds(current, ctx);
  9.4602 +
  9.4603 +		/*
  9.4604 +		 * at this point we are done with the PMU
  9.4605 +		 * so we can unreserve the resource.
  9.4606 +		 */
  9.4607 +		if (prev_state != PFM_CTX_ZOMBIE) 
  9.4608 +			pfm_unreserve_session(ctx, 1 , ctx->ctx_cpu);
  9.4609 +
  9.4610 +		/*
  9.4611 +		 * disconnect context from task
  9.4612 +		 */
  9.4613 +		task->thread.pfm_context = NULL;
  9.4614 +		/*
  9.4615 +		 * disconnect task from context
  9.4616 +		 */
  9.4617 +		ctx->ctx_task = NULL;
  9.4618 +
  9.4619 +		/*
  9.4620 +		 * There is nothing more to cleanup here.
  9.4621 +		 */
  9.4622 +		return 0;
  9.4623 +	}
  9.4624 +
  9.4625 +	/*
  9.4626 +	 * per-task mode
  9.4627 +	 */
  9.4628 +	tregs = task == current ? regs : task_pt_regs(task);
  9.4629 +
  9.4630 +	if (task == current) {
  9.4631 +		/*
  9.4632 +		 * cancel user level control
  9.4633 +		 */
  9.4634 +		ia64_psr(regs)->sp = 1;
  9.4635 +
  9.4636 +		DPRINT(("setting psr.sp for [%d]\n", task->pid));
  9.4637 +	}
  9.4638 +	/*
  9.4639 +	 * save PMDs to context
  9.4640 +	 * release ownership
  9.4641 +	 */
  9.4642 +	pfm_flush_pmds(task, ctx);
  9.4643 +
  9.4644 +	/*
  9.4645 +	 * at this point we are done with the PMU
  9.4646 +	 * so we can unreserve the resource.
  9.4647 +	 *
  9.4648 +	 * when state was ZOMBIE, we have already unreserved.
  9.4649 +	 */
  9.4650 +	if (prev_state != PFM_CTX_ZOMBIE) 
  9.4651 +		pfm_unreserve_session(ctx, 0 , ctx->ctx_cpu);
  9.4652 +
  9.4653 +	/*
  9.4654 +	 * reset activation counter and psr
  9.4655 +	 */
  9.4656 +	ctx->ctx_last_activation = PFM_INVALID_ACTIVATION;
  9.4657 +	SET_LAST_CPU(ctx, -1);
  9.4658 +
  9.4659 +	/*
  9.4660 +	 * PMU state will not be restored
  9.4661 +	 */
  9.4662 +	task->thread.flags &= ~IA64_THREAD_PM_VALID;
  9.4663 +
  9.4664 +	/*
  9.4665 +	 * break links between context and task
  9.4666 +	 */
  9.4667 +	task->thread.pfm_context  = NULL;
  9.4668 +	ctx->ctx_task             = NULL;
  9.4669 +
  9.4670 +	PFM_SET_WORK_PENDING(task, 0);
  9.4671 +
  9.4672 +	ctx->ctx_fl_trap_reason  = PFM_TRAP_REASON_NONE;
  9.4673 +	ctx->ctx_fl_can_restart  = 0;
  9.4674 +	ctx->ctx_fl_going_zombie = 0;
  9.4675 +
  9.4676 +	DPRINT(("disconnected [%d] from context\n", task->pid));
  9.4677 +
  9.4678 +	return 0;
  9.4679 +}
  9.4680 +
  9.4681 +
  9.4682 +/*
  9.4683 + * called only from exit_thread(): task == current
  9.4684 + * we come here only if current has a context attached (loaded or masked)
  9.4685 + */
  9.4686 +void
  9.4687 +pfm_exit_thread(struct task_struct *task)
  9.4688 +{
  9.4689 +	pfm_context_t *ctx;
  9.4690 +	unsigned long flags;
  9.4691 +	struct pt_regs *regs = task_pt_regs(task);
  9.4692 +	int ret, state;
  9.4693 +	int free_ok = 0;
  9.4694 +
  9.4695 +	ctx = PFM_GET_CTX(task);
  9.4696 +
  9.4697 +	PROTECT_CTX(ctx, flags);
  9.4698 +
  9.4699 +	DPRINT(("state=%d task [%d]\n", ctx->ctx_state, task->pid));
  9.4700 +
  9.4701 +	state = ctx->ctx_state;
  9.4702 +	switch(state) {
  9.4703 +		case PFM_CTX_UNLOADED:
  9.4704 +			/*
  9.4705 +	 		 * only comes to thios function if pfm_context is not NULL, i.e., cannot
  9.4706 +			 * be in unloaded state
  9.4707 +	 		 */
  9.4708 +			printk(KERN_ERR "perfmon: pfm_exit_thread [%d] ctx unloaded\n", task->pid);
  9.4709 +			break;
  9.4710 +		case PFM_CTX_LOADED:
  9.4711 +		case PFM_CTX_MASKED:
  9.4712 +			ret = pfm_context_unload(ctx, NULL, 0, regs);
  9.4713 +			if (ret) {
  9.4714 +				printk(KERN_ERR "perfmon: pfm_exit_thread [%d] state=%d unload failed %d\n", task->pid, state, ret);
  9.4715 +			}
  9.4716 +			DPRINT(("ctx unloaded for current state was %d\n", state));
  9.4717 +
  9.4718 +			pfm_end_notify_user(ctx);
  9.4719 +			break;
  9.4720 +		case PFM_CTX_ZOMBIE:
  9.4721 +			ret = pfm_context_unload(ctx, NULL, 0, regs);
  9.4722 +			if (ret) {
  9.4723 +				printk(KERN_ERR "perfmon: pfm_exit_thread [%d] state=%d unload failed %d\n", task->pid, state, ret);
  9.4724 +			}
  9.4725 +			free_ok = 1;
  9.4726 +			break;
  9.4727 +		default:
  9.4728 +			printk(KERN_ERR "perfmon: pfm_exit_thread [%d] unexpected state=%d\n", task->pid, state);
  9.4729 +			break;
  9.4730 +	}
  9.4731 +	UNPROTECT_CTX(ctx, flags);
  9.4732 +
  9.4733 +	{ u64 psr = pfm_get_psr();
  9.4734 +	  BUG_ON(psr & (IA64_PSR_UP|IA64_PSR_PP));
  9.4735 +	  BUG_ON(GET_PMU_OWNER());
  9.4736 +	  BUG_ON(ia64_psr(regs)->up);
  9.4737 +	  BUG_ON(ia64_psr(regs)->pp);
  9.4738 +	}
  9.4739 +
  9.4740 +	/*
  9.4741 +	 * All memory free operations (especially for vmalloc'ed memory)
  9.4742 +	 * MUST be done with interrupts ENABLED.
  9.4743 +	 */
  9.4744 +	if (free_ok) pfm_context_free(ctx);
  9.4745 +}
  9.4746 +
  9.4747 +/*
  9.4748 + * functions MUST be listed in the increasing order of their index (see permfon.h)
  9.4749 + */
  9.4750 +#define PFM_CMD(name, flags, arg_count, arg_type, getsz) { name, #name, flags, arg_count, sizeof(arg_type), getsz }
  9.4751 +#define PFM_CMD_S(name, flags) { name, #name, flags, 0, 0, NULL }
  9.4752 +#define PFM_CMD_PCLRWS	(PFM_CMD_FD|PFM_CMD_ARG_RW|PFM_CMD_STOP)
  9.4753 +#define PFM_CMD_PCLRW	(PFM_CMD_FD|PFM_CMD_ARG_RW)
  9.4754 +#define PFM_CMD_NONE	{ NULL, "no-cmd", 0, 0, 0, NULL}
  9.4755 +
  9.4756 +static pfm_cmd_desc_t pfm_cmd_tab[]={
  9.4757 +/* 0  */PFM_CMD_NONE,
  9.4758 +/* 1  */PFM_CMD(pfm_write_pmcs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_reg_t, NULL),
  9.4759 +/* 2  */PFM_CMD(pfm_write_pmds, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_reg_t, NULL),
  9.4760 +/* 3  */PFM_CMD(pfm_read_pmds, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_reg_t, NULL),
  9.4761 +/* 4  */PFM_CMD_S(pfm_stop, PFM_CMD_PCLRWS),
  9.4762 +/* 5  */PFM_CMD_S(pfm_start, PFM_CMD_PCLRWS),
  9.4763 +/* 6  */PFM_CMD_NONE,
  9.4764 +/* 7  */PFM_CMD_NONE,
  9.4765 +/* 8  */PFM_CMD(pfm_context_create, PFM_CMD_ARG_RW, 1, pfarg_context_t, pfm_ctx_getsize),
  9.4766 +/* 9  */PFM_CMD_NONE,
  9.4767 +/* 10 */PFM_CMD_S(pfm_restart, PFM_CMD_PCLRW),
  9.4768 +/* 11 */PFM_CMD_NONE,
  9.4769 +/* 12 */PFM_CMD(pfm_get_features, PFM_CMD_ARG_RW, 1, pfarg_features_t, NULL),
  9.4770 +/* 13 */PFM_CMD(pfm_debug, 0, 1, unsigned int, NULL),
  9.4771 +/* 14 */PFM_CMD_NONE,
  9.4772 +/* 15 */PFM_CMD(pfm_get_pmc_reset, PFM_CMD_ARG_RW, PFM_CMD_ARG_MANY, pfarg_reg_t, NULL),
  9.4773 +/* 16 */PFM_CMD(pfm_context_load, PFM_CMD_PCLRWS, 1, pfarg_load_t, NULL),
  9.4774 +/* 17 */PFM_CMD_S(pfm_context_unload, PFM_CMD_PCLRWS),
  9.4775 +/* 18 */PFM_CMD_NONE,
  9.4776 +/* 19 */PFM_CMD_NONE,
  9.4777 +/* 20 */PFM_CMD_NONE,
  9.4778 +/* 21 */PFM_CMD_NONE,
  9.4779 +/* 22 */PFM_CMD_NONE,
  9.4780 +/* 23 */PFM_CMD_NONE,
  9.4781 +/* 24 */PFM_CMD_NONE,
  9.4782 +/* 25 */PFM_CMD_NONE,
  9.4783 +/* 26 */PFM_CMD_NONE,
  9.4784 +/* 27 */PFM_CMD_NONE,
  9.4785 +/* 28 */PFM_CMD_NONE,
  9.4786 +/* 29 */PFM_CMD_NONE,
  9.4787 +/* 30 */PFM_CMD_NONE,
  9.4788 +/* 31 */PFM_CMD_NONE,
  9.4789 +/* 32 */PFM_CMD(pfm_write_ibrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL),
  9.4790 +/* 33 */PFM_CMD(pfm_write_dbrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL)
  9.4791 +};
  9.4792 +#define PFM_CMD_COUNT	(sizeof(pfm_cmd_tab)/sizeof(pfm_cmd_desc_t))
  9.4793 +
  9.4794 +static int
  9.4795 +pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags)
  9.4796 +{
  9.4797 +	struct task_struct *task;
  9.4798 +	int state, old_state;
  9.4799 +
  9.4800 +recheck:
  9.4801 +	state = ctx->ctx_state;
  9.4802 +	task  = ctx->ctx_task;
  9.4803 +
  9.4804 +	if (task == NULL) {
  9.4805 +		DPRINT(("context %d no task, state=%d\n", ctx->ctx_fd, state));
  9.4806 +		return 0;
  9.4807 +	}
  9.4808 +
  9.4809 +	DPRINT(("context %d state=%d [%d] task_state=%ld must_stop=%d\n",
  9.4810 +		ctx->ctx_fd,
  9.4811 +		state,
  9.4812 +		task->pid,
  9.4813 +		task->state, PFM_CMD_STOPPED(cmd)));
  9.4814 +
  9.4815 +	/*
  9.4816 +	 * self-monitoring always ok.
  9.4817 +	 *
  9.4818 +	 * for system-wide the caller can either be the creator of the
  9.4819 +	 * context (to one to which the context is attached to) OR
  9.4820 +	 * a task running on the same CPU as the session.
  9.4821 +	 */
  9.4822 +	if (task == current || ctx->ctx_fl_system) return 0;
  9.4823 +
  9.4824 +	/*
  9.4825 +	 * we are monitoring another thread
  9.4826 +	 */
  9.4827 +	switch(state) {
  9.4828 +		case PFM_CTX_UNLOADED:
  9.4829 +			/*
  9.4830 +			 * if context is UNLOADED we are safe to go
  9.4831 +			 */
  9.4832 +			return 0;
  9.4833 +		case PFM_CTX_ZOMBIE:
  9.4834 +			/*
  9.4835 +			 * no command can operate on a zombie context
  9.4836 +			 */
  9.4837 +			DPRINT(("cmd %d state zombie cannot operate on context\n", cmd));
  9.4838 +			return -EINVAL;
  9.4839 +		case PFM_CTX_MASKED:
  9.4840 +			/*
  9.4841 +			 * PMU state has been saved to software even though
  9.4842 +			 * the thread may still be running.
  9.4843 +			 */
  9.4844 +			if (cmd != PFM_UNLOAD_CONTEXT) return 0;
  9.4845 +	}
  9.4846 +
  9.4847 +	/*
  9.4848 +	 * context is LOADED or MASKED. Some commands may need to have 
  9.4849 +	 * the task stopped.
  9.4850 +	 *
  9.4851 +	 * We could lift this restriction for UP but it would mean that
  9.4852 +	 * the user has no guarantee the task would not run between
  9.4853 +	 * two successive calls to perfmonctl(). That's probably OK.
  9.4854 +	 * If this user wants to ensure the task does not run, then
  9.4855 +	 * the task must be stopped.
  9.4856 +	 */
  9.4857 +	if (PFM_CMD_STOPPED(cmd)) {
  9.4858 +		if ((task->state != TASK_STOPPED) && (task->state != TASK_TRACED)) {
  9.4859 +			DPRINT(("[%d] task not in stopped state\n", task->pid));
  9.4860 +			return -EBUSY;
  9.4861 +		}
  9.4862 +		/*
  9.4863 +		 * task is now stopped, wait for ctxsw out
  9.4864 +		 *
  9.4865 +		 * This is an interesting point in the code.
  9.4866 +		 * We need to unprotect the context because
  9.4867 +		 * the pfm_save_regs() routines needs to grab
  9.4868 +		 * the same lock. There are danger in doing
  9.4869 +		 * this because it leaves a window open for
  9.4870 +		 * another task to get access to the context
  9.4871 +		 * and possibly change its state. The one thing
  9.4872 +		 * that is not possible is for the context to disappear
  9.4873 +		 * because we are protected by the VFS layer, i.e.,
  9.4874 +		 * get_fd()/put_fd().
  9.4875 +		 */
  9.4876 +		old_state = state;
  9.4877 +
  9.4878 +		UNPROTECT_CTX(ctx, flags);
  9.4879 +
  9.4880 +		wait_task_inactive(task);
  9.4881 +
  9.4882 +		PROTECT_CTX(ctx, flags);
  9.4883 +
  9.4884 +		/*
  9.4885 +		 * we must recheck to verify if state has changed
  9.4886 +		 */
  9.4887 +		if (ctx->ctx_state != old_state) {
  9.4888 +			DPRINT(("old_state=%d new_state=%d\n", old_state, ctx->ctx_state));
  9.4889 +			goto recheck;
  9.4890 +		}
  9.4891 +	}
  9.4892 +	return 0;
  9.4893 +}
  9.4894 +
  9.4895 +/*
  9.4896 + * system-call entry point (must return long)
  9.4897 + */
  9.4898 +asmlinkage long
  9.4899 +sys_perfmonctl (int fd, int cmd, void __user *arg, int count)
  9.4900 +{
  9.4901 +	struct file *file = NULL;
  9.4902 +	pfm_context_t *ctx = NULL;
  9.4903 +	unsigned long flags = 0UL;
  9.4904 +	void *args_k = NULL;
  9.4905 +	long ret; /* will expand int return types */
  9.4906 +	size_t base_sz, sz, xtra_sz = 0;
  9.4907 +	int narg, completed_args = 0, call_made = 0, cmd_flags;
  9.4908 +	int (*func)(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs);
  9.4909 +	int (*getsize)(void *arg, size_t *sz);
  9.4910 +#define PFM_MAX_ARGSIZE	4096
  9.4911 +
  9.4912 +	/*
  9.4913 +	 * reject any call if perfmon was disabled at initialization
  9.4914 +	 */
  9.4915 +	if (unlikely(pmu_conf == NULL)) return -ENOSYS;
  9.4916 +
  9.4917 +	if (unlikely(cmd < 0 || cmd >= PFM_CMD_COUNT)) {
  9.4918 +		DPRINT(("invalid cmd=%d\n", cmd));
  9.4919 +		return -EINVAL;
  9.4920 +	}
  9.4921 +
  9.4922 +	func      = pfm_cmd_tab[cmd].cmd_func;
  9.4923 +	narg      = pfm_cmd_tab[cmd].cmd_narg;
  9.4924 +	base_sz   = pfm_cmd_tab[cmd].cmd_argsize;
  9.4925 +	getsize   = pfm_cmd_tab[cmd].cmd_getsize;
  9.4926 +	cmd_flags = pfm_cmd_tab[cmd].cmd_flags;
  9.4927 +
  9.4928 +	if (unlikely(func == NULL)) {
  9.4929 +		DPRINT(("invalid cmd=%d\n", cmd));
  9.4930 +		return -EINVAL;
  9.4931 +	}
  9.4932 +
  9.4933 +	DPRINT(("cmd=%s idx=%d narg=0x%x argsz=%lu count=%d\n",
  9.4934 +		PFM_CMD_NAME(cmd),
  9.4935 +		cmd,
  9.4936 +		narg,
  9.4937 +		base_sz,
  9.4938 +		count));
  9.4939 +
  9.4940 +	/*
  9.4941 +	 * check if number of arguments matches what the command expects
  9.4942 +	 */
  9.4943 +	if (unlikely((narg == PFM_CMD_ARG_MANY && count <= 0) || (narg > 0 && narg != count)))
  9.4944 +		return -EINVAL;
  9.4945 +
  9.4946 +restart_args:
  9.4947 +	sz = xtra_sz + base_sz*count;
  9.4948 +	/*
  9.4949 +	 * limit abuse to min page size
  9.4950 +	 */
  9.4951 +	if (unlikely(sz > PFM_MAX_ARGSIZE)) {
  9.4952 +		printk(KERN_ERR "perfmon: [%d] argument too big %lu\n", current->pid, sz);
  9.4953 +		return -E2BIG;
  9.4954 +	}
  9.4955 +
  9.4956 +	/*
  9.4957 +	 * allocate default-sized argument buffer
  9.4958 +	 */
  9.4959 +	if (likely(count && args_k == NULL)) {
  9.4960 +		args_k = kmalloc(PFM_MAX_ARGSIZE, GFP_KERNEL);
  9.4961 +		if (args_k == NULL) return -ENOMEM;
  9.4962 +	}
  9.4963 +
  9.4964 +	ret = -EFAULT;
  9.4965 +
  9.4966 +	/*
  9.4967 +	 * copy arguments
  9.4968 +	 *
  9.4969 +	 * assume sz = 0 for command without parameters
  9.4970 +	 */
  9.4971 +	if (sz && copy_from_user(args_k, arg, sz)) {
  9.4972 +		DPRINT(("cannot copy_from_user %lu bytes @%p\n", sz, arg));
  9.4973 +		goto error_args;
  9.4974 +	}
  9.4975 +
  9.4976 +	/*
  9.4977 +	 * check if command supports extra parameters
  9.4978 +	 */
  9.4979 +	if (completed_args == 0 && getsize) {
  9.4980 +		/*
  9.4981 +		 * get extra parameters size (based on main argument)
  9.4982 +		 */
  9.4983 +		ret = (*getsize)(args_k, &xtra_sz);
  9.4984 +		if (ret) goto error_args;
  9.4985 +
  9.4986 +		completed_args = 1;
  9.4987 +
  9.4988 +		DPRINT(("restart_args sz=%lu xtra_sz=%lu\n", sz, xtra_sz));
  9.4989 +
  9.4990 +		/* retry if necessary */
  9.4991 +		if (likely(xtra_sz)) goto restart_args;
  9.4992 +	}
  9.4993 +
  9.4994 +	if (unlikely((cmd_flags & PFM_CMD_FD) == 0)) goto skip_fd;
  9.4995 +
  9.4996 +	ret = -EBADF;
  9.4997 +
  9.4998 +	file = fget(fd);
  9.4999 +	if (unlikely(file == NULL)) {
  9.5000 +		DPRINT(("invalid fd %d\n", fd));
  9.5001 +		goto error_args;
  9.5002 +	}
  9.5003 +	if (unlikely(PFM_IS_FILE(file) == 0)) {
  9.5004 +		DPRINT(("fd %d not related to perfmon\n", fd));
  9.5005 +		goto error_args;
  9.5006 +	}
  9.5007 +
  9.5008 +	ctx = (pfm_context_t *)file->private_data;
  9.5009 +	if (unlikely(ctx == NULL)) {
  9.5010 +		DPRINT(("no context for fd %d\n", fd));
  9.5011 +		goto error_args;
  9.5012 +	}
  9.5013 +	prefetch(&ctx->ctx_state);
  9.5014 +
  9.5015 +	PROTECT_CTX(ctx, flags);
  9.5016 +
  9.5017 +	/*
  9.5018 +	 * check task is stopped
  9.5019 +	 */
  9.5020 +	ret = pfm_check_task_state(ctx, cmd, flags);
  9.5021 +	if (unlikely(ret)) goto abort_locked;
  9.5022 +
  9.5023 +skip_fd:
  9.5024 +	ret = (*func)(ctx, args_k, count, task_pt_regs(current));
  9.5025 +
  9.5026 +	call_made = 1;
  9.5027 +
  9.5028 +abort_locked:
  9.5029 +	if (likely(ctx)) {
  9.5030 +		DPRINT(("context unlocked\n"));
  9.5031 +		UNPROTECT_CTX(ctx, flags);
  9.5032 +	}
  9.5033 +
  9.5034 +	/* copy argument back to user, if needed */
  9.5035 +	if (call_made && PFM_CMD_RW_ARG(cmd) && copy_to_user(arg, args_k, base_sz*count)) ret = -EFAULT;
  9.5036 +
  9.5037 +error_args:
  9.5038 +	if (file)
  9.5039 +		fput(file);
  9.5040 +
  9.5041 +	kfree(args_k);
  9.5042 +
  9.5043 +	DPRINT(("cmd=%s ret=%ld\n", PFM_CMD_NAME(cmd), ret));
  9.5044 +
  9.5045 +	return ret;
  9.5046 +}
  9.5047 +
  9.5048 +static void
  9.5049 +pfm_resume_after_ovfl(pfm_context_t *ctx, unsigned long ovfl_regs, struct pt_regs *regs)
  9.5050 +{
  9.5051 +	pfm_buffer_fmt_t *fmt = ctx->ctx_buf_fmt;
  9.5052 +	pfm_ovfl_ctrl_t rst_ctrl;
  9.5053 +	int state;
  9.5054 +	int ret = 0;
  9.5055 +
  9.5056 +	state = ctx->ctx_state;
  9.5057 +	/*
  9.5058 +	 * Unlock sampling buffer and reset index atomically
  9.5059 +	 * XXX: not really needed when blocking
  9.5060 +	 */
  9.5061 +	if (CTX_HAS_SMPL(ctx)) {
  9.5062 +
  9.5063 +		rst_ctrl.bits.mask_monitoring = 0;
  9.5064 +		rst_ctrl.bits.reset_ovfl_pmds = 0;
  9.5065 +
  9.5066 +		if (state == PFM_CTX_LOADED)
  9.5067 +			ret = pfm_buf_fmt_restart_active(fmt, current, &rst_ctrl, ctx->ctx_smpl_hdr, regs);
  9.5068 +		else
  9.5069 +			ret = pfm_buf_fmt_restart(fmt, current, &rst_ctrl, ctx->ctx_smpl_hdr, regs);
  9.5070 +	} else {
  9.5071 +		rst_ctrl.bits.mask_monitoring = 0;
  9.5072 +		rst_ctrl.bits.reset_ovfl_pmds = 1;
  9.5073 +	}
  9.5074 +
  9.5075 +	if (ret == 0) {
  9.5076 +		if (rst_ctrl.bits.reset_ovfl_pmds) {
  9.5077 +			pfm_reset_regs(ctx, &ovfl_regs, PFM_PMD_LONG_RESET);
  9.5078 +		}
  9.5079 +		if (rst_ctrl.bits.mask_monitoring == 0) {
  9.5080 +			DPRINT(("resuming monitoring\n"));
  9.5081 +			if (ctx->ctx_state == PFM_CTX_MASKED) pfm_restore_monitoring(current);
  9.5082 +		} else {
  9.5083 +			DPRINT(("stopping monitoring\n"));
  9.5084 +			//pfm_stop_monitoring(current, regs);
  9.5085 +		}
  9.5086 +		ctx->ctx_state = PFM_CTX_LOADED;
  9.5087 +	}
  9.5088 +}
  9.5089 +
  9.5090 +/*
  9.5091 + * context MUST BE LOCKED when calling
  9.5092 + * can only be called for current
  9.5093 + */
  9.5094 +static void
  9.5095 +pfm_context_force_terminate(pfm_context_t *ctx, struct pt_regs *regs)
  9.5096 +{
  9.5097 +	int ret;
  9.5098 +
  9.5099 +	DPRINT(("entering for [%d]\n", current->pid));
  9.5100 +
  9.5101 +	ret = pfm_context_unload(ctx, NULL, 0, regs);
  9.5102 +	if (ret) {
  9.5103 +		printk(KERN_ERR "pfm_context_force_terminate: [%d] unloaded failed with %d\n", current->pid, ret);
  9.5104 +	}
  9.5105 +
  9.5106 +	/*
  9.5107 +	 * and wakeup controlling task, indicating we are now disconnected
  9.5108 +	 */
  9.5109 +	wake_up_interruptible(&ctx->ctx_zombieq);
  9.5110 +
  9.5111 +	/*
  9.5112 +	 * given that context is still locked, the controlling
  9.5113 +	 * task will only get access when we return from
  9.5114 +	 * pfm_handle_work().
  9.5115 +	 */
  9.5116 +}
  9.5117 +
  9.5118 +static int pfm_ovfl_notify_user(pfm_context_t *ctx, unsigned long ovfl_pmds);
  9.5119 + /*
  9.5120 +  * pfm_handle_work() can be called with interrupts enabled
  9.5121 +  * (TIF_NEED_RESCHED) or disabled. The down_interruptible
  9.5122 +  * call may sleep, therefore we must re-enable interrupts
  9.5123 +  * to avoid deadlocks. It is safe to do so because this function
  9.5124 +  * is called ONLY when returning to user level (PUStk=1), in which case
  9.5125 +  * there is no risk of kernel stack overflow due to deep
  9.5126 +  * interrupt nesting.
  9.5127 +  */
  9.5128 +void
  9.5129 +pfm_handle_work(void)
  9.5130 +{
  9.5131 +	pfm_context_t *ctx;
  9.5132 +	struct pt_regs *regs;
  9.5133 +	unsigned long flags, dummy_flags;
  9.5134 +	unsigned long ovfl_regs;
  9.5135 +	unsigned int reason;
  9.5136 +	int ret;
  9.5137 +
  9.5138 +	ctx = PFM_GET_CTX(current);
  9.5139 +	if (ctx == NULL) {
  9.5140 +		printk(KERN_ERR "perfmon: [%d] has no PFM context\n", current->pid);
  9.5141 +		return;
  9.5142 +	}
  9.5143 +
  9.5144 +	PROTECT_CTX(ctx, flags);
  9.5145 +
  9.5146 +	PFM_SET_WORK_PENDING(current, 0);
  9.5147 +
  9.5148 +	pfm_clear_task_notify();
  9.5149 +
  9.5150 +	regs = task_pt_regs(current);
  9.5151 +
  9.5152 +	/*
  9.5153 +	 * extract reason for being here and clear
  9.5154 +	 */
  9.5155 +	reason = ctx->ctx_fl_trap_reason;
  9.5156 +	ctx->ctx_fl_trap_reason = PFM_TRAP_REASON_NONE;
  9.5157 +	ovfl_regs = ctx->ctx_ovfl_regs[0];
  9.5158 +
  9.5159 +	DPRINT(("reason=%d state=%d\n", reason, ctx->ctx_state));
  9.5160 +
  9.5161 +	/*
  9.5162 +	 * must be done before we check for simple-reset mode
  9.5163 +	 */
  9.5164 +	if (ctx->ctx_fl_going_zombie || ctx->ctx_state == PFM_CTX_ZOMBIE) goto do_zombie;
  9.5165 +
  9.5166 +
  9.5167 +	//if (CTX_OVFL_NOBLOCK(ctx)) goto skip_blocking;
  9.5168 +	if (reason == PFM_TRAP_REASON_RESET) goto skip_blocking;
  9.5169 +
  9.5170 +	/*
  9.5171 +	 * restore interrupt mask to what it was on entry.
  9.5172 +	 * Could be enabled/diasbled.
  9.5173 +	 */
  9.5174 +	UNPROTECT_CTX(ctx, flags);
  9.5175 +
  9.5176 +	/*
  9.5177 +	 * force interrupt enable because of down_interruptible()
  9.5178 +	 */
  9.5179 +	local_irq_enable();
  9.5180 +
  9.5181 +	DPRINT(("before block sleeping\n"));
  9.5182 +
  9.5183 +	/*
  9.5184 +	 * may go through without blocking on SMP systems
  9.5185 +	 * if restart has been received already by the time we call down()
  9.5186 +	 */
  9.5187 +	ret = wait_for_completion_interruptible(&ctx->ctx_restart_done);
  9.5188 +
  9.5189 +	DPRINT(("after block sleeping ret=%d\n", ret));
  9.5190 +
  9.5191 +	/*
  9.5192 +	 * lock context and mask interrupts again
  9.5193 +	 * We save flags into a dummy because we may have
  9.5194 +	 * altered interrupts mask compared to entry in this
  9.5195 +	 * function.
  9.5196 +	 */
  9.5197 +	PROTECT_CTX(ctx, dummy_flags);
  9.5198 +
  9.5199 +	/*
  9.5200 +	 * we need to read the ovfl_regs only after wake-up
  9.5201 +	 * because we may have had pfm_write_pmds() in between
  9.5202 +	 * and that can changed PMD values and therefore 
  9.5203 +	 * ovfl_regs is reset for these new PMD values.
  9.5204 +	 */
  9.5205 +	ovfl_regs = ctx->ctx_ovfl_regs[0];
  9.5206 +
  9.5207 +	if (ctx->ctx_fl_going_zombie) {
  9.5208 +do_zombie:
  9.5209 +		DPRINT(("context is zombie, bailing out\n"));
  9.5210 +		pfm_context_force_terminate(ctx, regs);
  9.5211 +		goto nothing_to_do;
  9.5212 +	}
  9.5213 +	/*
  9.5214 +	 * in case of interruption of down() we don't restart anything
  9.5215 +	 */
  9.5216 +	if (ret < 0) goto nothing_to_do;
  9.5217 +
  9.5218 +skip_blocking:
  9.5219 +	pfm_resume_after_ovfl(ctx, ovfl_regs, regs);
  9.5220 +	ctx->ctx_ovfl_regs[0] = 0UL;
  9.5221 +
  9.5222 +nothing_to_do:
  9.5223 +	/*
  9.5224 +	 * restore flags as they were upon entry
  9.5225 +	 */
  9.5226 +	UNPROTECT_CTX(ctx, flags);
  9.5227 +}
  9.5228 +
  9.5229 +static int
  9.5230 +pfm_notify_user(pfm_context_t *ctx, pfm_msg_t *msg)
  9.5231 +{
  9.5232 +	if (ctx->ctx_state == PFM_CTX_ZOMBIE) {
  9.5233 +		DPRINT(("ignoring overflow notification, owner is zombie\n"));
  9.5234 +		return 0;
  9.5235 +	}
  9.5236 +
  9.5237 +	DPRINT(("waking up somebody\n"));
  9.5238 +
  9.5239 +	if (msg) wake_up_interruptible(&ctx->ctx_msgq_wait);
  9.5240 +
  9.5241 +	/*
  9.5242 +	 * safe, we are not in intr handler, nor in ctxsw when
  9.5243 +	 * we come here
  9.5244 +	 */
  9.5245 +	kill_fasync (&ctx->ctx_async_queue, SIGIO, POLL_IN);
  9.5246 +
  9.5247 +	return 0;
  9.5248 +}
  9.5249 +
  9.5250 +static int
  9.5251 +pfm_ovfl_notify_user(pfm_context_t *ctx, unsigned long ovfl_pmds)
  9.5252 +{
  9.5253 +	pfm_msg_t *msg = NULL;
  9.5254 +
  9.5255 +	if (ctx->ctx_fl_no_msg == 0) {
  9.5256 +		msg = pfm_get_new_msg(ctx);
  9.5257 +		if (msg == NULL) {
  9.5258 +			printk(KERN_ERR "perfmon: pfm_ovfl_notify_user no more notification msgs\n");
  9.5259 +			return -1;
  9.5260 +		}
  9.5261 +
  9.5262 +		msg->pfm_ovfl_msg.msg_type         = PFM_MSG_OVFL;
  9.5263 +		msg->pfm_ovfl_msg.msg_ctx_fd       = ctx->ctx_fd;
  9.5264 +		msg->pfm_ovfl_msg.msg_active_set   = 0;
  9.5265 +		msg->pfm_ovfl_msg.msg_ovfl_pmds[0] = ovfl_pmds;
  9.5266 +		msg->pfm_ovfl_msg.msg_ovfl_pmds[1] = 0UL;
  9.5267 +		msg->pfm_ovfl_msg.msg_ovfl_pmds[2] = 0UL;
  9.5268 +		msg->pfm_ovfl_msg.msg_ovfl_pmds[3] = 0UL;
  9.5269 +		msg->pfm_ovfl_msg.msg_tstamp       = 0UL;
  9.5270 +	}
  9.5271 +
  9.5272 +	DPRINT(("ovfl msg: msg=%p no_msg=%d fd=%d ovfl_pmds=0x%lx\n",
  9.5273 +		msg,
  9.5274 +		ctx->ctx_fl_no_msg,
  9.5275 +		ctx->ctx_fd,
  9.5276 +		ovfl_pmds));
  9.5277 +
  9.5278 +	return pfm_notify_user(ctx, msg);
  9.5279 +}
  9.5280 +
  9.5281 +static int
  9.5282 +pfm_end_notify_user(pfm_context_t *ctx)
  9.5283 +{
  9.5284 +	pfm_msg_t *msg;
  9.5285 +
  9.5286 +	msg = pfm_get_new_msg(ctx);
  9.5287 +	if (msg == NULL) {
  9.5288 +		printk(KERN_ERR "perfmon: pfm_end_notify_user no more notification msgs\n");
  9.5289 +		return -1;
  9.5290 +	}
  9.5291 +	/* no leak */
  9.5292 +	memset(msg, 0, sizeof(*msg));
  9.5293 +
  9.5294 +	msg->pfm_end_msg.msg_type    = PFM_MSG_END;
  9.5295 +	msg->pfm_end_msg.msg_ctx_fd  = ctx->ctx_fd;
  9.5296 +	msg->pfm_ovfl_msg.msg_tstamp = 0UL;
  9.5297 +
  9.5298 +	DPRINT(("end msg: msg=%p no_msg=%d ctx_fd=%d\n",
  9.5299 +		msg,
  9.5300 +		ctx->ctx_fl_no_msg,
  9.5301 +		ctx->ctx_fd));
  9.5302 +
  9.5303 +	return pfm_notify_user(ctx, msg);
  9.5304 +}
  9.5305 +
  9.5306 +/*
  9.5307 + * main overflow processing routine.
  9.5308 + * it can be called from the interrupt path or explicitely during the context switch code
  9.5309 + */
  9.5310 +static void
  9.5311 +pfm_overflow_handler(struct task_struct *task, pfm_context_t *ctx, u64 pmc0, struct pt_regs *regs)
  9.5312 +{
  9.5313 +	pfm_ovfl_arg_t *ovfl_arg;
  9.5314 +	unsigned long mask;
  9.5315 +	unsigned long old_val, ovfl_val, new_val;
  9.5316 +	unsigned long ovfl_notify = 0UL, ovfl_pmds = 0UL, smpl_pmds = 0UL, reset_pmds;
  9.5317 +	unsigned long tstamp;
  9.5318 +	pfm_ovfl_ctrl_t	ovfl_ctrl;
  9.5319 +	unsigned int i, has_smpl;
  9.5320 +	int must_notify = 0;
  9.5321 +
  9.5322 +	if (unlikely(ctx->ctx_state == PFM_CTX_ZOMBIE)) goto stop_monitoring;
  9.5323 +
  9.5324 +	/*
  9.5325 +	 * sanity test. Should never happen
  9.5326 +	 */
  9.5327 +	if (unlikely((pmc0 & 0x1) == 0)) goto sanity_check;
  9.5328 +
  9.5329 +	tstamp   = ia64_get_itc();
  9.5330 +	mask     = pmc0 >> PMU_FIRST_COUNTER;
  9.5331 +	ovfl_val = pmu_conf->ovfl_val;
  9.5332 +	has_smpl = CTX_HAS_SMPL(ctx);
  9.5333 +
  9.5334 +	DPRINT_ovfl(("pmc0=0x%lx pid=%d iip=0x%lx, %s "
  9.5335 +		     "used_pmds=0x%lx\n",
  9.5336 +			pmc0,
  9.5337 +			task ? task->pid: -1,
  9.5338 +			(regs ? regs->cr_iip : 0),
  9.5339 +			CTX_OVFL_NOBLOCK(ctx) ? "nonblocking" : "blocking",
  9.5340 +			ctx->ctx_used_pmds[0]));
  9.5341 +
  9.5342 +
  9.5343 +	/*
  9.5344 +	 * first we update the virtual counters
  9.5345 +	 * assume there was a prior ia64_srlz_d() issued
  9.5346 +	 */
  9.5347 +	for (i = PMU_FIRST_COUNTER; mask ; i++, mask >>= 1) {
  9.5348 +
  9.5349 +		/* skip pmd which did not overflow */
  9.5350 +		if ((mask & 0x1) == 0) continue;
  9.5351 +
  9.5352 +		/*
  9.5353 +		 * Note that the pmd is not necessarily 0 at this point as qualified events
  9.5354 +		 * may have happened before the PMU was frozen. The residual count is not
  9.535