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
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;
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;
}
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;
}
/* 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;
}
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);
/* 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;
}
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?? */
}
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;
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?? */
}
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;
}
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;
}
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;
}
/* 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;
}
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;
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;
}
}
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;
}
/* 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;
}
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);
/* 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;
}
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;
}
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 */
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;
}
}
/* 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;
}
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;
#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>
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
}
#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);