amd-vi: gcc build errors

amdvi_cmp_wait: gcc complained about a malformed string behind an ifdef.

struct amdvi_dte: widen the type of the first reserved bitfield so that
the packed representation would not cross an alignment boundary for that
type. Apparently that causes in-tree gcc (4.2) to insert padding
(despite packed, resulting in a wrong structure definition), and causes
more modern gcc to emit a warning.

ivrs_hdr_iterate_tbl: delete a misleading check about header length
being less than 0 (the type is unsigned) and replace it with a check
that the length doesn't exceed the table size.

Reviewed by:	anish, grehan
Approved by:	markj (mentor)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D11485
This commit is contained in:
Ryan Libby 2017-07-07 06:37:19 +00:00
parent e967aa2682
commit 5228ad10d4
3 changed files with 8 additions and 6 deletions

View File

@ -496,7 +496,7 @@ amdvi_cmp_wait(struct amdvi_softc *softc)
#ifdef AMDVI_DEBUG_CMD
if (status)
device_printf(softc->dev, "CMD completion DONE Tail:0x%x,
device_printf(softc->dev, "CMD completion DONE Tail:0x%x, "
"Head:0x%x, loop:%d.\n", ctrl->cmd_tail,
ctrl->cmd_head, loop);
#endif

View File

@ -65,7 +65,7 @@
struct amdvi_dte {
uint32_t dt_valid:1; /* Device Table valid. */
uint32_t pt_valid:1; /* Page translation valid. */
uint8_t :7; /* Reserved[8:2] */
uint16_t :7; /* Reserved[8:2] */
uint8_t pt_level:3; /* Paging level, 0 to disable. */
uint64_t pt_base:40; /* Page table root pointer. */
uint8_t :3; /* Reserved[54:52] */

View File

@ -75,6 +75,12 @@ ivrs_hdr_iterate_tbl(ivhd_iter_t iter, void *arg)
end = (ACPI_IVRS_HEADER *)((char *)ivrs + ivrs->Header.Length);
while (ivrs_hdr < end) {
if ((uint8_t *)ivrs_hdr + ivrs_hdr->Length > (uint8_t *)end) {
printf("AMD-Vi:IVHD/IVMD is corrupted, length : %d\n",
ivrs_hdr->Length);
break;
}
switch (ivrs_hdr->Type) {
case ACPI_IVRS_TYPE_HARDWARE: /* Legacy */
case 0x11:
@ -98,10 +104,6 @@ ivrs_hdr_iterate_tbl(ivhd_iter_t iter, void *arg)
ivrs_hdr = (ACPI_IVRS_HEADER *)((uint8_t *)ivrs_hdr +
ivrs_hdr->Length);
if (ivrs_hdr->Length < 0) {
printf("AMD-Vi:IVHD/IVMD is corrupted, length : %d\n", ivrs_hdr->Length);
break;
}
}
}