Skip to content

Commit

Permalink
hw/arm/xen_arm.c: convert DPRINTF to trace events and error/warn reports
Browse files Browse the repository at this point in the history
Tracing DPRINTFs to stderr might not be desired. A developer that relies
on trace events should be able to opt-in to each trace event and rely on
QEMU's log redirection, instead of stderr by default.

This commit converts DPRINTFs in this file that are used for tracing
into trace events. Errors or warnings are converted to error_report and
warn_report calls.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: fe5e3bd54231abe933f95a24e0e88208cd8cfd8f.1706544115.git.manos.pitsidianakis@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
epilys authored and pm215 committed Feb 2, 2024
1 parent fcc554c commit 6b4a990
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 5 additions & 0 deletions hw/arm/trace-events
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ z2_lcd_enable_disable_result(const char *result) "LCD %s"
z2_aer915_send_too_long(int8_t msg) "message too long (%i bytes)"
z2_aer915_send(uint8_t reg, uint8_t value) "reg %d value 0x%02x"
z2_aer915_event(int8_t event, int8_t len) "i2c event =0x%x len=%d bytes"

# xen_arm.c
xen_create_virtio_mmio_devices(int i, int irq, uint64_t base) "Created virtio-mmio device %d: irq %d base 0x%"PRIx64
xen_init_ram(uint64_t machine_ram_size) "Initialized xen ram with size 0x%"PRIx64
xen_enable_tpm(uint64_t addr) "Connected tpmdev at address 0x%"PRIx64
23 changes: 11 additions & 12 deletions hw/arm/xen_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "hw/xen/xen-hvm-common.h"
#include "sysemu/tpm.h"
#include "hw/xen/arch_hvm.h"
#include "trace.h"

#define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh")
OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM)
Expand Down Expand Up @@ -91,8 +92,9 @@ static void xen_create_virtio_mmio_devices(XenArmState *xam)

sysbus_create_simple("virtio-mmio", base, irq);

DPRINTF("Created virtio-mmio device %d: irq %d base 0x%lx\n",
i, GUEST_VIRTIO_MMIO_SPI_FIRST + i, base);
trace_xen_create_virtio_mmio_devices(i,
GUEST_VIRTIO_MMIO_SPI_FIRST + i,
base);
}
}

Expand All @@ -101,6 +103,7 @@ static void xen_init_ram(MachineState *machine)
MemoryRegion *sysmem = get_system_memory();
ram_addr_t block_len, ram_size[GUEST_RAM_BANKS];

trace_xen_init_ram(machine->ram_size);
if (machine->ram_size <= GUEST_RAM0_SIZE) {
ram_size[0] = machine->ram_size;
ram_size[1] = 0;
Expand All @@ -117,15 +120,10 @@ static void xen_init_ram(MachineState *machine)
memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo", &ram_memory,
GUEST_RAM0_BASE, ram_size[0]);
memory_region_add_subregion(sysmem, GUEST_RAM0_BASE, &ram_lo);
DPRINTF("Initialized region xen.ram.lo: base 0x%llx size 0x%lx\n",
GUEST_RAM0_BASE, ram_size[0]);

if (ram_size[1] > 0) {
memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi", &ram_memory,
GUEST_RAM1_BASE, ram_size[1]);
memory_region_add_subregion(sysmem, GUEST_RAM1_BASE, &ram_hi);
DPRINTF("Initialized region xen.ram.hi: base 0x%llx size 0x%lx\n",
GUEST_RAM1_BASE, ram_size[1]);
}
}

Expand Down Expand Up @@ -158,7 +156,7 @@ static void xen_enable_tpm(XenArmState *xam)

TPMBackend *be = qemu_find_tpm_be("tpm0");
if (be == NULL) {
DPRINTF("Couldn't fine the backend for tpm0\n");
error_report("Couldn't find tmp0 backend");
return;
}
dev = qdev_new(TYPE_TPM_TIS_SYSBUS);
Expand All @@ -168,7 +166,7 @@ static void xen_enable_tpm(XenArmState *xam)
sysbus_realize_and_unref(busdev, &error_fatal);
sysbus_mmio_map(busdev, 0, xam->cfg.tpm_base_addr);

DPRINTF("Connected tpmdev at address 0x%lx\n", xam->cfg.tpm_base_addr);
trace_xen_enable_tpm(xam->cfg.tpm_base_addr);
}
#endif

Expand All @@ -179,8 +177,9 @@ static void xen_arm_init(MachineState *machine)
xam->state = g_new0(XenIOState, 1);

if (machine->ram_size == 0) {
DPRINTF("ram_size not specified. QEMU machine started without IOREQ"
"(no emulated devices including Virtio)\n");
warn_report("%s non-zero ram size not specified. QEMU machine started"
" without IOREQ (no emulated devices including virtio)",
MACHINE_CLASS(object_get_class(OBJECT(machine)))->desc);
return;
}

Expand All @@ -194,7 +193,7 @@ static void xen_arm_init(MachineState *machine)
if (xam->cfg.tpm_base_addr) {
xen_enable_tpm(xam);
} else {
DPRINTF("tpm-base-addr is not provided. TPM will not be enabled\n");
warn_report("tpm-base-addr is not provided. TPM will not be enabled");
}
#endif
}
Expand Down

0 comments on commit 6b4a990

Please sign in to comment.