Merge ~dannf/ubuntu/+source/freeipmi:merge-cosmic into ~racb/ubuntu/+source/freeipmi:merge-cosmic
- Git
- lp:~dannf/ubuntu/+source/freeipmi
- merge-cosmic
- Merge into merge-cosmic
Proposed by
dann frazier
Status: | Needs review |
---|---|
Proposed branch: | ~dannf/ubuntu/+source/freeipmi:merge-cosmic |
Merge into: | ~racb/ubuntu/+source/freeipmi:merge-cosmic |
Diff against target: |
749 lines (+688/-0) 8 files modified
debian/changelog (+11/-0) debian/patches/0001-Fix-acpi-spmi-searching-corner-case.patch (+29/-0) debian/patches/0002-Don-t-try-to-separate-the-header-from-the-ACPI-table.patch (+183/-0) debian/patches/0003-Split-RSDT-XSDT-parsing-into-new-function.patch (+189/-0) debian/patches/0004-Add-support-for-parsing-SPMI-tables-exposed-via-sysf.patch (+159/-0) debian/patches/0005-Allow-sysfs-SPMI-parsing-on-ARM-platforms.patch (+47/-0) debian/patches/0006-Correct-order-of-bytes-in-specification_revision-fie.patch (+64/-0) debian/patches/series (+6/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robie Basak | Pending | ||
Review via email: mp+352214@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Unmerged commits
- 0eadb51... by dann frazier
-
Add support to ipmi-locate for parsing ACPI/SPMI tables out of sysfs:
* Cherry-pick patches from upstream that add support to ipmi-locate
for parsing ACPI/SPMI tables out of sysfs:
- 0001-Fix-acpi-spmi- searching- corner- case.patch
- 0002-Don-t-try-to- separate- the-header- from-the- ACPI-table. patch
- 0003-Split-RSDT-XSDT- parsing- into-new- function. patch
- 0004-Add-support- for-parsing- SPMI-tables- exposed- via-sysf. patch
- 0005-Allow-sysfs-SPMI- parsing- on-ARM- platforms. patch
- 0006-Correct-order-of- bytes-in- specification_ revision- fie.patch
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/debian/changelog b/debian/changelog |
2 | index 5a75ef2..c18bcca 100644 |
3 | --- a/debian/changelog |
4 | +++ b/debian/changelog |
5 | @@ -1,5 +1,6 @@ |
6 | freeipmi (1.5.7-2ubuntu1) cosmic; urgency=medium |
7 | |
8 | + [ Robie Basak ] |
9 | * Merge with Debian unstable. Remaining changes: |
10 | - debian/rules: Build with "-pie,-bindnow" |
11 | - Use dh-autoreconf to update libtool for ppc64el. |
12 | @@ -9,6 +10,16 @@ freeipmi (1.5.7-2ubuntu1) cosmic; urgency=medium |
13 | * Drop changes: |
14 | - Use kernel DMI table interface, when available (adopted upstream). |
15 | |
16 | + [ dann frazier ] |
17 | + * Cherry-pick patches from upstream that add support to ipmi-locate |
18 | + for parsing ACPI/SPMI tables out of sysfs (LP: #1784926): |
19 | + - 0001-Fix-acpi-spmi-searching-corner-case.patch |
20 | + - 0002-Don-t-try-to-separate-the-header-from-the-ACPI-table.patch |
21 | + - 0003-Split-RSDT-XSDT-parsing-into-new-function.patch |
22 | + - 0004-Add-support-for-parsing-SPMI-tables-exposed-via-sysf.patch |
23 | + - 0005-Allow-sysfs-SPMI-parsing-on-ARM-platforms.patch |
24 | + - 0006-Correct-order-of-bytes-in-specification_revision-fie.patch |
25 | + |
26 | -- Robie Basak <robie.basak@ubuntu.com> Thu, 26 Jul 2018 14:19:18 +0100 |
27 | |
28 | freeipmi (1.5.7-2) unstable; urgency=medium |
29 | diff --git a/debian/patches/0001-Fix-acpi-spmi-searching-corner-case.patch b/debian/patches/0001-Fix-acpi-spmi-searching-corner-case.patch |
30 | new file mode 100644 |
31 | index 0000000..37130c9 |
32 | --- /dev/null |
33 | +++ b/debian/patches/0001-Fix-acpi-spmi-searching-corner-case.patch |
34 | @@ -0,0 +1,29 @@ |
35 | +From d8673cf67d4cc856664f26b505a4f67a94f62d2b Mon Sep 17 00:00:00 2001 |
36 | +From: Albert Chu <chu11@llnl.gov> |
37 | +Date: Tue, 31 Jul 2018 17:11:09 -0700 |
38 | +Subject: [PATCH 1/6] Fix acpi spmi searching corner case |
39 | + |
40 | +--- |
41 | + ChangeLog | 6 ++++++ |
42 | + libfreeipmi/locate/ipmi-locate-acpi-spmi.c | 5 ++++- |
43 | + 2 files changed, 10 insertions(+), 1 deletion(-) |
44 | + |
45 | +diff --git a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
46 | +index 8e2cfe5e7..9593943e5 100644 |
47 | +--- a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
48 | ++++ b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
49 | +@@ -1461,7 +1461,10 @@ _ipmi_acpi_get_spmi_table (ipmi_locate_ctx_t ctx, |
50 | + |
51 | + table_interface_type = val; |
52 | + if (table_interface_type == interface_type) |
53 | +- rv = 0; |
54 | ++ { |
55 | ++ rv = 0; |
56 | ++ break; |
57 | ++ } |
58 | + } |
59 | + |
60 | + cleanup: |
61 | +-- |
62 | +2.18.0 |
63 | + |
64 | diff --git a/debian/patches/0002-Don-t-try-to-separate-the-header-from-the-ACPI-table.patch b/debian/patches/0002-Don-t-try-to-separate-the-header-from-the-ACPI-table.patch |
65 | new file mode 100644 |
66 | index 0000000..d7e735d |
67 | --- /dev/null |
68 | +++ b/debian/patches/0002-Don-t-try-to-separate-the-header-from-the-ACPI-table.patch |
69 | @@ -0,0 +1,183 @@ |
70 | +From 3c6fa7054ab4c1d899da9d3bacb9704f9f45c0f6 Mon Sep 17 00:00:00 2001 |
71 | +From: dann frazier <dann.frazier@canonical.com> |
72 | +Date: Wed, 1 Aug 2018 11:01:08 -0600 |
73 | +Subject: [PATCH 2/6] Don't try to separate the header from the ACPI table data |
74 | + |
75 | +_ipmi_acpi_get_spmi_table() calls _ipmi_acpi_get_firmware_table() to |
76 | +populate obj_acpi_table_hdr and table_data with the SPMI table header |
77 | +and SPMI table data, respectively. However, there appears to be an |
78 | +internal discrepancy as to whether or not the table_data should also |
79 | +contain the header as well. |
80 | + |
81 | +_ipmi_acpi_get_firmware_table() only returns the non-header data in |
82 | +table_data._ipmi_acpi_get_spmi_table() then loads that data into an |
83 | +object using the SPMI table template (tmpl_acpi_spmi_table_descriptor). |
84 | +However, you'll notice that the SPMI table template also includes the |
85 | +ACPI table header fields. So fiid_obj_set_all() is copying the headerless |
86 | +data into an object expecting header+data, corrupting it. |
87 | + |
88 | +One way to solve this problem would be removing the header fields from |
89 | +the SPMI table template, and adjusting the code appropriately. Another is |
90 | +to stop treating header and non-header data differently here, storing |
91 | +them both in table_data. That is the approach I've taken here. It also |
92 | +cleans up a layering issue where ipmi_locate_acpi_spmi_get_device_info |
93 | +was creating and passing the obj_acpi_table_hdr variable down to lower |
94 | +levels to use, while not having any use for the variable itself. |
95 | +--- |
96 | + ChangeLog | 6 ++++ |
97 | + libfreeipmi/locate/ipmi-locate-acpi-spmi.c | 35 ++++------------------ |
98 | + 2 files changed, 11 insertions(+), 30 deletions(-) |
99 | + |
100 | +diff --git a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
101 | +index 9593943e5..6d4ca3e6c 100644 |
102 | +--- a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
103 | ++++ b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
104 | +@@ -596,12 +596,10 @@ static int _ipmi_acpi_get_table (ipmi_locate_ctx_t ctx, |
105 | + static int _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
106 | + char *signature, |
107 | + unsigned int table_instance, |
108 | +- fiid_obj_t obj_acpi_table_hdr, |
109 | + uint8_t **sign_table_data, |
110 | + uint32_t *sign_table_data_length); |
111 | + static int _ipmi_acpi_get_spmi_table (ipmi_locate_ctx_t ctx, |
112 | + uint8_t interface_type, |
113 | +- fiid_obj_t obj_acpi_table_hdr, |
114 | + fiid_obj_t obj_acpi_spmi_table_descriptor); |
115 | + |
116 | + #define IPMI_INTERFACE_COUNT 5 |
117 | +@@ -1138,14 +1136,12 @@ _ipmi_acpi_get_table (ipmi_locate_ctx_t ctx, |
118 | + * PARAMETERS: |
119 | + * signature - ACPI signature for firmware table header |
120 | + * table_instance - Which instance of the firmware table |
121 | +- * obj_acpi_table_hdr - Initialized ACPI table header |
122 | + * sign_table_data - Initialized with malloc'ed ACPI firmware table data |
123 | + * sign_table_data_length - ACPI table DATA length |
124 | + * |
125 | + * RETURN: |
126 | + * return (0) for success. ACPI table header and firmware table DATA are |
127 | +- * returned through obj_acpi_table_hdr and signed_table_data |
128 | +- * parameters. |
129 | ++ * returned through the signed_table_data parameter. |
130 | + * |
131 | + * DESCRIPTION: |
132 | + * Top level call for any ACPI firmware table by table signature string. |
133 | +@@ -1156,7 +1152,6 @@ static int |
134 | + _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
135 | + char *signature, |
136 | + unsigned int table_instance, |
137 | +- fiid_obj_t obj_acpi_table_hdr, |
138 | + uint8_t **sign_table_data, |
139 | + uint32_t *sign_table_data_length) |
140 | + { |
141 | +@@ -1197,10 +1192,8 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
142 | + assert (ctx); |
143 | + assert (ctx->magic == IPMI_LOCATE_CTX_MAGIC); |
144 | + assert (signature); |
145 | +- assert (fiid_obj_valid (obj_acpi_table_hdr)); |
146 | + assert (sign_table_data); |
147 | + assert (sign_table_data_length); |
148 | +- assert (fiid_obj_template_compare (obj_acpi_table_hdr, tmpl_acpi_table_hdr) == 1); |
149 | + |
150 | + *sign_table_data = NULL; |
151 | + |
152 | +@@ -1345,16 +1338,13 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
153 | + goto cleanup; |
154 | + } |
155 | + |
156 | +- memcpy (obj_acpi_table_hdr, acpi_table, acpi_table_hdr_length); |
157 | +- *sign_table_data_length = acpi_table_length - acpi_table_hdr_length; |
158 | ++ *sign_table_data_length = acpi_table_length; |
159 | + if (!(*sign_table_data = malloc (*sign_table_data_length))) |
160 | + { |
161 | + LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_OUT_OF_MEMORY); |
162 | + goto cleanup; |
163 | + } |
164 | +- memcpy (*sign_table_data, |
165 | +- (acpi_table + acpi_table_hdr_length), |
166 | +- *sign_table_data_length); |
167 | ++ memcpy (*sign_table_data, acpi_table, *sign_table_data_length); |
168 | + |
169 | + rv = 0; |
170 | + cleanup: |
171 | +@@ -1372,13 +1362,11 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
172 | + * |
173 | + * PARAMETERS: |
174 | + * interface_type - Type of interface to look for (KCS, SSIF, SMIC, BT) |
175 | +- * obj_acpi_table_hdr - Initialized ACPI table header |
176 | + * acpi_table_firmware - Initialized ACPI firmware table |
177 | + * |
178 | + * RETURN: |
179 | +- * return (0) for success. ACPI table header and SPMI table is |
180 | +- * returned through obj_acpi_table_hdr and obj_acpi_spmi_table_descriptor |
181 | +- * parameters. |
182 | ++ * return (0) for success. ACPI SPMI table (including header) is |
183 | ++ * returned through the obj_acpi_spmi_table_descriptor parameter. |
184 | + * |
185 | + * DESCRIPTION: |
186 | + * Get SPMI table for the given interface type. |
187 | +@@ -1387,7 +1375,6 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
188 | + static int |
189 | + _ipmi_acpi_get_spmi_table (ipmi_locate_ctx_t ctx, |
190 | + uint8_t interface_type, |
191 | +- fiid_obj_t obj_acpi_table_hdr, |
192 | + fiid_obj_t obj_acpi_spmi_table_descriptor) |
193 | + { |
194 | + uint64_t val; |
195 | +@@ -1401,9 +1388,7 @@ _ipmi_acpi_get_spmi_table (ipmi_locate_ctx_t ctx, |
196 | + |
197 | + assert (ctx); |
198 | + assert (ctx->magic == IPMI_LOCATE_CTX_MAGIC); |
199 | +- assert (fiid_obj_valid (obj_acpi_table_hdr)); |
200 | + assert (fiid_obj_valid (obj_acpi_spmi_table_descriptor)); |
201 | +- assert (fiid_obj_template_compare (obj_acpi_table_hdr, tmpl_acpi_table_hdr) == 1); |
202 | + assert (fiid_obj_template_compare (obj_acpi_spmi_table_descriptor, tmpl_acpi_spmi_table_descriptor) == 1); |
203 | + |
204 | + for (instance = 0; instance < IPMI_INTERFACE_COUNT; instance++) |
205 | +@@ -1411,7 +1396,6 @@ _ipmi_acpi_get_spmi_table (ipmi_locate_ctx_t ctx, |
206 | + if (_ipmi_acpi_get_firmware_table (ctx, |
207 | + IPMI_ACPI_SPMI_SIG, |
208 | + instance, |
209 | +- obj_acpi_table_hdr, |
210 | + &table_data, |
211 | + &table_data_length) < 0) |
212 | + continue; |
213 | +@@ -1477,7 +1461,6 @@ ipmi_locate_acpi_spmi_get_device_info (ipmi_locate_ctx_t ctx, |
214 | + ipmi_interface_type_t type, |
215 | + struct ipmi_locate_info *info) |
216 | + { |
217 | +- fiid_obj_t obj_acpi_table_hdr = NULL; |
218 | + fiid_obj_t obj_acpi_spmi_table_descriptor = NULL; |
219 | + struct ipmi_locate_info linfo; |
220 | + uint64_t val; |
221 | +@@ -1507,12 +1490,6 @@ ipmi_locate_acpi_spmi_get_device_info (ipmi_locate_ctx_t ctx, |
222 | + } |
223 | + linfo.locate_driver_type = IPMI_LOCATE_DRIVER_ACPI; |
224 | + |
225 | +- if (!(obj_acpi_table_hdr = fiid_obj_create (tmpl_acpi_table_hdr))) |
226 | +- { |
227 | +- LOCATE_ERRNO_TO_LOCATE_ERRNUM (ctx, errno); |
228 | +- goto cleanup; |
229 | +- } |
230 | +- |
231 | + if (!(obj_acpi_spmi_table_descriptor = fiid_obj_create (tmpl_acpi_spmi_table_descriptor))) |
232 | + { |
233 | + LOCATE_ERRNO_TO_LOCATE_ERRNUM (ctx, errno); |
234 | +@@ -1521,7 +1498,6 @@ ipmi_locate_acpi_spmi_get_device_info (ipmi_locate_ctx_t ctx, |
235 | + |
236 | + if (_ipmi_acpi_get_spmi_table (ctx, |
237 | + type, |
238 | +- obj_acpi_table_hdr, |
239 | + obj_acpi_spmi_table_descriptor) < 0) |
240 | + goto cleanup; |
241 | + |
242 | +@@ -1666,7 +1642,6 @@ ipmi_locate_acpi_spmi_get_device_info (ipmi_locate_ctx_t ctx, |
243 | + memcpy (info, &linfo, sizeof (struct ipmi_locate_info)); |
244 | + rv = 0; |
245 | + cleanup: |
246 | +- fiid_obj_destroy (obj_acpi_table_hdr); |
247 | + fiid_obj_destroy (obj_acpi_spmi_table_descriptor); |
248 | + return (rv); |
249 | + #endif /* defined(__arm__) || defined(__aarch64__) */ |
250 | +-- |
251 | +2.18.0 |
252 | + |
253 | diff --git a/debian/patches/0003-Split-RSDT-XSDT-parsing-into-new-function.patch b/debian/patches/0003-Split-RSDT-XSDT-parsing-into-new-function.patch |
254 | new file mode 100644 |
255 | index 0000000..45e8a2c |
256 | --- /dev/null |
257 | +++ b/debian/patches/0003-Split-RSDT-XSDT-parsing-into-new-function.patch |
258 | @@ -0,0 +1,189 @@ |
259 | +From 184c746494c332c57deab661da1e949b5fc286a7 Mon Sep 17 00:00:00 2001 |
260 | +From: dann frazier <dann.frazier@canonical.com> |
261 | +Date: Wed, 1 Aug 2018 11:01:09 -0600 |
262 | +Subject: [PATCH 3/6] Split RSDT/XSDT parsing into new function |
263 | + |
264 | +In preparation for adding a new ACPI table retrieval method, split the |
265 | +existing code that retrieves tables out of /dev/mem into a new function. |
266 | +No functional change intended. |
267 | +--- |
268 | + libfreeipmi/locate/ipmi-locate-acpi-spmi.c | 109 +++++++++++++++++---- |
269 | + 1 file changed, 88 insertions(+), 21 deletions(-) |
270 | + |
271 | +diff --git a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
272 | +index 6d4ca3e6c..4eb5adae7 100644 |
273 | +--- a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
274 | ++++ b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
275 | +@@ -593,6 +593,11 @@ static int _ipmi_acpi_get_table (ipmi_locate_ctx_t ctx, |
276 | + char *signature, |
277 | + uint8_t **acpi_table, |
278 | + uint32_t *acpi_table_length); |
279 | ++static int _ipmi_acpi_get_table_dev_mem (ipmi_locate_ctx_t ctx, |
280 | ++ char *signature, |
281 | ++ unsigned int table_instance, |
282 | ++ uint8_t **acpi_table, |
283 | ++ uint32_t *acpi_table_length); |
284 | + static int _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
285 | + char *signature, |
286 | + unsigned int table_instance, |
287 | +@@ -1131,16 +1136,16 @@ _ipmi_acpi_get_table (ipmi_locate_ctx_t ctx, |
288 | + /******************************************************************************* |
289 | + * |
290 | + * FUNCTION: |
291 | +- * _ipmi_acpi_get_firmware_table |
292 | ++ * _ipmi_acpi_get_firmware_table_dev_mem |
293 | + * |
294 | + * PARAMETERS: |
295 | +- * signature - ACPI signature for firmware table header |
296 | +- * table_instance - Which instance of the firmware table |
297 | +- * sign_table_data - Initialized with malloc'ed ACPI firmware table data |
298 | +- * sign_table_data_length - ACPI table DATA length |
299 | ++ * signature - ACPI signature for firmware table header |
300 | ++ * table_instance - Which instance of the firmware table |
301 | ++ * acpi_table - Initialized with malloc'ed ACPI firmware table data |
302 | ++ * acpi_table_length - ACPI table DATA length |
303 | + * |
304 | + * RETURN: |
305 | +- * return (0) for success. ACPI table header and firmware table DATA are |
306 | ++ * return (0) for success. ACPI table (including header) is |
307 | + * returned through the signed_table_data parameter. |
308 | + * |
309 | + * DESCRIPTION: |
310 | +@@ -1149,11 +1154,11 @@ _ipmi_acpi_get_table (ipmi_locate_ctx_t ctx, |
311 | + * |
312 | + ******************************************************************************/ |
313 | + static int |
314 | +-_ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
315 | +- char *signature, |
316 | +- unsigned int table_instance, |
317 | +- uint8_t **sign_table_data, |
318 | +- uint32_t *sign_table_data_length) |
319 | ++_ipmi_acpi_get_table_dev_mem (ipmi_locate_ctx_t ctx, |
320 | ++ char *signature, |
321 | ++ unsigned int table_instance, |
322 | ++ uint8_t **acpi_table, |
323 | ++ uint32_t *acpi_table_length) |
324 | + { |
325 | + uint64_t val; |
326 | + |
327 | +@@ -1170,8 +1175,6 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
328 | + uint8_t *rsdt_xsdt_table_data; |
329 | + uint32_t rsdt_xsdt_table_data_length; |
330 | + unsigned int acpi_table_count; |
331 | +- uint8_t *acpi_table = NULL; |
332 | +- uint32_t acpi_table_length; |
333 | + |
334 | + fiid_obj_t obj_table = NULL; |
335 | + uint64_t table_address; |
336 | +@@ -1192,10 +1195,10 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
337 | + assert (ctx); |
338 | + assert (ctx->magic == IPMI_LOCATE_CTX_MAGIC); |
339 | + assert (signature); |
340 | +- assert (sign_table_data); |
341 | +- assert (sign_table_data_length); |
342 | ++ assert (acpi_table); |
343 | ++ assert (acpi_table_length); |
344 | + |
345 | +- *sign_table_data = NULL; |
346 | ++ *acpi_table = NULL; |
347 | + |
348 | + if ((acpi_table_hdr_length = fiid_template_len_bytes (tmpl_acpi_table_hdr)) < 0) |
349 | + { |
350 | +@@ -1319,8 +1322,8 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
351 | + if (_ipmi_acpi_get_table (ctx, |
352 | + table_address, |
353 | + signature, |
354 | +- &acpi_table, |
355 | +- &acpi_table_length) < 0) |
356 | ++ acpi_table, |
357 | ++ acpi_table_length) < 0) |
358 | + continue; |
359 | + |
360 | + signature_table_count++; |
361 | +@@ -1338,6 +1341,73 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
362 | + goto cleanup; |
363 | + } |
364 | + |
365 | ++ rv = 0; |
366 | ++ cleanup: |
367 | ++ free (rsdt_xsdt_table); |
368 | ++ fiid_obj_destroy (obj_table); |
369 | ++ fiid_obj_destroy (obj_acpi_rsdp_descriptor); |
370 | ++ return (rv); |
371 | ++} |
372 | ++ |
373 | ++/******************************************************************************* |
374 | ++ * |
375 | ++ * FUNCTION: |
376 | ++ * _ipmi_acpi_get_firmware_table |
377 | ++ * |
378 | ++ * PARAMETERS: |
379 | ++ * signature - ACPI signature for firmware table header |
380 | ++ * table_instance - Which instance of the firmware table |
381 | ++ * sign_table_data - Initialized with malloc'ed ACPI firmware table data |
382 | ++ * sign_table_data_length - ACPI table DATA length |
383 | ++ * |
384 | ++ * RETURN: |
385 | ++ * return (0) for success. ACPI table (including header) is returned |
386 | ++ * through the signed_table_data parameter. |
387 | ++ * |
388 | ++ * DESCRIPTION: |
389 | ++ * Top level call for any ACPI firmware table by table signature string. |
390 | ++ * |
391 | ++ ******************************************************************************/ |
392 | ++static int |
393 | ++_ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
394 | ++ char *signature, |
395 | ++ unsigned int table_instance, |
396 | ++ uint8_t **sign_table_data, |
397 | ++ uint32_t *sign_table_data_length) |
398 | ++{ |
399 | ++ uint64_t val; |
400 | ++ |
401 | ++ int acpi_table_hdr_length; |
402 | ++ int acpi_rsdp_descriptor_length; |
403 | ++ |
404 | ++ uint8_t *acpi_table = NULL; |
405 | ++ uint32_t acpi_table_length; |
406 | ++ |
407 | ++ int rv = -1; |
408 | ++ |
409 | ++ assert (ctx); |
410 | ++ assert (ctx->magic == IPMI_LOCATE_CTX_MAGIC); |
411 | ++ assert (signature); |
412 | ++ assert (sign_table_data); |
413 | ++ assert (sign_table_data_length); |
414 | ++ |
415 | ++ *sign_table_data = NULL; |
416 | ++ |
417 | ++ if ((_ipmi_acpi_get_table_dev_mem (ctx, signature, |
418 | ++ table_instance, |
419 | ++ &acpi_table, |
420 | ++ &acpi_table_length) != 0)) |
421 | ++ { |
422 | ++ LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_SYSTEM_ERROR); |
423 | ++ goto cleanup; |
424 | ++ } |
425 | ++ |
426 | ++ if (!acpi_table) |
427 | ++ { |
428 | ++ LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_SYSTEM_ERROR); |
429 | ++ goto cleanup; |
430 | ++ } |
431 | ++ |
432 | + *sign_table_data_length = acpi_table_length; |
433 | + if (!(*sign_table_data = malloc (*sign_table_data_length))) |
434 | + { |
435 | +@@ -1349,9 +1419,6 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
436 | + rv = 0; |
437 | + cleanup: |
438 | + free (acpi_table); |
439 | +- free (rsdt_xsdt_table); |
440 | +- fiid_obj_destroy (obj_table); |
441 | +- fiid_obj_destroy (obj_acpi_rsdp_descriptor); |
442 | + return (rv); |
443 | + } |
444 | + |
445 | +-- |
446 | +2.18.0 |
447 | + |
448 | diff --git a/debian/patches/0004-Add-support-for-parsing-SPMI-tables-exposed-via-sysf.patch b/debian/patches/0004-Add-support-for-parsing-SPMI-tables-exposed-via-sysf.patch |
449 | new file mode 100644 |
450 | index 0000000..758f4e4 |
451 | --- /dev/null |
452 | +++ b/debian/patches/0004-Add-support-for-parsing-SPMI-tables-exposed-via-sysf.patch |
453 | @@ -0,0 +1,159 @@ |
454 | +From 158a901d74bec24b4c1c9f6737f975dd27c7eef2 Mon Sep 17 00:00:00 2001 |
455 | +From: dann frazier <dann.frazier@canonical.com> |
456 | +Date: Wed, 1 Aug 2018 11:01:10 -0600 |
457 | +Subject: [PATCH 4/6] Add support for parsing SPMI tables exposed via sysfs |
458 | + |
459 | +Since 2.6.22 (released in 2007), the Linux kernel has exposed individual |
460 | +ACPI tables under /sys/firmware/acpi/tables. When available, we can parse |
461 | +these files instead of poking around in /dev/mem, which is more portable. |
462 | +Keep the /dev/mem parsing code as a fallback for older Linux kernels. |
463 | +--- |
464 | + ChangeLog | 3 + |
465 | + libfreeipmi/locate/ipmi-locate-acpi-spmi.c | 116 ++++++++++++++++++++- |
466 | + 2 files changed, 114 insertions(+), 5 deletions(-) |
467 | + |
468 | +diff --git a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
469 | +index 4eb5adae7..503d4528e 100644 |
470 | +--- a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
471 | ++++ b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
472 | +@@ -598,6 +598,11 @@ static int _ipmi_acpi_get_table_dev_mem (ipmi_locate_ctx_t ctx, |
473 | + unsigned int table_instance, |
474 | + uint8_t **acpi_table, |
475 | + uint32_t *acpi_table_length); |
476 | ++static int _ipmi_acpi_get_table_sysfs (ipmi_locate_ctx_t ctx, |
477 | ++ char *signature, |
478 | ++ unsigned int table_instance, |
479 | ++ uint8_t **acpi_table, |
480 | ++ uint32_t *acpi_table_length); |
481 | + static int _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
482 | + char *signature, |
483 | + unsigned int table_instance, |
484 | +@@ -1133,6 +1138,105 @@ _ipmi_acpi_get_table (ipmi_locate_ctx_t ctx, |
485 | + return (rv); |
486 | + } |
487 | + |
488 | ++/******************************************************************************* |
489 | ++ * |
490 | ++ * FUNCTION: |
491 | ++ * _ipmi_acpi_get_table_sysfs |
492 | ++ * |
493 | ++ * PARAMETERS: |
494 | ++ * signature - signature of the table |
495 | ++ * table_instance - Which instance of the firmware table |
496 | ++ * acpi_table - ACPI table in malloc'ed memory |
497 | ++ * acpi_table_length - ACPI table length |
498 | ++ * |
499 | ++ * RETURN: |
500 | ++ * A return value of 0 means success. ACPI table (including header) is |
501 | ++ * returned through acpi_table parameter. |
502 | ++ * |
503 | ++ * DESCRIPTION: |
504 | ++ * Retrieve any ACPI table (including header) from sysfs. |
505 | ++ * |
506 | ++ ******************************************************************************/ |
507 | ++static int |
508 | ++_ipmi_acpi_get_table_sysfs (ipmi_locate_ctx_t ctx, |
509 | ++ char *signature, |
510 | ++ unsigned int table_instance, |
511 | ++ uint8_t **acpi_table, |
512 | ++ uint32_t *acpi_table_length) |
513 | ++{ |
514 | ++ int sysfs_acpi_fd = -1; |
515 | ++ int rv = -1; |
516 | ++ static char const sysfs_fw_acpi_tables[] = "/sys/firmware/acpi/tables"; |
517 | ++ char *sysfs_path; |
518 | ++ int instance_length; |
519 | ++ int sysfs_path_length; |
520 | ++ uint8_t *acpi_table_buf = NULL; |
521 | ++ |
522 | ++ assert (ctx); |
523 | ++ assert (ctx->magic == IPMI_LOCATE_CTX_MAGIC); |
524 | ++ assert (signature); |
525 | ++ assert (table_instance >= 0); |
526 | ++ assert (acpi_table); |
527 | ++ assert (acpi_table_length); |
528 | ++ |
529 | ++ *acpi_table = NULL; |
530 | ++ |
531 | ++ instance_length = (table_instance + 1) / 10 + 1; |
532 | ++ sysfs_path_length = strlen (sysfs_fw_acpi_tables) + strlen(signature) + \ |
533 | ++ instance_length + 2; |
534 | ++ |
535 | ++ if (!(sysfs_path = malloc (sysfs_path_length))) |
536 | ++ { |
537 | ++ LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_OUT_OF_MEMORY); |
538 | ++ return (-1); |
539 | ++ } |
540 | ++ |
541 | ++ snprintf (sysfs_path, sysfs_path_length, "%s/%s%d", |
542 | ++ sysfs_fw_acpi_tables, signature, table_instance + 1); |
543 | ++ if ((sysfs_acpi_fd = open (sysfs_path, O_RDONLY)) < 0) |
544 | ++ { |
545 | ++ if (table_instance > 0) |
546 | ++ goto cleanup; |
547 | ++ /* If there is only 1 instance of a table on the system, the sysfs |
548 | ++ file will be the same as the signature, (e.g. |
549 | ++ /sys/firmware/acpi/tables/SPMI). If there are multiple instances |
550 | ++ of the same table, they will have the instance # as a suffix (e.g.: |
551 | ++ /sys/firmware/acpi/tables/SPMI1 & /sys/firmware/acpi/tables/SPMI2). |
552 | ++ So, for table_instance == 0, we need to try both */ |
553 | ++ snprintf (sysfs_path, sysfs_path_length, "%s/%s", |
554 | ++ sysfs_fw_acpi_tables, signature); |
555 | ++ if ((sysfs_acpi_fd = open (sysfs_path, O_RDONLY)) < 0) |
556 | ++ goto cleanup; |
557 | ++ } |
558 | ++ if ((*acpi_table_length = lseek (sysfs_acpi_fd, 0, SEEK_END)) == -1) |
559 | ++ { |
560 | ++ LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_SYSTEM_ERROR); |
561 | ++ goto cleanup; |
562 | ++ } |
563 | ++ if ((lseek (sysfs_acpi_fd, 0, SEEK_SET)) == -1) |
564 | ++ { |
565 | ++ LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_SYSTEM_ERROR); |
566 | ++ goto cleanup; |
567 | ++ } |
568 | ++ if (!(acpi_table_buf = malloc (*acpi_table_length))) |
569 | ++ { |
570 | ++ LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_OUT_OF_MEMORY); |
571 | ++ goto cleanup; |
572 | ++ } |
573 | ++ if ((read (sysfs_acpi_fd, acpi_table_buf, *acpi_table_length)) != |
574 | ++ *acpi_table_length) |
575 | ++ { |
576 | ++ LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_SYSTEM_ERROR); |
577 | ++ goto cleanup; |
578 | ++ } |
579 | ++ |
580 | ++ *acpi_table = acpi_table_buf; |
581 | ++ rv = 0; |
582 | ++ cleanup: |
583 | ++ close (sysfs_acpi_fd); |
584 | ++ return rv; |
585 | ++} |
586 | ++ |
587 | + /******************************************************************************* |
588 | + * |
589 | + * FUNCTION: |
590 | +@@ -1393,12 +1497,14 @@ _ipmi_acpi_get_firmware_table (ipmi_locate_ctx_t ctx, |
591 | + |
592 | + *sign_table_data = NULL; |
593 | + |
594 | +- if ((_ipmi_acpi_get_table_dev_mem (ctx, signature, |
595 | +- table_instance, |
596 | +- &acpi_table, |
597 | +- &acpi_table_length) != 0)) |
598 | ++ if ((_ipmi_acpi_get_table_sysfs (ctx, signature, table_instance, |
599 | ++ &acpi_table, &acpi_table_length) != 0)) |
600 | + { |
601 | +- LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_SYSTEM_ERROR); |
602 | ++ if ((_ipmi_acpi_get_table_dev_mem (ctx, signature, |
603 | ++ table_instance, |
604 | ++ &acpi_table, |
605 | ++ &acpi_table_length) != 0)) |
606 | ++ LOCATE_SET_ERRNUM (ctx, IPMI_LOCATE_ERR_SYSTEM_ERROR); |
607 | + goto cleanup; |
608 | + } |
609 | + |
610 | +-- |
611 | +2.18.0 |
612 | + |
613 | diff --git a/debian/patches/0005-Allow-sysfs-SPMI-parsing-on-ARM-platforms.patch b/debian/patches/0005-Allow-sysfs-SPMI-parsing-on-ARM-platforms.patch |
614 | new file mode 100644 |
615 | index 0000000..aadee84 |
616 | --- /dev/null |
617 | +++ b/debian/patches/0005-Allow-sysfs-SPMI-parsing-on-ARM-platforms.patch |
618 | @@ -0,0 +1,47 @@ |
619 | +From d928881287efb663a899f37364491facbd5615ed Mon Sep 17 00:00:00 2001 |
620 | +From: dann frazier <dann.frazier@canonical.com> |
621 | +Date: Wed, 1 Aug 2018 11:01:11 -0600 |
622 | +Subject: [PATCH 5/6] Allow sysfs SPMI parsing on ARM platforms |
623 | + |
624 | +SPMI parsing has been disabled on ARM because it relied on unsafe |
625 | +trolling through /dev/mem to find ACPI tables. Now that we support |
626 | +using the sysfs interface, it is safe to enable everywhere. Keep |
627 | +the fallback /dev/mem disabled on ARM though. |
628 | +--- |
629 | + ChangeLog | 3 +++ |
630 | + libfreeipmi/locate/ipmi-locate-acpi-spmi.c | 7 +++---- |
631 | + 2 files changed, 6 insertions(+), 4 deletions(-) |
632 | + |
633 | +diff --git a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
634 | +index 503d4528e..a89b16af6 100644 |
635 | +--- a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
636 | ++++ b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
637 | +@@ -1296,6 +1296,9 @@ _ipmi_acpi_get_table_dev_mem (ipmi_locate_ctx_t ctx, |
638 | + { 0, "", 0} |
639 | + }; |
640 | + |
641 | ++#if defined(__arm__) || defined (__aarch64__) |
642 | ++ return (-1); |
643 | ++#endif |
644 | + assert (ctx); |
645 | + assert (ctx->magic == IPMI_LOCATE_CTX_MAGIC); |
646 | + assert (signature); |
647 | +@@ -1639,9 +1642,6 @@ ipmi_locate_acpi_spmi_get_device_info (ipmi_locate_ctx_t ctx, |
648 | + uint64_t val; |
649 | + int rv = -1; |
650 | + |
651 | +-#if defined(__arm__) || defined(__aarch64__) |
652 | +- return (-1); |
653 | +-#else |
654 | + if (!ctx || ctx->magic != IPMI_LOCATE_CTX_MAGIC) |
655 | + { |
656 | + ERR_TRACE (ipmi_locate_ctx_errormsg (ctx), ipmi_locate_ctx_errnum (ctx)); |
657 | +@@ -1817,5 +1817,4 @@ ipmi_locate_acpi_spmi_get_device_info (ipmi_locate_ctx_t ctx, |
658 | + cleanup: |
659 | + fiid_obj_destroy (obj_acpi_spmi_table_descriptor); |
660 | + return (rv); |
661 | +-#endif /* defined(__arm__) || defined(__aarch64__) */ |
662 | + } |
663 | +-- |
664 | +2.18.0 |
665 | + |
666 | diff --git a/debian/patches/0006-Correct-order-of-bytes-in-specification_revision-fie.patch b/debian/patches/0006-Correct-order-of-bytes-in-specification_revision-fie.patch |
667 | new file mode 100644 |
668 | index 0000000..ff8b065 |
669 | --- /dev/null |
670 | +++ b/debian/patches/0006-Correct-order-of-bytes-in-specification_revision-fie.patch |
671 | @@ -0,0 +1,64 @@ |
672 | +From 40ba578f898ccaeaea0488a408d63749dd979dc2 Mon Sep 17 00:00:00 2001 |
673 | +From: dann frazier <dann.frazier@canonical.com> |
674 | +Date: Wed, 1 Aug 2018 11:01:12 -0600 |
675 | +Subject: [PATCH 6/6] Correct order of bytes in specification_revision field of |
676 | + ACPI SPMI table |
677 | + |
678 | +According to section C3-1 in the IPMI specification, the |
679 | +"Specification Revision (version)" field consistes of 2 bytes that: |
680 | + |
681 | +"Identifies the IPMI specification revision, in BCD format, to which the |
682 | +interface was designed. The first byte holds the most significant digits |
683 | +of the revision, e.g., a a value of 0x0150 indicates the interface is |
684 | +compatible with IPMI version v1.5." |
685 | + |
686 | +Based on that reading alone, the current template looks correct. However, |
687 | +earlier in the same section we have the text: |
688 | + |
689 | +"Per [ACPI 2.0], unless otherwise specified, numeric values for the table |
690 | +or structures are always encoded in little endian format." |
691 | + |
692 | +It isn't clear to me if this was intended to apply to the "Specification |
693 | +Revision" field or not. I mean, they are numeric values - but does the |
694 | +text "in BCD format" and "The first byte holds the most significant digits" |
695 | +trigger the "unless otherwise specified" exception? |
696 | + |
697 | +Luckily, a sample of several BIOS's suggests vendors have implemented this |
698 | +consistently, using little endian format: |
699 | + |
700 | ++-------------------------------------------------------------------+ |
701 | +| System | IPMI Ver (SMBIOS) | ACPI Spec Rev Bytes | |
702 | +| HiSilicon D06 | N/A | 00 02 | |
703 | +| HP ProLiant DL165 G7[*] | 1.5 | 00 01 | |
704 | +| HP ProLiant DL385 G7 | 2.0 | 00 02 | |
705 | +| QuantaGrid D52B | 2.0 | 00 02 | |
706 | +| Supermicro Super Server | 2.0 | 00 02 | |
707 | ++-------------------------------------------------------------------+ |
708 | +[*] Clearly the SMBIOS and ACPI data here are inconsistent but, IMO, |
709 | +"1.0" seems to be more likely the intent, vs. 0.1. |
710 | + |
711 | +Without this change, ipmi-locate will report specifications of 0.1 and |
712 | +0.2 instead of 1.0 and 2.0 on the sampled systems (all parsing done |
713 | +via sysfs). |
714 | +--- |
715 | + ChangeLog | 3 +++ |
716 | + libfreeipmi/locate/ipmi-locate-acpi-spmi.c | 2 +- |
717 | + 2 files changed, 4 insertions(+), 1 deletion(-) |
718 | + |
719 | +diff --git a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
720 | +index a89b16af6..b104869b1 100644 |
721 | +--- a/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
722 | ++++ b/libfreeipmi/locate/ipmi-locate-acpi-spmi.c |
723 | +@@ -184,8 +184,8 @@ fiid_template_t tmpl_acpi_spmi_table_descriptor = |
724 | + e.g. a value of 0x0150 indicates the interface is |
725 | + compatible with IPMI version v1.5. */ |
726 | + /* {16, "specification_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, */ |
727 | +- { 8, "specification_revision.major", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, |
728 | + { 8, "specification_revision.minor", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, |
729 | ++ { 8, "specification_revision.major", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, |
730 | + /* Interrupt type(s) used by |
731 | + the interface: |
732 | + [0] - SCI triggered through GPE |
733 | +-- |
734 | +2.18.0 |
735 | + |
736 | diff --git a/debian/patches/series b/debian/patches/series |
737 | index b7b4f52..817e8fa 100644 |
738 | --- a/debian/patches/series |
739 | +++ b/debian/patches/series |
740 | @@ -2,3 +2,9 @@ deb_bmc-watchdog_noRUN |
741 | dso-linking.patch |
742 | ipv6-ipmipower |
743 | ipv6-ipmi-discovery |
744 | +0001-Fix-acpi-spmi-searching-corner-case.patch |
745 | +0002-Don-t-try-to-separate-the-header-from-the-ACPI-table.patch |
746 | +0003-Split-RSDT-XSDT-parsing-into-new-function.patch |
747 | +0004-Add-support-for-parsing-SPMI-tables-exposed-via-sysf.patch |
748 | +0005-Allow-sysfs-SPMI-parsing-on-ARM-platforms.patch |
749 | +0006-Correct-order-of-bytes-in-specification_revision-fie.patch |