]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
Modified ACPI/SMBIOS pass-through so failures do not prevent VMs
authorRoss Philipson <ross.philipson@citrix.com>
Mon, 16 Mar 2009 18:54:21 +0000 (14:54 -0400)
committerRoss Philipson <ross.philipson@citrix.com>
Mon, 16 Mar 2009 18:54:21 +0000 (14:54 -0400)
from starting. Added a logging macro.

 Changes to be committed:
modified:   xenguest/acpi_decode.c
modified:   xenguest/smbios_decode.c
modified:   xenguest/xenguest_stubs.c
modified:   xenguest/xenguest_utils.h

xenguest/acpi_decode.c
xenguest/smbios_decode.c
xenguest/xenguest_stubs.c
xenguest/xenguest_utils.h

index 0388e5044c3a6e4da238cc1be6af1578b3f03f93..fe89dc3ce25bd9713f1b157d1bb640c1a2914e50 100644 (file)
@@ -78,7 +78,7 @@ struct acpi_table_info {
 static int process_acpi_rsdp(struct acpi_rsdp_info *rsdpinfo, uint8_t *rsdp)
 {
 #define ADDR_CHECK(a, p) if (a == NULL) { \
-        fprintf(stderr, "%s: failed to map ACPI table at phys="UINT_FMT"\n", ACPI_ERROR, p); \
+        XG_LOG("%s: failed to map ACPI table at phys="UINT_FMT"\n", ACPI_ERROR, p); \
         rc = -1; break;}
     uint8_t cs;
     uint32_t count, length;
@@ -97,7 +97,7 @@ static int process_acpi_rsdp(struct acpi_rsdp_info *rsdpinfo, uint8_t *rsdp)
         for (cs = 0, count = 0; count < length; count++)
             cs += rsdp[count];
         if (cs != 0) {
-            fprintf(stderr, "%s: invalid RSDP checksum\n", ACPI_ERROR);
+            XG_LOG("%s: invalid RSDP checksum\n", ACPI_ERROR);
             rc = -1;
             break;
         }
@@ -111,7 +111,7 @@ static int process_acpi_rsdp(struct acpi_rsdp_info *rsdpinfo, uint8_t *rsdp)
         rsdpinfo->rsdt_addr = addr;
         /* check the signatures for the RSDT */
         if (memcmp(rsdpinfo->rsdt_addr, "RSDT", 4) != 0) {            
-            fprintf(stderr, "%s: invalid RSDT signature=%.*s\n", ACPI_ERROR, 4, rsdpinfo->rsdt_addr);
+            XG_LOG("%s: invalid RSDT signature=%.*s\n", ACPI_ERROR, 4, rsdpinfo->rsdt_addr);
            rc = -1;
             break;
         }
@@ -137,7 +137,7 @@ static int process_acpi_rsdp(struct acpi_rsdp_info *rsdpinfo, uint8_t *rsdp)
         
         /* check the signatures for the XSDT */
         if (memcmp(rsdpinfo->xsdt_addr, "XSDT", 4) != 0) {
-            fprintf(stderr, "%s: invalid XSDT signature=%.*s\n", ACPI_ERROR, 4, rsdpinfo->xsdt_addr);
+            XG_LOG("%s: invalid XSDT signature=%.*s\n", ACPI_ERROR, 4, rsdpinfo->xsdt_addr);
             rc = -1;
             break;
         }
@@ -174,7 +174,7 @@ static int locate_acpi_pointers(struct acpi_rsdp_info *rsdpinfo)
     if ( (rc == 0) && (loc != 0) ) {
         addr = helper_mmap(loc, ACPI_RSDP_LENGTH);
         if (addr == NULL) {
-            fprintf(stderr, "%s: failed to map EFI RSDP at phys="UINT_FMT"\n", ACPI_ERROR, loc);
+            XG_LOG("%s: failed to map EFI RSDP at phys="UINT_FMT"\n", ACPI_ERROR, loc);
             return -1;
         }
         rc = process_acpi_rsdp(rsdpinfo, addr);
@@ -185,7 +185,7 @@ static int locate_acpi_pointers(struct acpi_rsdp_info *rsdpinfo)
     /* locate ACPI entry via memory scan of ROM region */
     addr = helper_mmap(SCAN_ROM_BIOS_BASE, SCAN_ROM_BIOS_SIZE);
     if (addr == NULL) {
-        fprintf(stderr, "%s: failed to map ROM BIOS at phys=%x\n", ACPI_ERROR, SCAN_ROM_BIOS_BASE);
+        XG_LOG("%s: failed to map ROM BIOS at phys=%x\n", ACPI_ERROR, SCAN_ROM_BIOS_BASE);
         return -1;
     }
 
@@ -210,7 +210,7 @@ static int locate_rsdt_acpi_table(struct acpi_rsdp_info *rsdpinfo, const char *s
     uint8_t *addr;
 
     if (rsdpinfo->rsdt_length <= ACPI_TABLE_LENGTH) {
-        fprintf(stderr, "%s: invalid RSDT - no table pointers\n", ACPI_ERROR);
+        XG_LOG("%s: invalid RSDT - no table pointers\n", ACPI_ERROR);
         return -1; /* invalid - no tables?? */
     }
 
@@ -228,7 +228,7 @@ static int locate_rsdt_acpi_table(struct acpi_rsdp_info *rsdpinfo, const char *s
             helper_unmmap(addr, ACPI_HEADER_LENGTH);
             addr = helper_mmap(*addr_list, ti->length);
             if (addr == NULL) {
-                fprintf(stderr, "%s: failed to map table #%d at phys=%x\n", ACPI_ERROR, i, *addr_list);
+                XG_LOG("%s: failed to map table #%d at phys=%x\n", ACPI_ERROR, i, *addr_list);
                 break;
             }
             ti->phys_addr = *addr_list;
@@ -251,7 +251,7 @@ static int locate_xsdt_acpi_table(struct acpi_rsdp_info *rsdpinfo, const char *s
     uint8_t *addr;
 
     if (rsdpinfo->xsdt_length <= ACPI_TABLE_LENGTH) {
-        fprintf(stderr, "%s: invalid XSDT - no table pointers\n", ACPI_ERROR);
+        XG_LOG("%s: invalid XSDT - no table pointers\n", ACPI_ERROR);
         return -1; /* invalid - no tables?? */
     }
 
@@ -269,7 +269,7 @@ static int locate_xsdt_acpi_table(struct acpi_rsdp_info *rsdpinfo, const char *s
             helper_unmmap(addr, ACPI_HEADER_LENGTH);
             addr = helper_mmap(*addr_list, ti->length);
             if (addr == NULL) {
-                fprintf(stderr, "%s: failed to map table #%d at phys=%lx\n", ACPI_ERROR, i, (long unsigned int)*addr_list);
+                XG_LOG("%s: failed to map table #%d at phys=%lx\n", ACPI_ERROR, i, (long unsigned int)*addr_list);
                 break;
             }
             ti->phys_addr = *addr_list;
@@ -301,7 +301,7 @@ static int decode_acpi_tables(struct acpi_rsdp_info *rsdpinfo, struct hvm_acinfo
     }
     
     if (rc != 0) {
-        fprintf(stderr, "%s: failed to locate SLIC table\n", ACPI_ERROR);
+        XG_LOG("%s: failed to locate SLIC table\n", ACPI_ERROR);
         return rc;
     }
     
@@ -321,7 +321,7 @@ static int decode_acpi_tables(struct acpi_rsdp_info *rsdpinfo, struct hvm_acinfo
         va_ac->creator_revision = (*(uint32_t*)(ptr + ACPI_TABLE_CREATOR_REVISION));
     }
     else {
-        fprintf(stderr, "%s: cannot copy SLIC table length=%x - out of space\n", ACPI_ERROR, ti.length);
+        XG_LOG("%s: cannot copy SLIC table length=%x - out of space\n", ACPI_ERROR, ti.length);
         rc = -1;
     }
     
@@ -342,7 +342,7 @@ int hvm_acpi_decode(struct hvm_acinfo_table *va_ac)
     /* first locate the ACPI  tables */
     rc = locate_acpi_pointers(&rsdpinfo);
     if (rc != 0) {
-        fprintf(stderr, "%s: failed to find ACPI info\n", ACPI_ERROR);
+        XG_LOG("%s: failed to find ACPI info\n", ACPI_ERROR);
         return rc;
     }
 
@@ -366,7 +366,7 @@ int hvm_acpi_decode(struct hvm_acinfo_table *va_ac)
     else {
         /* invalidate the table */
         memset(va_ac, 0, sizeof(struct hvm_acinfo_table));
-        fprintf(stderr, "%s: decoding failed, invalidating table\n", ACPI_ERROR);
+        XG_LOG("%s: decoding failed, invalidating table\n", ACPI_ERROR);
     }
 
     return rc;
index 3267c6e52705dfabc9ae5fa179b7b651af788ddb..e763474a94efa2831c82db3633b44556bd932f4c 100644 (file)
@@ -87,13 +87,13 @@ static int smbios_entry_point(struct smstructs_info *smstructs, uint8_t *entry_p
         for (cs = 0, count = 0; count < entry_point[SMBIOS_EPS_LENGTH]; count++)
             cs += entry_point[count];
         if (cs != 0) {
-            fprintf(stderr, "%s: invalid _SM_ checksum\n", SMBIOS_ERROR);
+            XG_LOG("%s: invalid _SM_ checksum\n", SMBIOS_ERROR);
             return -1;
         }
         /* nothing else really interesting in the EPS, move to the IEPS */
         entry_point += SMBIOS_IEPS_STRING;
         if (memcmp(entry_point, "_DMI_", 5) != 0) {
-            fprintf(stderr, "%s: EPS missing _DMI_ anchor\n", SMBIOS_ERROR);
+            XG_LOG("%s: EPS missing _DMI_ anchor\n", SMBIOS_ERROR);
             return -1;
         }
     }
@@ -102,7 +102,7 @@ static int smbios_entry_point(struct smstructs_info *smstructs, uint8_t *entry_p
     for (cs = 0, count = 0; count < SMBIOS_DMI_LENGTH; count++)
         cs += entry_point[count];
     if (cs != 0) {
-        fprintf(stderr, "%s: invalid _DMI_ checksum\n", SMBIOS_ERROR);
+        XG_LOG("%s: invalid _DMI_ checksum\n", SMBIOS_ERROR);
         return -1;
     }
 
@@ -113,13 +113,13 @@ static int smbios_entry_point(struct smstructs_info *smstructs, uint8_t *entry_p
 
     /* make sure these values are realistic, like not enough room for even one structure header */
     if ((smstructs->length < 4)||(smstructs->count == 0)) {
-        fprintf(stderr, "%s: EPS reporting invalid length and count\n", SMBIOS_ERROR);
+        XG_LOG("%s: EPS reporting invalid length and count\n", SMBIOS_ERROR);
         return -1;
     }
     
     smstructs->addr = helper_mmap(smstructs->phys_addr, smstructs->length);
     if (smstructs->addr == NULL) {
-        fprintf(stderr, "%s: failed to map SMBIOS structures at phys="UINT_FMT"\n", SMBIOS_ERROR, smstructs->phys_addr);
+        XG_LOG("%s: failed to map SMBIOS structures at phys="UINT_FMT"\n", SMBIOS_ERROR, smstructs->phys_addr);
         return -1;
     }
     
@@ -139,7 +139,7 @@ static int locate_smbios_structures(struct smstructs_info *smstructs)
     if ( (rc == 0) && (loc != 0) ) {
         addr = helper_mmap(loc, SMBIOS_SM_LENGTH);
         if (addr == NULL) {
-            fprintf(stderr, "%s: failed to map EFI EPS at phys="UINT_FMT"\n", SMBIOS_ERROR, loc);
+            XG_LOG("%s: failed to map EFI EPS at phys="UINT_FMT"\n", SMBIOS_ERROR, loc);
             return -1;
         }
         rc = smbios_entry_point(smstructs, addr, 1);
@@ -150,7 +150,7 @@ static int locate_smbios_structures(struct smstructs_info *smstructs)
     /* locate SMBIOS entry via memory scan of ROM region */
     addr = helper_mmap(SCAN_ROM_BIOS_BASE, SCAN_ROM_BIOS_SIZE);
     if (addr == NULL) {
-        fprintf(stderr, "%s: failed to map ROM BIOS at phys=%x\n", SMBIOS_ERROR, SCAN_ROM_BIOS_BASE);
+        XG_LOG("%s: failed to map ROM BIOS at phys=%x\n", SMBIOS_ERROR, SCAN_ROM_BIOS_BASE);
         return -1;
     }
 
@@ -180,7 +180,7 @@ static uint32_t copy_smbios_structure(struct hvm_sminfo_table *va_sm, uint8_t *p
     total = sizeof(struct hvm_sminfo_table) + va_sm->total_length;
     add = sizeof(struct hvm_smtable_header) + length;
     if ((total + add) >= HVM_SMINFO_MAX) {
-        fprintf(stderr, "%s: cannot copy type=%2.2x - out of space\n", SMBIOS_WARN, ptr[0]);
+        XG_LOG("%s: cannot copy type=%2.2x - out of space\n", SMBIOS_WARN, ptr[0]);
         return 0;
     }
 
@@ -205,7 +205,7 @@ static int decode_smbios_structures(struct smstructs_info *smstructs, struct hvm
         if ((ptr[SMBIOS_STRUCT_LENGTH] < 4)||
             ((ptr + ptr[SMBIOS_STRUCT_LENGTH]) > (ptr + smstructs->length))) {
             /* invalid, bad SMBIOS, bail out */
-            fprintf(stderr, "%s: invalid SMBIOS table data detected\n", SMBIOS_ERROR);
+            XG_LOG("%s: invalid SMBIOS table data detected\n", SMBIOS_ERROR);
             return -1;
         }
         /* run the tail pointer past the end of this struct and all strings */
@@ -244,7 +244,7 @@ static int decode_smbios_structures(struct smstructs_info *smstructs, struct hvm
         if (ptr[SMBIOS_STRUCT_TYPE] == SMBIOS_TYPE_EOT) {
             /* table is done - sanity check */
             if (idx != smstructs->count - 1) {
-                fprintf(stderr, "%s: SMBIOS missing EOT at end\n", SMBIOS_ERROR);
+                XG_LOG("%s: SMBIOS missing EOT at end\n", SMBIOS_ERROR);
                 return -1;
             }
         }
@@ -268,7 +268,7 @@ int hvm_smbios_decode(struct hvm_sminfo_table *va_sm)
     /* first locate the SMBIOS tables */
     rc = locate_smbios_structures(&smstructs);
     if (rc != 0) {
-        fprintf(stderr, "%s: failed to find SMBIOS info\n", SMBIOS_ERROR);
+        XG_LOG("%s: failed to find SMBIOS info\n", SMBIOS_ERROR);
         return rc;
     }
 
@@ -302,7 +302,7 @@ int hvm_smbios_decode(struct hvm_sminfo_table *va_sm)
     else {
         /* invalidate the table */
         memset(va_sm, 0, sizeof(struct hvm_sminfo_table));
-        fprintf(stderr, "%s: decoding failed, invalidating table\n", SMBIOS_ERROR);
+        XG_LOG("%s: decoding failed, invalidating table\n", SMBIOS_ERROR);
     }
 
     return rc;
index 554fe7668428ce8b4fa45068fae564632a410c36..7042bf9d61c9a3526076957563ac73a28660e0b9 100644 (file)
@@ -24,6 +24,7 @@
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/params.h>
 #include <sys/mman.h>
+#include "xenguest_utils.h"
 
 #define CAML_NAME_SPACE
 #include <caml/alloc.h>
@@ -200,16 +201,20 @@ static int hvm_build_set_params(int handle, int domid,
        if (smbios_pt) {
 #ifdef HVM_SMINFO_EXTENSIONS
                /* call routine to decode and load SMBIOS tables */
-               if (hvm_smbios_decode((struct hvm_sminfo_table *)va_map) != 0)
-                       return -1;
+               if (hvm_smbios_decode((struct hvm_sminfo_table *)va_map) != 0) {
+                       /* trace a warning and proceed - decoder invalidates table correctly */
+                       XG_LOG("xenguest helper: %s decoding failed - pass through functionality will be disabled.", "SMBIOS");
+               }
 #endif
        }
 
        if (acpi_pt) {
 #ifdef HVM_ACINFO_EXTENSIONS
-       /* call routine to decode and load ACPI tables */
-               if (hvm_acpi_decode((struct hvm_acinfo_table *)(va_map + HVM_ACINFO_OFFSET)) != 0)
-                       return -1;
+               /* call routine to decode and load ACPI tables */
+               if (hvm_acpi_decode((struct hvm_acinfo_table *)(va_map + HVM_ACINFO_OFFSET)) != 0) {
+                       /* trace a warning and proceed  - decoder invalidates table correctly */
+                       XG_LOG("xenguest helper: %s decoding failed - pass through functionality will be disabled.", "ACPI");
+               }
 #endif
        }
 
index 0c4c1a907f8dea43be239ae1416958a9f6f8d3b5..fba30f0bd146591c37e6bd8f17a835df96db84aa 100644 (file)
 #else
 #define INT_FMT "%d"
 #define UINT_FMT "%x"
-#endif 
+#endif
+
+/* simple log helper so people don't log to stdout and break the comm channel */
+#define XG_LOG(_f, _a...)   fprintf(stderr, _f, ##_a)
 
 uint8_t *helper_mmap(size_t phys_addr, size_t length);
 void helper_unmmap(uint8_t *addr, size_t length);