1 = sPAPR Dynamic Reconfiguration =
3 sPAPR/"pseries" guests make use of a facility called dynamic-reconfiguration
4 to handle hotplugging of dynamic "physical" resources like PCI cards, or
5 "logical"/paravirtual resources like memory, CPUs, and "physical"
6 host-bridges, which are generally managed by the host/hypervisor and provided
7 to guests as virtualized resources. The specifics of dynamic-reconfiguration
8 are documented extensively in PAPR+ v2.7, Section 13.1. This document
9 provides a summary of that information as it applies to the implementation
12 == Dynamic-reconfiguration Connectors ==
14 To manage hotplug/unplug of these resources, a firmware abstraction known as
15 a Dynamic Resource Connector (DRC) is used to assign a particular dynamic
16 resource to the guest, and provide an interface for the guest to manage
17 configuration/removal of the resource associated with it.
19 == Device-tree description of DRCs ==
21 A set of 4 Open Firmware device tree array properties are used to describe
22 the name/index/power-domain/type of each DRC allocated to a guest at
23 boot-time. There may be multiple sets of these arrays, rooted at different
24 paths in the device tree depending on the type of resource the DRCs manage.
26 In some cases, the DRCs themselves may be provided by a dynamic resource,
27 such as the DRCs managing PCI slots on a hotplugged PHB. In this case the
28 arrays would be fetched as part of the device tree retrieval interfaces
29 for hotplugged resources described under "Guest->Host interface".
31 The array properties are described below. Each entry/element in an array
32 describes the DRC identified by the element in the corresponding position
36 first 4-bytes: BE-encoded integer denoting the number of entries
37 each entry: a NULL-terminated <name> string encoded as a byte array
39 <name> values for logical/virtual resources are defined in PAPR+ v2.7,
40 Section 13.5.2.4, and basically consist of the type of the resource
41 followed by a space and a numerical value that's unique across resources
44 <name> values for "physical" resources such as PCI or VIO devices are
45 defined as being "location codes", which are the "location labels" of
46 each encapsulating device, starting from the chassis down to the
47 individual slot for the device, concatenated by a hyphen. This provides
48 a mapping of resources to a physical location in a chassis for debugging
49 purposes. For QEMU, this mapping is less important, so we assign a
50 location code that conforms to naming specifications, but is simply a
51 location label for the slot by itself to simplify the implementation.
52 The naming convention for location labels is documented in detail in
53 PAPR+ v2.7, Section 12.3.1.5, and in our case amounts to using "C<n>"
54 for PCI/VIO device slots, where <n> is unique across all PCI/VIO
58 first 4-bytes: BE-encoded integer denoting the number of entries
59 each 4-byte entry: BE-encoded <index> integer that is unique across all DRCs
62 <index> is arbitrary, but in the case of QEMU we try to maintain the
63 convention used to assign them to pSeries guests on pHyp:
65 bit[31:28]: integer encoding of <type>, where <type> is:
71 bit[27:0]: integer encoding of <id>, where <id> is unique across
72 all resources of specified type
74 ibm,drc-power-domains:
75 first 4-bytes: BE-encoded integer denoting the number of entries
76 each 4-byte entry: 32-bit, BE-encoded <index> integer that specifies the
77 power domain the resource will be assigned to. In the case of QEMU
78 we associated all resources with a "live insertion" domain, where the
79 power is assumed to be managed automatically. The integer value for
80 this domain is a special value of -1.
84 first 4-bytes: BE-encoded integer denoting the number of entries
85 each entry: a NULL-terminated <type> string encoded as a byte array
87 <type> is assigned as follows:
89 "PHB" for a physical host-bridge
92 "MEM" for memory resource
94 == Guest->Host interface to manage dynamic resources ==
96 Each DRC is given a globally unique DRC Index, and resources associated with
97 a particular DRC are configured/managed by the guest via a number of RTAS
98 calls which reference individual DRCs based on the DRC index. This can be
99 considered the guest->host interface.
101 rtas-set-power-level:
102 arg[0]: integer identifying power domain
103 arg[1]: new power level for the domain, 0-100
104 output[0]: status, 0 on success
105 output[1]: power level after command
107 Set the power level for a specified power domain
109 rtas-get-power-level:
110 arg[0]: integer identifying power domain
111 output[0]: status, 0 on success
112 output[1]: current power level
114 Get the power level for a specified power domain
117 arg[0]: integer identifying sensor/indicator type
118 arg[1]: index of sensor, for DR-related sensors this is generally the
120 arg[2]: desired sensor value
121 output[0]: status, 0 on success
123 Set the state of an indicator or sensor. For the purpose of this document we
124 focus on the indicator/sensor types associated with a DRC. The types are:
126 9001: isolation-state, controls/indicates whether a device has been made
127 accessible to a guest
129 supported sensor values:
130 0: isolate, device is made unaccessible by guest OS
131 1: unisolate, device is made available to guest OS
133 9002: dr-indicator, controls "visual" indicator associated with device
135 supported sensor values:
136 0: inactive, resource may be safely removed
137 1: active, resource is in use and cannot be safely removed
138 2: identify, used to visually identify slot for interactive hotplug
139 3: action, in most cases, used in the same manner as identify
141 9003: allocation-state, generally only used for "logical" DR resources to
142 request the allocation/deallocation of a resource prior to acquiring
143 it via isolation-state->unisolate, or after releasing it via
144 isolation-state->isolate, respectively. for "physical" DR (like PCI
145 hotplug/unplug) the pre-allocation of the resource is implied and
146 this sensor is unused.
148 supported sensor values:
149 0: unusable, tell firmware/system the resource can be
150 unallocated/reclaimed and added back to the system resource pool
151 1: usable, request the resource be allocated/reserved for use by
153 2: exchange, used to allocate a spare resource to use for fail-over
154 in certain situations. unused in QEMU
155 3: recover, used to reclaim a previously allocated resource that's
156 not currently allocated to the guest OS. unused in QEMU
158 rtas-get-sensor-state:
159 arg[0]: integer identifying sensor/indicator type
160 arg[1]: index of sensor, for DR-related sensors this is generally the
162 output[0]: status, 0 on success
164 Used to read an indicator or sensor value.
166 For DR-related operations, the only noteworthy sensor is dr-entity-sense,
167 which has a type value of 9003, as allocation-state does in the case of
168 rtas-set-indicator. The semantics/encodings of the sensor values are distinct
171 supported sensor values for dr-entity-sense (9003) sensor:
173 for physical resources: DRC/slot is empty
174 for logical resources: unused
176 for physical resources: DRC/slot is populated with a device/resource
177 for logical resources: resource has been allocated to the DRC
179 for physical resources: unused
180 for logical resources: DRC has no resource allocated to it
182 for physical resources: unused
183 for logical resources: resource available for exchange (see
184 allocation-state sensor semantics above)
186 for physical resources: unused
187 for logical resources: resource available for recovery (see
188 allocation-state sensor semantics above)
190 rtas-ibm-configure-connector:
191 arg[0]: guest physical address of 4096-byte work area buffer
192 arg[1]: 0, or address of additional 4096-byte work area buffer. only non-zero
193 if a prior RTAS response indicated a need for additional memory
195 0: completed transmittal of device-tree node
196 1: instruct guest to prepare for next DT sibling node
197 2: instruct guest to prepare for next DT child node
198 3: instruct guest to prepare for next DT property
199 4: instruct guest to ascend to parent DT node
200 5: instruct guest to provide additional work-area buffer
202 990x: instruct guest that operation took too long and to try
205 Used to fetch an OF device-tree description of the resource associated with
206 a particular DRC. The DRC index is encoded in the first 4-bytes of the first
209 Work area layout, using 4-byte offsets:
210 wa[0]: DRC index of the DRC to fetch device-tree nodes from
211 wa[1]: 0 (hard-coded)
212 wa[2]: for next-sibling/next-child response:
213 wa offset of null-terminated string denoting the new node's name
214 for next-property response:
215 wa offset of null-terminated string denoting new property's name
216 wa[3]: for next-property response (unused otherwise):
217 byte-length of new property's value
218 wa[4]: for next-property response (unused otherwise):
219 new property's value, encoded as an OFDT-compatible byte array
221 == hotplug/unplug events ==
223 For most DR operations, the hypervisor will issue host->guest add/remove events
224 using the EPOW/check-exception notification framework, where the host issues a
225 check-exception interrupt, then provides an RTAS event log via an
226 rtas-check-exception call issued by the guest in response. This framework is
227 documented by PAPR+ v2.7, and already use in by QEMU for generating powerdown
228 requests via EPOW events.
230 For DR, this framework has been extended to include hotplug events, which were
231 previously unneeded due to direct manipulation of DR-related guest userspace
232 tools by host-level management such as an HMC. This level of management is not
233 applicable to PowerKVM, hence the reason for extending the notification
234 framework to support hotplug events.
236 Note that these events are not yet formally part of the PAPR+ specification,
237 but support for this format has already been implemented in DR-related
238 guest tools such as powerpc-utils/librtas, as well as kernel patches that have
239 been submitted to handle in-kernel processing of memory/cpu-related hotplug
240 events[1], and is planned for formal inclusion is PAPR+ specification. The
241 hotplug-specific payload is QEMU implemented as follows (with all values
242 encoded in big-endian format):
244 struct rtas_event_log_v6_hp {
245 #define SECTION_ID_HOTPLUG 0x4850 /* HP */
246 struct section_header {
247 uint16_t section_id; /* set to SECTION_ID_HOTPLUG */
248 uint16_t section_length; /* sizeof(rtas_event_log_v6_hp),
249 * plus the length of the DRC name
250 * if a DRC name identifier is
251 * specified for hotplug_identifier
253 uint8_t section_version; /* version 1 */
254 uint8_t section_subtype; /* unused */
255 uint16_t creator_component_id; /* unused */
257 #define RTAS_LOG_V6_HP_TYPE_CPU 1
258 #define RTAS_LOG_V6_HP_TYPE_MEMORY 2
259 #define RTAS_LOG_V6_HP_TYPE_SLOT 3
260 #define RTAS_LOG_V6_HP_TYPE_PHB 4
261 #define RTAS_LOG_V6_HP_TYPE_PCI 5
262 uint8_t hotplug_type; /* type of resource/device */
263 #define RTAS_LOG_V6_HP_ACTION_ADD 1
264 #define RTAS_LOG_V6_HP_ACTION_REMOVE 2
265 uint8_t hotplug_action; /* action (add/remove) */
266 #define RTAS_LOG_V6_HP_ID_DRC_NAME 1
267 #define RTAS_LOG_V6_HP_ID_DRC_INDEX 2
268 #define RTAS_LOG_V6_HP_ID_DRC_COUNT 3
269 uint8_t hotplug_identifier; /* type of the resource identifier,
270 * which serves as the discriminator
271 * for the 'drc' union field below
275 uint32_t index; /* DRC index of resource to take action
278 uint32_t count; /* number of DR resources to take
279 * action on (guest chooses which)
281 char name[1]; /* string representing the name of the
282 * DRC to take action on
287 == ibm,lrdr-capacity ==
289 ibm,lrdr-capacity is a property in the /rtas device tree node that identifies
290 the dynamic reconfiguration capabilities of the guest. It consists of a triple
291 consisting of <phys>, <size> and <maxcpus>.
293 <phys>, encoded in BE format represents the maximum address in bytes and
294 hence the maximum memory that can be allocated to the guest.
296 <size>, encoded in BE format represents the size increments in which
297 memory can be hot-plugged to the guest.
299 <maxcpus>, a BE-encoded integer, represents the maximum number of
300 processors that the guest can have.
302 pseries guests use this property to note the maximum allowed CPUs for the
305 == ibm,dynamic-reconfiguration-memory ==
307 ibm,dynamic-reconfiguration-memory is a device tree node that represents
308 dynamically reconfigurable logical memory blocks (LMB). This node
309 is generated only when the guest advertises the support for it via
310 ibm,client-architecture-support call. Memory that is not dynamically
311 reconfigurable is represented by /memory nodes. The properties of this
312 node that are of interest to the sPAPR memory hotplug implementation
313 in QEMU are described here.
317 This 64bit integer defines the size of each dynamically reconfigurable LMB.
319 ibm,associativity-lookup-arrays
321 This property defines a lookup array in which the NUMA associativity
322 information for each LMB can be found. It is a property encoded array
323 that begins with an integer M, the number of associativity lists followed
324 by an integer N, the number of entries per associativity list and terminated
325 by M associativity lists each of length N integers.
327 This property provides the same information as given by ibm,associativity
328 property in a /memory node. Each assigned LMB has an index value between
329 0 and M-1 which is used as an index into this table to select which
330 associativity list to use for the LMB. This index value for each LMB
331 is defined in ibm,dynamic-memory property.
335 This property describes the dynamically reconfigurable memory. It is a
336 property encoded array that has an integer N, the number of LMBs followed
337 by N LMB list entires.
339 Each LMB list entry consists of the following elements:
341 - Logical address of the start of the LMB encoded as a 64bit integer. This
342 corresponds to reg property in /memory node.
343 - DRC index of the LMB that corresponds to ibm,my-drc-index property
345 - Four bytes reserved for expansion.
346 - Associativity list index for the LMB that is used as an index into
347 ibm,associativity-lookup-arrays property described earlier. This
348 is used to retrieve the right associativity list to be used for this
350 - A 32bit flags word. The bit at bit position 0x00000008 defines whether
351 the LMB is assigned to the the partition as of boot time.
353 [1] http://thread.gmane.org/gmane.linux.ports.ppc.embedded/75350/focus=106867