Skip to contentSkip to conversation

target/arm : add pvpanic mmio device

PATCH Superseded Peng Hao 3 participants 6 messages Oct 17, 2018 – Oct 18, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Peng Hao

author
#0 lore raw

PATCH 1/1 target/arm : add pvpanic mmio device

Add pvpanic mmio device that is similar to x86's pvpanic device.

---
 default-configs/arm-softmmu.mak |  2 +-
 hw/arm/virt.c                   | 21 ++++++++++++
 hw/misc/Makefile.objs           |  1 +
 hw/misc/pvpanic-mmio.c          | 76 +++++++++++++++++++++++++++++++++++++++++
 include/hw/arm/virt.h           |  1 +
 include/hw/misc/pvpanic-mmio.h  | 12 +++++++
 6 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 hw/misc/pvpanic-mmio.c
 create mode 100644 include/hw/misc/pvpanic-mmio.h
default-configs/arm-softmmu.mak +1 -1
index 2420491..4713c92 100644
@@ -43,7 +43,7 @@ CONFIG_USB_MUSB=y
 CONFIG_USB_EHCI_SYSBUS=y
 CONFIG_PLATFORM_BUS=y
 CONFIG_VIRTIO_MMIO=y
-
+CONFIG_PVPANIC_MMIO=y
 CONFIG_ARM11MPCORE=y
 CONFIG_A9MPCORE=y
 CONFIG_A15MPCORE=y
hw/arm/virt.c +21 -0
index a472566..ab41128 100644
@@ -140,6 +140,7 @@ static const MemMapEntry a15memmap[] = {
     [VIRT_UART] =               { 0x09000000, 0x00001000 },
     [VIRT_RTC] =                { 0x09010000, 0x00001000 },
     [VIRT_FW_CFG] =             { 0x09020000, 0x00000018 },
+    [VIRT_PVPANIC_MMIO] =       { 0x09020018, 0x00000002 },
     [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
     [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
     [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
@@ -798,6 +799,24 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
     g_free(nodename);
 }
 
+static void create_pvpanic_device(const VirtMachineState *vms)
+{
+    char *nodename;
+    hwaddr base = vms->memmap[VIRT_PVPANIC_MMIO].base;
+    hwaddr size = vms->memmap[VIRT_PVPANIC_MMIO].size;
+
+    sysbus_create_simple("pvpanic-mmio", base, NULL);
+
+    nodename = g_strdup_printf("/pvpanic-mmio@%" PRIx64, base);
+    qemu_fdt_add_subnode(vms->fdt, nodename);
+    qemu_fdt_setprop_string(vms->fdt, nodename,
+                            "compatible", "pvpanic,mmio");
+    qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg",
+                                 2, base, 2, size);
+    g_free(nodename);
+
+}
+
 static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic)
 {
     int i;
@@ -1544,6 +1563,8 @@ static void machvirt_init(MachineState *machine)
 
     create_pcie(vms, pic);
 
+    create_pvpanic_device(vms);
+
     create_gpio(vms, pic);
 
     /* Create mmio transports, so the user can create virtio backends
hw/misc/Makefile.objs +1 -0
index 6d50b03..6326260 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
 obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
 
 obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_PVPANIC_MMIO) += pvpanic-mmio.o
 obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
 obj-$(CONFIG_AUX) += auxbus.o
 obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
hw/misc/pvpanic-mmio.c new file +76 -0

76 lines not on this page · raw message

include/hw/arm/virt.h +1 -0
index 4cc57a7..61cc310 100644
@@ -70,6 +70,7 @@ enum {
     VIRT_MMIO,
     VIRT_RTC,
     VIRT_FW_CFG,
+    VIRT_PVPANIC_MMIO,
     VIRT_PCIE,
     VIRT_PCIE_MMIO,
     VIRT_PCIE_PIO,
include/hw/misc/pvpanic-mmio.h new file +12 -0
new file mode 100644
index 0000000..2e6bec3
@@ -0,0 +1,12 @@
+#ifndef HW_MISC_PVPANIC_H
+#define HW_MISC_PVPANIC_H
+#include "hw/sysbus.h"
+#define TYPE_PVPANIC_MMIO "pvpanic-mmio"
+#define PVPANIC_MMIO_DEVICE(obj)    \
+    OBJECT_CHECK(PVPanicState, (obj), TYPE_PVPANIC_MMIO)
+#endif
+
+typedef struct PVPanicState {
+    SysBusDevice parent_obj;
+    MemoryRegion mmio;
+} PVPanicState;
Signature · 1 line
1.8.3.1
#1 lore raw

hw/misc/pvpanic-mmio.c line 1

Quoted 3 lines · Peng Hao

+++ b/hw/misc/pvpanic-mmio.c

hw/misc/pvpanic-mmio.c new file +1 -0
@@ -0,0 +1,76 @@
+#include "qemu/osdep.h"

New file requires file header w/ copyright and license.

r~

#2 lore raw
Quoted 6 lines · Peng Hao

hw/misc/pvpanic-mmio.c line 1

Quoted 3 lines

+++ b/hw/misc/pvpanic-mmio.c

hw/misc/pvpanic-mmio.c new file +1 -0
@@ -0,0 +1,76 @@
+#include "qemu/osdep.h"

New file requires file header w/ copyright and license.

I will handle it in new version .Thanks

Quoted 1 line

r~

#3 lore raw
In reply to Peng Hao

Hi Peng,

Quoted 104 lines · Peng Hao

Add pvpanic mmio device that is similar to x86's pvpanic device.

---
 default-configs/arm-softmmu.mak |  2 +-
 hw/arm/virt.c                   | 21 ++++++++++++
 hw/misc/Makefile.objs           |  1 +
 hw/misc/pvpanic-mmio.c          | 76 +++++++++++++++++++++++++++++++++++++++++
 include/hw/arm/virt.h           |  1 +
 include/hw/misc/pvpanic-mmio.h  | 12 +++++++
 6 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 hw/misc/pvpanic-mmio.c
 create mode 100644 include/hw/misc/pvpanic-mmio.h
default-configs/arm-softmmu.mak +1 -1
index 2420491..4713c92 100644
@@ -43,7 +43,7 @@ CONFIG_USB_MUSB=y
 CONFIG_USB_EHCI_SYSBUS=y
 CONFIG_PLATFORM_BUS=y
 CONFIG_VIRTIO_MMIO=y
-
+CONFIG_PVPANIC_MMIO=y
 CONFIG_ARM11MPCORE=y
 CONFIG_A9MPCORE=y
 CONFIG_A15MPCORE=y
hw/arm/virt.c +21 -0
index a472566..ab41128 100644
@@ -140,6 +140,7 @@ static const MemMapEntry a15memmap[] = {
     [VIRT_UART] =               { 0x09000000, 0x00001000 },
     [VIRT_RTC] =                { 0x09010000, 0x00001000 },
     [VIRT_FW_CFG] =             { 0x09020000, 0x00000018 },
+    [VIRT_PVPANIC_MMIO] =       { 0x09020018, 0x00000002 },
     [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
     [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
     [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
@@ -798,6 +799,24 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
     g_free(nodename);
 }
 
+static void create_pvpanic_device(const VirtMachineState *vms)
+{
+    char *nodename;
+    hwaddr base = vms->memmap[VIRT_PVPANIC_MMIO].base;
+    hwaddr size = vms->memmap[VIRT_PVPANIC_MMIO].size;
+
+    sysbus_create_simple("pvpanic-mmio", base, NULL);
+
+    nodename = g_strdup_printf("/pvpanic-mmio@%" PRIx64, base);
+    qemu_fdt_add_subnode(vms->fdt, nodename);
+    qemu_fdt_setprop_string(vms->fdt, nodename,
+                            "compatible", "pvpanic,mmio");
+    qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg",
+                                 2, base, 2, size);
+    g_free(nodename);
+
+}
+
 static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic)
 {
     int i;
@@ -1544,6 +1563,8 @@ static void machvirt_init(MachineState *machine)
 
     create_pcie(vms, pic);
 
+    create_pvpanic_device(vms);
+
     create_gpio(vms, pic);
 
     /* Create mmio transports, so the user can create virtio backends
hw/misc/Makefile.objs +1 -0
index 6d50b03..6326260 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
 obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
 
 obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_PVPANIC_MMIO) += pvpanic-mmio.o
 obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
 obj-$(CONFIG_AUX) += auxbus.o
 obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
hw/misc/pvpanic-mmio.c new file +12 -0
new file mode 100644
index 0000000..c7f373e
@@ -0,0 +1,76 @@
+#include "qemu/osdep.h"
+#include "sysemu/sysemu.h"
+#include "qemu/log.h"
+#include "hw/misc/pvpanic-mmio.h"
+
+#define PVPANIC_MMIO_FEAT_CRASHED      0
+
+#define PVPANIC_MMIO_CRASHED        (1 << PVPANIC_MMIO_FEAT_CRASHED)
+
+static void handle_mmio_event(int event)
+{
+    static bool logged;

hw/misc/pvpanic-mmio.c line 22

Quoted 10 lines
hw/misc/pvpanic-mmio.c new file +10 -0
+
+    if (event & ~PVPANIC_MMIO_CRASHED && !logged) {
+        qemu_log_mask(LOG_GUEST_ERROR, "pvpanic-mmio: unknown event %#x.\n", event);
+        logged = true;
+    }
+
+    if (event & PVPANIC_MMIO_CRASHED) {
+        qemu_system_guest_panicked(NULL);
+        return;
+    }

It would be easier to maintain a single pvpanic device. There is no improvement here, it is the same handler than 'pvpanic.c'.

The current pvpanic device is not x86-only, it only implements the ioport API.
If you want to use the mmio API, please add it there. Basically you don't have to write any more code that in this patch, but just move it in the pvpanic.c file.

Thanks,

Phil.

Quoted 85 lines
hw/misc/pvpanic-mmio.c new file +54 -0
+}
+
+static uint64_t pvpanic_mmio_read(void *opaque, hwaddr addr, unsigned size)
+{
+    return -1;
+}
+
+static void pvpanic_mmio_write(void *opaque, hwaddr addr, uint64_t value,
+                                 unsigned size)
+{
+   handle_mmio_event(value);
+}
+
+static const MemoryRegionOps pvpanic_mmio_ops = {
+    .read = pvpanic_mmio_read,
+    .write = pvpanic_mmio_write,
+    .impl = {
+        .min_access_size = 1,
+        .max_access_size = 2,
+    },
+};
+
+
+static void pvpanic_mmio_initfn(Object *obj)
+{
+    PVPanicState *s = PVPANIC_MMIO_DEVICE(obj);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+
+    memory_region_init_io(&s->mmio, OBJECT(s), &pvpanic_mmio_ops, s,
+                          "pvpanic-mmio", 2);
+    sysbus_init_mmio(sbd, &s->mmio);
+}
+
+static void pvpanic_mmio_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+}
+
+static TypeInfo pvpanic_mmio_info = {
+    .name          = TYPE_PVPANIC_MMIO,
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(PVPanicState),
+    .instance_init = pvpanic_mmio_initfn,
+    .class_init    = pvpanic_mmio_class_init,
+};
+
+static void pvpanic_mmio_register_types(void)
+{
+    type_register_static(&pvpanic_mmio_info);
+}
+
+type_init(pvpanic_mmio_register_types)
include/hw/arm/virt.h +1 -0
index 4cc57a7..61cc310 100644
@@ -70,6 +70,7 @@ enum {
     VIRT_MMIO,
     VIRT_RTC,
     VIRT_FW_CFG,
+    VIRT_PVPANIC_MMIO,
     VIRT_PCIE,
     VIRT_PCIE_MMIO,
     VIRT_PCIE_PIO,
include/hw/misc/pvpanic-mmio.h new file +12 -0
new file mode 100644
index 0000000..2e6bec3
@@ -0,0 +1,12 @@
+#ifndef HW_MISC_PVPANIC_H
+#define HW_MISC_PVPANIC_H
+#include "hw/sysbus.h"
+#define TYPE_PVPANIC_MMIO "pvpanic-mmio"
+#define PVPANIC_MMIO_DEVICE(obj)    \
+    OBJECT_CHECK(PVPanicState, (obj), TYPE_PVPANIC_MMIO)
+#endif
+
+typedef struct PVPanicState {
+    SysBusDevice parent_obj;
+    MemoryRegion mmio;
+} PVPanicState;
#4 lore raw
Quoted 121 lines

Hi Peng,

Quoted 104 lines · Peng Hao

Add pvpanic mmio device that is similar to x86's pvpanic device.

---
 default-configs/arm-softmmu.mak |  2 +-
 hw/arm/virt.c                   | 21 ++++++++++++
 hw/misc/Makefile.objs           |  1 +
 hw/misc/pvpanic-mmio.c          | 76 +++++++++++++++++++++++++++++++++++++++++
 include/hw/arm/virt.h           |  1 +
 include/hw/misc/pvpanic-mmio.h  | 12 +++++++
 6 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 hw/misc/pvpanic-mmio.c
 create mode 100644 include/hw/misc/pvpanic-mmio.h
default-configs/arm-softmmu.mak +1 -1
index 2420491..4713c92 100644
@@ -43,7 +43,7 @@ CONFIG_USB_MUSB=y
 CONFIG_USB_EHCI_SYSBUS=y
 CONFIG_PLATFORM_BUS=y
 CONFIG_VIRTIO_MMIO=y
-
+CONFIG_PVPANIC_MMIO=y
 CONFIG_ARM11MPCORE=y
 CONFIG_A9MPCORE=y
 CONFIG_A15MPCORE=y
hw/arm/virt.c +21 -0
index a472566..ab41128 100644
@@ -140,6 +140,7 @@ static const MemMapEntry a15memmap[] = {
     [VIRT_UART] =               { 0x09000000, 0x00001000 },
     [VIRT_RTC] =                { 0x09010000, 0x00001000 },
     [VIRT_FW_CFG] =             { 0x09020000, 0x00000018 },
+    [VIRT_PVPANIC_MMIO] =       { 0x09020018, 0x00000002 },
     [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
     [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
     [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
@@ -798,6 +799,24 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
     g_free(nodename);
 }
 
+static void create_pvpanic_device(const VirtMachineState *vms)
+{
+    char *nodename;
+    hwaddr base = vms->memmap[VIRT_PVPANIC_MMIO].base;
+    hwaddr size = vms->memmap[VIRT_PVPANIC_MMIO].size;
+
+    sysbus_create_simple("pvpanic-mmio", base, NULL);
+
+    nodename = g_strdup_printf("/pvpanic-mmio@%" PRIx64, base);
+    qemu_fdt_add_subnode(vms->fdt, nodename);
+    qemu_fdt_setprop_string(vms->fdt, nodename,
+                            "compatible", "pvpanic,mmio");
+    qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg",
+                                 2, base, 2, size);
+    g_free(nodename);
+
+}
+
 static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic)
 {
     int i;
@@ -1544,6 +1563,8 @@ static void machvirt_init(MachineState *machine)
 
     create_pcie(vms, pic);
 
+    create_pvpanic_device(vms);
+
     create_gpio(vms, pic);
 
     /* Create mmio transports, so the user can create virtio backends
hw/misc/Makefile.objs +1 -0
index 6d50b03..6326260 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
 obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
 
 obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_PVPANIC_MMIO) += pvpanic-mmio.o
 obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
 obj-$(CONFIG_AUX) += auxbus.o
 obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
hw/misc/pvpanic-mmio.c new file +12 -0
new file mode 100644
index 0000000..c7f373e
@@ -0,0 +1,76 @@
+#include "qemu/osdep.h"
+#include "sysemu/sysemu.h"
+#include "qemu/log.h"
+#include "hw/misc/pvpanic-mmio.h"
+
+#define PVPANIC_MMIO_FEAT_CRASHED      0
+
+#define PVPANIC_MMIO_CRASHED        (1 << PVPANIC_MMIO_FEAT_CRASHED)
+
+static void handle_mmio_event(int event)
+{
+    static bool logged;

hw/misc/pvpanic-mmio.c line 22

Quoted 10 lines
hw/misc/pvpanic-mmio.c new file +10 -0
+
+    if (event & ~PVPANIC_MMIO_CRASHED && !logged) {
+        qemu_log_mask(LOG_GUEST_ERROR, "pvpanic-mmio: unknown event %#x.\n", event);
+        logged = true;
+    }
+
+    if (event & PVPANIC_MMIO_CRASHED) {
+        qemu_system_guest_panicked(NULL);
+        return;
+    }

It would be easier to maintain a single pvpanic device. There is no improvement here, it is the same handler than 'pvpanic.c'.

Quoted 2 lines

The current pvpanic device is not x86-only, it only implements the ioport API.

But in linux kernel the driver of pvpanic device is x86-only.

Quoted 3 lines

If you want to use the mmio API, please add it there. Basically you don't have to write any more code that in this patch, but just move it in the pvpanic.c file.

I want to use pvpanic directly instead of adding a new device emulation.
But I can't use it. Firstly pvpanic use ioport, but arm don't support ioport. secondly pvpanic device is emulated as a isa bus device, but arm don't support isa bus.
thirdly the realization of pvpanic device is depends on ACPI in linux kernel driver and in qemu the port info is passed through ACPI , but It is not necessary to configure ACPI for arm guest.

Thanks.

Quoted 4 lines

Thanks,

Phil.

#5 lore raw
Quoted 125 lines · On 18/10/2018 02:55, [email protected] wrote:
Quoted 121 lines

Hi Peng,

Quoted 104 lines · Peng Hao

Add pvpanic mmio device that is similar to x86's pvpanic device.

---
 default-configs/arm-softmmu.mak |  2 +-
 hw/arm/virt.c                   | 21 ++++++++++++
 hw/misc/Makefile.objs           |  1 +
 hw/misc/pvpanic-mmio.c          | 76 +++++++++++++++++++++++++++++++++++++++++
 include/hw/arm/virt.h           |  1 +
 include/hw/misc/pvpanic-mmio.h  | 12 +++++++
 6 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 hw/misc/pvpanic-mmio.c
 create mode 100644 include/hw/misc/pvpanic-mmio.h
default-configs/arm-softmmu.mak +1 -1
index 2420491..4713c92 100644
@@ -43,7 +43,7 @@ CONFIG_USB_MUSB=y
 CONFIG_USB_EHCI_SYSBUS=y
 CONFIG_PLATFORM_BUS=y
 CONFIG_VIRTIO_MMIO=y
-
+CONFIG_PVPANIC_MMIO=y
 CONFIG_ARM11MPCORE=y
 CONFIG_A9MPCORE=y
 CONFIG_A15MPCORE=y
hw/arm/virt.c +21 -0
index a472566..ab41128 100644
@@ -140,6 +140,7 @@ static const MemMapEntry a15memmap[] = {
     [VIRT_UART] =               { 0x09000000, 0x00001000 },
     [VIRT_RTC] =                { 0x09010000, 0x00001000 },
     [VIRT_FW_CFG] =             { 0x09020000, 0x00000018 },
+    [VIRT_PVPANIC_MMIO] =       { 0x09020018, 0x00000002 },
     [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
     [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
     [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
@@ -798,6 +799,24 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
     g_free(nodename);
 }
 
+static void create_pvpanic_device(const VirtMachineState *vms)
+{
+    char *nodename;
+    hwaddr base = vms->memmap[VIRT_PVPANIC_MMIO].base;
+    hwaddr size = vms->memmap[VIRT_PVPANIC_MMIO].size;
+
+    sysbus_create_simple("pvpanic-mmio", base, NULL);
+
+    nodename = g_strdup_printf("/pvpanic-mmio@%" PRIx64, base);
+    qemu_fdt_add_subnode(vms->fdt, nodename);
+    qemu_fdt_setprop_string(vms->fdt, nodename,
+                            "compatible", "pvpanic,mmio");
+    qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg",
+                                 2, base, 2, size);
+    g_free(nodename);
+
+}
+
 static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic)
 {
     int i;
@@ -1544,6 +1563,8 @@ static void machvirt_init(MachineState *machine)
 
     create_pcie(vms, pic);
 
+    create_pvpanic_device(vms);
+
     create_gpio(vms, pic);
 
     /* Create mmio transports, so the user can create virtio backends
hw/misc/Makefile.objs +1 -0
index 6d50b03..6326260 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
 obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
 
 obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_PVPANIC_MMIO) += pvpanic-mmio.o
 obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
 obj-$(CONFIG_AUX) += auxbus.o
 obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
hw/misc/pvpanic-mmio.c new file +12 -0
new file mode 100644
index 0000000..c7f373e
@@ -0,0 +1,76 @@
+#include "qemu/osdep.h"
+#include "sysemu/sysemu.h"
+#include "qemu/log.h"
+#include "hw/misc/pvpanic-mmio.h"
+
+#define PVPANIC_MMIO_FEAT_CRASHED      0
+
+#define PVPANIC_MMIO_CRASHED        (1 << PVPANIC_MMIO_FEAT_CRASHED)
+
+static void handle_mmio_event(int event)
+{
+    static bool logged;

hw/misc/pvpanic-mmio.c line 22

Quoted 10 lines
hw/misc/pvpanic-mmio.c new file +10 -0
+
+    if (event & ~PVPANIC_MMIO_CRASHED && !logged) {
+        qemu_log_mask(LOG_GUEST_ERROR, "pvpanic-mmio: unknown event %#x.\n", event);
+        logged = true;
+    }
+
+    if (event & PVPANIC_MMIO_CRASHED) {
+        qemu_system_guest_panicked(NULL);
+        return;
+    }

It would be easier to maintain a single pvpanic device. There is no improvement here, it is the same handler than 'pvpanic.c'.

Quoted 2 lines

The current pvpanic device is not x86-only, it only implements the ioport API.

But in linux kernel the driver of pvpanic device is x86-only.

Quoted 7 lines
Quoted 3 lines

If you want to use the mmio API, please add it there. Basically you don't have to write any more code that in this patch, but just move it in the pvpanic.c file.

I want to use pvpanic directly instead of adding a new device emulation. But I can't use it. Firstly pvpanic use ioport, but arm don't support ioport. secondly pvpanic device is emulated as a isa bus device, but arm don't support isa bus.

I tried to explain how to do it, but it was easier to just refactor your patch to show what I was expecting, so I'll send a series instead.

Quoted 8 lines

thirdly the realization of pvpanic device is depends on ACPI in linux kernel driver and in qemu the port info is passed through ACPI , but It is not necessary to configure ACPI for arm guest.

Thanks.

Quoted 4 lines

Thanks,

Phil.