Author: rlibby
Date: Fri Jul  7 06:37:19 2017
New Revision: 320764
URL: https://svnweb.freebsd.org/changeset/base/320764

Log:
  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

Modified:
  head/sys/amd64/vmm/amd/amdvi_hw.c
  head/sys/amd64/vmm/amd/amdvi_priv.h
  head/sys/amd64/vmm/amd/ivrs_drv.c

Modified: head/sys/amd64/vmm/amd/amdvi_hw.c
==============================================================================
--- head/sys/amd64/vmm/amd/amdvi_hw.c   Fri Jul  7 06:29:18 2017        
(r320763)
+++ head/sys/amd64/vmm/amd/amdvi_hw.c   Fri Jul  7 06:37:19 2017        
(r320764)
@@ -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

Modified: head/sys/amd64/vmm/amd/amdvi_priv.h
==============================================================================
--- head/sys/amd64/vmm/amd/amdvi_priv.h Fri Jul  7 06:29:18 2017        
(r320763)
+++ head/sys/amd64/vmm/amd/amdvi_priv.h Fri Jul  7 06:37:19 2017        
(r320764)
@@ -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] */

Modified: head/sys/amd64/vmm/amd/ivrs_drv.c
==============================================================================
--- head/sys/amd64/vmm/amd/ivrs_drv.c   Fri Jul  7 06:29:18 2017        
(r320763)
+++ head/sys/amd64/vmm/amd/ivrs_drv.c   Fri Jul  7 06:37:19 2017        
(r320764)
@@ -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;
-               }
        }
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to