From: <peng.hao2@zte.com.cn>
To: philmd@redhat.com
Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target/arm : add pvpanic mmio device
Date: Thu, 18 Oct 2018 08:55:16 +0800 (CST) [thread overview]
Message-ID: <201810180855169525575@zte.com.cn> (raw)
In-Reply-To: <61bc5059-e7b1-3371-66b3-5bc10d06935b@redhat.com>
>Hi Peng,
>
>On 17/10/2018 11:23, Peng Hao wrote:
>> Add pvpanic mmio device that is similar to x86's pvpanic device.
>
>>
>> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
>> ---
>> 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
>>
>> diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
>> index 2420491..4713c92 100644
>> --- a/default-configs/arm-softmmu.mak
>> +++ b/default-configs/arm-softmmu.mak
>> @@ -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
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index a472566..ab41128 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -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
>> diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
>> index 6d50b03..6326260 100644
>> --- a/hw/misc/Makefile.objs
>> +++ b/hw/misc/Makefile.objs
>> @@ -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
>> diff --git a/hw/misc/pvpanic-mmio.c b/hw/misc/pvpanic-mmio.c
>> new file mode 100644
>> index 0000000..c7f373e
>> --- /dev/null
>> +++ b/hw/misc/pvpanic-mmio.c
>> @@ -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;
>> +
>> + 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.
But in linux kernel the driver of pvpanic device is x86-only.
>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.
>
>Thanks,
>
>Phil.
next prev parent reply other threads:[~2018-10-18 0:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 9:23 [Qemu-devel] [PATCH] target/arm : add pvpanic mmio device Peng Hao
2018-10-17 1:32 ` Richard Henderson
2018-10-17 1:39 ` peng.hao2
2018-10-17 9:53 ` Philippe Mathieu-Daudé
2018-10-18 0:55 ` peng.hao2 [this message]
2018-10-18 12:49 ` Philippe Mathieu-Daudé
-- strict thread matches above, loose matches on Subject: below --
2018-10-17 9:20 Peng Hao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201810180855169525575@zte.com.cn \
--to=peng.hao2@zte.com.cn \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).