dm:use acrn-dm logger function instread of printf

Use acrn-dm logger function instread of printf,
this helps the stability testing log capture.

Tracked-On: #4098
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Cao Minggui <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
Mingqiang Chi 2019-11-13 14:11:37 +08:00 committed by wenlingz
parent 22a1bd6948
commit 5375a1613b
22 changed files with 130 additions and 121 deletions

View File

@ -41,6 +41,7 @@
#include "irq.h"
#include "lpc.h"
#include "monitor.h"
#include "log.h"
static pthread_mutex_t pm_lock = PTHREAD_MUTEX_INITIALIZER;
static struct mevent *power_button;
@ -225,7 +226,7 @@ INOUT_PORT(pm1_enable, PM1A_EVT_ADDR + 2, IOPORT_F_INOUT, pm1_enable_handler);
void
inject_power_button_event(struct vmctx *ctx)
{
printf("%s", "press power button\n");
pr_info("press power button\n");
pthread_mutex_lock(&pm_lock);
if (!(pm1_status & PM1_PWRBTN_STS)) {
pm1_status |= PM1_PWRBTN_STS;

View File

@ -23,6 +23,7 @@
#include "acpi.h"
#include "mevent.h"
#include "monitor.h"
#include "log.h"
#define POWER_BUTTON_NAME "power_button"
#define POWER_BUTTON_ACPI_DRV "/sys/bus/acpi/drivers/button/LNXPWRBN:00/"
@ -153,7 +154,7 @@ open_power_button_input_device(const char *drv, const char *dir)
/* Open the input device */
fd = open(name, O_RDONLY);
if (fd > 0)
printf("Watching power button on %s\n", name);
pr_info("Watching power button on %s\n", name);
while (nevent--)
free(event_dirs[nevent]);

View File

@ -202,7 +202,7 @@ static int open_hugetlbfs(struct vmctx *ctx, int level)
*(path + len) = '\0';
strncat(path, uuid_str, strnlen(uuid_str, sizeof(uuid_str)));
printf("open hugetlbfs file %s\n", path);
pr_info("open hugetlbfs file %s\n", path);
hugetlb_priv[level].fd = open(path, O_CREAT | O_RDWR, 0644);
if (hugetlb_priv[level].fd < 0) {
@ -280,12 +280,12 @@ static int mmap_hugetlbfs_from_level(struct vmctx *ctx, int level, size_t len,
if (addr == MAP_FAILED)
return -ENOMEM;
printf("mmap 0x%lx@%p\n", len, addr);
pr_info("mmap 0x%lx@%p\n", len, addr);
/* pre-allocate hugepages by touch them */
pagesz = hugetlb_priv[level].pg_size;
printf("touch %ld pages with pagesz 0x%lx\n", len/pagesz, pagesz);
pr_info("touch %ld pages with pagesz 0x%lx\n", len/pagesz, pagesz);
for (i = 0; i < len/pagesz; i++) {
*(volatile char *)addr = *addr;
@ -475,14 +475,14 @@ static int read_sys_info(const char *sys_path)
fp = fopen(sys_path, "r");
if (fp == NULL) {
printf("can't open: %s, err: %s\n", sys_path, strerror(errno));
pr_err("can't open: %s, err: %s\n", sys_path, strerror(errno));
return 0;
}
memset(tmp_buf, 0, 12);
result = fread(&tmp_buf, sizeof(char), 8, fp);
if (result <= 0)
printf("read %s, error: %s, please check!\n",
pr_err("read %s, error: %s, please check!\n",
sys_path, strerror(errno));
else
pages = strtol(tmp_buf, NULL, 10);
@ -507,7 +507,7 @@ static bool hugetlb_check_memgap(void)
if (hugetlb_priv[lvl].pages_delta > 0)
has_gap = true;
printf("level %d free/need pages:%d/%d page size:0x%x\n", lvl,
pr_info("level %d free/need pages:%d/%d page size:0x%x\n", lvl,
free_pages, need_pages, hugetlb_priv[lvl].pg_size);
}
@ -529,12 +529,12 @@ static void reserve_more_pages(int level)
/* system cmd to reserve needed huge pages */
fp = popen(cmd_buf, "r");
if (fp == NULL) {
printf("cmd: %s failed!\n", cmd_buf);
pr_err("cmd: %s failed!\n", cmd_buf);
return;
}
pclose(fp);
printf("to reserve pages (+orig %d): %s\n", orig_pages, cmd_buf);
pr_info("to reserve pages (+orig %d): %s\n", orig_pages, cmd_buf);
cur_pages = read_sys_info(hugetlb_priv[level].nr_pages_path);
hugetlb_priv[level].pages_delta = total_pages - cur_pages;
}
@ -559,7 +559,7 @@ static bool release_larger_freepage(int level_limit)
fp = popen(cmd_buf, "r");
if (fp == NULL) {
printf("cmd to free mem: %s failed!\n", cmd_buf);
pr_err("cmd to free mem: %s failed!\n", cmd_buf);
return false;
}
pclose(fp);
@ -598,7 +598,7 @@ static bool hugetlb_reserve_pages(void)
int left_gap = 0, pg_size;
int level;
printf("to reserve more free pages:\n");
pr_info("to reserve more free pages:\n");
for (level = hugetlb_lv_max - 1; level >= HUGETLB_LV1; level--) {
if (hugetlb_priv[level].pages_delta <= 0)
continue;
@ -635,12 +635,12 @@ static bool hugetlb_reserve_pages(void)
}
if (level >= HUGETLB_LV1) {
printf("level %d pages gap: %d failed to reserve!\n",
pr_err("level %d pages gap: %d failed to reserve!\n",
level, left_gap);
return false;
}
printf("now enough free pages are reserved!\n");
pr_info("now enough free pages are reserved!\n");
return true;
}
@ -663,7 +663,7 @@ bool init_hugetlb(void)
if (level < HUGETLB_LV1) /* mount fail for level 1 */
return false;
else if (level == HUGETLB_LV1) /* mount fail for level 2 */
printf("WARNING: only level 1 hugetlb supported");
pr_warn("WARNING: only level 1 hugetlb supported");
lock_fd = open(ACRN_HUGETLB_LOCK_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (lock_fd < 0) {
@ -758,15 +758,15 @@ int hugetlb_setup_memory(struct vmctx *ctx)
}
/* dump hugepage trying to setup */
printf("\ntry to setup hugepage with:\n");
pr_info("\ntry to setup hugepage with:\n");
for (level = HUGETLB_LV1; level < hugetlb_lv_max; level++) {
printf("\tlevel %d - lowmem 0x%lx, biosmem 0x%lx, highmem 0x%lx\n",
pr_info("\tlevel %d - lowmem 0x%lx, biosmem 0x%lx, highmem 0x%lx\n",
level,
hugetlb_priv[level].lowmem,
hugetlb_priv[level].biosmem,
hugetlb_priv[level].highmem);
}
printf("total_size 0x%lx\n\n", total_size);
pr_info("total_size 0x%lx\n\n", total_size);
/* basic overview vma */
ptr = mmap(NULL, total_size, PROT_NONE,
@ -784,7 +784,7 @@ int hugetlb_setup_memory(struct vmctx *ctx)
break;
}
}
printf("mmap ptr 0x%p -> baseaddr 0x%p\n", ptr, ctx->baseaddr);
pr_info("mmap ptr 0x%p -> baseaddr 0x%p\n", ptr, ctx->baseaddr);
/* mmap lowmem */
if (mmap_hugetlbfs(ctx, 0, get_lowmem_param, adj_lowmem_param) < 0) {
@ -809,9 +809,9 @@ int hugetlb_setup_memory(struct vmctx *ctx)
unlock_acrn_hugetlb();
/* dump hugepage really setup */
printf("\nreally setup hugepage with:\n");
pr_info("\nreally setup hugepage with:\n");
for (level = HUGETLB_LV1; level < hugetlb_lv_max; level++) {
printf("\tlevel %d - lowmem 0x%lx, biosmem 0x%lx, highmem 0x%lx\n",
pr_info("\tlevel %d - lowmem 0x%lx, biosmem 0x%lx, highmem 0x%lx\n",
level,
hugetlb_priv[level].lowmem,
hugetlb_priv[level].biosmem,

View File

@ -30,6 +30,7 @@
#include <string.h>
#include "inout.h"
#include "log.h"
SET_DECLARE(inout_port_set, struct inout_port);
#define MAX_IOPORTS (1 << 16)
@ -71,7 +72,7 @@ register_default_iohandler(int start, int size)
struct inout_port iop;
if (!VERIFY_IOPORT(start, size)) {
printf("invalid input: port:0x%x, size:%d", start, size);
pr_err("invalid input: port:0x%x, size:%d", start, size);
return;
}
@ -133,7 +134,7 @@ init_inout(void)
SET_FOREACH(iopp, inout_port_set) {
iop = *iopp;
if (iop->port >= MAX_IOPORTS) {
printf("%s: invalid port:0x%x", __func__, iop->port);
pr_err("%s: invalid port:0x%x", __func__, iop->port);
continue;
}
@ -150,7 +151,7 @@ register_inout(struct inout_port *iop)
int i;
if (!VERIFY_IOPORT(iop->port, iop->size)) {
printf("invalid input: port:0x%x, size:%d",
pr_err("invalid input: port:0x%x, size:%d",
iop->port, iop->size);
return -1;
}
@ -181,7 +182,7 @@ unregister_inout(struct inout_port *iop)
{
if (!VERIFY_IOPORT(iop->port, iop->size)) {
printf("invalid input: port:0x%x, size:%d",
pr_err("invalid input: port:0x%x, size:%d",
iop->port, iop->size);
return -1;
}

View File

@ -695,7 +695,7 @@ vm_loop(struct vmctx *ctx)
vm_suspend_resume(ctx);
}
}
printf("VM loop exit\n");
pr_err("VM loop exit\n");
}
static int

View File

@ -100,7 +100,7 @@ mmio_rb_add(struct mmio_rb_tree *rbt, struct mmio_rb_range *new)
if (overlap != NULL) {
#ifdef RB_DEBUG
printf("overlap detected: new %lx:%lx, tree %lx:%lx\n",
pr_dbg("overlap detected: new %lx:%lx, tree %lx:%lx\n",
new->mr_base, new->mr_end,
overlap->mr_base, overlap->mr_end);
#endif
@ -119,7 +119,7 @@ mmio_rb_dump(struct mmio_rb_tree *rbt)
pthread_rwlock_rdlock(&mmio_rwlock);
RB_FOREACH(np, mmio_rb_tree, rbt) {
printf(" %lx:%lx, %s\n", np->mr_base, np->mr_end,
pr_dbg(" %lx:%lx, %s\n", np->mr_base, np->mr_end,
np->mr_param.name);
}
pthread_rwlock_unlock(&mmio_rwlock);

View File

@ -211,9 +211,9 @@ int acrn_parse_intr_monitor(const char *opt)
(!dm_strtoui(cp + 1, &cp, 10, &period) && *cp == ',') &&
(!dm_strtoui(cp + 1, &cp, 10, &delay) && *cp == ',') &&
(!dm_strtoui(cp + 1, &cp, 10, &duration))) {
pr_info("interrupt storm monitor params: %d, %d, %d, %d\n", threshold, period, delay, duration);
printf("interrupt storm monitor params: %d, %d, %d, %d\n", threshold, period, delay, duration);
} else {
pr_err("%s: not correct, it should be like: --intr_monitor 10000,10,1,100, please check!\n", opt);
printf("%s: not correct, it should be like: --intr_monitor 10000,10,1,100, please check!\n", opt);
return -1;
}

View File

@ -77,7 +77,7 @@ int parse_pm_by_vuart(const char *opts)
}
}
pr_info("pm by vuart node-index = %d\n", node_index);
printf("pm by vuart node-index = %d\n", node_index);
strncpy(node_path, str, MAX_NODE_PATH - 1);
free(cpy);

View File

@ -33,6 +33,7 @@
#include "dm.h"
#include "vmmapi.h"
#include "sw_load.h"
#include "log.h"
#define SETUP_SIG 0x5a5aaa55
@ -183,7 +184,7 @@ acrn_prepare_ramdisk(struct vmctx *ctx)
}
if (len > (BOOTARGS_LOAD_OFF(ctx) - RAMDISK_LOAD_OFF(ctx))) {
printf("SW_LOAD ERR: the size of ramdisk file is too big"
pr_err("SW_LOAD ERR: the size of ramdisk file is too big"
" file len=0x%lx, limit is 0x%lx\n", len,
BOOTARGS_LOAD_OFF(ctx) - RAMDISK_LOAD_OFF(ctx));
fclose(fp);
@ -194,13 +195,13 @@ acrn_prepare_ramdisk(struct vmctx *ctx)
read = fread(ctx->baseaddr + RAMDISK_LOAD_OFF(ctx),
sizeof(char), len, fp);
if (read < len) {
printf("SW_LOAD ERR: could not read the whole ramdisk file,"
pr_err("SW_LOAD ERR: could not read the whole ramdisk file,"
" file len=%ld, read %lu\n", len, read);
fclose(fp);
return -1;
}
fclose(fp);
printf("SW_LOAD: ramdisk %s size %lu copied to guest 0x%lx\n",
pr_info("SW_LOAD: ramdisk %s size %lu copied to guest 0x%lx\n",
ramdisk_path, ramdisk_size, RAMDISK_LOAD_OFF(ctx));
return 0;
@ -272,7 +273,7 @@ acrn_prepare_zeropage(struct vmctx *ctx, int setup_size)
((uint64_t)RAMDISK_LOAD_OFF(ctx));
zeropage->hdr.ramdisk_size = (uint32_t)ramdisk_size;
printf("SW_LOAD: build zeropage for ramdisk addr: 0x%x,"
pr_info("SW_LOAD: build zeropage for ramdisk addr: 0x%x,"
" size: %d\n", zeropage->hdr.ramdisk_addr,
zeropage->hdr.ramdisk_size);
}
@ -280,7 +281,7 @@ acrn_prepare_zeropage(struct vmctx *ctx, int setup_size)
/* Copy bootargs load_addr in zeropage header structure */
zeropage->hdr.bootargs_addr = (uint32_t)
((uint64_t)BOOTARGS_LOAD_OFF(ctx));
printf("SW_LOAD: build zeropage for bootargs addr: 0x%x\n",
pr_info("SW_LOAD: build zeropage for bootargs addr: 0x%x\n",
zeropage->hdr.bootargs_addr);
/* set constant arguments in zero page */
@ -310,7 +311,7 @@ acrn_sw_load_bzimage(struct vmctx *ctx)
if (with_bootargs) {
strncpy(ctx->baseaddr + BOOTARGS_LOAD_OFF(ctx), get_bootargs(), STR_LEN);
printf("SW_LOAD: bootargs copied to guest 0x%lx\n",
pr_info("SW_LOAD: bootargs copied to guest 0x%lx\n",
BOOTARGS_LOAD_OFF(ctx));
}
@ -335,7 +336,7 @@ acrn_sw_load_bzimage(struct vmctx *ctx)
if (ret)
return ret;
printf("SW_LOAD: zeropage prepared @ 0x%lx, "
pr_info("SW_LOAD: zeropage prepared @ 0x%lx, "
"kernel_entry_addr=0x%lx\n",
ZEROPAGE_LOAD_OFF(ctx),
(KERNEL_LOAD_OFF(ctx) + setup_size));

View File

@ -253,11 +253,11 @@ acrn_create_e820_table(struct vmctx *ctx, struct e820_entry *e820)
removed++;
}
printf("SW_LOAD: build e820 %d entries to addr: %p\r\n",
pr_info("SW_LOAD: build e820 %d entries to addr: %p\r\n",
NUM_E820_ENTRIES - removed, (void *)e820);
for (k = 0; k < NUM_E820_ENTRIES - removed; k++)
printf("SW_LOAD: entry[%d]: addr 0x%016lx, size 0x%016lx, "
pr_info("SW_LOAD: entry[%d]: addr 0x%016lx, size 0x%016lx, "
" type 0x%x\r\n",
k, e820[k].baseaddr,
e820[k].length,

View File

@ -32,6 +32,7 @@
#include "dm.h"
#include "vmmapi.h"
#include "sw_load.h"
#include "log.h"
/* ovmf binary layout:
@ -239,7 +240,7 @@ acrn_writeback_ovmf_nvstorage(struct vmctx *ctx)
}
fclose(fp);
printf("OVMF_WRITEBACK: OVMF has been written back \
pr_info("OVMF_WRITEBACK: OVMF has been written back \
to partition blob %s size %lu from guest 0x%lx\n",
ovmf_path, OVMF_NVSTORAGE_SZ, OVMF_NVSTORAGE_OFFSET);

View File

@ -34,6 +34,7 @@
#include "vmmapi.h"
#include "sw_load.h"
#include "acpi.h"
#include "log.h"
/* If the vsbl is loaded by DM, the UOS memory layout will be like:
@ -131,7 +132,7 @@ acrn_parse_guest_part_info(char *arg)
strncpy(guest_part_info_path, arg, len + 1);
if (check_image(guest_part_info_path, 0, &guest_part_info_size) == 0) {
with_guest_part_info = true;
printf("SW_LOAD: get partition blob path %s\n",
pr_info("SW_LOAD: get partition blob path %s\n",
guest_part_info_path);
error = 0;
}
@ -238,7 +239,7 @@ acrn_prepare_vsbl(struct vmctx *ctx)
return -1;
}
fclose(fp);
printf("SW_LOAD: partition blob %s size %lu copy to guest 0x%lx\n",
pr_info("SW_LOAD: partition blob %s size %lu copy to guest 0x%lx\n",
vsbl_path, vsbl_size, VSBL_TOP(ctx) - vsbl_size);
return 0;
@ -295,7 +296,7 @@ acrn_sw_load_vsbl(struct vmctx *ctx)
vsbl_para->e820_entries = add_e820_entry(e820, vsbl_para->e820_entries,
vsbl_para->vsbl_address, vsbl_size, E820_TYPE_RESERVED);
printf("SW_LOAD: vsbl_entry 0x%lx\n", VSBL_TOP(ctx) - 16);
pr_info("SW_LOAD: vsbl_entry 0x%lx\n", VSBL_TOP(ctx) - 16);
vsbl_para->boot_device_address = boot_blk_bdf;
vsbl_para->trusty_enabled = trusty_enabled;

View File

@ -516,7 +516,7 @@ modify_bar_registration(struct pci_vdev *dev, int idx, int registration)
* addressing and generate ACPI PCI resource from using
* acrn-dm.
*/
printf("modify_bar_registration: bypass for pci-gvt\n");
pr_notice("modify_bar_registration: bypass for pci-gvt\n");
return 0;
}
switch (dev->bar[idx].type) {
@ -2306,7 +2306,7 @@ pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
if (baridx == 0) {
if (offset + size > DIOSZ) {
printf("diow: iow too large, offset %ld size %d\n",
pr_err("diow: iow too large, offset %ld size %d\n",
offset, size);
return;
}
@ -2319,7 +2319,7 @@ pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
else if (size == 4)
*(uint32_t *)offset = value;
else
printf("diow: iow unknown size %d\n", size);
pr_err("diow: iow unknown size %d\n", size);
/*
* Special magic value to generate an interrupt
@ -2335,7 +2335,7 @@ pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
if (baridx == 1 || baridx == 2) {
if (offset + size > DMEMSZ) {
printf("diow: memw too large, offset %ld size %d\n",
pr_err("diow: memw too large, offset %ld size %d\n",
offset, size);
return;
}
@ -2352,7 +2352,7 @@ pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
else if (size == 8)
*(uint64_t *)offset_ptr = value;
else
printf("diow: memw unknown size %d\n", size);
pr_err("diow: memw unknown size %d\n", size);
/*
* magic interrupt ??
@ -2360,7 +2360,7 @@ pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
}
if (baridx > 2 || baridx < 0)
printf("diow: unknown bar idx %d\n", baridx);
pr_err("diow: unknown bar idx %d\n", baridx);
}
static uint64_t
@ -2374,7 +2374,7 @@ pci_emul_dior(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
if (baridx == 0) {
if (offset + size > DIOSZ) {
printf("dior: ior too large, offset %ld size %d\n",
pr_err("dior: ior too large, offset %ld size %d\n",
offset, size);
return 0;
}
@ -2388,12 +2388,12 @@ pci_emul_dior(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
else if (size == 4)
value = *(uint32_t *)offset_ptr;
else
printf("dior: ior unknown size %d\n", size);
pr_err("dior: ior unknown size %d\n", size);
}
if (baridx == 1 || baridx == 2) {
if (offset + size > DMEMSZ) {
printf("dior: memr too large, offset %ld size %d\n",
pr_err("dior: memr too large, offset %ld size %d\n",
offset, size);
return 0;
}
@ -2410,12 +2410,12 @@ pci_emul_dior(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
else if (size == 8)
value = *(uint64_t *)offset_ptr;
else
printf("dior: ior unknown size %d\n", size);
pr_err("dior: ior unknown size %d\n", size);
}
if (baridx > 2 || baridx < 0) {
printf("dior: unknown bar idx %d\n", baridx);
pr_err("dior: unknown bar idx %d\n", baridx);
return 0;
}

View File

@ -501,7 +501,7 @@ deinit_msix_table(struct vmctx *ctx, struct passthru_dev *ptdev)
int vector_cnt = dev->msix.table_count;
if (ptdev->msix.ptirq_allocated) {
printf("ptdev reset msix: 0x%x-%x, vector_cnt=%d.\n",
pr_info("ptdev reset msix: 0x%x-%x, vector_cnt=%d.\n",
virt_bdf, ptdev->phys_bdf, vector_cnt);
vm_reset_ptdev_msix_info(ctx, virt_bdf, ptdev->phys_bdf, vector_cnt);
ptdev->msix.ptirq_allocated = false;
@ -920,7 +920,7 @@ passthru_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
vm_reset_ptdev_msix_info(ctx, virt_bdf, ptdev->phys_bdf, 1);
}
printf("vm_reset_ptdev_intx:0x%x-%x, ioapic virpin=%d.\n",
pr_info("vm_reset_ptdev_intx:0x%x-%x, ioapic virpin=%d.\n",
virt_bdf, ptdev->phys_bdf, dev->lintr.ioapic_irq);
if (dev->lintr.pin != 0) {
@ -992,9 +992,9 @@ passthru_bind_irq(struct vmctx *ctx, struct pci_vdev *dev)
if (dev->lintr.pin == 0)
return;
printf("vm_set_ptdev_intx for %d:%d.%d, ",
pr_info("vm_set_ptdev_intx for %d:%d.%d, ",
dev->bus, dev->slot, dev->func);
printf("virt_pin=%d, phys_pin=%d, virt_bdf=0x%x, phys_bdf=0x%x.\n",
pr_info("virt_pin=%d, phys_pin=%d, virt_bdf=0x%x, phys_bdf=0x%x.\n",
dev->lintr.ioapic_irq, ptdev->phys_pin,
virt_bdf, ptdev->phys_bdf);
@ -1106,7 +1106,7 @@ passthru_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
static void
write_dsdt_xdci(struct pci_vdev *dev)
{
printf("write virt-%x:%x.%x in dsdt for XDCI @ 00:15.1\n",
pr_info("write virt-%x:%x.%x in dsdt for XDCI @ 00:15.1\n",
dev->bus,
dev->slot,
dev->func);
@ -1124,7 +1124,7 @@ write_dsdt_xdci(struct pci_vdev *dev)
static void
write_dsdt_hdac(struct pci_vdev *dev)
{
printf("write virt-%x:%x.%x in dsdt for HDAC @ 00:17.0\n",
pr_info("write virt-%x:%x.%x in dsdt for HDAC @ 00:17.0\n",
dev->bus,
dev->slot,
dev->func);
@ -1243,7 +1243,7 @@ write_dsdt_hdac(struct pci_vdev *dev)
static void
write_dsdt_hdas(struct pci_vdev *dev)
{
printf("write virt-%x:%x.%x in dsdt for HDAS @ 00:e.0\n",
pr_info("write virt-%x:%x.%x in dsdt for HDAS @ 00:e.0\n",
dev->bus,
dev->slot,
dev->func);
@ -1463,7 +1463,7 @@ write_dsdt_hdas(struct pci_vdev *dev)
static void
write_dsdt_ipu_i2c(struct pci_vdev *dev)
{
printf("write virt-%x:%x.%x in dsdt for ipu's i2c-bus @ 00:16.0\n",
pr_info("write virt-%x:%x.%x in dsdt for ipu's i2c-bus @ 00:16.0\n",
dev->bus, dev->slot, dev->func);
/* physical I2C 0:16.0 */
@ -1693,7 +1693,7 @@ write_dsdt_ipu_i2c(struct pci_vdev *dev)
static void
write_dsdt_urt1(struct pci_vdev *dev)
{
printf("write virt-%x:%x.%x in dsdt for URT1 @ 00:18.0\n",
pr_info("write virt-%x:%x.%x in dsdt for URT1 @ 00:18.0\n",
dev->bus,
dev->slot,
dev->func);
@ -1715,7 +1715,7 @@ write_dsdt_urt1(struct pci_vdev *dev)
static void
write_dsdt_sdc(struct pci_vdev *dev)
{
printf("write SDC-%x:%x.%x in dsdt for SDC @ 00:1b.0\n",
pr_info("write SDC-%x:%x.%x in dsdt for SDC @ 00:1b.0\n",
dev->bus,
dev->slot,
dev->func);

View File

@ -450,7 +450,7 @@ virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
dummy_bctxt = false;
if (opts == NULL) {
printf("virtio_blk: backing device required\n");
pr_err("virtio_blk: backing device required\n");
return -1;
}

View File

@ -3919,7 +3919,7 @@ pci_xhci_parse_log_level(struct pci_xhci_vdev *xdev, char *opts)
errout:
if (rc)
printf("USB: fail to set log level, rc=%d\r\n", rc);
pr_err("USB: fail to set log level, rc=%d\r\n", rc);
free(o);
return rc;
}
@ -4086,7 +4086,7 @@ pci_xhci_parse_extcap(struct pci_xhci_vdev *xdev, char *opts)
errout:
if (rc)
printf("USB: fail to set vendor capability, rc=%d\r\n", rc);
pr_err("USB: fail to set vendor capability, rc=%d\r\n", rc);
free(o);
return rc;
}

View File

@ -72,7 +72,7 @@ atkbdc_kbd_queue_data(struct atkbdc_base *base, uint8_t val)
base->status |= KBDS_KBD_BUFFER_FULL;
base->outport |= KBDO_KBD_OUTFULL;
} else {
printf("atkbd data buffer full\n");
pr_err("atkbd data buffer full\n");
}
return (base->kbd.bcnt < FIFOSZ);

View File

@ -16,6 +16,7 @@
#include "inout.h"
#include "vmmapi.h"
#include "vrpmb.h"
#include "log.h"
#define CMOS_ADDR 0x74
#define CMOS_DATA 0x75
@ -96,7 +97,7 @@ int init_cmos_vrpmb(struct vmctx *ctx)
/* get vrpmb key, and store it to cmos buffer */
if (!get_vrpmb_key(vrpmb_buffer, RPMB_KEY_LEN)) {
printf("SW_LOAD: failed to get vrpmb key\n");
pr_err("SW_LOAD: failed to get vrpmb key\n");
return -1;
}
return 0;

View File

@ -39,6 +39,7 @@
#include "timer.h"
#include "inout.h"
#include "pit.h"
#include "log.h"
#define TMR2_OUT_STS 0x20
@ -358,7 +359,7 @@ pit_update_counter(struct vpit *vpit, struct channel *c, bool latch,
* set the timer to 100hz in this condition; do the same
* here.
*/
printf("vpit reading uninitialized counter value\n");
pr_warn("vpit reading uninitialized counter value\n");
c->initial = PIT_HZ_TO_TICKS(100);
delta_ticks = 0;
@ -471,7 +472,7 @@ vpit_update_mode(struct vpit *vpit, uint8_t val)
if (rw != TIMER_LATCH) {
if (rw != TIMER_16BIT) {
printf("vpit unsupported rw: 0x%x\n", rw);
pr_err("vpit unsupported rw: 0x%x\n", rw);
return (-1);
}
@ -482,7 +483,7 @@ vpit_update_mode(struct vpit *vpit, uint8_t val)
if (mode != TIMER_INTTC &&
!PERIODIC_MODE(mode & ~TIMER_MODE_DONT_CARE_MASK) &&
mode != TIMER_SWSTROBE) {
printf("vpit unsupported mode: 0x%x\n", mode);
pr_err("vpit unsupported mode: 0x%x\n", mode);
return (-1);
}
}
@ -647,8 +648,7 @@ vpit_nmisc_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
VPIT_UNLOCK();
} else
printf("out instr on NMI port (0x%u) not supported\n",
NMISC_PORT);
pr_err("out instr on NMI port (0x%x) not supported\n", NMISC_PORT);
return (0);
}

View File

@ -22,6 +22,7 @@
#include "vmmapi.h"
#include "tpm_internal.h"
#include "log.h"
/* According to definition in TPM2 spec */
#define TPM_ORD_ContinueSelfTest 0x53
@ -212,18 +213,18 @@ static int ctrl_chan_conn(const char *servername)
int ret;
if (!servername) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
if (strnlen(servername, sizeof(servaddr.sun_path)) == (sizeof(servaddr.sun_path))) {
printf("%s error, length of servername is too long\n", __func__);
pr_err("%s error, length of servername is too long\n", __func__);
return -1;
}
clifd = socket(AF_UNIX, SOCK_STREAM, 0);
if (clifd < 0) {
printf("socket failed.\n");
pr_err("socket failed.\n");
return -1;
}
@ -234,7 +235,7 @@ static int ctrl_chan_conn(const char *servername)
ret = connect(clifd, (struct sockaddr *)&servaddr, sizeof(servaddr));
if (ret < 0) {
printf("connect failed.\n");
pr_err("connect failed.\n");
close(clifd);
return -1;
}
@ -255,7 +256,7 @@ static int ctrl_chan_write(int ctrl_chan_fd, const uint8_t *buf, int len,
struct cmsghdr *pcmsg;
if (!buf || (!pdatafd && fd_num)) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
@ -282,7 +283,7 @@ static int ctrl_chan_write(int ctrl_chan_fd, const uint8_t *buf, int len,
pcmsg->cmsg_type = SCM_RIGHTS;
*((int *)CMSG_DATA(pcmsg)) = *pdatafd;
} else {
printf("fd_num failed.\n");
pr_err("fd_num failed.\n");
return -1;
}
@ -305,7 +306,7 @@ static int ctrl_chan_read(int ctrl_chan_fd, uint8_t *buf, int len)
int n;
if (!buf) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
@ -338,7 +339,7 @@ static int cmd_chan_write(int cmd_chan_fd, const uint8_t *buf, int len)
int buffer_length = len;
if (!buf) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
@ -364,7 +365,7 @@ static int cmd_chan_read(int cmd_chan_fd, uint8_t *buf, int len)
size_t nleft = len;
if (!buf) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
@ -410,7 +411,7 @@ static int swtpm_ctrlcmd(int ctrl_chan_fd, unsigned long cmd, void *msg,
int recv_num;
if (!msg || (!pdatafd && fd_num)) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
@ -423,14 +424,14 @@ static int swtpm_ctrlcmd(int ctrl_chan_fd, unsigned long cmd, void *msg,
send_num = ctrl_chan_write(ctrl_chan_fd, buf, n, pdatafd, fd_num);
if ((send_num <= 0) || (send_num != n) ) {
printf("%s failed to write %d != %ld\n", __func__, send_num, n);
pr_err("%s failed to write %d != %ld\n", __func__, send_num, n);
goto end;
}
if (msg_len_out != 0) {
recv_num = ctrl_chan_read(ctrl_chan_fd, msg, msg_len_out);
if ((recv_num <= 0) || (recv_num != msg_len_out)) {
printf("%s failed to read %d != %ld\n", __func__, recv_num, msg_len_out);
pr_err("%s failed to read %d != %ld\n", __func__, recv_num, msg_len_out);
goto end;
}
}
@ -459,7 +460,7 @@ static int swtpm_cmdcmd(int cmd_chan_fd,
bool is_selftest = false;
if (!in || !out) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
@ -470,19 +471,19 @@ static int swtpm_cmdcmd(int cmd_chan_fd,
ret = cmd_chan_write(cmd_chan_fd, (uint8_t *)in, in_len);
if ((ret == -1) || (ret != in_len)) {
printf("%s failed to write %ld != %d\n", __func__, ret, in_len);
pr_err("%s failed to write %ld != %d\n", __func__, ret, in_len);
return -1;
}
ret = cmd_chan_read(cmd_chan_fd, (uint8_t *)out,
sizeof(tpm_output_header));
if (ret == -1) {
printf("%s failed to read size\n", __func__);
pr_err("%s failed to read size\n", __func__);
return -1;
}
if (tpm_cmd_get_size(out) > out_len) {
printf("%s error, get out size is larger than out_len\n", __func__);
pr_err("%s error, get out size is larger than out_len\n", __func__);
return -1;
}
@ -490,7 +491,7 @@ static int swtpm_cmdcmd(int cmd_chan_fd,
(uint8_t *)out + sizeof(tpm_output_header),
tpm_cmd_get_size(out) - sizeof(tpm_output_header));
if (ret == -1) {
printf("%s failed to read data\n", __func__);
pr_err("%s failed to read data\n", __func__);
return -1;
}
@ -509,14 +510,14 @@ static int swtpm_ctrlchan_create(const char *arg_path)
int connfd;
if (!arg_path) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
connfd = ctrl_chan_conn(arg_path);
if(connfd < 0)
{
printf("Error[%d] when connecting...",errno);
pr_err("Error[%d] when connecting...", errno);
return -1;
}
@ -535,12 +536,12 @@ static int swtpm_cmdchan_create(void)
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0)
{
printf("socketpair failed!\n");
pr_err("socketpair failed!\n");
return -1;
}
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SET_DATAFD, &res, 0,
sizeof(res), &sv[1], 1) < 0 || res != 0) {
printf("swtpm: Failed to send CMD_SET_DATAFD: %s", strerror(errno));
pr_err("swtpm: Failed to send CMD_SET_DATAFD: %s", strerror(errno));
goto err_exit;
}
tpm_context.cmd_chan_fd = sv[0];
@ -559,19 +560,19 @@ static int swtpm_start(ptm_init *init)
ptm_res res;
if (!init) {
printf("%s error, invalid input\n", __func__);
pr_err("%s error, invalid input\n", __func__);
return -1;
}
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_INIT,
init, sizeof(*init), sizeof(*init), NULL, 0) < 0) {
printf("swtpm: could not send INIT: %s", strerror(errno));
pr_err("swtpm: could not send INIT: %s", strerror(errno));
goto err_exit;
}
res = __builtin_bswap32(init->u.resp.tpm_result);
if (res) {
printf("swtpm: TPM result for CMD_INIT: 0x%x", res);
pr_err("swtpm: TPM result for CMD_INIT: 0x%x", res);
goto err_exit;
}
@ -586,13 +587,13 @@ static int swtpm_stop(void)
ptm_res res = 0;
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_STOP, &res, 0, sizeof(res), NULL, 0) < 0) {
printf("swtpm: Could not stop TPM: %s", strerror(errno));
pr_err("swtpm: Could not stop TPM: %s", strerror(errno));
return -1;
}
res = __builtin_bswap32(res);
if (res) {
printf("swtpm: TPM result for CMD_STOP: 0x%x", res);
pr_err("swtpm: TPM result for CMD_STOP: 0x%x", res);
return -1;
}
@ -611,7 +612,7 @@ static int swtpm_set_buffer_size(size_t wanted_size,
ptm_setbuffersize psbs;
if (wanted_size == 0) {
printf("%s error, wanted_size is 0\n", __func__);
pr_err("%s error, wanted_size is 0\n", __func__);
return -1;
}
@ -619,13 +620,13 @@ static int swtpm_set_buffer_size(size_t wanted_size,
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SET_BUFFERSIZE, &psbs,
sizeof(psbs.u.req), sizeof(psbs.u.resp), NULL, 0) < 0) {
printf("swtpm: Could not set buffer size: %s", strerror(errno));
pr_err("swtpm: Could not set buffer size: %s", strerror(errno));
return -1;
}
psbs.u.resp.tpm_result = __builtin_bswap32(psbs.u.resp.tpm_result);
if (psbs.u.resp.tpm_result != 0) {
printf("swtpm: TPM result for set buffer size : 0x%x", psbs.u.resp.tpm_result);
pr_err("swtpm: TPM result for set buffer size : 0x%x", psbs.u.resp.tpm_result);
return -1;
}
@ -644,7 +645,7 @@ static int swtpm_startup_tpm(size_t buffersize,
};
if (swtpm_stop() < 0) {
printf("swtpm_stop() failed!\n");
pr_err("swtpm_stop() failed!\n");
return -1;
}
@ -666,9 +667,9 @@ static void swtpm_shutdown(void)
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SHUTDOWN,
&res, 0, sizeof(res), NULL, 0) < 0) {
printf("swtpm: Could not cleanly shutdown the TPM: %s", strerror(errno));
pr_err("swtpm: Could not cleanly shutdown the TPM: %s", strerror(errno));
} else if (res != 0) {
printf("swtpm: TPM result for sutdown: 0x%x", __builtin_bswap32(res));
pr_err("swtpm: TPM result for sutdown: 0x%x", __builtin_bswap32(res));
}
}
@ -682,13 +683,13 @@ static int swtpm_set_locality(uint8_t locty_number)
loc.u.req.loc = locty_number;
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SET_LOCALITY, &loc,
sizeof(loc), sizeof(loc), NULL, 0) < 0) {
printf("swtpm: could not set locality : %s", strerror(errno));
pr_err("swtpm: could not set locality : %s", strerror(errno));
return -1;
}
loc.u.resp.tpm_result = __builtin_bswap32(loc.u.resp.tpm_result);
if (loc.u.resp.tpm_result != 0) {
printf("swtpm: TPM result for set locality : 0x%x", loc.u.resp.tpm_result);
pr_err("swtpm: TPM result for set locality : 0x%x", loc.u.resp.tpm_result);
return -1;
}
@ -700,7 +701,7 @@ static int swtpm_set_locality(uint8_t locty_number)
static void swtpm_write_fatal_error_response(uint8_t *out, uint32_t out_len)
{
if (!out) {
printf("%s error, invalid input.\n", __func__);
pr_err("%s error, invalid input.\n", __func__);
return;
}
@ -726,7 +727,7 @@ int swtpm_startup(size_t buffersize)
int swtpm_handle_request(TPMCommBuffer *cmd)
{
if (!cmd) {
printf("%s error, invalid input.\n", __func__);
pr_err("%s error, invalid input.\n", __func__);
return -1;
}
@ -751,7 +752,7 @@ bool swtpm_get_tpm_established_flag(void)
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_GET_TPMESTABLISHED, &est,
0, sizeof(est), NULL, 0) < 0) {
printf("swtpm: Could not get the TPM established flag: %s", strerror(errno));
pr_err("swtpm: Could not get the TPM established flag: %s", strerror(errno));
return false;
}
@ -767,21 +768,21 @@ void swtpm_cancel_cmd(void)
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_CANCEL_TPM_CMD, &res, 0,
sizeof(res), NULL, 0) < 0) {
printf("swtpm: Could not cancel command: %s", strerror(errno));
pr_err("swtpm: Could not cancel command: %s", strerror(errno));
} else if (res != 0) {
printf("swtpm: Failed to cancel TPM: 0x%x", __builtin_bswap32(res));
pr_err("swtpm: Failed to cancel TPM: 0x%x", __builtin_bswap32(res));
}
}
int init_tpm_emulator(const char *sock_path)
{
if (swtpm_ctrlchan_create(sock_path) < 0) {
printf("error, failed to create ctrl channel.\n");
pr_err("error, failed to create ctrl channel.\n");
return -1;
}
if (swtpm_cmdchan_create() < 0) {
printf("error, failed to create cmd channel.\n");
pr_err("error, failed to create cmd channel.\n");
return -1;
}

View File

@ -7,6 +7,7 @@
#ifndef __LOG_H__
#define __LOG_H__
#include <stdbool.h>
#include "types.h"
/* Logging severity levels */

View File

@ -65,7 +65,7 @@ static int probe_disk_log_file(void)
if (stat(LOG_PATH_NODE, &st)) {
if (mkdir(LOG_PATH_NODE, 0644)) {
printf(DISK_PREFIX"create path: %s failed! Error: %s\n",
pr_err(DISK_PREFIX"create path: %s failed! Error: %s\n",
LOG_PATH_NODE, strerror(errno));
return -1;
}
@ -73,7 +73,7 @@ static int probe_disk_log_file(void)
dir = opendir(LOG_PATH_NODE);
if (!dir) {
printf(DISK_PREFIX" open %s failed! Error: %s\n",
pr_err(DISK_PREFIX" open %s failed! Error: %s\n",
LOG_PATH_NODE, strerror(errno));
return -1;
}
@ -100,12 +100,12 @@ static int probe_disk_log_file(void)
snprintf(file_name, FILE_NAME_LENGTH - 1, LOG_NAME_FMT, LOG_PATH_NODE, vmname, index);
disk_fd = open(file_name, O_RDWR | O_CREAT | O_APPEND, 0644);
if (disk_fd < 0) {
printf(DISK_PREFIX" open %s failed! Error: %s\n", file_name, strerror(errno));
pr_err(DISK_PREFIX" open %s failed! Error: %s\n", file_name, strerror(errno));
return -1;
}
if (write(disk_fd, LOG_DELIMITER, strlen(LOG_DELIMITER)) < 0) {
printf(DISK_PREFIX" write %s failed! Error: %s\n", file_name, strerror(errno));
pr_err(DISK_PREFIX" write %s failed! Error: %s\n", file_name, strerror(errno));
return -1;
}
@ -196,7 +196,7 @@ static void write_to_disk(const char *fmt, va_list args)
close(disk_fd);
disk_fd = open(file_name, O_RDWR | O_CREAT, 0644);
if (disk_fd < 0) {
printf(DISK_PREFIX" open %s failed! Error: %s\n", file_name, strerror(errno));
pr_err(DISK_PREFIX" open %s failed! Error: %s\n", file_name, strerror(errno));
return;
}
cur_log_size = 0;